1/*
2 * Copyright (C) 2010 Openismus GmbH
3 * Copyright (C) 2013 Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17
18 *
19 * Authors:
20 * Tristan Van Berkom <tristanvb@openismus.com>
21 * Matthias Clasen <mclasen@redhat.com>
22 * William Jon McCann <jmccann@redhat.com>
23 */
24
25#ifndef __GTK_FLOW_BOX_H__
26#define __GTK_FLOW_BOX_H__
27
28#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
29#error "Only <gtk/gtk.h> can be included directly."
30#endif
31
32#include <gtk/gtkbin.h>
33
34G_BEGIN_DECLS
35
36
37#define GTK_TYPE_FLOW_BOX (gtk_flow_box_get_type ())
38#define GTK_FLOW_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FLOW_BOX, GtkFlowBox))
39#define GTK_FLOW_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FLOW_BOX, GtkFlowBoxClass))
40#define GTK_IS_FLOW_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FLOW_BOX))
41#define GTK_IS_FLOW_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FLOW_BOX))
42#define GTK_FLOW_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FLOW_BOX, GtkFlowBoxClass))
43
44typedef struct _GtkFlowBox GtkFlowBox;
45typedef struct _GtkFlowBoxClass GtkFlowBoxClass;
46
47typedef struct _GtkFlowBoxChild GtkFlowBoxChild;
48typedef struct _GtkFlowBoxChildClass GtkFlowBoxChildClass;
49
50struct _GtkFlowBox
51{
52 GtkContainer container;
53};
54
55struct _GtkFlowBoxClass
56{
57 GtkContainerClass parent_class;
58
59 void (*child_activated) (GtkFlowBox *box,
60 GtkFlowBoxChild *child);
61 void (*selected_children_changed) (GtkFlowBox *box);
62 void (*activate_cursor_child) (GtkFlowBox *box);
63 void (*toggle_cursor_child) (GtkFlowBox *box);
64 gboolean (*move_cursor) (GtkFlowBox *box,
65 GtkMovementStep step,
66 gint count);
67 void (*select_all) (GtkFlowBox *box);
68 void (*unselect_all) (GtkFlowBox *box);
69
70 /* Padding for future expansion */
71 void (*_gtk_reserved1) (void);
72 void (*_gtk_reserved2) (void);
73 void (*_gtk_reserved3) (void);
74 void (*_gtk_reserved4) (void);
75 void (*_gtk_reserved5) (void);
76 void (*_gtk_reserved6) (void);
77};
78
79#define GTK_TYPE_FLOW_BOX_CHILD (gtk_flow_box_child_get_type ())
80#define GTK_FLOW_BOX_CHILD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FLOW_BOX_CHILD, GtkFlowBoxChild))
81#define GTK_FLOW_BOX_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FLOW_BOX_CHILD, GtkFlowBoxChildClass))
82#define GTK_IS_FLOW_BOX_CHILD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FLOW_BOX_CHILD))
83#define GTK_IS_FLOW_BOX_CHILD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FLOW_BOX_CHILD))
84#define GTK_FLOW_BOX_CHILD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EG_TYPE_FLOW_BOX_CHILD, GtkFlowBoxChildClass))
85
86struct _GtkFlowBoxChild
87{
88 GtkBin parent_instance;
89};
90
91struct _GtkFlowBoxChildClass
92{
93 GtkBinClass parent_class;
94
95 void (* activate) (GtkFlowBoxChild *child);
96
97 /* Padding for future expansion */
98 void (*_gtk_reserved1) (void);
99 void (*_gtk_reserved2) (void);
100};
101
102/**
103 * GtkFlowBoxCreateWidgetFunc:
104 * @item: (type GObject): the item from the model for which to create a widget for
105 * @user_data: (closure): user data from gtk_flow_box_bind_model()
106 *
107 * Called for flow boxes that are bound to a #GListModel with
108 * gtk_flow_box_bind_model() for each item that gets added to the model.
109 *
110 * Returns: (transfer full): a #GtkWidget that represents @item
111 *
112 * Since: 3.18
113 */
114typedef GtkWidget * (*GtkFlowBoxCreateWidgetFunc) (gpointer item,
115 gpointer user_data);
116
117GDK_AVAILABLE_IN_3_12
118GType gtk_flow_box_child_get_type (void) G_GNUC_CONST;
119GDK_AVAILABLE_IN_3_12
120GtkWidget* gtk_flow_box_child_new (void);
121GDK_AVAILABLE_IN_3_12
122gint gtk_flow_box_child_get_index (GtkFlowBoxChild *child);
123GDK_AVAILABLE_IN_3_12
124gboolean gtk_flow_box_child_is_selected (GtkFlowBoxChild *child);
125GDK_AVAILABLE_IN_3_12
126void gtk_flow_box_child_changed (GtkFlowBoxChild *child);
127
128
129GDK_AVAILABLE_IN_3_12
130GType gtk_flow_box_get_type (void) G_GNUC_CONST;
131
132GDK_AVAILABLE_IN_3_12
133GtkWidget *gtk_flow_box_new (void);
134
135GDK_AVAILABLE_IN_3_18
136void gtk_flow_box_bind_model (GtkFlowBox *box,
137 GListModel *model,
138 GtkFlowBoxCreateWidgetFunc create_widget_func,
139 gpointer user_data,
140 GDestroyNotify user_data_free_func);
141
142GDK_AVAILABLE_IN_3_12
143void gtk_flow_box_set_homogeneous (GtkFlowBox *box,
144 gboolean homogeneous);
145GDK_AVAILABLE_IN_3_12
146gboolean gtk_flow_box_get_homogeneous (GtkFlowBox *box);
147GDK_AVAILABLE_IN_3_12
148void gtk_flow_box_set_row_spacing (GtkFlowBox *box,
149 guint spacing);
150GDK_AVAILABLE_IN_3_12
151guint gtk_flow_box_get_row_spacing (GtkFlowBox *box);
152
153GDK_AVAILABLE_IN_3_12
154void gtk_flow_box_set_column_spacing (GtkFlowBox *box,
155 guint spacing);
156GDK_AVAILABLE_IN_3_12
157guint gtk_flow_box_get_column_spacing (GtkFlowBox *box);
158
159GDK_AVAILABLE_IN_3_12
160void gtk_flow_box_set_min_children_per_line (GtkFlowBox *box,
161 guint n_children);
162GDK_AVAILABLE_IN_3_12
163guint gtk_flow_box_get_min_children_per_line (GtkFlowBox *box);
164
165GDK_AVAILABLE_IN_3_12
166void gtk_flow_box_set_max_children_per_line (GtkFlowBox *box,
167 guint n_children);
168GDK_AVAILABLE_IN_3_12
169guint gtk_flow_box_get_max_children_per_line (GtkFlowBox *box);
170GDK_AVAILABLE_IN_3_12
171void gtk_flow_box_set_activate_on_single_click (GtkFlowBox *box,
172 gboolean single);
173GDK_AVAILABLE_IN_3_12
174gboolean gtk_flow_box_get_activate_on_single_click (GtkFlowBox *box);
175
176GDK_AVAILABLE_IN_3_12
177void gtk_flow_box_insert (GtkFlowBox *box,
178 GtkWidget *widget,
179 gint position);
180GDK_AVAILABLE_IN_3_12
181GtkFlowBoxChild *gtk_flow_box_get_child_at_index (GtkFlowBox *box,
182 gint idx);
183
184GDK_AVAILABLE_IN_3_22
185GtkFlowBoxChild *gtk_flow_box_get_child_at_pos (GtkFlowBox *box,
186 gint x,
187 gint y);
188
189typedef void (* GtkFlowBoxForeachFunc) (GtkFlowBox *box,
190 GtkFlowBoxChild *child,
191 gpointer user_data);
192
193GDK_AVAILABLE_IN_3_12
194void gtk_flow_box_selected_foreach (GtkFlowBox *box,
195 GtkFlowBoxForeachFunc func,
196 gpointer data);
197GDK_AVAILABLE_IN_3_12
198GList *gtk_flow_box_get_selected_children (GtkFlowBox *box);
199GDK_AVAILABLE_IN_3_12
200void gtk_flow_box_select_child (GtkFlowBox *box,
201 GtkFlowBoxChild *child);
202GDK_AVAILABLE_IN_3_12
203void gtk_flow_box_unselect_child (GtkFlowBox *box,
204 GtkFlowBoxChild *child);
205GDK_AVAILABLE_IN_3_12
206void gtk_flow_box_select_all (GtkFlowBox *box);
207GDK_AVAILABLE_IN_3_12
208void gtk_flow_box_unselect_all (GtkFlowBox *box);
209GDK_AVAILABLE_IN_3_12
210void gtk_flow_box_set_selection_mode (GtkFlowBox *box,
211 GtkSelectionMode mode);
212GDK_AVAILABLE_IN_3_12
213GtkSelectionMode gtk_flow_box_get_selection_mode (GtkFlowBox *box);
214GDK_AVAILABLE_IN_3_12
215void gtk_flow_box_set_hadjustment (GtkFlowBox *box,
216 GtkAdjustment *adjustment);
217GDK_AVAILABLE_IN_3_12
218void gtk_flow_box_set_vadjustment (GtkFlowBox *box,
219 GtkAdjustment *adjustment);
220
221typedef gboolean (*GtkFlowBoxFilterFunc) (GtkFlowBoxChild *child,
222 gpointer user_data);
223
224GDK_AVAILABLE_IN_3_12
225void gtk_flow_box_set_filter_func (GtkFlowBox *box,
226 GtkFlowBoxFilterFunc filter_func,
227 gpointer user_data,
228 GDestroyNotify destroy);
229GDK_AVAILABLE_IN_3_12
230void gtk_flow_box_invalidate_filter (GtkFlowBox *box);
231
232typedef gint (*GtkFlowBoxSortFunc) (GtkFlowBoxChild *child1,
233 GtkFlowBoxChild *child2,
234 gpointer user_data);
235
236GDK_AVAILABLE_IN_3_12
237void gtk_flow_box_set_sort_func (GtkFlowBox *box,
238 GtkFlowBoxSortFunc sort_func,
239 gpointer user_data,
240 GDestroyNotify destroy);
241GDK_AVAILABLE_IN_3_12
242void gtk_flow_box_invalidate_sort (GtkFlowBox *box);
243
244G_END_DECLS
245
246
247#endif /* __GTK_FLOW_BOX_H__ */
248