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/gtkbin.h>
30
31G_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_LIST_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_BOX, GtkListBoxClass))
37#define GTK_IS_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX))
38#define GTK_IS_LIST_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_BOX))
39#define GTK_LIST_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_BOX, GtkListBoxClass))
40
41typedef struct _GtkListBox GtkListBox;
42typedef struct _GtkListBoxClass GtkListBoxClass;
43
44typedef struct _GtkListBoxRow GtkListBoxRow;
45typedef struct _GtkListBoxRowClass GtkListBoxRowClass;
46
47struct _GtkListBox
48{
49 GtkContainer parent_instance;
50};
51
52/**
53 * GtkListBoxClass:
54 * @parent_class: The parent class.
55 * @row_selected: Class handler for the #GtkListBox::row-selected signal
56 * @row_activated: Class handler for the #GtkListBox::row-activated signal
57 * @activate_cursor_row: Class handler for the #GtkListBox::activate-cursor-row signal
58 * @toggle_cursor_row: Class handler for the #GtkListBox::toggle-cursor-row signal
59 * @move_cursor: Class handler for the #GtkListBox::move-cursor signal
60 * @selected_rows_changed: Class handler for the #GtkListBox::selected-rows-changed signal
61 * @select_all: Class handler for the #GtkListBox::select-all signal
62 * @unselect_all: Class handler for the #GtkListBox::unselect-all signal
63 */
64struct _GtkListBoxClass
65{
66 GtkContainerClass parent_class;
67
68 /*< public >*/
69
70 void (*row_selected) (GtkListBox *box,
71 GtkListBoxRow *row);
72 void (*row_activated) (GtkListBox *box,
73 GtkListBoxRow *row);
74 void (*activate_cursor_row) (GtkListBox *box);
75 void (*toggle_cursor_row) (GtkListBox *box);
76 void (*move_cursor) (GtkListBox *box,
77 GtkMovementStep step,
78 gint count);
79 void (*selected_rows_changed) (GtkListBox *box);
80 void (*select_all) (GtkListBox *box);
81 void (*unselect_all) (GtkListBox *box);
82
83 /*< private >*/
84
85 /* Padding for future expansion */
86 void (*_gtk_reserved1) (void);
87 void (*_gtk_reserved2) (void);
88 void (*_gtk_reserved3) (void);
89};
90
91#define GTK_TYPE_LIST_BOX_ROW (gtk_list_box_row_get_type ())
92#define GTK_LIST_BOX_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRow))
93#define GTK_LIST_BOX_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRowClass))
94#define GTK_IS_LIST_BOX_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX_ROW))
95#define GTK_IS_LIST_BOX_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_BOX_ROW))
96#define GTK_LIST_BOX_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_BOX_ROW, GtkListBoxRowClass))
97
98struct _GtkListBoxRow
99{
100 GtkBin parent_instance;
101};
102
103/**
104 * GtkListBoxRowClass:
105 * @parent_class: The parent class.
106 * @activate:
107 */
108struct _GtkListBoxRowClass
109{
110 GtkBinClass parent_class;
111
112 /*< public >*/
113
114 void (* activate) (GtkListBoxRow *row);
115
116 /*< private >*/
117
118 /* Padding for future expansion */
119 void (*_gtk_reserved1) (void);
120 void (*_gtk_reserved2) (void);
121};
122
123/**
124 * GtkListBoxFilterFunc:
125 * @row: the row that may be filtered
126 * @user_data: (closure): user data
127 *
128 * Will be called whenever the row changes or is added and lets you control
129 * if the row should be visible or not.
130 *
131 * Returns: %TRUE if the row should be visible, %FALSE otherwise
132 *
133 * Since: 3.10
134 */
135typedef gboolean (*GtkListBoxFilterFunc) (GtkListBoxRow *row,
136 gpointer user_data);
137
138/**
139 * GtkListBoxSortFunc:
140 * @row1: the first row
141 * @row2: the second row
142 * @user_data: (closure): user data
143 *
144 * Compare two rows to determine which should be first.
145 *
146 * Returns: < 0 if @row1 should be before @row2, 0 if they are
147 * equal and > 0 otherwise
148 *
149 * Since: 3.10
150 */
151typedef gint (*GtkListBoxSortFunc) (GtkListBoxRow *row1,
152 GtkListBoxRow *row2,
153 gpointer user_data);
154
155/**
156 * GtkListBoxUpdateHeaderFunc:
157 * @row: the row to update
158 * @before: (allow-none): the row before @row, or %NULL if it is first
159 * @user_data: (closure): user data
160 *
161 * Whenever @row changes or which row is before @row changes this
162 * is called, which lets you update the header on @row. You may
163 * remove or set a new one via gtk_list_box_row_set_header() or
164 * just change the state of the current header widget.
165 *
166 * Since: 3.10
167 */
168typedef void (*GtkListBoxUpdateHeaderFunc) (GtkListBoxRow *row,
169 GtkListBoxRow *before,
170 gpointer user_data);
171
172/**
173 * GtkListBoxCreateWidgetFunc:
174 * @item: (type GObject): the item from the model for which to create a widget for
175 * @user_data: (closure): user data
176 *
177 * Called for list boxes that are bound to a #GListModel with
178 * gtk_list_box_bind_model() for each item that gets added to the model.
179 *
180 * Versions of GTK+ prior to 3.18 called gtk_widget_show_all() on the rows
181 * created by the GtkListBoxCreateWidgetFunc, but this forced all widgets
182 * inside the row to be shown, and is no longer the case. Applications should
183 * be updated to show the desired row widgets.
184 *
185 * Returns: (transfer full): a #GtkWidget that represents @item
186 *
187 * Since: 3.16
188 */
189typedef GtkWidget * (*GtkListBoxCreateWidgetFunc) (gpointer item,
190 gpointer user_data);
191
192GDK_AVAILABLE_IN_3_10
193GType gtk_list_box_row_get_type (void) G_GNUC_CONST;
194GDK_AVAILABLE_IN_3_10
195GtkWidget* gtk_list_box_row_new (void);
196GDK_AVAILABLE_IN_3_10
197GtkWidget* gtk_list_box_row_get_header (GtkListBoxRow *row);
198GDK_AVAILABLE_IN_3_10
199void gtk_list_box_row_set_header (GtkListBoxRow *row,
200 GtkWidget *header);
201GDK_AVAILABLE_IN_3_10
202gint gtk_list_box_row_get_index (GtkListBoxRow *row);
203GDK_AVAILABLE_IN_3_10
204void gtk_list_box_row_changed (GtkListBoxRow *row);
205
206GDK_AVAILABLE_IN_3_14
207gboolean gtk_list_box_row_is_selected (GtkListBoxRow *row);
208
209GDK_AVAILABLE_IN_3_14
210void gtk_list_box_row_set_selectable (GtkListBoxRow *row,
211 gboolean selectable);
212GDK_AVAILABLE_IN_3_14
213gboolean gtk_list_box_row_get_selectable (GtkListBoxRow *row);
214
215
216GDK_AVAILABLE_IN_3_14
217void gtk_list_box_row_set_activatable (GtkListBoxRow *row,
218 gboolean activatable);
219GDK_AVAILABLE_IN_3_14
220gboolean gtk_list_box_row_get_activatable (GtkListBoxRow *row);
221
222GDK_AVAILABLE_IN_3_10
223GType gtk_list_box_get_type (void) G_GNUC_CONST;
224GDK_AVAILABLE_IN_3_10
225void gtk_list_box_prepend (GtkListBox *box,
226 GtkWidget *child);
227GDK_AVAILABLE_IN_3_10
228void gtk_list_box_insert (GtkListBox *box,
229 GtkWidget *child,
230 gint position);
231GDK_AVAILABLE_IN_3_10
232GtkListBoxRow* gtk_list_box_get_selected_row (GtkListBox *box);
233GDK_AVAILABLE_IN_3_10
234GtkListBoxRow* gtk_list_box_get_row_at_index (GtkListBox *box,
235 gint index_);
236GDK_AVAILABLE_IN_3_10
237GtkListBoxRow* gtk_list_box_get_row_at_y (GtkListBox *box,
238 gint y);
239GDK_AVAILABLE_IN_3_10
240void gtk_list_box_select_row (GtkListBox *box,
241 GtkListBoxRow *row);
242GDK_AVAILABLE_IN_3_10
243void gtk_list_box_set_placeholder (GtkListBox *box,
244 GtkWidget *placeholder);
245GDK_AVAILABLE_IN_3_10
246void gtk_list_box_set_adjustment (GtkListBox *box,
247 GtkAdjustment *adjustment);
248GDK_AVAILABLE_IN_3_10
249GtkAdjustment *gtk_list_box_get_adjustment (GtkListBox *box);
250
251typedef void (* GtkListBoxForeachFunc) (GtkListBox *box,
252 GtkListBoxRow *row,
253 gpointer user_data);
254
255GDK_AVAILABLE_IN_3_14
256void gtk_list_box_selected_foreach (GtkListBox *box,
257 GtkListBoxForeachFunc func,
258 gpointer data);
259GDK_AVAILABLE_IN_3_14
260GList *gtk_list_box_get_selected_rows (GtkListBox *box);
261GDK_AVAILABLE_IN_3_14
262void gtk_list_box_unselect_row (GtkListBox *box,
263 GtkListBoxRow *row);
264GDK_AVAILABLE_IN_3_14
265void gtk_list_box_select_all (GtkListBox *box);
266GDK_AVAILABLE_IN_3_14
267void gtk_list_box_unselect_all (GtkListBox *box);
268
269GDK_AVAILABLE_IN_3_10
270void gtk_list_box_set_selection_mode (GtkListBox *box,
271 GtkSelectionMode mode);
272GDK_AVAILABLE_IN_3_10
273GtkSelectionMode gtk_list_box_get_selection_mode (GtkListBox *box);
274GDK_AVAILABLE_IN_3_10
275void gtk_list_box_set_filter_func (GtkListBox *box,
276 GtkListBoxFilterFunc filter_func,
277 gpointer user_data,
278 GDestroyNotify destroy);
279GDK_AVAILABLE_IN_3_10
280void gtk_list_box_set_header_func (GtkListBox *box,
281 GtkListBoxUpdateHeaderFunc update_header,
282 gpointer user_data,
283 GDestroyNotify destroy);
284GDK_AVAILABLE_IN_3_10
285void gtk_list_box_invalidate_filter (GtkListBox *box);
286GDK_AVAILABLE_IN_3_10
287void gtk_list_box_invalidate_sort (GtkListBox *box);
288GDK_AVAILABLE_IN_3_10
289void gtk_list_box_invalidate_headers (GtkListBox *box);
290GDK_AVAILABLE_IN_3_10
291void gtk_list_box_set_sort_func (GtkListBox *box,
292 GtkListBoxSortFunc sort_func,
293 gpointer user_data,
294 GDestroyNotify destroy);
295GDK_AVAILABLE_IN_3_10
296void gtk_list_box_set_activate_on_single_click (GtkListBox *box,
297 gboolean single);
298GDK_AVAILABLE_IN_3_10
299gboolean gtk_list_box_get_activate_on_single_click (GtkListBox *box);
300GDK_AVAILABLE_IN_3_10
301void gtk_list_box_drag_unhighlight_row (GtkListBox *box);
302GDK_AVAILABLE_IN_3_10
303void gtk_list_box_drag_highlight_row (GtkListBox *box,
304 GtkListBoxRow *row);
305GDK_AVAILABLE_IN_3_10
306GtkWidget* gtk_list_box_new (void);
307
308
309GDK_AVAILABLE_IN_3_16
310void gtk_list_box_bind_model (GtkListBox *box,
311 GListModel *model,
312 GtkListBoxCreateWidgetFunc create_widget_func,
313 gpointer user_data,
314 GDestroyNotify user_data_free_func);
315
316G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBox, g_object_unref)
317G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBoxRow, g_object_unref)
318
319G_END_DECLS
320
321#endif
322

source code of include/gtk-3.0/gtk/gtklistbox.h