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 34 G_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 44 typedef struct _GtkFlowBox GtkFlowBox; 45 typedef struct _GtkFlowBoxClass GtkFlowBoxClass; 46 47 typedef struct _GtkFlowBoxChild GtkFlowBoxChild; 48 typedef struct _GtkFlowBoxChildClass GtkFlowBoxChildClass; 49 50 struct _GtkFlowBox 51 { 52 GtkContainer container; 53 }; 54 55 struct _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 86 struct _GtkFlowBoxChild 87 { 88 GtkBin parent_instance; 89 }; 90 91 struct _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 */ 114 typedef GtkWidget * (*GtkFlowBoxCreateWidgetFunc) (gpointer item, 115 gpointer user_data); 116 117 GDK_AVAILABLE_IN_3_12 118 GType gtk_flow_box_child_get_type (void) G_GNUC_CONST; 119 GDK_AVAILABLE_IN_3_12 120 GtkWidget* gtk_flow_box_child_new (void); 121 GDK_AVAILABLE_IN_3_12 122 gint gtk_flow_box_child_get_index (GtkFlowBoxChild *child); 123 GDK_AVAILABLE_IN_3_12 124 gboolean gtk_flow_box_child_is_selected (GtkFlowBoxChild *child); 125 GDK_AVAILABLE_IN_3_12 126 void gtk_flow_box_child_changed (GtkFlowBoxChild *child); 127 128 129 GDK_AVAILABLE_IN_3_12 130 GType gtk_flow_box_get_type (void) G_GNUC_CONST; 131 132 GDK_AVAILABLE_IN_3_12 133 GtkWidget *gtk_flow_box_new (void); 134 135 GDK_AVAILABLE_IN_3_18 136 void 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 142 GDK_AVAILABLE_IN_3_12 143 void gtk_flow_box_set_homogeneous (GtkFlowBox *box, 144 gboolean homogeneous); 145 GDK_AVAILABLE_IN_3_12 146 gboolean gtk_flow_box_get_homogeneous (GtkFlowBox *box); 147 GDK_AVAILABLE_IN_3_12 148 void gtk_flow_box_set_row_spacing (GtkFlowBox *box, 149 guint spacing); 150 GDK_AVAILABLE_IN_3_12 151 guint gtk_flow_box_get_row_spacing (GtkFlowBox *box); 152 153 GDK_AVAILABLE_IN_3_12 154 void gtk_flow_box_set_column_spacing (GtkFlowBox *box, 155 guint spacing); 156 GDK_AVAILABLE_IN_3_12 157 guint gtk_flow_box_get_column_spacing (GtkFlowBox *box); 158 159 GDK_AVAILABLE_IN_3_12 160 void gtk_flow_box_set_min_children_per_line (GtkFlowBox *box, 161 guint n_children); 162 GDK_AVAILABLE_IN_3_12 163 guint gtk_flow_box_get_min_children_per_line (GtkFlowBox *box); 164 165 GDK_AVAILABLE_IN_3_12 166 void gtk_flow_box_set_max_children_per_line (GtkFlowBox *box, 167 guint n_children); 168 GDK_AVAILABLE_IN_3_12 169 guint gtk_flow_box_get_max_children_per_line (GtkFlowBox *box); 170 GDK_AVAILABLE_IN_3_12 171 void gtk_flow_box_set_activate_on_single_click (GtkFlowBox *box, 172 gboolean single); 173 GDK_AVAILABLE_IN_3_12 174 gboolean gtk_flow_box_get_activate_on_single_click (GtkFlowBox *box); 175 176 GDK_AVAILABLE_IN_3_12 177 void gtk_flow_box_insert (GtkFlowBox *box, 178 GtkWidget *widget, 179 gint position); 180 GDK_AVAILABLE_IN_3_12 181 GtkFlowBoxChild *gtk_flow_box_get_child_at_index (GtkFlowBox *box, 182 gint idx); 183 184 GDK_AVAILABLE_IN_3_22 185 GtkFlowBoxChild *gtk_flow_box_get_child_at_pos (GtkFlowBox *box, 186 gint x, 187 gint y); 188 189 typedef void (* GtkFlowBoxForeachFunc) (GtkFlowBox *box, 190 GtkFlowBoxChild *child, 191 gpointer user_data); 192 193 GDK_AVAILABLE_IN_3_12 194 void gtk_flow_box_selected_foreach (GtkFlowBox *box, 195 GtkFlowBoxForeachFunc func, 196 gpointer data); 197 GDK_AVAILABLE_IN_3_12 198 GList *gtk_flow_box_get_selected_children (GtkFlowBox *box); 199 GDK_AVAILABLE_IN_3_12 200 void gtk_flow_box_select_child (GtkFlowBox *box, 201 GtkFlowBoxChild *child); 202 GDK_AVAILABLE_IN_3_12 203 void gtk_flow_box_unselect_child (GtkFlowBox *box, 204 GtkFlowBoxChild *child); 205 GDK_AVAILABLE_IN_3_12 206 void gtk_flow_box_select_all (GtkFlowBox *box); 207 GDK_AVAILABLE_IN_3_12 208 void gtk_flow_box_unselect_all (GtkFlowBox *box); 209 GDK_AVAILABLE_IN_3_12 210 void gtk_flow_box_set_selection_mode (GtkFlowBox *box, 211 GtkSelectionMode mode); 212 GDK_AVAILABLE_IN_3_12 213 GtkSelectionMode gtk_flow_box_get_selection_mode (GtkFlowBox *box); 214 GDK_AVAILABLE_IN_3_12 215 void gtk_flow_box_set_hadjustment (GtkFlowBox *box, 216 GtkAdjustment *adjustment); 217 GDK_AVAILABLE_IN_3_12 218 void gtk_flow_box_set_vadjustment (GtkFlowBox *box, 219 GtkAdjustment *adjustment); 220 221 typedef gboolean (*GtkFlowBoxFilterFunc) (GtkFlowBoxChild *child, 222 gpointer user_data); 223 224 GDK_AVAILABLE_IN_3_12 225 void gtk_flow_box_set_filter_func (GtkFlowBox *box, 226 GtkFlowBoxFilterFunc filter_func, 227 gpointer user_data, 228 GDestroyNotify destroy); 229 GDK_AVAILABLE_IN_3_12 230 void gtk_flow_box_invalidate_filter (GtkFlowBox *box); 231 232 typedef gint (*GtkFlowBoxSortFunc) (GtkFlowBoxChild *child1, 233 GtkFlowBoxChild *child2, 234 gpointer user_data); 235 236 GDK_AVAILABLE_IN_3_12 237 void gtk_flow_box_set_sort_func (GtkFlowBox *box, 238 GtkFlowBoxSortFunc sort_func, 239 gpointer user_data, 240 GDestroyNotify destroy); 241 GDK_AVAILABLE_IN_3_12 242 void gtk_flow_box_invalidate_sort (GtkFlowBox *box); 243 244 G_END_DECLS 245 246 247 #endif /* __GTK_FLOW_BOX_H__ */ 248