File: | ctk/ctkshortcutssection.c |
Warning: | line 630, column 3 Value stored to 'n_pages' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* ctkshortcutssection.c |
2 | * |
3 | * Copyright (C) 2015 Christian Hergert <christian@hergert.me> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public License as |
7 | * published by the Free Software Foundation; either version 2 of the |
8 | * License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | #include "config.h" |
20 | |
21 | #include "ctkshortcutssection.h" |
22 | |
23 | #include "ctkshortcutsgroup.h" |
24 | #include "ctkbutton.h" |
25 | #include "ctklabel.h" |
26 | #include "ctkstack.h" |
27 | #include "ctkstackswitcher.h" |
28 | #include "ctkstylecontext.h" |
29 | #include "ctkorientable.h" |
30 | #include "ctksizegroup.h" |
31 | #include "ctkwidget.h" |
32 | #include "ctkbindings.h" |
33 | #include "ctkprivate.h" |
34 | #include "ctkmarshalers.h" |
35 | #include "ctkgesturepan.h" |
36 | #include "ctkwidgetprivate.h" |
37 | #include "ctkintl.h" |
38 | |
39 | /** |
40 | * SECTION:ctkshortcutssection |
41 | * @Title: CtkShortcutsSection |
42 | * @Short_description: Represents an application mode in a CtkShortcutsWindow |
43 | * |
44 | * A CtkShortcutsSection collects all the keyboard shortcuts and gestures |
45 | * for a major application mode. If your application needs multiple sections, |
46 | * you should give each section a unique #CtkShortcutsSection:section-name and |
47 | * a #CtkShortcutsSection:title that can be shown in the section selector of |
48 | * the CtkShortcutsWindow. |
49 | * |
50 | * The #CtkShortcutsSection:max-height property can be used to influence how |
51 | * the groups in the section are distributed over pages and columns. |
52 | * |
53 | * This widget is only meant to be used with #CtkShortcutsWindow. |
54 | */ |
55 | |
56 | struct _CtkShortcutsSection |
57 | { |
58 | CtkBox parent_instance; |
59 | |
60 | gchar *name; |
61 | gchar *title; |
62 | gchar *view_name; |
63 | guint max_height; |
64 | |
65 | CtkStack *stack; |
66 | CtkStackSwitcher *switcher; |
67 | CtkWidget *show_all; |
68 | CtkWidget *footer; |
69 | GList *groups; |
70 | |
71 | gboolean has_filtered_group; |
72 | gboolean need_reflow; |
73 | |
74 | CtkGesture *pan_gesture; |
75 | }; |
76 | |
77 | struct _CtkShortcutsSectionClass |
78 | { |
79 | CtkBoxClass parent_class; |
80 | |
81 | gboolean (* change_current_page) (CtkShortcutsSection *self, |
82 | gint offset); |
83 | |
84 | }; |
85 | |
86 | G_DEFINE_TYPE (CtkShortcutsSection, ctk_shortcuts_section, CTK_TYPE_BOX)static void ctk_shortcuts_section_init (CtkShortcutsSection * self); static void ctk_shortcuts_section_class_init (CtkShortcutsSectionClass *klass); static GType ctk_shortcuts_section_get_type_once (void ); static gpointer ctk_shortcuts_section_parent_class = ((void *)0); static gint CtkShortcutsSection_private_offset; static void ctk_shortcuts_section_class_intern_init (gpointer klass) { ctk_shortcuts_section_parent_class = g_type_class_peek_parent (klass); if (CtkShortcutsSection_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkShortcutsSection_private_offset ); ctk_shortcuts_section_class_init ((CtkShortcutsSectionClass *) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_shortcuts_section_get_instance_private (CtkShortcutsSection *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkShortcutsSection_private_offset )))); } GType ctk_shortcuts_section_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_shortcuts_section_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_shortcuts_section_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_box_get_type ()), g_intern_static_string ("CtkShortcutsSection" ), sizeof (CtkShortcutsSectionClass), (GClassInitFunc)(void ( *)(void)) ctk_shortcuts_section_class_intern_init, sizeof (CtkShortcutsSection ), (GInstanceInitFunc)(void (*)(void)) ctk_shortcuts_section_init , (GTypeFlags) 0); { {{};} } return g_define_type_id; } |
87 | |
88 | enum { |
89 | PROP_0, |
90 | PROP_TITLE, |
91 | PROP_SECTION_NAME, |
92 | PROP_VIEW_NAME, |
93 | PROP_MAX_HEIGHT, |
94 | LAST_PROP |
95 | }; |
96 | |
97 | enum { |
98 | CHANGE_CURRENT_PAGE, |
99 | LAST_SIGNAL |
100 | }; |
101 | |
102 | static GParamSpec *properties[LAST_PROP]; |
103 | static guint signals[LAST_SIGNAL]; |
104 | |
105 | static void ctk_shortcuts_section_set_view_name (CtkShortcutsSection *self, |
106 | const gchar *view_name); |
107 | static void ctk_shortcuts_section_set_max_height (CtkShortcutsSection *self, |
108 | guint max_height); |
109 | static void ctk_shortcuts_section_add_group (CtkShortcutsSection *self, |
110 | CtkShortcutsGroup *group); |
111 | |
112 | static void ctk_shortcuts_section_show_all (CtkShortcutsSection *self); |
113 | static void ctk_shortcuts_section_filter_groups (CtkShortcutsSection *self); |
114 | static void ctk_shortcuts_section_reflow_groups (CtkShortcutsSection *self); |
115 | static void ctk_shortcuts_section_maybe_reflow (CtkShortcutsSection *self); |
116 | |
117 | static gboolean ctk_shortcuts_section_change_current_page (CtkShortcutsSection *self, |
118 | gint offset); |
119 | |
120 | static void ctk_shortcuts_section_pan_gesture_pan (CtkGesturePan *gesture, |
121 | CtkPanDirection direction, |
122 | gdouble offset, |
123 | CtkShortcutsSection *self); |
124 | |
125 | static void |
126 | ctk_shortcuts_section_add (CtkContainer *container, |
127 | CtkWidget *child) |
128 | { |
129 | CtkShortcutsSection *self = CTK_SHORTCUTS_SECTION (container)((((CtkShortcutsSection*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((container)), ((ctk_shortcuts_section_get_type ())))))); |
130 | |
131 | if (CTK_IS_SHORTCUTS_GROUP (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_shortcuts_group_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; }))))) |
132 | ctk_shortcuts_section_add_group (self, CTK_SHORTCUTS_GROUP (child)((((CtkShortcutsGroup*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((child)), ((ctk_shortcuts_group_get_type () ))))))); |
133 | else |
134 | g_warning ("Can't add children of type %s to %s", |
135 | G_OBJECT_TYPE_NAME (child)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (child))-> g_class))->g_type))))), |
136 | G_OBJECT_TYPE_NAME (container)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (container ))->g_class))->g_type)))))); |
137 | } |
138 | |
139 | static void |
140 | ctk_shortcuts_section_remove (CtkContainer *container, |
141 | CtkWidget *child) |
142 | { |
143 | CtkShortcutsSection *self = (CtkShortcutsSection *)container; |
144 | |
145 | if (CTK_IS_SHORTCUTS_GROUP (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_shortcuts_group_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; })))) && |
146 | ctk_widget_is_ancestor (child, CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ())))))))) |
147 | { |
148 | self->groups = g_list_remove (self->groups, child); |
149 | ctk_container_remove (CTK_CONTAINER (ctk_widget_get_parent (child))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_widget_get_parent (child))), ((ctk_container_get_type ())))))), child); |
150 | } |
151 | else |
152 | CTK_CONTAINER_CLASS (ctk_shortcuts_section_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_shortcuts_section_parent_class)), ((ctk_container_get_type ()))))))->remove (container, child); |
153 | } |
154 | |
155 | static void |
156 | ctk_shortcuts_section_forall (CtkContainer *container, |
157 | gboolean include_internal, |
158 | CtkCallback callback, |
159 | gpointer callback_data) |
160 | { |
161 | CtkShortcutsSection *self = (CtkShortcutsSection *)container; |
162 | GList *l; |
163 | |
164 | if (include_internal) |
165 | { |
166 | CTK_CONTAINER_CLASS (ctk_shortcuts_section_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_shortcuts_section_parent_class)), ((ctk_container_get_type ()))))))->forall (container, include_internal, callback, callback_data); |
167 | } |
168 | else |
169 | { |
170 | for (l = self->groups; l; l = l->next) |
171 | { |
172 | CtkWidget *group = l->data; |
173 | callback (group, callback_data); |
174 | } |
175 | } |
176 | } |
177 | |
178 | static void |
179 | map_child (CtkWidget *child) |
180 | { |
181 | if (_ctk_widget_get_visible (child) && |
182 | _ctk_widget_get_child_visible (child) && |
183 | !_ctk_widget_get_mapped (child)) |
184 | ctk_widget_map (child); |
185 | } |
186 | |
187 | static void |
188 | ctk_shortcuts_section_map (CtkWidget *widget) |
189 | { |
190 | CtkShortcutsSection *self = CTK_SHORTCUTS_SECTION (widget)((((CtkShortcutsSection*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), ((ctk_shortcuts_section_get_type ())))))); |
191 | |
192 | if (self->need_reflow) |
193 | ctk_shortcuts_section_reflow_groups (self); |
194 | |
195 | ctk_widget_set_mapped (widget, TRUE(!(0))); |
196 | |
197 | map_child (CTK_WIDGET (self->stack)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_widget_get_type ()))))))); |
198 | map_child (CTK_WIDGET (self->footer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->footer)), ((ctk_widget_get_type ()))))))); |
199 | } |
200 | |
201 | static void |
202 | ctk_shortcuts_section_unmap (CtkWidget *widget) |
203 | { |
204 | CtkShortcutsSection *self = CTK_SHORTCUTS_SECTION (widget)((((CtkShortcutsSection*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), ((ctk_shortcuts_section_get_type ())))))); |
205 | |
206 | ctk_widget_set_mapped (widget, FALSE(0)); |
207 | |
208 | ctk_widget_unmap (CTK_WIDGET (self->footer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->footer)), ((ctk_widget_get_type ()))))))); |
209 | ctk_widget_unmap (CTK_WIDGET (self->stack)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_widget_get_type ()))))))); |
210 | } |
211 | |
212 | static void |
213 | ctk_shortcuts_section_destroy (CtkWidget *widget) |
214 | { |
215 | CtkShortcutsSection *self = CTK_SHORTCUTS_SECTION (widget)((((CtkShortcutsSection*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), ((ctk_shortcuts_section_get_type ())))))); |
216 | |
217 | if (self->stack) |
218 | { |
219 | ctk_widget_destroy (CTK_WIDGET (self->stack)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_widget_get_type ()))))))); |
220 | self->stack = NULL((void*)0); |
221 | } |
222 | |
223 | if (self->footer) |
224 | { |
225 | ctk_widget_destroy (CTK_WIDGET (self->footer)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->footer)), ((ctk_widget_get_type ()))))))); |
226 | self->footer = NULL((void*)0); |
227 | } |
228 | |
229 | g_list_free (self->groups); |
230 | self->groups = NULL((void*)0); |
231 | |
232 | CTK_WIDGET_CLASS (ctk_shortcuts_section_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_shortcuts_section_parent_class)), ((ctk_widget_get_type ()))))))->destroy (widget); |
233 | } |
234 | |
235 | static void |
236 | ctk_shortcuts_section_finalize (GObject *object) |
237 | { |
238 | CtkShortcutsSection *self = (CtkShortcutsSection *)object; |
239 | |
240 | g_clear_pointer (&self->name, g_free)do { _Static_assert (sizeof *(&self->name) == sizeof ( gpointer), "Expression evaluates to false"); __typeof__ ((& self->name)) _pp = (&self->name); __typeof__ (*(& self->name)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free ) (_ptr); } while (0); |
241 | g_clear_pointer (&self->title, g_free)do { _Static_assert (sizeof *(&self->title) == sizeof ( gpointer), "Expression evaluates to false"); __typeof__ ((& self->title)) _pp = (&self->title); __typeof__ (*(& self->title)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free ) (_ptr); } while (0); |
242 | g_clear_pointer (&self->view_name, g_free)do { _Static_assert (sizeof *(&self->view_name) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((& self->view_name)) _pp = (&self->view_name); __typeof__ (*(&self->view_name)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr); } while (0); |
243 | g_clear_object (&self->pan_gesture)do { _Static_assert (sizeof *((&self->pan_gesture)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&self->pan_gesture))) _pp = ((&self->pan_gesture )); __typeof__ (*((&self->pan_gesture))) _ptr = *_pp; * _pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while ( 0); |
244 | |
245 | G_OBJECT_CLASS (ctk_shortcuts_section_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_shortcuts_section_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); |
246 | } |
247 | |
248 | static void |
249 | ctk_shortcuts_section_get_property (GObject *object, |
250 | guint prop_id, |
251 | GValue *value, |
252 | GParamSpec *pspec) |
253 | { |
254 | CtkShortcutsSection *self = (CtkShortcutsSection *)object; |
255 | |
256 | switch (prop_id) |
257 | { |
258 | case PROP_SECTION_NAME: |
259 | g_value_set_string (value, self->name); |
260 | break; |
261 | |
262 | case PROP_VIEW_NAME: |
263 | g_value_set_string (value, self->view_name); |
264 | break; |
265 | |
266 | case PROP_TITLE: |
267 | g_value_set_string (value, self->title); |
268 | break; |
269 | |
270 | case PROP_MAX_HEIGHT: |
271 | g_value_set_uint (value, self->max_height); |
272 | break; |
273 | |
274 | default: |
275 | 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'" , "ctkshortcutssection.c", 275, ("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); |
276 | } |
277 | } |
278 | |
279 | static void |
280 | ctk_shortcuts_section_set_property (GObject *object, |
281 | guint prop_id, |
282 | const GValue *value, |
283 | GParamSpec *pspec) |
284 | { |
285 | CtkShortcutsSection *self = (CtkShortcutsSection *)object; |
286 | |
287 | switch (prop_id) |
288 | { |
289 | case PROP_SECTION_NAME: |
290 | g_free (self->name); |
291 | self->name = g_value_dup_string (value); |
292 | break; |
293 | |
294 | case PROP_VIEW_NAME: |
295 | ctk_shortcuts_section_set_view_name (self, g_value_get_string (value)); |
296 | break; |
297 | |
298 | case PROP_TITLE: |
299 | g_free (self->title); |
300 | self->title = g_value_dup_string (value); |
301 | break; |
302 | |
303 | case PROP_MAX_HEIGHT: |
304 | ctk_shortcuts_section_set_max_height (self, g_value_get_uint (value)); |
305 | break; |
306 | |
307 | default: |
308 | 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'" , "ctkshortcutssection.c", 308, ("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); |
309 | } |
310 | } |
311 | |
312 | static GType |
313 | ctk_shortcuts_section_child_type (CtkContainer *container G_GNUC_UNUSED__attribute__ ((__unused__))) |
314 | { |
315 | return CTK_TYPE_SHORTCUTS_GROUP(ctk_shortcuts_group_get_type ()); |
316 | } |
317 | |
318 | static void |
319 | ctk_shortcuts_section_class_init (CtkShortcutsSectionClass *klass) |
320 | { |
321 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
322 | CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_widget_get_type ())))))); |
323 | CtkContainerClass *container_class = CTK_CONTAINER_CLASS (klass)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_container_get_type ())))))); |
324 | CtkBindingSet *binding_set; |
325 | |
326 | object_class->finalize = ctk_shortcuts_section_finalize; |
327 | object_class->get_property = ctk_shortcuts_section_get_property; |
328 | object_class->set_property = ctk_shortcuts_section_set_property; |
329 | |
330 | widget_class->map = ctk_shortcuts_section_map; |
331 | widget_class->unmap = ctk_shortcuts_section_unmap; |
332 | widget_class->destroy = ctk_shortcuts_section_destroy; |
333 | |
334 | container_class->add = ctk_shortcuts_section_add; |
335 | container_class->remove = ctk_shortcuts_section_remove; |
336 | container_class->forall = ctk_shortcuts_section_forall; |
337 | container_class->child_type = ctk_shortcuts_section_child_type; |
338 | |
339 | klass->change_current_page = ctk_shortcuts_section_change_current_page; |
340 | |
341 | /** |
342 | * CtkShortcutsSection:section-name: |
343 | * |
344 | * A unique name to identify this section among the sections |
345 | * added to the CtkShortcutsWindow. Setting the #CtkShortcutsWindow:section-name |
346 | * property to this string will make this section shown in the |
347 | * CtkShortcutsWindow. |
348 | */ |
349 | properties[PROP_SECTION_NAME] = |
350 | g_param_spec_string ("section-name", P_("Section Name")g_dgettext("ctk30" "-properties","Section Name"), P_("Section Name")g_dgettext("ctk30" "-properties","Section Name"), |
351 | NULL((void*)0), |
352 | (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB ))); |
353 | |
354 | /** |
355 | * CtkShortcutsSection:view-name: |
356 | * |
357 | * A view name to filter the groups in this section by. |
358 | * See #CtkShortcutsGroup:view. |
359 | * |
360 | * Applications are expected to use the #CtkShortcutsWindow:view-name |
361 | * property for this purpose. |
362 | */ |
363 | properties[PROP_VIEW_NAME] = |
364 | g_param_spec_string ("view-name", P_("View Name")g_dgettext("ctk30" "-properties","View Name"), P_("View Name")g_dgettext("ctk30" "-properties","View Name"), |
365 | NULL((void*)0), |
366 | (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB ) | G_PARAM_EXPLICIT_NOTIFY)); |
367 | |
368 | /** |
369 | * CtkShortcutsSection:title: |
370 | * |
371 | * The string to show in the section selector of the CtkShortcutsWindow |
372 | * for this section. If there is only one section, you don't need to |
373 | * set a title, since the section selector will not be shown in this case. |
374 | */ |
375 | properties[PROP_TITLE] = |
376 | g_param_spec_string ("title", P_("Title")g_dgettext("ctk30" "-properties","Title"), P_("Title")g_dgettext("ctk30" "-properties","Title"), |
377 | NULL((void*)0), |
378 | (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB ))); |
379 | |
380 | /** |
381 | * CtkShortcutsSection:max-height: |
382 | * |
383 | * The maximum number of lines to allow per column. This property can |
384 | * be used to influence how the groups in this section are distributed |
385 | * across pages and columns. The default value of 15 should work in |
386 | * most cases. |
387 | */ |
388 | properties[PROP_MAX_HEIGHT] = |
389 | g_param_spec_uint ("max-height", P_("Maximum Height")g_dgettext("ctk30" "-properties","Maximum Height"), P_("Maximum Height")g_dgettext("ctk30" "-properties","Maximum Height"), |
390 | 0, G_MAXUINT(2147483647 *2U +1U), 15, |
391 | (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB ) | G_PARAM_EXPLICIT_NOTIFY)); |
392 | |
393 | g_object_class_install_properties (object_class, LAST_PROP, properties); |
394 | |
395 | signals[CHANGE_CURRENT_PAGE] = |
396 | g_signal_new (I_("change-current-page")g_intern_static_string ("change-current-page"), |
397 | G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type), |
398 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
399 | G_STRUCT_OFFSET (CtkShortcutsSectionClass, change_current_page)((glong) __builtin_offsetof(CtkShortcutsSectionClass, change_current_page )), |
400 | NULL((void*)0), NULL((void*)0), |
401 | _ctk_marshal_BOOLEAN__INT, |
402 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 1, |
403 | G_TYPE_INT((GType) ((6) << (2)))); |
404 | |
405 | binding_set = ctk_binding_set_by_class (klass); |
406 | ctk_binding_entry_add_signal (binding_set, |
407 | CDK_KEY_Page_Up0xff55, 0, |
408 | "change-current-page", 1, |
409 | G_TYPE_INT((GType) ((6) << (2))), -1); |
410 | ctk_binding_entry_add_signal (binding_set, |
411 | CDK_KEY_Page_Down0xff56, 0, |
412 | "change-current-page", 1, |
413 | G_TYPE_INT((GType) ((6) << (2))), 1); |
414 | ctk_binding_entry_add_signal (binding_set, |
415 | CDK_KEY_Page_Up0xff55, CDK_CONTROL_MASK, |
416 | "change-current-page", 1, |
417 | G_TYPE_INT((GType) ((6) << (2))), -1); |
418 | ctk_binding_entry_add_signal (binding_set, |
419 | CDK_KEY_Page_Down0xff56, CDK_CONTROL_MASK, |
420 | "change-current-page", 1, |
421 | G_TYPE_INT((GType) ((6) << (2))), 1); |
422 | } |
423 | |
424 | static void |
425 | ctk_shortcuts_section_init (CtkShortcutsSection *self) |
426 | { |
427 | self->max_height = 15; |
428 | |
429 | ctk_orientable_set_orientation (CTK_ORIENTABLE (self)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_orientable_get_type ())))))), CTK_ORIENTATION_VERTICAL); |
430 | ctk_box_set_homogeneous (CTK_BOX (self)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_box_get_type ())))))), FALSE(0)); |
431 | ctk_box_set_spacing (CTK_BOX (self)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_box_get_type ())))))), 22); |
432 | ctk_container_set_border_width (CTK_CONTAINER (self)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_container_get_type ())))))), 24); |
433 | |
434 | self->stack = g_object_new (CTK_TYPE_STACK(ctk_stack_get_type ()), |
435 | "homogeneous", TRUE(!(0)), |
436 | "transition-type", CTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT, |
437 | "vexpand", TRUE(!(0)), |
438 | "visible", TRUE(!(0)), |
439 | NULL((void*)0)); |
440 | CTK_CONTAINER_CLASS (ctk_shortcuts_section_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_shortcuts_section_parent_class)), ((ctk_container_get_type ()))))))->add (CTK_CONTAINER (self)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_container_get_type ())))))), CTK_WIDGET (self->stack)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_widget_get_type ()))))))); |
441 | |
442 | self->switcher = g_object_new (CTK_TYPE_STACK_SWITCHER(ctk_stack_switcher_get_type ()), |
443 | "halign", CTK_ALIGN_CENTER, |
444 | "stack", self->stack, |
445 | "spacing", 12, |
446 | "no-show-all", TRUE(!(0)), |
447 | NULL((void*)0)); |
448 | |
449 | ctk_style_context_remove_class (ctk_widget_get_style_context (CTK_WIDGET (self->switcher)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->switcher)), ((ctk_widget_get_type ()))))))), CTK_STYLE_CLASS_LINKED"linked"); |
450 | |
451 | self->show_all = ctk_button_new_with_mnemonic (_("_Show All")((char *) g_dgettext ("ctk30", "_Show All"))); |
452 | ctk_widget_set_no_show_all (self->show_all, TRUE(!(0))); |
453 | g_signal_connect_swapped (self->show_all, "clicked",g_signal_connect_data ((self->show_all), ("clicked"), (((GCallback ) (ctk_shortcuts_section_show_all))), (self), ((void*)0), G_CONNECT_SWAPPED ) |
454 | G_CALLBACK (ctk_shortcuts_section_show_all), self)g_signal_connect_data ((self->show_all), ("clicked"), (((GCallback ) (ctk_shortcuts_section_show_all))), (self), ((void*)0), G_CONNECT_SWAPPED ); |
455 | |
456 | self->footer = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 20); |
457 | CTK_CONTAINER_CLASS (ctk_shortcuts_section_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_shortcuts_section_parent_class)), ((ctk_container_get_type ()))))))->add (CTK_CONTAINER (self)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_container_get_type ())))))), self->footer); |
458 | |
459 | ctk_box_set_center_widget (CTK_BOX (self->footer)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->footer)), ((ctk_box_get_type ())))))), CTK_WIDGET (self->switcher)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->switcher)), ((ctk_widget_get_type ()))))))); |
460 | ctk_box_pack_end (CTK_BOX (self->footer)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->footer)), ((ctk_box_get_type ())))))), self->show_all, TRUE(!(0)), TRUE(!(0)), 0); |
461 | ctk_widget_set_halign (self->show_all, CTK_ALIGN_END); |
462 | |
463 | self->pan_gesture = ctk_gesture_pan_new (CTK_WIDGET (self->stack)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_widget_get_type ())))))), CTK_ORIENTATION_HORIZONTAL); |
464 | g_signal_connect (self->pan_gesture, "pan",g_signal_connect_data ((self->pan_gesture), ("pan"), (((GCallback ) (ctk_shortcuts_section_pan_gesture_pan))), (self), ((void*) 0), (GConnectFlags) 0) |
465 | G_CALLBACK (ctk_shortcuts_section_pan_gesture_pan), self)g_signal_connect_data ((self->pan_gesture), ("pan"), (((GCallback ) (ctk_shortcuts_section_pan_gesture_pan))), (self), ((void*) 0), (GConnectFlags) 0); |
466 | } |
467 | |
468 | static void |
469 | ctk_shortcuts_section_set_view_name (CtkShortcutsSection *self, |
470 | const gchar *view_name) |
471 | { |
472 | if (g_strcmp0 (self->view_name, view_name) == 0) |
473 | return; |
474 | |
475 | g_free (self->view_name); |
476 | self->view_name = g_strdup (view_name)g_strdup_inline (view_name); |
477 | |
478 | ctk_shortcuts_section_filter_groups (self); |
479 | ctk_shortcuts_section_reflow_groups (self); |
480 | |
481 | g_object_notify_by_pspec (G_OBJECT (self)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), (((GType) ((20) << (2)))))))), properties[PROP_VIEW_NAME]); |
482 | } |
483 | |
484 | static void |
485 | ctk_shortcuts_section_set_max_height (CtkShortcutsSection *self, |
486 | guint max_height) |
487 | { |
488 | if (self->max_height == max_height) |
489 | return; |
490 | |
491 | self->max_height = max_height; |
492 | |
493 | ctk_shortcuts_section_maybe_reflow (self); |
494 | |
495 | g_object_notify_by_pspec (G_OBJECT (self)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), (((GType) ((20) << (2)))))))), properties[PROP_MAX_HEIGHT]); |
496 | } |
497 | |
498 | static void |
499 | ctk_shortcuts_section_add_group (CtkShortcutsSection *self, |
500 | CtkShortcutsGroup *group) |
501 | { |
502 | GList *children; |
503 | CtkWidget *page, *column; |
504 | |
505 | children = ctk_container_get_children (CTK_CONTAINER (self->stack)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_container_get_type ()))))))); |
506 | if (children) |
507 | page = g_list_last (children)->data; |
508 | else |
509 | { |
510 | page = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 22); |
511 | ctk_stack_add_named (self->stack, page, "1"); |
512 | } |
513 | g_list_free (children); |
514 | |
515 | children = ctk_container_get_children (CTK_CONTAINER (page)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page)), ((ctk_container_get_type ()))))))); |
516 | if (children) |
517 | column = g_list_last (children)->data; |
518 | else |
519 | { |
520 | column = ctk_box_new (CTK_ORIENTATION_VERTICAL, 22); |
521 | ctk_container_add (CTK_CONTAINER (page)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page)), ((ctk_container_get_type ())))))), column); |
522 | } |
523 | g_list_free (children); |
524 | |
525 | ctk_container_add (CTK_CONTAINER (column)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), ((ctk_container_get_type ())))))), CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); |
526 | self->groups = g_list_append (self->groups, group); |
527 | |
528 | ctk_shortcuts_section_maybe_reflow (self); |
529 | } |
530 | |
531 | static void |
532 | ctk_shortcuts_section_show_all (CtkShortcutsSection *self) |
533 | { |
534 | ctk_shortcuts_section_set_view_name (self, NULL((void*)0)); |
535 | } |
536 | |
537 | static void |
538 | update_group_visibility (CtkWidget *child, gpointer data) |
539 | { |
540 | CtkShortcutsSection *self = data; |
541 | |
542 | if (CTK_IS_SHORTCUTS_GROUP (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_shortcuts_group_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; }))))) |
543 | { |
544 | gchar *view; |
545 | gboolean match; |
546 | |
547 | g_object_get (child, "view", &view, NULL((void*)0)); |
548 | match = view == NULL((void*)0) || |
549 | self->view_name == NULL((void*)0) || |
550 | strcmp (view, self->view_name) == 0; |
551 | |
552 | ctk_widget_set_visible (child, match); |
553 | self->has_filtered_group |= !match; |
554 | |
555 | g_free (view); |
556 | } |
557 | else if (CTK_IS_CONTAINER (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_container_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; }))))) |
558 | { |
559 | ctk_container_foreach (CTK_CONTAINER (child)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_container_get_type ())))))), update_group_visibility, data); |
560 | } |
561 | } |
562 | |
563 | static void |
564 | ctk_shortcuts_section_filter_groups (CtkShortcutsSection *self) |
565 | { |
566 | self->has_filtered_group = FALSE(0); |
567 | |
568 | ctk_container_foreach (CTK_CONTAINER (self)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_container_get_type ())))))), update_group_visibility, self); |
569 | |
570 | ctk_widget_set_visible (CTK_WIDGET (self->show_all)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->show_all)), ((ctk_widget_get_type ())))))), self->has_filtered_group); |
571 | ctk_widget_set_visible (ctk_widget_get_parent (CTK_WIDGET (self->show_all)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->show_all)), ((ctk_widget_get_type ()))))))), |
572 | ctk_widget_get_visible (CTK_WIDGET (self->show_all)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->show_all)), ((ctk_widget_get_type ()))))))) || |
573 | ctk_widget_get_visible (CTK_WIDGET (self->switcher)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->switcher)), ((ctk_widget_get_type ())))))))); |
574 | } |
575 | |
576 | static void |
577 | ctk_shortcuts_section_maybe_reflow (CtkShortcutsSection *self) |
578 | { |
579 | if (ctk_widget_get_mapped (CTK_WIDGET (self)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_widget_get_type ())))))))) |
580 | ctk_shortcuts_section_reflow_groups (self); |
581 | else |
582 | self->need_reflow = TRUE(!(0)); |
583 | } |
584 | |
585 | static void |
586 | adjust_page_buttons (CtkWidget *widget, |
587 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
588 | { |
589 | CtkWidget *label; |
590 | |
591 | ctk_style_context_add_class (ctk_widget_get_style_context (widget), "circular"); |
592 | |
593 | label = ctk_bin_get_child (CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_bin_get_type ()))))))); |
594 | ctk_label_set_use_underline (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), TRUE(!(0))); |
595 | } |
596 | |
597 | static void |
598 | ctk_shortcuts_section_reflow_groups (CtkShortcutsSection *self) |
599 | { |
600 | GList *pages, *p; |
601 | GList *columns, *c; |
602 | GList *groups, *g; |
603 | GList *children; |
604 | guint n_rows; |
605 | guint n_columns; |
606 | guint n_pages; |
607 | CtkWidget *current_page, *current_column; |
608 | |
609 | /* collect all groups from the current pages */ |
610 | groups = NULL((void*)0); |
611 | pages = ctk_container_get_children (CTK_CONTAINER (self->stack)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_container_get_type ()))))))); |
612 | for (p = pages; p; p = p->next) |
613 | { |
614 | columns = ctk_container_get_children (CTK_CONTAINER (p->data)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((p->data)), ((ctk_container_get_type ()))))))); |
615 | for (c = columns; c; c = c->next) |
616 | { |
617 | children = ctk_container_get_children (CTK_CONTAINER (c->data)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((c->data)), ((ctk_container_get_type ()))))))); |
618 | groups = g_list_concat (groups, children); |
619 | } |
620 | g_list_free (columns); |
621 | } |
622 | g_list_free (pages); |
623 | |
624 | /* create new pages */ |
625 | current_page = NULL((void*)0); |
626 | current_column = NULL((void*)0); |
627 | pages = NULL((void*)0); |
628 | n_rows = 0; |
629 | n_columns = 0; |
630 | n_pages = 0; |
Value stored to 'n_pages' is never read | |
631 | for (g = groups; g; g = g->next) |
632 | { |
633 | CtkShortcutsGroup *group = g->data; |
634 | guint height; |
635 | gboolean visible; |
636 | |
637 | g_object_get (group, |
638 | "visible", &visible, |
639 | "height", &height, |
640 | NULL((void*)0)); |
641 | if (!visible) |
642 | height = 0; |
643 | |
644 | if (current_column == NULL((void*)0) || n_rows + height > self->max_height) |
645 | { |
646 | CtkWidget *column; |
647 | CtkSizeGroup *group; |
648 | |
649 | column = ctk_box_new (CTK_ORIENTATION_VERTICAL, 22); |
650 | ctk_widget_show (column); |
651 | |
652 | group = ctk_size_group_new (CTK_SIZE_GROUP_HORIZONTAL); |
653 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" |
654 | ctk_size_group_set_ignore_hidden (group, TRUE(!(0))); |
655 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop |
656 | g_object_set_data_full (G_OBJECT (column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), (((GType) ((20) << (2)))))))), "accel-size-group", group, g_object_unref); |
657 | |
658 | group = ctk_size_group_new (CTK_SIZE_GROUP_HORIZONTAL); |
659 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" |
660 | ctk_size_group_set_ignore_hidden (group, TRUE(!(0))); |
661 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop |
662 | g_object_set_data_full (G_OBJECT (column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), (((GType) ((20) << (2)))))))), "title-size-group", group, g_object_unref); |
663 | |
664 | if (n_columns % 2 == 0) |
665 | { |
666 | CtkWidget *page; |
667 | |
668 | page = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 22); |
669 | ctk_widget_show (page); |
670 | |
671 | pages = g_list_append (pages, page); |
672 | current_page = page; |
673 | } |
674 | |
675 | ctk_container_add (CTK_CONTAINER (current_page)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_page)), ((ctk_container_get_type ())))))), column); |
676 | current_column = column; |
677 | n_columns += 1; |
678 | n_rows = 0; |
679 | } |
680 | |
681 | n_rows += height; |
682 | |
683 | g_object_set (group, |
684 | "accel-size-group", g_object_get_data (G_OBJECT (current_column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_column)), (((GType) ((20) << (2)))))))), "accel-size-group"), |
685 | "title-size-group", g_object_get_data (G_OBJECT (current_column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_column)), (((GType) ((20) << (2)))))))), "title-size-group"), |
686 | NULL((void*)0)); |
687 | |
688 | g_object_ref (group)((__typeof__ (group)) (g_object_ref) (group)); |
689 | ctk_container_remove (CTK_CONTAINER (ctk_widget_get_parent (CTK_WIDGET (group)))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_widget_get_parent (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((group)), ((ctk_widget_get_type ()))))))) )), ((ctk_container_get_type ())))))), CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); |
690 | ctk_container_add (CTK_CONTAINER (current_column)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_column)), ((ctk_container_get_type ())))))), CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); |
691 | g_object_unref (group); |
692 | } |
693 | |
694 | /* balance the last page */ |
695 | if (n_columns % 2 == 1) |
696 | { |
697 | CtkWidget *column; |
698 | CtkSizeGroup *group; |
699 | GList *content; |
700 | guint n; |
701 | |
702 | column = ctk_box_new (CTK_ORIENTATION_VERTICAL, 22); |
703 | ctk_widget_show (column); |
704 | |
705 | group = ctk_size_group_new (CTK_SIZE_GROUP_HORIZONTAL); |
706 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" |
707 | ctk_size_group_set_ignore_hidden (group, TRUE(!(0))); |
708 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop |
709 | g_object_set_data_full (G_OBJECT (column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), (((GType) ((20) << (2)))))))), "accel-size-group", group, g_object_unref); |
710 | group = ctk_size_group_new (CTK_SIZE_GROUP_HORIZONTAL); |
711 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" |
712 | ctk_size_group_set_ignore_hidden (group, TRUE(!(0))); |
713 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop |
714 | g_object_set_data_full (G_OBJECT (column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), (((GType) ((20) << (2)))))))), "title-size-group", group, g_object_unref); |
715 | |
716 | ctk_container_add (CTK_CONTAINER (current_page)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_page)), ((ctk_container_get_type ())))))), column); |
717 | |
718 | content = ctk_container_get_children (CTK_CONTAINER (current_column)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_column)), ((ctk_container_get_type ()))))))); |
719 | n = 0; |
720 | |
721 | for (g = g_list_last (content); g; g = g->prev) |
722 | { |
723 | CtkShortcutsGroup *group = g->data; |
724 | guint height; |
725 | gboolean visible; |
726 | |
727 | g_object_get (group, |
728 | "visible", &visible, |
729 | "height", &height, |
730 | NULL((void*)0)); |
731 | if (!visible) |
732 | height = 0; |
733 | |
734 | if (n_rows - height == 0) |
735 | break; |
736 | if (ABS (n_rows - n)(((n_rows - n) < 0) ? -(n_rows - n) : (n_rows - n)) < ABS ((n_rows - height) - (n + height))((((n_rows - height) - (n + height)) < 0) ? -((n_rows - height ) - (n + height)) : ((n_rows - height) - (n + height)))) |
737 | break; |
738 | |
739 | n_rows -= height; |
740 | n += height; |
741 | } |
742 | |
743 | for (g = g->next; g; g = g->next) |
744 | { |
745 | CtkShortcutsGroup *group = g->data; |
746 | |
747 | g_object_set (group, |
748 | "accel-size-group", g_object_get_data (G_OBJECT (column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), (((GType) ((20) << (2)))))))), "accel-size-group"), |
749 | "title-size-group", g_object_get_data (G_OBJECT (column)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), (((GType) ((20) << (2)))))))), "title-size-group"), |
750 | NULL((void*)0)); |
751 | |
752 | g_object_ref (group)((__typeof__ (group)) (g_object_ref) (group)); |
753 | ctk_container_remove (CTK_CONTAINER (current_column)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_column)), ((ctk_container_get_type ())))))), CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); |
754 | ctk_container_add (CTK_CONTAINER (column)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), ((ctk_container_get_type ())))))), CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); |
755 | g_object_unref (group); |
756 | } |
757 | |
758 | g_list_free (content); |
759 | } |
760 | |
761 | /* replace the current pages with the new pages */ |
762 | children = ctk_container_get_children (CTK_CONTAINER (self->stack)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_container_get_type ()))))))); |
763 | g_list_free_full (children, (GDestroyNotify)ctk_widget_destroy); |
764 | |
765 | for (p = pages, n_pages = 0; p; p = p->next, n_pages++) |
766 | { |
767 | CtkWidget *page = p->data; |
768 | gchar *title; |
769 | |
770 | title = g_strdup_printf ("_%u", n_pages + 1); |
771 | ctk_stack_add_titled (self->stack, page, title, title); |
772 | g_free (title); |
773 | } |
774 | |
775 | /* fix up stack switcher */ |
776 | ctk_container_foreach (CTK_CONTAINER (self->switcher)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->switcher)), ((ctk_container_get_type ())))))), adjust_page_buttons, NULL((void*)0)); |
777 | ctk_widget_set_visible (CTK_WIDGET (self->switcher)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->switcher)), ((ctk_widget_get_type ())))))), (n_pages > 1)); |
778 | ctk_widget_set_visible (ctk_widget_get_parent (CTK_WIDGET (self->switcher)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->switcher)), ((ctk_widget_get_type ()))))))), |
779 | ctk_widget_get_visible (CTK_WIDGET (self->show_all)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->show_all)), ((ctk_widget_get_type ()))))))) || |
780 | ctk_widget_get_visible (CTK_WIDGET (self->switcher)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->switcher)), ((ctk_widget_get_type ())))))))); |
781 | |
782 | /* clean up */ |
783 | g_list_free (groups); |
784 | g_list_free (pages); |
785 | |
786 | self->need_reflow = FALSE(0); |
787 | } |
788 | |
789 | static gboolean |
790 | ctk_shortcuts_section_change_current_page (CtkShortcutsSection *self, |
791 | gint offset) |
792 | { |
793 | CtkWidget *child; |
794 | GList *children, *l; |
795 | |
796 | child = ctk_stack_get_visible_child (self->stack); |
797 | children = ctk_container_get_children (CTK_CONTAINER (self->stack)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self->stack)), ((ctk_container_get_type ()))))))); |
798 | l = g_list_find (children, child); |
799 | |
800 | if (offset == 1) |
801 | l = l->next; |
802 | else if (offset == -1) |
803 | l = l->prev; |
804 | else |
805 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkshortcutssection.c" , 805, ((const char*) (__func__)), ((void*)0)); } while (0); |
806 | |
807 | if (l) |
808 | ctk_stack_set_visible_child (self->stack, CTK_WIDGET (l->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_widget_get_type ()))))))); |
809 | else |
810 | ctk_widget_error_bell (CTK_WIDGET (self)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((self)), ((ctk_widget_get_type ()))))))); |
811 | |
812 | g_list_free (children); |
813 | |
814 | return TRUE(!(0)); |
815 | } |
816 | |
817 | static void |
818 | ctk_shortcuts_section_pan_gesture_pan (CtkGesturePan *gesture, |
819 | CtkPanDirection direction, |
820 | gdouble offset, |
821 | CtkShortcutsSection *self) |
822 | { |
823 | if (offset < 50) |
824 | return; |
825 | |
826 | if (direction == CTK_PAN_DIRECTION_LEFT) |
827 | ctk_shortcuts_section_change_current_page (self, 1); |
828 | else if (direction == CTK_PAN_DIRECTION_RIGHT) |
829 | ctk_shortcuts_section_change_current_page (self, -1); |
830 | else |
831 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkshortcutssection.c" , 831, ((const char*) (__func__)), ((void*)0)); } while (0); |
832 | |
833 | ctk_gesture_set_state (CTK_GESTURE (gesture)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), ((ctk_gesture_get_type ())))))), CTK_EVENT_SEQUENCE_DENIED); |
834 | } |