File: | ctk/ctkiconview.c |
Warning: | line 3590, column 16 Access of 'int' element in the heap area at index 1 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* ctkiconview.c | |||
2 | * Copyright (C) 2002, 2004 Anders Carlsson <andersca@gnu.org> | |||
3 | * | |||
4 | * This library is free software; you can redistribute it and/or | |||
5 | * modify it under the terms of the GNU Library General Public | |||
6 | * License as published by the Free Software Foundation; either | |||
7 | * version 2 of the License, or (at your option) any later version. | |||
8 | * | |||
9 | * This library is distributed in the hope that it will be useful, | |||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
12 | * Library General Public License for more details. | |||
13 | * | |||
14 | * You should have received a copy of the GNU Library General Public | |||
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
16 | */ | |||
17 | ||||
18 | #include "config.h" | |||
19 | ||||
20 | #include <string.h> | |||
21 | ||||
22 | #include "ctkiconview.h" | |||
23 | #include "ctkiconviewprivate.h" | |||
24 | ||||
25 | #include "ctkadjustmentprivate.h" | |||
26 | #include "ctkcelllayout.h" | |||
27 | #include "ctkcellrenderer.h" | |||
28 | #include "ctkcellareabox.h" | |||
29 | #include "ctkcellareacontext.h" | |||
30 | #include "ctkcellrenderertext.h" | |||
31 | #include "ctkcellrendererpixbuf.h" | |||
32 | #include "ctkorientable.h" | |||
33 | #include "ctkmarshalers.h" | |||
34 | #include "ctkbindings.h" | |||
35 | #include "ctkdnd.h" | |||
36 | #include "ctkmain.h" | |||
37 | #include "ctkintl.h" | |||
38 | #include "ctkaccessible.h" | |||
39 | #include "ctkwindow.h" | |||
40 | #include "ctkentry.h" | |||
41 | #include "ctkcombobox.h" | |||
42 | #include "ctkscrollable.h" | |||
43 | #include "ctksizerequest.h" | |||
44 | #include "ctktreednd.h" | |||
45 | #include "ctktypebuiltins.h" | |||
46 | #include "ctkprivate.h" | |||
47 | #include "ctkcssnodeprivate.h" | |||
48 | #include "ctkwidgetprivate.h" | |||
49 | #include "ctkstylecontextprivate.h" | |||
50 | #include "a11y/ctkiconviewaccessibleprivate.h" | |||
51 | ||||
52 | /** | |||
53 | * SECTION:ctkiconview | |||
54 | * @title: CtkIconView | |||
55 | * @short_description: A widget which displays a list of icons in a grid | |||
56 | * | |||
57 | * #CtkIconView provides an alternative view on a #CtkTreeModel. | |||
58 | * It displays the model as a grid of icons with labels. Like | |||
59 | * #CtkTreeView, it allows to select one or multiple items | |||
60 | * (depending on the selection mode, see ctk_icon_view_set_selection_mode()). | |||
61 | * In addition to selection with the arrow keys, #CtkIconView supports | |||
62 | * rubberband selection, which is controlled by dragging the pointer. | |||
63 | * | |||
64 | * Note that if the tree model is backed by an actual tree store (as | |||
65 | * opposed to a flat list where the mapping to icons is obvious), | |||
66 | * #CtkIconView will only display the first level of the tree and | |||
67 | * ignore the tree’s branches. | |||
68 | * | |||
69 | * # CSS nodes | |||
70 | * | |||
71 | * |[<!-- language="plain" --> | |||
72 | * iconview.view | |||
73 | * ╰── [rubberband] | |||
74 | * ]| | |||
75 | * | |||
76 | * CtkIconView has a single CSS node with name iconview and style class .view. | |||
77 | * For rubberband selection, a subnode with name rubberband is used. | |||
78 | */ | |||
79 | ||||
80 | #define SCROLL_EDGE_SIZE15 15 | |||
81 | ||||
82 | typedef struct _CtkIconViewChild CtkIconViewChild; | |||
83 | struct _CtkIconViewChild | |||
84 | { | |||
85 | CtkWidget *widget; | |||
86 | CdkRectangle area; | |||
87 | }; | |||
88 | ||||
89 | /* Signals */ | |||
90 | enum | |||
91 | { | |||
92 | ITEM_ACTIVATED, | |||
93 | SELECTION_CHANGED, | |||
94 | SELECT_ALL, | |||
95 | UNSELECT_ALL, | |||
96 | SELECT_CURSOR_ITEM, | |||
97 | TOGGLE_CURSOR_ITEM, | |||
98 | MOVE_CURSOR, | |||
99 | ACTIVATE_CURSOR_ITEM, | |||
100 | LAST_SIGNAL | |||
101 | }; | |||
102 | ||||
103 | /* Properties */ | |||
104 | enum | |||
105 | { | |||
106 | PROP_0, | |||
107 | PROP_PIXBUF_COLUMN, | |||
108 | PROP_TEXT_COLUMN, | |||
109 | PROP_MARKUP_COLUMN, | |||
110 | PROP_SELECTION_MODE, | |||
111 | PROP_ITEM_ORIENTATION, | |||
112 | PROP_MODEL, | |||
113 | PROP_COLUMNS, | |||
114 | PROP_ITEM_WIDTH, | |||
115 | PROP_SPACING, | |||
116 | PROP_ROW_SPACING, | |||
117 | PROP_COLUMN_SPACING, | |||
118 | PROP_MARGIN, | |||
119 | PROP_REORDERABLE, | |||
120 | PROP_TOOLTIP_COLUMN, | |||
121 | PROP_ITEM_PADDING, | |||
122 | PROP_CELL_AREA, | |||
123 | PROP_HADJUSTMENT, | |||
124 | PROP_VADJUSTMENT, | |||
125 | PROP_HSCROLL_POLICY, | |||
126 | PROP_VSCROLL_POLICY, | |||
127 | PROP_ACTIVATE_ON_SINGLE_CLICK | |||
128 | }; | |||
129 | ||||
130 | /* GObject vfuncs */ | |||
131 | static void ctk_icon_view_cell_layout_init (CtkCellLayoutIface *iface); | |||
132 | static void ctk_icon_view_dispose (GObject *object); | |||
133 | static void ctk_icon_view_constructed (GObject *object); | |||
134 | static void ctk_icon_view_set_property (GObject *object, | |||
135 | guint prop_id, | |||
136 | const GValue *value, | |||
137 | GParamSpec *pspec); | |||
138 | static void ctk_icon_view_get_property (GObject *object, | |||
139 | guint prop_id, | |||
140 | GValue *value, | |||
141 | GParamSpec *pspec); | |||
142 | /* CtkWidget vfuncs */ | |||
143 | static void ctk_icon_view_destroy (CtkWidget *widget); | |||
144 | static void ctk_icon_view_realize (CtkWidget *widget); | |||
145 | static void ctk_icon_view_unrealize (CtkWidget *widget); | |||
146 | static CtkSizeRequestMode ctk_icon_view_get_request_mode (CtkWidget *widget); | |||
147 | static void ctk_icon_view_get_preferred_width (CtkWidget *widget, | |||
148 | gint *minimum, | |||
149 | gint *natural); | |||
150 | static void ctk_icon_view_get_preferred_width_for_height | |||
151 | (CtkWidget *widget, | |||
152 | gint height, | |||
153 | gint *minimum, | |||
154 | gint *natural); | |||
155 | static void ctk_icon_view_get_preferred_height (CtkWidget *widget, | |||
156 | gint *minimum, | |||
157 | gint *natural); | |||
158 | static void ctk_icon_view_get_preferred_height_for_width | |||
159 | (CtkWidget *widget, | |||
160 | gint width, | |||
161 | gint *minimum, | |||
162 | gint *natural); | |||
163 | static void ctk_icon_view_size_allocate (CtkWidget *widget, | |||
164 | CtkAllocation *allocation); | |||
165 | static gboolean ctk_icon_view_draw (CtkWidget *widget, | |||
166 | cairo_t *cr); | |||
167 | static gboolean ctk_icon_view_motion (CtkWidget *widget, | |||
168 | CdkEventMotion *event); | |||
169 | static gboolean ctk_icon_view_leave (CtkWidget *widget, | |||
170 | CdkEventCrossing *event); | |||
171 | static gboolean ctk_icon_view_button_press (CtkWidget *widget, | |||
172 | CdkEventButton *event); | |||
173 | static gboolean ctk_icon_view_button_release (CtkWidget *widget, | |||
174 | CdkEventButton *event); | |||
175 | static gboolean ctk_icon_view_key_press (CtkWidget *widget, | |||
176 | CdkEventKey *event); | |||
177 | static gboolean ctk_icon_view_key_release (CtkWidget *widget, | |||
178 | CdkEventKey *event); | |||
179 | ||||
180 | ||||
181 | /* CtkContainer vfuncs */ | |||
182 | static void ctk_icon_view_remove (CtkContainer *container, | |||
183 | CtkWidget *widget); | |||
184 | static void ctk_icon_view_forall (CtkContainer *container, | |||
185 | gboolean include_internals, | |||
186 | CtkCallback callback, | |||
187 | gpointer callback_data); | |||
188 | ||||
189 | /* CtkIconView vfuncs */ | |||
190 | static void ctk_icon_view_real_select_all (CtkIconView *icon_view); | |||
191 | static void ctk_icon_view_real_unselect_all (CtkIconView *icon_view); | |||
192 | static void ctk_icon_view_real_select_cursor_item (CtkIconView *icon_view); | |||
193 | static void ctk_icon_view_real_toggle_cursor_item (CtkIconView *icon_view); | |||
194 | static gboolean ctk_icon_view_real_activate_cursor_item (CtkIconView *icon_view); | |||
195 | ||||
196 | /* Internal functions */ | |||
197 | static void ctk_icon_view_set_hadjustment_values (CtkIconView *icon_view); | |||
198 | static void ctk_icon_view_set_vadjustment_values (CtkIconView *icon_view); | |||
199 | static void ctk_icon_view_set_hadjustment (CtkIconView *icon_view, | |||
200 | CtkAdjustment *adjustment); | |||
201 | static void ctk_icon_view_set_vadjustment (CtkIconView *icon_view, | |||
202 | CtkAdjustment *adjustment); | |||
203 | static void ctk_icon_view_adjustment_changed (CtkAdjustment *adjustment, | |||
204 | CtkIconView *icon_view); | |||
205 | static void ctk_icon_view_layout (CtkIconView *icon_view); | |||
206 | static void ctk_icon_view_paint_item (CtkIconView *icon_view, | |||
207 | cairo_t *cr, | |||
208 | CtkIconViewItem *item, | |||
209 | gint x, | |||
210 | gint y, | |||
211 | gboolean draw_focus); | |||
212 | static void ctk_icon_view_paint_rubberband (CtkIconView *icon_view, | |||
213 | cairo_t *cr); | |||
214 | static void ctk_icon_view_queue_draw_path (CtkIconView *icon_view, | |||
215 | CtkTreePath *path); | |||
216 | static void ctk_icon_view_queue_draw_item (CtkIconView *icon_view, | |||
217 | CtkIconViewItem *item); | |||
218 | static void ctk_icon_view_start_rubberbanding (CtkIconView *icon_view, | |||
219 | CdkDevice *device, | |||
220 | gint x, | |||
221 | gint y); | |||
222 | static void ctk_icon_view_stop_rubberbanding (CtkIconView *icon_view); | |||
223 | static void ctk_icon_view_update_rubberband_selection (CtkIconView *icon_view); | |||
224 | static gboolean ctk_icon_view_item_hit_test (CtkIconView *icon_view, | |||
225 | CtkIconViewItem *item, | |||
226 | gint x, | |||
227 | gint y, | |||
228 | gint width, | |||
229 | gint height); | |||
230 | static gboolean ctk_icon_view_unselect_all_internal (CtkIconView *icon_view); | |||
231 | static void ctk_icon_view_update_rubberband (gpointer data); | |||
232 | static void ctk_icon_view_item_invalidate_size (CtkIconViewItem *item); | |||
233 | static void ctk_icon_view_invalidate_sizes (CtkIconView *icon_view); | |||
234 | static void ctk_icon_view_add_move_binding (CtkBindingSet *binding_set, | |||
235 | guint keyval, | |||
236 | guint modmask, | |||
237 | CtkMovementStep step, | |||
238 | gint count); | |||
239 | static gboolean ctk_icon_view_real_move_cursor (CtkIconView *icon_view, | |||
240 | CtkMovementStep step, | |||
241 | gint count); | |||
242 | static void ctk_icon_view_move_cursor_up_down (CtkIconView *icon_view, | |||
243 | gint count); | |||
244 | static void ctk_icon_view_move_cursor_page_up_down (CtkIconView *icon_view, | |||
245 | gint count); | |||
246 | static void ctk_icon_view_move_cursor_left_right (CtkIconView *icon_view, | |||
247 | gint count); | |||
248 | static void ctk_icon_view_move_cursor_start_end (CtkIconView *icon_view, | |||
249 | gint count); | |||
250 | static void ctk_icon_view_scroll_to_item (CtkIconView *icon_view, | |||
251 | CtkIconViewItem *item); | |||
252 | static gboolean ctk_icon_view_select_all_between (CtkIconView *icon_view, | |||
253 | CtkIconViewItem *anchor, | |||
254 | CtkIconViewItem *cursor); | |||
255 | ||||
256 | static void ctk_icon_view_ensure_cell_area (CtkIconView *icon_view, | |||
257 | CtkCellArea *cell_area); | |||
258 | ||||
259 | static CtkCellArea *ctk_icon_view_cell_layout_get_area (CtkCellLayout *layout); | |||
260 | ||||
261 | static void ctk_icon_view_item_selected_changed (CtkIconView *icon_view, | |||
262 | CtkIconViewItem *item); | |||
263 | ||||
264 | static void ctk_icon_view_add_editable (CtkCellArea *area, | |||
265 | CtkCellRenderer *renderer, | |||
266 | CtkCellEditable *editable, | |||
267 | CdkRectangle *cell_area, | |||
268 | const gchar *path, | |||
269 | CtkIconView *icon_view); | |||
270 | static void ctk_icon_view_remove_editable (CtkCellArea *area, | |||
271 | CtkCellRenderer *renderer, | |||
272 | CtkCellEditable *editable, | |||
273 | CtkIconView *icon_view); | |||
274 | static void update_text_cell (CtkIconView *icon_view); | |||
275 | static void update_pixbuf_cell (CtkIconView *icon_view); | |||
276 | ||||
277 | /* Source side drag signals */ | |||
278 | static void ctk_icon_view_drag_begin (CtkWidget *widget, | |||
279 | CdkDragContext *context); | |||
280 | static void ctk_icon_view_drag_end (CtkWidget *widget, | |||
281 | CdkDragContext *context); | |||
282 | static void ctk_icon_view_drag_data_get (CtkWidget *widget, | |||
283 | CdkDragContext *context, | |||
284 | CtkSelectionData *selection_data, | |||
285 | guint info, | |||
286 | guint time); | |||
287 | static void ctk_icon_view_drag_data_delete (CtkWidget *widget, | |||
288 | CdkDragContext *context); | |||
289 | ||||
290 | /* Target side drag signals */ | |||
291 | static void ctk_icon_view_drag_leave (CtkWidget *widget, | |||
292 | CdkDragContext *context, | |||
293 | guint time); | |||
294 | static gboolean ctk_icon_view_drag_motion (CtkWidget *widget, | |||
295 | CdkDragContext *context, | |||
296 | gint x, | |||
297 | gint y, | |||
298 | guint time); | |||
299 | static gboolean ctk_icon_view_drag_drop (CtkWidget *widget, | |||
300 | CdkDragContext *context, | |||
301 | gint x, | |||
302 | gint y, | |||
303 | guint time); | |||
304 | static void ctk_icon_view_drag_data_received (CtkWidget *widget, | |||
305 | CdkDragContext *context, | |||
306 | gint x, | |||
307 | gint y, | |||
308 | CtkSelectionData *selection_data, | |||
309 | guint info, | |||
310 | guint time); | |||
311 | static gboolean ctk_icon_view_maybe_begin_drag (CtkIconView *icon_view, | |||
312 | CdkEventMotion *event); | |||
313 | ||||
314 | static void remove_scroll_timeout (CtkIconView *icon_view); | |||
315 | ||||
316 | /* CtkBuildable */ | |||
317 | static CtkBuildableIface *parent_buildable_iface; | |||
318 | static void ctk_icon_view_buildable_init (CtkBuildableIface *iface); | |||
319 | static gboolean ctk_icon_view_buildable_custom_tag_start (CtkBuildable *buildable, | |||
320 | CtkBuilder *builder, | |||
321 | GObject *child, | |||
322 | const gchar *tagname, | |||
323 | GMarkupParser *parser, | |||
324 | gpointer *data); | |||
325 | static void ctk_icon_view_buildable_custom_tag_end (CtkBuildable *buildable, | |||
326 | CtkBuilder *builder, | |||
327 | GObject *child, | |||
328 | const gchar *tagname, | |||
329 | gpointer *data); | |||
330 | ||||
331 | static guint icon_view_signals[LAST_SIGNAL] = { 0 }; | |||
332 | ||||
333 | G_DEFINE_TYPE_WITH_CODE (CtkIconView, ctk_icon_view, CTK_TYPE_CONTAINER,static void ctk_icon_view_init (CtkIconView *self); static void ctk_icon_view_class_init (CtkIconViewClass *klass); static GType ctk_icon_view_get_type_once (void); static gpointer ctk_icon_view_parent_class = ((void*)0); static gint CtkIconView_private_offset; static void ctk_icon_view_class_intern_init (gpointer klass) { ctk_icon_view_parent_class = g_type_class_peek_parent (klass); if (CtkIconView_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkIconView_private_offset ); ctk_icon_view_class_init ((CtkIconViewClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_icon_view_get_instance_private (CtkIconView *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkIconView_private_offset)))); } GType ctk_icon_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_icon_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_icon_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkIconView" ), sizeof (CtkIconViewClass), (GClassInitFunc)(void (*)(void) ) ctk_icon_view_class_intern_init, sizeof (CtkIconView), (GInstanceInitFunc )(void (*)(void)) ctk_icon_view_init, (GTypeFlags) 0); { {{ CtkIconView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkIconViewPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_icon_view_cell_layout_init , ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_layout_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_icon_view_buildable_init, ((void*)0), ( (void*)0) }; g_type_add_interface_static (g_define_type_id, ( ctk_buildable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
334 | G_ADD_PRIVATE (CtkIconView)static void ctk_icon_view_init (CtkIconView *self); static void ctk_icon_view_class_init (CtkIconViewClass *klass); static GType ctk_icon_view_get_type_once (void); static gpointer ctk_icon_view_parent_class = ((void*)0); static gint CtkIconView_private_offset; static void ctk_icon_view_class_intern_init (gpointer klass) { ctk_icon_view_parent_class = g_type_class_peek_parent (klass); if (CtkIconView_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkIconView_private_offset ); ctk_icon_view_class_init ((CtkIconViewClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_icon_view_get_instance_private (CtkIconView *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkIconView_private_offset)))); } GType ctk_icon_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_icon_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_icon_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkIconView" ), sizeof (CtkIconViewClass), (GClassInitFunc)(void (*)(void) ) ctk_icon_view_class_intern_init, sizeof (CtkIconView), (GInstanceInitFunc )(void (*)(void)) ctk_icon_view_init, (GTypeFlags) 0); { {{ CtkIconView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkIconViewPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_icon_view_cell_layout_init , ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_layout_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_icon_view_buildable_init, ((void*)0), ( (void*)0) }; g_type_add_interface_static (g_define_type_id, ( ctk_buildable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
335 | G_IMPLEMENT_INTERFACE (CTK_TYPE_CELL_LAYOUT,static void ctk_icon_view_init (CtkIconView *self); static void ctk_icon_view_class_init (CtkIconViewClass *klass); static GType ctk_icon_view_get_type_once (void); static gpointer ctk_icon_view_parent_class = ((void*)0); static gint CtkIconView_private_offset; static void ctk_icon_view_class_intern_init (gpointer klass) { ctk_icon_view_parent_class = g_type_class_peek_parent (klass); if (CtkIconView_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkIconView_private_offset ); ctk_icon_view_class_init ((CtkIconViewClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_icon_view_get_instance_private (CtkIconView *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkIconView_private_offset)))); } GType ctk_icon_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_icon_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_icon_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkIconView" ), sizeof (CtkIconViewClass), (GClassInitFunc)(void (*)(void) ) ctk_icon_view_class_intern_init, sizeof (CtkIconView), (GInstanceInitFunc )(void (*)(void)) ctk_icon_view_init, (GTypeFlags) 0); { {{ CtkIconView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkIconViewPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_icon_view_cell_layout_init , ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_layout_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_icon_view_buildable_init, ((void*)0), ( (void*)0) }; g_type_add_interface_static (g_define_type_id, ( ctk_buildable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
336 | ctk_icon_view_cell_layout_init)static void ctk_icon_view_init (CtkIconView *self); static void ctk_icon_view_class_init (CtkIconViewClass *klass); static GType ctk_icon_view_get_type_once (void); static gpointer ctk_icon_view_parent_class = ((void*)0); static gint CtkIconView_private_offset; static void ctk_icon_view_class_intern_init (gpointer klass) { ctk_icon_view_parent_class = g_type_class_peek_parent (klass); if (CtkIconView_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkIconView_private_offset ); ctk_icon_view_class_init ((CtkIconViewClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_icon_view_get_instance_private (CtkIconView *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkIconView_private_offset)))); } GType ctk_icon_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_icon_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_icon_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkIconView" ), sizeof (CtkIconViewClass), (GClassInitFunc)(void (*)(void) ) ctk_icon_view_class_intern_init, sizeof (CtkIconView), (GInstanceInitFunc )(void (*)(void)) ctk_icon_view_init, (GTypeFlags) 0); { {{ CtkIconView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkIconViewPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_icon_view_cell_layout_init , ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_layout_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_icon_view_buildable_init, ((void*)0), ( (void*)0) }; g_type_add_interface_static (g_define_type_id, ( ctk_buildable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
337 | G_IMPLEMENT_INTERFACE (CTK_TYPE_BUILDABLE,static void ctk_icon_view_init (CtkIconView *self); static void ctk_icon_view_class_init (CtkIconViewClass *klass); static GType ctk_icon_view_get_type_once (void); static gpointer ctk_icon_view_parent_class = ((void*)0); static gint CtkIconView_private_offset; static void ctk_icon_view_class_intern_init (gpointer klass) { ctk_icon_view_parent_class = g_type_class_peek_parent (klass); if (CtkIconView_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkIconView_private_offset ); ctk_icon_view_class_init ((CtkIconViewClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_icon_view_get_instance_private (CtkIconView *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkIconView_private_offset)))); } GType ctk_icon_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_icon_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_icon_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkIconView" ), sizeof (CtkIconViewClass), (GClassInitFunc)(void (*)(void) ) ctk_icon_view_class_intern_init, sizeof (CtkIconView), (GInstanceInitFunc )(void (*)(void)) ctk_icon_view_init, (GTypeFlags) 0); { {{ CtkIconView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkIconViewPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_icon_view_cell_layout_init , ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_layout_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_icon_view_buildable_init, ((void*)0), ( (void*)0) }; g_type_add_interface_static (g_define_type_id, ( ctk_buildable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
338 | ctk_icon_view_buildable_init)static void ctk_icon_view_init (CtkIconView *self); static void ctk_icon_view_class_init (CtkIconViewClass *klass); static GType ctk_icon_view_get_type_once (void); static gpointer ctk_icon_view_parent_class = ((void*)0); static gint CtkIconView_private_offset; static void ctk_icon_view_class_intern_init (gpointer klass) { ctk_icon_view_parent_class = g_type_class_peek_parent (klass); if (CtkIconView_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkIconView_private_offset ); ctk_icon_view_class_init ((CtkIconViewClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_icon_view_get_instance_private (CtkIconView *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkIconView_private_offset)))); } GType ctk_icon_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_icon_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_icon_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkIconView" ), sizeof (CtkIconViewClass), (GClassInitFunc)(void (*)(void) ) ctk_icon_view_class_intern_init, sizeof (CtkIconView), (GInstanceInitFunc )(void (*)(void)) ctk_icon_view_init, (GTypeFlags) 0); { {{ CtkIconView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkIconViewPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_icon_view_cell_layout_init , ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_layout_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_icon_view_buildable_init, ((void*)0), ( (void*)0) }; g_type_add_interface_static (g_define_type_id, ( ctk_buildable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
339 | G_IMPLEMENT_INTERFACE (CTK_TYPE_SCROLLABLE, NULL))static void ctk_icon_view_init (CtkIconView *self); static void ctk_icon_view_class_init (CtkIconViewClass *klass); static GType ctk_icon_view_get_type_once (void); static gpointer ctk_icon_view_parent_class = ((void*)0); static gint CtkIconView_private_offset; static void ctk_icon_view_class_intern_init (gpointer klass) { ctk_icon_view_parent_class = g_type_class_peek_parent (klass); if (CtkIconView_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkIconView_private_offset ); ctk_icon_view_class_init ((CtkIconViewClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_icon_view_get_instance_private (CtkIconView *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkIconView_private_offset)))); } GType ctk_icon_view_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_icon_view_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_icon_view_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkIconView" ), sizeof (CtkIconViewClass), (GClassInitFunc)(void (*)(void) ) ctk_icon_view_class_intern_init, sizeof (CtkIconView), (GInstanceInitFunc )(void (*)(void)) ctk_icon_view_init, (GTypeFlags) 0); { {{ CtkIconView_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkIconViewPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_icon_view_cell_layout_init , ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_layout_get_type ()), &g_implement_interface_info ); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_icon_view_buildable_init, ((void*)0), ( (void*)0) }; g_type_add_interface_static (g_define_type_id, ( ctk_buildable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_scrollable_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
340 | ||||
341 | static void | |||
342 | ctk_icon_view_class_init (CtkIconViewClass *klass) | |||
343 | { | |||
344 | GObjectClass *gobject_class; | |||
345 | CtkWidgetClass *widget_class; | |||
346 | CtkContainerClass *container_class; | |||
347 | CtkBindingSet *binding_set; | |||
348 | ||||
349 | binding_set = ctk_binding_set_by_class (klass); | |||
350 | ||||
351 | gobject_class = (GObjectClass *) klass; | |||
352 | widget_class = (CtkWidgetClass *) klass; | |||
353 | container_class = (CtkContainerClass *) klass; | |||
354 | ||||
355 | gobject_class->constructed = ctk_icon_view_constructed; | |||
356 | gobject_class->dispose = ctk_icon_view_dispose; | |||
357 | gobject_class->set_property = ctk_icon_view_set_property; | |||
358 | gobject_class->get_property = ctk_icon_view_get_property; | |||
359 | ||||
360 | widget_class->destroy = ctk_icon_view_destroy; | |||
361 | widget_class->realize = ctk_icon_view_realize; | |||
362 | widget_class->unrealize = ctk_icon_view_unrealize; | |||
363 | widget_class->get_request_mode = ctk_icon_view_get_request_mode; | |||
364 | widget_class->get_preferred_width = ctk_icon_view_get_preferred_width; | |||
365 | widget_class->get_preferred_height = ctk_icon_view_get_preferred_height; | |||
366 | widget_class->get_preferred_width_for_height = ctk_icon_view_get_preferred_width_for_height; | |||
367 | widget_class->get_preferred_height_for_width = ctk_icon_view_get_preferred_height_for_width; | |||
368 | widget_class->size_allocate = ctk_icon_view_size_allocate; | |||
369 | widget_class->draw = ctk_icon_view_draw; | |||
370 | widget_class->motion_notify_event = ctk_icon_view_motion; | |||
371 | widget_class->leave_notify_event = ctk_icon_view_leave; | |||
372 | widget_class->button_press_event = ctk_icon_view_button_press; | |||
373 | widget_class->button_release_event = ctk_icon_view_button_release; | |||
374 | widget_class->key_press_event = ctk_icon_view_key_press; | |||
375 | widget_class->key_release_event = ctk_icon_view_key_release; | |||
376 | widget_class->drag_begin = ctk_icon_view_drag_begin; | |||
377 | widget_class->drag_end = ctk_icon_view_drag_end; | |||
378 | widget_class->drag_data_get = ctk_icon_view_drag_data_get; | |||
379 | widget_class->drag_data_delete = ctk_icon_view_drag_data_delete; | |||
380 | widget_class->drag_leave = ctk_icon_view_drag_leave; | |||
381 | widget_class->drag_motion = ctk_icon_view_drag_motion; | |||
382 | widget_class->drag_drop = ctk_icon_view_drag_drop; | |||
383 | widget_class->drag_data_received = ctk_icon_view_drag_data_received; | |||
384 | ||||
385 | container_class->remove = ctk_icon_view_remove; | |||
386 | container_class->forall = ctk_icon_view_forall; | |||
387 | ||||
388 | klass->select_all = ctk_icon_view_real_select_all; | |||
389 | klass->unselect_all = ctk_icon_view_real_unselect_all; | |||
390 | klass->select_cursor_item = ctk_icon_view_real_select_cursor_item; | |||
391 | klass->toggle_cursor_item = ctk_icon_view_real_toggle_cursor_item; | |||
392 | klass->activate_cursor_item = ctk_icon_view_real_activate_cursor_item; | |||
393 | klass->move_cursor = ctk_icon_view_real_move_cursor; | |||
394 | ||||
395 | /* Properties */ | |||
396 | /** | |||
397 | * CtkIconView:selection-mode: | |||
398 | * | |||
399 | * The ::selection-mode property specifies the selection mode of | |||
400 | * icon view. If the mode is #CTK_SELECTION_MULTIPLE, rubberband selection | |||
401 | * is enabled, for the other modes, only keyboard selection is possible. | |||
402 | * | |||
403 | * Since: 2.6 | |||
404 | */ | |||
405 | g_object_class_install_property (gobject_class, | |||
406 | PROP_SELECTION_MODE, | |||
407 | g_param_spec_enum ("selection-mode", | |||
408 | P_("Selection mode")g_dgettext("ctk30" "-properties","Selection mode"), | |||
409 | P_("The selection mode")g_dgettext("ctk30" "-properties","The selection mode"), | |||
410 | CTK_TYPE_SELECTION_MODE(ctk_selection_mode_get_type ()), | |||
411 | CTK_SELECTION_SINGLE, | |||
412 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
413 | ||||
414 | /** | |||
415 | * CtkIconView:pixbuf-column: | |||
416 | * | |||
417 | * The ::pixbuf-column property contains the number of the model column | |||
418 | * containing the pixbufs which are displayed. The pixbuf column must be | |||
419 | * of type #GDK_TYPE_PIXBUF. Setting this property to -1 turns off the | |||
420 | * display of pixbufs. | |||
421 | * | |||
422 | * Since: 2.6 | |||
423 | */ | |||
424 | g_object_class_install_property (gobject_class, | |||
425 | PROP_PIXBUF_COLUMN, | |||
426 | g_param_spec_int ("pixbuf-column", | |||
427 | P_("Pixbuf column")g_dgettext("ctk30" "-properties","Pixbuf column"), | |||
428 | P_("Model column used to retrieve the icon pixbuf from")g_dgettext("ctk30" "-properties","Model column used to retrieve the icon pixbuf from" ), | |||
429 | -1, G_MAXINT2147483647, -1, | |||
430 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
431 | ||||
432 | /** | |||
433 | * CtkIconView:text-column: | |||
434 | * | |||
435 | * The ::text-column property contains the number of the model column | |||
436 | * containing the texts which are displayed. The text column must be | |||
437 | * of type #G_TYPE_STRING. If this property and the :markup-column | |||
438 | * property are both set to -1, no texts are displayed. | |||
439 | * | |||
440 | * Since: 2.6 | |||
441 | */ | |||
442 | g_object_class_install_property (gobject_class, | |||
443 | PROP_TEXT_COLUMN, | |||
444 | g_param_spec_int ("text-column", | |||
445 | P_("Text column")g_dgettext("ctk30" "-properties","Text column"), | |||
446 | P_("Model column used to retrieve the text from")g_dgettext("ctk30" "-properties","Model column used to retrieve the text from" ), | |||
447 | -1, G_MAXINT2147483647, -1, | |||
448 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
449 | ||||
450 | ||||
451 | /** | |||
452 | * CtkIconView:markup-column: | |||
453 | * | |||
454 | * The ::markup-column property contains the number of the model column | |||
455 | * containing markup information to be displayed. The markup column must be | |||
456 | * of type #G_TYPE_STRING. If this property and the :text-column property | |||
457 | * are both set to column numbers, it overrides the text column. | |||
458 | * If both are set to -1, no texts are displayed. | |||
459 | * | |||
460 | * Since: 2.6 | |||
461 | */ | |||
462 | g_object_class_install_property (gobject_class, | |||
463 | PROP_MARKUP_COLUMN, | |||
464 | g_param_spec_int ("markup-column", | |||
465 | P_("Markup column")g_dgettext("ctk30" "-properties","Markup column"), | |||
466 | P_("Model column used to retrieve the text if using Pango markup")g_dgettext("ctk30" "-properties","Model column used to retrieve the text if using Pango markup" ), | |||
467 | -1, G_MAXINT2147483647, -1, | |||
468 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
469 | ||||
470 | g_object_class_install_property (gobject_class, | |||
471 | PROP_MODEL, | |||
472 | g_param_spec_object ("model", | |||
473 | P_("Icon View Model")g_dgettext("ctk30" "-properties","Icon View Model"), | |||
474 | P_("The model for the icon view")g_dgettext("ctk30" "-properties","The model for the icon view" ), | |||
475 | CTK_TYPE_TREE_MODEL(ctk_tree_model_get_type ()), | |||
476 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
477 | ||||
478 | /** | |||
479 | * CtkIconView:columns: | |||
480 | * | |||
481 | * The columns property contains the number of the columns in which the | |||
482 | * items should be displayed. If it is -1, the number of columns will | |||
483 | * be chosen automatically to fill the available area. | |||
484 | * | |||
485 | * Since: 2.6 | |||
486 | */ | |||
487 | g_object_class_install_property (gobject_class, | |||
488 | PROP_COLUMNS, | |||
489 | g_param_spec_int ("columns", | |||
490 | P_("Number of columns")g_dgettext("ctk30" "-properties","Number of columns"), | |||
491 | P_("Number of columns to display")g_dgettext("ctk30" "-properties","Number of columns to display" ), | |||
492 | -1, G_MAXINT2147483647, -1, | |||
493 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
494 | ||||
495 | ||||
496 | /** | |||
497 | * CtkIconView:item-width: | |||
498 | * | |||
499 | * The item-width property specifies the width to use for each item. | |||
500 | * If it is set to -1, the icon view will automatically determine a | |||
501 | * suitable item size. | |||
502 | * | |||
503 | * Since: 2.6 | |||
504 | */ | |||
505 | g_object_class_install_property (gobject_class, | |||
506 | PROP_ITEM_WIDTH, | |||
507 | g_param_spec_int ("item-width", | |||
508 | P_("Width for each item")g_dgettext("ctk30" "-properties","Width for each item"), | |||
509 | P_("The width used for each item")g_dgettext("ctk30" "-properties","The width used for each item" ), | |||
510 | -1, G_MAXINT2147483647, -1, | |||
511 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
512 | ||||
513 | /** | |||
514 | * CtkIconView:spacing: | |||
515 | * | |||
516 | * The spacing property specifies the space which is inserted between | |||
517 | * the cells (i.e. the icon and the text) of an item. | |||
518 | * | |||
519 | * Since: 2.6 | |||
520 | */ | |||
521 | g_object_class_install_property (gobject_class, | |||
522 | PROP_SPACING, | |||
523 | g_param_spec_int ("spacing", | |||
524 | P_("Spacing")g_dgettext("ctk30" "-properties","Spacing"), | |||
525 | P_("Space which is inserted between cells of an item")g_dgettext("ctk30" "-properties","Space which is inserted between cells of an item" ), | |||
526 | 0, G_MAXINT2147483647, 0, | |||
527 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
528 | ||||
529 | /** | |||
530 | * CtkIconView:row-spacing: | |||
531 | * | |||
532 | * The row-spacing property specifies the space which is inserted between | |||
533 | * the rows of the icon view. | |||
534 | * | |||
535 | * Since: 2.6 | |||
536 | */ | |||
537 | g_object_class_install_property (gobject_class, | |||
538 | PROP_ROW_SPACING, | |||
539 | g_param_spec_int ("row-spacing", | |||
540 | P_("Row Spacing")g_dgettext("ctk30" "-properties","Row Spacing"), | |||
541 | P_("Space which is inserted between grid rows")g_dgettext("ctk30" "-properties","Space which is inserted between grid rows" ), | |||
542 | 0, G_MAXINT2147483647, 6, | |||
543 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
544 | ||||
545 | /** | |||
546 | * CtkIconView:column-spacing: | |||
547 | * | |||
548 | * The column-spacing property specifies the space which is inserted between | |||
549 | * the columns of the icon view. | |||
550 | * | |||
551 | * Since: 2.6 | |||
552 | */ | |||
553 | g_object_class_install_property (gobject_class, | |||
554 | PROP_COLUMN_SPACING, | |||
555 | g_param_spec_int ("column-spacing", | |||
556 | P_("Column Spacing")g_dgettext("ctk30" "-properties","Column Spacing"), | |||
557 | P_("Space which is inserted between grid columns")g_dgettext("ctk30" "-properties","Space which is inserted between grid columns" ), | |||
558 | 0, G_MAXINT2147483647, 6, | |||
559 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
560 | ||||
561 | /** | |||
562 | * CtkIconView:margin: | |||
563 | * | |||
564 | * The margin property specifies the space which is inserted | |||
565 | * at the edges of the icon view. | |||
566 | * | |||
567 | * Since: 2.6 | |||
568 | */ | |||
569 | g_object_class_install_property (gobject_class, | |||
570 | PROP_MARGIN, | |||
571 | g_param_spec_int ("margin", | |||
572 | P_("Margin")g_dgettext("ctk30" "-properties","Margin"), | |||
573 | P_("Space which is inserted at the edges of the icon view")g_dgettext("ctk30" "-properties","Space which is inserted at the edges of the icon view" ), | |||
574 | 0, G_MAXINT2147483647, 6, | |||
575 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
576 | ||||
577 | /** | |||
578 | * CtkIconView:item-orientation: | |||
579 | * | |||
580 | * The item-orientation property specifies how the cells (i.e. the icon and | |||
581 | * the text) of the item are positioned relative to each other. | |||
582 | * | |||
583 | * Since: 2.6 | |||
584 | */ | |||
585 | g_object_class_install_property (gobject_class, | |||
586 | PROP_ITEM_ORIENTATION, | |||
587 | g_param_spec_enum ("item-orientation", | |||
588 | P_("Item Orientation")g_dgettext("ctk30" "-properties","Item Orientation"), | |||
589 | P_("How the text and icon of each item are positioned relative to each other")g_dgettext("ctk30" "-properties","How the text and icon of each item are positioned relative to each other" ), | |||
590 | CTK_TYPE_ORIENTATION(ctk_orientation_get_type ()), | |||
591 | CTK_ORIENTATION_VERTICAL, | |||
592 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
593 | ||||
594 | /** | |||
595 | * CtkIconView:reorderable: | |||
596 | * | |||
597 | * The reorderable property specifies if the items can be reordered | |||
598 | * by DND. | |||
599 | * | |||
600 | * Since: 2.8 | |||
601 | */ | |||
602 | g_object_class_install_property (gobject_class, | |||
603 | PROP_REORDERABLE, | |||
604 | g_param_spec_boolean ("reorderable", | |||
605 | P_("Reorderable")g_dgettext("ctk30" "-properties","Reorderable"), | |||
606 | P_("View is reorderable")g_dgettext("ctk30" "-properties","View is reorderable"), | |||
607 | FALSE(0), | |||
608 | G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); | |||
609 | ||||
610 | g_object_class_install_property (gobject_class, | |||
611 | PROP_TOOLTIP_COLUMN, | |||
612 | g_param_spec_int ("tooltip-column", | |||
613 | P_("Tooltip Column")g_dgettext("ctk30" "-properties","Tooltip Column"), | |||
614 | P_("The column in the model containing the tooltip texts for the items")g_dgettext("ctk30" "-properties","The column in the model containing the tooltip texts for the items" ), | |||
615 | -1, | |||
616 | G_MAXINT2147483647, | |||
617 | -1, | |||
618 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
619 | ||||
620 | /** | |||
621 | * CtkIconView:item-padding: | |||
622 | * | |||
623 | * The item-padding property specifies the padding around each | |||
624 | * of the icon view's item. | |||
625 | * | |||
626 | * Since: 2.18 | |||
627 | */ | |||
628 | g_object_class_install_property (gobject_class, | |||
629 | PROP_ITEM_PADDING, | |||
630 | g_param_spec_int ("item-padding", | |||
631 | P_("Item Padding")g_dgettext("ctk30" "-properties","Item Padding"), | |||
632 | P_("Padding around icon view items")g_dgettext("ctk30" "-properties","Padding around icon view items" ), | |||
633 | 0, G_MAXINT2147483647, 6, | |||
634 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
635 | ||||
636 | /** | |||
637 | * CtkIconView:cell-area: | |||
638 | * | |||
639 | * The #CtkCellArea used to layout cell renderers for this view. | |||
640 | * | |||
641 | * If no area is specified when creating the icon view with ctk_icon_view_new_with_area() | |||
642 | * a #CtkCellAreaBox will be used. | |||
643 | * | |||
644 | * Since: 3.0 | |||
645 | */ | |||
646 | g_object_class_install_property (gobject_class, | |||
647 | PROP_CELL_AREA, | |||
648 | g_param_spec_object ("cell-area", | |||
649 | P_("Cell Area")g_dgettext("ctk30" "-properties","Cell Area"), | |||
650 | P_("The CtkCellArea used to layout cells")g_dgettext("ctk30" "-properties","The CtkCellArea used to layout cells" ), | |||
651 | CTK_TYPE_CELL_AREA(ctk_cell_area_get_type ()), | |||
652 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY)); | |||
653 | ||||
654 | /** | |||
655 | * CtkIconView:activate-on-single-click: | |||
656 | * | |||
657 | * The activate-on-single-click property specifies whether the "item-activated" signal | |||
658 | * will be emitted after a single click. | |||
659 | * | |||
660 | * Since: 3.8 | |||
661 | */ | |||
662 | g_object_class_install_property (gobject_class, | |||
663 | PROP_ACTIVATE_ON_SINGLE_CLICK, | |||
664 | g_param_spec_boolean ("activate-on-single-click", | |||
665 | P_("Activate on Single Click")g_dgettext("ctk30" "-properties","Activate on Single Click"), | |||
666 | P_("Activate row on a single click")g_dgettext("ctk30" "-properties","Activate row on a single click" ), | |||
667 | FALSE(0), | |||
668 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
669 | ||||
670 | /* Scrollable interface properties */ | |||
671 | g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment"); | |||
672 | g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment"); | |||
673 | g_object_class_override_property (gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy"); | |||
674 | g_object_class_override_property (gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy"); | |||
675 | ||||
676 | /* Style properties */ | |||
677 | /** | |||
678 | * CtkIconView:selection-box-color: | |||
679 | * | |||
680 | * The color of the selection box. | |||
681 | * | |||
682 | * Deprecated: 3.20: The color of the selection box is determined by CSS; | |||
683 | * the value of this style property is ignored. | |||
684 | */ | |||
685 | ctk_widget_class_install_style_property (widget_class, | |||
686 | g_param_spec_boxed ("selection-box-color", | |||
687 | P_("Selection Box Color")g_dgettext("ctk30" "-properties","Selection Box Color"), | |||
688 | P_("Color of the selection box")g_dgettext("ctk30" "-properties","Color of the selection box" ), | |||
689 | g_type_from_name ("CdkColor"), | |||
690 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED)); | |||
691 | ||||
692 | ||||
693 | /** | |||
694 | * CtkIconView:selection-box-alpha: | |||
695 | * | |||
696 | * The opacity of the selection box. | |||
697 | * | |||
698 | * Deprecated: 3.20: The opacity of the selection box is determined by CSS; | |||
699 | * the value of this style property is ignored. | |||
700 | */ | |||
701 | ctk_widget_class_install_style_property (widget_class, | |||
702 | g_param_spec_uchar ("selection-box-alpha", | |||
703 | P_("Selection Box Alpha")g_dgettext("ctk30" "-properties","Selection Box Alpha"), | |||
704 | P_("Opacity of the selection box")g_dgettext("ctk30" "-properties","Opacity of the selection box" ), | |||
705 | 0, 0xff, | |||
706 | 0x40, | |||
707 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED)); | |||
708 | ||||
709 | /* Signals */ | |||
710 | /** | |||
711 | * CtkIconView::item-activated: | |||
712 | * @iconview: the object on which the signal is emitted | |||
713 | * @path: the #CtkTreePath for the activated item | |||
714 | * | |||
715 | * The ::item-activated signal is emitted when the method | |||
716 | * ctk_icon_view_item_activated() is called, when the user double | |||
717 | * clicks an item with the "activate-on-single-click" property set | |||
718 | * to %FALSE, or when the user single clicks an item when the | |||
719 | * "activate-on-single-click" property set to %TRUE. It is also | |||
720 | * emitted when a non-editable item is selected and one of the keys: | |||
721 | * Space, Return or Enter is pressed. | |||
722 | */ | |||
723 | icon_view_signals[ITEM_ACTIVATED] = | |||
724 | g_signal_new (I_("item-activated")g_intern_static_string ("item-activated"), | |||
725 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
726 | G_SIGNAL_RUN_LAST, | |||
727 | G_STRUCT_OFFSET (CtkIconViewClass, item_activated)((glong) __builtin_offsetof(CtkIconViewClass, item_activated) ), | |||
728 | NULL((void*)0), NULL((void*)0), | |||
729 | NULL((void*)0), | |||
730 | G_TYPE_NONE((GType) ((1) << (2))), 1, | |||
731 | CTK_TYPE_TREE_PATH(ctk_tree_path_get_type ())); | |||
732 | ||||
733 | /** | |||
734 | * CtkIconView::selection-changed: | |||
735 | * @iconview: the object on which the signal is emitted | |||
736 | * | |||
737 | * The ::selection-changed signal is emitted when the selection | |||
738 | * (i.e. the set of selected items) changes. | |||
739 | */ | |||
740 | icon_view_signals[SELECTION_CHANGED] = | |||
741 | g_signal_new (I_("selection-changed")g_intern_static_string ("selection-changed"), | |||
742 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
743 | G_SIGNAL_RUN_FIRST, | |||
744 | G_STRUCT_OFFSET (CtkIconViewClass, selection_changed)((glong) __builtin_offsetof(CtkIconViewClass, selection_changed )), | |||
745 | NULL((void*)0), NULL((void*)0), | |||
746 | NULL((void*)0), | |||
747 | G_TYPE_NONE((GType) ((1) << (2))), 0); | |||
748 | ||||
749 | /** | |||
750 | * CtkIconView::select-all: | |||
751 | * @iconview: the object on which the signal is emitted | |||
752 | * | |||
753 | * A [keybinding signal][CtkBindingSignal] | |||
754 | * which gets emitted when the user selects all items. | |||
755 | * | |||
756 | * Applications should not connect to it, but may emit it with | |||
757 | * g_signal_emit_by_name() if they need to control selection | |||
758 | * programmatically. | |||
759 | * | |||
760 | * The default binding for this signal is Ctrl-a. | |||
761 | */ | |||
762 | icon_view_signals[SELECT_ALL] = | |||
763 | g_signal_new (I_("select-all")g_intern_static_string ("select-all"), | |||
764 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
765 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
766 | G_STRUCT_OFFSET (CtkIconViewClass, select_all)((glong) __builtin_offsetof(CtkIconViewClass, select_all)), | |||
767 | NULL((void*)0), NULL((void*)0), | |||
768 | NULL((void*)0), | |||
769 | G_TYPE_NONE((GType) ((1) << (2))), 0); | |||
770 | ||||
771 | /** | |||
772 | * CtkIconView::unselect-all: | |||
773 | * @iconview: the object on which the signal is emitted | |||
774 | * | |||
775 | * A [keybinding signal][CtkBindingSignal] | |||
776 | * which gets emitted when the user unselects all items. | |||
777 | * | |||
778 | * Applications should not connect to it, but may emit it with | |||
779 | * g_signal_emit_by_name() if they need to control selection | |||
780 | * programmatically. | |||
781 | * | |||
782 | * The default binding for this signal is Ctrl-Shift-a. | |||
783 | */ | |||
784 | icon_view_signals[UNSELECT_ALL] = | |||
785 | g_signal_new (I_("unselect-all")g_intern_static_string ("unselect-all"), | |||
786 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
787 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
788 | G_STRUCT_OFFSET (CtkIconViewClass, unselect_all)((glong) __builtin_offsetof(CtkIconViewClass, unselect_all)), | |||
789 | NULL((void*)0), NULL((void*)0), | |||
790 | NULL((void*)0), | |||
791 | G_TYPE_NONE((GType) ((1) << (2))), 0); | |||
792 | ||||
793 | /** | |||
794 | * CtkIconView::select-cursor-item: | |||
795 | * @iconview: the object on which the signal is emitted | |||
796 | * | |||
797 | * A [keybinding signal][CtkBindingSignal] | |||
798 | * which gets emitted when the user selects the item that is currently | |||
799 | * focused. | |||
800 | * | |||
801 | * Applications should not connect to it, but may emit it with | |||
802 | * g_signal_emit_by_name() if they need to control selection | |||
803 | * programmatically. | |||
804 | * | |||
805 | * There is no default binding for this signal. | |||
806 | */ | |||
807 | icon_view_signals[SELECT_CURSOR_ITEM] = | |||
808 | g_signal_new (I_("select-cursor-item")g_intern_static_string ("select-cursor-item"), | |||
809 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
810 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
811 | G_STRUCT_OFFSET (CtkIconViewClass, select_cursor_item)((glong) __builtin_offsetof(CtkIconViewClass, select_cursor_item )), | |||
812 | NULL((void*)0), NULL((void*)0), | |||
813 | NULL((void*)0), | |||
814 | G_TYPE_NONE((GType) ((1) << (2))), 0); | |||
815 | ||||
816 | /** | |||
817 | * CtkIconView::toggle-cursor-item: | |||
818 | * @iconview: the object on which the signal is emitted | |||
819 | * | |||
820 | * A [keybinding signal][CtkBindingSignal] | |||
821 | * which gets emitted when the user toggles whether the currently | |||
822 | * focused item is selected or not. The exact effect of this | |||
823 | * depend on the selection mode. | |||
824 | * | |||
825 | * Applications should not connect to it, but may emit it with | |||
826 | * g_signal_emit_by_name() if they need to control selection | |||
827 | * programmatically. | |||
828 | * | |||
829 | * There is no default binding for this signal is Ctrl-Space. | |||
830 | */ | |||
831 | icon_view_signals[TOGGLE_CURSOR_ITEM] = | |||
832 | g_signal_new (I_("toggle-cursor-item")g_intern_static_string ("toggle-cursor-item"), | |||
833 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
834 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
835 | G_STRUCT_OFFSET (CtkIconViewClass, toggle_cursor_item)((glong) __builtin_offsetof(CtkIconViewClass, toggle_cursor_item )), | |||
836 | NULL((void*)0), NULL((void*)0), | |||
837 | NULL((void*)0), | |||
838 | G_TYPE_NONE((GType) ((1) << (2))), 0); | |||
839 | ||||
840 | /** | |||
841 | * CtkIconView::activate-cursor-item: | |||
842 | * @iconview: the object on which the signal is emitted | |||
843 | * | |||
844 | * A [keybinding signal][CtkBindingSignal] | |||
845 | * which gets emitted when the user activates the currently | |||
846 | * focused item. | |||
847 | * | |||
848 | * Applications should not connect to it, but may emit it with | |||
849 | * g_signal_emit_by_name() if they need to control activation | |||
850 | * programmatically. | |||
851 | * | |||
852 | * The default bindings for this signal are Space, Return and Enter. | |||
853 | */ | |||
854 | icon_view_signals[ACTIVATE_CURSOR_ITEM] = | |||
855 | g_signal_new (I_("activate-cursor-item")g_intern_static_string ("activate-cursor-item"), | |||
856 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
857 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
858 | G_STRUCT_OFFSET (CtkIconViewClass, activate_cursor_item)((glong) __builtin_offsetof(CtkIconViewClass, activate_cursor_item )), | |||
859 | NULL((void*)0), NULL((void*)0), | |||
860 | _ctk_marshal_BOOLEAN__VOID, | |||
861 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 0); | |||
862 | g_signal_set_va_marshaller (icon_view_signals[ACTIVATE_CURSOR_ITEM], | |||
863 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), | |||
864 | _ctk_marshal_BOOLEAN__VOIDv); | |||
865 | ||||
866 | /** | |||
867 | * CtkIconView::move-cursor: | |||
868 | * @iconview: the object which received the signal | |||
869 | * @step: the granularity of the move, as a #CtkMovementStep | |||
870 | * @count: the number of @step units to move | |||
871 | * | |||
872 | * The ::move-cursor signal is a | |||
873 | * [keybinding signal][CtkBindingSignal] | |||
874 | * which gets emitted when the user initiates a cursor movement. | |||
875 | * | |||
876 | * Applications should not connect to it, but may emit it with | |||
877 | * g_signal_emit_by_name() if they need to control the cursor | |||
878 | * programmatically. | |||
879 | * | |||
880 | * The default bindings for this signal include | |||
881 | * - Arrow keys which move by individual steps | |||
882 | * - Home/End keys which move to the first/last item | |||
883 | * - PageUp/PageDown which move by "pages" | |||
884 | * All of these will extend the selection when combined with | |||
885 | * the Shift modifier. | |||
886 | */ | |||
887 | icon_view_signals[MOVE_CURSOR] = | |||
888 | g_signal_new (I_("move-cursor")g_intern_static_string ("move-cursor"), | |||
889 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), | |||
890 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |||
891 | G_STRUCT_OFFSET (CtkIconViewClass, move_cursor)((glong) __builtin_offsetof(CtkIconViewClass, move_cursor)), | |||
892 | NULL((void*)0), NULL((void*)0), | |||
893 | _ctk_marshal_BOOLEAN__ENUM_INT, | |||
894 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 2, | |||
895 | CTK_TYPE_MOVEMENT_STEP(ctk_movement_step_get_type ()), | |||
896 | G_TYPE_INT((GType) ((6) << (2)))); | |||
897 | g_signal_set_va_marshaller (icon_view_signals[MOVE_CURSOR], | |||
898 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), | |||
899 | _ctk_marshal_BOOLEAN__ENUM_INTv); | |||
900 | ||||
901 | /* Key bindings */ | |||
902 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_a0x061, CDK_CONTROL_MASK, | |||
903 | "select-all", 0); | |||
904 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_a0x061, CDK_CONTROL_MASK | CDK_SHIFT_MASK, | |||
905 | "unselect-all", 0); | |||
906 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_space0x020, CDK_CONTROL_MASK, | |||
907 | "toggle-cursor-item", 0); | |||
908 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Space0xff80, CDK_CONTROL_MASK, | |||
909 | "toggle-cursor-item", 0); | |||
910 | ||||
911 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_space0x020, 0, | |||
912 | "activate-cursor-item", 0); | |||
913 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Space0xff80, 0, | |||
914 | "activate-cursor-item", 0); | |||
915 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_Return0xff0d, 0, | |||
916 | "activate-cursor-item", 0); | |||
917 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_ISO_Enter0xfe34, 0, | |||
918 | "activate-cursor-item", 0); | |||
919 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Enter0xff8d, 0, | |||
920 | "activate-cursor-item", 0); | |||
921 | ||||
922 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_Up0xff52, 0, | |||
923 | CTK_MOVEMENT_DISPLAY_LINES, -1); | |||
924 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_Up0xff97, 0, | |||
925 | CTK_MOVEMENT_DISPLAY_LINES, -1); | |||
926 | ||||
927 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_Down0xff54, 0, | |||
928 | CTK_MOVEMENT_DISPLAY_LINES, 1); | |||
929 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_Down0xff99, 0, | |||
930 | CTK_MOVEMENT_DISPLAY_LINES, 1); | |||
931 | ||||
932 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_p0x070, CDK_CONTROL_MASK, | |||
933 | CTK_MOVEMENT_DISPLAY_LINES, -1); | |||
934 | ||||
935 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_n0x06e, CDK_CONTROL_MASK, | |||
936 | CTK_MOVEMENT_DISPLAY_LINES, 1); | |||
937 | ||||
938 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_Home0xff50, 0, | |||
939 | CTK_MOVEMENT_BUFFER_ENDS, -1); | |||
940 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_Home0xff95, 0, | |||
941 | CTK_MOVEMENT_BUFFER_ENDS, -1); | |||
942 | ||||
943 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_End0xff57, 0, | |||
944 | CTK_MOVEMENT_BUFFER_ENDS, 1); | |||
945 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_End0xff9c, 0, | |||
946 | CTK_MOVEMENT_BUFFER_ENDS, 1); | |||
947 | ||||
948 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_Page_Up0xff55, 0, | |||
949 | CTK_MOVEMENT_PAGES, -1); | |||
950 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_Page_Up0xff9a, 0, | |||
951 | CTK_MOVEMENT_PAGES, -1); | |||
952 | ||||
953 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_Page_Down0xff56, 0, | |||
954 | CTK_MOVEMENT_PAGES, 1); | |||
955 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_Page_Down0xff9b, 0, | |||
956 | CTK_MOVEMENT_PAGES, 1); | |||
957 | ||||
958 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_Right0xff53, 0, | |||
959 | CTK_MOVEMENT_VISUAL_POSITIONS, 1); | |||
960 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_Left0xff51, 0, | |||
961 | CTK_MOVEMENT_VISUAL_POSITIONS, -1); | |||
962 | ||||
963 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_Right0xff98, 0, | |||
964 | CTK_MOVEMENT_VISUAL_POSITIONS, 1); | |||
965 | ctk_icon_view_add_move_binding (binding_set, CDK_KEY_KP_Left0xff96, 0, | |||
966 | CTK_MOVEMENT_VISUAL_POSITIONS, -1); | |||
967 | ||||
968 | ctk_widget_class_set_accessible_type (widget_class, CTK_TYPE_ICON_VIEW_ACCESSIBLE(ctk_icon_view_accessible_get_type ())); | |||
969 | ctk_widget_class_set_css_name (widget_class, "iconview"); | |||
970 | } | |||
971 | ||||
972 | static void | |||
973 | ctk_icon_view_buildable_init (CtkBuildableIface *iface) | |||
974 | { | |||
975 | parent_buildable_iface = g_type_interface_peek_parent (iface); | |||
976 | iface->add_child = _ctk_cell_layout_buildable_add_child; | |||
977 | iface->custom_tag_start = ctk_icon_view_buildable_custom_tag_start; | |||
978 | iface->custom_tag_end = ctk_icon_view_buildable_custom_tag_end; | |||
979 | } | |||
980 | ||||
981 | static void | |||
982 | ctk_icon_view_cell_layout_init (CtkCellLayoutIface *iface) | |||
983 | { | |||
984 | iface->get_area = ctk_icon_view_cell_layout_get_area; | |||
985 | } | |||
986 | ||||
987 | static void | |||
988 | ctk_icon_view_init (CtkIconView *icon_view) | |||
989 | { | |||
990 | icon_view->priv = ctk_icon_view_get_instance_private (icon_view); | |||
991 | ||||
992 | icon_view->priv->width = 0; | |||
993 | icon_view->priv->height = 0; | |||
994 | icon_view->priv->selection_mode = CTK_SELECTION_SINGLE; | |||
995 | icon_view->priv->pressed_button = -1; | |||
996 | icon_view->priv->press_start_x = -1; | |||
997 | icon_view->priv->press_start_y = -1; | |||
998 | icon_view->priv->text_column = -1; | |||
999 | icon_view->priv->markup_column = -1; | |||
1000 | icon_view->priv->pixbuf_column = -1; | |||
1001 | icon_view->priv->text_cell = NULL((void*)0); | |||
1002 | icon_view->priv->pixbuf_cell = NULL((void*)0); | |||
1003 | icon_view->priv->tooltip_column = -1; | |||
1004 | ||||
1005 | ctk_widget_set_can_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), TRUE(!(0))); | |||
1006 | ||||
1007 | icon_view->priv->item_orientation = CTK_ORIENTATION_VERTICAL; | |||
1008 | ||||
1009 | icon_view->priv->columns = -1; | |||
1010 | icon_view->priv->item_width = -1; | |||
1011 | icon_view->priv->spacing = 0; | |||
1012 | icon_view->priv->row_spacing = 6; | |||
1013 | icon_view->priv->column_spacing = 6; | |||
1014 | icon_view->priv->margin = 6; | |||
1015 | icon_view->priv->item_padding = 6; | |||
1016 | icon_view->priv->activate_on_single_click = FALSE(0); | |||
1017 | ||||
1018 | icon_view->priv->draw_focus = TRUE(!(0)); | |||
1019 | ||||
1020 | icon_view->priv->row_contexts = | |||
1021 | g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); | |||
1022 | ||||
1023 | ctk_style_context_add_class (ctk_widget_get_style_context (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))), | |||
1024 | CTK_STYLE_CLASS_VIEW"view"); | |||
1025 | } | |||
1026 | ||||
1027 | /* GObject methods */ | |||
1028 | ||||
1029 | static void | |||
1030 | ctk_icon_view_constructed (GObject *object) | |||
1031 | { | |||
1032 | CtkIconView *icon_view = CTK_ICON_VIEW (object)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_icon_view_get_type ())))))); | |||
1033 | ||||
1034 | G_OBJECT_CLASS (ctk_icon_view_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_icon_view_parent_class)), (((GType) ((20) << ( 2))))))))->constructed (object); | |||
1035 | ||||
1036 | ctk_icon_view_ensure_cell_area (icon_view, NULL((void*)0)); | |||
1037 | } | |||
1038 | ||||
1039 | static void | |||
1040 | ctk_icon_view_dispose (GObject *object) | |||
1041 | { | |||
1042 | CtkIconView *icon_view; | |||
1043 | CtkIconViewPrivate *priv; | |||
1044 | ||||
1045 | icon_view = CTK_ICON_VIEW (object)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_icon_view_get_type ())))))); | |||
1046 | priv = icon_view->priv; | |||
1047 | ||||
1048 | if (priv->cell_area_context) | |||
1049 | { | |||
1050 | g_object_unref (priv->cell_area_context); | |||
1051 | priv->cell_area_context = NULL((void*)0); | |||
1052 | } | |||
1053 | ||||
1054 | if (priv->row_contexts) | |||
1055 | { | |||
1056 | g_ptr_array_free (priv->row_contexts, TRUE(!(0))); | |||
1057 | priv->row_contexts = NULL((void*)0); | |||
1058 | } | |||
1059 | ||||
1060 | if (priv->cell_area) | |||
1061 | { | |||
1062 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
1063 | ||||
1064 | g_signal_handler_disconnect (priv->cell_area, priv->add_editable_id); | |||
1065 | g_signal_handler_disconnect (priv->cell_area, priv->remove_editable_id); | |||
1066 | priv->add_editable_id = 0; | |||
1067 | priv->remove_editable_id = 0; | |||
1068 | ||||
1069 | g_object_unref (priv->cell_area); | |||
1070 | priv->cell_area = NULL((void*)0); | |||
1071 | } | |||
1072 | ||||
1073 | G_OBJECT_CLASS (ctk_icon_view_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_icon_view_parent_class)), (((GType) ((20) << ( 2))))))))->dispose (object); | |||
1074 | } | |||
1075 | ||||
1076 | static void | |||
1077 | ctk_icon_view_set_property (GObject *object, | |||
1078 | guint prop_id, | |||
1079 | const GValue *value, | |||
1080 | GParamSpec *pspec) | |||
1081 | { | |||
1082 | CtkIconView *icon_view; | |||
1083 | CtkCellArea *area; | |||
1084 | ||||
1085 | icon_view = CTK_ICON_VIEW (object)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_icon_view_get_type ())))))); | |||
1086 | ||||
1087 | switch (prop_id) | |||
1088 | { | |||
1089 | case PROP_SELECTION_MODE: | |||
1090 | ctk_icon_view_set_selection_mode (icon_view, g_value_get_enum (value)); | |||
1091 | break; | |||
1092 | case PROP_PIXBUF_COLUMN: | |||
1093 | ctk_icon_view_set_pixbuf_column (icon_view, g_value_get_int (value)); | |||
1094 | break; | |||
1095 | case PROP_TEXT_COLUMN: | |||
1096 | ctk_icon_view_set_text_column (icon_view, g_value_get_int (value)); | |||
1097 | break; | |||
1098 | case PROP_MARKUP_COLUMN: | |||
1099 | ctk_icon_view_set_markup_column (icon_view, g_value_get_int (value)); | |||
1100 | break; | |||
1101 | case PROP_MODEL: | |||
1102 | ctk_icon_view_set_model (icon_view, g_value_get_object (value)); | |||
1103 | break; | |||
1104 | case PROP_ITEM_ORIENTATION: | |||
1105 | ctk_icon_view_set_item_orientation (icon_view, g_value_get_enum (value)); | |||
1106 | break; | |||
1107 | case PROP_COLUMNS: | |||
1108 | ctk_icon_view_set_columns (icon_view, g_value_get_int (value)); | |||
1109 | break; | |||
1110 | case PROP_ITEM_WIDTH: | |||
1111 | ctk_icon_view_set_item_width (icon_view, g_value_get_int (value)); | |||
1112 | break; | |||
1113 | case PROP_SPACING: | |||
1114 | ctk_icon_view_set_spacing (icon_view, g_value_get_int (value)); | |||
1115 | break; | |||
1116 | case PROP_ROW_SPACING: | |||
1117 | ctk_icon_view_set_row_spacing (icon_view, g_value_get_int (value)); | |||
1118 | break; | |||
1119 | case PROP_COLUMN_SPACING: | |||
1120 | ctk_icon_view_set_column_spacing (icon_view, g_value_get_int (value)); | |||
1121 | break; | |||
1122 | case PROP_MARGIN: | |||
1123 | ctk_icon_view_set_margin (icon_view, g_value_get_int (value)); | |||
1124 | break; | |||
1125 | case PROP_REORDERABLE: | |||
1126 | ctk_icon_view_set_reorderable (icon_view, g_value_get_boolean (value)); | |||
1127 | break; | |||
1128 | ||||
1129 | case PROP_TOOLTIP_COLUMN: | |||
1130 | ctk_icon_view_set_tooltip_column (icon_view, g_value_get_int (value)); | |||
1131 | break; | |||
1132 | ||||
1133 | case PROP_ITEM_PADDING: | |||
1134 | ctk_icon_view_set_item_padding (icon_view, g_value_get_int (value)); | |||
1135 | break; | |||
1136 | ||||
1137 | case PROP_ACTIVATE_ON_SINGLE_CLICK: | |||
1138 | ctk_icon_view_set_activate_on_single_click (icon_view, g_value_get_boolean (value)); | |||
1139 | break; | |||
1140 | ||||
1141 | case PROP_CELL_AREA: | |||
1142 | /* Construct-only, can only be assigned once */ | |||
1143 | area = g_value_get_object (value); | |||
1144 | if (area) | |||
1145 | { | |||
1146 | if (icon_view->priv->cell_area != NULL((void*)0)) | |||
1147 | { | |||
1148 | g_warning ("cell-area has already been set, ignoring construct property"); | |||
1149 | g_object_ref_sink (area)((__typeof__ (area)) (g_object_ref_sink) (area)); | |||
1150 | g_object_unref (area); | |||
1151 | } | |||
1152 | else | |||
1153 | ctk_icon_view_ensure_cell_area (icon_view, area); | |||
1154 | } | |||
1155 | break; | |||
1156 | ||||
1157 | case PROP_HADJUSTMENT: | |||
1158 | ctk_icon_view_set_hadjustment (icon_view, g_value_get_object (value)); | |||
1159 | break; | |||
1160 | case PROP_VADJUSTMENT: | |||
1161 | ctk_icon_view_set_vadjustment (icon_view, g_value_get_object (value)); | |||
1162 | break; | |||
1163 | case PROP_HSCROLL_POLICY: | |||
1164 | if (icon_view->priv->hscroll_policy != g_value_get_enum (value)) | |||
1165 | { | |||
1166 | icon_view->priv->hscroll_policy = g_value_get_enum (value); | |||
1167 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
1168 | g_object_notify_by_pspec (object, pspec); | |||
1169 | } | |||
1170 | break; | |||
1171 | case PROP_VSCROLL_POLICY: | |||
1172 | if (icon_view->priv->vscroll_policy != g_value_get_enum (value)) | |||
1173 | { | |||
1174 | icon_view->priv->vscroll_policy = g_value_get_enum (value); | |||
1175 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
1176 | g_object_notify_by_pspec (object, pspec); | |||
1177 | } | |||
1178 | break; | |||
1179 | ||||
1180 | default: | |||
1181 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkiconview.c", 1181, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
1182 | break; | |||
1183 | } | |||
1184 | } | |||
1185 | ||||
1186 | static void | |||
1187 | ctk_icon_view_get_property (GObject *object, | |||
1188 | guint prop_id, | |||
1189 | GValue *value, | |||
1190 | GParamSpec *pspec) | |||
1191 | { | |||
1192 | CtkIconView *icon_view; | |||
1193 | ||||
1194 | icon_view = CTK_ICON_VIEW (object)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_icon_view_get_type ())))))); | |||
1195 | ||||
1196 | switch (prop_id) | |||
1197 | { | |||
1198 | case PROP_SELECTION_MODE: | |||
1199 | g_value_set_enum (value, icon_view->priv->selection_mode); | |||
1200 | break; | |||
1201 | case PROP_PIXBUF_COLUMN: | |||
1202 | g_value_set_int (value, icon_view->priv->pixbuf_column); | |||
1203 | break; | |||
1204 | case PROP_TEXT_COLUMN: | |||
1205 | g_value_set_int (value, icon_view->priv->text_column); | |||
1206 | break; | |||
1207 | case PROP_MARKUP_COLUMN: | |||
1208 | g_value_set_int (value, icon_view->priv->markup_column); | |||
1209 | break; | |||
1210 | case PROP_MODEL: | |||
1211 | g_value_set_object (value, icon_view->priv->model); | |||
1212 | break; | |||
1213 | case PROP_ITEM_ORIENTATION: | |||
1214 | g_value_set_enum (value, icon_view->priv->item_orientation); | |||
1215 | break; | |||
1216 | case PROP_COLUMNS: | |||
1217 | g_value_set_int (value, icon_view->priv->columns); | |||
1218 | break; | |||
1219 | case PROP_ITEM_WIDTH: | |||
1220 | g_value_set_int (value, icon_view->priv->item_width); | |||
1221 | break; | |||
1222 | case PROP_SPACING: | |||
1223 | g_value_set_int (value, icon_view->priv->spacing); | |||
1224 | break; | |||
1225 | case PROP_ROW_SPACING: | |||
1226 | g_value_set_int (value, icon_view->priv->row_spacing); | |||
1227 | break; | |||
1228 | case PROP_COLUMN_SPACING: | |||
1229 | g_value_set_int (value, icon_view->priv->column_spacing); | |||
1230 | break; | |||
1231 | case PROP_MARGIN: | |||
1232 | g_value_set_int (value, icon_view->priv->margin); | |||
1233 | break; | |||
1234 | case PROP_REORDERABLE: | |||
1235 | g_value_set_boolean (value, icon_view->priv->reorderable); | |||
1236 | break; | |||
1237 | case PROP_TOOLTIP_COLUMN: | |||
1238 | g_value_set_int (value, icon_view->priv->tooltip_column); | |||
1239 | break; | |||
1240 | ||||
1241 | case PROP_ITEM_PADDING: | |||
1242 | g_value_set_int (value, icon_view->priv->item_padding); | |||
1243 | break; | |||
1244 | ||||
1245 | case PROP_ACTIVATE_ON_SINGLE_CLICK: | |||
1246 | g_value_set_boolean (value, icon_view->priv->activate_on_single_click); | |||
1247 | break; | |||
1248 | ||||
1249 | case PROP_CELL_AREA: | |||
1250 | g_value_set_object (value, icon_view->priv->cell_area); | |||
1251 | break; | |||
1252 | ||||
1253 | case PROP_HADJUSTMENT: | |||
1254 | g_value_set_object (value, icon_view->priv->hadjustment); | |||
1255 | break; | |||
1256 | case PROP_VADJUSTMENT: | |||
1257 | g_value_set_object (value, icon_view->priv->vadjustment); | |||
1258 | break; | |||
1259 | case PROP_HSCROLL_POLICY: | |||
1260 | g_value_set_enum (value, icon_view->priv->hscroll_policy); | |||
1261 | break; | |||
1262 | case PROP_VSCROLL_POLICY: | |||
1263 | g_value_set_enum (value, icon_view->priv->vscroll_policy); | |||
1264 | break; | |||
1265 | ||||
1266 | default: | |||
1267 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkiconview.c", 1267, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); | |||
1268 | break; | |||
1269 | } | |||
1270 | } | |||
1271 | ||||
1272 | /* CtkWidget methods */ | |||
1273 | static void | |||
1274 | ctk_icon_view_destroy (CtkWidget *widget) | |||
1275 | { | |||
1276 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1277 | ||||
1278 | ctk_icon_view_set_model (icon_view, NULL((void*)0)); | |||
1279 | ||||
1280 | if (icon_view->priv->scroll_to_path != NULL((void*)0)) | |||
1281 | { | |||
1282 | ctk_tree_row_reference_free (icon_view->priv->scroll_to_path); | |||
1283 | icon_view->priv->scroll_to_path = NULL((void*)0); | |||
1284 | } | |||
1285 | ||||
1286 | remove_scroll_timeout (icon_view); | |||
1287 | ||||
1288 | if (icon_view->priv->hadjustment != NULL((void*)0)) | |||
1289 | { | |||
1290 | g_object_unref (icon_view->priv->hadjustment); | |||
1291 | icon_view->priv->hadjustment = NULL((void*)0); | |||
1292 | } | |||
1293 | ||||
1294 | if (icon_view->priv->vadjustment != NULL((void*)0)) | |||
1295 | { | |||
1296 | g_object_unref (icon_view->priv->vadjustment); | |||
1297 | icon_view->priv->vadjustment = NULL((void*)0); | |||
1298 | } | |||
1299 | ||||
1300 | CTK_WIDGET_CLASS (ctk_icon_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_icon_view_parent_class)), ((ctk_widget_get_type ())) ))))->destroy (widget); | |||
1301 | } | |||
1302 | ||||
1303 | static void | |||
1304 | ctk_icon_view_realize (CtkWidget *widget) | |||
1305 | { | |||
1306 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1307 | CtkAllocation allocation; | |||
1308 | CdkWindow *window; | |||
1309 | CdkWindowAttr attributes; | |||
1310 | gint attributes_mask; | |||
1311 | ||||
1312 | ctk_widget_set_realized (widget, TRUE(!(0))); | |||
1313 | ||||
1314 | ctk_widget_get_allocation (widget, &allocation); | |||
1315 | ||||
1316 | /* Make the main, clipping window */ | |||
1317 | attributes.window_type = CDK_WINDOW_CHILD; | |||
1318 | attributes.x = allocation.x; | |||
1319 | attributes.y = allocation.y; | |||
1320 | attributes.width = allocation.width; | |||
1321 | attributes.height = allocation.height; | |||
1322 | attributes.wclass = CDK_INPUT_OUTPUT; | |||
1323 | attributes.visual = ctk_widget_get_visual (widget); | |||
1324 | attributes.event_mask = CDK_VISIBILITY_NOTIFY_MASK; | |||
1325 | ||||
1326 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; | |||
1327 | ||||
1328 | window = cdk_window_new (ctk_widget_get_parent_window (widget), | |||
1329 | &attributes, attributes_mask); | |||
1330 | ctk_widget_set_window (widget, window); | |||
1331 | ctk_widget_register_window (widget, window); | |||
1332 | ||||
1333 | ctk_widget_get_allocation (widget, &allocation); | |||
1334 | ||||
1335 | /* Make the window for the icon view */ | |||
1336 | attributes.x = 0; | |||
1337 | attributes.y = 0; | |||
1338 | attributes.width = MAX (icon_view->priv->width, allocation.width)(((icon_view->priv->width) > (allocation.width)) ? ( icon_view->priv->width) : (allocation.width)); | |||
1339 | attributes.height = MAX (icon_view->priv->height, allocation.height)(((icon_view->priv->height) > (allocation.height)) ? (icon_view->priv->height) : (allocation.height)); | |||
1340 | attributes.event_mask = (CDK_SCROLL_MASK | | |||
1341 | CDK_SMOOTH_SCROLL_MASK | | |||
1342 | CDK_POINTER_MOTION_MASK | | |||
1343 | CDK_LEAVE_NOTIFY_MASK | | |||
1344 | CDK_BUTTON_PRESS_MASK | | |||
1345 | CDK_BUTTON_RELEASE_MASK | | |||
1346 | CDK_KEY_PRESS_MASK | | |||
1347 | CDK_KEY_RELEASE_MASK) | | |||
1348 | ctk_widget_get_events (widget); | |||
1349 | ||||
1350 | icon_view->priv->bin_window = cdk_window_new (window, | |||
1351 | &attributes, attributes_mask); | |||
1352 | ctk_widget_register_window (widget, icon_view->priv->bin_window); | |||
1353 | cdk_window_show (icon_view->priv->bin_window); | |||
1354 | } | |||
1355 | ||||
1356 | static void | |||
1357 | ctk_icon_view_unrealize (CtkWidget *widget) | |||
1358 | { | |||
1359 | CtkIconView *icon_view; | |||
1360 | ||||
1361 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1362 | ||||
1363 | ctk_widget_unregister_window (widget, icon_view->priv->bin_window); | |||
1364 | cdk_window_destroy (icon_view->priv->bin_window); | |||
1365 | icon_view->priv->bin_window = NULL((void*)0); | |||
1366 | ||||
1367 | CTK_WIDGET_CLASS (ctk_icon_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_icon_view_parent_class)), ((ctk_widget_get_type ())) ))))->unrealize (widget); | |||
1368 | } | |||
1369 | ||||
1370 | static gint | |||
1371 | ctk_icon_view_get_n_items (CtkIconView *icon_view) | |||
1372 | { | |||
1373 | CtkIconViewPrivate *priv = icon_view->priv; | |||
1374 | ||||
1375 | if (priv->model == NULL((void*)0)) | |||
1376 | return 0; | |||
1377 | ||||
1378 | return ctk_tree_model_iter_n_children (priv->model, NULL((void*)0)); | |||
1379 | } | |||
1380 | ||||
1381 | static void | |||
1382 | adjust_wrap_width (CtkIconView *icon_view) | |||
1383 | { | |||
1384 | if (icon_view->priv->text_cell) | |||
1385 | { | |||
1386 | gint pixbuf_width, wrap_width; | |||
1387 | ||||
1388 | if (icon_view->priv->items && icon_view->priv->pixbuf_cell) | |||
1389 | { | |||
1390 | ctk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell, | |||
1391 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
1392 | &pixbuf_width, NULL((void*)0)); | |||
1393 | } | |||
1394 | else | |||
1395 | { | |||
1396 | pixbuf_width = 0; | |||
1397 | } | |||
1398 | ||||
1399 | if (icon_view->priv->item_width >= 0) | |||
1400 | { | |||
1401 | if (icon_view->priv->item_orientation == CTK_ORIENTATION_VERTICAL) | |||
1402 | { | |||
1403 | wrap_width = icon_view->priv->item_width; | |||
1404 | } | |||
1405 | else | |||
1406 | { | |||
1407 | wrap_width = icon_view->priv->item_width - pixbuf_width; | |||
1408 | } | |||
1409 | ||||
1410 | wrap_width -= 2 * icon_view->priv->item_padding * 2; | |||
1411 | } | |||
1412 | else | |||
1413 | { | |||
1414 | wrap_width = MAX (pixbuf_width * 2, 50)(((pixbuf_width * 2) > (50)) ? (pixbuf_width * 2) : (50)); | |||
1415 | } | |||
1416 | ||||
1417 | if (icon_view->priv->items && icon_view->priv->pixbuf_cell) | |||
1418 | { | |||
1419 | /* Here we go with the same old guess, try the icon size and set double | |||
1420 | * the size of the first icon found in the list, naive but works much | |||
1421 | * of the time */ | |||
1422 | ||||
1423 | wrap_width = MAX (wrap_width * 2, 50)(((wrap_width * 2) > (50)) ? (wrap_width * 2) : (50)); | |||
1424 | } | |||
1425 | ||||
1426 | g_object_set (icon_view->priv->text_cell, "wrap-width", wrap_width, NULL((void*)0)); | |||
1427 | g_object_set (icon_view->priv->text_cell, "width", wrap_width, NULL((void*)0)); | |||
1428 | } | |||
1429 | } | |||
1430 | ||||
1431 | /* General notes about layout | |||
1432 | * | |||
1433 | * The icon view is layouted like this: | |||
1434 | * | |||
1435 | * +----------+ s +----------+ | |||
1436 | * | padding | p | padding | | |||
1437 | * | +------+ | a | +------+ | | |||
1438 | * | | cell | | c | | cell | | | |||
1439 | * | +------+ | i | +------+ | | |||
1440 | * | | n | | | |||
1441 | * +----------+ g +----------+ | |||
1442 | * | |||
1443 | * In size request and allocation code, there are 3 sizes that are used: | |||
1444 | * * cell size | |||
1445 | * This is the size returned by ctk_cell_area_get_preferred_foo(). In places | |||
1446 | * where code is interacting with the cell area and renderers this is useful. | |||
1447 | * * padded size | |||
1448 | * This is the cell size plus the item padding on each side. | |||
1449 | * * spaced size | |||
1450 | * This is the padded size plus the spacing. This is what’s used for most | |||
1451 | * calculations because it can (ab)use the following formula: | |||
1452 | * iconview_size = 2 * margin + n_items * spaced_size - spacing | |||
1453 | * So when reading this code and fixing my bugs where I confuse these two, be | |||
1454 | * aware of this distinction. | |||
1455 | */ | |||
1456 | static void | |||
1457 | cell_area_get_preferred_size (CtkIconView *icon_view, | |||
1458 | CtkCellAreaContext *context, | |||
1459 | CtkOrientation orientation, | |||
1460 | gint for_size, | |||
1461 | gint *minimum, | |||
1462 | gint *natural) | |||
1463 | { | |||
1464 | if (orientation == CTK_ORIENTATION_HORIZONTAL) | |||
1465 | { | |||
1466 | if (for_size > 0) | |||
1467 | ctk_cell_area_get_preferred_width_for_height (icon_view->priv->cell_area, | |||
1468 | context, | |||
1469 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
1470 | for_size, | |||
1471 | minimum, natural); | |||
1472 | else | |||
1473 | ctk_cell_area_get_preferred_width (icon_view->priv->cell_area, | |||
1474 | context, | |||
1475 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
1476 | minimum, natural); | |||
1477 | } | |||
1478 | else | |||
1479 | { | |||
1480 | if (for_size > 0) | |||
1481 | ctk_cell_area_get_preferred_height_for_width (icon_view->priv->cell_area, | |||
1482 | context, | |||
1483 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
1484 | for_size, | |||
1485 | minimum, natural); | |||
1486 | else | |||
1487 | ctk_cell_area_get_preferred_height (icon_view->priv->cell_area, | |||
1488 | context, | |||
1489 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
1490 | minimum, natural); | |||
1491 | } | |||
1492 | } | |||
1493 | ||||
1494 | static gboolean | |||
1495 | ctk_icon_view_is_empty (CtkIconView *icon_view) | |||
1496 | { | |||
1497 | return icon_view->priv->items == NULL((void*)0); | |||
1498 | } | |||
1499 | ||||
1500 | static void | |||
1501 | ctk_icon_view_get_preferred_item_size (CtkIconView *icon_view, | |||
1502 | CtkOrientation orientation, | |||
1503 | gint for_size, | |||
1504 | gint *minimum, | |||
1505 | gint *natural) | |||
1506 | { | |||
1507 | CtkIconViewPrivate *priv = icon_view->priv; | |||
1508 | CtkCellAreaContext *context; | |||
1509 | GList *items; | |||
1510 | ||||
1511 | g_assert (!ctk_icon_view_is_empty (icon_view))do { if (!ctk_icon_view_is_empty (icon_view)) ; else g_assertion_message_expr ("Ctk", "ctkiconview.c", 1511, ((const char*) (__func__)), "!ctk_icon_view_is_empty (icon_view)" ); } while (0); | |||
1512 | ||||
1513 | context = ctk_cell_area_create_context (priv->cell_area); | |||
1514 | ||||
1515 | for_size -= 2 * priv->item_padding; | |||
1516 | ||||
1517 | if (for_size > 0) | |||
1518 | { | |||
1519 | /* This is necessary for the context to work properly */ | |||
1520 | for (items = priv->items; items; items = items->next) | |||
1521 | { | |||
1522 | CtkIconViewItem *item = items->data; | |||
1523 | ||||
1524 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
1525 | cell_area_get_preferred_size (icon_view, context, 1 - orientation, -1, NULL((void*)0), NULL((void*)0)); | |||
1526 | } | |||
1527 | } | |||
1528 | ||||
1529 | for (items = priv->items; items; items = items->next) | |||
1530 | { | |||
1531 | CtkIconViewItem *item = items->data; | |||
1532 | ||||
1533 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
1534 | if (items == priv->items) | |||
1535 | adjust_wrap_width (icon_view); | |||
1536 | cell_area_get_preferred_size (icon_view, context, orientation, for_size, NULL((void*)0), NULL((void*)0)); | |||
1537 | } | |||
1538 | ||||
1539 | if (orientation == CTK_ORIENTATION_HORIZONTAL) | |||
1540 | { | |||
1541 | if (for_size > 0) | |||
1542 | ctk_cell_area_context_get_preferred_width_for_height (context, | |||
1543 | for_size, | |||
1544 | minimum, natural); | |||
1545 | else | |||
1546 | ctk_cell_area_context_get_preferred_width (context, | |||
1547 | minimum, natural); | |||
1548 | } | |||
1549 | else | |||
1550 | { | |||
1551 | if (for_size > 0) | |||
1552 | ctk_cell_area_context_get_preferred_height_for_width (context, | |||
1553 | for_size, | |||
1554 | minimum, natural); | |||
1555 | else | |||
1556 | ctk_cell_area_context_get_preferred_height (context, | |||
1557 | minimum, natural); | |||
1558 | } | |||
1559 | ||||
1560 | if (orientation == CTK_ORIENTATION_HORIZONTAL && priv->item_width >= 0) | |||
1561 | { | |||
1562 | if (minimum) | |||
1563 | *minimum = MAX (*minimum, priv->item_width)(((*minimum) > (priv->item_width)) ? (*minimum) : (priv ->item_width)); | |||
1564 | if (natural) | |||
1565 | *natural = *minimum; | |||
1566 | } | |||
1567 | ||||
1568 | if (minimum) | |||
1569 | *minimum = MAX (1, *minimum + 2 * priv->item_padding)(((1) > (*minimum + 2 * priv->item_padding)) ? (1) : (* minimum + 2 * priv->item_padding)); | |||
1570 | if (natural) | |||
1571 | *natural = MAX (1, *natural + 2 * priv->item_padding)(((1) > (*natural + 2 * priv->item_padding)) ? (1) : (* natural + 2 * priv->item_padding)); | |||
1572 | ||||
1573 | g_object_unref (context); | |||
1574 | } | |||
1575 | ||||
1576 | static void | |||
1577 | ctk_icon_view_compute_n_items_for_size (CtkIconView *icon_view, | |||
1578 | CtkOrientation orientation, | |||
1579 | gint size, | |||
1580 | gint *min_items, | |||
1581 | gint *min_item_size, | |||
1582 | gint *max_items, | |||
1583 | gint *max_item_size) | |||
1584 | { | |||
1585 | CtkIconViewPrivate *priv = icon_view->priv; | |||
1586 | int minimum, natural, spacing; | |||
1587 | ||||
1588 | g_return_if_fail (min_item_size == NULL || min_items != NULL)do { if ((min_item_size == ((void*)0) || min_items != ((void* )0))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "min_item_size == NULL || min_items != NULL") ; return; } } while (0); | |||
1589 | g_return_if_fail (max_item_size == NULL || max_items != NULL)do { if ((max_item_size == ((void*)0) || max_items != ((void* )0))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "max_item_size == NULL || max_items != NULL") ; return; } } while (0); | |||
1590 | g_return_if_fail (!ctk_icon_view_is_empty (icon_view))do { if ((!ctk_icon_view_is_empty (icon_view))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!ctk_icon_view_is_empty (icon_view)" ); return; } } while (0); | |||
1591 | ||||
1592 | ctk_icon_view_get_preferred_item_size (icon_view, orientation, -1, &minimum, &natural); | |||
1593 | ||||
1594 | if (orientation == CTK_ORIENTATION_HORIZONTAL) | |||
1595 | spacing = priv->column_spacing; | |||
1596 | else | |||
1597 | spacing = priv->row_spacing; | |||
1598 | ||||
1599 | size -= 2 * priv->margin; | |||
1600 | size += spacing; | |||
1601 | minimum += spacing; | |||
1602 | natural += spacing; | |||
1603 | ||||
1604 | if (priv->columns > 0) | |||
1605 | { | |||
1606 | if (orientation == CTK_ORIENTATION_HORIZONTAL) | |||
1607 | { | |||
1608 | if (min_items) | |||
1609 | *min_items = priv->columns; | |||
1610 | if (max_items) | |||
1611 | *max_items = priv->columns; | |||
1612 | } | |||
1613 | else | |||
1614 | { | |||
1615 | int n_items = ctk_icon_view_get_n_items (icon_view); | |||
1616 | ||||
1617 | if (min_items) | |||
1618 | *min_items = (n_items + priv->columns - 1) / priv->columns; | |||
1619 | if (max_items) | |||
1620 | *max_items = (n_items + priv->columns - 1) / priv->columns; | |||
1621 | } | |||
1622 | } | |||
1623 | else | |||
1624 | { | |||
1625 | if (max_items) | |||
1626 | { | |||
1627 | if (size <= minimum) | |||
1628 | *max_items = 1; | |||
1629 | else | |||
1630 | *max_items = size / minimum; | |||
1631 | } | |||
1632 | ||||
1633 | if (min_items) | |||
1634 | { | |||
1635 | if (size <= natural) | |||
1636 | *min_items = 1; | |||
1637 | else | |||
1638 | *min_items = size / natural; | |||
1639 | } | |||
1640 | } | |||
1641 | ||||
1642 | if (min_item_size) | |||
1643 | { | |||
1644 | *min_item_size = size / *min_items; | |||
1645 | *min_item_size = CLAMP (*min_item_size, minimum, natural)(((*min_item_size) > (natural)) ? (natural) : (((*min_item_size ) < (minimum)) ? (minimum) : (*min_item_size))); | |||
1646 | *min_item_size -= spacing; | |||
1647 | *min_item_size -= 2 * priv->item_padding; | |||
1648 | } | |||
1649 | ||||
1650 | if (max_item_size) | |||
1651 | { | |||
1652 | *max_item_size = size / *max_items; | |||
1653 | *max_item_size = CLAMP (*max_item_size, minimum, natural)(((*max_item_size) > (natural)) ? (natural) : (((*max_item_size ) < (minimum)) ? (minimum) : (*max_item_size))); | |||
1654 | *max_item_size -= spacing; | |||
1655 | *max_item_size -= 2 * priv->item_padding; | |||
1656 | } | |||
1657 | } | |||
1658 | ||||
1659 | static CtkSizeRequestMode | |||
1660 | ctk_icon_view_get_request_mode (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
1661 | { | |||
1662 | return CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; | |||
1663 | } | |||
1664 | ||||
1665 | static void | |||
1666 | ctk_icon_view_get_preferred_width (CtkWidget *widget, | |||
1667 | gint *minimum, | |||
1668 | gint *natural) | |||
1669 | { | |||
1670 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1671 | CtkIconViewPrivate *priv = icon_view->priv; | |||
1672 | int item_min, item_nat; | |||
1673 | ||||
1674 | if (ctk_icon_view_is_empty (icon_view)) | |||
1675 | { | |||
1676 | *minimum = *natural = 2 * priv->margin; | |||
1677 | return; | |||
1678 | } | |||
1679 | ||||
1680 | ctk_icon_view_get_preferred_item_size (icon_view, CTK_ORIENTATION_HORIZONTAL, -1, &item_min, &item_nat); | |||
1681 | ||||
1682 | if (priv->columns > 0) | |||
1683 | { | |||
1684 | *minimum = item_min * priv->columns + priv->column_spacing * (priv->columns - 1); | |||
1685 | *natural = item_nat * priv->columns + priv->column_spacing * (priv->columns - 1); | |||
1686 | } | |||
1687 | else | |||
1688 | { | |||
1689 | int n_items = ctk_icon_view_get_n_items (icon_view); | |||
1690 | ||||
1691 | *minimum = item_min; | |||
1692 | *natural = item_nat * n_items + priv->column_spacing * (n_items - 1); | |||
1693 | } | |||
1694 | ||||
1695 | *minimum += 2 * priv->margin; | |||
1696 | *natural += 2 * priv->margin; | |||
1697 | } | |||
1698 | ||||
1699 | static void | |||
1700 | ctk_icon_view_get_preferred_width_for_height (CtkWidget *widget, | |||
1701 | gint height, | |||
1702 | gint *minimum, | |||
1703 | gint *natural) | |||
1704 | { | |||
1705 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1706 | CtkIconViewPrivate *priv = icon_view->priv; | |||
1707 | int item_min, item_nat, rows, row_height, n_items; | |||
1708 | ||||
1709 | if (ctk_icon_view_is_empty (icon_view)) | |||
1710 | { | |||
1711 | *minimum = *natural = 2 * priv->margin; | |||
1712 | return; | |||
1713 | } | |||
1714 | ||||
1715 | ctk_icon_view_compute_n_items_for_size (icon_view, CTK_ORIENTATION_VERTICAL, height, &rows, &row_height, NULL((void*)0), NULL((void*)0)); | |||
1716 | n_items = ctk_icon_view_get_n_items (icon_view); | |||
1717 | ||||
1718 | ctk_icon_view_get_preferred_item_size (icon_view, CTK_ORIENTATION_HORIZONTAL, row_height, &item_min, &item_nat); | |||
1719 | *minimum = (item_min + priv->column_spacing) * ((n_items + rows - 1) / rows) - priv->column_spacing; | |||
1720 | *natural = (item_nat + priv->column_spacing) * ((n_items + rows - 1) / rows) - priv->column_spacing; | |||
1721 | ||||
1722 | *minimum += 2 * priv->margin; | |||
1723 | *natural += 2 * priv->margin; | |||
1724 | } | |||
1725 | ||||
1726 | static void | |||
1727 | ctk_icon_view_get_preferred_height (CtkWidget *widget, | |||
1728 | gint *minimum, | |||
1729 | gint *natural) | |||
1730 | { | |||
1731 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1732 | CtkIconViewPrivate *priv = icon_view->priv; | |||
1733 | int item_min, item_nat, n_items; | |||
1734 | ||||
1735 | if (ctk_icon_view_is_empty (icon_view)) | |||
1736 | { | |||
1737 | *minimum = *natural = 2 * priv->margin; | |||
1738 | return; | |||
1739 | } | |||
1740 | ||||
1741 | ctk_icon_view_get_preferred_item_size (icon_view, CTK_ORIENTATION_VERTICAL, -1, &item_min, &item_nat); | |||
1742 | n_items = ctk_icon_view_get_n_items (icon_view); | |||
1743 | ||||
1744 | if (priv->columns > 0) | |||
1745 | { | |||
1746 | int n_rows = (n_items + priv->columns - 1) / priv->columns; | |||
1747 | ||||
1748 | *minimum = item_min * n_rows + priv->row_spacing * (n_rows - 1); | |||
1749 | *natural = item_nat * n_rows + priv->row_spacing * (n_rows - 1); | |||
1750 | } | |||
1751 | else | |||
1752 | { | |||
1753 | *minimum = item_min; | |||
1754 | *natural = item_nat * n_items + priv->row_spacing * (n_items - 1); | |||
1755 | } | |||
1756 | ||||
1757 | *minimum += 2 * priv->margin; | |||
1758 | *natural += 2 * priv->margin; | |||
1759 | } | |||
1760 | ||||
1761 | static void | |||
1762 | ctk_icon_view_get_preferred_height_for_width (CtkWidget *widget, | |||
1763 | gint width, | |||
1764 | gint *minimum, | |||
1765 | gint *natural) | |||
1766 | { | |||
1767 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1768 | CtkIconViewPrivate *priv = icon_view->priv; | |||
1769 | int item_min, item_nat, columns, column_width, n_items; | |||
1770 | ||||
1771 | if (ctk_icon_view_is_empty (icon_view)) | |||
1772 | { | |||
1773 | *minimum = *natural = 2 * priv->margin; | |||
1774 | return; | |||
1775 | } | |||
1776 | ||||
1777 | ctk_icon_view_compute_n_items_for_size (icon_view, CTK_ORIENTATION_HORIZONTAL, width, NULL((void*)0), NULL((void*)0), &columns, &column_width); | |||
1778 | n_items = ctk_icon_view_get_n_items (icon_view); | |||
1779 | ||||
1780 | ctk_icon_view_get_preferred_item_size (icon_view, CTK_ORIENTATION_VERTICAL, column_width, &item_min, &item_nat); | |||
1781 | *minimum = (item_min + priv->row_spacing) * ((n_items + columns - 1) / columns) - priv->row_spacing; | |||
1782 | *natural = (item_nat + priv->row_spacing) * ((n_items + columns - 1) / columns) - priv->row_spacing; | |||
1783 | ||||
1784 | *minimum += 2 * priv->margin; | |||
1785 | *natural += 2 * priv->margin; | |||
1786 | } | |||
1787 | ||||
1788 | static void | |||
1789 | ctk_icon_view_allocate_children (CtkIconView *icon_view) | |||
1790 | { | |||
1791 | GList *list; | |||
1792 | ||||
1793 | for (list = icon_view->priv->children; list; list = list->next) | |||
1794 | { | |||
1795 | CtkIconViewChild *child = list->data; | |||
1796 | ||||
1797 | /* totally ignore our child's requisition */ | |||
1798 | ctk_widget_size_allocate (child->widget, &child->area); | |||
1799 | } | |||
1800 | } | |||
1801 | ||||
1802 | static void | |||
1803 | ctk_icon_view_size_allocate (CtkWidget *widget, | |||
1804 | CtkAllocation *allocation) | |||
1805 | { | |||
1806 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1807 | ||||
1808 | ctk_widget_set_allocation (widget, allocation); | |||
1809 | ||||
1810 | ctk_icon_view_layout (icon_view); | |||
1811 | ||||
1812 | if (ctk_widget_get_realized (widget)) | |||
1813 | { | |||
1814 | cdk_window_move_resize (ctk_widget_get_window (widget), | |||
1815 | allocation->x, allocation->y, | |||
1816 | allocation->width, allocation->height); | |||
1817 | cdk_window_resize (icon_view->priv->bin_window, | |||
1818 | MAX (icon_view->priv->width, allocation->width)(((icon_view->priv->width) > (allocation->width)) ? (icon_view->priv->width) : (allocation->width)), | |||
1819 | MAX (icon_view->priv->height, allocation->height)(((icon_view->priv->height) > (allocation->height )) ? (icon_view->priv->height) : (allocation->height ))); | |||
1820 | } | |||
1821 | ||||
1822 | ctk_icon_view_allocate_children (icon_view); | |||
1823 | ||||
1824 | /* Delay signal emission */ | |||
1825 | g_object_freeze_notify (G_OBJECT (icon_view->priv->hadjustment)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view->priv->hadjustment)), (((GType) ((20) << (2))))))))); | |||
1826 | g_object_freeze_notify (G_OBJECT (icon_view->priv->vadjustment)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view->priv->vadjustment)), (((GType) ((20) << (2))))))))); | |||
1827 | ||||
1828 | ctk_icon_view_set_hadjustment_values (icon_view); | |||
1829 | ctk_icon_view_set_vadjustment_values (icon_view); | |||
1830 | ||||
1831 | if (ctk_widget_get_realized (widget) && | |||
1832 | icon_view->priv->scroll_to_path) | |||
1833 | { | |||
1834 | CtkTreePath *path; | |||
1835 | path = ctk_tree_row_reference_get_path (icon_view->priv->scroll_to_path); | |||
1836 | ctk_tree_row_reference_free (icon_view->priv->scroll_to_path); | |||
1837 | icon_view->priv->scroll_to_path = NULL((void*)0); | |||
1838 | ||||
1839 | ctk_icon_view_scroll_to_path (icon_view, path, | |||
1840 | icon_view->priv->scroll_to_use_align, | |||
1841 | icon_view->priv->scroll_to_row_align, | |||
1842 | icon_view->priv->scroll_to_col_align); | |||
1843 | ctk_tree_path_free (path); | |||
1844 | } | |||
1845 | ||||
1846 | /* Emit any pending signals now */ | |||
1847 | g_object_thaw_notify (G_OBJECT (icon_view->priv->hadjustment)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view->priv->hadjustment)), (((GType) ((20) << (2))))))))); | |||
1848 | g_object_thaw_notify (G_OBJECT (icon_view->priv->vadjustment)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view->priv->vadjustment)), (((GType) ((20) << (2))))))))); | |||
1849 | } | |||
1850 | ||||
1851 | static gboolean | |||
1852 | ctk_icon_view_draw (CtkWidget *widget, | |||
1853 | cairo_t *cr) | |||
1854 | { | |||
1855 | CtkIconView *icon_view; | |||
1856 | GList *icons; | |||
1857 | CtkTreePath *path; | |||
1858 | gint dest_index; | |||
1859 | CtkIconViewDropPosition dest_pos; | |||
1860 | CtkIconViewItem *dest_item = NULL((void*)0); | |||
1861 | CtkStyleContext *context; | |||
1862 | ||||
1863 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1864 | ||||
1865 | context = ctk_widget_get_style_context (widget); | |||
1866 | ctk_render_background (context, cr, | |||
1867 | 0, 0, | |||
1868 | ctk_widget_get_allocated_width (widget), | |||
1869 | ctk_widget_get_allocated_height (widget)); | |||
1870 | ||||
1871 | if (!ctk_cairo_should_draw_window (cr, icon_view->priv->bin_window)) | |||
1872 | return FALSE(0); | |||
1873 | ||||
1874 | cairo_save (cr); | |||
1875 | ||||
1876 | ctk_cairo_transform_to_window (cr, widget, icon_view->priv->bin_window); | |||
1877 | ||||
1878 | cairo_set_line_width (cr, 1.); | |||
1879 | ||||
1880 | ctk_icon_view_get_drag_dest_item (icon_view, &path, &dest_pos); | |||
1881 | ||||
1882 | if (path) | |||
1883 | { | |||
1884 | dest_index = ctk_tree_path_get_indices (path)[0]; | |||
1885 | ctk_tree_path_free (path); | |||
1886 | } | |||
1887 | else | |||
1888 | dest_index = -1; | |||
1889 | ||||
1890 | for (icons = icon_view->priv->items; icons; icons = icons->next) | |||
1891 | { | |||
1892 | CtkIconViewItem *item = icons->data; | |||
1893 | CdkRectangle paint_area; | |||
1894 | ||||
1895 | paint_area.x = item->cell_area.x - icon_view->priv->item_padding; | |||
1896 | paint_area.y = item->cell_area.y - icon_view->priv->item_padding; | |||
1897 | paint_area.width = item->cell_area.width + icon_view->priv->item_padding * 2; | |||
1898 | paint_area.height = item->cell_area.height + icon_view->priv->item_padding * 2; | |||
1899 | ||||
1900 | cairo_save (cr); | |||
1901 | ||||
1902 | cairo_rectangle (cr, paint_area.x, paint_area.y, paint_area.width, paint_area.height); | |||
1903 | cairo_clip (cr); | |||
1904 | ||||
1905 | if (cdk_cairo_get_clip_rectangle (cr, NULL((void*)0))) | |||
1906 | { | |||
1907 | ctk_icon_view_paint_item (icon_view, cr, item, | |||
1908 | item->cell_area.x, item->cell_area.y, | |||
1909 | icon_view->priv->draw_focus); | |||
1910 | ||||
1911 | if (dest_index == item->index) | |||
1912 | dest_item = item; | |||
1913 | } | |||
1914 | ||||
1915 | cairo_restore (cr); | |||
1916 | } | |||
1917 | ||||
1918 | if (dest_item && | |||
1919 | dest_pos != CTK_ICON_VIEW_NO_DROP) | |||
1920 | { | |||
1921 | CdkRectangle rect = { 0 }; | |||
1922 | ||||
1923 | switch (dest_pos) | |||
1924 | { | |||
1925 | case CTK_ICON_VIEW_DROP_INTO: | |||
1926 | rect = dest_item->cell_area; | |||
1927 | break; | |||
1928 | case CTK_ICON_VIEW_DROP_ABOVE: | |||
1929 | rect.x = dest_item->cell_area.x; | |||
1930 | rect.y = dest_item->cell_area.y - 1; | |||
1931 | rect.width = dest_item->cell_area.width; | |||
1932 | rect.height = 2; | |||
1933 | break; | |||
1934 | case CTK_ICON_VIEW_DROP_LEFT: | |||
1935 | rect.x = dest_item->cell_area.x - 1; | |||
1936 | rect.y = dest_item->cell_area.y; | |||
1937 | rect.width = 2; | |||
1938 | rect.height = dest_item->cell_area.height; | |||
1939 | break; | |||
1940 | case CTK_ICON_VIEW_DROP_BELOW: | |||
1941 | rect.x = dest_item->cell_area.x; | |||
1942 | rect.y = dest_item->cell_area.y + dest_item->cell_area.height - 1; | |||
1943 | rect.width = dest_item->cell_area.width; | |||
1944 | rect.height = 2; | |||
1945 | break; | |||
1946 | case CTK_ICON_VIEW_DROP_RIGHT: | |||
1947 | rect.x = dest_item->cell_area.x + dest_item->cell_area.width - 1; | |||
1948 | rect.y = dest_item->cell_area.y; | |||
1949 | rect.width = 2; | |||
1950 | rect.height = dest_item->cell_area.height; | |||
1951 | case CTK_ICON_VIEW_NO_DROP: ; | |||
1952 | break; | |||
1953 | } | |||
1954 | ||||
1955 | ctk_render_focus (context, cr, | |||
1956 | rect.x, rect.y, | |||
1957 | rect.width, rect.height); | |||
1958 | } | |||
1959 | ||||
1960 | if (icon_view->priv->doing_rubberband) | |||
1961 | ctk_icon_view_paint_rubberband (icon_view, cr); | |||
1962 | ||||
1963 | cairo_restore (cr); | |||
1964 | ||||
1965 | return CTK_WIDGET_CLASS (ctk_icon_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_icon_view_parent_class)), ((ctk_widget_get_type ())) ))))->draw (widget, cr); | |||
1966 | } | |||
1967 | ||||
1968 | static gboolean | |||
1969 | rubberband_scroll_timeout (gpointer data) | |||
1970 | { | |||
1971 | CtkIconView *icon_view = data; | |||
1972 | ||||
1973 | ctk_adjustment_set_value (icon_view->priv->vadjustment, | |||
1974 | ctk_adjustment_get_value (icon_view->priv->vadjustment) + | |||
1975 | icon_view->priv->scroll_value_diff); | |||
1976 | ||||
1977 | ctk_icon_view_update_rubberband (icon_view); | |||
1978 | ||||
1979 | return TRUE(!(0)); | |||
1980 | } | |||
1981 | ||||
1982 | static gboolean | |||
1983 | ctk_icon_view_motion (CtkWidget *widget, | |||
1984 | CdkEventMotion *event) | |||
1985 | { | |||
1986 | CtkAllocation allocation; | |||
1987 | CtkIconView *icon_view; | |||
1988 | gint abs_y; | |||
1989 | ||||
1990 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
1991 | ||||
1992 | ctk_icon_view_maybe_begin_drag (icon_view, event); | |||
1993 | ||||
1994 | if (icon_view->priv->doing_rubberband) | |||
1995 | { | |||
1996 | ctk_icon_view_update_rubberband (widget); | |||
1997 | ||||
1998 | abs_y = event->y - icon_view->priv->height * | |||
1999 | (ctk_adjustment_get_value (icon_view->priv->vadjustment) / | |||
2000 | (ctk_adjustment_get_upper (icon_view->priv->vadjustment) - | |||
2001 | ctk_adjustment_get_lower (icon_view->priv->vadjustment))); | |||
2002 | ||||
2003 | ctk_widget_get_allocation (widget, &allocation); | |||
2004 | ||||
2005 | if (abs_y < 0 || abs_y > allocation.height) | |||
2006 | { | |||
2007 | if (abs_y < 0) | |||
2008 | icon_view->priv->scroll_value_diff = abs_y; | |||
2009 | else | |||
2010 | icon_view->priv->scroll_value_diff = abs_y - allocation.height; | |||
2011 | ||||
2012 | icon_view->priv->event_last_x = event->x; | |||
2013 | icon_view->priv->event_last_y = event->y; | |||
2014 | ||||
2015 | if (icon_view->priv->scroll_timeout_id == 0) { | |||
2016 | icon_view->priv->scroll_timeout_id = cdk_threads_add_timeout (30, rubberband_scroll_timeout, | |||
2017 | icon_view); | |||
2018 | g_source_set_name_by_id (icon_view->priv->scroll_timeout_id, "[ctk+] rubberband_scroll_timeout"); | |||
2019 | } | |||
2020 | } | |||
2021 | else | |||
2022 | remove_scroll_timeout (icon_view); | |||
2023 | } | |||
2024 | else | |||
2025 | { | |||
2026 | CtkIconViewItem *item, *last_prelight_item; | |||
2027 | CtkCellRenderer *cell = NULL((void*)0); | |||
2028 | ||||
2029 | last_prelight_item = icon_view->priv->last_prelight; | |||
2030 | item = _ctk_icon_view_get_item_at_coords (icon_view, | |||
2031 | event->x, event->y, | |||
2032 | FALSE(0), | |||
2033 | &cell); | |||
2034 | ||||
2035 | if (item != last_prelight_item) | |||
2036 | { | |||
2037 | if (item != NULL((void*)0)) | |||
2038 | { | |||
2039 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
2040 | } | |||
2041 | ||||
2042 | if (last_prelight_item != NULL((void*)0)) | |||
2043 | { | |||
2044 | ctk_icon_view_queue_draw_item (icon_view, | |||
2045 | icon_view->priv->last_prelight); | |||
2046 | } | |||
2047 | ||||
2048 | icon_view->priv->last_prelight = item; | |||
2049 | } | |||
2050 | } | |||
2051 | ||||
2052 | return TRUE(!(0)); | |||
2053 | } | |||
2054 | ||||
2055 | static gboolean | |||
2056 | ctk_icon_view_leave (CtkWidget *widget, | |||
2057 | CdkEventCrossing *event G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
2058 | { | |||
2059 | CtkIconView *icon_view; | |||
2060 | CtkIconViewPrivate *priv; | |||
2061 | ||||
2062 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
2063 | priv = icon_view->priv; | |||
2064 | ||||
2065 | if (priv->last_prelight) | |||
2066 | { | |||
2067 | ctk_icon_view_queue_draw_item (icon_view, priv->last_prelight); | |||
2068 | priv->last_prelight = NULL((void*)0); | |||
2069 | } | |||
2070 | ||||
2071 | return FALSE(0); | |||
2072 | } | |||
2073 | ||||
2074 | static void | |||
2075 | ctk_icon_view_remove (CtkContainer *container, | |||
2076 | CtkWidget *widget) | |||
2077 | { | |||
2078 | CtkIconView *icon_view; | |||
2079 | CtkIconViewChild *child = NULL((void*)0); | |||
2080 | GList *tmp_list; | |||
2081 | ||||
2082 | icon_view = CTK_ICON_VIEW (container)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_icon_view_get_type ())))))); | |||
2083 | ||||
2084 | tmp_list = icon_view->priv->children; | |||
2085 | while (tmp_list) | |||
2086 | { | |||
2087 | child = tmp_list->data; | |||
2088 | if (child->widget == widget) | |||
2089 | { | |||
2090 | ctk_widget_unparent (widget); | |||
2091 | ||||
2092 | icon_view->priv->children = g_list_remove_link (icon_view->priv->children, tmp_list); | |||
2093 | g_list_free_1 (tmp_list); | |||
2094 | g_free (child); | |||
2095 | return; | |||
2096 | } | |||
2097 | ||||
2098 | tmp_list = tmp_list->next; | |||
2099 | } | |||
2100 | } | |||
2101 | ||||
2102 | static void | |||
2103 | ctk_icon_view_forall (CtkContainer *container, | |||
2104 | gboolean include_internals G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2105 | CtkCallback callback, | |||
2106 | gpointer callback_data) | |||
2107 | { | |||
2108 | CtkIconView *icon_view; | |||
2109 | CtkIconViewChild *child = NULL((void*)0); | |||
2110 | GList *tmp_list; | |||
2111 | ||||
2112 | icon_view = CTK_ICON_VIEW (container)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_icon_view_get_type ())))))); | |||
2113 | ||||
2114 | tmp_list = icon_view->priv->children; | |||
2115 | while (tmp_list) | |||
2116 | { | |||
2117 | child = tmp_list->data; | |||
2118 | tmp_list = tmp_list->next; | |||
2119 | ||||
2120 | (* callback) (child->widget, callback_data); | |||
2121 | } | |||
2122 | } | |||
2123 | ||||
2124 | static void | |||
2125 | ctk_icon_view_item_selected_changed (CtkIconView *icon_view, | |||
2126 | CtkIconViewItem *item) | |||
2127 | { | |||
2128 | AtkObject *obj; | |||
2129 | AtkObject *item_obj; | |||
2130 | ||||
2131 | obj = ctk_widget_get_accessible (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
2132 | if (obj != NULL((void*)0)) | |||
2133 | { | |||
2134 | item_obj = atk_object_ref_accessible_child (obj, item->index); | |||
2135 | if (item_obj != NULL((void*)0)) | |||
2136 | { | |||
2137 | atk_object_notify_state_change (item_obj, ATK_STATE_SELECTED, item->selected); | |||
2138 | g_object_unref (item_obj); | |||
2139 | } | |||
2140 | } | |||
2141 | } | |||
2142 | ||||
2143 | static void | |||
2144 | ctk_icon_view_add_editable (CtkCellArea *area G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2145 | CtkCellRenderer *renderer G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2146 | CtkCellEditable *editable, | |||
2147 | CdkRectangle *cell_area, | |||
2148 | const gchar *path G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2149 | CtkIconView *icon_view) | |||
2150 | { | |||
2151 | CtkIconViewChild *child; | |||
2152 | CtkWidget *widget = CTK_WIDGET (editable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editable)), ((ctk_widget_get_type ())))))); | |||
2153 | ||||
2154 | child = g_new (CtkIconViewChild, 1)((CtkIconViewChild *) g_malloc_n ((1), sizeof (CtkIconViewChild ))); | |||
2155 | ||||
2156 | child->widget = widget; | |||
2157 | child->area.x = cell_area->x; | |||
2158 | child->area.y = cell_area->y; | |||
2159 | child->area.width = cell_area->width; | |||
2160 | child->area.height = cell_area->height; | |||
2161 | ||||
2162 | icon_view->priv->children = g_list_append (icon_view->priv->children, child); | |||
2163 | ||||
2164 | if (ctk_widget_get_realized (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))))) | |||
2165 | ctk_widget_set_parent_window (child->widget, icon_view->priv->bin_window); | |||
2166 | ||||
2167 | ctk_widget_set_parent (widget, CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
2168 | } | |||
2169 | ||||
2170 | static void | |||
2171 | ctk_icon_view_remove_editable (CtkCellArea *area, | |||
2172 | CtkCellRenderer *renderer G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2173 | CtkCellEditable *editable, | |||
2174 | CtkIconView *icon_view) | |||
2175 | { | |||
2176 | CtkTreePath *path; | |||
2177 | ||||
2178 | if (ctk_widget_has_focus (CTK_WIDGET (editable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editable)), ((ctk_widget_get_type ())))))))) | |||
2179 | ctk_widget_grab_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
2180 | ||||
2181 | ctk_container_remove (CTK_CONTAINER (icon_view)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_container_get_type ())))))), | |||
2182 | CTK_WIDGET (editable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editable)), ((ctk_widget_get_type ()))))))); | |||
2183 | ||||
2184 | path = ctk_tree_path_new_from_string (ctk_cell_area_get_current_path_string (area)); | |||
2185 | ctk_icon_view_queue_draw_path (icon_view, path); | |||
2186 | ctk_tree_path_free (path); | |||
2187 | } | |||
2188 | ||||
2189 | /** | |||
2190 | * ctk_icon_view_set_cursor: | |||
2191 | * @icon_view: A #CtkIconView | |||
2192 | * @path: A #CtkTreePath | |||
2193 | * @cell: (allow-none): One of the cell renderers of @icon_view, or %NULL | |||
2194 | * @start_editing: %TRUE if the specified cell should start being edited. | |||
2195 | * | |||
2196 | * Sets the current keyboard focus to be at @path, and selects it. This is | |||
2197 | * useful when you want to focus the user’s attention on a particular item. | |||
2198 | * If @cell is not %NULL, then focus is given to the cell specified by | |||
2199 | * it. Additionally, if @start_editing is %TRUE, then editing should be | |||
2200 | * started in the specified cell. | |||
2201 | * | |||
2202 | * This function is often followed by `ctk_widget_grab_focus | |||
2203 | * (icon_view)` in order to give keyboard focus to the widget. | |||
2204 | * Please note that editing can only happen when the widget is realized. | |||
2205 | * | |||
2206 | * Since: 2.8 | |||
2207 | **/ | |||
2208 | void | |||
2209 | ctk_icon_view_set_cursor (CtkIconView *icon_view, | |||
2210 | CtkTreePath *path, | |||
2211 | CtkCellRenderer *cell, | |||
2212 | gboolean start_editing) | |||
2213 | { | |||
2214 | CtkIconViewItem *item = NULL((void*)0); | |||
2215 | ||||
2216 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
2217 | g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return; } } while (0); | |||
2218 | g_return_if_fail (cell == NULL || CTK_IS_CELL_RENDERER (cell))do { if ((cell == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((cell)); GType __t = ((ctk_cell_renderer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell == NULL || CTK_IS_CELL_RENDERER (cell)" ); return; } } while (0); | |||
2219 | ||||
2220 | if (icon_view->priv->cell_area) | |||
2221 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
2222 | ||||
2223 | if (ctk_tree_path_get_depth (path) == 1) | |||
2224 | item = g_list_nth_data (icon_view->priv->items, | |||
2225 | ctk_tree_path_get_indices(path)[0]); | |||
2226 | ||||
2227 | if (!item) | |||
2228 | return; | |||
2229 | ||||
2230 | _ctk_icon_view_set_cursor_item (icon_view, item, cell); | |||
2231 | ctk_icon_view_scroll_to_path (icon_view, path, FALSE(0), 0.0, 0.0); | |||
2232 | ||||
2233 | if (start_editing && | |||
2234 | icon_view->priv->cell_area) | |||
2235 | { | |||
2236 | CtkCellAreaContext *context; | |||
2237 | ||||
2238 | context = g_ptr_array_index (icon_view->priv->row_contexts, item->row)((icon_view->priv->row_contexts)->pdata)[item->row ]; | |||
2239 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
2240 | ctk_cell_area_activate (icon_view->priv->cell_area, context, | |||
2241 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), &item->cell_area, | |||
2242 | 0 /* XXX flags */, TRUE(!(0))); | |||
2243 | } | |||
2244 | } | |||
2245 | ||||
2246 | /** | |||
2247 | * ctk_icon_view_get_cursor: | |||
2248 | * @icon_view: A #CtkIconView | |||
2249 | * @path: (out) (allow-none) (transfer full): Return location for the current | |||
2250 | * cursor path, or %NULL | |||
2251 | * @cell: (out) (allow-none) (transfer none): Return location the current | |||
2252 | * focus cell, or %NULL | |||
2253 | * | |||
2254 | * Fills in @path and @cell with the current cursor path and cell. | |||
2255 | * If the cursor isn’t currently set, then *@path will be %NULL. | |||
2256 | * If no cell currently has focus, then *@cell will be %NULL. | |||
2257 | * | |||
2258 | * The returned #CtkTreePath must be freed with ctk_tree_path_free(). | |||
2259 | * | |||
2260 | * Returns: %TRUE if the cursor is set. | |||
2261 | * | |||
2262 | * Since: 2.8 | |||
2263 | **/ | |||
2264 | gboolean | |||
2265 | ctk_icon_view_get_cursor (CtkIconView *icon_view, | |||
2266 | CtkTreePath **path, | |||
2267 | CtkCellRenderer **cell) | |||
2268 | { | |||
2269 | CtkIconViewItem *item; | |||
2270 | ||||
2271 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
2272 | ||||
2273 | item = icon_view->priv->cursor_item; | |||
2274 | ||||
2275 | if (path != NULL((void*)0)) | |||
2276 | { | |||
2277 | if (item != NULL((void*)0)) | |||
2278 | *path = ctk_tree_path_new_from_indices (item->index, -1); | |||
2279 | else | |||
2280 | *path = NULL((void*)0); | |||
2281 | } | |||
2282 | ||||
2283 | if (cell != NULL((void*)0) && item != NULL((void*)0) && icon_view->priv->cell_area != NULL((void*)0)) | |||
2284 | *cell = ctk_cell_area_get_focus_cell (icon_view->priv->cell_area); | |||
2285 | ||||
2286 | return (item != NULL((void*)0)); | |||
2287 | } | |||
2288 | ||||
2289 | static gboolean | |||
2290 | ctk_icon_view_button_press (CtkWidget *widget, | |||
2291 | CdkEventButton *event) | |||
2292 | { | |||
2293 | CtkIconView *icon_view; | |||
2294 | CtkIconViewItem *item; | |||
2295 | gboolean dirty = FALSE(0); | |||
2296 | CtkCellRenderer *cell = NULL((void*)0), *cursor_cell = NULL((void*)0); | |||
2297 | ||||
2298 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
2299 | ||||
2300 | if (event->window != icon_view->priv->bin_window) | |||
2301 | return FALSE(0); | |||
2302 | ||||
2303 | if (!ctk_widget_has_focus (widget)) | |||
2304 | ctk_widget_grab_focus (widget); | |||
2305 | ||||
2306 | if (event->button == CDK_BUTTON_PRIMARY(1) && event->type == CDK_BUTTON_PRESS) | |||
2307 | { | |||
2308 | CdkModifierType extend_mod_mask; | |||
2309 | CdkModifierType modify_mod_mask; | |||
2310 | ||||
2311 | extend_mod_mask = | |||
2312 | ctk_widget_get_modifier_mask (widget, CDK_MODIFIER_INTENT_EXTEND_SELECTION); | |||
2313 | ||||
2314 | modify_mod_mask = | |||
2315 | ctk_widget_get_modifier_mask (widget, CDK_MODIFIER_INTENT_MODIFY_SELECTION); | |||
2316 | ||||
2317 | item = _ctk_icon_view_get_item_at_coords (icon_view, | |||
2318 | event->x, event->y, | |||
2319 | FALSE(0), | |||
2320 | &cell); | |||
2321 | ||||
2322 | /* | |||
2323 | * We consider only the cells' area as the item area if the | |||
2324 | * item is not selected, but if it *is* selected, the complete | |||
2325 | * selection rectangle is considered to be part of the item. | |||
2326 | */ | |||
2327 | if (item != NULL((void*)0) && (cell != NULL((void*)0) || item->selected)) | |||
2328 | { | |||
2329 | if (cell != NULL((void*)0)) | |||
2330 | { | |||
2331 | if (ctk_cell_renderer_is_activatable (cell)) | |||
2332 | cursor_cell = cell; | |||
2333 | } | |||
2334 | ||||
2335 | ctk_icon_view_scroll_to_item (icon_view, item); | |||
2336 | ||||
2337 | if (icon_view->priv->selection_mode == CTK_SELECTION_NONE) | |||
2338 | { | |||
2339 | _ctk_icon_view_set_cursor_item (icon_view, item, cursor_cell); | |||
2340 | } | |||
2341 | else if (icon_view->priv->selection_mode == CTK_SELECTION_MULTIPLE && | |||
2342 | (event->state & extend_mod_mask)) | |||
2343 | { | |||
2344 | ctk_icon_view_unselect_all_internal (icon_view); | |||
2345 | ||||
2346 | _ctk_icon_view_set_cursor_item (icon_view, item, cursor_cell); | |||
2347 | if (!icon_view->priv->anchor_item) | |||
2348 | icon_view->priv->anchor_item = item; | |||
2349 | else | |||
2350 | ctk_icon_view_select_all_between (icon_view, | |||
2351 | icon_view->priv->anchor_item, | |||
2352 | item); | |||
2353 | dirty = TRUE(!(0)); | |||
2354 | } | |||
2355 | else | |||
2356 | { | |||
2357 | if ((icon_view->priv->selection_mode == CTK_SELECTION_MULTIPLE || | |||
2358 | ((icon_view->priv->selection_mode == CTK_SELECTION_SINGLE) && item->selected)) && | |||
2359 | (event->state & modify_mod_mask)) | |||
2360 | { | |||
2361 | item->selected = !item->selected; | |||
2362 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
2363 | dirty = TRUE(!(0)); | |||
2364 | } | |||
2365 | else | |||
2366 | { | |||
2367 | ctk_icon_view_unselect_all_internal (icon_view); | |||
2368 | ||||
2369 | item->selected = TRUE(!(0)); | |||
2370 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
2371 | dirty = TRUE(!(0)); | |||
2372 | } | |||
2373 | _ctk_icon_view_set_cursor_item (icon_view, item, cursor_cell); | |||
2374 | icon_view->priv->anchor_item = item; | |||
2375 | } | |||
2376 | ||||
2377 | /* Save press to possibly begin a drag */ | |||
2378 | if (icon_view->priv->pressed_button < 0) | |||
2379 | { | |||
2380 | icon_view->priv->pressed_button = event->button; | |||
2381 | icon_view->priv->press_start_x = event->x; | |||
2382 | icon_view->priv->press_start_y = event->y; | |||
2383 | } | |||
2384 | ||||
2385 | icon_view->priv->last_single_clicked = item; | |||
2386 | ||||
2387 | /* cancel the current editing, if it exists */ | |||
2388 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
2389 | ||||
2390 | if (cell != NULL((void*)0) && ctk_cell_renderer_is_activatable (cell)) | |||
2391 | { | |||
2392 | CtkCellAreaContext *context; | |||
2393 | ||||
2394 | context = g_ptr_array_index (icon_view->priv->row_contexts, item->row)((icon_view->priv->row_contexts)->pdata)[item->row ]; | |||
2395 | ||||
2396 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
2397 | ctk_cell_area_activate (icon_view->priv->cell_area, context, | |||
2398 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
2399 | &item->cell_area, 0/* XXX flags */, FALSE(0)); | |||
2400 | } | |||
2401 | } | |||
2402 | else | |||
2403 | { | |||
2404 | if (icon_view->priv->selection_mode != CTK_SELECTION_BROWSE && | |||
2405 | !(event->state & modify_mod_mask)) | |||
2406 | { | |||
2407 | dirty = ctk_icon_view_unselect_all_internal (icon_view); | |||
2408 | } | |||
2409 | ||||
2410 | if (icon_view->priv->selection_mode == CTK_SELECTION_MULTIPLE) | |||
2411 | ctk_icon_view_start_rubberbanding (icon_view, event->device, event->x, event->y); | |||
2412 | } | |||
2413 | ||||
2414 | /* don't draw keyboard focus around an clicked-on item */ | |||
2415 | icon_view->priv->draw_focus = FALSE(0); | |||
2416 | } | |||
2417 | ||||
2418 | if (!icon_view->priv->activate_on_single_click | |||
2419 | && event->button == CDK_BUTTON_PRIMARY(1) | |||
2420 | && event->type == CDK_2BUTTON_PRESS) | |||
2421 | { | |||
2422 | item = _ctk_icon_view_get_item_at_coords (icon_view, | |||
2423 | event->x, event->y, | |||
2424 | FALSE(0), | |||
2425 | NULL((void*)0)); | |||
2426 | ||||
2427 | if (item && item == icon_view->priv->last_single_clicked) | |||
2428 | { | |||
2429 | CtkTreePath *path; | |||
2430 | ||||
2431 | path = ctk_tree_path_new_from_indices (item->index, -1); | |||
2432 | ctk_icon_view_item_activated (icon_view, path); | |||
2433 | ctk_tree_path_free (path); | |||
2434 | } | |||
2435 | ||||
2436 | icon_view->priv->last_single_clicked = NULL((void*)0); | |||
2437 | icon_view->priv->pressed_button = -1; | |||
2438 | } | |||
2439 | ||||
2440 | if (dirty) | |||
2441 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
2442 | ||||
2443 | return event->button == CDK_BUTTON_PRIMARY(1); | |||
2444 | } | |||
2445 | ||||
2446 | static gboolean | |||
2447 | button_event_modifies_selection (CdkEventButton *event) | |||
2448 | { | |||
2449 | return (event->state & (CDK_CONTROL_MASK | CDK_SHIFT_MASK)) != 0; | |||
2450 | } | |||
2451 | ||||
2452 | static gboolean | |||
2453 | ctk_icon_view_button_release (CtkWidget *widget, | |||
2454 | CdkEventButton *event) | |||
2455 | { | |||
2456 | CtkIconView *icon_view; | |||
2457 | ||||
2458 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
2459 | ||||
2460 | if (icon_view->priv->pressed_button == event->button) | |||
2461 | icon_view->priv->pressed_button = -1; | |||
2462 | ||||
2463 | ctk_icon_view_stop_rubberbanding (icon_view); | |||
2464 | ||||
2465 | remove_scroll_timeout (icon_view); | |||
2466 | ||||
2467 | if (event->button == CDK_BUTTON_PRIMARY(1) | |||
2468 | && icon_view->priv->activate_on_single_click | |||
2469 | && !button_event_modifies_selection (event) | |||
2470 | && icon_view->priv->last_single_clicked != NULL((void*)0)) | |||
2471 | { | |||
2472 | CtkIconViewItem *item; | |||
2473 | ||||
2474 | item = _ctk_icon_view_get_item_at_coords (icon_view, | |||
2475 | event->x, event->y, | |||
2476 | FALSE(0), | |||
2477 | NULL((void*)0)); | |||
2478 | if (item == icon_view->priv->last_single_clicked) | |||
2479 | { | |||
2480 | CtkTreePath *path; | |||
2481 | path = ctk_tree_path_new_from_indices (item->index, -1); | |||
2482 | ctk_icon_view_item_activated (icon_view, path); | |||
2483 | ctk_tree_path_free (path); | |||
2484 | } | |||
2485 | ||||
2486 | icon_view->priv->last_single_clicked = NULL((void*)0); | |||
2487 | } | |||
2488 | ||||
2489 | return TRUE(!(0)); | |||
2490 | } | |||
2491 | ||||
2492 | static gboolean | |||
2493 | ctk_icon_view_key_press (CtkWidget *widget, | |||
2494 | CdkEventKey *event) | |||
2495 | { | |||
2496 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
2497 | ||||
2498 | if (icon_view->priv->doing_rubberband) | |||
2499 | { | |||
2500 | if (event->keyval == CDK_KEY_Escape0xff1b) | |||
2501 | ctk_icon_view_stop_rubberbanding (icon_view); | |||
2502 | ||||
2503 | return TRUE(!(0)); | |||
2504 | } | |||
2505 | ||||
2506 | return CTK_WIDGET_CLASS (ctk_icon_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_icon_view_parent_class)), ((ctk_widget_get_type ())) ))))->key_press_event (widget, event); | |||
2507 | } | |||
2508 | ||||
2509 | static gboolean | |||
2510 | ctk_icon_view_key_release (CtkWidget *widget, | |||
2511 | CdkEventKey *event) | |||
2512 | { | |||
2513 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
2514 | ||||
2515 | if (icon_view->priv->doing_rubberband) | |||
2516 | return TRUE(!(0)); | |||
2517 | ||||
2518 | return CTK_WIDGET_CLASS (ctk_icon_view_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_icon_view_parent_class)), ((ctk_widget_get_type ())) ))))->key_release_event (widget, event); | |||
2519 | } | |||
2520 | ||||
2521 | static void | |||
2522 | ctk_icon_view_update_rubberband (gpointer data) | |||
2523 | { | |||
2524 | CtkIconView *icon_view; | |||
2525 | gint x, y; | |||
2526 | CdkRectangle old_area; | |||
2527 | CdkRectangle new_area; | |||
2528 | cairo_region_t *invalid_region; | |||
2529 | ||||
2530 | icon_view = CTK_ICON_VIEW (data)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_icon_view_get_type ())))))); | |||
2531 | ||||
2532 | cdk_window_get_device_position (icon_view->priv->bin_window, | |||
2533 | icon_view->priv->rubberband_device, | |||
2534 | &x, &y, NULL((void*)0)); | |||
2535 | ||||
2536 | x = MAX (x, 0)(((x) > (0)) ? (x) : (0)); | |||
2537 | y = MAX (y, 0)(((y) > (0)) ? (y) : (0)); | |||
2538 | ||||
2539 | old_area.x = MIN (icon_view->priv->rubberband_x1,(((icon_view->priv->rubberband_x1) < (icon_view-> priv->rubberband_x2)) ? (icon_view->priv->rubberband_x1 ) : (icon_view->priv->rubberband_x2)) | |||
2540 | icon_view->priv->rubberband_x2)(((icon_view->priv->rubberband_x1) < (icon_view-> priv->rubberband_x2)) ? (icon_view->priv->rubberband_x1 ) : (icon_view->priv->rubberband_x2)); | |||
2541 | old_area.y = MIN (icon_view->priv->rubberband_y1,(((icon_view->priv->rubberband_y1) < (icon_view-> priv->rubberband_y2)) ? (icon_view->priv->rubberband_y1 ) : (icon_view->priv->rubberband_y2)) | |||
2542 | icon_view->priv->rubberband_y2)(((icon_view->priv->rubberband_y1) < (icon_view-> priv->rubberband_y2)) ? (icon_view->priv->rubberband_y1 ) : (icon_view->priv->rubberband_y2)); | |||
2543 | old_area.width = ABS (icon_view->priv->rubberband_x2 -(((icon_view->priv->rubberband_x2 - icon_view->priv-> rubberband_x1) < 0) ? -(icon_view->priv->rubberband_x2 - icon_view->priv->rubberband_x1) : (icon_view->priv ->rubberband_x2 - icon_view->priv->rubberband_x1)) | |||
2544 | icon_view->priv->rubberband_x1)(((icon_view->priv->rubberband_x2 - icon_view->priv-> rubberband_x1) < 0) ? -(icon_view->priv->rubberband_x2 - icon_view->priv->rubberband_x1) : (icon_view->priv ->rubberband_x2 - icon_view->priv->rubberband_x1)) + 1; | |||
2545 | old_area.height = ABS (icon_view->priv->rubberband_y2 -(((icon_view->priv->rubberband_y2 - icon_view->priv-> rubberband_y1) < 0) ? -(icon_view->priv->rubberband_y2 - icon_view->priv->rubberband_y1) : (icon_view->priv ->rubberband_y2 - icon_view->priv->rubberband_y1)) | |||
2546 | icon_view->priv->rubberband_y1)(((icon_view->priv->rubberband_y2 - icon_view->priv-> rubberband_y1) < 0) ? -(icon_view->priv->rubberband_y2 - icon_view->priv->rubberband_y1) : (icon_view->priv ->rubberband_y2 - icon_view->priv->rubberband_y1)) + 1; | |||
2547 | ||||
2548 | new_area.x = MIN (icon_view->priv->rubberband_x1, x)(((icon_view->priv->rubberband_x1) < (x)) ? (icon_view ->priv->rubberband_x1) : (x)); | |||
2549 | new_area.y = MIN (icon_view->priv->rubberband_y1, y)(((icon_view->priv->rubberband_y1) < (y)) ? (icon_view ->priv->rubberband_y1) : (y)); | |||
2550 | new_area.width = ABS (x - icon_view->priv->rubberband_x1)(((x - icon_view->priv->rubberband_x1) < 0) ? -(x - icon_view ->priv->rubberband_x1) : (x - icon_view->priv->rubberband_x1 )) + 1; | |||
2551 | new_area.height = ABS (y - icon_view->priv->rubberband_y1)(((y - icon_view->priv->rubberband_y1) < 0) ? -(y - icon_view ->priv->rubberband_y1) : (y - icon_view->priv->rubberband_y1 )) + 1; | |||
2552 | ||||
2553 | invalid_region = cairo_region_create_rectangle (&old_area); | |||
2554 | cairo_region_union_rectangle (invalid_region, &new_area); | |||
2555 | ||||
2556 | cdk_window_invalidate_region (icon_view->priv->bin_window, invalid_region, TRUE(!(0))); | |||
2557 | ||||
2558 | cairo_region_destroy (invalid_region); | |||
2559 | ||||
2560 | icon_view->priv->rubberband_x2 = x; | |||
2561 | icon_view->priv->rubberband_y2 = y; | |||
2562 | ||||
2563 | ctk_icon_view_update_rubberband_selection (icon_view); | |||
2564 | } | |||
2565 | ||||
2566 | static void | |||
2567 | ctk_icon_view_start_rubberbanding (CtkIconView *icon_view, | |||
2568 | CdkDevice *device, | |||
2569 | gint x, | |||
2570 | gint y) | |||
2571 | { | |||
2572 | CtkIconViewPrivate *priv = icon_view->priv; | |||
2573 | GList *items; | |||
2574 | CtkCssNode *widget_node; | |||
2575 | ||||
2576 | if (priv->rubberband_device) | |||
2577 | return; | |||
2578 | ||||
2579 | for (items = priv->items; items; items = items->next) | |||
2580 | { | |||
2581 | CtkIconViewItem *item = items->data; | |||
2582 | ||||
2583 | item->selected_before_rubberbanding = item->selected; | |||
2584 | } | |||
2585 | ||||
2586 | priv->rubberband_x1 = x; | |||
2587 | priv->rubberband_y1 = y; | |||
2588 | priv->rubberband_x2 = x; | |||
2589 | priv->rubberband_y2 = y; | |||
2590 | ||||
2591 | priv->doing_rubberband = TRUE(!(0)); | |||
2592 | priv->rubberband_device = device; | |||
2593 | ||||
2594 | widget_node = ctk_widget_get_css_node (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
2595 | priv->rubberband_node = ctk_css_node_new (); | |||
2596 | ctk_css_node_set_name (priv->rubberband_node, I_("rubberband")g_intern_static_string ("rubberband")); | |||
2597 | ctk_css_node_set_parent (priv->rubberband_node, widget_node); | |||
2598 | ctk_css_node_set_state (priv->rubberband_node, ctk_css_node_get_state (widget_node)); | |||
2599 | g_object_unref (priv->rubberband_node); | |||
2600 | } | |||
2601 | ||||
2602 | static void | |||
2603 | ctk_icon_view_stop_rubberbanding (CtkIconView *icon_view) | |||
2604 | { | |||
2605 | CtkIconViewPrivate *priv = icon_view->priv; | |||
2606 | ||||
2607 | if (!priv->doing_rubberband) | |||
2608 | return; | |||
2609 | ||||
2610 | priv->doing_rubberband = FALSE(0); | |||
2611 | priv->rubberband_device = NULL((void*)0); | |||
2612 | ctk_css_node_set_parent (priv->rubberband_node, NULL((void*)0)); | |||
2613 | priv->rubberband_node = NULL((void*)0); | |||
2614 | ||||
2615 | ctk_widget_queue_draw (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
2616 | } | |||
2617 | ||||
2618 | static void | |||
2619 | ctk_icon_view_update_rubberband_selection (CtkIconView *icon_view) | |||
2620 | { | |||
2621 | GList *items; | |||
2622 | gint x, y, width, height; | |||
2623 | gboolean dirty = FALSE(0); | |||
2624 | ||||
2625 | x = MIN (icon_view->priv->rubberband_x1,(((icon_view->priv->rubberband_x1) < (icon_view-> priv->rubberband_x2)) ? (icon_view->priv->rubberband_x1 ) : (icon_view->priv->rubberband_x2)) | |||
2626 | icon_view->priv->rubberband_x2)(((icon_view->priv->rubberband_x1) < (icon_view-> priv->rubberband_x2)) ? (icon_view->priv->rubberband_x1 ) : (icon_view->priv->rubberband_x2)); | |||
2627 | y = MIN (icon_view->priv->rubberband_y1,(((icon_view->priv->rubberband_y1) < (icon_view-> priv->rubberband_y2)) ? (icon_view->priv->rubberband_y1 ) : (icon_view->priv->rubberband_y2)) | |||
2628 | icon_view->priv->rubberband_y2)(((icon_view->priv->rubberband_y1) < (icon_view-> priv->rubberband_y2)) ? (icon_view->priv->rubberband_y1 ) : (icon_view->priv->rubberband_y2)); | |||
2629 | width = ABS (icon_view->priv->rubberband_x1 -(((icon_view->priv->rubberband_x1 - icon_view->priv-> rubberband_x2) < 0) ? -(icon_view->priv->rubberband_x1 - icon_view->priv->rubberband_x2) : (icon_view->priv ->rubberband_x1 - icon_view->priv->rubberband_x2)) | |||
2630 | icon_view->priv->rubberband_x2)(((icon_view->priv->rubberband_x1 - icon_view->priv-> rubberband_x2) < 0) ? -(icon_view->priv->rubberband_x1 - icon_view->priv->rubberband_x2) : (icon_view->priv ->rubberband_x1 - icon_view->priv->rubberband_x2)); | |||
2631 | height = ABS (icon_view->priv->rubberband_y1 -(((icon_view->priv->rubberband_y1 - icon_view->priv-> rubberband_y2) < 0) ? -(icon_view->priv->rubberband_y1 - icon_view->priv->rubberband_y2) : (icon_view->priv ->rubberband_y1 - icon_view->priv->rubberband_y2)) | |||
2632 | icon_view->priv->rubberband_y2)(((icon_view->priv->rubberband_y1 - icon_view->priv-> rubberband_y2) < 0) ? -(icon_view->priv->rubberband_y1 - icon_view->priv->rubberband_y2) : (icon_view->priv ->rubberband_y1 - icon_view->priv->rubberband_y2)); | |||
2633 | ||||
2634 | for (items = icon_view->priv->items; items; items = items->next) | |||
2635 | { | |||
2636 | CtkIconViewItem *item = items->data; | |||
2637 | gboolean is_in; | |||
2638 | gboolean selected; | |||
2639 | ||||
2640 | is_in = ctk_icon_view_item_hit_test (icon_view, item, | |||
2641 | x, y, width, height); | |||
2642 | ||||
2643 | selected = is_in ^ item->selected_before_rubberbanding; | |||
2644 | ||||
2645 | if (item->selected != selected) | |||
2646 | { | |||
2647 | item->selected = selected; | |||
2648 | dirty = TRUE(!(0)); | |||
2649 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
2650 | } | |||
2651 | } | |||
2652 | ||||
2653 | if (dirty) | |||
2654 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
2655 | } | |||
2656 | ||||
2657 | ||||
2658 | typedef struct { | |||
2659 | CdkRectangle hit_rect; | |||
2660 | gboolean hit; | |||
2661 | } HitTestData; | |||
2662 | ||||
2663 | static gboolean | |||
2664 | hit_test (CtkCellRenderer *renderer G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2665 | const CdkRectangle *cell_area, | |||
2666 | const CdkRectangle *cell_background G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2667 | HitTestData *data) | |||
2668 | { | |||
2669 | if (MIN (data->hit_rect.x + data->hit_rect.width, cell_area->x + cell_area->width)(((data->hit_rect.x + data->hit_rect.width) < (cell_area ->x + cell_area->width)) ? (data->hit_rect.x + data-> hit_rect.width) : (cell_area->x + cell_area->width)) - | |||
2670 | MAX (data->hit_rect.x, cell_area->x)(((data->hit_rect.x) > (cell_area->x)) ? (data->hit_rect .x) : (cell_area->x)) > 0 && | |||
2671 | MIN (data->hit_rect.y + data->hit_rect.height, cell_area->y + cell_area->height)(((data->hit_rect.y + data->hit_rect.height) < (cell_area ->y + cell_area->height)) ? (data->hit_rect.y + data ->hit_rect.height) : (cell_area->y + cell_area->height )) - | |||
2672 | MAX (data->hit_rect.y, cell_area->y)(((data->hit_rect.y) > (cell_area->y)) ? (data->hit_rect .y) : (cell_area->y)) > 0) | |||
2673 | data->hit = TRUE(!(0)); | |||
2674 | ||||
2675 | return (data->hit != FALSE(0)); | |||
2676 | } | |||
2677 | ||||
2678 | static gboolean | |||
2679 | ctk_icon_view_item_hit_test (CtkIconView *icon_view, | |||
2680 | CtkIconViewItem *item, | |||
2681 | gint x, | |||
2682 | gint y, | |||
2683 | gint width, | |||
2684 | gint height) | |||
2685 | { | |||
2686 | HitTestData data = { { x, y, width, height }, FALSE(0) }; | |||
2687 | CtkCellAreaContext *context; | |||
2688 | CdkRectangle *item_area = &item->cell_area; | |||
2689 | ||||
2690 | if (MIN (x + width, item_area->x + item_area->width)(((x + width) < (item_area->x + item_area->width)) ? (x + width) : (item_area->x + item_area->width)) - MAX (x, item_area->x)(((x) > (item_area->x)) ? (x) : (item_area->x)) <= 0 || | |||
2691 | MIN (y + height, item_area->y + item_area->height)(((y + height) < (item_area->y + item_area->height)) ? (y + height) : (item_area->y + item_area->height)) - MAX (y, item_area->y)(((y) > (item_area->y)) ? (y) : (item_area->y)) <= 0) | |||
2692 | return FALSE(0); | |||
2693 | ||||
2694 | context = g_ptr_array_index (icon_view->priv->row_contexts, item->row)((icon_view->priv->row_contexts)->pdata)[item->row ]; | |||
2695 | ||||
2696 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
2697 | ctk_cell_area_foreach_alloc (icon_view->priv->cell_area, context, | |||
2698 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
2699 | item_area, item_area, | |||
2700 | (CtkCellAllocCallback)hit_test, &data); | |||
2701 | ||||
2702 | return data.hit; | |||
2703 | } | |||
2704 | ||||
2705 | static gboolean | |||
2706 | ctk_icon_view_unselect_all_internal (CtkIconView *icon_view) | |||
2707 | { | |||
2708 | gboolean dirty = FALSE(0); | |||
2709 | GList *items; | |||
2710 | ||||
2711 | if (icon_view->priv->selection_mode == CTK_SELECTION_NONE) | |||
2712 | return FALSE(0); | |||
2713 | ||||
2714 | for (items = icon_view->priv->items; items; items = items->next) | |||
2715 | { | |||
2716 | CtkIconViewItem *item = items->data; | |||
2717 | ||||
2718 | if (item->selected) | |||
2719 | { | |||
2720 | item->selected = FALSE(0); | |||
2721 | dirty = TRUE(!(0)); | |||
2722 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
2723 | ctk_icon_view_item_selected_changed (icon_view, item); | |||
2724 | } | |||
2725 | } | |||
2726 | ||||
2727 | return dirty; | |||
2728 | } | |||
2729 | ||||
2730 | ||||
2731 | /* CtkIconView signals */ | |||
2732 | static void | |||
2733 | ctk_icon_view_real_select_all (CtkIconView *icon_view) | |||
2734 | { | |||
2735 | ctk_icon_view_select_all (icon_view); | |||
2736 | } | |||
2737 | ||||
2738 | static void | |||
2739 | ctk_icon_view_real_unselect_all (CtkIconView *icon_view) | |||
2740 | { | |||
2741 | ctk_icon_view_unselect_all (icon_view); | |||
2742 | } | |||
2743 | ||||
2744 | static void | |||
2745 | ctk_icon_view_real_select_cursor_item (CtkIconView *icon_view) | |||
2746 | { | |||
2747 | ctk_icon_view_unselect_all (icon_view); | |||
2748 | ||||
2749 | if (icon_view->priv->cursor_item != NULL((void*)0)) | |||
2750 | _ctk_icon_view_select_item (icon_view, icon_view->priv->cursor_item); | |||
2751 | } | |||
2752 | ||||
2753 | static gboolean | |||
2754 | ctk_icon_view_real_activate_cursor_item (CtkIconView *icon_view) | |||
2755 | { | |||
2756 | CtkTreePath *path; | |||
2757 | CtkCellAreaContext *context; | |||
2758 | ||||
2759 | if (!icon_view->priv->cursor_item) | |||
2760 | return FALSE(0); | |||
2761 | ||||
2762 | context = g_ptr_array_index (icon_view->priv->row_contexts, icon_view->priv->cursor_item->row)((icon_view->priv->row_contexts)->pdata)[icon_view-> priv->cursor_item->row]; | |||
2763 | ||||
2764 | _ctk_icon_view_set_cell_data (icon_view, icon_view->priv->cursor_item); | |||
2765 | ctk_cell_area_activate (icon_view->priv->cell_area, context, | |||
2766 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
2767 | &icon_view->priv->cursor_item->cell_area, | |||
2768 | 0 /* XXX flags */, | |||
2769 | FALSE(0)); | |||
2770 | ||||
2771 | path = ctk_tree_path_new_from_indices (icon_view->priv->cursor_item->index, -1); | |||
2772 | ctk_icon_view_item_activated (icon_view, path); | |||
2773 | ctk_tree_path_free (path); | |||
2774 | ||||
2775 | return TRUE(!(0)); | |||
2776 | } | |||
2777 | ||||
2778 | static void | |||
2779 | ctk_icon_view_real_toggle_cursor_item (CtkIconView *icon_view) | |||
2780 | { | |||
2781 | if (!icon_view->priv->cursor_item) | |||
2782 | return; | |||
2783 | ||||
2784 | switch (icon_view->priv->selection_mode) | |||
2785 | { | |||
2786 | case CTK_SELECTION_NONE: | |||
2787 | break; | |||
2788 | case CTK_SELECTION_BROWSE: | |||
2789 | _ctk_icon_view_select_item (icon_view, icon_view->priv->cursor_item); | |||
2790 | break; | |||
2791 | case CTK_SELECTION_SINGLE: | |||
2792 | if (icon_view->priv->cursor_item->selected) | |||
2793 | _ctk_icon_view_unselect_item (icon_view, icon_view->priv->cursor_item); | |||
2794 | else | |||
2795 | _ctk_icon_view_select_item (icon_view, icon_view->priv->cursor_item); | |||
2796 | break; | |||
2797 | case CTK_SELECTION_MULTIPLE: | |||
2798 | icon_view->priv->cursor_item->selected = !icon_view->priv->cursor_item->selected; | |||
2799 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
2800 | ||||
2801 | ctk_icon_view_item_selected_changed (icon_view, icon_view->priv->cursor_item); | |||
2802 | ctk_icon_view_queue_draw_item (icon_view, icon_view->priv->cursor_item); | |||
2803 | break; | |||
2804 | } | |||
2805 | } | |||
2806 | ||||
2807 | static void | |||
2808 | ctk_icon_view_set_hadjustment_values (CtkIconView *icon_view) | |||
2809 | { | |||
2810 | CtkAllocation allocation; | |||
2811 | CtkAdjustment *adj = icon_view->priv->hadjustment; | |||
2812 | gdouble old_page_size; | |||
2813 | gdouble old_upper; | |||
2814 | gdouble old_value; | |||
2815 | gdouble new_value; | |||
2816 | gdouble new_upper; | |||
2817 | ||||
2818 | ctk_widget_get_allocation (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), &allocation); | |||
2819 | ||||
2820 | old_value = ctk_adjustment_get_value (adj); | |||
2821 | old_upper = ctk_adjustment_get_upper (adj); | |||
2822 | old_page_size = ctk_adjustment_get_page_size (adj); | |||
2823 | new_upper = MAX (allocation.width, icon_view->priv->width)(((allocation.width) > (icon_view->priv->width)) ? ( allocation.width) : (icon_view->priv->width)); | |||
2824 | ||||
2825 | if (ctk_widget_get_direction (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL) | |||
2826 | { | |||
2827 | /* Make sure no scrolling occurs for RTL locales also (if possible) */ | |||
2828 | /* Quick explanation: | |||
2829 | * In LTR locales, leftmost portion of visible rectangle should stay | |||
2830 | * fixed, which means left edge of scrollbar thumb should remain fixed | |||
2831 | * and thus adjustment's value should stay the same. | |||
2832 | * | |||
2833 | * In RTL locales, we want to keep rightmost portion of visible | |||
2834 | * rectangle fixed. This means right edge of thumb should remain fixed. | |||
2835 | * In this case, upper - value - page_size should remain constant. | |||
2836 | */ | |||
2837 | new_value = (new_upper - allocation.width) - | |||
2838 | (old_upper - old_value - old_page_size); | |||
2839 | new_value = CLAMP (new_value, 0, new_upper - allocation.width)(((new_value) > (new_upper - allocation.width)) ? (new_upper - allocation.width) : (((new_value) < (0)) ? (0) : (new_value ))); | |||
2840 | } | |||
2841 | else | |||
2842 | new_value = CLAMP (old_value, 0, new_upper - allocation.width)(((old_value) > (new_upper - allocation.width)) ? (new_upper - allocation.width) : (((old_value) < (0)) ? (0) : (old_value ))); | |||
2843 | ||||
2844 | ctk_adjustment_configure (adj, | |||
2845 | new_value, | |||
2846 | 0.0, | |||
2847 | new_upper, | |||
2848 | allocation.width * 0.1, | |||
2849 | allocation.width * 0.9, | |||
2850 | allocation.width); | |||
2851 | } | |||
2852 | ||||
2853 | static void | |||
2854 | ctk_icon_view_set_vadjustment_values (CtkIconView *icon_view) | |||
2855 | { | |||
2856 | CtkAllocation allocation; | |||
2857 | CtkAdjustment *adj = icon_view->priv->vadjustment; | |||
2858 | ||||
2859 | ctk_widget_get_allocation (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), &allocation); | |||
2860 | ||||
2861 | ctk_adjustment_configure (adj, | |||
2862 | ctk_adjustment_get_value (adj), | |||
2863 | 0.0, | |||
2864 | MAX (allocation.height, icon_view->priv->height)(((allocation.height) > (icon_view->priv->height)) ? (allocation.height) : (icon_view->priv->height)), | |||
2865 | allocation.height * 0.1, | |||
2866 | allocation.height * 0.9, | |||
2867 | allocation.height); | |||
2868 | } | |||
2869 | ||||
2870 | static void | |||
2871 | ctk_icon_view_set_hadjustment (CtkIconView *icon_view, | |||
2872 | CtkAdjustment *adjustment) | |||
2873 | { | |||
2874 | CtkIconViewPrivate *priv = icon_view->priv; | |||
2875 | ||||
2876 | if (adjustment && priv->hadjustment == adjustment) | |||
2877 | return; | |||
2878 | ||||
2879 | if (priv->hadjustment != NULL((void*)0)) | |||
2880 | { | |||
2881 | g_signal_handlers_disconnect_matched (priv->hadjustment, | |||
2882 | G_SIGNAL_MATCH_DATA, | |||
2883 | 0, 0, NULL((void*)0), NULL((void*)0), icon_view); | |||
2884 | g_object_unref (priv->hadjustment); | |||
2885 | } | |||
2886 | ||||
2887 | if (!adjustment) | |||
2888 | adjustment = ctk_adjustment_new (0.0, 0.0, 0.0, | |||
2889 | 0.0, 0.0, 0.0); | |||
2890 | ||||
2891 | g_signal_connect (adjustment, "value-changed",g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_icon_view_adjustment_changed))), (icon_view), ((void*) 0), (GConnectFlags) 0) | |||
2892 | G_CALLBACK (ctk_icon_view_adjustment_changed), icon_view)g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_icon_view_adjustment_changed))), (icon_view), ((void*) 0), (GConnectFlags) 0); | |||
2893 | priv->hadjustment = g_object_ref_sink (adjustment)((__typeof__ (adjustment)) (g_object_ref_sink) (adjustment)); | |||
2894 | ctk_icon_view_set_hadjustment_values (icon_view); | |||
2895 | ||||
2896 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "hadjustment"); | |||
2897 | } | |||
2898 | ||||
2899 | static void | |||
2900 | ctk_icon_view_set_vadjustment (CtkIconView *icon_view, | |||
2901 | CtkAdjustment *adjustment) | |||
2902 | { | |||
2903 | CtkIconViewPrivate *priv = icon_view->priv; | |||
2904 | ||||
2905 | if (adjustment && priv->vadjustment == adjustment) | |||
2906 | return; | |||
2907 | ||||
2908 | if (priv->vadjustment != NULL((void*)0)) | |||
2909 | { | |||
2910 | g_signal_handlers_disconnect_matched (priv->vadjustment, | |||
2911 | G_SIGNAL_MATCH_DATA, | |||
2912 | 0, 0, NULL((void*)0), NULL((void*)0), icon_view); | |||
2913 | g_object_unref (priv->vadjustment); | |||
2914 | } | |||
2915 | ||||
2916 | if (!adjustment) | |||
2917 | adjustment = ctk_adjustment_new (0.0, 0.0, 0.0, | |||
2918 | 0.0, 0.0, 0.0); | |||
2919 | ||||
2920 | g_signal_connect (adjustment, "value-changed",g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_icon_view_adjustment_changed))), (icon_view), ((void*) 0), (GConnectFlags) 0) | |||
2921 | G_CALLBACK (ctk_icon_view_adjustment_changed), icon_view)g_signal_connect_data ((adjustment), ("value-changed"), (((GCallback ) (ctk_icon_view_adjustment_changed))), (icon_view), ((void*) 0), (GConnectFlags) 0); | |||
2922 | priv->vadjustment = g_object_ref_sink (adjustment)((__typeof__ (adjustment)) (g_object_ref_sink) (adjustment)); | |||
2923 | ctk_icon_view_set_vadjustment_values (icon_view); | |||
2924 | ||||
2925 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "vadjustment"); | |||
2926 | } | |||
2927 | ||||
2928 | static void | |||
2929 | ctk_icon_view_adjustment_changed (CtkAdjustment *adjustment G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2930 | CtkIconView *icon_view) | |||
2931 | { | |||
2932 | CtkIconViewPrivate *priv = icon_view->priv; | |||
2933 | ||||
2934 | if (ctk_widget_get_realized (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))))) | |||
2935 | { | |||
2936 | cdk_window_move (priv->bin_window, | |||
2937 | - ctk_adjustment_get_value (priv->hadjustment), | |||
2938 | - ctk_adjustment_get_value (priv->vadjustment)); | |||
2939 | ||||
2940 | if (icon_view->priv->doing_rubberband) | |||
2941 | ctk_icon_view_update_rubberband (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
2942 | ||||
2943 | _ctk_icon_view_accessible_adjustment_changed (icon_view); | |||
2944 | } | |||
2945 | } | |||
2946 | ||||
2947 | static gint | |||
2948 | compare_sizes (gconstpointer p1, | |||
2949 | gconstpointer p2, | |||
2950 | gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
2951 | { | |||
2952 | return GPOINTER_TO_INT (((const CtkRequestedSize *) p1)->data)((gint) (glong) (((const CtkRequestedSize *) p1)->data)) | |||
2953 | - GPOINTER_TO_INT (((const CtkRequestedSize *) p2)->data)((gint) (glong) (((const CtkRequestedSize *) p2)->data)); | |||
2954 | } | |||
2955 | ||||
2956 | static void | |||
2957 | ctk_icon_view_layout (CtkIconView *icon_view) | |||
2958 | { | |||
2959 | CtkIconViewPrivate *priv = icon_view->priv; | |||
2960 | CtkWidget *widget = CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))); | |||
2961 | GList *items; | |||
2962 | gint item_width; /* this doesn't include item_padding */ | |||
2963 | gint n_columns, n_rows, n_items; | |||
2964 | gint col, row; | |||
2965 | CtkRequestedSize *sizes; | |||
2966 | gboolean rtl; | |||
2967 | ||||
2968 | if (ctk_icon_view_is_empty (icon_view)) | |||
2969 | return; | |||
2970 | ||||
2971 | rtl = ctk_widget_get_direction (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL; | |||
2972 | n_items = ctk_icon_view_get_n_items (icon_view); | |||
2973 | ||||
2974 | ctk_icon_view_compute_n_items_for_size (icon_view, | |||
2975 | CTK_ORIENTATION_HORIZONTAL, | |||
2976 | ctk_widget_get_allocated_width (widget), | |||
2977 | NULL((void*)0), NULL((void*)0), | |||
2978 | &n_columns, &item_width); | |||
2979 | n_rows = (n_items + n_columns - 1) / n_columns; | |||
2980 | ||||
2981 | priv->width = n_columns * (item_width + 2 * priv->item_padding + priv->column_spacing) - priv->column_spacing; | |||
2982 | priv->width += 2 * priv->margin; | |||
2983 | priv->width = MAX (priv->width, ctk_widget_get_allocated_width (widget))(((priv->width) > (ctk_widget_get_allocated_width (widget ))) ? (priv->width) : (ctk_widget_get_allocated_width (widget ))); | |||
2984 | ||||
2985 | /* Clear the per row contexts */ | |||
2986 | g_ptr_array_set_size (icon_view->priv->row_contexts, 0); | |||
2987 | ||||
2988 | ctk_cell_area_context_reset (priv->cell_area_context); | |||
2989 | /* because layouting is complicated. We designed an API | |||
2990 | * that is O(N²) and nonsensical. | |||
2991 | * And we're proud of it. */ | |||
2992 | for (items = priv->items; items; items = items->next) | |||
2993 | { | |||
2994 | _ctk_icon_view_set_cell_data (icon_view, items->data); | |||
2995 | ctk_cell_area_get_preferred_width (priv->cell_area, | |||
2996 | priv->cell_area_context, | |||
2997 | widget, | |||
2998 | NULL((void*)0), NULL((void*)0)); | |||
2999 | } | |||
3000 | ||||
3001 | sizes = g_newa (CtkRequestedSize, n_rows)((CtkRequestedSize*) __builtin_alloca (sizeof (CtkRequestedSize ) * (gsize) (n_rows))); | |||
3002 | items = priv->items; | |||
3003 | priv->height = priv->margin; | |||
3004 | ||||
3005 | /* Collect the heights for all rows */ | |||
3006 | for (row = 0; row < n_rows; row++) | |||
3007 | { | |||
3008 | CtkCellAreaContext *context = ctk_cell_area_copy_context (priv->cell_area, priv->cell_area_context); | |||
3009 | g_ptr_array_add (priv->row_contexts, context); | |||
3010 | ||||
3011 | for (col = 0; col < n_columns && items; col++, items = items->next) | |||
3012 | { | |||
3013 | CtkIconViewItem *item = items->data; | |||
3014 | ||||
3015 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
3016 | ctk_cell_area_get_preferred_height_for_width (priv->cell_area, | |||
3017 | context, | |||
3018 | widget, | |||
3019 | item_width, | |||
3020 | NULL((void*)0), NULL((void*)0)); | |||
3021 | } | |||
3022 | ||||
3023 | sizes[row].data = GINT_TO_POINTER (row)((gpointer) (glong) (row)); | |||
3024 | ctk_cell_area_context_get_preferred_height_for_width (context, | |||
3025 | item_width, | |||
3026 | &sizes[row].minimum_size, | |||
3027 | &sizes[row].natural_size); | |||
3028 | priv->height += sizes[row].minimum_size + 2 * priv->item_padding + priv->row_spacing; | |||
3029 | } | |||
3030 | ||||
3031 | priv->height -= priv->row_spacing; | |||
3032 | priv->height += priv->margin; | |||
3033 | priv->height = MIN (priv->height, ctk_widget_get_allocated_height (widget))(((priv->height) < (ctk_widget_get_allocated_height (widget ))) ? (priv->height) : (ctk_widget_get_allocated_height (widget ))); | |||
3034 | ||||
3035 | ctk_distribute_natural_allocation (ctk_widget_get_allocated_height (widget) - priv->height, | |||
3036 | n_rows, | |||
3037 | sizes); | |||
3038 | ||||
3039 | /* Actually allocate the rows */ | |||
3040 | g_qsort_with_data (sizes, n_rows, sizeof (CtkRequestedSize), compare_sizes, NULL((void*)0)); | |||
3041 | ||||
3042 | items = priv->items; | |||
3043 | priv->height = priv->margin; | |||
3044 | ||||
3045 | for (row = 0; row < n_rows; row++) | |||
3046 | { | |||
3047 | CtkCellAreaContext *context = g_ptr_array_index (priv->row_contexts, row)((priv->row_contexts)->pdata)[row]; | |||
3048 | ctk_cell_area_context_allocate (context, item_width, sizes[row].minimum_size); | |||
3049 | ||||
3050 | priv->height += priv->item_padding; | |||
3051 | ||||
3052 | for (col = 0; col < n_columns && items; col++, items = items->next) | |||
3053 | { | |||
3054 | CtkIconViewItem *item = items->data; | |||
3055 | ||||
3056 | item->cell_area.x = priv->margin + (col * 2 + 1) * priv->item_padding + col * (priv->column_spacing + item_width); | |||
3057 | item->cell_area.width = item_width; | |||
3058 | item->cell_area.y = priv->height; | |||
3059 | item->cell_area.height = sizes[row].minimum_size; | |||
3060 | item->row = row; | |||
3061 | item->col = col; | |||
3062 | if (rtl) | |||
3063 | { | |||
3064 | item->cell_area.x = priv->width - item_width - item->cell_area.x; | |||
3065 | item->col = n_columns - 1 - col; | |||
3066 | } | |||
3067 | } | |||
3068 | ||||
3069 | priv->height += sizes[row].minimum_size + priv->item_padding + priv->row_spacing; | |||
3070 | } | |||
3071 | ||||
3072 | priv->height -= priv->row_spacing; | |||
3073 | priv->height += priv->margin; | |||
3074 | priv->height = MAX (priv->height, ctk_widget_get_allocated_height (widget))(((priv->height) > (ctk_widget_get_allocated_height (widget ))) ? (priv->height) : (ctk_widget_get_allocated_height (widget ))); | |||
3075 | } | |||
3076 | ||||
3077 | static void | |||
3078 | ctk_icon_view_invalidate_sizes (CtkIconView *icon_view) | |||
3079 | { | |||
3080 | /* Clear all item sizes */ | |||
3081 | g_list_foreach (icon_view->priv->items, | |||
3082 | (GFunc)ctk_icon_view_item_invalidate_size, NULL((void*)0)); | |||
3083 | ||||
3084 | /* Re-layout the items */ | |||
3085 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3086 | } | |||
3087 | ||||
3088 | static void | |||
3089 | ctk_icon_view_item_invalidate_size (CtkIconViewItem *item) | |||
3090 | { | |||
3091 | item->cell_area.width = -1; | |||
3092 | item->cell_area.height = -1; | |||
3093 | } | |||
3094 | ||||
3095 | static void | |||
3096 | ctk_icon_view_paint_item (CtkIconView *icon_view, | |||
3097 | cairo_t *cr, | |||
3098 | CtkIconViewItem *item, | |||
3099 | gint x, | |||
3100 | gint y, | |||
3101 | gboolean draw_focus) | |||
3102 | { | |||
3103 | CdkRectangle cell_area; | |||
3104 | CtkStateFlags state = 0; | |||
3105 | CtkCellRendererState flags = 0; | |||
3106 | CtkStyleContext *style_context; | |||
3107 | CtkWidget *widget = CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))); | |||
3108 | CtkIconViewPrivate *priv = icon_view->priv; | |||
3109 | CtkCellAreaContext *context; | |||
3110 | ||||
3111 | if (priv->model == NULL((void*)0) || item->cell_area.width <= 0 || item->cell_area.height <= 0) | |||
3112 | return; | |||
3113 | ||||
3114 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
3115 | ||||
3116 | style_context = ctk_widget_get_style_context (widget); | |||
3117 | state = ctk_widget_get_state_flags (widget); | |||
3118 | ||||
3119 | ctk_style_context_save (style_context); | |||
3120 | ctk_style_context_add_class (style_context, CTK_STYLE_CLASS_CELL"cell"); | |||
3121 | ||||
3122 | state &= ~(CTK_STATE_FLAG_SELECTED | CTK_STATE_FLAG_PRELIGHT); | |||
3123 | ||||
3124 | if ((state & CTK_STATE_FLAG_FOCUSED) && | |||
3125 | item == icon_view->priv->cursor_item) | |||
3126 | flags |= CTK_CELL_RENDERER_FOCUSED; | |||
3127 | ||||
3128 | if (item->selected) | |||
3129 | { | |||
3130 | state |= CTK_STATE_FLAG_SELECTED; | |||
3131 | flags |= CTK_CELL_RENDERER_SELECTED; | |||
3132 | } | |||
3133 | ||||
3134 | if (item == priv->last_prelight) | |||
3135 | { | |||
3136 | state |= CTK_STATE_FLAG_PRELIGHT; | |||
3137 | flags |= CTK_CELL_RENDERER_PRELIT; | |||
3138 | } | |||
3139 | ||||
3140 | ctk_style_context_set_state (style_context, state); | |||
3141 | ||||
3142 | ctk_render_background (style_context, cr, | |||
3143 | x - priv->item_padding, | |||
3144 | y - priv->item_padding, | |||
3145 | item->cell_area.width + priv->item_padding * 2, | |||
3146 | item->cell_area.height + priv->item_padding * 2); | |||
3147 | ctk_render_frame (style_context, cr, | |||
3148 | x - priv->item_padding, | |||
3149 | y - priv->item_padding, | |||
3150 | item->cell_area.width + priv->item_padding * 2, | |||
3151 | item->cell_area.height + priv->item_padding * 2); | |||
3152 | ||||
3153 | cell_area.x = x; | |||
3154 | cell_area.y = y; | |||
3155 | cell_area.width = item->cell_area.width; | |||
3156 | cell_area.height = item->cell_area.height; | |||
3157 | ||||
3158 | context = g_ptr_array_index (priv->row_contexts, item->row)((priv->row_contexts)->pdata)[item->row]; | |||
3159 | ctk_cell_area_render (priv->cell_area, context, | |||
3160 | widget, cr, &cell_area, &cell_area, flags, | |||
3161 | draw_focus); | |||
3162 | ||||
3163 | ctk_style_context_restore (style_context); | |||
3164 | } | |||
3165 | ||||
3166 | static void | |||
3167 | ctk_icon_view_paint_rubberband (CtkIconView *icon_view, | |||
3168 | cairo_t *cr) | |||
3169 | { | |||
3170 | CtkIconViewPrivate *priv = icon_view->priv; | |||
3171 | CtkStyleContext *context; | |||
3172 | CdkRectangle rect; | |||
3173 | ||||
3174 | cairo_save (cr); | |||
3175 | ||||
3176 | rect.x = MIN (priv->rubberband_x1, priv->rubberband_x2)(((priv->rubberband_x1) < (priv->rubberband_x2)) ? ( priv->rubberband_x1) : (priv->rubberband_x2)); | |||
3177 | rect.y = MIN (priv->rubberband_y1, priv->rubberband_y2)(((priv->rubberband_y1) < (priv->rubberband_y2)) ? ( priv->rubberband_y1) : (priv->rubberband_y2)); | |||
3178 | rect.width = ABS (priv->rubberband_x1 - priv->rubberband_x2)(((priv->rubberband_x1 - priv->rubberband_x2) < 0) ? -(priv->rubberband_x1 - priv->rubberband_x2) : (priv-> rubberband_x1 - priv->rubberband_x2)) + 1; | |||
3179 | rect.height = ABS (priv->rubberband_y1 - priv->rubberband_y2)(((priv->rubberband_y1 - priv->rubberband_y2) < 0) ? -(priv->rubberband_y1 - priv->rubberband_y2) : (priv-> rubberband_y1 - priv->rubberband_y2)) + 1; | |||
3180 | ||||
3181 | context = ctk_widget_get_style_context (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3182 | ||||
3183 | ctk_style_context_save_to_node (context, priv->rubberband_node); | |||
3184 | ||||
3185 | cdk_cairo_rectangle (cr, &rect); | |||
3186 | cairo_clip (cr); | |||
3187 | ||||
3188 | ctk_render_background (context, cr, | |||
3189 | rect.x, rect.y, | |||
3190 | rect.width, rect.height); | |||
3191 | ctk_render_frame (context, cr, | |||
3192 | rect.x, rect.y, | |||
3193 | rect.width, rect.height); | |||
3194 | ||||
3195 | ctk_style_context_restore (context); | |||
3196 | cairo_restore (cr); | |||
3197 | } | |||
3198 | ||||
3199 | static void | |||
3200 | ctk_icon_view_queue_draw_path (CtkIconView *icon_view, | |||
3201 | CtkTreePath *path) | |||
3202 | { | |||
3203 | GList *l; | |||
3204 | gint index; | |||
3205 | ||||
3206 | index = ctk_tree_path_get_indices (path)[0]; | |||
3207 | ||||
3208 | for (l = icon_view->priv->items; l; l = l->next) | |||
3209 | { | |||
3210 | CtkIconViewItem *item = l->data; | |||
3211 | ||||
3212 | if (item->index == index) | |||
3213 | { | |||
3214 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
3215 | break; | |||
3216 | } | |||
3217 | } | |||
3218 | } | |||
3219 | ||||
3220 | static void | |||
3221 | ctk_icon_view_queue_draw_item (CtkIconView *icon_view, | |||
3222 | CtkIconViewItem *item) | |||
3223 | { | |||
3224 | CdkRectangle rect; | |||
3225 | CdkRectangle *item_area = &item->cell_area; | |||
3226 | ||||
3227 | rect.x = item_area->x - icon_view->priv->item_padding; | |||
3228 | rect.y = item_area->y - icon_view->priv->item_padding; | |||
3229 | rect.width = item_area->width + icon_view->priv->item_padding * 2; | |||
3230 | rect.height = item_area->height + icon_view->priv->item_padding * 2; | |||
3231 | ||||
3232 | if (icon_view->priv->bin_window) | |||
3233 | cdk_window_invalidate_rect (icon_view->priv->bin_window, &rect, TRUE(!(0))); | |||
3234 | } | |||
3235 | ||||
3236 | void | |||
3237 | _ctk_icon_view_set_cursor_item (CtkIconView *icon_view, | |||
3238 | CtkIconViewItem *item, | |||
3239 | CtkCellRenderer *cursor_cell) | |||
3240 | { | |||
3241 | AtkObject *obj; | |||
3242 | AtkObject *item_obj; | |||
3243 | AtkObject *cursor_item_obj; | |||
3244 | ||||
3245 | /* When hitting this path from keynav, the focus cell is | |||
3246 | * already set, we dont need to notify the atk object | |||
3247 | * but we still need to queue the draw here (in the case | |||
3248 | * that the focus cell changes but not the cursor item). | |||
3249 | */ | |||
3250 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
3251 | ||||
3252 | if (icon_view->priv->cursor_item == item && | |||
3253 | (cursor_cell == NULL((void*)0) || cursor_cell == ctk_cell_area_get_focus_cell (icon_view->priv->cell_area))) | |||
3254 | return; | |||
3255 | ||||
3256 | obj = ctk_widget_get_accessible (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3257 | if (icon_view->priv->cursor_item != NULL((void*)0)) | |||
3258 | { | |||
3259 | ctk_icon_view_queue_draw_item (icon_view, icon_view->priv->cursor_item); | |||
3260 | if (obj != NULL((void*)0)) | |||
3261 | { | |||
3262 | cursor_item_obj = atk_object_ref_accessible_child (obj, icon_view->priv->cursor_item->index); | |||
3263 | if (cursor_item_obj != NULL((void*)0)) | |||
3264 | atk_object_notify_state_change (cursor_item_obj, ATK_STATE_FOCUSED, FALSE(0)); | |||
3265 | } | |||
3266 | } | |||
3267 | icon_view->priv->cursor_item = item; | |||
3268 | ||||
3269 | if (cursor_cell) | |||
3270 | ctk_cell_area_set_focus_cell (icon_view->priv->cell_area, cursor_cell); | |||
3271 | else | |||
3272 | { | |||
3273 | /* Make sure there is a cell in focus initially */ | |||
3274 | if (!ctk_cell_area_get_focus_cell (icon_view->priv->cell_area)) | |||
3275 | ctk_cell_area_focus (icon_view->priv->cell_area, CTK_DIR_TAB_FORWARD); | |||
3276 | } | |||
3277 | ||||
3278 | /* Notify that accessible focus object has changed */ | |||
3279 | item_obj = atk_object_ref_accessible_child (obj, item->index); | |||
3280 | ||||
3281 | if (item_obj != NULL((void*)0)) | |||
3282 | { | |||
3283 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" ; | |||
3284 | atk_focus_tracker_notify (item_obj); | |||
3285 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ; | |||
3286 | atk_object_notify_state_change (item_obj, ATK_STATE_FOCUSED, TRUE(!(0))); | |||
3287 | g_object_unref (item_obj); | |||
3288 | } | |||
3289 | } | |||
3290 | ||||
3291 | ||||
3292 | static CtkIconViewItem * | |||
3293 | ctk_icon_view_item_new (void) | |||
3294 | { | |||
3295 | CtkIconViewItem *item; | |||
3296 | ||||
3297 | item = g_slice_new0 (CtkIconViewItem)((CtkIconViewItem*) g_slice_alloc0 (sizeof (CtkIconViewItem)) ); | |||
3298 | ||||
3299 | item->cell_area.width = -1; | |||
3300 | item->cell_area.height = -1; | |||
3301 | ||||
3302 | return item; | |||
3303 | } | |||
3304 | ||||
3305 | static void | |||
3306 | ctk_icon_view_item_free (CtkIconViewItem *item) | |||
3307 | { | |||
3308 | g_return_if_fail (item != NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "item != NULL"); return; } } while (0); | |||
3309 | ||||
3310 | g_slice_free (CtkIconViewItem, item)do { if (1) g_slice_free1 (sizeof (CtkIconViewItem), (item)); else (void) ((CtkIconViewItem*) 0 == (item)); } while (0); | |||
3311 | } | |||
3312 | ||||
3313 | CtkIconViewItem * | |||
3314 | _ctk_icon_view_get_item_at_coords (CtkIconView *icon_view, | |||
3315 | gint x, | |||
3316 | gint y, | |||
3317 | gboolean only_in_cell, | |||
3318 | CtkCellRenderer **cell_at_pos) | |||
3319 | { | |||
3320 | GList *items; | |||
3321 | ||||
3322 | if (cell_at_pos) | |||
3323 | *cell_at_pos = NULL((void*)0); | |||
3324 | ||||
3325 | for (items = icon_view->priv->items; items; items = items->next) | |||
3326 | { | |||
3327 | CtkIconViewItem *item = items->data; | |||
3328 | CdkRectangle *item_area = &item->cell_area; | |||
3329 | ||||
3330 | if (x >= item_area->x - icon_view->priv->column_spacing/2 && | |||
3331 | x <= item_area->x + item_area->width + icon_view->priv->column_spacing/2 && | |||
3332 | y >= item_area->y - icon_view->priv->row_spacing/2 && | |||
3333 | y <= item_area->y + item_area->height + icon_view->priv->row_spacing/2) | |||
3334 | { | |||
3335 | if (only_in_cell || cell_at_pos) | |||
3336 | { | |||
3337 | CtkCellRenderer *cell = NULL((void*)0); | |||
3338 | CtkCellAreaContext *context; | |||
3339 | ||||
3340 | context = g_ptr_array_index (icon_view->priv->row_contexts, item->row)((icon_view->priv->row_contexts)->pdata)[item->row ]; | |||
3341 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
3342 | ||||
3343 | if (x >= item_area->x && x <= item_area->x + item_area->width && | |||
3344 | y >= item_area->y && y <= item_area->y + item_area->height) | |||
3345 | cell = ctk_cell_area_get_cell_at_position (icon_view->priv->cell_area, context, | |||
3346 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
3347 | item_area, | |||
3348 | x, y, NULL((void*)0)); | |||
3349 | ||||
3350 | if (cell_at_pos) | |||
3351 | *cell_at_pos = cell; | |||
3352 | ||||
3353 | if (only_in_cell) | |||
3354 | return cell != NULL((void*)0) ? item : NULL((void*)0); | |||
3355 | else | |||
3356 | return item; | |||
3357 | } | |||
3358 | return item; | |||
3359 | } | |||
3360 | } | |||
3361 | return NULL((void*)0); | |||
3362 | } | |||
3363 | ||||
3364 | void | |||
3365 | _ctk_icon_view_select_item (CtkIconView *icon_view, | |||
3366 | CtkIconViewItem *item) | |||
3367 | { | |||
3368 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
3369 | g_return_if_fail (item != NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "item != NULL"); return; } } while (0); | |||
3370 | ||||
3371 | if (item->selected) | |||
3372 | return; | |||
3373 | ||||
3374 | if (icon_view->priv->selection_mode == CTK_SELECTION_NONE) | |||
3375 | return; | |||
3376 | else if (icon_view->priv->selection_mode != CTK_SELECTION_MULTIPLE) | |||
3377 | ctk_icon_view_unselect_all_internal (icon_view); | |||
3378 | ||||
3379 | item->selected = TRUE(!(0)); | |||
3380 | ||||
3381 | ctk_icon_view_item_selected_changed (icon_view, item); | |||
3382 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
3383 | ||||
3384 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
3385 | } | |||
3386 | ||||
3387 | ||||
3388 | void | |||
3389 | _ctk_icon_view_unselect_item (CtkIconView *icon_view, | |||
3390 | CtkIconViewItem *item) | |||
3391 | { | |||
3392 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
3393 | g_return_if_fail (item != NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "item != NULL"); return; } } while (0); | |||
3394 | ||||
3395 | if (!item->selected) | |||
3396 | return; | |||
3397 | ||||
3398 | if (icon_view->priv->selection_mode == CTK_SELECTION_NONE || | |||
3399 | icon_view->priv->selection_mode == CTK_SELECTION_BROWSE) | |||
3400 | return; | |||
3401 | ||||
3402 | item->selected = FALSE(0); | |||
3403 | ||||
3404 | ctk_icon_view_item_selected_changed (icon_view, item); | |||
3405 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
3406 | ||||
3407 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
3408 | } | |||
3409 | ||||
3410 | static void | |||
3411 | verify_items (CtkIconView *icon_view) | |||
3412 | { | |||
3413 | GList *items; | |||
3414 | int i = 0; | |||
3415 | ||||
3416 | for (items = icon_view->priv->items; items; items = items->next) | |||
3417 | { | |||
3418 | CtkIconViewItem *item = items->data; | |||
3419 | ||||
3420 | if (item->index != i) | |||
3421 | g_error ("List item does not match its index: " | |||
3422 | "item index %d and list index %d\n", item->index, i); | |||
3423 | ||||
3424 | i++; | |||
3425 | } | |||
3426 | } | |||
3427 | ||||
3428 | static void | |||
3429 | ctk_icon_view_row_changed (CtkTreeModel *model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3430 | CtkTreePath *path, | |||
3431 | CtkTreeIter *iter G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3432 | gpointer data) | |||
3433 | { | |||
3434 | CtkIconView *icon_view = CTK_ICON_VIEW (data)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_icon_view_get_type ())))))); | |||
3435 | ||||
3436 | /* ignore changes in branches */ | |||
3437 | if (ctk_tree_path_get_depth (path) > 1) | |||
3438 | return; | |||
3439 | ||||
3440 | /* An icon view subclass might add it's own model and populate | |||
3441 | * things at init() time instead of waiting for the constructor() | |||
3442 | * to be called | |||
3443 | */ | |||
3444 | if (icon_view->priv->cell_area) | |||
3445 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
3446 | ||||
3447 | /* Here we can use a "grow-only" strategy for optimization | |||
3448 | * and only invalidate a single item and queue a relayout | |||
3449 | * instead of invalidating the whole thing. | |||
3450 | * | |||
3451 | * For now CtkIconView still cant deal with huge models | |||
3452 | * so just invalidate the whole thing when the model | |||
3453 | * changes. | |||
3454 | */ | |||
3455 | ctk_icon_view_invalidate_sizes (icon_view); | |||
3456 | ||||
3457 | verify_items (icon_view); | |||
3458 | } | |||
3459 | ||||
3460 | static void | |||
3461 | ctk_icon_view_row_inserted (CtkTreeModel *model, | |||
3462 | CtkTreePath *path, | |||
3463 | CtkTreeIter *iter, | |||
3464 | gpointer data) | |||
3465 | { | |||
3466 | CtkIconView *icon_view = CTK_ICON_VIEW (data)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_icon_view_get_type ())))))); | |||
3467 | gint index; | |||
3468 | CtkIconViewItem *item; | |||
3469 | GList *list; | |||
3470 | ||||
3471 | /* ignore changes in branches */ | |||
3472 | if (ctk_tree_path_get_depth (path) > 1) | |||
3473 | return; | |||
3474 | ||||
3475 | ctk_tree_model_ref_node (model, iter); | |||
3476 | ||||
3477 | index = ctk_tree_path_get_indices(path)[0]; | |||
3478 | ||||
3479 | item = ctk_icon_view_item_new (); | |||
3480 | ||||
3481 | item->index = index; | |||
3482 | ||||
3483 | /* FIXME: We can be more efficient here, | |||
3484 | we can store a tail pointer and use that when | |||
3485 | appending (which is a rather common operation) | |||
3486 | */ | |||
3487 | icon_view->priv->items = g_list_insert (icon_view->priv->items, | |||
3488 | item, index); | |||
3489 | ||||
3490 | list = g_list_nth (icon_view->priv->items, index + 1); | |||
3491 | for (; list; list = list->next) | |||
3492 | { | |||
3493 | item = list->data; | |||
3494 | ||||
3495 | item->index++; | |||
3496 | } | |||
3497 | ||||
3498 | verify_items (icon_view); | |||
3499 | ||||
3500 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3501 | } | |||
3502 | ||||
3503 | static void | |||
3504 | ctk_icon_view_row_deleted (CtkTreeModel *model, | |||
3505 | CtkTreePath *path, | |||
3506 | gpointer data) | |||
3507 | { | |||
3508 | CtkIconView *icon_view = CTK_ICON_VIEW (data)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_icon_view_get_type ())))))); | |||
3509 | gint index; | |||
3510 | CtkIconViewItem *item; | |||
3511 | GList *list, *next; | |||
3512 | gboolean emit = FALSE(0); | |||
3513 | CtkTreeIter iter; | |||
3514 | ||||
3515 | /* ignore changes in branches */ | |||
3516 | if (ctk_tree_path_get_depth (path) > 1) | |||
3517 | return; | |||
3518 | ||||
3519 | if (ctk_tree_model_get_iter (model, &iter, path)) | |||
3520 | ctk_tree_model_unref_node (model, &iter); | |||
3521 | ||||
3522 | index = ctk_tree_path_get_indices(path)[0]; | |||
3523 | ||||
3524 | list = g_list_nth (icon_view->priv->items, index); | |||
3525 | item = list->data; | |||
3526 | ||||
3527 | if (icon_view->priv->cell_area) | |||
3528 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
3529 | ||||
3530 | if (item == icon_view->priv->anchor_item) | |||
3531 | icon_view->priv->anchor_item = NULL((void*)0); | |||
3532 | ||||
3533 | if (item == icon_view->priv->cursor_item) | |||
3534 | icon_view->priv->cursor_item = NULL((void*)0); | |||
3535 | ||||
3536 | if (item == icon_view->priv->last_prelight) | |||
3537 | icon_view->priv->last_prelight = NULL((void*)0); | |||
3538 | ||||
3539 | if (item->selected) | |||
3540 | emit = TRUE(!(0)); | |||
3541 | ||||
3542 | ctk_icon_view_item_free (item); | |||
3543 | ||||
3544 | for (next = list->next; next; next = next->next) | |||
3545 | { | |||
3546 | item = next->data; | |||
3547 | ||||
3548 | item->index--; | |||
3549 | } | |||
3550 | ||||
3551 | icon_view->priv->items = g_list_delete_link (icon_view->priv->items, list); | |||
3552 | ||||
3553 | verify_items (icon_view); | |||
3554 | ||||
3555 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3556 | ||||
3557 | if (emit) | |||
3558 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
3559 | } | |||
3560 | ||||
3561 | static void | |||
3562 | ctk_icon_view_rows_reordered (CtkTreeModel *model, | |||
3563 | CtkTreePath *parent G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3564 | CtkTreeIter *iter, | |||
3565 | gint *new_order, | |||
3566 | gpointer data) | |||
3567 | { | |||
3568 | CtkIconView *icon_view = CTK_ICON_VIEW (data)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_icon_view_get_type ())))))); | |||
3569 | int i; | |||
3570 | int length; | |||
3571 | GList *items = NULL((void*)0), *list; | |||
3572 | CtkIconViewItem **item_array; | |||
3573 | gint *order; | |||
3574 | ||||
3575 | /* ignore changes in branches */ | |||
3576 | if (iter != NULL((void*)0)) | |||
| ||||
3577 | return; | |||
3578 | ||||
3579 | if (icon_view->priv->cell_area) | |||
3580 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
3581 | ||||
3582 | length = ctk_tree_model_iter_n_children (model, NULL((void*)0)); | |||
3583 | ||||
3584 | order = g_new (gint, length)((gint *) g_malloc_n ((length), sizeof (gint))); | |||
3585 | for (i = 0; i < length; i++) | |||
3586 | order [new_order[i]] = i; | |||
3587 | ||||
3588 | item_array = g_new (CtkIconViewItem *, length)((CtkIconViewItem * *) g_malloc_n ((length), sizeof (CtkIconViewItem *))); | |||
3589 | for (i = 0, list = icon_view->priv->items; list != NULL((void*)0); list = list->next, i++) | |||
3590 | item_array[order[i]] = list->data; | |||
| ||||
3591 | g_free (order); | |||
3592 | ||||
3593 | for (i = length - 1; i >= 0; i--) | |||
3594 | { | |||
3595 | item_array[i]->index = i; | |||
3596 | items = g_list_prepend (items, item_array[i]); | |||
3597 | } | |||
3598 | ||||
3599 | g_free (item_array); | |||
3600 | g_list_free (icon_view->priv->items); | |||
3601 | icon_view->priv->items = items; | |||
3602 | ||||
3603 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3604 | ||||
3605 | verify_items (icon_view); | |||
3606 | } | |||
3607 | ||||
3608 | static void | |||
3609 | ctk_icon_view_build_items (CtkIconView *icon_view) | |||
3610 | { | |||
3611 | CtkTreeIter iter; | |||
3612 | int i; | |||
3613 | GList *items = NULL((void*)0); | |||
3614 | ||||
3615 | if (!ctk_tree_model_get_iter_first (icon_view->priv->model, | |||
3616 | &iter)) | |||
3617 | return; | |||
3618 | ||||
3619 | i = 0; | |||
3620 | ||||
3621 | do | |||
3622 | { | |||
3623 | CtkIconViewItem *item = ctk_icon_view_item_new (); | |||
3624 | ||||
3625 | item->index = i; | |||
3626 | ||||
3627 | i++; | |||
3628 | ||||
3629 | items = g_list_prepend (items, item); | |||
3630 | ||||
3631 | } while (ctk_tree_model_iter_next (icon_view->priv->model, &iter)); | |||
3632 | ||||
3633 | icon_view->priv->items = g_list_reverse (items); | |||
3634 | } | |||
3635 | ||||
3636 | static void | |||
3637 | ctk_icon_view_add_move_binding (CtkBindingSet *binding_set, | |||
3638 | guint keyval, | |||
3639 | guint modmask, | |||
3640 | CtkMovementStep step, | |||
3641 | gint count) | |||
3642 | { | |||
3643 | ||||
3644 | ctk_binding_entry_add_signal (binding_set, keyval, modmask, | |||
3645 | I_("move-cursor")g_intern_static_string ("move-cursor"), 2, | |||
3646 | G_TYPE_ENUM((GType) ((12) << (2))), step, | |||
3647 | G_TYPE_INT((GType) ((6) << (2))), count); | |||
3648 | ||||
3649 | ctk_binding_entry_add_signal (binding_set, keyval, CDK_SHIFT_MASK, | |||
3650 | "move-cursor", 2, | |||
3651 | G_TYPE_ENUM((GType) ((12) << (2))), step, | |||
3652 | G_TYPE_INT((GType) ((6) << (2))), count); | |||
3653 | ||||
3654 | if ((modmask & CDK_CONTROL_MASK) == CDK_CONTROL_MASK) | |||
3655 | return; | |||
3656 | ||||
3657 | ctk_binding_entry_add_signal (binding_set, keyval, CDK_CONTROL_MASK | CDK_SHIFT_MASK, | |||
3658 | "move-cursor", 2, | |||
3659 | G_TYPE_ENUM((GType) ((12) << (2))), step, | |||
3660 | G_TYPE_INT((GType) ((6) << (2))), count); | |||
3661 | ||||
3662 | ctk_binding_entry_add_signal (binding_set, keyval, CDK_CONTROL_MASK, | |||
3663 | "move-cursor", 2, | |||
3664 | G_TYPE_ENUM((GType) ((12) << (2))), step, | |||
3665 | G_TYPE_INT((GType) ((6) << (2))), count); | |||
3666 | } | |||
3667 | ||||
3668 | static gboolean | |||
3669 | ctk_icon_view_real_move_cursor (CtkIconView *icon_view, | |||
3670 | CtkMovementStep step, | |||
3671 | gint count) | |||
3672 | { | |||
3673 | CdkModifierType state; | |||
3674 | ||||
3675 | g_return_val_if_fail (CTK_ICON_VIEW (icon_view), FALSE)do { if ((((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((icon_view)), ((ctk_icon_view_get_type () )))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_ICON_VIEW (icon_view)"); return ((0)); } } while (0); | |||
3676 | g_return_val_if_fail (step == CTK_MOVEMENT_LOGICAL_POSITIONS ||do { if ((step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS" ); return ((0)); } } while (0) | |||
3677 | step == CTK_MOVEMENT_VISUAL_POSITIONS ||do { if ((step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS" ); return ((0)); } } while (0) | |||
3678 | step == CTK_MOVEMENT_DISPLAY_LINES ||do { if ((step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS" ); return ((0)); } } while (0) | |||
3679 | step == CTK_MOVEMENT_PAGES ||do { if ((step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS" ); return ((0)); } } while (0) | |||
3680 | step == CTK_MOVEMENT_BUFFER_ENDS, FALSE)do { if ((step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "step == CTK_MOVEMENT_LOGICAL_POSITIONS || step == CTK_MOVEMENT_VISUAL_POSITIONS || step == CTK_MOVEMENT_DISPLAY_LINES || step == CTK_MOVEMENT_PAGES || step == CTK_MOVEMENT_BUFFER_ENDS" ); return ((0)); } } while (0); | |||
3681 | ||||
3682 | if (!ctk_widget_has_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))))) | |||
3683 | return FALSE(0); | |||
3684 | ||||
3685 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, FALSE(0)); | |||
3686 | ctk_widget_grab_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3687 | ||||
3688 | if (ctk_get_current_event_state (&state)) | |||
3689 | { | |||
3690 | CdkModifierType extend_mod_mask; | |||
3691 | CdkModifierType modify_mod_mask; | |||
3692 | ||||
3693 | extend_mod_mask = | |||
3694 | ctk_widget_get_modifier_mask (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
3695 | CDK_MODIFIER_INTENT_EXTEND_SELECTION); | |||
3696 | modify_mod_mask = | |||
3697 | ctk_widget_get_modifier_mask (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
3698 | CDK_MODIFIER_INTENT_MODIFY_SELECTION); | |||
3699 | ||||
3700 | if ((state & modify_mod_mask) == modify_mod_mask) | |||
3701 | icon_view->priv->modify_selection_pressed = TRUE(!(0)); | |||
3702 | if ((state & extend_mod_mask) == extend_mod_mask) | |||
3703 | icon_view->priv->extend_selection_pressed = TRUE(!(0)); | |||
3704 | } | |||
3705 | /* else we assume not pressed */ | |||
3706 | ||||
3707 | switch (step) | |||
3708 | { | |||
3709 | case CTK_MOVEMENT_LOGICAL_POSITIONS: | |||
3710 | case CTK_MOVEMENT_VISUAL_POSITIONS: | |||
3711 | ctk_icon_view_move_cursor_left_right (icon_view, count); | |||
3712 | break; | |||
3713 | case CTK_MOVEMENT_DISPLAY_LINES: | |||
3714 | ctk_icon_view_move_cursor_up_down (icon_view, count); | |||
3715 | break; | |||
3716 | case CTK_MOVEMENT_PAGES: | |||
3717 | ctk_icon_view_move_cursor_page_up_down (icon_view, count); | |||
3718 | break; | |||
3719 | case CTK_MOVEMENT_BUFFER_ENDS: | |||
3720 | ctk_icon_view_move_cursor_start_end (icon_view, count); | |||
3721 | break; | |||
3722 | default: | |||
3723 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkiconview.c", 3723, ( (const char*) (__func__)), ((void*)0)); } while (0); | |||
3724 | } | |||
3725 | ||||
3726 | icon_view->priv->modify_selection_pressed = FALSE(0); | |||
3727 | icon_view->priv->extend_selection_pressed = FALSE(0); | |||
3728 | ||||
3729 | icon_view->priv->draw_focus = TRUE(!(0)); | |||
3730 | ||||
3731 | return TRUE(!(0)); | |||
3732 | } | |||
3733 | ||||
3734 | static CtkIconViewItem * | |||
3735 | find_item (CtkIconView *icon_view, | |||
3736 | CtkIconViewItem *current, | |||
3737 | gint row_ofs, | |||
3738 | gint col_ofs) | |||
3739 | { | |||
3740 | gint row, col; | |||
3741 | GList *items; | |||
3742 | CtkIconViewItem *item; | |||
3743 | ||||
3744 | /* FIXME: this could be more efficient | |||
3745 | */ | |||
3746 | row = current->row + row_ofs; | |||
3747 | col = current->col + col_ofs; | |||
3748 | ||||
3749 | for (items = icon_view->priv->items; items; items = items->next) | |||
3750 | { | |||
3751 | item = items->data; | |||
3752 | if (item->row == row && item->col == col) | |||
3753 | return item; | |||
3754 | } | |||
3755 | ||||
3756 | return NULL((void*)0); | |||
3757 | } | |||
3758 | ||||
3759 | static CtkIconViewItem * | |||
3760 | find_item_page_up_down (CtkIconView *icon_view, | |||
3761 | CtkIconViewItem *current, | |||
3762 | gint count) | |||
3763 | { | |||
3764 | GList *item, *next; | |||
3765 | gint y, col; | |||
3766 | ||||
3767 | col = current->col; | |||
3768 | y = current->cell_area.y + count * ctk_adjustment_get_page_size (icon_view->priv->vadjustment); | |||
3769 | ||||
3770 | item = g_list_find (icon_view->priv->items, current); | |||
3771 | if (count > 0) | |||
3772 | { | |||
3773 | while (item) | |||
3774 | { | |||
3775 | for (next = item->next; next; next = next->next) | |||
3776 | { | |||
3777 | if (((CtkIconViewItem *)next->data)->col == col) | |||
3778 | break; | |||
3779 | } | |||
3780 | if (!next || ((CtkIconViewItem *)next->data)->cell_area.y > y) | |||
3781 | break; | |||
3782 | ||||
3783 | item = next; | |||
3784 | } | |||
3785 | } | |||
3786 | else | |||
3787 | { | |||
3788 | while (item) | |||
3789 | { | |||
3790 | for (next = item->prev; next; next = next->prev) | |||
3791 | { | |||
3792 | if (((CtkIconViewItem *)next->data)->col == col) | |||
3793 | break; | |||
3794 | } | |||
3795 | if (!next || ((CtkIconViewItem *)next->data)->cell_area.y < y) | |||
3796 | break; | |||
3797 | ||||
3798 | item = next; | |||
3799 | } | |||
3800 | } | |||
3801 | ||||
3802 | if (item) | |||
3803 | return item->data; | |||
3804 | ||||
3805 | return NULL((void*)0); | |||
3806 | } | |||
3807 | ||||
3808 | static gboolean | |||
3809 | ctk_icon_view_select_all_between (CtkIconView *icon_view, | |||
3810 | CtkIconViewItem *anchor, | |||
3811 | CtkIconViewItem *cursor) | |||
3812 | { | |||
3813 | GList *items; | |||
3814 | CtkIconViewItem *item; | |||
3815 | gint row1, row2, col1, col2; | |||
3816 | gboolean dirty = FALSE(0); | |||
3817 | ||||
3818 | if (anchor->row < cursor->row) | |||
3819 | { | |||
3820 | row1 = anchor->row; | |||
3821 | row2 = cursor->row; | |||
3822 | } | |||
3823 | else | |||
3824 | { | |||
3825 | row1 = cursor->row; | |||
3826 | row2 = anchor->row; | |||
3827 | } | |||
3828 | ||||
3829 | if (anchor->col < cursor->col) | |||
3830 | { | |||
3831 | col1 = anchor->col; | |||
3832 | col2 = cursor->col; | |||
3833 | } | |||
3834 | else | |||
3835 | { | |||
3836 | col1 = cursor->col; | |||
3837 | col2 = anchor->col; | |||
3838 | } | |||
3839 | ||||
3840 | for (items = icon_view->priv->items; items; items = items->next) | |||
3841 | { | |||
3842 | item = items->data; | |||
3843 | ||||
3844 | if (row1 <= item->row && item->row <= row2 && | |||
3845 | col1 <= item->col && item->col <= col2) | |||
3846 | { | |||
3847 | if (!item->selected) | |||
3848 | { | |||
3849 | dirty = TRUE(!(0)); | |||
3850 | item->selected = TRUE(!(0)); | |||
3851 | ctk_icon_view_item_selected_changed (icon_view, item); | |||
3852 | } | |||
3853 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
3854 | } | |||
3855 | } | |||
3856 | ||||
3857 | return dirty; | |||
3858 | } | |||
3859 | ||||
3860 | static void | |||
3861 | ctk_icon_view_move_cursor_up_down (CtkIconView *icon_view, | |||
3862 | gint count) | |||
3863 | { | |||
3864 | CtkIconViewItem *item; | |||
3865 | CtkCellRenderer *cell = NULL((void*)0); | |||
3866 | gboolean dirty = FALSE(0); | |||
3867 | gint step; | |||
3868 | CtkDirectionType direction; | |||
3869 | ||||
3870 | if (!ctk_widget_has_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))))) | |||
3871 | return; | |||
3872 | ||||
3873 | direction = count < 0 ? CTK_DIR_UP : CTK_DIR_DOWN; | |||
3874 | ||||
3875 | if (!icon_view->priv->cursor_item) | |||
3876 | { | |||
3877 | GList *list; | |||
3878 | ||||
3879 | if (count > 0) | |||
3880 | list = icon_view->priv->items; | |||
3881 | else | |||
3882 | list = g_list_last (icon_view->priv->items); | |||
3883 | ||||
3884 | if (list) | |||
3885 | { | |||
3886 | item = list->data; | |||
3887 | ||||
3888 | /* Give focus to the first cell initially */ | |||
3889 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
3890 | ctk_cell_area_focus (icon_view->priv->cell_area, direction); | |||
3891 | } | |||
3892 | else | |||
3893 | { | |||
3894 | item = NULL((void*)0); | |||
3895 | } | |||
3896 | } | |||
3897 | else | |||
3898 | { | |||
3899 | item = icon_view->priv->cursor_item; | |||
3900 | step = count > 0 ? 1 : -1; | |||
3901 | ||||
3902 | /* Save the current focus cell in case we hit the edge */ | |||
3903 | cell = ctk_cell_area_get_focus_cell (icon_view->priv->cell_area); | |||
3904 | ||||
3905 | while (item) | |||
3906 | { | |||
3907 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
3908 | ||||
3909 | if (ctk_cell_area_focus (icon_view->priv->cell_area, direction)) | |||
3910 | break; | |||
3911 | ||||
3912 | item = find_item (icon_view, item, step, 0); | |||
3913 | } | |||
3914 | } | |||
3915 | ||||
3916 | if (!item) | |||
3917 | { | |||
3918 | if (!ctk_widget_keynav_failed (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), direction)) | |||
3919 | { | |||
3920 | CtkWidget *toplevel = ctk_widget_get_toplevel (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3921 | if (toplevel) | |||
3922 | ctk_widget_child_focus (toplevel, | |||
3923 | direction == CTK_DIR_UP ? | |||
3924 | CTK_DIR_TAB_BACKWARD : | |||
3925 | CTK_DIR_TAB_FORWARD); | |||
3926 | ||||
3927 | } | |||
3928 | ||||
3929 | ctk_cell_area_set_focus_cell (icon_view->priv->cell_area, cell); | |||
3930 | return; | |||
3931 | } | |||
3932 | ||||
3933 | if (icon_view->priv->modify_selection_pressed || | |||
3934 | !icon_view->priv->extend_selection_pressed || | |||
3935 | !icon_view->priv->anchor_item || | |||
3936 | icon_view->priv->selection_mode != CTK_SELECTION_MULTIPLE) | |||
3937 | icon_view->priv->anchor_item = item; | |||
3938 | ||||
3939 | cell = ctk_cell_area_get_focus_cell (icon_view->priv->cell_area); | |||
3940 | _ctk_icon_view_set_cursor_item (icon_view, item, cell); | |||
3941 | ||||
3942 | if (!icon_view->priv->modify_selection_pressed && | |||
3943 | icon_view->priv->selection_mode != CTK_SELECTION_NONE) | |||
3944 | { | |||
3945 | dirty = ctk_icon_view_unselect_all_internal (icon_view); | |||
3946 | dirty = ctk_icon_view_select_all_between (icon_view, | |||
3947 | icon_view->priv->anchor_item, | |||
3948 | item) || dirty; | |||
3949 | } | |||
3950 | ||||
3951 | ctk_icon_view_scroll_to_item (icon_view, item); | |||
3952 | ||||
3953 | if (dirty) | |||
3954 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
3955 | } | |||
3956 | ||||
3957 | static void | |||
3958 | ctk_icon_view_move_cursor_page_up_down (CtkIconView *icon_view, | |||
3959 | gint count) | |||
3960 | { | |||
3961 | CtkIconViewItem *item; | |||
3962 | gboolean dirty = FALSE(0); | |||
3963 | ||||
3964 | if (!ctk_widget_has_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))))) | |||
3965 | return; | |||
3966 | ||||
3967 | if (!icon_view->priv->cursor_item) | |||
3968 | { | |||
3969 | GList *list; | |||
3970 | ||||
3971 | if (count > 0) | |||
3972 | list = icon_view->priv->items; | |||
3973 | else | |||
3974 | list = g_list_last (icon_view->priv->items); | |||
3975 | ||||
3976 | item = list ? list->data : NULL((void*)0); | |||
3977 | } | |||
3978 | else | |||
3979 | item = find_item_page_up_down (icon_view, | |||
3980 | icon_view->priv->cursor_item, | |||
3981 | count); | |||
3982 | ||||
3983 | if (item == icon_view->priv->cursor_item) | |||
3984 | ctk_widget_error_bell (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
3985 | ||||
3986 | if (!item) | |||
3987 | return; | |||
3988 | ||||
3989 | if (icon_view->priv->modify_selection_pressed || | |||
3990 | !icon_view->priv->extend_selection_pressed || | |||
3991 | !icon_view->priv->anchor_item || | |||
3992 | icon_view->priv->selection_mode != CTK_SELECTION_MULTIPLE) | |||
3993 | icon_view->priv->anchor_item = item; | |||
3994 | ||||
3995 | _ctk_icon_view_set_cursor_item (icon_view, item, NULL((void*)0)); | |||
3996 | ||||
3997 | if (!icon_view->priv->modify_selection_pressed && | |||
3998 | icon_view->priv->selection_mode != CTK_SELECTION_NONE) | |||
3999 | { | |||
4000 | dirty = ctk_icon_view_unselect_all_internal (icon_view); | |||
4001 | dirty = ctk_icon_view_select_all_between (icon_view, | |||
4002 | icon_view->priv->anchor_item, | |||
4003 | item) || dirty; | |||
4004 | } | |||
4005 | ||||
4006 | ctk_icon_view_scroll_to_item (icon_view, item); | |||
4007 | ||||
4008 | if (dirty) | |||
4009 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
4010 | } | |||
4011 | ||||
4012 | static void | |||
4013 | ctk_icon_view_move_cursor_left_right (CtkIconView *icon_view, | |||
4014 | gint count) | |||
4015 | { | |||
4016 | CtkIconViewItem *item; | |||
4017 | CtkCellRenderer *cell = NULL((void*)0); | |||
4018 | gboolean dirty = FALSE(0); | |||
4019 | gint step; | |||
4020 | CtkDirectionType direction; | |||
4021 | ||||
4022 | if (!ctk_widget_has_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))))) | |||
4023 | return; | |||
4024 | ||||
4025 | direction = count < 0 ? CTK_DIR_LEFT : CTK_DIR_RIGHT; | |||
4026 | ||||
4027 | if (!icon_view->priv->cursor_item) | |||
4028 | { | |||
4029 | GList *list; | |||
4030 | ||||
4031 | if (count > 0) | |||
4032 | list = icon_view->priv->items; | |||
4033 | else | |||
4034 | list = g_list_last (icon_view->priv->items); | |||
4035 | ||||
4036 | if (list) | |||
4037 | { | |||
4038 | item = list->data; | |||
4039 | ||||
4040 | /* Give focus to the first cell initially */ | |||
4041 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
4042 | ctk_cell_area_focus (icon_view->priv->cell_area, direction); | |||
4043 | } | |||
4044 | else | |||
4045 | { | |||
4046 | item = NULL((void*)0); | |||
4047 | } | |||
4048 | } | |||
4049 | else | |||
4050 | { | |||
4051 | item = icon_view->priv->cursor_item; | |||
4052 | step = count > 0 ? 1 : -1; | |||
4053 | ||||
4054 | /* Save the current focus cell in case we hit the edge */ | |||
4055 | cell = ctk_cell_area_get_focus_cell (icon_view->priv->cell_area); | |||
4056 | ||||
4057 | while (item) | |||
4058 | { | |||
4059 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
4060 | ||||
4061 | if (ctk_cell_area_focus (icon_view->priv->cell_area, direction)) | |||
4062 | break; | |||
4063 | ||||
4064 | item = find_item (icon_view, item, 0, step); | |||
4065 | } | |||
4066 | } | |||
4067 | ||||
4068 | if (!item) | |||
4069 | { | |||
4070 | if (!ctk_widget_keynav_failed (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), direction)) | |||
4071 | { | |||
4072 | CtkWidget *toplevel = ctk_widget_get_toplevel (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
4073 | if (toplevel) | |||
4074 | ctk_widget_child_focus (toplevel, | |||
4075 | direction == CTK_DIR_LEFT ? | |||
4076 | CTK_DIR_TAB_BACKWARD : | |||
4077 | CTK_DIR_TAB_FORWARD); | |||
4078 | ||||
4079 | } | |||
4080 | ||||
4081 | ctk_cell_area_set_focus_cell (icon_view->priv->cell_area, cell); | |||
4082 | return; | |||
4083 | } | |||
4084 | ||||
4085 | if (icon_view->priv->modify_selection_pressed || | |||
4086 | !icon_view->priv->extend_selection_pressed || | |||
4087 | !icon_view->priv->anchor_item || | |||
4088 | icon_view->priv->selection_mode != CTK_SELECTION_MULTIPLE) | |||
4089 | icon_view->priv->anchor_item = item; | |||
4090 | ||||
4091 | cell = ctk_cell_area_get_focus_cell (icon_view->priv->cell_area); | |||
4092 | _ctk_icon_view_set_cursor_item (icon_view, item, cell); | |||
4093 | ||||
4094 | if (!icon_view->priv->modify_selection_pressed && | |||
4095 | icon_view->priv->selection_mode != CTK_SELECTION_NONE) | |||
4096 | { | |||
4097 | dirty = ctk_icon_view_unselect_all_internal (icon_view); | |||
4098 | dirty = ctk_icon_view_select_all_between (icon_view, | |||
4099 | icon_view->priv->anchor_item, | |||
4100 | item) || dirty; | |||
4101 | } | |||
4102 | ||||
4103 | ctk_icon_view_scroll_to_item (icon_view, item); | |||
4104 | ||||
4105 | if (dirty) | |||
4106 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
4107 | } | |||
4108 | ||||
4109 | static void | |||
4110 | ctk_icon_view_move_cursor_start_end (CtkIconView *icon_view, | |||
4111 | gint count) | |||
4112 | { | |||
4113 | CtkIconViewItem *item; | |||
4114 | GList *list; | |||
4115 | gboolean dirty = FALSE(0); | |||
4116 | ||||
4117 | if (!ctk_widget_has_focus (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))))) | |||
4118 | return; | |||
4119 | ||||
4120 | if (count < 0) | |||
4121 | list = icon_view->priv->items; | |||
4122 | else | |||
4123 | list = g_list_last (icon_view->priv->items); | |||
4124 | ||||
4125 | item = list ? list->data : NULL((void*)0); | |||
4126 | ||||
4127 | if (item == icon_view->priv->cursor_item) | |||
4128 | ctk_widget_error_bell (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
4129 | ||||
4130 | if (!item) | |||
4131 | return; | |||
4132 | ||||
4133 | if (icon_view->priv->modify_selection_pressed || | |||
4134 | !icon_view->priv->extend_selection_pressed || | |||
4135 | !icon_view->priv->anchor_item || | |||
4136 | icon_view->priv->selection_mode != CTK_SELECTION_MULTIPLE) | |||
4137 | icon_view->priv->anchor_item = item; | |||
4138 | ||||
4139 | _ctk_icon_view_set_cursor_item (icon_view, item, NULL((void*)0)); | |||
4140 | ||||
4141 | if (!icon_view->priv->modify_selection_pressed && | |||
4142 | icon_view->priv->selection_mode != CTK_SELECTION_NONE) | |||
4143 | { | |||
4144 | dirty = ctk_icon_view_unselect_all_internal (icon_view); | |||
4145 | dirty = ctk_icon_view_select_all_between (icon_view, | |||
4146 | icon_view->priv->anchor_item, | |||
4147 | item) || dirty; | |||
4148 | } | |||
4149 | ||||
4150 | ctk_icon_view_scroll_to_item (icon_view, item); | |||
4151 | ||||
4152 | if (dirty) | |||
4153 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
4154 | } | |||
4155 | ||||
4156 | /** | |||
4157 | * ctk_icon_view_scroll_to_path: | |||
4158 | * @icon_view: A #CtkIconView. | |||
4159 | * @path: The path of the item to move to. | |||
4160 | * @use_align: whether to use alignment arguments, or %FALSE. | |||
4161 | * @row_align: The vertical alignment of the item specified by @path. | |||
4162 | * @col_align: The horizontal alignment of the item specified by @path. | |||
4163 | * | |||
4164 | * Moves the alignments of @icon_view to the position specified by @path. | |||
4165 | * @row_align determines where the row is placed, and @col_align determines | |||
4166 | * where @column is placed. Both are expected to be between 0.0 and 1.0. | |||
4167 | * 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means | |||
4168 | * center. | |||
4169 | * | |||
4170 | * If @use_align is %FALSE, then the alignment arguments are ignored, and the | |||
4171 | * tree does the minimum amount of work to scroll the item onto the screen. | |||
4172 | * This means that the item will be scrolled to the edge closest to its current | |||
4173 | * position. If the item is currently visible on the screen, nothing is done. | |||
4174 | * | |||
4175 | * This function only works if the model is set, and @path is a valid row on | |||
4176 | * the model. If the model changes before the @icon_view is realized, the | |||
4177 | * centered path will be modified to reflect this change. | |||
4178 | * | |||
4179 | * Since: 2.8 | |||
4180 | **/ | |||
4181 | void | |||
4182 | ctk_icon_view_scroll_to_path (CtkIconView *icon_view, | |||
4183 | CtkTreePath *path, | |||
4184 | gboolean use_align, | |||
4185 | gfloat row_align, | |||
4186 | gfloat col_align) | |||
4187 | { | |||
4188 | CtkIconViewItem *item = NULL((void*)0); | |||
4189 | CtkWidget *widget; | |||
4190 | ||||
4191 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
4192 | g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return; } } while (0); | |||
4193 | g_return_if_fail (row_align >= 0.0 && row_align <= 1.0)do { if ((row_align >= 0.0 && row_align <= 1.0) ) { } else { g_return_if_fail_warning ("Ctk", ((const char*) ( __func__)), "row_align >= 0.0 && row_align <= 1.0" ); return; } } while (0); | |||
4194 | g_return_if_fail (col_align >= 0.0 && col_align <= 1.0)do { if ((col_align >= 0.0 && col_align <= 1.0) ) { } else { g_return_if_fail_warning ("Ctk", ((const char*) ( __func__)), "col_align >= 0.0 && col_align <= 1.0" ); return; } } while (0); | |||
4195 | ||||
4196 | widget = CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))); | |||
4197 | ||||
4198 | if (ctk_tree_path_get_depth (path) > 0) | |||
4199 | item = g_list_nth_data (icon_view->priv->items, | |||
4200 | ctk_tree_path_get_indices(path)[0]); | |||
4201 | ||||
4202 | if (!item || item->cell_area.width < 0 || | |||
4203 | !ctk_widget_get_realized (widget)) | |||
4204 | { | |||
4205 | if (icon_view->priv->scroll_to_path) | |||
4206 | ctk_tree_row_reference_free (icon_view->priv->scroll_to_path); | |||
4207 | ||||
4208 | icon_view->priv->scroll_to_path = NULL((void*)0); | |||
4209 | ||||
4210 | if (path) | |||
4211 | icon_view->priv->scroll_to_path = ctk_tree_row_reference_new_proxy (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), icon_view->priv->model, path); | |||
4212 | ||||
4213 | icon_view->priv->scroll_to_use_align = use_align; | |||
4214 | icon_view->priv->scroll_to_row_align = row_align; | |||
4215 | icon_view->priv->scroll_to_col_align = col_align; | |||
4216 | ||||
4217 | return; | |||
4218 | } | |||
4219 | ||||
4220 | if (use_align) | |||
4221 | { | |||
4222 | CtkAllocation allocation; | |||
4223 | gint x, y; | |||
4224 | gfloat offset; | |||
4225 | CdkRectangle item_area = | |||
4226 | { | |||
4227 | item->cell_area.x - icon_view->priv->item_padding, | |||
4228 | item->cell_area.y - icon_view->priv->item_padding, | |||
4229 | item->cell_area.width + icon_view->priv->item_padding * 2, | |||
4230 | item->cell_area.height + icon_view->priv->item_padding * 2 | |||
4231 | }; | |||
4232 | ||||
4233 | cdk_window_get_position (icon_view->priv->bin_window, &x, &y); | |||
4234 | ||||
4235 | ctk_widget_get_allocation (widget, &allocation); | |||
4236 | ||||
4237 | offset = y + item_area.y - row_align * (allocation.height - item_area.height); | |||
4238 | ||||
4239 | ctk_adjustment_set_value (icon_view->priv->vadjustment, | |||
4240 | ctk_adjustment_get_value (icon_view->priv->vadjustment) + offset); | |||
4241 | ||||
4242 | offset = x + item_area.x - col_align * (allocation.width - item_area.width); | |||
4243 | ||||
4244 | ctk_adjustment_set_value (icon_view->priv->hadjustment, | |||
4245 | ctk_adjustment_get_value (icon_view->priv->hadjustment) + offset); | |||
4246 | } | |||
4247 | else | |||
4248 | ctk_icon_view_scroll_to_item (icon_view, item); | |||
4249 | } | |||
4250 | ||||
4251 | ||||
4252 | static void | |||
4253 | ctk_icon_view_scroll_to_item (CtkIconView *icon_view, | |||
4254 | CtkIconViewItem *item) | |||
4255 | { | |||
4256 | CtkIconViewPrivate *priv = icon_view->priv; | |||
4257 | CtkWidget *widget = CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))); | |||
4258 | CtkAdjustment *hadj, *vadj; | |||
4259 | CtkAllocation allocation; | |||
4260 | gint x, y; | |||
4261 | CdkRectangle item_area; | |||
4262 | ||||
4263 | item_area.x = item->cell_area.x - priv->item_padding; | |||
4264 | item_area.y = item->cell_area.y - priv->item_padding; | |||
4265 | item_area.width = item->cell_area.width + priv->item_padding * 2; | |||
4266 | item_area.height = item->cell_area.height + priv->item_padding * 2; | |||
4267 | ||||
4268 | cdk_window_get_position (icon_view->priv->bin_window, &x, &y); | |||
4269 | ctk_widget_get_allocation (widget, &allocation); | |||
4270 | ||||
4271 | hadj = icon_view->priv->hadjustment; | |||
4272 | vadj = icon_view->priv->vadjustment; | |||
4273 | ||||
4274 | if (y + item_area.y < 0) | |||
4275 | ctk_adjustment_animate_to_value (vadj, | |||
4276 | ctk_adjustment_get_value (vadj) | |||
4277 | + y + item_area.y); | |||
4278 | else if (y + item_area.y + item_area.height > allocation.height) | |||
4279 | ctk_adjustment_animate_to_value (vadj, | |||
4280 | ctk_adjustment_get_value (vadj) | |||
4281 | + y + item_area.y + item_area.height - allocation.height); | |||
4282 | ||||
4283 | if (x + item_area.x < 0) | |||
4284 | ctk_adjustment_animate_to_value (hadj, | |||
4285 | ctk_adjustment_get_value (hadj) | |||
4286 | + x + item_area.x); | |||
4287 | else if (x + item_area.x + item_area.width > allocation.width) | |||
4288 | ctk_adjustment_animate_to_value (hadj, | |||
4289 | ctk_adjustment_get_value (hadj) | |||
4290 | + x + item_area.x + item_area.width - allocation.width); | |||
4291 | } | |||
4292 | ||||
4293 | /* CtkCellLayout implementation */ | |||
4294 | ||||
4295 | static void | |||
4296 | ctk_icon_view_ensure_cell_area (CtkIconView *icon_view, | |||
4297 | CtkCellArea *cell_area) | |||
4298 | { | |||
4299 | CtkIconViewPrivate *priv = icon_view->priv; | |||
4300 | ||||
4301 | if (priv->cell_area) | |||
4302 | return; | |||
4303 | ||||
4304 | if (cell_area) | |||
4305 | priv->cell_area = cell_area; | |||
4306 | else | |||
4307 | priv->cell_area = ctk_cell_area_box_new (); | |||
4308 | ||||
4309 | g_object_ref_sink (priv->cell_area)((__typeof__ (priv->cell_area)) (g_object_ref_sink) (priv-> cell_area)); | |||
4310 | ||||
4311 | if (CTK_IS_ORIENTABLE (priv->cell_area)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (priv->cell_area)); GType __t = ((ctk_orientable_get_type ( ))); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
4312 | ctk_orientable_set_orientation (CTK_ORIENTABLE (priv->cell_area)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->cell_area)), ((ctk_orientable_get_type ())))))), priv->item_orientation); | |||
4313 | ||||
4314 | priv->cell_area_context = ctk_cell_area_create_context (priv->cell_area); | |||
4315 | ||||
4316 | priv->add_editable_id = | |||
4317 | g_signal_connect (priv->cell_area, "add-editable",g_signal_connect_data ((priv->cell_area), ("add-editable") , (((GCallback) (ctk_icon_view_add_editable))), (icon_view), ( (void*)0), (GConnectFlags) 0) | |||
4318 | G_CALLBACK (ctk_icon_view_add_editable), icon_view)g_signal_connect_data ((priv->cell_area), ("add-editable") , (((GCallback) (ctk_icon_view_add_editable))), (icon_view), ( (void*)0), (GConnectFlags) 0); | |||
4319 | priv->remove_editable_id = | |||
4320 | g_signal_connect (priv->cell_area, "remove-editable",g_signal_connect_data ((priv->cell_area), ("remove-editable" ), (((GCallback) (ctk_icon_view_remove_editable))), (icon_view ), ((void*)0), (GConnectFlags) 0) | |||
4321 | G_CALLBACK (ctk_icon_view_remove_editable), icon_view)g_signal_connect_data ((priv->cell_area), ("remove-editable" ), (((GCallback) (ctk_icon_view_remove_editable))), (icon_view ), ((void*)0), (GConnectFlags) 0); | |||
4322 | ||||
4323 | update_text_cell (icon_view); | |||
4324 | update_pixbuf_cell (icon_view); | |||
4325 | } | |||
4326 | ||||
4327 | static CtkCellArea * | |||
4328 | ctk_icon_view_cell_layout_get_area (CtkCellLayout *cell_layout) | |||
4329 | { | |||
4330 | CtkIconView *icon_view = CTK_ICON_VIEW (cell_layout)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_icon_view_get_type ())))))); | |||
4331 | CtkIconViewPrivate *priv = icon_view->priv; | |||
4332 | ||||
4333 | if (G_UNLIKELY (!priv->cell_area)(!priv->cell_area)) | |||
4334 | ctk_icon_view_ensure_cell_area (icon_view, NULL((void*)0)); | |||
4335 | ||||
4336 | return icon_view->priv->cell_area; | |||
4337 | } | |||
4338 | ||||
4339 | void | |||
4340 | _ctk_icon_view_set_cell_data (CtkIconView *icon_view, | |||
4341 | CtkIconViewItem *item) | |||
4342 | { | |||
4343 | CtkTreeIter iter; | |||
4344 | CtkTreePath *path; | |||
4345 | ||||
4346 | path = ctk_tree_path_new_from_indices (item->index, -1); | |||
4347 | if (!ctk_tree_model_get_iter (icon_view->priv->model, &iter, path)) | |||
4348 | return; | |||
4349 | ctk_tree_path_free (path); | |||
4350 | ||||
4351 | ctk_cell_area_apply_attributes (icon_view->priv->cell_area, | |||
4352 | icon_view->priv->model, | |||
4353 | &iter, FALSE(0), FALSE(0)); | |||
4354 | } | |||
4355 | ||||
4356 | ||||
4357 | ||||
4358 | /* Public API */ | |||
4359 | ||||
4360 | ||||
4361 | /** | |||
4362 | * ctk_icon_view_new: | |||
4363 | * | |||
4364 | * Creates a new #CtkIconView widget | |||
4365 | * | |||
4366 | * Returns: A newly created #CtkIconView widget | |||
4367 | * | |||
4368 | * Since: 2.6 | |||
4369 | **/ | |||
4370 | CtkWidget * | |||
4371 | ctk_icon_view_new (void) | |||
4372 | { | |||
4373 | return g_object_new (CTK_TYPE_ICON_VIEW(ctk_icon_view_get_type ()), NULL((void*)0)); | |||
4374 | } | |||
4375 | ||||
4376 | /** | |||
4377 | * ctk_icon_view_new_with_area: | |||
4378 | * @area: the #CtkCellArea to use to layout cells | |||
4379 | * | |||
4380 | * Creates a new #CtkIconView widget using the | |||
4381 | * specified @area to layout cells inside the icons. | |||
4382 | * | |||
4383 | * Returns: A newly created #CtkIconView widget | |||
4384 | * | |||
4385 | * Since: 3.0 | |||
4386 | **/ | |||
4387 | CtkWidget * | |||
4388 | ctk_icon_view_new_with_area (CtkCellArea *area) | |||
4389 | { | |||
4390 | return g_object_new (CTK_TYPE_ICON_VIEW(ctk_icon_view_get_type ()), "cell-area", area, NULL((void*)0)); | |||
4391 | } | |||
4392 | ||||
4393 | /** | |||
4394 | * ctk_icon_view_new_with_model: | |||
4395 | * @model: The model. | |||
4396 | * | |||
4397 | * Creates a new #CtkIconView widget with the model @model. | |||
4398 | * | |||
4399 | * Returns: A newly created #CtkIconView widget. | |||
4400 | * | |||
4401 | * Since: 2.6 | |||
4402 | **/ | |||
4403 | CtkWidget * | |||
4404 | ctk_icon_view_new_with_model (CtkTreeModel *model) | |||
4405 | { | |||
4406 | return g_object_new (CTK_TYPE_ICON_VIEW(ctk_icon_view_get_type ()), "model", model, NULL((void*)0)); | |||
4407 | } | |||
4408 | ||||
4409 | /** | |||
4410 | * ctk_icon_view_convert_widget_to_bin_window_coords: | |||
4411 | * @icon_view: a #CtkIconView | |||
4412 | * @wx: X coordinate relative to the widget | |||
4413 | * @wy: Y coordinate relative to the widget | |||
4414 | * @bx: (out): return location for bin_window X coordinate | |||
4415 | * @by: (out): return location for bin_window Y coordinate | |||
4416 | * | |||
4417 | * Converts widget coordinates to coordinates for the bin_window, | |||
4418 | * as expected by e.g. ctk_icon_view_get_path_at_pos(). | |||
4419 | * | |||
4420 | * Since: 2.12 | |||
4421 | */ | |||
4422 | void | |||
4423 | ctk_icon_view_convert_widget_to_bin_window_coords (CtkIconView *icon_view, | |||
4424 | gint wx, | |||
4425 | gint wy, | |||
4426 | gint *bx, | |||
4427 | gint *by) | |||
4428 | { | |||
4429 | gint x, y; | |||
4430 | ||||
4431 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
4432 | ||||
4433 | if (icon_view->priv->bin_window) | |||
4434 | cdk_window_get_position (icon_view->priv->bin_window, &x, &y); | |||
4435 | else | |||
4436 | x = y = 0; | |||
4437 | ||||
4438 | if (bx) | |||
4439 | *bx = wx - x; | |||
4440 | if (by) | |||
4441 | *by = wy - y; | |||
4442 | } | |||
4443 | ||||
4444 | /** | |||
4445 | * ctk_icon_view_get_path_at_pos: | |||
4446 | * @icon_view: A #CtkIconView. | |||
4447 | * @x: The x position to be identified | |||
4448 | * @y: The y position to be identified | |||
4449 | * | |||
4450 | * Finds the path at the point (@x, @y), relative to bin_window coordinates. | |||
4451 | * See ctk_icon_view_get_item_at_pos(), if you are also interested in | |||
4452 | * the cell at the specified position. | |||
4453 | * See ctk_icon_view_convert_widget_to_bin_window_coords() for converting | |||
4454 | * widget coordinates to bin_window coordinates. | |||
4455 | * | |||
4456 | * Returns: (nullable) (transfer full): The #CtkTreePath corresponding | |||
4457 | * to the icon or %NULL if no icon exists at that position. | |||
4458 | * | |||
4459 | * Since: 2.6 | |||
4460 | **/ | |||
4461 | CtkTreePath * | |||
4462 | ctk_icon_view_get_path_at_pos (CtkIconView *icon_view, | |||
4463 | gint x, | |||
4464 | gint y) | |||
4465 | { | |||
4466 | CtkIconViewItem *item; | |||
4467 | CtkTreePath *path; | |||
4468 | ||||
4469 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (((void*)0)); } } while (0); | |||
4470 | ||||
4471 | item = _ctk_icon_view_get_item_at_coords (icon_view, x, y, TRUE(!(0)), NULL((void*)0)); | |||
4472 | ||||
4473 | if (!item) | |||
4474 | return NULL((void*)0); | |||
4475 | ||||
4476 | path = ctk_tree_path_new_from_indices (item->index, -1); | |||
4477 | ||||
4478 | return path; | |||
4479 | } | |||
4480 | ||||
4481 | /** | |||
4482 | * ctk_icon_view_get_item_at_pos: | |||
4483 | * @icon_view: A #CtkIconView. | |||
4484 | * @x: The x position to be identified | |||
4485 | * @y: The y position to be identified | |||
4486 | * @path: (out) (allow-none): Return location for the path, or %NULL | |||
4487 | * @cell: (out) (allow-none) (transfer none): Return location for the renderer | |||
4488 | * responsible for the cell at (@x, @y), or %NULL | |||
4489 | * | |||
4490 | * Finds the path at the point (@x, @y), relative to bin_window coordinates. | |||
4491 | * In contrast to ctk_icon_view_get_path_at_pos(), this function also | |||
4492 | * obtains the cell at the specified position. The returned path should | |||
4493 | * be freed with ctk_tree_path_free(). | |||
4494 | * See ctk_icon_view_convert_widget_to_bin_window_coords() for converting | |||
4495 | * widget coordinates to bin_window coordinates. | |||
4496 | * | |||
4497 | * Returns: %TRUE if an item exists at the specified position | |||
4498 | * | |||
4499 | * Since: 2.8 | |||
4500 | **/ | |||
4501 | gboolean | |||
4502 | ctk_icon_view_get_item_at_pos (CtkIconView *icon_view, | |||
4503 | gint x, | |||
4504 | gint y, | |||
4505 | CtkTreePath **path, | |||
4506 | CtkCellRenderer **cell) | |||
4507 | { | |||
4508 | CtkIconViewItem *item; | |||
4509 | CtkCellRenderer *renderer = NULL((void*)0); | |||
4510 | ||||
4511 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
4512 | ||||
4513 | item = _ctk_icon_view_get_item_at_coords (icon_view, x, y, TRUE(!(0)), &renderer); | |||
4514 | ||||
4515 | if (path != NULL((void*)0)) | |||
4516 | { | |||
4517 | if (item != NULL((void*)0)) | |||
4518 | *path = ctk_tree_path_new_from_indices (item->index, -1); | |||
4519 | else | |||
4520 | *path = NULL((void*)0); | |||
4521 | } | |||
4522 | ||||
4523 | if (cell != NULL((void*)0)) | |||
4524 | *cell = renderer; | |||
4525 | ||||
4526 | return (item != NULL((void*)0)); | |||
4527 | } | |||
4528 | ||||
4529 | /** | |||
4530 | * ctk_icon_view_get_cell_rect: | |||
4531 | * @icon_view: a #CtkIconView | |||
4532 | * @path: a #CtkTreePath | |||
4533 | * @cell: (allow-none): a #CtkCellRenderer or %NULL | |||
4534 | * @rect: (out): rectangle to fill with cell rect | |||
4535 | * | |||
4536 | * Fills the bounding rectangle in widget coordinates for the cell specified by | |||
4537 | * @path and @cell. If @cell is %NULL the main cell area is used. | |||
4538 | * | |||
4539 | * This function is only valid if @icon_view is realized. | |||
4540 | * | |||
4541 | * Returns: %FALSE if there is no such item, %TRUE otherwise | |||
4542 | * | |||
4543 | * Since: 3.6 | |||
4544 | */ | |||
4545 | gboolean | |||
4546 | ctk_icon_view_get_cell_rect (CtkIconView *icon_view, | |||
4547 | CtkTreePath *path, | |||
4548 | CtkCellRenderer *cell, | |||
4549 | CdkRectangle *rect) | |||
4550 | { | |||
4551 | CtkIconViewItem *item = NULL((void*)0); | |||
4552 | gint x, y; | |||
4553 | ||||
4554 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
4555 | g_return_val_if_fail (cell == NULL || CTK_IS_CELL_RENDERER (cell), FALSE)do { if ((cell == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((cell)); GType __t = ((ctk_cell_renderer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell == NULL || CTK_IS_CELL_RENDERER (cell)" ); return ((0)); } } while (0); | |||
4556 | ||||
4557 | if (ctk_tree_path_get_depth (path) > 0) | |||
4558 | item = g_list_nth_data (icon_view->priv->items, | |||
4559 | ctk_tree_path_get_indices(path)[0]); | |||
4560 | ||||
4561 | if (!item) | |||
4562 | return FALSE(0); | |||
4563 | ||||
4564 | if (cell) | |||
4565 | { | |||
4566 | CtkCellAreaContext *context; | |||
4567 | ||||
4568 | context = g_ptr_array_index (icon_view->priv->row_contexts, item->row)((icon_view->priv->row_contexts)->pdata)[item->row ]; | |||
4569 | _ctk_icon_view_set_cell_data (icon_view, item); | |||
4570 | ctk_cell_area_get_cell_allocation (icon_view->priv->cell_area, context, | |||
4571 | CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
4572 | cell, &item->cell_area, rect); | |||
4573 | } | |||
4574 | else | |||
4575 | { | |||
4576 | rect->x = item->cell_area.x - icon_view->priv->item_padding; | |||
4577 | rect->y = item->cell_area.y - icon_view->priv->item_padding; | |||
4578 | rect->width = item->cell_area.width + icon_view->priv->item_padding * 2; | |||
4579 | rect->height = item->cell_area.height + icon_view->priv->item_padding * 2; | |||
4580 | } | |||
4581 | ||||
4582 | if (icon_view->priv->bin_window) | |||
4583 | { | |||
4584 | cdk_window_get_position (icon_view->priv->bin_window, &x, &y); | |||
4585 | rect->x += x; | |||
4586 | rect->y += y; | |||
4587 | } | |||
4588 | ||||
4589 | return TRUE(!(0)); | |||
4590 | } | |||
4591 | ||||
4592 | /** | |||
4593 | * ctk_icon_view_set_tooltip_item: | |||
4594 | * @icon_view: a #CtkIconView | |||
4595 | * @tooltip: a #CtkTooltip | |||
4596 | * @path: a #CtkTreePath | |||
4597 | * | |||
4598 | * Sets the tip area of @tooltip to be the area covered by the item at @path. | |||
4599 | * See also ctk_icon_view_set_tooltip_column() for a simpler alternative. | |||
4600 | * See also ctk_tooltip_set_tip_area(). | |||
4601 | * | |||
4602 | * Since: 2.12 | |||
4603 | */ | |||
4604 | void | |||
4605 | ctk_icon_view_set_tooltip_item (CtkIconView *icon_view, | |||
4606 | CtkTooltip *tooltip, | |||
4607 | CtkTreePath *path) | |||
4608 | { | |||
4609 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
4610 | g_return_if_fail (CTK_IS_TOOLTIP (tooltip))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tooltip)); GType __t = ((ctk_tooltip_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOLTIP (tooltip)"); return; } } while (0); | |||
4611 | ||||
4612 | ctk_icon_view_set_tooltip_cell (icon_view, tooltip, path, NULL((void*)0)); | |||
4613 | } | |||
4614 | ||||
4615 | /** | |||
4616 | * ctk_icon_view_set_tooltip_cell: | |||
4617 | * @icon_view: a #CtkIconView | |||
4618 | * @tooltip: a #CtkTooltip | |||
4619 | * @path: a #CtkTreePath | |||
4620 | * @cell: (allow-none): a #CtkCellRenderer or %NULL | |||
4621 | * | |||
4622 | * Sets the tip area of @tooltip to the area which @cell occupies in | |||
4623 | * the item pointed to by @path. See also ctk_tooltip_set_tip_area(). | |||
4624 | * | |||
4625 | * See also ctk_icon_view_set_tooltip_column() for a simpler alternative. | |||
4626 | * | |||
4627 | * Since: 2.12 | |||
4628 | */ | |||
4629 | void | |||
4630 | ctk_icon_view_set_tooltip_cell (CtkIconView *icon_view, | |||
4631 | CtkTooltip *tooltip, | |||
4632 | CtkTreePath *path, | |||
4633 | CtkCellRenderer *cell) | |||
4634 | { | |||
4635 | CdkRectangle rect; | |||
4636 | ||||
4637 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
4638 | g_return_if_fail (CTK_IS_TOOLTIP (tooltip))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tooltip)); GType __t = ((ctk_tooltip_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOLTIP (tooltip)"); return; } } while (0); | |||
4639 | g_return_if_fail (cell == NULL || CTK_IS_CELL_RENDERER (cell))do { if ((cell == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((cell)); GType __t = ((ctk_cell_renderer_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell == NULL || CTK_IS_CELL_RENDERER (cell)" ); return; } } while (0); | |||
4640 | ||||
4641 | if (!ctk_icon_view_get_cell_rect (icon_view, path, cell, &rect)) | |||
4642 | return; | |||
4643 | ||||
4644 | ctk_tooltip_set_tip_area (tooltip, &rect); | |||
4645 | } | |||
4646 | ||||
4647 | ||||
4648 | /** | |||
4649 | * ctk_icon_view_get_tooltip_context: | |||
4650 | * @icon_view: an #CtkIconView | |||
4651 | * @x: (inout): the x coordinate (relative to widget coordinates) | |||
4652 | * @y: (inout): the y coordinate (relative to widget coordinates) | |||
4653 | * @keyboard_tip: whether this is a keyboard tooltip or not | |||
4654 | * @model: (out) (allow-none) (transfer none): a pointer to receive a | |||
4655 | * #CtkTreeModel or %NULL | |||
4656 | * @path: (out) (allow-none): a pointer to receive a #CtkTreePath or %NULL | |||
4657 | * @iter: (out) (allow-none): a pointer to receive a #CtkTreeIter or %NULL | |||
4658 | * | |||
4659 | * This function is supposed to be used in a #CtkWidget::query-tooltip | |||
4660 | * signal handler for #CtkIconView. The @x, @y and @keyboard_tip values | |||
4661 | * which are received in the signal handler, should be passed to this | |||
4662 | * function without modification. | |||
4663 | * | |||
4664 | * The return value indicates whether there is an icon view item at the given | |||
4665 | * coordinates (%TRUE) or not (%FALSE) for mouse tooltips. For keyboard | |||
4666 | * tooltips the item returned will be the cursor item. When %TRUE, then any of | |||
4667 | * @model, @path and @iter which have been provided will be set to point to | |||
4668 | * that row and the corresponding model. @x and @y will always be converted | |||
4669 | * to be relative to @icon_view’s bin_window if @keyboard_tooltip is %FALSE. | |||
4670 | * | |||
4671 | * Returns: whether or not the given tooltip context points to a item | |||
4672 | * | |||
4673 | * Since: 2.12 | |||
4674 | */ | |||
4675 | gboolean | |||
4676 | ctk_icon_view_get_tooltip_context (CtkIconView *icon_view, | |||
4677 | gint *x, | |||
4678 | gint *y, | |||
4679 | gboolean keyboard_tip, | |||
4680 | CtkTreeModel **model, | |||
4681 | CtkTreePath **path, | |||
4682 | CtkTreeIter *iter) | |||
4683 | { | |||
4684 | CtkTreePath *tmppath = NULL((void*)0); | |||
4685 | ||||
4686 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
4687 | g_return_val_if_fail (x != NULL, FALSE)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "x != NULL"); return ((0 )); } } while (0); | |||
4688 | g_return_val_if_fail (y != NULL, FALSE)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "y != NULL"); return ((0 )); } } while (0); | |||
4689 | ||||
4690 | if (keyboard_tip) | |||
4691 | { | |||
4692 | ctk_icon_view_get_cursor (icon_view, &tmppath, NULL((void*)0)); | |||
4693 | ||||
4694 | if (!tmppath) | |||
4695 | return FALSE(0); | |||
4696 | } | |||
4697 | else | |||
4698 | { | |||
4699 | ctk_icon_view_convert_widget_to_bin_window_coords (icon_view, *x, *y, | |||
4700 | x, y); | |||
4701 | ||||
4702 | if (!ctk_icon_view_get_item_at_pos (icon_view, *x, *y, &tmppath, NULL((void*)0))) | |||
4703 | return FALSE(0); | |||
4704 | } | |||
4705 | ||||
4706 | if (model) | |||
4707 | *model = ctk_icon_view_get_model (icon_view); | |||
4708 | ||||
4709 | if (iter) | |||
4710 | ctk_tree_model_get_iter (ctk_icon_view_get_model (icon_view), | |||
4711 | iter, tmppath); | |||
4712 | ||||
4713 | if (path) | |||
4714 | *path = tmppath; | |||
4715 | else | |||
4716 | ctk_tree_path_free (tmppath); | |||
4717 | ||||
4718 | return TRUE(!(0)); | |||
4719 | } | |||
4720 | ||||
4721 | static gboolean | |||
4722 | ctk_icon_view_set_tooltip_query_cb (CtkWidget *widget, | |||
4723 | gint x, | |||
4724 | gint y, | |||
4725 | gboolean keyboard_tip, | |||
4726 | CtkTooltip *tooltip, | |||
4727 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
4728 | { | |||
4729 | gchar *str; | |||
4730 | CtkTreeIter iter; | |||
4731 | CtkTreePath *path; | |||
4732 | CtkTreeModel *model; | |||
4733 | CtkIconView *icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
4734 | ||||
4735 | if (!ctk_icon_view_get_tooltip_context (CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))), | |||
4736 | &x, &y, | |||
4737 | keyboard_tip, | |||
4738 | &model, &path, &iter)) | |||
4739 | return FALSE(0); | |||
4740 | ||||
4741 | ctk_tree_model_get (model, &iter, icon_view->priv->tooltip_column, &str, -1); | |||
4742 | ||||
4743 | if (!str) | |||
4744 | { | |||
4745 | ctk_tree_path_free (path); | |||
4746 | return FALSE(0); | |||
4747 | } | |||
4748 | ||||
4749 | ctk_tooltip_set_markup (tooltip, str); | |||
4750 | ctk_icon_view_set_tooltip_item (icon_view, tooltip, path); | |||
4751 | ||||
4752 | ctk_tree_path_free (path); | |||
4753 | g_free (str); | |||
4754 | ||||
4755 | return TRUE(!(0)); | |||
4756 | } | |||
4757 | ||||
4758 | ||||
4759 | /** | |||
4760 | * ctk_icon_view_set_tooltip_column: | |||
4761 | * @icon_view: a #CtkIconView | |||
4762 | * @column: an integer, which is a valid column number for @icon_view’s model | |||
4763 | * | |||
4764 | * If you only plan to have simple (text-only) tooltips on full items, you | |||
4765 | * can use this function to have #CtkIconView handle these automatically | |||
4766 | * for you. @column should be set to the column in @icon_view’s model | |||
4767 | * containing the tooltip texts, or -1 to disable this feature. | |||
4768 | * | |||
4769 | * When enabled, #CtkWidget:has-tooltip will be set to %TRUE and | |||
4770 | * @icon_view will connect a #CtkWidget::query-tooltip signal handler. | |||
4771 | * | |||
4772 | * Note that the signal handler sets the text with ctk_tooltip_set_markup(), | |||
4773 | * so &, <, etc have to be escaped in the text. | |||
4774 | * | |||
4775 | * Since: 2.12 | |||
4776 | */ | |||
4777 | void | |||
4778 | ctk_icon_view_set_tooltip_column (CtkIconView *icon_view, | |||
4779 | gint column) | |||
4780 | { | |||
4781 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
4782 | ||||
4783 | if (column == icon_view->priv->tooltip_column) | |||
4784 | return; | |||
4785 | ||||
4786 | if (column == -1) | |||
4787 | { | |||
4788 | g_signal_handlers_disconnect_by_func (icon_view,g_signal_handlers_disconnect_matched ((icon_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (ctk_icon_view_set_tooltip_query_cb), (((void*)0))) | |||
4789 | ctk_icon_view_set_tooltip_query_cb,g_signal_handlers_disconnect_matched ((icon_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (ctk_icon_view_set_tooltip_query_cb), (((void*)0))) | |||
4790 | NULL)g_signal_handlers_disconnect_matched ((icon_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (ctk_icon_view_set_tooltip_query_cb), (((void*)0))); | |||
4791 | ctk_widget_set_has_tooltip (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), FALSE(0)); | |||
4792 | } | |||
4793 | else | |||
4794 | { | |||
4795 | if (icon_view->priv->tooltip_column == -1) | |||
4796 | { | |||
4797 | g_signal_connect (icon_view, "query-tooltip",g_signal_connect_data ((icon_view), ("query-tooltip"), (((GCallback ) (ctk_icon_view_set_tooltip_query_cb))), (((void*)0)), ((void *)0), (GConnectFlags) 0) | |||
4798 | G_CALLBACK (ctk_icon_view_set_tooltip_query_cb), NULL)g_signal_connect_data ((icon_view), ("query-tooltip"), (((GCallback ) (ctk_icon_view_set_tooltip_query_cb))), (((void*)0)), ((void *)0), (GConnectFlags) 0); | |||
4799 | ctk_widget_set_has_tooltip (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), TRUE(!(0))); | |||
4800 | } | |||
4801 | } | |||
4802 | ||||
4803 | icon_view->priv->tooltip_column = column; | |||
4804 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "tooltip-column"); | |||
4805 | } | |||
4806 | ||||
4807 | /** | |||
4808 | * ctk_icon_view_get_tooltip_column: | |||
4809 | * @icon_view: a #CtkIconView | |||
4810 | * | |||
4811 | * Returns the column of @icon_view’s model which is being used for | |||
4812 | * displaying tooltips on @icon_view’s rows. | |||
4813 | * | |||
4814 | * Returns: the index of the tooltip column that is currently being | |||
4815 | * used, or -1 if this is disabled. | |||
4816 | * | |||
4817 | * Since: 2.12 | |||
4818 | */ | |||
4819 | gint | |||
4820 | ctk_icon_view_get_tooltip_column (CtkIconView *icon_view) | |||
4821 | { | |||
4822 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (0); } } while (0 ); | |||
4823 | ||||
4824 | return icon_view->priv->tooltip_column; | |||
4825 | } | |||
4826 | ||||
4827 | /** | |||
4828 | * ctk_icon_view_get_visible_range: | |||
4829 | * @icon_view: A #CtkIconView | |||
4830 | * @start_path: (out) (allow-none): Return location for start of region, | |||
4831 | * or %NULL | |||
4832 | * @end_path: (out) (allow-none): Return location for end of region, or %NULL | |||
4833 | * | |||
4834 | * Sets @start_path and @end_path to be the first and last visible path. | |||
4835 | * Note that there may be invisible paths in between. | |||
4836 | * | |||
4837 | * Both paths should be freed with ctk_tree_path_free() after use. | |||
4838 | * | |||
4839 | * Returns: %TRUE, if valid paths were placed in @start_path and @end_path | |||
4840 | * | |||
4841 | * Since: 2.8 | |||
4842 | **/ | |||
4843 | gboolean | |||
4844 | ctk_icon_view_get_visible_range (CtkIconView *icon_view, | |||
4845 | CtkTreePath **start_path, | |||
4846 | CtkTreePath **end_path) | |||
4847 | { | |||
4848 | gint start_index = -1; | |||
4849 | gint end_index = -1; | |||
4850 | GList *icons; | |||
4851 | ||||
4852 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
4853 | ||||
4854 | if (icon_view->priv->hadjustment == NULL((void*)0) || | |||
4855 | icon_view->priv->vadjustment == NULL((void*)0)) | |||
4856 | return FALSE(0); | |||
4857 | ||||
4858 | if (start_path == NULL((void*)0) && end_path == NULL((void*)0)) | |||
4859 | return FALSE(0); | |||
4860 | ||||
4861 | for (icons = icon_view->priv->items; icons; icons = icons->next) | |||
4862 | { | |||
4863 | CtkIconViewItem *item = icons->data; | |||
4864 | CdkRectangle *item_area = &item->cell_area; | |||
4865 | ||||
4866 | if ((item_area->x + item_area->width >= (int)ctk_adjustment_get_value (icon_view->priv->hadjustment)) && | |||
4867 | (item_area->y + item_area->height >= (int)ctk_adjustment_get_value (icon_view->priv->vadjustment)) && | |||
4868 | (item_area->x <= | |||
4869 | (int) (ctk_adjustment_get_value (icon_view->priv->hadjustment) + | |||
4870 | ctk_adjustment_get_page_size (icon_view->priv->hadjustment))) && | |||
4871 | (item_area->y <= | |||
4872 | (int) (ctk_adjustment_get_value (icon_view->priv->vadjustment) + | |||
4873 | ctk_adjustment_get_page_size (icon_view->priv->vadjustment)))) | |||
4874 | { | |||
4875 | if (start_index == -1) | |||
4876 | start_index = item->index; | |||
4877 | end_index = item->index; | |||
4878 | } | |||
4879 | } | |||
4880 | ||||
4881 | if (start_path && start_index != -1) | |||
4882 | *start_path = ctk_tree_path_new_from_indices (start_index, -1); | |||
4883 | if (end_path && end_index != -1) | |||
4884 | *end_path = ctk_tree_path_new_from_indices (end_index, -1); | |||
4885 | ||||
4886 | return start_index != -1; | |||
4887 | } | |||
4888 | ||||
4889 | /** | |||
4890 | * ctk_icon_view_selected_foreach: | |||
4891 | * @icon_view: A #CtkIconView. | |||
4892 | * @func: (scope call): The function to call for each selected icon. | |||
4893 | * @data: User data to pass to the function. | |||
4894 | * | |||
4895 | * Calls a function for each selected icon. Note that the model or | |||
4896 | * selection cannot be modified from within this function. | |||
4897 | * | |||
4898 | * Since: 2.6 | |||
4899 | **/ | |||
4900 | void | |||
4901 | ctk_icon_view_selected_foreach (CtkIconView *icon_view, | |||
4902 | CtkIconViewForeachFunc func, | |||
4903 | gpointer data) | |||
4904 | { | |||
4905 | GList *list; | |||
4906 | ||||
4907 | for (list = icon_view->priv->items; list; list = list->next) | |||
4908 | { | |||
4909 | CtkIconViewItem *item = list->data; | |||
4910 | CtkTreePath *path = ctk_tree_path_new_from_indices (item->index, -1); | |||
4911 | ||||
4912 | if (item->selected) | |||
4913 | (* func) (icon_view, path, data); | |||
4914 | ||||
4915 | ctk_tree_path_free (path); | |||
4916 | } | |||
4917 | } | |||
4918 | ||||
4919 | /** | |||
4920 | * ctk_icon_view_set_selection_mode: | |||
4921 | * @icon_view: A #CtkIconView. | |||
4922 | * @mode: The selection mode | |||
4923 | * | |||
4924 | * Sets the selection mode of the @icon_view. | |||
4925 | * | |||
4926 | * Since: 2.6 | |||
4927 | **/ | |||
4928 | void | |||
4929 | ctk_icon_view_set_selection_mode (CtkIconView *icon_view, | |||
4930 | CtkSelectionMode mode) | |||
4931 | { | |||
4932 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
4933 | ||||
4934 | if (mode == icon_view->priv->selection_mode) | |||
4935 | return; | |||
4936 | ||||
4937 | if (mode == CTK_SELECTION_NONE || | |||
4938 | icon_view->priv->selection_mode == CTK_SELECTION_MULTIPLE) | |||
4939 | ctk_icon_view_unselect_all (icon_view); | |||
4940 | ||||
4941 | icon_view->priv->selection_mode = mode; | |||
4942 | ||||
4943 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "selection-mode"); | |||
4944 | } | |||
4945 | ||||
4946 | /** | |||
4947 | * ctk_icon_view_get_selection_mode: | |||
4948 | * @icon_view: A #CtkIconView. | |||
4949 | * | |||
4950 | * Gets the selection mode of the @icon_view. | |||
4951 | * | |||
4952 | * Returns: the current selection mode | |||
4953 | * | |||
4954 | * Since: 2.6 | |||
4955 | **/ | |||
4956 | CtkSelectionMode | |||
4957 | ctk_icon_view_get_selection_mode (CtkIconView *icon_view) | |||
4958 | { | |||
4959 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), CTK_SELECTION_SINGLE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (CTK_SELECTION_SINGLE ); } } while (0); | |||
4960 | ||||
4961 | return icon_view->priv->selection_mode; | |||
4962 | } | |||
4963 | ||||
4964 | /** | |||
4965 | * ctk_icon_view_set_model: | |||
4966 | * @icon_view: A #CtkIconView. | |||
4967 | * @model: (allow-none): The model. | |||
4968 | * | |||
4969 | * Sets the model for a #CtkIconView. | |||
4970 | * If the @icon_view already has a model set, it will remove | |||
4971 | * it before setting the new model. If @model is %NULL, then | |||
4972 | * it will unset the old model. | |||
4973 | * | |||
4974 | * Since: 2.6 | |||
4975 | **/ | |||
4976 | void | |||
4977 | ctk_icon_view_set_model (CtkIconView *icon_view, | |||
4978 | CtkTreeModel *model) | |||
4979 | { | |||
4980 | gboolean dirty; | |||
4981 | ||||
4982 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
4983 | g_return_if_fail (model == NULL || CTK_IS_TREE_MODEL (model))do { if ((model == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((model)); GType __t = ((ctk_tree_model_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "model == NULL || CTK_IS_TREE_MODEL (model)" ); return; } } while (0); | |||
4984 | ||||
4985 | if (icon_view->priv->model == model) | |||
4986 | return; | |||
4987 | ||||
4988 | if (icon_view->priv->scroll_to_path) | |||
4989 | { | |||
4990 | ctk_tree_row_reference_free (icon_view->priv->scroll_to_path); | |||
4991 | icon_view->priv->scroll_to_path = NULL((void*)0); | |||
4992 | } | |||
4993 | ||||
4994 | /* The area can be NULL while disposing */ | |||
4995 | if (icon_view->priv->cell_area) | |||
4996 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
4997 | ||||
4998 | dirty = ctk_icon_view_unselect_all_internal (icon_view); | |||
4999 | ||||
5000 | if (model) | |||
5001 | { | |||
5002 | GType column_type; | |||
5003 | ||||
5004 | if (icon_view->priv->pixbuf_column != -1) | |||
5005 | { | |||
5006 | column_type = ctk_tree_model_get_column_type (model, | |||
5007 | icon_view->priv->pixbuf_column); | |||
5008 | ||||
5009 | g_return_if_fail (column_type == GDK_TYPE_PIXBUF)do { if ((column_type == (gdk_pixbuf_get_type ()))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "column_type == GDK_TYPE_PIXBUF"); return; } } while (0); | |||
5010 | } | |||
5011 | ||||
5012 | if (icon_view->priv->text_column != -1) | |||
5013 | { | |||
5014 | column_type = ctk_tree_model_get_column_type (model, | |||
5015 | icon_view->priv->text_column); | |||
5016 | ||||
5017 | g_return_if_fail (column_type == G_TYPE_STRING)do { if ((column_type == ((GType) ((16) << (2))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "column_type == G_TYPE_STRING"); return; } } while (0); | |||
5018 | } | |||
5019 | ||||
5020 | if (icon_view->priv->markup_column != -1) | |||
5021 | { | |||
5022 | column_type = ctk_tree_model_get_column_type (model, | |||
5023 | icon_view->priv->markup_column); | |||
5024 | ||||
5025 | g_return_if_fail (column_type == G_TYPE_STRING)do { if ((column_type == ((GType) ((16) << (2))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "column_type == G_TYPE_STRING"); return; } } while (0); | |||
5026 | } | |||
5027 | ||||
5028 | } | |||
5029 | ||||
5030 | if (icon_view->priv->model) | |||
5031 | { | |||
5032 | g_signal_handlers_disconnect_by_func (icon_view->priv->model,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_changed), (icon_view) ) | |||
5033 | ctk_icon_view_row_changed,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_changed), (icon_view) ) | |||
5034 | icon_view)g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_changed), (icon_view) ); | |||
5035 | g_signal_handlers_disconnect_by_func (icon_view->priv->model,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_inserted), (icon_view )) | |||
5036 | ctk_icon_view_row_inserted,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_inserted), (icon_view )) | |||
5037 | icon_view)g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_inserted), (icon_view )); | |||
5038 | g_signal_handlers_disconnect_by_func (icon_view->priv->model,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_deleted), (icon_view) ) | |||
5039 | ctk_icon_view_row_deleted,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_deleted), (icon_view) ) | |||
5040 | icon_view)g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_row_deleted), (icon_view) ); | |||
5041 | g_signal_handlers_disconnect_by_func (icon_view->priv->model,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_rows_reordered), (icon_view )) | |||
5042 | ctk_icon_view_rows_reordered,g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_rows_reordered), (icon_view )) | |||
5043 | icon_view)g_signal_handlers_disconnect_matched ((icon_view->priv-> model), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_icon_view_rows_reordered), (icon_view )); | |||
5044 | ||||
5045 | g_object_unref (icon_view->priv->model); | |||
5046 | ||||
5047 | g_list_free_full (icon_view->priv->items, (GDestroyNotify) ctk_icon_view_item_free); | |||
5048 | icon_view->priv->items = NULL((void*)0); | |||
5049 | icon_view->priv->anchor_item = NULL((void*)0); | |||
5050 | icon_view->priv->cursor_item = NULL((void*)0); | |||
5051 | icon_view->priv->last_single_clicked = NULL((void*)0); | |||
5052 | icon_view->priv->last_prelight = NULL((void*)0); | |||
5053 | icon_view->priv->width = 0; | |||
5054 | icon_view->priv->height = 0; | |||
5055 | } | |||
5056 | ||||
5057 | icon_view->priv->model = model; | |||
5058 | ||||
5059 | if (icon_view->priv->model) | |||
5060 | { | |||
5061 | g_object_ref (icon_view->priv->model)((__typeof__ (icon_view->priv->model)) (g_object_ref) ( icon_view->priv->model)); | |||
5062 | g_signal_connect (icon_view->priv->model,g_signal_connect_data ((icon_view->priv->model), ("row-changed" ), (((GCallback) (ctk_icon_view_row_changed))), (icon_view), ( (void*)0), (GConnectFlags) 0) | |||
5063 | "row-changed",g_signal_connect_data ((icon_view->priv->model), ("row-changed" ), (((GCallback) (ctk_icon_view_row_changed))), (icon_view), ( (void*)0), (GConnectFlags) 0) | |||
5064 | G_CALLBACK (ctk_icon_view_row_changed),g_signal_connect_data ((icon_view->priv->model), ("row-changed" ), (((GCallback) (ctk_icon_view_row_changed))), (icon_view), ( (void*)0), (GConnectFlags) 0) | |||
5065 | icon_view)g_signal_connect_data ((icon_view->priv->model), ("row-changed" ), (((GCallback) (ctk_icon_view_row_changed))), (icon_view), ( (void*)0), (GConnectFlags) 0); | |||
5066 | g_signal_connect (icon_view->priv->model,g_signal_connect_data ((icon_view->priv->model), ("row-inserted" ), (((GCallback) (ctk_icon_view_row_inserted))), (icon_view), ((void*)0), (GConnectFlags) 0) | |||
5067 | "row-inserted",g_signal_connect_data ((icon_view->priv->model), ("row-inserted" ), (((GCallback) (ctk_icon_view_row_inserted))), (icon_view), ((void*)0), (GConnectFlags) 0) | |||
5068 | G_CALLBACK (ctk_icon_view_row_inserted),g_signal_connect_data ((icon_view->priv->model), ("row-inserted" ), (((GCallback) (ctk_icon_view_row_inserted))), (icon_view), ((void*)0), (GConnectFlags) 0) | |||
5069 | icon_view)g_signal_connect_data ((icon_view->priv->model), ("row-inserted" ), (((GCallback) (ctk_icon_view_row_inserted))), (icon_view), ((void*)0), (GConnectFlags) 0); | |||
5070 | g_signal_connect (icon_view->priv->model,g_signal_connect_data ((icon_view->priv->model), ("row-deleted" ), (((GCallback) (ctk_icon_view_row_deleted))), (icon_view), ( (void*)0), (GConnectFlags) 0) | |||
5071 | "row-deleted",g_signal_connect_data ((icon_view->priv->model), ("row-deleted" ), (((GCallback) (ctk_icon_view_row_deleted))), (icon_view), ( (void*)0), (GConnectFlags) 0) | |||
5072 | G_CALLBACK (ctk_icon_view_row_deleted),g_signal_connect_data ((icon_view->priv->model), ("row-deleted" ), (((GCallback) (ctk_icon_view_row_deleted))), (icon_view), ( (void*)0), (GConnectFlags) 0) | |||
5073 | icon_view)g_signal_connect_data ((icon_view->priv->model), ("row-deleted" ), (((GCallback) (ctk_icon_view_row_deleted))), (icon_view), ( (void*)0), (GConnectFlags) 0); | |||
5074 | g_signal_connect (icon_view->priv->model,g_signal_connect_data ((icon_view->priv->model), ("rows-reordered" ), (((GCallback) (ctk_icon_view_rows_reordered))), (icon_view ), ((void*)0), (GConnectFlags) 0) | |||
5075 | "rows-reordered",g_signal_connect_data ((icon_view->priv->model), ("rows-reordered" ), (((GCallback) (ctk_icon_view_rows_reordered))), (icon_view ), ((void*)0), (GConnectFlags) 0) | |||
5076 | G_CALLBACK (ctk_icon_view_rows_reordered),g_signal_connect_data ((icon_view->priv->model), ("rows-reordered" ), (((GCallback) (ctk_icon_view_rows_reordered))), (icon_view ), ((void*)0), (GConnectFlags) 0) | |||
5077 | icon_view)g_signal_connect_data ((icon_view->priv->model), ("rows-reordered" ), (((GCallback) (ctk_icon_view_rows_reordered))), (icon_view ), ((void*)0), (GConnectFlags) 0); | |||
5078 | ||||
5079 | ctk_icon_view_build_items (icon_view); | |||
5080 | } | |||
5081 | ||||
5082 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "model"); | |||
5083 | ||||
5084 | if (dirty) | |||
5085 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
5086 | ||||
5087 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
5088 | } | |||
5089 | ||||
5090 | /** | |||
5091 | * ctk_icon_view_get_model: | |||
5092 | * @icon_view: a #CtkIconView | |||
5093 | * | |||
5094 | * Returns the model the #CtkIconView is based on. Returns %NULL if the | |||
5095 | * model is unset. | |||
5096 | * | |||
5097 | * Returns: (nullable) (transfer none): A #CtkTreeModel, or %NULL if none is | |||
5098 | * currently being used. | |||
5099 | * | |||
5100 | * Since: 2.6 | |||
5101 | **/ | |||
5102 | CtkTreeModel * | |||
5103 | ctk_icon_view_get_model (CtkIconView *icon_view) | |||
5104 | { | |||
5105 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (((void*)0)); } } while (0); | |||
5106 | ||||
5107 | return icon_view->priv->model; | |||
5108 | } | |||
5109 | ||||
5110 | static void | |||
5111 | update_text_cell (CtkIconView *icon_view) | |||
5112 | { | |||
5113 | if (!icon_view->priv->cell_area) | |||
5114 | return; | |||
5115 | ||||
5116 | if (icon_view->priv->text_column == -1 && | |||
5117 | icon_view->priv->markup_column == -1) | |||
5118 | { | |||
5119 | if (icon_view->priv->text_cell != NULL((void*)0)) | |||
5120 | { | |||
5121 | ctk_cell_area_remove (icon_view->priv->cell_area, | |||
5122 | icon_view->priv->text_cell); | |||
5123 | icon_view->priv->text_cell = NULL((void*)0); | |||
5124 | } | |||
5125 | } | |||
5126 | else | |||
5127 | { | |||
5128 | if (icon_view->priv->text_cell == NULL((void*)0)) | |||
5129 | { | |||
5130 | icon_view->priv->text_cell = ctk_cell_renderer_text_new (); | |||
5131 | ||||
5132 | ctk_cell_layout_pack_end (CTK_CELL_LAYOUT (icon_view)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_cell_layout_get_type ())))))), icon_view->priv->text_cell, FALSE(0)); | |||
5133 | } | |||
5134 | ||||
5135 | if (icon_view->priv->markup_column != -1) | |||
5136 | ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (icon_view)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_cell_layout_get_type ())))))), | |||
5137 | icon_view->priv->text_cell, | |||
5138 | "markup", icon_view->priv->markup_column, | |||
5139 | NULL((void*)0)); | |||
5140 | else | |||
5141 | ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (icon_view)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_cell_layout_get_type ())))))), | |||
5142 | icon_view->priv->text_cell, | |||
5143 | "text", icon_view->priv->text_column, | |||
5144 | NULL((void*)0)); | |||
5145 | ||||
5146 | if (icon_view->priv->item_orientation == CTK_ORIENTATION_VERTICAL) | |||
5147 | g_object_set (icon_view->priv->text_cell, | |||
5148 | "alignment", PANGO_ALIGN_CENTER, | |||
5149 | "wrap-mode", PANGO_WRAP_WORD_CHAR, | |||
5150 | "xalign", 0.5, | |||
5151 | "yalign", 0.0, | |||
5152 | NULL((void*)0)); | |||
5153 | else | |||
5154 | g_object_set (icon_view->priv->text_cell, | |||
5155 | "alignment", PANGO_ALIGN_LEFT, | |||
5156 | "wrap-mode", PANGO_WRAP_WORD_CHAR, | |||
5157 | "xalign", 0.0, | |||
5158 | "yalign", 0.5, | |||
5159 | NULL((void*)0)); | |||
5160 | } | |||
5161 | } | |||
5162 | ||||
5163 | static void | |||
5164 | update_pixbuf_cell (CtkIconView *icon_view) | |||
5165 | { | |||
5166 | if (!icon_view->priv->cell_area) | |||
5167 | return; | |||
5168 | ||||
5169 | if (icon_view->priv->pixbuf_column == -1) | |||
5170 | { | |||
5171 | if (icon_view->priv->pixbuf_cell != NULL((void*)0)) | |||
5172 | { | |||
5173 | ctk_cell_area_remove (icon_view->priv->cell_area, | |||
5174 | icon_view->priv->pixbuf_cell); | |||
5175 | ||||
5176 | icon_view->priv->pixbuf_cell = NULL((void*)0); | |||
5177 | } | |||
5178 | } | |||
5179 | else | |||
5180 | { | |||
5181 | if (icon_view->priv->pixbuf_cell == NULL((void*)0)) | |||
5182 | { | |||
5183 | icon_view->priv->pixbuf_cell = ctk_cell_renderer_pixbuf_new (); | |||
5184 | ||||
5185 | ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (icon_view)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_cell_layout_get_type ())))))), icon_view->priv->pixbuf_cell, FALSE(0)); | |||
5186 | } | |||
5187 | ||||
5188 | ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (icon_view)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_cell_layout_get_type ())))))), | |||
5189 | icon_view->priv->pixbuf_cell, | |||
5190 | "pixbuf", icon_view->priv->pixbuf_column, | |||
5191 | NULL((void*)0)); | |||
5192 | ||||
5193 | if (icon_view->priv->item_orientation == CTK_ORIENTATION_VERTICAL) | |||
5194 | g_object_set (icon_view->priv->pixbuf_cell, | |||
5195 | "xalign", 0.5, | |||
5196 | "yalign", 1.0, | |||
5197 | NULL((void*)0)); | |||
5198 | else | |||
5199 | g_object_set (icon_view->priv->pixbuf_cell, | |||
5200 | "xalign", 0.0, | |||
5201 | "yalign", 0.0, | |||
5202 | NULL((void*)0)); | |||
5203 | } | |||
5204 | } | |||
5205 | ||||
5206 | /** | |||
5207 | * ctk_icon_view_set_text_column: | |||
5208 | * @icon_view: A #CtkIconView. | |||
5209 | * @column: A column in the currently used model, or -1 to display no text | |||
5210 | * | |||
5211 | * Sets the column with text for @icon_view to be @column. The text | |||
5212 | * column must be of type #G_TYPE_STRING. | |||
5213 | * | |||
5214 | * Since: 2.6 | |||
5215 | **/ | |||
5216 | void | |||
5217 | ctk_icon_view_set_text_column (CtkIconView *icon_view, | |||
5218 | gint column) | |||
5219 | { | |||
5220 | if (column == icon_view->priv->text_column) | |||
5221 | return; | |||
5222 | ||||
5223 | if (column == -1) | |||
5224 | icon_view->priv->text_column = -1; | |||
5225 | else | |||
5226 | { | |||
5227 | if (icon_view->priv->model != NULL((void*)0)) | |||
5228 | { | |||
5229 | GType column_type; | |||
5230 | ||||
5231 | column_type = ctk_tree_model_get_column_type (icon_view->priv->model, column); | |||
5232 | ||||
5233 | g_return_if_fail (column_type == G_TYPE_STRING)do { if ((column_type == ((GType) ((16) << (2))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "column_type == G_TYPE_STRING"); return; } } while (0); | |||
5234 | } | |||
5235 | ||||
5236 | icon_view->priv->text_column = column; | |||
5237 | } | |||
5238 | ||||
5239 | if (icon_view->priv->cell_area) | |||
5240 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5241 | ||||
5242 | update_text_cell (icon_view); | |||
5243 | ||||
5244 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5245 | ||||
5246 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "text-column"); | |||
5247 | } | |||
5248 | ||||
5249 | /** | |||
5250 | * ctk_icon_view_get_text_column: | |||
5251 | * @icon_view: A #CtkIconView. | |||
5252 | * | |||
5253 | * Returns the column with text for @icon_view. | |||
5254 | * | |||
5255 | * Returns: the text column, or -1 if it’s unset. | |||
5256 | * | |||
5257 | * Since: 2.6 | |||
5258 | */ | |||
5259 | gint | |||
5260 | ctk_icon_view_get_text_column (CtkIconView *icon_view) | |||
5261 | { | |||
5262 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5263 | ||||
5264 | return icon_view->priv->text_column; | |||
5265 | } | |||
5266 | ||||
5267 | /** | |||
5268 | * ctk_icon_view_set_markup_column: | |||
5269 | * @icon_view: A #CtkIconView. | |||
5270 | * @column: A column in the currently used model, or -1 to display no text | |||
5271 | * | |||
5272 | * Sets the column with markup information for @icon_view to be | |||
5273 | * @column. The markup column must be of type #G_TYPE_STRING. | |||
5274 | * If the markup column is set to something, it overrides | |||
5275 | * the text column set by ctk_icon_view_set_text_column(). | |||
5276 | * | |||
5277 | * Since: 2.6 | |||
5278 | **/ | |||
5279 | void | |||
5280 | ctk_icon_view_set_markup_column (CtkIconView *icon_view, | |||
5281 | gint column) | |||
5282 | { | |||
5283 | if (column == icon_view->priv->markup_column) | |||
5284 | return; | |||
5285 | ||||
5286 | if (column == -1) | |||
5287 | icon_view->priv->markup_column = -1; | |||
5288 | else | |||
5289 | { | |||
5290 | if (icon_view->priv->model != NULL((void*)0)) | |||
5291 | { | |||
5292 | GType column_type; | |||
5293 | ||||
5294 | column_type = ctk_tree_model_get_column_type (icon_view->priv->model, column); | |||
5295 | ||||
5296 | g_return_if_fail (column_type == G_TYPE_STRING)do { if ((column_type == ((GType) ((16) << (2))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "column_type == G_TYPE_STRING"); return; } } while (0); | |||
5297 | } | |||
5298 | ||||
5299 | icon_view->priv->markup_column = column; | |||
5300 | } | |||
5301 | ||||
5302 | if (icon_view->priv->cell_area) | |||
5303 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5304 | ||||
5305 | update_text_cell (icon_view); | |||
5306 | ||||
5307 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5308 | ||||
5309 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "markup-column"); | |||
5310 | } | |||
5311 | ||||
5312 | /** | |||
5313 | * ctk_icon_view_get_markup_column: | |||
5314 | * @icon_view: A #CtkIconView. | |||
5315 | * | |||
5316 | * Returns the column with markup text for @icon_view. | |||
5317 | * | |||
5318 | * Returns: the markup column, or -1 if it’s unset. | |||
5319 | * | |||
5320 | * Since: 2.6 | |||
5321 | */ | |||
5322 | gint | |||
5323 | ctk_icon_view_get_markup_column (CtkIconView *icon_view) | |||
5324 | { | |||
5325 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5326 | ||||
5327 | return icon_view->priv->markup_column; | |||
5328 | } | |||
5329 | ||||
5330 | /** | |||
5331 | * ctk_icon_view_set_pixbuf_column: | |||
5332 | * @icon_view: A #CtkIconView. | |||
5333 | * @column: A column in the currently used model, or -1 to disable | |||
5334 | * | |||
5335 | * Sets the column with pixbufs for @icon_view to be @column. The pixbuf | |||
5336 | * column must be of type #GDK_TYPE_PIXBUF | |||
5337 | * | |||
5338 | * Since: 2.6 | |||
5339 | **/ | |||
5340 | void | |||
5341 | ctk_icon_view_set_pixbuf_column (CtkIconView *icon_view, | |||
5342 | gint column) | |||
5343 | { | |||
5344 | if (column == icon_view->priv->pixbuf_column) | |||
5345 | return; | |||
5346 | ||||
5347 | if (column == -1) | |||
5348 | icon_view->priv->pixbuf_column = -1; | |||
5349 | else | |||
5350 | { | |||
5351 | if (icon_view->priv->model != NULL((void*)0)) | |||
5352 | { | |||
5353 | GType column_type; | |||
5354 | ||||
5355 | column_type = ctk_tree_model_get_column_type (icon_view->priv->model, column); | |||
5356 | ||||
5357 | g_return_if_fail (column_type == GDK_TYPE_PIXBUF)do { if ((column_type == (gdk_pixbuf_get_type ()))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "column_type == GDK_TYPE_PIXBUF"); return; } } while (0); | |||
5358 | } | |||
5359 | ||||
5360 | icon_view->priv->pixbuf_column = column; | |||
5361 | } | |||
5362 | ||||
5363 | if (icon_view->priv->cell_area) | |||
5364 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5365 | ||||
5366 | update_pixbuf_cell (icon_view); | |||
5367 | ||||
5368 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5369 | ||||
5370 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "pixbuf-column"); | |||
5371 | ||||
5372 | } | |||
5373 | ||||
5374 | /** | |||
5375 | * ctk_icon_view_get_pixbuf_column: | |||
5376 | * @icon_view: A #CtkIconView. | |||
5377 | * | |||
5378 | * Returns the column with pixbufs for @icon_view. | |||
5379 | * | |||
5380 | * Returns: the pixbuf column, or -1 if it’s unset. | |||
5381 | * | |||
5382 | * Since: 2.6 | |||
5383 | */ | |||
5384 | gint | |||
5385 | ctk_icon_view_get_pixbuf_column (CtkIconView *icon_view) | |||
5386 | { | |||
5387 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5388 | ||||
5389 | return icon_view->priv->pixbuf_column; | |||
5390 | } | |||
5391 | ||||
5392 | /** | |||
5393 | * ctk_icon_view_select_path: | |||
5394 | * @icon_view: A #CtkIconView. | |||
5395 | * @path: The #CtkTreePath to be selected. | |||
5396 | * | |||
5397 | * Selects the row at @path. | |||
5398 | * | |||
5399 | * Since: 2.6 | |||
5400 | **/ | |||
5401 | void | |||
5402 | ctk_icon_view_select_path (CtkIconView *icon_view, | |||
5403 | CtkTreePath *path) | |||
5404 | { | |||
5405 | CtkIconViewItem *item = NULL((void*)0); | |||
5406 | ||||
5407 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5408 | g_return_if_fail (icon_view->priv->model != NULL)do { if ((icon_view->priv->model != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "icon_view->priv->model != NULL"); return; } } while (0); | |||
5409 | g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return; } } while (0); | |||
5410 | ||||
5411 | if (ctk_tree_path_get_depth (path) > 0) | |||
5412 | item = g_list_nth_data (icon_view->priv->items, | |||
5413 | ctk_tree_path_get_indices(path)[0]); | |||
5414 | ||||
5415 | if (item) | |||
5416 | _ctk_icon_view_select_item (icon_view, item); | |||
5417 | } | |||
5418 | ||||
5419 | /** | |||
5420 | * ctk_icon_view_unselect_path: | |||
5421 | * @icon_view: A #CtkIconView. | |||
5422 | * @path: The #CtkTreePath to be unselected. | |||
5423 | * | |||
5424 | * Unselects the row at @path. | |||
5425 | * | |||
5426 | * Since: 2.6 | |||
5427 | **/ | |||
5428 | void | |||
5429 | ctk_icon_view_unselect_path (CtkIconView *icon_view, | |||
5430 | CtkTreePath *path) | |||
5431 | { | |||
5432 | CtkIconViewItem *item; | |||
5433 | ||||
5434 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5435 | g_return_if_fail (icon_view->priv->model != NULL)do { if ((icon_view->priv->model != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "icon_view->priv->model != NULL"); return; } } while (0); | |||
5436 | g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return; } } while (0); | |||
5437 | ||||
5438 | item = g_list_nth_data (icon_view->priv->items, | |||
5439 | ctk_tree_path_get_indices(path)[0]); | |||
5440 | ||||
5441 | if (!item) | |||
5442 | return; | |||
5443 | ||||
5444 | _ctk_icon_view_unselect_item (icon_view, item); | |||
5445 | } | |||
5446 | ||||
5447 | /** | |||
5448 | * ctk_icon_view_get_selected_items: | |||
5449 | * @icon_view: A #CtkIconView. | |||
5450 | * | |||
5451 | * Creates a list of paths of all selected items. Additionally, if you are | |||
5452 | * planning on modifying the model after calling this function, you may | |||
5453 | * want to convert the returned list into a list of #CtkTreeRowReferences. | |||
5454 | * To do this, you can use ctk_tree_row_reference_new(). | |||
5455 | * | |||
5456 | * To free the return value, use: | |||
5457 | * |[<!-- language="C" --> | |||
5458 | * g_list_free_full (list, (GDestroyNotify) ctk_tree_path_free); | |||
5459 | * ]| | |||
5460 | * | |||
5461 | * Returns: (element-type CtkTreePath) (transfer full): A #GList containing a #CtkTreePath for each selected row. | |||
5462 | * | |||
5463 | * Since: 2.6 | |||
5464 | **/ | |||
5465 | GList * | |||
5466 | ctk_icon_view_get_selected_items (CtkIconView *icon_view) | |||
5467 | { | |||
5468 | GList *list; | |||
5469 | GList *selected = NULL((void*)0); | |||
5470 | ||||
5471 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (((void*)0)); } } while (0); | |||
5472 | ||||
5473 | for (list = icon_view->priv->items; list != NULL((void*)0); list = list->next) | |||
5474 | { | |||
5475 | CtkIconViewItem *item = list->data; | |||
5476 | ||||
5477 | if (item->selected) | |||
5478 | { | |||
5479 | CtkTreePath *path = ctk_tree_path_new_from_indices (item->index, -1); | |||
5480 | ||||
5481 | selected = g_list_prepend (selected, path); | |||
5482 | } | |||
5483 | } | |||
5484 | ||||
5485 | return selected; | |||
5486 | } | |||
5487 | ||||
5488 | /** | |||
5489 | * ctk_icon_view_select_all: | |||
5490 | * @icon_view: A #CtkIconView. | |||
5491 | * | |||
5492 | * Selects all the icons. @icon_view must has its selection mode set | |||
5493 | * to #CTK_SELECTION_MULTIPLE. | |||
5494 | * | |||
5495 | * Since: 2.6 | |||
5496 | **/ | |||
5497 | void | |||
5498 | ctk_icon_view_select_all (CtkIconView *icon_view) | |||
5499 | { | |||
5500 | GList *items; | |||
5501 | gboolean dirty = FALSE(0); | |||
5502 | ||||
5503 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5504 | ||||
5505 | if (icon_view->priv->selection_mode != CTK_SELECTION_MULTIPLE) | |||
5506 | return; | |||
5507 | ||||
5508 | for (items = icon_view->priv->items; items; items = items->next) | |||
5509 | { | |||
5510 | CtkIconViewItem *item = items->data; | |||
5511 | ||||
5512 | if (!item->selected) | |||
5513 | { | |||
5514 | dirty = TRUE(!(0)); | |||
5515 | item->selected = TRUE(!(0)); | |||
5516 | ctk_icon_view_queue_draw_item (icon_view, item); | |||
5517 | } | |||
5518 | } | |||
5519 | ||||
5520 | if (dirty) | |||
5521 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
5522 | } | |||
5523 | ||||
5524 | /** | |||
5525 | * ctk_icon_view_unselect_all: | |||
5526 | * @icon_view: A #CtkIconView. | |||
5527 | * | |||
5528 | * Unselects all the icons. | |||
5529 | * | |||
5530 | * Since: 2.6 | |||
5531 | **/ | |||
5532 | void | |||
5533 | ctk_icon_view_unselect_all (CtkIconView *icon_view) | |||
5534 | { | |||
5535 | gboolean dirty = FALSE(0); | |||
5536 | ||||
5537 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5538 | ||||
5539 | if (icon_view->priv->selection_mode == CTK_SELECTION_BROWSE) | |||
5540 | return; | |||
5541 | ||||
5542 | dirty = ctk_icon_view_unselect_all_internal (icon_view); | |||
5543 | ||||
5544 | if (dirty) | |||
5545 | g_signal_emit (icon_view, icon_view_signals[SELECTION_CHANGED], 0); | |||
5546 | } | |||
5547 | ||||
5548 | /** | |||
5549 | * ctk_icon_view_path_is_selected: | |||
5550 | * @icon_view: A #CtkIconView. | |||
5551 | * @path: A #CtkTreePath to check selection on. | |||
5552 | * | |||
5553 | * Returns %TRUE if the icon pointed to by @path is currently | |||
5554 | * selected. If @path does not point to a valid location, %FALSE is returned. | |||
5555 | * | |||
5556 | * Returns: %TRUE if @path is selected. | |||
5557 | * | |||
5558 | * Since: 2.6 | |||
5559 | **/ | |||
5560 | gboolean | |||
5561 | ctk_icon_view_path_is_selected (CtkIconView *icon_view, | |||
5562 | CtkTreePath *path) | |||
5563 | { | |||
5564 | CtkIconViewItem *item; | |||
5565 | ||||
5566 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
5567 | g_return_val_if_fail (icon_view->priv->model != NULL, FALSE)do { if ((icon_view->priv->model != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "icon_view->priv->model != NULL"); return ((0)); } } while (0); | |||
5568 | g_return_val_if_fail (path != NULL, FALSE)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return ( (0)); } } while (0); | |||
5569 | ||||
5570 | item = g_list_nth_data (icon_view->priv->items, | |||
5571 | ctk_tree_path_get_indices(path)[0]); | |||
5572 | ||||
5573 | if (!item) | |||
5574 | return FALSE(0); | |||
5575 | ||||
5576 | return item->selected; | |||
5577 | } | |||
5578 | ||||
5579 | /** | |||
5580 | * ctk_icon_view_get_item_row: | |||
5581 | * @icon_view: a #CtkIconView | |||
5582 | * @path: the #CtkTreePath of the item | |||
5583 | * | |||
5584 | * Gets the row in which the item @path is currently | |||
5585 | * displayed. Row numbers start at 0. | |||
5586 | * | |||
5587 | * Returns: The row in which the item is displayed | |||
5588 | * | |||
5589 | * Since: 2.22 | |||
5590 | */ | |||
5591 | gint | |||
5592 | ctk_icon_view_get_item_row (CtkIconView *icon_view, | |||
5593 | CtkTreePath *path) | |||
5594 | { | |||
5595 | CtkIconViewItem *item; | |||
5596 | ||||
5597 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5598 | g_return_val_if_fail (icon_view->priv->model != NULL, -1)do { if ((icon_view->priv->model != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "icon_view->priv->model != NULL"); return (-1); } } while (0); | |||
5599 | g_return_val_if_fail (path != NULL, -1)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return ( -1); } } while (0); | |||
5600 | ||||
5601 | item = g_list_nth_data (icon_view->priv->items, | |||
5602 | ctk_tree_path_get_indices(path)[0]); | |||
5603 | ||||
5604 | if (!item) | |||
5605 | return -1; | |||
5606 | ||||
5607 | return item->row; | |||
5608 | } | |||
5609 | ||||
5610 | /** | |||
5611 | * ctk_icon_view_get_item_column: | |||
5612 | * @icon_view: a #CtkIconView | |||
5613 | * @path: the #CtkTreePath of the item | |||
5614 | * | |||
5615 | * Gets the column in which the item @path is currently | |||
5616 | * displayed. Column numbers start at 0. | |||
5617 | * | |||
5618 | * Returns: The column in which the item is displayed | |||
5619 | * | |||
5620 | * Since: 2.22 | |||
5621 | */ | |||
5622 | gint | |||
5623 | ctk_icon_view_get_item_column (CtkIconView *icon_view, | |||
5624 | CtkTreePath *path) | |||
5625 | { | |||
5626 | CtkIconViewItem *item; | |||
5627 | ||||
5628 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5629 | g_return_val_if_fail (icon_view->priv->model != NULL, -1)do { if ((icon_view->priv->model != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "icon_view->priv->model != NULL"); return (-1); } } while (0); | |||
5630 | g_return_val_if_fail (path != NULL, -1)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return ( -1); } } while (0); | |||
5631 | ||||
5632 | item = g_list_nth_data (icon_view->priv->items, | |||
5633 | ctk_tree_path_get_indices(path)[0]); | |||
5634 | ||||
5635 | if (!item) | |||
5636 | return -1; | |||
5637 | ||||
5638 | return item->col; | |||
5639 | } | |||
5640 | ||||
5641 | /** | |||
5642 | * ctk_icon_view_item_activated: | |||
5643 | * @icon_view: A #CtkIconView | |||
5644 | * @path: The #CtkTreePath to be activated | |||
5645 | * | |||
5646 | * Activates the item determined by @path. | |||
5647 | * | |||
5648 | * Since: 2.6 | |||
5649 | **/ | |||
5650 | void | |||
5651 | ctk_icon_view_item_activated (CtkIconView *icon_view, | |||
5652 | CtkTreePath *path) | |||
5653 | { | |||
5654 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5655 | g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return; } } while (0); | |||
5656 | ||||
5657 | g_signal_emit (icon_view, icon_view_signals[ITEM_ACTIVATED], 0, path); | |||
5658 | } | |||
5659 | ||||
5660 | /** | |||
5661 | * ctk_icon_view_set_item_orientation: | |||
5662 | * @icon_view: a #CtkIconView | |||
5663 | * @orientation: the relative position of texts and icons | |||
5664 | * | |||
5665 | * Sets the ::item-orientation property which determines whether the labels | |||
5666 | * are drawn beside the icons instead of below. | |||
5667 | * | |||
5668 | * Since: 2.6 | |||
5669 | **/ | |||
5670 | void | |||
5671 | ctk_icon_view_set_item_orientation (CtkIconView *icon_view, | |||
5672 | CtkOrientation orientation) | |||
5673 | { | |||
5674 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5675 | ||||
5676 | if (icon_view->priv->item_orientation != orientation) | |||
5677 | { | |||
5678 | icon_view->priv->item_orientation = orientation; | |||
5679 | ||||
5680 | if (icon_view->priv->cell_area) | |||
5681 | { | |||
5682 | if (CTK_IS_ORIENTABLE (icon_view->priv->cell_area)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (icon_view->priv->cell_area)); GType __t = ((ctk_orientable_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) | |||
5683 | ctk_orientable_set_orientation (CTK_ORIENTABLE (icon_view->priv->cell_area)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view->priv->cell_area)), ((ctk_orientable_get_type ())))))), | |||
5684 | icon_view->priv->item_orientation); | |||
5685 | ||||
5686 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5687 | } | |||
5688 | ||||
5689 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5690 | ||||
5691 | update_text_cell (icon_view); | |||
5692 | update_pixbuf_cell (icon_view); | |||
5693 | ||||
5694 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "item-orientation"); | |||
5695 | } | |||
5696 | } | |||
5697 | ||||
5698 | /** | |||
5699 | * ctk_icon_view_get_item_orientation: | |||
5700 | * @icon_view: a #CtkIconView | |||
5701 | * | |||
5702 | * Returns the value of the ::item-orientation property which determines | |||
5703 | * whether the labels are drawn beside the icons instead of below. | |||
5704 | * | |||
5705 | * Returns: the relative position of texts and icons | |||
5706 | * | |||
5707 | * Since: 2.6 | |||
5708 | **/ | |||
5709 | CtkOrientation | |||
5710 | ctk_icon_view_get_item_orientation (CtkIconView *icon_view) | |||
5711 | { | |||
5712 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view),do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (CTK_ORIENTATION_VERTICAL ); } } while (0) | |||
5713 | CTK_ORIENTATION_VERTICAL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (CTK_ORIENTATION_VERTICAL ); } } while (0); | |||
5714 | ||||
5715 | return icon_view->priv->item_orientation; | |||
5716 | } | |||
5717 | ||||
5718 | /** | |||
5719 | * ctk_icon_view_set_columns: | |||
5720 | * @icon_view: a #CtkIconView | |||
5721 | * @columns: the number of columns | |||
5722 | * | |||
5723 | * Sets the ::columns property which determines in how | |||
5724 | * many columns the icons are arranged. If @columns is | |||
5725 | * -1, the number of columns will be chosen automatically | |||
5726 | * to fill the available area. | |||
5727 | * | |||
5728 | * Since: 2.6 | |||
5729 | */ | |||
5730 | void | |||
5731 | ctk_icon_view_set_columns (CtkIconView *icon_view, | |||
5732 | gint columns) | |||
5733 | { | |||
5734 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5735 | ||||
5736 | if (icon_view->priv->columns != columns) | |||
5737 | { | |||
5738 | icon_view->priv->columns = columns; | |||
5739 | ||||
5740 | if (icon_view->priv->cell_area) | |||
5741 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5742 | ||||
5743 | ctk_widget_queue_resize (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
5744 | ||||
5745 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "columns"); | |||
5746 | } | |||
5747 | } | |||
5748 | ||||
5749 | /** | |||
5750 | * ctk_icon_view_get_columns: | |||
5751 | * @icon_view: a #CtkIconView | |||
5752 | * | |||
5753 | * Returns the value of the ::columns property. | |||
5754 | * | |||
5755 | * Returns: the number of columns, or -1 | |||
5756 | * | |||
5757 | * Since: 2.6 | |||
5758 | */ | |||
5759 | gint | |||
5760 | ctk_icon_view_get_columns (CtkIconView *icon_view) | |||
5761 | { | |||
5762 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5763 | ||||
5764 | return icon_view->priv->columns; | |||
5765 | } | |||
5766 | ||||
5767 | /** | |||
5768 | * ctk_icon_view_set_item_width: | |||
5769 | * @icon_view: a #CtkIconView | |||
5770 | * @item_width: the width for each item | |||
5771 | * | |||
5772 | * Sets the ::item-width property which specifies the width | |||
5773 | * to use for each item. If it is set to -1, the icon view will | |||
5774 | * automatically determine a suitable item size. | |||
5775 | * | |||
5776 | * Since: 2.6 | |||
5777 | */ | |||
5778 | void | |||
5779 | ctk_icon_view_set_item_width (CtkIconView *icon_view, | |||
5780 | gint item_width) | |||
5781 | { | |||
5782 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5783 | ||||
5784 | if (icon_view->priv->item_width != item_width) | |||
5785 | { | |||
5786 | icon_view->priv->item_width = item_width; | |||
5787 | ||||
5788 | if (icon_view->priv->cell_area) | |||
5789 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5790 | ||||
5791 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5792 | ||||
5793 | update_text_cell (icon_view); | |||
5794 | ||||
5795 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "item-width"); | |||
5796 | } | |||
5797 | } | |||
5798 | ||||
5799 | /** | |||
5800 | * ctk_icon_view_get_item_width: | |||
5801 | * @icon_view: a #CtkIconView | |||
5802 | * | |||
5803 | * Returns the value of the ::item-width property. | |||
5804 | * | |||
5805 | * Returns: the width of a single item, or -1 | |||
5806 | * | |||
5807 | * Since: 2.6 | |||
5808 | */ | |||
5809 | gint | |||
5810 | ctk_icon_view_get_item_width (CtkIconView *icon_view) | |||
5811 | { | |||
5812 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5813 | ||||
5814 | return icon_view->priv->item_width; | |||
5815 | } | |||
5816 | ||||
5817 | ||||
5818 | /** | |||
5819 | * ctk_icon_view_set_spacing: | |||
5820 | * @icon_view: a #CtkIconView | |||
5821 | * @spacing: the spacing | |||
5822 | * | |||
5823 | * Sets the ::spacing property which specifies the space | |||
5824 | * which is inserted between the cells (i.e. the icon and | |||
5825 | * the text) of an item. | |||
5826 | * | |||
5827 | * Since: 2.6 | |||
5828 | */ | |||
5829 | void | |||
5830 | ctk_icon_view_set_spacing (CtkIconView *icon_view, | |||
5831 | gint spacing) | |||
5832 | { | |||
5833 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5834 | ||||
5835 | if (icon_view->priv->spacing != spacing) | |||
5836 | { | |||
5837 | icon_view->priv->spacing = spacing; | |||
5838 | ||||
5839 | if (icon_view->priv->cell_area) | |||
5840 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5841 | ||||
5842 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5843 | ||||
5844 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "spacing"); | |||
5845 | } | |||
5846 | } | |||
5847 | ||||
5848 | /** | |||
5849 | * ctk_icon_view_get_spacing: | |||
5850 | * @icon_view: a #CtkIconView | |||
5851 | * | |||
5852 | * Returns the value of the ::spacing property. | |||
5853 | * | |||
5854 | * Returns: the space between cells | |||
5855 | * | |||
5856 | * Since: 2.6 | |||
5857 | */ | |||
5858 | gint | |||
5859 | ctk_icon_view_get_spacing (CtkIconView *icon_view) | |||
5860 | { | |||
5861 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5862 | ||||
5863 | return icon_view->priv->spacing; | |||
5864 | } | |||
5865 | ||||
5866 | /** | |||
5867 | * ctk_icon_view_set_row_spacing: | |||
5868 | * @icon_view: a #CtkIconView | |||
5869 | * @row_spacing: the row spacing | |||
5870 | * | |||
5871 | * Sets the ::row-spacing property which specifies the space | |||
5872 | * which is inserted between the rows of the icon view. | |||
5873 | * | |||
5874 | * Since: 2.6 | |||
5875 | */ | |||
5876 | void | |||
5877 | ctk_icon_view_set_row_spacing (CtkIconView *icon_view, | |||
5878 | gint row_spacing) | |||
5879 | { | |||
5880 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5881 | ||||
5882 | if (icon_view->priv->row_spacing != row_spacing) | |||
5883 | { | |||
5884 | icon_view->priv->row_spacing = row_spacing; | |||
5885 | ||||
5886 | if (icon_view->priv->cell_area) | |||
5887 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5888 | ||||
5889 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5890 | ||||
5891 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "row-spacing"); | |||
5892 | } | |||
5893 | } | |||
5894 | ||||
5895 | /** | |||
5896 | * ctk_icon_view_get_row_spacing: | |||
5897 | * @icon_view: a #CtkIconView | |||
5898 | * | |||
5899 | * Returns the value of the ::row-spacing property. | |||
5900 | * | |||
5901 | * Returns: the space between rows | |||
5902 | * | |||
5903 | * Since: 2.6 | |||
5904 | */ | |||
5905 | gint | |||
5906 | ctk_icon_view_get_row_spacing (CtkIconView *icon_view) | |||
5907 | { | |||
5908 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5909 | ||||
5910 | return icon_view->priv->row_spacing; | |||
5911 | } | |||
5912 | ||||
5913 | /** | |||
5914 | * ctk_icon_view_set_column_spacing: | |||
5915 | * @icon_view: a #CtkIconView | |||
5916 | * @column_spacing: the column spacing | |||
5917 | * | |||
5918 | * Sets the ::column-spacing property which specifies the space | |||
5919 | * which is inserted between the columns of the icon view. | |||
5920 | * | |||
5921 | * Since: 2.6 | |||
5922 | */ | |||
5923 | void | |||
5924 | ctk_icon_view_set_column_spacing (CtkIconView *icon_view, | |||
5925 | gint column_spacing) | |||
5926 | { | |||
5927 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5928 | ||||
5929 | if (icon_view->priv->column_spacing != column_spacing) | |||
5930 | { | |||
5931 | icon_view->priv->column_spacing = column_spacing; | |||
5932 | ||||
5933 | if (icon_view->priv->cell_area) | |||
5934 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5935 | ||||
5936 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5937 | ||||
5938 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "column-spacing"); | |||
5939 | } | |||
5940 | } | |||
5941 | ||||
5942 | /** | |||
5943 | * ctk_icon_view_get_column_spacing: | |||
5944 | * @icon_view: a #CtkIconView | |||
5945 | * | |||
5946 | * Returns the value of the ::column-spacing property. | |||
5947 | * | |||
5948 | * Returns: the space between columns | |||
5949 | * | |||
5950 | * Since: 2.6 | |||
5951 | */ | |||
5952 | gint | |||
5953 | ctk_icon_view_get_column_spacing (CtkIconView *icon_view) | |||
5954 | { | |||
5955 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
5956 | ||||
5957 | return icon_view->priv->column_spacing; | |||
5958 | } | |||
5959 | ||||
5960 | /** | |||
5961 | * ctk_icon_view_set_margin: | |||
5962 | * @icon_view: a #CtkIconView | |||
5963 | * @margin: the margin | |||
5964 | * | |||
5965 | * Sets the ::margin property which specifies the space | |||
5966 | * which is inserted at the top, bottom, left and right | |||
5967 | * of the icon view. | |||
5968 | * | |||
5969 | * Since: 2.6 | |||
5970 | */ | |||
5971 | void | |||
5972 | ctk_icon_view_set_margin (CtkIconView *icon_view, | |||
5973 | gint margin) | |||
5974 | { | |||
5975 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
5976 | ||||
5977 | if (icon_view->priv->margin != margin) | |||
5978 | { | |||
5979 | icon_view->priv->margin = margin; | |||
5980 | ||||
5981 | if (icon_view->priv->cell_area) | |||
5982 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
5983 | ||||
5984 | ctk_icon_view_invalidate_sizes (icon_view); | |||
5985 | ||||
5986 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "margin"); | |||
5987 | } | |||
5988 | } | |||
5989 | ||||
5990 | /** | |||
5991 | * ctk_icon_view_get_margin: | |||
5992 | * @icon_view: a #CtkIconView | |||
5993 | * | |||
5994 | * Returns the value of the ::margin property. | |||
5995 | * | |||
5996 | * Returns: the space at the borders | |||
5997 | * | |||
5998 | * Since: 2.6 | |||
5999 | */ | |||
6000 | gint | |||
6001 | ctk_icon_view_get_margin (CtkIconView *icon_view) | |||
6002 | { | |||
6003 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
6004 | ||||
6005 | return icon_view->priv->margin; | |||
6006 | } | |||
6007 | ||||
6008 | /** | |||
6009 | * ctk_icon_view_set_item_padding: | |||
6010 | * @icon_view: a #CtkIconView | |||
6011 | * @item_padding: the item padding | |||
6012 | * | |||
6013 | * Sets the #CtkIconView:item-padding property which specifies the padding | |||
6014 | * around each of the icon view’s items. | |||
6015 | * | |||
6016 | * Since: 2.18 | |||
6017 | */ | |||
6018 | void | |||
6019 | ctk_icon_view_set_item_padding (CtkIconView *icon_view, | |||
6020 | gint item_padding) | |||
6021 | { | |||
6022 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
6023 | ||||
6024 | if (icon_view->priv->item_padding != item_padding) | |||
6025 | { | |||
6026 | icon_view->priv->item_padding = item_padding; | |||
6027 | ||||
6028 | if (icon_view->priv->cell_area) | |||
6029 | ctk_cell_area_stop_editing (icon_view->priv->cell_area, TRUE(!(0))); | |||
6030 | ||||
6031 | ctk_icon_view_invalidate_sizes (icon_view); | |||
6032 | ||||
6033 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "item-padding"); | |||
6034 | } | |||
6035 | } | |||
6036 | ||||
6037 | /** | |||
6038 | * ctk_icon_view_get_item_padding: | |||
6039 | * @icon_view: a #CtkIconView | |||
6040 | * | |||
6041 | * Returns the value of the ::item-padding property. | |||
6042 | * | |||
6043 | * Returns: the padding around items | |||
6044 | * | |||
6045 | * Since: 2.18 | |||
6046 | */ | |||
6047 | gint | |||
6048 | ctk_icon_view_get_item_padding (CtkIconView *icon_view) | |||
6049 | { | |||
6050 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (-1); } } while ( 0); | |||
6051 | ||||
6052 | return icon_view->priv->item_padding; | |||
6053 | } | |||
6054 | ||||
6055 | /* Get/set whether drag_motion requested the drag data and | |||
6056 | * drag_data_received should thus not actually insert the data, | |||
6057 | * since the data doesn’t result from a drop. | |||
6058 | */ | |||
6059 | static void | |||
6060 | set_status_pending (CdkDragContext *context, | |||
6061 | CdkDragAction suggested_action) | |||
6062 | { | |||
6063 | g_object_set_data (G_OBJECT (context)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((context)), (((GType) ((20) << (2)))))))), | |||
6064 | I_("ctk-icon-view-status-pending")g_intern_static_string ("ctk-icon-view-status-pending"), | |||
6065 | GINT_TO_POINTER (suggested_action)((gpointer) (glong) (suggested_action))); | |||
6066 | } | |||
6067 | ||||
6068 | static CdkDragAction | |||
6069 | get_status_pending (CdkDragContext *context) | |||
6070 | { | |||
6071 | return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (context),((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((context)), (((GType) ((20) << (2)) )))))), "ctk-icon-view-status-pending"))) | |||
6072 | "ctk-icon-view-status-pending"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((context)), (((GType) ((20) << (2)) )))))), "ctk-icon-view-status-pending"))); | |||
6073 | } | |||
6074 | ||||
6075 | static void | |||
6076 | unset_reorderable (CtkIconView *icon_view) | |||
6077 | { | |||
6078 | if (icon_view->priv->reorderable) | |||
6079 | { | |||
6080 | icon_view->priv->reorderable = FALSE(0); | |||
6081 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "reorderable"); | |||
6082 | } | |||
6083 | } | |||
6084 | ||||
6085 | static void | |||
6086 | set_source_row (CdkDragContext *context, | |||
6087 | CtkTreeModel *model, | |||
6088 | CtkTreePath *source_row) | |||
6089 | { | |||
6090 | if (source_row) | |||
6091 | g_object_set_data_full (G_OBJECT (context)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((context)), (((GType) ((20) << (2)))))))), | |||
6092 | I_("ctk-icon-view-source-row")g_intern_static_string ("ctk-icon-view-source-row"), | |||
6093 | ctk_tree_row_reference_new (model, source_row), | |||
6094 | (GDestroyNotify) ctk_tree_row_reference_free); | |||
6095 | else | |||
6096 | g_object_set_data_full (G_OBJECT (context)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((context)), (((GType) ((20) << (2)))))))), | |||
6097 | I_("ctk-icon-view-source-row")g_intern_static_string ("ctk-icon-view-source-row"), | |||
6098 | NULL((void*)0), NULL((void*)0)); | |||
6099 | } | |||
6100 | ||||
6101 | static CtkTreePath* | |||
6102 | get_source_row (CdkDragContext *context) | |||
6103 | { | |||
6104 | CtkTreeRowReference *ref; | |||
6105 | ||||
6106 | ref = g_object_get_data (G_OBJECT (context)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((context)), (((GType) ((20) << (2)))))))), "ctk-icon-view-source-row"); | |||
6107 | ||||
6108 | if (ref) | |||
6109 | return ctk_tree_row_reference_get_path (ref); | |||
6110 | else | |||
6111 | return NULL((void*)0); | |||
6112 | } | |||
6113 | ||||
6114 | typedef struct | |||
6115 | { | |||
6116 | CtkTreeRowReference *dest_row; | |||
6117 | gboolean empty_view_drop; | |||
6118 | gboolean drop_append_mode; | |||
6119 | } DestRow; | |||
6120 | ||||
6121 | static void | |||
6122 | dest_row_free (gpointer data) | |||
6123 | { | |||
6124 | DestRow *dr = (DestRow *)data; | |||
6125 | ||||
6126 | ctk_tree_row_reference_free (dr->dest_row); | |||
6127 | g_free (dr); | |||
6128 | } | |||
6129 | ||||
6130 | static void | |||
6131 | set_dest_row (CdkDragContext *context, | |||
6132 | CtkTreeModel *model, | |||
6133 | CtkTreePath *dest_row, | |||
6134 | gboolean empty_view_drop, | |||
6135 | gboolean drop_append_mode) | |||
6136 | { | |||
6137 | DestRow *dr; | |||
6138 | ||||
6139 | if (!dest_row) | |||
6140 | { | |||
6141 | g_object_set_data_full (G_OBJECT (context)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((context)), (((GType) ((20) << (2)))))))), | |||
6142 | I_("ctk-icon-view-dest-row")g_intern_static_string ("ctk-icon-view-dest-row"), | |||
6143 | NULL((void*)0), NULL((void*)0)); | |||
6144 | return; | |||
6145 | } | |||
6146 | ||||
6147 | dr = g_new0 (DestRow, 1)((DestRow *) g_malloc0_n ((1), sizeof (DestRow))); | |||
6148 | ||||
6149 | dr->dest_row = ctk_tree_row_reference_new (model, dest_row); | |||
6150 | dr->empty_view_drop = empty_view_drop; | |||
6151 | dr->drop_append_mode = drop_append_mode; | |||
6152 | g_object_set_data_full (G_OBJECT (context)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((context)), (((GType) ((20) << (2)))))))), | |||
6153 | I_("ctk-icon-view-dest-row")g_intern_static_string ("ctk-icon-view-dest-row"), | |||
6154 | dr, (GDestroyNotify) dest_row_free); | |||
6155 | } | |||
6156 | ||||
6157 | static CtkTreePath* | |||
6158 | get_dest_row (CdkDragContext *context) | |||
6159 | { | |||
6160 | DestRow *dr; | |||
6161 | ||||
6162 | dr = g_object_get_data (G_OBJECT (context)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((context)), (((GType) ((20) << (2)))))))), "ctk-icon-view-dest-row"); | |||
6163 | ||||
6164 | if (dr) | |||
6165 | { | |||
6166 | CtkTreePath *path = NULL((void*)0); | |||
6167 | ||||
6168 | if (dr->dest_row) | |||
6169 | path = ctk_tree_row_reference_get_path (dr->dest_row); | |||
6170 | else if (dr->empty_view_drop) | |||
6171 | path = ctk_tree_path_new_from_indices (0, -1); | |||
6172 | else | |||
6173 | path = NULL((void*)0); | |||
6174 | ||||
6175 | if (path && dr->drop_append_mode) | |||
6176 | ctk_tree_path_next (path); | |||
6177 | ||||
6178 | return path; | |||
6179 | } | |||
6180 | else | |||
6181 | return NULL((void*)0); | |||
6182 | } | |||
6183 | ||||
6184 | static gboolean | |||
6185 | check_model_dnd (CtkTreeModel *model, | |||
6186 | GType required_iface, | |||
6187 | const gchar *signal) | |||
6188 | { | |||
6189 | if (model == NULL((void*)0) || !G_TYPE_CHECK_INSTANCE_TYPE ((model), required_iface)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = (required_iface); gboolean __r; if (!__inst ) __r = (0); else if (__inst->g_class && __inst-> g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) | |||
6190 | { | |||
6191 | g_warning ("You must override the default '%s' handler " | |||
6192 | "on CtkIconView when using models that don't support " | |||
6193 | "the %s interface and enabling drag-and-drop. The simplest way to do this " | |||
6194 | "is to connect to '%s' and call " | |||
6195 | "g_signal_stop_emission_by_name() in your signal handler to prevent " | |||
6196 | "the default handler from running. Look at the source code " | |||
6197 | "for the default handler in ctkiconview.c to get an idea what " | |||
6198 | "your handler should do. (ctkiconview.c is in the CTK+ source " | |||
6199 | "code.) If you're using CTK+ from a language other than C, " | |||
6200 | "there may be a more natural way to override default handlers, e.g. via derivation.", | |||
6201 | signal, g_type_name (required_iface), signal); | |||
6202 | return FALSE(0); | |||
6203 | } | |||
6204 | else | |||
6205 | return TRUE(!(0)); | |||
6206 | } | |||
6207 | ||||
6208 | static void | |||
6209 | remove_scroll_timeout (CtkIconView *icon_view) | |||
6210 | { | |||
6211 | if (icon_view->priv->scroll_timeout_id != 0) | |||
6212 | { | |||
6213 | g_source_remove (icon_view->priv->scroll_timeout_id); | |||
6214 | ||||
6215 | icon_view->priv->scroll_timeout_id = 0; | |||
6216 | } | |||
6217 | } | |||
6218 | ||||
6219 | static void | |||
6220 | ctk_icon_view_autoscroll (CtkIconView *icon_view) | |||
6221 | { | |||
6222 | CdkWindow *window; | |||
6223 | gint px, py, width, height; | |||
6224 | gint hoffset, voffset; | |||
6225 | ||||
6226 | window = ctk_widget_get_window (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
6227 | ||||
6228 | px = icon_view->priv->event_last_x; | |||
6229 | py = icon_view->priv->event_last_y; | |||
6230 | cdk_window_get_geometry (window, NULL((void*)0), NULL((void*)0), &width, &height); | |||
6231 | ||||
6232 | /* see if we are near the edge. */ | |||
6233 | voffset = py - 2 * SCROLL_EDGE_SIZE15; | |||
6234 | if (voffset > 0) | |||
6235 | voffset = MAX (py - (height - 2 * SCROLL_EDGE_SIZE), 0)(((py - (height - 2 * 15)) > (0)) ? (py - (height - 2 * 15 )) : (0)); | |||
6236 | ||||
6237 | hoffset = px - 2 * SCROLL_EDGE_SIZE15; | |||
6238 | if (hoffset > 0) | |||
6239 | hoffset = MAX (px - (width - 2 * SCROLL_EDGE_SIZE), 0)(((px - (width - 2 * 15)) > (0)) ? (px - (width - 2 * 15)) : (0)); | |||
6240 | ||||
6241 | if (voffset != 0) | |||
6242 | ctk_adjustment_set_value (icon_view->priv->vadjustment, | |||
6243 | ctk_adjustment_get_value (icon_view->priv->vadjustment) + voffset); | |||
6244 | ||||
6245 | if (hoffset != 0) | |||
6246 | ctk_adjustment_set_value (icon_view->priv->hadjustment, | |||
6247 | ctk_adjustment_get_value (icon_view->priv->hadjustment) + hoffset); | |||
6248 | } | |||
6249 | ||||
6250 | static gboolean | |||
6251 | drag_scroll_timeout (gpointer data) | |||
6252 | { | |||
6253 | ctk_icon_view_autoscroll (data); | |||
6254 | ||||
6255 | return TRUE(!(0)); | |||
6256 | } | |||
6257 | ||||
6258 | static gboolean | |||
6259 | set_destination (CtkIconView *icon_view, | |||
6260 | CdkDragContext *context, | |||
6261 | gint x, | |||
6262 | gint y, | |||
6263 | CdkDragAction *suggested_action, | |||
6264 | CdkAtom *target) | |||
6265 | { | |||
6266 | CtkWidget *widget; | |||
6267 | CtkTreePath *path = NULL((void*)0); | |||
6268 | CtkIconViewDropPosition pos; | |||
6269 | CtkIconViewDropPosition old_pos; | |||
6270 | CtkTreePath *old_dest_path = NULL((void*)0); | |||
6271 | gboolean can_drop = FALSE(0); | |||
6272 | ||||
6273 | widget = CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))); | |||
6274 | ||||
6275 | *suggested_action = 0; | |||
6276 | *target = CDK_NONE((CdkAtom)((gpointer) (gulong) (0))); | |||
6277 | ||||
6278 | if (!icon_view->priv->dest_set) | |||
6279 | { | |||
6280 | /* someone unset us as a drag dest, note that if | |||
6281 | * we return FALSE drag_leave isn't called | |||
6282 | */ | |||
6283 | ||||
6284 | ctk_icon_view_set_drag_dest_item (icon_view, | |||
6285 | NULL((void*)0), | |||
6286 | CTK_ICON_VIEW_DROP_LEFT); | |||
6287 | ||||
6288 | remove_scroll_timeout (CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ()))))))); | |||
6289 | ||||
6290 | return FALSE(0); /* no longer a drop site */ | |||
6291 | } | |||
6292 | ||||
6293 | *target = ctk_drag_dest_find_target (widget, context, | |||
6294 | ctk_drag_dest_get_target_list (widget)); | |||
6295 | if (*target == CDK_NONE((CdkAtom)((gpointer) (gulong) (0)))) | |||
6296 | return FALSE(0); | |||
6297 | ||||
6298 | if (!ctk_icon_view_get_dest_item_at_pos (icon_view, x, y, &path, &pos)) | |||
6299 | { | |||
6300 | gint n_children; | |||
6301 | CtkTreeModel *model; | |||
6302 | ||||
6303 | /* the row got dropped on empty space, let's setup a special case | |||
6304 | */ | |||
6305 | ||||
6306 | if (path) | |||
6307 | ctk_tree_path_free (path); | |||
6308 | ||||
6309 | model = ctk_icon_view_get_model (icon_view); | |||
6310 | ||||
6311 | n_children = ctk_tree_model_iter_n_children (model, NULL((void*)0)); | |||
6312 | if (n_children) | |||
6313 | { | |||
6314 | pos = CTK_ICON_VIEW_DROP_BELOW; | |||
6315 | path = ctk_tree_path_new_from_indices (n_children - 1, -1); | |||
6316 | } | |||
6317 | else | |||
6318 | { | |||
6319 | pos = CTK_ICON_VIEW_DROP_ABOVE; | |||
6320 | path = ctk_tree_path_new_from_indices (0, -1); | |||
6321 | } | |||
6322 | ||||
6323 | can_drop = TRUE(!(0)); | |||
6324 | ||||
6325 | goto out; | |||
6326 | } | |||
6327 | ||||
6328 | g_assert (path)do { if (path) ; else g_assertion_message_expr ("Ctk", "ctkiconview.c" , 6328, ((const char*) (__func__)), "path"); } while (0); | |||
6329 | ||||
6330 | ctk_icon_view_get_drag_dest_item (icon_view, | |||
6331 | &old_dest_path, | |||
6332 | &old_pos); | |||
6333 | ||||
6334 | if (old_dest_path) | |||
6335 | ctk_tree_path_free (old_dest_path); | |||
6336 | ||||
6337 | if (TRUE(!(0)) /* FIXME if the location droppable predicate */) | |||
6338 | { | |||
6339 | can_drop = TRUE(!(0)); | |||
6340 | } | |||
6341 | ||||
6342 | out: | |||
6343 | if (can_drop) | |||
6344 | { | |||
6345 | CtkWidget *source_widget; | |||
6346 | ||||
6347 | *suggested_action = cdk_drag_context_get_suggested_action (context); | |||
6348 | source_widget = ctk_drag_get_source_widget (context); | |||
6349 | ||||
6350 | if (source_widget == widget) | |||
6351 | { | |||
6352 | /* Default to MOVE, unless the user has | |||
6353 | * pressed ctrl or shift to affect available actions | |||
6354 | */ | |||
6355 | if ((cdk_drag_context_get_actions (context) & CDK_ACTION_MOVE) != 0) | |||
6356 | *suggested_action = CDK_ACTION_MOVE; | |||
6357 | } | |||
6358 | ||||
6359 | ctk_icon_view_set_drag_dest_item (CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))), | |||
6360 | path, pos); | |||
6361 | } | |||
6362 | else | |||
6363 | { | |||
6364 | /* can't drop here */ | |||
6365 | ctk_icon_view_set_drag_dest_item (CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))), | |||
6366 | NULL((void*)0), | |||
6367 | CTK_ICON_VIEW_DROP_LEFT); | |||
6368 | } | |||
6369 | ||||
6370 | if (path) | |||
6371 | ctk_tree_path_free (path); | |||
6372 | ||||
6373 | return TRUE(!(0)); | |||
6374 | } | |||
6375 | ||||
6376 | static CtkTreePath* | |||
6377 | get_logical_destination (CtkIconView *icon_view, | |||
6378 | gboolean *drop_append_mode) | |||
6379 | { | |||
6380 | /* adjust path to point to the row the drop goes in front of */ | |||
6381 | CtkTreePath *path = NULL((void*)0); | |||
6382 | CtkIconViewDropPosition pos; | |||
6383 | ||||
6384 | *drop_append_mode = FALSE(0); | |||
6385 | ||||
6386 | ctk_icon_view_get_drag_dest_item (icon_view, &path, &pos); | |||
6387 | ||||
6388 | if (path == NULL((void*)0)) | |||
6389 | return NULL((void*)0); | |||
6390 | ||||
6391 | if (pos == CTK_ICON_VIEW_DROP_RIGHT || | |||
6392 | pos == CTK_ICON_VIEW_DROP_BELOW) | |||
6393 | { | |||
6394 | CtkTreeIter iter; | |||
6395 | CtkTreeModel *model = icon_view->priv->model; | |||
6396 | ||||
6397 | if (!ctk_tree_model_get_iter (model, &iter, path) || | |||
6398 | !ctk_tree_model_iter_next (model, &iter)) | |||
6399 | *drop_append_mode = TRUE(!(0)); | |||
6400 | else | |||
6401 | { | |||
6402 | *drop_append_mode = FALSE(0); | |||
6403 | ctk_tree_path_next (path); | |||
6404 | } | |||
6405 | } | |||
6406 | ||||
6407 | return path; | |||
6408 | } | |||
6409 | ||||
6410 | static gboolean | |||
6411 | ctk_icon_view_maybe_begin_drag (CtkIconView *icon_view, | |||
6412 | CdkEventMotion *event) | |||
6413 | { | |||
6414 | CtkWidget *widget = CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))); | |||
6415 | CdkDragContext *context; | |||
6416 | CtkTreePath *path = NULL((void*)0); | |||
6417 | gint button; | |||
6418 | CtkTreeModel *model; | |||
6419 | gboolean retval = FALSE(0); | |||
6420 | ||||
6421 | if (!icon_view->priv->source_set) | |||
6422 | goto out; | |||
6423 | ||||
6424 | if (icon_view->priv->pressed_button < 0) | |||
6425 | goto out; | |||
6426 | ||||
6427 | if (!ctk_drag_check_threshold (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), | |||
6428 | icon_view->priv->press_start_x, | |||
6429 | icon_view->priv->press_start_y, | |||
6430 | event->x, event->y)) | |||
6431 | goto out; | |||
6432 | ||||
6433 | model = ctk_icon_view_get_model (icon_view); | |||
6434 | ||||
6435 | if (model == NULL((void*)0)) | |||
6436 | goto out; | |||
6437 | ||||
6438 | button = icon_view->priv->pressed_button; | |||
6439 | icon_view->priv->pressed_button = -1; | |||
6440 | ||||
6441 | path = ctk_icon_view_get_path_at_pos (icon_view, | |||
6442 | icon_view->priv->press_start_x, | |||
6443 | icon_view->priv->press_start_y); | |||
6444 | ||||
6445 | if (path == NULL((void*)0)) | |||
6446 | goto out; | |||
6447 | ||||
6448 | if (!CTK_IS_TREE_DRAG_SOURCE (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_tree_drag_source_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) || | |||
6449 | !ctk_tree_drag_source_row_draggable (CTK_TREE_DRAG_SOURCE (model)((((CtkTreeDragSource*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((model)), ((ctk_tree_drag_source_get_type ( ))))))), | |||
6450 | path)) | |||
6451 | goto out; | |||
6452 | ||||
6453 | /* FIXME Check whether we're a start button, if not return FALSE and | |||
6454 | * free path | |||
6455 | */ | |||
6456 | ||||
6457 | /* Now we can begin the drag */ | |||
6458 | ||||
6459 | retval = TRUE(!(0)); | |||
6460 | ||||
6461 | context = ctk_drag_begin_with_coordinates (widget, | |||
6462 | ctk_drag_source_get_target_list (widget), | |||
6463 | icon_view->priv->source_actions, | |||
6464 | button, | |||
6465 | (CdkEvent*)event, | |||
6466 | icon_view->priv->press_start_x, | |||
6467 | icon_view->priv->press_start_y); | |||
6468 | ||||
6469 | set_source_row (context, model, path); | |||
6470 | ||||
6471 | out: | |||
6472 | if (path) | |||
6473 | ctk_tree_path_free (path); | |||
6474 | ||||
6475 | return retval; | |||
6476 | } | |||
6477 | ||||
6478 | /* Source side drag signals */ | |||
6479 | static void | |||
6480 | ctk_icon_view_drag_begin (CtkWidget *widget, | |||
6481 | CdkDragContext *context) | |||
6482 | { | |||
6483 | CtkIconView *icon_view; | |||
6484 | CtkIconViewItem *item; | |||
6485 | cairo_surface_t *icon; | |||
6486 | gint x, y; | |||
6487 | CtkTreePath *path; | |||
6488 | double sx, sy; | |||
6489 | ||||
6490 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
6491 | ||||
6492 | /* if the user uses a custom DnD impl, we don't set the icon here */ | |||
6493 | if (!icon_view->priv->dest_set && !icon_view->priv->source_set) | |||
6494 | return; | |||
6495 | ||||
6496 | item = _ctk_icon_view_get_item_at_coords (icon_view, | |||
6497 | icon_view->priv->press_start_x, | |||
6498 | icon_view->priv->press_start_y, | |||
6499 | TRUE(!(0)), | |||
6500 | NULL((void*)0)); | |||
6501 | ||||
6502 | g_return_if_fail (item != NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "item != NULL"); return; } } while (0); | |||
6503 | ||||
6504 | x = icon_view->priv->press_start_x - item->cell_area.x + icon_view->priv->item_padding; | |||
6505 | y = icon_view->priv->press_start_y - item->cell_area.y + icon_view->priv->item_padding; | |||
6506 | ||||
6507 | path = ctk_tree_path_new_from_indices (item->index, -1); | |||
6508 | icon = ctk_icon_view_create_drag_icon (icon_view, path); | |||
6509 | ctk_tree_path_free (path); | |||
6510 | ||||
6511 | cairo_surface_get_device_scale (icon, &sx, &sy); | |||
6512 | cairo_surface_set_device_offset (icon, -x * sx, -y * sy); | |||
6513 | ||||
6514 | ctk_drag_set_icon_surface (context, icon); | |||
6515 | ||||
6516 | cairo_surface_destroy (icon); | |||
6517 | } | |||
6518 | ||||
6519 | static void | |||
6520 | ctk_icon_view_drag_end (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
6521 | CdkDragContext *context G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
6522 | { | |||
6523 | /* do nothing */ | |||
6524 | } | |||
6525 | ||||
6526 | static void | |||
6527 | ctk_icon_view_drag_data_get (CtkWidget *widget, | |||
6528 | CdkDragContext *context, | |||
6529 | CtkSelectionData *selection_data, | |||
6530 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
6531 | guint time G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
6532 | { | |||
6533 | CtkIconView *icon_view; | |||
6534 | CtkTreeModel *model; | |||
6535 | CtkTreePath *source_row; | |||
6536 | ||||
6537 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
6538 | model = ctk_icon_view_get_model (icon_view); | |||
6539 | ||||
6540 | if (model == NULL((void*)0)) | |||
6541 | return; | |||
6542 | ||||
6543 | if (!icon_view->priv->source_set) | |||
6544 | return; | |||
6545 | ||||
6546 | source_row = get_source_row (context); | |||
6547 | ||||
6548 | if (source_row == NULL((void*)0)) | |||
6549 | return; | |||
6550 | ||||
6551 | /* We can implement the CTK_TREE_MODEL_ROW target generically for | |||
6552 | * any model; for DragSource models there are some other targets | |||
6553 | * we also support. | |||
6554 | */ | |||
6555 | ||||
6556 | if (CTK_IS_TREE_DRAG_SOURCE (model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (model)); GType __t = ((ctk_tree_drag_source_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) && | |||
6557 | ctk_tree_drag_source_drag_data_get (CTK_TREE_DRAG_SOURCE (model)((((CtkTreeDragSource*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((model)), ((ctk_tree_drag_source_get_type ( ))))))), | |||
6558 | source_row, | |||
6559 | selection_data)) | |||
6560 | goto done; | |||
6561 | ||||
6562 | /* If drag_data_get does nothing, try providing row data. */ | |||
6563 | if (ctk_selection_data_get_target (selection_data) == cdk_atom_intern_static_string ("CTK_TREE_MODEL_ROW")) | |||
6564 | ctk_tree_set_row_drag_data (selection_data, | |||
6565 | model, | |||
6566 | source_row); | |||
6567 | ||||
6568 | done: | |||
6569 | ctk_tree_path_free (source_row); | |||
6570 | } | |||
6571 | ||||
6572 | static void | |||
6573 | ctk_icon_view_drag_data_delete (CtkWidget *widget, | |||
6574 | CdkDragContext *context) | |||
6575 | { | |||
6576 | CtkTreeModel *model; | |||
6577 | CtkIconView *icon_view; | |||
6578 | CtkTreePath *source_row; | |||
6579 | ||||
6580 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
6581 | model = ctk_icon_view_get_model (icon_view); | |||
6582 | ||||
6583 | if (!check_model_dnd (model, CTK_TYPE_TREE_DRAG_SOURCE(ctk_tree_drag_source_get_type ()), "drag-data-delete")) | |||
6584 | return; | |||
6585 | ||||
6586 | if (!icon_view->priv->source_set) | |||
6587 | return; | |||
6588 | ||||
6589 | source_row = get_source_row (context); | |||
6590 | ||||
6591 | if (source_row == NULL((void*)0)) | |||
6592 | return; | |||
6593 | ||||
6594 | ctk_tree_drag_source_drag_data_delete (CTK_TREE_DRAG_SOURCE (model)((((CtkTreeDragSource*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((model)), ((ctk_tree_drag_source_get_type ( ))))))), | |||
6595 | source_row); | |||
6596 | ||||
6597 | ctk_tree_path_free (source_row); | |||
6598 | ||||
6599 | set_source_row (context, NULL((void*)0), NULL((void*)0)); | |||
6600 | } | |||
6601 | ||||
6602 | /* Target side drag signals */ | |||
6603 | static void | |||
6604 | ctk_icon_view_drag_leave (CtkWidget *widget, | |||
6605 | CdkDragContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
6606 | guint time G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
6607 | { | |||
6608 | CtkIconView *icon_view; | |||
6609 | ||||
6610 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
6611 | ||||
6612 | /* unset any highlight row */ | |||
6613 | ctk_icon_view_set_drag_dest_item (icon_view, | |||
6614 | NULL((void*)0), | |||
6615 | CTK_ICON_VIEW_DROP_LEFT); | |||
6616 | ||||
6617 | remove_scroll_timeout (icon_view); | |||
6618 | } | |||
6619 | ||||
6620 | static gboolean | |||
6621 | ctk_icon_view_drag_motion (CtkWidget *widget, | |||
6622 | CdkDragContext *context, | |||
6623 | gint x, | |||
6624 | gint y, | |||
6625 | guint time) | |||
6626 | { | |||
6627 | CtkTreePath *path = NULL((void*)0); | |||
6628 | CtkIconViewDropPosition pos; | |||
6629 | CtkIconView *icon_view; | |||
6630 | CdkDragAction suggested_action = 0; | |||
6631 | CdkAtom target; | |||
6632 | gboolean empty; | |||
6633 | ||||
6634 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
6635 | ||||
6636 | if (!set_destination (icon_view, context, x, y, &suggested_action, &target)) | |||
6637 | return FALSE(0); | |||
6638 | ||||
6639 | icon_view->priv->event_last_x = x; | |||
6640 | icon_view->priv->event_last_y = y; | |||
6641 | ||||
6642 | ctk_icon_view_get_drag_dest_item (icon_view, &path, &pos); | |||
6643 | ||||
6644 | /* we only know this *after* set_desination_row */ | |||
6645 | empty = icon_view->priv->empty_view_drop; | |||
6646 | ||||
6647 | if (path == NULL((void*)0) && !empty) | |||
6648 | { | |||
6649 | /* Can't drop here. */ | |||
6650 | cdk_drag_status (context, 0, time); | |||
6651 | } | |||
6652 | else | |||
6653 | { | |||
6654 | if (icon_view->priv->scroll_timeout_id == 0) | |||
6655 | { | |||
6656 | icon_view->priv->scroll_timeout_id = | |||
6657 | cdk_threads_add_timeout (50, drag_scroll_timeout, icon_view); | |||
6658 | g_source_set_name_by_id (icon_view->priv->scroll_timeout_id, "[ctk+] drag_scroll_timeout"); | |||
6659 | } | |||
6660 | ||||
6661 | if (target == cdk_atom_intern_static_string ("CTK_TREE_MODEL_ROW")) | |||
6662 | { | |||
6663 | /* Request data so we can use the source row when | |||
6664 | * determining whether to accept the drop | |||
6665 | */ | |||
6666 | set_status_pending (context, suggested_action); | |||
6667 | ctk_drag_get_data (widget, context, target, time); | |||
6668 | } | |||
6669 | else | |||
6670 | { | |||
6671 | set_status_pending (context, 0); | |||
6672 | cdk_drag_status (context, suggested_action, time); | |||
6673 | } | |||
6674 | } | |||
6675 | ||||
6676 | if (path) | |||
6677 | ctk_tree_path_free (path); | |||
6678 | ||||
6679 | return TRUE(!(0)); | |||
6680 | } | |||
6681 | ||||
6682 | static gboolean | |||
6683 | ctk_icon_view_drag_drop (CtkWidget *widget, | |||
6684 | CdkDragContext *context, | |||
6685 | gint x, | |||
6686 | gint y, | |||
6687 | guint time) | |||
6688 | { | |||
6689 | CtkIconView *icon_view; | |||
6690 | CtkTreePath *path; | |||
6691 | CdkDragAction suggested_action = 0; | |||
6692 | CdkAtom target = CDK_NONE((CdkAtom)((gpointer) (gulong) (0))); | |||
6693 | CtkTreeModel *model; | |||
6694 | gboolean drop_append_mode; | |||
6695 | ||||
6696 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
6697 | model = ctk_icon_view_get_model (icon_view); | |||
6698 | ||||
6699 | remove_scroll_timeout (CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ()))))))); | |||
6700 | ||||
6701 | if (!icon_view->priv->dest_set) | |||
6702 | return FALSE(0); | |||
6703 | ||||
6704 | if (!check_model_dnd (model, CTK_TYPE_TREE_DRAG_DEST(ctk_tree_drag_dest_get_type ()), "drag-drop")) | |||
6705 | return FALSE(0); | |||
6706 | ||||
6707 | if (!set_destination (icon_view, context, x, y, &suggested_action, &target)) | |||
6708 | return FALSE(0); | |||
6709 | ||||
6710 | path = get_logical_destination (icon_view, &drop_append_mode); | |||
6711 | ||||
6712 | if (target != CDK_NONE((CdkAtom)((gpointer) (gulong) (0))) && path != NULL((void*)0)) | |||
6713 | { | |||
6714 | /* in case a motion had requested drag data, change things so we | |||
6715 | * treat drag data receives as a drop. | |||
6716 | */ | |||
6717 | set_status_pending (context, 0); | |||
6718 | set_dest_row (context, model, path, | |||
6719 | icon_view->priv->empty_view_drop, drop_append_mode); | |||
6720 | } | |||
6721 | ||||
6722 | if (path) | |||
6723 | ctk_tree_path_free (path); | |||
6724 | ||||
6725 | /* Unset this thing */ | |||
6726 | ctk_icon_view_set_drag_dest_item (icon_view, NULL((void*)0), CTK_ICON_VIEW_DROP_LEFT); | |||
6727 | ||||
6728 | if (target != CDK_NONE((CdkAtom)((gpointer) (gulong) (0)))) | |||
6729 | { | |||
6730 | ctk_drag_get_data (widget, context, target, time); | |||
6731 | return TRUE(!(0)); | |||
6732 | } | |||
6733 | else | |||
6734 | return FALSE(0); | |||
6735 | } | |||
6736 | ||||
6737 | static void | |||
6738 | ctk_icon_view_drag_data_received (CtkWidget *widget, | |||
6739 | CdkDragContext *context, | |||
6740 | gint x G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
6741 | gint y G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
6742 | CtkSelectionData *selection_data, | |||
6743 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
6744 | guint time) | |||
6745 | { | |||
6746 | CtkTreePath *path; | |||
6747 | gboolean accepted = FALSE(0); | |||
6748 | CtkTreeModel *model; | |||
6749 | CtkIconView *icon_view; | |||
6750 | CtkTreePath *dest_row; | |||
6751 | CdkDragAction suggested_action; | |||
6752 | gboolean drop_append_mode; | |||
6753 | ||||
6754 | icon_view = CTK_ICON_VIEW (widget)((((CtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_icon_view_get_type ())))))); | |||
6755 | model = ctk_icon_view_get_model (icon_view); | |||
6756 | ||||
6757 | if (!check_model_dnd (model, CTK_TYPE_TREE_DRAG_DEST(ctk_tree_drag_dest_get_type ()), "drag-data-received")) | |||
6758 | return; | |||
6759 | ||||
6760 | if (!icon_view->priv->dest_set) | |||
6761 | return; | |||
6762 | ||||
6763 | suggested_action = get_status_pending (context); | |||
6764 | ||||
6765 | if (suggested_action) | |||
6766 | { | |||
6767 | /* We are getting this data due to a request in drag_motion, | |||
6768 | * rather than due to a request in drag_drop, so we are just | |||
6769 | * supposed to call drag_status, not actually paste in the | |||
6770 | * data. | |||
6771 | */ | |||
6772 | path = get_logical_destination (icon_view, &drop_append_mode); | |||
6773 | ||||
6774 | if (path == NULL((void*)0)) | |||
6775 | suggested_action = 0; | |||
6776 | ||||
6777 | if (suggested_action) | |||
6778 | { | |||
6779 | if (!ctk_tree_drag_dest_row_drop_possible (CTK_TREE_DRAG_DEST (model)((((CtkTreeDragDest*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_tree_drag_dest_get_type ())))))), | |||
6780 | path, | |||
6781 | selection_data)) | |||
6782 | suggested_action = 0; | |||
6783 | } | |||
6784 | ||||
6785 | cdk_drag_status (context, suggested_action, time); | |||
6786 | ||||
6787 | if (path) | |||
6788 | ctk_tree_path_free (path); | |||
6789 | ||||
6790 | /* If you can't drop, remove user drop indicator until the next motion */ | |||
6791 | if (suggested_action == 0) | |||
6792 | ctk_icon_view_set_drag_dest_item (icon_view, | |||
6793 | NULL((void*)0), | |||
6794 | CTK_ICON_VIEW_DROP_LEFT); | |||
6795 | return; | |||
6796 | } | |||
6797 | ||||
6798 | ||||
6799 | dest_row = get_dest_row (context); | |||
6800 | ||||
6801 | if (dest_row == NULL((void*)0)) | |||
6802 | return; | |||
6803 | ||||
6804 | if (ctk_selection_data_get_length (selection_data) >= 0) | |||
6805 | { | |||
6806 | if (ctk_tree_drag_dest_drag_data_received (CTK_TREE_DRAG_DEST (model)((((CtkTreeDragDest*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_tree_drag_dest_get_type ())))))), | |||
6807 | dest_row, | |||
6808 | selection_data)) | |||
6809 | accepted = TRUE(!(0)); | |||
6810 | } | |||
6811 | ||||
6812 | ctk_drag_finish (context, | |||
6813 | accepted, | |||
6814 | (cdk_drag_context_get_selected_action (context) == CDK_ACTION_MOVE), | |||
6815 | time); | |||
6816 | ||||
6817 | ctk_tree_path_free (dest_row); | |||
6818 | ||||
6819 | /* drop dest_row */ | |||
6820 | set_dest_row (context, NULL((void*)0), NULL((void*)0), FALSE(0), FALSE(0)); | |||
6821 | } | |||
6822 | ||||
6823 | /* Drag-and-Drop support */ | |||
6824 | /** | |||
6825 | * ctk_icon_view_enable_model_drag_source: | |||
6826 | * @icon_view: a #CtkIconView | |||
6827 | * @start_button_mask: Mask of allowed buttons to start drag | |||
6828 | * @targets: (array length=n_targets): the table of targets that the drag will | |||
6829 | * support | |||
6830 | * @n_targets: the number of items in @targets | |||
6831 | * @actions: the bitmask of possible actions for a drag from this | |||
6832 | * widget | |||
6833 | * | |||
6834 | * Turns @icon_view into a drag source for automatic DND. Calling this | |||
6835 | * method sets #CtkIconView:reorderable to %FALSE. | |||
6836 | * | |||
6837 | * Since: 2.8 | |||
6838 | **/ | |||
6839 | void | |||
6840 | ctk_icon_view_enable_model_drag_source (CtkIconView *icon_view, | |||
6841 | CdkModifierType start_button_mask, | |||
6842 | const CtkTargetEntry *targets, | |||
6843 | gint n_targets, | |||
6844 | CdkDragAction actions) | |||
6845 | { | |||
6846 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
6847 | ||||
6848 | ctk_drag_source_set (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), 0, targets, n_targets, actions); | |||
6849 | ||||
6850 | icon_view->priv->start_button_mask = start_button_mask; | |||
6851 | icon_view->priv->source_actions = actions; | |||
6852 | ||||
6853 | icon_view->priv->source_set = TRUE(!(0)); | |||
6854 | ||||
6855 | unset_reorderable (icon_view); | |||
6856 | } | |||
6857 | ||||
6858 | /** | |||
6859 | * ctk_icon_view_enable_model_drag_dest: | |||
6860 | * @icon_view: a #CtkIconView | |||
6861 | * @targets: (array length=n_targets): the table of targets that the drag will | |||
6862 | * support | |||
6863 | * @n_targets: the number of items in @targets | |||
6864 | * @actions: the bitmask of possible actions for a drag to this | |||
6865 | * widget | |||
6866 | * | |||
6867 | * Turns @icon_view into a drop destination for automatic DND. Calling this | |||
6868 | * method sets #CtkIconView:reorderable to %FALSE. | |||
6869 | * | |||
6870 | * Since: 2.8 | |||
6871 | **/ | |||
6872 | void | |||
6873 | ctk_icon_view_enable_model_drag_dest (CtkIconView *icon_view, | |||
6874 | const CtkTargetEntry *targets, | |||
6875 | gint n_targets, | |||
6876 | CdkDragAction actions) | |||
6877 | { | |||
6878 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
6879 | ||||
6880 | ctk_drag_dest_set (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))), 0, targets, n_targets, actions); | |||
6881 | ||||
6882 | icon_view->priv->dest_actions = actions; | |||
6883 | ||||
6884 | icon_view->priv->dest_set = TRUE(!(0)); | |||
6885 | ||||
6886 | unset_reorderable (icon_view); | |||
6887 | } | |||
6888 | ||||
6889 | /** | |||
6890 | * ctk_icon_view_unset_model_drag_source: | |||
6891 | * @icon_view: a #CtkIconView | |||
6892 | * | |||
6893 | * Undoes the effect of ctk_icon_view_enable_model_drag_source(). Calling this | |||
6894 | * method sets #CtkIconView:reorderable to %FALSE. | |||
6895 | * | |||
6896 | * Since: 2.8 | |||
6897 | **/ | |||
6898 | void | |||
6899 | ctk_icon_view_unset_model_drag_source (CtkIconView *icon_view) | |||
6900 | { | |||
6901 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
6902 | ||||
6903 | if (icon_view->priv->source_set) | |||
6904 | { | |||
6905 | ctk_drag_source_unset (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
6906 | icon_view->priv->source_set = FALSE(0); | |||
6907 | } | |||
6908 | ||||
6909 | unset_reorderable (icon_view); | |||
6910 | } | |||
6911 | ||||
6912 | /** | |||
6913 | * ctk_icon_view_unset_model_drag_dest: | |||
6914 | * @icon_view: a #CtkIconView | |||
6915 | * | |||
6916 | * Undoes the effect of ctk_icon_view_enable_model_drag_dest(). Calling this | |||
6917 | * method sets #CtkIconView:reorderable to %FALSE. | |||
6918 | * | |||
6919 | * Since: 2.8 | |||
6920 | **/ | |||
6921 | void | |||
6922 | ctk_icon_view_unset_model_drag_dest (CtkIconView *icon_view) | |||
6923 | { | |||
6924 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
6925 | ||||
6926 | if (icon_view->priv->dest_set) | |||
6927 | { | |||
6928 | ctk_drag_dest_unset (CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ()))))))); | |||
6929 | icon_view->priv->dest_set = FALSE(0); | |||
6930 | } | |||
6931 | ||||
6932 | unset_reorderable (icon_view); | |||
6933 | } | |||
6934 | ||||
6935 | /* These are useful to implement your own custom stuff. */ | |||
6936 | /** | |||
6937 | * ctk_icon_view_set_drag_dest_item: | |||
6938 | * @icon_view: a #CtkIconView | |||
6939 | * @path: (allow-none): The path of the item to highlight, or %NULL. | |||
6940 | * @pos: Specifies where to drop, relative to the item | |||
6941 | * | |||
6942 | * Sets the item that is highlighted for feedback. | |||
6943 | * | |||
6944 | * Since: 2.8 | |||
6945 | */ | |||
6946 | void | |||
6947 | ctk_icon_view_set_drag_dest_item (CtkIconView *icon_view, | |||
6948 | CtkTreePath *path, | |||
6949 | CtkIconViewDropPosition pos) | |||
6950 | { | |||
6951 | /* Note; this function is exported to allow a custom DND | |||
6952 | * implementation, so it can't touch TreeViewDragInfo | |||
6953 | */ | |||
6954 | ||||
6955 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
6956 | ||||
6957 | if (icon_view->priv->dest_item) | |||
6958 | { | |||
6959 | CtkTreePath *current_path; | |||
6960 | current_path = ctk_tree_row_reference_get_path (icon_view->priv->dest_item); | |||
6961 | ctk_tree_row_reference_free (icon_view->priv->dest_item); | |||
6962 | icon_view->priv->dest_item = NULL((void*)0); | |||
6963 | ||||
6964 | ctk_icon_view_queue_draw_path (icon_view, current_path); | |||
6965 | ctk_tree_path_free (current_path); | |||
6966 | } | |||
6967 | ||||
6968 | /* special case a drop on an empty model */ | |||
6969 | icon_view->priv->empty_view_drop = FALSE(0); | |||
6970 | if (pos == CTK_ICON_VIEW_DROP_ABOVE && path | |||
6971 | && ctk_tree_path_get_depth (path) == 1 | |||
6972 | && ctk_tree_path_get_indices (path)[0] == 0) | |||
6973 | { | |||
6974 | gint n_children; | |||
6975 | ||||
6976 | n_children = ctk_tree_model_iter_n_children (icon_view->priv->model, | |||
6977 | NULL((void*)0)); | |||
6978 | ||||
6979 | if (n_children == 0) | |||
6980 | icon_view->priv->empty_view_drop = TRUE(!(0)); | |||
6981 | } | |||
6982 | ||||
6983 | icon_view->priv->dest_pos = pos; | |||
6984 | ||||
6985 | if (path) | |||
6986 | { | |||
6987 | icon_view->priv->dest_item = | |||
6988 | ctk_tree_row_reference_new_proxy (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), | |||
6989 | icon_view->priv->model, path); | |||
6990 | ||||
6991 | ctk_icon_view_queue_draw_path (icon_view, path); | |||
6992 | } | |||
6993 | } | |||
6994 | ||||
6995 | /** | |||
6996 | * ctk_icon_view_get_drag_dest_item: | |||
6997 | * @icon_view: a #CtkIconView | |||
6998 | * @path: (out) (allow-none): Return location for the path of | |||
6999 | * the highlighted item, or %NULL. | |||
7000 | * @pos: (out) (allow-none): Return location for the drop position, or %NULL | |||
7001 | * | |||
7002 | * Gets information about the item that is highlighted for feedback. | |||
7003 | * | |||
7004 | * Since: 2.8 | |||
7005 | **/ | |||
7006 | void | |||
7007 | ctk_icon_view_get_drag_dest_item (CtkIconView *icon_view, | |||
7008 | CtkTreePath **path, | |||
7009 | CtkIconViewDropPosition *pos) | |||
7010 | { | |||
7011 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
7012 | ||||
7013 | if (path) | |||
7014 | { | |||
7015 | if (icon_view->priv->dest_item) | |||
7016 | *path = ctk_tree_row_reference_get_path (icon_view->priv->dest_item); | |||
7017 | else | |||
7018 | *path = NULL((void*)0); | |||
7019 | } | |||
7020 | ||||
7021 | if (pos) | |||
7022 | *pos = icon_view->priv->dest_pos; | |||
7023 | } | |||
7024 | ||||
7025 | /** | |||
7026 | * ctk_icon_view_get_dest_item_at_pos: | |||
7027 | * @icon_view: a #CtkIconView | |||
7028 | * @drag_x: the position to determine the destination item for | |||
7029 | * @drag_y: the position to determine the destination item for | |||
7030 | * @path: (out) (allow-none): Return location for the path of the item, | |||
7031 | * or %NULL. | |||
7032 | * @pos: (out) (allow-none): Return location for the drop position, or %NULL | |||
7033 | * | |||
7034 | * Determines the destination item for a given position. | |||
7035 | * | |||
7036 | * Returns: whether there is an item at the given position. | |||
7037 | * | |||
7038 | * Since: 2.8 | |||
7039 | **/ | |||
7040 | gboolean | |||
7041 | ctk_icon_view_get_dest_item_at_pos (CtkIconView *icon_view, | |||
7042 | gint drag_x, | |||
7043 | gint drag_y, | |||
7044 | CtkTreePath **path, | |||
7045 | CtkIconViewDropPosition *pos) | |||
7046 | { | |||
7047 | CtkIconViewItem *item; | |||
7048 | ||||
7049 | /* Note; this function is exported to allow a custom DND | |||
7050 | * implementation, so it can't touch TreeViewDragInfo | |||
7051 | */ | |||
7052 | ||||
7053 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
7054 | g_return_val_if_fail (drag_x >= 0, FALSE)do { if ((drag_x >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "drag_x >= 0"); return ((0)); } } while (0); | |||
7055 | g_return_val_if_fail (drag_y >= 0, FALSE)do { if ((drag_y >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "drag_y >= 0"); return ((0)); } } while (0); | |||
7056 | g_return_val_if_fail (icon_view->priv->bin_window != NULL, FALSE)do { if ((icon_view->priv->bin_window != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "icon_view->priv->bin_window != NULL"); return ((0) ); } } while (0); | |||
7057 | ||||
7058 | ||||
7059 | if (path) | |||
7060 | *path = NULL((void*)0); | |||
7061 | ||||
7062 | item = _ctk_icon_view_get_item_at_coords (icon_view, | |||
7063 | drag_x + ctk_adjustment_get_value (icon_view->priv->hadjustment), | |||
7064 | drag_y + ctk_adjustment_get_value (icon_view->priv->vadjustment), | |||
7065 | FALSE(0), NULL((void*)0)); | |||
7066 | ||||
7067 | if (item == NULL((void*)0)) | |||
7068 | return FALSE(0); | |||
7069 | ||||
7070 | if (path) | |||
7071 | *path = ctk_tree_path_new_from_indices (item->index, -1); | |||
7072 | ||||
7073 | if (pos) | |||
7074 | { | |||
7075 | if (drag_x < item->cell_area.x + item->cell_area.width / 4) | |||
7076 | *pos = CTK_ICON_VIEW_DROP_LEFT; | |||
7077 | else if (drag_x > item->cell_area.x + item->cell_area.width * 3 / 4) | |||
7078 | *pos = CTK_ICON_VIEW_DROP_RIGHT; | |||
7079 | else if (drag_y < item->cell_area.y + item->cell_area.height / 4) | |||
7080 | *pos = CTK_ICON_VIEW_DROP_ABOVE; | |||
7081 | else if (drag_y > item->cell_area.y + item->cell_area.height * 3 / 4) | |||
7082 | *pos = CTK_ICON_VIEW_DROP_BELOW; | |||
7083 | else | |||
7084 | *pos = CTK_ICON_VIEW_DROP_INTO; | |||
7085 | } | |||
7086 | ||||
7087 | return TRUE(!(0)); | |||
7088 | } | |||
7089 | ||||
7090 | /** | |||
7091 | * ctk_icon_view_create_drag_icon: | |||
7092 | * @icon_view: a #CtkIconView | |||
7093 | * @path: a #CtkTreePath in @icon_view | |||
7094 | * | |||
7095 | * Creates a #cairo_surface_t representation of the item at @path. | |||
7096 | * This image is used for a drag icon. | |||
7097 | * | |||
7098 | * Returns: (transfer full): a newly-allocated surface of the drag icon. | |||
7099 | * | |||
7100 | * Since: 2.8 | |||
7101 | **/ | |||
7102 | cairo_surface_t * | |||
7103 | ctk_icon_view_create_drag_icon (CtkIconView *icon_view, | |||
7104 | CtkTreePath *path) | |||
7105 | { | |||
7106 | CtkWidget *widget; | |||
7107 | cairo_t *cr; | |||
7108 | cairo_surface_t *surface; | |||
7109 | GList *l; | |||
7110 | gint index; | |||
7111 | ||||
7112 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return (((void*)0)); } } while (0); | |||
7113 | g_return_val_if_fail (path != NULL, NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "path != NULL"); return ( ((void*)0)); } } while (0); | |||
7114 | ||||
7115 | widget = CTK_WIDGET (icon_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), ((ctk_widget_get_type ())))))); | |||
7116 | ||||
7117 | if (!ctk_widget_get_realized (widget)) | |||
7118 | return NULL((void*)0); | |||
7119 | ||||
7120 | index = ctk_tree_path_get_indices (path)[0]; | |||
7121 | ||||
7122 | for (l = icon_view->priv->items; l; l = l->next) | |||
7123 | { | |||
7124 | CtkIconViewItem *item = l->data; | |||
7125 | ||||
7126 | if (index == item->index) | |||
7127 | { | |||
7128 | CdkRectangle rect = { | |||
7129 | item->cell_area.x - icon_view->priv->item_padding, | |||
7130 | item->cell_area.y - icon_view->priv->item_padding, | |||
7131 | item->cell_area.width + icon_view->priv->item_padding * 2, | |||
7132 | item->cell_area.height + icon_view->priv->item_padding * 2 | |||
7133 | }; | |||
7134 | ||||
7135 | surface = cdk_window_create_similar_surface (icon_view->priv->bin_window, | |||
7136 | CAIRO_CONTENT_COLOR_ALPHA, | |||
7137 | rect.width, | |||
7138 | rect.height); | |||
7139 | ||||
7140 | cr = cairo_create (surface); | |||
7141 | ||||
7142 | ctk_icon_view_paint_item (icon_view, cr, item, | |||
7143 | icon_view->priv->item_padding, | |||
7144 | icon_view->priv->item_padding, | |||
7145 | FALSE(0)); | |||
7146 | ||||
7147 | cairo_destroy (cr); | |||
7148 | ||||
7149 | return surface; | |||
7150 | } | |||
7151 | } | |||
7152 | ||||
7153 | return NULL((void*)0); | |||
7154 | } | |||
7155 | ||||
7156 | /** | |||
7157 | * ctk_icon_view_get_reorderable: | |||
7158 | * @icon_view: a #CtkIconView | |||
7159 | * | |||
7160 | * Retrieves whether the user can reorder the list via drag-and-drop. | |||
7161 | * See ctk_icon_view_set_reorderable(). | |||
7162 | * | |||
7163 | * Returns: %TRUE if the list can be reordered. | |||
7164 | * | |||
7165 | * Since: 2.8 | |||
7166 | **/ | |||
7167 | gboolean | |||
7168 | ctk_icon_view_get_reorderable (CtkIconView *icon_view) | |||
7169 | { | |||
7170 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
7171 | ||||
7172 | return icon_view->priv->reorderable; | |||
7173 | } | |||
7174 | ||||
7175 | static const CtkTargetEntry item_targets[] = { | |||
7176 | { "CTK_TREE_MODEL_ROW", CTK_TARGET_SAME_WIDGET, 0 } | |||
7177 | }; | |||
7178 | ||||
7179 | ||||
7180 | /** | |||
7181 | * ctk_icon_view_set_reorderable: | |||
7182 | * @icon_view: A #CtkIconView. | |||
7183 | * @reorderable: %TRUE, if the list of items can be reordered. | |||
7184 | * | |||
7185 | * This function is a convenience function to allow you to reorder models that | |||
7186 | * support the #CtkTreeDragSourceIface and the #CtkTreeDragDestIface. Both | |||
7187 | * #CtkTreeStore and #CtkListStore support these. If @reorderable is %TRUE, then | |||
7188 | * the user can reorder the model by dragging and dropping rows. The | |||
7189 | * developer can listen to these changes by connecting to the model's | |||
7190 | * row_inserted and row_deleted signals. The reordering is implemented by setting up | |||
7191 | * the icon view as a drag source and destination. Therefore, drag and | |||
7192 | * drop can not be used in a reorderable view for any other purpose. | |||
7193 | * | |||
7194 | * This function does not give you any degree of control over the order -- any | |||
7195 | * reordering is allowed. If more control is needed, you should probably | |||
7196 | * handle drag and drop manually. | |||
7197 | * | |||
7198 | * Since: 2.8 | |||
7199 | **/ | |||
7200 | void | |||
7201 | ctk_icon_view_set_reorderable (CtkIconView *icon_view, | |||
7202 | gboolean reorderable) | |||
7203 | { | |||
7204 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
7205 | ||||
7206 | reorderable = reorderable != FALSE(0); | |||
7207 | ||||
7208 | if (icon_view->priv->reorderable == reorderable) | |||
7209 | return; | |||
7210 | ||||
7211 | if (reorderable) | |||
7212 | { | |||
7213 | ctk_icon_view_enable_model_drag_source (icon_view, | |||
7214 | CDK_BUTTON1_MASK, | |||
7215 | item_targets, | |||
7216 | G_N_ELEMENTS (item_targets)(sizeof (item_targets) / sizeof ((item_targets)[0])), | |||
7217 | CDK_ACTION_MOVE); | |||
7218 | ctk_icon_view_enable_model_drag_dest (icon_view, | |||
7219 | item_targets, | |||
7220 | G_N_ELEMENTS (item_targets)(sizeof (item_targets) / sizeof ((item_targets)[0])), | |||
7221 | CDK_ACTION_MOVE); | |||
7222 | } | |||
7223 | else | |||
7224 | { | |||
7225 | ctk_icon_view_unset_model_drag_source (icon_view); | |||
7226 | ctk_icon_view_unset_model_drag_dest (icon_view); | |||
7227 | } | |||
7228 | ||||
7229 | icon_view->priv->reorderable = reorderable; | |||
7230 | ||||
7231 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "reorderable"); | |||
7232 | } | |||
7233 | ||||
7234 | /** | |||
7235 | * ctk_icon_view_set_activate_on_single_click: | |||
7236 | * @icon_view: a #CtkIconView | |||
7237 | * @single: %TRUE to emit item-activated on a single click | |||
7238 | * | |||
7239 | * Causes the #CtkIconView::item-activated signal to be emitted on | |||
7240 | * a single click instead of a double click. | |||
7241 | * | |||
7242 | * Since: 3.8 | |||
7243 | **/ | |||
7244 | void | |||
7245 | ctk_icon_view_set_activate_on_single_click (CtkIconView *icon_view, | |||
7246 | gboolean single) | |||
7247 | { | |||
7248 | g_return_if_fail (CTK_IS_ICON_VIEW (icon_view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return; } } while (0); | |||
7249 | ||||
7250 | single = single != FALSE(0); | |||
7251 | ||||
7252 | if (icon_view->priv->activate_on_single_click == single) | |||
7253 | return; | |||
7254 | ||||
7255 | icon_view->priv->activate_on_single_click = single; | |||
7256 | g_object_notify (G_OBJECT (icon_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((icon_view)), (((GType) ((20) << (2)))))))), "activate-on-single-click"); | |||
7257 | } | |||
7258 | ||||
7259 | /** | |||
7260 | * ctk_icon_view_get_activate_on_single_click: | |||
7261 | * @icon_view: a #CtkIconView | |||
7262 | * | |||
7263 | * Gets the setting set by ctk_icon_view_set_activate_on_single_click(). | |||
7264 | * | |||
7265 | * Returns: %TRUE if item-activated will be emitted on a single click | |||
7266 | * | |||
7267 | * Since: 3.8 | |||
7268 | **/ | |||
7269 | gboolean | |||
7270 | ctk_icon_view_get_activate_on_single_click (CtkIconView *icon_view) | |||
7271 | { | |||
7272 | g_return_val_if_fail (CTK_IS_ICON_VIEW (icon_view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((icon_view)); GType __t = ((ctk_icon_view_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_ICON_VIEW (icon_view)"); return ((0)); } } while ( 0); | |||
7273 | ||||
7274 | return icon_view->priv->activate_on_single_click; | |||
7275 | } | |||
7276 | ||||
7277 | static gboolean | |||
7278 | ctk_icon_view_buildable_custom_tag_start (CtkBuildable *buildable, | |||
7279 | CtkBuilder *builder, | |||
7280 | GObject *child, | |||
7281 | const gchar *tagname, | |||
7282 | GMarkupParser *parser, | |||
7283 | gpointer *data) | |||
7284 | { | |||
7285 | if (parent_buildable_iface->custom_tag_start (buildable, builder, child, | |||
7286 | tagname, parser, data)) | |||
7287 | return TRUE(!(0)); | |||
7288 | ||||
7289 | return _ctk_cell_layout_buildable_custom_tag_start (buildable, builder, child, | |||
7290 | tagname, parser, data); | |||
7291 | } | |||
7292 | ||||
7293 | static void | |||
7294 | ctk_icon_view_buildable_custom_tag_end (CtkBuildable *buildable, | |||
7295 | CtkBuilder *builder, | |||
7296 | GObject *child, | |||
7297 | const gchar *tagname, | |||
7298 | gpointer *data) | |||
7299 | { | |||
7300 | if (!_ctk_cell_layout_buildable_custom_tag_end (buildable, builder, | |||
7301 | child, tagname, data)) | |||
7302 | parent_buildable_iface->custom_tag_end (buildable, builder, | |||
7303 | child, tagname, data); | |||
7304 | } |