Bug Summary

File:ctk/deprecated/ctkhandlebox.c
Warning:line 1195, column 7
This statement is never executed

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 ctkhandlebox.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 -fdebug-compilation-dir=/rootdir/ctk -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-21/lib/clang/21 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.26.0" -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_DISABLE_CAST_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/cairo -I /usr/local/include/cdk-pixbuf-2.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -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 -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 -D PIC -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker security.ArrayBound -analyzer-checker unix.cstring.NotNullTerminated -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -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/2026-06-09-180917-46040-1 -x c deprecated/ctkhandlebox.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1998 Elliot Lee
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
20 * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS
21 * file for a list of people on the CTK+ Team. See the ChangeLog
22 * files for a list of changes. These files are distributed with
23 * CTK+ at ftp://ftp.ctk.org/pub/ctk/.
24 */
25
26#include "config.h"
27
28#include <stdlib.h>
29
30#define CDK_DISABLE_DEPRECATION_WARNINGS
31
32#include "ctkhandlebox.h"
33#include "ctkinvisible.h"
34#include "ctkmain.h"
35#include "ctkmarshalers.h"
36#include "ctkrender.h"
37#include "ctkwindow.h"
38#include "ctktypebuiltins.h"
39#include "ctkprivate.h"
40#include "ctkintl.h"
41
42
43/**
44 * SECTION:ctkhandlebox
45 * @Short_description: a widget for detachable window portions
46 * @Title: CtkHandleBox
47 *
48 * The #CtkHandleBox widget allows a portion of a window to be "torn
49 * off". It is a bin widget which displays its child and a handle that
50 * the user can drag to tear off a separate window (the “float
51 * window”) containing the child widget. A thin
52 * “ghost” is drawn in the original location of the
53 * handlebox. By dragging the separate window back to its original
54 * location, it can be reattached.
55 *
56 * When reattaching, the ghost and float window, must be aligned
57 * along one of the edges, the “snap edge”.
58 * This either can be specified by the application programmer
59 * explicitly, or CTK+ will pick a reasonable default based
60 * on the handle position.
61 *
62 * To make detaching and reattaching the handlebox as minimally confusing
63 * as possible to the user, it is important to set the snap edge so that
64 * the snap edge does not move when the handlebox is deattached. For
65 * instance, if the handlebox is packed at the bottom of a VBox, then
66 * when the handlebox is detached, the bottom edge of the handlebox's
67 * allocation will remain fixed as the height of the handlebox shrinks,
68 * so the snap edge should be set to %CTK_POS_BOTTOM.
69 *
70 * > #CtkHandleBox has been deprecated. It is very specialized, lacks features
71 * > to make it useful and most importantly does not fit well into modern
72 * > application design. Do not use it. There is no replacement.
73 */
74
75
76struct _CtkHandleBoxPrivate
77{
78 /* Properties */
79 CtkPositionType handle_position;
80 gint snap_edge;
81 CtkShadowType shadow_type;
82 gboolean child_detached;
83 /* Properties */
84
85 CtkAllocation attach_allocation;
86 CtkAllocation float_allocation;
87
88 CdkDevice *grab_device;
89
90 CdkWindow *bin_window; /* parent window for children */
91 CdkWindow *float_window;
92
93 /* Variables used during a drag
94 */
95 gint orig_x;
96 gint orig_y;
97
98 guint float_window_mapped : 1;
99 guint in_drag : 1;
100 guint shrink_on_detach : 1;
101};
102
103enum {
104 PROP_0,
105 PROP_SHADOW_TYPE,
106 PROP_HANDLE_POSITION,
107 PROP_SNAP_EDGE,
108 PROP_SNAP_EDGE_SET,
109 PROP_CHILD_DETACHED
110};
111
112#define DRAG_HANDLE_SIZE10 10
113#define CHILDLESS_SIZE25 25
114#define GHOST_HEIGHT3 3
115#define TOLERANCE5 5
116
117enum {
118 SIGNAL_CHILD_ATTACHED,
119 SIGNAL_CHILD_DETACHED,
120 SIGNAL_LAST
121};
122
123/* The algorithm for docking and redocking implemented here
124 * has a couple of nice properties:
125 *
126 * 1) During a single drag, docking always occurs at the
127 * the same cursor position. This means that the users
128 * motions are reversible, and that you won't
129 * undock/dock oscillations.
130 *
131 * 2) Docking generally occurs at user-visible features.
132 * The user, once they figure out to redock, will
133 * have useful information about doing it again in
134 * the future.
135 *
136 * Please try to preserve these properties if you
137 * change the algorithm. (And the current algorithm
138 * is far from ideal). Briefly, the current algorithm
139 * for deciding whether the handlebox is docked or not:
140 *
141 * 1) The decision is done by comparing two rectangles - the
142 * allocation if the widget at the start of the drag,
143 * and the boundary of hb->bin_window at the start of
144 * of the drag offset by the distance that the cursor
145 * has moved.
146 *
147 * 2) These rectangles must have one edge, the “snap_edge”
148 * of the handlebox, aligned within TOLERANCE.
149 *
150 * 3) On the other dimension, the extents of one rectangle
151 * must be contained in the extents of the other,
152 * extended by tolerance. That is, either we can have:
153 *
154 * <-TOLERANCE-|--------bin_window--------------|-TOLERANCE->
155 * <--------float_window-------------------->
156 *
157 * or we can have:
158 *
159 * <-TOLERANCE-|------float_window--------------|-TOLERANCE->
160 * <--------bin_window-------------------->
161 */
162
163static void ctk_handle_box_set_property (GObject *object,
164 guint param_id,
165 const GValue *value,
166 GParamSpec *pspec);
167static void ctk_handle_box_get_property (GObject *object,
168 guint param_id,
169 GValue *value,
170 GParamSpec *pspec);
171static void ctk_handle_box_map (CtkWidget *widget);
172static void ctk_handle_box_unmap (CtkWidget *widget);
173static void ctk_handle_box_realize (CtkWidget *widget);
174static void ctk_handle_box_unrealize (CtkWidget *widget);
175static void ctk_handle_box_style_updated (CtkWidget *widget);
176static void ctk_handle_box_size_request (CtkWidget *widget,
177 CtkRequisition *requisition);
178static void ctk_handle_box_get_preferred_width (CtkWidget *widget,
179 gint *minimum,
180 gint *natural);
181static void ctk_handle_box_get_preferred_height (CtkWidget *widget,
182 gint *minimum,
183 gint *natural);
184static void ctk_handle_box_size_allocate (CtkWidget *widget,
185 CtkAllocation *real_allocation);
186static void ctk_handle_box_add (CtkContainer *container,
187 CtkWidget *widget);
188static void ctk_handle_box_remove (CtkContainer *container,
189 CtkWidget *widget);
190static gboolean ctk_handle_box_draw (CtkWidget *widget,
191 cairo_t *cr);
192static gboolean ctk_handle_box_button_press (CtkWidget *widget,
193 CdkEventButton *event);
194static gboolean ctk_handle_box_motion (CtkWidget *widget,
195 CdkEventMotion *event);
196static gboolean ctk_handle_box_delete_event (CtkWidget *widget,
197 CdkEventAny *event);
198static void ctk_handle_box_reattach (CtkHandleBox *hb);
199static void ctk_handle_box_end_drag (CtkHandleBox *hb,
200 guint32 time);
201
202static guint handle_box_signals[SIGNAL_LAST] = { 0 };
203
204G_DEFINE_TYPE_WITH_PRIVATE (CtkHandleBox, ctk_handle_box, CTK_TYPE_BIN)static void ctk_handle_box_init (CtkHandleBox *self); static void
ctk_handle_box_class_init (CtkHandleBoxClass *klass); static
GType ctk_handle_box_get_type_once (void); static gpointer ctk_handle_box_parent_class
= ((void*)0); static gint CtkHandleBox_private_offset; static
void ctk_handle_box_class_intern_init (gpointer klass) { ctk_handle_box_parent_class
= g_type_class_peek_parent (klass); if (CtkHandleBox_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &CtkHandleBox_private_offset
); ctk_handle_box_class_init ((CtkHandleBoxClass*) klass); } __attribute__
((__unused__)) static inline gpointer ctk_handle_box_get_instance_private
(CtkHandleBox *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (CtkHandleBox_private_offset)))); } GType ctk_handle_box_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_handle_box_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_handle_box_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
ctk_bin_get_type ()), g_intern_static_string ("CtkHandleBox")
, sizeof (CtkHandleBoxClass), (GClassInitFunc)(void (*)(void)
) ctk_handle_box_class_intern_init, sizeof (CtkHandleBox), (GInstanceInitFunc
)(void (*)(void)) ctk_handle_box_init, (GTypeFlags) 0); { {{ CtkHandleBox_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (CtkHandleBoxPrivate
)); };} } return g_define_type_id; }
205
206static void
207ctk_handle_box_class_init (CtkHandleBoxClass *class)
208{
209 GObjectClass *gobject_class;
210 CtkWidgetClass *widget_class;
211 CtkContainerClass *container_class;
212
213 gobject_class = (GObjectClass *) class;
214 widget_class = (CtkWidgetClass *) class;
215 container_class = (CtkContainerClass *) class;
216
217 gobject_class->set_property = ctk_handle_box_set_property;
218 gobject_class->get_property = ctk_handle_box_get_property;
219
220 g_object_class_install_property (gobject_class,
221 PROP_SHADOW_TYPE,
222 g_param_spec_enum ("shadow-type",
223 P_("Shadow type")g_dgettext("ctk30" "-properties","Shadow type"),
224 P_("Appearance of the shadow that surrounds the container")g_dgettext("ctk30" "-properties","Appearance of the shadow that surrounds the container"
)
,
225 CTK_TYPE_SHADOW_TYPE(ctk_shadow_type_get_type ()),
226 CTK_SHADOW_OUT,
227 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
228
229 g_object_class_install_property (gobject_class,
230 PROP_HANDLE_POSITION,
231 g_param_spec_enum ("handle-position",
232 P_("Handle position")g_dgettext("ctk30" "-properties","Handle position"),
233 P_("Position of the handle relative to the child widget")g_dgettext("ctk30" "-properties","Position of the handle relative to the child widget"
)
,
234 CTK_TYPE_POSITION_TYPE(ctk_position_type_get_type ()),
235 CTK_POS_LEFT,
236 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
237
238 g_object_class_install_property (gobject_class,
239 PROP_SNAP_EDGE,
240 g_param_spec_enum ("snap-edge",
241 P_("Snap edge")g_dgettext("ctk30" "-properties","Snap edge"),
242 P_("Side of the handlebox that's lined up with the docking point to dock the handlebox")g_dgettext("ctk30" "-properties","Side of the handlebox that's lined up with the docking point to dock the handlebox"
)
,
243 CTK_TYPE_POSITION_TYPE(ctk_position_type_get_type ()),
244 CTK_POS_TOP,
245 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
246
247 g_object_class_install_property (gobject_class,
248 PROP_SNAP_EDGE_SET,
249 g_param_spec_boolean ("snap-edge-set",
250 P_("Snap edge set")g_dgettext("ctk30" "-properties","Snap edge set"),
251 P_("Whether to use the value from the snap_edge property or a value derived from handle_position")g_dgettext("ctk30" "-properties","Whether to use the value from the snap_edge property or a value derived from handle_position"
)
,
252 FALSE(0),
253 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
254
255 g_object_class_install_property (gobject_class,
256 PROP_CHILD_DETACHED,
257 g_param_spec_boolean ("child-detached",
258 P_("Child Detached")g_dgettext("ctk30" "-properties","Child Detached"),
259 P_("A boolean value indicating whether the handlebox's child is attached or detached.")g_dgettext("ctk30" "-properties","A boolean value indicating whether the handlebox's child is attached or detached."
)
,
260 FALSE(0),
261 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
262
263 widget_class->map = ctk_handle_box_map;
264 widget_class->unmap = ctk_handle_box_unmap;
265 widget_class->realize = ctk_handle_box_realize;
266 widget_class->unrealize = ctk_handle_box_unrealize;
267 widget_class->style_updated = ctk_handle_box_style_updated;
268 widget_class->get_preferred_width = ctk_handle_box_get_preferred_width;
269 widget_class->get_preferred_height = ctk_handle_box_get_preferred_height;
270 widget_class->size_allocate = ctk_handle_box_size_allocate;
271 widget_class->draw = ctk_handle_box_draw;
272 widget_class->button_press_event = ctk_handle_box_button_press;
273 widget_class->delete_event = ctk_handle_box_delete_event;
274
275 container_class->add = ctk_handle_box_add;
276 container_class->remove = ctk_handle_box_remove;
277
278 class->child_attached = NULL((void*)0);
279 class->child_detached = NULL((void*)0);
280
281 /**
282 * CtkHandleBox::child-attached:
283 * @handlebox: the object which received the signal.
284 * @widget: the child widget of the handlebox.
285 * (this argument provides no extra information
286 * and is here only for backwards-compatibility)
287 *
288 * This signal is emitted when the contents of the
289 * handlebox are reattached to the main window.
290 *
291 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
292 */
293 handle_box_signals[SIGNAL_CHILD_ATTACHED] =
294 g_signal_new (I_("child-attached")g_intern_static_string ("child-attached"),
295 G_OBJECT_CLASS_TYPE (gobject_class)((((GTypeClass*) (gobject_class))->g_type)),
296 G_SIGNAL_RUN_FIRST,
297 G_STRUCT_OFFSET (CtkHandleBoxClass, child_attached)((glong) __builtin_offsetof(CtkHandleBoxClass, child_attached
))
,
298 NULL((void*)0), NULL((void*)0),
299 NULL((void*)0),
300 G_TYPE_NONE((GType) ((1) << (2))), 1,
301 CTK_TYPE_WIDGET(ctk_widget_get_type ()));
302
303 /**
304 * CtkHandleBox::child-detached:
305 * @handlebox: the object which received the signal.
306 * @widget: the child widget of the handlebox.
307 * (this argument provides no extra information
308 * and is here only for backwards-compatibility)
309 *
310 * This signal is emitted when the contents of the
311 * handlebox are detached from the main window.
312 *
313 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
314 */
315 handle_box_signals[SIGNAL_CHILD_DETACHED] =
316 g_signal_new (I_("child-detached")g_intern_static_string ("child-detached"),
317 G_OBJECT_CLASS_TYPE (gobject_class)((((GTypeClass*) (gobject_class))->g_type)),
318 G_SIGNAL_RUN_FIRST,
319 G_STRUCT_OFFSET (CtkHandleBoxClass, child_detached)((glong) __builtin_offsetof(CtkHandleBoxClass, child_detached
))
,
320 NULL((void*)0), NULL((void*)0),
321 NULL((void*)0),
322 G_TYPE_NONE((GType) ((1) << (2))), 1,
323 CTK_TYPE_WIDGET(ctk_widget_get_type ()));
324}
325
326static void
327ctk_handle_box_init (CtkHandleBox *handle_box)
328{
329 CtkHandleBoxPrivate *priv;
330 CtkStyleContext *context;
331
332 handle_box->priv = ctk_handle_box_get_instance_private (handle_box);
333 priv = handle_box->priv;
334
335 ctk_widget_set_has_window (CTK_WIDGET (handle_box)((((CtkWidget*) (void *) ((handle_box))))), TRUE(!(0)));
336
337 priv->bin_window = NULL((void*)0);
338 priv->float_window = NULL((void*)0);
339 priv->shadow_type = CTK_SHADOW_OUT;
340 priv->handle_position = CTK_POS_LEFT;
341 priv->float_window_mapped = FALSE(0);
342 priv->child_detached = FALSE(0);
343 priv->in_drag = FALSE(0);
344 priv->shrink_on_detach = TRUE(!(0));
345 priv->snap_edge = -1;
346
347 context = ctk_widget_get_style_context (CTK_WIDGET (handle_box)((((CtkWidget*) (void *) ((handle_box))))));
348 ctk_style_context_add_class (context, CTK_STYLE_CLASS_DOCK"dock");
349}
350
351static void
352ctk_handle_box_set_property (GObject *object,
353 guint prop_id,
354 const GValue *value,
355 GParamSpec *pspec)
356{
357 CtkHandleBox *handle_box = CTK_HANDLE_BOX (object)((((CtkHandleBox*) (void *) ((object)))));
358
359 switch (prop_id)
360 {
361 case PROP_SHADOW_TYPE:
362 ctk_handle_box_set_shadow_type (handle_box, g_value_get_enum (value));
363 break;
364 case PROP_HANDLE_POSITION:
365 ctk_handle_box_set_handle_position (handle_box, g_value_get_enum (value));
366 break;
367 case PROP_SNAP_EDGE:
368 ctk_handle_box_set_snap_edge (handle_box, g_value_get_enum (value));
369 break;
370 case PROP_SNAP_EDGE_SET:
371 if (!g_value_get_boolean (value))
372 ctk_handle_box_set_snap_edge (handle_box, (CtkPositionType)-1);
373 break;
374 default:
375 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'"
, "deprecated/ctkhandlebox.c", 375, ("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)
;
376 break;
377 }
378}
379
380static void
381ctk_handle_box_get_property (GObject *object,
382 guint prop_id,
383 GValue *value,
384 GParamSpec *pspec)
385{
386 CtkHandleBox *handle_box = CTK_HANDLE_BOX (object)((((CtkHandleBox*) (void *) ((object)))));
387 CtkHandleBoxPrivate *priv = handle_box->priv;
388
389 switch (prop_id)
390 {
391 case PROP_SHADOW_TYPE:
392 g_value_set_enum (value, priv->shadow_type);
393 break;
394 case PROP_HANDLE_POSITION:
395 g_value_set_enum (value, priv->handle_position);
396 break;
397 case PROP_SNAP_EDGE:
398 g_value_set_enum (value,
399 (priv->snap_edge == -1 ?
400 CTK_POS_TOP : priv->snap_edge));
401 break;
402 case PROP_SNAP_EDGE_SET:
403 g_value_set_boolean (value, priv->snap_edge != -1);
404 break;
405 case PROP_CHILD_DETACHED:
406 g_value_set_boolean (value, priv->child_detached);
407 break;
408 default:
409 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'"
, "deprecated/ctkhandlebox.c", 409, ("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)
;
410 break;
411 }
412}
413
414/**
415 * ctk_handle_box_new:
416 *
417 * Create a new handle box.
418 *
419 * Returns: a new #CtkHandleBox.
420 *
421 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
422 */
423CtkWidget*
424ctk_handle_box_new (void)
425{
426 return g_object_new (CTK_TYPE_HANDLE_BOX(ctk_handle_box_get_type ()), NULL((void*)0));
427}
428
429static void
430ctk_handle_box_map (CtkWidget *widget)
431{
432 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
433 CtkHandleBoxPrivate *priv = hb->priv;
434 CtkBin *bin = CTK_BIN (widget)((((CtkBin*) (void *) ((widget)))));
435 CtkWidget *child;
436
437 ctk_widget_set_mapped (widget, TRUE(!(0)));
438
439 child = ctk_bin_get_child (bin);
440 if (child != NULL((void*)0) &&
441 ctk_widget_get_visible (child) &&
442 !ctk_widget_get_mapped (child))
443 ctk_widget_map (child);
444
445 if (priv->child_detached && !priv->float_window_mapped)
446 {
447 cdk_window_show (priv->float_window);
448 priv->float_window_mapped = TRUE(!(0));
449 }
450
451 cdk_window_show (priv->bin_window);
452 cdk_window_show (ctk_widget_get_window (widget));
453}
454
455static void
456ctk_handle_box_unmap (CtkWidget *widget)
457{
458 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
459 CtkHandleBoxPrivate *priv = hb->priv;
460
461 ctk_widget_set_mapped (widget, FALSE(0));
462
463 cdk_window_hide (ctk_widget_get_window (widget));
464 if (priv->float_window_mapped)
465 {
466 cdk_window_hide (priv->float_window);
467 priv->float_window_mapped = FALSE(0);
468 }
469
470 CTK_WIDGET_CLASS (ctk_handle_box_parent_class)((((CtkWidgetClass*) (void *) ((ctk_handle_box_parent_class))
)))
->unmap (widget);
471}
472
473static void
474ctk_handle_box_realize (CtkWidget *widget)
475{
476 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
477 CtkHandleBoxPrivate *priv = hb->priv;
478 CtkAllocation allocation;
479 CtkRequisition requisition;
480 CtkStyleContext *context;
481 CtkWidget *child;
482 CdkWindow *window;
483 CdkWindowAttr attributes;
484 gint attributes_mask;
485
486 ctk_widget_set_realized (widget, TRUE(!(0)));
487
488 ctk_widget_get_allocation (widget, &allocation);
489
490 attributes.x = allocation.x;
491 attributes.y = allocation.y;
492 attributes.width = allocation.width;
493 attributes.height = allocation.height;
494 attributes.window_type = CDK_WINDOW_CHILD;
495 attributes.wclass = CDK_INPUT_OUTPUT;
496 attributes.visual = ctk_widget_get_visual (widget);
497 attributes.event_mask = ctk_widget_get_events (widget);
498 attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL;
499
500 window = cdk_window_new (ctk_widget_get_parent_window (widget),
501 &attributes, attributes_mask);
502 ctk_widget_set_window (widget, window);
503 cdk_window_set_user_data (window, widget);
504
505 attributes.x = 0;
506 attributes.y = 0;
507 attributes.width = allocation.width;
508 attributes.height = allocation.height;
509 attributes.window_type = CDK_WINDOW_CHILD;
510 attributes.event_mask = (ctk_widget_get_events (widget)
511 | CDK_BUTTON1_MOTION_MASK
512 | CDK_POINTER_MOTION_HINT_MASK
513 | CDK_BUTTON_PRESS_MASK
514 | CDK_BUTTON_RELEASE_MASK);
515 attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL;
516
517 priv->bin_window = cdk_window_new (window,
518 &attributes, attributes_mask);
519 cdk_window_set_user_data (priv->bin_window, widget);
520
521 child = ctk_bin_get_child (CTK_BIN (hb)((((CtkBin*) (void *) ((hb))))));
522 if (child)
523 ctk_widget_set_parent_window (child, priv->bin_window);
524
525 ctk_widget_get_preferred_size (widget, &requisition, NULL((void*)0));
526
527 attributes.x = 0;
528 attributes.y = 0;
529 attributes.width = requisition.width;
530 attributes.height = requisition.height;
531 attributes.window_type = CDK_WINDOW_TOPLEVEL;
532 attributes.wclass = CDK_INPUT_OUTPUT;
533 attributes.visual = ctk_widget_get_visual (widget);
534 attributes.event_mask = (ctk_widget_get_events (widget)
535 | CDK_KEY_PRESS_MASK
536 | CDK_ENTER_NOTIFY_MASK
537 | CDK_LEAVE_NOTIFY_MASK
538 | CDK_FOCUS_CHANGE_MASK
539 | CDK_STRUCTURE_MASK);
540 attributes.type_hint = CDK_WINDOW_TYPE_HINT_TOOLBAR;
541 attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL | CDK_WA_TYPE_HINT;
542 priv->float_window = cdk_window_new (cdk_screen_get_root_window (ctk_widget_get_screen (widget)),
543 &attributes, attributes_mask);
544 cdk_window_set_user_data (priv->float_window, widget);
545 cdk_window_set_decorations (priv->float_window, 0);
546 cdk_window_set_type_hint (priv->float_window, CDK_WINDOW_TYPE_HINT_TOOLBAR);
547
548 context = ctk_widget_get_style_context (widget);
549 ctk_style_context_set_background (context, window);
550 ctk_style_context_set_background (context, priv->bin_window);
551 ctk_style_context_set_background (context, priv->float_window);
552}
553
554static void
555ctk_handle_box_unrealize (CtkWidget *widget)
556{
557 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
558 CtkHandleBoxPrivate *priv = hb->priv;
559
560 cdk_window_set_user_data (priv->bin_window, NULL((void*)0));
561 cdk_window_destroy (priv->bin_window);
562 priv->bin_window = NULL((void*)0);
563 cdk_window_set_user_data (priv->float_window, NULL((void*)0));
564 cdk_window_destroy (priv->float_window);
565 priv->float_window = NULL((void*)0);
566
567 CTK_WIDGET_CLASS (ctk_handle_box_parent_class)((((CtkWidgetClass*) (void *) ((ctk_handle_box_parent_class))
)))
->unrealize (widget);
568}
569
570static void
571ctk_handle_box_style_updated (CtkWidget *widget)
572{
573 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
574 CtkHandleBoxPrivate *priv = hb->priv;
575
576 CTK_WIDGET_CLASS (ctk_handle_box_parent_class)((((CtkWidgetClass*) (void *) ((ctk_handle_box_parent_class))
)))
->style_updated (widget);
577
578 if (ctk_widget_get_realized (widget) &&
579 ctk_widget_get_has_window (widget))
580 {
581 CtkStateFlags state;
582 CtkStyleContext *context;
583
584 context = ctk_widget_get_style_context (widget);
585 state = ctk_widget_get_state_flags (widget);
586
587 ctk_style_context_save (context);
588 ctk_style_context_set_state (context, state);
589
590 ctk_style_context_set_background (context, ctk_widget_get_window (widget));
591 ctk_style_context_set_background (context, priv->bin_window);
592 ctk_style_context_set_background (context, priv->float_window);
593
594 ctk_style_context_restore (context);
595 }
596}
597
598static int
599effective_handle_position (CtkHandleBox *hb)
600{
601 CtkHandleBoxPrivate *priv = hb->priv;
602 int handle_position;
603
604 if (ctk_widget_get_direction (CTK_WIDGET (hb)((((CtkWidget*) (void *) ((hb)))))) == CTK_TEXT_DIR_LTR)
605 handle_position = priv->handle_position;
606 else
607 {
608 switch (priv->handle_position)
609 {
610 case CTK_POS_LEFT:
611 handle_position = CTK_POS_RIGHT;
612 break;
613 case CTK_POS_RIGHT:
614 handle_position = CTK_POS_LEFT;
615 break;
616 default:
617 handle_position = priv->handle_position;
618 break;
619 }
620 }
621
622 return handle_position;
623}
624
625static void
626ctk_handle_box_size_request (CtkWidget *widget,
627 CtkRequisition *requisition)
628{
629 CtkBin *bin = CTK_BIN (widget)((((CtkBin*) (void *) ((widget)))));
630 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
631 CtkHandleBoxPrivate *priv = hb->priv;
632 CtkRequisition child_requisition;
633 CtkWidget *child;
634 gint handle_position;
635
636 handle_position = effective_handle_position (hb);
637
638 if (handle_position == CTK_POS_LEFT ||
639 handle_position == CTK_POS_RIGHT)
640 {
641 requisition->width = DRAG_HANDLE_SIZE10;
642 requisition->height = 0;
643 }
644 else
645 {
646 requisition->width = 0;
647 requisition->height = DRAG_HANDLE_SIZE10;
648 }
649
650 child = ctk_bin_get_child (bin);
651 /* if our child is not visible, we still request its size, since we
652 * won't have any useful hint for our size otherwise.
653 */
654 if (child)
655 {
656 ctk_widget_get_preferred_size (child, &child_requisition, NULL((void*)0));
657 }
658 else
659 {
660 child_requisition.width = 0;
661 child_requisition.height = 0;
662 }
663
664 if (priv->child_detached)
665 {
666 /* FIXME: This doesn't work currently */
667 if (!priv->shrink_on_detach)
668 {
669 if (handle_position == CTK_POS_LEFT ||
670 handle_position == CTK_POS_RIGHT)
671 requisition->height += child_requisition.height;
672 else
673 requisition->width += child_requisition.width;
674 }
675 else
676 {
677 CtkStyleContext *context;
678 CtkStateFlags state;
679 CtkBorder padding;
680
681 context = ctk_widget_get_style_context (widget);
682 state = ctk_widget_get_state_flags (widget);
683 ctk_style_context_get_padding (context, state, &padding);
684
685 if (handle_position == CTK_POS_LEFT ||
686 handle_position == CTK_POS_RIGHT)
687 requisition->height += padding.top;
688 else
689 requisition->width += padding.left;
690 }
691 }
692 else
693 {
694 guint border_width;
695
696 border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) ((widget))))));
697 requisition->width += border_width * 2;
698 requisition->height += border_width * 2;
699
700 if (child)
701 {
702 requisition->width += child_requisition.width;
703 requisition->height += child_requisition.height;
704 }
705 else
706 {
707 requisition->width += CHILDLESS_SIZE25;
708 requisition->height += CHILDLESS_SIZE25;
709 }
710 }
711}
712
713static void
714ctk_handle_box_get_preferred_width (CtkWidget *widget,
715 gint *minimum,
716 gint *natural)
717{
718 CtkRequisition requisition;
719
720 ctk_handle_box_size_request (widget, &requisition);
721
722 *minimum = *natural = requisition.width;
723}
724
725static void
726ctk_handle_box_get_preferred_height (CtkWidget *widget,
727 gint *minimum,
728 gint *natural)
729{
730 CtkRequisition requisition;
731
732 ctk_handle_box_size_request (widget, &requisition);
733
734 *minimum = *natural = requisition.height;
735}
736
737
738static void
739ctk_handle_box_size_allocate (CtkWidget *widget,
740 CtkAllocation *allocation)
741{
742 CtkBin *bin = CTK_BIN (widget)((((CtkBin*) (void *) ((widget)))));
743 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
744 CtkHandleBoxPrivate *priv = hb->priv;
745 CtkRequisition child_requisition;
746 CtkWidget *child;
747 gint handle_position;
748
749 handle_position = effective_handle_position (hb);
750
751 child = ctk_bin_get_child (bin);
752
753 if (child)
754 {
755 ctk_widget_get_preferred_size (child, &child_requisition, NULL((void*)0));
756 }
757 else
758 {
759 child_requisition.width = 0;
760 child_requisition.height = 0;
761 }
762
763 ctk_widget_set_allocation (widget, allocation);
764
765 if (ctk_widget_get_realized (widget))
766 cdk_window_move_resize (ctk_widget_get_window (widget),
767 allocation->x, allocation->y,
768 allocation->width, allocation->height);
769
770 if (child != NULL((void*)0) && ctk_widget_get_visible (child))
771 {
772 CtkAllocation child_allocation;
773 guint border_width;
774
775 border_width = ctk_container_get_border_width (CTK_CONTAINER (widget)((((CtkContainer*) (void *) ((widget))))));
776
777 child_allocation.x = border_width;
778 child_allocation.y = border_width;
779 if (handle_position == CTK_POS_LEFT)
780 child_allocation.x += DRAG_HANDLE_SIZE10;
781 else if (handle_position == CTK_POS_TOP)
782 child_allocation.y += DRAG_HANDLE_SIZE10;
783
784 if (priv->child_detached)
785 {
786 guint float_width;
787 guint float_height;
788
789 child_allocation.width = child_requisition.width;
790 child_allocation.height = child_requisition.height;
791
792 float_width = child_allocation.width + 2 * border_width;
793 float_height = child_allocation.height + 2 * border_width;
794
795 if (handle_position == CTK_POS_LEFT ||
796 handle_position == CTK_POS_RIGHT)
797 float_width += DRAG_HANDLE_SIZE10;
798 else
799 float_height += DRAG_HANDLE_SIZE10;
800
801 if (ctk_widget_get_realized (widget))
802 {
803 cdk_window_resize (priv->float_window,
804 float_width,
805 float_height);
806 cdk_window_move_resize (priv->bin_window,
807 0,
808 0,
809 float_width,
810 float_height);
811 }
812 }
813 else
814 {
815 child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width)(((1) > ((gint) allocation->width - 2 * border_width)) ?
(1) : ((gint) allocation->width - 2 * border_width))
;
816 child_allocation.height = MAX (1, (gint) allocation->height - 2 * border_width)(((1) > ((gint) allocation->height - 2 * border_width))
? (1) : ((gint) allocation->height - 2 * border_width))
;
817
818 if (handle_position == CTK_POS_LEFT ||
819 handle_position == CTK_POS_RIGHT)
820 child_allocation.width -= DRAG_HANDLE_SIZE10;
821 else
822 child_allocation.height -= DRAG_HANDLE_SIZE10;
823
824 if (ctk_widget_get_realized (widget))
825 cdk_window_move_resize (priv->bin_window,
826 0,
827 0,
828 allocation->width,
829 allocation->height);
830 }
831
832 ctk_widget_size_allocate (child, &child_allocation);
833 }
834}
835
836static void
837ctk_handle_box_draw_ghost (CtkHandleBox *hb,
838 cairo_t *cr)
839{
840 CtkWidget *widget = CTK_WIDGET (hb)((((CtkWidget*) (void *) ((hb)))));
841 CtkStateFlags state;
842 CtkStyleContext *context;
843 guint x;
844 guint y;
845 guint width;
846 guint height;
847 gint allocation_width;
848 gint allocation_height;
849 gint handle_position;
850
851 handle_position = effective_handle_position (hb);
852 allocation_width = ctk_widget_get_allocated_width (widget);
853 allocation_height = ctk_widget_get_allocated_height (widget);
854
855 if (handle_position == CTK_POS_LEFT ||
856 handle_position == CTK_POS_RIGHT)
857 {
858 x = handle_position == CTK_POS_LEFT ? 0 : allocation_width - DRAG_HANDLE_SIZE10;
859 y = 0;
860 width = DRAG_HANDLE_SIZE10;
861 height = allocation_height;
862 }
863 else
864 {
865 x = 0;
866 y = handle_position == CTK_POS_TOP ? 0 : allocation_height - DRAG_HANDLE_SIZE10;
867 width = allocation_width;
868 height = DRAG_HANDLE_SIZE10;
869 }
870
871 context = ctk_widget_get_style_context (widget);
872 state = ctk_widget_get_state_flags (widget);
873
874 ctk_style_context_save (context);
875 ctk_style_context_set_state (context, state);
876
877 ctk_render_background (context, cr, x, y, width, height);
878 ctk_render_frame (context, cr, x, y, width, height);
879
880 if (handle_position == CTK_POS_LEFT ||
881 handle_position == CTK_POS_RIGHT)
882 ctk_render_line (context, cr,
883 handle_position == CTK_POS_LEFT ? DRAG_HANDLE_SIZE10 : 0,
884 allocation_height / 2,
885 handle_position == CTK_POS_LEFT ? allocation_width : allocation_width - DRAG_HANDLE_SIZE10,
886 allocation_height / 2);
887 else
888 ctk_render_line (context, cr,
889 allocation_width / 2,
890 handle_position == CTK_POS_TOP ? DRAG_HANDLE_SIZE10 : 0,
891 allocation_width / 2,
892 handle_position == CTK_POS_TOP ? allocation_height : allocation_height - DRAG_HANDLE_SIZE10);
893
894 ctk_style_context_restore (context);
895}
896
897/**
898 * ctk_handle_box_set_shadow_type:
899 * @handle_box: a #CtkHandleBox
900 * @type: the shadow type.
901 *
902 * Sets the type of shadow to be drawn around the border
903 * of the handle box.
904 *
905 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
906 */
907void
908ctk_handle_box_set_shadow_type (CtkHandleBox *handle_box,
909 CtkShadowType type)
910{
911 CtkHandleBoxPrivate *priv;
912
913 g_return_if_fail (CTK_IS_HANDLE_BOX (handle_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((handle_box)); GType __t = ((ctk_handle_box_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_HANDLE_BOX (handle_box)"); return; } }
while (0)
;
914
915 priv = handle_box->priv;
916
917 if ((CtkShadowType) priv->shadow_type != type)
918 {
919 priv->shadow_type = type;
920 g_object_notify (G_OBJECT (handle_box)((((GObject*) (void *) ((handle_box))))), "shadow-type");
921 ctk_widget_queue_resize (CTK_WIDGET (handle_box)((((CtkWidget*) (void *) ((handle_box))))));
922 }
923}
924
925/**
926 * ctk_handle_box_get_shadow_type:
927 * @handle_box: a #CtkHandleBox
928 *
929 * Gets the type of shadow drawn around the handle box. See
930 * ctk_handle_box_set_shadow_type().
931 *
932 * Returns: the type of shadow currently drawn around the handle box.
933 *
934 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
935 **/
936CtkShadowType
937ctk_handle_box_get_shadow_type (CtkHandleBox *handle_box)
938{
939 g_return_val_if_fail (CTK_IS_HANDLE_BOX (handle_box), CTK_SHADOW_ETCHED_OUT)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((handle_box)); GType __t = ((ctk_handle_box_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_HANDLE_BOX (handle_box)"); return (CTK_SHADOW_ETCHED_OUT
); } } while (0)
;
940
941 return handle_box->priv->shadow_type;
942}
943
944/**
945 * ctk_handle_box_set_handle_position:
946 * @handle_box: a #CtkHandleBox
947 * @position: the side of the handlebox where the handle should be drawn.
948 *
949 * Sets the side of the handlebox where the handle is drawn.
950 *
951 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
952 */
953void
954ctk_handle_box_set_handle_position (CtkHandleBox *handle_box,
955 CtkPositionType position)
956{
957 CtkHandleBoxPrivate *priv;
958
959 g_return_if_fail (CTK_IS_HANDLE_BOX (handle_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((handle_box)); GType __t = ((ctk_handle_box_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_HANDLE_BOX (handle_box)"); return; } }
while (0)
;
960
961 priv = handle_box->priv;
962
963 if ((CtkPositionType) priv->handle_position != position)
964 {
965 priv->handle_position = position;
966 g_object_notify (G_OBJECT (handle_box)((((GObject*) (void *) ((handle_box))))), "handle-position");
967 ctk_widget_queue_resize (CTK_WIDGET (handle_box)((((CtkWidget*) (void *) ((handle_box))))));
968 }
969}
970
971/**
972 * ctk_handle_box_get_handle_position:
973 * @handle_box: a #CtkHandleBox
974 *
975 * Gets the handle position of the handle box. See
976 * ctk_handle_box_set_handle_position().
977 *
978 * Returns: the current handle position.
979 *
980 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
981 **/
982CtkPositionType
983ctk_handle_box_get_handle_position (CtkHandleBox *handle_box)
984{
985 g_return_val_if_fail (CTK_IS_HANDLE_BOX (handle_box), CTK_POS_LEFT)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((handle_box)); GType __t = ((ctk_handle_box_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_HANDLE_BOX (handle_box)"); return (CTK_POS_LEFT
); } } while (0)
;
986
987 return handle_box->priv->handle_position;
988}
989
990/**
991 * ctk_handle_box_set_snap_edge:
992 * @handle_box: a #CtkHandleBox
993 * @edge: the snap edge, or -1 to unset the value; in which
994 * case CTK+ will try to guess an appropriate value
995 * in the future.
996 *
997 * Sets the snap edge of a handlebox. The snap edge is
998 * the edge of the detached child that must be aligned
999 * with the corresponding edge of the “ghost” left
1000 * behind when the child was detached to reattach
1001 * the torn-off window. Usually, the snap edge should
1002 * be chosen so that it stays in the same place on
1003 * the screen when the handlebox is torn off.
1004 *
1005 * If the snap edge is not set, then an appropriate value
1006 * will be guessed from the handle position. If the
1007 * handle position is %CTK_POS_RIGHT or %CTK_POS_LEFT,
1008 * then the snap edge will be %CTK_POS_TOP, otherwise
1009 * it will be %CTK_POS_LEFT.
1010 *
1011 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
1012 */
1013void
1014ctk_handle_box_set_snap_edge (CtkHandleBox *handle_box,
1015 CtkPositionType edge)
1016{
1017 CtkHandleBoxPrivate *priv;
1018
1019 g_return_if_fail (CTK_IS_HANDLE_BOX (handle_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((handle_box)); GType __t = ((ctk_handle_box_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_HANDLE_BOX (handle_box)"); return; } }
while (0)
;
1020
1021 priv = handle_box->priv;
1022
1023 if (priv->snap_edge != edge)
1024 {
1025 priv->snap_edge = edge;
1026
1027 g_object_freeze_notify (G_OBJECT (handle_box)((((GObject*) (void *) ((handle_box))))));
1028 g_object_notify (G_OBJECT (handle_box)((((GObject*) (void *) ((handle_box))))), "snap-edge");
1029 g_object_notify (G_OBJECT (handle_box)((((GObject*) (void *) ((handle_box))))), "snap-edge-set");
1030 g_object_thaw_notify (G_OBJECT (handle_box)((((GObject*) (void *) ((handle_box))))));
1031 }
1032}
1033
1034/**
1035 * ctk_handle_box_get_snap_edge:
1036 * @handle_box: a #CtkHandleBox
1037 *
1038 * Gets the edge used for determining reattachment of the handle box.
1039 * See ctk_handle_box_set_snap_edge().
1040 *
1041 * Returns: the edge used for determining reattachment, or
1042 * (CtkPositionType)-1 if this is determined (as per default)
1043 * from the handle position.
1044 *
1045 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
1046 **/
1047CtkPositionType
1048ctk_handle_box_get_snap_edge (CtkHandleBox *handle_box)
1049{
1050 g_return_val_if_fail (CTK_IS_HANDLE_BOX (handle_box), (CtkPositionType)-1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((handle_box)); GType __t = ((ctk_handle_box_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_HANDLE_BOX (handle_box)"); return ((CtkPositionType
)-1); } } while (0)
;
1051
1052 return (CtkPositionType)handle_box->priv->snap_edge;
1053}
1054
1055/**
1056 * ctk_handle_box_get_child_detached:
1057 * @handle_box: a #CtkHandleBox
1058 *
1059 * Whether the handlebox’s child is currently detached.
1060 *
1061 * Returns: %TRUE if the child is currently detached, otherwise %FALSE
1062 *
1063 * Since: 2.14
1064 *
1065 * Deprecated: 3.4: #CtkHandleBox has been deprecated.
1066 **/
1067gboolean
1068ctk_handle_box_get_child_detached (CtkHandleBox *handle_box)
1069{
1070 g_return_val_if_fail (CTK_IS_HANDLE_BOX (handle_box), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((handle_box)); GType __t = ((ctk_handle_box_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_HANDLE_BOX (handle_box)"); return ((0
)); } } while (0)
;
1071
1072 return handle_box->priv->child_detached;
1073}
1074
1075static void
1076ctk_handle_box_paint (CtkWidget *widget,
1077 cairo_t *cr)
1078{
1079 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
1080 CtkHandleBoxPrivate *priv = hb->priv;
1081 CtkBin *bin = CTK_BIN (widget)((((CtkBin*) (void *) ((widget)))));
1082 CtkStyleContext *context;
1083 CtkStateFlags state;
1084 CtkWidget *child;
1085 gint width, height;
1086 CdkRectangle rect;
1087 gint handle_position;
1088
1089 handle_position = effective_handle_position (hb);
1090
1091 width = cdk_window_get_width (priv->bin_window);
1092 height = cdk_window_get_height (priv->bin_window);
1093
1094 context = ctk_widget_get_style_context (widget);
1095 state = ctk_widget_get_state_flags (widget);
1096
1097 ctk_style_context_save (context);
1098 ctk_style_context_set_state (context, state);
1099
1100 ctk_render_background (context, cr, 0, 0, width, height);
1101 ctk_render_frame (context, cr, 0, 0, width, height);
1102
1103 switch (handle_position)
1104 {
1105 case CTK_POS_LEFT:
1106 rect.x = 0;
1107 rect.y = 0;
1108 rect.width = DRAG_HANDLE_SIZE10;
1109 rect.height = height;
1110 break;
1111 case CTK_POS_RIGHT:
1112 rect.x = width - DRAG_HANDLE_SIZE10;
1113 rect.y = 0;
1114 rect.width = DRAG_HANDLE_SIZE10;
1115 rect.height = height;
1116 break;
1117 case CTK_POS_TOP:
1118 rect.x = 0;
1119 rect.y = 0;
1120 rect.width = width;
1121 rect.height = DRAG_HANDLE_SIZE10;
1122 break;
1123 case CTK_POS_BOTTOM:
1124 rect.x = 0;
1125 rect.y = height - DRAG_HANDLE_SIZE10;
1126 rect.width = width;
1127 rect.height = DRAG_HANDLE_SIZE10;
1128 break;
1129 default:
1130 g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "deprecated/ctkhandlebox.c"
, 1130, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1131 break;
1132 }
1133
1134 ctk_render_handle (context, cr,
1135 rect.x, rect.y, rect.width, rect.height);
1136
1137 child = ctk_bin_get_child (bin);
1138 if (child != NULL((void*)0) && ctk_widget_get_visible (child))
1139 CTK_WIDGET_CLASS (ctk_handle_box_parent_class)((((CtkWidgetClass*) (void *) ((ctk_handle_box_parent_class))
)))
->draw (widget, cr);
1140
1141 ctk_style_context_restore (context);
1142}
1143
1144static gboolean
1145ctk_handle_box_draw (CtkWidget *widget,
1146 cairo_t *cr)
1147{
1148 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
1149 CtkHandleBoxPrivate *priv = hb->priv;
1150
1151 if (ctk_cairo_should_draw_window (cr, ctk_widget_get_window (widget)))
1152 {
1153 if (priv->child_detached)
1154 ctk_handle_box_draw_ghost (hb, cr);
1155 }
1156 else if (ctk_cairo_should_draw_window (cr, priv->bin_window))
1157 ctk_handle_box_paint (widget, cr);
1158
1159 return FALSE(0);
1160}
1161
1162static CtkWidget *
1163ctk_handle_box_get_invisible (void)
1164{
1165 static CtkWidget *handle_box_invisible = NULL((void*)0);
1166
1167 if (!handle_box_invisible)
1168 {
1169 handle_box_invisible = ctk_invisible_new ();
1170 ctk_widget_show (handle_box_invisible);
1171 }
1172
1173 return handle_box_invisible;
1174}
1175
1176static gboolean
1177ctk_handle_box_grab_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
1178 CdkEvent *event,
1179 CtkHandleBox *hb)
1180{
1181 CtkHandleBoxPrivate *priv = hb->priv;
1182
1183 switch (event->type)
1184 {
1185 case CDK_BUTTON_RELEASE:
1186 if (priv->in_drag) /* sanity check */
1187 {
1188 ctk_handle_box_end_drag (hb, event->button.time);
1189 return TRUE(!(0));
1190 }
1191 break;
1192
1193 case CDK_MOTION_NOTIFY:
1194 return ctk_handle_box_motion (CTK_WIDGET (hb)((((CtkWidget*) (void *) ((hb))))), (CdkEventMotion *)event);
1195 break;
This statement is never executed
1196
1197 default:
1198 break;
1199 }
1200
1201 return FALSE(0);
1202}
1203
1204static gboolean
1205ctk_handle_box_button_press (CtkWidget *widget,
1206 CdkEventButton *event)
1207{
1208 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
1209 CtkHandleBoxPrivate *priv = hb->priv;
1210 gboolean event_handled;
1211 gint handle_position;
1212
1213 handle_position = effective_handle_position (hb);
1214
1215 event_handled = FALSE(0);
1216 if ((event->button == CDK_BUTTON_PRIMARY(1)) &&
1217 (event->type == CDK_BUTTON_PRESS || event->type == CDK_2BUTTON_PRESS))
1218 {
1219 CtkWidget *child;
1220 gboolean in_handle;
1221
1222 if (event->window != priv->bin_window)
1223 return FALSE(0);
1224
1225 child = ctk_bin_get_child (CTK_BIN (hb)((((CtkBin*) (void *) ((hb))))));
1226
1227 if (child)
1228 {
1229 CtkAllocation child_allocation;
1230 guint border_width;
1231
1232 ctk_widget_get_allocation (child, &child_allocation);
1233 border_width = ctk_container_get_border_width (CTK_CONTAINER (hb)((((CtkContainer*) (void *) ((hb))))));
1234
1235 switch (handle_position)
1236 {
1237 case CTK_POS_LEFT:
1238 in_handle = event->x < DRAG_HANDLE_SIZE10;
1239 break;
1240 case CTK_POS_TOP:
1241 in_handle = event->y < DRAG_HANDLE_SIZE10;
1242 break;
1243 case CTK_POS_RIGHT:
1244 in_handle = event->x > 2 * border_width + child_allocation.width;
1245 break;
1246 case CTK_POS_BOTTOM:
1247 in_handle = event->y > 2 * border_width + child_allocation.height;
1248 break;
1249 default:
1250 in_handle = FALSE(0);
1251 break;
1252 }
1253 }
1254 else
1255 {
1256 in_handle = FALSE(0);
1257 event_handled = TRUE(!(0));
1258 }
1259
1260 if (in_handle)
1261 {
1262 if (event->type == CDK_BUTTON_PRESS) /* Start a drag */
1263 {
1264 CdkCursor *fleur;
1265
1266 CtkWidget *invisible = ctk_handle_box_get_invisible ();
1267 CdkWindow *window;
1268 gint root_x, root_y;
1269
1270 ctk_invisible_set_screen (CTK_INVISIBLE (invisible)((((CtkInvisible*) (void *) ((invisible))))),
1271 ctk_widget_get_screen (CTK_WIDGET (hb)((((CtkWidget*) (void *) ((hb)))))));
1272 cdk_window_get_origin (priv->bin_window, &root_x, &root_y);
1273
1274 priv->orig_x = event->x_root;
1275 priv->orig_y = event->y_root;
1276
1277 priv->float_allocation.x = root_x - event->x_root;
1278 priv->float_allocation.y = root_y - event->y_root;
1279 priv->float_allocation.width = cdk_window_get_width (priv->bin_window);
1280 priv->float_allocation.height = cdk_window_get_height (priv->bin_window);
1281
1282 window = ctk_widget_get_window (widget);
1283 if (cdk_window_is_viewable (window))
1284 {
1285 cdk_window_get_origin (window, &root_x, &root_y);
1286
1287 priv->attach_allocation.x = root_x;
1288 priv->attach_allocation.y = root_y;
1289 priv->attach_allocation.width = cdk_window_get_width (window);
1290 priv->attach_allocation.height = cdk_window_get_height (window);
1291 }
1292 else
1293 {
1294 priv->attach_allocation.x = -1;
1295 priv->attach_allocation.y = -1;
1296 priv->attach_allocation.width = 0;
1297 priv->attach_allocation.height = 0;
1298 }
1299 priv->in_drag = TRUE(!(0));
1300 priv->grab_device = event->device;
1301 fleur = cdk_cursor_new_for_display (ctk_widget_get_display (widget),
1302 CDK_FLEUR);
1303 if (cdk_device_grab (event->device,
1304 ctk_widget_get_window (invisible),
1305 CDK_OWNERSHIP_WINDOW,
1306 FALSE(0),
1307 (CDK_BUTTON1_MOTION_MASK |
1308 CDK_POINTER_MOTION_HINT_MASK |
1309 CDK_BUTTON_RELEASE_MASK),
1310 fleur,
1311 event->time) != CDK_GRAB_SUCCESS)
1312 {
1313 priv->in_drag = FALSE(0);
1314 priv->grab_device = NULL((void*)0);
1315 }
1316 else
1317 {
1318 ctk_device_grab_add (invisible, priv->grab_device, TRUE(!(0)));
1319 g_signal_connect (invisible, "event",g_signal_connect_data ((invisible), ("event"), (((GCallback) (
ctk_handle_box_grab_event))), (hb), ((void*)0), (GConnectFlags
) 0)
1320 G_CALLBACK (ctk_handle_box_grab_event), hb)g_signal_connect_data ((invisible), ("event"), (((GCallback) (
ctk_handle_box_grab_event))), (hb), ((void*)0), (GConnectFlags
) 0)
;
1321 }
1322
1323 g_object_unref (fleur);
1324 event_handled = TRUE(!(0));
1325 }
1326 else if (priv->child_detached) /* Double click */
1327 {
1328 ctk_handle_box_reattach (hb);
1329 }
1330 }
1331 }
1332
1333 return event_handled;
1334}
1335
1336static gboolean
1337ctk_handle_box_motion (CtkWidget *widget,
1338 CdkEventMotion *event)
1339{
1340 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
1341 CtkHandleBoxPrivate *priv = hb->priv;
1342 CtkWidget *child;
1343 gint new_x, new_y;
1344 gint snap_edge;
1345 gboolean is_snapped = FALSE(0);
1346 gint handle_position;
1347 CdkGeometry geometry;
1348 CdkScreen *screen, *pointer_screen;
1349
1350 if (!priv->in_drag)
1351 return FALSE(0);
1352 handle_position = effective_handle_position (hb);
1353
1354 /* Calculate the attachment point on the float, if the float
1355 * were detached
1356 */
1357 new_x = 0;
1358 new_y = 0;
1359 screen = ctk_widget_get_screen (widget);
1360 cdk_device_get_position (event->device,
1361 &pointer_screen,
1362 &new_x, &new_y);
1363 if (pointer_screen != screen)
1364 {
1365 new_x = priv->orig_x;
1366 new_y = priv->orig_y;
1367 }
1368
1369 new_x += priv->float_allocation.x;
1370 new_y += priv->float_allocation.y;
1371
1372 snap_edge = priv->snap_edge;
1373 if (snap_edge == -1)
1374 snap_edge = (handle_position == CTK_POS_LEFT ||
1375 handle_position == CTK_POS_RIGHT) ?
1376 CTK_POS_TOP : CTK_POS_LEFT;
1377
1378 if (ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL)
1379 switch (snap_edge)
1380 {
1381 case CTK_POS_LEFT:
1382 snap_edge = CTK_POS_RIGHT;
1383 break;
1384 case CTK_POS_RIGHT:
1385 snap_edge = CTK_POS_LEFT;
1386 break;
1387 default:
1388 break;
1389 }
1390
1391 /* First, check if the snapped edge is aligned
1392 */
1393 switch (snap_edge)
1394 {
1395 case CTK_POS_TOP:
1396 is_snapped = abs (priv->attach_allocation.y - new_y) < TOLERANCE5;
1397 break;
1398 case CTK_POS_BOTTOM:
1399 is_snapped = abs (priv->attach_allocation.y + (gint)priv->attach_allocation.height -
1400 new_y - (gint)priv->float_allocation.height) < TOLERANCE5;
1401 break;
1402 case CTK_POS_LEFT:
1403 is_snapped = abs (priv->attach_allocation.x - new_x) < TOLERANCE5;
1404 break;
1405 case CTK_POS_RIGHT:
1406 is_snapped = abs (priv->attach_allocation.x + (gint)priv->attach_allocation.width -
1407 new_x - (gint)priv->float_allocation.width) < TOLERANCE5;
1408 break;
1409 }
1410
1411 /* Next, check if coordinates in the other direction are sufficiently
1412 * aligned
1413 */
1414 if (is_snapped)
1415 {
1416 gint float_pos1 = 0; /* Initialize to suppress warnings */
1417 gint float_pos2 = 0;
1418 gint attach_pos1 = 0;
1419 gint attach_pos2 = 0;
1420
1421 switch (snap_edge)
1422 {
1423 case CTK_POS_TOP:
1424 case CTK_POS_BOTTOM:
1425 attach_pos1 = priv->attach_allocation.x;
1426 attach_pos2 = priv->attach_allocation.x + priv->attach_allocation.width;
1427 float_pos1 = new_x;
1428 float_pos2 = new_x + priv->float_allocation.width;
1429 break;
1430 case CTK_POS_LEFT:
1431 case CTK_POS_RIGHT:
1432 attach_pos1 = priv->attach_allocation.y;
1433 attach_pos2 = priv->attach_allocation.y + priv->attach_allocation.height;
1434 float_pos1 = new_y;
1435 float_pos2 = new_y + priv->float_allocation.height;
1436 break;
1437 }
1438
1439 is_snapped = ((attach_pos1 - TOLERANCE5 < float_pos1) &&
1440 (attach_pos2 + TOLERANCE5 > float_pos2)) ||
1441 ((float_pos1 - TOLERANCE5 < attach_pos1) &&
1442 (float_pos2 + TOLERANCE5 > attach_pos2));
1443 }
1444
1445 child = ctk_bin_get_child (CTK_BIN (hb)((((CtkBin*) (void *) ((hb))))));
1446
1447 if (is_snapped)
1448 {
1449 if (priv->child_detached)
1450 {
1451 priv->child_detached = FALSE(0);
1452 cdk_window_hide (priv->float_window);
1453 cdk_window_reparent (priv->bin_window, ctk_widget_get_window (widget), 0, 0);
1454 priv->float_window_mapped = FALSE(0);
1455 g_signal_emit (hb,
1456 handle_box_signals[SIGNAL_CHILD_ATTACHED],
1457 0,
1458 child);
1459
1460 ctk_widget_queue_resize (widget);
1461 }
1462 }
1463 else
1464 {
1465 gint width, height;
1466
1467 width = cdk_window_get_width (priv->float_window);
1468 height = cdk_window_get_height (priv->float_window);
1469
1470 switch (handle_position)
1471 {
1472 case CTK_POS_LEFT:
1473 new_y += ((gint)priv->float_allocation.height - height) / 2;
1474 break;
1475 case CTK_POS_RIGHT:
1476 new_x += (gint)priv->float_allocation.width - width;
1477 new_y += ((gint)priv->float_allocation.height - height) / 2;
1478 break;
1479 case CTK_POS_TOP:
1480 new_x += ((gint)priv->float_allocation.width - width) / 2;
1481 break;
1482 case CTK_POS_BOTTOM:
1483 new_x += ((gint)priv->float_allocation.width - width) / 2;
1484 new_y += (gint)priv->float_allocation.height - height;
1485 break;
1486 }
1487
1488 if (priv->child_detached)
1489 {
1490 cdk_window_move (priv->float_window, new_x, new_y);
1491 cdk_window_raise (priv->float_window);
1492 }
1493 else
1494 {
1495 guint border_width;
1496 CtkRequisition child_requisition;
1497
1498 priv->child_detached = TRUE(!(0));
1499
1500 if (child)
1501 {
1502 ctk_widget_get_preferred_size (child, &child_requisition, NULL((void*)0));
1503 }
1504 else
1505 {
1506 child_requisition.width = 0;
1507 child_requisition.height = 0;
1508 }
1509
1510 border_width = ctk_container_get_border_width (CTK_CONTAINER (hb)((((CtkContainer*) (void *) ((hb))))));
1511 width = child_requisition.width + 2 * border_width;
1512 height = child_requisition.height + 2 * border_width;
1513
1514 if (handle_position == CTK_POS_LEFT || handle_position == CTK_POS_RIGHT)
1515 width += DRAG_HANDLE_SIZE10;
1516 else
1517 height += DRAG_HANDLE_SIZE10;
1518
1519 cdk_window_move_resize (priv->float_window, new_x, new_y, width, height);
1520 cdk_window_reparent (priv->bin_window, priv->float_window, 0, 0);
1521 cdk_window_set_geometry_hints (priv->float_window, &geometry, CDK_HINT_POS);
1522 cdk_window_show (priv->float_window);
1523 priv->float_window_mapped = TRUE(!(0));
1524#if 0
1525 /* this extra move is necessary if we use decorations, or our
1526 * window manager insists on decorations.
1527 */
1528 cdk_display_sync (ctk_widget_get_display (widget));
1529 cdk_window_move (priv->float_window, new_x, new_y);
1530 cdk_display_sync (ctk_widget_get_display (widget));
1531#endif /* 0 */
1532 g_signal_emit (hb,
1533 handle_box_signals[SIGNAL_CHILD_DETACHED],
1534 0,
1535 child);
1536
1537 ctk_widget_queue_resize (widget);
1538 }
1539 }
1540
1541 return TRUE(!(0));
1542}
1543
1544static void
1545ctk_handle_box_add (CtkContainer *container,
1546 CtkWidget *widget)
1547{
1548 CtkHandleBoxPrivate *priv = CTK_HANDLE_BOX (container)((((CtkHandleBox*) (void *) ((container)))))->priv;
1549
1550 ctk_widget_set_parent_window (widget, priv->bin_window);
1551 CTK_CONTAINER_CLASS (ctk_handle_box_parent_class)((((CtkContainerClass*) (void *) ((ctk_handle_box_parent_class
)))))
->add (container, widget);
1552}
1553
1554static void
1555ctk_handle_box_remove (CtkContainer *container,
1556 CtkWidget *widget)
1557{
1558 CTK_CONTAINER_CLASS (ctk_handle_box_parent_class)((((CtkContainerClass*) (void *) ((ctk_handle_box_parent_class
)))))
->remove (container, widget);
1559
1560 ctk_handle_box_reattach (CTK_HANDLE_BOX (container)((((CtkHandleBox*) (void *) ((container))))));
1561}
1562
1563static gint
1564ctk_handle_box_delete_event (CtkWidget *widget,
1565 CdkEventAny *event)
1566{
1567 CtkHandleBox *hb = CTK_HANDLE_BOX (widget)((((CtkHandleBox*) (void *) ((widget)))));
1568 CtkHandleBoxPrivate *priv = hb->priv;
1569
1570 if (event->window == priv->float_window)
1571 {
1572 ctk_handle_box_reattach (hb);
1573
1574 return TRUE(!(0));
1575 }
1576
1577 return FALSE(0);
1578}
1579
1580static void
1581ctk_handle_box_reattach (CtkHandleBox *hb)
1582{
1583 CtkHandleBoxPrivate *priv = hb->priv;
1584 CtkWidget *widget = CTK_WIDGET (hb)((((CtkWidget*) (void *) ((hb)))));
1585
1586 if (priv->child_detached)
1587 {
1588 priv->child_detached = FALSE(0);
1589 if (ctk_widget_get_realized (widget))
1590 {
1591 CtkWidget *child;
1592
1593 cdk_window_hide (priv->float_window);
1594 cdk_window_reparent (priv->bin_window, ctk_widget_get_window (widget),
1595 0, 0);
1596
1597 child = ctk_bin_get_child (CTK_BIN (hb)((((CtkBin*) (void *) ((hb))))));
1598 if (child)
1599 g_signal_emit (hb,
1600 handle_box_signals[SIGNAL_CHILD_ATTACHED],
1601 0,
1602 child);
1603
1604 }
1605 priv->float_window_mapped = FALSE(0);
1606 }
1607 if (priv->in_drag)
1608 ctk_handle_box_end_drag (hb, CDK_CURRENT_TIME0L);
1609
1610 ctk_widget_queue_resize (CTK_WIDGET (hb)((((CtkWidget*) (void *) ((hb))))));
1611}
1612
1613static void
1614ctk_handle_box_end_drag (CtkHandleBox *hb,
1615 guint32 time)
1616{
1617 CtkHandleBoxPrivate *priv = hb->priv;
1618 CtkWidget *invisible = ctk_handle_box_get_invisible ();
1619
1620 priv->in_drag = FALSE(0);
1621
1622 ctk_device_grab_remove (invisible, priv->grab_device);
1623 cdk_device_ungrab (priv->grab_device, time);
1624 g_signal_handlers_disconnect_by_func (invisible,g_signal_handlers_disconnect_matched ((invisible), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (ctk_handle_box_grab_event))), (hb))
1625 G_CALLBACK (ctk_handle_box_grab_event),g_signal_handlers_disconnect_matched ((invisible), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (ctk_handle_box_grab_event))), (hb))
1626 hb)g_signal_handlers_disconnect_matched ((invisible), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (ctk_handle_box_grab_event))), (hb))
;
1627
1628 priv->grab_device = NULL((void*)0);
1629}