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
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_IS_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX))
37
38typedef struct _GtkListBox GtkListBox;
39typedef struct _GtkListBoxRow GtkListBoxRow;
40typedef 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
49struct _GtkListBoxRow
50{
51 GtkWidget parent_instance;
52};
53
54/**
55 * GtkListBoxRowClass:
56 * @parent_class: The parent class.
57 * @activate:
58 */
59struct _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 */
82typedef 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 */
96typedef 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 */
112typedef void (*GtkListBoxUpdateHeaderFunc) (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 */
129typedef GtkWidget * (*GtkListBoxCreateWidgetFunc) (gpointer item,
130 gpointer user_data);
131
132GDK_AVAILABLE_IN_ALL
133GType gtk_list_box_row_get_type (void) G_GNUC_CONST;
134GDK_AVAILABLE_IN_ALL
135GtkWidget* gtk_list_box_row_new (void);
136
137GDK_AVAILABLE_IN_ALL
138void gtk_list_box_row_set_child (GtkListBoxRow *row,
139 GtkWidget *child);
140GDK_AVAILABLE_IN_ALL
141GtkWidget *gtk_list_box_row_get_child (GtkListBoxRow *row);
142
143GDK_AVAILABLE_IN_ALL
144GtkWidget* gtk_list_box_row_get_header (GtkListBoxRow *row);
145GDK_AVAILABLE_IN_ALL
146void gtk_list_box_row_set_header (GtkListBoxRow *row,
147 GtkWidget *header);
148GDK_AVAILABLE_IN_ALL
149int gtk_list_box_row_get_index (GtkListBoxRow *row);
150GDK_AVAILABLE_IN_ALL
151void gtk_list_box_row_changed (GtkListBoxRow *row);
152
153GDK_AVAILABLE_IN_ALL
154gboolean gtk_list_box_row_is_selected (GtkListBoxRow *row);
155
156GDK_AVAILABLE_IN_ALL
157void gtk_list_box_row_set_selectable (GtkListBoxRow *row,
158 gboolean selectable);
159GDK_AVAILABLE_IN_ALL
160gboolean gtk_list_box_row_get_selectable (GtkListBoxRow *row);
161
162
163GDK_AVAILABLE_IN_ALL
164void gtk_list_box_row_set_activatable (GtkListBoxRow *row,
165 gboolean activatable);
166GDK_AVAILABLE_IN_ALL
167gboolean gtk_list_box_row_get_activatable (GtkListBoxRow *row);
168
169GDK_AVAILABLE_IN_ALL
170GType gtk_list_box_get_type (void) G_GNUC_CONST;
171GDK_AVAILABLE_IN_ALL
172void gtk_list_box_prepend (GtkListBox *box,
173 GtkWidget *child);
174GDK_AVAILABLE_IN_ALL
175void gtk_list_box_append (GtkListBox *box,
176 GtkWidget *child);
177GDK_AVAILABLE_IN_ALL
178void gtk_list_box_insert (GtkListBox *box,
179 GtkWidget *child,
180 int position);
181GDK_AVAILABLE_IN_ALL
182void gtk_list_box_remove (GtkListBox *box,
183 GtkWidget *child);
184GDK_AVAILABLE_IN_ALL
185GtkListBoxRow* gtk_list_box_get_selected_row (GtkListBox *box);
186GDK_AVAILABLE_IN_ALL
187GtkListBoxRow* gtk_list_box_get_row_at_index (GtkListBox *box,
188 int index_);
189GDK_AVAILABLE_IN_ALL
190GtkListBoxRow* gtk_list_box_get_row_at_y (GtkListBox *box,
191 int y);
192GDK_AVAILABLE_IN_ALL
193void gtk_list_box_select_row (GtkListBox *box,
194 GtkListBoxRow *row);
195GDK_AVAILABLE_IN_ALL
196void gtk_list_box_set_placeholder (GtkListBox *box,
197 GtkWidget *placeholder);
198GDK_AVAILABLE_IN_ALL
199void gtk_list_box_set_adjustment (GtkListBox *box,
200 GtkAdjustment *adjustment);
201GDK_AVAILABLE_IN_ALL
202GtkAdjustment *gtk_list_box_get_adjustment (GtkListBox *box);
203
204typedef void (* GtkListBoxForeachFunc) (GtkListBox *box,
205 GtkListBoxRow *row,
206 gpointer user_data);
207
208GDK_AVAILABLE_IN_ALL
209void gtk_list_box_selected_foreach (GtkListBox *box,
210 GtkListBoxForeachFunc func,
211 gpointer data);
212GDK_AVAILABLE_IN_ALL
213GList *gtk_list_box_get_selected_rows (GtkListBox *box);
214GDK_AVAILABLE_IN_ALL
215void gtk_list_box_unselect_row (GtkListBox *box,
216 GtkListBoxRow *row);
217GDK_AVAILABLE_IN_ALL
218void gtk_list_box_select_all (GtkListBox *box);
219GDK_AVAILABLE_IN_ALL
220void gtk_list_box_unselect_all (GtkListBox *box);
221
222GDK_AVAILABLE_IN_ALL
223void gtk_list_box_set_selection_mode (GtkListBox *box,
224 GtkSelectionMode mode);
225GDK_AVAILABLE_IN_ALL
226GtkSelectionMode gtk_list_box_get_selection_mode (GtkListBox *box);
227GDK_AVAILABLE_IN_ALL
228void gtk_list_box_set_filter_func (GtkListBox *box,
229 GtkListBoxFilterFunc filter_func,
230 gpointer user_data,
231 GDestroyNotify destroy);
232GDK_AVAILABLE_IN_ALL
233void gtk_list_box_set_header_func (GtkListBox *box,
234 GtkListBoxUpdateHeaderFunc update_header,
235 gpointer user_data,
236 GDestroyNotify destroy);
237GDK_AVAILABLE_IN_ALL
238void gtk_list_box_invalidate_filter (GtkListBox *box);
239GDK_AVAILABLE_IN_ALL
240void gtk_list_box_invalidate_sort (GtkListBox *box);
241GDK_AVAILABLE_IN_ALL
242void gtk_list_box_invalidate_headers (GtkListBox *box);
243GDK_AVAILABLE_IN_ALL
244void gtk_list_box_set_sort_func (GtkListBox *box,
245 GtkListBoxSortFunc sort_func,
246 gpointer user_data,
247 GDestroyNotify destroy);
248GDK_AVAILABLE_IN_ALL
249void gtk_list_box_set_activate_on_single_click (GtkListBox *box,
250 gboolean single);
251GDK_AVAILABLE_IN_ALL
252gboolean gtk_list_box_get_activate_on_single_click (GtkListBox *box);
253GDK_AVAILABLE_IN_ALL
254void gtk_list_box_drag_unhighlight_row (GtkListBox *box);
255GDK_AVAILABLE_IN_ALL
256void gtk_list_box_drag_highlight_row (GtkListBox *box,
257 GtkListBoxRow *row);
258GDK_AVAILABLE_IN_ALL
259GtkWidget* gtk_list_box_new (void);
260
261
262GDK_AVAILABLE_IN_ALL
263void 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
269GDK_AVAILABLE_IN_ALL
270void gtk_list_box_set_show_separators (GtkListBox *box,
271 gboolean show_separators);
272GDK_AVAILABLE_IN_ALL
273gboolean gtk_list_box_get_show_separators (GtkListBox *box);
274
275G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBox, g_object_unref)
276G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBoxRow, g_object_unref)
277
278G_END_DECLS
279
280#endif
281

source code of gtk/gtk/gtklistbox.h