1/* gtktreeselection.h
2 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GTK_TREE_SELECTION_H__
19#define __GTK_TREE_SELECTION_H__
20
21#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22#error "Only <gtk/gtk.h> can be included directly."
23#endif
24
25#include <gtk/gtktreeview.h>
26
27G_BEGIN_DECLS
28
29
30#define GTK_TYPE_TREE_SELECTION (gtk_tree_selection_get_type ())
31#define GTK_TREE_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_SELECTION, GtkTreeSelection))
32#define GTK_IS_TREE_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_SELECTION))
33
34/**
35 * GtkTreeSelectionFunc:
36 * @selection: A `GtkTreeSelection`
37 * @model: A `GtkTreeModel` being viewed
38 * @path: The `GtkTreePath` of the row in question
39 * @path_currently_selected: %TRUE, if the path is currently selected
40 * @data: (closure): user data
41 *
42 * A function used by gtk_tree_selection_set_select_function() to filter
43 * whether or not a row may be selected. It is called whenever a row's
44 * state might change.
45 *
46 * A return value of %TRUE indicates to @selection that it is okay to
47 * change the selection.
48 *
49 * Returns: %TRUE, if the selection state of the row can be toggled
50 */
51typedef gboolean (* GtkTreeSelectionFunc) (GtkTreeSelection *selection,
52 GtkTreeModel *model,
53 GtkTreePath *path,
54 gboolean path_currently_selected,
55 gpointer data);
56
57/**
58 * GtkTreeSelectionForeachFunc:
59 * @model: The `GtkTreeModel` being viewed
60 * @path: The `GtkTreePath` of a selected row
61 * @iter: A `GtkTreeIter` pointing to a selected row
62 * @data: (closure): user data
63 *
64 * A function used by gtk_tree_selection_selected_foreach() to map all
65 * selected rows. It will be called on every selected row in the view.
66 */
67typedef void (* GtkTreeSelectionForeachFunc) (GtkTreeModel *model,
68 GtkTreePath *path,
69 GtkTreeIter *iter,
70 gpointer data);
71
72
73GDK_AVAILABLE_IN_ALL
74GType gtk_tree_selection_get_type (void) G_GNUC_CONST;
75
76GDK_AVAILABLE_IN_ALL
77void gtk_tree_selection_set_mode (GtkTreeSelection *selection,
78 GtkSelectionMode type);
79GDK_AVAILABLE_IN_ALL
80GtkSelectionMode gtk_tree_selection_get_mode (GtkTreeSelection *selection);
81GDK_AVAILABLE_IN_ALL
82void gtk_tree_selection_set_select_function (GtkTreeSelection *selection,
83 GtkTreeSelectionFunc func,
84 gpointer data,
85 GDestroyNotify destroy);
86GDK_AVAILABLE_IN_ALL
87gpointer gtk_tree_selection_get_user_data (GtkTreeSelection *selection);
88GDK_AVAILABLE_IN_ALL
89GtkTreeView* gtk_tree_selection_get_tree_view (GtkTreeSelection *selection);
90
91GDK_AVAILABLE_IN_ALL
92GtkTreeSelectionFunc gtk_tree_selection_get_select_function (GtkTreeSelection *selection);
93
94/* Only meaningful if GTK_SELECTION_SINGLE or GTK_SELECTION_BROWSE is set */
95/* Use selected_foreach or get_selected_rows for GTK_SELECTION_MULTIPLE */
96GDK_AVAILABLE_IN_ALL
97gboolean gtk_tree_selection_get_selected (GtkTreeSelection *selection,
98 GtkTreeModel **model,
99 GtkTreeIter *iter);
100GDK_AVAILABLE_IN_ALL
101GList * gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection,
102 GtkTreeModel **model);
103GDK_AVAILABLE_IN_ALL
104int gtk_tree_selection_count_selected_rows (GtkTreeSelection *selection);
105GDK_AVAILABLE_IN_ALL
106void gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
107 GtkTreeSelectionForeachFunc func,
108 gpointer data);
109GDK_AVAILABLE_IN_ALL
110void gtk_tree_selection_select_path (GtkTreeSelection *selection,
111 GtkTreePath *path);
112GDK_AVAILABLE_IN_ALL
113void gtk_tree_selection_unselect_path (GtkTreeSelection *selection,
114 GtkTreePath *path);
115GDK_AVAILABLE_IN_ALL
116void gtk_tree_selection_select_iter (GtkTreeSelection *selection,
117 GtkTreeIter *iter);
118GDK_AVAILABLE_IN_ALL
119void gtk_tree_selection_unselect_iter (GtkTreeSelection *selection,
120 GtkTreeIter *iter);
121GDK_AVAILABLE_IN_ALL
122gboolean gtk_tree_selection_path_is_selected (GtkTreeSelection *selection,
123 GtkTreePath *path);
124GDK_AVAILABLE_IN_ALL
125gboolean gtk_tree_selection_iter_is_selected (GtkTreeSelection *selection,
126 GtkTreeIter *iter);
127GDK_AVAILABLE_IN_ALL
128void gtk_tree_selection_select_all (GtkTreeSelection *selection);
129GDK_AVAILABLE_IN_ALL
130void gtk_tree_selection_unselect_all (GtkTreeSelection *selection);
131GDK_AVAILABLE_IN_ALL
132void gtk_tree_selection_select_range (GtkTreeSelection *selection,
133 GtkTreePath *start_path,
134 GtkTreePath *end_path);
135GDK_AVAILABLE_IN_ALL
136void gtk_tree_selection_unselect_range (GtkTreeSelection *selection,
137 GtkTreePath *start_path,
138 GtkTreePath *end_path);
139
140
141G_END_DECLS
142
143#endif /* __GTK_TREE_SELECTION_H__ */
144

source code of gtk/gtk/gtktreeselection.h