File: | ctk/ctktoolitemgroup.c |
Warning: | line 1003, column 43 Division by zero |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* CtkToolPalette -- A tool palette with categories and DnD support | |||
2 | * Copyright (C) 2008 Openismus GmbH | |||
3 | * | |||
4 | * This library is free software; you can redistribute it and/or | |||
5 | * modify it under the terms of the GNU Lesser General Public | |||
6 | * License as published by the Free Software Foundation; either | |||
7 | * version 2.1 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 | * Lesser General Public License for more details. | |||
13 | * | |||
14 | * You should have received a copy of the GNU Lesser General Public | |||
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | |||
16 | * | |||
17 | * Authors: | |||
18 | * Mathias Hasselmann | |||
19 | * Jan Arne Petersen | |||
20 | */ | |||
21 | ||||
22 | #include "config.h" | |||
23 | ||||
24 | #include <math.h> | |||
25 | #include <string.h> | |||
26 | ||||
27 | #include "ctktoolpaletteprivate.h" | |||
28 | #include "ctktypebuiltins.h" | |||
29 | #include "ctkprivate.h" | |||
30 | #include "ctkintl.h" | |||
31 | #include "ctkcssnodeprivate.h" | |||
32 | #include "ctkstylecontextprivate.h" | |||
33 | #include "ctkwidgetprivate.h" | |||
34 | ||||
35 | ||||
36 | #define ANIMATION_TIMEOUT50 50 | |||
37 | #define ANIMATION_DURATION(50 * 4) (ANIMATION_TIMEOUT50 * 4) | |||
38 | #define DEFAULT_ANIMATION_STATE(!(0)) TRUE(!(0)) | |||
39 | #define DEFAULT_EXPANDER_SIZE16 16 | |||
40 | #define DEFAULT_HEADER_SPACING2 2 | |||
41 | ||||
42 | #define DEFAULT_LABEL"" "" | |||
43 | #define DEFAULT_COLLAPSED(0) FALSE(0) | |||
44 | #define DEFAULT_ELLIPSIZEPANGO_ELLIPSIZE_NONE PANGO_ELLIPSIZE_NONE | |||
45 | ||||
46 | /** | |||
47 | * SECTION:ctktoolitemgroup | |||
48 | * @Short_description: A sub container used in a tool palette | |||
49 | * @Title: CtkToolItemGroup | |||
50 | * | |||
51 | * A #CtkToolItemGroup is used together with #CtkToolPalette to add | |||
52 | * #CtkToolItems to a palette like container with different | |||
53 | * categories and drag and drop support. | |||
54 | * | |||
55 | * # CSS nodes | |||
56 | * | |||
57 | * CtkToolItemGroup has a single CSS node named toolitemgroup. | |||
58 | * | |||
59 | * Since: 2.20 | |||
60 | */ | |||
61 | ||||
62 | enum | |||
63 | { | |||
64 | PROP_NONE, | |||
65 | PROP_LABEL, | |||
66 | PROP_LABEL_WIDGET, | |||
67 | PROP_COLLAPSED, | |||
68 | PROP_ELLIPSIZE, | |||
69 | PROP_RELIEF | |||
70 | }; | |||
71 | ||||
72 | enum | |||
73 | { | |||
74 | CHILD_PROP_NONE, | |||
75 | CHILD_PROP_HOMOGENEOUS, | |||
76 | CHILD_PROP_EXPAND, | |||
77 | CHILD_PROP_FILL, | |||
78 | CHILD_PROP_NEW_ROW, | |||
79 | CHILD_PROP_POSITION, | |||
80 | }; | |||
81 | ||||
82 | typedef struct _CtkToolItemGroupChild CtkToolItemGroupChild; | |||
83 | ||||
84 | struct _CtkToolItemGroupPrivate | |||
85 | { | |||
86 | CtkWidget *header; | |||
87 | CtkWidget *label_widget; | |||
88 | ||||
89 | CtkCssNode *arrow_node; | |||
90 | ||||
91 | GList *children; | |||
92 | ||||
93 | gint64 animation_start; | |||
94 | GSource *animation_timeout; | |||
95 | gint expander_size; | |||
96 | gint header_spacing; | |||
97 | ||||
98 | gulong focus_set_id; | |||
99 | CtkWidget *toplevel; | |||
100 | ||||
101 | CtkSettings *settings; | |||
102 | gulong settings_connection; | |||
103 | ||||
104 | PangoEllipsizeMode ellipsize; | |||
105 | ||||
106 | guint animation : 1; | |||
107 | guint collapsed : 1; | |||
108 | }; | |||
109 | ||||
110 | struct _CtkToolItemGroupChild | |||
111 | { | |||
112 | CtkToolItem *item; | |||
113 | ||||
114 | guint homogeneous : 1; | |||
115 | guint expand : 1; | |||
116 | guint fill : 1; | |||
117 | guint new_row : 1; | |||
118 | }; | |||
119 | ||||
120 | static void ctk_tool_item_group_tool_shell_init (CtkToolShellIface *iface); | |||
121 | ||||
122 | G_DEFINE_TYPE_WITH_CODE (CtkToolItemGroup, ctk_tool_item_group, CTK_TYPE_CONTAINER,static void ctk_tool_item_group_init (CtkToolItemGroup *self) ; static void ctk_tool_item_group_class_init (CtkToolItemGroupClass *klass); static GType ctk_tool_item_group_get_type_once (void ); static gpointer ctk_tool_item_group_parent_class = ((void* )0); static gint CtkToolItemGroup_private_offset; static void ctk_tool_item_group_class_intern_init (gpointer klass) { ctk_tool_item_group_parent_class = g_type_class_peek_parent (klass); if (CtkToolItemGroup_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolItemGroup_private_offset ); ctk_tool_item_group_class_init ((CtkToolItemGroupClass*) klass ); } __attribute__ ((__unused__)) static inline gpointer ctk_tool_item_group_get_instance_private (CtkToolItemGroup *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolItemGroup_private_offset)))); } GType ctk_tool_item_group_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_tool_item_group_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_tool_item_group_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolItemGroup" ), sizeof (CtkToolItemGroupClass), (GClassInitFunc)(void (*)( void)) ctk_tool_item_group_class_intern_init, sizeof (CtkToolItemGroup ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_item_group_init , (GTypeFlags) 0); { {{ CtkToolItemGroup_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolItemGroupPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_tool_item_group_tool_shell_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_tool_shell_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
123 | G_ADD_PRIVATE (CtkToolItemGroup)static void ctk_tool_item_group_init (CtkToolItemGroup *self) ; static void ctk_tool_item_group_class_init (CtkToolItemGroupClass *klass); static GType ctk_tool_item_group_get_type_once (void ); static gpointer ctk_tool_item_group_parent_class = ((void* )0); static gint CtkToolItemGroup_private_offset; static void ctk_tool_item_group_class_intern_init (gpointer klass) { ctk_tool_item_group_parent_class = g_type_class_peek_parent (klass); if (CtkToolItemGroup_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolItemGroup_private_offset ); ctk_tool_item_group_class_init ((CtkToolItemGroupClass*) klass ); } __attribute__ ((__unused__)) static inline gpointer ctk_tool_item_group_get_instance_private (CtkToolItemGroup *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolItemGroup_private_offset)))); } GType ctk_tool_item_group_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_tool_item_group_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_tool_item_group_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolItemGroup" ), sizeof (CtkToolItemGroupClass), (GClassInitFunc)(void (*)( void)) ctk_tool_item_group_class_intern_init, sizeof (CtkToolItemGroup ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_item_group_init , (GTypeFlags) 0); { {{ CtkToolItemGroup_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolItemGroupPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_tool_item_group_tool_shell_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_tool_shell_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
124 | G_IMPLEMENT_INTERFACE (CTK_TYPE_TOOL_SHELL,static void ctk_tool_item_group_init (CtkToolItemGroup *self) ; static void ctk_tool_item_group_class_init (CtkToolItemGroupClass *klass); static GType ctk_tool_item_group_get_type_once (void ); static gpointer ctk_tool_item_group_parent_class = ((void* )0); static gint CtkToolItemGroup_private_offset; static void ctk_tool_item_group_class_intern_init (gpointer klass) { ctk_tool_item_group_parent_class = g_type_class_peek_parent (klass); if (CtkToolItemGroup_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolItemGroup_private_offset ); ctk_tool_item_group_class_init ((CtkToolItemGroupClass*) klass ); } __attribute__ ((__unused__)) static inline gpointer ctk_tool_item_group_get_instance_private (CtkToolItemGroup *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolItemGroup_private_offset)))); } GType ctk_tool_item_group_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_tool_item_group_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_tool_item_group_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolItemGroup" ), sizeof (CtkToolItemGroupClass), (GClassInitFunc)(void (*)( void)) ctk_tool_item_group_class_intern_init, sizeof (CtkToolItemGroup ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_item_group_init , (GTypeFlags) 0); { {{ CtkToolItemGroup_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolItemGroupPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_tool_item_group_tool_shell_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_tool_shell_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
125 | ctk_tool_item_group_tool_shell_init))static void ctk_tool_item_group_init (CtkToolItemGroup *self) ; static void ctk_tool_item_group_class_init (CtkToolItemGroupClass *klass); static GType ctk_tool_item_group_get_type_once (void ); static gpointer ctk_tool_item_group_parent_class = ((void* )0); static gint CtkToolItemGroup_private_offset; static void ctk_tool_item_group_class_intern_init (gpointer klass) { ctk_tool_item_group_parent_class = g_type_class_peek_parent (klass); if (CtkToolItemGroup_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToolItemGroup_private_offset ); ctk_tool_item_group_class_init ((CtkToolItemGroupClass*) klass ); } __attribute__ ((__unused__)) static inline gpointer ctk_tool_item_group_get_instance_private (CtkToolItemGroup *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkToolItemGroup_private_offset)))); } GType ctk_tool_item_group_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_tool_item_group_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_tool_item_group_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type ()), g_intern_static_string ("CtkToolItemGroup" ), sizeof (CtkToolItemGroupClass), (GClassInitFunc)(void (*)( void)) ctk_tool_item_group_class_intern_init, sizeof (CtkToolItemGroup ), (GInstanceInitFunc)(void (*)(void)) ctk_tool_item_group_init , (GTypeFlags) 0); { {{ CtkToolItemGroup_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToolItemGroupPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) ctk_tool_item_group_tool_shell_init, ((void *)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_tool_shell_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; }; | |||
126 | ||||
127 | static CtkWidget* | |||
128 | ctk_tool_item_group_get_alignment (CtkToolItemGroup *group) | |||
129 | { | |||
130 | return ctk_bin_get_child (CTK_BIN (group->priv->header)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->priv->header)), ((ctk_bin_get_type ()))))))); | |||
131 | } | |||
132 | ||||
133 | static CtkOrientation | |||
134 | ctk_tool_item_group_get_orientation (CtkToolShell *shell) | |||
135 | { | |||
136 | CtkWidget *parent = ctk_widget_get_parent (CTK_WIDGET (shell)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((shell)), ((ctk_widget_get_type ()))))))); | |||
137 | ||||
138 | if (CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; }))))) | |||
139 | return ctk_orientable_get_orientation (CTK_ORIENTABLE (parent)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_orientable_get_type ()))))))); | |||
140 | ||||
141 | return CTK_ORIENTATION_VERTICAL; | |||
142 | } | |||
143 | ||||
144 | static CtkToolbarStyle | |||
145 | ctk_tool_item_group_get_style (CtkToolShell *shell) | |||
146 | { | |||
147 | CtkWidget *parent = ctk_widget_get_parent (CTK_WIDGET (shell)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((shell)), ((ctk_widget_get_type ()))))))); | |||
148 | ||||
149 | if (CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; }))))) | |||
150 | return ctk_tool_palette_get_style (CTK_TOOL_PALETTE (parent)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (parent), ((ctk_tool_palette_get_type ()))))))); | |||
151 | ||||
152 | return CTK_TOOLBAR_ICONS; | |||
153 | } | |||
154 | ||||
155 | static CtkIconSize | |||
156 | ctk_tool_item_group_get_icon_size (CtkToolShell *shell) | |||
157 | { | |||
158 | CtkWidget *parent = ctk_widget_get_parent (CTK_WIDGET (shell)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((shell)), ((ctk_widget_get_type ()))))))); | |||
159 | ||||
160 | if (CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; }))))) | |||
161 | return ctk_tool_palette_get_icon_size (CTK_TOOL_PALETTE (parent)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (parent), ((ctk_tool_palette_get_type ()))))))); | |||
162 | ||||
163 | return CTK_ICON_SIZE_SMALL_TOOLBAR; | |||
164 | } | |||
165 | ||||
166 | static PangoEllipsizeMode | |||
167 | ctk_tool_item_group_get_ellipsize_mode (CtkToolShell *shell) | |||
168 | { | |||
169 | return CTK_TOOL_ITEM_GROUP (shell)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (shell), ((ctk_tool_item_group_get_type ()))) )))->priv->ellipsize; | |||
170 | } | |||
171 | ||||
172 | static gfloat | |||
173 | ctk_tool_item_group_get_text_alignment (CtkToolShell *shell) | |||
174 | { | |||
175 | if (CTK_TOOLBAR_TEXT == ctk_tool_item_group_get_style (shell) || | |||
176 | CTK_TOOLBAR_BOTH_HORIZ == ctk_tool_item_group_get_style (shell)) | |||
177 | return 0.0; | |||
178 | ||||
179 | return 0.5; | |||
180 | } | |||
181 | ||||
182 | static CtkOrientation | |||
183 | ctk_tool_item_group_get_text_orientation (CtkToolShell *shell G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
184 | { | |||
185 | return CTK_ORIENTATION_HORIZONTAL; | |||
186 | } | |||
187 | ||||
188 | static CtkSizeGroup * | |||
189 | ctk_tool_item_group_get_text_size_group (CtkToolShell *shell) | |||
190 | { | |||
191 | CtkWidget *parent = ctk_widget_get_parent (CTK_WIDGET (shell)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((shell)), ((ctk_widget_get_type ()))))))); | |||
192 | ||||
193 | if (CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; }))))) | |||
194 | return _ctk_tool_palette_get_size_group (CTK_TOOL_PALETTE (parent)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (parent), ((ctk_tool_palette_get_type ()))))))); | |||
195 | ||||
196 | return NULL((void*)0); | |||
197 | } | |||
198 | ||||
199 | static void | |||
200 | animation_change_notify (CtkToolItemGroup *group) | |||
201 | { | |||
202 | CtkSettings *settings = group->priv->settings; | |||
203 | gboolean animation; | |||
204 | ||||
205 | if (settings) | |||
206 | g_object_get (settings, | |||
207 | "ctk-enable-animations", &animation, | |||
208 | NULL((void*)0)); | |||
209 | else | |||
210 | animation = DEFAULT_ANIMATION_STATE(!(0)); | |||
211 | ||||
212 | group->priv->animation = animation; | |||
213 | } | |||
214 | ||||
215 | static void | |||
216 | ctk_tool_item_group_settings_change_notify (CtkSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
217 | const GParamSpec *pspec, | |||
218 | CtkToolItemGroup *group) | |||
219 | { | |||
220 | if (strcmp (pspec->name, "ctk-enable-animations") == 0) | |||
221 | animation_change_notify (group); | |||
222 | } | |||
223 | ||||
224 | static void | |||
225 | ctk_tool_item_group_screen_changed (CtkWidget *widget, | |||
226 | CdkScreen *previous_screen G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
227 | { | |||
228 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))); | |||
229 | CtkToolItemGroupPrivate* priv = group->priv; | |||
230 | CtkSettings *old_settings = priv->settings; | |||
231 | CtkSettings *settings; | |||
232 | ||||
233 | if (ctk_widget_has_screen (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))))) | |||
234 | settings = ctk_widget_get_settings (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
235 | else | |||
236 | settings = NULL((void*)0); | |||
237 | ||||
238 | if (settings == old_settings) | |||
239 | return; | |||
240 | ||||
241 | if (old_settings) | |||
242 | { | |||
243 | g_signal_handler_disconnect (old_settings, priv->settings_connection); | |||
244 | priv->settings_connection = 0; | |||
245 | g_object_unref (old_settings); | |||
246 | } | |||
247 | ||||
248 | if (settings) | |||
249 | { | |||
250 | priv->settings_connection = | |||
251 | g_signal_connect (settings, "notify",g_signal_connect_data ((settings), ("notify"), (((GCallback) ( ctk_tool_item_group_settings_change_notify))), (group), ((void *)0), (GConnectFlags) 0) | |||
252 | G_CALLBACK (ctk_tool_item_group_settings_change_notify),g_signal_connect_data ((settings), ("notify"), (((GCallback) ( ctk_tool_item_group_settings_change_notify))), (group), ((void *)0), (GConnectFlags) 0) | |||
253 | group)g_signal_connect_data ((settings), ("notify"), (((GCallback) ( ctk_tool_item_group_settings_change_notify))), (group), ((void *)0), (GConnectFlags) 0); | |||
254 | priv->settings = g_object_ref (settings)((__typeof__ (settings)) (g_object_ref) (settings)); | |||
255 | } | |||
256 | else | |||
257 | priv->settings = NULL((void*)0); | |||
258 | ||||
259 | animation_change_notify (group); | |||
260 | } | |||
261 | ||||
262 | static void | |||
263 | ctk_tool_item_group_tool_shell_init (CtkToolShellIface *iface) | |||
264 | { | |||
265 | iface->get_icon_size = ctk_tool_item_group_get_icon_size; | |||
266 | iface->get_orientation = ctk_tool_item_group_get_orientation; | |||
267 | iface->get_style = ctk_tool_item_group_get_style; | |||
268 | iface->get_text_alignment = ctk_tool_item_group_get_text_alignment; | |||
269 | iface->get_text_orientation = ctk_tool_item_group_get_text_orientation; | |||
270 | iface->get_text_size_group = ctk_tool_item_group_get_text_size_group; | |||
271 | iface->get_ellipsize_mode = ctk_tool_item_group_get_ellipsize_mode; | |||
272 | } | |||
273 | ||||
274 | static gboolean | |||
275 | ctk_tool_item_group_header_draw_cb (CtkWidget *widget, | |||
276 | cairo_t *cr, | |||
277 | gpointer data) | |||
278 | { | |||
279 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (data)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (data), ((ctk_tool_item_group_get_type ())))) )); | |||
280 | CtkToolItemGroupPrivate* priv = group->priv; | |||
281 | CtkOrientation orientation; | |||
282 | gint x, y, width, height; | |||
283 | CtkTextDirection direction; | |||
284 | CtkStyleContext *context; | |||
285 | ||||
286 | orientation = ctk_tool_shell_get_orientation (CTK_TOOL_SHELL (group)((((CtkToolShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_tool_shell_get_type ()))))))); | |||
287 | direction = ctk_widget_get_direction (widget); | |||
288 | width = ctk_widget_get_allocated_width (widget); | |||
289 | height = ctk_widget_get_allocated_height (widget); | |||
290 | context = ctk_widget_get_style_context (widget); | |||
291 | ||||
292 | ctk_style_context_save_to_node (context, priv->arrow_node); | |||
293 | ||||
294 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
295 | { | |||
296 | ctk_style_context_add_class (context, CTK_STYLE_CLASS_VERTICAL"vertical"); | |||
297 | ||||
298 | if (CTK_TEXT_DIR_RTL == direction) | |||
299 | x = width; | |||
300 | else | |||
301 | x = 0; | |||
302 | ||||
303 | y = height / 2 - priv->expander_size / 2; | |||
304 | } | |||
305 | else | |||
306 | { | |||
307 | ctk_style_context_add_class (context, CTK_STYLE_CLASS_HORIZONTAL"horizontal"); | |||
308 | x = width / 2 - priv->expander_size / 2; | |||
309 | y = 0; | |||
310 | } | |||
311 | ||||
312 | ctk_render_expander (context, cr, x, y, | |||
313 | priv->expander_size, | |||
314 | priv->expander_size); | |||
315 | ||||
316 | ctk_style_context_restore (context); | |||
317 | ||||
318 | return FALSE(0); | |||
319 | } | |||
320 | ||||
321 | static void | |||
322 | ctk_tool_item_group_header_clicked_cb (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
323 | gpointer data) | |||
324 | { | |||
325 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (data)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (data), ((ctk_tool_item_group_get_type ())))) )); | |||
326 | CtkToolItemGroupPrivate* priv = group->priv; | |||
327 | CtkWidget *parent = ctk_widget_get_parent (data); | |||
328 | ||||
329 | if (priv->collapsed || | |||
330 | !CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; })))) || | |||
331 | !ctk_tool_palette_get_exclusive (CTK_TOOL_PALETTE (parent)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (parent), ((ctk_tool_palette_get_type ())))))), data)) | |||
332 | ctk_tool_item_group_set_collapsed (group, !priv->collapsed); | |||
333 | } | |||
334 | ||||
335 | static void | |||
336 | ctk_tool_item_group_header_adjust_style (CtkToolItemGroup *group) | |||
337 | { | |||
338 | CtkWidget *alignment = ctk_tool_item_group_get_alignment (group); | |||
339 | CtkWidget *label_widget = ctk_bin_get_child (CTK_BIN (alignment)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((alignment)), ((ctk_bin_get_type ()))))))); | |||
340 | CtkWidget *widget = CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))); | |||
341 | CtkToolItemGroupPrivate* priv = group->priv; | |||
342 | gint dx = 0, dy = 0; | |||
343 | CtkTextDirection direction = ctk_widget_get_direction (widget); | |||
344 | ||||
345 | ctk_widget_style_get (widget, | |||
346 | "header-spacing", &(priv->header_spacing), | |||
347 | "expander-size", &(priv->expander_size), | |||
348 | NULL((void*)0)); | |||
349 | ||||
350 | ctk_widget_set_size_request (alignment, -1, priv->expander_size); | |||
351 | ||||
352 | switch (ctk_tool_shell_get_orientation (CTK_TOOL_SHELL (group)((((CtkToolShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_tool_shell_get_type ())))))))) | |||
353 | { | |||
354 | case CTK_ORIENTATION_HORIZONTAL: | |||
355 | dy = priv->header_spacing + priv->expander_size; | |||
356 | ||||
357 | if (CTK_IS_LABEL (label_widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (label_widget)); GType __t = ((ctk_label_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; }))))) | |||
358 | { | |||
359 | ctk_label_set_ellipsize (CTK_LABEL (label_widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label_widget)), ((ctk_label_get_type ())))))), PANGO_ELLIPSIZE_NONE); | |||
360 | if (CTK_TEXT_DIR_RTL == direction) | |||
361 | ctk_label_set_angle (CTK_LABEL (label_widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label_widget)), ((ctk_label_get_type ())))))), -90); | |||
362 | else | |||
363 | ctk_label_set_angle (CTK_LABEL (label_widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label_widget)), ((ctk_label_get_type ())))))), 90); | |||
364 | } | |||
365 | break; | |||
366 | ||||
367 | case CTK_ORIENTATION_VERTICAL: | |||
368 | dx = priv->header_spacing + priv->expander_size; | |||
369 | ||||
370 | if (CTK_IS_LABEL (label_widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (label_widget)); GType __t = ((ctk_label_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; }))))) | |||
371 | { | |||
372 | ctk_label_set_ellipsize (CTK_LABEL (label_widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label_widget)), ((ctk_label_get_type ())))))), priv->ellipsize); | |||
373 | ctk_label_set_angle (CTK_LABEL (label_widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label_widget)), ((ctk_label_get_type ())))))), 0); | |||
374 | } | |||
375 | break; | |||
376 | } | |||
377 | ||||
378 | ctk_alignment_set_padding (CTK_ALIGNMENT (alignment)((((CtkAlignment*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((alignment)), ((ctk_alignment_get_type ())))))), dy, 0, dx, 0); | |||
379 | } | |||
380 | ||||
381 | static void | |||
382 | update_arrow_state (CtkToolItemGroup *group) | |||
383 | { | |||
384 | CtkToolItemGroupPrivate *priv = group->priv; | |||
385 | CtkStateFlags state; | |||
386 | ||||
387 | state = ctk_widget_get_state_flags (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
388 | ||||
389 | if (priv->collapsed) | |||
390 | state &= ~CTK_STATE_FLAG_CHECKED; | |||
391 | else | |||
392 | state |= CTK_STATE_FLAG_CHECKED; | |||
393 | ctk_css_node_set_state (priv->arrow_node, state); | |||
394 | } | |||
395 | ||||
396 | static void | |||
397 | ctk_tool_item_group_init (CtkToolItemGroup *group) | |||
398 | { | |||
399 | CtkWidget *alignment; | |||
400 | CtkToolItemGroupPrivate* priv; | |||
401 | CtkCssNode *widget_node; | |||
402 | ||||
403 | group->priv = priv = ctk_tool_item_group_get_instance_private (group); | |||
404 | ||||
405 | priv->children = NULL((void*)0); | |||
406 | priv->header_spacing = DEFAULT_HEADER_SPACING2; | |||
407 | priv->expander_size = DEFAULT_EXPANDER_SIZE16; | |||
408 | priv->collapsed = DEFAULT_COLLAPSED(0); | |||
409 | ||||
410 | priv->label_widget = ctk_label_new (NULL((void*)0)); | |||
411 | ctk_widget_set_halign (priv->label_widget, CTK_ALIGN_START); | |||
412 | ctk_widget_set_valign (priv->label_widget, CTK_ALIGN_CENTER); | |||
413 | ||||
414 | alignment = ctk_alignment_new (0.5, 0.5, 1.0, 1.0); | |||
415 | ||||
416 | ctk_container_add (CTK_CONTAINER (alignment)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((alignment)), ((ctk_container_get_type ())))))), priv->label_widget); | |||
417 | ctk_widget_show_all (alignment); | |||
418 | ||||
419 | priv->header = ctk_button_new (); | |||
420 | g_object_ref_sink (priv->header)((__typeof__ (priv->header)) (g_object_ref_sink) (priv-> header)); | |||
421 | ctk_widget_set_focus_on_click (priv->header, FALSE(0)); | |||
422 | ctk_container_add (CTK_CONTAINER (priv->header)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->header)), ((ctk_container_get_type ())))))), alignment); | |||
423 | ctk_widget_set_parent (priv->header, CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
424 | ||||
425 | ctk_tool_item_group_header_adjust_style (group); | |||
426 | ||||
427 | g_signal_connect_after (alignment, "draw",g_signal_connect_data ((alignment), ("draw"), (((GCallback) ( ctk_tool_item_group_header_draw_cb))), (group), ((void*)0), G_CONNECT_AFTER ) | |||
428 | G_CALLBACK (ctk_tool_item_group_header_draw_cb),g_signal_connect_data ((alignment), ("draw"), (((GCallback) ( ctk_tool_item_group_header_draw_cb))), (group), ((void*)0), G_CONNECT_AFTER ) | |||
429 | group)g_signal_connect_data ((alignment), ("draw"), (((GCallback) ( ctk_tool_item_group_header_draw_cb))), (group), ((void*)0), G_CONNECT_AFTER ); | |||
430 | ||||
431 | g_signal_connect (priv->header, "clicked",g_signal_connect_data ((priv->header), ("clicked"), (((GCallback ) (ctk_tool_item_group_header_clicked_cb))), (group), ((void* )0), (GConnectFlags) 0) | |||
432 | G_CALLBACK (ctk_tool_item_group_header_clicked_cb),g_signal_connect_data ((priv->header), ("clicked"), (((GCallback ) (ctk_tool_item_group_header_clicked_cb))), (group), ((void* )0), (GConnectFlags) 0) | |||
433 | group)g_signal_connect_data ((priv->header), ("clicked"), (((GCallback ) (ctk_tool_item_group_header_clicked_cb))), (group), ((void* )0), (GConnectFlags) 0); | |||
434 | ||||
435 | widget_node = ctk_widget_get_css_node (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
436 | priv->arrow_node = ctk_css_node_new (); | |||
437 | ctk_css_node_set_name (priv->arrow_node, I_("arrow")g_intern_static_string ("arrow")); | |||
438 | ctk_css_node_set_parent (priv->arrow_node, widget_node); | |||
439 | ctk_css_node_set_state (priv->arrow_node, ctk_css_node_get_state (widget_node)); | |||
440 | g_object_unref (priv->arrow_node); | |||
441 | ||||
442 | update_arrow_state (group); | |||
443 | } | |||
444 | ||||
445 | static void | |||
446 | ctk_tool_item_group_set_property (GObject *object, | |||
447 | guint prop_id, | |||
448 | const GValue *value, | |||
449 | GParamSpec *pspec) | |||
450 | { | |||
451 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (object)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (object), ((ctk_tool_item_group_get_type ())) )))); | |||
452 | ||||
453 | switch (prop_id) | |||
454 | { | |||
455 | case PROP_LABEL: | |||
456 | ctk_tool_item_group_set_label (group, g_value_get_string (value)); | |||
457 | break; | |||
458 | ||||
459 | case PROP_LABEL_WIDGET: | |||
460 | ctk_tool_item_group_set_label_widget (group, g_value_get_object (value)); | |||
461 | break; | |||
462 | ||||
463 | case PROP_COLLAPSED: | |||
464 | ctk_tool_item_group_set_collapsed (group, g_value_get_boolean (value)); | |||
465 | break; | |||
466 | ||||
467 | case PROP_ELLIPSIZE: | |||
468 | ctk_tool_item_group_set_ellipsize (group, g_value_get_enum (value)); | |||
469 | break; | |||
470 | ||||
471 | case PROP_RELIEF: | |||
472 | ctk_tool_item_group_set_header_relief (group, g_value_get_enum(value)); | |||
473 | break; | |||
474 | ||||
475 | default: | |||
476 | 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'" , "ctktoolitemgroup.c", 476, ("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); | |||
477 | break; | |||
478 | } | |||
479 | } | |||
480 | ||||
481 | static void | |||
482 | ctk_tool_item_group_get_property (GObject *object, | |||
483 | guint prop_id, | |||
484 | GValue *value, | |||
485 | GParamSpec *pspec) | |||
486 | { | |||
487 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (object)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (object), ((ctk_tool_item_group_get_type ())) )))); | |||
488 | ||||
489 | switch (prop_id) | |||
490 | { | |||
491 | case PROP_LABEL: | |||
492 | g_value_set_string (value, ctk_tool_item_group_get_label (group)); | |||
493 | break; | |||
494 | ||||
495 | case PROP_LABEL_WIDGET: | |||
496 | g_value_set_object (value, | |||
497 | ctk_tool_item_group_get_label_widget (group)); | |||
498 | break; | |||
499 | ||||
500 | case PROP_COLLAPSED: | |||
501 | g_value_set_boolean (value, ctk_tool_item_group_get_collapsed (group)); | |||
502 | break; | |||
503 | ||||
504 | case PROP_ELLIPSIZE: | |||
505 | g_value_set_enum (value, ctk_tool_item_group_get_ellipsize (group)); | |||
506 | break; | |||
507 | ||||
508 | case PROP_RELIEF: | |||
509 | g_value_set_enum (value, ctk_tool_item_group_get_header_relief (group)); | |||
510 | break; | |||
511 | ||||
512 | default: | |||
513 | 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'" , "ctktoolitemgroup.c", 513, ("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); | |||
514 | break; | |||
515 | } | |||
516 | } | |||
517 | ||||
518 | static void | |||
519 | ctk_tool_item_group_finalize (GObject *object) | |||
520 | { | |||
521 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (object)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (object), ((ctk_tool_item_group_get_type ())) )))); | |||
522 | ||||
523 | g_list_free (group->priv->children); | |||
524 | ||||
525 | G_OBJECT_CLASS (ctk_tool_item_group_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_item_group_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); | |||
526 | } | |||
527 | ||||
528 | static void | |||
529 | ctk_tool_item_group_dispose (GObject *object) | |||
530 | { | |||
531 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (object)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (object), ((ctk_tool_item_group_get_type ())) )))); | |||
532 | CtkToolItemGroupPrivate* priv = group->priv; | |||
533 | ||||
534 | if (priv->toplevel) | |||
535 | { | |||
536 | /* disconnect focus tracking handler */ | |||
537 | g_signal_handler_disconnect (priv->toplevel, | |||
538 | priv->focus_set_id); | |||
539 | ||||
540 | priv->focus_set_id = 0; | |||
541 | priv->toplevel = NULL((void*)0); | |||
542 | } | |||
543 | ||||
544 | if (priv->settings_connection > 0) | |||
545 | { | |||
546 | g_signal_handler_disconnect (priv->settings, priv->settings_connection); | |||
547 | priv->settings_connection = 0; | |||
548 | } | |||
549 | ||||
550 | g_clear_object (&priv->settings)do { _Static_assert (sizeof *((&priv->settings)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->settings))) _pp = ((&priv->settings)); __typeof__ (*((&priv->settings))) _ptr = *_pp; *_pp = ((void*)0) ; if (_ptr) (g_object_unref) (_ptr); } while (0); | |||
551 | if (priv->header) | |||
552 | ctk_widget_destroy (priv->header); | |||
553 | g_clear_object (&priv->header)do { _Static_assert (sizeof *((&priv->header)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->header))) _pp = ((&priv->header)); __typeof__ (*((&priv->header))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); | |||
554 | ||||
555 | G_OBJECT_CLASS (ctk_tool_item_group_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_item_group_parent_class)), (((GType) ((20) << (2))))))))->dispose (object); | |||
556 | } | |||
557 | ||||
558 | static void | |||
559 | ctk_tool_item_group_get_item_size (CtkToolItemGroup *group, | |||
560 | CtkRequisition *item_size, | |||
561 | gboolean homogeneous_only, | |||
562 | gint *requested_rows) | |||
563 | { | |||
564 | CtkWidget *parent = ctk_widget_get_parent (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
565 | ||||
566 | if (CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; }))))) | |||
567 | _ctk_tool_palette_get_item_size (CTK_TOOL_PALETTE (parent)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (parent), ((ctk_tool_palette_get_type ())))))), item_size, homogeneous_only, requested_rows); | |||
568 | else | |||
569 | _ctk_tool_item_group_item_size_request (group, item_size, homogeneous_only, requested_rows); | |||
570 | } | |||
571 | ||||
572 | static void | |||
573 | ctk_tool_item_group_size_request (CtkWidget *widget, | |||
574 | CtkRequisition *requisition) | |||
575 | { | |||
576 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))); | |||
577 | CtkToolItemGroupPrivate* priv = group->priv; | |||
578 | CtkOrientation orientation; | |||
579 | CtkRequisition item_size; | |||
580 | gint requested_rows; | |||
581 | guint border_width; | |||
582 | ||||
583 | if (priv->children && ctk_tool_item_group_get_label_widget (group)) | |||
584 | { | |||
585 | ctk_widget_get_preferred_size (priv->header, | |||
586 | requisition, NULL((void*)0)); | |||
587 | ctk_widget_show (priv->header); | |||
588 | } | |||
589 | else | |||
590 | { | |||
591 | requisition->width = requisition->height = 0; | |||
592 | ctk_widget_hide (priv->header); | |||
593 | } | |||
594 | ||||
595 | ctk_tool_item_group_get_item_size (group, &item_size, FALSE(0), &requested_rows); | |||
596 | ||||
597 | orientation = ctk_tool_shell_get_orientation (CTK_TOOL_SHELL (group)((((CtkToolShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_tool_shell_get_type ()))))))); | |||
598 | ||||
599 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
600 | requisition->width = MAX (requisition->width, item_size.width)(((requisition->width) > (item_size.width)) ? (requisition ->width) : (item_size.width)); | |||
601 | else | |||
602 | requisition->height = MAX (requisition->height, item_size.height * requested_rows)(((requisition->height) > (item_size.height * requested_rows )) ? (requisition->height) : (item_size.height * requested_rows )); | |||
603 | ||||
604 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); | |||
605 | requisition->width += border_width * 2; | |||
606 | requisition->height += border_width * 2; | |||
607 | } | |||
608 | ||||
609 | static void | |||
610 | ctk_tool_item_group_get_preferred_width (CtkWidget *widget, | |||
611 | gint *minimum, | |||
612 | gint *natural) | |||
613 | { | |||
614 | CtkRequisition requisition; | |||
615 | ||||
616 | ctk_tool_item_group_size_request (widget, &requisition); | |||
617 | ||||
618 | *minimum = *natural = requisition.width; | |||
619 | } | |||
620 | ||||
621 | static void | |||
622 | ctk_tool_item_group_get_preferred_height (CtkWidget *widget, | |||
623 | gint *minimum, | |||
624 | gint *natural) | |||
625 | { | |||
626 | CtkRequisition requisition; | |||
627 | ||||
628 | ctk_tool_item_group_size_request (widget, &requisition); | |||
629 | ||||
630 | *minimum = *natural = requisition.height; | |||
631 | } | |||
632 | ||||
633 | ||||
634 | static gboolean | |||
635 | ctk_tool_item_group_is_item_visible (CtkToolItemGroup *group, | |||
636 | CtkToolItemGroupChild *child) | |||
637 | { | |||
638 | CtkToolbarStyle style; | |||
639 | CtkOrientation orientation; | |||
640 | ||||
641 | orientation = ctk_tool_shell_get_orientation (CTK_TOOL_SHELL (group)((((CtkToolShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_tool_shell_get_type ()))))))); | |||
642 | style = ctk_tool_shell_get_style (CTK_TOOL_SHELL (group)((((CtkToolShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_tool_shell_get_type ()))))))); | |||
643 | ||||
644 | /* horizontal tool palettes with text style support only homogeneous items */ | |||
645 | if (!child->homogeneous && | |||
646 | CTK_ORIENTATION_HORIZONTAL == orientation && | |||
647 | CTK_TOOLBAR_TEXT == style) | |||
648 | return FALSE(0); | |||
649 | ||||
650 | return | |||
651 | (ctk_widget_get_visible (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))))) && | |||
652 | (CTK_ORIENTATION_VERTICAL == orientation ? | |||
653 | ctk_tool_item_get_visible_vertical (child->item) : | |||
654 | ctk_tool_item_get_visible_horizontal (child->item)); | |||
655 | } | |||
656 | ||||
657 | static inline unsigned | |||
658 | udiv (unsigned x, | |||
659 | unsigned y) | |||
660 | { | |||
661 | return (x + y - 1) / y; | |||
662 | } | |||
663 | ||||
664 | static void | |||
665 | ctk_tool_item_group_real_size_query (CtkWidget *widget, | |||
666 | CtkAllocation *allocation, | |||
667 | CtkRequisition *inquery) | |||
668 | { | |||
669 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))); | |||
670 | CtkToolItemGroupPrivate* priv = group->priv; | |||
671 | ||||
672 | CtkRequisition item_size; | |||
673 | CtkAllocation item_area; | |||
674 | ||||
675 | CtkOrientation orientation; | |||
676 | ||||
677 | gint min_rows; | |||
678 | guint border_width; | |||
679 | ||||
680 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); | |||
681 | orientation = ctk_tool_shell_get_orientation (CTK_TOOL_SHELL (group)((((CtkToolShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_tool_shell_get_type ()))))))); | |||
682 | ||||
683 | /* figure out the size of homogeneous items */ | |||
684 | ctk_tool_item_group_get_item_size (group, &item_size, TRUE(!(0)), &min_rows); | |||
685 | ||||
686 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
687 | item_size.width = MIN (item_size.width, allocation->width)(((item_size.width) < (allocation->width)) ? (item_size .width) : (allocation->width)); | |||
688 | else | |||
689 | item_size.height = MIN (item_size.height, allocation->height)(((item_size.height) < (allocation->height)) ? (item_size .height) : (allocation->height)); | |||
690 | ||||
691 | item_size.width = MAX (item_size.width, 1)(((item_size.width) > (1)) ? (item_size.width) : (1)); | |||
692 | item_size.height = MAX (item_size.height, 1)(((item_size.height) > (1)) ? (item_size.height) : (1)); | |||
693 | ||||
694 | item_area.width = 0; | |||
695 | item_area.height = 0; | |||
696 | ||||
697 | /* figure out the required columns (n_columns) and rows (n_rows) | |||
698 | * to place all items | |||
699 | */ | |||
700 | if (!priv->collapsed || !priv->animation || priv->animation_timeout) | |||
701 | { | |||
702 | guint n_columns; | |||
703 | gint n_rows; | |||
704 | GList *it; | |||
705 | ||||
706 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
707 | { | |||
708 | gboolean new_row = FALSE(0); | |||
709 | gint row = -1; | |||
710 | guint col = 0; | |||
711 | ||||
712 | item_area.width = allocation->width - 2 * border_width; | |||
713 | n_columns = MAX (item_area.width / item_size.width, 1)(((item_area.width / item_size.width) > (1)) ? (item_area. width / item_size.width) : (1)); | |||
714 | ||||
715 | /* calculate required rows for n_columns columns */ | |||
716 | for (it = priv->children; it != NULL((void*)0); it = it->next) | |||
717 | { | |||
718 | CtkToolItemGroupChild *child = it->data; | |||
719 | ||||
720 | if (!ctk_tool_item_group_is_item_visible (group, child)) | |||
721 | continue; | |||
722 | ||||
723 | if (new_row || child->new_row) | |||
724 | { | |||
725 | new_row = FALSE(0); | |||
726 | row++; | |||
727 | col = 0; | |||
728 | } | |||
729 | ||||
730 | if (child->expand) | |||
731 | new_row = TRUE(!(0)); | |||
732 | ||||
733 | if (child->homogeneous) | |||
734 | { | |||
735 | col++; | |||
736 | if (col >= n_columns) | |||
737 | new_row = TRUE(!(0)); | |||
738 | } | |||
739 | else | |||
740 | { | |||
741 | CtkRequisition req = {0, 0}; | |||
742 | guint width; | |||
743 | ||||
744 | ctk_widget_get_preferred_size (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), | |||
745 | &req, NULL((void*)0)); | |||
746 | ||||
747 | width = udiv (req.width, item_size.width); | |||
748 | col += width; | |||
749 | ||||
750 | if (col > n_columns) | |||
751 | row++; | |||
752 | ||||
753 | col = width; | |||
754 | ||||
755 | if (col >= n_columns) | |||
756 | new_row = TRUE(!(0)); | |||
757 | } | |||
758 | } | |||
759 | n_rows = row + 2; | |||
760 | } | |||
761 | else | |||
762 | { | |||
763 | guint *row_min_width; | |||
764 | gint row = -1; | |||
765 | gboolean new_row = TRUE(!(0)); | |||
766 | guint col = 0, min_col, max_col = 0, all_items = 0; | |||
767 | gint i; | |||
768 | ||||
769 | item_area.height = allocation->height - 2 * border_width; | |||
770 | n_rows = MAX (item_area.height / item_size.height, min_rows)(((item_area.height / item_size.height) > (min_rows)) ? (item_area .height / item_size.height) : (min_rows)); | |||
771 | ||||
772 | row_min_width = g_new0 (guint, n_rows)((guint *) g_malloc0_n ((n_rows), sizeof (guint))); | |||
773 | ||||
774 | /* calculate minimal and maximal required cols and minimal | |||
775 | * required rows | |||
776 | */ | |||
777 | for (it = priv->children; it != NULL((void*)0); it = it->next) | |||
778 | { | |||
779 | CtkToolItemGroupChild *child = it->data; | |||
780 | ||||
781 | if (!ctk_tool_item_group_is_item_visible (group, child)) | |||
782 | continue; | |||
783 | ||||
784 | if (new_row || child->new_row) | |||
785 | { | |||
786 | new_row = FALSE(0); | |||
787 | row++; | |||
788 | col = 0; | |||
789 | row_min_width[row] = 1; | |||
790 | } | |||
791 | ||||
792 | if (child->expand) | |||
793 | new_row = TRUE(!(0)); | |||
794 | ||||
795 | if (child->homogeneous) | |||
796 | { | |||
797 | col++; | |||
798 | all_items++; | |||
799 | } | |||
800 | else | |||
801 | { | |||
802 | CtkRequisition req = {0, 0}; | |||
803 | guint width; | |||
804 | ||||
805 | ctk_widget_get_preferred_size (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), | |||
806 | &req, NULL((void*)0)); | |||
807 | ||||
808 | width = udiv (req.width, item_size.width); | |||
809 | ||||
810 | col += width; | |||
811 | all_items += width; | |||
812 | ||||
813 | row_min_width[row] = MAX (row_min_width[row], width)(((row_min_width[row]) > (width)) ? (row_min_width[row]) : (width)); | |||
814 | } | |||
815 | ||||
816 | max_col = MAX (max_col, col)(((max_col) > (col)) ? (max_col) : (col)); | |||
817 | } | |||
818 | ||||
819 | /* calculate minimal required cols */ | |||
820 | min_col = udiv (all_items, n_rows); | |||
821 | ||||
822 | for (i = 0; i <= row; i++) | |||
823 | { | |||
824 | min_col = MAX (min_col, row_min_width[i])(((min_col) > (row_min_width[i])) ? (min_col) : (row_min_width [i])); | |||
825 | } | |||
826 | ||||
827 | /* simple linear search for minimal required columns | |||
828 | * for the given maximal number of rows (n_rows) | |||
829 | */ | |||
830 | for (n_columns = min_col; n_columns < max_col; n_columns ++) | |||
831 | { | |||
832 | new_row = TRUE(!(0)); | |||
833 | row = -1; | |||
834 | /* calculate required rows for n_columns columns */ | |||
835 | for (it = priv->children; it != NULL((void*)0); it = it->next) | |||
836 | { | |||
837 | CtkToolItemGroupChild *child = it->data; | |||
838 | ||||
839 | if (!ctk_tool_item_group_is_item_visible (group, child)) | |||
840 | continue; | |||
841 | ||||
842 | if (new_row || child->new_row) | |||
843 | { | |||
844 | new_row = FALSE(0); | |||
845 | row++; | |||
846 | col = 0; | |||
847 | } | |||
848 | ||||
849 | if (child->expand) | |||
850 | new_row = TRUE(!(0)); | |||
851 | ||||
852 | if (child->homogeneous) | |||
853 | { | |||
854 | col++; | |||
855 | if (col >= n_columns) | |||
856 | new_row = TRUE(!(0)); | |||
857 | } | |||
858 | else | |||
859 | { | |||
860 | CtkRequisition req = {0, 0}; | |||
861 | guint width; | |||
862 | ||||
863 | ctk_widget_get_preferred_size (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), | |||
864 | &req, NULL((void*)0)); | |||
865 | ||||
866 | width = udiv (req.width, item_size.width); | |||
867 | col += width; | |||
868 | ||||
869 | if (col > n_columns) | |||
870 | row++; | |||
871 | ||||
872 | col = width; | |||
873 | ||||
874 | if (col >= n_columns) | |||
875 | new_row = TRUE(!(0)); | |||
876 | } | |||
877 | } | |||
878 | ||||
879 | if (row < n_rows) | |||
880 | break; | |||
881 | } | |||
882 | } | |||
883 | ||||
884 | item_area.width = item_size.width * n_columns; | |||
885 | item_area.height = item_size.height * n_rows; | |||
886 | } | |||
887 | ||||
888 | inquery->width = 0; | |||
889 | inquery->height = 0; | |||
890 | ||||
891 | /* figure out header widget size */ | |||
892 | if (ctk_widget_get_visible (priv->header)) | |||
893 | { | |||
894 | CtkRequisition child_requisition; | |||
895 | ||||
896 | ctk_widget_get_preferred_size (priv->header, | |||
897 | &child_requisition, NULL((void*)0)); | |||
898 | ||||
899 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
900 | inquery->height += child_requisition.height; | |||
901 | else | |||
902 | inquery->width += child_requisition.width; | |||
903 | } | |||
904 | ||||
905 | /* report effective widget size */ | |||
906 | inquery->width += item_area.width + 2 * border_width; | |||
907 | inquery->height += item_area.height + 2 * border_width; | |||
908 | } | |||
909 | ||||
910 | static void | |||
911 | ctk_tool_item_group_real_size_allocate (CtkWidget *widget, | |||
912 | CtkAllocation *allocation) | |||
913 | { | |||
914 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))); | |||
915 | CtkToolItemGroupPrivate* priv = group->priv; | |||
916 | CtkRequisition child_requisition; | |||
917 | CtkAllocation child_allocation; | |||
918 | ||||
919 | CtkRequisition item_size; | |||
920 | CtkAllocation item_area; | |||
921 | ||||
922 | CtkOrientation orientation; | |||
923 | ||||
924 | GList *it; | |||
925 | ||||
926 | gint n_columns, n_rows = 1; | |||
927 | gint min_rows; | |||
928 | guint border_width; | |||
929 | CtkTextDirection direction; | |||
930 | ||||
931 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); | |||
932 | ||||
933 | direction = ctk_widget_get_direction (widget); | |||
934 | ||||
935 | orientation = ctk_tool_shell_get_orientation (CTK_TOOL_SHELL (group)((((CtkToolShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_tool_shell_get_type ()))))))); | |||
936 | ||||
937 | /* chain up */ | |||
938 | CTK_WIDGET_CLASS (ctk_tool_item_group_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_item_group_parent_class)), ((ctk_widget_get_type ()))))))->size_allocate (widget, allocation); | |||
939 | ||||
940 | child_allocation.x = border_width; | |||
941 | child_allocation.y = border_width; | |||
942 | ||||
943 | /* place the header widget */ | |||
944 | if (ctk_widget_get_visible (priv->header)) | |||
945 | { | |||
946 | ctk_widget_get_preferred_size (priv->header, | |||
947 | &child_requisition, NULL((void*)0)); | |||
948 | ||||
949 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
950 | { | |||
951 | child_allocation.width = allocation->width; | |||
952 | child_allocation.height = child_requisition.height; | |||
953 | } | |||
954 | else | |||
955 | { | |||
956 | child_allocation.width = child_requisition.width; | |||
957 | child_allocation.height = allocation->height; | |||
958 | ||||
959 | if (CTK_TEXT_DIR_RTL == direction) | |||
960 | child_allocation.x = allocation->width - border_width - child_allocation.width; | |||
961 | } | |||
962 | ||||
963 | ctk_widget_size_allocate (priv->header, &child_allocation); | |||
964 | ||||
965 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
966 | child_allocation.y += child_allocation.height; | |||
967 | else if (CTK_TEXT_DIR_RTL != direction) | |||
968 | child_allocation.x += child_allocation.width; | |||
969 | else | |||
970 | child_allocation.x = border_width; | |||
971 | } | |||
972 | else | |||
973 | child_requisition.width = child_requisition.height = 0; | |||
974 | ||||
975 | /* figure out the size of homogeneous items */ | |||
976 | ctk_tool_item_group_get_item_size (group, &item_size, TRUE(!(0)), &min_rows); | |||
977 | ||||
978 | item_size.width = MAX (item_size.width, 1)(((item_size.width) > (1)) ? (item_size.width) : (1)); | |||
979 | item_size.height = MAX (item_size.height, 1)(((item_size.height) > (1)) ? (item_size.height) : (1)); | |||
980 | ||||
981 | /* figure out the available columns and size of item_area */ | |||
982 | if (CTK_ORIENTATION_VERTICAL == orientation) | |||
983 | { | |||
984 | item_size.width = MIN (item_size.width, allocation->width)(((item_size.width) < (allocation->width)) ? (item_size .width) : (allocation->width)); | |||
985 | ||||
986 | item_area.width = allocation->width - 2 * border_width; | |||
987 | item_area.height = allocation->height - 2 * border_width - child_requisition.height; | |||
988 | ||||
989 | n_columns = MAX (item_area.width / item_size.width, 1)(((item_area.width / item_size.width) > (1)) ? (item_area. width / item_size.width) : (1)); | |||
990 | ||||
991 | item_size.width = item_area.width / n_columns; | |||
992 | } | |||
993 | else | |||
994 | { | |||
995 | item_size.height = MIN (item_size.height, allocation->height)(((item_size.height) < (allocation->height)) ? (item_size .height) : (allocation->height)); | |||
996 | ||||
997 | item_area.width = allocation->width - 2 * border_width - child_requisition.width; | |||
998 | item_area.height = allocation->height - 2 * border_width; | |||
999 | ||||
1000 | n_columns = MAX (item_area.width / item_size.width, 1)(((item_area.width / item_size.width) > (1)) ? (item_area. width / item_size.width) : (1)); | |||
1001 | n_rows = MAX (item_area.height / item_size.height, min_rows)(((item_area.height / item_size.height) > (min_rows)) ? (item_area .height / item_size.height) : (min_rows)); | |||
1002 | ||||
1003 | item_size.height = item_area.height / n_rows; | |||
| ||||
1004 | } | |||
1005 | ||||
1006 | item_area.x = child_allocation.x; | |||
1007 | item_area.y = child_allocation.y; | |||
1008 | ||||
1009 | /* when expanded or in transition, place the tool items in a grid like layout */ | |||
1010 | if (!priv->collapsed || !priv->animation || priv->animation_timeout) | |||
1011 | { | |||
1012 | gint col = 0, row = 0; | |||
1013 | ||||
1014 | for (it = priv->children; it != NULL((void*)0); it = it->next) | |||
1015 | { | |||
1016 | CtkToolItemGroupChild *child = it->data; | |||
1017 | gint col_child; | |||
1018 | ||||
1019 | if (!ctk_tool_item_group_is_item_visible (group, child)) | |||
1020 | { | |||
1021 | ctk_widget_set_child_visible (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), FALSE(0)); | |||
1022 | ||||
1023 | continue; | |||
1024 | } | |||
1025 | ||||
1026 | /* for non homogeneous widgets request the required size */ | |||
1027 | child_requisition.width = 0; | |||
1028 | ||||
1029 | if (!child->homogeneous) | |||
1030 | { | |||
1031 | ctk_widget_get_preferred_size (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), | |||
1032 | &child_requisition, NULL((void*)0)); | |||
1033 | child_requisition.width = MIN (child_requisition.width, item_area.width)(((child_requisition.width) < (item_area.width)) ? (child_requisition .width) : (item_area.width)); | |||
1034 | } | |||
1035 | ||||
1036 | /* select next row if at end of row */ | |||
1037 | if (col > 0 && (child->new_row || (col * item_size.width) + MAX (child_requisition.width, item_size.width)(((child_requisition.width) > (item_size.width)) ? (child_requisition .width) : (item_size.width)) > item_area.width)) | |||
1038 | { | |||
1039 | row++; | |||
1040 | col = 0; | |||
1041 | child_allocation.y += child_allocation.height; | |||
1042 | } | |||
1043 | ||||
1044 | col_child = col; | |||
1045 | ||||
1046 | /* calculate the position and size of the item */ | |||
1047 | if (!child->homogeneous) | |||
1048 | { | |||
1049 | gint col_width; | |||
1050 | gint width; | |||
1051 | ||||
1052 | if (!child->expand) | |||
1053 | col_width = udiv (child_requisition.width, item_size.width); | |||
1054 | else | |||
1055 | col_width = n_columns - col; | |||
1056 | ||||
1057 | width = col_width * item_size.width; | |||
1058 | ||||
1059 | if (CTK_TEXT_DIR_RTL == direction) | |||
1060 | col_child = (n_columns - col - col_width); | |||
1061 | ||||
1062 | if (child->fill) | |||
1063 | { | |||
1064 | child_allocation.x = item_area.x + col_child * item_size.width; | |||
1065 | child_allocation.width = width; | |||
1066 | } | |||
1067 | else | |||
1068 | { | |||
1069 | child_allocation.x = | |||
1070 | (item_area.x + col_child * item_size.width + | |||
1071 | (width - child_requisition.width) / 2); | |||
1072 | child_allocation.width = child_requisition.width; | |||
1073 | } | |||
1074 | ||||
1075 | col += col_width; | |||
1076 | } | |||
1077 | else | |||
1078 | { | |||
1079 | if (CTK_TEXT_DIR_RTL == direction) | |||
1080 | col_child = (n_columns - col - 1); | |||
1081 | ||||
1082 | child_allocation.x = item_area.x + col_child * item_size.width; | |||
1083 | child_allocation.width = item_size.width; | |||
1084 | ||||
1085 | col++; | |||
1086 | } | |||
1087 | ||||
1088 | child_allocation.height = item_size.height; | |||
1089 | ||||
1090 | ctk_widget_size_allocate (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), &child_allocation); | |||
1091 | ctk_widget_set_child_visible (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), TRUE(!(0))); | |||
1092 | } | |||
1093 | ||||
1094 | child_allocation.y += item_size.height; | |||
1095 | } | |||
1096 | ||||
1097 | /* or just hide all items, when collapsed */ | |||
1098 | ||||
1099 | else | |||
1100 | { | |||
1101 | for (it = priv->children; it != NULL((void*)0); it = it->next) | |||
1102 | { | |||
1103 | CtkToolItemGroupChild *child = it->data; | |||
1104 | ||||
1105 | ctk_widget_set_child_visible (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), FALSE(0)); | |||
1106 | } | |||
1107 | } | |||
1108 | } | |||
1109 | ||||
1110 | static void | |||
1111 | ctk_tool_item_group_size_allocate (CtkWidget *widget, | |||
1112 | CtkAllocation *allocation) | |||
1113 | { | |||
1114 | ctk_tool_item_group_real_size_allocate (widget, allocation); | |||
| ||||
1115 | ||||
1116 | if (ctk_widget_get_mapped (widget)) | |||
1117 | cdk_window_invalidate_rect (ctk_widget_get_window (widget), NULL((void*)0), FALSE(0)); | |||
1118 | } | |||
1119 | ||||
1120 | static void | |||
1121 | ctk_tool_item_group_set_focus_cb (CtkWidget *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1122 | CtkWidget *widget, | |||
1123 | gpointer user_data) | |||
1124 | { | |||
1125 | CtkAdjustment *adjustment; | |||
1126 | CtkAllocation allocation, p_allocation; | |||
1127 | CtkWidget *p; | |||
1128 | ||||
1129 | /* Find this group's parent widget in the focused widget's anchestry. */ | |||
1130 | for (p = widget; p; p = ctk_widget_get_parent (p)) | |||
1131 | if (p == user_data) | |||
1132 | { | |||
1133 | p = ctk_widget_get_parent (p); | |||
1134 | break; | |||
1135 | } | |||
1136 | ||||
1137 | if (CTK_IS_TOOL_PALETTE (p)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( p); GType __t = ((ctk_tool_palette_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; }))))) | |||
1138 | { | |||
1139 | /* Check that the focused widgets is fully visible within | |||
1140 | * the group's parent widget and make it visible otherwise. */ | |||
1141 | ||||
1142 | adjustment = ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (p)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((p)), ((ctk_scrollable_get_type ()))))))); | |||
1143 | ||||
1144 | if (adjustment) | |||
1145 | { | |||
1146 | int y; | |||
1147 | ||||
1148 | ctk_widget_get_allocation (widget, &allocation); | |||
1149 | ctk_widget_get_allocation (p, &p_allocation); | |||
1150 | ||||
1151 | /* Handle vertical adjustment. */ | |||
1152 | if (ctk_widget_translate_coordinates | |||
1153 | (widget, p, 0, 0, NULL((void*)0), &y) && y < 0) | |||
1154 | { | |||
1155 | y += ctk_adjustment_get_value (adjustment); | |||
1156 | ctk_adjustment_clamp_page (adjustment, y, y + allocation.height); | |||
1157 | } | |||
1158 | else if (ctk_widget_translate_coordinates (widget, p, 0, allocation.height, NULL((void*)0), &y) && | |||
1159 | y > p_allocation.height) | |||
1160 | { | |||
1161 | y += ctk_adjustment_get_value (adjustment); | |||
1162 | ctk_adjustment_clamp_page (adjustment, y - allocation.height, y); | |||
1163 | } | |||
1164 | } | |||
1165 | ||||
1166 | adjustment = ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (p)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((p)), ((ctk_scrollable_get_type ()))))))); | |||
1167 | ||||
1168 | if (adjustment) | |||
1169 | { | |||
1170 | int x; | |||
1171 | ||||
1172 | ctk_widget_get_allocation (widget, &allocation); | |||
1173 | ctk_widget_get_allocation (p, &p_allocation); | |||
1174 | ||||
1175 | /* Handle horizontal adjustment. */ | |||
1176 | if (ctk_widget_translate_coordinates | |||
1177 | (widget, p, 0, 0, &x, NULL((void*)0)) && x < 0) | |||
1178 | { | |||
1179 | x += ctk_adjustment_get_value (adjustment); | |||
1180 | ctk_adjustment_clamp_page (adjustment, x, x + allocation.width); | |||
1181 | } | |||
1182 | else if (ctk_widget_translate_coordinates (widget, p, allocation.width, 0, &x, NULL((void*)0)) && | |||
1183 | x > p_allocation.width) | |||
1184 | { | |||
1185 | x += ctk_adjustment_get_value (adjustment); | |||
1186 | ctk_adjustment_clamp_page (adjustment, x - allocation.width, x); | |||
1187 | } | |||
1188 | ||||
1189 | return; | |||
1190 | } | |||
1191 | } | |||
1192 | } | |||
1193 | ||||
1194 | static void | |||
1195 | ctk_tool_item_group_set_toplevel_window (CtkToolItemGroup *group, | |||
1196 | CtkWidget *toplevel) | |||
1197 | { | |||
1198 | CtkToolItemGroupPrivate* priv = group->priv; | |||
1199 | ||||
1200 | if (toplevel != priv->toplevel) | |||
1201 | { | |||
1202 | if (priv->toplevel) | |||
1203 | { | |||
1204 | /* Disconnect focus tracking handler. */ | |||
1205 | g_signal_handler_disconnect (priv->toplevel, | |||
1206 | priv->focus_set_id); | |||
1207 | ||||
1208 | priv->focus_set_id = 0; | |||
1209 | priv->toplevel = NULL((void*)0); | |||
1210 | } | |||
1211 | ||||
1212 | if (toplevel) | |||
1213 | { | |||
1214 | /* Install focus tracking handler. We connect to the window's | |||
1215 | * set-focus signal instead of connecting to the focus signal of | |||
1216 | * each child to: | |||
1217 | * | |||
1218 | * 1) Reduce the number of signal handlers used. | |||
1219 | * 2) Avoid special handling for group headers. | |||
1220 | * 3) Catch focus grabs not only for direct children, | |||
1221 | * but also for nested widgets. | |||
1222 | */ | |||
1223 | priv->focus_set_id = | |||
1224 | g_signal_connect (toplevel, "set-focus",g_signal_connect_data ((toplevel), ("set-focus"), (((GCallback ) (ctk_tool_item_group_set_focus_cb))), (group), ((void*)0), ( GConnectFlags) 0) | |||
1225 | G_CALLBACK (ctk_tool_item_group_set_focus_cb),g_signal_connect_data ((toplevel), ("set-focus"), (((GCallback ) (ctk_tool_item_group_set_focus_cb))), (group), ((void*)0), ( GConnectFlags) 0) | |||
1226 | group)g_signal_connect_data ((toplevel), ("set-focus"), (((GCallback ) (ctk_tool_item_group_set_focus_cb))), (group), ((void*)0), ( GConnectFlags) 0); | |||
1227 | ||||
1228 | priv->toplevel = toplevel; | |||
1229 | } | |||
1230 | } | |||
1231 | } | |||
1232 | ||||
1233 | static void | |||
1234 | ctk_tool_item_group_realize (CtkWidget *widget) | |||
1235 | { | |||
1236 | CtkAllocation allocation; | |||
1237 | CtkWidget *toplevel_window; | |||
1238 | CdkWindow *window; | |||
1239 | CdkWindowAttr attributes; | |||
1240 | gint attributes_mask; | |||
1241 | guint border_width; | |||
1242 | ||||
1243 | ctk_widget_set_realized (widget, TRUE(!(0))); | |||
1244 | ||||
1245 | border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ()))))))); | |||
1246 | ctk_widget_get_allocation (widget, &allocation); | |||
1247 | ||||
1248 | attributes.window_type = CDK_WINDOW_CHILD; | |||
1249 | attributes.x = allocation.x + border_width; | |||
1250 | attributes.y = allocation.y + border_width; | |||
1251 | attributes.width = allocation.width - border_width * 2; | |||
1252 | attributes.height = allocation.height - border_width * 2; | |||
1253 | attributes.wclass = CDK_INPUT_OUTPUT; | |||
1254 | attributes.visual = ctk_widget_get_visual (widget); | |||
1255 | attributes.event_mask = ctk_widget_get_events (widget) | |||
1256 | | CDK_VISIBILITY_NOTIFY_MASK | |||
1257 | | CDK_BUTTON_PRESS_MASK | CDK_BUTTON_RELEASE_MASK | |||
1258 | | CDK_BUTTON_MOTION_MASK; | |||
1259 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; | |||
1260 | ||||
1261 | window = cdk_window_new (ctk_widget_get_parent_window (widget), | |||
1262 | &attributes, attributes_mask); | |||
1263 | ctk_widget_set_window (widget, window); | |||
1264 | ||||
1265 | ctk_widget_register_window (widget, window); | |||
1266 | ||||
1267 | ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), | |||
1268 | (CtkCallback) ctk_widget_set_parent_window, | |||
1269 | window); | |||
1270 | ||||
1271 | ctk_widget_queue_resize_no_redraw (widget); | |||
1272 | ||||
1273 | toplevel_window = ctk_widget_get_ancestor (widget, CTK_TYPE_WINDOW(ctk_window_get_type ())); | |||
1274 | ctk_tool_item_group_set_toplevel_window (CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))), | |||
1275 | toplevel_window); | |||
1276 | } | |||
1277 | ||||
1278 | static void | |||
1279 | ctk_tool_item_group_unrealize (CtkWidget *widget) | |||
1280 | { | |||
1281 | ctk_tool_item_group_set_toplevel_window (CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) )))), NULL((void*)0)); | |||
1282 | CTK_WIDGET_CLASS (ctk_tool_item_group_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_item_group_parent_class)), ((ctk_widget_get_type ()))))))->unrealize (widget); | |||
1283 | } | |||
1284 | ||||
1285 | static gboolean | |||
1286 | ctk_tool_item_group_draw (CtkWidget *widget, | |||
1287 | cairo_t *cr) | |||
1288 | { | |||
1289 | ctk_render_background (ctk_widget_get_style_context (widget), cr, | |||
1290 | 0, 0, | |||
1291 | ctk_widget_get_allocated_width (widget), | |||
1292 | ctk_widget_get_allocated_height (widget)); | |||
1293 | ||||
1294 | return CTK_WIDGET_CLASS (ctk_tool_item_group_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_item_group_parent_class)), ((ctk_widget_get_type ()))))))->draw (widget, cr); | |||
1295 | } | |||
1296 | ||||
1297 | static void | |||
1298 | ctk_tool_item_group_style_updated (CtkWidget *widget) | |||
1299 | { | |||
1300 | ctk_tool_item_group_header_adjust_style (CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) ))))); | |||
1301 | CTK_WIDGET_CLASS (ctk_tool_item_group_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tool_item_group_parent_class)), ((ctk_widget_get_type ()))))))->style_updated (widget); | |||
1302 | } | |||
1303 | ||||
1304 | static void | |||
1305 | ctk_tool_item_group_state_flags_changed (CtkWidget *widget, | |||
1306 | CtkStateFlags previous_flags G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
1307 | { | |||
1308 | update_arrow_state (CTK_TOOL_ITEM_GROUP (widget)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (widget), ((ctk_tool_item_group_get_type ())) ))))); | |||
1309 | } | |||
1310 | ||||
1311 | static void | |||
1312 | ctk_tool_item_group_add (CtkContainer *container, | |||
1313 | CtkWidget *widget) | |||
1314 | { | |||
1315 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (container))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (container); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_TOOL_ITEM_GROUP (container)"); return ; } } while (0); | |||
1316 | g_return_if_fail (CTK_IS_TOOL_ITEM (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_tool_item_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_TOOL_ITEM (widget)"); return; } } while (0); | |||
1317 | ||||
1318 | ctk_tool_item_group_insert (CTK_TOOL_ITEM_GROUP (container)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (container), ((ctk_tool_item_group_get_type ( ))))))), | |||
1319 | CTK_TOOL_ITEM (widget)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tool_item_get_type ())))))), -1); | |||
1320 | } | |||
1321 | ||||
1322 | static void | |||
1323 | ctk_tool_item_group_remove (CtkContainer *container, | |||
1324 | CtkWidget *child) | |||
1325 | { | |||
1326 | CtkToolItemGroup *group; | |||
1327 | CtkToolItemGroupPrivate* priv; | |||
1328 | GList *it; | |||
1329 | ||||
1330 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (container))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (container); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_TOOL_ITEM_GROUP (container)"); return ; } } while (0); | |||
1331 | group = CTK_TOOL_ITEM_GROUP (container)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (container), ((ctk_tool_item_group_get_type ( ))))))); | |||
1332 | priv = group->priv; | |||
1333 | ||||
1334 | for (it = priv->children; it != NULL((void*)0); it = it->next) | |||
1335 | { | |||
1336 | CtkToolItemGroupChild *child_info = it->data; | |||
1337 | ||||
1338 | if ((CtkWidget *)child_info->item == child) | |||
1339 | { | |||
1340 | g_object_unref (child); | |||
1341 | ctk_widget_unparent (child); | |||
1342 | ||||
1343 | g_free (child_info); | |||
1344 | priv->children = g_list_delete_link (priv->children, it); | |||
1345 | ||||
1346 | ctk_widget_queue_resize (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ()))))))); | |||
1347 | break; | |||
1348 | } | |||
1349 | } | |||
1350 | } | |||
1351 | ||||
1352 | static void | |||
1353 | ctk_tool_item_group_forall (CtkContainer *container, | |||
1354 | gboolean internals, | |||
1355 | CtkCallback callback, | |||
1356 | gpointer callback_data) | |||
1357 | { | |||
1358 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (container)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (container), ((ctk_tool_item_group_get_type ( ))))))); | |||
1359 | CtkToolItemGroupPrivate* priv = group->priv; | |||
1360 | GList *children; | |||
1361 | ||||
1362 | if (internals && priv->header) | |||
1363 | callback (priv->header, callback_data); | |||
1364 | ||||
1365 | children = priv->children; | |||
1366 | while (children) | |||
1367 | { | |||
1368 | CtkToolItemGroupChild *child = children->data; | |||
1369 | children = children->next; /* store pointer before call to callback | |||
1370 | because the child pointer is invalid if the | |||
1371 | child->item is removed from the item group | |||
1372 | in callback */ | |||
1373 | ||||
1374 | callback (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), callback_data); | |||
1375 | } | |||
1376 | } | |||
1377 | ||||
1378 | static GType | |||
1379 | ctk_tool_item_group_child_type (CtkContainer *container G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
1380 | { | |||
1381 | return CTK_TYPE_TOOL_ITEM(ctk_tool_item_get_type ()); | |||
1382 | } | |||
1383 | ||||
1384 | static CtkToolItemGroupChild * | |||
1385 | ctk_tool_item_group_get_child (CtkToolItemGroup *group, | |||
1386 | CtkToolItem *item, | |||
1387 | gint *position, | |||
1388 | GList **link) | |||
1389 | { | |||
1390 | guint i; | |||
1391 | GList *it; | |||
1392 | ||||
1393 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (((void*)0)); } } while (0); | |||
1394 | g_return_val_if_fail (CTK_IS_TOOL_ITEM (item), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((item)); GType __t = ((ctk_tool_item_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_TOOL_ITEM (item)"); return (((void*)0)); } } while (0); | |||
1395 | ||||
1396 | for (it = group->priv->children, i = 0; it != NULL((void*)0); it = it->next, ++i) | |||
1397 | { | |||
1398 | CtkToolItemGroupChild *child = it->data; | |||
1399 | ||||
1400 | if (child->item == item) | |||
1401 | { | |||
1402 | if (position) | |||
1403 | *position = i; | |||
1404 | ||||
1405 | if (link) | |||
1406 | *link = it; | |||
1407 | ||||
1408 | return child; | |||
1409 | } | |||
1410 | } | |||
1411 | ||||
1412 | return NULL((void*)0); | |||
1413 | } | |||
1414 | ||||
1415 | static void | |||
1416 | ctk_tool_item_group_get_item_packing (CtkToolItemGroup *group, | |||
1417 | CtkToolItem *item, | |||
1418 | gboolean *homogeneous, | |||
1419 | gboolean *expand, | |||
1420 | gboolean *fill, | |||
1421 | gboolean *new_row) | |||
1422 | { | |||
1423 | CtkToolItemGroupChild *child; | |||
1424 | ||||
1425 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
1426 | g_return_if_fail (CTK_IS_TOOL_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((item)); GType __t = ((ctk_tool_item_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_TOOL_ITEM (item)"); return; } } while (0); | |||
1427 | ||||
1428 | child = ctk_tool_item_group_get_child (group, item, NULL((void*)0), NULL((void*)0)); | |||
1429 | if (!child) | |||
1430 | return; | |||
1431 | ||||
1432 | if (expand) | |||
1433 | *expand = child->expand; | |||
1434 | ||||
1435 | if (homogeneous) | |||
1436 | *homogeneous = child->homogeneous; | |||
1437 | ||||
1438 | if (fill) | |||
1439 | *fill = child->fill; | |||
1440 | ||||
1441 | if (new_row) | |||
1442 | *new_row = child->new_row; | |||
1443 | } | |||
1444 | ||||
1445 | static void | |||
1446 | ctk_tool_item_group_set_item_packing (CtkToolItemGroup *group, | |||
1447 | CtkToolItem *item, | |||
1448 | gboolean homogeneous, | |||
1449 | gboolean expand, | |||
1450 | gboolean fill, | |||
1451 | gboolean new_row) | |||
1452 | { | |||
1453 | CtkToolItemGroupChild *child; | |||
1454 | gboolean changed = FALSE(0); | |||
1455 | ||||
1456 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
1457 | g_return_if_fail (CTK_IS_TOOL_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((item)); GType __t = ((ctk_tool_item_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_TOOL_ITEM (item)"); return; } } while (0); | |||
1458 | ||||
1459 | child = ctk_tool_item_group_get_child (group, item, NULL((void*)0), NULL((void*)0)); | |||
1460 | if (!child) | |||
1461 | return; | |||
1462 | ||||
1463 | ctk_widget_freeze_child_notify (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ()))))))); | |||
1464 | ||||
1465 | if (child->homogeneous != homogeneous) | |||
1466 | { | |||
1467 | child->homogeneous = homogeneous; | |||
1468 | changed = TRUE(!(0)); | |||
1469 | ctk_widget_child_notify (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), "homogeneous"); | |||
1470 | } | |||
1471 | if (child->expand != expand) | |||
1472 | { | |||
1473 | child->expand = expand; | |||
1474 | changed = TRUE(!(0)); | |||
1475 | ctk_widget_child_notify (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), "expand"); | |||
1476 | } | |||
1477 | if (child->fill != fill) | |||
1478 | { | |||
1479 | child->fill = fill; | |||
1480 | changed = TRUE(!(0)); | |||
1481 | ctk_widget_child_notify (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), "fill"); | |||
1482 | } | |||
1483 | if (child->new_row != new_row) | |||
1484 | { | |||
1485 | child->new_row = new_row; | |||
1486 | changed = TRUE(!(0)); | |||
1487 | ctk_widget_child_notify (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), "new-row"); | |||
1488 | } | |||
1489 | ||||
1490 | ctk_widget_thaw_child_notify (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ()))))))); | |||
1491 | ||||
1492 | if (changed | |||
1493 | && ctk_widget_get_visible (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))) | |||
1494 | && ctk_widget_get_visible (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))))) | |||
1495 | ctk_widget_queue_resize (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
1496 | } | |||
1497 | ||||
1498 | static void | |||
1499 | ctk_tool_item_group_set_child_property (CtkContainer *container, | |||
1500 | CtkWidget *child, | |||
1501 | guint prop_id, | |||
1502 | const GValue *value, | |||
1503 | GParamSpec *pspec) | |||
1504 | { | |||
1505 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (container)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (container), ((ctk_tool_item_group_get_type ( ))))))); | |||
1506 | CtkToolItem *item = CTK_TOOL_ITEM (child)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_tool_item_get_type ())))))); | |||
1507 | gboolean homogeneous, expand, fill, new_row; | |||
1508 | ||||
1509 | if (prop_id != CHILD_PROP_POSITION) | |||
1510 | ctk_tool_item_group_get_item_packing (group, item, | |||
1511 | &homogeneous, | |||
1512 | &expand, | |||
1513 | &fill, | |||
1514 | &new_row); | |||
1515 | ||||
1516 | switch (prop_id) | |||
1517 | { | |||
1518 | case CHILD_PROP_HOMOGENEOUS: | |||
1519 | ctk_tool_item_group_set_item_packing (group, item, | |||
1520 | g_value_get_boolean (value), | |||
1521 | expand, | |||
1522 | fill, | |||
1523 | new_row); | |||
1524 | break; | |||
1525 | ||||
1526 | case CHILD_PROP_EXPAND: | |||
1527 | ctk_tool_item_group_set_item_packing (group, item, | |||
1528 | homogeneous, | |||
1529 | g_value_get_boolean (value), | |||
1530 | fill, | |||
1531 | new_row); | |||
1532 | break; | |||
1533 | ||||
1534 | case CHILD_PROP_FILL: | |||
1535 | ctk_tool_item_group_set_item_packing (group, item, | |||
1536 | homogeneous, | |||
1537 | expand, | |||
1538 | g_value_get_boolean (value), | |||
1539 | new_row); | |||
1540 | break; | |||
1541 | ||||
1542 | case CHILD_PROP_NEW_ROW: | |||
1543 | ctk_tool_item_group_set_item_packing (group, item, | |||
1544 | homogeneous, | |||
1545 | expand, | |||
1546 | fill, | |||
1547 | g_value_get_boolean (value)); | |||
1548 | break; | |||
1549 | ||||
1550 | case CHILD_PROP_POSITION: | |||
1551 | ctk_tool_item_group_set_item_position (group, item, g_value_get_int (value)); | |||
1552 | break; | |||
1553 | ||||
1554 | default: | |||
1555 | CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); 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'" , "ctktoolitemgroup.c", 1555, ("child 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); | |||
1556 | break; | |||
1557 | } | |||
1558 | } | |||
1559 | ||||
1560 | static void | |||
1561 | ctk_tool_item_group_get_child_property (CtkContainer *container, | |||
1562 | CtkWidget *child, | |||
1563 | guint prop_id, | |||
1564 | GValue *value, | |||
1565 | GParamSpec *pspec) | |||
1566 | { | |||
1567 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (container)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (container), ((ctk_tool_item_group_get_type ( ))))))); | |||
1568 | CtkToolItem *item = CTK_TOOL_ITEM (child)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_tool_item_get_type ())))))); | |||
1569 | gboolean homogeneous, expand, fill, new_row; | |||
1570 | ||||
1571 | if (prop_id != CHILD_PROP_POSITION) | |||
1572 | ctk_tool_item_group_get_item_packing (group, item, | |||
1573 | &homogeneous, | |||
1574 | &expand, | |||
1575 | &fill, | |||
1576 | &new_row); | |||
1577 | ||||
1578 | switch (prop_id) | |||
1579 | { | |||
1580 | case CHILD_PROP_HOMOGENEOUS: | |||
1581 | g_value_set_boolean (value, homogeneous); | |||
1582 | break; | |||
1583 | ||||
1584 | case CHILD_PROP_EXPAND: | |||
1585 | g_value_set_boolean (value, expand); | |||
1586 | break; | |||
1587 | ||||
1588 | case CHILD_PROP_FILL: | |||
1589 | g_value_set_boolean (value, fill); | |||
1590 | break; | |||
1591 | ||||
1592 | case CHILD_PROP_NEW_ROW: | |||
1593 | g_value_set_boolean (value, new_row); | |||
1594 | break; | |||
1595 | ||||
1596 | case CHILD_PROP_POSITION: | |||
1597 | g_value_set_int (value, ctk_tool_item_group_get_item_position (group, item)); | |||
1598 | break; | |||
1599 | ||||
1600 | default: | |||
1601 | CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); 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'" , "ctktoolitemgroup.c", 1601, ("child 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); | |||
1602 | break; | |||
1603 | } | |||
1604 | } | |||
1605 | ||||
1606 | static void | |||
1607 | ctk_tool_item_group_class_init (CtkToolItemGroupClass *cls) | |||
1608 | { | |||
1609 | GObjectClass *oclass = G_OBJECT_CLASS (cls)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((cls)), (((GType) ((20) << (2)))))))); | |||
1610 | CtkWidgetClass *wclass = CTK_WIDGET_CLASS (cls)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((cls)), ((ctk_widget_get_type ())))))); | |||
1611 | CtkContainerClass *cclass = CTK_CONTAINER_CLASS (cls)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((cls)), ((ctk_container_get_type ())))))); | |||
1612 | ||||
1613 | oclass->set_property = ctk_tool_item_group_set_property; | |||
1614 | oclass->get_property = ctk_tool_item_group_get_property; | |||
1615 | oclass->finalize = ctk_tool_item_group_finalize; | |||
1616 | oclass->dispose = ctk_tool_item_group_dispose; | |||
1617 | ||||
1618 | wclass->get_preferred_width = ctk_tool_item_group_get_preferred_width; | |||
1619 | wclass->get_preferred_height = ctk_tool_item_group_get_preferred_height; | |||
1620 | wclass->size_allocate = ctk_tool_item_group_size_allocate; | |||
1621 | wclass->realize = ctk_tool_item_group_realize; | |||
1622 | wclass->unrealize = ctk_tool_item_group_unrealize; | |||
1623 | wclass->style_updated = ctk_tool_item_group_style_updated; | |||
1624 | wclass->screen_changed = ctk_tool_item_group_screen_changed; | |||
1625 | wclass->draw = ctk_tool_item_group_draw; | |||
1626 | wclass->state_flags_changed = ctk_tool_item_group_state_flags_changed; | |||
1627 | ||||
1628 | cclass->add = ctk_tool_item_group_add; | |||
1629 | cclass->remove = ctk_tool_item_group_remove; | |||
1630 | cclass->forall = ctk_tool_item_group_forall; | |||
1631 | cclass->child_type = ctk_tool_item_group_child_type; | |||
1632 | cclass->set_child_property = ctk_tool_item_group_set_child_property; | |||
1633 | cclass->get_child_property = ctk_tool_item_group_get_child_property; | |||
1634 | ||||
1635 | g_object_class_install_property (oclass, PROP_LABEL, | |||
1636 | g_param_spec_string ("label", | |||
1637 | P_("Label")g_dgettext("ctk30" "-properties","Label"), | |||
1638 | P_("The human-readable title of this item group")g_dgettext("ctk30" "-properties","The human-readable title of this item group" ), | |||
1639 | DEFAULT_LABEL"", | |||
1640 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1641 | ||||
1642 | g_object_class_install_property (oclass, PROP_LABEL_WIDGET, | |||
1643 | g_param_spec_object ("label-widget", | |||
1644 | P_("Label widget")g_dgettext("ctk30" "-properties","Label widget"), | |||
1645 | P_("A widget to display in place of the usual label")g_dgettext("ctk30" "-properties","A widget to display in place of the usual label" ), | |||
1646 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), | |||
1647 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1648 | ||||
1649 | g_object_class_install_property (oclass, PROP_COLLAPSED, | |||
1650 | g_param_spec_boolean ("collapsed", | |||
1651 | P_("Collapsed")g_dgettext("ctk30" "-properties","Collapsed"), | |||
1652 | P_("Whether the group has been collapsed and items are hidden")g_dgettext("ctk30" "-properties","Whether the group has been collapsed and items are hidden" ), | |||
1653 | DEFAULT_COLLAPSED(0), | |||
1654 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
1655 | ||||
1656 | g_object_class_install_property (oclass, PROP_ELLIPSIZE, | |||
1657 | g_param_spec_enum ("ellipsize", | |||
1658 | P_("ellipsize")g_dgettext("ctk30" "-properties","ellipsize"), | |||
1659 | P_("Ellipsize for item group headers")g_dgettext("ctk30" "-properties","Ellipsize for item group headers" ), | |||
1660 | PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ()), DEFAULT_ELLIPSIZEPANGO_ELLIPSIZE_NONE, | |||
1661 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
1662 | ||||
1663 | g_object_class_install_property (oclass, PROP_RELIEF, | |||
1664 | g_param_spec_enum ("header-relief", | |||
1665 | P_("Header Relief")g_dgettext("ctk30" "-properties","Header Relief"), | |||
1666 | P_("Relief of the group header button")g_dgettext("ctk30" "-properties","Relief of the group header button" ), | |||
1667 | CTK_TYPE_RELIEF_STYLE(ctk_relief_style_get_type ()), CTK_RELIEF_NORMAL, | |||
1668 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY)); | |||
1669 | ||||
1670 | ctk_widget_class_install_style_property (wclass, | |||
1671 | g_param_spec_int ("expander-size", | |||
1672 | P_("Expander Size")g_dgettext("ctk30" "-properties","Expander Size"), | |||
1673 | P_("Size of the expander arrow")g_dgettext("ctk30" "-properties","Size of the expander arrow" ), | |||
1674 | 0, G_MAXINT2147483647, DEFAULT_EXPANDER_SIZE16, | |||
1675 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1676 | ||||
1677 | ctk_widget_class_install_style_property (wclass, | |||
1678 | g_param_spec_int ("header-spacing", | |||
1679 | P_("Header Spacing")g_dgettext("ctk30" "-properties","Header Spacing"), | |||
1680 | P_("Spacing between expander arrow and caption")g_dgettext("ctk30" "-properties","Spacing between expander arrow and caption" ), | |||
1681 | 0, G_MAXINT2147483647, DEFAULT_HEADER_SPACING2, | |||
1682 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1683 | ||||
1684 | ctk_container_class_install_child_property (cclass, CHILD_PROP_HOMOGENEOUS, | |||
1685 | g_param_spec_boolean ("homogeneous", | |||
1686 | P_("Homogeneous")g_dgettext("ctk30" "-properties","Homogeneous"), | |||
1687 | P_("Whether the item should be the same size as other homogeneous items")g_dgettext("ctk30" "-properties","Whether the item should be the same size as other homogeneous items" ), | |||
1688 | TRUE(!(0)), | |||
1689 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1690 | ||||
1691 | ctk_container_class_install_child_property (cclass, CHILD_PROP_EXPAND, | |||
1692 | g_param_spec_boolean ("expand", | |||
1693 | P_("Expand")g_dgettext("ctk30" "-properties","Expand"), | |||
1694 | P_("Whether the item should receive extra space when the group grows")g_dgettext("ctk30" "-properties","Whether the item should receive extra space when the group grows" ), | |||
1695 | FALSE(0), | |||
1696 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1697 | ||||
1698 | ctk_container_class_install_child_property (cclass, CHILD_PROP_FILL, | |||
1699 | g_param_spec_boolean ("fill", | |||
1700 | P_("Fill")g_dgettext("ctk30" "-properties","Fill"), | |||
1701 | P_("Whether the item should fill the available space")g_dgettext("ctk30" "-properties","Whether the item should fill the available space" ), | |||
1702 | TRUE(!(0)), | |||
1703 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1704 | ||||
1705 | ctk_container_class_install_child_property (cclass, CHILD_PROP_NEW_ROW, | |||
1706 | g_param_spec_boolean ("new-row", | |||
1707 | P_("New Row")g_dgettext("ctk30" "-properties","New Row"), | |||
1708 | P_("Whether the item should start a new row")g_dgettext("ctk30" "-properties","Whether the item should start a new row" ), | |||
1709 | FALSE(0), | |||
1710 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1711 | ||||
1712 | ctk_container_class_install_child_property (cclass, CHILD_PROP_POSITION, | |||
1713 | g_param_spec_int ("position", | |||
1714 | P_("Position")g_dgettext("ctk30" "-properties","Position"), | |||
1715 | P_("Position of the item within this group")g_dgettext("ctk30" "-properties","Position of the item within this group" ), | |||
1716 | 0, | |||
1717 | G_MAXINT2147483647, | |||
1718 | 0, | |||
1719 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); | |||
1720 | ||||
1721 | ctk_widget_class_set_css_name (wclass, "toolitemgroup"); | |||
1722 | } | |||
1723 | ||||
1724 | /** | |||
1725 | * ctk_tool_item_group_new: | |||
1726 | * @label: the label of the new group | |||
1727 | * | |||
1728 | * Creates a new tool item group with label @label. | |||
1729 | * | |||
1730 | * Returns: a new #CtkToolItemGroup. | |||
1731 | * | |||
1732 | * Since: 2.20 | |||
1733 | */ | |||
1734 | CtkWidget* | |||
1735 | ctk_tool_item_group_new (const gchar *label) | |||
1736 | { | |||
1737 | return g_object_new (CTK_TYPE_TOOL_ITEM_GROUP(ctk_tool_item_group_get_type ()), "label", label, NULL((void*)0)); | |||
1738 | } | |||
1739 | ||||
1740 | /** | |||
1741 | * ctk_tool_item_group_set_label: | |||
1742 | * @group: a #CtkToolItemGroup | |||
1743 | * @label: the new human-readable label of of the group | |||
1744 | * | |||
1745 | * Sets the label of the tool item group. The label is displayed in the header | |||
1746 | * of the group. | |||
1747 | * | |||
1748 | * Since: 2.20 | |||
1749 | */ | |||
1750 | void | |||
1751 | ctk_tool_item_group_set_label (CtkToolItemGroup *group, | |||
1752 | const gchar *label) | |||
1753 | { | |||
1754 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
1755 | ||||
1756 | if (!label) | |||
1757 | ctk_tool_item_group_set_label_widget (group, NULL((void*)0)); | |||
1758 | else | |||
1759 | { | |||
1760 | CtkWidget *child = ctk_label_new (label); | |||
1761 | ctk_widget_show (child); | |||
1762 | ||||
1763 | ctk_tool_item_group_set_label_widget (group, child); | |||
1764 | } | |||
1765 | ||||
1766 | g_object_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2)))))))), "label"); | |||
1767 | } | |||
1768 | ||||
1769 | /** | |||
1770 | * ctk_tool_item_group_set_label_widget: | |||
1771 | * @group: a #CtkToolItemGroup | |||
1772 | * @label_widget: the widget to be displayed in place of the usual label | |||
1773 | * | |||
1774 | * Sets the label of the tool item group. | |||
1775 | * The label widget is displayed in the header of the group, in place | |||
1776 | * of the usual label. | |||
1777 | * | |||
1778 | * Since: 2.20 | |||
1779 | */ | |||
1780 | void | |||
1781 | ctk_tool_item_group_set_label_widget (CtkToolItemGroup *group, | |||
1782 | CtkWidget *label_widget) | |||
1783 | { | |||
1784 | CtkToolItemGroupPrivate* priv; | |||
1785 | CtkWidget *alignment; | |||
1786 | ||||
1787 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
1788 | g_return_if_fail (label_widget == NULL || CTK_IS_WIDGET (label_widget))do { if ((label_widget == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((label_widget)); GType __t = ((ctk_widget_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__)), "label_widget == NULL || CTK_IS_WIDGET (label_widget)" ); return; } } while (0); | |||
1789 | g_return_if_fail (label_widget == NULL || ctk_widget_get_parent (label_widget) == NULL)do { if ((label_widget == ((void*)0) || ctk_widget_get_parent (label_widget) == ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "label_widget == NULL || ctk_widget_get_parent (label_widget) == NULL" ); return; } } while (0); | |||
1790 | ||||
1791 | priv = group->priv; | |||
1792 | ||||
1793 | if (priv->label_widget == label_widget) | |||
1794 | return; | |||
1795 | ||||
1796 | alignment = ctk_tool_item_group_get_alignment (group); | |||
1797 | ||||
1798 | if (priv->label_widget) | |||
1799 | { | |||
1800 | ctk_widget_set_state_flags (priv->label_widget, 0, TRUE(!(0))); | |||
1801 | ctk_container_remove (CTK_CONTAINER (alignment)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((alignment)), ((ctk_container_get_type ())))))), priv->label_widget); | |||
1802 | } | |||
1803 | ||||
1804 | ||||
1805 | if (label_widget) | |||
1806 | ctk_container_add (CTK_CONTAINER (alignment)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((alignment)), ((ctk_container_get_type ())))))), label_widget); | |||
1807 | ||||
1808 | priv->label_widget = label_widget; | |||
1809 | ||||
1810 | if (ctk_widget_get_visible (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))))) | |||
1811 | ctk_widget_queue_resize (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
1812 | ||||
1813 | /* Only show the header widget if the group has children: */ | |||
1814 | if (label_widget && priv->children) | |||
1815 | ctk_widget_show (priv->header); | |||
1816 | else | |||
1817 | ctk_widget_hide (priv->header); | |||
1818 | ||||
1819 | g_object_freeze_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2))))))))); | |||
1820 | g_object_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2)))))))), "label-widget"); | |||
1821 | g_object_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2)))))))), "label"); | |||
1822 | g_object_thaw_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2))))))))); | |||
1823 | } | |||
1824 | ||||
1825 | /** | |||
1826 | * ctk_tool_item_group_set_header_relief: | |||
1827 | * @group: a #CtkToolItemGroup | |||
1828 | * @style: the #CtkReliefStyle | |||
1829 | * | |||
1830 | * Set the button relief of the group header. | |||
1831 | * See ctk_button_set_relief() for details. | |||
1832 | * | |||
1833 | * Since: 2.20 | |||
1834 | */ | |||
1835 | void | |||
1836 | ctk_tool_item_group_set_header_relief (CtkToolItemGroup *group, | |||
1837 | CtkReliefStyle style) | |||
1838 | { | |||
1839 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
1840 | ||||
1841 | if (ctk_button_get_relief (CTK_BUTTON (group->priv->header)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->priv->header)), ((ctk_button_get_type ()))) )))) != style) | |||
1842 | { | |||
1843 | ctk_button_set_relief (CTK_BUTTON (group->priv->header)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->priv->header)), ((ctk_button_get_type ()))) ))), style); | |||
1844 | g_object_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2)))))))), "header-relief"); | |||
1845 | } | |||
1846 | } | |||
1847 | ||||
1848 | static gint64 | |||
1849 | ctk_tool_item_group_get_animation_timestamp (CtkToolItemGroup *group) | |||
1850 | { | |||
1851 | return (g_source_get_time (group->priv->animation_timeout) - | |||
1852 | group->priv->animation_start) / 1000; | |||
1853 | } | |||
1854 | ||||
1855 | static void | |||
1856 | ctk_tool_item_group_force_expose (CtkToolItemGroup *group) | |||
1857 | { | |||
1858 | CtkToolItemGroupPrivate* priv = group->priv; | |||
1859 | CtkWidget *widget = CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))); | |||
1860 | ||||
1861 | if (ctk_widget_get_realized (priv->header)) | |||
1862 | { | |||
1863 | CtkAllocation alignment_allocation; | |||
1864 | CtkWidget *alignment = ctk_tool_item_group_get_alignment (group); | |||
1865 | CdkRectangle area; | |||
1866 | ||||
1867 | /* Find the header button's arrow area... */ | |||
1868 | ctk_widget_get_allocation (alignment, &alignment_allocation); | |||
1869 | area.x = alignment_allocation.x; | |||
1870 | area.y = alignment_allocation.y + (alignment_allocation.height - priv->expander_size) / 2; | |||
1871 | area.height = priv->expander_size; | |||
1872 | area.width = priv->expander_size; | |||
1873 | ||||
1874 | /* ... and invalidated it to get it animated. */ | |||
1875 | cdk_window_invalidate_rect (ctk_widget_get_window (priv->header), &area, TRUE(!(0))); | |||
1876 | } | |||
1877 | ||||
1878 | if (ctk_widget_get_realized (widget)) | |||
1879 | { | |||
1880 | CtkAllocation allocation; | |||
1881 | CtkWidget *parent = ctk_widget_get_parent (widget); | |||
1882 | int x, y, width, height; | |||
1883 | ||||
1884 | /* Find the tool item area button's arrow area... */ | |||
1885 | ctk_widget_get_allocation (widget, &allocation); | |||
1886 | width = allocation.width; | |||
1887 | height = allocation.height; | |||
1888 | ||||
1889 | ctk_widget_translate_coordinates (widget, parent, 0, 0, &x, &y); | |||
1890 | ||||
1891 | if (ctk_widget_get_visible (priv->header)) | |||
1892 | { | |||
1893 | CtkAllocation header_allocation; | |||
1894 | ||||
1895 | ctk_widget_get_allocation (priv->header, &header_allocation); | |||
1896 | height -= header_allocation.height; | |||
1897 | y += header_allocation.height; | |||
1898 | } | |||
1899 | ||||
1900 | /* ... and invalidated it to get it animated. */ | |||
1901 | ctk_widget_queue_draw_area (parent, x, y, width, height); | |||
1902 | } | |||
1903 | } | |||
1904 | ||||
1905 | static gboolean | |||
1906 | ctk_tool_item_group_animation_cb (gpointer data) | |||
1907 | { | |||
1908 | CtkToolItemGroup *group = CTK_TOOL_ITEM_GROUP (data)((((CtkToolItemGroup*) (void *) g_type_check_instance_cast (( GTypeInstance*) (data), ((ctk_tool_item_group_get_type ())))) )); | |||
1909 | CtkToolItemGroupPrivate* priv = group->priv; | |||
1910 | gint64 timestamp = ctk_tool_item_group_get_animation_timestamp (group); | |||
1911 | gboolean retval; | |||
1912 | ||||
1913 | cdk_threads_enter (); | |||
1914 | ||||
1915 | /* Enque this early to reduce number of expose events. */ | |||
1916 | ctk_widget_queue_resize_no_redraw (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
1917 | ||||
1918 | ctk_tool_item_group_force_expose (group); | |||
1919 | ||||
1920 | /* Finish animation when done. */ | |||
1921 | if (timestamp >= ANIMATION_DURATION(50 * 4)) | |||
1922 | priv->animation_timeout = NULL((void*)0); | |||
1923 | ||||
1924 | retval = (priv->animation_timeout != NULL((void*)0)); | |||
1925 | ||||
1926 | cdk_threads_leave (); | |||
1927 | ||||
1928 | return retval; | |||
1929 | } | |||
1930 | ||||
1931 | /** | |||
1932 | * ctk_tool_item_group_set_collapsed: | |||
1933 | * @group: a #CtkToolItemGroup | |||
1934 | * @collapsed: whether the @group should be collapsed or expanded | |||
1935 | * | |||
1936 | * Sets whether the @group should be collapsed or expanded. | |||
1937 | * | |||
1938 | * Since: 2.20 | |||
1939 | */ | |||
1940 | void | |||
1941 | ctk_tool_item_group_set_collapsed (CtkToolItemGroup *group, | |||
1942 | gboolean collapsed) | |||
1943 | { | |||
1944 | CtkWidget *parent; | |||
1945 | CtkToolItemGroupPrivate* priv; | |||
1946 | ||||
1947 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
1948 | ||||
1949 | priv = group->priv; | |||
1950 | ||||
1951 | parent = ctk_widget_get_parent (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
1952 | if (CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; })))) && !collapsed) | |||
1953 | _ctk_tool_palette_set_expanding_child (CTK_TOOL_PALETTE (parent)((((CtkToolPalette*) (void *) g_type_check_instance_cast ((GTypeInstance *) (parent), ((ctk_tool_palette_get_type ())))))), | |||
1954 | CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
1955 | if (collapsed != priv->collapsed) | |||
1956 | { | |||
1957 | if (priv->animation) | |||
1958 | { | |||
1959 | if (priv->animation_timeout) | |||
1960 | g_source_destroy (priv->animation_timeout); | |||
1961 | ||||
1962 | priv->animation_start = g_get_monotonic_time (); | |||
1963 | priv->animation_timeout = g_timeout_source_new (ANIMATION_TIMEOUT50); | |||
1964 | ||||
1965 | g_source_set_callback (priv->animation_timeout, | |||
1966 | ctk_tool_item_group_animation_cb, | |||
1967 | group, NULL((void*)0)); | |||
1968 | g_source_attach (priv->animation_timeout, NULL((void*)0)); | |||
1969 | } | |||
1970 | else | |||
1971 | ctk_tool_item_group_force_expose (group); | |||
1972 | ||||
1973 | priv->collapsed = collapsed; | |||
1974 | update_arrow_state (group); | |||
1975 | g_object_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2)))))))), "collapsed"); | |||
1976 | } | |||
1977 | } | |||
1978 | ||||
1979 | /** | |||
1980 | * ctk_tool_item_group_set_ellipsize: | |||
1981 | * @group: a #CtkToolItemGroup | |||
1982 | * @ellipsize: the #PangoEllipsizeMode labels in @group should use | |||
1983 | * | |||
1984 | * Sets the ellipsization mode which should be used by labels in @group. | |||
1985 | * | |||
1986 | * Since: 2.20 | |||
1987 | */ | |||
1988 | void | |||
1989 | ctk_tool_item_group_set_ellipsize (CtkToolItemGroup *group, | |||
1990 | PangoEllipsizeMode ellipsize) | |||
1991 | { | |||
1992 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
1993 | ||||
1994 | if (ellipsize != group->priv->ellipsize) | |||
1995 | { | |||
1996 | group->priv->ellipsize = ellipsize; | |||
1997 | ctk_tool_item_group_header_adjust_style (group); | |||
1998 | g_object_notify (G_OBJECT (group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), (((GType) ((20) << (2)))))))), "ellipsize"); | |||
1999 | _ctk_tool_item_group_palette_reconfigured (group); | |||
2000 | } | |||
2001 | } | |||
2002 | ||||
2003 | /** | |||
2004 | * ctk_tool_item_group_get_label: | |||
2005 | * @group: a #CtkToolItemGroup | |||
2006 | * | |||
2007 | * Gets the label of @group. | |||
2008 | * | |||
2009 | * Returns: the label of @group. The label is an internal string of @group | |||
2010 | * and must not be modified. Note that %NULL is returned if a custom | |||
2011 | * label has been set with ctk_tool_item_group_set_label_widget() | |||
2012 | * | |||
2013 | * Since: 2.20 | |||
2014 | */ | |||
2015 | const gchar* | |||
2016 | ctk_tool_item_group_get_label (CtkToolItemGroup *group) | |||
2017 | { | |||
2018 | CtkToolItemGroupPrivate *priv; | |||
2019 | ||||
2020 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (((void*)0)); } } while (0); | |||
2021 | ||||
2022 | priv = group->priv; | |||
2023 | ||||
2024 | if (CTK_IS_LABEL (priv->label_widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (priv->label_widget)); GType __t = ((ctk_label_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; }))))) | |||
2025 | return ctk_label_get_label (CTK_LABEL (priv->label_widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->label_widget)), ((ctk_label_get_type ()))))))); | |||
2026 | else | |||
2027 | return NULL((void*)0); | |||
2028 | } | |||
2029 | ||||
2030 | /** | |||
2031 | * ctk_tool_item_group_get_label_widget: | |||
2032 | * @group: a #CtkToolItemGroup | |||
2033 | * | |||
2034 | * Gets the label widget of @group. | |||
2035 | * See ctk_tool_item_group_set_label_widget(). | |||
2036 | * | |||
2037 | * Returns: (transfer none): the label widget of @group | |||
2038 | * | |||
2039 | * Since: 2.20 | |||
2040 | */ | |||
2041 | CtkWidget* | |||
2042 | ctk_tool_item_group_get_label_widget (CtkToolItemGroup *group) | |||
2043 | { | |||
2044 | CtkWidget *alignment = ctk_tool_item_group_get_alignment (group); | |||
2045 | ||||
2046 | return ctk_bin_get_child (CTK_BIN (alignment)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((alignment)), ((ctk_bin_get_type ()))))))); | |||
2047 | } | |||
2048 | ||||
2049 | /** | |||
2050 | * ctk_tool_item_group_get_collapsed: | |||
2051 | * @group: a CtkToolItemGroup | |||
2052 | * | |||
2053 | * Gets whether @group is collapsed or expanded. | |||
2054 | * | |||
2055 | * Returns: %TRUE if @group is collapsed, %FALSE if it is expanded | |||
2056 | * | |||
2057 | * Since: 2.20 | |||
2058 | */ | |||
2059 | gboolean | |||
2060 | ctk_tool_item_group_get_collapsed (CtkToolItemGroup *group) | |||
2061 | { | |||
2062 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), DEFAULT_COLLAPSED)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return ((0)); } } while (0); | |||
2063 | ||||
2064 | return group->priv->collapsed; | |||
2065 | } | |||
2066 | ||||
2067 | /** | |||
2068 | * ctk_tool_item_group_get_ellipsize: | |||
2069 | * @group: a #CtkToolItemGroup | |||
2070 | * | |||
2071 | * Gets the ellipsization mode of @group. | |||
2072 | * | |||
2073 | * Returns: the #PangoEllipsizeMode of @group | |||
2074 | * | |||
2075 | * Since: 2.20 | |||
2076 | */ | |||
2077 | PangoEllipsizeMode | |||
2078 | ctk_tool_item_group_get_ellipsize (CtkToolItemGroup *group) | |||
2079 | { | |||
2080 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), DEFAULT_ELLIPSIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (PANGO_ELLIPSIZE_NONE ); } } while (0); | |||
2081 | ||||
2082 | return group->priv->ellipsize; | |||
2083 | } | |||
2084 | ||||
2085 | /** | |||
2086 | * ctk_tool_item_group_get_header_relief: | |||
2087 | * @group: a #CtkToolItemGroup | |||
2088 | * | |||
2089 | * Gets the relief mode of the header button of @group. | |||
2090 | * | |||
2091 | * Returns: the #CtkReliefStyle | |||
2092 | * | |||
2093 | * Since: 2.20 | |||
2094 | */ | |||
2095 | CtkReliefStyle | |||
2096 | ctk_tool_item_group_get_header_relief (CtkToolItemGroup *group) | |||
2097 | { | |||
2098 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), CTK_RELIEF_NORMAL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (CTK_RELIEF_NORMAL ); } } while (0); | |||
2099 | ||||
2100 | return ctk_button_get_relief (CTK_BUTTON (group->priv->header)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group->priv->header)), ((ctk_button_get_type ()))) )))); | |||
2101 | } | |||
2102 | ||||
2103 | /** | |||
2104 | * ctk_tool_item_group_insert: | |||
2105 | * @group: a #CtkToolItemGroup | |||
2106 | * @item: the #CtkToolItem to insert into @group | |||
2107 | * @position: the position of @item in @group, starting with 0. | |||
2108 | * The position -1 means end of list. | |||
2109 | * | |||
2110 | * Inserts @item at @position in the list of children of @group. | |||
2111 | * | |||
2112 | * Since: 2.20 | |||
2113 | */ | |||
2114 | void | |||
2115 | ctk_tool_item_group_insert (CtkToolItemGroup *group, | |||
2116 | CtkToolItem *item, | |||
2117 | gint position) | |||
2118 | { | |||
2119 | CtkWidget *parent, *child_widget; | |||
2120 | CtkToolItemGroupChild *child; | |||
2121 | ||||
2122 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
2123 | g_return_if_fail (CTK_IS_TOOL_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((item)); GType __t = ((ctk_tool_item_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_TOOL_ITEM (item)"); return; } } while (0); | |||
2124 | g_return_if_fail (position >= -1)do { if ((position >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "position >= -1"); return ; } } while (0); | |||
2125 | ||||
2126 | parent = ctk_widget_get_parent (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
2127 | ||||
2128 | child = g_new (CtkToolItemGroupChild, 1)((CtkToolItemGroupChild *) g_malloc_n ((1), sizeof (CtkToolItemGroupChild ))); | |||
2129 | child->item = g_object_ref_sink (item)((__typeof__ (item)) (g_object_ref_sink) (item)); | |||
2130 | child->homogeneous = TRUE(!(0)); | |||
2131 | child->expand = FALSE(0); | |||
2132 | child->fill = TRUE(!(0)); | |||
2133 | child->new_row = FALSE(0); | |||
2134 | ||||
2135 | group->priv->children = g_list_insert (group->priv->children, child, position); | |||
2136 | ||||
2137 | if (CTK_IS_TOOL_PALETTE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( parent); GType __t = ((ctk_tool_palette_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; }))))) | |||
2138 | _ctk_tool_palette_child_set_drag_source (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), parent); | |||
2139 | ||||
2140 | child_widget = ctk_bin_get_child (CTK_BIN (item)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_bin_get_type ()))))))); | |||
2141 | ||||
2142 | ctk_widget_set_focus_on_click (child_widget, TRUE(!(0))); | |||
2143 | ||||
2144 | ctk_widget_set_parent (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
2145 | } | |||
2146 | ||||
2147 | /** | |||
2148 | * ctk_tool_item_group_set_item_position: | |||
2149 | * @group: a #CtkToolItemGroup | |||
2150 | * @item: the #CtkToolItem to move to a new position, should | |||
2151 | * be a child of @group. | |||
2152 | * @position: the new position of @item in @group, starting with 0. | |||
2153 | * The position -1 means end of list. | |||
2154 | * | |||
2155 | * Sets the position of @item in the list of children of @group. | |||
2156 | * | |||
2157 | * Since: 2.20 | |||
2158 | */ | |||
2159 | void | |||
2160 | ctk_tool_item_group_set_item_position (CtkToolItemGroup *group, | |||
2161 | CtkToolItem *item, | |||
2162 | gint position) | |||
2163 | { | |||
2164 | gint old_position; | |||
2165 | GList *link; | |||
2166 | CtkToolItemGroupChild *child; | |||
2167 | CtkToolItemGroupPrivate* priv; | |||
2168 | ||||
2169 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
2170 | g_return_if_fail (CTK_IS_TOOL_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((item)); GType __t = ((ctk_tool_item_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_TOOL_ITEM (item)"); return; } } while (0); | |||
2171 | g_return_if_fail (position >= -1)do { if ((position >= -1)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "position >= -1"); return ; } } while (0); | |||
2172 | ||||
2173 | child = ctk_tool_item_group_get_child (group, item, &old_position, &link); | |||
2174 | priv = group->priv; | |||
2175 | ||||
2176 | g_return_if_fail (child != NULL)do { if ((child != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "child != NULL"); return ; } } while (0); | |||
2177 | ||||
2178 | if (position == old_position) | |||
2179 | return; | |||
2180 | ||||
2181 | priv->children = g_list_delete_link (priv->children, link); | |||
2182 | priv->children = g_list_insert (priv->children, child, position); | |||
2183 | ||||
2184 | ctk_widget_child_notify (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), "position"); | |||
2185 | if (ctk_widget_get_visible (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))) && | |||
2186 | ctk_widget_get_visible (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))))) | |||
2187 | ctk_widget_queue_resize (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ()))))))); | |||
2188 | } | |||
2189 | ||||
2190 | /** | |||
2191 | * ctk_tool_item_group_get_item_position: | |||
2192 | * @group: a #CtkToolItemGroup | |||
2193 | * @item: a #CtkToolItem | |||
2194 | * | |||
2195 | * Gets the position of @item in @group as index. | |||
2196 | * | |||
2197 | * Returns: the index of @item in @group or -1 if @item is no child of @group | |||
2198 | * | |||
2199 | * Since: 2.20 | |||
2200 | */ | |||
2201 | gint | |||
2202 | ctk_tool_item_group_get_item_position (CtkToolItemGroup *group, | |||
2203 | CtkToolItem *item) | |||
2204 | { | |||
2205 | gint position; | |||
2206 | ||||
2207 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (-1); } } while (0); | |||
2208 | g_return_val_if_fail (CTK_IS_TOOL_ITEM (item), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((item)); GType __t = ((ctk_tool_item_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_TOOL_ITEM (item)"); return (-1); } } while (0); | |||
2209 | ||||
2210 | if (ctk_tool_item_group_get_child (group, item, &position, NULL((void*)0))) | |||
2211 | return position; | |||
2212 | ||||
2213 | return -1; | |||
2214 | } | |||
2215 | ||||
2216 | /** | |||
2217 | * ctk_tool_item_group_get_n_items: | |||
2218 | * @group: a #CtkToolItemGroup | |||
2219 | * | |||
2220 | * Gets the number of tool items in @group. | |||
2221 | * | |||
2222 | * Returns: the number of tool items in @group | |||
2223 | * | |||
2224 | * Since: 2.20 | |||
2225 | */ | |||
2226 | guint | |||
2227 | ctk_tool_item_group_get_n_items (CtkToolItemGroup *group) | |||
2228 | { | |||
2229 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (0); } } while ( 0); | |||
2230 | ||||
2231 | return g_list_length (group->priv->children); | |||
2232 | } | |||
2233 | ||||
2234 | /** | |||
2235 | * ctk_tool_item_group_get_nth_item: | |||
2236 | * @group: a #CtkToolItemGroup | |||
2237 | * @index: the index | |||
2238 | * | |||
2239 | * Gets the tool item at @index in group. | |||
2240 | * | |||
2241 | * Returns: (transfer none): the #CtkToolItem at index | |||
2242 | * | |||
2243 | * Since: 2.20 | |||
2244 | */ | |||
2245 | CtkToolItem* | |||
2246 | ctk_tool_item_group_get_nth_item (CtkToolItemGroup *group, | |||
2247 | guint index) | |||
2248 | { | |||
2249 | CtkToolItemGroupChild *child; | |||
2250 | ||||
2251 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (((void*)0)); } } while (0); | |||
2252 | ||||
2253 | child = g_list_nth_data (group->priv->children, index); | |||
2254 | ||||
2255 | return child != NULL((void*)0) ? child->item : NULL((void*)0); | |||
2256 | } | |||
2257 | ||||
2258 | /** | |||
2259 | * ctk_tool_item_group_get_drop_item: | |||
2260 | * @group: a #CtkToolItemGroup | |||
2261 | * @x: the x position | |||
2262 | * @y: the y position | |||
2263 | * | |||
2264 | * Gets the tool item at position (x, y). | |||
2265 | * | |||
2266 | * Returns: (transfer none): the #CtkToolItem at position (x, y) | |||
2267 | * | |||
2268 | * Since: 2.20 | |||
2269 | */ | |||
2270 | CtkToolItem* | |||
2271 | ctk_tool_item_group_get_drop_item (CtkToolItemGroup *group, | |||
2272 | gint x, | |||
2273 | gint y) | |||
2274 | { | |||
2275 | CtkAllocation allocation; | |||
2276 | GList *it; | |||
2277 | ||||
2278 | g_return_val_if_fail (CTK_IS_TOOL_ITEM_GROUP (group), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return (((void*)0)); } } while (0); | |||
2279 | ||||
2280 | ctk_widget_get_allocation (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))), &allocation); | |||
2281 | ||||
2282 | g_return_val_if_fail (x >= 0 && x < allocation.width, NULL)do { if ((x >= 0 && x < allocation.width)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "x >= 0 && x < allocation.width"); return (( (void*)0)); } } while (0); | |||
2283 | g_return_val_if_fail (y >= 0 && y < allocation.height, NULL)do { if ((y >= 0 && y < allocation.height)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "y >= 0 && y < allocation.height"); return ( ((void*)0)); } } while (0); | |||
2284 | ||||
2285 | for (it = group->priv->children; it != NULL((void*)0); it = it->next) | |||
2286 | { | |||
2287 | CtkToolItemGroupChild *child = it->data; | |||
2288 | CtkToolItem *item = child->item; | |||
2289 | gint x0, y0; | |||
2290 | ||||
2291 | if (!item || !ctk_tool_item_group_is_item_visible (group, child)) | |||
2292 | continue; | |||
2293 | ||||
2294 | ctk_widget_get_allocation (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ())))))), &allocation); | |||
2295 | ||||
2296 | x0 = x - allocation.x; | |||
2297 | y0 = y - allocation.y; | |||
2298 | ||||
2299 | if (x0 >= 0 && x0 < allocation.width && | |||
2300 | y0 >= 0 && y0 < allocation.height) | |||
2301 | return item; | |||
2302 | } | |||
2303 | ||||
2304 | return NULL((void*)0); | |||
2305 | } | |||
2306 | ||||
2307 | void | |||
2308 | _ctk_tool_item_group_item_size_request (CtkToolItemGroup *group, | |||
2309 | CtkRequisition *item_size, | |||
2310 | gboolean homogeneous_only, | |||
2311 | gint *requested_rows) | |||
2312 | { | |||
2313 | CtkRequisition child_requisition; | |||
2314 | GList *it; | |||
2315 | gint rows = 0; | |||
2316 | gboolean new_row = TRUE(!(0)); | |||
2317 | ||||
2318 | g_return_if_fail (CTK_IS_TOOL_ITEM_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) (group); GType __t = ((ctk_tool_item_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; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_TOOL_ITEM_GROUP (group)"); return; } } while (0); | |||
2319 | g_return_if_fail (NULL != item_size)do { if ((((void*)0) != item_size)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "NULL != item_size"); return ; } } while (0); | |||
2320 | ||||
2321 | item_size->width = item_size->height = 0; | |||
2322 | ||||
2323 | for (it = group->priv->children; it != NULL((void*)0); it = it->next) | |||
2324 | { | |||
2325 | CtkToolItemGroupChild *child = it->data; | |||
2326 | ||||
2327 | if (!ctk_tool_item_group_is_item_visible (group, child)) | |||
2328 | continue; | |||
2329 | ||||
2330 | if (child->new_row || new_row) | |||
2331 | { | |||
2332 | rows++; | |||
2333 | new_row = FALSE(0); | |||
2334 | } | |||
2335 | ||||
2336 | if (!child->homogeneous && child->expand) | |||
2337 | new_row = TRUE(!(0)); | |||
2338 | ||||
2339 | ctk_widget_get_preferred_size (CTK_WIDGET (child->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child->item)), ((ctk_widget_get_type ())))))), | |||
2340 | &child_requisition, NULL((void*)0)); | |||
2341 | ||||
2342 | if (!homogeneous_only || child->homogeneous) | |||
2343 | item_size->width = MAX (item_size->width, child_requisition.width)(((item_size->width) > (child_requisition.width)) ? (item_size ->width) : (child_requisition.width)); | |||
2344 | item_size->height = MAX (item_size->height, child_requisition.height)(((item_size->height) > (child_requisition.height)) ? ( item_size->height) : (child_requisition.height)); | |||
2345 | } | |||
2346 | ||||
2347 | if (requested_rows
| |||
2348 | *requested_rows = rows; | |||
2349 | } | |||
2350 | ||||
2351 | gint | |||
2352 | _ctk_tool_item_group_get_size_for_limit (CtkToolItemGroup *group, | |||
2353 | gint limit, | |||
2354 | gboolean vertical, | |||
2355 | gboolean animation) | |||
2356 | { | |||
2357 | CtkRequisition requisition; | |||
2358 | CtkToolItemGroupPrivate* priv = group->priv; | |||
2359 | ||||
2360 | ctk_widget_get_preferred_size (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))), | |||
2361 | &requisition, NULL((void*)0)); | |||
2362 | ||||
2363 | if (!priv->collapsed || priv->animation_timeout) | |||
2364 | { | |||
2365 | CtkAllocation allocation = { 0, 0, requisition.width, requisition.height }; | |||
2366 | CtkRequisition inquery; | |||
2367 | ||||
2368 | if (vertical) | |||
2369 | allocation.width = limit; | |||
2370 | else | |||
2371 | allocation.height = limit; | |||
2372 | ||||
2373 | ctk_tool_item_group_real_size_query (CTK_WIDGET (group)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_widget_get_type ())))))), | |||
2374 | &allocation, &inquery); | |||
2375 | ||||
2376 | if (vertical) | |||
2377 | inquery.height -= requisition.height; | |||
2378 | else | |||
2379 | inquery.width -= requisition.width; | |||
2380 | ||||
2381 | if (priv->animation_timeout && animation) | |||
2382 | { | |||
2383 | gint64 timestamp = ctk_tool_item_group_get_animation_timestamp (group); | |||
2384 | ||||
2385 | timestamp = MIN (timestamp, ANIMATION_DURATION)(((timestamp) < ((50 * 4))) ? (timestamp) : ((50 * 4))); | |||
2386 | ||||
2387 | if (priv->collapsed) | |||
2388 | timestamp = ANIMATION_DURATION(50 * 4) - timestamp; | |||
2389 | ||||
2390 | if (vertical) | |||
2391 | { | |||
2392 | inquery.height *= timestamp; | |||
2393 | inquery.height /= ANIMATION_DURATION(50 * 4); | |||
2394 | } | |||
2395 | else | |||
2396 | { | |||
2397 | inquery.width *= timestamp; | |||
2398 | inquery.width /= ANIMATION_DURATION(50 * 4); | |||
2399 | } | |||
2400 | } | |||
2401 | ||||
2402 | if (vertical) | |||
2403 | requisition.height += inquery.height; | |||
2404 | else | |||
2405 | requisition.width += inquery.width; | |||
2406 | } | |||
2407 | ||||
2408 | return (vertical ? requisition.height : requisition.width); | |||
2409 | } | |||
2410 | ||||
2411 | gint | |||
2412 | _ctk_tool_item_group_get_height_for_width (CtkToolItemGroup *group, | |||
2413 | gint width) | |||
2414 | { | |||
2415 | return _ctk_tool_item_group_get_size_for_limit (group, width, TRUE(!(0)), group->priv->animation); | |||
2416 | } | |||
2417 | ||||
2418 | gint | |||
2419 | _ctk_tool_item_group_get_width_for_height (CtkToolItemGroup *group, | |||
2420 | gint height) | |||
2421 | { | |||
2422 | return _ctk_tool_item_group_get_size_for_limit (group, height, FALSE(0), TRUE(!(0))); | |||
2423 | } | |||
2424 | ||||
2425 | static void | |||
2426 | ctk_tool_palette_reconfigured_foreach_item (CtkWidget *child, | |||
2427 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
2428 | { | |||
2429 | if (CTK_IS_TOOL_ITEM (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_tool_item_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; }))))) | |||
2430 | ctk_tool_item_toolbar_reconfigured (CTK_TOOL_ITEM (child)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_tool_item_get_type ()))))))); | |||
2431 | } | |||
2432 | ||||
2433 | ||||
2434 | void | |||
2435 | _ctk_tool_item_group_palette_reconfigured (CtkToolItemGroup *group) | |||
2436 | { | |||
2437 | ctk_container_foreach (CTK_CONTAINER (group)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((group)), ((ctk_container_get_type ())))))), | |||
2438 | ctk_tool_palette_reconfigured_foreach_item, | |||
2439 | NULL((void*)0)); | |||
2440 | ||||
2441 | ctk_tool_item_group_header_adjust_style (group); | |||
2442 | } |