Synopsis#include <gtk/gtk.h> GtkTreeSelection; gboolean (*GtkTreeSelectionFunc) (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data); void (*GtkTreeSelectionForeachFunc) (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); void gtk_tree_selection_set_mode (GtkTreeSelection *selection, GtkSelectionMode type); GtkSelectionMode gtk_tree_selection_get_mode (GtkTreeSelection *selection); void gtk_tree_selection_set_select_function (GtkTreeSelection *selection, GtkTreeSelectionFunc func, gpointer data, GDestroyNotify destroy); GtkTreeSelectionFunc gtk_tree_selection_get_select_function (GtkTreeSelection *selection); gpointer gtk_tree_selection_get_user_data (GtkTreeSelection *selection); GtkTreeView* gtk_tree_selection_get_tree_view (GtkTreeSelection *selection); gboolean gtk_tree_selection_get_selected (GtkTreeSelection *selection, GtkTreeModel **model, GtkTreeIter *iter); void gtk_tree_selection_selected_foreach (GtkTreeSelection *selection, GtkTreeSelectionForeachFunc func, gpointer data); GList* gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection, GtkTreeModel **model); gint gtk_tree_selection_count_selected_rows (GtkTreeSelection *selection); void gtk_tree_selection_select_path (GtkTreeSelection *selection, GtkTreePath *path); void gtk_tree_selection_unselect_path (GtkTreeSelection *selection, GtkTreePath *path); gboolean gtk_tree_selection_path_is_selected (GtkTreeSelection *selection, GtkTreePath *path); void gtk_tree_selection_select_iter (GtkTreeSelection *selection, GtkTreeIter *iter); void gtk_tree_selection_unselect_iter (GtkTreeSelection *selection, GtkTreeIter *iter); gboolean gtk_tree_selection_iter_is_selected (GtkTreeSelection *selection, GtkTreeIter *iter); void gtk_tree_selection_select_all (GtkTreeSelection *selection); void gtk_tree_selection_unselect_all (GtkTreeSelection *selection); void gtk_tree_selection_select_range (GtkTreeSelection *selection, GtkTreePath *start_path, GtkTreePath *end_path); void gtk_tree_selection_unselect_range (GtkTreeSelection *selection, GtkTreePath *start_path, GtkTreePath *end_path); DescriptionThe GtkTreeSelection object is a helper object to manage the selection for a GtkTreeView widget. The GtkTreeSelection object is automatically created when a new GtkTreeView widget is created, and cannot exist independentally of this widget. The primary reason the GtkTreeSelection objects exists is for cleanliness of code and API. That is, there is no conceptual reason all these functions could not be methods on the GtkTreeView widget instead of a separate function.
The GtkTreeSelection object is gotten from a GtkTreeView by calling
One of the important things to remember when monitoring the selection of a view is that the "changed" signal is mostly a hint. That is, it may only emit one signal when a range of rows is selected. Additionally, it may on occasion emit a ::changed signal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row). DetailsGtkTreeSelectionFunc ()gboolean (*GtkTreeSelectionFunc) (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data);
A function used by
GtkTreeSelectionForeachFunc ()void (*GtkTreeSelectionForeachFunc) (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
A function used by
gtk_tree_selection_set_mode ()void gtk_tree_selection_set_mode (GtkTreeSelection *selection, GtkSelectionMode type);
Sets the selection mode of the
gtk_tree_selection_get_mode ()GtkSelectionMode gtk_tree_selection_get_mode (GtkTreeSelection *selection);
Gets the selection mode for
gtk_tree_selection_set_select_function ()void gtk_tree_selection_set_select_function (GtkTreeSelection *selection, GtkTreeSelectionFunc func, gpointer data, GDestroyNotify destroy);
Sets the selection function. If set, this function is called before any node
is selected or unselected, giving some control over which nodes are selected.
The select function should return
gtk_tree_selection_get_select_function ()GtkTreeSelectionFunc gtk_tree_selection_get_select_function (GtkTreeSelection *selection); Returns the current selection function.
Since 2.14 gtk_tree_selection_get_user_data ()gpointer gtk_tree_selection_get_user_data (GtkTreeSelection *selection); Returns the user data for the selection function.
gtk_tree_selection_get_tree_view ()GtkTreeView* gtk_tree_selection_get_tree_view (GtkTreeSelection *selection);
Returns the tree view associated with
gtk_tree_selection_get_selected ()gboolean gtk_tree_selection_get_selected (GtkTreeSelection *selection, GtkTreeModel **model, GtkTreeIter *iter);
Sets
gtk_tree_selection_selected_foreach ()void gtk_tree_selection_selected_foreach (GtkTreeSelection *selection, GtkTreeSelectionForeachFunc func, gpointer data);
Calls a function for each selected node. Note that you cannot modify
the tree or selection from within this function. As a result,
gtk_tree_selection_get_selected_rows ()GList* gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection, GtkTreeModel **model);
Creates a list of path of all selected rows. Additionally, if you are
planning on modifying the model after calling this function, you may
want to convert the returned list into a list of GtkTreeRowReferences.
To do this, you can use To free the return value, use: g_list_foreach (list, gtk_tree_path_free, NULL); g_list_free (list);
Since 2.2 gtk_tree_selection_count_selected_rows ()gint gtk_tree_selection_count_selected_rows (GtkTreeSelection *selection);
Returns the number of rows that have been selected in
Since 2.2 gtk_tree_selection_select_path ()void gtk_tree_selection_select_path (GtkTreeSelection *selection, GtkTreePath *path);
Select the row at
gtk_tree_selection_unselect_path ()void gtk_tree_selection_unselect_path (GtkTreeSelection *selection, GtkTreePath *path);
Unselects the row at
gtk_tree_selection_path_is_selected ()gboolean gtk_tree_selection_path_is_selected (GtkTreeSelection *selection, GtkTreePath *path);
Returns
gtk_tree_selection_select_iter ()void gtk_tree_selection_select_iter (GtkTreeSelection *selection, GtkTreeIter *iter); Selects the specified iterator.
gtk_tree_selection_unselect_iter ()void gtk_tree_selection_unselect_iter (GtkTreeSelection *selection, GtkTreeIter *iter); Unselects the specified iterator.
gtk_tree_selection_iter_is_selected ()gboolean gtk_tree_selection_iter_is_selected (GtkTreeSelection *selection, GtkTreeIter *iter);
Returns
gtk_tree_selection_select_all ()void gtk_tree_selection_select_all (GtkTreeSelection *selection);
Selects all the nodes.
gtk_tree_selection_unselect_all ()void gtk_tree_selection_unselect_all (GtkTreeSelection *selection); Unselects all the nodes.
gtk_tree_selection_select_range ()void gtk_tree_selection_select_range (GtkTreeSelection *selection, GtkTreePath *start_path, GtkTreePath *end_path);
Selects a range of nodes, determined by
gtk_tree_selection_unselect_range ()void gtk_tree_selection_unselect_range (GtkTreeSelection *selection, GtkTreePath *start_path, GtkTreePath *end_path);
Unselects a range of nodes, determined by
Since 2.2 Signal DetailsThe
|
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
GtkTreeView, GtkTreeViewColumn, GtkTreeDnd, GtkTreeMode, GtkTreeSortable, GtkTreeModelSort, GtkListStore, GtkTreeStore, GtkCellRenderer, GtkCellEditable, GtkCellRendererPixbuf, GtkCellRendererText, GtkCellRendererToggle