eb05362005-11-05Henrik Grubbström (Grubba) /* -*- C -*- */
1a05542005-07-28Martin Nilsson class GTK2.TreeModel;
bfacff2006-02-06Lance Dillon mixin_for G.Object;
1a05542005-07-28Martin Nilsson 
bfacff2006-02-06Lance Dillon signal row_changed; signal row_deleted; signal row_has_child_toggled; signal row_inserted; signal rows_reordered;
1a05542005-07-28Martin Nilsson 
bfacff2006-02-06Lance Dillon int get_flags(); //! Returns a set of flags supported by this interface. int get_n_columns(); //! Returns the number of columns suppported by this model. int get_column_type(int index); //! Returns the type of the column.
f284492006-08-03Lance Dillon +GTK2.TreeIter get_iter(GTK2.TreePath path)
bfacff2006-02-06Lance Dillon //! Returns a valid iterator pointer to path {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { GtkTreeIter *iter; struct object *o1; int res; get_all_args("get_iter",args,"%o",&o1); iter=(GtkTreeIter *)g_malloc(sizeof(GtkTreeIter)); if (iter==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_iter",sizeof(GtkTreeIter)); res=gtk_tree_model_get_iter(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  iter,(GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program)); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  if (res) {
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(iter,pgtk2_tree_iter_program);
bfacff2006-02-06Lance Dillon  } else { push_int(0); } } }
f284492006-08-03Lance Dillon +GTK2.TreeIter get_iter_from_string(string path)
bfacff2006-02-06Lance Dillon //! Returns a valid iterator from a path string. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { GtkTreeIter *iter; int res; const gchar *s; get_all_args("get_iter_from_string",args,"%s",&s); iter=(GtkTreeIter *)g_malloc(sizeof(GtkTreeIter)); if (iter==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_iter_from_string",sizeof(GtkTreeIter)); res=gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(THIS->obj), iter,s);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  if (res) {
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(iter,pgtk2_tree_iter_program);
bfacff2006-02-06Lance Dillon  } else { push_int(0); } } }
f284492006-08-03Lance Dillon +GTK2.TreeIter get_iter_first()
bfacff2006-02-06Lance Dillon //! Get GTK2.TreeIter with the first iterator in the tree ("0"). {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  { GtkTreeIter *iter; int res; iter=(GtkTreeIter *)g_malloc(sizeof(GtkTreeIter)); if (iter==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_iter_first",sizeof(GtkTreeIter)); res=gtk_tree_model_get_iter_first(GTK_TREE_MODEL(THIS->obj), iter); if (res) {
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(iter,pgtk2_tree_iter_program);
bfacff2006-02-06Lance Dillon  } else { push_int(0); } } }
f284492006-08-03Lance Dillon +GTK2.TreePath get_path(GTK2.TreeIter iter)
bfacff2006-02-06Lance Dillon //! Returns a GTK2.TreePath from iter. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { GtkTreePath *path; struct object *o1; get_all_args("get_path",args,"%o",&o1); path=(void *)gtk_tree_model_get_path(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program)); pgtk2_pop_n_elems(args); push_gobjectclass(path,pgtk2_tree_path_program);
bfacff2006-02-06Lance Dillon  } } array get_row(GTK2.TreeIter iter) //! Get the row at this iter. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon /* fprintf(stderr,"get_row(): \n"); */ { int i; int cols; struct object *o1; GtkTreeIter *gti; get_all_args("get_row",args,"%o",&o1);
ba9e802006-02-27Martin Stjernholm  gti=(GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  cols=gtk_tree_model_get_n_columns(GTK_TREE_MODEL(THIS->obj)); for (i=0; i<cols; i++) {
00432a2006-08-08Lance Dillon  GValue v={0};
bfacff2006-02-06Lance Dillon  gtk_tree_model_get_value(GTK_TREE_MODEL(THIS->obj),gti,i,&v);
f284492006-08-03Lance Dillon  pgtk2_push_gvalue_rt(&v);
bfacff2006-02-06Lance Dillon  } f_aggregate(cols); } } mixed get_value(GTK2.TreeIter iter, int column) //! Get value at column of iter. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  {
00432a2006-08-08Lance Dillon  GValue v={0};
bfacff2006-02-06Lance Dillon  struct object *o1; INT_TYPE col; get_all_args("get_value",args,"%o%i",&o1,&col); gtk_tree_model_get_value(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program),col,&v); pgtk2_pop_n_elems(args);
f284492006-08-03Lance Dillon  pgtk2_push_gvalue_rt(&v);
bfacff2006-02-06Lance Dillon  g_value_unset(&v); } }
f284492006-08-03Lance Dillon +GTK2.TreeIter iter_next(GTK2.TreeIter iter)
bfacff2006-02-06Lance Dillon //! Go to next node. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1; int res; get_all_args("iter_next",args,"%o",&o1); res=gtk_tree_model_iter_next(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program)); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  PGTK_PUSH_INT(res); } }
f284492006-08-03Lance Dillon +GTK2.TreeIter iter_children(GTK2.TreeIter parent)
bfacff2006-02-06Lance Dillon //! Get first child of parent. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { GtkTreeIter *iter; struct object *o1; int res; get_all_args("iter_children",args,"%o",&o1); iter=g_malloc(sizeof(GtkTreeIter)); if (iter==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("iter_children",sizeof(GtkTreeIter)); res=gtk_tree_model_iter_children(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  iter,(GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program)); pgtk2_pop_n_elems(args); push_gobjectclass(iter,pgtk2_tree_iter_program);
bfacff2006-02-06Lance Dillon  } } int iter_has_child(GTK2.TreeIter iter) //! Check if iter has children. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1; int res; get_all_args("iter_has_child",args,"%o",&o1); res=gtk_tree_model_iter_has_child(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program)); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  if (res) push_int(1); else push_int(0); } } int iter_n_children(GTK2.TreeIter iter) //! Returns the number of children this iter has. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1; int res; get_all_args("iter_n_children",args,"%o",&o1); res=gtk_tree_model_iter_n_children(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program)); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  push_int(res); } }
f284492006-08-03Lance Dillon +GTK2.TreeIter iter_nth_child(GTK2.TreeIter parent, int index)
bfacff2006-02-06Lance Dillon //! Get the child of parent using the given index. //! Returns valid GTK2.TreeIter if it exists, or 0. //! If the index is too big, or parent is invalid, //! then it returns the index from the root node. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { GtkTreeIter *iter; struct object *o1; int res; INT_TYPE n; get_all_args("iter_nth_child",args,"%o%i",&o1,&n); iter=g_malloc(sizeof(GtkTreeIter)); if (iter==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("iter_nth_child",sizeof(GtkTreeIter)); res=gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  iter,(GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program),n); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  if (res) {
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(iter,pgtk2_tree_iter_program);
bfacff2006-02-06Lance Dillon  } else { push_int(0); } } }
f284492006-08-03Lance Dillon +GTK2.TreeIter iter_parent(GTK2.TreeIter child)
bfacff2006-02-06Lance Dillon //! Get parent of child, or 0 if none. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { GtkTreeIter *iter; struct object *o1; int res; get_all_args("iter_parent",args,"%o",&o1); iter=g_malloc(sizeof(GtkTreeIter)); if (iter==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("iter_parent",sizeof(GtkTreeIter)); res=gtk_tree_model_iter_parent(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  iter,(GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program)); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  if (res) {
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(iter,pgtk2_tree_iter_program);
bfacff2006-02-06Lance Dillon  } else { push_int(0); } } } require gtk22; string get_string_from_iter(GTK2.TreeIter iter) //! Get string representation of iter. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1; int res; gchar *gs; get_all_args("get_string_from_iter",args,"%o",&o1); gs=gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreeIter *)get_pg2object(o1,pgtk2_tree_iter_program)); pgtk2_pop_n_elems(args);
bfacff2006-02-06Lance Dillon  PGTK_PUSH_GCHAR(gs); g_free(gs); } } endrequire; void row_changed(GTK2.TreePath path, GTK2.TreeIter iter) //! Emit "row-changed" signal. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1,*o2; get_all_args("row_changed",args,"%o%o",&o1,&o2); gtk_tree_model_row_changed(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program), (GtkTreeIter *)get_pg2object(o2,pgtk2_tree_iter_program));
bfacff2006-02-06Lance Dillon  } RETURN_THIS(); } void row_inserted(GTK2.TreePath path, GTK2.TreeIter iter) //! Emit "row-inserted" signal. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1,*o2; get_all_args("row_inserted",args,"%o%o",&o1,&o2); gtk_tree_model_row_inserted(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program), (GtkTreeIter *)get_pg2object(o2,pgtk2_tree_iter_program));
bfacff2006-02-06Lance Dillon  } RETURN_THIS(); } void row_has_child_toggled(GTK2.TreePath path, GTK2.TreeIter iter) //! Emit "row-has-child-toggled" signal. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1,*o2; get_all_args("row_has_child_toggled",args,"%o%o",&o1,&o2); gtk_tree_model_row_has_child_toggled(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program), (GtkTreeIter *)get_pg2object(o2,pgtk2_tree_iter_program));
bfacff2006-02-06Lance Dillon  } RETURN_THIS(); } void row_deleted(GTK2.TreePath path) //! Emit "row-deleted" signal. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
bfacff2006-02-06Lance Dillon  { struct object *o1; get_all_args("row_deleted",args,"%o",&o1); gtk_tree_model_row_deleted(GTK_TREE_MODEL(THIS->obj),
ba9e802006-02-27Martin Stjernholm  (GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program));
bfacff2006-02-06Lance Dillon  } RETURN_THIS(); }