eb05362005-11-05Henrik Grubbström (Grubba) /* -*- C -*- */
1a05542005-07-28Martin Nilsson require gtk26; class GTK2.CellView; inherit GTK2.Widget;
587c132006-01-03Martin Nilsson inherit GTK2.CellLayout;
1a05542005-07-28Martin Nilsson  //! Properties: //! string background //! GDK2.Color background-gdk //! int background-set
3d76632005-11-03Lance Dillon void create(string|GDK2.Pixbuf|mapping(string:mixed)|void text, ?int markup)
1a05542005-07-28Martin Nilsson //! Create a new W(CellView) widget. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_not_inited(); pgtk2_verify_setup();
1a05542005-07-28Martin Nilsson  if (args==1) {
3d76632005-11-03Lance Dillon  GtkWidget *gcv;
1a05542005-07-28Martin Nilsson  if (Pike_sp[-args].type==PIKE_T_OBJECT) { struct object *o1; get_all_args("create",args,"%o",&o1);
3d76632005-11-03Lance Dillon  gcv=gtk_cell_view_new_with_pixbuf(GDK_PIXBUF(get_gobject(o1))); THIS->obj=G_OBJECT(gcv); } else if (Pike_sp[-args].type==PIKE_T_STRING) {
535ddd2005-12-18Marcus Comstedt  struct pike_string *str; get_all_args("create",args,"%t",&str); ref_push_string(str); f_string_to_utf8(1);
eac9aa2005-12-18Martin Nilsson  gcv=gtk_cell_view_new_with_text(CGSTR0(Pike_sp[-1].u.string));
535ddd2005-12-18Marcus Comstedt  pop_stack();
3d76632005-11-03Lance Dillon  THIS->obj=G_OBJECT(gcv); } else { INIT_WITH_PROPS(GTK_TYPE_CELL_VIEW);
1a05542005-07-28Martin Nilsson  } } else if (args==2) {
535ddd2005-12-18Marcus Comstedt  struct pike_string *str;
cac4202005-12-17Marcus Comstedt  INT_TYPE mark;
3d76632005-11-03Lance Dillon  GtkWidget *gcv;
535ddd2005-12-18Marcus Comstedt  get_all_args("create",args,"%t%i",&str,&mark); ref_push_string(str); f_string_to_utf8(1);
1a05542005-07-28Martin Nilsson  if (mark)
eac9aa2005-12-18Martin Nilsson  gcv=gtk_cell_view_new_with_markup(CGSTR0(Pike_sp[-1].u.string));
1a05542005-07-28Martin Nilsson  else
eac9aa2005-12-18Martin Nilsson  gcv=gtk_cell_view_new_with_text(CGSTR0(Pike_sp[-1].u.string));
535ddd2005-12-18Marcus Comstedt  pop_stack();
3d76632005-11-03Lance Dillon  THIS->obj=G_OBJECT(gcv);
1a05542005-07-28Martin Nilsson  } else {
3d76632005-11-03Lance Dillon  GtkWidget *gcv; gcv=gtk_cell_view_new(); THIS->obj=G_OBJECT(gcv);
1a05542005-07-28Martin Nilsson  }
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args); pgtk2__init_this_object();
1a05542005-07-28Martin Nilsson } void set_model(GTK2.TreeModel model); //! Sets the model. If this view already has a model set, it will remove it //! before setting the new model. void set_displayed_row(?GTK2.TreePath path) //! Sets the row of the model that is currently displayed. If the path is //! omitted, then the contents of the cellview "stick" at their last value; //! this is not normally a desired result, but may be a needed intermediate //! state if say, the mode becomes temporarily empty. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  if (args) { struct object *o1; get_all_args("set_displayed_row",args,"%o",&o1); gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(THIS->obj), (GtkTreePath *)get_gobject(o1)); } else { gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(THIS->obj),NULL); } RETURN_THIS(); } GTK2.TreePath get_displayed_row() //! Returns a W(TreePath) referring to the currently displayed row. If no //! row is currently displayed, 0 is returned. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  { GtkTreePath *path=gtk_cell_view_get_displayed_row(GTK_CELL_VIEW(THIS->obj));
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(path,pgtk2_tree_path_program);
1a05542005-07-28Martin Nilsson  } } mapping(string:int) get_size_of_row(GTK2.TreePath path) //! Returns width and height of the size needed to display the model row //! pointed to by path. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1; GtkRequisition req; get_all_args("get_size_of_row",args,"%o",&o1); gtk_cell_view_get_size_of_row(GTK_CELL_VIEW(THIS->obj), (GtkTreePath *)get_gobject(o1),&req);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("width")); push_int(req.width); ref_push_string(_STR("height")); push_int(req.height);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(4); } } void set_background_color(GDK2.Color color) //! Sets the background color. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct object *o1; get_all_args("set_background_color",args,"%o",&o1); gtk_cell_view_set_background_color(GTK_CELL_VIEW(THIS->obj), (GdkColor *)get_gdkobject(o1,color)); } RETURN_THIS(); } endrequire;