Bug Summary

File:ctk/ctktoolbar.c
Warning:line 1574, column 24
Although the value stored to 'size' is used in the enclosing expression, the value is never actually read from 'size'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ctktoolbar.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.25.5" -D CTK_BINARY_VERSION="3.0.0" -D CTK_COMPILATION -D CTK_PRINT_BACKEND_ENABLE_UNSUPPORTED -D CTK_LIBDIR="/usr/lib" -D CTK_LOCALEDIR="/usr/share/locale" -D CTK_DATADIR="/usr/share" -D CTK_DATA_PREFIX="/usr" -D CTK_SYSCONFDIR="/usr/etc" -D CTK_HOST="x86_64-pc-linux-gnu" -D CTK_PRINT_BACKENDS="file,cups" -D X11_DATA_PREFIX="/usr" -D ISO_CODES_PREFIX="" -I .. -I ../ctk -I .. -I ../cdk -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/ctk -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-171502-43637-1 -x c ctktoolbar.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * CtkToolbar copyright (C) Federico Mena
4 *
5 * Copyright (C) 2002 Anders Carlsson <andersca@gnome.org>
6 * Copyright (C) 2002 James Henstridge <james@daa.com.au>
7 * Copyright (C) 2003, 2004 Soeren Sandmann <sandmann@daimi.au.dk>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS
25 * file for a list of people on the CTK+ Team. See the ChangeLog
26 * files for a list of changes. These files are distributed with
27 * CTK+ at ftp://ftp.ctk.org/pub/ctk/.
28 */
29
30
31#include "config.h"
32
33#include <math.h>
34#include <string.h>
35
36#include "ctktoolbar.h"
37#include "ctktoolbarprivate.h"
38
39#include "ctkbindings.h"
40#include "ctkbox.h"
41#include "ctkcontainerprivate.h"
42#include "ctkcsscustomgadgetprivate.h"
43#include "ctkcssnodeprivate.h"
44#include "ctkimage.h"
45#include "ctkintl.h"
46#include "ctklabel.h"
47#include "ctkmain.h"
48#include "ctkmarshalers.h"
49#include "ctkmenu.h"
50#include "ctkorientable.h"
51#include "ctkorientableprivate.h"
52#include "ctkprivate.h"
53#include "ctkradiobutton.h"
54#include "ctkradiotoolbutton.h"
55#include "ctkrender.h"
56#include "ctkseparatormenuitem.h"
57#include "ctkseparatortoolitem.h"
58#include "ctktoolshell.h"
59#include "ctktypebuiltins.h"
60#include "ctkwidgetpath.h"
61#include "ctkwidgetprivate.h"
62#include "ctkwindowprivate.h"
63
64
65/**
66 * SECTION:ctktoolbar
67 * @Short_description: Create bars of buttons and other widgets
68 * @Title: CtkToolbar
69 * @See_also: #CtkToolItem
70 *
71 * A toolbar is created with a call to ctk_toolbar_new().
72 *
73 * A toolbar can contain instances of a subclass of #CtkToolItem. To add
74 * a #CtkToolItem to the a toolbar, use ctk_toolbar_insert(). To remove
75 * an item from the toolbar use ctk_container_remove(). To add a button
76 * to the toolbar, add an instance of #CtkToolButton.
77 *
78 * Toolbar items can be visually grouped by adding instances of
79 * #CtkSeparatorToolItem to the toolbar. If the CtkToolbar child property
80 * “expand” is #TRUE and the property #CtkSeparatorToolItem:draw is set to
81 * #FALSE, the effect is to force all following items to the end of the toolbar.
82 *
83 * By default, a toolbar can be shrunk, upon which it will add an arrow button
84 * to show an overflow menu offering access to any #CtkToolItem child that has
85 * a proxy menu item. To disable this and request enough size for all children,
86 * call ctk_toolbar_set_show_arrow() to set #CtkToolbar:show-arrow to %FALSE.
87 *
88 * Creating a context menu for the toolbar can be done by connecting to
89 * the #CtkToolbar::popup-context-menu signal.
90 *
91 * # CSS nodes
92 *
93 * CtkToolbar has a single CSS node with name toolbar.
94 */
95
96
97typedef struct _ToolbarContent ToolbarContent;
98
99#define DEFAULT_SPACE_SIZE12 12
100#define DEFAULT_SPACE_STYLECTK_TOOLBAR_SPACE_LINE CTK_TOOLBAR_SPACE_LINE
101#define SPACE_LINE_DIVISION10.0 10.0
102#define SPACE_LINE_START2.0 2.0
103#define SPACE_LINE_END8.0 8.0
104
105#define DEFAULT_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR CTK_ICON_SIZE_LARGE_TOOLBAR
106#define DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_BOTH_HORIZ CTK_TOOLBAR_BOTH_HORIZ
107#define DEFAULT_ANIMATION_STATE(!(0)) TRUE(!(0))
108
109#define MAX_HOMOGENEOUS_N_CHARS13 13 /* Items that are wider than this do not participate
110 * in the homogeneous game. In units of
111 * pango_font_get_estimated_char_width().
112 */
113#define SLIDE_SPEED600.0 600.0 /* How fast the items slide, in pixels per second */
114#define ACCEL_THRESHOLD0.18 0.18 /* After how much time in seconds will items start speeding up */
115
116
117struct _CtkToolbarPrivate
118{
119 CtkMenu *menu;
120 CtkSettings *settings;
121
122 CtkIconSize icon_size;
123 CtkToolbarStyle style;
124
125 CtkToolItem *highlight_tool_item;
126 CtkWidget *arrow;
127 CtkWidget *arrow_button;
128
129 CdkWindow *event_window;
130
131 CtkCssGadget *gadget;
132 CtkAllocation prev_allocation;
133
134 GList *content;
135
136 GTimer *timer;
137
138 gulong settings_connection;
139
140 gint idle_id;
141 gint button_maxw; /* maximum width of homogeneous children */
142 gint button_maxh; /* maximum height of homogeneous children */
143 gint max_homogeneous_pixels;
144 gint num_children;
145
146 CtkOrientation orientation;
147
148 guint animation : 1;
149 guint icon_size_set : 1;
150 guint is_sliding : 1;
151 guint need_rebuild : 1; /* whether the overflow menu should be regenerated */
152 guint need_sync : 1;
153 guint show_arrow : 1;
154 guint style_set : 1;
155};
156
157/* Properties */
158enum {
159 PROP_0,
160 PROP_ORIENTATION,
161 PROP_TOOLBAR_STYLE,
162 PROP_SHOW_ARROW,
163 PROP_TOOLTIPS,
164 PROP_ICON_SIZE,
165 PROP_ICON_SIZE_SET
166};
167
168/* Child properties */
169enum {
170 CHILD_PROP_0,
171 CHILD_PROP_EXPAND,
172 CHILD_PROP_HOMOGENEOUS
173};
174
175/* Signals */
176enum {
177 ORIENTATION_CHANGED,
178 STYLE_CHANGED,
179 POPUP_CONTEXT_MENU,
180 FOCUS_HOME_OR_END,
181 LAST_SIGNAL
182};
183
184typedef enum {
185 NOT_ALLOCATED,
186 NORMAL,
187 HIDDEN,
188 OVERFLOWN
189} ItemState;
190
191
192static void ctk_toolbar_set_property (GObject *object,
193 guint prop_id,
194 const GValue *value,
195 GParamSpec *pspec);
196static void ctk_toolbar_get_property (GObject *object,
197 guint prop_id,
198 GValue *value,
199 GParamSpec *pspec);
200static gint ctk_toolbar_draw (CtkWidget *widget,
201 cairo_t *cr);
202static void ctk_toolbar_realize (CtkWidget *widget);
203static void ctk_toolbar_unrealize (CtkWidget *widget);
204static void ctk_toolbar_get_preferred_width (CtkWidget *widget,
205 gint *minimum,
206 gint *natural);
207static void ctk_toolbar_get_preferred_height (CtkWidget *widget,
208 gint *minimum,
209 gint *natural);
210
211static void ctk_toolbar_size_allocate (CtkWidget *widget,
212 CtkAllocation *allocation);
213static void ctk_toolbar_style_updated (CtkWidget *widget);
214static gboolean ctk_toolbar_focus (CtkWidget *widget,
215 CtkDirectionType dir);
216static void ctk_toolbar_move_focus (CtkWidget *widget,
217 CtkDirectionType dir);
218static void ctk_toolbar_screen_changed (CtkWidget *widget,
219 CdkScreen *previous_screen);
220static void ctk_toolbar_map (CtkWidget *widget);
221static void ctk_toolbar_unmap (CtkWidget *widget);
222static void ctk_toolbar_set_child_property (CtkContainer *container,
223 CtkWidget *child,
224 guint property_id,
225 const GValue *value,
226 GParamSpec *pspec);
227static void ctk_toolbar_get_child_property (CtkContainer *container,
228 CtkWidget *child,
229 guint property_id,
230 GValue *value,
231 GParamSpec *pspec);
232static void ctk_toolbar_finalize (GObject *object);
233static void ctk_toolbar_dispose (GObject *object);
234static void ctk_toolbar_show_all (CtkWidget *widget);
235static void ctk_toolbar_add (CtkContainer *container,
236 CtkWidget *widget);
237static void ctk_toolbar_remove (CtkContainer *container,
238 CtkWidget *widget);
239static void ctk_toolbar_forall (CtkContainer *container,
240 gboolean include_internals,
241 CtkCallback callback,
242 gpointer callback_data);
243static GType ctk_toolbar_child_type (CtkContainer *container);
244
245static void ctk_toolbar_direction_changed (CtkWidget *widget,
246 CtkTextDirection previous_direction);
247static void ctk_toolbar_orientation_changed (CtkToolbar *toolbar,
248 CtkOrientation orientation);
249static void ctk_toolbar_real_style_changed (CtkToolbar *toolbar,
250 CtkToolbarStyle style);
251static gboolean ctk_toolbar_focus_home_or_end (CtkToolbar *toolbar,
252 gboolean focus_home);
253static gboolean ctk_toolbar_button_press (CtkWidget *toolbar,
254 CdkEventButton *event);
255static gboolean ctk_toolbar_arrow_button_press (CtkWidget *button,
256 CdkEventButton *event,
257 CtkToolbar *toolbar);
258static void ctk_toolbar_arrow_button_clicked (CtkWidget *button,
259 CtkToolbar *toolbar);
260static void ctk_toolbar_update_button_relief (CtkToolbar *toolbar);
261static gboolean ctk_toolbar_popup_menu (CtkWidget *toolbar);
262static void ctk_toolbar_reconfigured (CtkToolbar *toolbar);
263
264static void ctk_toolbar_allocate (CtkCssGadget *gadget,
265 const CtkAllocation *allocation,
266 int baseline,
267 CtkAllocation *out_clip,
268 gpointer data);
269static void ctk_toolbar_measure (CtkCssGadget *gadget,
270 CtkOrientation orientation,
271 int for_size,
272 int *minimum,
273 int *natural,
274 int *minimum_baseline,
275 int *natural_baseline,
276 gpointer data);
277static gboolean ctk_toolbar_render (CtkCssGadget *gadget,
278 cairo_t *cr,
279 int x,
280 int y,
281 int width,
282 int height,
283 gpointer data);
284
285static CtkReliefStyle get_button_relief (CtkToolbar *toolbar);
286static gint get_max_child_expand (CtkToolbar *toolbar);
287
288/* methods on ToolbarContent 'class' */
289static ToolbarContent *toolbar_content_new_tool_item (CtkToolbar *toolbar,
290 CtkToolItem *item,
291 gboolean is_placeholder,
292 gint pos);
293static void toolbar_content_remove (ToolbarContent *content,
294 CtkToolbar *toolbar);
295static void toolbar_content_free (ToolbarContent *content);
296static void toolbar_content_draw (ToolbarContent *content,
297 CtkContainer *container,
298 cairo_t *cr);
299static gboolean toolbar_content_visible (ToolbarContent *content,
300 CtkToolbar *toolbar);
301static void toolbar_content_size_request (ToolbarContent *content,
302 CtkToolbar *toolbar,
303 CtkRequisition *requisition);
304static gboolean toolbar_content_is_homogeneous (ToolbarContent *content,
305 CtkToolbar *toolbar);
306static gboolean toolbar_content_is_placeholder (ToolbarContent *content);
307static gboolean toolbar_content_disappearing (ToolbarContent *content);
308static ItemState toolbar_content_get_state (ToolbarContent *content);
309static gboolean toolbar_content_child_visible (ToolbarContent *content);
310static void toolbar_content_get_goal_allocation (ToolbarContent *content,
311 CtkAllocation *allocation);
312static void toolbar_content_get_allocation (ToolbarContent *content,
313 CtkAllocation *allocation);
314static void toolbar_content_set_start_allocation (ToolbarContent *content,
315 CtkAllocation *new_start_allocation);
316static void toolbar_content_get_start_allocation (ToolbarContent *content,
317 CtkAllocation *start_allocation);
318static gboolean toolbar_content_get_expand (ToolbarContent *content);
319static void toolbar_content_set_goal_allocation (ToolbarContent *content,
320 CtkAllocation *allocation);
321static void toolbar_content_set_child_visible (ToolbarContent *content,
322 CtkToolbar *toolbar,
323 gboolean visible);
324static void toolbar_content_size_allocate (ToolbarContent *content,
325 CtkAllocation *allocation);
326static void toolbar_content_set_state (ToolbarContent *content,
327 ItemState new_state);
328static CtkWidget * toolbar_content_get_widget (ToolbarContent *content);
329static void toolbar_content_set_disappearing (ToolbarContent *content,
330 gboolean disappearing);
331static void toolbar_content_set_size_request (ToolbarContent *content,
332 gint width,
333 gint height);
334static void toolbar_content_toolbar_reconfigured (ToolbarContent *content,
335 CtkToolbar *toolbar);
336static CtkWidget * toolbar_content_retrieve_menu_item (ToolbarContent *content);
337static gboolean toolbar_content_has_proxy_menu_item (ToolbarContent *content);
338static gboolean toolbar_content_is_separator (ToolbarContent *content);
339static void toolbar_content_show_all (ToolbarContent *content);
340static void toolbar_content_set_expand (ToolbarContent *content,
341 gboolean expand);
342
343static void toolbar_tool_shell_iface_init (CtkToolShellIface *iface);
344static CtkIconSize toolbar_get_icon_size (CtkToolShell *shell);
345static CtkOrientation toolbar_get_orientation (CtkToolShell *shell);
346static CtkToolbarStyle toolbar_get_style (CtkToolShell *shell);
347static CtkReliefStyle toolbar_get_relief_style (CtkToolShell *shell);
348static void toolbar_rebuild_menu (CtkToolShell *shell);
349
350
351G_DEFINE_TYPE_WITH_CODE (CtkToolbar, ctk_toolbar, CTK_TYPE_CONTAINER,static void ctk_toolbar_init (CtkToolbar *self); static void ctk_toolbar_class_init
(CtkToolbarClass *klass); static GType ctk_toolbar_get_type_once
(void); static gpointer ctk_toolbar_parent_class = ((void*)0
); static gint CtkToolbar_private_offset; static void ctk_toolbar_class_intern_init
(gpointer klass) { ctk_toolbar_parent_class = g_type_class_peek_parent
(klass); if (CtkToolbar_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkToolbar_private_offset); ctk_toolbar_class_init
((CtkToolbarClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ctk_toolbar_get_instance_private (CtkToolbar
*self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkToolbar_private_offset
)))); } GType ctk_toolbar_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_toolbar_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_toolbar_get_type_once (void)
{ GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkToolbar"), sizeof (CtkToolbarClass
), (GClassInitFunc)(void (*)(void)) ctk_toolbar_class_intern_init
, sizeof (CtkToolbar), (GInstanceInitFunc)(void (*)(void)) ctk_toolbar_init
, (GTypeFlags) 0); { {{ CtkToolbar_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkToolbarPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) toolbar_tool_shell_iface_init, ((void*)0), ((void*)0)
}; g_type_add_interface_static (g_define_type_id, (ctk_tool_shell_get_type
()), &g_implement_interface_info); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
352 G_ADD_PRIVATE (CtkToolbar)static void ctk_toolbar_init (CtkToolbar *self); static void ctk_toolbar_class_init
(CtkToolbarClass *klass); static GType ctk_toolbar_get_type_once
(void); static gpointer ctk_toolbar_parent_class = ((void*)0
); static gint CtkToolbar_private_offset; static void ctk_toolbar_class_intern_init
(gpointer klass) { ctk_toolbar_parent_class = g_type_class_peek_parent
(klass); if (CtkToolbar_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkToolbar_private_offset); ctk_toolbar_class_init
((CtkToolbarClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ctk_toolbar_get_instance_private (CtkToolbar
*self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkToolbar_private_offset
)))); } GType ctk_toolbar_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_toolbar_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_toolbar_get_type_once (void)
{ GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkToolbar"), sizeof (CtkToolbarClass
), (GClassInitFunc)(void (*)(void)) ctk_toolbar_class_intern_init
, sizeof (CtkToolbar), (GInstanceInitFunc)(void (*)(void)) ctk_toolbar_init
, (GTypeFlags) 0); { {{ CtkToolbar_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkToolbarPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) toolbar_tool_shell_iface_init, ((void*)0), ((void*)0)
}; g_type_add_interface_static (g_define_type_id, (ctk_tool_shell_get_type
()), &g_implement_interface_info); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
353 G_IMPLEMENT_INTERFACE (CTK_TYPE_TOOL_SHELL,static void ctk_toolbar_init (CtkToolbar *self); static void ctk_toolbar_class_init
(CtkToolbarClass *klass); static GType ctk_toolbar_get_type_once
(void); static gpointer ctk_toolbar_parent_class = ((void*)0
); static gint CtkToolbar_private_offset; static void ctk_toolbar_class_intern_init
(gpointer klass) { ctk_toolbar_parent_class = g_type_class_peek_parent
(klass); if (CtkToolbar_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkToolbar_private_offset); ctk_toolbar_class_init
((CtkToolbarClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ctk_toolbar_get_instance_private (CtkToolbar
*self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkToolbar_private_offset
)))); } GType ctk_toolbar_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_toolbar_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_toolbar_get_type_once (void)
{ GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkToolbar"), sizeof (CtkToolbarClass
), (GClassInitFunc)(void (*)(void)) ctk_toolbar_class_intern_init
, sizeof (CtkToolbar), (GInstanceInitFunc)(void (*)(void)) ctk_toolbar_init
, (GTypeFlags) 0); { {{ CtkToolbar_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkToolbarPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) toolbar_tool_shell_iface_init, ((void*)0), ((void*)0)
}; g_type_add_interface_static (g_define_type_id, (ctk_tool_shell_get_type
()), &g_implement_interface_info); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
354 toolbar_tool_shell_iface_init)static void ctk_toolbar_init (CtkToolbar *self); static void ctk_toolbar_class_init
(CtkToolbarClass *klass); static GType ctk_toolbar_get_type_once
(void); static gpointer ctk_toolbar_parent_class = ((void*)0
); static gint CtkToolbar_private_offset; static void ctk_toolbar_class_intern_init
(gpointer klass) { ctk_toolbar_parent_class = g_type_class_peek_parent
(klass); if (CtkToolbar_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkToolbar_private_offset); ctk_toolbar_class_init
((CtkToolbarClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ctk_toolbar_get_instance_private (CtkToolbar
*self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkToolbar_private_offset
)))); } GType ctk_toolbar_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_toolbar_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_toolbar_get_type_once (void)
{ GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkToolbar"), sizeof (CtkToolbarClass
), (GClassInitFunc)(void (*)(void)) ctk_toolbar_class_intern_init
, sizeof (CtkToolbar), (GInstanceInitFunc)(void (*)(void)) ctk_toolbar_init
, (GTypeFlags) 0); { {{ CtkToolbar_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkToolbarPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) toolbar_tool_shell_iface_init, ((void*)0), ((void*)0)
}; g_type_add_interface_static (g_define_type_id, (ctk_tool_shell_get_type
()), &g_implement_interface_info); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
355 G_IMPLEMENT_INTERFACE (CTK_TYPE_ORIENTABLE,static void ctk_toolbar_init (CtkToolbar *self); static void ctk_toolbar_class_init
(CtkToolbarClass *klass); static GType ctk_toolbar_get_type_once
(void); static gpointer ctk_toolbar_parent_class = ((void*)0
); static gint CtkToolbar_private_offset; static void ctk_toolbar_class_intern_init
(gpointer klass) { ctk_toolbar_parent_class = g_type_class_peek_parent
(klass); if (CtkToolbar_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkToolbar_private_offset); ctk_toolbar_class_init
((CtkToolbarClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ctk_toolbar_get_instance_private (CtkToolbar
*self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkToolbar_private_offset
)))); } GType ctk_toolbar_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_toolbar_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_toolbar_get_type_once (void)
{ GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkToolbar"), sizeof (CtkToolbarClass
), (GClassInitFunc)(void (*)(void)) ctk_toolbar_class_intern_init
, sizeof (CtkToolbar), (GInstanceInitFunc)(void (*)(void)) ctk_toolbar_init
, (GTypeFlags) 0); { {{ CtkToolbar_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkToolbarPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) toolbar_tool_shell_iface_init, ((void*)0), ((void*)0)
}; g_type_add_interface_static (g_define_type_id, (ctk_tool_shell_get_type
()), &g_implement_interface_info); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
356 NULL))static void ctk_toolbar_init (CtkToolbar *self); static void ctk_toolbar_class_init
(CtkToolbarClass *klass); static GType ctk_toolbar_get_type_once
(void); static gpointer ctk_toolbar_parent_class = ((void*)0
); static gint CtkToolbar_private_offset; static void ctk_toolbar_class_intern_init
(gpointer klass) { ctk_toolbar_parent_class = g_type_class_peek_parent
(klass); if (CtkToolbar_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkToolbar_private_offset); ctk_toolbar_class_init
((CtkToolbarClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer ctk_toolbar_get_instance_private (CtkToolbar
*self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkToolbar_private_offset
)))); } GType ctk_toolbar_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_toolbar_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_toolbar_get_type_once (void)
{ GType g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkToolbar"), sizeof (CtkToolbarClass
), (GClassInitFunc)(void (*)(void)) ctk_toolbar_class_intern_init
, sizeof (CtkToolbar), (GInstanceInitFunc)(void (*)(void)) ctk_toolbar_init
, (GTypeFlags) 0); { {{ CtkToolbar_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkToolbarPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) toolbar_tool_shell_iface_init, ((void*)0), ((void*)0)
}; g_type_add_interface_static (g_define_type_id, (ctk_tool_shell_get_type
()), &g_implement_interface_info); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
357
358static guint toolbar_signals[LAST_SIGNAL] = { 0 };
359
360
361static void
362add_arrow_bindings (CtkBindingSet *binding_set,
363 guint keysym,
364 CtkDirectionType dir)
365{
366 guint keypad_keysym = keysym - CDK_KEY_Left0xff51 + CDK_KEY_KP_Left0xff96;
367
368 ctk_binding_entry_add_signal (binding_set, keysym, 0,
369 "move-focus", 1,
370 CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), dir);
371 ctk_binding_entry_add_signal (binding_set, keypad_keysym, 0,
372 "move-focus", 1,
373 CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), dir);
374}
375
376static void
377add_ctrl_tab_bindings (CtkBindingSet *binding_set,
378 CdkModifierType modifiers,
379 CtkDirectionType direction)
380{
381 ctk_binding_entry_add_signal (binding_set,
382 CDK_KEY_Tab0xff09, CDK_CONTROL_MASK | modifiers,
383 "move-focus", 1,
384 CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction);
385 ctk_binding_entry_add_signal (binding_set,
386 CDK_KEY_KP_Tab0xff89, CDK_CONTROL_MASK | modifiers,
387 "move-focus", 1,
388 CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction);
389}
390
391static void
392ctk_toolbar_class_init (CtkToolbarClass *klass)
393{
394 GObjectClass *gobject_class;
395 CtkWidgetClass *widget_class;
396 CtkContainerClass *container_class;
397 CtkBindingSet *binding_set;
398
399 gobject_class = (GObjectClass *)klass;
400 widget_class = (CtkWidgetClass *)klass;
401 container_class = (CtkContainerClass *)klass;
402
403 gobject_class->set_property = ctk_toolbar_set_property;
404 gobject_class->get_property = ctk_toolbar_get_property;
405 gobject_class->finalize = ctk_toolbar_finalize;
406 gobject_class->dispose = ctk_toolbar_dispose;
407
408 widget_class->button_press_event = ctk_toolbar_button_press;
409 widget_class->draw = ctk_toolbar_draw;
410 widget_class->get_preferred_width = ctk_toolbar_get_preferred_width;
411 widget_class->get_preferred_height = ctk_toolbar_get_preferred_height;
412 widget_class->size_allocate = ctk_toolbar_size_allocate;
413 widget_class->style_updated = ctk_toolbar_style_updated;
414 widget_class->focus = ctk_toolbar_focus;
415
416 ctk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TOOL_BAR);
417
418 /* need to override the base class function via override_class_handler,
419 * because the signal slot is not available in CtkWidgetClass
420 */
421 g_signal_override_class_handler ("move-focus",
422 CTK_TYPE_TOOLBAR(ctk_toolbar_get_type ()),
423 G_CALLBACK (ctk_toolbar_move_focus)((GCallback) (ctk_toolbar_move_focus)));
424
425 widget_class->screen_changed = ctk_toolbar_screen_changed;
426 widget_class->realize = ctk_toolbar_realize;
427 widget_class->unrealize = ctk_toolbar_unrealize;
428 widget_class->map = ctk_toolbar_map;
429 widget_class->unmap = ctk_toolbar_unmap;
430 widget_class->popup_menu = ctk_toolbar_popup_menu;
431 widget_class->show_all = ctk_toolbar_show_all;
432 widget_class->direction_changed = ctk_toolbar_direction_changed;
433
434 container_class->add = ctk_toolbar_add;
435 container_class->remove = ctk_toolbar_remove;
436 container_class->forall = ctk_toolbar_forall;
437 container_class->child_type = ctk_toolbar_child_type;
438 container_class->get_child_property = ctk_toolbar_get_child_property;
439 container_class->set_child_property = ctk_toolbar_set_child_property;
440
441 ctk_container_class_handle_border_width (container_class);
442
443 klass->orientation_changed = ctk_toolbar_orientation_changed;
444 klass->style_changed = ctk_toolbar_real_style_changed;
445
446 /**
447 * CtkToolbar::orientation-changed:
448 * @toolbar: the object which emitted the signal
449 * @orientation: the new #CtkOrientation of the toolbar
450 *
451 * Emitted when the orientation of the toolbar changes.
452 */
453 toolbar_signals[ORIENTATION_CHANGED] =
454 g_signal_new (I_("orientation-changed")g_intern_static_string ("orientation-changed"),
455 G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)),
456 G_SIGNAL_RUN_FIRST,
457 G_STRUCT_OFFSET (CtkToolbarClass, orientation_changed)((glong) __builtin_offsetof(CtkToolbarClass, orientation_changed
))
,
458 NULL((void*)0), NULL((void*)0),
459 NULL((void*)0),
460 G_TYPE_NONE((GType) ((1) << (2))), 1,
461 CTK_TYPE_ORIENTATION(ctk_orientation_get_type ()));
462 /**
463 * CtkToolbar::style-changed:
464 * @toolbar: The #CtkToolbar which emitted the signal
465 * @style: the new #CtkToolbarStyle of the toolbar
466 *
467 * Emitted when the style of the toolbar changes.
468 */
469 toolbar_signals[STYLE_CHANGED] =
470 g_signal_new (I_("style-changed")g_intern_static_string ("style-changed"),
471 G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)),
472 G_SIGNAL_RUN_FIRST,
473 G_STRUCT_OFFSET (CtkToolbarClass, style_changed)((glong) __builtin_offsetof(CtkToolbarClass, style_changed)),
474 NULL((void*)0), NULL((void*)0),
475 NULL((void*)0),
476 G_TYPE_NONE((GType) ((1) << (2))), 1,
477 CTK_TYPE_TOOLBAR_STYLE(ctk_toolbar_style_get_type ()));
478 /**
479 * CtkToolbar::popup-context-menu:
480 * @toolbar: the #CtkToolbar which emitted the signal
481 * @x: the x coordinate of the point where the menu should appear
482 * @y: the y coordinate of the point where the menu should appear
483 * @button: the mouse button the user pressed, or -1
484 *
485 * Emitted when the user right-clicks the toolbar or uses the
486 * keybinding to display a popup menu.
487 *
488 * Application developers should handle this signal if they want
489 * to display a context menu on the toolbar. The context-menu should
490 * appear at the coordinates given by @x and @y. The mouse button
491 * number is given by the @button parameter. If the menu was popped
492 * up using the keybaord, @button is -1.
493 *
494 * Returns: return %TRUE if the signal was handled, %FALSE if not
495 */
496 toolbar_signals[POPUP_CONTEXT_MENU] =
497 g_signal_new (I_("popup-context-menu")g_intern_static_string ("popup-context-menu"),
498 G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)),
499 G_SIGNAL_RUN_LAST,
500 G_STRUCT_OFFSET (CtkToolbarClass, popup_context_menu)((glong) __builtin_offsetof(CtkToolbarClass, popup_context_menu
))
,
501 _ctk_boolean_handled_accumulator, NULL((void*)0),
502 _ctk_marshal_BOOLEAN__INT_INT_INT,
503 G_TYPE_BOOLEAN((GType) ((5) << (2))), 3,
504 G_TYPE_INT((GType) ((6) << (2))), G_TYPE_INT((GType) ((6) << (2))),
505 G_TYPE_INT((GType) ((6) << (2))));
506
507 /**
508 * CtkToolbar::focus-home-or-end:
509 * @toolbar: the #CtkToolbar which emitted the signal
510 * @focus_home: %TRUE if the first item should be focused
511 *
512 * A keybinding signal used internally by CTK+. This signal can't
513 * be used in application code
514 *
515 * Returns: %TRUE if the signal was handled, %FALSE if not
516 */
517 toolbar_signals[FOCUS_HOME_OR_END] =
518 g_signal_new_class_handler (I_("focus-home-or-end")g_intern_static_string ("focus-home-or-end"),
519 G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)),
520 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
521 G_CALLBACK (ctk_toolbar_focus_home_or_end)((GCallback) (ctk_toolbar_focus_home_or_end)),
522 NULL((void*)0), NULL((void*)0),
523 _ctk_marshal_BOOLEAN__BOOLEAN,
524 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
525 G_TYPE_BOOLEAN((GType) ((5) << (2))));
526
527 /* properties */
528 g_object_class_override_property (gobject_class,
529 PROP_ORIENTATION,
530 "orientation");
531
532 g_object_class_install_property (gobject_class,
533 PROP_TOOLBAR_STYLE,
534 g_param_spec_enum ("toolbar-style",
535 P_("Toolbar Style")g_dgettext("ctk30" "-properties","Toolbar Style"),
536 P_("How to draw the toolbar")g_dgettext("ctk30" "-properties","How to draw the toolbar"),
537 CTK_TYPE_TOOLBAR_STYLE(ctk_toolbar_style_get_type ()),
538 DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_BOTH_HORIZ,
539 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY));
540 g_object_class_install_property (gobject_class,
541 PROP_SHOW_ARROW,
542 g_param_spec_boolean ("show-arrow",
543 P_("Show Arrow")g_dgettext("ctk30" "-properties","Show Arrow"),
544 P_("If an arrow should be shown if the toolbar doesn't fit")g_dgettext("ctk30" "-properties","If an arrow should be shown if the toolbar doesn't fit"
)
,
545 TRUE(!(0)),
546 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY));
547
548 /**
549 * CtkToolbar:icon-size:
550 *
551 * The size of the icons in a toolbar is normally determined by
552 * the toolbar-icon-size setting. When this property is set, it
553 * overrides the setting.
554 *
555 * This should only be used for special-purpose toolbars, normal
556 * application toolbars should respect the user preferences for the
557 * size of icons.
558 *
559 * Since: 2.10
560 */
561 g_object_class_install_property (gobject_class,
562 PROP_ICON_SIZE,
563 g_param_spec_enum ("icon-size",
564 P_("Icon size")g_dgettext("ctk30" "-properties","Icon size"),
565 P_("Size of icons in this toolbar")g_dgettext("ctk30" "-properties","Size of icons in this toolbar"
)
,
566 CTK_TYPE_ICON_SIZE(ctk_icon_size_get_type ()),
567 DEFAULT_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR,
568 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY));
569
570 /**
571 * CtkToolbar:icon-size-set:
572 *
573 * Is %TRUE if the icon-size property has been set.
574 *
575 * Since: 2.10
576 */
577 g_object_class_install_property (gobject_class,
578 PROP_ICON_SIZE_SET,
579 g_param_spec_boolean ("icon-size-set",
580 P_("Icon size set")g_dgettext("ctk30" "-properties","Icon size set"),
581 P_("Whether the icon-size property has been set")g_dgettext("ctk30" "-properties","Whether the icon-size property has been set"
)
,
582 FALSE(0),
583 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
584
585 /* child properties */
586 ctk_container_class_install_child_property (container_class,
587 CHILD_PROP_EXPAND,
588 g_param_spec_boolean ("expand",
589 P_("Expand")g_dgettext("ctk30" "-properties","Expand"),
590 P_("Whether the item should receive extra space when the toolbar grows")g_dgettext("ctk30" "-properties","Whether the item should receive extra space when the toolbar grows"
)
,
591 FALSE(0),
592 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
593
594 ctk_container_class_install_child_property (container_class,
595 CHILD_PROP_HOMOGENEOUS,
596 g_param_spec_boolean ("homogeneous",
597 P_("Homogeneous")g_dgettext("ctk30" "-properties","Homogeneous"),
598 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"
)
,
599 FALSE(0),
600 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
601
602 /**
603 * CtkToolbar:space-size:
604 *
605 * Size of toolbar spacers.
606 *
607 * Deprecated: 3.20: Use the standard margin/padding CSS properties on the
608 * separator elements; the value of this style property is ignored.
609 */
610 ctk_widget_class_install_style_property (widget_class,
611 g_param_spec_int ("space-size",
612 P_("Spacer size")g_dgettext("ctk30" "-properties","Spacer size"),
613 P_("Size of spacers")g_dgettext("ctk30" "-properties","Size of spacers"),
614 0,
615 G_MAXINT2147483647,
616 DEFAULT_SPACE_SIZE12,
617 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED));
618
619 /**
620 * CtkToolbar:internal-padding:
621 *
622 * Amount of border space between the toolbar shadow and the buttons.
623 *
624 * Deprecated: 3.6: Use the standard padding CSS property
625 * (through objects like #CtkStyleContext and #CtkCssProvider); the value
626 * of this style property is ignored.
627 */
628 ctk_widget_class_install_style_property (widget_class,
629 g_param_spec_int ("internal-padding",
630 P_("Internal padding")g_dgettext("ctk30" "-properties","Internal padding"),
631 P_("Amount of border space between the toolbar shadow and the buttons")g_dgettext("ctk30" "-properties","Amount of border space between the toolbar shadow and the buttons"
)
,
632 0,
633 G_MAXINT2147483647,
634 0,
635 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED));
636
637 ctk_widget_class_install_style_property (widget_class,
638 g_param_spec_int ("max-child-expand",
639 P_("Maximum child expand")g_dgettext("ctk30" "-properties","Maximum child expand"),
640 P_("Maximum amount of space an expandable item will be given")g_dgettext("ctk30" "-properties","Maximum amount of space an expandable item will be given"
)
,
641 0,
642 G_MAXINT2147483647,
643 G_MAXINT2147483647,
644 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
645
646 /**
647 * CtkToolbar:space-style:
648 *
649 * Style of toolbar spacers.
650 *
651 * Deprecated: 3.20: Use CSS properties on the separator elements to style
652 * toolbar spacers; the value of this style property is ignored.
653 */
654 ctk_widget_class_install_style_property (widget_class,
655 g_param_spec_enum ("space-style",
656 P_("Space style")g_dgettext("ctk30" "-properties","Space style"),
657 P_("Whether spacers are vertical lines or just blank")g_dgettext("ctk30" "-properties","Whether spacers are vertical lines or just blank"
)
,
658 CTK_TYPE_TOOLBAR_SPACE_STYLE(ctk_toolbar_space_style_get_type ()),
659 DEFAULT_SPACE_STYLECTK_TOOLBAR_SPACE_LINE,
660 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED));
661
662 ctk_widget_class_install_style_property (widget_class,
663 g_param_spec_enum ("button-relief",
664 P_("Button relief")g_dgettext("ctk30" "-properties","Button relief"),
665 P_("Type of bevel around toolbar buttons")g_dgettext("ctk30" "-properties","Type of bevel around toolbar buttons"
)
,
666 CTK_TYPE_RELIEF_STYLE(ctk_relief_style_get_type ()),
667 CTK_RELIEF_NONE,
668 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
669 /**
670 * CtkToolbar:shadow-type:
671 *
672 * Style of bevel around the toolbar.
673 *
674 * Deprecated: 3.6: Use the standard border CSS property
675 * (through objects like #CtkStyleContext and #CtkCssProvider); the value
676 * of this style property is ignored.
677 */
678 ctk_widget_class_install_style_property (widget_class,
679 g_param_spec_enum ("shadow-type",
680 P_("Shadow type")g_dgettext("ctk30" "-properties","Shadow type"),
681 P_("Style of bevel around the toolbar")g_dgettext("ctk30" "-properties","Style of bevel around the toolbar"
)
,
682 CTK_TYPE_SHADOW_TYPE(ctk_shadow_type_get_type ()),
683 CTK_SHADOW_OUT,
684 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED));
685
686 binding_set = ctk_binding_set_by_class (klass);
687
688 add_arrow_bindings (binding_set, CDK_KEY_Left0xff51, CTK_DIR_LEFT);
689 add_arrow_bindings (binding_set, CDK_KEY_Right0xff53, CTK_DIR_RIGHT);
690 add_arrow_bindings (binding_set, CDK_KEY_Up0xff52, CTK_DIR_UP);
691 add_arrow_bindings (binding_set, CDK_KEY_Down0xff54, CTK_DIR_DOWN);
692
693 ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Home0xff95, 0,
694 "focus-home-or-end", 1,
695 G_TYPE_BOOLEAN((GType) ((5) << (2))), TRUE(!(0)));
696 ctk_binding_entry_add_signal (binding_set, CDK_KEY_Home0xff50, 0,
697 "focus-home-or-end", 1,
698 G_TYPE_BOOLEAN((GType) ((5) << (2))), TRUE(!(0)));
699 ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_End0xff9c, 0,
700 "focus-home-or-end", 1,
701 G_TYPE_BOOLEAN((GType) ((5) << (2))), FALSE(0));
702 ctk_binding_entry_add_signal (binding_set, CDK_KEY_End0xff57, 0,
703 "focus-home-or-end", 1,
704 G_TYPE_BOOLEAN((GType) ((5) << (2))), FALSE(0));
705
706 add_ctrl_tab_bindings (binding_set, 0, CTK_DIR_TAB_FORWARD);
707 add_ctrl_tab_bindings (binding_set, CDK_SHIFT_MASK, CTK_DIR_TAB_BACKWARD);
708
709 ctk_widget_class_set_css_name (widget_class, "toolbar");
710}
711
712static void
713toolbar_tool_shell_iface_init (CtkToolShellIface *iface)
714{
715 iface->get_icon_size = toolbar_get_icon_size;
716 iface->get_orientation = toolbar_get_orientation;
717 iface->get_style = toolbar_get_style;
718 iface->get_relief_style = toolbar_get_relief_style;
719 iface->rebuild_menu = toolbar_rebuild_menu;
720}
721
722static void
723ctk_toolbar_init (CtkToolbar *toolbar)
724{
725 CtkToolbarPrivate *priv;
726 CtkWidget *widget;
727 CtkCssNode *widget_node;
728
729 widget = CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
;
730 toolbar->priv = ctk_toolbar_get_instance_private (toolbar);
731 priv = toolbar->priv;
732
733 ctk_widget_set_can_focus (widget, FALSE(0));
734 ctk_widget_set_has_window (widget, FALSE(0));
735
736 priv->orientation = CTK_ORIENTATION_HORIZONTAL;
737 priv->style = DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_BOTH_HORIZ;
738 priv->icon_size = DEFAULT_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR;
739 priv->animation = DEFAULT_ANIMATION_STATE(!(0));
740
741 _ctk_orientable_set_style_classes (CTK_ORIENTABLE (toolbar)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_orientable_get_type ()))))))
);
742
743 widget_node = ctk_widget_get_css_node (widget);
744 priv->gadget = ctk_css_custom_gadget_new_for_node (widget_node,
745 widget,
746 ctk_toolbar_measure,
747 ctk_toolbar_allocate,
748 ctk_toolbar_render,
749 NULL((void*)0), NULL((void*)0));
750
751 priv->arrow_button = ctk_toggle_button_new ();
752 g_signal_connect (priv->arrow_button, "button-press-event",g_signal_connect_data ((priv->arrow_button), ("button-press-event"
), (((GCallback) (ctk_toolbar_arrow_button_press))), (toolbar
), ((void*)0), (GConnectFlags) 0)
753 G_CALLBACK (ctk_toolbar_arrow_button_press), toolbar)g_signal_connect_data ((priv->arrow_button), ("button-press-event"
), (((GCallback) (ctk_toolbar_arrow_button_press))), (toolbar
), ((void*)0), (GConnectFlags) 0)
;
754 g_signal_connect (priv->arrow_button, "clicked",g_signal_connect_data ((priv->arrow_button), ("clicked"), (
((GCallback) (ctk_toolbar_arrow_button_clicked))), (toolbar),
((void*)0), (GConnectFlags) 0)
755 G_CALLBACK (ctk_toolbar_arrow_button_clicked), toolbar)g_signal_connect_data ((priv->arrow_button), ("clicked"), (
((GCallback) (ctk_toolbar_arrow_button_clicked))), (toolbar),
((void*)0), (GConnectFlags) 0)
;
756 ctk_button_set_relief (CTK_BUTTON (priv->arrow_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_button_get_type ()))))))
,
757 get_button_relief (toolbar));
758
759 ctk_widget_set_focus_on_click (priv->arrow_button, FALSE(0));
760
761 priv->arrow = ctk_image_new_from_icon_name ("pan-down-symbolic", CTK_ICON_SIZE_BUTTON);
762 ctk_widget_set_name (priv->arrow, "ctk-toolbar-arrow");
763 ctk_widget_show (priv->arrow);
764 ctk_container_add (CTK_CONTAINER (priv->arrow_button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_container_get_type ()))))
))
, priv->arrow);
765
766 ctk_widget_set_parent (priv->arrow_button, widget);
767
768 /* which child position a drop will occur at */
769 priv->menu = NULL((void*)0);
770 priv->show_arrow = TRUE(!(0));
771 priv->settings = NULL((void*)0);
772
773 priv->max_homogeneous_pixels = -1;
774
775 priv->timer = g_timer_new ();
776}
777
778static void
779ctk_toolbar_set_property (GObject *object,
780 guint prop_id,
781 const GValue *value,
782 GParamSpec *pspec)
783{
784 CtkToolbar *toolbar = CTK_TOOLBAR (object)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_toolbar_get_type ()))))))
;
785 CtkToolbarPrivate *priv = toolbar->priv;
786
787 switch (prop_id)
788 {
789 case PROP_ORIENTATION:
790 g_signal_emit (toolbar, toolbar_signals[ORIENTATION_CHANGED], 0,
791 g_value_get_enum (value));
792 break;
793 case PROP_TOOLBAR_STYLE:
794 ctk_toolbar_set_style (toolbar, g_value_get_enum (value));
795 break;
796 case PROP_SHOW_ARROW:
797 ctk_toolbar_set_show_arrow (toolbar, g_value_get_boolean (value));
798 break;
799 case PROP_ICON_SIZE:
800 ctk_toolbar_set_icon_size (toolbar, g_value_get_enum (value));
801 break;
802 case PROP_ICON_SIZE_SET:
803 if (g_value_get_boolean (value))
804 priv->icon_size_set = TRUE(!(0));
805 else
806 ctk_toolbar_unset_icon_size (toolbar);
807 break;
808 default:
809 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'"
, "ctktoolbar.c", 809, ("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)
;
810 break;
811 }
812}
813
814static void
815ctk_toolbar_get_property (GObject *object,
816 guint prop_id,
817 GValue *value,
818 GParamSpec *pspec)
819{
820 CtkToolbar *toolbar = CTK_TOOLBAR (object)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_toolbar_get_type ()))))))
;
821 CtkToolbarPrivate *priv = toolbar->priv;
822
823 switch (prop_id)
824 {
825 case PROP_ORIENTATION:
826 g_value_set_enum (value, priv->orientation);
827 break;
828 case PROP_TOOLBAR_STYLE:
829 g_value_set_enum (value, priv->style);
830 break;
831 case PROP_SHOW_ARROW:
832 g_value_set_boolean (value, priv->show_arrow);
833 break;
834 case PROP_ICON_SIZE:
835 g_value_set_enum (value, ctk_toolbar_get_icon_size (toolbar));
836 break;
837 case PROP_ICON_SIZE_SET:
838 g_value_set_boolean (value, priv->icon_size_set);
839 break;
840 default:
841 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'"
, "ctktoolbar.c", 841, ("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)
;
842 break;
843 }
844}
845
846static void
847ctk_toolbar_map (CtkWidget *widget)
848{
849 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
850 CtkToolbarPrivate *priv = toolbar->priv;
851
852 CTK_WIDGET_CLASS (ctk_toolbar_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_toolbar_parent_class)), ((ctk_widget_get_type ()))))
))
->map (widget);
853
854 if (priv->event_window)
855 cdk_window_show_unraised (priv->event_window);
856}
857
858static void
859ctk_toolbar_unmap (CtkWidget *widget)
860{
861 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
862 CtkToolbarPrivate *priv = toolbar->priv;
863
864 if (priv->event_window)
865 cdk_window_hide (priv->event_window);
866
867 CTK_WIDGET_CLASS (ctk_toolbar_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_toolbar_parent_class)), ((ctk_widget_get_type ()))))
))
->unmap (widget);
868}
869
870static void
871ctk_toolbar_realize (CtkWidget *widget)
872{
873 CtkAllocation allocation;
874 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
875 CtkToolbarPrivate *priv = toolbar->priv;
876 CdkWindow *window;
877 CdkWindowAttr attributes;
878 gint attributes_mask;
879
880 ctk_widget_set_realized (widget, TRUE(!(0)));
881
882 ctk_widget_get_allocation (widget, &allocation);
883
884 attributes.wclass = CDK_INPUT_ONLY;
885 attributes.window_type = CDK_WINDOW_CHILD;
886 attributes.x = allocation.x;
887 attributes.y = allocation.y;
888 attributes.width = allocation.width;
889 attributes.height = allocation.height;
890 attributes.event_mask = ctk_widget_get_events (widget);
891 attributes.event_mask |= (CDK_BUTTON_PRESS_MASK |
892 CDK_BUTTON_RELEASE_MASK |
893 CDK_POINTER_MOTION_MASK |
894 CDK_ENTER_NOTIFY_MASK |
895 CDK_LEAVE_NOTIFY_MASK);
896
897 attributes_mask = CDK_WA_X | CDK_WA_Y;
898
899 window = ctk_widget_get_parent_window (widget);
900 ctk_widget_set_window (widget, window);
901 g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window));
902
903 priv->event_window = cdk_window_new (ctk_widget_get_parent_window (widget),
904 &attributes, attributes_mask);
905 ctk_widget_register_window (widget, priv->event_window);
906}
907
908static void
909ctk_toolbar_unrealize (CtkWidget *widget)
910{
911 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
912 CtkToolbarPrivate *priv = toolbar->priv;
913
914 if (priv->event_window)
915 {
916 ctk_widget_unregister_window (widget, priv->event_window);
917 cdk_window_destroy (priv->event_window);
918 priv->event_window = NULL((void*)0);
919 }
920
921 CTK_WIDGET_CLASS (ctk_toolbar_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_toolbar_parent_class)), ((ctk_widget_get_type ()))))
))
->unrealize (widget);
922}
923
924static gboolean
925ctk_toolbar_render (CtkCssGadget *gadget,
926 cairo_t *cr,
927 int x G_GNUC_UNUSED__attribute__ ((__unused__)),
928 int y G_GNUC_UNUSED__attribute__ ((__unused__)),
929 int width G_GNUC_UNUSED__attribute__ ((__unused__)),
930 int height G_GNUC_UNUSED__attribute__ ((__unused__)),
931 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
932{
933 CtkWidget *widget = ctk_css_gadget_get_owner (gadget);
934 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
935 CtkToolbarPrivate *priv = toolbar->priv;
936 GList *list;
937
938 for (list = priv->content; list != NULL((void*)0); list = list->next)
939 {
940 ToolbarContent *content = list->data;
941
942 toolbar_content_draw (content, CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
, cr);
943 }
944
945 ctk_container_propagate_draw (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
946 priv->arrow_button,
947 cr);
948
949 return FALSE(0);
950}
951
952static gint
953ctk_toolbar_draw (CtkWidget *widget,
954 cairo_t *cr)
955{
956 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
957 CtkToolbarPrivate *priv = toolbar->priv;
958
959 ctk_css_gadget_draw (priv->gadget, cr);
960
961 return FALSE(0);
962}
963
964static void
965ctk_toolbar_measure (CtkCssGadget *gadget,
966 CtkOrientation orientation,
967 int for_size G_GNUC_UNUSED__attribute__ ((__unused__)),
968 int *minimum,
969 int *natural,
970 int *minimum_baseline G_GNUC_UNUSED__attribute__ ((__unused__)),
971 int *natural_baseline G_GNUC_UNUSED__attribute__ ((__unused__)),
972 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
973{
974 CtkWidget *widget = ctk_css_gadget_get_owner (gadget);
975 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
976 CtkToolbarPrivate *priv = toolbar->priv;
977 GList *list;
978 gint max_child_height;
979 gint max_child_width;
980 gint max_homogeneous_child_width;
981 gint max_homogeneous_child_height;
982 gint homogeneous_size;
983 gint pack_front_size;
984 CtkRequisition arrow_requisition, min_requisition, nat_requisition;
985
986 max_homogeneous_child_width = 0;
987 max_homogeneous_child_height = 0;
988 max_child_width = 0;
989 max_child_height = 0;
990 for (list = priv->content; list != NULL((void*)0); list = list->next)
991 {
992 CtkRequisition requisition;
993 ToolbarContent *content = list->data;
994
995 if (!toolbar_content_visible (content, toolbar))
996 continue;
997
998 toolbar_content_size_request (content, toolbar, &requisition);
999
1000 max_child_width = MAX (max_child_width, requisition.width)(((max_child_width) > (requisition.width)) ? (max_child_width
) : (requisition.width))
;
1001 max_child_height = MAX (max_child_height, requisition.height)(((max_child_height) > (requisition.height)) ? (max_child_height
) : (requisition.height))
;
1002
1003 if (toolbar_content_is_homogeneous (content, toolbar))
1004 {
1005 max_homogeneous_child_width = MAX (max_homogeneous_child_width, requisition.width)(((max_homogeneous_child_width) > (requisition.width)) ? (
max_homogeneous_child_width) : (requisition.width))
;
1006 max_homogeneous_child_height = MAX (max_homogeneous_child_height, requisition.height)(((max_homogeneous_child_height) > (requisition.height)) ?
(max_homogeneous_child_height) : (requisition.height))
;
1007 }
1008 }
1009
1010 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1011 homogeneous_size = max_homogeneous_child_width;
1012 else
1013 homogeneous_size = max_homogeneous_child_height;
1014
1015 pack_front_size = 0;
1016 for (list = priv->content; list != NULL((void*)0); list = list->next)
1017 {
1018 ToolbarContent *content = list->data;
1019 guint size;
1020
1021 if (!toolbar_content_visible (content, toolbar))
1022 continue;
1023
1024 if (toolbar_content_is_homogeneous (content, toolbar))
1025 {
1026 size = homogeneous_size;
1027 }
1028 else
1029 {
1030 CtkRequisition requisition;
1031
1032 toolbar_content_size_request (content, toolbar, &requisition);
1033
1034 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1035 size = requisition.width;
1036 else
1037 size = requisition.height;
1038 }
1039
1040 pack_front_size += size;
1041 }
1042
1043 arrow_requisition.height = 0;
1044 arrow_requisition.width = 0;
1045
1046 if (priv->show_arrow)
1047 ctk_widget_get_preferred_size (priv->arrow_button,
1048 &arrow_requisition, NULL((void*)0));
1049
1050 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1051 {
1052 nat_requisition.width = pack_front_size;
1053 nat_requisition.height = MAX (max_child_height, arrow_requisition.height)(((max_child_height) > (arrow_requisition.height)) ? (max_child_height
) : (arrow_requisition.height))
;
1054
1055 min_requisition.width = priv->show_arrow ? arrow_requisition.width : nat_requisition.width;
1056 min_requisition.height = nat_requisition.height;
1057 }
1058 else
1059 {
1060 nat_requisition.width = MAX (max_child_width, arrow_requisition.width)(((max_child_width) > (arrow_requisition.width)) ? (max_child_width
) : (arrow_requisition.width))
;
1061 nat_requisition.height = pack_front_size;
1062
1063 min_requisition.width = nat_requisition.width;
1064 min_requisition.height = priv->show_arrow ? arrow_requisition.height : nat_requisition.height;
1065 }
1066
1067 priv->button_maxw = max_homogeneous_child_width;
1068 priv->button_maxh = max_homogeneous_child_height;
1069
1070 if (orientation == CTK_ORIENTATION_HORIZONTAL)
1071 {
1072 *minimum = min_requisition.width;
1073 *natural = nat_requisition.width;
1074 }
1075 else
1076 {
1077 *minimum = min_requisition.height;
1078 *natural = nat_requisition.height;
1079 }
1080}
1081
1082static void
1083ctk_toolbar_get_preferred_width (CtkWidget *widget,
1084 gint *minimum,
1085 gint *natural)
1086{
1087 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
1088 CtkToolbarPrivate *priv = toolbar->priv;
1089
1090 ctk_css_gadget_get_preferred_size (priv->gadget,
1091 CTK_ORIENTATION_HORIZONTAL,
1092 -1,
1093 minimum, natural,
1094 NULL((void*)0), NULL((void*)0));
1095}
1096
1097static void
1098ctk_toolbar_get_preferred_height (CtkWidget *widget,
1099 gint *minimum,
1100 gint *natural)
1101{
1102 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
1103 CtkToolbarPrivate *priv = toolbar->priv;
1104
1105 ctk_css_gadget_get_preferred_size (priv->gadget,
1106 CTK_ORIENTATION_VERTICAL,
1107 -1,
1108 minimum, natural,
1109 NULL((void*)0), NULL((void*)0));
1110}
1111
1112static gint
1113position (CtkToolbar *toolbar,
1114 gint from,
1115 gint to,
1116 gdouble elapsed)
1117{
1118 CtkToolbarPrivate *priv = toolbar->priv;
1119 gint n_pixels;
1120
1121 if (!priv->animation)
1122 return to;
1123
1124 if (elapsed <= ACCEL_THRESHOLD0.18)
1125 {
1126 n_pixels = SLIDE_SPEED600.0 * elapsed;
1127 }
1128 else
1129 {
1130 /* The formula is a second degree polynomial in
1131 * @elapsed that has the line SLIDE_SPEED * @elapsed
1132 * as tangent for @elapsed == ACCEL_THRESHOLD.
1133 * This makes @n_pixels a smooth function of elapsed time.
1134 */
1135 n_pixels = (SLIDE_SPEED600.0 / ACCEL_THRESHOLD0.18) * elapsed * elapsed -
1136 SLIDE_SPEED600.0 * elapsed + SLIDE_SPEED600.0 * ACCEL_THRESHOLD0.18;
1137 }
1138
1139 if (to > from)
1140 return MIN (from + n_pixels, to)(((from + n_pixels) < (to)) ? (from + n_pixels) : (to));
1141 else
1142 return MAX (from - n_pixels, to)(((from - n_pixels) > (to)) ? (from - n_pixels) : (to));
1143}
1144
1145static void
1146compute_intermediate_allocation (CtkToolbar *toolbar,
1147 const CtkAllocation *start,
1148 const CtkAllocation *goal,
1149 CtkAllocation *intermediate)
1150{
1151 CtkToolbarPrivate *priv = toolbar->priv;
1152 gdouble elapsed = g_timer_elapsed (priv->timer, NULL((void*)0));
1153
1154 intermediate->x = position (toolbar, start->x, goal->x, elapsed);
1155 intermediate->y = position (toolbar, start->y, goal->y, elapsed);
1156 intermediate->width = position (toolbar, start->x + start->width,
1157 goal->x + goal->width,
1158 elapsed) - intermediate->x;
1159 intermediate->height = position (toolbar, start->y + start->height,
1160 goal->y + goal->height,
1161 elapsed) - intermediate->y;
1162}
1163
1164static void
1165fixup_allocation_for_rtl (gint total_size,
1166 CtkAllocation *allocation)
1167{
1168 allocation->x += (total_size - (2 * allocation->x + allocation->width));
1169}
1170
1171static void
1172fixup_allocation_for_vertical (CtkAllocation *allocation)
1173{
1174 gint tmp;
1175
1176 tmp = allocation->x;
1177 allocation->x = allocation->y;
1178 allocation->y = tmp;
1179
1180 tmp = allocation->width;
1181 allocation->width = allocation->height;
1182 allocation->height = tmp;
1183}
1184
1185static gint
1186get_item_size (CtkToolbar *toolbar,
1187 ToolbarContent *content)
1188{
1189 CtkToolbarPrivate *priv = toolbar->priv;
1190 CtkRequisition requisition;
1191
1192 toolbar_content_size_request (content, toolbar, &requisition);
1193
1194 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1195 {
1196 if (toolbar_content_is_homogeneous (content, toolbar))
1197 return priv->button_maxw;
1198 else
1199 return requisition.width;
1200 }
1201 else
1202 {
1203 if (toolbar_content_is_homogeneous (content, toolbar))
1204 return priv->button_maxh;
1205 else
1206 return requisition.height;
1207 }
1208}
1209
1210static gboolean
1211slide_idle_handler (gpointer data)
1212{
1213 CtkToolbar *toolbar = CTK_TOOLBAR (data)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((ctk_toolbar_get_type ()))))))
;
1214 CtkToolbarPrivate *priv = toolbar->priv;
1215 GList *list;
1216
1217 if (priv->need_sync)
1218 {
1219 cdk_display_flush (ctk_widget_get_display (data));
1220 priv->need_sync = FALSE(0);
1221 }
1222
1223 for (list = priv->content; list != NULL((void*)0); list = list->next)
1224 {
1225 ToolbarContent *content = list->data;
1226 ItemState state;
1227 CtkAllocation goal_allocation;
1228 CtkAllocation allocation;
1229 gboolean cont;
1230
1231 state = toolbar_content_get_state (content);
1232 toolbar_content_get_goal_allocation (content, &goal_allocation);
1233 toolbar_content_get_allocation (content, &allocation);
1234
1235 cont = FALSE(0);
1236
1237 if (state == NOT_ALLOCATED)
1238 {
1239 /* an unallocated item means that size allocate has to
1240 * called at least once more
1241 */
1242 cont = TRUE(!(0));
1243 }
1244
1245 /* An invisible item with a goal allocation of
1246 * 0 is already at its goal.
1247 */
1248 if ((state == NORMAL || state == OVERFLOWN) &&
1249 ((goal_allocation.width != 0 &&
1250 goal_allocation.height != 0) ||
1251 toolbar_content_child_visible (content)))
1252 {
1253 if ((goal_allocation.x != allocation.x ||
1254 goal_allocation.y != allocation.y ||
1255 goal_allocation.width != allocation.width ||
1256 goal_allocation.height != allocation.height))
1257 {
1258 /* An item is not in its right position yet. Note
1259 * that OVERFLOWN items do get an allocation in
1260 * ctk_toolbar_size_allocate(). This way you can see
1261 * them slide back in when you drag an item off the
1262 * toolbar.
1263 */
1264 cont = TRUE(!(0));
1265 }
1266 }
1267
1268 if (toolbar_content_is_placeholder (content) &&
1269 toolbar_content_disappearing (content) &&
1270 toolbar_content_child_visible (content))
1271 {
1272 /* A disappearing placeholder is still visible.
1273 */
1274
1275 cont = TRUE(!(0));
1276 }
1277
1278 if (cont)
1279 {
1280 ctk_widget_queue_resize_no_redraw (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
1281
1282 return TRUE(!(0));
1283 }
1284 }
1285
1286 ctk_widget_queue_resize_no_redraw (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
1287
1288 priv->is_sliding = FALSE(0);
1289 priv->idle_id = 0;
1290
1291 return FALSE(0);
1292}
1293
1294static gboolean
1295rect_within (CtkAllocation *a1,
1296 CtkAllocation *a2)
1297{
1298 return (a1->x >= a2->x &&
1299 a1->x + a1->width <= a2->x + a2->width &&
1300 a1->y >= a2->y &&
1301 a1->y + a1->height <= a2->y + a2->height);
1302}
1303
1304static void
1305ctk_toolbar_begin_sliding (CtkToolbar *toolbar)
1306{
1307 CtkAllocation content_allocation;
1308 CtkWidget *widget = CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
;
1309 CtkToolbarPrivate *priv = toolbar->priv;
1310 GList *list;
1311 gint cur_x;
1312 gint cur_y;
1313 gboolean rtl;
1314 gboolean vertical;
1315
1316 /* Start the sliding. This function copies the allocation of every
1317 * item into content->start_allocation. For items that haven't
1318 * been allocated yet, we calculate their position and save that
1319 * in start_allocatino along with zero width and zero height.
1320 *
1321 * FIXME: It would be nice if we could share this code with
1322 * the equivalent in ctk_widget_size_allocate().
1323 */
1324 priv->is_sliding = TRUE(!(0));
1325
1326 if (!priv->idle_id)
1327 {
1328 priv->idle_id = cdk_threads_add_idle (slide_idle_handler, toolbar);
1329 g_source_set_name_by_id (priv->idle_id, "[ctk+] slide_idle_handler");
1330 }
1331
1332 ctk_css_gadget_get_content_allocation (priv->gadget,
1333 &content_allocation, NULL((void*)0));
1334
1335 rtl = (ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL);
1336 vertical = (priv->orientation == CTK_ORIENTATION_VERTICAL);
1337
1338 if (rtl)
1339 {
1340 cur_x = content_allocation.width;
1341 cur_y = content_allocation.height;
1342 }
1343 else
1344 {
1345 cur_x = 0;
1346 cur_y = 0;
1347 }
1348
1349 cur_x += content_allocation.x;
1350 cur_y += content_allocation.y;
1351
1352 for (list = priv->content; list != NULL((void*)0); list = list->next)
1353 {
1354 ToolbarContent *content = list->data;
1355 CtkAllocation new_start_allocation;
1356 CtkAllocation item_allocation;
1357 ItemState state;
1358
1359 state = toolbar_content_get_state (content);
1360 toolbar_content_get_allocation (content, &item_allocation);
1361
1362 if ((state == NORMAL &&
1363 rect_within (&item_allocation, &content_allocation)) ||
1364 state == OVERFLOWN)
1365 {
1366 new_start_allocation = item_allocation;
1367 }
1368 else
1369 {
1370 new_start_allocation.x = cur_x;
1371 new_start_allocation.y = cur_y;
1372
1373 if (vertical)
1374 {
1375 new_start_allocation.width = content_allocation.width;
1376 new_start_allocation.height = 0;
1377 }
1378 else
1379 {
1380 new_start_allocation.width = 0;
1381 new_start_allocation.height = content_allocation.height;
1382 }
1383 }
1384
1385 if (vertical)
1386 cur_y = new_start_allocation.y + new_start_allocation.height;
1387 else if (rtl)
1388 cur_x = new_start_allocation.x;
1389 else
1390 cur_x = new_start_allocation.x + new_start_allocation.width;
1391
1392 toolbar_content_set_start_allocation (content, &new_start_allocation);
1393 }
1394
1395 /* This resize will run before the first idle handler. This
1396 * will make sure that items get the right goal allocation
1397 * so that the idle handler will not immediately return
1398 * FALSE
1399 */
1400 ctk_widget_queue_resize_no_redraw (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
1401 g_timer_reset (priv->timer);
1402}
1403
1404static void
1405ctk_toolbar_stop_sliding (CtkToolbar *toolbar)
1406{
1407 CtkToolbarPrivate *priv = toolbar->priv;
1408
1409 if (priv->is_sliding)
1410 {
1411 GList *list;
1412
1413 priv->is_sliding = FALSE(0);
1414
1415 if (priv->idle_id)
1416 {
1417 g_source_remove (priv->idle_id);
1418 priv->idle_id = 0;
1419 }
1420
1421 list = priv->content;
1422 while (list)
1423 {
1424 ToolbarContent *content = list->data;
1425 list = list->next;
1426
1427 if (toolbar_content_is_placeholder (content))
1428 {
1429 toolbar_content_remove (content, toolbar);
1430 toolbar_content_free (content);
1431 }
1432 }
1433
1434 ctk_widget_queue_resize_no_redraw (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
1435 }
1436}
1437
1438static void
1439remove_item (CtkWidget *menu_item,
1440 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
1441{
1442 ctk_container_remove (CTK_CONTAINER (ctk_widget_get_parent (menu_item))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_widget_get_parent (menu_item))), ((ctk_container_get_type
()))))))
,
1443 menu_item);
1444}
1445
1446static void
1447menu_deactivated (CtkWidget *menu G_GNUC_UNUSED__attribute__ ((__unused__)),
1448 CtkToolbar *toolbar)
1449{
1450 CtkToolbarPrivate *priv = toolbar->priv;
1451
1452 ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->arrow_button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_toggle_button_get_type ()
))))))
, FALSE(0));
1453}
1454
1455static void
1456menu_detached (CtkWidget *widget,
1457 CtkMenu *menu G_GNUC_UNUSED__attribute__ ((__unused__)))
1458{
1459 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
1460 CtkToolbarPrivate *priv = toolbar->priv;
1461
1462 priv->menu = NULL((void*)0);
1463}
1464
1465static void
1466rebuild_menu (CtkToolbar *toolbar)
1467{
1468 CtkToolbarPrivate *priv = toolbar->priv;
1469 GList *list, *children;
1470
1471 if (!priv->menu)
1472 {
1473 priv->menu = CTK_MENU (ctk_menu_new ())((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_menu_new ())), ((ctk_menu_get_type ()))))))
;
1474 ctk_menu_attach_to_widget (priv->menu,
1475 CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
,
1476 menu_detached);
1477
1478 g_signal_connect (priv->menu, "deactivate",g_signal_connect_data ((priv->menu), ("deactivate"), (((GCallback
) (menu_deactivated))), (toolbar), ((void*)0), (GConnectFlags
) 0)
1479 G_CALLBACK (menu_deactivated), toolbar)g_signal_connect_data ((priv->menu), ("deactivate"), (((GCallback
) (menu_deactivated))), (toolbar), ((void*)0), (GConnectFlags
) 0)
;
1480 }
1481
1482 ctk_container_foreach (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_container_get_type ()))))))
, remove_item, NULL((void*)0));
1483
1484 for (list = priv->content; list != NULL((void*)0); list = list->next)
1485 {
1486 ToolbarContent *content = list->data;
1487
1488 if (toolbar_content_get_state (content) == OVERFLOWN &&
1489 !toolbar_content_is_placeholder (content))
1490 {
1491 CtkWidget *menu_item = toolbar_content_retrieve_menu_item (content);
1492
1493 if (menu_item)
1494 {
1495 g_assert (CTK_IS_MENU_ITEM (menu_item))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menu_item)); GType __t = ((ctk_menu_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_assertion_message_expr ("Ctk", "ctktoolbar.c", 1495, ((const
char*) (__func__)), "CTK_IS_MENU_ITEM (menu_item)"); } while
(0)
;
1496 ctk_menu_shell_append (CTK_MENU_SHELL (priv->menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_menu_shell_get_type ()))))))
, menu_item);
1497 }
1498 }
1499 }
1500
1501 /* Remove leading and trailing separator items */
1502 children = ctk_container_get_children (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_container_get_type ()))))))
);
1503
1504 list = children;
1505 while (list && CTK_IS_SEPARATOR_MENU_ITEM (list->data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(list->data)); GType __t = ((ctk_separator_menu_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; }))))
)
1506 {
1507 CtkWidget *child = list->data;
1508
1509 ctk_container_remove (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_container_get_type ()))))))
, child);
1510 list = list->next;
1511 }
1512 g_list_free (children);
1513
1514 /* Regenerate the list of children so we don't try to remove items twice */
1515 children = ctk_container_get_children (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_container_get_type ()))))))
);
1516
1517 list = g_list_last (children);
1518 while (list && CTK_IS_SEPARATOR_MENU_ITEM (list->data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(list->data)); GType __t = ((ctk_separator_menu_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; }))))
)
1519 {
1520 CtkWidget *child = list->data;
1521
1522 ctk_container_remove (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_container_get_type ()))))))
, child);
1523 list = list->prev;
1524 }
1525 g_list_free (children);
1526
1527 priv->need_rebuild = FALSE(0);
1528}
1529
1530static void
1531ctk_toolbar_allocate (CtkCssGadget *gadget,
1532 const CtkAllocation *allocation,
1533 int baseline G_GNUC_UNUSED__attribute__ ((__unused__)),
1534 CtkAllocation *out_clip G_GNUC_UNUSED__attribute__ ((__unused__)),
1535 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
1536{
1537 CtkWidget *widget = ctk_css_gadget_get_owner (gadget);
1538 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
1539 CtkToolbarPrivate *priv = toolbar->priv;
1540 CtkAllocation arrow_allocation, item_area, widget_allocation;
1541 CtkAllocation *allocations;
1542 ItemState *new_states;
1543 gint arrow_size;
1544 gint size, pos, short_size;
1545 GList *list;
1546 gint i;
1547 gboolean need_arrow;
1548 gint n_expand_items;
1549 gint available_size;
1550 gint n_items;
1551 gint needed_size;
1552 CtkRequisition arrow_requisition;
1553 gboolean overflowing;
1554 gboolean size_changed;
1555
1556 ctk_widget_get_allocation (widget, &widget_allocation);
1557 size_changed = FALSE(0);
1558 if (widget_allocation.x != priv->prev_allocation.x ||
1559 widget_allocation.y != priv->prev_allocation.y ||
1560 widget_allocation.width != priv->prev_allocation.width ||
1561 widget_allocation.height != priv->prev_allocation.height)
1562 {
1563 size_changed = TRUE(!(0));
1564 }
1565
1566 if (size_changed)
1567 ctk_toolbar_stop_sliding (toolbar);
1568
1569 ctk_widget_get_preferred_size (priv->arrow_button,
1570 &arrow_requisition, NULL((void*)0));
1571
1572 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1573 {
1574 available_size = size = allocation->width;
Although the value stored to 'size' is used in the enclosing expression, the value is never actually read from 'size'
1575 short_size = allocation->height;
1576 arrow_size = arrow_requisition.width;
1577 }
1578 else
1579 {
1580 available_size = size = allocation->height;
1581 short_size = allocation->width;
1582 arrow_size = arrow_requisition.height;
1583 }
1584
1585 n_items = g_list_length (priv->content);
1586 allocations = g_new0 (CtkAllocation, n_items)((CtkAllocation *) g_malloc0_n ((n_items), sizeof (CtkAllocation
)))
;
1587 new_states = g_new0 (ItemState, n_items)((ItemState *) g_malloc0_n ((n_items), sizeof (ItemState)));
1588
1589 needed_size = 0;
1590 need_arrow = FALSE(0);
1591 for (list = priv->content; list != NULL((void*)0); list = list->next)
1592 {
1593 ToolbarContent *content = list->data;
1594
1595 if (toolbar_content_visible (content, toolbar))
1596 {
1597 needed_size += get_item_size (toolbar, content);
1598
1599 /* Do we need an arrow?
1600 *
1601 * Assume we don't, and see if any non-separator item
1602 * with a proxy menu item is then going to overflow.
1603 */
1604 if (needed_size > available_size &&
1605 !need_arrow &&
1606 priv->show_arrow &&
1607 toolbar_content_has_proxy_menu_item (content) &&
1608 !toolbar_content_is_separator (content))
1609 {
1610 need_arrow = TRUE(!(0));
1611 }
1612 }
1613 }
1614
1615 if (need_arrow)
1616 size = available_size - arrow_size;
1617 else
1618 size = available_size;
1619
1620 /* calculate widths and states of items */
1621 overflowing = FALSE(0);
1622 for (list = priv->content, i = 0; list != NULL((void*)0); list = list->next, ++i)
1623 {
1624 ToolbarContent *content = list->data;
1625 gint item_size;
1626
1627 if (!toolbar_content_visible (content, toolbar))
1628 {
1629 new_states[i] = HIDDEN;
1630 continue;
1631 }
1632
1633 item_size = get_item_size (toolbar, content);
1634 if (item_size <= size && !overflowing)
1635 {
1636 size -= item_size;
1637 allocations[i].width = item_size;
1638 new_states[i] = NORMAL;
1639 }
1640 else
1641 {
1642 overflowing = TRUE(!(0));
1643 new_states[i] = OVERFLOWN;
1644 allocations[i].width = item_size;
1645 }
1646 }
1647
1648 /* calculate width of arrow */
1649 if (need_arrow)
1650 {
1651 arrow_allocation.width = arrow_size;
1652 arrow_allocation.height = MAX (short_size, 1)(((short_size) > (1)) ? (short_size) : (1));
1653 }
1654
1655 /* expand expandable items */
1656
1657 /* We don't expand when there is an overflow menu,
1658 * because that leads to weird jumps when items get
1659 * moved to the overflow menu and the expanding
1660 * items suddenly get a lot of extra space
1661 */
1662 if (!overflowing)
1663 {
1664 gint max_child_expand;
1665 n_expand_items = 0;
1666
1667 for (i = 0, list = priv->content; list != NULL((void*)0); list = list->next, ++i)
1668 {
1669 ToolbarContent *content = list->data;
1670
1671 if (toolbar_content_get_expand (content) && new_states[i] == NORMAL)
1672 n_expand_items++;
1673 }
1674
1675 max_child_expand = get_max_child_expand (toolbar);
1676 for (list = priv->content, i = 0; list != NULL((void*)0); list = list->next, ++i)
1677 {
1678 ToolbarContent *content = list->data;
1679
1680 if (toolbar_content_get_expand (content) && new_states[i] == NORMAL)
1681 {
1682 gint extra = size / n_expand_items;
1683 if (size % n_expand_items != 0)
1684 extra++;
1685
1686 if (extra > max_child_expand)
1687 extra = max_child_expand;
1688
1689 allocations[i].width += extra;
1690 size -= extra;
1691 n_expand_items--;
1692 }
1693 }
1694
1695 g_assert (n_expand_items == 0)do { if (n_expand_items == 0) ; else g_assertion_message_expr
("Ctk", "ctktoolbar.c", 1695, ((const char*) (__func__)), "n_expand_items == 0"
); } while (0)
;
1696 }
1697
1698 /* position items */
1699 pos = 0;
1700 for (list = priv->content, i = 0; list != NULL((void*)0); list = list->next, ++i)
1701 {
1702 /* Both NORMAL and OVERFLOWN items get a position.
1703 * This ensures that sliding will work for OVERFLOWN items too.
1704 */
1705 if (new_states[i] == NORMAL || new_states[i] == OVERFLOWN)
1706 {
1707 allocations[i].x = pos;
1708 allocations[i].y = 0;
1709 allocations[i].height = short_size;
1710
1711 pos += allocations[i].width;
1712 }
1713 }
1714
1715 /* position arrow */
1716 if (need_arrow)
1717 {
1718 arrow_allocation.x = available_size - arrow_allocation.width;
1719 arrow_allocation.y = 0;
1720 }
1721
1722 item_area.x = 0;
1723 item_area.y = 0;
1724 item_area.width = available_size - (need_arrow? arrow_size : 0);
1725 item_area.height = short_size;
1726
1727 /* fix up allocations in the vertical or RTL cases */
1728 if (priv->orientation == CTK_ORIENTATION_VERTICAL)
1729 {
1730 for (i = 0; i < n_items; ++i)
1731 fixup_allocation_for_vertical (&(allocations[i]));
1732
1733 if (need_arrow)
1734 fixup_allocation_for_vertical (&arrow_allocation);
1735
1736 fixup_allocation_for_vertical (&item_area);
1737 }
1738 else if (ctk_widget_get_direction (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
) == CTK_TEXT_DIR_RTL)
1739 {
1740 for (i = 0; i < n_items; ++i)
1741 fixup_allocation_for_rtl (available_size, &(allocations[i]));
1742
1743 if (need_arrow)
1744 fixup_allocation_for_rtl (available_size, &arrow_allocation);
1745
1746 fixup_allocation_for_rtl (available_size, &item_area);
1747 }
1748
1749 /* translate the items by allocation->(x,y) */
1750 for (i = 0; i < n_items; ++i)
1751 {
1752 allocations[i].x += allocation->x;
1753 allocations[i].y += allocation->y;
1754 }
1755
1756 if (need_arrow)
1757 {
1758 arrow_allocation.x += allocation->x;
1759 arrow_allocation.y += allocation->y;
1760 }
1761
1762 item_area.x += allocation->x;
1763 item_area.y += allocation->y;
1764
1765 /* did anything change? */
1766 for (list = priv->content, i = 0; list != NULL((void*)0); list = list->next, i++)
1767 {
1768 ToolbarContent *content = list->data;
1769
1770 if (toolbar_content_get_state (content) == NORMAL &&
1771 new_states[i] != NORMAL)
1772 {
1773 /* an item disappeared and we didn't change size, so begin sliding */
1774 if (!size_changed)
1775 ctk_toolbar_begin_sliding (toolbar);
1776 }
1777 }
1778
1779 /* finally allocate the items */
1780 if (priv->is_sliding)
1781 {
1782 for (list = priv->content, i = 0; list != NULL((void*)0); list = list->next, i++)
1783 {
1784 ToolbarContent *content = list->data;
1785
1786 toolbar_content_set_goal_allocation (content, &(allocations[i]));
1787 }
1788 }
1789
1790 for (list = priv->content, i = 0; list != NULL((void*)0); list = list->next, ++i)
1791 {
1792 ToolbarContent *content = list->data;
1793
1794 if (new_states[i] == OVERFLOWN || new_states[i] == NORMAL)
1795 {
1796 CtkAllocation alloc;
1797 CtkAllocation start_allocation = { 0, };
1798 CtkAllocation goal_allocation;
1799
1800 if (priv->is_sliding)
1801 {
1802 toolbar_content_get_start_allocation (content, &start_allocation);
1803 toolbar_content_get_goal_allocation (content, &goal_allocation);
1804
1805 compute_intermediate_allocation (toolbar,
1806 &start_allocation,
1807 &goal_allocation,
1808 &alloc);
1809
1810 priv->need_sync = TRUE(!(0));
1811 }
1812 else
1813 {
1814 alloc = allocations[i];
1815 }
1816
1817 if (alloc.width <= 0 || alloc.height <= 0)
1818 {
1819 toolbar_content_set_child_visible (content, toolbar, FALSE(0));
1820 }
1821 else
1822 {
1823 if (!rect_within (&alloc, &item_area))
1824 {
1825 toolbar_content_set_child_visible (content, toolbar, FALSE(0));
1826 toolbar_content_size_allocate (content, &alloc);
1827 }
1828 else
1829 {
1830 toolbar_content_set_child_visible (content, toolbar, TRUE(!(0)));
1831 toolbar_content_size_allocate (content, &alloc);
1832 }
1833 }
1834 }
1835 else
1836 {
1837 toolbar_content_set_child_visible (content, toolbar, FALSE(0));
1838 }
1839
1840 toolbar_content_set_state (content, new_states[i]);
1841 }
1842
1843 if (priv->menu && priv->need_rebuild)
1844 rebuild_menu (toolbar);
1845
1846 if (need_arrow)
1847 {
1848 ctk_widget_size_allocate (CTK_WIDGET (priv->arrow_button)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_widget_get_type ()))))))
,
1849 &arrow_allocation);
1850 ctk_widget_show (CTK_WIDGET (priv->arrow_button)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_widget_get_type ()))))))
);
1851 }
1852 else
1853 {
1854 ctk_widget_hide (CTK_WIDGET (priv->arrow_button)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_widget_get_type ()))))))
);
1855
1856 if (priv->menu && ctk_widget_get_visible (CTK_WIDGET (priv->menu)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_widget_get_type ()))))))
))
1857 ctk_menu_shell_deactivate (CTK_MENU_SHELL (priv->menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_menu_shell_get_type ()))))))
);
1858 }
1859
1860 g_free (allocations);
1861 g_free (new_states);
1862}
1863
1864static void
1865ctk_toolbar_size_allocate (CtkWidget *widget,
1866 CtkAllocation *allocation)
1867{
1868 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
1869 CtkToolbarPrivate *priv = toolbar->priv;
1870 CtkAllocation clip;
1871
1872 ctk_widget_set_allocation (widget, allocation);
1873
1874 if (ctk_widget_get_realized (widget))
1875 cdk_window_move_resize (priv->event_window,
1876 allocation->x,
1877 allocation->y,
1878 allocation->width,
1879 allocation->height);
1880
1881 ctk_css_gadget_allocate (priv->gadget,
1882 allocation,
1883 ctk_widget_get_allocated_baseline (widget),
1884 &clip);
1885
1886 ctk_widget_set_clip (widget, &clip);
1887}
1888
1889static void
1890ctk_toolbar_update_button_relief (CtkToolbar *toolbar)
1891{
1892 CtkToolbarPrivate *priv = toolbar->priv;
1893 CtkReliefStyle relief;
1894
1895 relief = get_button_relief (toolbar);
1896
1897 if (relief != ctk_button_get_relief (CTK_BUTTON (priv->arrow_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_button_get_type ()))))))
))
1898 {
1899 ctk_toolbar_reconfigured (toolbar);
1900
1901 ctk_button_set_relief (CTK_BUTTON (priv->arrow_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_button_get_type ()))))))
, relief);
1902 }
1903}
1904
1905static void
1906ctk_toolbar_style_updated (CtkWidget *widget)
1907{
1908 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
1909 CtkToolbarPrivate *priv = toolbar->priv;
1910
1911 CTK_WIDGET_CLASS (ctk_toolbar_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_toolbar_parent_class)), ((ctk_widget_get_type ()))))
))
->style_updated (widget);
1912
1913 priv->max_homogeneous_pixels = -1;
1914 ctk_toolbar_update_button_relief (CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
);
1915}
1916
1917static GList *
1918ctk_toolbar_list_children_in_focus_order (CtkToolbar *toolbar,
1919 CtkDirectionType dir)
1920{
1921 CtkToolbarPrivate *priv = toolbar->priv;
1922 GList *result = NULL((void*)0);
1923 GList *list;
1924 gboolean rtl;
1925
1926 /* generate list of children in reverse logical order */
1927
1928 for (list = priv->content; list != NULL((void*)0); list = list->next)
1929 {
1930 ToolbarContent *content = list->data;
1931 CtkWidget *widget;
1932
1933 widget = toolbar_content_get_widget (content);
1934
1935 if (widget)
1936 result = g_list_prepend (result, widget);
1937 }
1938
1939 result = g_list_prepend (result, priv->arrow_button);
1940
1941 rtl = (ctk_widget_get_direction (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
) == CTK_TEXT_DIR_RTL);
1942
1943 /* move in logical order when
1944 *
1945 * - dir is TAB_FORWARD
1946 *
1947 * - in RTL mode and moving left or up
1948 *
1949 * - in LTR mode and moving right or down
1950 */
1951 if (dir == CTK_DIR_TAB_FORWARD ||
1952 (rtl && (dir == CTK_DIR_UP || dir == CTK_DIR_LEFT)) ||
1953 (!rtl && (dir == CTK_DIR_DOWN || dir == CTK_DIR_RIGHT)))
1954 {
1955 result = g_list_reverse (result);
1956 }
1957
1958 return result;
1959}
1960
1961static gboolean
1962ctk_toolbar_focus_home_or_end (CtkToolbar *toolbar,
1963 gboolean focus_home)
1964{
1965 GList *children, *list;
1966 CtkDirectionType dir = focus_home? CTK_DIR_RIGHT : CTK_DIR_LEFT;
1967
1968 children = ctk_toolbar_list_children_in_focus_order (toolbar, dir);
1969
1970 if (ctk_widget_get_direction (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
) == CTK_TEXT_DIR_RTL)
1971 {
1972 children = g_list_reverse (children);
1973
1974 dir = (dir == CTK_DIR_RIGHT)? CTK_DIR_LEFT : CTK_DIR_RIGHT;
1975 }
1976
1977 for (list = children; list != NULL((void*)0); list = list->next)
1978 {
1979 CtkWidget *child = list->data;
1980
1981 if (ctk_container_get_focus_child (CTK_CONTAINER (toolbar)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_container_get_type ()))))))
) == child)
1982 break;
1983
1984 if (ctk_widget_get_mapped (child) && ctk_widget_child_focus (child, dir))
1985 break;
1986 }
1987
1988 g_list_free (children);
1989
1990 return TRUE(!(0));
1991}
1992
1993/* Keybinding handler. This function is called when the user presses
1994 * Ctrl TAB or an arrow key.
1995 */
1996static void
1997ctk_toolbar_move_focus (CtkWidget *widget,
1998 CtkDirectionType dir)
1999{
2000 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
2001 CtkContainer *container = CTK_CONTAINER (toolbar)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_container_get_type ()))))))
;
2002 CtkWidget *focus_child;
2003 GList *list;
2004 gboolean try_focus = FALSE(0);
2005 GList *children;
2006
2007 focus_child = ctk_container_get_focus_child (container);
2008
2009 if (focus_child && ctk_widget_child_focus (focus_child, dir))
2010 return;
2011
2012 children = ctk_toolbar_list_children_in_focus_order (toolbar, dir);
2013
2014 for (list = children; list != NULL((void*)0); list = list->next)
2015 {
2016 CtkWidget *child = list->data;
2017
2018 if (try_focus && ctk_widget_get_mapped (child) && ctk_widget_child_focus (child, dir))
2019 break;
2020
2021 if (child == focus_child)
2022 try_focus = TRUE(!(0));
2023 }
2024
2025 g_list_free (children);
2026}
2027
2028/* The focus handler for the toolbar. It called when the user presses
2029 * TAB or otherwise tries to focus the toolbar.
2030 */
2031static gboolean
2032ctk_toolbar_focus (CtkWidget *widget,
2033 CtkDirectionType dir)
2034{
2035 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
2036 GList *children, *list;
2037 gboolean result = FALSE(0);
2038
2039 /* if focus is already somewhere inside the toolbar then return FALSE.
2040 * The only way focus can stay inside the toolbar is when the user presses
2041 * arrow keys or Ctrl TAB (both of which are handled by the
2042 * ctk_toolbar_move_focus() keybinding function.
2043 */
2044 if (ctk_container_get_focus_child (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
))
2045 return FALSE(0);
2046
2047 children = ctk_toolbar_list_children_in_focus_order (toolbar, dir);
2048
2049 for (list = children; list != NULL((void*)0); list = list->next)
2050 {
2051 CtkWidget *child = list->data;
2052
2053 if (ctk_widget_get_mapped (child) && ctk_widget_child_focus (child, dir))
2054 {
2055 result = TRUE(!(0));
2056 break;
2057 }
2058 }
2059
2060 g_list_free (children);
2061
2062 return result;
2063}
2064
2065static CtkSettings *
2066toolbar_get_settings (CtkToolbar *toolbar)
2067{
2068 return toolbar->priv->settings;
2069}
2070
2071static void
2072animation_change_notify (CtkToolbar *toolbar)
2073{
2074 CtkToolbarPrivate *priv = toolbar->priv;
2075 CtkSettings *settings = toolbar_get_settings (toolbar);
2076 gboolean animation;
2077
2078 if (settings)
2079 g_object_get (settings,
2080 "ctk-enable-animations", &animation,
2081 NULL((void*)0));
2082 else
2083 animation = DEFAULT_ANIMATION_STATE(!(0));
2084
2085 priv->animation = animation;
2086}
2087
2088static void
2089settings_change_notify (CtkSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)),
2090 const GParamSpec *pspec,
2091 CtkToolbar *toolbar)
2092{
2093 if (! strcmp (pspec->name, "ctk-enable-animations"))
2094 animation_change_notify (toolbar);
2095}
2096
2097static void
2098ctk_toolbar_screen_changed (CtkWidget *widget,
2099 CdkScreen *previous_screen G_GNUC_UNUSED__attribute__ ((__unused__)))
2100{
2101 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
2102 CtkToolbarPrivate *priv = toolbar->priv;
2103 CtkSettings *old_settings = toolbar_get_settings (toolbar);
2104 CtkSettings *settings;
2105
2106 if (ctk_widget_has_screen (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
))
2107 settings = ctk_widget_get_settings (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
2108 else
2109 settings = NULL((void*)0);
2110
2111 if (settings == old_settings)
2112 return;
2113
2114 if (old_settings)
2115 {
2116 g_signal_handler_disconnect (old_settings, priv->settings_connection);
2117 priv->settings_connection = 0;
2118 g_object_unref (old_settings);
2119 }
2120
2121 if (settings)
2122 {
2123 priv->settings_connection =
2124 g_signal_connect (settings, "notify",g_signal_connect_data ((settings), ("notify"), (((GCallback) (
settings_change_notify))), (toolbar), ((void*)0), (GConnectFlags
) 0)
2125 G_CALLBACK (settings_change_notify),g_signal_connect_data ((settings), ("notify"), (((GCallback) (
settings_change_notify))), (toolbar), ((void*)0), (GConnectFlags
) 0)
2126 toolbar)g_signal_connect_data ((settings), ("notify"), (((GCallback) (
settings_change_notify))), (toolbar), ((void*)0), (GConnectFlags
) 0)
;
2127
2128 priv->settings = g_object_ref (settings)((__typeof__ (settings)) (g_object_ref) (settings));
2129 }
2130 else
2131 priv->settings = NULL((void*)0);
2132
2133 animation_change_notify (toolbar);
2134}
2135
2136static int
2137find_drop_index (CtkToolbar *toolbar,
2138 gint x,
2139 gint y)
2140{
2141 CtkToolbarPrivate *priv = toolbar->priv;
2142 GList *interesting_content;
2143 GList *list;
2144 CtkOrientation orientation;
2145 CtkTextDirection direction;
2146 gint best_distance = G_MAXINT2147483647;
2147 gint distance;
2148 gint cursor;
2149 gint pos;
2150 ToolbarContent *best_content;
2151 CtkAllocation allocation;
2152
2153 /* list items we care about wrt. drag and drop */
2154 interesting_content = NULL((void*)0);
2155 for (list = priv->content; list != NULL((void*)0); list = list->next)
2156 {
2157 ToolbarContent *content = list->data;
2158
2159 if (toolbar_content_get_state (content) == NORMAL)
2160 interesting_content = g_list_prepend (interesting_content, content);
2161 }
2162 interesting_content = g_list_reverse (interesting_content);
2163
2164 if (!interesting_content)
2165 return 0;
2166
2167 orientation = priv->orientation;
2168 direction = ctk_widget_get_direction (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
2169
2170 /* distance to first interesting item */
2171 best_content = interesting_content->data;
2172 toolbar_content_get_allocation (best_content, &allocation);
2173
2174 if (orientation == CTK_ORIENTATION_HORIZONTAL)
2175 {
2176 cursor = x;
2177
2178 if (direction == CTK_TEXT_DIR_LTR)
2179 pos = allocation.x;
2180 else
2181 pos = allocation.x + allocation.width;
2182 }
2183 else
2184 {
2185 cursor = y;
2186 pos = allocation.y;
2187 }
2188
2189 best_content = NULL((void*)0);
2190 best_distance = ABS (pos - cursor)(((pos - cursor) < 0) ? -(pos - cursor) : (pos - cursor));
2191
2192 /* distance to far end of each item */
2193 for (list = interesting_content; list != NULL((void*)0); list = list->next)
2194 {
2195 ToolbarContent *content = list->data;
2196
2197 toolbar_content_get_allocation (content, &allocation);
2198
2199 if (orientation == CTK_ORIENTATION_HORIZONTAL)
2200 {
2201 if (direction == CTK_TEXT_DIR_LTR)
2202 pos = allocation.x + allocation.width;
2203 else
2204 pos = allocation.x;
2205 }
2206 else
2207 {
2208 pos = allocation.y + allocation.height;
2209 }
2210
2211 distance = ABS (pos - cursor)(((pos - cursor) < 0) ? -(pos - cursor) : (pos - cursor));
2212
2213 if (distance < best_distance)
2214 {
2215 best_distance = distance;
2216 best_content = content;
2217 }
2218 }
2219
2220 g_list_free (interesting_content);
2221
2222 if (!best_content)
2223 return 0;
2224 else
2225 return g_list_index (priv->content, best_content) + 1;
2226}
2227
2228static void
2229reset_all_placeholders (CtkToolbar *toolbar)
2230{
2231 CtkToolbarPrivate *priv = toolbar->priv;
2232 GList *list;
2233
2234 for (list = priv->content; list != NULL((void*)0); list = list->next)
2235 {
2236 ToolbarContent *content = list->data;
2237 if (toolbar_content_is_placeholder (content))
2238 toolbar_content_set_disappearing (content, TRUE(!(0)));
2239 }
2240}
2241
2242static gint
2243physical_to_logical (CtkToolbar *toolbar,
2244 gint physical)
2245{
2246 CtkToolbarPrivate *priv = toolbar->priv;
2247 GList *list;
2248 int logical;
2249
2250 g_assert (physical >= 0)do { if (physical >= 0) ; else g_assertion_message_expr ("Ctk"
, "ctktoolbar.c", 2250, ((const char*) (__func__)), "physical >= 0"
); } while (0)
;
2251
2252 logical = 0;
2253 for (list = priv->content; list && physical > 0; list = list->next)
2254 {
2255 ToolbarContent *content = list->data;
2256
2257 if (!toolbar_content_is_placeholder (content))
2258 logical++;
2259 physical--;
2260 }
2261
2262 g_assert (physical == 0)do { if (physical == 0) ; else g_assertion_message_expr ("Ctk"
, "ctktoolbar.c", 2262, ((const char*) (__func__)), "physical == 0"
); } while (0)
;
2263
2264 return logical;
2265}
2266
2267static gint
2268logical_to_physical (CtkToolbar *toolbar,
2269 gint logical)
2270{
2271 CtkToolbarPrivate *priv = toolbar->priv;
2272 GList *list;
2273 gint physical;
2274
2275 g_assert (logical >= 0)do { if (logical >= 0) ; else g_assertion_message_expr ("Ctk"
, "ctktoolbar.c", 2275, ((const char*) (__func__)), "logical >= 0"
); } while (0)
;
2276
2277 physical = 0;
2278 for (list = priv->content; list; list = list->next)
2279 {
2280 ToolbarContent *content = list->data;
2281
2282 if (!toolbar_content_is_placeholder (content))
2283 {
2284 if (logical == 0)
2285 break;
2286 logical--;
2287 }
2288
2289 physical++;
2290 }
2291
2292 g_assert (logical == 0)do { if (logical == 0) ; else g_assertion_message_expr ("Ctk"
, "ctktoolbar.c", 2292, ((const char*) (__func__)), "logical == 0"
); } while (0)
;
2293
2294 return physical;
2295}
2296
2297/**
2298 * ctk_toolbar_set_drop_highlight_item:
2299 * @toolbar: a #CtkToolbar
2300 * @tool_item: (allow-none): a #CtkToolItem, or %NULL to turn of highlighting
2301 * @index_: a position on @toolbar
2302 *
2303 * Highlights @toolbar to give an idea of what it would look like
2304 * if @item was added to @toolbar at the position indicated by @index_.
2305 * If @item is %NULL, highlighting is turned off. In that case @index_
2306 * is ignored.
2307 *
2308 * The @tool_item passed to this function must not be part of any widget
2309 * hierarchy. When an item is set as drop highlight item it can not
2310 * added to any widget hierarchy or used as highlight item for another
2311 * toolbar.
2312 *
2313 * Since: 2.4
2314 **/
2315void
2316ctk_toolbar_set_drop_highlight_item (CtkToolbar *toolbar,
2317 CtkToolItem *tool_item,
2318 gint index_)
2319{
2320 ToolbarContent *content;
2321 CtkToolbarPrivate *priv;
2322 gint n_items;
2323 CtkRequisition requisition;
2324 CtkRequisition old_requisition;
2325 gboolean restart_sliding;
2326
2327 g_return_if_fail (CTK_IS_TOOLBAR (toolbar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return; } } while (0)
;
2328 g_return_if_fail (tool_item == NULL || CTK_IS_TOOL_ITEM (tool_item))do { if ((tool_item == ((void*)0) || (((__extension__ ({ GTypeInstance
*__inst = (GTypeInstance*) ((tool_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__)), "tool_item == NULL || CTK_IS_TOOL_ITEM (tool_item)"
); return; } } while (0)
;
2329
2330 priv = toolbar->priv;
2331
2332 if (!tool_item)
2333 {
2334 if (priv->highlight_tool_item)
2335 {
2336 ctk_widget_unparent (CTK_WIDGET (priv->highlight_tool_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->highlight_tool_item)), ((ctk_widget_get_type ()
))))))
);
2337 g_object_unref (priv->highlight_tool_item);
2338 priv->highlight_tool_item = NULL((void*)0);
2339 }
2340
2341 reset_all_placeholders (toolbar);
2342 ctk_toolbar_begin_sliding (toolbar);
2343 return;
2344 }
2345
2346 n_items = ctk_toolbar_get_n_items (toolbar);
2347 if (index_ < 0 || index_ > n_items)
2348 index_ = n_items;
2349
2350 if (tool_item != priv->highlight_tool_item)
2351 {
2352 if (priv->highlight_tool_item)
2353 g_object_unref (priv->highlight_tool_item);
2354
2355 g_object_ref_sink (tool_item)((__typeof__ (tool_item)) (g_object_ref_sink) (tool_item));
2356
2357 priv->highlight_tool_item = tool_item;
2358
2359 ctk_widget_set_parent (CTK_WIDGET (priv->highlight_tool_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->highlight_tool_item)), ((ctk_widget_get_type ()
))))))
,
2360 CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
2361 }
2362
2363 index_ = logical_to_physical (toolbar, index_);
2364
2365 content = g_list_nth_data (priv->content, index_);
2366
2367 if (index_ > 0)
2368 {
2369 ToolbarContent *prev_content;
2370
2371 prev_content = g_list_nth_data (priv->content, index_ - 1);
2372
2373 if (prev_content && toolbar_content_is_placeholder (prev_content))
2374 content = prev_content;
2375 }
2376
2377 if (!content || !toolbar_content_is_placeholder (content))
2378 {
2379 CtkWidget *placeholder;
2380
2381 placeholder = CTK_WIDGET (ctk_separator_tool_item_new ())((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_separator_tool_item_new ())), ((ctk_widget_get_type (
)))))))
;
2382
2383 content = toolbar_content_new_tool_item (toolbar,
2384 CTK_TOOL_ITEM (placeholder)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((placeholder)), ((ctk_tool_item_get_type ()))))))
,
2385 TRUE(!(0)), index_);
2386 ctk_widget_show (placeholder);
2387 }
2388
2389 g_assert (content)do { if (content) ; else g_assertion_message_expr ("Ctk", "ctktoolbar.c"
, 2389, ((const char*) (__func__)), "content"); } while (0)
;
2390 g_assert (toolbar_content_is_placeholder (content))do { if (toolbar_content_is_placeholder (content)) ; else g_assertion_message_expr
("Ctk", "ctktoolbar.c", 2390, ((const char*) (__func__)), "toolbar_content_is_placeholder (content)"
); } while (0)
;
2391
2392 ctk_widget_get_preferred_size (CTK_WIDGET (priv->highlight_tool_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->highlight_tool_item)), ((ctk_widget_get_type ()
))))))
,
2393 &requisition, NULL((void*)0));
2394
2395 toolbar_content_set_expand (content, ctk_tool_item_get_expand (tool_item));
2396
2397 restart_sliding = FALSE(0);
2398 toolbar_content_size_request (content, toolbar, &old_requisition);
2399 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
2400 {
2401 requisition.height = -1;
2402 if (requisition.width != old_requisition.width)
2403 restart_sliding = TRUE(!(0));
2404 }
2405 else
2406 {
2407 requisition.width = -1;
2408 if (requisition.height != old_requisition.height)
2409 restart_sliding = TRUE(!(0));
2410 }
2411
2412 if (toolbar_content_disappearing (content))
2413 restart_sliding = TRUE(!(0));
2414
2415 reset_all_placeholders (toolbar);
2416 toolbar_content_set_disappearing (content, FALSE(0));
2417
2418 toolbar_content_set_size_request (content,
2419 requisition.width, requisition.height);
2420
2421 if (restart_sliding)
2422 ctk_toolbar_begin_sliding (toolbar);
2423}
2424
2425static void
2426ctk_toolbar_get_child_property (CtkContainer *container,
2427 CtkWidget *child,
2428 guint property_id,
2429 GValue *value,
2430 GParamSpec *pspec)
2431{
2432 CtkToolItem *item = CTK_TOOL_ITEM (child)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_tool_item_get_type ()))))))
;
2433
2434 switch (property_id)
2435 {
2436 case CHILD_PROP_HOMOGENEOUS:
2437 g_value_set_boolean (value, ctk_tool_item_get_homogeneous (item));
2438 break;
2439
2440 case CHILD_PROP_EXPAND:
2441 g_value_set_boolean (value, ctk_tool_item_get_expand (item));
2442 break;
2443
2444 default:
2445 CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctktoolbar.c", 2445, ("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)
;
2446 break;
2447 }
2448}
2449
2450static void
2451ctk_toolbar_set_child_property (CtkContainer *container,
2452 CtkWidget *child,
2453 guint property_id,
2454 const GValue *value,
2455 GParamSpec *pspec)
2456{
2457 switch (property_id)
2458 {
2459 case CHILD_PROP_HOMOGENEOUS:
2460 ctk_tool_item_set_homogeneous (CTK_TOOL_ITEM (child)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_tool_item_get_type ()))))))
, g_value_get_boolean (value));
2461 break;
2462
2463 case CHILD_PROP_EXPAND:
2464 ctk_tool_item_set_expand (CTK_TOOL_ITEM (child)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_tool_item_get_type ()))))))
, g_value_get_boolean (value));
2465 break;
2466
2467 default:
2468 CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctktoolbar.c", 2468, ("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)
;
2469 break;
2470 }
2471}
2472
2473static void
2474ctk_toolbar_show_all (CtkWidget *widget)
2475{
2476 CtkToolbar *toolbar = CTK_TOOLBAR (widget)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_toolbar_get_type ()))))))
;
2477 CtkToolbarPrivate *priv = toolbar->priv;
2478 GList *list;
2479
2480 for (list = priv->content; list != NULL((void*)0); list = list->next)
2481 {
2482 ToolbarContent *content = list->data;
2483
2484 toolbar_content_show_all (content);
2485 }
2486
2487 ctk_widget_show (widget);
2488}
2489
2490static void
2491ctk_toolbar_add (CtkContainer *container,
2492 CtkWidget *widget)
2493{
2494 CtkToolbar *toolbar = CTK_TOOLBAR (container)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_toolbar_get_type ()))))))
;
2495
2496 ctk_toolbar_insert (toolbar, CTK_TOOL_ITEM (widget)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_tool_item_get_type ()))))))
, -1);
2497}
2498
2499static void
2500ctk_toolbar_remove (CtkContainer *container,
2501 CtkWidget *widget)
2502{
2503 CtkToolbar *toolbar = CTK_TOOLBAR (container)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_toolbar_get_type ()))))))
;
2504 CtkToolbarPrivate *priv = toolbar->priv;
2505 ToolbarContent *content_to_remove;
2506 GList *list;
2507
2508 content_to_remove = NULL((void*)0);
2509 for (list = priv->content; list != NULL((void*)0); list = list->next)
2510 {
2511 ToolbarContent *content = list->data;
2512 CtkWidget *child;
2513
2514 child = toolbar_content_get_widget (content);
2515 if (child && child == widget)
2516 {
2517 content_to_remove = content;
2518 break;
2519 }
2520 }
2521
2522 g_return_if_fail (content_to_remove != NULL)do { if ((content_to_remove != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "content_to_remove != NULL"
); return; } } while (0)
;
2523
2524 toolbar_content_remove (content_to_remove, toolbar);
2525 toolbar_content_free (content_to_remove);
2526}
2527
2528static void
2529ctk_toolbar_forall (CtkContainer *container,
2530 gboolean include_internals,
2531 CtkCallback callback,
2532 gpointer callback_data)
2533{
2534 CtkToolbar *toolbar = CTK_TOOLBAR (container)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_toolbar_get_type ()))))))
;
2535 CtkToolbarPrivate *priv = toolbar->priv;
2536 GList *list;
2537
2538 g_return_if_fail (callback != NULL)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "callback != NULL"); return
; } } while (0)
;
2539
2540 list = priv->content;
2541 while (list)
2542 {
2543 ToolbarContent *content = list->data;
2544 GList *next = list->next;
2545
2546 if (include_internals || !toolbar_content_is_placeholder (content))
2547 {
2548 CtkWidget *child = toolbar_content_get_widget (content);
2549
2550 if (child)
2551 callback (child, callback_data);
2552 }
2553
2554 list = next;
2555 }
2556
2557 if (include_internals && priv->arrow_button)
2558 callback (priv->arrow_button, callback_data);
2559}
2560
2561static GType
2562ctk_toolbar_child_type (CtkContainer *container G_GNUC_UNUSED__attribute__ ((__unused__)))
2563{
2564 return CTK_TYPE_TOOL_ITEM(ctk_tool_item_get_type ());
2565}
2566
2567static void
2568ctk_toolbar_reconfigured (CtkToolbar *toolbar)
2569{
2570 CtkToolbarPrivate *priv = toolbar->priv;
2571 GList *list;
2572
2573 list = priv->content;
2574 while (list)
2575 {
2576 ToolbarContent *content = list->data;
2577 GList *next = list->next;
2578
2579 toolbar_content_toolbar_reconfigured (content, toolbar);
2580
2581 list = next;
2582 }
2583}
2584
2585static void
2586ctk_toolbar_orientation_changed (CtkToolbar *toolbar,
2587 CtkOrientation orientation)
2588{
2589 CtkToolbarPrivate *priv = toolbar->priv;
2590
2591 if (priv->orientation != orientation)
2592 {
2593 priv->orientation = orientation;
2594
2595 if (orientation == CTK_ORIENTATION_HORIZONTAL)
2596 ctk_image_set_from_icon_name (CTK_IMAGE (priv->arrow)((((CtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow)), ((ctk_image_get_type ()))))))
, "pan-down-symbolic", CTK_ICON_SIZE_BUTTON);
2597 else
2598 ctk_image_set_from_icon_name (CTK_IMAGE (priv->arrow)((((CtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow)), ((ctk_image_get_type ()))))))
, "pan-end-symbolic", CTK_ICON_SIZE_BUTTON);
2599
2600 ctk_toolbar_reconfigured (toolbar);
2601
2602 _ctk_orientable_set_style_classes (CTK_ORIENTABLE (toolbar)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_orientable_get_type ()))))))
);
2603 ctk_widget_queue_resize (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
2604 g_object_notify (G_OBJECT (toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), (((GType) ((20) << (2))))))))
, "orientation");
2605 }
2606}
2607
2608static void
2609ctk_toolbar_real_style_changed (CtkToolbar *toolbar,
2610 CtkToolbarStyle style)
2611{
2612 CtkToolbarPrivate *priv = toolbar->priv;
2613
2614 if (priv->style != style)
2615 {
2616 priv->style = style;
2617
2618 ctk_toolbar_reconfigured (toolbar);
2619
2620 ctk_widget_queue_resize (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
2621 g_object_notify (G_OBJECT (toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), (((GType) ((20) << (2))))))))
, "toolbar-style");
2622 }
2623}
2624
2625static void
2626show_menu (CtkToolbar *toolbar,
2627 CdkEventButton *event)
2628{
2629 CtkToolbarPrivate *priv = toolbar->priv;
2630 CtkRequisition minimum_size;
2631
2632 rebuild_menu (toolbar);
2633
2634 ctk_widget_show_all (CTK_WIDGET (priv->menu)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_widget_get_type ()))))))
);
2635
2636 switch (priv->orientation)
2637 {
2638 case CTK_ORIENTATION_HORIZONTAL:
2639 ctk_widget_get_preferred_size (priv->arrow_button, &minimum_size, NULL((void*)0));
2640
2641 g_object_set (priv->menu,
2642 "anchor-hints", (CDK_ANCHOR_FLIP_Y |
2643 CDK_ANCHOR_SLIDE |
2644 CDK_ANCHOR_RESIZE),
2645 "menu-type-hint", CDK_WINDOW_TYPE_HINT_DROPDOWN_MENU,
2646 "rect-anchor-dx", -minimum_size.width,
2647 NULL((void*)0));
2648
2649 ctk_menu_popup_at_widget (priv->menu,
2650 priv->arrow_button,
2651 CDK_GRAVITY_SOUTH_EAST,
2652 CDK_GRAVITY_NORTH_WEST,
2653 (CdkEvent *) event);
2654
2655 break;
2656
2657 case CTK_ORIENTATION_VERTICAL:
2658 g_object_set (priv->menu,
2659 "anchor-hints", (CDK_ANCHOR_FLIP_X |
2660 CDK_ANCHOR_SLIDE |
2661 CDK_ANCHOR_RESIZE),
2662 NULL((void*)0));
2663
2664 ctk_menu_popup_at_widget (priv->menu,
2665 priv->arrow_button,
2666 CDK_GRAVITY_NORTH_EAST,
2667 CDK_GRAVITY_NORTH_WEST,
2668 (CdkEvent *) event);
2669
2670 break;
2671 }
2672}
2673
2674static void
2675ctk_toolbar_arrow_button_clicked (CtkWidget *button G_GNUC_UNUSED__attribute__ ((__unused__)),
2676 CtkToolbar *toolbar)
2677{
2678 CtkToolbarPrivate *priv = toolbar->priv;
2679
2680 if (ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->arrow_button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->arrow_button)), ((ctk_toggle_button_get_type ()
))))))
) &&
2681 (!priv->menu || !ctk_widget_get_visible (CTK_WIDGET (priv->menu)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_widget_get_type ()))))))
)))
2682 {
2683 /* We only get here when the button is clicked with the keyboard,
2684 * because mouse button presses result in the menu being shown so
2685 * that priv->menu would be non-NULL and visible.
2686 */
2687 show_menu (toolbar, NULL((void*)0));
2688 ctk_menu_shell_select_first (CTK_MENU_SHELL (priv->menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_menu_shell_get_type ()))))))
, FALSE(0));
2689 }
2690}
2691
2692static gboolean
2693ctk_toolbar_arrow_button_press (CtkWidget *button,
2694 CdkEventButton *event,
2695 CtkToolbar *toolbar)
2696{
2697 show_menu (toolbar, event);
2698 ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (button)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((ctk_toggle_button_get_type ()))))))
, TRUE(!(0)));
2699
2700 return TRUE(!(0));
2701}
2702
2703static gboolean
2704ctk_toolbar_button_press (CtkWidget *toolbar,
2705 CdkEventButton *event)
2706{
2707 if (cdk_event_triggers_context_menu ((CdkEvent *) event))
2708 {
2709 gboolean return_value;
2710
2711 g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0,
2712 (int)event->x_root, (int)event->y_root, event->button,
2713 &return_value);
2714
2715 return return_value;
2716 }
2717
2718 return FALSE(0);
2719}
2720
2721static gboolean
2722ctk_toolbar_popup_menu (CtkWidget *toolbar)
2723{
2724 gboolean return_value;
2725 /* This function is the handler for the "popup menu" keybinding,
2726 * ie., it is called when the user presses Shift F10
2727 */
2728 g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0,
2729 -1, -1, -1, &return_value);
2730
2731 return return_value;
2732}
2733
2734/**
2735 * ctk_toolbar_new:
2736 *
2737 * Creates a new toolbar.
2738
2739 * Returns: the newly-created toolbar.
2740 **/
2741CtkWidget *
2742ctk_toolbar_new (void)
2743{
2744 CtkToolbar *toolbar;
2745
2746 toolbar = g_object_new (CTK_TYPE_TOOLBAR(ctk_toolbar_get_type ()), NULL((void*)0));
2747
2748 return CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
;
2749}
2750
2751/**
2752 * ctk_toolbar_insert:
2753 * @toolbar: a #CtkToolbar
2754 * @item: a #CtkToolItem
2755 * @pos: the position of the new item
2756 *
2757 * Insert a #CtkToolItem into the toolbar at position @pos. If @pos is
2758 * 0 the item is prepended to the start of the toolbar. If @pos is
2759 * negative, the item is appended to the end of the toolbar.
2760 *
2761 * Since: 2.4
2762 **/
2763void
2764ctk_toolbar_insert (CtkToolbar *toolbar,
2765 CtkToolItem *item,
2766 gint pos)
2767{
2768 g_return_if_fail (CTK_IS_TOOLBAR (toolbar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return; } } while (0)
;
2769 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)
;
2770
2771 pos = MIN (pos, (int)g_list_length (toolbar->priv->content))(((pos) < ((int)g_list_length (toolbar->priv->content
))) ? (pos) : ((int)g_list_length (toolbar->priv->content
)))
;
2772
2773 if (pos >= 0)
2774 pos = logical_to_physical (toolbar, pos);
2775
2776 toolbar_content_new_tool_item (toolbar, item, FALSE(0), pos);
2777}
2778
2779/**
2780 * ctk_toolbar_get_item_index:
2781 * @toolbar: a #CtkToolbar
2782 * @item: a #CtkToolItem that is a child of @toolbar
2783 *
2784 * Returns the position of @item on the toolbar, starting from 0.
2785 * It is an error if @item is not a child of the toolbar.
2786 *
2787 * Returns: the position of item on the toolbar.
2788 *
2789 * Since: 2.4
2790 **/
2791gint
2792ctk_toolbar_get_item_index (CtkToolbar *toolbar,
2793 CtkToolItem *item)
2794{
2795 CtkToolbarPrivate *priv;
2796 GList *list;
2797 int n;
2798
2799 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return (-1); } } while (0)
;
2800 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)
;
2801 g_return_val_if_fail (ctk_widget_get_parent (CTK_WIDGET (item)) == CTK_WIDGET (toolbar), -1)do { if ((ctk_widget_get_parent (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((item)), ((ctk_widget_get_type ()))))))) ==
((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ())))))))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "ctk_widget_get_parent (CTK_WIDGET (item)) == CTK_WIDGET (toolbar)"
); return (-1); } } while (0)
;
2802
2803 priv = toolbar->priv;
2804
2805 n = 0;
2806 for (list = priv->content; list != NULL((void*)0); list = list->next)
2807 {
2808 ToolbarContent *content = list->data;
2809 CtkWidget *widget;
2810
2811 widget = toolbar_content_get_widget (content);
2812
2813 if (item == CTK_TOOL_ITEM (widget)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_tool_item_get_type ()))))))
)
2814 break;
2815
2816 ++n;
2817 }
2818
2819 return physical_to_logical (toolbar, n);
2820}
2821
2822/**
2823 * ctk_toolbar_set_style:
2824 * @toolbar: a #CtkToolbar.
2825 * @style: the new style for @toolbar.
2826 *
2827 * Alters the view of @toolbar to display either icons only, text only, or both.
2828 **/
2829void
2830ctk_toolbar_set_style (CtkToolbar *toolbar,
2831 CtkToolbarStyle style)
2832{
2833 CtkToolbarPrivate *priv;
2834
2835 g_return_if_fail (CTK_IS_TOOLBAR (toolbar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return; } } while (0)
;
2836
2837 priv = toolbar->priv;
2838
2839 priv->style_set = TRUE(!(0));
2840 g_signal_emit (toolbar, toolbar_signals[STYLE_CHANGED], 0, style);
2841}
2842
2843/**
2844 * ctk_toolbar_get_style:
2845 * @toolbar: a #CtkToolbar
2846 *
2847 * Retrieves whether the toolbar has text, icons, or both . See
2848 * ctk_toolbar_set_style().
2849
2850 * Returns: the current style of @toolbar
2851 **/
2852CtkToolbarStyle
2853ctk_toolbar_get_style (CtkToolbar *toolbar)
2854{
2855 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), DEFAULT_TOOLBAR_STYLE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return (CTK_TOOLBAR_BOTH_HORIZ
); } } while (0)
;
2856
2857 return toolbar->priv->style;
2858}
2859
2860/**
2861 * ctk_toolbar_unset_style:
2862 * @toolbar: a #CtkToolbar
2863 *
2864 * Unsets a toolbar style set with ctk_toolbar_set_style(), so that
2865 * user preferences will be used to determine the toolbar style.
2866 **/
2867void
2868ctk_toolbar_unset_style (CtkToolbar *toolbar)
2869{
2870 CtkToolbarPrivate *priv;
2871 CtkToolbarStyle style;
2872
2873 g_return_if_fail (CTK_IS_TOOLBAR (toolbar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return; } } while (0)
;
2874
2875 priv = toolbar->priv;
2876
2877 if (priv->style_set)
2878 {
2879 style = DEFAULT_TOOLBAR_STYLECTK_TOOLBAR_BOTH_HORIZ;
2880
2881 if (style != priv->style)
2882 g_signal_emit (toolbar, toolbar_signals[STYLE_CHANGED], 0, style);
2883
2884 priv->style_set = FALSE(0);
2885 }
2886}
2887
2888/**
2889 * ctk_toolbar_get_n_items:
2890 * @toolbar: a #CtkToolbar
2891 *
2892 * Returns the number of items on the toolbar.
2893 *
2894 * Returns: the number of items on the toolbar
2895 *
2896 * Since: 2.4
2897 **/
2898gint
2899ctk_toolbar_get_n_items (CtkToolbar *toolbar)
2900{
2901 CtkToolbarPrivate *priv;
2902
2903 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return (-1); } } while (0)
;
2904
2905 priv = toolbar->priv;
2906
2907 return physical_to_logical (toolbar, g_list_length (priv->content));
2908}
2909
2910/**
2911 * ctk_toolbar_get_nth_item:
2912 * @toolbar: a #CtkToolbar
2913 * @n: A position on the toolbar
2914 *
2915 * Returns the @n'th item on @toolbar, or %NULL if the
2916 * toolbar does not contain an @n'th item.
2917 *
2918 * Returns: (nullable) (transfer none): The @n'th #CtkToolItem on @toolbar,
2919 * or %NULL if there isn’t an @n'th item.
2920 *
2921 * Since: 2.4
2922 **/
2923CtkToolItem *
2924ctk_toolbar_get_nth_item (CtkToolbar *toolbar,
2925 gint n)
2926{
2927 CtkToolbarPrivate *priv;
2928 ToolbarContent *content;
2929 gint n_items;
2930
2931 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return (((void*)0)); } } while
(0)
;
2932
2933 priv = toolbar->priv;
2934
2935 n_items = ctk_toolbar_get_n_items (toolbar);
2936
2937 if (n < 0 || n >= n_items)
2938 return NULL((void*)0);
2939
2940 content = g_list_nth_data (priv->content, logical_to_physical (toolbar, n));
2941
2942 g_assert (content)do { if (content) ; else g_assertion_message_expr ("Ctk", "ctktoolbar.c"
, 2942, ((const char*) (__func__)), "content"); } while (0)
;
2943 g_assert (!toolbar_content_is_placeholder (content))do { if (!toolbar_content_is_placeholder (content)) ; else g_assertion_message_expr
("Ctk", "ctktoolbar.c", 2943, ((const char*) (__func__)), "!toolbar_content_is_placeholder (content)"
); } while (0)
;
2944
2945 return CTK_TOOL_ITEM (toolbar_content_get_widget (content))((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar_content_get_widget (content))), ((ctk_tool_item_get_type
()))))))
;
2946}
2947
2948/**
2949 * ctk_toolbar_get_icon_size:
2950 * @toolbar: a #CtkToolbar
2951 *
2952 * Retrieves the icon size for the toolbar. See ctk_toolbar_set_icon_size().
2953 *
2954 * Returns: the current icon size for the icons on the toolbar.
2955 **/
2956CtkIconSize
2957ctk_toolbar_get_icon_size (CtkToolbar *toolbar)
2958{
2959 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), DEFAULT_ICON_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return (CTK_ICON_SIZE_LARGE_TOOLBAR
); } } while (0)
;
2960
2961 return toolbar->priv->icon_size;
2962}
2963
2964/**
2965 * ctk_toolbar_get_relief_style:
2966 * @toolbar: a #CtkToolbar
2967 *
2968 * Returns the relief style of buttons on @toolbar. See
2969 * ctk_button_set_relief().
2970 *
2971 * Returns: The relief style of buttons on @toolbar.
2972 *
2973 * Since: 2.4
2974 **/
2975CtkReliefStyle
2976ctk_toolbar_get_relief_style (CtkToolbar *toolbar)
2977{
2978 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), CTK_RELIEF_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return (CTK_RELIEF_NONE); } }
while (0)
;
2979
2980 return get_button_relief (toolbar);
2981}
2982
2983/**
2984 * ctk_toolbar_set_show_arrow:
2985 * @toolbar: a #CtkToolbar
2986 * @show_arrow: Whether to show an overflow menu
2987 *
2988 * Sets whether to show an overflow menu when @toolbar isn’t allocated enough
2989 * size to show all of its items. If %TRUE, items which can’t fit in @toolbar,
2990 * and which have a proxy menu item set by ctk_tool_item_set_proxy_menu_item()
2991 * or #CtkToolItem::create-menu-proxy, will be available in an overflow menu,
2992 * which can be opened by an added arrow button. If %FALSE, @toolbar will
2993 * request enough size to fit all of its child items without any overflow.
2994 *
2995 * Since: 2.4
2996 **/
2997void
2998ctk_toolbar_set_show_arrow (CtkToolbar *toolbar,
2999 gboolean show_arrow)
3000{
3001 CtkToolbarPrivate *priv;
3002
3003 g_return_if_fail (CTK_IS_TOOLBAR (toolbar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return; } } while (0)
;
3004
3005 priv = toolbar->priv;
3006
3007 show_arrow = show_arrow != FALSE(0);
3008
3009 if (priv->show_arrow != show_arrow)
3010 {
3011 priv->show_arrow = show_arrow;
3012
3013 if (!priv->show_arrow)
3014 ctk_widget_hide (priv->arrow_button);
3015
3016 ctk_widget_queue_resize (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
3017 g_object_notify (G_OBJECT (toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), (((GType) ((20) << (2))))))))
, "show-arrow");
3018 }
3019}
3020
3021/**
3022 * ctk_toolbar_get_show_arrow:
3023 * @toolbar: a #CtkToolbar
3024 *
3025 * Returns whether the toolbar has an overflow menu.
3026 * See ctk_toolbar_set_show_arrow().
3027 *
3028 * Returns: %TRUE if the toolbar has an overflow menu.
3029 *
3030 * Since: 2.4
3031 **/
3032gboolean
3033ctk_toolbar_get_show_arrow (CtkToolbar *toolbar)
3034{
3035 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return ((0)); } } while (0)
;
3036
3037 return toolbar->priv->show_arrow;
3038}
3039
3040/**
3041 * ctk_toolbar_get_drop_index:
3042 * @toolbar: a #CtkToolbar
3043 * @x: x coordinate of a point on the toolbar
3044 * @y: y coordinate of a point on the toolbar
3045 *
3046 * Returns the position corresponding to the indicated point on
3047 * @toolbar. This is useful when dragging items to the toolbar:
3048 * this function returns the position a new item should be
3049 * inserted.
3050 *
3051 * @x and @y are in @toolbar coordinates.
3052 *
3053 * Returns: The position corresponding to the point (@x, @y) on the toolbar.
3054 *
3055 * Since: 2.4
3056 **/
3057gint
3058ctk_toolbar_get_drop_index (CtkToolbar *toolbar,
3059 gint x,
3060 gint y)
3061{
3062 g_return_val_if_fail (CTK_IS_TOOLBAR (toolbar), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return (-1); } } while (0)
;
3063
3064 return physical_to_logical (toolbar, find_drop_index (toolbar, x, y));
3065}
3066
3067static void
3068ctk_toolbar_dispose (GObject *object)
3069{
3070 CtkToolbar *toolbar = CTK_TOOLBAR (object)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_toolbar_get_type ()))))))
;
3071 CtkToolbarPrivate *priv = toolbar->priv;
3072
3073 if (priv->arrow_button)
3074 {
3075 ctk_widget_unparent (priv->arrow_button);
3076 priv->arrow_button = NULL((void*)0);
3077 }
3078
3079 if (priv->menu)
3080 {
3081 g_signal_handlers_disconnect_by_func (priv->menu,g_signal_handlers_disconnect_matched ((priv->menu), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_deactivated), (toolbar))
3082 menu_deactivated, toolbar)g_signal_handlers_disconnect_matched ((priv->menu), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_deactivated), (toolbar))
;
3083 ctk_widget_destroy (CTK_WIDGET (priv->menu)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->menu)), ((ctk_widget_get_type ()))))))
);
3084 priv->menu = NULL((void*)0);
3085 }
3086
3087 if (priv->settings_connection > 0)
3088 {
3089 g_signal_handler_disconnect (priv->settings, priv->settings_connection);
3090 priv->settings_connection = 0;
3091 }
3092
3093 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)
;
3094
3095 G_OBJECT_CLASS (ctk_toolbar_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_toolbar_parent_class)), (((GType) ((20) << (2)
)))))))
->dispose (object);
3096}
3097
3098static void
3099ctk_toolbar_finalize (GObject *object)
3100{
3101 CtkToolbar *toolbar = CTK_TOOLBAR (object)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_toolbar_get_type ()))))))
;
3102 CtkToolbarPrivate *priv = toolbar->priv;
3103
3104 g_list_free_full (priv->content, (GDestroyNotify)toolbar_content_free);
3105
3106 g_timer_destroy (priv->timer);
3107
3108 if (priv->idle_id)
3109 g_source_remove (priv->idle_id);
3110
3111 g_clear_object (&priv->gadget)do { _Static_assert (sizeof *((&priv->gadget)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->gadget))) _pp = ((&priv->gadget)); __typeof__
(*((&priv->gadget))) _ptr = *_pp; *_pp = ((void*)0); if
(_ptr) (g_object_unref) (_ptr); } while (0)
;
3112
3113 G_OBJECT_CLASS (ctk_toolbar_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_toolbar_parent_class)), (((GType) ((20) << (2)
)))))))
->finalize (object);
3114}
3115
3116/**
3117 * ctk_toolbar_set_icon_size:
3118 * @toolbar: A #CtkToolbar
3119 * @icon_size: The #CtkIconSize that stock icons in the toolbar shall have.
3120 *
3121 * This function sets the size of stock icons in the toolbar. You
3122 * can call it both before you add the icons and after they’ve been
3123 * added. The size you set will override user preferences for the default
3124 * icon size.
3125 *
3126 * This should only be used for special-purpose toolbars, normal
3127 * application toolbars should respect the user preferences for the
3128 * size of icons.
3129 **/
3130void
3131ctk_toolbar_set_icon_size (CtkToolbar *toolbar,
3132 CtkIconSize icon_size)
3133{
3134 CtkToolbarPrivate *priv;
3135
3136 g_return_if_fail (CTK_IS_TOOLBAR (toolbar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return; } } while (0)
;
3137 g_return_if_fail (icon_size != CTK_ICON_SIZE_INVALID)do { if ((icon_size != CTK_ICON_SIZE_INVALID)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "icon_size != CTK_ICON_SIZE_INVALID"
); return; } } while (0)
;
3138
3139 priv = toolbar->priv;
3140
3141 if (!priv->icon_size_set)
3142 {
3143 priv->icon_size_set = TRUE(!(0));
3144 g_object_notify (G_OBJECT (toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), (((GType) ((20) << (2))))))))
, "icon-size-set");
3145 }
3146
3147 if (priv->icon_size == icon_size)
3148 return;
3149
3150 priv->icon_size = icon_size;
3151 g_object_notify (G_OBJECT (toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), (((GType) ((20) << (2))))))))
, "icon-size");
3152
3153 ctk_toolbar_reconfigured (toolbar);
3154
3155 ctk_widget_queue_resize (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
3156}
3157
3158/**
3159 * ctk_toolbar_unset_icon_size:
3160 * @toolbar: a #CtkToolbar
3161 *
3162 * Unsets toolbar icon size set with ctk_toolbar_set_icon_size(), so that
3163 * user preferences will be used to determine the icon size.
3164 **/
3165void
3166ctk_toolbar_unset_icon_size (CtkToolbar *toolbar)
3167{
3168 CtkToolbarPrivate *priv;
3169 CtkIconSize size;
3170
3171 g_return_if_fail (CTK_IS_TOOLBAR (toolbar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); GType __t = ((ctk_toolbar_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_TOOLBAR (toolbar)"); return; } } while (0)
;
3172
3173 priv = toolbar->priv;
3174
3175 if (priv->icon_size_set)
3176 {
3177 size = DEFAULT_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR;
3178
3179 if (size != priv->icon_size)
3180 {
3181 ctk_toolbar_set_icon_size (toolbar, size);
3182 g_object_notify (G_OBJECT (toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), (((GType) ((20) << (2))))))))
, "icon-size");
3183 }
3184
3185 priv->icon_size_set = FALSE(0);
3186 g_object_notify (G_OBJECT (toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), (((GType) ((20) << (2))))))))
, "icon-size-set");
3187 }
3188}
3189
3190/*
3191 * ToolbarContent methods
3192 */
3193typedef enum {
3194 UNKNOWN,
3195 YES,
3196 NO
3197} TriState;
3198
3199struct _ToolbarContent
3200{
3201 ItemState state;
3202
3203 CtkToolItem *item;
3204 CtkAllocation allocation;
3205 CtkAllocation start_allocation;
3206 CtkAllocation goal_allocation;
3207 guint is_placeholder : 1;
3208 guint disappearing : 1;
3209 guint has_menu : 2;
3210};
3211
3212static ToolbarContent *
3213toolbar_content_new_tool_item (CtkToolbar *toolbar,
3214 CtkToolItem *item,
3215 gboolean is_placeholder,
3216 gint pos)
3217{
3218 CtkToolbarPrivate *priv = toolbar->priv;
3219 ToolbarContent *content, *previous;
3220
3221 content = g_slice_new0 (ToolbarContent)((ToolbarContent*) g_slice_alloc0 (sizeof (ToolbarContent)));
3222
3223 content->state = NOT_ALLOCATED;
3224 content->item = item;
3225 content->is_placeholder = is_placeholder;
3226
3227 previous = pos > 0 ? g_list_nth_data (priv->content, -1) : NULL((void*)0);
3228 priv->content = g_list_insert (priv->content, content, pos);
3229
3230 if (ctk_widget_get_direction (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
) == CTK_TEXT_DIR_RTL)
3231 ctk_css_node_insert_after (ctk_widget_get_css_node (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
),
3232 ctk_widget_get_css_node (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((ctk_widget_get_type ()))))))
),
3233 previous ? ctk_widget_get_css_node (CTK_WIDGET (previous->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((previous->item)), ((ctk_widget_get_type ()))))))
) : NULL((void*)0));
3234 else
3235 ctk_css_node_insert_before (ctk_widget_get_css_node (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
),
3236 ctk_widget_get_css_node (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((ctk_widget_get_type ()))))))
),
3237 previous ? ctk_widget_get_css_node (CTK_WIDGET (previous->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((previous->item)), ((ctk_widget_get_type ()))))))
) : NULL((void*)0));
3238
3239 ctk_widget_set_parent (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((ctk_widget_get_type ()))))))
, CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
3240
3241 if (!is_placeholder)
3242 {
3243 priv->num_children++;
3244
3245 ctk_toolbar_stop_sliding (toolbar);
3246 }
3247
3248 ctk_widget_queue_resize (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
3249 priv->need_rebuild = TRUE(!(0));
3250
3251 return content;
3252}
3253
3254static void
3255toolbar_content_remove (ToolbarContent *content,
3256 CtkToolbar *toolbar)
3257{
3258 CtkToolbarPrivate *priv = toolbar->priv;
3259
3260 ctk_widget_unparent (CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
);
3261
3262 priv->content = g_list_remove (priv->content, content);
3263
3264 if (!toolbar_content_is_placeholder (content))
3265 priv->num_children--;
3266
3267 ctk_widget_queue_resize (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
3268 priv->need_rebuild = TRUE(!(0));
3269}
3270
3271static void
3272toolbar_content_free (ToolbarContent *content)
3273{
3274 g_slice_free (ToolbarContent, content)do { if (1) g_slice_free1 (sizeof (ToolbarContent), (content)
); else (void) ((ToolbarContent*) 0 == (content)); } while (0
)
;
3275}
3276
3277static gint
3278calculate_max_homogeneous_pixels (CtkWidget *widget)
3279{
3280 PangoContext *context;
3281 PangoFontMetrics *metrics;
3282 gint char_width;
3283
3284 context = ctk_widget_get_pango_context (widget);
3285
3286 metrics = pango_context_get_metrics (context,
3287 pango_context_get_font_description (context),
3288 pango_context_get_language (context));
3289 char_width = pango_font_metrics_get_approximate_char_width (metrics);
3290 pango_font_metrics_unref (metrics);
3291
3292 return PANGO_PIXELS (MAX_HOMOGENEOUS_N_CHARS * char_width)(((int)(13 * char_width) + 512) >> 10);
3293}
3294
3295static void
3296toolbar_content_draw (ToolbarContent *content,
3297 CtkContainer *container,
3298 cairo_t *cr)
3299{
3300 CtkWidget *widget;
3301
3302 if (content->is_placeholder)
3303 return;
3304
3305 widget = CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
;
3306
3307 if (widget)
3308 ctk_container_propagate_draw (container, widget, cr);
3309}
3310
3311static gboolean
3312toolbar_content_visible (ToolbarContent *content,
3313 CtkToolbar *toolbar)
3314{
3315 CtkToolbarPrivate *priv = toolbar->priv;
3316 CtkToolItem *item;
3317
3318 item = content->item;
3319
3320 if (!ctk_widget_get_visible (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((ctk_widget_get_type ()))))))
))
3321 return FALSE(0);
3322
3323 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL &&
3324 ctk_tool_item_get_visible_horizontal (item))
3325 return TRUE(!(0));
3326
3327 if (priv->orientation == CTK_ORIENTATION_VERTICAL &&
3328 ctk_tool_item_get_visible_vertical (item))
3329 return TRUE(!(0));
3330
3331 return FALSE(0);
3332}
3333
3334static void
3335toolbar_content_size_request (ToolbarContent *content,
3336 CtkToolbar *toolbar G_GNUC_UNUSED__attribute__ ((__unused__)),
3337 CtkRequisition *requisition)
3338{
3339 ctk_widget_get_preferred_size (CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
,
3340 requisition, NULL((void*)0));
3341 if (content->is_placeholder &&
3342 content->disappearing)
3343 {
3344 requisition->width = 0;
3345 requisition->height = 0;
3346 }
3347}
3348
3349static gboolean
3350toolbar_content_is_homogeneous (ToolbarContent *content,
3351 CtkToolbar *toolbar)
3352{
3353 CtkToolbarPrivate *priv = toolbar->priv;
3354 CtkRequisition requisition;
3355 gboolean result;
3356
3357 if (priv->max_homogeneous_pixels < 0)
3358 {
3359 priv->max_homogeneous_pixels =
3360 calculate_max_homogeneous_pixels (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
);
3361 }
3362
3363 toolbar_content_size_request (content, toolbar, &requisition);
3364
3365 if (requisition.width > priv->max_homogeneous_pixels)
3366 return FALSE(0);
3367
3368 result = ctk_tool_item_get_homogeneous (content->item) &&
3369 !CTK_IS_SEPARATOR_TOOL_ITEM (content->item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(content->item)); GType __t = ((ctk_separator_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; }))))
;
3370
3371 if (ctk_tool_item_get_is_important (content->item) &&
3372 priv->style == CTK_TOOLBAR_BOTH_HORIZ &&
3373 priv->orientation == CTK_ORIENTATION_HORIZONTAL)
3374 {
3375 result = FALSE(0);
3376 }
3377
3378 return result;
3379}
3380
3381static gboolean
3382toolbar_content_is_placeholder (ToolbarContent *content)
3383{
3384 if (content->is_placeholder)
3385 return TRUE(!(0));
3386
3387 return FALSE(0);
3388}
3389
3390static gboolean
3391toolbar_content_disappearing (ToolbarContent *content)
3392{
3393 if (content->disappearing)
3394 return TRUE(!(0));
3395
3396 return FALSE(0);
3397}
3398
3399static ItemState
3400toolbar_content_get_state (ToolbarContent *content)
3401{
3402 return content->state;
3403}
3404
3405static gboolean
3406toolbar_content_child_visible (ToolbarContent *content)
3407{
3408 return ctk_widget_get_child_visible (CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
);
3409}
3410
3411static void
3412toolbar_content_get_goal_allocation (ToolbarContent *content,
3413 CtkAllocation *allocation)
3414{
3415 *allocation = content->goal_allocation;
3416}
3417
3418static void
3419toolbar_content_get_allocation (ToolbarContent *content,
3420 CtkAllocation *allocation)
3421{
3422 *allocation = content->allocation;
3423}
3424
3425static void
3426toolbar_content_set_start_allocation (ToolbarContent *content,
3427 CtkAllocation *allocation)
3428{
3429 content->start_allocation = *allocation;
3430}
3431
3432static gboolean
3433toolbar_content_get_expand (ToolbarContent *content)
3434{
3435 if (!content->disappearing &&
3436 ctk_tool_item_get_expand (content->item))
3437 return TRUE(!(0));
3438
3439 return FALSE(0);
3440}
3441
3442static void
3443toolbar_content_set_goal_allocation (ToolbarContent *content,
3444 CtkAllocation *allocation)
3445{
3446 content->goal_allocation = *allocation;
3447}
3448
3449static void
3450toolbar_content_set_child_visible (ToolbarContent *content,
3451 CtkToolbar *toolbar G_GNUC_UNUSED__attribute__ ((__unused__)),
3452 gboolean visible)
3453{
3454 ctk_widget_set_child_visible (CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
,
3455 visible);
3456}
3457
3458static void
3459toolbar_content_get_start_allocation (ToolbarContent *content,
3460 CtkAllocation *start_allocation)
3461{
3462 *start_allocation = content->start_allocation;
3463}
3464
3465static void
3466toolbar_content_size_allocate (ToolbarContent *content,
3467 CtkAllocation *allocation)
3468{
3469 content->allocation = *allocation;
3470 ctk_widget_size_allocate (CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
,
3471 allocation);
3472}
3473
3474static void
3475toolbar_content_set_state (ToolbarContent *content,
3476 ItemState state)
3477{
3478 content->state = state;
3479}
3480
3481static CtkWidget *
3482toolbar_content_get_widget (ToolbarContent *content)
3483{
3484 return CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
;
3485}
3486
3487
3488static void
3489toolbar_content_set_disappearing (ToolbarContent *content,
3490 gboolean disappearing)
3491{
3492 content->disappearing = disappearing;
3493}
3494
3495static void
3496toolbar_content_set_size_request (ToolbarContent *content,
3497 gint width,
3498 gint height)
3499{
3500 ctk_widget_set_size_request (CTK_WIDGET (content->item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content->item)), ((ctk_widget_get_type ()))))))
,
3501 width, height);
3502}
3503
3504static void
3505toolbar_content_toolbar_reconfigured (ToolbarContent *content,
3506 CtkToolbar *toolbar G_GNUC_UNUSED__attribute__ ((__unused__)))
3507{
3508 ctk_tool_item_toolbar_reconfigured (content->item);
3509}
3510
3511static CtkWidget *
3512toolbar_content_retrieve_menu_item (ToolbarContent *content)
3513{
3514 return ctk_tool_item_retrieve_proxy_menu_item (content->item);
3515}
3516
3517static gboolean
3518toolbar_content_has_proxy_menu_item (ToolbarContent *content)
3519{
3520 CtkWidget *menu_item;
3521
3522 if (content->has_menu == YES)
3523 return TRUE(!(0));
3524 else if (content->has_menu == NO)
3525 return FALSE(0);
3526
3527 menu_item = toolbar_content_retrieve_menu_item (content);
3528
3529 content->has_menu = menu_item? YES : NO;
3530
3531 return menu_item != NULL((void*)0);
3532}
3533
3534static void
3535toolbar_content_set_unknown_menu_status (ToolbarContent *content)
3536{
3537 content->has_menu = UNKNOWN;
3538}
3539
3540static gboolean
3541toolbar_content_is_separator (ToolbarContent *content)
3542{
3543 return CTK_IS_SEPARATOR_TOOL_ITEM (content->item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(content->item)); GType __t = ((ctk_separator_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; }))))
;
3544}
3545
3546static void
3547toolbar_content_set_expand (ToolbarContent *content,
3548 gboolean expand)
3549{
3550 ctk_tool_item_set_expand (content->item, expand);
3551}
3552
3553static void
3554toolbar_content_show_all (ToolbarContent *content)
3555{
3556 CtkWidget *widget;
3557
3558 widget = toolbar_content_get_widget (content);
3559 if (widget)
3560 ctk_widget_show_all (widget);
3561}
3562
3563/*
3564 * Getters
3565 */
3566static CtkReliefStyle
3567get_button_relief (CtkToolbar *toolbar)
3568{
3569 CtkReliefStyle button_relief = CTK_RELIEF_NORMAL;
3570
3571 ctk_widget_style_get (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
,
3572 "button-relief", &button_relief,
3573 NULL((void*)0));
3574
3575 return button_relief;
3576}
3577
3578static gint
3579get_max_child_expand (CtkToolbar *toolbar)
3580{
3581 gint mexpand = G_MAXINT2147483647;
3582
3583 ctk_widget_style_get (CTK_WIDGET (toolbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((ctk_widget_get_type ()))))))
,
3584 "max-child-expand", &mexpand,
3585 NULL((void*)0));
3586 return mexpand;
3587}
3588
3589/* CTK+ internal methods */
3590gchar *
3591_ctk_toolbar_elide_underscores (const gchar *original)
3592{
3593 gchar *q, *result;
3594 const gchar *p, *end;
3595 gsize len;
3596 gboolean last_underscore;
3597
3598 if (!original)
3599 return NULL((void*)0);
3600
3601 len = strlen (original);
3602 q = result = g_malloc (len + 1);
3603 last_underscore = FALSE(0);
3604
3605 end = original + len;
3606 for (p = original; p < end; p++)
3607 {
3608 if (!last_underscore && *p == '_')
3609 last_underscore = TRUE(!(0));
3610 else
3611 {
3612 last_underscore = FALSE(0);
3613 if (original + 2 <= p && p + 1 <= end &&
3614 p[-2] == '(' && p[-1] == '_' && p[0] != '_' && p[1] == ')')
3615 {
3616 q--;
3617 *q = '\0';
3618 p++;
3619 }
3620 else
3621 *q++ = *p;
3622 }
3623 }
3624
3625 if (last_underscore)
3626 *q++ = '_';
3627
3628 *q = '\0';
3629
3630 return result;
3631}
3632
3633static CtkIconSize
3634toolbar_get_icon_size (CtkToolShell *shell)
3635{
3636 CtkToolbar *toolbar = CTK_TOOLBAR (shell)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((shell)), ((ctk_toolbar_get_type ()))))))
;
3637 CtkToolbarPrivate *priv = toolbar->priv;
3638
3639 return priv->icon_size;
3640}
3641
3642static CtkOrientation
3643toolbar_get_orientation (CtkToolShell *shell)
3644{
3645 CtkToolbar *toolbar = CTK_TOOLBAR (shell)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((shell)), ((ctk_toolbar_get_type ()))))))
;
3646 CtkToolbarPrivate *priv = toolbar->priv;
3647
3648 return priv->orientation;
3649}
3650
3651static CtkToolbarStyle
3652toolbar_get_style (CtkToolShell *shell)
3653{
3654 CtkToolbar *toolbar = CTK_TOOLBAR (shell)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((shell)), ((ctk_toolbar_get_type ()))))))
;
3655 CtkToolbarPrivate *priv = toolbar->priv;
3656
3657 return priv->style;
3658}
3659
3660static CtkReliefStyle
3661toolbar_get_relief_style (CtkToolShell *shell)
3662{
3663 return get_button_relief (CTK_TOOLBAR (shell)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((shell)), ((ctk_toolbar_get_type ()))))))
);
3664}
3665
3666static void
3667toolbar_rebuild_menu (CtkToolShell *shell)
3668{
3669 CtkToolbar *toolbar = CTK_TOOLBAR (shell)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((shell)), ((ctk_toolbar_get_type ()))))))
;
3670 CtkToolbarPrivate *priv = toolbar->priv;
3671 GList *list;
3672
3673 priv->need_rebuild = TRUE(!(0));
3674
3675 for (list = priv->content; list != NULL((void*)0); list = list->next)
3676 {
3677 ToolbarContent *content = list->data;
3678
3679 toolbar_content_set_unknown_menu_status (content);
3680 }
3681
3682 ctk_widget_queue_resize (CTK_WIDGET (shell)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((shell)), ((ctk_widget_get_type ()))))))
);
3683}
3684
3685static void
3686ctk_toolbar_direction_changed (CtkWidget *widget,
3687 CtkTextDirection previous_direction)
3688{
3689 CTK_WIDGET_CLASS (ctk_toolbar_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_toolbar_parent_class)), ((ctk_widget_get_type ()))))
))
->direction_changed (widget, previous_direction);
3690
3691 ctk_css_node_reverse_children (ctk_widget_get_css_node (widget));
3692}
3693