1 | /* |
2 | * Copyright (c) 2013 Red Hat, Inc. |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU Lesser General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or (at your |
7 | * option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, but |
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
12 | * License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public License |
15 | * along with this program; if not, write to the Free Software Foundation, |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | * |
18 | * Author: Alexander Larsson <alexl@redhat.com> |
19 | * |
20 | */ |
21 | |
22 | #ifndef __GTK_LIST_BOX_H__ |
23 | #define __GTK_LIST_BOX_H__ |
24 | |
25 | #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) |
26 | #error "Only <gtk/gtk.h> can be included directly." |
27 | #endif |
28 | |
29 | #include <gtk/gtkwidget.h> |
30 | |
31 | G_BEGIN_DECLS |
32 | |
33 | |
34 | #define GTK_TYPE_LIST_BOX (gtk_list_box_get_type ()) |
35 | #define GTK_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_BOX, GtkListBox)) |
36 | #define GTK_IS_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX)) |
37 | |
38 | typedef struct _GtkListBox GtkListBox; |
39 | typedef struct _GtkListBoxRow GtkListBoxRow; |
40 | typedef struct _GtkListBoxRowClass GtkListBoxRowClass; |
41 | |
42 | #define GTK_TYPE_LIST_BOX_ROW (gtk_list_box_row_get_type ()) |
43 | #define GTK_LIST_BOX_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRow)) |
44 | #define GTK_LIST_BOX_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRowClass)) |
45 | #define GTK_IS_LIST_BOX_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX_ROW)) |
46 | #define GTK_IS_LIST_BOX_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_BOX_ROW)) |
47 | #define GTK_LIST_BOX_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRowClass)) |
48 | |
49 | struct _GtkListBoxRow |
50 | { |
51 | GtkWidget parent_instance; |
52 | }; |
53 | |
54 | /** |
55 | * GtkListBoxRowClass: |
56 | * @parent_class: The parent class. |
57 | * @activate: |
58 | */ |
59 | struct _GtkListBoxRowClass |
60 | { |
61 | GtkWidgetClass parent_class; |
62 | |
63 | /*< public >*/ |
64 | |
65 | void (* activate) (GtkListBoxRow *row); |
66 | |
67 | /*< private >*/ |
68 | |
69 | gpointer padding[8]; |
70 | }; |
71 | |
72 | /** |
73 | * GtkListBoxFilterFunc: |
74 | * @row: the row that may be filtered |
75 | * @user_data: (closure): user data |
76 | * |
77 | * Will be called whenever the row changes or is added and lets you control |
78 | * if the row should be visible or not. |
79 | * |
80 | * Returns: %TRUE if the row should be visible, %FALSE otherwise |
81 | */ |
82 | typedef gboolean (*GtkListBoxFilterFunc) (GtkListBoxRow *row, |
83 | gpointer user_data); |
84 | |
85 | /** |
86 | * GtkListBoxSortFunc: |
87 | * @row1: the first row |
88 | * @row2: the second row |
89 | * @user_data: (closure): user data |
90 | * |
91 | * Compare two rows to determine which should be first. |
92 | * |
93 | * Returns: < 0 if @row1 should be before @row2, 0 if they are |
94 | * equal and > 0 otherwise |
95 | */ |
96 | typedef int (*GtkListBoxSortFunc) (GtkListBoxRow *row1, |
97 | GtkListBoxRow *row2, |
98 | gpointer user_data); |
99 | |
100 | /** |
101 | * GtkListBoxUpdateHeaderFunc: |
102 | * @row: the row to update |
103 | * @before: (nullable): the row before @row, or %NULL if it is first |
104 | * @user_data: (closure): user data |
105 | * |
106 | * Whenever @row changes or which row is before @row changes this |
107 | * is called, which lets you update the header on @row. |
108 | * |
109 | * You may remove or set a new one via [method@Gtk.ListBoxRow.set_header] |
110 | * or just change the state of the current header widget. |
111 | */ |
112 | typedef void (*) (GtkListBoxRow *row, |
113 | GtkListBoxRow *before, |
114 | gpointer user_data); |
115 | |
116 | /** |
117 | * GtkListBoxCreateWidgetFunc: |
118 | * @item: (type GObject): the item from the model for which to create a widget for |
119 | * @user_data: (closure): user data |
120 | * |
121 | * Called for list boxes that are bound to a `GListModel` with |
122 | * gtk_list_box_bind_model() for each item that gets added to the model. |
123 | * |
124 | * If the widget returned is not a #GtkListBoxRow widget, then the widget |
125 | * will be inserted as the child of an intermediate #GtkListBoxRow. |
126 | * |
127 | * Returns: (transfer full): a `GtkWidget` that represents @item |
128 | */ |
129 | typedef GtkWidget * (*GtkListBoxCreateWidgetFunc) (gpointer item, |
130 | gpointer user_data); |
131 | |
132 | GDK_AVAILABLE_IN_ALL |
133 | GType gtk_list_box_row_get_type (void) G_GNUC_CONST; |
134 | GDK_AVAILABLE_IN_ALL |
135 | GtkWidget* gtk_list_box_row_new (void); |
136 | |
137 | GDK_AVAILABLE_IN_ALL |
138 | void gtk_list_box_row_set_child (GtkListBoxRow *row, |
139 | GtkWidget *child); |
140 | GDK_AVAILABLE_IN_ALL |
141 | GtkWidget *gtk_list_box_row_get_child (GtkListBoxRow *row); |
142 | |
143 | GDK_AVAILABLE_IN_ALL |
144 | GtkWidget* (GtkListBoxRow *row); |
145 | GDK_AVAILABLE_IN_ALL |
146 | void (GtkListBoxRow *row, |
147 | GtkWidget *); |
148 | GDK_AVAILABLE_IN_ALL |
149 | int gtk_list_box_row_get_index (GtkListBoxRow *row); |
150 | GDK_AVAILABLE_IN_ALL |
151 | void gtk_list_box_row_changed (GtkListBoxRow *row); |
152 | |
153 | GDK_AVAILABLE_IN_ALL |
154 | gboolean gtk_list_box_row_is_selected (GtkListBoxRow *row); |
155 | |
156 | GDK_AVAILABLE_IN_ALL |
157 | void gtk_list_box_row_set_selectable (GtkListBoxRow *row, |
158 | gboolean selectable); |
159 | GDK_AVAILABLE_IN_ALL |
160 | gboolean gtk_list_box_row_get_selectable (GtkListBoxRow *row); |
161 | |
162 | |
163 | GDK_AVAILABLE_IN_ALL |
164 | void gtk_list_box_row_set_activatable (GtkListBoxRow *row, |
165 | gboolean activatable); |
166 | GDK_AVAILABLE_IN_ALL |
167 | gboolean gtk_list_box_row_get_activatable (GtkListBoxRow *row); |
168 | |
169 | GDK_AVAILABLE_IN_ALL |
170 | GType gtk_list_box_get_type (void) G_GNUC_CONST; |
171 | GDK_AVAILABLE_IN_ALL |
172 | void gtk_list_box_prepend (GtkListBox *box, |
173 | GtkWidget *child); |
174 | GDK_AVAILABLE_IN_ALL |
175 | void gtk_list_box_append (GtkListBox *box, |
176 | GtkWidget *child); |
177 | GDK_AVAILABLE_IN_ALL |
178 | void gtk_list_box_insert (GtkListBox *box, |
179 | GtkWidget *child, |
180 | int position); |
181 | GDK_AVAILABLE_IN_ALL |
182 | void gtk_list_box_remove (GtkListBox *box, |
183 | GtkWidget *child); |
184 | GDK_AVAILABLE_IN_ALL |
185 | GtkListBoxRow* gtk_list_box_get_selected_row (GtkListBox *box); |
186 | GDK_AVAILABLE_IN_ALL |
187 | GtkListBoxRow* gtk_list_box_get_row_at_index (GtkListBox *box, |
188 | int index_); |
189 | GDK_AVAILABLE_IN_ALL |
190 | GtkListBoxRow* gtk_list_box_get_row_at_y (GtkListBox *box, |
191 | int y); |
192 | GDK_AVAILABLE_IN_ALL |
193 | void gtk_list_box_select_row (GtkListBox *box, |
194 | GtkListBoxRow *row); |
195 | GDK_AVAILABLE_IN_ALL |
196 | void gtk_list_box_set_placeholder (GtkListBox *box, |
197 | GtkWidget *placeholder); |
198 | GDK_AVAILABLE_IN_ALL |
199 | void gtk_list_box_set_adjustment (GtkListBox *box, |
200 | GtkAdjustment *adjustment); |
201 | GDK_AVAILABLE_IN_ALL |
202 | GtkAdjustment *gtk_list_box_get_adjustment (GtkListBox *box); |
203 | |
204 | typedef void (* GtkListBoxForeachFunc) (GtkListBox *box, |
205 | GtkListBoxRow *row, |
206 | gpointer user_data); |
207 | |
208 | GDK_AVAILABLE_IN_ALL |
209 | void gtk_list_box_selected_foreach (GtkListBox *box, |
210 | GtkListBoxForeachFunc func, |
211 | gpointer data); |
212 | GDK_AVAILABLE_IN_ALL |
213 | GList *gtk_list_box_get_selected_rows (GtkListBox *box); |
214 | GDK_AVAILABLE_IN_ALL |
215 | void gtk_list_box_unselect_row (GtkListBox *box, |
216 | GtkListBoxRow *row); |
217 | GDK_AVAILABLE_IN_ALL |
218 | void gtk_list_box_select_all (GtkListBox *box); |
219 | GDK_AVAILABLE_IN_ALL |
220 | void gtk_list_box_unselect_all (GtkListBox *box); |
221 | |
222 | GDK_AVAILABLE_IN_ALL |
223 | void gtk_list_box_set_selection_mode (GtkListBox *box, |
224 | GtkSelectionMode mode); |
225 | GDK_AVAILABLE_IN_ALL |
226 | GtkSelectionMode gtk_list_box_get_selection_mode (GtkListBox *box); |
227 | GDK_AVAILABLE_IN_ALL |
228 | void gtk_list_box_set_filter_func (GtkListBox *box, |
229 | GtkListBoxFilterFunc filter_func, |
230 | gpointer user_data, |
231 | GDestroyNotify destroy); |
232 | GDK_AVAILABLE_IN_ALL |
233 | void (GtkListBox *box, |
234 | GtkListBoxUpdateHeaderFunc , |
235 | gpointer user_data, |
236 | GDestroyNotify destroy); |
237 | GDK_AVAILABLE_IN_ALL |
238 | void gtk_list_box_invalidate_filter (GtkListBox *box); |
239 | GDK_AVAILABLE_IN_ALL |
240 | void gtk_list_box_invalidate_sort (GtkListBox *box); |
241 | GDK_AVAILABLE_IN_ALL |
242 | void (GtkListBox *box); |
243 | GDK_AVAILABLE_IN_ALL |
244 | void gtk_list_box_set_sort_func (GtkListBox *box, |
245 | GtkListBoxSortFunc sort_func, |
246 | gpointer user_data, |
247 | GDestroyNotify destroy); |
248 | GDK_AVAILABLE_IN_ALL |
249 | void gtk_list_box_set_activate_on_single_click (GtkListBox *box, |
250 | gboolean single); |
251 | GDK_AVAILABLE_IN_ALL |
252 | gboolean gtk_list_box_get_activate_on_single_click (GtkListBox *box); |
253 | GDK_AVAILABLE_IN_ALL |
254 | void gtk_list_box_drag_unhighlight_row (GtkListBox *box); |
255 | GDK_AVAILABLE_IN_ALL |
256 | void gtk_list_box_drag_highlight_row (GtkListBox *box, |
257 | GtkListBoxRow *row); |
258 | GDK_AVAILABLE_IN_ALL |
259 | GtkWidget* gtk_list_box_new (void); |
260 | |
261 | |
262 | GDK_AVAILABLE_IN_ALL |
263 | void gtk_list_box_bind_model (GtkListBox *box, |
264 | GListModel *model, |
265 | GtkListBoxCreateWidgetFunc create_widget_func, |
266 | gpointer user_data, |
267 | GDestroyNotify user_data_free_func); |
268 | |
269 | GDK_AVAILABLE_IN_ALL |
270 | void gtk_list_box_set_show_separators (GtkListBox *box, |
271 | gboolean show_separators); |
272 | GDK_AVAILABLE_IN_ALL |
273 | gboolean gtk_list_box_get_show_separators (GtkListBox *box); |
274 | |
275 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBox, g_object_unref) |
276 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBoxRow, g_object_unref) |
277 | |
278 | G_END_DECLS |
279 | |
280 | #endif |
281 | |