eb0536 | 2005-11-05 | Henrik Grubbström (Grubba) | | /* -*- C -*- */
|
1a0554 | 2005-07-28 | Martin Nilsson | | class GTK2.TreePath;
//! TreePath.
void create(?string path)
//! Creates a new GTK2.TreePath.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_not_inited();
pgtk2_verify_setup();
|
1a0554 | 2005-07-28 | Martin Nilsson | | if (args) {
char *s;
get_all_args("create",args,"%s",&s);
if (s) {
THIS->obj=(void *)gtk_tree_path_new_from_string(s);
|
f439a1 | 2008-04-11 | Per Hedbor | | THIS->owned=1;
|
1a0554 | 2005-07-28 | Martin Nilsson | | } else {
THIS->obj=(void *)gtk_tree_path_new_first();
|
f439a1 | 2008-04-11 | Per Hedbor | | THIS->owned=1;
|
1a0554 | 2005-07-28 | Martin Nilsson | | }
} else {
THIS->obj=(void *)gtk_tree_path_new_first();
|
f439a1 | 2008-04-11 | Per Hedbor | | THIS->owned=1;
|
1a0554 | 2005-07-28 | Martin Nilsson | | }
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
pgtk2__init_this_object();
|
1a0554 | 2005-07-28 | Martin Nilsson | | }
string _sprintf(int flag)
{
|
cac420 | 2005-12-17 | Marcus Comstedt | | INT_TYPE mode=0;
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | if (args)
get_all_args("_sprintf",args,"%i",&mode);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin Nilsson | | if (mode!='O') {
push_undefined();
return;
}
{
gchar *s=gtk_tree_path_to_string((GtkTreePath *)THIS->obj);
if (s) {
|
9fb503 | 2006-01-14 | Martin Nilsson | | ref_push_string(_STR("GTK2.TreePath( \""));
|
1a0554 | 2005-07-28 | Martin Nilsson | | push_text(s);
|
9fb503 | 2006-01-14 | Martin Nilsson | | ref_push_string(_STR("\" );"));
|
1a0554 | 2005-07-28 | Martin 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.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | {
const gchar *a1;
a1=gtk_tree_path_to_string((GtkTreePath *)THIS->obj);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin 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.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
3d7663 | 2005-11-03 | Lance Dillon | | {
|
cac420 | 2005-12-17 | Marcus Comstedt | | INT_TYPE index;
|
1a0554 | 2005-07-28 | Martin 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.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
3d7663 | 2005-11-03 | Lance Dillon | | {
|
cac420 | 2005-12-17 | Marcus Comstedt | | INT_TYPE index;
|
1a0554 | 2005-07-28 | Martin 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.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin 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);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin Nilsson | | while (arr[n])
PGTK_PUSH_INT(arr[n++]);
|
3d7663 | 2005-11-03 | Lance Dillon | | if (!n)
|
1a0554 | 2005-07-28 | Martin Nilsson | | ref_push_array(&empty_array);
|
3d7663 | 2005-11-03 | Lance Dillon | | else
|
1a0554 | 2005-07-28 | Martin Nilsson | | f_aggregate(n);
}
void destroy()
{
|
2edd4f | 2008-01-30 | Per Hedbor | | if (THIS->obj && THIS->owned)
|
1a0554 | 2005-07-28 | Martin Nilsson | | gtk_tree_path_free((GtkTreePath *)THIS->obj);
THIS->obj=0;
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin Nilsson | | PGTK_PUSH_INT(0);
}
GTK2.TreePath copy()
//! Creates a new GTK2.TreePath as a copy.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | {
GtkTreePath *a1;
a1=(GtkTreePath *)gtk_tree_path_copy((GtkTreePath *)THIS->obj);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
2edd4f | 2008-01-30 | Per Hedbor | | push_pgdk2object(a1,pgtk2_tree_path_program,1);
|
1a0554 | 2005-07-28 | Martin 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.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | {
GtkTreePath *gp=NULL;
struct object *o1;
int res;
get_all_args("compare",args,"%o",&o1);
if (o1)
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | gp=(GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program);
|
1a0554 | 2005-07-28 | Martin Nilsson | | res=gtk_tree_path_compare((GtkTreePath *)THIS->obj,gp);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin Nilsson | | PGTK_PUSH_INT(res);
}
}
void next()
//! Moves the path to point to the next node at the current depth.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin 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.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | gtk_tree_path_prev((GtkTreePath *)THIS->obj);
RETURN_THIS();
}
|
3d7663 | 2005-11-03 | Lance Dillon | | void up()
|
1a0554 | 2005-07-28 | Martin Nilsson | | //! Moves the path to point to its parent node, if it has a parent.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | gtk_tree_path_up((GtkTreePath *)THIS->obj);
RETURN_THIS();
}
void down()
//! Moves path to point to the first child of the current path.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin 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.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | {
GtkTreePath *gp=NULL;
struct object *o1;
int res;
get_all_args("is_ancestor",args,"%o",&o1);
if (o1)
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | gp=(GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program);
|
1a0554 | 2005-07-28 | Martin Nilsson | | res=gtk_tree_path_is_ancestor((GtkTreePath *)THIS->obj,gp);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin Nilsson | | PGTK_PUSH_INT(res);
}
}
int is_descendant(GTK2.TreePath ancestor)
//! Returns TRUE if this path is a descendant of ancestor.
{
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_verify_inited();
|
1a0554 | 2005-07-28 | Martin Nilsson | | {
|
d5be63 | 2008-01-18 | Henrik Grubbström (Grubba) | | GtkTreePath *gp = NULL;
|
1a0554 | 2005-07-28 | Martin Nilsson | | struct object *o1;
int res;
get_all_args("is_descendant",args,"%o",&o1);
if (o1)
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | gp=(GtkTreePath *)get_pg2object(o1,pgtk2_tree_path_program);
|
1a0554 | 2005-07-28 | Martin Nilsson | | res=gtk_tree_path_is_descendant((GtkTreePath *)THIS->obj,gp);
|
ba9e80 | 2006-02-27 | Martin Stjernholm | | pgtk2_pop_n_elems(args);
|
1a0554 | 2005-07-28 | Martin Nilsson | | PGTK_PUSH_INT(res);
}
}
|