Top |
void | row-changed | Run Last |
void | row-deleted | Run First |
void | row-has-child-toggled | Run Last |
void | row-inserted | Run First |
void | rows-reordered | Run First |
GtkTreeModel | |
struct | GtkTreeIter |
GtkTreePath | |
GtkTreeRowReference | |
struct | GtkTreeModelIface |
enum | GtkTreeModelFlags |
GtkTreeModel is implemented by GtkListStore, GtkTreeModelFilter, GtkTreeModelSort and GtkTreeStore.
gboolean (*GtkTreeModelForeachFunc) (GtkTreeModel *model
,GtkTreePath *path
,GtkTreeIter *iter
,gpointer data
);
GtkTreePath *
gtk_tree_path_new (void
);
Creates a new GtkTreePath. This structure refers to a row.
GtkTreePath *
gtk_tree_path_new_from_string (const gchar *path
);
Creates a new GtkTreePath initialized to path
. path
is expected to be a
colon separated list of numbers. For example, the string "10:4:0" would
create a path of depth 3 pointing to the 11th child of the root node, the 5th
child of that 11th child, and the 1st child of that 5th child. If an invalid
path string is passed in, NULL
is returned.
GtkTreePath * gtk_tree_path_new_from_indices (gint first_index
,...
);
Creates a new path with first_index
and varargs
as indices.
Since: 2.2
gchar *
gtk_tree_path_to_string (GtkTreePath *path
);
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.
GtkTreePath *
gtk_tree_path_new_first (void
);
Creates a new GtkTreePath. The string representation of this path is "0"
#define gtk_tree_path_new_root() gtk_tree_path_new_first()
gtk_tree_path_new_root
is deprecated and should not be used in newly-written code.
void gtk_tree_path_append_index (GtkTreePath *path
,gint index_
);
Appends a new index to a path. As a result, the depth of the path is increased.
void gtk_tree_path_prepend_index (GtkTreePath *path
,gint index_
);
Prepends a new index to a path. As a result, the depth of the path is increased.
gint
gtk_tree_path_get_depth (GtkTreePath *path
);
Returns the current depth of path
.
gint *
gtk_tree_path_get_indices (GtkTreePath *path
);
Returns the current indices of path
. This is an array of integers, each
representing a node in a tree. This value should not be freed.
gint * gtk_tree_path_get_indices_with_depth (GtkTreePath *path
,gint *depth
);
Returns the current indices of path
.
This is an array of integers, each representing a node in a tree.
It also returns the number of elements in the array.
The array should not be freed.
Since: 2.22
GtkTreePath *
gtk_tree_path_copy (const GtkTreePath *path
);
Creates a new GtkTreePath as a copy of path
.
gint gtk_tree_path_compare (const GtkTreePath *a
,const GtkTreePath *b
);
Compares two paths. If a
appears before b
in a tree, then -1 is returned.
If b
appears before a
, then 1 is returned. If the two nodes are equal,
then 0 is returned.
void
gtk_tree_path_next (GtkTreePath *path
);
Moves the path
to point to the next node at the current depth.
gboolean
gtk_tree_path_prev (GtkTreePath *path
);
Moves the path
to point to the previous node at the current depth,
if it exists.
gboolean
gtk_tree_path_up (GtkTreePath *path
);
Moves the path
to point to its parent node, if it has a parent.
void
gtk_tree_path_down (GtkTreePath *path
);
Moves path
to point to the first child of the current path.
gboolean gtk_tree_path_is_ancestor (GtkTreePath *path
,GtkTreePath *descendant
);
Returns TRUE
if descendant
is a descendant of path
.
gboolean gtk_tree_path_is_descendant (GtkTreePath *path
,GtkTreePath *ancestor
);
Returns TRUE
if path
is a descendant of ancestor
.
GtkTreeRowReference * gtk_tree_row_reference_new (GtkTreeModel *model
,GtkTreePath *path
);
Creates a row reference based on path
. This reference will keep pointing
to the node pointed to by path
, so long as it exists. It listens to all
signals emitted by model
, and updates its path appropriately. If path
isn't a valid path in model
, then NULL
is returned.
GtkTreeRowReference * gtk_tree_row_reference_new_proxy (GObject *proxy
,GtkTreeModel *model
,GtkTreePath *path
);
You do not need to use this function. Creates a row reference based on
path
. This reference will keep pointing to the node pointed to by path
,
so long as it exists. If path
isn't a valid path in model
, then NULL
is
returned. However, unlike references created with
gtk_tree_row_reference_new()
, it does not listen to the model for changes.
The creator of the row reference must do this explicitly using
gtk_tree_row_reference_inserted()
, gtk_tree_row_reference_deleted()
,
gtk_tree_row_reference_reordered()
.
These functions must be called exactly once per proxy when the
corresponding signal on the model is emitted. This single call
updates all row references for that proxy. Since built-in GTK+
objects like GtkTreeView already use this mechanism internally,
using them as the proxy object will produce unpredictable results.
Further more, passing the same object as model
and proxy
doesn't work for reasons of internal implementation.
This type of row reference is primarily meant by structures that need to carefully monitor exactly when a row reference updates itself, and is not generally needed by most applications.
GtkTreeModel *
gtk_tree_row_reference_get_model (GtkTreeRowReference *reference
);
Returns the model that the row reference is monitoring.
Since: 2.8
GtkTreePath *
gtk_tree_row_reference_get_path (GtkTreeRowReference *reference
);
Returns a path that the row reference currently points to, or NULL
if the
path pointed to is no longer valid.
gboolean
gtk_tree_row_reference_valid (GtkTreeRowReference *reference
);
Returns TRUE
if the reference
is non-NULL
and refers to a current valid
path.
void
gtk_tree_row_reference_free (GtkTreeRowReference *reference
);
Free's reference
. reference
may be NULL
.
GtkTreeRowReference *
gtk_tree_row_reference_copy (GtkTreeRowReference *reference
);
Copies a GtkTreeRowReference.
Since: 2.2
void gtk_tree_row_reference_inserted (GObject *proxy
,GtkTreePath *path
);
Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
know that the model emitted the "row_inserted" signal.
void gtk_tree_row_reference_deleted (GObject *proxy
,GtkTreePath *path
);
Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
know that the model emitted the "row_deleted" signal.
void gtk_tree_row_reference_reordered (GObject *proxy
,GtkTreePath *path
,GtkTreeIter *iter
,gint *new_order
);
Lets a set of row reference created by gtk_tree_row_reference_new_proxy()
know that the model emitted the "rows_reordered" signal.
GtkTreeIter *
gtk_tree_iter_copy (GtkTreeIter *iter
);
Creates a dynamically allocated tree iterator as a copy of iter
.
This function is not intended for use in applications, because you
can just copy the structs by value
(GtkTreeIter new_iter = iter;
).
You must free this iter with gtk_tree_iter_free()
.
void
gtk_tree_iter_free (GtkTreeIter *iter
);
Frees an iterator that has been allocated by gtk_tree_iter_copy()
.
This function is mainly used for language bindings.
GtkTreeModelFlags
gtk_tree_model_get_flags (GtkTreeModel *tree_model
);
Returns a set of flags supported by this interface. The flags are a bitwise
combination of GtkTreeModelFlags. The flags supported should not change
during the lifecycle of the tree_model
.
gint
gtk_tree_model_get_n_columns (GtkTreeModel *tree_model
);
Returns the number of columns supported by tree_model
.
GType gtk_tree_model_get_column_type (GtkTreeModel *tree_model
,gint index_
);
Returns the type of the column.
gboolean gtk_tree_model_get_iter (GtkTreeModel *tree_model
,GtkTreeIter *iter
,GtkTreePath *path
);
Sets iter
to a valid iterator pointing to path
.
tree_model |
A GtkTreeModel. |
|
iter |
The uninitialized GtkTreeIter. |
[out] |
path |
The GtkTreePath. |
gboolean gtk_tree_model_get_iter_from_string (GtkTreeModel *tree_model
,GtkTreeIter *iter
,const gchar *path_string
);
Sets iter
to a valid iterator pointing to path_string
, if it
exists. Otherwise, iter
is left invalid and FALSE
is returned.
tree_model |
A GtkTreeModel. |
|
iter |
An uninitialized GtkTreeIter. |
[out] |
path_string |
A string representation of a GtkTreePath. |
gboolean gtk_tree_model_get_iter_first (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Initializes iter
with the first iterator in the tree (the one at the path
"0") and returns TRUE
. Returns FALSE
if the tree is empty.
#define gtk_tree_model_get_iter_root(tree_model, iter) gtk_tree_model_get_iter_first(tree_model, iter)
gtk_tree_model_get_iter_root
is deprecated and should not be used in newly-written code.
GtkTreePath * gtk_tree_model_get_path (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Returns a newly-created GtkTreePath referenced by iter
. This path should
be freed with gtk_tree_path_free()
.
void gtk_tree_model_get_value (GtkTreeModel *tree_model
,GtkTreeIter *iter
,gint column
,GValue *value
);
Initializes and sets value
to that at column
.
When done with value
, g_value_unset()
needs to be called
to free any allocated memory.
tree_model |
A GtkTreeModel. |
|
iter |
The GtkTreeIter. |
|
column |
The column to lookup the value at. |
|
value |
An empty GValue to set. |
[out][transfer none] |
gboolean gtk_tree_model_iter_next (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Sets iter
to point to the node following it at the current level. If there
is no next iter
, FALSE
is returned and iter
is set to be invalid.
gboolean gtk_tree_model_iter_children (GtkTreeModel *tree_model
,GtkTreeIter *iter
,GtkTreeIter *parent
);
Sets iter
to point to the first child of parent
. If parent
has no
children, FALSE
is returned and iter
is set to be invalid. parent
will remain a valid node after this function has been called.
If parent
is NULL
returns the first node, equivalent to
gtk_tree_model_get_iter_first (tree_model, iter);
tree_model |
A GtkTreeModel. |
|
iter |
The new GtkTreeIter to be set to the child. |
[out] |
parent |
The GtkTreeIter, or |
[allow-none] |
gboolean gtk_tree_model_iter_has_child (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Returns TRUE
if iter
has children, FALSE
otherwise.
gint gtk_tree_model_iter_n_children (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Returns the number of children that iter
has. As a special case, if iter
is NULL
, then the number of toplevel nodes is returned.
gboolean gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model
,GtkTreeIter *iter
,GtkTreeIter *parent
,gint n
);
Sets iter
to be the child of parent
, using the given index. The first
index is 0. If n
is too big, or parent
has no children, iter
is set
to an invalid iterator and FALSE
is returned. parent
will remain a valid
node after this function has been called. As a special case, if parent
is
NULL
, then the n
th root node is set.
tree_model |
A GtkTreeModel. |
|
iter |
The GtkTreeIter to set to the nth child. |
[out] |
parent |
The GtkTreeIter to get the child from, or |
[allow-none] |
n |
Then index of the desired child. |
gboolean gtk_tree_model_iter_parent (GtkTreeModel *tree_model
,GtkTreeIter *iter
,GtkTreeIter *child
);
Sets iter
to be the parent of child
. If child
is at the toplevel, and
doesn't have a parent, then iter
is set to an invalid iterator and FALSE
is returned. child
will remain a valid node after this function has been
called.
gchar * gtk_tree_model_get_string_from_iter (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Generates a string representation of the iter. This string is a ':' separated list of numbers. For example, "4:10:0:3" would be an acceptable return value for this string.
Since: 2.2
void gtk_tree_model_ref_node (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Lets the tree ref the node. This is an optional method for models to implement. To be more specific, models may ignore this call as it exists primarily for performance reasons.
This function is primarily meant as a way for views to let caching model know when nodes are being displayed (and hence, whether or not to cache that node.) For example, a file-system based model would not want to keep the entire file-hierarchy in memory, just the sections that are currently being displayed by every current view.
A model should be expected to be able to get an iter independent of its reffed state.
void gtk_tree_model_unref_node (GtkTreeModel *tree_model
,GtkTreeIter *iter
);
Lets the tree unref the node. This is an optional method for models to implement. To be more specific, models may ignore this call as it exists primarily for performance reasons.
For more information on what this means, see gtk_tree_model_ref_node()
.
Please note that nodes that are deleted are not unreffed.
void gtk_tree_model_get (GtkTreeModel *tree_model
,GtkTreeIter *iter
,...
);
Gets the value of one or more cells in the row referenced by iter
.
The variable argument list should contain integer column numbers,
each column number followed by a place to store the value being
retrieved. The list is terminated by a -1. For example, to get a
value from column 0 with type G_TYPE_STRING
, you would
write: gtk_tree_model_get (model, iter, 0, &place_string_here, -1)
,
where place_string_here
is a gchar* to be
filled with the string.
Returned values with type G_TYPE_OBJECT
have to be unreferenced, values
with type G_TYPE_STRING
or G_TYPE_BOXED
have to be freed. Other values are
passed by value.
void gtk_tree_model_get_valist (GtkTreeModel *tree_model
,GtkTreeIter *iter
,va_list var_args
);
See gtk_tree_model_get()
, this version takes a va_list
for language bindings to use.
void gtk_tree_model_foreach (GtkTreeModel *model
,GtkTreeModelForeachFunc func
,gpointer user_data
);
Calls func on each node in model in a depth-first fashion.
If func
returns TRUE
, then the tree ceases to be walked, and
gtk_tree_model_foreach()
returns.
void gtk_tree_model_row_changed (GtkTreeModel *tree_model
,GtkTreePath *path
,GtkTreeIter *iter
);
Emits the "row-changed" signal on tree_model
.
tree_model |
||
path |
A GtkTreePath pointing to the changed row |
|
iter |
A valid GtkTreeIter pointing to the changed row |
void gtk_tree_model_row_inserted (GtkTreeModel *tree_model
,GtkTreePath *path
,GtkTreeIter *iter
);
Emits the "row-inserted" signal on tree_model
tree_model |
||
path |
A GtkTreePath pointing to the inserted row |
|
iter |
A valid GtkTreeIter pointing to the inserted row |
void gtk_tree_model_row_has_child_toggled (GtkTreeModel *tree_model
,GtkTreePath *path
,GtkTreeIter *iter
);
Emits the "row-has-child-toggled" signal on tree_model
. This should be
called by models after the child state of a node changes.
tree_model |
||
path |
A GtkTreePath pointing to the changed row |
|
iter |
A valid GtkTreeIter pointing to the changed row |
void gtk_tree_model_row_deleted (GtkTreeModel *tree_model
,GtkTreePath *path
);
Emits the "row-deleted" signal on tree_model
. This should be called by
models after a row has been removed. The location pointed to by path
should be the location that the row previously was at. It may not be a
valid location anymore.
void gtk_tree_model_rows_reordered (GtkTreeModel *tree_model
,GtkTreePath *path
,GtkTreeIter *iter
,gint *new_order
);
Emits the "rows-reordered" signal on tree_model
. This should be called by
models when their rows have been reordered.
tree_model |
||
path |
A GtkTreePath pointing to the tree node whose children have been reordered |
|
iter |
A valid GtkTreeIter pointing to the node whose children have been
reordered, or |
|
new_order |
an array of integers mapping the current position of each child
to its old position before the re-ordering,
i.e. |
struct GtkTreeIter { gint stamp; gpointer user_data; gpointer user_data2; gpointer user_data3; };
struct GtkTreeModelIface { GTypeInterface g_iface; /* Signals */ void (* row_changed) (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter); void (* row_inserted) (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter); void (* row_has_child_toggled) (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter); void (* row_deleted) (GtkTreeModel *tree_model, GtkTreePath *path); void (* rows_reordered) (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gint *new_order); /* Virtual Table */ GtkTreeModelFlags (* get_flags) (GtkTreeModel *tree_model); gint (* get_n_columns) (GtkTreeModel *tree_model); GType (* get_column_type) (GtkTreeModel *tree_model, gint index_); gboolean (* get_iter) (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path); GtkTreePath *(* get_path) (GtkTreeModel *tree_model, GtkTreeIter *iter); void (* get_value) (GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value); gboolean (* iter_next) (GtkTreeModel *tree_model, GtkTreeIter *iter); gboolean (* iter_children) (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent); gboolean (* iter_has_child) (GtkTreeModel *tree_model, GtkTreeIter *iter); gint (* iter_n_children) (GtkTreeModel *tree_model, GtkTreeIter *iter); gboolean (* iter_nth_child) (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n); gboolean (* iter_parent) (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child); void (* ref_node) (GtkTreeModel *tree_model, GtkTreeIter *iter); void (* unref_node) (GtkTreeModel *tree_model, GtkTreeIter *iter); };
“row-changed”
signalvoid user_function (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
This signal is emitted when a row in the model has changed.
tree_model |
the GtkTreeModel on which the signal is emitted |
|
path |
a GtkTreePath identifying the changed row |
|
iter |
a valid GtkTreeIter pointing to the changed row |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“row-deleted”
signalvoid user_function (GtkTreeModel *tree_model, GtkTreePath *path, gpointer user_data)
This signal is emitted when a row has been deleted.
Note that no iterator is passed to the signal handler, since the row is already deleted.
This should be called by models after a row has been removed.
The location pointed to by path
should be the location that
the row previously was at. It may not be a valid location anymore.
tree_model |
the GtkTreeModel on which the signal is emitted |
|
path |
a GtkTreePath identifying the row |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“row-has-child-toggled”
signalvoid user_function (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
This signal is emitted when a row has gotten the first child row or lost its last child row.
tree_model |
the GtkTreeModel on which the signal is emitted |
|
path |
a GtkTreePath identifying the row |
|
iter |
a valid GtkTreeIter pointing to the row |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“row-inserted”
signalvoid user_function (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
This signal is emitted when a new row has been inserted in the model.
Note that the row may still be empty at this point, since it is a common pattern to first insert an empty row, and then fill it with the desired values.
tree_model |
the GtkTreeModel on which the signal is emitted |
|
path |
a GtkTreePath identifying the new row |
|
iter |
a valid GtkTreeIter pointing to the new row |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“rows-reordered”
signalvoid user_function (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer new_order, gpointer user_data)
This signal is emitted when the children of a node in the GtkTreeModel have been reordered.
Note that this signal is not emitted when rows are reordered by DND, since this is implemented by removing and then reinserting the row.
tree_model |
the GtkTreeModel on which the signal is emitted |
|
path |
a GtkTreePath identifying the tree node whose children have been reordered |
|
iter |
a valid GtkTreeIter pointing to the node whose |
|
new_order |
an array of integers mapping the current position of
each child to its old position before the re-ordering,
i.e. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First