eb05362005-11-05Henrik Grubbström (Grubba) /* -*- C -*- */
1a05542005-07-28Martin Nilsson class GTK2.TreePath; //! TreePath. void create(?string path) //! Creates a new GTK2.TreePath. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_not_inited(); pgtk2_verify_setup();
1a05542005-07-28Martin Nilsson  if (args) { char *s; get_all_args("create",args,"%s",&s); if (s) { THIS->obj=(void *)gtk_tree_path_new_from_string(s);
f439a12008-04-11Per Hedbor  THIS->owned=1;
1a05542005-07-28Martin Nilsson  } else { THIS->obj=(void *)gtk_tree_path_new_first();
f439a12008-04-11Per Hedbor  THIS->owned=1;
1a05542005-07-28Martin Nilsson  } } else { THIS->obj=(void *)gtk_tree_path_new_first();
f439a12008-04-11Per Hedbor  THIS->owned=1;
1a05542005-07-28Martin Nilsson  }
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args); pgtk2__init_this_object();
1a05542005-07-28Martin Nilsson } string _sprintf(int flag) {
cac4202005-12-17Marcus Comstedt  INT_TYPE mode=0;
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  if (args) get_all_args("_sprintf",args,"%i",&mode);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  if (mode!='O') { push_undefined(); return; } { gchar *s=gtk_tree_path_to_string((GtkTreePath *)THIS->obj); if (s) {
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("GTK2.TreePath( \""));
74a5dd2010-09-19Marcus Comstedt  PGTK_PUSH_GCHAR(s);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("\" );"));
1a05542005-07-28Martin Nilsson  f_add(3); g_free(s); } else push_undefined(); } } string to_string() //! Generates a string representation of the path. //! This string is a ':' separated list of numbers. //! For example, "4:10:0:3" would be an acceptable return value //! for this string. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { const gchar *a1; a1=gtk_tree_path_to_string((GtkTreePath *)THIS->obj);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  PGTK_PUSH_GCHAR(a1); } } void append_index(int index) //! Appends a new index to path. As a result, the depth //! of the path is increased. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
3d76632005-11-03Lance Dillon  {
cac4202005-12-17Marcus Comstedt  INT_TYPE index;
1a05542005-07-28Martin Nilsson  get_all_args("append_index",args,"%i",&index); gtk_tree_path_append_index((GtkTreePath *)THIS->obj,index); } RETURN_THIS(); } void prepend_index(int index) //! Prepends a new index to a path. As a result, the depth //! of the path is increased. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
3d76632005-11-03Lance Dillon  {
cac4202005-12-17Marcus Comstedt  INT_TYPE index;
1a05542005-07-28Martin Nilsson  get_all_args("prepend_index",args,"%i",&index); gtk_tree_path_prepend_index((GtkTreePath *)THIS->obj,index); } RETURN_THIS(); } int get_depth() //! Returns the current depth of path. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  PGTK_PUSH_INT(gtk_tree_path_get_depth((GtkTreePath *)THIS->obj)); } array(int) get_indices() //! Returns the current indices of path as an array //! of integers, each representing a node in a tree. { int n=0; gint *arr=gtk_tree_path_get_indices((GtkTreePath *)THIS->obj);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  while (arr[n]) PGTK_PUSH_INT(arr[n++]);
3d76632005-11-03Lance Dillon  if (!n)
1a05542005-07-28Martin Nilsson  ref_push_array(&empty_array);
3d76632005-11-03Lance Dillon  else
1a05542005-07-28Martin Nilsson  f_aggregate(n); } void destroy() {
2edd4f2008-01-30Per Hedbor  if (THIS->obj && THIS->owned)
1a05542005-07-28Martin Nilsson  gtk_tree_path_free((GtkTreePath *)THIS->obj); THIS->obj=0;
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  PGTK_PUSH_INT(0); } GTK2.TreePath copy() //! Creates a new GTK2.TreePath as a copy. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { GtkTreePath *a1; a1=(GtkTreePath *)gtk_tree_path_copy((GtkTreePath *)THIS->obj);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
2edd4f2008-01-30Per Hedbor  push_pgdk2object(a1,pgtk2_tree_path_program,1);
1a05542005-07-28Martin Nilsson  } } int compare(GTK2.TreePath b) //! Compares two paths. If this path appears before b, -1 is returned. //! If b before this path, 1 is return. If they are equal, 0 is returned. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { GtkTreePath *gp=NULL; struct object *o1; int res; get_all_args("compare",args,"%o",&o1); if (o1)
ba9e802006-02-27Martin Stjernholm  gp=(GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program);
1a05542005-07-28Martin Nilsson  res=gtk_tree_path_compare((GtkTreePath *)THIS->obj,gp);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  PGTK_PUSH_INT(res); } } void next() //! Moves the path to point to the next node at the current depth. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  gtk_tree_path_next((GtkTreePath *)THIS->obj); RETURN_THIS(); } void prev() //! Moves the path to point to the previous node at the current depth, //! if it exists. Returns TRUE if the move was made. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  gtk_tree_path_prev((GtkTreePath *)THIS->obj); RETURN_THIS(); }
3d76632005-11-03Lance Dillon void up()
1a05542005-07-28Martin Nilsson //! Moves the path to point to its parent node, if it has a parent. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  gtk_tree_path_up((GtkTreePath *)THIS->obj); RETURN_THIS(); } void down() //! Moves path to point to the first child of the current path. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  gtk_tree_path_down((GtkTreePath *)THIS->obj); RETURN_THIS(); } int is_ancestor(GTK2.TreePath descendant) //! Returns TRUE if descendant is a descendant of this path. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { GtkTreePath *gp=NULL; struct object *o1; int res; get_all_args("is_ancestor",args,"%o",&o1); if (o1)
ba9e802006-02-27Martin Stjernholm  gp=(GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program);
1a05542005-07-28Martin Nilsson  res=gtk_tree_path_is_ancestor((GtkTreePath *)THIS->obj,gp);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  PGTK_PUSH_INT(res); } } int is_descendant(GTK2.TreePath ancestor) //! Returns TRUE if this path is a descendant of ancestor. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  {
d5be632008-01-18Henrik Grubbström (Grubba)  GtkTreePath *gp = NULL;
1a05542005-07-28Martin Nilsson  struct object *o1; int res; get_all_args("is_descendant",args,"%o",&o1); if (o1)
ba9e802006-02-27Martin Stjernholm  gp=(GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program);
1a05542005-07-28Martin Nilsson  res=gtk_tree_path_is_descendant((GtkTreePath *)THIS->obj,gp);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson  PGTK_PUSH_INT(res); } }