Bug Summary

File:ctk/ctkwidget.c
Warning:line 16994, column 4
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 ctkwidget.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.25.7" -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/cairo -I /usr/local/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/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-05-20-085847-45482-1 -x c ctkwidget.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the CTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * CTK+ at ftp://ftp.ctk.org/pub/ctk/.
23 */
24
25#include "config.h"
26
27#include <stdarg.h>
28#include <string.h>
29#include <locale.h>
30#include <math.h>
31
32#include <gobject/gvaluecollector.h>
33#include <gobject/gobjectnotifyqueue.c>
34#include <cairo-gobject.h>
35
36#include "ctkcontainer.h"
37#include "ctkaccelmapprivate.h"
38#include "ctkaccelgroupprivate.h"
39#include "ctkclipboard.h"
40#include "ctkcssstylepropertyprivate.h"
41#include "ctkcssnumbervalueprivate.h"
42#include "ctkcssshadowsvalueprivate.h"
43#include "ctkintl.h"
44#include "ctkmarshalers.h"
45#include "ctkselectionprivate.h"
46#include "ctksettingsprivate.h"
47#include "ctksizegroup-private.h"
48#include "ctkwidget.h"
49#include "ctkwidgetprivate.h"
50#include "ctkwindowprivate.h"
51#include "ctkcontainerprivate.h"
52#include "ctkbindings.h"
53#include "ctkprivate.h"
54#include "ctkaccessible.h"
55#include "ctktooltipprivate.h"
56#include "ctkinvisible.h"
57#include "ctkbuildable.h"
58#include "ctkbuilderprivate.h"
59#include "ctksizerequest.h"
60#include "ctkstylecontextprivate.h"
61#include "ctkcssprovider.h"
62#include "ctkcsswidgetnodeprivate.h"
63#include "ctkmodifierstyle.h"
64#include "ctkversion.h"
65#include "ctkdebug.h"
66#include "ctkplug.h"
67#include "ctktypebuiltins.h"
68#include "a11y/ctkwidgetaccessible.h"
69#include "ctkapplicationprivate.h"
70#include "ctkgestureprivate.h"
71#include "ctkwidgetpathprivate.h"
72
73/* for the use of round() */
74#include "fallback-c89.c"
75
76/**
77 * SECTION:ctkwidget
78 * @Short_description: Base class for all widgets
79 * @Title: CtkWidget
80 *
81 * CtkWidget is the base class all widgets in CTK+ derive from. It manages the
82 * widget lifecycle, states and style.
83 *
84 * # Height-for-width Geometry Management # {#geometry-management}
85 *
86 * CTK+ uses a height-for-width (and width-for-height) geometry management
87 * system. Height-for-width means that a widget can change how much
88 * vertical space it needs, depending on the amount of horizontal space
89 * that it is given (and similar for width-for-height). The most common
90 * example is a label that reflows to fill up the available width, wraps
91 * to fewer lines, and therefore needs less height.
92 *
93 * Height-for-width geometry management is implemented in CTK+ by way
94 * of five virtual methods:
95 *
96 * - #CtkWidgetClass.get_request_mode()
97 * - #CtkWidgetClass.get_preferred_width()
98 * - #CtkWidgetClass.get_preferred_height()
99 * - #CtkWidgetClass.get_preferred_height_for_width()
100 * - #CtkWidgetClass.get_preferred_width_for_height()
101 * - #CtkWidgetClass.get_preferred_height_and_baseline_for_width()
102 *
103 * There are some important things to keep in mind when implementing
104 * height-for-width and when using it in container implementations.
105 *
106 * The geometry management system will query a widget hierarchy in
107 * only one orientation at a time. When widgets are initially queried
108 * for their minimum sizes it is generally done in two initial passes
109 * in the #CtkSizeRequestMode chosen by the toplevel.
110 *
111 * For example, when queried in the normal
112 * %CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode:
113 * First, the default minimum and natural width for each widget
114 * in the interface will be computed using ctk_widget_get_preferred_width().
115 * Because the preferred widths for each container depend on the preferred
116 * widths of their children, this information propagates up the hierarchy,
117 * and finally a minimum and natural width is determined for the entire
118 * toplevel. Next, the toplevel will use the minimum width to query for the
119 * minimum height contextual to that width using
120 * ctk_widget_get_preferred_height_for_width(), which will also be a highly
121 * recursive operation. The minimum height for the minimum width is normally
122 * used to set the minimum size constraint on the toplevel
123 * (unless ctk_window_set_geometry_hints() is explicitly used instead).
124 *
125 * After the toplevel window has initially requested its size in both
126 * dimensions it can go on to allocate itself a reasonable size (or a size
127 * previously specified with ctk_window_set_default_size()). During the
128 * recursive allocation process it’s important to note that request cycles
129 * will be recursively executed while container widgets allocate their children.
130 * Each container widget, once allocated a size, will go on to first share the
131 * space in one orientation among its children and then request each child's
132 * height for its target allocated width or its width for allocated height,
133 * depending. In this way a #CtkWidget will typically be requested its size
134 * a number of times before actually being allocated a size. The size a
135 * widget is finally allocated can of course differ from the size it has
136 * requested. For this reason, #CtkWidget caches a small number of results
137 * to avoid re-querying for the same sizes in one allocation cycle.
138 *
139 * See
140 * [CtkContainer’s geometry management section][container-geometry-management]
141 * to learn more about how height-for-width allocations are performed
142 * by container widgets.
143 *
144 * If a widget does move content around to intelligently use up the
145 * allocated size then it must support the request in both
146 * #CtkSizeRequestModes even if the widget in question only
147 * trades sizes in a single orientation.
148 *
149 * For instance, a #CtkLabel that does height-for-width word wrapping
150 * will not expect to have #CtkWidgetClass.get_preferred_height() called
151 * because that call is specific to a width-for-height request. In this
152 * case the label must return the height required for its own minimum
153 * possible width. By following this rule any widget that handles
154 * height-for-width or width-for-height requests will always be allocated
155 * at least enough space to fit its own content.
156 *
157 * Here are some examples of how a %CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget
158 * generally deals with width-for-height requests, for #CtkWidgetClass.get_preferred_height()
159 * it will do:
160 *
161 * |[<!-- language="C" -->
162 * static void
163 * foo_widget_get_preferred_height (CtkWidget *widget,
164 * gint *min_height,
165 * gint *nat_height)
166 * {
167 * if (i_am_in_height_for_width_mode)
168 * {
169 * gint min_width, nat_width;
170 *
171 * CTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
172 * &min_width,
173 * &nat_width);
174 * CTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width
175 * (widget,
176 * min_width,
177 * min_height,
178 * nat_height);
179 * }
180 * else
181 * {
182 * ... some widgets do both. For instance, if a CtkLabel is
183 * rotated to 90 degrees it will return the minimum and
184 * natural height for the rotated label here.
185 * }
186 * }
187 * ]|
188 *
189 * And in #CtkWidgetClass.get_preferred_width_for_height() it will simply return
190 * the minimum and natural width:
191 * |[<!-- language="C" -->
192 * static void
193 * foo_widget_get_preferred_width_for_height (CtkWidget *widget,
194 * gint for_height,
195 * gint *min_width,
196 * gint *nat_width)
197 * {
198 * if (i_am_in_height_for_width_mode)
199 * {
200 * CTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
201 * min_width,
202 * nat_width);
203 * }
204 * else
205 * {
206 * ... again if a widget is sometimes operating in
207 * width-for-height mode (like a rotated CtkLabel) it can go
208 * ahead and do its real width for height calculation here.
209 * }
210 * }
211 * ]|
212 *
213 * Often a widget needs to get its own request during size request or
214 * allocation. For example, when computing height it may need to also
215 * compute width. Or when deciding how to use an allocation, the widget
216 * may need to know its natural size. In these cases, the widget should
217 * be careful to call its virtual methods directly, like this:
218 *
219 * |[<!-- language="C" -->
220 * CTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget,
221 * &min,
222 * &natural);
223 * ]|
224 *
225 * It will not work to use the wrapper functions, such as
226 * ctk_widget_get_preferred_width() inside your own size request
227 * implementation. These return a request adjusted by #CtkSizeGroup
228 * and by the #CtkWidgetClass.adjust_size_request() virtual method. If a
229 * widget used the wrappers inside its virtual method implementations,
230 * then the adjustments (such as widget margins) would be applied
231 * twice. CTK+ therefore does not allow this and will warn if you try
232 * to do it.
233 *
234 * Of course if you are getting the size request for
235 * another widget, such as a child of a
236 * container, you must use the wrapper APIs.
237 * Otherwise, you would not properly consider widget margins,
238 * #CtkSizeGroup, and so forth.
239 *
240 * Since 3.10 CTK+ also supports baseline vertical alignment of widgets. This
241 * means that widgets are positioned such that the typographical baseline of
242 * widgets in the same row are aligned. This happens if a widget supports baselines,
243 * has a vertical alignment of %CTK_ALIGN_BASELINE, and is inside a container
244 * that supports baselines and has a natural “row” that it aligns to the baseline,
245 * or a baseline assigned to it by the grandparent.
246 *
247 * Baseline alignment support for a widget is done by the #CtkWidgetClass.get_preferred_height_and_baseline_for_width()
248 * virtual function. It allows you to report a baseline in combination with the
249 * minimum and natural height. If there is no baseline you can return -1 to indicate
250 * this. The default implementation of this virtual function calls into the
251 * #CtkWidgetClass.get_preferred_height() and #CtkWidgetClass.get_preferred_height_for_width(),
252 * so if baselines are not supported it doesn’t need to be implemented.
253 *
254 * If a widget ends up baseline aligned it will be allocated all the space in the parent
255 * as if it was %CTK_ALIGN_FILL, but the selected baseline can be found via ctk_widget_get_allocated_baseline().
256 * If this has a value other than -1 you need to align the widget such that the baseline
257 * appears at the position.
258 *
259 * # Style Properties
260 *
261 * #CtkWidget introduces “style
262 * properties” - these are basically object properties that are stored
263 * not on the object, but in the style object associated to the widget. Style
264 * properties are set in [resource files][ctk3-Resource-Files].
265 * This mechanism is used for configuring such things as the location of the
266 * scrollbar arrows through the theme, giving theme authors more control over the
267 * look of applications without the need to write a theme engine in C.
268 *
269 * Use ctk_widget_class_install_style_property() to install style properties for
270 * a widget class, ctk_widget_class_find_style_property() or
271 * ctk_widget_class_list_style_properties() to get information about existing
272 * style properties and ctk_widget_style_get_property(), ctk_widget_style_get() or
273 * ctk_widget_style_get_valist() to obtain the value of a style property.
274 *
275 * # CtkWidget as CtkBuildable
276 *
277 * The CtkWidget implementation of the CtkBuildable interface supports a
278 * custom <accelerator> element, which has attributes named ”key”, ”modifiers”
279 * and ”signal” and allows to specify accelerators.
280 *
281 * An example of a UI definition fragment specifying an accelerator:
282 * |[
283 * <object class="CtkButton">
284 * <accelerator key="q" modifiers="CDK_CONTROL_MASK" signal="clicked"/>
285 * </object>
286 * ]|
287 *
288 * In addition to accelerators, CtkWidget also support a custom <accessible>
289 * element, which supports actions and relations. Properties on the accessible
290 * implementation of an object can be set by accessing the internal child
291 * “accessible” of a #CtkWidget.
292 *
293 * An example of a UI definition fragment specifying an accessible:
294 * |[
295 * <object class="CtkLabel" id="label1"/>
296 * <property name="label">I am a Label for a Button</property>
297 * </object>
298 * <object class="CtkButton" id="button1">
299 * <accessibility>
300 * <action action_name="click" translatable="yes">Click the button.</action>
301 * <relation target="label1" type="labelled-by"/>
302 * </accessibility>
303 * <child internal-child="accessible">
304 * <object class="AtkObject" id="a11y-button1">
305 * <property name="accessible-name">Clickable Button</property>
306 * </object>
307 * </child>
308 * </object>
309 * ]|
310 *
311 * Finally, CtkWidget allows style information such as style classes to
312 * be associated with widgets, using the custom <style> element:
313 * |[
314 * <object class="CtkButton" id="button1">
315 * <style>
316 * <class name="my-special-button-class"/>
317 * <class name="dark-button"/>
318 * </style>
319 * </object>
320 * ]|
321 *
322 * # Building composite widgets from template XML ## {#composite-templates}
323 *
324 * CtkWidget exposes some facilities to automate the procedure
325 * of creating composite widgets using #CtkBuilder interface description
326 * language.
327 *
328 * To create composite widgets with #CtkBuilder XML, one must associate
329 * the interface description with the widget class at class initialization
330 * time using ctk_widget_class_set_template().
331 *
332 * The interface description semantics expected in composite template descriptions
333 * is slightly different from regular #CtkBuilder XML.
334 *
335 * Unlike regular interface descriptions, ctk_widget_class_set_template() will
336 * expect a <template> tag as a direct child of the toplevel <interface>
337 * tag. The <template> tag must specify the “class” attribute which must be
338 * the type name of the widget. Optionally, the “parent” attribute may be
339 * specified to specify the direct parent type of the widget type, this is
340 * ignored by the CtkBuilder but required for Glade to introspect what kind
341 * of properties and internal children exist for a given type when the actual
342 * type does not exist.
343 *
344 * The XML which is contained inside the <template> tag behaves as if it were
345 * added to the <object> tag defining @widget itself. You may set properties
346 * on @widget by inserting <property> tags into the <template> tag, and also
347 * add <child> tags to add children and extend @widget in the normal way you
348 * would with <object> tags.
349 *
350 * Additionally, <object> tags can also be added before and after the initial
351 * <template> tag in the normal way, allowing one to define auxiliary objects
352 * which might be referenced by other widgets declared as children of the
353 * <template> tag.
354 *
355 * An example of a CtkBuilder Template Definition:
356 * |[
357 * <interface>
358 * <template class="FooWidget" parent="CtkBox">
359 * <property name="orientation">CTK_ORIENTATION_HORIZONTAL</property>
360 * <property name="spacing">4</property>
361 * <child>
362 * <object class="CtkButton" id="hello_button">
363 * <property name="label">Hello World</property>
364 * <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/>
365 * </object>
366 * </child>
367 * <child>
368 * <object class="CtkButton" id="goodbye_button">
369 * <property name="label">Goodbye World</property>
370 * </object>
371 * </child>
372 * </template>
373 * </interface>
374 * ]|
375 *
376 * Typically, you'll place the template fragment into a file that is
377 * bundled with your project, using #GResource. In order to load the
378 * template, you need to call ctk_widget_class_set_template_from_resource()
379 * from the class initialization of your #CtkWidget type:
380 *
381 * |[<!-- language="C" -->
382 * static void
383 * foo_widget_class_init (FooWidgetClass *klass)
384 * {
385 * // ...
386 *
387 * ctk_widget_class_set_template_from_resource (CTK_WIDGET_CLASS (klass),
388 * "/com/example/ui/foowidget.ui");
389 * }
390 * ]|
391 *
392 * You will also need to call ctk_widget_init_template() from the instance
393 * initialization function:
394 *
395 * |[<!-- language="C" -->
396 * static void
397 * foo_widget_init (FooWidget *self)
398 * {
399 * // ...
400 * ctk_widget_init_template (CTK_WIDGET (self));
401 * }
402 * ]|
403 *
404 * You can access widgets defined in the template using the
405 * ctk_widget_get_template_child() function, but you will typically declare
406 * a pointer in the instance private data structure of your type using the same
407 * name as the widget in the template definition, and call
408 * ctk_widget_class_bind_template_child_private() with that name, e.g.
409 *
410 * |[<!-- language="C" -->
411 * typedef struct {
412 * CtkWidget *hello_button;
413 * CtkWidget *goodbye_button;
414 * } FooWidgetPrivate;
415 *
416 * G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, CTK_TYPE_BOX)
417 *
418 * static void
419 * foo_widget_class_init (FooWidgetClass *klass)
420 * {
421 * // ...
422 * ctk_widget_class_set_template_from_resource (CTK_WIDGET_CLASS (klass),
423 * "/com/example/ui/foowidget.ui");
424 * ctk_widget_class_bind_template_child_private (CTK_WIDGET_CLASS (klass),
425 * FooWidget, hello_button);
426 * ctk_widget_class_bind_template_child_private (CTK_WIDGET_CLASS (klass),
427 * FooWidget, goodbye_button);
428 * }
429 *
430 * static void
431 * foo_widget_init (FooWidget *widget)
432 * {
433 *
434 * }
435 * ]|
436 *
437 * You can also use ctk_widget_class_bind_template_callback() to connect a signal
438 * callback defined in the template with a function visible in the scope of the
439 * class, e.g.
440 *
441 * |[<!-- language="C" -->
442 * // the signal handler has the instance and user data swapped
443 * // because of the swapped="yes" attribute in the template XML
444 * static void
445 * hello_button_clicked (FooWidget *self,
446 * CtkButton *button)
447 * {
448 * g_print ("Hello, world!\n");
449 * }
450 *
451 * static void
452 * foo_widget_class_init (FooWidgetClass *klass)
453 * {
454 * // ...
455 * ctk_widget_class_set_template_from_resource (CTK_WIDGET_CLASS (klass),
456 * "/com/example/ui/foowidget.ui");
457 * ctk_widget_class_bind_template_callback (CTK_WIDGET_CLASS (klass), hello_button_clicked);
458 * }
459 * ]|
460 */
461
462#define CTK_STATE_FLAGS_DO_PROPAGATE(CTK_STATE_FLAG_INSENSITIVE|CTK_STATE_FLAG_BACKDROP) (CTK_STATE_FLAG_INSENSITIVE|CTK_STATE_FLAG_BACKDROP)
463
464#define WIDGET_CLASS(w)((((CtkWidgetClass*) (((GTypeInstance*) ((w)))->g_class)))
)
CTK_WIDGET_GET_CLASS (w)((((CtkWidgetClass*) (((GTypeInstance*) ((w)))->g_class)))
)
465
466typedef struct {
467 gchar *name; /* Name of the template automatic child */
468 gboolean internal_child; /* Whether the automatic widget should be exported as an <internal-child> */
469 gssize offset; /* Instance private data offset where to set the automatic child (or 0) */
470} AutomaticChildClass;
471
472typedef struct {
473 gchar *callback_name;
474 GCallback callback_symbol;
475} CallbackSymbol;
476
477typedef struct {
478 GBytes *data;
479 GSList *children;
480 GSList *callbacks;
481 CtkBuilderConnectFunc connect_func;
482 gpointer connect_data;
483 GDestroyNotify destroy_notify;
484} CtkWidgetTemplate;
485
486typedef struct {
487 CtkEventController *controller;
488 guint grab_notify_id;
489 guint sequence_state_changed_id;
490} EventControllerData;
491
492struct _CtkWidgetClassPrivate
493{
494 CtkWidgetTemplate *template;
495 GType accessible_type;
496 AtkRole accessible_role;
497 const char *css_name;
498};
499
500enum {
501 DESTROY,
502 SHOW,
503 HIDE,
504 MAP,
505 UNMAP,
506 REALIZE,
507 UNREALIZE,
508 SIZE_ALLOCATE,
509 STATE_FLAGS_CHANGED,
510 STATE_CHANGED,
511 PARENT_SET,
512 HIERARCHY_CHANGED,
513 STYLE_SET,
514 DIRECTION_CHANGED,
515 GRAB_NOTIFY,
516 CHILD_NOTIFY,
517 DRAW,
518 MNEMONIC_ACTIVATE,
519 GRAB_FOCUS,
520 FOCUS,
521 MOVE_FOCUS,
522 KEYNAV_FAILED,
523 EVENT,
524 EVENT_AFTER,
525 BUTTON_PRESS_EVENT,
526 BUTTON_RELEASE_EVENT,
527 SCROLL_EVENT,
528 MOTION_NOTIFY_EVENT,
529 DELETE_EVENT,
530 DESTROY_EVENT,
531 KEY_PRESS_EVENT,
532 KEY_RELEASE_EVENT,
533 ENTER_NOTIFY_EVENT,
534 LEAVE_NOTIFY_EVENT,
535 CONFIGURE_EVENT,
536 FOCUS_IN_EVENT,
537 FOCUS_OUT_EVENT,
538 MAP_EVENT,
539 UNMAP_EVENT,
540 PROPERTY_NOTIFY_EVENT,
541 SELECTION_CLEAR_EVENT,
542 SELECTION_REQUEST_EVENT,
543 SELECTION_NOTIFY_EVENT,
544 SELECTION_GET,
545 SELECTION_RECEIVED,
546 PROXIMITY_IN_EVENT,
547 PROXIMITY_OUT_EVENT,
548 VISIBILITY_NOTIFY_EVENT,
549 WINDOW_STATE_EVENT,
550 DAMAGE_EVENT,
551 GRAB_BROKEN_EVENT,
552 DRAG_BEGIN,
553 DRAG_END,
554 DRAG_DATA_DELETE,
555 DRAG_LEAVE,
556 DRAG_MOTION,
557 DRAG_DROP,
558 DRAG_DATA_GET,
559 DRAG_DATA_RECEIVED,
560 POPUP_MENU,
561 SHOW_HELP,
562 ACCEL_CLOSURES_CHANGED,
563 SCREEN_CHANGED,
564 CAN_ACTIVATE_ACCEL,
565 COMPOSITED_CHANGED,
566 QUERY_TOOLTIP,
567 DRAG_FAILED,
568 STYLE_UPDATED,
569 TOUCH_EVENT,
570 LAST_SIGNAL
571};
572
573enum {
574 PROP_0,
575 PROP_NAME,
576 PROP_PARENT,
577 PROP_WIDTH_REQUEST,
578 PROP_HEIGHT_REQUEST,
579 PROP_VISIBLE,
580 PROP_SENSITIVE,
581 PROP_APP_PAINTABLE,
582 PROP_CAN_FOCUS,
583 PROP_HAS_FOCUS,
584 PROP_IS_FOCUS,
585 PROP_FOCUS_ON_CLICK,
586 PROP_CAN_DEFAULT,
587 PROP_HAS_DEFAULT,
588 PROP_RECEIVES_DEFAULT,
589 PROP_COMPOSITE_CHILD,
590 PROP_STYLE,
591 PROP_EVENTS,
592 PROP_NO_SHOW_ALL,
593 PROP_HAS_TOOLTIP,
594 PROP_TOOLTIP_MARKUP,
595 PROP_TOOLTIP_TEXT,
596 PROP_WINDOW,
597 PROP_OPACITY,
598 PROP_DOUBLE_BUFFERED,
599 PROP_HALIGN,
600 PROP_VALIGN,
601 PROP_MARGIN_LEFT,
602 PROP_MARGIN_RIGHT,
603 PROP_MARGIN_START,
604 PROP_MARGIN_END,
605 PROP_MARGIN_TOP,
606 PROP_MARGIN_BOTTOM,
607 PROP_MARGIN,
608 PROP_HEXPAND,
609 PROP_VEXPAND,
610 PROP_HEXPAND_SET,
611 PROP_VEXPAND_SET,
612 PROP_EXPAND,
613 PROP_SCALE_FACTOR,
614 NUM_PROPERTIES
615};
616
617static GParamSpec *widget_props[NUM_PROPERTIES] = { NULL((void*)0), };
618
619typedef struct _CtkStateData CtkStateData;
620
621struct _CtkStateData
622{
623 guint flags_to_set;
624 guint flags_to_unset;
625
626 gint old_scale_factor;
627};
628
629/* --- prototypes --- */
630static void ctk_widget_base_class_init (gpointer g_class);
631static void ctk_widget_class_init (CtkWidgetClass *klass);
632static void ctk_widget_base_class_finalize (CtkWidgetClass *klass);
633static void ctk_widget_init (GTypeInstance *instance,
634 gpointer g_class);
635static void ctk_widget_set_property (GObject *object,
636 guint prop_id,
637 const GValue *value,
638 GParamSpec *pspec);
639static void ctk_widget_get_property (GObject *object,
640 guint prop_id,
641 GValue *value,
642 GParamSpec *pspec);
643static void ctk_widget_constructed (GObject *object);
644static void ctk_widget_dispose (GObject *object);
645static void ctk_widget_real_destroy (CtkWidget *object);
646static void ctk_widget_finalize (GObject *object);
647static void ctk_widget_real_show (CtkWidget *widget);
648static void ctk_widget_real_hide (CtkWidget *widget);
649static void ctk_widget_real_map (CtkWidget *widget);
650static void ctk_widget_real_unmap (CtkWidget *widget);
651static void ctk_widget_real_realize (CtkWidget *widget);
652static void ctk_widget_real_unrealize (CtkWidget *widget);
653static void ctk_widget_real_size_allocate (CtkWidget *widget,
654 CtkAllocation *allocation);
655static void ctk_widget_real_style_set (CtkWidget *widget,
656 CtkStyle *previous_style);
657static void ctk_widget_real_direction_changed(CtkWidget *widget,
658 CtkTextDirection previous_direction);
659
660static void ctk_widget_real_grab_focus (CtkWidget *focus_widget);
661static gboolean ctk_widget_real_query_tooltip (CtkWidget *widget,
662 gint x,
663 gint y,
664 gboolean keyboard_tip,
665 CtkTooltip *tooltip);
666static void ctk_widget_real_style_updated (CtkWidget *widget);
667static gboolean ctk_widget_real_show_help (CtkWidget *widget,
668 CtkWidgetHelpType help_type);
669static gboolean _ctk_widget_run_controllers (CtkWidget *widget,
670 const CdkEvent *event,
671 CtkPropagationPhase phase);
672
673static void ctk_widget_dispatch_child_properties_changed (CtkWidget *object,
674 guint n_pspecs,
675 GParamSpec **pspecs);
676static gboolean ctk_widget_real_scroll_event (CtkWidget *widget,
677 CdkEventScroll *event);
678static gboolean ctk_widget_real_button_event (CtkWidget *widget,
679 CdkEventButton *event);
680static gboolean ctk_widget_real_motion_event (CtkWidget *widget,
681 CdkEventMotion *event);
682static gboolean ctk_widget_real_key_press_event (CtkWidget *widget,
683 CdkEventKey *event);
684static gboolean ctk_widget_real_key_release_event (CtkWidget *widget,
685 CdkEventKey *event);
686static gboolean ctk_widget_real_focus_in_event (CtkWidget *widget,
687 CdkEventFocus *event);
688static gboolean ctk_widget_real_focus_out_event (CtkWidget *widget,
689 CdkEventFocus *event);
690static gboolean ctk_widget_real_touch_event (CtkWidget *widget,
691 CdkEventTouch *event);
692static gboolean ctk_widget_real_grab_broken_event (CtkWidget *widget,
693 CdkEventGrabBroken *event);
694static gboolean ctk_widget_real_focus (CtkWidget *widget,
695 CtkDirectionType direction);
696static void ctk_widget_real_move_focus (CtkWidget *widget,
697 CtkDirectionType direction);
698static gboolean ctk_widget_real_keynav_failed (CtkWidget *widget,
699 CtkDirectionType direction);
700#ifdef G_ENABLE_CONSISTENCY_CHECKS1
701static void ctk_widget_verify_invariants (CtkWidget *widget);
702static void ctk_widget_push_verify_invariants (CtkWidget *widget);
703static void ctk_widget_pop_verify_invariants (CtkWidget *widget);
704#else
705#define ctk_widget_verify_invariants(widget)
706#define ctk_widget_push_verify_invariants(widget)
707#define ctk_widget_pop_verify_invariants(widget)
708#endif
709static PangoContext* ctk_widget_peek_pango_context (CtkWidget *widget);
710static void ctk_widget_update_pango_context (CtkWidget *widget);
711static void ctk_widget_propagate_state (CtkWidget *widget,
712 CtkStateData *data);
713static void ctk_widget_update_alpha (CtkWidget *widget);
714
715static gint ctk_widget_event_internal (CtkWidget *widget,
716 CdkEvent *event);
717static gboolean ctk_widget_real_mnemonic_activate (CtkWidget *widget,
718 gboolean group_cycling);
719static void ctk_widget_real_get_width (CtkWidget *widget,
720 gint *minimum_size,
721 gint *natural_size);
722static void ctk_widget_real_get_height (CtkWidget *widget,
723 gint *minimum_size,
724 gint *natural_size);
725static void ctk_widget_real_get_height_for_width (CtkWidget *widget,
726 gint width,
727 gint *minimum_height,
728 gint *natural_height);
729static void ctk_widget_real_get_width_for_height (CtkWidget *widget,
730 gint height,
731 gint *minimum_width,
732 gint *natural_width);
733static void ctk_widget_real_state_flags_changed (CtkWidget *widget,
734 CtkStateFlags old_state);
735static void ctk_widget_real_queue_draw_region (CtkWidget *widget,
736 const cairo_region_t *region);
737static AtkObject* ctk_widget_real_get_accessible (CtkWidget *widget);
738static void ctk_widget_accessible_interface_init (AtkImplementorIface *iface);
739static AtkObject* ctk_widget_ref_accessible (AtkImplementor *implementor);
740static void ctk_widget_invalidate_widget_windows (CtkWidget *widget,
741 cairo_region_t *region);
742static CdkScreen * ctk_widget_get_screen_unchecked (CtkWidget *widget);
743static gboolean ctk_widget_real_can_activate_accel (CtkWidget *widget,
744 guint signal_id);
745
746static void ctk_widget_real_set_has_tooltip (CtkWidget *widget,
747 gboolean has_tooltip,
748 gboolean force);
749static void ctk_widget_buildable_interface_init (CtkBuildableIface *iface);
750static void ctk_widget_buildable_set_name (CtkBuildable *buildable,
751 const gchar *name);
752static const gchar * ctk_widget_buildable_get_name (CtkBuildable *buildable);
753static GObject * ctk_widget_buildable_get_internal_child (CtkBuildable *buildable,
754 CtkBuilder *builder,
755 const gchar *childname);
756static void ctk_widget_buildable_set_buildable_property (CtkBuildable *buildable,
757 CtkBuilder *builder,
758 const gchar *name,
759 const GValue *value);
760static gboolean ctk_widget_buildable_custom_tag_start (CtkBuildable *buildable,
761 CtkBuilder *builder,
762 GObject *child,
763 const gchar *tagname,
764 GMarkupParser *parser,
765 gpointer *data);
766static void ctk_widget_buildable_custom_finished (CtkBuildable *buildable,
767 CtkBuilder *builder,
768 GObject *child,
769 const gchar *tagname,
770 gpointer data);
771static void ctk_widget_buildable_parser_finished (CtkBuildable *buildable,
772 CtkBuilder *builder);
773
774static CtkSizeRequestMode ctk_widget_real_get_request_mode (CtkWidget *widget);
775static void ctk_widget_real_get_width (CtkWidget *widget,
776 gint *minimum_size,
777 gint *natural_size);
778static void ctk_widget_real_get_height (CtkWidget *widget,
779 gint *minimum_size,
780 gint *natural_size);
781
782static void ctk_widget_queue_tooltip_query (CtkWidget *widget);
783
784
785static void ctk_widget_real_adjust_size_request (CtkWidget *widget,
786 CtkOrientation orientation,
787 gint *minimum_size,
788 gint *natural_size);
789static void ctk_widget_real_adjust_baseline_request (CtkWidget *widget,
790 gint *minimum_baseline,
791 gint *natural_baseline);
792static void ctk_widget_real_adjust_size_allocation (CtkWidget *widget,
793 CtkOrientation orientation,
794 gint *minimum_size,
795 gint *natural_size,
796 gint *allocated_pos,
797 gint *allocated_size);
798static void ctk_widget_real_adjust_baseline_allocation (CtkWidget *widget,
799 gint *baseline);
800
801static void template_data_free (CtkWidgetTemplate *template_data);
802
803static void ctk_widget_set_usize_internal (CtkWidget *widget,
804 gint width,
805 gint height);
806
807static void ctk_widget_add_events_internal (CtkWidget *widget,
808 CdkDevice *device,
809 gint events);
810static void ctk_widget_set_device_enabled_internal (CtkWidget *widget,
811 CdkDevice *device,
812 gboolean recurse,
813 gboolean enabled);
814
815static void ctk_widget_on_frame_clock_update (CdkFrameClock *frame_clock,
816 CtkWidget *widget);
817
818static gboolean event_window_is_still_viewable (CdkEvent *event);
819
820static void ctk_widget_update_input_shape (CtkWidget *widget);
821
822/* --- variables --- */
823static gint CtkWidget_private_offset = 0;
824static gpointer ctk_widget_parent_class = NULL((void*)0);
825static guint widget_signals[LAST_SIGNAL] = { 0 };
826static guint composite_child_stack = 0;
827CtkTextDirection ctk_default_direction = CTK_TEXT_DIR_LTR;
828static GParamSpecPool *style_property_spec_pool = NULL((void*)0);
829
830static GQuark quark_property_parser = 0;
831static GQuark quark_accel_path = 0;
832static GQuark quark_accel_closures = 0;
833static GQuark quark_event_mask = 0;
834static GQuark quark_device_event_mask = 0;
835static GQuark quark_parent_window = 0;
836static GQuark quark_shape_info = 0;
837static GQuark quark_input_shape_info = 0;
838static GQuark quark_pango_context = 0;
839static GQuark quark_mnemonic_labels = 0;
840static GQuark quark_tooltip_markup = 0;
841static GQuark quark_tooltip_window = 0;
842static GQuark quark_visual = 0;
843static GQuark quark_modifier_style = 0;
844static GQuark quark_enabled_devices = 0;
845static GQuark quark_size_groups = 0;
846static GQuark quark_auto_children = 0;
847static GQuark quark_widget_path = 0;
848static GQuark quark_action_muxer = 0;
849static GQuark quark_font_options = 0;
850static GQuark quark_font_map = 0;
851
852GParamSpecPool *_ctk_widget_child_property_pool = NULL((void*)0);
853GObjectNotifyContext *_ctk_widget_child_property_notify_context = NULL((void*)0);
854
855/* --- functions --- */
856GType
857ctk_widget_get_type (void)
858{
859 static GType widget_type = 0;
860
861 if (G_UNLIKELY (widget_type == 0)(widget_type == 0))
862 {
863 const GTypeInfo widget_info =
864 {
865 sizeof (CtkWidgetClass),
866 ctk_widget_base_class_init,
867 (GBaseFinalizeFunc) ctk_widget_base_class_finalize,
868 (GClassInitFunc) ctk_widget_class_init,
869 NULL((void*)0), /* class_finalize */
870 NULL((void*)0), /* class_init */
871 sizeof (CtkWidget),
872 0, /* n_preallocs */
873 ctk_widget_init,
874 NULL((void*)0), /* value_table */
875 };
876
877 const GInterfaceInfo accessibility_info =
878 {
879 (GInterfaceInitFunc) ctk_widget_accessible_interface_init,
880 (GInterfaceFinalizeFunc) NULL((void*)0),
881 NULL((void*)0) /* interface data */
882 };
883
884 const GInterfaceInfo buildable_info =
885 {
886 (GInterfaceInitFunc) ctk_widget_buildable_interface_init,
887 (GInterfaceFinalizeFunc) NULL((void*)0),
888 NULL((void*)0) /* interface data */
889 };
890
891 widget_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED(g_initially_unowned_get_type()), "CtkWidget",
892 &widget_info, G_TYPE_FLAG_ABSTRACT);
893
894 g_type_add_class_private (widget_type, sizeof (CtkWidgetClassPrivate));
895
896 CtkWidget_private_offset =
897 g_type_add_instance_private (widget_type, sizeof (CtkWidgetPrivate));
898
899 g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR(atk_implementor_get_type ()),
900 &accessibility_info) ;
901 g_type_add_interface_static (widget_type, CTK_TYPE_BUILDABLE(ctk_buildable_get_type ()),
902 &buildable_info) ;
903 }
904
905 return widget_type;
906}
907
908static inline gpointer
909ctk_widget_get_instance_private (CtkWidget *self)
910{
911 return (G_STRUCT_MEMBER_P (self, CtkWidget_private_offset)((gpointer) ((guint8*) (self) + (glong) (CtkWidget_private_offset
)))
);
912}
913
914static void
915ctk_widget_base_class_init (gpointer g_class)
916{
917 CtkWidgetClass *klass = g_class;
918
919 klass->priv = G_TYPE_CLASS_GET_PRIVATE (g_class, CTK_TYPE_WIDGET, CtkWidgetClassPrivate)((CtkWidgetClassPrivate*) g_type_class_get_private ((GTypeClass
*) (g_class), ((ctk_widget_get_type ()))))
;
920 klass->priv->template = NULL((void*)0);
921}
922
923static void
924child_property_notify_dispatcher (GObject *object,
925 guint n_pspecs,
926 GParamSpec **pspecs)
927{
928 CTK_WIDGET_GET_CLASS (object)((((CtkWidgetClass*) (((GTypeInstance*) ((object)))->g_class
))))
->dispatch_child_properties_changed (CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
, n_pspecs, pspecs);
929}
930
931/* We guard against the draw signal callbacks modifying the state of the
932 * cairo context by surrounding it with save/restore.
933 * Maybe we should also cairo_new_path() just to be sure?
934 */
935static void
936ctk_widget_draw_marshaller (GClosure *closure,
937 GValue *return_value,
938 guint n_param_values,
939 const GValue *param_values,
940 gpointer invocation_hint,
941 gpointer marshal_data)
942{
943 cairo_t *cr = g_value_get_boxed (&param_values[1]);
944
945 cairo_save (cr);
946
947 _ctk_marshal_BOOLEAN__BOXED (closure,
948 return_value,
949 n_param_values,
950 param_values,
951 invocation_hint,
952 marshal_data);
953
954
955 cairo_restore (cr);
956}
957
958static void
959ctk_widget_draw_marshallerv (GClosure *closure,
960 GValue *return_value,
961 gpointer instance,
962 va_list args,
963 gpointer marshal_data,
964 int n_params,
965 GType *param_types)
966{
967 cairo_t *cr;
968 va_list args_copy;
969
970 G_VA_COPY (args_copy, args)__builtin_va_copy(args_copy, args);
971 cr = va_arg (args_copy, gpointer)__builtin_va_arg(args_copy, gpointer);
972
973 cairo_save (cr);
974
975 _ctk_marshal_BOOLEAN__BOXEDv (closure,
976 return_value,
977 instance,
978 args,
979 marshal_data,
980 n_params,
981 param_types);
982
983
984 cairo_restore (cr);
985
986 va_end (args_copy)__builtin_va_end(args_copy);
987}
988
989static void
990ctk_widget_class_init (CtkWidgetClass *klass)
991{
992 static GObjectNotifyContext cpn_context = { 0, NULL((void*)0), NULL((void*)0) };
993 GObjectClass *gobject_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
994 CtkBindingSet *binding_set;
995
996 g_type_class_adjust_private_offset (klass, &CtkWidget_private_offset);
997 ctk_widget_parent_class = g_type_class_peek_parent (klass);
998
999 quark_property_parser = g_quark_from_static_string ("ctk-rc-property-parser");
1000 quark_accel_path = g_quark_from_static_string ("ctk-accel-path");
1001 quark_accel_closures = g_quark_from_static_string ("ctk-accel-closures");
1002 quark_event_mask = g_quark_from_static_string ("ctk-event-mask");
1003 quark_device_event_mask = g_quark_from_static_string ("ctk-device-event-mask");
1004 quark_parent_window = g_quark_from_static_string ("ctk-parent-window");
1005 quark_shape_info = g_quark_from_static_string ("ctk-shape-info");
1006 quark_input_shape_info = g_quark_from_static_string ("ctk-input-shape-info");
1007 quark_pango_context = g_quark_from_static_string ("ctk-pango-context");
1008 quark_mnemonic_labels = g_quark_from_static_string ("ctk-mnemonic-labels");
1009 quark_tooltip_markup = g_quark_from_static_string ("ctk-tooltip-markup");
1010 quark_tooltip_window = g_quark_from_static_string ("ctk-tooltip-window");
1011 quark_visual = g_quark_from_static_string ("ctk-widget-visual");
1012 quark_modifier_style = g_quark_from_static_string ("ctk-widget-modifier-style");
1013 quark_enabled_devices = g_quark_from_static_string ("ctk-widget-enabled-devices");
1014 quark_size_groups = g_quark_from_static_string ("ctk-widget-size-groups");
1015 quark_auto_children = g_quark_from_static_string ("ctk-widget-auto-children");
1016 quark_widget_path = g_quark_from_static_string ("ctk-widget-path");
1017 quark_action_muxer = g_quark_from_static_string ("ctk-widget-action-muxer");
1018 quark_font_options = g_quark_from_static_string ("ctk-widget-font-options");
1019 quark_font_map = g_quark_from_static_string ("ctk-widget-font-map");
1020
1021 style_property_spec_pool = g_param_spec_pool_new (FALSE(0));
1022 _ctk_widget_child_property_pool = g_param_spec_pool_new (TRUE(!(0)));
1023 cpn_context.quark_notify_queue = g_quark_from_static_string ("CtkWidget-child-property-notify-queue");
1024 cpn_context.dispatcher = child_property_notify_dispatcher;
1025 _ctk_widget_child_property_notify_context = &cpn_context;
1026
1027 gobject_class->constructed = ctk_widget_constructed;
1028 gobject_class->dispose = ctk_widget_dispose;
1029 gobject_class->finalize = ctk_widget_finalize;
1030 gobject_class->set_property = ctk_widget_set_property;
1031 gobject_class->get_property = ctk_widget_get_property;
1032
1033 klass->destroy = ctk_widget_real_destroy;
1034
1035 klass->activate_signal = 0;
1036 klass->dispatch_child_properties_changed = ctk_widget_dispatch_child_properties_changed;
1037 klass->show = ctk_widget_real_show;
1038 klass->show_all = ctk_widget_show;
1039 klass->hide = ctk_widget_real_hide;
1040 klass->map = ctk_widget_real_map;
1041 klass->unmap = ctk_widget_real_unmap;
1042 klass->realize = ctk_widget_real_realize;
1043 klass->unrealize = ctk_widget_real_unrealize;
1044 klass->size_allocate = ctk_widget_real_size_allocate;
1045 klass->get_request_mode = ctk_widget_real_get_request_mode;
1046 klass->get_preferred_width = ctk_widget_real_get_width;
1047 klass->get_preferred_height = ctk_widget_real_get_height;
1048 klass->get_preferred_width_for_height = ctk_widget_real_get_width_for_height;
1049 klass->get_preferred_height_for_width = ctk_widget_real_get_height_for_width;
1050 klass->get_preferred_height_and_baseline_for_width = NULL((void*)0);
1051 klass->state_changed = NULL((void*)0);
1052 klass->state_flags_changed = ctk_widget_real_state_flags_changed;
1053 klass->parent_set = NULL((void*)0);
1054 klass->hierarchy_changed = NULL((void*)0);
1055 klass->style_set = ctk_widget_real_style_set;
1056 klass->direction_changed = ctk_widget_real_direction_changed;
1057 klass->grab_notify = NULL((void*)0);
1058 klass->child_notify = NULL((void*)0);
1059 klass->draw = NULL((void*)0);
1060 klass->mnemonic_activate = ctk_widget_real_mnemonic_activate;
1061 klass->grab_focus = ctk_widget_real_grab_focus;
1062 klass->focus = ctk_widget_real_focus;
1063 klass->move_focus = ctk_widget_real_move_focus;
1064 klass->keynav_failed = ctk_widget_real_keynav_failed;
1065 klass->event = NULL((void*)0);
1066 klass->scroll_event = ctk_widget_real_scroll_event;
1067 klass->button_press_event = ctk_widget_real_button_event;
1068 klass->button_release_event = ctk_widget_real_button_event;
1069 klass->motion_notify_event = ctk_widget_real_motion_event;
1070 klass->touch_event = ctk_widget_real_touch_event;
1071 klass->delete_event = NULL((void*)0);
1072 klass->destroy_event = NULL((void*)0);
1073 klass->key_press_event = ctk_widget_real_key_press_event;
1074 klass->key_release_event = ctk_widget_real_key_release_event;
1075 klass->enter_notify_event = NULL((void*)0);
1076 klass->leave_notify_event = NULL((void*)0);
1077 klass->configure_event = NULL((void*)0);
1078 klass->focus_in_event = ctk_widget_real_focus_in_event;
1079 klass->focus_out_event = ctk_widget_real_focus_out_event;
1080 klass->map_event = NULL((void*)0);
1081 klass->unmap_event = NULL((void*)0);
1082 klass->window_state_event = NULL((void*)0);
1083 klass->property_notify_event = _ctk_selection_property_notify;
1084 klass->selection_clear_event = _ctk_selection_clear;
1085 klass->selection_request_event = _ctk_selection_request;
1086 klass->selection_notify_event = _ctk_selection_notify;
1087 klass->selection_received = NULL((void*)0);
1088 klass->proximity_in_event = NULL((void*)0);
1089 klass->proximity_out_event = NULL((void*)0);
1090 klass->drag_begin = NULL((void*)0);
1091 klass->drag_end = NULL((void*)0);
1092 klass->drag_data_delete = NULL((void*)0);
1093 klass->drag_leave = NULL((void*)0);
1094 klass->drag_motion = NULL((void*)0);
1095 klass->drag_drop = NULL((void*)0);
1096 klass->drag_data_received = NULL((void*)0);
1097 klass->screen_changed = NULL((void*)0);
1098 klass->can_activate_accel = ctk_widget_real_can_activate_accel;
1099 klass->grab_broken_event = ctk_widget_real_grab_broken_event;
1100 klass->query_tooltip = ctk_widget_real_query_tooltip;
1101 klass->style_updated = ctk_widget_real_style_updated;
1102
1103 klass->show_help = ctk_widget_real_show_help;
1104
1105 /* Accessibility support */
1106 klass->priv->accessible_type = CTK_TYPE_ACCESSIBLE(ctk_accessible_get_type ());
1107 klass->priv->accessible_role = ATK_ROLE_INVALID;
1108 klass->get_accessible = ctk_widget_real_get_accessible;
1109
1110 klass->adjust_size_request = ctk_widget_real_adjust_size_request;
1111 klass->adjust_baseline_request = ctk_widget_real_adjust_baseline_request;
1112 klass->adjust_size_allocation = ctk_widget_real_adjust_size_allocation;
1113 klass->adjust_baseline_allocation = ctk_widget_real_adjust_baseline_allocation;
1114 klass->queue_draw_region = ctk_widget_real_queue_draw_region;
1115
1116 widget_props[PROP_NAME] =
1117 g_param_spec_string ("name",
1118 P_("Widget name")g_dgettext("ctk30" "-properties","Widget name"),
1119 P_("The name of the widget")g_dgettext("ctk30" "-properties","The name of the widget"),
1120 NULL((void*)0),
1121 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1122
1123 widget_props[PROP_PARENT] =
1124 g_param_spec_object ("parent",
1125 P_("Parent widget")g_dgettext("ctk30" "-properties","Parent widget"),
1126 P_("The parent widget of this widget. Must be a Container widget")g_dgettext("ctk30" "-properties","The parent widget of this widget. Must be a Container widget"
)
,
1127 CTK_TYPE_CONTAINER(ctk_container_get_type ()),
1128 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1129
1130 widget_props[PROP_WIDTH_REQUEST] =
1131 g_param_spec_int ("width-request",
1132 P_("Width request")g_dgettext("ctk30" "-properties","Width request"),
1133 P_("Override for width request of the widget, or -1 if natural request should be used")g_dgettext("ctk30" "-properties","Override for width request of the widget, or -1 if natural request should be used"
)
,
1134 -1, G_MAXINT2147483647,
1135 -1,
1136 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1137
1138 widget_props[PROP_HEIGHT_REQUEST] =
1139 g_param_spec_int ("height-request",
1140 P_("Height request")g_dgettext("ctk30" "-properties","Height request"),
1141 P_("Override for height request of the widget, or -1 if natural request should be used")g_dgettext("ctk30" "-properties","Override for height request of the widget, or -1 if natural request should be used"
)
,
1142 -1, G_MAXINT2147483647,
1143 -1,
1144 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1145
1146 widget_props[PROP_VISIBLE] =
1147 g_param_spec_boolean ("visible",
1148 P_("Visible")g_dgettext("ctk30" "-properties","Visible"),
1149 P_("Whether the widget is visible")g_dgettext("ctk30" "-properties","Whether the widget is visible"
)
,
1150 FALSE(0),
1151 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1152
1153 widget_props[PROP_SENSITIVE] =
1154 g_param_spec_boolean ("sensitive",
1155 P_("Sensitive")g_dgettext("ctk30" "-properties","Sensitive"),
1156 P_("Whether the widget responds to input")g_dgettext("ctk30" "-properties","Whether the widget responds to input"
)
,
1157 TRUE(!(0)),
1158 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1159
1160 widget_props[PROP_APP_PAINTABLE] =
1161 g_param_spec_boolean ("app-paintable",
1162 P_("Application paintable")g_dgettext("ctk30" "-properties","Application paintable"),
1163 P_("Whether the application will paint directly on the widget")g_dgettext("ctk30" "-properties","Whether the application will paint directly on the widget"
)
,
1164 FALSE(0),
1165 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1166
1167 widget_props[PROP_CAN_FOCUS] =
1168 g_param_spec_boolean ("can-focus",
1169 P_("Can focus")g_dgettext("ctk30" "-properties","Can focus"),
1170 P_("Whether the widget can accept the input focus")g_dgettext("ctk30" "-properties","Whether the widget can accept the input focus"
)
,
1171 FALSE(0),
1172 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1173
1174 widget_props[PROP_HAS_FOCUS] =
1175 g_param_spec_boolean ("has-focus",
1176 P_("Has focus")g_dgettext("ctk30" "-properties","Has focus"),
1177 P_("Whether the widget has the input focus")g_dgettext("ctk30" "-properties","Whether the widget has the input focus"
)
,
1178 FALSE(0),
1179 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1180
1181 widget_props[PROP_IS_FOCUS] =
1182 g_param_spec_boolean ("is-focus",
1183 P_("Is focus")g_dgettext("ctk30" "-properties","Is focus"),
1184 P_("Whether the widget is the focus widget within the toplevel")g_dgettext("ctk30" "-properties","Whether the widget is the focus widget within the toplevel"
)
,
1185 FALSE(0),
1186 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1187
1188 /**
1189 * CtkWidget:focus-on-click:
1190 *
1191 * Whether the widget should grab focus when it is clicked with the mouse.
1192 *
1193 * This property is only relevant for widgets that can take focus.
1194 *
1195 * Before 3.20, several widgets (CtkButton, CtkFileChooserButton,
1196 * CtkComboBox) implemented this property individually.
1197 *
1198 * Since: 3.20
1199 */
1200 widget_props[PROP_FOCUS_ON_CLICK] =
1201 g_param_spec_boolean ("focus-on-click",
1202 P_("Focus on click")g_dgettext("ctk30" "-properties","Focus on click"),
1203 P_("Whether the widget should grab focus when it is clicked with the mouse")g_dgettext("ctk30" "-properties","Whether the widget should grab focus when it is clicked with the mouse"
)
,
1204 TRUE(!(0)),
1205 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1206
1207 widget_props[PROP_CAN_DEFAULT] =
1208 g_param_spec_boolean ("can-default",
1209 P_("Can default")g_dgettext("ctk30" "-properties","Can default"),
1210 P_("Whether the widget can be the default widget")g_dgettext("ctk30" "-properties","Whether the widget can be the default widget"
)
,
1211 FALSE(0),
1212 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1213
1214 widget_props[PROP_HAS_DEFAULT] =
1215 g_param_spec_boolean ("has-default",
1216 P_("Has default")g_dgettext("ctk30" "-properties","Has default"),
1217 P_("Whether the widget is the default widget")g_dgettext("ctk30" "-properties","Whether the widget is the default widget"
)
,
1218 FALSE(0),
1219 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1220
1221 widget_props[PROP_RECEIVES_DEFAULT] =
1222 g_param_spec_boolean ("receives-default",
1223 P_("Receives default")g_dgettext("ctk30" "-properties","Receives default"),
1224 P_("If TRUE, the widget will receive the default action when it is focused")g_dgettext("ctk30" "-properties","If TRUE, the widget will receive the default action when it is focused"
)
,
1225 FALSE(0),
1226 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1227
1228 widget_props[PROP_COMPOSITE_CHILD] =
1229 g_param_spec_boolean ("composite-child",
1230 P_("Composite child")g_dgettext("ctk30" "-properties","Composite child"),
1231 P_("Whether the widget is part of a composite widget")g_dgettext("ctk30" "-properties","Whether the widget is part of a composite widget"
)
,
1232 FALSE(0),
1233 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1234
1235G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
1236
1237 /**
1238 * CtkWidget:style:
1239 *
1240 * The style of the widget, which contains information about how it will look (colors, etc).
1241 *
1242 * Deprecated: Use #CtkStyleContext instead
1243 */
1244 widget_props[PROP_STYLE] =
1245 g_param_spec_object ("style",
1246 P_("Style")g_dgettext("ctk30" "-properties","Style"),
1247 P_("The style of the widget, which contains information about how it will look (colors etc)")g_dgettext("ctk30" "-properties","The style of the widget, which contains information about how it will look (colors etc)"
)
,
1248 CTK_TYPE_STYLE(ctk_style_get_type ()),
1249 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1250
1251G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
1252
1253 widget_props[PROP_EVENTS] =
1254 g_param_spec_flags ("events",
1255 P_("Events")g_dgettext("ctk30" "-properties","Events"),
1256 P_("The event mask that decides what kind of CdkEvents this widget gets")g_dgettext("ctk30" "-properties","The event mask that decides what kind of CdkEvents this widget gets"
)
,
1257 CDK_TYPE_EVENT_MASK(cdk_event_mask_get_type ()),
1258 CDK_STRUCTURE_MASK,
1259 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1260
1261 widget_props[PROP_NO_SHOW_ALL] =
1262 g_param_spec_boolean ("no-show-all",
1263 P_("No show all")g_dgettext("ctk30" "-properties","No show all"),
1264 P_("Whether ctk_widget_show_all() should not affect this widget")g_dgettext("ctk30" "-properties","Whether ctk_widget_show_all() should not affect this widget"
)
,
1265 FALSE(0),
1266 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1267
1268/**
1269 * CtkWidget:has-tooltip:
1270 *
1271 * Enables or disables the emission of #CtkWidget::query-tooltip on @widget.
1272 * A value of %TRUE indicates that @widget can have a tooltip, in this case
1273 * the widget will be queried using #CtkWidget::query-tooltip to determine
1274 * whether it will provide a tooltip or not.
1275 *
1276 * Note that setting this property to %TRUE for the first time will change
1277 * the event masks of the CdkWindows of this widget to include leave-notify
1278 * and motion-notify events. This cannot and will not be undone when the
1279 * property is set to %FALSE again.
1280 *
1281 * Since: 2.12
1282 */
1283 widget_props[PROP_HAS_TOOLTIP] =
1284 g_param_spec_boolean ("has-tooltip",
1285 P_("Has tooltip")g_dgettext("ctk30" "-properties","Has tooltip"),
1286 P_("Whether this widget has a tooltip")g_dgettext("ctk30" "-properties","Whether this widget has a tooltip"
)
,
1287 FALSE(0),
1288 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1289
1290 /**
1291 * CtkWidget:tooltip-text:
1292 *
1293 * Sets the text of tooltip to be the given string.
1294 *
1295 * Also see ctk_tooltip_set_text().
1296 *
1297 * This is a convenience property which will take care of getting the
1298 * tooltip shown if the given string is not %NULL: #CtkWidget:has-tooltip
1299 * will automatically be set to %TRUE and there will be taken care of
1300 * #CtkWidget::query-tooltip in the default signal handler.
1301 *
1302 * Note that if both #CtkWidget:tooltip-text and #CtkWidget:tooltip-markup
1303 * are set, the last one wins.
1304 *
1305 * Since: 2.12
1306 */
1307 widget_props[PROP_TOOLTIP_TEXT] =
1308 g_param_spec_string ("tooltip-text",
1309 P_("Tooltip Text")g_dgettext("ctk30" "-properties","Tooltip Text"),
1310 P_("The contents of the tooltip for this widget")g_dgettext("ctk30" "-properties","The contents of the tooltip for this widget"
)
,
1311 NULL((void*)0),
1312 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1313
1314 /**
1315 * CtkWidget:tooltip-markup:
1316 *
1317 * Sets the text of tooltip to be the given string, which is marked up
1318 * with the [Pango text markup language][PangoMarkupFormat].
1319 * Also see ctk_tooltip_set_markup().
1320 *
1321 * This is a convenience property which will take care of getting the
1322 * tooltip shown if the given string is not %NULL: #CtkWidget:has-tooltip
1323 * will automatically be set to %TRUE and there will be taken care of
1324 * #CtkWidget::query-tooltip in the default signal handler.
1325 *
1326 * Note that if both #CtkWidget:tooltip-text and #CtkWidget:tooltip-markup
1327 * are set, the last one wins.
1328 *
1329 * Since: 2.12
1330 */
1331 widget_props[PROP_TOOLTIP_MARKUP] =
1332 g_param_spec_string ("tooltip-markup",
1333 P_("Tooltip markup")g_dgettext("ctk30" "-properties","Tooltip markup"),
1334 P_("The contents of the tooltip for this widget")g_dgettext("ctk30" "-properties","The contents of the tooltip for this widget"
)
,
1335 NULL((void*)0),
1336 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1337
1338 /**
1339 * CtkWidget:window:
1340 *
1341 * The widget's window if it is realized, %NULL otherwise.
1342 *
1343 * Since: 2.14
1344 */
1345 widget_props[PROP_WINDOW] =
1346 g_param_spec_object ("window",
1347 P_("Window")g_dgettext("ctk30" "-properties","Window"),
1348 P_("The widget's window if it is realized")g_dgettext("ctk30" "-properties","The widget's window if it is realized"
)
,
1349 CDK_TYPE_WINDOW(cdk_window_get_type ()),
1350 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1351
1352 /**
1353 * CtkWidget:double-buffered:
1354 *
1355 * Whether the widget is double buffered.
1356 *
1357 * Since: 2.18
1358 *
1359 * Deprecated: 3.14: Widgets should not use this property.
1360 */
1361 widget_props[PROP_DOUBLE_BUFFERED] =
1362 g_param_spec_boolean ("double-buffered",
1363 P_("Double Buffered")g_dgettext("ctk30" "-properties","Double Buffered"),
1364 P_("Whether the widget is double buffered")g_dgettext("ctk30" "-properties","Whether the widget is double buffered"
)
,
1365 TRUE(!(0)),
1366 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED);
1367
1368 /**
1369 * CtkWidget:halign:
1370 *
1371 * How to distribute horizontal space if widget gets extra space, see #CtkAlign
1372 *
1373 * Since: 3.0
1374 */
1375 widget_props[PROP_HALIGN] =
1376 g_param_spec_enum ("halign",
1377 P_("Horizontal Alignment")g_dgettext("ctk30" "-properties","Horizontal Alignment"),
1378 P_("How to position in extra horizontal space")g_dgettext("ctk30" "-properties","How to position in extra horizontal space"
)
,
1379 CTK_TYPE_ALIGN(ctk_align_get_type ()),
1380 CTK_ALIGN_FILL,
1381 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1382
1383 /**
1384 * CtkWidget:valign:
1385 *
1386 * How to distribute vertical space if widget gets extra space, see #CtkAlign
1387 *
1388 * Since: 3.0
1389 */
1390 widget_props[PROP_VALIGN] =
1391 g_param_spec_enum ("valign",
1392 P_("Vertical Alignment")g_dgettext("ctk30" "-properties","Vertical Alignment"),
1393 P_("How to position in extra vertical space")g_dgettext("ctk30" "-properties","How to position in extra vertical space"
)
,
1394 CTK_TYPE_ALIGN(ctk_align_get_type ()),
1395 CTK_ALIGN_FILL,
1396 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1397
1398 /**
1399 * CtkWidget:margin-left:
1400 *
1401 * Margin on left side of widget.
1402 *
1403 * This property adds margin outside of the widget's normal size
1404 * request, the margin will be added in addition to the size from
1405 * ctk_widget_set_size_request() for example.
1406 *
1407 * Deprecated: 3.12: Use #CtkWidget:margin-start instead.
1408 *
1409 * Since: 3.0
1410 */
1411 widget_props[PROP_MARGIN_LEFT] =
1412 g_param_spec_int ("margin-left",
1413 P_("Margin on Left")g_dgettext("ctk30" "-properties","Margin on Left"),
1414 P_("Pixels of extra space on the left side")g_dgettext("ctk30" "-properties","Pixels of extra space on the left side"
)
,
1415 0, G_MAXINT16((gint16) 0x7fff),
1416 0,
1417 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED);
1418
1419 /**
1420 * CtkWidget:margin-right:
1421 *
1422 * Margin on right side of widget.
1423 *
1424 * This property adds margin outside of the widget's normal size
1425 * request, the margin will be added in addition to the size from
1426 * ctk_widget_set_size_request() for example.
1427 *
1428 * Deprecated: 3.12: Use #CtkWidget:margin-end instead.
1429 *
1430 * Since: 3.0
1431 */
1432 widget_props[PROP_MARGIN_RIGHT] =
1433 g_param_spec_int ("margin-right",
1434 P_("Margin on Right")g_dgettext("ctk30" "-properties","Margin on Right"),
1435 P_("Pixels of extra space on the right side")g_dgettext("ctk30" "-properties","Pixels of extra space on the right side"
)
,
1436 0, G_MAXINT16((gint16) 0x7fff),
1437 0,
1438 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED);
1439
1440 /**
1441 * CtkWidget:margin-start:
1442 *
1443 * Margin on start of widget, horizontally. This property supports
1444 * left-to-right and right-to-left text directions.
1445 *
1446 * This property adds margin outside of the widget's normal size
1447 * request, the margin will be added in addition to the size from
1448 * ctk_widget_set_size_request() for example.
1449 *
1450 * Since: 3.12
1451 */
1452 widget_props[PROP_MARGIN_START] =
1453 g_param_spec_int ("margin-start",
1454 P_("Margin on Start")g_dgettext("ctk30" "-properties","Margin on Start"),
1455 P_("Pixels of extra space on the start")g_dgettext("ctk30" "-properties","Pixels of extra space on the start"
)
,
1456 0, G_MAXINT16((gint16) 0x7fff),
1457 0,
1458 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1459
1460 /**
1461 * CtkWidget:margin-end:
1462 *
1463 * Margin on end of widget, horizontally. This property supports
1464 * left-to-right and right-to-left text directions.
1465 *
1466 * This property adds margin outside of the widget's normal size
1467 * request, the margin will be added in addition to the size from
1468 * ctk_widget_set_size_request() for example.
1469 *
1470 * Since: 3.12
1471 */
1472 widget_props[PROP_MARGIN_END] =
1473 g_param_spec_int ("margin-end",
1474 P_("Margin on End")g_dgettext("ctk30" "-properties","Margin on End"),
1475 P_("Pixels of extra space on the end")g_dgettext("ctk30" "-properties","Pixels of extra space on the end"
)
,
1476 0, G_MAXINT16((gint16) 0x7fff),
1477 0,
1478 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1479
1480 /**
1481 * CtkWidget:margin-top:
1482 *
1483 * Margin on top side of widget.
1484 *
1485 * This property adds margin outside of the widget's normal size
1486 * request, the margin will be added in addition to the size from
1487 * ctk_widget_set_size_request() for example.
1488 *
1489 * Since: 3.0
1490 */
1491 widget_props[PROP_MARGIN_TOP] =
1492 g_param_spec_int ("margin-top",
1493 P_("Margin on Top")g_dgettext("ctk30" "-properties","Margin on Top"),
1494 P_("Pixels of extra space on the top side")g_dgettext("ctk30" "-properties","Pixels of extra space on the top side"
)
,
1495 0, G_MAXINT16((gint16) 0x7fff),
1496 0,
1497 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1498
1499 /**
1500 * CtkWidget:margin-bottom:
1501 *
1502 * Margin on bottom side of widget.
1503 *
1504 * This property adds margin outside of the widget's normal size
1505 * request, the margin will be added in addition to the size from
1506 * ctk_widget_set_size_request() for example.
1507 *
1508 * Since: 3.0
1509 */
1510 widget_props[PROP_MARGIN_BOTTOM] =
1511 g_param_spec_int ("margin-bottom",
1512 P_("Margin on Bottom")g_dgettext("ctk30" "-properties","Margin on Bottom"),
1513 P_("Pixels of extra space on the bottom side")g_dgettext("ctk30" "-properties","Pixels of extra space on the bottom side"
)
,
1514 0, G_MAXINT16((gint16) 0x7fff),
1515 0,
1516 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1517
1518 /**
1519 * CtkWidget:margin:
1520 *
1521 * Sets all four sides' margin at once. If read, returns max
1522 * margin on any side.
1523 *
1524 * Since: 3.0
1525 */
1526 widget_props[PROP_MARGIN] =
1527 g_param_spec_int ("margin",
1528 P_("All Margins")g_dgettext("ctk30" "-properties","All Margins"),
1529 P_("Pixels of extra space on all four sides")g_dgettext("ctk30" "-properties","Pixels of extra space on all four sides"
)
,
1530 0, G_MAXINT16((gint16) 0x7fff),
1531 0,
1532 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1533
1534 /**
1535 * CtkWidget:hexpand:
1536 *
1537 * Whether to expand horizontally. See ctk_widget_set_hexpand().
1538 *
1539 * Since: 3.0
1540 */
1541 widget_props[PROP_HEXPAND] =
1542 g_param_spec_boolean ("hexpand",
1543 P_("Horizontal Expand")g_dgettext("ctk30" "-properties","Horizontal Expand"),
1544 P_("Whether widget wants more horizontal space")g_dgettext("ctk30" "-properties","Whether widget wants more horizontal space"
)
,
1545 FALSE(0),
1546 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1547
1548 /**
1549 * CtkWidget:hexpand-set:
1550 *
1551 * Whether to use the #CtkWidget:hexpand property. See ctk_widget_get_hexpand_set().
1552 *
1553 * Since: 3.0
1554 */
1555 widget_props[PROP_HEXPAND_SET] =
1556 g_param_spec_boolean ("hexpand-set",
1557 P_("Horizontal Expand Set")g_dgettext("ctk30" "-properties","Horizontal Expand Set"),
1558 P_("Whether to use the hexpand property")g_dgettext("ctk30" "-properties","Whether to use the hexpand property"
)
,
1559 FALSE(0),
1560 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1561
1562 /**
1563 * CtkWidget:vexpand:
1564 *
1565 * Whether to expand vertically. See ctk_widget_set_vexpand().
1566 *
1567 * Since: 3.0
1568 */
1569 widget_props[PROP_VEXPAND] =
1570 g_param_spec_boolean ("vexpand",
1571 P_("Vertical Expand")g_dgettext("ctk30" "-properties","Vertical Expand"),
1572 P_("Whether widget wants more vertical space")g_dgettext("ctk30" "-properties","Whether widget wants more vertical space"
)
,
1573 FALSE(0),
1574 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1575
1576 /**
1577 * CtkWidget:vexpand-set:
1578 *
1579 * Whether to use the #CtkWidget:vexpand property. See ctk_widget_get_vexpand_set().
1580 *
1581 * Since: 3.0
1582 */
1583 widget_props[PROP_VEXPAND_SET] =
1584 g_param_spec_boolean ("vexpand-set",
1585 P_("Vertical Expand Set")g_dgettext("ctk30" "-properties","Vertical Expand Set"),
1586 P_("Whether to use the vexpand property")g_dgettext("ctk30" "-properties","Whether to use the vexpand property"
)
,
1587 FALSE(0),
1588 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1589
1590 /**
1591 * CtkWidget:expand:
1592 *
1593 * Whether to expand in both directions. Setting this sets both #CtkWidget:hexpand and #CtkWidget:vexpand
1594 *
1595 * Since: 3.0
1596 */
1597 widget_props[PROP_EXPAND] =
1598 g_param_spec_boolean ("expand",
1599 P_("Expand Both")g_dgettext("ctk30" "-properties","Expand Both"),
1600 P_("Whether widget wants to expand in both directions")g_dgettext("ctk30" "-properties","Whether widget wants to expand in both directions"
)
,
1601 FALSE(0),
1602 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1603
1604 /**
1605 * CtkWidget:opacity:
1606 *
1607 * The requested opacity of the widget. See ctk_widget_set_opacity() for
1608 * more details about window opacity.
1609 *
1610 * Before 3.8 this was only available in CtkWindow
1611 *
1612 * Since: 3.8
1613 */
1614 widget_props[PROP_OPACITY] =
1615 g_param_spec_double ("opacity",
1616 P_("Opacity for Widget")g_dgettext("ctk30" "-properties","Opacity for Widget"),
1617 P_("The opacity of the widget, from 0 to 1")g_dgettext("ctk30" "-properties","The opacity of the widget, from 0 to 1"
)
,
1618 0.0, 1.0,
1619 1.0,
1620 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
1621
1622 /**
1623 * CtkWidget:scale-factor:
1624 *
1625 * The scale factor of the widget. See ctk_widget_get_scale_factor() for
1626 * more details about widget scaling.
1627 *
1628 * Since: 3.10
1629 */
1630 widget_props[PROP_SCALE_FACTOR] =
1631 g_param_spec_int ("scale-factor",
1632 P_("Scale factor")g_dgettext("ctk30" "-properties","Scale factor"),
1633 P_("The scaling factor of the window")g_dgettext("ctk30" "-properties","The scaling factor of the window"
)
,
1634 1, G_MAXINT2147483647,
1635 1,
1636 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
1637
1638 g_object_class_install_properties (gobject_class, NUM_PROPERTIES, widget_props);
1639
1640 /**
1641 * CtkWidget::destroy:
1642 * @object: the object which received the signal
1643 *
1644 * Signals that all holders of a reference to the widget should release
1645 * the reference that they hold. May result in finalization of the widget
1646 * if all references are released.
1647 *
1648 * This signal is not suitable for saving widget state.
1649 */
1650 widget_signals[DESTROY] =
1651 g_signal_new (I_("destroy")g_intern_static_string ("destroy"),
1652 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1653 G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
1654 G_STRUCT_OFFSET (CtkWidgetClass, destroy)((glong) __builtin_offsetof(CtkWidgetClass, destroy)),
1655 NULL((void*)0), NULL((void*)0),
1656 NULL((void*)0),
1657 G_TYPE_NONE((GType) ((1) << (2))), 0);
1658
1659 /**
1660 * CtkWidget::show:
1661 * @widget: the object which received the signal.
1662 *
1663 * The ::show signal is emitted when @widget is shown, for example with
1664 * ctk_widget_show().
1665 */
1666 widget_signals[SHOW] =
1667 g_signal_new (I_("show")g_intern_static_string ("show"),
1668 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1669 G_SIGNAL_RUN_FIRST,
1670 G_STRUCT_OFFSET (CtkWidgetClass, show)((glong) __builtin_offsetof(CtkWidgetClass, show)),
1671 NULL((void*)0), NULL((void*)0),
1672 NULL((void*)0),
1673 G_TYPE_NONE((GType) ((1) << (2))), 0);
1674
1675 /**
1676 * CtkWidget::hide:
1677 * @widget: the object which received the signal.
1678 *
1679 * The ::hide signal is emitted when @widget is hidden, for example with
1680 * ctk_widget_hide().
1681 */
1682 widget_signals[HIDE] =
1683 g_signal_new (I_("hide")g_intern_static_string ("hide"),
1684 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1685 G_SIGNAL_RUN_FIRST,
1686 G_STRUCT_OFFSET (CtkWidgetClass, hide)((glong) __builtin_offsetof(CtkWidgetClass, hide)),
1687 NULL((void*)0), NULL((void*)0),
1688 NULL((void*)0),
1689 G_TYPE_NONE((GType) ((1) << (2))), 0);
1690
1691 /**
1692 * CtkWidget::map:
1693 * @widget: the object which received the signal.
1694 *
1695 * The ::map signal is emitted when @widget is going to be mapped, that is
1696 * when the widget is visible (which is controlled with
1697 * ctk_widget_set_visible()) and all its parents up to the toplevel widget
1698 * are also visible. Once the map has occurred, #CtkWidget::map-event will
1699 * be emitted.
1700 *
1701 * The ::map signal can be used to determine whether a widget will be drawn,
1702 * for instance it can resume an animation that was stopped during the
1703 * emission of #CtkWidget::unmap.
1704 */
1705 widget_signals[MAP] =
1706 g_signal_new (I_("map")g_intern_static_string ("map"),
1707 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1708 G_SIGNAL_RUN_FIRST,
1709 G_STRUCT_OFFSET (CtkWidgetClass, map)((glong) __builtin_offsetof(CtkWidgetClass, map)),
1710 NULL((void*)0), NULL((void*)0),
1711 NULL((void*)0),
1712 G_TYPE_NONE((GType) ((1) << (2))), 0);
1713
1714 /**
1715 * CtkWidget::unmap:
1716 * @widget: the object which received the signal.
1717 *
1718 * The ::unmap signal is emitted when @widget is going to be unmapped, which
1719 * means that either it or any of its parents up to the toplevel widget have
1720 * been set as hidden.
1721 *
1722 * As ::unmap indicates that a widget will not be shown any longer, it can be
1723 * used to, for example, stop an animation on the widget.
1724 */
1725 widget_signals[UNMAP] =
1726 g_signal_new (I_("unmap")g_intern_static_string ("unmap"),
1727 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1728 G_SIGNAL_RUN_FIRST,
1729 G_STRUCT_OFFSET (CtkWidgetClass, unmap)((glong) __builtin_offsetof(CtkWidgetClass, unmap)),
1730 NULL((void*)0), NULL((void*)0),
1731 NULL((void*)0),
1732 G_TYPE_NONE((GType) ((1) << (2))), 0);
1733
1734 /**
1735 * CtkWidget::realize:
1736 * @widget: the object which received the signal.
1737 *
1738 * The ::realize signal is emitted when @widget is associated with a
1739 * #CdkWindow, which means that ctk_widget_realize() has been called or the
1740 * widget has been mapped (that is, it is going to be drawn).
1741 */
1742 widget_signals[REALIZE] =
1743 g_signal_new (I_("realize")g_intern_static_string ("realize"),
1744 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1745 G_SIGNAL_RUN_FIRST,
1746 G_STRUCT_OFFSET (CtkWidgetClass, realize)((glong) __builtin_offsetof(CtkWidgetClass, realize)),
1747 NULL((void*)0), NULL((void*)0),
1748 NULL((void*)0),
1749 G_TYPE_NONE((GType) ((1) << (2))), 0);
1750
1751 /**
1752 * CtkWidget::unrealize:
1753 * @widget: the object which received the signal.
1754 *
1755 * The ::unrealize signal is emitted when the #CdkWindow associated with
1756 * @widget is destroyed, which means that ctk_widget_unrealize() has been
1757 * called or the widget has been unmapped (that is, it is going to be
1758 * hidden).
1759 */
1760 widget_signals[UNREALIZE] =
1761 g_signal_new (I_("unrealize")g_intern_static_string ("unrealize"),
1762 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1763 G_SIGNAL_RUN_LAST,
1764 G_STRUCT_OFFSET (CtkWidgetClass, unrealize)((glong) __builtin_offsetof(CtkWidgetClass, unrealize)),
1765 NULL((void*)0), NULL((void*)0),
1766 NULL((void*)0),
1767 G_TYPE_NONE((GType) ((1) << (2))), 0);
1768
1769 /**
1770 * CtkWidget::size-allocate:
1771 * @widget: the object which received the signal.
1772 * @allocation: (type Ctk.Allocation): the region which has been
1773 * allocated to the widget.
1774 */
1775 widget_signals[SIZE_ALLOCATE] =
1776 g_signal_new (I_("size-allocate")g_intern_static_string ("size-allocate"),
1777 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1778 G_SIGNAL_RUN_FIRST,
1779 G_STRUCT_OFFSET (CtkWidgetClass, size_allocate)((glong) __builtin_offsetof(CtkWidgetClass, size_allocate)),
1780 NULL((void*)0), NULL((void*)0),
1781 NULL((void*)0),
1782 G_TYPE_NONE((GType) ((1) << (2))), 1,
1783 CDK_TYPE_RECTANGLE(cdk_rectangle_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
1784
1785 /**
1786 * CtkWidget::state-changed:
1787 * @widget: the object which received the signal.
1788 * @state: the previous state
1789 *
1790 * The ::state-changed signal is emitted when the widget state changes.
1791 * See ctk_widget_get_state().
1792 */
1793 widget_signals[STATE_CHANGED] =
1794 g_signal_new (I_("state-changed")g_intern_static_string ("state-changed"),
1795 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1796 G_SIGNAL_RUN_FIRST | G_SIGNAL_DEPRECATED,
1797 G_STRUCT_OFFSET (CtkWidgetClass, state_changed)((glong) __builtin_offsetof(CtkWidgetClass, state_changed)),
1798 NULL((void*)0), NULL((void*)0),
1799 NULL((void*)0),
1800 G_TYPE_NONE((GType) ((1) << (2))), 1,
1801 CTK_TYPE_STATE_TYPE(ctk_state_type_get_type ()));
1802
1803 /**
1804 * CtkWidget::state-flags-changed:
1805 * @widget: the object which received the signal.
1806 * @flags: The previous state flags.
1807 *
1808 * The ::state-flags-changed signal is emitted when the widget state
1809 * changes, see ctk_widget_get_state_flags().
1810 *
1811 * Since: 3.0
1812 */
1813 widget_signals[STATE_FLAGS_CHANGED] =
1814 g_signal_new (I_("state-flags-changed")g_intern_static_string ("state-flags-changed"),
1815 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1816 G_SIGNAL_RUN_FIRST,
1817 G_STRUCT_OFFSET (CtkWidgetClass, state_flags_changed)((glong) __builtin_offsetof(CtkWidgetClass, state_flags_changed
))
,
1818 NULL((void*)0), NULL((void*)0),
1819 NULL((void*)0),
1820 G_TYPE_NONE((GType) ((1) << (2))), 1,
1821 CTK_TYPE_STATE_FLAGS(ctk_state_flags_get_type ()));
1822
1823 /**
1824 * CtkWidget::parent-set:
1825 * @widget: the object on which the signal is emitted
1826 * @old_parent: (allow-none): the previous parent, or %NULL if the widget
1827 * just got its initial parent.
1828 *
1829 * The ::parent-set signal is emitted when a new parent
1830 * has been set on a widget.
1831 */
1832 widget_signals[PARENT_SET] =
1833 g_signal_new (I_("parent-set")g_intern_static_string ("parent-set"),
1834 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1835 G_SIGNAL_RUN_FIRST,
1836 G_STRUCT_OFFSET (CtkWidgetClass, parent_set)((glong) __builtin_offsetof(CtkWidgetClass, parent_set)),
1837 NULL((void*)0), NULL((void*)0),
1838 NULL((void*)0),
1839 G_TYPE_NONE((GType) ((1) << (2))), 1,
1840 CTK_TYPE_WIDGET(ctk_widget_get_type ()));
1841
1842 /**
1843 * CtkWidget::hierarchy-changed:
1844 * @widget: the object on which the signal is emitted
1845 * @previous_toplevel: (allow-none): the previous toplevel ancestor, or %NULL
1846 * if the widget was previously unanchored
1847 *
1848 * The ::hierarchy-changed signal is emitted when the
1849 * anchored state of a widget changes. A widget is
1850 * “anchored” when its toplevel
1851 * ancestor is a #CtkWindow. This signal is emitted when
1852 * a widget changes from un-anchored to anchored or vice-versa.
1853 */
1854 widget_signals[HIERARCHY_CHANGED] =
1855 g_signal_new (I_("hierarchy-changed")g_intern_static_string ("hierarchy-changed"),
1856 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1857 G_SIGNAL_RUN_LAST,
1858 G_STRUCT_OFFSET (CtkWidgetClass, hierarchy_changed)((glong) __builtin_offsetof(CtkWidgetClass, hierarchy_changed
))
,
1859 NULL((void*)0), NULL((void*)0),
1860 NULL((void*)0),
1861 G_TYPE_NONE((GType) ((1) << (2))), 1,
1862 CTK_TYPE_WIDGET(ctk_widget_get_type ()));
1863
1864 /**
1865 * CtkWidget::style-set:
1866 * @widget: the object on which the signal is emitted
1867 * @previous_style: (allow-none): the previous style, or %NULL if the widget
1868 * just got its initial style
1869 *
1870 * The ::style-set signal is emitted when a new style has been set
1871 * on a widget. Note that style-modifying functions like
1872 * ctk_widget_modify_base() also cause this signal to be emitted.
1873 *
1874 * Note that this signal is emitted for changes to the deprecated
1875 * #CtkStyle. To track changes to the #CtkStyleContext associated
1876 * with a widget, use the #CtkWidget::style-updated signal.
1877 *
1878 * Deprecated:3.0: Use the #CtkWidget::style-updated signal
1879 */
1880
1881 widget_signals[STYLE_SET] =
1882 g_signal_new (I_("style-set")g_intern_static_string ("style-set"),
1883 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1884 G_SIGNAL_RUN_FIRST | G_SIGNAL_DEPRECATED,
1885 G_STRUCT_OFFSET (CtkWidgetClass, style_set)((glong) __builtin_offsetof(CtkWidgetClass, style_set)),
1886 NULL((void*)0), NULL((void*)0),
1887 NULL((void*)0),
1888 G_TYPE_NONE((GType) ((1) << (2))), 1,
1889 CTK_TYPE_STYLE(ctk_style_get_type ()));
1890
1891 /**
1892 * CtkWidget::style-updated:
1893 * @widget: the object on which the signal is emitted
1894 *
1895 * The ::style-updated signal is a convenience signal that is emitted when the
1896 * #CtkStyleContext::changed signal is emitted on the @widget's associated
1897 * #CtkStyleContext as returned by ctk_widget_get_style_context().
1898 *
1899 * Note that style-modifying functions like ctk_widget_override_color() also
1900 * cause this signal to be emitted.
1901 *
1902 * Since: 3.0
1903 */
1904 widget_signals[STYLE_UPDATED] =
1905 g_signal_new (I_("style-updated")g_intern_static_string ("style-updated"),
1906 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1907 G_SIGNAL_RUN_FIRST,
1908 G_STRUCT_OFFSET (CtkWidgetClass, style_updated)((glong) __builtin_offsetof(CtkWidgetClass, style_updated)),
1909 NULL((void*)0), NULL((void*)0),
1910 NULL((void*)0),
1911 G_TYPE_NONE((GType) ((1) << (2))), 0);
1912
1913 /**
1914 * CtkWidget::direction-changed:
1915 * @widget: the object on which the signal is emitted
1916 * @previous_direction: the previous text direction of @widget
1917 *
1918 * The ::direction-changed signal is emitted when the text direction
1919 * of a widget changes.
1920 */
1921 widget_signals[DIRECTION_CHANGED] =
1922 g_signal_new (I_("direction-changed")g_intern_static_string ("direction-changed"),
1923 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1924 G_SIGNAL_RUN_FIRST,
1925 G_STRUCT_OFFSET (CtkWidgetClass, direction_changed)((glong) __builtin_offsetof(CtkWidgetClass, direction_changed
))
,
1926 NULL((void*)0), NULL((void*)0),
1927 NULL((void*)0),
1928 G_TYPE_NONE((GType) ((1) << (2))), 1,
1929 CTK_TYPE_TEXT_DIRECTION(ctk_text_direction_get_type ()));
1930
1931 /**
1932 * CtkWidget::grab-notify:
1933 * @widget: the object which received the signal
1934 * @was_grabbed: %FALSE if the widget becomes shadowed, %TRUE
1935 * if it becomes unshadowed
1936 *
1937 * The ::grab-notify signal is emitted when a widget becomes
1938 * shadowed by a CTK+ grab (not a pointer or keyboard grab) on
1939 * another widget, or when it becomes unshadowed due to a grab
1940 * being removed.
1941 *
1942 * A widget is shadowed by a ctk_grab_add() when the topmost
1943 * grab widget in the grab stack of its window group is not
1944 * its ancestor.
1945 */
1946 widget_signals[GRAB_NOTIFY] =
1947 g_signal_new (I_("grab-notify")g_intern_static_string ("grab-notify"),
1948 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1949 G_SIGNAL_RUN_FIRST,
1950 G_STRUCT_OFFSET (CtkWidgetClass, grab_notify)((glong) __builtin_offsetof(CtkWidgetClass, grab_notify)),
1951 NULL((void*)0), NULL((void*)0),
1952 NULL((void*)0),
1953 G_TYPE_NONE((GType) ((1) << (2))), 1,
1954 G_TYPE_BOOLEAN((GType) ((5) << (2))));
1955
1956 /**
1957 * CtkWidget::child-notify:
1958 * @widget: the object which received the signal
1959 * @child_property: the #GParamSpec of the changed child property
1960 *
1961 * The ::child-notify signal is emitted for each
1962 * [child property][child-properties] that has
1963 * changed on an object. The signal's detail holds the property name.
1964 */
1965 widget_signals[CHILD_NOTIFY] =
1966 g_signal_new (I_("child-notify")g_intern_static_string ("child-notify"),
1967 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
1968 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
1969 G_STRUCT_OFFSET (CtkWidgetClass, child_notify)((glong) __builtin_offsetof(CtkWidgetClass, child_notify)),
1970 NULL((void*)0), NULL((void*)0),
1971 NULL((void*)0),
1972 G_TYPE_NONE((GType) ((1) << (2))), 1,
1973 G_TYPE_PARAM((GType) ((19) << (2))));
1974
1975 /**
1976 * CtkWidget::draw:
1977 * @widget: the object which received the signal
1978 * @cr: the cairo context to draw to
1979 *
1980 * This signal is emitted when a widget is supposed to render itself.
1981 * The @widget's top left corner must be painted at the origin of
1982 * the passed in context and be sized to the values returned by
1983 * ctk_widget_get_allocated_width() and
1984 * ctk_widget_get_allocated_height().
1985 *
1986 * Signal handlers connected to this signal can modify the cairo
1987 * context passed as @cr in any way they like and don't need to
1988 * restore it. The signal emission takes care of calling cairo_save()
1989 * before and cairo_restore() after invoking the handler.
1990 *
1991 * The signal handler will get a @cr with a clip region already set to the
1992 * widget's dirty region, i.e. to the area that needs repainting. Complicated
1993 * widgets that want to avoid redrawing themselves completely can get the full
1994 * extents of the clip region with cdk_cairo_get_clip_rectangle(), or they can
1995 * get a finer-grained representation of the dirty region with
1996 * cairo_copy_clip_rectangle_list().
1997 *
1998 * Returns: %TRUE to stop other handlers from being invoked for the event.
1999 * %FALSE to propagate the event further.
2000 *
2001 * Since: 3.0
2002 */
2003 widget_signals[DRAW] =
2004 g_signal_new (I_("draw")g_intern_static_string ("draw"),
2005 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
2006 G_SIGNAL_RUN_LAST,
2007 G_STRUCT_OFFSET (CtkWidgetClass, draw)((glong) __builtin_offsetof(CtkWidgetClass, draw)),
2008 _ctk_boolean_handled_accumulator, NULL((void*)0),
2009 ctk_widget_draw_marshaller,
2010 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2011 CAIRO_GOBJECT_TYPE_CONTEXTcairo_gobject_context_get_type ());
2012 g_signal_set_va_marshaller (widget_signals[DRAW], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2013 ctk_widget_draw_marshallerv);
2014
2015 /**
2016 * CtkWidget::mnemonic-activate:
2017 * @widget: the object which received the signal.
2018 * @group_cycling: %TRUE if there are other widgets with the same mnemonic
2019 *
2020 * The default handler for this signal activates @widget if @group_cycling
2021 * is %FALSE, or just makes @widget grab focus if @group_cycling is %TRUE.
2022 *
2023 * Returns: %TRUE to stop other handlers from being invoked for the event.
2024 * %FALSE to propagate the event further.
2025 */
2026 widget_signals[MNEMONIC_ACTIVATE] =
2027 g_signal_new (I_("mnemonic-activate")g_intern_static_string ("mnemonic-activate"),
2028 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
2029 G_SIGNAL_RUN_LAST,
2030 G_STRUCT_OFFSET (CtkWidgetClass, mnemonic_activate)((glong) __builtin_offsetof(CtkWidgetClass, mnemonic_activate
))
,
2031 _ctk_boolean_handled_accumulator, NULL((void*)0),
2032 _ctk_marshal_BOOLEAN__BOOLEAN,
2033 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2034 G_TYPE_BOOLEAN((GType) ((5) << (2))));
2035 g_signal_set_va_marshaller (widget_signals[MNEMONIC_ACTIVATE],
2036 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
2037 _ctk_marshal_BOOLEAN__BOOLEANv);
2038
2039 /**
2040 * CtkWidget::grab-focus:
2041 * @widget: the object which received the signal.
2042 */
2043 widget_signals[GRAB_FOCUS] =
2044 g_signal_new (I_("grab-focus")g_intern_static_string ("grab-focus"),
2045 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
2046 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2047 G_STRUCT_OFFSET (CtkWidgetClass, grab_focus)((glong) __builtin_offsetof(CtkWidgetClass, grab_focus)),
2048 NULL((void*)0), NULL((void*)0),
2049 NULL((void*)0),
2050 G_TYPE_NONE((GType) ((1) << (2))), 0);
2051
2052 /**
2053 * CtkWidget::focus:
2054 * @widget: the object which received the signal.
2055 * @direction:
2056 *
2057 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
2058 */
2059 widget_signals[FOCUS] =
2060 g_signal_new (I_("focus")g_intern_static_string ("focus"),
2061 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2062 G_SIGNAL_RUN_LAST,
2063 G_STRUCT_OFFSET (CtkWidgetClass, focus)((glong) __builtin_offsetof(CtkWidgetClass, focus)),
2064 _ctk_boolean_handled_accumulator, NULL((void*)0),
2065 _ctk_marshal_BOOLEAN__ENUM,
2066 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2067 CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()));
2068 g_signal_set_va_marshaller (widget_signals[FOCUS],
2069 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
2070 _ctk_marshal_BOOLEAN__ENUMv);
2071
2072 /**
2073 * CtkWidget::move-focus:
2074 * @widget: the object which received the signal.
2075 * @direction:
2076 */
2077 widget_signals[MOVE_FOCUS] =
2078 g_signal_new (I_("move-focus")g_intern_static_string ("move-focus"),
2079 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2080 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2081 G_STRUCT_OFFSET (CtkWidgetClass, move_focus)((glong) __builtin_offsetof(CtkWidgetClass, move_focus)),
2082 NULL((void*)0), NULL((void*)0),
2083 NULL((void*)0),
2084 G_TYPE_NONE((GType) ((1) << (2))),
2085 1,
2086 CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()));
2087
2088 /**
2089 * CtkWidget::keynav-failed:
2090 * @widget: the object which received the signal
2091 * @direction: the direction of movement
2092 *
2093 * Gets emitted if keyboard navigation fails.
2094 * See ctk_widget_keynav_failed() for details.
2095 *
2096 * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
2097 * if the emitting widget should try to handle the keyboard
2098 * navigation attempt in its parent container(s).
2099 *
2100 * Since: 2.12
2101 **/
2102 widget_signals[KEYNAV_FAILED] =
2103 g_signal_new (I_("keynav-failed")g_intern_static_string ("keynav-failed"),
2104 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2105 G_SIGNAL_RUN_LAST,
2106 G_STRUCT_OFFSET (CtkWidgetClass, keynav_failed)((glong) __builtin_offsetof(CtkWidgetClass, keynav_failed)),
2107 _ctk_boolean_handled_accumulator, NULL((void*)0),
2108 _ctk_marshal_BOOLEAN__ENUM,
2109 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2110 CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()));
2111 g_signal_set_va_marshaller (widget_signals[KEYNAV_FAILED],
2112 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2113 _ctk_marshal_BOOLEAN__ENUMv);
2114
2115 /**
2116 * CtkWidget::event:
2117 * @widget: the object which received the signal.
2118 * @event: the #CdkEvent which triggered this signal
2119 *
2120 * The CTK+ main loop will emit three signals for each CDK event delivered
2121 * to a widget: one generic ::event signal, another, more specific,
2122 * signal that matches the type of event delivered (e.g.
2123 * #CtkWidget::key-press-event) and finally a generic
2124 * #CtkWidget::event-after signal.
2125 *
2126 * Returns: %TRUE to stop other handlers from being invoked for the event
2127 * and to cancel the emission of the second specific ::event signal.
2128 * %FALSE to propagate the event further and to allow the emission of
2129 * the second signal. The ::event-after signal is emitted regardless of
2130 * the return value.
2131 */
2132 widget_signals[EVENT] =
2133 g_signal_new (I_("event")g_intern_static_string ("event"),
2134 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2135 G_SIGNAL_RUN_LAST,
2136 G_STRUCT_OFFSET (CtkWidgetClass, event)((glong) __builtin_offsetof(CtkWidgetClass, event)),
2137 _ctk_boolean_handled_accumulator, NULL((void*)0),
2138 _ctk_marshal_BOOLEAN__BOXED,
2139 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2140 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2141 g_signal_set_va_marshaller (widget_signals[EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2142 _ctk_marshal_BOOLEAN__BOXEDv);
2143
2144 /**
2145 * CtkWidget::event-after:
2146 * @widget: the object which received the signal.
2147 * @event: the #CdkEvent which triggered this signal
2148 *
2149 * After the emission of the #CtkWidget::event signal and (optionally)
2150 * the second more specific signal, ::event-after will be emitted
2151 * regardless of the previous two signals handlers return values.
2152 *
2153 */
2154 widget_signals[EVENT_AFTER] =
2155 g_signal_new (I_("event-after")g_intern_static_string ("event-after"),
2156 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2157 0,
2158 0,
2159 NULL((void*)0), NULL((void*)0),
2160 NULL((void*)0),
2161 G_TYPE_NONE((GType) ((1) << (2))), 1,
2162 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2163
2164 /**
2165 * CtkWidget::button-press-event:
2166 * @widget: the object which received the signal.
2167 * @event: (type Cdk.EventButton): the #CdkEventButton which triggered
2168 * this signal.
2169 *
2170 * The ::button-press-event signal will be emitted when a button
2171 * (typically from a mouse) is pressed.
2172 *
2173 * To receive this signal, the #CdkWindow associated to the
2174 * widget needs to enable the #CDK_BUTTON_PRESS_MASK mask.
2175 *
2176 * This signal will be sent to the grab widget if there is one.
2177 *
2178 * Returns: %TRUE to stop other handlers from being invoked for the event.
2179 * %FALSE to propagate the event further.
2180 */
2181 widget_signals[BUTTON_PRESS_EVENT] =
2182 g_signal_new (I_("button-press-event")g_intern_static_string ("button-press-event"),
2183 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2184 G_SIGNAL_RUN_LAST,
2185 G_STRUCT_OFFSET (CtkWidgetClass, button_press_event)((glong) __builtin_offsetof(CtkWidgetClass, button_press_event
))
,
2186 _ctk_boolean_handled_accumulator, NULL((void*)0),
2187 _ctk_marshal_BOOLEAN__BOXED,
2188 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2189 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2190 g_signal_set_va_marshaller (widget_signals[BUTTON_PRESS_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2191 _ctk_marshal_BOOLEAN__BOXEDv);
2192
2193 /**
2194 * CtkWidget::button-release-event:
2195 * @widget: the object which received the signal.
2196 * @event: (type Cdk.EventButton): the #CdkEventButton which triggered
2197 * this signal.
2198 *
2199 * The ::button-release-event signal will be emitted when a button
2200 * (typically from a mouse) is released.
2201 *
2202 * To receive this signal, the #CdkWindow associated to the
2203 * widget needs to enable the #CDK_BUTTON_RELEASE_MASK mask.
2204 *
2205 * This signal will be sent to the grab widget if there is one.
2206 *
2207 * Returns: %TRUE to stop other handlers from being invoked for the event.
2208 * %FALSE to propagate the event further.
2209 */
2210 widget_signals[BUTTON_RELEASE_EVENT] =
2211 g_signal_new (I_("button-release-event")g_intern_static_string ("button-release-event"),
2212 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2213 G_SIGNAL_RUN_LAST,
2214 G_STRUCT_OFFSET (CtkWidgetClass, button_release_event)((glong) __builtin_offsetof(CtkWidgetClass, button_release_event
))
,
2215 _ctk_boolean_handled_accumulator, NULL((void*)0),
2216 _ctk_marshal_BOOLEAN__BOXED,
2217 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2218 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2219 g_signal_set_va_marshaller (widget_signals[BUTTON_RELEASE_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2220 _ctk_marshal_BOOLEAN__BOXEDv);
2221
2222 widget_signals[TOUCH_EVENT] =
2223 g_signal_new (I_("touch-event")g_intern_static_string ("touch-event"),
2224 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2225 G_SIGNAL_RUN_LAST,
2226 G_STRUCT_OFFSET (CtkWidgetClass, touch_event)((glong) __builtin_offsetof(CtkWidgetClass, touch_event)),
2227 _ctk_boolean_handled_accumulator, NULL((void*)0),
2228 _ctk_marshal_BOOLEAN__BOXED,
2229 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2230 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2231 g_signal_set_va_marshaller (widget_signals[TOUCH_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2232 _ctk_marshal_BOOLEAN__BOXEDv);
2233
2234 /**
2235 * CtkWidget::scroll-event:
2236 * @widget: the object which received the signal.
2237 * @event: (type Cdk.EventScroll): the #CdkEventScroll which triggered
2238 * this signal.
2239 *
2240 * The ::scroll-event signal is emitted when a button in the 4 to 7
2241 * range is pressed. Wheel mice are usually configured to generate
2242 * button press events for buttons 4 and 5 when the wheel is turned.
2243 *
2244 * To receive this signal, the #CdkWindow associated to the widget needs
2245 * to enable the #CDK_SCROLL_MASK mask.
2246 *
2247 * This signal will be sent to the grab widget if there is one.
2248 *
2249 * Returns: %TRUE to stop other handlers from being invoked for the event.
2250 * %FALSE to propagate the event further.
2251 */
2252 widget_signals[SCROLL_EVENT] =
2253 g_signal_new (I_("scroll-event")g_intern_static_string ("scroll-event"),
2254 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2255 G_SIGNAL_RUN_LAST,
2256 G_STRUCT_OFFSET (CtkWidgetClass, scroll_event)((glong) __builtin_offsetof(CtkWidgetClass, scroll_event)),
2257 _ctk_boolean_handled_accumulator, NULL((void*)0),
2258 _ctk_marshal_BOOLEAN__BOXED,
2259 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2260 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2261 g_signal_set_va_marshaller (widget_signals[SCROLL_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2262 _ctk_marshal_BOOLEAN__BOXEDv);
2263
2264 /**
2265 * CtkWidget::motion-notify-event:
2266 * @widget: the object which received the signal.
2267 * @event: (type Cdk.EventMotion): the #CdkEventMotion which triggered
2268 * this signal.
2269 *
2270 * The ::motion-notify-event signal is emitted when the pointer moves
2271 * over the widget's #CdkWindow.
2272 *
2273 * To receive this signal, the #CdkWindow associated to the widget
2274 * needs to enable the #CDK_POINTER_MOTION_MASK mask.
2275 *
2276 * This signal will be sent to the grab widget if there is one.
2277 *
2278 * Returns: %TRUE to stop other handlers from being invoked for the event.
2279 * %FALSE to propagate the event further.
2280 */
2281 widget_signals[MOTION_NOTIFY_EVENT] =
2282 g_signal_new (I_("motion-notify-event")g_intern_static_string ("motion-notify-event"),
2283 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2284 G_SIGNAL_RUN_LAST,
2285 G_STRUCT_OFFSET (CtkWidgetClass, motion_notify_event)((glong) __builtin_offsetof(CtkWidgetClass, motion_notify_event
))
,
2286 _ctk_boolean_handled_accumulator, NULL((void*)0),
2287 _ctk_marshal_BOOLEAN__BOXED,
2288 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2289 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2290 g_signal_set_va_marshaller (widget_signals[MOTION_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2291 _ctk_marshal_BOOLEAN__BOXEDv);
2292
2293 /**
2294 * CtkWidget::composited-changed:
2295 * @widget: the object on which the signal is emitted
2296 *
2297 * The ::composited-changed signal is emitted when the composited
2298 * status of @widgets screen changes.
2299 * See cdk_screen_is_composited().
2300 *
2301 * Deprecated: 3.22: Use CdkScreen::composited-changed instead.
2302 */
2303 widget_signals[COMPOSITED_CHANGED] =
2304 g_signal_new (I_("composited-changed")g_intern_static_string ("composited-changed"),
2305 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2306 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION | G_SIGNAL_DEPRECATED,
2307 G_STRUCT_OFFSET (CtkWidgetClass, composited_changed)((glong) __builtin_offsetof(CtkWidgetClass, composited_changed
))
,
2308 NULL((void*)0), NULL((void*)0),
2309 NULL((void*)0),
2310 G_TYPE_NONE((GType) ((1) << (2))), 0);
2311
2312 /**
2313 * CtkWidget::delete-event:
2314 * @widget: the object which received the signal
2315 * @event: the event which triggered this signal
2316 *
2317 * The ::delete-event signal is emitted if a user requests that
2318 * a toplevel window is closed. The default handler for this signal
2319 * destroys the window. Connecting ctk_widget_hide_on_delete() to
2320 * this signal will cause the window to be hidden instead, so that
2321 * it can later be shown again without reconstructing it.
2322 *
2323 * Returns: %TRUE to stop other handlers from being invoked for the event.
2324 * %FALSE to propagate the event further.
2325 */
2326 widget_signals[DELETE_EVENT] =
2327 g_signal_new (I_("delete-event")g_intern_static_string ("delete-event"),
2328 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2329 G_SIGNAL_RUN_LAST,
2330 G_STRUCT_OFFSET (CtkWidgetClass, delete_event)((glong) __builtin_offsetof(CtkWidgetClass, delete_event)),
2331 _ctk_boolean_handled_accumulator, NULL((void*)0),
2332 _ctk_marshal_BOOLEAN__BOXED,
2333 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2334 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2335 g_signal_set_va_marshaller (widget_signals[DELETE_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2336 _ctk_marshal_BOOLEAN__BOXEDv);
2337
2338 /**
2339 * CtkWidget::destroy-event:
2340 * @widget: the object which received the signal.
2341 * @event: the event which triggered this signal
2342 *
2343 * The ::destroy-event signal is emitted when a #CdkWindow is destroyed.
2344 * You rarely get this signal, because most widgets disconnect themselves
2345 * from their window before they destroy it, so no widget owns the
2346 * window at destroy time.
2347 *
2348 * To receive this signal, the #CdkWindow associated to the widget needs
2349 * to enable the #CDK_STRUCTURE_MASK mask. CDK will enable this mask
2350 * automatically for all new windows.
2351 *
2352 * Returns: %TRUE to stop other handlers from being invoked for the event.
2353 * %FALSE to propagate the event further.
2354 */
2355 widget_signals[DESTROY_EVENT] =
2356 g_signal_new (I_("destroy-event")g_intern_static_string ("destroy-event"),
2357 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2358 G_SIGNAL_RUN_LAST,
2359 G_STRUCT_OFFSET (CtkWidgetClass, destroy_event)((glong) __builtin_offsetof(CtkWidgetClass, destroy_event)),
2360 _ctk_boolean_handled_accumulator, NULL((void*)0),
2361 _ctk_marshal_BOOLEAN__BOXED,
2362 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2363 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2364 g_signal_set_va_marshaller (widget_signals[DESTROY_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2365 _ctk_marshal_BOOLEAN__BOXEDv);
2366
2367 /**
2368 * CtkWidget::key-press-event:
2369 * @widget: the object which received the signal
2370 * @event: (type Cdk.EventKey): the #CdkEventKey which triggered this signal.
2371 *
2372 * The ::key-press-event signal is emitted when a key is pressed. The signal
2373 * emission will reoccur at the key-repeat rate when the key is kept pressed.
2374 *
2375 * To receive this signal, the #CdkWindow associated to the widget needs
2376 * to enable the #CDK_KEY_PRESS_MASK mask.
2377 *
2378 * This signal will be sent to the grab widget if there is one.
2379 *
2380 * Returns: %TRUE to stop other handlers from being invoked for the event.
2381 * %FALSE to propagate the event further.
2382 */
2383 widget_signals[KEY_PRESS_EVENT] =
2384 g_signal_new (I_("key-press-event")g_intern_static_string ("key-press-event"),
2385 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2386 G_SIGNAL_RUN_LAST,
2387 G_STRUCT_OFFSET (CtkWidgetClass, key_press_event)((glong) __builtin_offsetof(CtkWidgetClass, key_press_event)),
2388 _ctk_boolean_handled_accumulator, NULL((void*)0),
2389 _ctk_marshal_BOOLEAN__BOXED,
2390 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2391 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2392 g_signal_set_va_marshaller (widget_signals[KEY_PRESS_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2393 _ctk_marshal_BOOLEAN__BOXEDv);
2394
2395 /**
2396 * CtkWidget::key-release-event:
2397 * @widget: the object which received the signal
2398 * @event: (type Cdk.EventKey): the #CdkEventKey which triggered this signal.
2399 *
2400 * The ::key-release-event signal is emitted when a key is released.
2401 *
2402 * To receive this signal, the #CdkWindow associated to the widget needs
2403 * to enable the #CDK_KEY_RELEASE_MASK mask.
2404 *
2405 * This signal will be sent to the grab widget if there is one.
2406 *
2407 * Returns: %TRUE to stop other handlers from being invoked for the event.
2408 * %FALSE to propagate the event further.
2409 */
2410 widget_signals[KEY_RELEASE_EVENT] =
2411 g_signal_new (I_("key-release-event")g_intern_static_string ("key-release-event"),
2412 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2413 G_SIGNAL_RUN_LAST,
2414 G_STRUCT_OFFSET (CtkWidgetClass, key_release_event)((glong) __builtin_offsetof(CtkWidgetClass, key_release_event
))
,
2415 _ctk_boolean_handled_accumulator, NULL((void*)0),
2416 _ctk_marshal_BOOLEAN__BOXED,
2417 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2418 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2419 g_signal_set_va_marshaller (widget_signals[KEY_RELEASE_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2420 _ctk_marshal_BOOLEAN__BOXEDv);
2421
2422 /**
2423 * CtkWidget::enter-notify-event:
2424 * @widget: the object which received the signal
2425 * @event: (type Cdk.EventCrossing): the #CdkEventCrossing which triggered
2426 * this signal.
2427 *
2428 * The ::enter-notify-event will be emitted when the pointer enters
2429 * the @widget's window.
2430 *
2431 * To receive this signal, the #CdkWindow associated to the widget needs
2432 * to enable the #CDK_ENTER_NOTIFY_MASK mask.
2433 *
2434 * This signal will be sent to the grab widget if there is one.
2435 *
2436 * Returns: %TRUE to stop other handlers from being invoked for the event.
2437 * %FALSE to propagate the event further.
2438 */
2439 widget_signals[ENTER_NOTIFY_EVENT] =
2440 g_signal_new (I_("enter-notify-event")g_intern_static_string ("enter-notify-event"),
2441 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2442 G_SIGNAL_RUN_LAST,
2443 G_STRUCT_OFFSET (CtkWidgetClass, enter_notify_event)((glong) __builtin_offsetof(CtkWidgetClass, enter_notify_event
))
,
2444 _ctk_boolean_handled_accumulator, NULL((void*)0),
2445 _ctk_marshal_BOOLEAN__BOXED,
2446 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2447 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2448 g_signal_set_va_marshaller (widget_signals[ENTER_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2449 _ctk_marshal_BOOLEAN__BOXEDv);
2450
2451 /**
2452 * CtkWidget::leave-notify-event:
2453 * @widget: the object which received the signal
2454 * @event: (type Cdk.EventCrossing): the #CdkEventCrossing which triggered
2455 * this signal.
2456 *
2457 * The ::leave-notify-event will be emitted when the pointer leaves
2458 * the @widget's window.
2459 *
2460 * To receive this signal, the #CdkWindow associated to the widget needs
2461 * to enable the #CDK_LEAVE_NOTIFY_MASK mask.
2462 *
2463 * This signal will be sent to the grab widget if there is one.
2464 *
2465 * Returns: %TRUE to stop other handlers from being invoked for the event.
2466 * %FALSE to propagate the event further.
2467 */
2468 widget_signals[LEAVE_NOTIFY_EVENT] =
2469 g_signal_new (I_("leave-notify-event")g_intern_static_string ("leave-notify-event"),
2470 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2471 G_SIGNAL_RUN_LAST,
2472 G_STRUCT_OFFSET (CtkWidgetClass, leave_notify_event)((glong) __builtin_offsetof(CtkWidgetClass, leave_notify_event
))
,
2473 _ctk_boolean_handled_accumulator, NULL((void*)0),
2474 _ctk_marshal_BOOLEAN__BOXED,
2475 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2476 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2477 g_signal_set_va_marshaller (widget_signals[LEAVE_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2478 _ctk_marshal_BOOLEAN__BOXEDv);
2479
2480 /**
2481 * CtkWidget::configure-event:
2482 * @widget: the object which received the signal
2483 * @event: (type Cdk.EventConfigure): the #CdkEventConfigure which triggered
2484 * this signal.
2485 *
2486 * The ::configure-event signal will be emitted when the size, position or
2487 * stacking of the @widget's window has changed.
2488 *
2489 * To receive this signal, the #CdkWindow associated to the widget needs
2490 * to enable the #CDK_STRUCTURE_MASK mask. CDK will enable this mask
2491 * automatically for all new windows.
2492 *
2493 * Returns: %TRUE to stop other handlers from being invoked for the event.
2494 * %FALSE to propagate the event further.
2495 */
2496 widget_signals[CONFIGURE_EVENT] =
2497 g_signal_new (I_("configure-event")g_intern_static_string ("configure-event"),
2498 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2499 G_SIGNAL_RUN_LAST,
2500 G_STRUCT_OFFSET (CtkWidgetClass, configure_event)((glong) __builtin_offsetof(CtkWidgetClass, configure_event)),
2501 _ctk_boolean_handled_accumulator, NULL((void*)0),
2502 _ctk_marshal_BOOLEAN__BOXED,
2503 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2504 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2505 g_signal_set_va_marshaller (widget_signals[CONFIGURE_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2506 _ctk_marshal_BOOLEAN__BOXEDv);
2507
2508 /**
2509 * CtkWidget::focus-in-event:
2510 * @widget: the object which received the signal
2511 * @event: (type Cdk.EventFocus): the #CdkEventFocus which triggered
2512 * this signal.
2513 *
2514 * The ::focus-in-event signal will be emitted when the keyboard focus
2515 * enters the @widget's window.
2516 *
2517 * To receive this signal, the #CdkWindow associated to the widget needs
2518 * to enable the #CDK_FOCUS_CHANGE_MASK mask.
2519 *
2520 * Returns: %TRUE to stop other handlers from being invoked for the event.
2521 * %FALSE to propagate the event further.
2522 */
2523 widget_signals[FOCUS_IN_EVENT] =
2524 g_signal_new (I_("focus-in-event")g_intern_static_string ("focus-in-event"),
2525 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2526 G_SIGNAL_RUN_LAST,
2527 G_STRUCT_OFFSET (CtkWidgetClass, focus_in_event)((glong) __builtin_offsetof(CtkWidgetClass, focus_in_event)),
2528 _ctk_boolean_handled_accumulator, NULL((void*)0),
2529 _ctk_marshal_BOOLEAN__BOXED,
2530 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2531 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2532 g_signal_set_va_marshaller (widget_signals[FOCUS_IN_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2533 _ctk_marshal_BOOLEAN__BOXEDv);
2534
2535 /**
2536 * CtkWidget::focus-out-event:
2537 * @widget: the object which received the signal
2538 * @event: (type Cdk.EventFocus): the #CdkEventFocus which triggered this
2539 * signal.
2540 *
2541 * The ::focus-out-event signal will be emitted when the keyboard focus
2542 * leaves the @widget's window.
2543 *
2544 * To receive this signal, the #CdkWindow associated to the widget needs
2545 * to enable the #CDK_FOCUS_CHANGE_MASK mask.
2546 *
2547 * Returns: %TRUE to stop other handlers from being invoked for the event.
2548 * %FALSE to propagate the event further.
2549 */
2550 widget_signals[FOCUS_OUT_EVENT] =
2551 g_signal_new (I_("focus-out-event")g_intern_static_string ("focus-out-event"),
2552 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2553 G_SIGNAL_RUN_LAST,
2554 G_STRUCT_OFFSET (CtkWidgetClass, focus_out_event)((glong) __builtin_offsetof(CtkWidgetClass, focus_out_event)),
2555 _ctk_boolean_handled_accumulator, NULL((void*)0),
2556 _ctk_marshal_BOOLEAN__BOXED,
2557 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2558 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2559 g_signal_set_va_marshaller (widget_signals[FOCUS_OUT_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2560 _ctk_marshal_BOOLEAN__BOXEDv);
2561
2562 /**
2563 * CtkWidget::map-event:
2564 * @widget: the object which received the signal
2565 * @event: (type Cdk.EventAny): the #CdkEventAny which triggered this signal.
2566 *
2567 * The ::map-event signal will be emitted when the @widget's window is
2568 * mapped. A window is mapped when it becomes visible on the screen.
2569 *
2570 * To receive this signal, the #CdkWindow associated to the widget needs
2571 * to enable the #CDK_STRUCTURE_MASK mask. CDK will enable this mask
2572 * automatically for all new windows.
2573 *
2574 * Returns: %TRUE to stop other handlers from being invoked for the event.
2575 * %FALSE to propagate the event further.
2576 */
2577 widget_signals[MAP_EVENT] =
2578 g_signal_new (I_("map-event")g_intern_static_string ("map-event"),
2579 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2580 G_SIGNAL_RUN_LAST,
2581 G_STRUCT_OFFSET (CtkWidgetClass, map_event)((glong) __builtin_offsetof(CtkWidgetClass, map_event)),
2582 _ctk_boolean_handled_accumulator, NULL((void*)0),
2583 _ctk_marshal_BOOLEAN__BOXED,
2584 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2585 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2586 g_signal_set_va_marshaller (widget_signals[MAP_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2587 _ctk_marshal_BOOLEAN__BOXEDv);
2588
2589 /**
2590 * CtkWidget::unmap-event:
2591 * @widget: the object which received the signal
2592 * @event: (type Cdk.EventAny): the #CdkEventAny which triggered this signal
2593 *
2594 * The ::unmap-event signal will be emitted when the @widget's window is
2595 * unmapped. A window is unmapped when it becomes invisible on the screen.
2596 *
2597 * To receive this signal, the #CdkWindow associated to the widget needs
2598 * to enable the #CDK_STRUCTURE_MASK mask. CDK will enable this mask
2599 * automatically for all new windows.
2600 *
2601 * Returns: %TRUE to stop other handlers from being invoked for the event.
2602 * %FALSE to propagate the event further.
2603 */
2604 widget_signals[UNMAP_EVENT] =
2605 g_signal_new (I_("unmap-event")g_intern_static_string ("unmap-event"),
2606 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2607 G_SIGNAL_RUN_LAST,
2608 G_STRUCT_OFFSET (CtkWidgetClass, unmap_event)((glong) __builtin_offsetof(CtkWidgetClass, unmap_event)),
2609 _ctk_boolean_handled_accumulator, NULL((void*)0),
2610 _ctk_marshal_BOOLEAN__BOXED,
2611 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2612 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2613 g_signal_set_va_marshaller (widget_signals[UNMAP_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2614 _ctk_marshal_BOOLEAN__BOXEDv);
2615
2616 /**
2617 * CtkWidget::property-notify-event:
2618 * @widget: the object which received the signal
2619 * @event: (type Cdk.EventProperty): the #CdkEventProperty which triggered
2620 * this signal.
2621 *
2622 * The ::property-notify-event signal will be emitted when a property on
2623 * the @widget's window has been changed or deleted.
2624 *
2625 * To receive this signal, the #CdkWindow associated to the widget needs
2626 * to enable the #CDK_PROPERTY_CHANGE_MASK mask.
2627 *
2628 * Returns: %TRUE to stop other handlers from being invoked for the event.
2629 * %FALSE to propagate the event further.
2630 */
2631 widget_signals[PROPERTY_NOTIFY_EVENT] =
2632 g_signal_new (I_("property-notify-event")g_intern_static_string ("property-notify-event"),
2633 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2634 G_SIGNAL_RUN_LAST,
2635 G_STRUCT_OFFSET (CtkWidgetClass, property_notify_event)((glong) __builtin_offsetof(CtkWidgetClass, property_notify_event
))
,
2636 _ctk_boolean_handled_accumulator, NULL((void*)0),
2637 _ctk_marshal_BOOLEAN__BOXED,
2638 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2639 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2640 g_signal_set_va_marshaller (widget_signals[PROPERTY_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2641 _ctk_marshal_BOOLEAN__BOXEDv);
2642
2643 /**
2644 * CtkWidget::selection-clear-event:
2645 * @widget: the object which received the signal
2646 * @event: (type Cdk.EventSelection): the #CdkEventSelection which triggered
2647 * this signal.
2648 *
2649 * The ::selection-clear-event signal will be emitted when the
2650 * the @widget's window has lost ownership of a selection.
2651 *
2652 * Returns: %TRUE to stop other handlers from being invoked for the event.
2653 * %FALSE to propagate the event further.
2654 */
2655 widget_signals[SELECTION_CLEAR_EVENT] =
2656 g_signal_new (I_("selection-clear-event")g_intern_static_string ("selection-clear-event"),
2657 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2658 G_SIGNAL_RUN_LAST,
2659 G_STRUCT_OFFSET (CtkWidgetClass, selection_clear_event)((glong) __builtin_offsetof(CtkWidgetClass, selection_clear_event
))
,
2660 _ctk_boolean_handled_accumulator, NULL((void*)0),
2661 _ctk_marshal_BOOLEAN__BOXED,
2662 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2663 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2664 g_signal_set_va_marshaller (widget_signals[SELECTION_CLEAR_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2665 _ctk_marshal_BOOLEAN__BOXEDv);
2666
2667 /**
2668 * CtkWidget::selection-request-event:
2669 * @widget: the object which received the signal
2670 * @event: (type Cdk.EventSelection): the #CdkEventSelection which triggered
2671 * this signal.
2672 *
2673 * The ::selection-request-event signal will be emitted when
2674 * another client requests ownership of the selection owned by
2675 * the @widget's window.
2676 *
2677 * Returns: %TRUE to stop other handlers from being invoked for the event.
2678 * %FALSE to propagate the event further.
2679 */
2680 widget_signals[SELECTION_REQUEST_EVENT] =
2681 g_signal_new (I_("selection-request-event")g_intern_static_string ("selection-request-event"),
2682 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2683 G_SIGNAL_RUN_LAST,
2684 G_STRUCT_OFFSET (CtkWidgetClass, selection_request_event)((glong) __builtin_offsetof(CtkWidgetClass, selection_request_event
))
,
2685 _ctk_boolean_handled_accumulator, NULL((void*)0),
2686 _ctk_marshal_BOOLEAN__BOXED,
2687 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2688 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2689 g_signal_set_va_marshaller (widget_signals[SELECTION_REQUEST_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2690 _ctk_marshal_BOOLEAN__BOXEDv);
2691
2692 /**
2693 * CtkWidget::selection-notify-event:
2694 * @widget: the object which received the signal.
2695 * @event: (type Cdk.EventSelection):
2696 *
2697 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
2698 */
2699 widget_signals[SELECTION_NOTIFY_EVENT] =
2700 g_signal_new (I_("selection-notify-event")g_intern_static_string ("selection-notify-event"),
2701 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2702 G_SIGNAL_RUN_LAST,
2703 G_STRUCT_OFFSET (CtkWidgetClass, selection_notify_event)((glong) __builtin_offsetof(CtkWidgetClass, selection_notify_event
))
,
2704 _ctk_boolean_handled_accumulator, NULL((void*)0),
2705 _ctk_marshal_BOOLEAN__BOXED,
2706 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2707 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2708 g_signal_set_va_marshaller (widget_signals[SELECTION_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2709 _ctk_marshal_BOOLEAN__BOXEDv);
2710
2711 /**
2712 * CtkWidget::selection-received:
2713 * @widget: the object which received the signal.
2714 * @data:
2715 * @time:
2716 */
2717 widget_signals[SELECTION_RECEIVED] =
2718 g_signal_new (I_("selection-received")g_intern_static_string ("selection-received"),
2719 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2720 G_SIGNAL_RUN_LAST,
2721 G_STRUCT_OFFSET (CtkWidgetClass, selection_received)((glong) __builtin_offsetof(CtkWidgetClass, selection_received
))
,
2722 NULL((void*)0), NULL((void*)0),
2723 _ctk_marshal_VOID__BOXED_UINT,
2724 G_TYPE_NONE((GType) ((1) << (2))), 2,
2725 CTK_TYPE_SELECTION_DATA(ctk_selection_data_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))),
2726 G_TYPE_UINT((GType) ((7) << (2))));
2727 g_signal_set_va_marshaller (widget_signals[SELECTION_RECEIVED],
2728 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2729 _ctk_marshal_VOID__BOXED_UINTv);
2730
2731 /**
2732 * CtkWidget::selection-get:
2733 * @widget: the object which received the signal.
2734 * @data:
2735 * @info:
2736 * @time:
2737 */
2738 widget_signals[SELECTION_GET] =
2739 g_signal_new (I_("selection-get")g_intern_static_string ("selection-get"),
2740 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2741 G_SIGNAL_RUN_LAST,
2742 G_STRUCT_OFFSET (CtkWidgetClass, selection_get)((glong) __builtin_offsetof(CtkWidgetClass, selection_get)),
2743 NULL((void*)0), NULL((void*)0),
2744 _ctk_marshal_VOID__BOXED_UINT_UINT,
2745 G_TYPE_NONE((GType) ((1) << (2))), 3,
2746 CTK_TYPE_SELECTION_DATA(ctk_selection_data_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))),
2747 G_TYPE_UINT((GType) ((7) << (2))),
2748 G_TYPE_UINT((GType) ((7) << (2))));
2749 g_signal_set_va_marshaller (widget_signals[SELECTION_GET],
2750 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2751 _ctk_marshal_VOID__BOXED_UINT_UINTv);
2752
2753 /**
2754 * CtkWidget::proximity-in-event:
2755 * @widget: the object which received the signal
2756 * @event: (type Cdk.EventProximity): the #CdkEventProximity which triggered
2757 * this signal.
2758 *
2759 * To receive this signal the #CdkWindow associated to the widget needs
2760 * to enable the #CDK_PROXIMITY_IN_MASK mask.
2761 *
2762 * This signal will be sent to the grab widget if there is one.
2763 *
2764 * Returns: %TRUE to stop other handlers from being invoked for the event.
2765 * %FALSE to propagate the event further.
2766 */
2767 widget_signals[PROXIMITY_IN_EVENT] =
2768 g_signal_new (I_("proximity-in-event")g_intern_static_string ("proximity-in-event"),
2769 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2770 G_SIGNAL_RUN_LAST,
2771 G_STRUCT_OFFSET (CtkWidgetClass, proximity_in_event)((glong) __builtin_offsetof(CtkWidgetClass, proximity_in_event
))
,
2772 _ctk_boolean_handled_accumulator, NULL((void*)0),
2773 _ctk_marshal_BOOLEAN__BOXED,
2774 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2775 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2776 g_signal_set_va_marshaller (widget_signals[PROXIMITY_IN_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2777 _ctk_marshal_BOOLEAN__BOXEDv);
2778
2779 /**
2780 * CtkWidget::proximity-out-event:
2781 * @widget: the object which received the signal
2782 * @event: (type Cdk.EventProximity): the #CdkEventProximity which triggered
2783 * this signal.
2784 *
2785 * To receive this signal the #CdkWindow associated to the widget needs
2786 * to enable the #CDK_PROXIMITY_OUT_MASK mask.
2787 *
2788 * This signal will be sent to the grab widget if there is one.
2789 *
2790 * Returns: %TRUE to stop other handlers from being invoked for the event.
2791 * %FALSE to propagate the event further.
2792 */
2793 widget_signals[PROXIMITY_OUT_EVENT] =
2794 g_signal_new (I_("proximity-out-event")g_intern_static_string ("proximity-out-event"),
2795 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2796 G_SIGNAL_RUN_LAST,
2797 G_STRUCT_OFFSET (CtkWidgetClass, proximity_out_event)((glong) __builtin_offsetof(CtkWidgetClass, proximity_out_event
))
,
2798 _ctk_boolean_handled_accumulator, NULL((void*)0),
2799 _ctk_marshal_BOOLEAN__BOXED,
2800 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
2801 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
2802 g_signal_set_va_marshaller (widget_signals[PROXIMITY_OUT_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2803 _ctk_marshal_BOOLEAN__BOXEDv);
2804
2805 /**
2806 * CtkWidget::drag-leave:
2807 * @widget: the object which received the signal.
2808 * @context: the drag context
2809 * @time: the timestamp of the motion event
2810 *
2811 * The ::drag-leave signal is emitted on the drop site when the cursor
2812 * leaves the widget. A typical reason to connect to this signal is to
2813 * undo things done in #CtkWidget::drag-motion, e.g. undo highlighting
2814 * with ctk_drag_unhighlight().
2815 *
2816 *
2817 * Likewise, the #CtkWidget::drag-leave signal is also emitted before the
2818 * ::drag-drop signal, for instance to allow cleaning up of a preview item
2819 * created in the #CtkWidget::drag-motion signal handler.
2820 */
2821 widget_signals[DRAG_LEAVE] =
2822 g_signal_new (I_("drag-leave")g_intern_static_string ("drag-leave"),
2823 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2824 G_SIGNAL_RUN_LAST,
2825 G_STRUCT_OFFSET (CtkWidgetClass, drag_leave)((glong) __builtin_offsetof(CtkWidgetClass, drag_leave)),
2826 NULL((void*)0), NULL((void*)0),
2827 _ctk_marshal_VOID__OBJECT_UINT,
2828 G_TYPE_NONE((GType) ((1) << (2))), 2,
2829 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()),
2830 G_TYPE_UINT((GType) ((7) << (2))));
2831 g_signal_set_va_marshaller (widget_signals[DRAG_LEAVE],
2832 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2833 _ctk_marshal_VOID__OBJECT_UINTv);
2834
2835 /**
2836 * CtkWidget::drag-begin:
2837 * @widget: the object which received the signal
2838 * @context: the drag context
2839 *
2840 * The ::drag-begin signal is emitted on the drag source when a drag is
2841 * started. A typical reason to connect to this signal is to set up a
2842 * custom drag icon with e.g. ctk_drag_source_set_icon_pixbuf().
2843 *
2844 * Note that some widgets set up a drag icon in the default handler of
2845 * this signal, so you may have to use g_signal_connect_after() to
2846 * override what the default handler did.
2847 */
2848 widget_signals[DRAG_BEGIN] =
2849 g_signal_new (I_("drag-begin")g_intern_static_string ("drag-begin"),
2850 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2851 G_SIGNAL_RUN_LAST,
2852 G_STRUCT_OFFSET (CtkWidgetClass, drag_begin)((glong) __builtin_offsetof(CtkWidgetClass, drag_begin)),
2853 NULL((void*)0), NULL((void*)0),
2854 NULL((void*)0),
2855 G_TYPE_NONE((GType) ((1) << (2))), 1,
2856 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()));
2857
2858 /**
2859 * CtkWidget::drag-end:
2860 * @widget: the object which received the signal
2861 * @context: the drag context
2862 *
2863 * The ::drag-end signal is emitted on the drag source when a drag is
2864 * finished. A typical reason to connect to this signal is to undo
2865 * things done in #CtkWidget::drag-begin.
2866 */
2867 widget_signals[DRAG_END] =
2868 g_signal_new (I_("drag-end")g_intern_static_string ("drag-end"),
2869 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2870 G_SIGNAL_RUN_LAST,
2871 G_STRUCT_OFFSET (CtkWidgetClass, drag_end)((glong) __builtin_offsetof(CtkWidgetClass, drag_end)),
2872 NULL((void*)0), NULL((void*)0),
2873 NULL((void*)0),
2874 G_TYPE_NONE((GType) ((1) << (2))), 1,
2875 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()));
2876
2877 /**
2878 * CtkWidget::drag-data-delete:
2879 * @widget: the object which received the signal
2880 * @context: the drag context
2881 *
2882 * The ::drag-data-delete signal is emitted on the drag source when a drag
2883 * with the action %CDK_ACTION_MOVE is successfully completed. The signal
2884 * handler is responsible for deleting the data that has been dropped. What
2885 * "delete" means depends on the context of the drag operation.
2886 */
2887 widget_signals[DRAG_DATA_DELETE] =
2888 g_signal_new (I_("drag-data-delete")g_intern_static_string ("drag-data-delete"),
2889 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2890 G_SIGNAL_RUN_LAST,
2891 G_STRUCT_OFFSET (CtkWidgetClass, drag_data_delete)((glong) __builtin_offsetof(CtkWidgetClass, drag_data_delete)
)
,
2892 NULL((void*)0), NULL((void*)0),
2893 NULL((void*)0),
2894 G_TYPE_NONE((GType) ((1) << (2))), 1,
2895 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()));
2896
2897 /**
2898 * CtkWidget::drag-failed:
2899 * @widget: the object which received the signal
2900 * @context: the drag context
2901 * @result: the result of the drag operation
2902 *
2903 * The ::drag-failed signal is emitted on the drag source when a drag has
2904 * failed. The signal handler may hook custom code to handle a failed DnD
2905 * operation based on the type of error, it returns %TRUE is the failure has
2906 * been already handled (not showing the default "drag operation failed"
2907 * animation), otherwise it returns %FALSE.
2908 *
2909 * Returns: %TRUE if the failed drag operation has been already handled.
2910 *
2911 * Since: 2.12
2912 */
2913 widget_signals[DRAG_FAILED] =
2914 g_signal_new (I_("drag-failed")g_intern_static_string ("drag-failed"),
2915 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2916 G_SIGNAL_RUN_LAST,
2917 G_STRUCT_OFFSET (CtkWidgetClass, drag_failed)((glong) __builtin_offsetof(CtkWidgetClass, drag_failed)),
2918 _ctk_boolean_handled_accumulator, NULL((void*)0),
2919 _ctk_marshal_BOOLEAN__OBJECT_ENUM,
2920 G_TYPE_BOOLEAN((GType) ((5) << (2))), 2,
2921 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()),
2922 CTK_TYPE_DRAG_RESULT(ctk_drag_result_get_type ()));
2923 g_signal_set_va_marshaller (widget_signals[DRAG_FAILED],
2924 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2925 _ctk_marshal_BOOLEAN__OBJECT_ENUMv);
2926
2927 /**
2928 * CtkWidget::drag-motion:
2929 * @widget: the object which received the signal
2930 * @context: the drag context
2931 * @x: the x coordinate of the current cursor position
2932 * @y: the y coordinate of the current cursor position
2933 * @time: the timestamp of the motion event
2934 *
2935 * The ::drag-motion signal is emitted on the drop site when the user
2936 * moves the cursor over the widget during a drag. The signal handler
2937 * must determine whether the cursor position is in a drop zone or not.
2938 * If it is not in a drop zone, it returns %FALSE and no further processing
2939 * is necessary. Otherwise, the handler returns %TRUE. In this case, the
2940 * handler is responsible for providing the necessary information for
2941 * displaying feedback to the user, by calling cdk_drag_status().
2942 *
2943 * If the decision whether the drop will be accepted or rejected can't be
2944 * made based solely on the cursor position and the type of the data, the
2945 * handler may inspect the dragged data by calling ctk_drag_get_data() and
2946 * defer the cdk_drag_status() call to the #CtkWidget::drag-data-received
2947 * handler. Note that you must pass #CTK_DEST_DEFAULT_DROP,
2948 * #CTK_DEST_DEFAULT_MOTION or #CTK_DEST_DEFAULT_ALL to ctk_drag_dest_set()
2949 * when using the drag-motion signal that way.
2950 *
2951 * Also note that there is no drag-enter signal. The drag receiver has to
2952 * keep track of whether he has received any drag-motion signals since the
2953 * last #CtkWidget::drag-leave and if not, treat the drag-motion signal as
2954 * an "enter" signal. Upon an "enter", the handler will typically highlight
2955 * the drop site with ctk_drag_highlight().
2956 * |[<!-- language="C" -->
2957 * static void
2958 * drag_motion (CtkWidget *widget,
2959 * CdkDragContext *context,
2960 * gint x,
2961 * gint y,
2962 * guint time)
2963 * {
2964 * CdkAtom target;
2965 *
2966 * PrivateData *private_data = GET_PRIVATE_DATA (widget);
2967 *
2968 * if (!private_data->drag_highlight)
2969 * {
2970 * private_data->drag_highlight = 1;
2971 * ctk_drag_highlight (widget);
2972 * }
2973 *
2974 * target = ctk_drag_dest_find_target (widget, context, NULL);
2975 * if (target == CDK_NONE)
2976 * cdk_drag_status (context, 0, time);
2977 * else
2978 * {
2979 * private_data->pending_status
2980 * = cdk_drag_context_get_suggested_action (context);
2981 * ctk_drag_get_data (widget, context, target, time);
2982 * }
2983 *
2984 * return TRUE;
2985 * }
2986 *
2987 * static void
2988 * drag_data_received (CtkWidget *widget,
2989 * CdkDragContext *context,
2990 * gint x,
2991 * gint y,
2992 * CtkSelectionData *selection_data,
2993 * guint info,
2994 * guint time)
2995 * {
2996 * PrivateData *private_data = GET_PRIVATE_DATA (widget);
2997 *
2998 * if (private_data->suggested_action)
2999 * {
3000 * private_data->suggested_action = 0;
3001 *
3002 * // We are getting this data due to a request in drag_motion,
3003 * // rather than due to a request in drag_drop, so we are just
3004 * // supposed to call cdk_drag_status(), not actually paste in
3005 * // the data.
3006 *
3007 * str = ctk_selection_data_get_text (selection_data);
3008 * if (!data_is_acceptable (str))
3009 * cdk_drag_status (context, 0, time);
3010 * else
3011 * cdk_drag_status (context,
3012 * private_data->suggested_action,
3013 * time);
3014 * }
3015 * else
3016 * {
3017 * // accept the drop
3018 * }
3019 * }
3020 * ]|
3021 *
3022 * Returns: whether the cursor position is in a drop zone
3023 */
3024 widget_signals[DRAG_MOTION] =
3025 g_signal_new (I_("drag-motion")g_intern_static_string ("drag-motion"),
3026 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3027 G_SIGNAL_RUN_LAST,
3028 G_STRUCT_OFFSET (CtkWidgetClass, drag_motion)((glong) __builtin_offsetof(CtkWidgetClass, drag_motion)),
3029 _ctk_boolean_handled_accumulator, NULL((void*)0),
3030 _ctk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
3031 G_TYPE_BOOLEAN((GType) ((5) << (2))), 4,
3032 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()),
3033 G_TYPE_INT((GType) ((6) << (2))),
3034 G_TYPE_INT((GType) ((6) << (2))),
3035 G_TYPE_UINT((GType) ((7) << (2))));
3036 g_signal_set_va_marshaller (widget_signals[DRAG_MOTION],
3037 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3038 _ctk_marshal_BOOLEAN__OBJECT_INT_INT_UINTv);
3039
3040 /**
3041 * CtkWidget::drag-drop:
3042 * @widget: the object which received the signal
3043 * @context: the drag context
3044 * @x: the x coordinate of the current cursor position
3045 * @y: the y coordinate of the current cursor position
3046 * @time: the timestamp of the motion event
3047 *
3048 * The ::drag-drop signal is emitted on the drop site when the user drops
3049 * the data onto the widget. The signal handler must determine whether
3050 * the cursor position is in a drop zone or not. If it is not in a drop
3051 * zone, it returns %FALSE and no further processing is necessary.
3052 * Otherwise, the handler returns %TRUE. In this case, the handler must
3053 * ensure that ctk_drag_finish() is called to let the source know that
3054 * the drop is done. The call to ctk_drag_finish() can be done either
3055 * directly or in a #CtkWidget::drag-data-received handler which gets
3056 * triggered by calling ctk_drag_get_data() to receive the data for one
3057 * or more of the supported targets.
3058 *
3059 * Returns: whether the cursor position is in a drop zone
3060 */
3061 widget_signals[DRAG_DROP] =
3062 g_signal_new (I_("drag-drop")g_intern_static_string ("drag-drop"),
3063 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3064 G_SIGNAL_RUN_LAST,
3065 G_STRUCT_OFFSET (CtkWidgetClass, drag_drop)((glong) __builtin_offsetof(CtkWidgetClass, drag_drop)),
3066 _ctk_boolean_handled_accumulator, NULL((void*)0),
3067 _ctk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
3068 G_TYPE_BOOLEAN((GType) ((5) << (2))), 4,
3069 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()),
3070 G_TYPE_INT((GType) ((6) << (2))),
3071 G_TYPE_INT((GType) ((6) << (2))),
3072 G_TYPE_UINT((GType) ((7) << (2))));
3073 g_signal_set_va_marshaller (widget_signals[DRAG_DROP],
3074 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3075 _ctk_marshal_BOOLEAN__OBJECT_INT_INT_UINTv);
3076
3077 /**
3078 * CtkWidget::drag-data-get:
3079 * @widget: the object which received the signal
3080 * @context: the drag context
3081 * @data: the #CtkSelectionData to be filled with the dragged data
3082 * @info: the info that has been registered with the target in the
3083 * #CtkTargetList
3084 * @time: the timestamp at which the data was requested
3085 *
3086 * The ::drag-data-get signal is emitted on the drag source when the drop
3087 * site requests the data which is dragged. It is the responsibility of
3088 * the signal handler to fill @data with the data in the format which
3089 * is indicated by @info. See ctk_selection_data_set() and
3090 * ctk_selection_data_set_text().
3091 */
3092 widget_signals[DRAG_DATA_GET] =
3093 g_signal_new (I_("drag-data-get")g_intern_static_string ("drag-data-get"),
3094 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3095 G_SIGNAL_RUN_LAST,
3096 G_STRUCT_OFFSET (CtkWidgetClass, drag_data_get)((glong) __builtin_offsetof(CtkWidgetClass, drag_data_get)),
3097 NULL((void*)0), NULL((void*)0),
3098 _ctk_marshal_VOID__OBJECT_BOXED_UINT_UINT,
3099 G_TYPE_NONE((GType) ((1) << (2))), 4,
3100 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()),
3101 CTK_TYPE_SELECTION_DATA(ctk_selection_data_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))),
3102 G_TYPE_UINT((GType) ((7) << (2))),
3103 G_TYPE_UINT((GType) ((7) << (2))));
3104 g_signal_set_va_marshaller (widget_signals[DRAG_DATA_GET],
3105 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3106 _ctk_marshal_VOID__OBJECT_BOXED_UINT_UINTv);
3107
3108 /**
3109 * CtkWidget::drag-data-received:
3110 * @widget: the object which received the signal
3111 * @context: the drag context
3112 * @x: where the drop happened
3113 * @y: where the drop happened
3114 * @data: the received data
3115 * @info: the info that has been registered with the target in the
3116 * #CtkTargetList
3117 * @time: the timestamp at which the data was received
3118 *
3119 * The ::drag-data-received signal is emitted on the drop site when the
3120 * dragged data has been received. If the data was received in order to
3121 * determine whether the drop will be accepted, the handler is expected
3122 * to call cdk_drag_status() and not finish the drag.
3123 * If the data was received in response to a #CtkWidget::drag-drop signal
3124 * (and this is the last target to be received), the handler for this
3125 * signal is expected to process the received data and then call
3126 * ctk_drag_finish(), setting the @success parameter depending on
3127 * whether the data was processed successfully.
3128 *
3129 * Applications must create some means to determine why the signal was emitted
3130 * and therefore whether to call cdk_drag_status() or ctk_drag_finish().
3131 *
3132 * The handler may inspect the selected action with
3133 * cdk_drag_context_get_selected_action() before calling
3134 * ctk_drag_finish(), e.g. to implement %CDK_ACTION_ASK as
3135 * shown in the following example:
3136 * |[<!-- language="C" -->
3137 * void
3138 * drag_data_received (CtkWidget *widget,
3139 * CdkDragContext *context,
3140 * gint x,
3141 * gint y,
3142 * CtkSelectionData *data,
3143 * guint info,
3144 * guint time)
3145 * {
3146 * if ((data->length >= 0) && (data->format == 8))
3147 * {
3148 * CdkDragAction action;
3149 *
3150 * // handle data here
3151 *
3152 * action = cdk_drag_context_get_selected_action (context);
3153 * if (action == CDK_ACTION_ASK)
3154 * {
3155 * CtkWidget *dialog;
3156 * gint response;
3157 *
3158 * dialog = ctk_message_dialog_new (NULL,
3159 * CTK_DIALOG_MODAL |
3160 * CTK_DIALOG_DESTROY_WITH_PARENT,
3161 * CTK_MESSAGE_INFO,
3162 * CTK_BUTTONS_YES_NO,
3163 * "Move the data ?\n");
3164 * response = ctk_dialog_run (CTK_DIALOG (dialog));
3165 * ctk_widget_destroy (dialog);
3166 *
3167 * if (response == CTK_RESPONSE_YES)
3168 * action = CDK_ACTION_MOVE;
3169 * else
3170 * action = CDK_ACTION_COPY;
3171 * }
3172 *
3173 * ctk_drag_finish (context, TRUE, action == CDK_ACTION_MOVE, time);
3174 * }
3175 * else
3176 * ctk_drag_finish (context, FALSE, FALSE, time);
3177 * }
3178 * ]|
3179 */
3180 widget_signals[DRAG_DATA_RECEIVED] =
3181 g_signal_new (I_("drag-data-received")g_intern_static_string ("drag-data-received"),
3182 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3183 G_SIGNAL_RUN_LAST,
3184 G_STRUCT_OFFSET (CtkWidgetClass, drag_data_received)((glong) __builtin_offsetof(CtkWidgetClass, drag_data_received
))
,
3185 NULL((void*)0), NULL((void*)0),
3186 _ctk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT_UINT,
3187 G_TYPE_NONE((GType) ((1) << (2))), 6,
3188 CDK_TYPE_DRAG_CONTEXT(cdk_drag_context_get_type ()),
3189 G_TYPE_INT((GType) ((6) << (2))),
3190 G_TYPE_INT((GType) ((6) << (2))),
3191 CTK_TYPE_SELECTION_DATA(ctk_selection_data_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))),
3192 G_TYPE_UINT((GType) ((7) << (2))),
3193 G_TYPE_UINT((GType) ((7) << (2))));
3194 g_signal_set_va_marshaller (widget_signals[DRAG_DATA_RECEIVED],
3195 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3196 _ctk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT_UINTv);
3197
3198 /**
3199 * CtkWidget::visibility-notify-event:
3200 * @widget: the object which received the signal
3201 * @event: (type Cdk.EventVisibility): the #CdkEventVisibility which
3202 * triggered this signal.
3203 *
3204 * The ::visibility-notify-event will be emitted when the @widget's
3205 * window is obscured or unobscured.
3206 *
3207 * To receive this signal the #CdkWindow associated to the widget needs
3208 * to enable the #CDK_VISIBILITY_NOTIFY_MASK mask.
3209 *
3210 * Returns: %TRUE to stop other handlers from being invoked for the event.
3211 * %FALSE to propagate the event further.
3212 *
3213 * Deprecated: 3.12: Modern composited windowing systems with pervasive
3214 * transparency make it impossible to track the visibility of a window
3215 * reliably, so this signal can not be guaranteed to provide useful
3216 * information.
3217 */
3218 widget_signals[VISIBILITY_NOTIFY_EVENT] =
3219 g_signal_new (I_("visibility-notify-event")g_intern_static_string ("visibility-notify-event"),
3220 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3221 G_SIGNAL_RUN_LAST | G_SIGNAL_DEPRECATED,
3222 G_STRUCT_OFFSET (CtkWidgetClass, visibility_notify_event)((glong) __builtin_offsetof(CtkWidgetClass, visibility_notify_event
))
,
3223 _ctk_boolean_handled_accumulator, NULL((void*)0),
3224 _ctk_marshal_BOOLEAN__BOXED,
3225 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
3226 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
3227 g_signal_set_va_marshaller (widget_signals[VISIBILITY_NOTIFY_EVENT],
3228 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3229 _ctk_marshal_BOOLEAN__BOXEDv);
3230
3231 /**
3232 * CtkWidget::window-state-event:
3233 * @widget: the object which received the signal
3234 * @event: (type Cdk.EventWindowState): the #CdkEventWindowState which
3235 * triggered this signal.
3236 *
3237 * The ::window-state-event will be emitted when the state of the
3238 * toplevel window associated to the @widget changes.
3239 *
3240 * To receive this signal the #CdkWindow associated to the widget
3241 * needs to enable the #CDK_STRUCTURE_MASK mask. CDK will enable
3242 * this mask automatically for all new windows.
3243 *
3244 * Returns: %TRUE to stop other handlers from being invoked for the
3245 * event. %FALSE to propagate the event further.
3246 */
3247 widget_signals[WINDOW_STATE_EVENT] =
3248 g_signal_new (I_("window-state-event")g_intern_static_string ("window-state-event"),
3249 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3250 G_SIGNAL_RUN_LAST,
3251 G_STRUCT_OFFSET (CtkWidgetClass, window_state_event)((glong) __builtin_offsetof(CtkWidgetClass, window_state_event
))
,
3252 _ctk_boolean_handled_accumulator, NULL((void*)0),
3253 _ctk_marshal_BOOLEAN__BOXED,
3254 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
3255 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
3256 g_signal_set_va_marshaller (widget_signals[WINDOW_STATE_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3257 _ctk_marshal_BOOLEAN__BOXEDv);
3258
3259 /**
3260 * CtkWidget::damage-event:
3261 * @widget: the object which received the signal
3262 * @event: (type Cdk.EventExpose): the #CdkEventExpose event
3263 *
3264 * Emitted when a redirected window belonging to @widget gets drawn into.
3265 * The region/area members of the event shows what area of the redirected
3266 * drawable was drawn into.
3267 *
3268 * Returns: %TRUE to stop other handlers from being invoked for the event.
3269 * %FALSE to propagate the event further.
3270 *
3271 * Since: 2.14
3272 */
3273 widget_signals[DAMAGE_EVENT] =
3274 g_signal_new (I_("damage-event")g_intern_static_string ("damage-event"),
3275 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3276 G_SIGNAL_RUN_LAST,
3277 G_STRUCT_OFFSET (CtkWidgetClass, damage_event)((glong) __builtin_offsetof(CtkWidgetClass, damage_event)),
3278 _ctk_boolean_handled_accumulator, NULL((void*)0),
3279 _ctk_marshal_BOOLEAN__BOXED,
3280 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
3281 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
3282 g_signal_set_va_marshaller (widget_signals[DAMAGE_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3283 _ctk_marshal_BOOLEAN__BOXEDv);
3284
3285/**
3286 * CtkWidget::grab-broken-event:
3287 * @widget: the object which received the signal
3288 * @event: (type Cdk.EventGrabBroken): the #CdkEventGrabBroken event
3289 *
3290 * Emitted when a pointer or keyboard grab on a window belonging
3291 * to @widget gets broken.
3292 *
3293 * On X11, this happens when the grab window becomes unviewable
3294 * (i.e. it or one of its ancestors is unmapped), or if the same
3295 * application grabs the pointer or keyboard again.
3296 *
3297 * Returns: %TRUE to stop other handlers from being invoked for
3298 * the event. %FALSE to propagate the event further.
3299 *
3300 * Since: 2.8
3301 */
3302 widget_signals[GRAB_BROKEN_EVENT] =
3303 g_signal_new (I_("grab-broken-event")g_intern_static_string ("grab-broken-event"),
3304 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3305 G_SIGNAL_RUN_LAST,
3306 G_STRUCT_OFFSET (CtkWidgetClass, grab_broken_event)((glong) __builtin_offsetof(CtkWidgetClass, grab_broken_event
))
,
3307 _ctk_boolean_handled_accumulator, NULL((void*)0),
3308 _ctk_marshal_BOOLEAN__BOXED,
3309 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
3310 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
3311 g_signal_set_va_marshaller (widget_signals[GRAB_BROKEN_EVENT], G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3312 _ctk_marshal_BOOLEAN__BOXEDv);
3313
3314 /**
3315 * CtkWidget::query-tooltip:
3316 * @widget: the object which received the signal
3317 * @x: the x coordinate of the cursor position where the request has
3318 * been emitted, relative to @widget's left side
3319 * @y: the y coordinate of the cursor position where the request has
3320 * been emitted, relative to @widget's top
3321 * @keyboard_mode: %TRUE if the tooltip was triggered using the keyboard
3322 * @tooltip: a #CtkTooltip
3323 *
3324 * Emitted when #CtkWidget:has-tooltip is %TRUE and the hover timeout
3325 * has expired with the cursor hovering "above" @widget; or emitted when @widget got
3326 * focus in keyboard mode.
3327 *
3328 * Using the given coordinates, the signal handler should determine
3329 * whether a tooltip should be shown for @widget. If this is the case
3330 * %TRUE should be returned, %FALSE otherwise. Note that if
3331 * @keyboard_mode is %TRUE, the values of @x and @y are undefined and
3332 * should not be used.
3333 *
3334 * The signal handler is free to manipulate @tooltip with the therefore
3335 * destined function calls.
3336 *
3337 * Returns: %TRUE if @tooltip should be shown right now, %FALSE otherwise.
3338 *
3339 * Since: 2.12
3340 */
3341 widget_signals[QUERY_TOOLTIP] =
3342 g_signal_new (I_("query-tooltip")g_intern_static_string ("query-tooltip"),
3343 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3344 G_SIGNAL_RUN_LAST,
3345 G_STRUCT_OFFSET (CtkWidgetClass, query_tooltip)((glong) __builtin_offsetof(CtkWidgetClass, query_tooltip)),
3346 _ctk_boolean_handled_accumulator, NULL((void*)0),
3347 _ctk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECT,
3348 G_TYPE_BOOLEAN((GType) ((5) << (2))), 4,
3349 G_TYPE_INT((GType) ((6) << (2))),
3350 G_TYPE_INT((GType) ((6) << (2))),
3351 G_TYPE_BOOLEAN((GType) ((5) << (2))),
3352 CTK_TYPE_TOOLTIP(ctk_tooltip_get_type ()));
3353 g_signal_set_va_marshaller (widget_signals[QUERY_TOOLTIP],
3354 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3355 _ctk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECTv);
3356
3357 /**
3358 * CtkWidget::popup-menu:
3359 * @widget: the object which received the signal
3360 *
3361 * This signal gets emitted whenever a widget should pop up a context
3362 * menu. This usually happens through the standard key binding mechanism;
3363 * by pressing a certain key while a widget is focused, the user can cause
3364 * the widget to pop up a menu. For example, the #CtkEntry widget creates
3365 * a menu with clipboard commands. See the
3366 * [Popup Menu Migration Checklist][checklist-popup-menu]
3367 * for an example of how to use this signal.
3368 *
3369 * Returns: %TRUE if a menu was activated
3370 */
3371 widget_signals[POPUP_MENU] =
3372 g_signal_new (I_("popup-menu")g_intern_static_string ("popup-menu"),
3373 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3374 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
3375 G_STRUCT_OFFSET (CtkWidgetClass, popup_menu)((glong) __builtin_offsetof(CtkWidgetClass, popup_menu)),
3376 _ctk_boolean_handled_accumulator, NULL((void*)0),
3377 _ctk_marshal_BOOLEAN__VOID,
3378 G_TYPE_BOOLEAN((GType) ((5) << (2))), 0);
3379 g_signal_set_va_marshaller (widget_signals[POPUP_MENU],
3380 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3381 _ctk_marshal_BOOLEAN__VOIDv);
3382
3383 /**
3384 * CtkWidget::show-help:
3385 * @widget: the object which received the signal.
3386 * @help_type:
3387 *
3388 * Returns: %TRUE to stop other handlers from being invoked for the event.
3389 * %FALSE to propagate the event further.
3390 */
3391 widget_signals[SHOW_HELP] =
3392 g_signal_new (I_("show-help")g_intern_static_string ("show-help"),
3393 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3394 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
3395 G_STRUCT_OFFSET (CtkWidgetClass, show_help)((glong) __builtin_offsetof(CtkWidgetClass, show_help)),
3396 _ctk_boolean_handled_accumulator, NULL((void*)0),
3397 _ctk_marshal_BOOLEAN__ENUM,
3398 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
3399 CTK_TYPE_WIDGET_HELP_TYPE(ctk_widget_help_type_get_type ()));
3400 g_signal_set_va_marshaller (widget_signals[SHOW_HELP],
3401 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3402 _ctk_marshal_BOOLEAN__ENUMv);
3403
3404 /**
3405 * CtkWidget::accel-closures-changed:
3406 * @widget: the object which received the signal.
3407 */
3408 widget_signals[ACCEL_CLOSURES_CHANGED] =
3409 g_signal_new (I_("accel-closures-changed")g_intern_static_string ("accel-closures-changed"),
3410 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3411 0,
3412 0,
3413 NULL((void*)0), NULL((void*)0),
3414 NULL((void*)0),
3415 G_TYPE_NONE((GType) ((1) << (2))), 0);
3416
3417 /**
3418 * CtkWidget::screen-changed:
3419 * @widget: the object on which the signal is emitted
3420 * @previous_screen: (allow-none): the previous screen, or %NULL if the
3421 * widget was not associated with a screen before
3422 *
3423 * The ::screen-changed signal gets emitted when the
3424 * screen of a widget has changed.
3425 */
3426 widget_signals[SCREEN_CHANGED] =
3427 g_signal_new (I_("screen-changed")g_intern_static_string ("screen-changed"),
3428 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3429 G_SIGNAL_RUN_LAST,
3430 G_STRUCT_OFFSET (CtkWidgetClass, screen_changed)((glong) __builtin_offsetof(CtkWidgetClass, screen_changed)),
3431 NULL((void*)0), NULL((void*)0),
3432 NULL((void*)0),
3433 G_TYPE_NONE((GType) ((1) << (2))), 1,
3434 CDK_TYPE_SCREEN(cdk_screen_get_type ()));
3435
3436 /**
3437 * CtkWidget::can-activate-accel:
3438 * @widget: the object which received the signal
3439 * @signal_id: the ID of a signal installed on @widget
3440 *
3441 * Determines whether an accelerator that activates the signal
3442 * identified by @signal_id can currently be activated.
3443 * This signal is present to allow applications and derived
3444 * widgets to override the default #CtkWidget handling
3445 * for determining whether an accelerator can be activated.
3446 *
3447 * Returns: %TRUE if the signal can be activated.
3448 */
3449 widget_signals[CAN_ACTIVATE_ACCEL] =
3450 g_signal_new (I_("can-activate-accel")g_intern_static_string ("can-activate-accel"),
3451 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
3452 G_SIGNAL_RUN_LAST,
3453 G_STRUCT_OFFSET (CtkWidgetClass, can_activate_accel)((glong) __builtin_offsetof(CtkWidgetClass, can_activate_accel
))
,
3454 _ctk_boolean_handled_accumulator, NULL((void*)0),
3455 _ctk_marshal_BOOLEAN__UINT,
3456 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1, G_TYPE_UINT((GType) ((7) << (2))));
3457
3458 binding_set = ctk_binding_set_by_class (klass);
3459 ctk_binding_entry_add_signal (binding_set, CDK_KEY_F100xffc7, CDK_SHIFT_MASK,
3460 "popup-menu", 0);
3461 ctk_binding_entry_add_signal (binding_set, CDK_KEY_Menu0xff67, 0,
3462 "popup-menu", 0);
3463
3464 ctk_binding_entry_add_signal (binding_set, CDK_KEY_F10xffbe, CDK_CONTROL_MASK,
3465 "show-help", 1,
3466 CTK_TYPE_WIDGET_HELP_TYPE(ctk_widget_help_type_get_type ()),
3467 CTK_WIDGET_HELP_TOOLTIP);
3468 ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_F10xff91, CDK_CONTROL_MASK,
3469 "show-help", 1,
3470 CTK_TYPE_WIDGET_HELP_TYPE(ctk_widget_help_type_get_type ()),
3471 CTK_WIDGET_HELP_TOOLTIP);
3472 ctk_binding_entry_add_signal (binding_set, CDK_KEY_F10xffbe, CDK_SHIFT_MASK,
3473 "show-help", 1,
3474 CTK_TYPE_WIDGET_HELP_TYPE(ctk_widget_help_type_get_type ()),
3475 CTK_WIDGET_HELP_WHATS_THIS);
3476 ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_F10xff91, CDK_SHIFT_MASK,
3477 "show-help", 1,
3478 CTK_TYPE_WIDGET_HELP_TYPE(ctk_widget_help_type_get_type ()),
3479 CTK_WIDGET_HELP_WHATS_THIS);
3480
3481 /**
3482 * CtkWidget:interior-focus:
3483 *
3484 * The "interior-focus" style property defines whether
3485 * to draw the focus indicator inside widgets.
3486 *
3487 * Deprecated: 3.14: use the outline CSS properties instead.
3488 */
3489 ctk_widget_class_install_style_property (klass,
3490 g_param_spec_boolean ("interior-focus",
3491 P_("Interior Focus")g_dgettext("ctk30" "-properties","Interior Focus"),
3492 P_("Whether to draw the focus indicator inside widgets")g_dgettext("ctk30" "-properties","Whether to draw the focus indicator inside widgets"
)
,
3493 TRUE(!(0)),
3494 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED));
3495 /**
3496 * CtkWidget:focus-line-width:
3497 *
3498 * The "focus-line-width" style property defines the width,
3499 * in pixels, of the focus indicator line
3500 *
3501 * Deprecated: 3.14: use the outline-width and padding CSS properties instead.
3502 */
3503 ctk_widget_class_install_style_property (klass,
3504 g_param_spec_int ("focus-line-width",
3505 P_("Focus linewidth")g_dgettext("ctk30" "-properties","Focus linewidth"),
3506 P_("Width, in pixels, of the focus indicator line")g_dgettext("ctk30" "-properties","Width, in pixels, of the focus indicator line"
)
,
3507 0, G_MAXINT2147483647, 1,
3508 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED));
3509 /**
3510 * CtkWidget:focus-line-pattern:
3511 *
3512 * The "focus-line-pattern" style property defines the dash pattern used to
3513 * draw the focus indicator. The character values are interpreted as pixel
3514 * widths of alternating on and off segments of the line.
3515 *
3516 * Deprecated: 3.14: use the outline-style CSS property instead.
3517 */
3518 ctk_widget_class_install_style_property (klass,
3519 g_param_spec_string ("focus-line-pattern",
3520 P_("Focus line dash pattern")g_dgettext("ctk30" "-properties","Focus line dash pattern"),
3521 P_("Dash pattern used to draw the focus indicator. The character values are interpreted as pixel widths of alternating on and off segments of the line.")g_dgettext("ctk30" "-properties","Dash pattern used to draw the focus indicator. The character values are interpreted as pixel widths of alternating on and off segments of the line."
)
,
3522 "\1\1",
3523 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED));
3524 /**
3525 * CtkWidget:focus-padding:
3526 *
3527 * The "focus-padding" style property defines the width, in pixels,
3528 * between focus indicator and the widget 'box'.
3529 *
3530 * Deprecated: 3.14: use the outline-offset CSS properties instead.
3531 */
3532 ctk_widget_class_install_style_property (klass,
3533 g_param_spec_int ("focus-padding",
3534 P_("Focus padding")g_dgettext("ctk30" "-properties","Focus padding"),
3535 P_("Width, in pixels, between focus indicator and the widget 'box'")g_dgettext("ctk30" "-properties","Width, in pixels, between focus indicator and the widget 'box'"
)
,
3536 0, G_MAXINT2147483647, 1,
3537 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED));
3538 /**
3539 * CtkWidget:cursor-color:
3540 *
3541 * The color with which to draw the insertion cursor in entries and
3542 * text views.
3543 */
3544 ctk_widget_class_install_style_property (klass,
3545 g_param_spec_boxed ("cursor-color",
3546 P_("Cursor color")g_dgettext("ctk30" "-properties","Cursor color"),
3547 P_("Color with which to draw insertion cursor")g_dgettext("ctk30" "-properties","Color with which to draw insertion cursor"
)
,
3548 CDK_TYPE_COLOR(cdk_color_get_type ()),
3549 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3550 /**
3551 * CtkWidget:secondary-cursor-color:
3552 *
3553 * The color with which to draw the secondary insertion cursor in entries and
3554 * text views when editing mixed right-to-left and left-to-right text.
3555 */
3556 ctk_widget_class_install_style_property (klass,
3557 g_param_spec_boxed ("secondary-cursor-color",
3558 P_("Secondary cursor color")g_dgettext("ctk30" "-properties","Secondary cursor color"),
3559 P_("Color with which to draw the secondary insertion cursor when editing mixed right-to-left and left-to-right text")g_dgettext("ctk30" "-properties","Color with which to draw the secondary insertion cursor when editing mixed right-to-left and left-to-right text"
)
,
3560 CDK_TYPE_COLOR(cdk_color_get_type ()),
3561 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3562
3563 ctk_widget_class_install_style_property (klass,
3564 g_param_spec_float ("cursor-aspect-ratio",
3565 P_("Cursor line aspect ratio")g_dgettext("ctk30" "-properties","Cursor line aspect ratio"),
3566 P_("Aspect ratio with which to draw insertion cursor")g_dgettext("ctk30" "-properties","Aspect ratio with which to draw insertion cursor"
)
,
3567 0.0, 1.0, 0.04,
3568 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3569
3570 ctk_widget_class_install_style_property (klass,
3571 g_param_spec_boolean ("window-dragging",
3572 P_("Window dragging")g_dgettext("ctk30" "-properties","Window dragging"),
3573 P_("Whether windows can be dragged and maximized by clicking on empty areas")g_dgettext("ctk30" "-properties","Whether windows can be dragged and maximized by clicking on empty areas"
)
,
3574 FALSE(0),
3575 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3576 /**
3577 * CtkWidget:link-color:
3578 *
3579 * The "link-color" style property defines the color of unvisited links.
3580 *
3581 * Since: 2.10
3582 */
3583 ctk_widget_class_install_style_property (klass,
3584 g_param_spec_boxed ("link-color",
3585 P_("Unvisited Link Color")g_dgettext("ctk30" "-properties","Unvisited Link Color"),
3586 P_("Color of unvisited links")g_dgettext("ctk30" "-properties","Color of unvisited links"),
3587 CDK_TYPE_COLOR(cdk_color_get_type ()),
3588 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3589
3590 /**
3591 * CtkWidget:visited-link-color:
3592 *
3593 * The "visited-link-color" style property defines the color of visited links.
3594 *
3595 * Since: 2.10
3596 */
3597 ctk_widget_class_install_style_property (klass,
3598 g_param_spec_boxed ("visited-link-color",
3599 P_("Visited Link Color")g_dgettext("ctk30" "-properties","Visited Link Color"),
3600 P_("Color of visited links")g_dgettext("ctk30" "-properties","Color of visited links"),
3601 CDK_TYPE_COLOR(cdk_color_get_type ()),
3602 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3603
3604 /**
3605 * CtkWidget:wide-separators:
3606 *
3607 * The "wide-separators" style property defines whether separators have
3608 * configurable width and should be drawn using a box instead of a line.
3609 *
3610 * Since: 2.10
3611 *
3612 * Deprecated: 3.20: Use CSS properties on the separator elements to style
3613 * separators; the value of this style property is ignored.
3614 */
3615 ctk_widget_class_install_style_property (klass,
3616 g_param_spec_boolean ("wide-separators",
3617 P_("Wide Separators")g_dgettext("ctk30" "-properties","Wide Separators"),
3618 P_("Whether separators have configurable width and should be drawn using a box instead of a line")g_dgettext("ctk30" "-properties","Whether separators have configurable width and should be drawn using a box instead of a line"
)
,
3619 FALSE(0),
3620 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED));
3621
3622 /**
3623 * CtkWidget:separator-width:
3624 *
3625 * The "separator-width" style property defines the width of separators.
3626 * This property only takes effect if the "wide-separators" style property is %TRUE.
3627 *
3628 * Since: 2.10
3629 *
3630 * Deprecated: 3.20: Use the standard min-width CSS property on the separator
3631 * elements to size separators; the value of this style property is ignored.
3632 */
3633 ctk_widget_class_install_style_property (klass,
3634 g_param_spec_int ("separator-width",
3635 P_("Separator Width")g_dgettext("ctk30" "-properties","Separator Width"),
3636 P_("The width of separators if wide-separators is TRUE")g_dgettext("ctk30" "-properties","The width of separators if wide-separators is TRUE"
)
,
3637 0, G_MAXINT2147483647, 0,
3638 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED));
3639
3640 /**
3641 * CtkWidget:separator-height:
3642 *
3643 * The "separator-height" style property defines the height of separators.
3644 * This property only takes effect if the "wide-separators" style property is %TRUE.
3645 *
3646 * Since: 2.10
3647 *
3648 * Deprecated: 3.20: Use the standard min-height CSS property on the separator
3649 * elements to size separators; the value of this style property is ignored.
3650 */
3651 ctk_widget_class_install_style_property (klass,
3652 g_param_spec_int ("separator-height",
3653 P_("Separator Height")g_dgettext("ctk30" "-properties","Separator Height"),
3654 P_("The height of separators if \"wide-separators\" is TRUE")g_dgettext("ctk30" "-properties","The height of separators if \"wide-separators\" is TRUE"
)
,
3655 0, G_MAXINT2147483647, 0,
3656 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_DEPRECATED));
3657
3658 /**
3659 * CtkWidget:scroll-arrow-hlength:
3660 *
3661 * The "scroll-arrow-hlength" style property defines the length of
3662 * horizontal scroll arrows.
3663 *
3664 * Since: 2.10
3665 */
3666 ctk_widget_class_install_style_property (klass,
3667 g_param_spec_int ("scroll-arrow-hlength",
3668 P_("Horizontal Scroll Arrow Length")g_dgettext("ctk30" "-properties","Horizontal Scroll Arrow Length"
)
,
3669 P_("The length of horizontal scroll arrows")g_dgettext("ctk30" "-properties","The length of horizontal scroll arrows"
)
,
3670 1, G_MAXINT2147483647, 16,
3671 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3672
3673 /**
3674 * CtkWidget:scroll-arrow-vlength:
3675 *
3676 * The "scroll-arrow-vlength" style property defines the length of
3677 * vertical scroll arrows.
3678 *
3679 * Since: 2.10
3680 */
3681 ctk_widget_class_install_style_property (klass,
3682 g_param_spec_int ("scroll-arrow-vlength",
3683 P_("Vertical Scroll Arrow Length")g_dgettext("ctk30" "-properties","Vertical Scroll Arrow Length"
)
,
3684 P_("The length of vertical scroll arrows")g_dgettext("ctk30" "-properties","The length of vertical scroll arrows"
)
,
3685 1, G_MAXINT2147483647, 16,
3686 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3687
3688 ctk_widget_class_install_style_property (klass,
3689 g_param_spec_int ("text-handle-width",
3690 P_("Width of text selection handles")g_dgettext("ctk30" "-properties","Width of text selection handles"
)
,
3691 P_("Width of text selection handles")g_dgettext("ctk30" "-properties","Width of text selection handles"
)
,
3692 1, G_MAXINT2147483647, 16,
3693 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3694 ctk_widget_class_install_style_property (klass,
3695 g_param_spec_int ("text-handle-height",
3696 P_("Height of text selection handles")g_dgettext("ctk30" "-properties","Height of text selection handles"
)
,
3697 P_("Height of text selection handles")g_dgettext("ctk30" "-properties","Height of text selection handles"
)
,
3698 1, G_MAXINT2147483647, 20,
3699 CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
3700
3701 ctk_widget_class_set_accessible_type (klass, CTK_TYPE_WIDGET_ACCESSIBLE(ctk_widget_accessible_get_type ()));
3702 ctk_widget_class_set_css_name (klass, "widget");
3703}
3704
3705static void
3706ctk_widget_base_class_finalize (CtkWidgetClass *klass)
3707{
3708 GList *list, *node;
3709
3710 list = g_param_spec_pool_list_owned (style_property_spec_pool, G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)));
3711 for (node = list; node; node = node->next)
3712 {
3713 GParamSpec *pspec = node->data;
3714
3715 g_param_spec_pool_remove (style_property_spec_pool, pspec);
3716 g_param_spec_unref (pspec);
3717 }
3718 g_list_free (list);
3719
3720 template_data_free (klass->priv->template);
3721}
3722
3723static void
3724ctk_widget_set_property (GObject *object,
3725 guint prop_id,
3726 const GValue *value,
3727 GParamSpec *pspec)
3728{
3729 CtkWidget *widget = CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
;
3730
3731 switch (prop_id)
3732 {
3733 gboolean tmp;
3734 gchar *tooltip_markup;
3735 const gchar *tooltip_text;
3736 CtkWindow *tooltip_window;
3737
3738 case PROP_NAME:
3739 ctk_widget_set_name (widget, g_value_get_string (value));
3740 break;
3741 case PROP_PARENT:
3742 ctk_container_add (CTK_CONTAINER (g_value_get_object (value))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_value_get_object (value))), ((ctk_container_get_type (
)))))))
, widget);
3743 break;
3744 case PROP_WIDTH_REQUEST:
3745 ctk_widget_set_usize_internal (widget, g_value_get_int (value), -2);
3746 break;
3747 case PROP_HEIGHT_REQUEST:
3748 ctk_widget_set_usize_internal (widget, -2, g_value_get_int (value));
3749 break;
3750 case PROP_VISIBLE:
3751 ctk_widget_set_visible (widget, g_value_get_boolean (value));
3752 break;
3753 case PROP_SENSITIVE:
3754 ctk_widget_set_sensitive (widget, g_value_get_boolean (value));
3755 break;
3756 case PROP_APP_PAINTABLE:
3757 ctk_widget_set_app_paintable (widget, g_value_get_boolean (value));
3758 break;
3759 case PROP_CAN_FOCUS:
3760 ctk_widget_set_can_focus (widget, g_value_get_boolean (value));
3761 break;
3762 case PROP_HAS_FOCUS:
3763 if (g_value_get_boolean (value))
3764 ctk_widget_grab_focus (widget);
3765 break;
3766 case PROP_IS_FOCUS:
3767 if (g_value_get_boolean (value))
3768 ctk_widget_grab_focus (widget);
3769 break;
3770 case PROP_FOCUS_ON_CLICK:
3771 ctk_widget_set_focus_on_click (widget, g_value_get_boolean (value));
3772 break;
3773 case PROP_CAN_DEFAULT:
3774 ctk_widget_set_can_default (widget, g_value_get_boolean (value));
3775 break;
3776 case PROP_HAS_DEFAULT:
3777 if (g_value_get_boolean (value))
3778 ctk_widget_grab_default (widget);
3779 break;
3780 case PROP_RECEIVES_DEFAULT:
3781 ctk_widget_set_receives_default (widget, g_value_get_boolean (value));
3782 break;
3783 case PROP_STYLE:
3784 ctk_widget_set_style (widget, g_value_get_object (value));
3785 break;
3786 case PROP_EVENTS:
3787 if (!_ctk_widget_get_realized (widget) && _ctk_widget_get_has_window (widget))
3788 ctk_widget_set_events (widget, g_value_get_flags (value));
3789 break;
3790 case PROP_NO_SHOW_ALL:
3791 ctk_widget_set_no_show_all (widget, g_value_get_boolean (value));
3792 break;
3793 case PROP_HAS_TOOLTIP:
3794 ctk_widget_real_set_has_tooltip (widget,
3795 g_value_get_boolean (value), FALSE(0));
3796 break;
3797 case PROP_TOOLTIP_MARKUP:
3798 tooltip_window = g_object_get_qdata (object, quark_tooltip_window);
3799 tooltip_markup = g_value_dup_string (value);
3800
3801 /* Treat an empty string as a NULL string,
3802 * because an empty string would be useless for a tooltip:
3803 */
3804 if (tooltip_markup && (strlen (tooltip_markup) == 0))
3805 {
3806 g_free (tooltip_markup);
3807 tooltip_markup = NULL((void*)0);
3808 }
3809
3810 g_object_set_qdata_full (object, quark_tooltip_markup,
3811 tooltip_markup, g_free);
3812
3813 tmp = (tooltip_window != NULL((void*)0) || tooltip_markup != NULL((void*)0));
3814 ctk_widget_real_set_has_tooltip (widget, tmp, FALSE(0));
3815 if (_ctk_widget_get_visible (widget))
3816 ctk_widget_queue_tooltip_query (widget);
3817 break;
3818 case PROP_TOOLTIP_TEXT:
3819 tooltip_window = g_object_get_qdata (object, quark_tooltip_window);
3820
3821 tooltip_text = g_value_get_string (value);
3822
3823 /* Treat an empty string as a NULL string,
3824 * because an empty string would be useless for a tooltip:
3825 */
3826 if (tooltip_text && (strlen (tooltip_text) == 0))
3827 tooltip_text = NULL((void*)0);
3828
3829 tooltip_markup = tooltip_text ? g_markup_escape_text (tooltip_text, -1) : NULL((void*)0);
3830
3831 g_object_set_qdata_full (object, quark_tooltip_markup,
3832 tooltip_markup, g_free);
3833
3834 tmp = (tooltip_window != NULL((void*)0) || tooltip_markup != NULL((void*)0));
3835 ctk_widget_real_set_has_tooltip (widget, tmp, FALSE(0));
3836 if (_ctk_widget_get_visible (widget))
3837 ctk_widget_queue_tooltip_query (widget);
3838 break;
3839 case PROP_DOUBLE_BUFFERED:
3840 ctk_widget_set_double_buffered (widget, g_value_get_boolean (value));
3841 break;
3842 case PROP_HALIGN:
3843 ctk_widget_set_halign (widget, g_value_get_enum (value));
3844 break;
3845 case PROP_VALIGN:
3846 ctk_widget_set_valign (widget, g_value_get_enum (value));
3847 break;
3848 case PROP_MARGIN_LEFT:
3849 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
3850 ctk_widget_set_margin_left (widget, g_value_get_int (value));
3851 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
3852 break;
3853 case PROP_MARGIN_RIGHT:
3854 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
3855 ctk_widget_set_margin_right (widget, g_value_get_int (value));
3856 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
3857 break;
3858 case PROP_MARGIN_START:
3859 ctk_widget_set_margin_start (widget, g_value_get_int (value));
3860 break;
3861 case PROP_MARGIN_END:
3862 ctk_widget_set_margin_end (widget, g_value_get_int (value));
3863 break;
3864 case PROP_MARGIN_TOP:
3865 ctk_widget_set_margin_top (widget, g_value_get_int (value));
3866 break;
3867 case PROP_MARGIN_BOTTOM:
3868 ctk_widget_set_margin_bottom (widget, g_value_get_int (value));
3869 break;
3870 case PROP_MARGIN:
3871 g_object_freeze_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
3872 ctk_widget_set_margin_start (widget, g_value_get_int (value));
3873 ctk_widget_set_margin_end (widget, g_value_get_int (value));
3874 ctk_widget_set_margin_top (widget, g_value_get_int (value));
3875 ctk_widget_set_margin_bottom (widget, g_value_get_int (value));
3876 g_object_thaw_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
3877 break;
3878 case PROP_HEXPAND:
3879 ctk_widget_set_hexpand (widget, g_value_get_boolean (value));
3880 break;
3881 case PROP_HEXPAND_SET:
3882 ctk_widget_set_hexpand_set (widget, g_value_get_boolean (value));
3883 break;
3884 case PROP_VEXPAND:
3885 ctk_widget_set_vexpand (widget, g_value_get_boolean (value));
3886 break;
3887 case PROP_VEXPAND_SET:
3888 ctk_widget_set_vexpand_set (widget, g_value_get_boolean (value));
3889 break;
3890 case PROP_EXPAND:
3891 g_object_freeze_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
3892 ctk_widget_set_hexpand (widget, g_value_get_boolean (value));
3893 ctk_widget_set_vexpand (widget, g_value_get_boolean (value));
3894 g_object_thaw_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
3895 break;
3896 case PROP_OPACITY:
3897 ctk_widget_set_opacity (widget, g_value_get_double (value));
3898 break;
3899 default:
3900 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'"
, "ctkwidget.c", 3900, ("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)
;
3901 break;
3902 }
3903}
3904
3905static void
3906ctk_widget_get_property (GObject *object,
3907 guint prop_id,
3908 GValue *value,
3909 GParamSpec *pspec)
3910{
3911 CtkWidget *widget = CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
;
3912 CtkWidgetPrivate *priv = widget->priv;
3913
3914 switch (prop_id)
3915 {
3916 gpointer *eventp;
3917
3918 case PROP_NAME:
3919 if (priv->name)
3920 g_value_set_string (value, priv->name);
3921 else
3922 g_value_set_static_string (value, "");
3923 break;
3924 case PROP_PARENT:
3925 g_value_set_object (value, priv->parent);
3926 break;
3927 case PROP_WIDTH_REQUEST:
3928 {
3929 int w;
3930 ctk_widget_get_size_request (widget, &w, NULL((void*)0));
3931 g_value_set_int (value, w);
3932 }
3933 break;
3934 case PROP_HEIGHT_REQUEST:
3935 {
3936 int h;
3937 ctk_widget_get_size_request (widget, NULL((void*)0), &h);
3938 g_value_set_int (value, h);
3939 }
3940 break;
3941 case PROP_VISIBLE:
3942 g_value_set_boolean (value, _ctk_widget_get_visible (widget));
3943 break;
3944 case PROP_SENSITIVE:
3945 g_value_set_boolean (value, ctk_widget_get_sensitive (widget));
3946 break;
3947 case PROP_APP_PAINTABLE:
3948 g_value_set_boolean (value, ctk_widget_get_app_paintable (widget));
3949 break;
3950 case PROP_CAN_FOCUS:
3951 g_value_set_boolean (value, ctk_widget_get_can_focus (widget));
3952 break;
3953 case PROP_HAS_FOCUS:
3954 g_value_set_boolean (value, ctk_widget_has_focus (widget));
3955 break;
3956 case PROP_IS_FOCUS:
3957 g_value_set_boolean (value, ctk_widget_is_focus (widget));
3958 break;
3959 case PROP_FOCUS_ON_CLICK:
3960 g_value_set_boolean (value, ctk_widget_get_focus_on_click (widget));
3961 break;
3962 case PROP_CAN_DEFAULT:
3963 g_value_set_boolean (value, ctk_widget_get_can_default (widget));
3964 break;
3965 case PROP_HAS_DEFAULT:
3966 g_value_set_boolean (value, ctk_widget_has_default (widget));
3967 break;
3968 case PROP_RECEIVES_DEFAULT:
3969 g_value_set_boolean (value, ctk_widget_get_receives_default (widget));
3970 break;
3971 case PROP_COMPOSITE_CHILD:
3972 g_value_set_boolean (value, widget->priv->composite_child);
3973 break;
3974 case PROP_STYLE:
3975 g_value_set_object (value, ctk_widget_get_style (widget));
3976 break;
3977 case PROP_EVENTS:
3978 eventp = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_event_mask);
3979 g_value_set_flags (value, GPOINTER_TO_INT (eventp)((gint) (glong) (eventp)));
3980 break;
3981 case PROP_NO_SHOW_ALL:
3982 g_value_set_boolean (value, ctk_widget_get_no_show_all (widget));
3983 break;
3984 case PROP_HAS_TOOLTIP:
3985 g_value_set_boolean (value, ctk_widget_get_has_tooltip (widget));
3986 break;
3987 case PROP_TOOLTIP_TEXT:
3988 {
3989 gchar *escaped = g_object_get_qdata (object, quark_tooltip_markup);
3990 gchar *text = NULL((void*)0);
3991
3992 if (escaped && !pango_parse_markup (escaped, -1, 0, NULL((void*)0), &text, NULL((void*)0), NULL((void*)0)))
3993 g_assert (NULL == text)do { if (((void*)0) == text) ; else g_assertion_message_expr (
"Ctk", "ctkwidget.c", 3993, ((const char*) (__func__)), "NULL == text"
); } while (0)
; /* text should still be NULL in case of markup errors */
3994
3995 g_value_take_string (value, text);
3996 }
3997 break;
3998 case PROP_TOOLTIP_MARKUP:
3999 g_value_set_string (value, g_object_get_qdata (object, quark_tooltip_markup));
4000 break;
4001 case PROP_WINDOW:
4002 g_value_set_object (value, _ctk_widget_get_window (widget));
4003 break;
4004 case PROP_DOUBLE_BUFFERED:
4005 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
4006 g_value_set_boolean (value, ctk_widget_get_double_buffered (widget));
4007 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
4008 break;
4009 case PROP_HALIGN:
4010 g_value_set_enum (value, ctk_widget_get_halign (widget));
4011 break;
4012 case PROP_VALIGN:
4013 g_value_set_enum (value, ctk_widget_get_valign_with_baseline (widget));
4014 break;
4015 case PROP_MARGIN_LEFT:
4016 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
4017 g_value_set_int (value, ctk_widget_get_margin_left (widget));
4018 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
4019 break;
4020 case PROP_MARGIN_RIGHT:
4021 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
4022 g_value_set_int (value, ctk_widget_get_margin_right (widget));
4023 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
4024 break;
4025 case PROP_MARGIN_START:
4026 g_value_set_int (value, ctk_widget_get_margin_start (widget));
4027 break;
4028 case PROP_MARGIN_END:
4029 g_value_set_int (value, ctk_widget_get_margin_end (widget));
4030 break;
4031 case PROP_MARGIN_TOP:
4032 g_value_set_int (value, ctk_widget_get_margin_top (widget));
4033 break;
4034 case PROP_MARGIN_BOTTOM:
4035 g_value_set_int (value, ctk_widget_get_margin_bottom (widget));
4036 break;
4037 case PROP_MARGIN:
4038 g_value_set_int (value, MAX (MAX (priv->margin.left,((((((priv->margin.left) > (priv->margin.right)) ? (
priv->margin.left) : (priv->margin.right))) > ((((priv
->margin.top) > (priv->margin.bottom)) ? (priv->margin
.top) : (priv->margin.bottom)))) ? ((((priv->margin.left
) > (priv->margin.right)) ? (priv->margin.left) : (priv
->margin.right))) : ((((priv->margin.top) > (priv->
margin.bottom)) ? (priv->margin.top) : (priv->margin.bottom
))))
4039 priv->margin.right),((((((priv->margin.left) > (priv->margin.right)) ? (
priv->margin.left) : (priv->margin.right))) > ((((priv
->margin.top) > (priv->margin.bottom)) ? (priv->margin
.top) : (priv->margin.bottom)))) ? ((((priv->margin.left
) > (priv->margin.right)) ? (priv->margin.left) : (priv
->margin.right))) : ((((priv->margin.top) > (priv->
margin.bottom)) ? (priv->margin.top) : (priv->margin.bottom
))))
4040 MAX (priv->margin.top,((((((priv->margin.left) > (priv->margin.right)) ? (
priv->margin.left) : (priv->margin.right))) > ((((priv
->margin.top) > (priv->margin.bottom)) ? (priv->margin
.top) : (priv->margin.bottom)))) ? ((((priv->margin.left
) > (priv->margin.right)) ? (priv->margin.left) : (priv
->margin.right))) : ((((priv->margin.top) > (priv->
margin.bottom)) ? (priv->margin.top) : (priv->margin.bottom
))))
4041 priv->margin.bottom))((((((priv->margin.left) > (priv->margin.right)) ? (
priv->margin.left) : (priv->margin.right))) > ((((priv
->margin.top) > (priv->margin.bottom)) ? (priv->margin
.top) : (priv->margin.bottom)))) ? ((((priv->margin.left
) > (priv->margin.right)) ? (priv->margin.left) : (priv
->margin.right))) : ((((priv->margin.top) > (priv->
margin.bottom)) ? (priv->margin.top) : (priv->margin.bottom
))))
);
4042 break;
4043 case PROP_HEXPAND:
4044 g_value_set_boolean (value, ctk_widget_get_hexpand (widget));
4045 break;
4046 case PROP_HEXPAND_SET:
4047 g_value_set_boolean (value, ctk_widget_get_hexpand_set (widget));
4048 break;
4049 case PROP_VEXPAND:
4050 g_value_set_boolean (value, ctk_widget_get_vexpand (widget));
4051 break;
4052 case PROP_VEXPAND_SET:
4053 g_value_set_boolean (value, ctk_widget_get_vexpand_set (widget));
4054 break;
4055 case PROP_EXPAND:
4056 g_value_set_boolean (value,
4057 ctk_widget_get_hexpand (widget) &&
4058 ctk_widget_get_vexpand (widget));
4059 break;
4060 case PROP_OPACITY:
4061 g_value_set_double (value, ctk_widget_get_opacity (widget));
4062 break;
4063 case PROP_SCALE_FACTOR:
4064 g_value_set_int (value, ctk_widget_get_scale_factor (widget));
4065 break;
4066 default:
4067 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'"
, "ctkwidget.c", 4067, ("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)
;
4068 break;
4069 }
4070}
4071
4072static void
4073_ctk_widget_emulate_press (CtkWidget *widget,
4074 const CdkEvent *event)
4075{
4076 CtkWidget *event_widget, *next_child, *parent;
4077 CdkEvent *press;
4078
4079 event_widget = ctk_get_event_widget ((CdkEvent *) event);
4080
4081 if (event_widget == widget)
4082 return;
4083
4084 if (event->type == CDK_TOUCH_BEGIN ||
4085 event->type == CDK_TOUCH_UPDATE ||
4086 event->type == CDK_TOUCH_END)
4087 {
4088 press = cdk_event_copy (event);
4089 press->type = CDK_TOUCH_BEGIN;
4090 }
4091 else if (event->type == CDK_BUTTON_PRESS ||
4092 event->type == CDK_BUTTON_RELEASE)
4093 {
4094 press = cdk_event_copy (event);
4095 press->type = CDK_BUTTON_PRESS;
4096 }
4097 else if (event->type == CDK_MOTION_NOTIFY)
4098 {
4099 press = cdk_event_new (CDK_BUTTON_PRESS);
4100 press->button.window = g_object_ref (event->motion.window)((__typeof__ (event->motion.window)) (g_object_ref) (event
->motion.window))
;
4101 press->button.time = event->motion.time;
4102 press->button.x = event->motion.x;
4103 press->button.y = event->motion.y;
4104 press->button.x_root = event->motion.x_root;
4105 press->button.y_root = event->motion.y_root;
4106 press->button.state = event->motion.state;
4107
4108 press->button.axes = g_memdup2 (event->motion.axes,
4109 sizeof (gdouble) *
4110 cdk_device_get_n_axes (event->motion.device));
4111
4112 if (event->motion.state & CDK_BUTTON3_MASK)
4113 press->button.button = 3;
4114 else if (event->motion.state & CDK_BUTTON2_MASK)
4115 press->button.button = 2;
4116 else
4117 {
4118 if ((event->motion.state & CDK_BUTTON1_MASK) == 0)
4119 g_critical ("Guessing button number 1 on generated button press event");
4120
4121 press->button.button = 1;
4122 }
4123
4124 cdk_event_set_device (press, cdk_event_get_device (event));
4125 cdk_event_set_source_device (press, cdk_event_get_source_device (event));
4126 }
4127 else
4128 return;
4129
4130 press->any.send_event = TRUE(!(0));
4131 next_child = event_widget;
4132 parent = _ctk_widget_get_parent (next_child);
4133
4134 while (parent != widget)
4135 {
4136 next_child = parent;
4137 parent = _ctk_widget_get_parent (parent);
4138 }
4139
4140 /* Perform propagation state starting from the next child in the chain */
4141 if (!_ctk_propagate_captured_event (event_widget, press, next_child))
4142 ctk_propagate_event (event_widget, press);
4143
4144 cdk_event_free (press);
4145}
4146
4147static const CdkEvent *
4148_ctk_widget_get_last_event (CtkWidget *widget,
4149 CdkEventSequence *sequence)
4150{
4151 CtkWidgetPrivate *priv = widget->priv;
4152 EventControllerData *data;
4153 const CdkEvent *event;
4154 GList *l;
4155
4156 for (l = priv->event_controllers; l; l = l->next)
4157 {
4158 data = l->data;
4159
4160 if (!CTK_IS_GESTURE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_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; }))))
)
4161 continue;
4162
4163 event = ctk_gesture_get_last_event (CTK_GESTURE (data->controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), ((ctk_gesture_get_type ()))))))
,
4164 sequence);
4165 if (event)
4166 return event;
4167 }
4168
4169 return NULL((void*)0);
4170}
4171
4172static gboolean
4173_ctk_widget_get_emulating_sequence (CtkWidget *widget,
4174 CdkEventSequence *sequence,
4175 CdkEventSequence **sequence_out)
4176{
4177 CtkWidgetPrivate *priv = widget->priv;
4178 GList *l;
4179
4180 *sequence_out = sequence;
4181
4182 if (sequence)
4183 {
4184 const CdkEvent *last_event;
4185
4186 last_event = _ctk_widget_get_last_event (widget, sequence);
4187
4188 if (last_event &&
4189 (last_event->type == CDK_TOUCH_BEGIN ||
4190 last_event->type == CDK_TOUCH_UPDATE ||
4191 last_event->type == CDK_TOUCH_END) &&
4192 last_event->touch.emulating_pointer)
4193 return TRUE(!(0));
4194 }
4195 else
4196 {
4197 /* For a NULL(pointer) sequence, find the pointer emulating one */
4198 for (l = priv->event_controllers; l; l = l->next)
4199 {
4200 EventControllerData *data = l->data;
4201
4202 if (!CTK_IS_GESTURE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_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; }))))
)
4203 continue;
4204
4205 if (_ctk_gesture_get_pointer_emulating_sequence (CTK_GESTURE (data->controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), ((ctk_gesture_get_type ()))))))
,
4206 sequence_out))
4207 return TRUE(!(0));
4208 }
4209 }
4210
4211 return FALSE(0);
4212}
4213
4214static gboolean
4215ctk_widget_needs_press_emulation (CtkWidget *widget,
4216 CdkEventSequence *sequence)
4217{
4218 CtkWidgetPrivate *priv = widget->priv;
4219 gboolean sequence_press_handled = FALSE(0);
4220 GList *l;
4221
4222 /* Check whether there is any remaining gesture in
4223 * the capture phase that handled the press event
4224 */
4225 for (l = priv->event_controllers; l; l = l->next)
4226 {
4227 EventControllerData *data;
4228 CtkPropagationPhase phase;
4229 CtkGesture *gesture;
4230
4231 data = l->data;
4232 phase = ctk_event_controller_get_propagation_phase (data->controller);
4233
4234 if (phase != CTK_PHASE_CAPTURE)
4235 continue;
4236 if (!CTK_IS_GESTURE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_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; }))))
)
4237 continue;
4238
4239 gesture = CTK_GESTURE (data->controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), ((ctk_gesture_get_type ()))))))
;
4240 sequence_press_handled |=
4241 (ctk_gesture_handles_sequence (gesture, sequence) &&
4242 _ctk_gesture_handled_sequence_press (gesture, sequence));
4243 }
4244
4245 return !sequence_press_handled;
4246}
4247
4248static gint
4249_ctk_widget_set_sequence_state_internal (CtkWidget *widget,
4250 CdkEventSequence *sequence,
4251 CtkEventSequenceState state,
4252 CtkGesture *emitter)
4253{
4254 gboolean emulates_pointer, sequence_handled = FALSE(0);
4255 CtkWidgetPrivate *priv = widget->priv;
4256 const CdkEvent *mimic_event;
4257 GList *group = NULL((void*)0), *l;
4258 CdkEventSequence *seq;
4259 gint n_handled = 0;
4260
4261 if (!priv->event_controllers && state != CTK_EVENT_SEQUENCE_CLAIMED)
4262 return TRUE(!(0));
4263
4264 if (emitter)
4265 group = ctk_gesture_get_group (emitter);
4266
4267 emulates_pointer = _ctk_widget_get_emulating_sequence (widget, sequence, &seq);
4268 mimic_event = _ctk_widget_get_last_event (widget, seq);
4269
4270 for (l = priv->event_controllers; l; l = l->next)
4271 {
4272 CtkEventSequenceState gesture_state;
4273 EventControllerData *data;
4274 CtkGesture *gesture;
4275 gboolean retval;
4276
4277 seq = sequence;
4278 data = l->data;
4279 gesture_state = state;
4280
4281 if (!CTK_IS_GESTURE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_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; }))))
)
4282 continue;
4283
4284 gesture = CTK_GESTURE (data->controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), ((ctk_gesture_get_type ()))))))
;
4285
4286 if (gesture == emitter)
4287 {
4288 sequence_handled |=
4289 _ctk_gesture_handled_sequence_press (gesture, sequence);
4290 n_handled++;
4291 continue;
4292 }
4293
4294 if (seq && emulates_pointer &&
4295 !ctk_gesture_handles_sequence (gesture, seq))
4296 seq = NULL((void*)0);
4297
4298 if (group && !g_list_find (group, data->controller))
4299 {
4300 /* If a group is provided, ensure only gestures pertaining to the group
4301 * get a "claimed" state, all other claiming gestures must deny the sequence.
4302 */
4303 if (gesture_state == CTK_EVENT_SEQUENCE_CLAIMED &&
4304 ctk_gesture_get_sequence_state (gesture, sequence) == CTK_EVENT_SEQUENCE_CLAIMED)
4305 gesture_state = CTK_EVENT_SEQUENCE_DENIED;
4306 else
4307 continue;
4308 }
4309 else if (!group &&
4310 ctk_gesture_get_sequence_state (gesture, sequence) != CTK_EVENT_SEQUENCE_CLAIMED)
4311 continue;
4312
4313 g_signal_handler_block (data->controller, data->sequence_state_changed_id);
4314 retval = ctk_gesture_set_sequence_state (gesture, seq, gesture_state);
4315 g_signal_handler_unblock (data->controller, data->sequence_state_changed_id);
4316
4317 if (retval || gesture == emitter)
4318 {
4319 sequence_handled |=
4320 _ctk_gesture_handled_sequence_press (gesture, seq);
4321 n_handled++;
4322 }
4323 }
4324
4325 /* If the sequence goes denied, check whether this is a controller attached
4326 * to the capture phase, that additionally handled the button/touch press (i.e.
4327 * it was consumed), the corresponding press will be emulated for widgets
4328 * beneath, so the widgets beneath get a coherent stream of events from now on.
4329 */
4330 if (n_handled > 0 && sequence_handled &&
4331 state == CTK_EVENT_SEQUENCE_DENIED &&
4332 ctk_widget_needs_press_emulation (widget, sequence))
4333 _ctk_widget_emulate_press (widget, mimic_event);
4334
4335 g_list_free (group);
4336
4337 return n_handled;
4338}
4339
4340static gboolean
4341_ctk_widget_cancel_sequence (CtkWidget *widget,
4342 CdkEventSequence *sequence)
4343{
4344 CtkWidgetPrivate *priv = widget->priv;
4345 gboolean emulates_pointer;
4346 gboolean handled = FALSE(0);
4347 CdkEventSequence *seq;
4348 GList *l;
4349
4350 emulates_pointer = _ctk_widget_get_emulating_sequence (widget, sequence, &seq);
4351
4352 for (l = priv->event_controllers; l; l = l->next)
4353 {
4354 EventControllerData *data;
4355 CtkGesture *gesture;
4356
4357 seq = sequence;
4358 data = l->data;
4359
4360 if (!CTK_IS_GESTURE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_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; }))))
)
4361 continue;
4362
4363 gesture = CTK_GESTURE (data->controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), ((ctk_gesture_get_type ()))))))
;
4364
4365 if (seq && emulates_pointer &&
4366 !ctk_gesture_handles_sequence (gesture, seq))
4367 seq = NULL((void*)0);
4368
4369 if (!ctk_gesture_handles_sequence (gesture, seq))
4370 continue;
4371
4372 handled |= _ctk_gesture_cancel_sequence (gesture, seq);
4373 }
4374
4375 return handled;
4376}
4377
4378static void
4379ctk_widget_init (GTypeInstance *instance, gpointer g_class)
4380{
4381 CtkWidget *widget = CTK_WIDGET (instance)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instance)), ((ctk_widget_get_type ()))))))
;
4382 CtkWidgetPrivate *priv;
4383
4384 widget->priv = ctk_widget_get_instance_private (widget);
4385 priv = widget->priv;
4386
4387 priv->child_visible = TRUE(!(0));
4388 priv->name = NULL((void*)0);
4389 priv->allocation.x = -1;
4390 priv->allocation.y = -1;
4391 priv->allocation.width = 1;
4392 priv->allocation.height = 1;
4393 priv->user_alpha = 255;
4394 priv->alpha = 255;
4395 priv->window = NULL((void*)0);
4396 priv->parent = NULL((void*)0);
4397
4398 priv->sensitive = TRUE(!(0));
4399 priv->composite_child = composite_child_stack != 0;
4400 priv->double_buffered = TRUE(!(0));
4401 priv->redraw_on_alloc = TRUE(!(0));
4402 priv->alloc_needed = TRUE(!(0));
4403 priv->alloc_needed_on_child = TRUE(!(0));
4404 priv->focus_on_click = TRUE(!(0));
4405#ifdef G_ENABLE_DEBUG1
4406 priv->highlight_resize = FALSE(0);
4407#endif
4408
4409 switch (_ctk_widget_get_direction (widget))
4410 {
4411 case CTK_TEXT_DIR_LTR:
4412 priv->state_flags = CTK_STATE_FLAG_DIR_LTR;
4413 break;
4414
4415 case CTK_TEXT_DIR_RTL:
4416 priv->state_flags = CTK_STATE_FLAG_DIR_RTL;
4417 break;
4418
4419 case CTK_TEXT_DIR_NONE:
4420 default:
4421 g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkwidget.c", 4421, ((
const char*) (__func__)), ((void*)0)); } while (0)
;
4422 break;
4423 }
4424
4425 /* this will be set to TRUE if the widget gets a child or if the
4426 * expand flag is set on the widget, but until one of those happen
4427 * we know the expand is already properly FALSE.
4428 *
4429 * We really want to default FALSE here to avoid computing expand
4430 * all over the place while initially building a widget tree.
4431 */
4432 priv->need_compute_expand = FALSE(0);
4433
4434 priv->halign = CTK_ALIGN_FILL;
4435 priv->valign = CTK_ALIGN_FILL;
4436
4437 priv->width = -1;
4438 priv->height = -1;
4439
4440 _ctk_size_request_cache_init (&priv->requests);
4441
4442 priv->cssnode = ctk_css_widget_node_new (widget);
4443 ctk_css_node_set_state (priv->cssnode, priv->state_flags);
4444 /* need to set correct type here, and only class has the correct type here */
4445 ctk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class)(((GTypeClass*) (g_class))->g_type));
4446 ctk_css_node_set_name (priv->cssnode, CTK_WIDGET_CLASS (g_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((g_class)), ((ctk_widget_get_type ()))))))
->priv->css_name);
4447
4448 priv->style = ctk_widget_get_default_style ();
4449
4450 g_object_ref (priv->style)((__typeof__ (priv->style)) (g_object_ref) (priv->style
))
;
4451}
4452
4453
4454static void
4455ctk_widget_dispatch_child_properties_changed (CtkWidget *widget,
4456 guint n_pspecs,
4457 GParamSpec **pspecs)
4458{
4459 CtkWidgetPrivate *priv = widget->priv;
4460 CtkWidget *container = priv->parent;
4461 guint i;
4462
4463 for (i = 0; widget->priv->parent == container && i < n_pspecs; i++)
4464 g_signal_emit (widget, widget_signals[CHILD_NOTIFY], g_param_spec_get_name_quark (pspecs[i]), pspecs[i]);
4465}
4466
4467/**
4468 * ctk_widget_freeze_child_notify:
4469 * @widget: a #CtkWidget
4470 *
4471 * Stops emission of #CtkWidget::child-notify signals on @widget. The
4472 * signals are queued until ctk_widget_thaw_child_notify() is called
4473 * on @widget.
4474 *
4475 * This is the analogue of g_object_freeze_notify() for child properties.
4476 **/
4477void
4478ctk_widget_freeze_child_notify (CtkWidget *widget)
4479{
4480 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4481
4482 if (!G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
->ref_count)
4483 return;
4484
4485 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
4486 g_object_notify_queue_freeze (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, _ctk_widget_child_property_notify_context);
4487 g_object_unref (widget);
4488}
4489
4490/**
4491 * ctk_widget_child_notify:
4492 * @widget: a #CtkWidget
4493 * @child_property: the name of a child property installed on the
4494 * class of @widget’s parent
4495 *
4496 * Emits a #CtkWidget::child-notify signal for the
4497 * [child property][child-properties] @child_property
4498 * on @widget.
4499 *
4500 * This is the analogue of g_object_notify() for child properties.
4501 *
4502 * Also see ctk_container_child_notify().
4503 */
4504void
4505ctk_widget_child_notify (CtkWidget *widget,
4506 const gchar *child_property)
4507{
4508 if (widget->priv->parent == NULL((void*)0))
4509 return;
4510
4511 ctk_container_child_notify (CTK_CONTAINER (widget->priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget->priv->parent)), ((ctk_container_get_type (
)))))))
, widget, child_property);
4512}
4513
4514/**
4515 * ctk_widget_thaw_child_notify:
4516 * @widget: a #CtkWidget
4517 *
4518 * Reverts the effect of a previous call to ctk_widget_freeze_child_notify().
4519 * This causes all queued #CtkWidget::child-notify signals on @widget to be
4520 * emitted.
4521 */
4522void
4523ctk_widget_thaw_child_notify (CtkWidget *widget)
4524{
4525 GObjectNotifyQueue *nqueue;
4526
4527 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4528
4529 if (!G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
->ref_count)
4530 return;
4531
4532 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
4533 nqueue = g_object_notify_queue_from_object (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, _ctk_widget_child_property_notify_context);
4534 if (!nqueue || !nqueue->freeze_count)
4535 g_warning (G_STRLOC"ctkwidget.c" ":" "4535" ": child-property-changed notification for %s(%p) is not frozen",
4536 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
4537 else
4538 g_object_notify_queue_thaw (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, nqueue);
4539 g_object_unref (widget);
4540}
4541
4542
4543/**
4544 * ctk_widget_new:
4545 * @type: type ID of the widget to create
4546 * @first_property_name: name of first property to set
4547 * @...: value of first property, followed by more properties,
4548 * %NULL-terminated
4549 *
4550 * This is a convenience function for creating a widget and setting
4551 * its properties in one go. For example you might write:
4552 * `ctk_widget_new (CTK_TYPE_LABEL, "label", "Hello World", "xalign",
4553 * 0.0, NULL)` to create a left-aligned label. Equivalent to
4554 * g_object_new(), but returns a widget so you don’t have to
4555 * cast the object yourself.
4556 *
4557 * Returns: a new #CtkWidget of type @widget_type
4558 **/
4559CtkWidget*
4560ctk_widget_new (GType type,
4561 const gchar *first_property_name,
4562 ...)
4563{
4564 CtkWidget *widget;
4565 va_list var_args;
4566
4567 g_return_val_if_fail (g_type_is_a (type, CTK_TYPE_WIDGET), NULL)do { if ((((type) == ((ctk_widget_get_type ())) || (g_type_is_a
) ((type), ((ctk_widget_get_type ())))))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "g_type_is_a (type, CTK_TYPE_WIDGET)"
); return (((void*)0)); } } while (0)
;
4568
4569 va_start (var_args, first_property_name)__builtin_va_start(var_args, first_property_name);
4570 widget = (CtkWidget *)g_object_new_valist (type, first_property_name, var_args);
4571 va_end (var_args)__builtin_va_end(var_args);
4572
4573 return widget;
4574}
4575
4576static inline void
4577ctk_widget_queue_draw_child (CtkWidget *widget)
4578{
4579 CtkWidgetPrivate *priv = widget->priv;
4580 CtkWidget *parent;
4581
4582 parent = priv->parent;
4583 if (parent && _ctk_widget_is_drawable (parent))
4584 ctk_widget_queue_draw_area (parent,
4585 priv->clip.x,
4586 priv->clip.y,
4587 priv->clip.width,
4588 priv->clip.height);
4589}
4590
4591/**
4592 * ctk_widget_unparent:
4593 * @widget: a #CtkWidget
4594 *
4595 * This function is only for use in widget implementations.
4596 * Should be called by implementations of the remove method
4597 * on #CtkContainer, to dissociate a child from the container.
4598 **/
4599void
4600ctk_widget_unparent (CtkWidget *widget)
4601{
4602 CtkWidgetPrivate *priv;
4603 GObjectNotifyQueue *nqueue;
4604 CtkWidget *toplevel;
4605 CtkWidget *old_parent;
4606
4607 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4608
4609 priv = widget->priv;
4610
4611 if (priv->parent == NULL((void*)0))
4612 return;
4613
4614 /* keep this function in sync with ctk_menu_detach() */
4615
4616 ctk_widget_push_verify_invariants (widget);
4617
4618 g_object_freeze_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
4619 nqueue = g_object_notify_queue_freeze (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, _ctk_widget_child_property_notify_context);
4620
4621 toplevel = _ctk_widget_get_toplevel (widget);
4622 if (_ctk_widget_is_toplevel (toplevel))
4623 _ctk_window_unset_focus_and_default (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
, widget);
4624
4625 if (ctk_container_get_focus_child (CTK_CONTAINER (priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->parent)), ((ctk_container_get_type ()))))))
) == widget)
4626 ctk_container_set_focus_child (CTK_CONTAINER (priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->parent)), ((ctk_container_get_type ()))))))
, NULL((void*)0));
4627
4628 ctk_widget_queue_draw_child (widget);
4629
4630 /* Reset the width and height here, to force reallocation if we
4631 * get added back to a new parent. This won't work if our new
4632 * allocation is smaller than 1x1 and we actually want a size of 1x1...
4633 * (would 0x0 be OK here?)
4634 */
4635 priv->allocation.width = 1;
4636 priv->allocation.height = 1;
4637
4638 if (_ctk_widget_get_realized (widget))
4639 {
4640 if (priv->in_reparent)
4641 ctk_widget_unmap (widget);
4642 else
4643 ctk_widget_unrealize (widget);
4644 }
4645
4646 /* If we are unanchoring the child, we save around the toplevel
4647 * to emit hierarchy changed
4648 */
4649 if (priv->parent->priv->anchored)
4650 g_object_ref (toplevel)((__typeof__ (toplevel)) (g_object_ref) (toplevel));
4651 else
4652 toplevel = NULL((void*)0);
4653
4654 /* Removing a widget from a container restores the child visible
4655 * flag to the default state, so it doesn't affect the child
4656 * in the next parent.
4657 */
4658 priv->child_visible = TRUE(!(0));
4659
4660 old_parent = priv->parent;
4661 priv->parent = NULL((void*)0);
4662
4663 /* parent may no longer expand if the removed
4664 * child was expand=TRUE and could therefore
4665 * be forcing it to.
4666 */
4667 if (_ctk_widget_get_visible (widget) &&
4668 (priv->need_compute_expand ||
4669 priv->computed_hexpand ||
4670 priv->computed_vexpand))
4671 {
4672 ctk_widget_queue_compute_expand (old_parent);
4673 }
4674
4675 /* Unset BACKDROP since we are no longer inside a toplevel window */
4676 ctk_widget_unset_state_flags (widget, CTK_STATE_FLAG_BACKDROP);
4677 if (priv->context)
4678 ctk_style_context_set_parent (priv->context, NULL((void*)0));
4679 ctk_css_node_set_parent (widget->priv->cssnode, NULL((void*)0));
4680
4681 _ctk_widget_update_parent_muxer (widget);
4682
4683 g_signal_emit (widget, widget_signals[PARENT_SET], 0, old_parent);
4684 if (toplevel)
4685 {
4686 _ctk_widget_propagate_hierarchy_changed (widget, toplevel);
4687 g_object_unref (toplevel);
4688 }
4689
4690 /* Now that the parent pointer is nullified and the hierarchy-changed
4691 * already passed, go ahead and unset the parent window, if we are unparenting
4692 * an embedded CtkWindow the window will become toplevel again and hierarchy-changed
4693 * will fire again for the new subhierarchy.
4694 */
4695 ctk_widget_set_parent_window (widget, NULL((void*)0));
4696
4697 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_PARENT]);
4698 g_object_thaw_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
4699 if (!priv->parent)
4700 g_object_notify_queue_clear (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, nqueue);
4701 g_object_notify_queue_thaw (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, nqueue);
4702
4703 ctk_widget_pop_verify_invariants (widget);
4704 g_object_unref (widget);
4705}
4706
4707/**
4708 * ctk_widget_destroy:
4709 * @widget: a #CtkWidget
4710 *
4711 * Destroys a widget.
4712 *
4713 * When a widget is destroyed all references it holds on other objects
4714 * will be released:
4715 *
4716 * - if the widget is inside a container, it will be removed from its
4717 * parent
4718 * - if the widget is a container, all its children will be destroyed,
4719 * recursively
4720 * - if the widget is a top level, it will be removed from the list
4721 * of top level widgets that CTK+ maintains internally
4722 *
4723 * It's expected that all references held on the widget will also
4724 * be released; you should connect to the #CtkWidget::destroy signal
4725 * if you hold a reference to @widget and you wish to remove it when
4726 * this function is called. It is not necessary to do so if you are
4727 * implementing a #CtkContainer, as you'll be able to use the
4728 * #CtkContainerClass.remove() virtual function for that.
4729 *
4730 * It's important to notice that ctk_widget_destroy() will only cause
4731 * the @widget to be finalized if no additional references, acquired
4732 * using g_object_ref(), are held on it. In case additional references
4733 * are in place, the @widget will be in an "inert" state after calling
4734 * this function; @widget will still point to valid memory, allowing you
4735 * to release the references you hold, but you may not query the widget's
4736 * own state.
4737 *
4738 * You should typically call this function on top level widgets, and
4739 * rarely on child widgets.
4740 *
4741 * See also: ctk_container_remove()
4742 */
4743void
4744ctk_widget_destroy (CtkWidget *widget)
4745{
4746 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4747
4748 if (!widget->priv->in_destruction)
4749 g_object_run_dispose (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
4750}
4751
4752/**
4753 * ctk_widget_destroyed:
4754 * @widget: a #CtkWidget
4755 * @widget_pointer: (inout) (transfer none): address of a variable that contains @widget
4756 *
4757 * This function sets *@widget_pointer to %NULL if @widget_pointer !=
4758 * %NULL. It’s intended to be used as a callback connected to the
4759 * “destroy” signal of a widget. You connect ctk_widget_destroyed()
4760 * as a signal handler, and pass the address of your widget variable
4761 * as user data. Then when the widget is destroyed, the variable will
4762 * be set to %NULL. Useful for example to avoid multiple copies
4763 * of the same dialog.
4764 **/
4765void
4766ctk_widget_destroyed (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
4767 CtkWidget **widget_pointer)
4768{
4769 /* Don't make any assumptions about the
4770 * value of widget!
4771 * Even check widget_pointer.
4772 */
4773 if (widget_pointer)
4774 *widget_pointer = NULL((void*)0);
4775}
4776
4777/**
4778 * ctk_widget_show:
4779 * @widget: a #CtkWidget
4780 *
4781 * Flags a widget to be displayed. Any widget that isn’t shown will
4782 * not appear on the screen. If you want to show all the widgets in a
4783 * container, it’s easier to call ctk_widget_show_all() on the
4784 * container, instead of individually showing the widgets.
4785 *
4786 * Remember that you have to show the containers containing a widget,
4787 * in addition to the widget itself, before it will appear onscreen.
4788 *
4789 * When a toplevel container is shown, it is immediately realized and
4790 * mapped; other shown widgets are realized and mapped when their
4791 * toplevel container is realized and mapped.
4792 **/
4793void
4794ctk_widget_show (CtkWidget *widget)
4795{
4796 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4797
4798 if (!_ctk_widget_get_visible (widget))
4799 {
4800 CtkWidget *parent;
4801
4802 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
4803 ctk_widget_push_verify_invariants (widget);
4804
4805 parent = _ctk_widget_get_parent (widget);
4806 if (parent)
4807 {
4808 ctk_widget_queue_resize (parent);
4809
4810 /* see comment in set_parent() for why this should and can be
4811 * conditional
4812 */
4813 if (widget->priv->need_compute_expand ||
4814 widget->priv->computed_hexpand ||
4815 widget->priv->computed_vexpand)
4816 ctk_widget_queue_compute_expand (parent);
4817 }
4818
4819 ctk_css_node_set_visible (widget->priv->cssnode, TRUE(!(0)));
4820
4821 g_signal_emit (widget, widget_signals[SHOW], 0);
4822 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_VISIBLE]);
4823
4824 ctk_widget_pop_verify_invariants (widget);
4825 g_object_unref (widget);
4826 }
4827}
4828
4829static void
4830ctk_widget_real_show (CtkWidget *widget)
4831{
4832 CtkWidgetPrivate *priv = widget->priv;
4833
4834 if (!_ctk_widget_get_visible (widget))
4835 {
4836 priv->visible = TRUE(!(0));
4837
4838 if (priv->parent &&
4839 _ctk_widget_get_mapped (priv->parent) &&
4840 _ctk_widget_get_child_visible (widget) &&
4841 !_ctk_widget_get_mapped (widget))
4842 ctk_widget_map (widget);
4843 }
4844}
4845
4846static void
4847ctk_widget_show_map_callback (CtkWidget *widget,
4848 CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)),
4849 gint *flag)
4850{
4851 *flag = TRUE(!(0));
4852 g_signal_handlers_disconnect_by_func (widget,g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (ctk_widget_show_map_callback), (flag))
4853 ctk_widget_show_map_callback,g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (ctk_widget_show_map_callback), (flag))
4854 flag)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (ctk_widget_show_map_callback), (flag))
;
4855}
4856
4857/**
4858 * ctk_widget_show_now:
4859 * @widget: a #CtkWidget
4860 *
4861 * Shows a widget. If the widget is an unmapped toplevel widget
4862 * (i.e. a #CtkWindow that has not yet been shown), enter the main
4863 * loop and wait for the window to actually be mapped. Be careful;
4864 * because the main loop is running, anything can happen during
4865 * this function.
4866 **/
4867void
4868ctk_widget_show_now (CtkWidget *widget)
4869{
4870 gint flag = FALSE(0);
4871
4872 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4873
4874 /* make sure we will get event */
4875 if (!_ctk_widget_get_mapped (widget) &&
4876 _ctk_widget_is_toplevel (widget))
4877 {
4878 ctk_widget_show (widget);
4879
4880 g_signal_connect (widget, "map-event",g_signal_connect_data ((widget), ("map-event"), (((GCallback)
(ctk_widget_show_map_callback))), (&flag), ((void*)0), (
GConnectFlags) 0)
4881 G_CALLBACK (ctk_widget_show_map_callback),g_signal_connect_data ((widget), ("map-event"), (((GCallback)
(ctk_widget_show_map_callback))), (&flag), ((void*)0), (
GConnectFlags) 0)
4882 &flag)g_signal_connect_data ((widget), ("map-event"), (((GCallback)
(ctk_widget_show_map_callback))), (&flag), ((void*)0), (
GConnectFlags) 0)
;
4883
4884 while (!flag)
4885 ctk_main_iteration ();
4886 }
4887 else
4888 ctk_widget_show (widget);
4889}
4890
4891/**
4892 * ctk_widget_hide:
4893 * @widget: a #CtkWidget
4894 *
4895 * Reverses the effects of ctk_widget_show(), causing the widget to be
4896 * hidden (invisible to the user).
4897 **/
4898void
4899ctk_widget_hide (CtkWidget *widget)
4900{
4901 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4902
4903 if (_ctk_widget_get_visible (widget))
4904 {
4905 CtkWidget *toplevel = _ctk_widget_get_toplevel (widget);
4906 CtkWidget *parent;
4907
4908 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
4909 ctk_widget_push_verify_invariants (widget);
4910
4911 if (toplevel != widget && _ctk_widget_is_toplevel (toplevel))
4912 _ctk_window_unset_focus_and_default (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
, widget);
4913
4914 /* a parent may now be expand=FALSE since we're hidden. */
4915 if (widget->priv->need_compute_expand ||
4916 widget->priv->computed_hexpand ||
4917 widget->priv->computed_vexpand)
4918 {
4919 ctk_widget_queue_compute_expand (widget);
4920 }
4921
4922 ctk_css_node_set_visible (widget->priv->cssnode, FALSE(0));
4923
4924 g_signal_emit (widget, widget_signals[HIDE], 0);
4925 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_VISIBLE]);
4926
4927 parent = ctk_widget_get_parent (widget);
4928 if (parent)
4929 ctk_widget_queue_resize (parent);
4930
4931 ctk_widget_queue_allocate (widget);
4932
4933 ctk_widget_pop_verify_invariants (widget);
4934 g_object_unref (widget);
4935 }
4936}
4937
4938static void
4939ctk_widget_real_hide (CtkWidget *widget)
4940{
4941 if (_ctk_widget_get_visible (widget))
4942 {
4943 widget->priv->visible = FALSE(0);
4944
4945 if (_ctk_widget_get_mapped (widget))
4946 ctk_widget_unmap (widget);
4947 }
4948}
4949
4950/**
4951 * ctk_widget_hide_on_delete:
4952 * @widget: a #CtkWidget
4953 *
4954 * Utility function; intended to be connected to the #CtkWidget::delete-event
4955 * signal on a #CtkWindow. The function calls ctk_widget_hide() on its
4956 * argument, then returns %TRUE. If connected to ::delete-event, the
4957 * result is that clicking the close button for a window (on the
4958 * window frame, top right corner usually) will hide but not destroy
4959 * the window. By default, CTK+ destroys windows when ::delete-event
4960 * is received.
4961 *
4962 * Returns: %TRUE
4963 **/
4964gboolean
4965ctk_widget_hide_on_delete (CtkWidget *widget)
4966{
4967 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
4968
4969 ctk_widget_hide (widget);
4970
4971 return TRUE(!(0));
4972}
4973
4974/**
4975 * ctk_widget_show_all:
4976 * @widget: a #CtkWidget
4977 *
4978 * Recursively shows a widget, and any child widgets (if the widget is
4979 * a container).
4980 **/
4981void
4982ctk_widget_show_all (CtkWidget *widget)
4983{
4984 CtkWidgetClass *class;
4985
4986 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
4987
4988 if (ctk_widget_get_no_show_all (widget))
4989 return;
4990
4991 class = CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
;
4992
4993 if (class->show_all)
4994 class->show_all (widget);
4995}
4996
4997/**
4998 * ctk_widget_map:
4999 * @widget: a #CtkWidget
5000 *
5001 * This function is only for use in widget implementations. Causes
5002 * a widget to be mapped if it isn’t already.
5003 **/
5004void
5005ctk_widget_map (CtkWidget *widget)
5006{
5007 CtkWidgetPrivate *priv;
5008
5009 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5010 g_return_if_fail (_ctk_widget_get_visible (widget))do { if ((_ctk_widget_get_visible (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "_ctk_widget_get_visible (widget)"
); return; } } while (0)
;
5011 g_return_if_fail (_ctk_widget_get_child_visible (widget))do { if ((_ctk_widget_get_child_visible (widget))) { } else {
g_return_if_fail_warning ("Ctk", ((const char*) (__func__)),
"_ctk_widget_get_child_visible (widget)"); return; } } while
(0)
;
5012
5013 priv = widget->priv;
5014
5015 if (!_ctk_widget_get_mapped (widget))
5016 {
5017 ctk_widget_push_verify_invariants (widget);
5018
5019 if (!_ctk_widget_get_realized (widget))
5020 ctk_widget_realize (widget);
5021
5022 g_signal_emit (widget, widget_signals[MAP], 0);
5023
5024 if (!_ctk_widget_get_has_window (widget))
5025 cdk_window_invalidate_rect (priv->window, &priv->clip, FALSE(0));
5026
5027 ctk_widget_pop_verify_invariants (widget);
5028 }
5029}
5030
5031/**
5032 * ctk_widget_unmap:
5033 * @widget: a #CtkWidget
5034 *
5035 * This function is only for use in widget implementations. Causes
5036 * a widget to be unmapped if it’s currently mapped.
5037 **/
5038void
5039ctk_widget_unmap (CtkWidget *widget)
5040{
5041 CtkWidgetPrivate *priv;
5042
5043 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5044
5045 priv = widget->priv;
5046
5047 if (_ctk_widget_get_mapped (widget))
5048 {
5049 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
5050 ctk_widget_push_verify_invariants (widget);
5051
5052 if (!_ctk_widget_get_has_window (widget))
5053 cdk_window_invalidate_rect (priv->window, &priv->clip, FALSE(0));
5054 _ctk_tooltip_hide (widget);
5055
5056 g_signal_emit (widget, widget_signals[UNMAP], 0);
5057
5058 ctk_widget_pop_verify_invariants (widget);
5059 g_object_unref (widget);
5060 }
5061}
5062
5063static void
5064_ctk_widget_enable_device_events (CtkWidget *widget)
5065{
5066 GHashTable *device_events;
5067 GHashTableIter iter;
5068 gpointer key, value;
5069
5070 device_events = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_device_event_mask);
5071
5072 if (!device_events)
5073 return;
5074
5075 g_hash_table_iter_init (&iter, device_events);
5076
5077 while (g_hash_table_iter_next (&iter, &key, &value))
5078 {
5079 CdkDevice *device;
5080 CdkEventMask event_mask;
5081
5082 device = key;
5083 event_mask = GPOINTER_TO_UINT (value)((guint) (gulong) (value));
5084 ctk_widget_add_events_internal (widget, device, event_mask);
5085 }
5086}
5087
5088typedef struct {
5089 CtkWidget *widget;
5090 CdkDevice *device;
5091 gboolean enabled;
5092} DeviceEnableData;
5093
5094static void
5095device_enable_foreach (CtkWidget *widget,
5096 gpointer user_data)
5097{
5098 DeviceEnableData *data = user_data;
5099 ctk_widget_set_device_enabled_internal (widget, data->device, TRUE(!(0)), data->enabled);
5100}
5101
5102static void
5103device_enable_foreach_window (gpointer win,
5104 gpointer user_data)
5105{
5106 CdkWindow *window = win;
5107 DeviceEnableData *data = user_data;
5108 CdkEventMask events;
5109 CtkWidget *window_widget;
5110 GList *window_list;
5111
5112 cdk_window_get_user_data (window, (gpointer *) &window_widget);
5113 if (data->widget != window_widget)
5114 return;
5115
5116 if (data->enabled)
5117 events = cdk_window_get_events (window);
5118 else
5119 events = 0;
5120
5121 cdk_window_set_device_events (window, data->device, events);
5122
5123 window_list = cdk_window_peek_children (window);
5124 g_list_foreach (window_list, device_enable_foreach_window, data);
5125}
5126
5127void
5128ctk_widget_set_device_enabled_internal (CtkWidget *widget,
5129 CdkDevice *device,
5130 gboolean recurse,
5131 gboolean enabled)
5132{
5133 DeviceEnableData data;
5134
5135 data.widget = widget;
5136 data.device = device;
5137 data.enabled = enabled;
5138
5139 if (_ctk_widget_get_has_window (widget))
5140 {
5141 CdkWindow *window;
5142
5143 window = _ctk_widget_get_window (widget);
5144 device_enable_foreach_window (window, &data);
5145 }
5146 else
5147 {
5148 GList *window_list;
5149
5150 window_list = cdk_window_peek_children (_ctk_widget_get_window (widget));
5151 g_list_foreach (window_list, device_enable_foreach_window, &data);
5152 }
5153
5154 if (recurse && CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
5155 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
, device_enable_foreach, &data);
5156}
5157
5158static void
5159ctk_widget_update_devices_mask (CtkWidget *widget,
5160 gboolean recurse)
5161{
5162 GList *enabled_devices, *l;
5163
5164 enabled_devices = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_enabled_devices);
5165
5166 for (l = enabled_devices; l; l = l->next)
5167 ctk_widget_set_device_enabled_internal (widget, CDK_DEVICE (l->data)((((CdkDevice*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), ((cdk_device_get_type ()))))))
, recurse, TRUE(!(0)));
5168}
5169
5170typedef struct _CtkTickCallbackInfo CtkTickCallbackInfo;
5171
5172struct _CtkTickCallbackInfo
5173{
5174 guint refcount;
5175
5176 guint id;
5177 CtkTickCallback callback;
5178 gpointer user_data;
5179 GDestroyNotify notify;
5180
5181 guint destroyed : 1;
5182};
5183
5184static void
5185ref_tick_callback_info (CtkTickCallbackInfo *info)
5186{
5187 info->refcount++;
5188}
5189
5190static void
5191unref_tick_callback_info (CtkWidget *widget,
5192 CtkTickCallbackInfo *info,
5193 GList *link)
5194{
5195 CtkWidgetPrivate *priv = widget->priv;
5196
5197 info->refcount--;
5198 if (info->refcount == 0)
5199 {
5200 priv->tick_callbacks = g_list_delete_link (priv->tick_callbacks, link);
5201 if (info->notify)
5202 info->notify (info->user_data);
5203 g_slice_free (CtkTickCallbackInfo, info)do { if (1) g_slice_free1 (sizeof (CtkTickCallbackInfo), (info
)); else (void) ((CtkTickCallbackInfo*) 0 == (info)); } while
(0)
;
5204 }
5205
5206 if (priv->tick_callbacks == NULL((void*)0) && priv->clock_tick_id)
5207 {
5208 CdkFrameClock *frame_clock = ctk_widget_get_frame_clock (widget);
5209 g_signal_handler_disconnect (frame_clock, priv->clock_tick_id);
5210 priv->clock_tick_id = 0;
5211 cdk_frame_clock_end_updating (frame_clock);
5212 }
5213}
5214
5215static void
5216destroy_tick_callback_info (CtkWidget *widget,
5217 CtkTickCallbackInfo *info,
5218 GList *link)
5219{
5220 if (!info->destroyed)
5221 {
5222 info->destroyed = TRUE(!(0));
5223 unref_tick_callback_info (widget, info, link);
5224 }
5225}
5226
5227static void
5228destroy_tick_callbacks (CtkWidget *widget)
5229{
5230 CtkWidgetPrivate *priv = widget->priv;
5231 GList *l;
5232
5233 for (l = priv->tick_callbacks; l;)
5234 {
5235 GList *next = l->next;
5236 destroy_tick_callback_info (widget, l->data, l);
5237 l = next;
5238 }
5239}
5240
5241static void
5242ctk_widget_on_frame_clock_update (CdkFrameClock *frame_clock,
5243 CtkWidget *widget)
5244{
5245 CtkWidgetPrivate *priv = widget->priv;
5246 GList *l;
5247
5248 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
5249
5250 for (l = priv->tick_callbacks; l;)
5251 {
5252 CtkTickCallbackInfo *info = l->data;
5253 GList *next;
5254
5255 ref_tick_callback_info (info);
5256 if (!info->destroyed)
5257 {
5258 if (info->callback (widget,
5259 frame_clock,
5260 info->user_data) == G_SOURCE_REMOVE(0))
5261 {
5262 destroy_tick_callback_info (widget, info, l);
5263 }
5264 }
5265
5266 next = l->next;
5267 unref_tick_callback_info (widget, info, l);
5268 l = next;
5269 }
5270
5271 g_object_unref (widget);
5272}
5273
5274static guint tick_callback_id;
5275
5276/**
5277 * ctk_widget_add_tick_callback:
5278 * @widget: a #CtkWidget
5279 * @callback: function to call for updating animations
5280 * @user_data: data to pass to @callback
5281 * @notify: function to call to free @user_data when the callback is removed.
5282 *
5283 * Queues an animation frame update and adds a callback to be called
5284 * before each frame. Until the tick callback is removed, it will be
5285 * called frequently (usually at the frame rate of the output device
5286 * or as quickly as the application can be repainted, whichever is
5287 * slower). For this reason, is most suitable for handling graphics
5288 * that change every frame or every few frames. The tick callback does
5289 * not automatically imply a relayout or repaint. If you want a
5290 * repaint or relayout, and aren’t changing widget properties that
5291 * would trigger that (for example, changing the text of a #CtkLabel),
5292 * then you will have to call ctk_widget_queue_resize() or
5293 * ctk_widget_queue_draw_area() yourself.
5294 *
5295 * cdk_frame_clock_get_frame_time() should generally be used for timing
5296 * continuous animations and
5297 * cdk_frame_timings_get_predicted_presentation_time() if you are
5298 * trying to display isolated frames at particular times.
5299 *
5300 * This is a more convenient alternative to connecting directly to the
5301 * #CdkFrameClock::update signal of #CdkFrameClock, since you don't
5302 * have to worry about when a #CdkFrameClock is assigned to a widget.
5303 *
5304 * Returns: an id for the connection of this callback. Remove the callback
5305 * by passing it to ctk_widget_remove_tick_callback()
5306 *
5307 * Since: 3.8
5308 */
5309guint
5310ctk_widget_add_tick_callback (CtkWidget *widget,
5311 CtkTickCallback callback,
5312 gpointer user_data,
5313 GDestroyNotify notify)
5314{
5315 CtkWidgetPrivate *priv;
5316 CtkTickCallbackInfo *info;
5317 CdkFrameClock *frame_clock;
5318
5319 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
5320
5321 priv = widget->priv;
5322
5323 if (priv->frameclock_connected && !priv->clock_tick_id)
5324 {
5325 frame_clock = ctk_widget_get_frame_clock (widget);
5326
5327 if (frame_clock)
5328 {
5329 priv->clock_tick_id = g_signal_connect (frame_clock, "update",g_signal_connect_data ((frame_clock), ("update"), (((GCallback
) (ctk_widget_on_frame_clock_update))), (widget), ((void*)0),
(GConnectFlags) 0)
5330 G_CALLBACK (ctk_widget_on_frame_clock_update),g_signal_connect_data ((frame_clock), ("update"), (((GCallback
) (ctk_widget_on_frame_clock_update))), (widget), ((void*)0),
(GConnectFlags) 0)
5331 widget)g_signal_connect_data ((frame_clock), ("update"), (((GCallback
) (ctk_widget_on_frame_clock_update))), (widget), ((void*)0),
(GConnectFlags) 0)
;
5332 cdk_frame_clock_begin_updating (frame_clock);
5333 }
5334 }
5335
5336 info = g_slice_new0 (CtkTickCallbackInfo)((CtkTickCallbackInfo*) g_slice_alloc0 ((sizeof (CtkTickCallbackInfo
) > 0 ? sizeof (CtkTickCallbackInfo) : 1)))
;
5337
5338 info->refcount = 1;
5339 info->id = ++tick_callback_id;
5340 info->callback = callback;
5341 info->user_data = user_data;
5342 info->notify = notify;
5343
5344 priv->tick_callbacks = g_list_prepend (priv->tick_callbacks,
5345 info);
5346
5347 return info->id;
5348}
5349
5350/**
5351 * ctk_widget_remove_tick_callback:
5352 * @widget: a #CtkWidget
5353 * @id: an id returned by ctk_widget_add_tick_callback()
5354 *
5355 * Removes a tick callback previously registered with
5356 * ctk_widget_add_tick_callback().
5357 *
5358 * Since: 3.8
5359 */
5360void
5361ctk_widget_remove_tick_callback (CtkWidget *widget,
5362 guint id)
5363{
5364 CtkWidgetPrivate *priv;
5365 GList *l;
5366
5367 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5368
5369 priv = widget->priv;
5370
5371 for (l = priv->tick_callbacks; l; l = l->next)
5372 {
5373 CtkTickCallbackInfo *info = l->data;
5374 if (info->id == id)
5375 {
5376 destroy_tick_callback_info (widget, info, l);
5377 return;
5378 }
5379 }
5380}
5381
5382gboolean
5383ctk_widget_has_tick_callback (CtkWidget *widget)
5384{
5385 return widget->priv->tick_callbacks != NULL((void*)0);
5386}
5387
5388static void
5389ctk_widget_connect_frame_clock (CtkWidget *widget,
5390 CdkFrameClock *frame_clock)
5391{
5392 CtkWidgetPrivate *priv = widget->priv;
5393
5394 priv->frameclock_connected = TRUE(!(0));
5395
5396 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
5397 _ctk_container_maybe_start_idle_sizer (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
);
5398
5399 if (priv->tick_callbacks != NULL((void*)0) && !priv->clock_tick_id)
5400 {
5401 priv->clock_tick_id = g_signal_connect (frame_clock, "update",g_signal_connect_data ((frame_clock), ("update"), (((GCallback
) (ctk_widget_on_frame_clock_update))), (widget), ((void*)0),
(GConnectFlags) 0)
5402 G_CALLBACK (ctk_widget_on_frame_clock_update),g_signal_connect_data ((frame_clock), ("update"), (((GCallback
) (ctk_widget_on_frame_clock_update))), (widget), ((void*)0),
(GConnectFlags) 0)
5403 widget)g_signal_connect_data ((frame_clock), ("update"), (((GCallback
) (ctk_widget_on_frame_clock_update))), (widget), ((void*)0),
(GConnectFlags) 0)
;
5404 cdk_frame_clock_begin_updating (frame_clock);
5405 }
5406
5407 ctk_css_node_invalidate_frame_clock (priv->cssnode, FALSE(0));
5408
5409 if (priv->context)
5410 ctk_style_context_set_frame_clock (priv->context, frame_clock);
5411}
5412
5413static void
5414ctk_widget_disconnect_frame_clock (CtkWidget *widget,
5415 CdkFrameClock *frame_clock)
5416{
5417 CtkWidgetPrivate *priv = widget->priv;
5418
5419 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
5420 _ctk_container_stop_idle_sizer (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
);
5421
5422 ctk_css_node_invalidate_frame_clock (priv->cssnode, FALSE(0));
5423
5424 if (priv->clock_tick_id)
5425 {
5426 g_signal_handler_disconnect (frame_clock, priv->clock_tick_id);
5427 priv->clock_tick_id = 0;
5428 cdk_frame_clock_end_updating (frame_clock);
5429 }
5430
5431 priv->frameclock_connected = FALSE(0);
5432
5433 if (priv->context)
5434 ctk_style_context_set_frame_clock (priv->context, NULL((void*)0));
5435}
5436
5437/**
5438 * ctk_widget_realize:
5439 * @widget: a #CtkWidget
5440 *
5441 * Creates the CDK (windowing system) resources associated with a
5442 * widget. For example, @widget->window will be created when a widget
5443 * is realized. Normally realization happens implicitly; if you show
5444 * a widget and all its parent containers, then the widget will be
5445 * realized and mapped automatically.
5446 *
5447 * Realizing a widget requires all
5448 * the widget’s parent widgets to be realized; calling
5449 * ctk_widget_realize() realizes the widget’s parents in addition to
5450 * @widget itself. If a widget is not yet inside a toplevel window
5451 * when you realize it, bad things will happen.
5452 *
5453 * This function is primarily used in widget implementations, and
5454 * isn’t very useful otherwise. Many times when you think you might
5455 * need it, a better approach is to connect to a signal that will be
5456 * called after the widget is realized automatically, such as
5457 * #CtkWidget::draw. Or simply g_signal_connect () to the
5458 * #CtkWidget::realize signal.
5459 **/
5460void
5461ctk_widget_realize (CtkWidget *widget)
5462{
5463 CtkWidgetPrivate *priv;
5464 cairo_region_t *region;
5465
5466 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5467 g_return_if_fail (widget->priv->anchored ||do { if ((widget->priv->anchored || (((__extension__ ({
GTypeInstance *__inst = (GTypeInstance*) ((widget)); GType __t
= ((ctk_invisible_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__)), "widget->priv->anchored || CTK_IS_INVISIBLE (widget)"
); return; } } while (0)
5468 CTK_IS_INVISIBLE (widget))do { if ((widget->priv->anchored || (((__extension__ ({
GTypeInstance *__inst = (GTypeInstance*) ((widget)); GType __t
= ((ctk_invisible_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__)), "widget->priv->anchored || CTK_IS_INVISIBLE (widget)"
); return; } } while (0)
;
5469
5470 priv = widget->priv;
5471
5472 if (!_ctk_widget_get_realized (widget))
5473 {
5474 ctk_widget_push_verify_invariants (widget);
5475
5476 /*
5477 if (CTK_IS_CONTAINER (widget) && _ctk_widget_get_has_window (widget))
5478 g_message ("ctk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
5479 */
5480
5481 if (priv->parent == NULL((void*)0) &&
5482 !_ctk_widget_is_toplevel (widget))
5483 g_warning ("Calling ctk_widget_realize() on a widget that isn't "
5484 "inside a toplevel window is not going to work very well. "
5485 "Widgets must be inside a toplevel container before realizing them.");
5486
5487 if (priv->parent && !_ctk_widget_get_realized (priv->parent))
5488 ctk_widget_realize (priv->parent);
5489
5490 ctk_widget_ensure_style (widget);
5491
5492 g_signal_emit (widget, widget_signals[REALIZE], 0);
5493
5494 ctk_widget_real_set_has_tooltip (widget, ctk_widget_get_has_tooltip (widget), TRUE(!(0)));
5495
5496 if (priv->has_shape_mask)
5497 {
5498 region = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_shape_info);
5499 cdk_window_shape_combine_region (priv->window, region, 0, 0);
5500 }
5501
5502 ctk_widget_update_input_shape (widget);
5503
5504 if (priv->multidevice)
5505 cdk_window_set_support_multidevice (priv->window, TRUE(!(0)));
5506
5507 _ctk_widget_enable_device_events (widget);
5508 ctk_widget_update_devices_mask (widget, TRUE(!(0)));
5509
5510 ctk_widget_update_alpha (widget);
5511
5512 if (priv->context)
5513 ctk_style_context_set_scale (priv->context, ctk_widget_get_scale_factor (widget));
5514 ctk_widget_connect_frame_clock (widget,
5515 ctk_widget_get_frame_clock (widget));
5516
5517 ctk_widget_pop_verify_invariants (widget);
5518 }
5519}
5520
5521/**
5522 * ctk_widget_unrealize:
5523 * @widget: a #CtkWidget
5524 *
5525 * This function is only useful in widget implementations.
5526 * Causes a widget to be unrealized (frees all CDK resources
5527 * associated with the widget, such as @widget->window).
5528 **/
5529void
5530ctk_widget_unrealize (CtkWidget *widget)
5531{
5532 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5533
5534 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
5535 ctk_widget_push_verify_invariants (widget);
5536
5537 if (widget->priv->has_shape_mask)
5538 ctk_widget_shape_combine_region (widget, NULL((void*)0));
5539
5540 if (g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_input_shape_info))
5541 ctk_widget_input_shape_combine_region (widget, NULL((void*)0));
5542
5543 if (_ctk_widget_get_realized (widget))
5544 {
5545 if (widget->priv->mapped)
5546 ctk_widget_unmap (widget);
5547
5548 ctk_widget_disconnect_frame_clock (widget,
5549 ctk_widget_get_frame_clock (widget));
5550
5551 g_signal_emit (widget, widget_signals[UNREALIZE], 0);
5552 g_assert (!widget->priv->mapped)do { if (!widget->priv->mapped) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 5552, ((const char*) (__func__)), "!widget->priv->mapped"
); } while (0)
;
5553 ctk_widget_set_realized (widget, FALSE(0));
5554 }
5555
5556 ctk_widget_pop_verify_invariants (widget);
5557 g_object_unref (widget);
5558}
5559
5560/*****************************************
5561 * Draw queueing.
5562 *****************************************/
5563
5564static void
5565ctk_widget_real_queue_draw_region (CtkWidget *widget,
5566 const cairo_region_t *region)
5567{
5568 CtkWidgetPrivate *priv = widget->priv;
5569
5570 cdk_window_invalidate_region (priv->window, region, TRUE(!(0)));
5571}
5572
5573/**
5574 * ctk_widget_queue_draw_region:
5575 * @widget: a #CtkWidget
5576 * @region: region to draw
5577 *
5578 * Invalidates the area of @widget defined by @region by calling
5579 * cdk_window_invalidate_region() on the widget’s window and all its
5580 * child windows. Once the main loop becomes idle (after the current
5581 * batch of events has been processed, roughly), the window will
5582 * receive expose events for the union of all regions that have been
5583 * invalidated.
5584 *
5585 * Normally you would only use this function in widget
5586 * implementations. You might also use it to schedule a redraw of a
5587 * #CtkDrawingArea or some portion thereof.
5588 *
5589 * Since: 3.0
5590 **/
5591void
5592ctk_widget_queue_draw_region (CtkWidget *widget,
5593 const cairo_region_t *region)
5594{
5595 CtkWidget *w;
5596
5597 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5598
5599 if (!_ctk_widget_get_realized (widget))
5600 return;
5601
5602 /* Just return if the widget or one of its ancestors isn't mapped */
5603 for (w = widget; w != NULL((void*)0); w = w->priv->parent)
5604 if (!_ctk_widget_get_mapped (w))
5605 return;
5606
5607 WIDGET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->queue_draw_region (widget, region);
5608}
5609
5610/**
5611 * ctk_widget_queue_draw_area:
5612 * @widget: a #CtkWidget
5613 * @x: x coordinate of upper-left corner of rectangle to redraw
5614 * @y: y coordinate of upper-left corner of rectangle to redraw
5615 * @width: width of region to draw
5616 * @height: height of region to draw
5617 *
5618 * Convenience function that calls ctk_widget_queue_draw_region() on
5619 * the region created from the given coordinates.
5620 *
5621 * The region here is specified in widget coordinates.
5622 * Widget coordinates are a bit odd; for historical reasons, they are
5623 * defined as @widget->window coordinates for widgets that return %TRUE for
5624 * ctk_widget_get_has_window(), and are relative to @widget->allocation.x,
5625 * @widget->allocation.y otherwise.
5626 *
5627 * @width or @height may be 0, in this case this function does
5628 * nothing. Negative values for @width and @height are not allowed.
5629 */
5630void
5631ctk_widget_queue_draw_area (CtkWidget *widget,
5632 gint x,
5633 gint y,
5634 gint width,
5635 gint height)
5636{
5637 CdkRectangle rect;
5638 cairo_region_t *region;
5639
5640 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5641 g_return_if_fail (width >= 0)do { if ((width >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= 0"); return
; } } while (0)
;
5642 g_return_if_fail (height >= 0)do { if ((height >= 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= 0"); return
; } } while (0)
;
5643
5644 if (width == 0 || height == 0)
5645 return;
5646
5647 rect.x = x;
5648 rect.y = y;
5649 rect.width = width;
5650 rect.height = height;
5651
5652 region = cairo_region_create_rectangle (&rect);
5653 ctk_widget_queue_draw_region (widget, region);
5654 cairo_region_destroy (region);
5655}
5656
5657/**
5658 * ctk_widget_queue_draw:
5659 * @widget: a #CtkWidget
5660 *
5661 * Equivalent to calling ctk_widget_queue_draw_area() for the
5662 * entire area of a widget.
5663 **/
5664void
5665ctk_widget_queue_draw (CtkWidget *widget)
5666{
5667 CdkRectangle rect;
5668
5669 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5670
5671 ctk_widget_get_clip (widget, &rect);
5672
5673 if (!_ctk_widget_get_has_window (widget))
5674 ctk_widget_queue_draw_area (widget,
5675 rect.x, rect.y, rect.width, rect.height);
5676 else
5677 ctk_widget_queue_draw_area (widget,
5678 0, 0, rect.width, rect.height);
5679}
5680
5681static void
5682ctk_widget_set_alloc_needed (CtkWidget *widget);
5683/**
5684 * ctk_widget_queue_allocate:
5685 * @widget: a #CtkWidget
5686 *
5687 * This function is only for use in widget implementations.
5688 *
5689 * Flags the widget for a rerun of the CtkWidgetClass::size_allocate
5690 * function. Use this function instead of ctk_widget_queue_resize()
5691 * when the @widget's size request didn't change but it wants to
5692 * reposition its contents.
5693 *
5694 * An example user of this function is ctk_widget_set_halign().
5695 *
5696 * Since: 3.20
5697 */
5698void
5699ctk_widget_queue_allocate (CtkWidget *widget)
5700{
5701 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5702
5703 if (_ctk_widget_get_realized (widget))
5704 ctk_widget_queue_draw (widget);
5705
5706 ctk_widget_set_alloc_needed (widget);
5707}
5708
5709/**
5710 * ctk_widget_queue_resize_internal:
5711 * @widget: a #CtkWidget
5712 *
5713 * Queue a resize on a widget, and on all other widgets grouped with this widget.
5714 **/
5715void
5716ctk_widget_queue_resize_internal (CtkWidget *widget)
5717{
5718 GSList *groups, *l, *widgets;
5719
5720 if (ctk_widget_get_resize_needed (widget))
5721 return;
5722
5723 ctk_widget_queue_resize_on_widget (widget);
5724
5725 groups = _ctk_widget_get_sizegroups (widget);
5726
5727 for (l = groups; l; l = l->next)
5728 {
5729
5730G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
5731 if (ctk_size_group_get_ignore_hidden (l->data) && !ctk_widget_is_visible (widget))
5732 continue;
5733G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
5734
5735 for (widgets = ctk_size_group_get_widgets (l->data); widgets; widgets = widgets->next)
5736 {
5737 ctk_widget_queue_resize_internal (widgets->data);
5738 }
5739 }
5740
5741G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
5742 if (CTK_IS_RESIZE_CONTAINER (widget)((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*)
((widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))) &&
(ctk_container_get_resize_mode (((((CtkContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((ctk_container_get_type ())))
)))) != CTK_RESIZE_PARENT))
)
5743 {
5744 ctk_container_queue_resize_handler (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
);
5745G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
5746 }
5747 else if (_ctk_widget_get_visible (widget))
5748 {
5749 CtkWidget *parent = _ctk_widget_get_parent (widget);
5750 if (parent)
5751 ctk_widget_queue_resize_internal (parent);
5752 }
5753}
5754
5755/**
5756 * ctk_widget_queue_resize:
5757 * @widget: a #CtkWidget
5758 *
5759 * This function is only for use in widget implementations.
5760 * Flags a widget to have its size renegotiated; should
5761 * be called when a widget for some reason has a new size request.
5762 * For example, when you change the text in a #CtkLabel, #CtkLabel
5763 * queues a resize to ensure there’s enough space for the new text.
5764 *
5765 * Note that you cannot call ctk_widget_queue_resize() on a widget
5766 * from inside its implementation of the CtkWidgetClass::size_allocate
5767 * virtual method. Calls to ctk_widget_queue_resize() from inside
5768 * CtkWidgetClass::size_allocate will be silently ignored.
5769 **/
5770void
5771ctk_widget_queue_resize (CtkWidget *widget)
5772{
5773 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5774
5775 if (_ctk_widget_get_realized (widget))
5776 ctk_widget_queue_draw (widget);
5777
5778 ctk_widget_queue_resize_internal (widget);
5779}
5780
5781/**
5782 * ctk_widget_queue_resize_no_redraw:
5783 * @widget: a #CtkWidget
5784 *
5785 * This function works like ctk_widget_queue_resize(),
5786 * except that the widget is not invalidated.
5787 *
5788 * Since: 2.4
5789 **/
5790void
5791ctk_widget_queue_resize_no_redraw (CtkWidget *widget)
5792{
5793 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5794
5795 ctk_widget_queue_resize_internal (widget);
5796}
5797
5798/**
5799 * ctk_widget_get_frame_clock:
5800 * @widget: a #CtkWidget
5801 *
5802 * Obtains the frame clock for a widget. The frame clock is a global
5803 * “ticker” that can be used to drive animations and repaints. The
5804 * most common reason to get the frame clock is to call
5805 * cdk_frame_clock_get_frame_time(), in order to get a time to use for
5806 * animating. For example you might record the start of the animation
5807 * with an initial value from cdk_frame_clock_get_frame_time(), and
5808 * then update the animation by calling
5809 * cdk_frame_clock_get_frame_time() again during each repaint.
5810 *
5811 * cdk_frame_clock_request_phase() will result in a new frame on the
5812 * clock, but won’t necessarily repaint any widgets. To repaint a
5813 * widget, you have to use ctk_widget_queue_draw() which invalidates
5814 * the widget (thus scheduling it to receive a draw on the next
5815 * frame). ctk_widget_queue_draw() will also end up requesting a frame
5816 * on the appropriate frame clock.
5817 *
5818 * A widget’s frame clock will not change while the widget is
5819 * mapped. Reparenting a widget (which implies a temporary unmap) can
5820 * change the widget’s frame clock.
5821 *
5822 * Unrealized widgets do not have a frame clock.
5823 *
5824 * Returns: (nullable) (transfer none): a #CdkFrameClock,
5825 * or %NULL if widget is unrealized
5826 *
5827 * Since: 3.8
5828 */
5829CdkFrameClock*
5830ctk_widget_get_frame_clock (CtkWidget *widget)
5831{
5832 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
5833
5834 if (widget->priv->realized)
5835 {
5836 /* We use ctk_widget_get_toplevel() here to make it explicit that
5837 * the frame clock is a property of the toplevel that a widget
5838 * is anchored to; cdk_window_get_toplevel() will go up the
5839 * hierarchy anyways, but should squash any funny business with
5840 * reparenting windows and widgets.
5841 */
5842 CtkWidget *toplevel = _ctk_widget_get_toplevel (widget);
5843 CdkWindow *window = _ctk_widget_get_window (toplevel);
5844 g_assert (window != NULL)do { if (window != ((void*)0)) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 5844, ((const char*) (__func__)), "window != NULL"
); } while (0)
;
5845
5846 return cdk_window_get_frame_clock (window);
5847 }
5848 else
5849 {
5850 return NULL((void*)0);
5851 }
5852}
5853
5854/**
5855 * ctk_widget_size_request:
5856 * @widget: a #CtkWidget
5857 * @requisition: (out): a #CtkRequisition to be filled in
5858 *
5859 * This function is typically used when implementing a #CtkContainer
5860 * subclass. Obtains the preferred size of a widget. The container
5861 * uses this information to arrange its child widgets and decide what
5862 * size allocations to give them with ctk_widget_size_allocate().
5863 *
5864 * You can also call this function from an application, with some
5865 * caveats. Most notably, getting a size request requires the widget
5866 * to be associated with a screen, because font information may be
5867 * needed. Multihead-aware applications should keep this in mind.
5868 *
5869 * Also remember that the size request is not necessarily the size
5870 * a widget will actually be allocated.
5871 *
5872 * Deprecated: 3.0: Use ctk_widget_get_preferred_size() instead.
5873 **/
5874void
5875ctk_widget_size_request (CtkWidget *widget,
5876 CtkRequisition *requisition)
5877{
5878 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5879
5880 ctk_widget_get_preferred_size (widget, requisition, NULL((void*)0));
5881}
5882
5883/**
5884 * ctk_widget_get_child_requisition:
5885 * @widget: a #CtkWidget
5886 * @requisition: (out): a #CtkRequisition to be filled in
5887 *
5888 * This function is only for use in widget implementations. Obtains
5889 * @widget->requisition, unless someone has forced a particular
5890 * geometry on the widget (e.g. with ctk_widget_set_size_request()),
5891 * in which case it returns that geometry instead of the widget's
5892 * requisition.
5893 *
5894 * This function differs from ctk_widget_size_request() in that
5895 * it retrieves the last size request value from @widget->requisition,
5896 * while ctk_widget_size_request() actually calls the "size_request" method
5897 * on @widget to compute the size request and fill in @widget->requisition,
5898 * and only then returns @widget->requisition.
5899 *
5900 * Because this function does not call the “size_request” method, it
5901 * can only be used when you know that @widget->requisition is
5902 * up-to-date, that is, ctk_widget_size_request() has been called
5903 * since the last time a resize was queued. In general, only container
5904 * implementations have this information; applications should use
5905 * ctk_widget_size_request().
5906 *
5907 *
5908 * Deprecated: 3.0: Use ctk_widget_get_preferred_size() instead.
5909 **/
5910void
5911ctk_widget_get_child_requisition (CtkWidget *widget,
5912 CtkRequisition *requisition)
5913{
5914 ctk_widget_get_preferred_size (widget, requisition, NULL((void*)0));
5915}
5916
5917static gboolean
5918invalidate_predicate (CdkWindow *window,
5919 gpointer data)
5920{
5921 gpointer user_data;
5922
5923 cdk_window_get_user_data (window, &user_data);
5924
5925 return (user_data == data);
5926}
5927
5928/* Invalidate @region in widget->window and all children
5929 * of widget->window owned by widget. @region is in the
5930 * same coordinates as widget->allocation and will be
5931 * modified by this call.
5932 */
5933static void
5934ctk_widget_invalidate_widget_windows (CtkWidget *widget,
5935 cairo_region_t *region)
5936{
5937 CtkWidgetPrivate *priv = widget->priv;
5938
5939 if (!_ctk_widget_get_realized (widget))
5940 return;
5941
5942 if (_ctk_widget_get_has_window (widget) && priv->parent)
5943 {
5944 int x, y;
5945
5946 cdk_window_get_position (priv->window, &x, &y);
5947 cairo_region_translate (region, -x, -y);
5948 }
5949
5950 cdk_window_invalidate_maybe_recurse (priv->window, region,
5951 invalidate_predicate, widget);
5952}
5953
5954/**
5955 * ctk_widget_size_allocate_with_baseline:
5956 * @widget: a #CtkWidget
5957 * @allocation: position and size to be allocated to @widget
5958 * @baseline: The baseline of the child, or -1
5959 *
5960 * This function is only used by #CtkContainer subclasses, to assign a size,
5961 * position and (optionally) baseline to their child widgets.
5962 *
5963 * In this function, the allocation and baseline may be adjusted. It
5964 * will be forced to a 1x1 minimum size, and the
5965 * adjust_size_allocation virtual and adjust_baseline_allocation
5966 * methods on the child will be used to adjust the allocation and
5967 * baseline. Standard adjustments include removing the widget's
5968 * margins, and applying the widget’s #CtkWidget:halign and
5969 * #CtkWidget:valign properties.
5970 *
5971 * If the child widget does not have a valign of %CTK_ALIGN_BASELINE the
5972 * baseline argument is ignored and -1 is used instead.
5973 *
5974 * Since: 3.10
5975 **/
5976void
5977ctk_widget_size_allocate_with_baseline (CtkWidget *widget,
5978 CtkAllocation *allocation,
5979 gint baseline)
5980{
5981 CtkWidgetPrivate *priv;
5982 CdkRectangle real_allocation;
5983 CdkRectangle old_allocation, old_clip;
5984 CdkRectangle adjusted_allocation;
5985 gboolean alloc_needed;
5986 gboolean size_changed;
5987 gboolean baseline_changed;
5988 gboolean position_changed;
5989 gint natural_width, natural_height, dummy;
5990 gint min_width, min_height;
5991 gint old_baseline;
5992
5993 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
5994
5995 priv = widget->priv;
5996
5997 if (!priv->visible && !_ctk_widget_is_toplevel (widget))
5998 return;
5999
6000 ctk_widget_push_verify_invariants (widget);
6001
6002#ifdef G_ENABLE_DEBUG1
6003 if (CTK_DISPLAY_DEBUG_CHECK (ctk_widget_get_display (widget), RESIZE)(ctk_get_display_debug_flags (ctk_widget_get_display (widget)
) & CTK_DEBUG_RESIZE)
)
6004 {
6005 priv->highlight_resize = TRUE(!(0));
6006 ctk_widget_queue_draw (widget);
6007 }
6008
6009#ifdef G_ENABLE_CONSISTENCY_CHECKS1
6010 if (ctk_widget_get_resize_needed (widget))
6011 {
6012 g_warning ("Allocating size to %s %p without calling ctk_widget_get_preferred_width/height(). "
6013 "How does the code know the size to allocate?",
6014 ctk_widget_get_name (widget), widget);
6015 }
6016#endif
6017
6018 if (CTK_DEBUG_CHECK (GEOMETRY)(ctk_get_debug_flags () & CTK_DEBUG_GEOMETRY))
6019 {
6020 gint depth;
6021 CtkWidget *parent;
6022 const gchar *name;
6023
6024 depth = 0;
6025 parent = widget;
6026 while (parent)
6027 {
6028 depth++;
6029 parent = _ctk_widget_get_parent (parent);
6030 }
6031
6032 name = g_type_name (G_OBJECT_TYPE (G_OBJECT (widget))(((((GTypeClass*) (((GTypeInstance*) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
)))))))->g_class))->g_type)))
);
6033 g_message ("ctk_widget_size_allocate: %*s%s %d %d %d %d, baseline %d",
6034 2 * depth, " ", name,
6035 allocation->x, allocation->y,
6036 allocation->width, allocation->height,
6037 baseline);
6038 }
6039#endif /* G_ENABLE_DEBUG */
6040
6041 /* Never pass a baseline to a child unless it requested it.
6042 This means containers don't have to manually check for this. */
6043 if (baseline != -1 &&
6044 (ctk_widget_get_valign_with_baseline (widget) != CTK_ALIGN_BASELINE ||
6045 !_ctk_widget_has_baseline_support (widget)))
6046 baseline = -1;
6047
6048 alloc_needed = priv->alloc_needed;
6049 /* Preserve request/allocate ordering */
6050 priv->alloc_needed = FALSE(0);
6051
6052 old_allocation = priv->allocation;
6053 old_clip = priv->clip;
6054 old_baseline = priv->allocated_baseline;
6055 real_allocation = *allocation;
6056
6057 priv->allocated_size = *allocation;
6058 priv->allocated_size_baseline = baseline;
6059
6060 adjusted_allocation = real_allocation;
6061 if (ctk_widget_get_request_mode (widget) == CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
6062 {
6063 /* Go ahead and request the height for allocated width, note that the internals
6064 * of get_height_for_width will internally limit the for_size to natural size
6065 * when aligning implicitly.
6066 */
6067 ctk_widget_get_preferred_width (widget, &min_width, &natural_width);
6068 ctk_widget_get_preferred_height_for_width (widget, real_allocation.width, &min_height, &natural_height);
6069 }
6070 else
6071 {
6072 /* Go ahead and request the width for allocated height, note that the internals
6073 * of get_width_for_height will internally limit the for_size to natural size
6074 * when aligning implicitly.
6075 */
6076 ctk_widget_get_preferred_height (widget, &min_height, &natural_height);
6077 ctk_widget_get_preferred_width_for_height (widget, real_allocation.height, &min_width, &natural_width);
6078 }
6079
6080#ifdef G_ENABLE_CONSISTENCY_CHECKS1
6081 if ((min_width > real_allocation.width || min_height > real_allocation.height) &&
6082 !CTK_IS_SCROLLABLE (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_scrollable_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; }))))
)
6083 g_warning ("ctk_widget_size_allocate(): attempt to underallocate %s%s %s %p. "
6084 "Allocation is %dx%d, but minimum required size is %dx%d.",
6085 priv->parent ? G_OBJECT_TYPE_NAME (priv->parent)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (priv->
parent))->g_class))->g_type)))))
: "", priv->parent ? "'s child" : "toplevel",
6086 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget,
6087 real_allocation.width, real_allocation.height,
6088 min_width, min_height);
6089#endif
6090 /* Now that we have the right natural height and width, go ahead and remove any margins from the
6091 * allocated sizes and possibly limit them to the natural sizes */
6092 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->adjust_size_allocation (widget,
6093 CTK_ORIENTATION_HORIZONTAL,
6094 &dummy,
6095 &natural_width,
6096 &adjusted_allocation.x,
6097 &adjusted_allocation.width);
6098 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->adjust_size_allocation (widget,
6099 CTK_ORIENTATION_VERTICAL,
6100 &dummy,
6101 &natural_height,
6102 &adjusted_allocation.y,
6103 &adjusted_allocation.height);
6104 if (baseline >= 0)
6105 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->adjust_baseline_allocation (widget,
6106 &baseline);
6107
6108 if (adjusted_allocation.x < real_allocation.x ||
6109 adjusted_allocation.y < real_allocation.y ||
6110 (adjusted_allocation.x + adjusted_allocation.width) >
6111 (real_allocation.x + real_allocation.width) ||
6112 (adjusted_allocation.y + adjusted_allocation.height >
6113 real_allocation.y + real_allocation.height))
6114 {
6115 g_warning ("%s %p attempted to adjust its size allocation from %d,%d %dx%d to %d,%d %dx%d. adjust_size_allocation must keep allocation inside original bounds",
6116 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget,
6117 real_allocation.x, real_allocation.y, real_allocation.width, real_allocation.height,
6118 adjusted_allocation.x, adjusted_allocation.y, adjusted_allocation.width, adjusted_allocation.height);
6119 }
6120 else
6121 {
6122 real_allocation = adjusted_allocation;
6123 }
6124
6125 if (real_allocation.width < 0 || real_allocation.height < 0)
6126 {
6127 g_warning ("ctk_widget_size_allocate(): attempt to allocate widget with width %d and height %d",
6128 real_allocation.width,
6129 real_allocation.height);
6130 }
6131
6132 real_allocation.width = MAX (real_allocation.width, 1)(((real_allocation.width) > (1)) ? (real_allocation.width)
: (1))
;
6133 real_allocation.height = MAX (real_allocation.height, 1)(((real_allocation.height) > (1)) ? (real_allocation.height
) : (1))
;
6134
6135 baseline_changed = old_baseline != baseline;
6136 size_changed = (old_allocation.width != real_allocation.width ||
6137 old_allocation.height != real_allocation.height);
6138 position_changed = (old_allocation.x != real_allocation.x ||
6139 old_allocation.y != real_allocation.y);
6140
6141 if (!alloc_needed && !size_changed && !position_changed && !baseline_changed)
6142 goto out;
6143
6144 priv->allocated_baseline = baseline;
6145 if (g_signal_has_handler_pending (widget, widget_signals[SIZE_ALLOCATE], 0, FALSE(0)))
6146 g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
6147 else
6148 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->size_allocate (widget, &real_allocation);
6149
6150 /* Size allocation is god... after consulting god, no further requests or allocations are needed */
6151#ifdef G_ENABLE_DEBUG1
6152 if (CTK_DEBUG_CHECK (GEOMETRY)(ctk_get_debug_flags () & CTK_DEBUG_GEOMETRY) && ctk_widget_get_resize_needed (widget))
6153 {
6154 g_warning ("%s %p or a child called ctk_widget_queue_resize() during size_allocate().",
6155 ctk_widget_get_name (widget), widget);
6156 }
6157#endif
6158 ctk_widget_ensure_resize (widget);
6159 priv->alloc_needed = FALSE(0);
6160 priv->alloc_needed_on_child = FALSE(0);
6161
6162 size_changed |= (old_clip.width != priv->clip.width ||
6163 old_clip.height != priv->clip.height);
6164 position_changed |= (old_clip.x != priv->clip.x ||
6165 old_clip.y != priv->clip.y);
6166
6167 if (_ctk_widget_get_mapped (widget) && priv->redraw_on_alloc)
6168 {
6169 if (!_ctk_widget_get_has_window (widget) && position_changed)
6170 {
6171 /* Invalidate union(old_clip,priv->clip) in priv->window
6172 */
6173 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->clip);
6174 cairo_region_union_rectangle (invalidate, &old_clip);
6175
6176 cdk_window_invalidate_region (priv->window, invalidate, FALSE(0));
6177 cairo_region_destroy (invalidate);
6178 }
6179
6180 if (size_changed || baseline_changed)
6181 {
6182 /* Invalidate union(old_clip,priv->clip) in priv->window and descendants owned by widget
6183 */
6184 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->clip);
6185 cairo_region_union_rectangle (invalidate, &old_clip);
6186
6187 ctk_widget_invalidate_widget_windows (widget, invalidate);
6188 cairo_region_destroy (invalidate);
6189 }
6190 }
6191
6192 if ((size_changed || position_changed || baseline_changed) && priv->parent &&
6193 _ctk_widget_get_realized (priv->parent) && _ctk_container_get_reallocate_redraws (CTK_CONTAINER (priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->parent)), ((ctk_container_get_type ()))))))
))
6194 {
6195 cairo_region_t *invalidate = cairo_region_create_rectangle (&priv->parent->priv->clip);
6196 ctk_widget_invalidate_widget_windows (priv->parent, invalidate);
6197 cairo_region_destroy (invalidate);
6198 }
6199
6200out:
6201 if (priv->alloc_needed_on_child)
6202 ctk_widget_ensure_allocate (widget);
6203
6204 ctk_widget_pop_verify_invariants (widget);
6205}
6206
6207
6208/**
6209 * ctk_widget_size_allocate:
6210 * @widget: a #CtkWidget
6211 * @allocation: position and size to be allocated to @widget
6212 *
6213 * This function is only used by #CtkContainer subclasses, to assign a size
6214 * and position to their child widgets.
6215 *
6216 * In this function, the allocation may be adjusted. It will be forced
6217 * to a 1x1 minimum size, and the adjust_size_allocation virtual
6218 * method on the child will be used to adjust the allocation. Standard
6219 * adjustments include removing the widget’s margins, and applying the
6220 * widget’s #CtkWidget:halign and #CtkWidget:valign properties.
6221 *
6222 * For baseline support in containers you need to use ctk_widget_size_allocate_with_baseline()
6223 * instead.
6224 **/
6225void
6226ctk_widget_size_allocate (CtkWidget *widget,
6227 CtkAllocation *allocation)
6228{
6229 ctk_widget_size_allocate_with_baseline (widget, allocation, -1);
6230}
6231
6232/**
6233 * ctk_widget_common_ancestor:
6234 * @widget_a: a #CtkWidget
6235 * @widget_b: a #CtkWidget
6236 *
6237 * Find the common ancestor of @widget_a and @widget_b that
6238 * is closest to the two widgets.
6239 *
6240 * Returns: (nullable): the closest common ancestor of @widget_a and
6241 * @widget_b or %NULL if @widget_a and @widget_b do not
6242 * share a common ancestor.
6243 **/
6244static CtkWidget *
6245ctk_widget_common_ancestor (CtkWidget *widget_a,
6246 CtkWidget *widget_b)
6247{
6248 CtkWidget *parent_a;
6249 CtkWidget *parent_b;
6250 gint depth_a = 0;
6251 gint depth_b = 0;
6252
6253 parent_a = widget_a;
6254 while (parent_a->priv->parent)
6255 {
6256 parent_a = parent_a->priv->parent;
6257 depth_a++;
6258 }
6259
6260 parent_b = widget_b;
6261 while (parent_b->priv->parent)
6262 {
6263 parent_b = parent_b->priv->parent;
6264 depth_b++;
6265 }
6266
6267 if (parent_a != parent_b)
6268 return NULL((void*)0);
6269
6270 while (depth_a > depth_b)
6271 {
6272 widget_a = widget_a->priv->parent;
6273 depth_a--;
6274 }
6275
6276 while (depth_b > depth_a)
6277 {
6278 widget_b = widget_b->priv->parent;
6279 depth_b--;
6280 }
6281
6282 while (widget_a != widget_b)
6283 {
6284 widget_a = widget_a->priv->parent;
6285 widget_b = widget_b->priv->parent;
6286 }
6287
6288 return widget_a;
6289}
6290
6291/**
6292 * ctk_widget_translate_coordinates:
6293 * @src_widget: a #CtkWidget
6294 * @dest_widget: a #CtkWidget
6295 * @src_x: X position relative to @src_widget
6296 * @src_y: Y position relative to @src_widget
6297 * @dest_x: (out) (optional): location to store X position relative to @dest_widget
6298 * @dest_y: (out) (optional): location to store Y position relative to @dest_widget
6299 *
6300 * Translate coordinates relative to @src_widget’s allocation to coordinates
6301 * relative to @dest_widget’s allocations. In order to perform this
6302 * operation, both widgets must be realized, and must share a common
6303 * toplevel.
6304 *
6305 * Returns: %FALSE if either widget was not realized, or there
6306 * was no common ancestor. In this case, nothing is stored in
6307 * *@dest_x and *@dest_y. Otherwise %TRUE.
6308 **/
6309gboolean
6310ctk_widget_translate_coordinates (CtkWidget *src_widget,
6311 CtkWidget *dest_widget,
6312 gint src_x,
6313 gint src_y,
6314 gint *dest_x,
6315 gint *dest_y)
6316{
6317 CtkWidgetPrivate *src_priv;
6318 CtkWidgetPrivate *dest_priv;
6319 CtkWidget *ancestor;
6320 CdkWindow *window;
6321 GList *dest_list = NULL((void*)0);
6322
6323 g_return_val_if_fail (CTK_IS_WIDGET (src_widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((src_widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (src_widget)"); return ((0)); } } while (0
)
;
6324 g_return_val_if_fail (CTK_IS_WIDGET (dest_widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dest_widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (dest_widget)"); return ((0)); } } while (
0)
;
6325
6326 ancestor = ctk_widget_common_ancestor (src_widget, dest_widget);
6327 if (!ancestor || !_ctk_widget_get_realized (src_widget) || !_ctk_widget_get_realized (dest_widget))
6328 return FALSE(0);
6329
6330 src_priv = src_widget->priv;
6331 dest_priv = dest_widget->priv;
6332
6333 /* Translate from allocation relative to window relative */
6334 if (_ctk_widget_get_has_window (src_widget) && src_priv->parent)
6335 {
6336 gint wx, wy;
6337 cdk_window_get_position (src_priv->window, &wx, &wy);
6338
6339 src_x -= wx - src_priv->allocation.x;
6340 src_y -= wy - src_priv->allocation.y;
6341 }
6342 else
6343 {
6344 src_x += src_priv->allocation.x;
6345 src_y += src_priv->allocation.y;
6346 }
6347
6348 /* Translate to the common ancestor */
6349 window = src_priv->window;
6350 while (window != ancestor->priv->window)
6351 {
6352 gdouble dx, dy;
6353
6354 cdk_window_coords_to_parent (window, src_x, src_y, &dx, &dy);
6355
6356 src_x = dx;
6357 src_y = dy;
6358
6359 window = cdk_window_get_effective_parent (window);
6360
6361 if (!window) /* Handle CtkHandleBox */
6362 return FALSE(0);
6363 }
6364
6365 /* And back */
6366 window = dest_priv->window;
6367 while (window != ancestor->priv->window)
6368 {
6369 dest_list = g_list_prepend (dest_list, window);
6370
6371 window = cdk_window_get_effective_parent (window);
6372
6373 if (!window) /* Handle CtkHandleBox */
6374 {
6375 g_list_free (dest_list);
6376 return FALSE(0);
6377 }
6378 }
6379
6380 while (dest_list)
6381 {
6382 gdouble dx, dy;
6383
6384 cdk_window_coords_from_parent (dest_list->data, src_x, src_y, &dx, &dy);
6385
6386 src_x = dx;
6387 src_y = dy;
6388
6389 dest_list = g_list_remove (dest_list, dest_list->data);
6390 }
6391
6392 /* Translate from window relative to allocation relative */
6393 if (_ctk_widget_get_has_window (dest_widget) && dest_priv->parent)
6394 {
6395 gint wx, wy;
6396 cdk_window_get_position (dest_priv->window, &wx, &wy);
6397
6398 src_x += wx - dest_priv->allocation.x;
6399 src_y += wy - dest_priv->allocation.y;
6400 }
6401 else
6402 {
6403 src_x -= dest_priv->allocation.x;
6404 src_y -= dest_priv->allocation.y;
6405 }
6406
6407 if (dest_x)
6408 *dest_x = src_x;
6409 if (dest_y)
6410 *dest_y = src_y;
6411
6412 return TRUE(!(0));
6413}
6414
6415static void
6416ctk_widget_real_size_allocate (CtkWidget *widget,
6417 CtkAllocation *allocation)
6418{
6419 CtkWidgetPrivate *priv = widget->priv;
6420
6421 ctk_widget_set_allocation (widget, allocation);
6422
6423 if (_ctk_widget_get_realized (widget) &&
6424 _ctk_widget_get_has_window (widget))
6425 {
6426 cdk_window_move_resize (priv->window,
6427 allocation->x, allocation->y,
6428 allocation->width, allocation->height);
6429 }
6430}
6431
6432/* translate initial/final into start/end */
6433static CtkAlign
6434effective_align (CtkAlign align,
6435 CtkTextDirection direction)
6436{
6437 switch (align)
6438 {
6439 case CTK_ALIGN_START:
6440 return direction == CTK_TEXT_DIR_RTL ? CTK_ALIGN_END : CTK_ALIGN_START;
6441 case CTK_ALIGN_END:
6442 return direction == CTK_TEXT_DIR_RTL ? CTK_ALIGN_START : CTK_ALIGN_END;
6443 default:
6444 return align;
6445 }
6446}
6447
6448static void
6449adjust_for_align (CtkAlign align,
6450 gint *natural_size,
6451 gint *allocated_pos,
6452 gint *allocated_size)
6453{
6454 switch (align)
6455 {
6456 case CTK_ALIGN_BASELINE:
6457 case CTK_ALIGN_FILL:
6458 /* change nothing */
6459 break;
6460 case CTK_ALIGN_START:
6461 /* keep *allocated_pos where it is */
6462 *allocated_size = MIN (*allocated_size, *natural_size)(((*allocated_size) < (*natural_size)) ? (*allocated_size)
: (*natural_size))
;
6463 break;
6464 case CTK_ALIGN_END:
6465 if (*allocated_size > *natural_size)
6466 {
6467 *allocated_pos += (*allocated_size - *natural_size);
6468 *allocated_size = *natural_size;
6469 }
6470 break;
6471 case CTK_ALIGN_CENTER:
6472 if (*allocated_size > *natural_size)
6473 {
6474 *allocated_pos += (*allocated_size - *natural_size) / 2;
6475 *allocated_size = MIN (*allocated_size, *natural_size)(((*allocated_size) < (*natural_size)) ? (*allocated_size)
: (*natural_size))
;
6476 }
6477 break;
6478 }
6479}
6480
6481static void
6482adjust_for_margin(gint start_margin,
6483 gint end_margin,
6484 gint *minimum_size,
6485 gint *natural_size,
6486 gint *allocated_pos,
6487 gint *allocated_size)
6488{
6489 *minimum_size -= (start_margin + end_margin);
6490 *natural_size -= (start_margin + end_margin);
6491 *allocated_pos += start_margin;
6492 *allocated_size -= (start_margin + end_margin);
6493}
6494
6495static void
6496ctk_widget_real_adjust_size_allocation (CtkWidget *widget,
6497 CtkOrientation orientation,
6498 gint *minimum_size,
6499 gint *natural_size,
6500 gint *allocated_pos,
6501 gint *allocated_size)
6502{
6503 CtkWidgetPrivate *priv = widget->priv;
6504
6505 if (orientation == CTK_ORIENTATION_HORIZONTAL)
6506 {
6507 adjust_for_margin (priv->margin.left,
6508 priv->margin.right,
6509 minimum_size, natural_size,
6510 allocated_pos, allocated_size);
6511 adjust_for_align (effective_align (priv->halign, _ctk_widget_get_direction (widget)),
6512 natural_size, allocated_pos, allocated_size);
6513 }
6514 else
6515 {
6516 adjust_for_margin (priv->margin.top,
6517 priv->margin.bottom,
6518 minimum_size, natural_size,
6519 allocated_pos, allocated_size);
6520 adjust_for_align (effective_align (priv->valign, CTK_TEXT_DIR_NONE),
6521 natural_size, allocated_pos, allocated_size);
6522 }
6523}
6524
6525static void
6526ctk_widget_real_adjust_baseline_allocation (CtkWidget *widget,
6527 gint *baseline)
6528{
6529 if (*baseline >= 0)
6530 *baseline -= widget->priv->margin.top;
6531}
6532
6533static gboolean
6534ctk_widget_real_can_activate_accel (CtkWidget *widget,
6535 guint signal_id G_GNUC_UNUSED__attribute__ ((__unused__)))
6536{
6537 CtkWidgetPrivate *priv = widget->priv;
6538
6539 /* widgets must be onscreen for accels to take effect */
6540 return ctk_widget_is_sensitive (widget) &&
6541 _ctk_widget_is_drawable (widget) &&
6542 cdk_window_is_viewable (priv->window);
6543}
6544
6545/**
6546 * ctk_widget_can_activate_accel:
6547 * @widget: a #CtkWidget
6548 * @signal_id: the ID of a signal installed on @widget
6549 *
6550 * Determines whether an accelerator that activates the signal
6551 * identified by @signal_id can currently be activated.
6552 * This is done by emitting the #CtkWidget::can-activate-accel
6553 * signal on @widget; if the signal isn’t overridden by a
6554 * handler or in a derived widget, then the default check is
6555 * that the widget must be sensitive, and the widget and all
6556 * its ancestors mapped.
6557 *
6558 * Returns: %TRUE if the accelerator can be activated.
6559 *
6560 * Since: 2.4
6561 **/
6562gboolean
6563ctk_widget_can_activate_accel (CtkWidget *widget,
6564 guint signal_id)
6565{
6566 gboolean can_activate = FALSE(0);
6567 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
6568 g_signal_emit (widget, widget_signals[CAN_ACTIVATE_ACCEL], 0, signal_id, &can_activate);
6569 return can_activate;
6570}
6571
6572typedef struct {
6573 GClosure closure;
6574 guint signal_id;
6575} AccelClosure;
6576
6577static void
6578closure_accel_activate (GClosure *closure,
6579 GValue *return_value,
6580 guint n_param_values G_GNUC_UNUSED__attribute__ ((__unused__)),
6581 const GValue *param_values G_GNUC_UNUSED__attribute__ ((__unused__)),
6582 gpointer invocation_hint G_GNUC_UNUSED__attribute__ ((__unused__)),
6583 gpointer marshal_data G_GNUC_UNUSED__attribute__ ((__unused__)))
6584{
6585 AccelClosure *aclosure = (AccelClosure*) closure;
6586 gboolean can_activate = ctk_widget_can_activate_accel (closure->data, aclosure->signal_id);
6587
6588 if (can_activate)
6589 g_signal_emit (closure->data, aclosure->signal_id, 0);
6590
6591 /* whether accelerator was handled */
6592 g_value_set_boolean (return_value, can_activate);
6593}
6594
6595static void
6596closures_destroy (gpointer data)
6597{
6598 GSList *slist, *closures = data;
6599
6600 for (slist = closures; slist; slist = slist->next)
6601 {
6602 g_closure_invalidate (slist->data);
6603 g_closure_unref (slist->data);
6604 }
6605 g_slist_free (closures);
6606}
6607
6608static GClosure*
6609widget_new_accel_closure (CtkWidget *widget,
6610 guint signal_id)
6611{
6612 AccelClosure *aclosure;
6613 GClosure *closure = NULL((void*)0);
6614 GSList *slist, *closures;
6615
6616 closures = g_object_steal_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_accel_closures);
6617 for (slist = closures; slist; slist = slist->next)
6618 if (!ctk_accel_group_from_accel_closure (slist->data))
6619 {
6620 /* reuse this closure */
6621 closure = slist->data;
6622 break;
6623 }
6624 if (!closure)
6625 {
6626 closure = g_closure_new_object (sizeof (AccelClosure), G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
6627 closures = g_slist_prepend (closures, g_closure_ref (closure));
6628 g_closure_sink (closure);
6629 g_closure_set_marshal (closure, closure_accel_activate);
6630 }
6631 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_accel_closures, closures, closures_destroy);
6632
6633 aclosure = (AccelClosure*) closure;
6634 g_assert (closure->data == widget)do { if (closure->data == widget) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 6634, ((const char*) (__func__)), "closure->data == widget"
); } while (0)
;
6635 g_assert (closure->marshal == closure_accel_activate)do { if (closure->marshal == closure_accel_activate) ; else
g_assertion_message_expr ("Ctk", "ctkwidget.c", 6635, ((const
char*) (__func__)), "closure->marshal == closure_accel_activate"
); } while (0)
;
6636 aclosure->signal_id = signal_id;
6637
6638 return closure;
6639}
6640
6641/**
6642 * ctk_widget_add_accelerator:
6643 * @widget: widget to install an accelerator on
6644 * @accel_signal: widget signal to emit on accelerator activation
6645 * @accel_group: accel group for this widget, added to its toplevel
6646 * @accel_key: CDK keyval of the accelerator
6647 * @accel_mods: modifier key combination of the accelerator
6648 * @accel_flags: flag accelerators, e.g. %CTK_ACCEL_VISIBLE
6649 *
6650 * Installs an accelerator for this @widget in @accel_group that causes
6651 * @accel_signal to be emitted if the accelerator is activated.
6652 * The @accel_group needs to be added to the widget’s toplevel via
6653 * ctk_window_add_accel_group(), and the signal must be of type %G_SIGNAL_ACTION.
6654 * Accelerators added through this function are not user changeable during
6655 * runtime. If you want to support accelerators that can be changed by the
6656 * user, use ctk_accel_map_add_entry() and ctk_widget_set_accel_path() or
6657 * ctk_menu_item_set_accel_path() instead.
6658 */
6659void
6660ctk_widget_add_accelerator (CtkWidget *widget,
6661 const gchar *accel_signal,
6662 CtkAccelGroup *accel_group,
6663 guint accel_key,
6664 CdkModifierType accel_mods,
6665 CtkAccelFlags accel_flags)
6666{
6667 GClosure *closure;
6668 GSignalQuery query;
6669
6670 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
6671 g_return_if_fail (accel_signal != NULL)do { if ((accel_signal != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "accel_signal != NULL");
return; } } while (0)
;
6672 g_return_if_fail (CTK_IS_ACCEL_GROUP (accel_group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((accel_group)); GType __t = ((ctk_accel_group_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "CTK_IS_ACCEL_GROUP (accel_group)"); return
; } } while (0)
;
6673
6674 g_signal_query (g_signal_lookup (accel_signal, G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
), &query);
6675 if (!query.signal_id ||
6676 !(query.signal_flags & G_SIGNAL_ACTION) ||
6677 query.return_type != G_TYPE_NONE((GType) ((1) << (2))) ||
6678 query.n_params)
6679 {
6680 /* hmm, should be elaborate enough */
6681 g_warning (G_STRLOC"ctkwidget.c" ":" "6681" ": widget '%s' has no activatable signal \"%s\" without arguments",
6682 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, accel_signal);
6683 return;
6684 }
6685
6686 closure = widget_new_accel_closure (widget, query.signal_id);
6687
6688 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
6689
6690 /* install the accelerator. since we don't map this onto an accel_path,
6691 * the accelerator will automatically be locked.
6692 */
6693 ctk_accel_group_connect (accel_group,
6694 accel_key,
6695 accel_mods,
6696 accel_flags | CTK_ACCEL_LOCKED,
6697 closure);
6698
6699 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
6700
6701 g_object_unref (widget);
6702}
6703
6704/**
6705 * ctk_widget_remove_accelerator:
6706 * @widget: widget to install an accelerator on
6707 * @accel_group: accel group for this widget
6708 * @accel_key: CDK keyval of the accelerator
6709 * @accel_mods: modifier key combination of the accelerator
6710 *
6711 * Removes an accelerator from @widget, previously installed with
6712 * ctk_widget_add_accelerator().
6713 *
6714 * Returns: whether an accelerator was installed and could be removed
6715 */
6716gboolean
6717ctk_widget_remove_accelerator (CtkWidget *widget,
6718 CtkAccelGroup *accel_group,
6719 guint accel_key,
6720 CdkModifierType accel_mods)
6721{
6722 CtkAccelGroupEntry *ag_entry;
6723 GList *slist, *clist;
6724 guint n;
6725
6726 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
6727 g_return_val_if_fail (CTK_IS_ACCEL_GROUP (accel_group), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((accel_group)); GType __t = ((ctk_accel_group_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "CTK_IS_ACCEL_GROUP (accel_group)"); return
((0)); } } while (0)
;
6728
6729 ag_entry = ctk_accel_group_query (accel_group, accel_key, accel_mods, &n);
6730 clist = ctk_widget_list_accel_closures (widget);
6731 for (slist = clist; slist; slist = slist->next)
6732 {
6733 guint i;
6734
6735 for (i = 0; i < n; i++)
6736 if (slist->data == (gpointer) ag_entry[i].closure)
6737 {
6738 gboolean is_removed = ctk_accel_group_disconnect (accel_group, slist->data);
6739
6740 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
6741
6742 g_list_free (clist);
6743
6744 return is_removed;
6745 }
6746 }
6747 g_list_free (clist);
6748
6749 g_warning (G_STRLOC"ctkwidget.c" ":" "6749" ": no accelerator (%u,%u) installed in accel group (%p) for %s (%p)",
6750 accel_key, accel_mods, accel_group,
6751 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
6752
6753 return FALSE(0);
6754}
6755
6756/**
6757 * ctk_widget_list_accel_closures:
6758 * @widget: widget to list accelerator closures for
6759 *
6760 * Lists the closures used by @widget for accelerator group connections
6761 * with ctk_accel_group_connect_by_path() or ctk_accel_group_connect().
6762 * The closures can be used to monitor accelerator changes on @widget,
6763 * by connecting to the @CtkAccelGroup::accel-changed signal of the
6764 * #CtkAccelGroup of a closure which can be found out with
6765 * ctk_accel_group_from_accel_closure().
6766 *
6767 * Returns: (transfer container) (element-type GClosure):
6768 * a newly allocated #GList of closures
6769 */
6770GList*
6771ctk_widget_list_accel_closures (CtkWidget *widget)
6772{
6773 GSList *slist;
6774 GList *clist = NULL((void*)0);
6775
6776 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
6777
6778 for (slist = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_accel_closures); slist; slist = slist->next)
6779 if (ctk_accel_group_from_accel_closure (slist->data))
6780 clist = g_list_prepend (clist, slist->data);
6781 return clist;
6782}
6783
6784typedef struct {
6785 GQuark path_quark;
6786 CtkAccelGroup *accel_group;
6787 GClosure *closure;
6788} AccelPath;
6789
6790static void
6791destroy_accel_path (gpointer data)
6792{
6793 AccelPath *apath = data;
6794
6795 ctk_accel_group_disconnect (apath->accel_group, apath->closure);
6796
6797 /* closures_destroy takes care of unrefing the closure */
6798 g_object_unref (apath->accel_group);
6799
6800 g_slice_free (AccelPath, apath)do { if (1) g_slice_free1 (sizeof (AccelPath), (apath)); else
(void) ((AccelPath*) 0 == (apath)); } while (0)
;
6801}
6802
6803
6804/**
6805 * ctk_widget_set_accel_path:
6806 * @widget: a #CtkWidget
6807 * @accel_path: (allow-none): path used to look up the accelerator
6808 * @accel_group: (allow-none): a #CtkAccelGroup.
6809 *
6810 * Given an accelerator group, @accel_group, and an accelerator path,
6811 * @accel_path, sets up an accelerator in @accel_group so whenever the
6812 * key binding that is defined for @accel_path is pressed, @widget
6813 * will be activated. This removes any accelerators (for any
6814 * accelerator group) installed by previous calls to
6815 * ctk_widget_set_accel_path(). Associating accelerators with
6816 * paths allows them to be modified by the user and the modifications
6817 * to be saved for future use. (See ctk_accel_map_save().)
6818 *
6819 * This function is a low level function that would most likely
6820 * be used by a menu creation system like #CtkUIManager. If you
6821 * use #CtkUIManager, setting up accelerator paths will be done
6822 * automatically.
6823 *
6824 * Even when you you aren’t using #CtkUIManager, if you only want to
6825 * set up accelerators on menu items ctk_menu_item_set_accel_path()
6826 * provides a somewhat more convenient interface.
6827 *
6828 * Note that @accel_path string will be stored in a #GQuark. Therefore, if you
6829 * pass a static string, you can save some memory by interning it first with
6830 * g_intern_static_string().
6831 **/
6832void
6833ctk_widget_set_accel_path (CtkWidget *widget,
6834 const gchar *accel_path,
6835 CtkAccelGroup *accel_group)
6836{
6837 AccelPath *apath;
6838
6839 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
6840 g_return_if_fail (CTK_WIDGET_GET_CLASS (widget)->activate_signal != 0)do { if ((((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))
->g_class))))->activate_signal != 0)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "CTK_WIDGET_GET_CLASS (widget)->activate_signal != 0"
); return; } } while (0)
;
6841
6842 if (accel_path)
6843 {
6844 g_return_if_fail (CTK_IS_ACCEL_GROUP (accel_group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((accel_group)); GType __t = ((ctk_accel_group_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "CTK_IS_ACCEL_GROUP (accel_group)"); return
; } } while (0)
;
6845 g_return_if_fail (_ctk_accel_path_is_valid (accel_path))do { if ((_ctk_accel_path_is_valid (accel_path))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "_ctk_accel_path_is_valid (accel_path)"
); return; } } while (0)
;
6846
6847 ctk_accel_map_add_entry (accel_path, 0, 0);
6848 apath = g_slice_new (AccelPath)((AccelPath*) g_slice_alloc ((sizeof (AccelPath) > 0 ? sizeof
(AccelPath) : 1)))
;
6849 apath->accel_group = g_object_ref (accel_group)((__typeof__ (accel_group)) (g_object_ref) (accel_group));
6850 apath->path_quark = g_quark_from_string (accel_path);
6851 apath->closure = widget_new_accel_closure (widget, CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->activate_signal);
6852 }
6853 else
6854 apath = NULL((void*)0);
6855
6856 /* also removes possible old settings */
6857 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_accel_path, apath, destroy_accel_path);
6858
6859 if (apath)
6860 ctk_accel_group_connect_by_path (apath->accel_group, g_quark_to_string (apath->path_quark), apath->closure);
6861
6862 g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
6863}
6864
6865const gchar*
6866_ctk_widget_get_accel_path (CtkWidget *widget,
6867 gboolean *locked)
6868{
6869 AccelPath *apath;
6870
6871 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
6872
6873 apath = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_accel_path);
6874 if (locked)
6875 *locked = apath ? ctk_accel_group_get_is_locked (apath->accel_group) : TRUE(!(0));
6876 return apath ? g_quark_to_string (apath->path_quark) : NULL((void*)0);
6877}
6878
6879/**
6880 * ctk_widget_mnemonic_activate:
6881 * @widget: a #CtkWidget
6882 * @group_cycling: %TRUE if there are other widgets with the same mnemonic
6883 *
6884 * Emits the #CtkWidget::mnemonic-activate signal.
6885 *
6886 * Returns: %TRUE if the signal has been handled
6887 */
6888gboolean
6889ctk_widget_mnemonic_activate (CtkWidget *widget,
6890 gboolean group_cycling)
6891{
6892 gboolean handled;
6893
6894 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
6895
6896 group_cycling = group_cycling != FALSE(0);
6897 if (!ctk_widget_is_sensitive (widget))
6898 handled = TRUE(!(0));
6899 else
6900 g_signal_emit (widget,
6901 widget_signals[MNEMONIC_ACTIVATE],
6902 0,
6903 group_cycling,
6904 &handled);
6905 return handled;
6906}
6907
6908static gboolean
6909ctk_widget_real_mnemonic_activate (CtkWidget *widget,
6910 gboolean group_cycling)
6911{
6912 if (!group_cycling && CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->activate_signal)
6913 ctk_widget_activate (widget);
6914 else if (ctk_widget_get_can_focus (widget))
6915 ctk_widget_grab_focus (widget);
6916 else
6917 {
6918 g_warning ("widget '%s' isn't suitable for mnemonic activation",
6919 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
);
6920 ctk_widget_error_bell (widget);
6921 }
6922 return TRUE(!(0));
6923}
6924
6925static const cairo_user_data_key_t mark_for_draw_key;
6926
6927static gboolean
6928ctk_cairo_is_marked_for_draw (cairo_t *cr)
6929{
6930 return cairo_get_user_data (cr, &mark_for_draw_key) != NULL((void*)0);
6931}
6932
6933static void
6934ctk_cairo_set_marked_for_draw (cairo_t *cr,
6935 gboolean marked)
6936{
6937 if (marked)
6938 cairo_set_user_data (cr, &mark_for_draw_key, GINT_TO_POINTER (1)((gpointer) (glong) (1)), NULL((void*)0));
6939 else
6940 cairo_set_user_data (cr, &mark_for_draw_key, NULL((void*)0), NULL((void*)0));
6941}
6942
6943/**
6944 * ctk_cairo_should_draw_window:
6945 * @cr: a cairo context
6946 * @window: the window to check. @window may not be an input-only
6947 * window.
6948 *
6949 * This function is supposed to be called in #CtkWidget::draw
6950 * implementations for widgets that support multiple windows.
6951 * @cr must be untransformed from invoking of the draw function.
6952 * This function will return %TRUE if the contents of the given
6953 * @window are supposed to be drawn and %FALSE otherwise. Note
6954 * that when the drawing was not initiated by the windowing
6955 * system this function will return %TRUE for all windows, so
6956 * you need to draw the bottommost window first. Also, do not
6957 * use “else if” statements to check which window should be drawn.
6958 *
6959 * Returns: %TRUE if @window should be drawn
6960 *
6961 * Since: 3.0
6962 */
6963gboolean
6964ctk_cairo_should_draw_window (cairo_t *cr,
6965 CdkWindow *window)
6966{
6967 CdkDrawingContext *context;
6968 CdkWindow *tmp;
6969
6970 g_return_val_if_fail (cr != NULL, FALSE)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return ((
0)); } } while (0)
;
6971 g_return_val_if_fail (CDK_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((cdk_window_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__
)), "CDK_IS_WINDOW (window)"); return ((0)); } } while (0)
;
6972
6973 if (ctk_cairo_is_marked_for_draw (cr))
6974 return TRUE(!(0));
6975
6976 context = cdk_cairo_get_drawing_context (cr);
6977 if (context == NULL((void*)0))
6978 return TRUE(!(0));
6979
6980 tmp = cdk_drawing_context_get_window (context);
6981 if (tmp == NULL((void*)0))
6982 return TRUE(!(0));
6983
6984 while (!cdk_window_has_native (window))
6985 window = cdk_window_get_parent (window);
6986
6987 return tmp == window;
6988}
6989
6990void
6991ctk_widget_draw_internal (CtkWidget *widget,
6992 cairo_t *cr,
6993 gboolean clip_to_size)
6994{
6995 if (!_ctk_widget_is_drawable (widget))
6996 return;
6997
6998 if (clip_to_size)
6999 {
7000 cairo_rectangle (cr,
7001 widget->priv->clip.x - widget->priv->allocation.x,
7002 widget->priv->clip.y - widget->priv->allocation.y,
7003 widget->priv->clip.width,
7004 widget->priv->clip.height);
7005 cairo_clip (cr);
7006 }
7007
7008 if (cdk_cairo_get_clip_rectangle (cr, NULL((void*)0)))
7009 {
7010 CdkWindow *event_window = NULL((void*)0);
7011 gboolean result;
7012 gboolean push_group;
7013
7014 /* If this was a cairo_t passed via ctk_widget_draw() then we don't
7015 * require a window; otherwise we check for the window associated
7016 * to the drawing context and mark it using the clip region of the
7017 * Cairo context.
7018 */
7019 if (!ctk_cairo_is_marked_for_draw (cr))
7020 {
7021 CdkDrawingContext *context = cdk_cairo_get_drawing_context (cr);
7022
7023 if (context != NULL((void*)0))
7024 {
7025 event_window = cdk_drawing_context_get_window (context);
7026 if (event_window != NULL((void*)0))
7027 cdk_window_mark_paint_from_clip (event_window, cr);
7028 }
7029 }
7030
7031 push_group =
7032 widget->priv->alpha != 255 &&
7033 (!_ctk_widget_is_toplevel (widget) ||
7034 ctk_widget_get_visual (widget) == cdk_screen_get_rgba_visual (ctk_widget_get_screen (widget)));
7035
7036 if (push_group)
7037 cairo_push_group (cr);
7038
7039#ifdef G_ENABLE_CONSISTENCY_CHECKS1
7040 if (_ctk_widget_get_alloc_needed (widget))
7041 g_warning ("%s %p is drawn without a current allocation. This should not happen.", G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
7042#endif
7043
7044 if (g_signal_has_handler_pending (widget, widget_signals[DRAW], 0, FALSE(0)))
7045 {
7046 g_signal_emit (widget, widget_signals[DRAW],
7047 0, cr,
7048 &result);
7049 }
7050 else if (CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->draw)
7051 {
7052 cairo_save (cr);
7053 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->draw (widget, cr);
7054 cairo_restore (cr);
7055 }
7056
7057#ifdef G_ENABLE_DEBUG1
7058 if (CTK_DISPLAY_DEBUG_CHECK (ctk_widget_get_display (widget), BASELINES)(ctk_get_display_debug_flags (ctk_widget_get_display (widget)
) & CTK_DEBUG_BASELINES)
)
7059 {
7060 gint baseline = ctk_widget_get_allocated_baseline (widget);
7061 gint width = ctk_widget_get_allocated_width (widget);
7062
7063 if (baseline != -1)
7064 {
7065 cairo_save (cr);
7066 cairo_new_path (cr);
7067 cairo_move_to (cr, 0, baseline+0.5);
7068 cairo_line_to (cr, width, baseline+0.5);
7069 cairo_set_line_width (cr, 1.0);
7070 cairo_set_source_rgba (cr, 1.0, 0, 0, 0.25);
7071 cairo_stroke (cr);
7072 cairo_restore (cr);
7073 }
7074 }
7075 if (widget->priv->highlight_resize)
7076 {
7077 CtkAllocation alloc;
7078 ctk_widget_get_allocation (widget, &alloc);
7079
7080 cairo_rectangle (cr, 0, 0, alloc.width, alloc.height);
7081 cairo_set_source_rgba (cr, 1, 0, 0, 0.2);
7082 cairo_fill (cr);
7083
7084 ctk_widget_queue_draw (widget);
7085
7086 widget->priv->highlight_resize = FALSE(0);
7087 }
7088#endif
7089
7090 if (push_group)
7091 {
7092 cairo_pop_group_to_source (cr);
7093 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
7094 cairo_paint_with_alpha (cr, widget->priv->alpha / 255.0);
7095 }
7096
7097 if (cairo_status (cr) &&
7098 event_window != NULL((void*)0))
7099 {
7100 /* We check the event so we only warn about internal CTK+ calls.
7101 * Errors might come from PDF streams having write failures and
7102 * we don't want to spam stderr in that case.
7103 * We do want to catch errors from
7104 */
7105 g_warning ("drawing failure for widget '%s': %s",
7106 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
,
7107 cairo_status_to_string (cairo_status (cr)));
7108 }
7109 }
7110}
7111
7112/**
7113 * ctk_widget_draw:
7114 * @widget: the widget to draw. It must be drawable (see
7115 * ctk_widget_is_drawable()) and a size must have been allocated.
7116 * @cr: a cairo context to draw to
7117 *
7118 * Draws @widget to @cr. The top left corner of the widget will be
7119 * drawn to the currently set origin point of @cr.
7120 *
7121 * You should pass a cairo context as @cr argument that is in an
7122 * original state. Otherwise the resulting drawing is undefined. For
7123 * example changing the operator using cairo_set_operator() or the
7124 * line width using cairo_set_line_width() might have unwanted side
7125 * effects.
7126 * You may however change the context’s transform matrix - like with
7127 * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
7128 * region with cairo_clip() prior to calling this function. Also, it
7129 * is fine to modify the context with cairo_save() and
7130 * cairo_push_group() prior to calling this function.
7131 *
7132 * Note that special-purpose widgets may contain special code for
7133 * rendering to the screen and might appear differently on screen
7134 * and when rendered using ctk_widget_draw().
7135 *
7136 * Since: 3.0
7137 **/
7138void
7139ctk_widget_draw (CtkWidget *widget,
7140 cairo_t *cr)
7141{
7142 gboolean was_marked;
7143
7144 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
7145 g_return_if_fail (!widget->priv->alloc_needed)do { if ((!widget->priv->alloc_needed)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "!widget->priv->alloc_needed"
); return; } } while (0)
;
7146 g_return_if_fail (!widget->priv->alloc_needed_on_child)do { if ((!widget->priv->alloc_needed_on_child)) { } else
{ g_return_if_fail_warning ("Ctk", ((const char*) (__func__)
), "!widget->priv->alloc_needed_on_child"); return; } }
while (0)
;
7147 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
7148
7149 cairo_save (cr);
7150
7151 was_marked = ctk_cairo_is_marked_for_draw (cr);
7152
7153 /* We mark the window so that ctk_cairo_should_draw_window()
7154 * will always return TRUE, and all CdkWindows get drawn
7155 */
7156 ctk_cairo_set_marked_for_draw (cr, TRUE(!(0)));
7157
7158 ctk_widget_draw_internal (widget, cr, TRUE(!(0)));
7159
7160 ctk_cairo_set_marked_for_draw (cr, was_marked);
7161
7162 cairo_restore (cr);
7163}
7164
7165static gboolean
7166ctk_widget_real_scroll_event (CtkWidget *widget,
7167 CdkEventScroll *event)
7168{
7169 return _ctk_widget_run_controllers (widget, (CdkEvent *) event,
7170 CTK_PHASE_BUBBLE);
7171}
7172
7173static gboolean
7174ctk_widget_real_button_event (CtkWidget *widget,
7175 CdkEventButton *event)
7176{
7177 return _ctk_widget_run_controllers (widget, (CdkEvent *) event,
7178 CTK_PHASE_BUBBLE);
7179}
7180
7181static gboolean
7182ctk_widget_real_motion_event (CtkWidget *widget,
7183 CdkEventMotion *event)
7184{
7185 return _ctk_widget_run_controllers (widget, (CdkEvent *) event,
7186 CTK_PHASE_BUBBLE);
7187}
7188
7189static gboolean
7190ctk_widget_real_key_press_event (CtkWidget *widget,
7191 CdkEventKey *event)
7192{
7193 if (_ctk_widget_run_controllers (widget, (CdkEvent *) event,
7194 CTK_PHASE_BUBBLE))
7195 return CDK_EVENT_STOP((!(0)));
7196
7197 return ctk_bindings_activate_event (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, event);
7198}
7199
7200static gboolean
7201ctk_widget_real_key_release_event (CtkWidget *widget,
7202 CdkEventKey *event)
7203{
7204 if (_ctk_widget_run_controllers (widget, (CdkEvent *) event,
7205 CTK_PHASE_BUBBLE))
7206 return CDK_EVENT_STOP((!(0)));
7207
7208 return ctk_bindings_activate_event (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, event);
7209}
7210
7211static gboolean
7212ctk_widget_real_focus_in_event (CtkWidget *widget,
7213 CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__)))
7214{
7215 ctk_widget_queue_draw (widget);
7216
7217 return FALSE(0);
7218}
7219
7220static gboolean
7221ctk_widget_real_focus_out_event (CtkWidget *widget,
7222 CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__)))
7223{
7224 ctk_widget_queue_draw (widget);
7225
7226 return FALSE(0);
7227}
7228
7229static gboolean
7230ctk_widget_real_touch_event (CtkWidget *widget,
7231 CdkEventTouch *event)
7232{
7233 CdkEvent *bevent;
7234 gboolean return_val = FALSE(0);
7235
7236 if (!event->emulating_pointer)
7237 return _ctk_widget_run_controllers (widget, (CdkEvent*) event,
7238 CTK_PHASE_BUBBLE);
7239
7240 if (event->type == CDK_TOUCH_UPDATE ||
7241 event->type == CDK_TOUCH_BEGIN)
7242 {
7243 bevent = cdk_event_new (CDK_MOTION_NOTIFY);
7244 bevent->any.window = g_object_ref (event->window)((__typeof__ (event->window)) (g_object_ref) (event->window
))
;
7245 bevent->any.send_event = FALSE(0);
7246 bevent->motion.time = event->time;
7247 bevent->button.state = event->state;
7248 bevent->motion.x_root = event->x_root;
7249 bevent->motion.y_root = event->y_root;
7250 bevent->motion.x = event->x;
7251 bevent->motion.y = event->y;
7252 bevent->motion.device = event->device;
7253 bevent->motion.is_hint = FALSE(0);
7254 bevent->motion.axes = g_memdup2 (event->axes,
7255 sizeof (gdouble) * cdk_device_get_n_axes (event->device));
7256 cdk_event_set_source_device (bevent, cdk_event_get_source_device ((CdkEvent*)event));
7257
7258 if (event->type == CDK_TOUCH_UPDATE)
7259 bevent->motion.state |= CDK_BUTTON1_MASK;
7260
7261 g_signal_emit (widget, widget_signals[MOTION_NOTIFY_EVENT], 0, bevent, &return_val);
7262
7263 cdk_event_free (bevent);
7264 }
7265
7266 if (event->type == CDK_TOUCH_BEGIN ||
7267 event->type == CDK_TOUCH_END)
7268 {
7269 CdkEventType type;
7270 gint signum;
7271
7272 if (event->type == CDK_TOUCH_BEGIN)
7273 {
7274 type = CDK_BUTTON_PRESS;
7275 signum = BUTTON_PRESS_EVENT;
7276 }
7277 else
7278 {
7279 type = CDK_BUTTON_RELEASE;
7280 signum = BUTTON_RELEASE_EVENT;
7281 }
7282 bevent = cdk_event_new (type);
7283 bevent->any.window = g_object_ref (event->window)((__typeof__ (event->window)) (g_object_ref) (event->window
))
;
7284 bevent->any.send_event = FALSE(0);
7285 bevent->button.time = event->time;
7286 bevent->button.state = event->state;
7287 bevent->button.button = 1;
7288 bevent->button.x_root = event->x_root;
7289 bevent->button.y_root = event->y_root;
7290 bevent->button.x = event->x;
7291 bevent->button.y = event->y;
7292 bevent->button.device = event->device;
7293 bevent->button.axes = g_memdup2 (event->axes,
7294 sizeof (gdouble) * cdk_device_get_n_axes (event->device));
7295 cdk_event_set_source_device (bevent, cdk_event_get_source_device ((CdkEvent*)event));
7296
7297 if (event->type == CDK_TOUCH_END)
7298 bevent->button.state |= CDK_BUTTON1_MASK;
7299
7300 g_signal_emit (widget, widget_signals[signum], 0, bevent, &return_val);
7301
7302 cdk_event_free (bevent);
7303 }
7304
7305 return return_val;
7306}
7307
7308static gboolean
7309ctk_widget_real_grab_broken_event (CtkWidget *widget,
7310 CdkEventGrabBroken *event)
7311{
7312 return _ctk_widget_run_controllers (widget, (CdkEvent*) event,
7313 CTK_PHASE_BUBBLE);
7314}
7315
7316#define WIDGET_REALIZED_FOR_EVENT(widget, event)(event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized
(widget))
\
7317 (event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized(widget))
7318
7319/**
7320 * ctk_widget_event:
7321 * @widget: a #CtkWidget
7322 * @event: a #CdkEvent
7323 *
7324 * Rarely-used function. This function is used to emit
7325 * the event signals on a widget (those signals should never
7326 * be emitted without using this function to do so).
7327 * If you want to synthesize an event though, don’t use this function;
7328 * instead, use ctk_main_do_event() so the event will behave as if
7329 * it were in the event queue. Don’t synthesize expose events; instead,
7330 * use cdk_window_invalidate_rect() to invalidate a region of the
7331 * window.
7332 *
7333 * Returns: return from the event signal emission (%TRUE if
7334 * the event was handled)
7335 **/
7336gboolean
7337ctk_widget_event (CtkWidget *widget,
7338 CdkEvent *event)
7339{
7340 g_return_val_if_fail (CTK_IS_WIDGET (widget), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((!(0))); } } while (0)
;
7341 g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE)do { if (((event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized
(widget)))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "WIDGET_REALIZED_FOR_EVENT (widget, event)"
); return ((!(0))); } } while (0)
;
7342
7343 if (event->type == CDK_EXPOSE)
7344 {
7345 g_warning ("Events of type CDK_EXPOSE cannot be synthesized. To get "
7346 "the same effect, call cdk_window_invalidate_rect/region(), "
7347 "followed by cdk_window_process_updates().");
7348 return TRUE(!(0));
7349 }
7350
7351 return ctk_widget_event_internal (widget, event);
7352}
7353
7354void
7355_ctk_widget_set_captured_event_handler (CtkWidget *widget,
7356 CtkCapturedEventHandler callback)
7357{
7358 g_object_set_data (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "captured-event-handler", callback);
7359}
7360
7361static CdkEventMask
7362_ctk_widget_get_controllers_evmask (CtkWidget *widget)
7363{
7364 EventControllerData *data;
7365 CdkEventMask evmask = 0;
7366 CtkWidgetPrivate *priv;
7367 GList *l;
7368
7369 priv = widget->priv;
7370
7371 for (l = priv->event_controllers; l; l = l->next)
7372 {
7373 data = l->data;
7374 if (data->controller)
7375 evmask |= ctk_event_controller_get_event_mask (CTK_EVENT_CONTROLLER (data->controller)((((CtkEventController*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((data->controller)), ((ctk_event_controller_get_type
()))))))
);
7376 }
7377
7378 return evmask;
7379}
7380
7381static gboolean
7382_ctk_widget_run_controllers (CtkWidget *widget,
7383 const CdkEvent *event,
7384 CtkPropagationPhase phase)
7385{
7386 EventControllerData *data;
7387 gboolean handled = FALSE(0);
7388 CtkWidgetPrivate *priv;
7389 GList *l;
7390
7391 priv = widget->priv;
7392 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
7393
7394 l = priv->event_controllers;
7395 while (l != NULL((void*)0))
7396 {
7397 GList *next = l->next;
7398
7399 if (!WIDGET_REALIZED_FOR_EVENT (widget, event)(event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized
(widget))
)
7400 break;
7401
7402 data = l->data;
7403
7404 if (data->controller == NULL((void*)0))
7405 {
7406 priv->event_controllers = g_list_delete_link (priv->event_controllers, l);
7407 g_free (data);
7408 }
7409 else
7410 {
7411 CtkPropagationPhase controller_phase;
7412
7413 controller_phase = ctk_event_controller_get_propagation_phase (data->controller);
7414
7415 if (controller_phase == phase)
7416 handled |= ctk_event_controller_handle_event (data->controller, event);
7417 }
7418
7419 l = next;
7420 }
7421
7422 g_object_unref (widget);
7423
7424 return handled;
7425}
7426
7427static void
7428cancel_event_sequence_on_hierarchy (CtkWidget *widget,
7429 CtkWidget *event_widget,
7430 CdkEventSequence *sequence)
7431{
7432 gboolean cancel = TRUE(!(0));
7433
7434 while (event_widget)
7435 {
7436 if (event_widget == widget)
7437 cancel = FALSE(0);
7438 else if (cancel)
7439 _ctk_widget_cancel_sequence (event_widget, sequence);
7440 else
7441 _ctk_widget_set_sequence_state_internal (event_widget, sequence,
7442 CTK_EVENT_SEQUENCE_DENIED,
7443 NULL((void*)0));
7444
7445 event_widget = _ctk_widget_get_parent (event_widget);
7446 }
7447}
7448
7449gboolean
7450_ctk_widget_captured_event (CtkWidget *widget,
7451 CdkEvent *event)
7452{
7453 gboolean return_val = FALSE(0);
7454 CtkCapturedEventHandler handler;
7455
7456 g_return_val_if_fail (CTK_IS_WIDGET (widget), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((!(0))); } } while (0)
;
7457 g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE)do { if (((event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized
(widget)))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "WIDGET_REALIZED_FOR_EVENT (widget, event)"
); return ((!(0))); } } while (0)
;
7458
7459 if (event->type == CDK_EXPOSE)
7460 {
7461 g_warning ("Events of type CDK_EXPOSE cannot be synthesized. To get "
7462 "the same effect, call cdk_window_invalidate_rect/region(), "
7463 "followed by cdk_window_process_updates().");
7464 return TRUE(!(0));
7465 }
7466
7467 if (!event_window_is_still_viewable (event))
7468 return TRUE(!(0));
7469
7470 return_val = _ctk_widget_run_controllers (widget, event, CTK_PHASE_CAPTURE);
7471
7472 handler = g_object_get_data (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "captured-event-handler");
7473 if (!handler)
7474 return return_val;
7475
7476 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
7477
7478 return_val |= handler (widget, event);
7479 return_val |= !WIDGET_REALIZED_FOR_EVENT (widget, event)(event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized
(widget))
;
7480
7481 /* The widget that was originally to receive the event
7482 * handles motion hints, but the capturing widget might
7483 * not, so ensure we get further motion events.
7484 */
7485 if (return_val &&
7486 event->type == CDK_MOTION_NOTIFY &&
7487 event->motion.is_hint &&
7488 (cdk_window_get_events (event->any.window) &
7489 CDK_POINTER_MOTION_HINT_MASK) != 0)
7490 cdk_event_request_motions (&event->motion);
7491
7492 g_object_unref (widget);
7493
7494 return return_val;
7495}
7496
7497/* Returns TRUE if a translation should be done */
7498static gboolean
7499_ctk_widget_get_translation_to_window (CtkWidget *widget,
7500 CdkWindow *window,
7501 int *x,
7502 int *y)
7503{
7504 CdkWindow *w, *widget_window;
7505
7506 if (!_ctk_widget_get_has_window (widget))
7507 {
7508 *x = -widget->priv->allocation.x;
7509 *y = -widget->priv->allocation.y;
7510 }
7511 else
7512 {
7513 *x = 0;
7514 *y = 0;
7515 }
7516
7517 widget_window = _ctk_widget_get_window (widget);
7518
7519 for (w = window; w && w != widget_window; w = cdk_window_get_parent (w))
7520 {
7521 int wx, wy;
7522 cdk_window_get_position (w, &wx, &wy);
7523 *x += wx;
7524 *y += wy;
7525 }
7526
7527 if (w == NULL((void*)0))
7528 {
7529 *x = 0;
7530 *y = 0;
7531 return FALSE(0);
7532 }
7533
7534 return TRUE(!(0));
7535}
7536
7537
7538/**
7539 * ctk_cairo_transform_to_window:
7540 * @cr: the cairo context to transform
7541 * @widget: the widget the context is currently centered for
7542 * @window: the window to transform the context to
7543 *
7544 * Transforms the given cairo context @cr that from @widget-relative
7545 * coordinates to @window-relative coordinates.
7546 * If the @widget’s window is not an ancestor of @window, no
7547 * modification will be applied.
7548 *
7549 * This is the inverse to the transformation CTK applies when
7550 * preparing an expose event to be emitted with the #CtkWidget::draw
7551 * signal. It is intended to help porting multiwindow widgets from
7552 * CTK+ 2 to the rendering architecture of CTK+ 3.
7553 *
7554 * Since: 3.0
7555 **/
7556void
7557ctk_cairo_transform_to_window (cairo_t *cr,
7558 CtkWidget *widget,
7559 CdkWindow *window)
7560{
7561 int x, y;
7562
7563 g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "cr != NULL"); return; }
} while (0)
;
7564 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
7565 g_return_if_fail (CDK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((cdk_window_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__
)), "CDK_IS_WINDOW (window)"); return; } } while (0)
;
7566
7567 if (_ctk_widget_get_translation_to_window (widget, window, &x, &y))
7568 cairo_translate (cr, x, y);
7569}
7570
7571/**
7572 * ctk_widget_send_expose:
7573 * @widget: a #CtkWidget
7574 * @event: a expose #CdkEvent
7575 *
7576 * Very rarely-used function. This function is used to emit
7577 * an expose event on a widget. This function is not normally used
7578 * directly. The only time it is used is when propagating an expose
7579 * event to a windowless child widget (ctk_widget_get_has_window() is %FALSE),
7580 * and that is normally done using ctk_container_propagate_draw().
7581 *
7582 * If you want to force an area of a window to be redrawn,
7583 * use cdk_window_invalidate_rect() or cdk_window_invalidate_region().
7584 * To cause the redraw to be done immediately, follow that call
7585 * with a call to cdk_window_process_updates().
7586 *
7587 * Returns: return from the event signal emission (%TRUE if
7588 * the event was handled)
7589 *
7590 * Deprecated: 3.22: Application and widget code should not handle
7591 * expose events directly; invalidation should use the #CtkWidget
7592 * API, and drawing should only happen inside #CtkWidget::draw
7593 * implementations
7594 */
7595gint
7596ctk_widget_send_expose (CtkWidget *widget,
7597 CdkEvent *event)
7598{
7599 g_return_val_if_fail (CTK_IS_WIDGET (widget), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((!(0))); } } while (0)
;
7600 g_return_val_if_fail (ctk_widget_get_realized (widget), TRUE)do { if ((ctk_widget_get_realized (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "ctk_widget_get_realized (widget)"
); return ((!(0))); } } while (0)
;
7601 g_return_val_if_fail (event != NULL, TRUE)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "event != NULL"); return
((!(0))); } } while (0)
;
7602 g_return_val_if_fail (event->type == CDK_EXPOSE, TRUE)do { if ((event->type == CDK_EXPOSE)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "event->type == CDK_EXPOSE"
); return ((!(0))); } } while (0)
;
7603
7604 ctk_widget_render (widget, event->any.window, event->expose.region);
7605
7606 return FALSE(0);
7607}
7608
7609static gboolean
7610event_window_is_still_viewable (CdkEvent *event)
7611{
7612 /* Check that we think the event's window is viewable before
7613 * delivering the event, to prevent surprises. We do this here
7614 * at the last moment, since the event may have been queued
7615 * up behind other events, held over a recursive main loop, etc.
7616 */
7617 switch (event->type)
7618 {
7619 case CDK_EXPOSE:
7620 case CDK_MOTION_NOTIFY:
7621 case CDK_BUTTON_PRESS:
7622 case CDK_2BUTTON_PRESS:
7623 case CDK_3BUTTON_PRESS:
7624 case CDK_KEY_PRESS:
7625 case CDK_ENTER_NOTIFY:
7626 case CDK_PROXIMITY_IN:
7627 case CDK_SCROLL:
7628 return event->any.window && cdk_window_is_viewable (event->any.window);
7629
7630#if 0
7631 /* The following events are the second half of paired events;
7632 * we always deliver them to deal with widgets that clean up
7633 * on the second half.
7634 */
7635 case CDK_BUTTON_RELEASE:
7636 case CDK_KEY_RELEASE:
7637 case CDK_LEAVE_NOTIFY:
7638 case CDK_PROXIMITY_OUT:
7639#endif
7640
7641 default:
7642 /* Remaining events would make sense on an not-viewable window,
7643 * or don't have an associated window.
7644 */
7645 return TRUE(!(0));
7646 }
7647}
7648
7649static gint
7650ctk_widget_event_internal (CtkWidget *widget,
7651 CdkEvent *event)
7652{
7653 gboolean return_val = FALSE(0), handled;
7654
7655 /* We check only once for is-still-visible; if someone
7656 * hides the window in on of the signals on the widget,
7657 * they are responsible for returning TRUE to terminate
7658 * handling.
7659 */
7660 if (!event_window_is_still_viewable (event))
7661 return TRUE(!(0));
7662
7663 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
7664
7665 if (widget == ctk_get_event_widget (event))
7666 return_val |= _ctk_widget_run_controllers (widget, event, CTK_PHASE_TARGET);
7667
7668 g_signal_emit (widget, widget_signals[EVENT], 0, event, &handled);
7669 return_val |= handled | !WIDGET_REALIZED_FOR_EVENT (widget, event)(event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized
(widget))
;
7670 if (!return_val)
7671 {
7672 gint signal_num;
7673
7674 switch (event->type)
7675 {
7676 case CDK_TOUCHPAD_SWIPE:
7677 case CDK_TOUCHPAD_PINCH:
7678 return_val |= _ctk_widget_run_controllers (widget, event, CTK_PHASE_BUBBLE);
7679 /* Fall through */
7680 case CDK_PAD_BUTTON_PRESS:
7681 case CDK_PAD_BUTTON_RELEASE:
7682 case CDK_PAD_RING:
7683 case CDK_PAD_STRIP:
7684 case CDK_PAD_GROUP_MODE:
7685 case CDK_EXPOSE:
7686 case CDK_NOTHING:
7687 signal_num = -1;
7688 break;
7689 case CDK_BUTTON_PRESS:
7690 case CDK_2BUTTON_PRESS:
7691 case CDK_3BUTTON_PRESS:
7692 signal_num = BUTTON_PRESS_EVENT;
7693 break;
7694 case CDK_TOUCH_BEGIN:
7695 case CDK_TOUCH_UPDATE:
7696 case CDK_TOUCH_END:
7697 case CDK_TOUCH_CANCEL:
7698 signal_num = TOUCH_EVENT;
7699 break;
7700 case CDK_SCROLL:
7701 signal_num = SCROLL_EVENT;
7702 break;
7703 case CDK_BUTTON_RELEASE:
7704 signal_num = BUTTON_RELEASE_EVENT;
7705 break;
7706 case CDK_MOTION_NOTIFY:
7707 signal_num = MOTION_NOTIFY_EVENT;
7708 break;
7709 case CDK_DELETE:
7710 signal_num = DELETE_EVENT;
7711 break;
7712 case CDK_DESTROY:
7713 signal_num = DESTROY_EVENT;
7714 _ctk_tooltip_hide (widget);
7715 break;
7716 case CDK_KEY_PRESS:
7717 signal_num = KEY_PRESS_EVENT;
7718 break;
7719 case CDK_KEY_RELEASE:
7720 signal_num = KEY_RELEASE_EVENT;
7721 break;
7722 case CDK_ENTER_NOTIFY:
7723 signal_num = ENTER_NOTIFY_EVENT;
7724 break;
7725 case CDK_LEAVE_NOTIFY:
7726 signal_num = LEAVE_NOTIFY_EVENT;
7727 break;
7728 case CDK_FOCUS_CHANGE:
7729 signal_num = event->focus_change.in ? FOCUS_IN_EVENT : FOCUS_OUT_EVENT;
7730 if (event->focus_change.in)
7731 _ctk_tooltip_focus_in (widget);
7732 else
7733 _ctk_tooltip_focus_out (widget);
7734 break;
7735 case CDK_CONFIGURE:
7736 signal_num = CONFIGURE_EVENT;
7737 break;
7738 case CDK_MAP:
7739 signal_num = MAP_EVENT;
7740 break;
7741 case CDK_UNMAP:
7742 signal_num = UNMAP_EVENT;
7743 break;
7744 case CDK_WINDOW_STATE:
7745 signal_num = WINDOW_STATE_EVENT;
7746 break;
7747 case CDK_PROPERTY_NOTIFY:
7748 signal_num = PROPERTY_NOTIFY_EVENT;
7749 break;
7750 case CDK_SELECTION_CLEAR:
7751 signal_num = SELECTION_CLEAR_EVENT;
7752 break;
7753 case CDK_SELECTION_REQUEST:
7754 signal_num = SELECTION_REQUEST_EVENT;
7755 break;
7756 case CDK_SELECTION_NOTIFY:
7757 signal_num = SELECTION_NOTIFY_EVENT;
7758 break;
7759 case CDK_PROXIMITY_IN:
7760 signal_num = PROXIMITY_IN_EVENT;
7761 break;
7762 case CDK_PROXIMITY_OUT:
7763 signal_num = PROXIMITY_OUT_EVENT;
7764 break;
7765 case CDK_VISIBILITY_NOTIFY:
7766 signal_num = VISIBILITY_NOTIFY_EVENT;
7767 break;
7768 case CDK_GRAB_BROKEN:
7769 signal_num = GRAB_BROKEN_EVENT;
7770 break;
7771 case CDK_DAMAGE:
7772 signal_num = DAMAGE_EVENT;
7773 break;
7774 default:
7775 g_warning ("ctk_widget_event(): unhandled event type: %d", event->type);
7776 signal_num = -1;
7777 break;
7778 }
7779 if (signal_num != -1)
7780 {
7781 g_signal_emit (widget, widget_signals[signal_num], 0, event, &handled);
7782 return_val |= handled;
7783 }
7784 }
7785 if (WIDGET_REALIZED_FOR_EVENT (widget, event)(event->type == CDK_FOCUS_CHANGE || _ctk_widget_get_realized
(widget))
)
7786 g_signal_emit (widget, widget_signals[EVENT_AFTER], 0, event);
7787 else
7788 return_val = TRUE(!(0));
7789
7790 g_object_unref (widget);
7791
7792 return return_val;
7793}
7794
7795/**
7796 * ctk_widget_activate:
7797 * @widget: a #CtkWidget that’s activatable
7798 *
7799 * For widgets that can be “activated” (buttons, menu items, etc.)
7800 * this function activates them. Activation is what happens when you
7801 * press Enter on a widget during key navigation. If @widget isn't
7802 * activatable, the function returns %FALSE.
7803 *
7804 * Returns: %TRUE if the widget was activatable
7805 **/
7806gboolean
7807ctk_widget_activate (CtkWidget *widget)
7808{
7809 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
7810
7811 if (WIDGET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->activate_signal)
7812 {
7813 /* FIXME: we should eventually check the signals signature here */
7814 g_signal_emit (widget, WIDGET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->activate_signal, 0);
7815
7816 return TRUE(!(0));
7817 }
7818 else
7819 return FALSE(0);
7820}
7821
7822static void
7823ctk_widget_reparent_subwindows (CtkWidget *widget,
7824 CdkWindow *new_window)
7825{
7826 CtkWidgetPrivate *priv = widget->priv;
7827
7828 if (!_ctk_widget_get_has_window (widget))
7829 {
7830 GList *children = cdk_window_get_children (priv->window);
7831 GList *tmp_list;
7832
7833 for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
7834 {
7835 CdkWindow *window = tmp_list->data;
7836 gpointer child;
7837
7838 cdk_window_get_user_data (window, &child);
7839 while (child && child != widget)
7840 child = ((CtkWidget*) child)->priv->parent;
7841
7842 if (child)
7843 cdk_window_reparent (window, new_window, 0, 0);
7844 }
7845
7846 g_list_free (children);
7847 }
7848 else
7849 {
7850 CdkWindow *parent;
7851 GList *tmp_list, *children;
7852
7853 parent = cdk_window_get_parent (priv->window);
7854
7855 if (parent == NULL((void*)0))
7856 cdk_window_reparent (priv->window, new_window, 0, 0);
7857 else
7858 {
7859 children = cdk_window_get_children (parent);
7860
7861 for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
7862 {
7863 CdkWindow *window = tmp_list->data;
7864 gpointer child;
7865
7866 cdk_window_get_user_data (window, &child);
7867
7868 if (child == widget)
7869 cdk_window_reparent (window, new_window, 0, 0);
7870 }
7871
7872 g_list_free (children);
7873 }
7874 }
7875}
7876
7877static void
7878ctk_widget_reparent_fixup_child (CtkWidget *widget,
7879 gpointer client_data)
7880{
7881 CtkWidgetPrivate *priv = widget->priv;
7882
7883 g_assert (client_data != NULL)do { if (client_data != ((void*)0)) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 7883, ((const char*) (__func__)), "client_data != NULL"
); } while (0)
;
7884
7885 if (!_ctk_widget_get_has_window (widget))
7886 {
7887 if (priv->window)
7888 g_object_unref (priv->window);
7889 priv->window = (CdkWindow*) client_data;
7890 if (priv->window)
7891 g_object_ref (priv->window)((__typeof__ (priv->window)) (g_object_ref) (priv->window
))
;
7892
7893 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
7894 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
7895 ctk_widget_reparent_fixup_child,
7896 client_data);
7897 }
7898}
7899
7900/**
7901 * ctk_widget_reparent:
7902 * @widget: a #CtkWidget
7903 * @new_parent: a #CtkContainer to move the widget into
7904 *
7905 * Moves a widget from one #CtkContainer to another, handling reference
7906 * count issues to avoid destroying the widget.
7907 **/
7908void
7909ctk_widget_reparent (CtkWidget *widget,
7910 CtkWidget *new_parent)
7911{
7912 CtkWidgetPrivate *priv;
7913
7914 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
7915 g_return_if_fail (CTK_IS_CONTAINER (new_parent))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((new_parent)); GType __t = ((ctk_container_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
)))))) { } else { g_return_if_fail_warning ("Ctk", ((const char
*) (__func__)), "CTK_IS_CONTAINER (new_parent)"); return; } }
while (0)
;
7916 priv = widget->priv;
7917 g_return_if_fail (priv->parent != NULL)do { if ((priv->parent != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "priv->parent != NULL"
); return; } } while (0)
;
7918
7919 if (priv->parent != new_parent)
7920 {
7921 /* First try to see if we can get away without unrealizing
7922 * the widget as we reparent it. if so we set a flag so
7923 * that ctk_widget_unparent doesn't unrealize widget
7924 */
7925 if (_ctk_widget_get_realized (widget) && _ctk_widget_get_realized (new_parent))
7926 priv->in_reparent = TRUE(!(0));
7927
7928 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
7929 ctk_container_remove (CTK_CONTAINER (priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->parent)), ((ctk_container_get_type ()))))))
, widget);
7930 ctk_container_add (CTK_CONTAINER (new_parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_parent)), ((ctk_container_get_type ()))))))
, widget);
7931 g_object_unref (widget);
7932
7933 if (priv->in_reparent)
7934 {
7935 priv->in_reparent = FALSE(0);
7936
7937 ctk_widget_reparent_subwindows (widget, ctk_widget_get_parent_window (widget));
7938 ctk_widget_reparent_fixup_child (widget,
7939 ctk_widget_get_parent_window (widget));
7940 }
7941
7942 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_PARENT]);
7943 }
7944}
7945
7946/**
7947 * ctk_widget_intersect:
7948 * @widget: a #CtkWidget
7949 * @area: a rectangle
7950 * @intersection: (out caller-allocates) (optional): rectangle to store
7951 * intersection of @widget and @area
7952 *
7953 * Computes the intersection of a @widget’s area and @area, storing
7954 * the intersection in @intersection, and returns %TRUE if there was
7955 * an intersection. @intersection may be %NULL if you’re only
7956 * interested in whether there was an intersection.
7957 *
7958 * Returns: %TRUE if there was an intersection
7959 **/
7960gboolean
7961ctk_widget_intersect (CtkWidget *widget,
7962 const CdkRectangle *area,
7963 CdkRectangle *intersection)
7964{
7965 CtkWidgetPrivate *priv;
7966 CdkRectangle *dest;
7967 CdkRectangle tmp;
7968 gint return_val;
7969
7970 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
7971 g_return_val_if_fail (area != NULL, FALSE)do { if ((area != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "area != NULL"); return (
(0)); } } while (0)
;
7972
7973 priv = widget->priv;
7974
7975 if (intersection)
7976 dest = intersection;
7977 else
7978 dest = &tmp;
7979
7980 return_val = cdk_rectangle_intersect (&priv->allocation, area, dest);
7981
7982 if (return_val && intersection && _ctk_widget_get_has_window (widget))
7983 {
7984 intersection->x -= priv->allocation.x;
7985 intersection->y -= priv->allocation.y;
7986 }
7987
7988 return return_val;
7989}
7990
7991/**
7992 * ctk_widget_region_intersect:
7993 * @widget: a #CtkWidget
7994 * @region: a #cairo_region_t, in the same coordinate system as
7995 * @widget->allocation. That is, relative to @widget->window
7996 * for widgets which return %FALSE from ctk_widget_get_has_window();
7997 * relative to the parent window of @widget->window otherwise.
7998 *
7999 * Computes the intersection of a @widget’s area and @region, returning
8000 * the intersection. The result may be empty, use cairo_region_is_empty() to
8001 * check.
8002 *
8003 * Returns: A newly allocated region holding the intersection of @widget
8004 * and @region.
8005 *
8006 * Deprecated: 3.14: Use ctk_widget_get_allocation() and
8007 * cairo_region_intersect_rectangle() to get the same behavior.
8008 */
8009cairo_region_t *
8010ctk_widget_region_intersect (CtkWidget *widget,
8011 const cairo_region_t *region)
8012{
8013 CdkRectangle rect;
8014 cairo_region_t *dest;
8015
8016 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
8017 g_return_val_if_fail (region != NULL, NULL)do { if ((region != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "region != NULL"); return
(((void*)0)); } } while (0)
;
8018
8019 _ctk_widget_get_allocation (widget, &rect);
8020
8021 dest = cairo_region_create_rectangle (&rect);
8022
8023 cairo_region_intersect (dest, region);
8024
8025 return dest;
8026}
8027
8028/**
8029 * _ctk_widget_grab_notify:
8030 * @widget: a #CtkWidget
8031 * @was_grabbed: whether a grab is now in effect
8032 *
8033 * Emits the #CtkWidget::grab-notify signal on @widget.
8034 *
8035 * Since: 2.6
8036 **/
8037void
8038_ctk_widget_grab_notify (CtkWidget *widget,
8039 gboolean was_grabbed)
8040{
8041 g_signal_emit (widget, widget_signals[GRAB_NOTIFY], 0, was_grabbed);
8042}
8043
8044/**
8045 * ctk_widget_grab_focus:
8046 * @widget: a #CtkWidget
8047 *
8048 * Causes @widget to have the keyboard focus for the #CtkWindow it's
8049 * inside. @widget must be a focusable widget, such as a #CtkEntry;
8050 * something like #CtkFrame won’t work.
8051 *
8052 * More precisely, it must have the %CTK_CAN_FOCUS flag set. Use
8053 * ctk_widget_set_can_focus() to modify that flag.
8054 *
8055 * The widget also needs to be realized and mapped. This is indicated by the
8056 * related signals. Grabbing the focus immediately after creating the widget
8057 * will likely fail and cause critical warnings.
8058 **/
8059void
8060ctk_widget_grab_focus (CtkWidget *widget)
8061{
8062 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8063
8064 if (!ctk_widget_is_sensitive (widget))
8065 return;
8066
8067 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
8068 g_signal_emit (widget, widget_signals[GRAB_FOCUS], 0);
8069 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_HAS_FOCUS]);
8070 g_object_unref (widget);
8071}
8072
8073static void
8074reset_focus_recurse (CtkWidget *widget,
8075 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
8076{
8077 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
8078 {
8079 CtkContainer *container;
8080
8081 container = CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
;
8082 ctk_container_set_focus_child (container, NULL((void*)0));
8083
8084 ctk_container_foreach (container,
8085 reset_focus_recurse,
8086 NULL((void*)0));
8087 }
8088}
8089
8090static void
8091ctk_widget_real_grab_focus (CtkWidget *focus_widget)
8092{
8093 if (ctk_widget_get_can_focus (focus_widget))
8094 {
8095 CtkWidget *toplevel;
8096 CtkWidget *widget;
8097
8098 /* clear the current focus setting, break if the current widget
8099 * is the focus widget's parent, since containers above that will
8100 * be set by the next loop.
8101 */
8102 toplevel = _ctk_widget_get_toplevel (focus_widget);
8103 if (_ctk_widget_is_toplevel (toplevel) && CTK_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((ctk_window_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; }))))
)
8104 {
8105 widget = ctk_window_get_focus (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
);
8106
8107 if (widget == focus_widget)
8108 {
8109 /* We call _ctk_window_internal_set_focus() here so that the
8110 * toplevel window can request the focus if necessary.
8111 * This is needed when the toplevel is a CtkPlug
8112 */
8113 if (!ctk_widget_has_focus (widget))
8114 _ctk_window_internal_set_focus (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
, focus_widget);
8115
8116 return;
8117 }
8118
8119 if (widget)
8120 {
8121 CtkWidget *common_ancestor = ctk_widget_common_ancestor (widget, focus_widget);
8122
8123 if (widget != common_ancestor)
8124 {
8125 while (widget->priv->parent)
8126 {
8127 widget = widget->priv->parent;
8128 ctk_container_set_focus_child (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
, NULL((void*)0));
8129 if (widget == common_ancestor)
8130 break;
8131 }
8132 }
8133 }
8134 }
8135 else if (toplevel != focus_widget)
8136 {
8137 /* ctk_widget_grab_focus() operates on a tree without window...
8138 * actually, this is very questionable behavior.
8139 */
8140
8141 ctk_container_foreach (CTK_CONTAINER (toplevel)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_container_get_type ()))))))
,
8142 reset_focus_recurse,
8143 NULL((void*)0));
8144 }
8145
8146 /* now propagate the new focus up the widget tree and finally
8147 * set it on the window
8148 */
8149 widget = focus_widget;
8150 while (widget->priv->parent)
8151 {
8152 ctk_container_set_focus_child (CTK_CONTAINER (widget->priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget->priv->parent)), ((ctk_container_get_type (
)))))))
, widget);
8153 widget = widget->priv->parent;
8154 }
8155 if (CTK_IS_WINDOW (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_window_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; }))))
)
8156 _ctk_window_internal_set_focus (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_window_get_type ()))))))
, focus_widget);
8157 }
8158}
8159
8160static gboolean
8161ctk_widget_real_query_tooltip (CtkWidget *widget,
8162 gint x G_GNUC_UNUSED__attribute__ ((__unused__)),
8163 gint y G_GNUC_UNUSED__attribute__ ((__unused__)),
8164 gboolean keyboard_tip G_GNUC_UNUSED__attribute__ ((__unused__)),
8165 CtkTooltip *tooltip)
8166{
8167 gchar *tooltip_markup;
8168 gboolean has_tooltip;
8169
8170 tooltip_markup = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_tooltip_markup);
8171 has_tooltip = ctk_widget_get_has_tooltip (widget);
8172
8173 if (has_tooltip && tooltip_markup)
8174 {
8175 ctk_tooltip_set_markup (tooltip, tooltip_markup);
8176 return TRUE(!(0));
8177 }
8178
8179 return FALSE(0);
8180}
8181
8182gboolean
8183ctk_widget_query_tooltip (CtkWidget *widget,
8184 gint x,
8185 gint y,
8186 gboolean keyboard_mode,
8187 CtkTooltip *tooltip)
8188{
8189 gboolean retval = FALSE(0);
8190
8191 g_signal_emit (widget,
8192 widget_signals[QUERY_TOOLTIP],
8193 0,
8194 x, y,
8195 keyboard_mode,
8196 tooltip,
8197 &retval);
8198
8199 return retval;
8200}
8201
8202static void
8203ctk_widget_real_state_flags_changed (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
8204 CtkStateFlags old_state G_GNUC_UNUSED__attribute__ ((__unused__)))
8205{
8206}
8207
8208static void
8209ctk_widget_real_style_updated (CtkWidget *widget)
8210{
8211 CtkWidgetPrivate *priv = widget->priv;
8212
8213 ctk_widget_update_alpha (widget);
8214
8215 if (widget->priv->context)
8216 {
8217 CtkCssStyleChange *change = ctk_style_context_get_change (widget->priv->context);
8218 gboolean has_text = ctk_widget_peek_pango_context (widget) != NULL((void*)0);
8219
8220 if (change == NULL((void*)0) ||
8221 (has_text && ctk_css_style_change_affects (change, CTK_CSS_AFFECTS_FONT)))
8222 ctk_widget_update_pango_context (widget);
8223
8224 if (widget->priv->anchored)
8225 {
8226 if (change == NULL((void*)0) ||
8227 ctk_css_style_change_affects (change, CTK_CSS_AFFECTS_SIZE) ||
8228 (has_text && ctk_css_style_change_affects (change, CTK_CSS_AFFECTS_TEXT)))
8229 ctk_widget_queue_resize (widget);
8230 else if (ctk_css_style_change_affects (change, CTK_CSS_AFFECTS_CLIP))
8231 ctk_widget_queue_allocate (widget);
8232 else if (ctk_css_style_change_affects (change, CTK_CSS_AFFECTS_REDRAW(CTK_CSS_AFFECTS_FOREGROUND | CTK_CSS_AFFECTS_BACKGROUND | CTK_CSS_AFFECTS_BORDER
| CTK_CSS_AFFECTS_ICON | CTK_CSS_AFFECTS_SYMBOLIC_ICON | CTK_CSS_AFFECTS_OUTLINE
)
))
8233 ctk_widget_queue_draw (widget);
8234 }
8235 }
8236 else
8237 {
8238 ctk_widget_update_pango_context (widget);
8239
8240 if (widget->priv->anchored)
8241 ctk_widget_queue_resize (widget);
8242 }
8243
8244 if (priv->style != NULL((void*)0) &&
8245 priv->style != ctk_widget_get_default_style ())
8246 {
8247 /* Trigger ::style-set for old
8248 * widgets not listening to this
8249 */
8250 g_signal_emit (widget,
8251 widget_signals[STYLE_SET],
8252 0,
8253 widget->priv->style);
8254 }
8255}
8256
8257static gboolean
8258ctk_widget_real_show_help (CtkWidget *widget,
8259 CtkWidgetHelpType help_type)
8260{
8261 if (help_type == CTK_WIDGET_HELP_TOOLTIP)
8262 {
8263 _ctk_tooltip_toggle_keyboard_mode (widget);
8264
8265 return TRUE(!(0));
8266 }
8267 else
8268 return FALSE(0);
8269}
8270
8271static gboolean
8272ctk_widget_real_focus (CtkWidget *widget,
8273 CtkDirectionType direction G_GNUC_UNUSED__attribute__ ((__unused__)))
8274{
8275 if (!ctk_widget_get_can_focus (widget))
8276 return FALSE(0);
8277
8278 if (!ctk_widget_is_focus (widget))
8279 {
8280 ctk_widget_grab_focus (widget);
8281 return TRUE(!(0));
8282 }
8283 else
8284 return FALSE(0);
8285}
8286
8287static void
8288ctk_widget_real_move_focus (CtkWidget *widget,
8289 CtkDirectionType direction)
8290{
8291 CtkWidget *toplevel = _ctk_widget_get_toplevel (widget);
8292
8293 if (widget != toplevel && CTK_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((ctk_window_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; }))))
)
8294 {
8295 g_signal_emit (toplevel, widget_signals[MOVE_FOCUS], 0,
8296 direction);
8297 }
8298}
8299
8300static gboolean
8301ctk_widget_real_keynav_failed (CtkWidget *widget,
8302 CtkDirectionType direction)
8303{
8304 switch (direction)
8305 {
8306 case CTK_DIR_TAB_FORWARD:
8307 case CTK_DIR_TAB_BACKWARD:
8308 return FALSE(0);
8309
8310 case CTK_DIR_UP:
8311 case CTK_DIR_DOWN:
8312 case CTK_DIR_LEFT:
8313 case CTK_DIR_RIGHT:
8314 break;
8315 }
8316
8317 ctk_widget_error_bell (widget);
8318
8319 return TRUE(!(0));
8320}
8321
8322/**
8323 * ctk_widget_set_can_focus:
8324 * @widget: a #CtkWidget
8325 * @can_focus: whether or not @widget can own the input focus.
8326 *
8327 * Specifies whether @widget can own the input focus. See
8328 * ctk_widget_grab_focus() for actually setting the input focus on a
8329 * widget.
8330 *
8331 * Since: 2.18
8332 **/
8333void
8334ctk_widget_set_can_focus (CtkWidget *widget,
8335 gboolean can_focus)
8336{
8337 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8338
8339 if (widget->priv->can_focus != can_focus)
8340 {
8341 widget->priv->can_focus = can_focus;
8342
8343 ctk_widget_queue_resize (widget);
8344 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_CAN_FOCUS]);
8345 }
8346}
8347
8348/**
8349 * ctk_widget_get_can_focus:
8350 * @widget: a #CtkWidget
8351 *
8352 * Determines whether @widget can own the input focus. See
8353 * ctk_widget_set_can_focus().
8354 *
8355 * Returns: %TRUE if @widget can own the input focus, %FALSE otherwise
8356 *
8357 * Since: 2.18
8358 **/
8359gboolean
8360ctk_widget_get_can_focus (CtkWidget *widget)
8361{
8362 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8363
8364 return widget->priv->can_focus;
8365}
8366
8367/**
8368 * ctk_widget_has_focus:
8369 * @widget: a #CtkWidget
8370 *
8371 * Determines if the widget has the global input focus. See
8372 * ctk_widget_is_focus() for the difference between having the global
8373 * input focus, and only having the focus within a toplevel.
8374 *
8375 * Returns: %TRUE if the widget has the global input focus.
8376 *
8377 * Since: 2.18
8378 **/
8379gboolean
8380ctk_widget_has_focus (CtkWidget *widget)
8381{
8382 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8383
8384 return widget->priv->has_focus;
8385}
8386
8387/**
8388 * ctk_widget_has_visible_focus:
8389 * @widget: a #CtkWidget
8390 *
8391 * Determines if the widget should show a visible indication that
8392 * it has the global input focus. This is a convenience function for
8393 * use in ::draw handlers that takes into account whether focus
8394 * indication should currently be shown in the toplevel window of
8395 * @widget. See ctk_window_get_focus_visible() for more information
8396 * about focus indication.
8397 *
8398 * To find out if the widget has the global input focus, use
8399 * ctk_widget_has_focus().
8400 *
8401 * Returns: %TRUE if the widget should display a “focus rectangle”
8402 *
8403 * Since: 3.2
8404 */
8405gboolean
8406ctk_widget_has_visible_focus (CtkWidget *widget)
8407{
8408 gboolean draw_focus;
8409
8410 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8411
8412 if (widget->priv->has_focus)
8413 {
8414 CtkWidget *toplevel;
8415
8416 toplevel = _ctk_widget_get_toplevel (widget);
8417
8418 if (CTK_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((ctk_window_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; }))))
)
8419 draw_focus = ctk_window_get_focus_visible (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
);
8420 else
8421 draw_focus = TRUE(!(0));
8422 }
8423 else
8424 draw_focus = FALSE(0);
8425
8426 return draw_focus;
8427}
8428
8429/**
8430 * ctk_widget_is_focus:
8431 * @widget: a #CtkWidget
8432 *
8433 * Determines if the widget is the focus widget within its
8434 * toplevel. (This does not mean that the #CtkWidget:has-focus property is
8435 * necessarily set; #CtkWidget:has-focus will only be set if the
8436 * toplevel widget additionally has the global input focus.)
8437 *
8438 * Returns: %TRUE if the widget is the focus widget.
8439 **/
8440gboolean
8441ctk_widget_is_focus (CtkWidget *widget)
8442{
8443 CtkWidget *toplevel;
8444
8445 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8446
8447 toplevel = _ctk_widget_get_toplevel (widget);
8448
8449 if (CTK_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((ctk_window_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; }))))
)
8450 return widget == ctk_window_get_focus (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
);
8451 else
8452 return FALSE(0);
8453}
8454
8455/**
8456 * ctk_widget_set_focus_on_click:
8457 * @widget: a #CtkWidget
8458 * @focus_on_click: whether the widget should grab focus when clicked with the mouse
8459 *
8460 * Sets whether the widget should grab focus when it is clicked with the mouse.
8461 * Making mouse clicks not grab focus is useful in places like toolbars where
8462 * you don’t want the keyboard focus removed from the main area of the
8463 * application.
8464 *
8465 * Since: 3.20
8466 **/
8467void
8468ctk_widget_set_focus_on_click (CtkWidget *widget,
8469 gboolean focus_on_click)
8470{
8471 CtkWidgetPrivate *priv;
8472
8473 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8474
8475 priv = widget->priv;
8476
8477 focus_on_click = focus_on_click != FALSE(0);
8478
8479 if (priv->focus_on_click != focus_on_click)
8480 {
8481 priv->focus_on_click = focus_on_click;
8482
8483 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_FOCUS_ON_CLICK]);
8484 }
8485}
8486
8487/**
8488 * ctk_widget_get_focus_on_click:
8489 * @widget: a #CtkWidget
8490 *
8491 * Returns whether the widget should grab focus when it is clicked with the mouse.
8492 * See ctk_widget_set_focus_on_click().
8493 *
8494 * Returns: %TRUE if the widget should grab focus when it is clicked with
8495 * the mouse.
8496 *
8497 * Since: 3.20
8498 **/
8499gboolean
8500ctk_widget_get_focus_on_click (CtkWidget *widget)
8501{
8502 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8503
8504 return widget->priv->focus_on_click;
8505}
8506
8507
8508/**
8509 * ctk_widget_set_can_default:
8510 * @widget: a #CtkWidget
8511 * @can_default: whether or not @widget can be a default widget.
8512 *
8513 * Specifies whether @widget can be a default widget. See
8514 * ctk_widget_grab_default() for details about the meaning of
8515 * “default”.
8516 *
8517 * Since: 2.18
8518 **/
8519void
8520ctk_widget_set_can_default (CtkWidget *widget,
8521 gboolean can_default)
8522{
8523 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8524
8525 if (widget->priv->can_default != can_default)
8526 {
8527 widget->priv->can_default = can_default;
8528
8529 ctk_widget_queue_resize (widget);
8530 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_CAN_DEFAULT]);
8531 }
8532}
8533
8534/**
8535 * ctk_widget_get_can_default:
8536 * @widget: a #CtkWidget
8537 *
8538 * Determines whether @widget can be a default widget. See
8539 * ctk_widget_set_can_default().
8540 *
8541 * Returns: %TRUE if @widget can be a default widget, %FALSE otherwise
8542 *
8543 * Since: 2.18
8544 **/
8545gboolean
8546ctk_widget_get_can_default (CtkWidget *widget)
8547{
8548 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8549
8550 return widget->priv->can_default;
8551}
8552
8553/**
8554 * ctk_widget_has_default:
8555 * @widget: a #CtkWidget
8556 *
8557 * Determines whether @widget is the current default widget within its
8558 * toplevel. See ctk_widget_set_can_default().
8559 *
8560 * Returns: %TRUE if @widget is the current default widget within
8561 * its toplevel, %FALSE otherwise
8562 *
8563 * Since: 2.18
8564 */
8565gboolean
8566ctk_widget_has_default (CtkWidget *widget)
8567{
8568 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8569
8570 return widget->priv->has_default;
8571}
8572
8573void
8574_ctk_widget_set_has_default (CtkWidget *widget,
8575 gboolean has_default)
8576{
8577 CtkStyleContext *context;
8578
8579 widget->priv->has_default = has_default;
8580
8581 context = _ctk_widget_get_style_context (widget);
8582
8583 if (has_default)
8584 ctk_style_context_add_class (context, CTK_STYLE_CLASS_DEFAULT"default");
8585 else
8586 ctk_style_context_remove_class (context, CTK_STYLE_CLASS_DEFAULT"default");
8587}
8588
8589/**
8590 * ctk_widget_grab_default:
8591 * @widget: a #CtkWidget
8592 *
8593 * Causes @widget to become the default widget. @widget must be able to be
8594 * a default widget; typically you would ensure this yourself
8595 * by calling ctk_widget_set_can_default() with a %TRUE value.
8596 * The default widget is activated when
8597 * the user presses Enter in a window. Default widgets must be
8598 * activatable, that is, ctk_widget_activate() should affect them. Note
8599 * that #CtkEntry widgets require the “activates-default” property
8600 * set to %TRUE before they activate the default widget when Enter
8601 * is pressed and the #CtkEntry is focused.
8602 **/
8603void
8604ctk_widget_grab_default (CtkWidget *widget)
8605{
8606 CtkWidget *window;
8607
8608 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8609 g_return_if_fail (ctk_widget_get_can_default (widget))do { if ((ctk_widget_get_can_default (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "ctk_widget_get_can_default (widget)"
); return; } } while (0)
;
8610
8611 window = _ctk_widget_get_toplevel (widget);
8612
8613 if (window && _ctk_widget_is_toplevel (window))
8614 ctk_window_set_default (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, widget);
8615 else
8616 g_warning (G_STRLOC"ctkwidget.c" ":" "8616" ": widget not within a CtkWindow");
8617}
8618
8619/**
8620 * ctk_widget_set_receives_default:
8621 * @widget: a #CtkWidget
8622 * @receives_default: whether or not @widget can be a default widget.
8623 *
8624 * Specifies whether @widget will be treated as the default widget
8625 * within its toplevel when it has the focus, even if another widget
8626 * is the default.
8627 *
8628 * See ctk_widget_grab_default() for details about the meaning of
8629 * “default”.
8630 *
8631 * Since: 2.18
8632 **/
8633void
8634ctk_widget_set_receives_default (CtkWidget *widget,
8635 gboolean receives_default)
8636{
8637 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8638
8639 if (widget->priv->receives_default != receives_default)
8640 {
8641 widget->priv->receives_default = receives_default;
8642
8643 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_RECEIVES_DEFAULT]);
8644 }
8645}
8646
8647/**
8648 * ctk_widget_get_receives_default:
8649 * @widget: a #CtkWidget
8650 *
8651 * Determines whether @widget is always treated as the default widget
8652 * within its toplevel when it has the focus, even if another widget
8653 * is the default.
8654 *
8655 * See ctk_widget_set_receives_default().
8656 *
8657 * Returns: %TRUE if @widget acts as the default widget when focused,
8658 * %FALSE otherwise
8659 *
8660 * Since: 2.18
8661 **/
8662gboolean
8663ctk_widget_get_receives_default (CtkWidget *widget)
8664{
8665 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8666
8667 return widget->priv->receives_default;
8668}
8669
8670/**
8671 * ctk_widget_has_grab:
8672 * @widget: a #CtkWidget
8673 *
8674 * Determines whether the widget is currently grabbing events, so it
8675 * is the only widget receiving input events (keyboard and mouse).
8676 *
8677 * See also ctk_grab_add().
8678 *
8679 * Returns: %TRUE if the widget is in the grab_widgets stack
8680 *
8681 * Since: 2.18
8682 **/
8683gboolean
8684ctk_widget_has_grab (CtkWidget *widget)
8685{
8686 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8687
8688 return widget->priv->has_grab;
8689}
8690
8691void
8692_ctk_widget_set_has_grab (CtkWidget *widget,
8693 gboolean has_grab)
8694{
8695 widget->priv->has_grab = has_grab;
8696}
8697
8698/**
8699 * ctk_widget_device_is_shadowed:
8700 * @widget: a #CtkWidget
8701 * @device: a #CdkDevice
8702 *
8703 * Returns %TRUE if @device has been shadowed by a CTK+
8704 * device grab on another widget, so it would stop sending
8705 * events to @widget. This may be used in the
8706 * #CtkWidget::grab-notify signal to check for specific
8707 * devices. See ctk_device_grab_add().
8708 *
8709 * Returns: %TRUE if there is an ongoing grab on @device
8710 * by another #CtkWidget than @widget.
8711 *
8712 * Since: 3.0
8713 **/
8714gboolean
8715ctk_widget_device_is_shadowed (CtkWidget *widget,
8716 CdkDevice *device)
8717{
8718 CtkWindowGroup *group;
8719 CtkWidget *grab_widget, *toplevel;
8720
8721 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
8722 g_return_val_if_fail (CDK_IS_DEVICE (device), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_device_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__
)), "CDK_IS_DEVICE (device)"); return ((0)); } } while (0)
;
8723
8724 if (!_ctk_widget_get_realized (widget))
8725 return TRUE(!(0));
8726
8727 toplevel = _ctk_widget_get_toplevel (widget);
8728
8729 if (CTK_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((ctk_window_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; }))))
)
8730 group = ctk_window_get_group (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
);
8731 else
8732 group = ctk_window_get_group (NULL((void*)0));
8733
8734 grab_widget = ctk_window_group_get_current_device_grab (group, device);
8735
8736 /* Widget not inside the hierarchy of grab_widget */
8737 if (grab_widget &&
8738 widget != grab_widget &&
8739 !ctk_widget_is_ancestor (widget, grab_widget))
8740 return TRUE(!(0));
8741
8742 grab_widget = ctk_window_group_get_current_grab (group);
8743 if (grab_widget && widget != grab_widget &&
8744 !ctk_widget_is_ancestor (widget, grab_widget))
8745 return TRUE(!(0));
8746
8747 return FALSE(0);
8748}
8749
8750/**
8751 * ctk_widget_set_name:
8752 * @widget: a #CtkWidget
8753 * @name: name for the widget
8754 *
8755 * Widgets can be named, which allows you to refer to them from a
8756 * CSS file. You can apply a style to widgets with a particular name
8757 * in the CSS file. See the documentation for the CSS syntax (on the
8758 * same page as the docs for #CtkStyleContext).
8759 *
8760 * Note that the CSS syntax has certain special characters to delimit
8761 * and represent elements in a selector (period, #, >, *...), so using
8762 * these will make your widget impossible to match by name. Any combination
8763 * of alphanumeric symbols, dashes and underscores will suffice.
8764 */
8765void
8766ctk_widget_set_name (CtkWidget *widget,
8767 const gchar *name)
8768{
8769 CtkWidgetPrivate *priv;
8770 gchar *new_name;
8771
8772 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8773
8774 priv = widget->priv;
8775
8776 new_name = g_strdup (name)g_strdup_inline (name);
8777 g_free (priv->name);
8778 priv->name = new_name;
8779
8780 if (priv->context)
8781 ctk_style_context_set_id (priv->context, priv->name);
8782
8783 ctk_css_node_set_id (priv->cssnode, priv->name);
8784
8785 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_NAME]);
8786}
8787
8788/**
8789 * ctk_widget_get_name:
8790 * @widget: a #CtkWidget
8791 *
8792 * Retrieves the name of a widget. See ctk_widget_set_name() for the
8793 * significance of widget names.
8794 *
8795 * Returns: name of the widget. This string is owned by CTK+ and
8796 * should not be modified or freed
8797 **/
8798const gchar*
8799ctk_widget_get_name (CtkWidget *widget)
8800{
8801 CtkWidgetPrivate *priv;
8802
8803 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
8804
8805 priv = widget->priv;
8806
8807 if (priv->name)
8808 return priv->name;
8809 return G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
;
8810}
8811
8812static void
8813ctk_widget_update_state_flags (CtkWidget *widget,
8814 CtkStateFlags flags_to_set,
8815 CtkStateFlags flags_to_unset)
8816{
8817 CtkWidgetPrivate *priv;
8818
8819 priv = widget->priv;
8820
8821 /* Handle insensitive first, since it is propagated
8822 * differently throughout the widget hierarchy.
8823 */
8824 if ((priv->state_flags & CTK_STATE_FLAG_INSENSITIVE) && (flags_to_unset & CTK_STATE_FLAG_INSENSITIVE))
8825 ctk_widget_set_sensitive (widget, TRUE(!(0)));
8826 else if (!(priv->state_flags & CTK_STATE_FLAG_INSENSITIVE) && (flags_to_set & CTK_STATE_FLAG_INSENSITIVE))
8827 ctk_widget_set_sensitive (widget, FALSE(0));
8828
8829 flags_to_set &= ~(CTK_STATE_FLAG_INSENSITIVE);
8830 flags_to_unset &= ~(CTK_STATE_FLAG_INSENSITIVE);
8831
8832 if (flags_to_set != 0 || flags_to_unset != 0)
8833 {
8834 CtkStateData data;
8835
8836 data.old_scale_factor = ctk_widget_get_scale_factor (widget);
8837 data.flags_to_set = flags_to_set;
8838 data.flags_to_unset = flags_to_unset;
8839
8840 ctk_widget_propagate_state (widget, &data);
8841 }
8842}
8843
8844/**
8845 * ctk_widget_set_state_flags:
8846 * @widget: a #CtkWidget
8847 * @flags: State flags to turn on
8848 * @clear: Whether to clear state before turning on @flags
8849 *
8850 * This function is for use in widget implementations. Turns on flag
8851 * values in the current widget state (insensitive, prelighted, etc.).
8852 *
8853 * This function accepts the values %CTK_STATE_FLAG_DIR_LTR and
8854 * %CTK_STATE_FLAG_DIR_RTL but ignores them. If you want to set the widget's
8855 * direction, use ctk_widget_set_direction().
8856 *
8857 * It is worth mentioning that any other state than %CTK_STATE_FLAG_INSENSITIVE,
8858 * will be propagated down to all non-internal children if @widget is a
8859 * #CtkContainer, while %CTK_STATE_FLAG_INSENSITIVE itself will be propagated
8860 * down to all #CtkContainer children by different means than turning on the
8861 * state flag down the hierarchy, both ctk_widget_get_state_flags() and
8862 * ctk_widget_is_sensitive() will make use of these.
8863 *
8864 * Since: 3.0
8865 **/
8866void
8867ctk_widget_set_state_flags (CtkWidget *widget,
8868 CtkStateFlags flags,
8869 gboolean clear)
8870{
8871#define ALLOWED_FLAGS (~(CTK_STATE_FLAG_DIR_LTR | CTK_STATE_FLAG_DIR_RTL))
8872
8873 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8874 g_return_if_fail (flags < (1 << CTK_STATE_FLAGS_BITS))do { if ((flags < (1 << 13))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "flags < (1 << CTK_STATE_FLAGS_BITS)"
); return; } } while (0)
;
8875
8876 if ((!clear && (widget->priv->state_flags & flags) == flags) ||
8877 (clear && widget->priv->state_flags == flags))
8878 return;
8879
8880 if (clear)
8881 ctk_widget_update_state_flags (widget, flags & ALLOWED_FLAGS, ~flags & ALLOWED_FLAGS);
8882 else
8883 ctk_widget_update_state_flags (widget, flags & ALLOWED_FLAGS, 0);
8884
8885#undef ALLOWED_FLAGS
8886}
8887
8888/**
8889 * ctk_widget_unset_state_flags:
8890 * @widget: a #CtkWidget
8891 * @flags: State flags to turn off
8892 *
8893 * This function is for use in widget implementations. Turns off flag
8894 * values for the current widget state (insensitive, prelighted, etc.).
8895 * See ctk_widget_set_state_flags().
8896 *
8897 * Since: 3.0
8898 **/
8899void
8900ctk_widget_unset_state_flags (CtkWidget *widget,
8901 CtkStateFlags flags)
8902{
8903 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
8904 g_return_if_fail (flags < (1 << CTK_STATE_FLAGS_BITS))do { if ((flags < (1 << 13))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "flags < (1 << CTK_STATE_FLAGS_BITS)"
); return; } } while (0)
;
8905
8906 if ((widget->priv->state_flags & flags) == 0)
8907 return;
8908
8909 ctk_widget_update_state_flags (widget, 0, flags);
8910}
8911
8912/**
8913 * ctk_widget_get_state_flags:
8914 * @widget: a #CtkWidget
8915 *
8916 * Returns the widget state as a flag set. It is worth mentioning
8917 * that the effective %CTK_STATE_FLAG_INSENSITIVE state will be
8918 * returned, that is, also based on parent insensitivity, even if
8919 * @widget itself is sensitive.
8920 *
8921 * Also note that if you are looking for a way to obtain the
8922 * #CtkStateFlags to pass to a #CtkStyleContext method, you
8923 * should look at ctk_style_context_get_state().
8924 *
8925 * Returns: The state flags for widget
8926 *
8927 * Since: 3.0
8928 **/
8929CtkStateFlags
8930ctk_widget_get_state_flags (CtkWidget *widget)
8931{
8932 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
8933
8934 return widget->priv->state_flags;
8935}
8936
8937/**
8938 * ctk_widget_set_state:
8939 * @widget: a #CtkWidget
8940 * @state: new state for @widget
8941 *
8942 * This function is for use in widget implementations. Sets the state
8943 * of a widget (insensitive, prelighted, etc.) Usually you should set
8944 * the state using wrapper functions such as ctk_widget_set_sensitive().
8945 **/
8946void
8947ctk_widget_set_state (CtkWidget *widget,
8948 CtkStateType state)
8949{
8950 CtkStateFlags flags;
8951
8952 if (state == ctk_widget_get_state (widget))
8953 return;
8954
8955 switch (state)
8956 {
8957 case CTK_STATE_ACTIVE:
8958 flags = CTK_STATE_FLAG_ACTIVE;
8959 break;
8960 case CTK_STATE_PRELIGHT:
8961 flags = CTK_STATE_FLAG_PRELIGHT;
8962 break;
8963 case CTK_STATE_SELECTED:
8964 flags = CTK_STATE_FLAG_SELECTED;
8965 break;
8966 case CTK_STATE_INSENSITIVE:
8967 flags = CTK_STATE_FLAG_INSENSITIVE;
8968 break;
8969 case CTK_STATE_INCONSISTENT:
8970 flags = CTK_STATE_FLAG_INCONSISTENT;
8971 break;
8972 case CTK_STATE_FOCUSED:
8973 flags = CTK_STATE_FLAG_FOCUSED;
8974 break;
8975 case CTK_STATE_NORMAL:
8976 default:
8977 flags = 0;
8978 break;
8979 }
8980
8981 ctk_widget_update_state_flags (widget,
8982 flags,
8983 (CTK_STATE_FLAG_ACTIVE | CTK_STATE_FLAG_PRELIGHT | CTK_STATE_FLAG_SELECTED
8984 | CTK_STATE_FLAG_INSENSITIVE | CTK_STATE_FLAG_INCONSISTENT | CTK_STATE_FLAG_FOCUSED) ^ flags);
8985}
8986
8987/**
8988 * ctk_widget_get_state:
8989 * @widget: a #CtkWidget
8990 *
8991 * Returns the widget’s state. See ctk_widget_set_state().
8992 *
8993 * Returns: the state of @widget.
8994 *
8995 * Since: 2.18
8996 */
8997CtkStateType
8998ctk_widget_get_state (CtkWidget *widget)
8999{
9000 CtkStateFlags flags;
9001
9002 g_return_val_if_fail (CTK_IS_WIDGET (widget), CTK_STATE_NORMAL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (CTK_STATE_NORMAL); } }
while (0)
;
9003
9004 flags = _ctk_widget_get_state_flags (widget);
9005
9006 if (flags & CTK_STATE_FLAG_INSENSITIVE)
9007 return CTK_STATE_INSENSITIVE;
9008 else if (flags & CTK_STATE_FLAG_ACTIVE)
9009 return CTK_STATE_ACTIVE;
9010 else if (flags & CTK_STATE_FLAG_SELECTED)
9011 return CTK_STATE_SELECTED;
9012 else if (flags & CTK_STATE_FLAG_PRELIGHT)
9013 return CTK_STATE_PRELIGHT;
9014 else
9015 return CTK_STATE_NORMAL;
9016}
9017
9018/**
9019 * ctk_widget_set_visible:
9020 * @widget: a #CtkWidget
9021 * @visible: whether the widget should be shown or not
9022 *
9023 * Sets the visibility state of @widget. Note that setting this to
9024 * %TRUE doesn’t mean the widget is actually viewable, see
9025 * ctk_widget_get_visible().
9026 *
9027 * This function simply calls ctk_widget_show() or ctk_widget_hide()
9028 * but is nicer to use when the visibility of the widget depends on
9029 * some condition.
9030 *
9031 * Since: 2.18
9032 **/
9033void
9034ctk_widget_set_visible (CtkWidget *widget,
9035 gboolean visible)
9036{
9037 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9038
9039 if (visible)
9040 ctk_widget_show (widget);
9041 else
9042 ctk_widget_hide (widget);
9043}
9044
9045void
9046_ctk_widget_set_visible_flag (CtkWidget *widget,
9047 gboolean visible)
9048{
9049 CtkWidgetPrivate *priv = widget->priv;
9050
9051 priv->visible = visible;
9052
9053 if (!visible)
9054 {
9055 priv->allocation.x = -1;
9056 priv->allocation.y = -1;
9057 priv->allocation.width = 1;
9058 priv->allocation.height = 1;
9059 memset (&priv->clip, 0, sizeof (priv->clip));
9060 memset (&priv->allocated_size, 0, sizeof (priv->allocated_size));
9061 priv->allocated_size_baseline = 0;
9062 }
9063}
9064
9065/**
9066 * ctk_widget_get_visible:
9067 * @widget: a #CtkWidget
9068 *
9069 * Determines whether the widget is visible. If you want to
9070 * take into account whether the widget’s parent is also marked as
9071 * visible, use ctk_widget_is_visible() instead.
9072 *
9073 * This function does not check if the widget is obscured in any way.
9074 *
9075 * See ctk_widget_set_visible().
9076 *
9077 * Returns: %TRUE if the widget is visible
9078 *
9079 * Since: 2.18
9080 **/
9081gboolean
9082ctk_widget_get_visible (CtkWidget *widget)
9083{
9084 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9085
9086 return widget->priv->visible;
9087}
9088
9089/**
9090 * ctk_widget_is_visible:
9091 * @widget: a #CtkWidget
9092 *
9093 * Determines whether the widget and all its parents are marked as
9094 * visible.
9095 *
9096 * This function does not check if the widget is obscured in any way.
9097 *
9098 * See also ctk_widget_get_visible() and ctk_widget_set_visible()
9099 *
9100 * Returns: %TRUE if the widget and all its parents are visible
9101 *
9102 * Since: 3.8
9103 **/
9104gboolean
9105ctk_widget_is_visible (CtkWidget *widget)
9106{
9107 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9108
9109 while (widget)
9110 {
9111 CtkWidgetPrivate *priv = widget->priv;
9112
9113 if (!priv->visible)
9114 return FALSE(0);
9115
9116 widget = priv->parent;
9117 }
9118
9119 return TRUE(!(0));
9120}
9121
9122/**
9123 * ctk_widget_set_has_window:
9124 * @widget: a #CtkWidget
9125 * @has_window: whether or not @widget has a window.
9126 *
9127 * Specifies whether @widget has a #CdkWindow of its own. Note that
9128 * all realized widgets have a non-%NULL “window” pointer
9129 * (ctk_widget_get_window() never returns a %NULL window when a widget
9130 * is realized), but for many of them it’s actually the #CdkWindow of
9131 * one of its parent widgets. Widgets that do not create a %window for
9132 * themselves in #CtkWidget::realize must announce this by
9133 * calling this function with @has_window = %FALSE.
9134 *
9135 * This function should only be called by widget implementations,
9136 * and they should call it in their init() function.
9137 *
9138 * Since: 2.18
9139 **/
9140void
9141ctk_widget_set_has_window (CtkWidget *widget,
9142 gboolean has_window)
9143{
9144 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9145
9146 widget->priv->no_window = !has_window;
9147}
9148
9149/**
9150 * ctk_widget_get_has_window:
9151 * @widget: a #CtkWidget
9152 *
9153 * Determines whether @widget has a #CdkWindow of its own. See
9154 * ctk_widget_set_has_window().
9155 *
9156 * Returns: %TRUE if @widget has a window, %FALSE otherwise
9157 *
9158 * Since: 2.18
9159 **/
9160gboolean
9161ctk_widget_get_has_window (CtkWidget *widget)
9162{
9163 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9164
9165 return ! widget->priv->no_window;
9166}
9167
9168/**
9169 * ctk_widget_is_toplevel:
9170 * @widget: a #CtkWidget
9171 *
9172 * Determines whether @widget is a toplevel widget.
9173 *
9174 * Currently only #CtkWindow and #CtkInvisible (and out-of-process
9175 * #CtkPlugs) are toplevel widgets. Toplevel widgets have no parent
9176 * widget.
9177 *
9178 * Returns: %TRUE if @widget is a toplevel, %FALSE otherwise
9179 *
9180 * Since: 2.18
9181 **/
9182gboolean
9183ctk_widget_is_toplevel (CtkWidget *widget)
9184{
9185 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9186
9187 return widget->priv->toplevel;
9188}
9189
9190void
9191_ctk_widget_set_is_toplevel (CtkWidget *widget,
9192 gboolean is_toplevel)
9193{
9194 widget->priv->toplevel = is_toplevel;
9195}
9196
9197/**
9198 * ctk_widget_is_drawable:
9199 * @widget: a #CtkWidget
9200 *
9201 * Determines whether @widget can be drawn to. A widget can be drawn
9202 * to if it is mapped and visible.
9203 *
9204 * Returns: %TRUE if @widget is drawable, %FALSE otherwise
9205 *
9206 * Since: 2.18
9207 **/
9208gboolean
9209ctk_widget_is_drawable (CtkWidget *widget)
9210{
9211 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9212
9213 return (_ctk_widget_get_visible (widget) &&
9214 _ctk_widget_get_mapped (widget));
9215}
9216
9217/**
9218 * ctk_widget_get_realized:
9219 * @widget: a #CtkWidget
9220 *
9221 * Determines whether @widget is realized.
9222 *
9223 * Returns: %TRUE if @widget is realized, %FALSE otherwise
9224 *
9225 * Since: 2.20
9226 **/
9227gboolean
9228ctk_widget_get_realized (CtkWidget *widget)
9229{
9230 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9231
9232 return widget->priv->realized;
9233}
9234
9235/**
9236 * ctk_widget_set_realized:
9237 * @widget: a #CtkWidget
9238 * @realized: %TRUE to mark the widget as realized
9239 *
9240 * Marks the widget as being realized. This function must only be
9241 * called after all #CdkWindows for the @widget have been created
9242 * and registered.
9243 *
9244 * This function should only ever be called in a derived widget's
9245 * “realize” or “unrealize” implementation.
9246 *
9247 * Since: 2.20
9248 */
9249void
9250ctk_widget_set_realized (CtkWidget *widget,
9251 gboolean realized)
9252{
9253 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9254
9255 widget->priv->realized = realized;
9256}
9257
9258/**
9259 * ctk_widget_get_mapped:
9260 * @widget: a #CtkWidget
9261 *
9262 * Whether the widget is mapped.
9263 *
9264 * Returns: %TRUE if the widget is mapped, %FALSE otherwise.
9265 *
9266 * Since: 2.20
9267 */
9268gboolean
9269ctk_widget_get_mapped (CtkWidget *widget)
9270{
9271 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9272
9273 return widget->priv->mapped;
9274}
9275
9276/**
9277 * ctk_widget_set_mapped:
9278 * @widget: a #CtkWidget
9279 * @mapped: %TRUE to mark the widget as mapped
9280 *
9281 * Marks the widget as being mapped.
9282 *
9283 * This function should only ever be called in a derived widget's
9284 * “map” or “unmap” implementation.
9285 *
9286 * Since: 2.20
9287 */
9288void
9289ctk_widget_set_mapped (CtkWidget *widget,
9290 gboolean mapped)
9291{
9292 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9293
9294 widget->priv->mapped = mapped;
9295}
9296
9297/**
9298 * ctk_widget_set_app_paintable:
9299 * @widget: a #CtkWidget
9300 * @app_paintable: %TRUE if the application will paint on the widget
9301 *
9302 * Sets whether the application intends to draw on the widget in
9303 * an #CtkWidget::draw handler.
9304 *
9305 * This is a hint to the widget and does not affect the behavior of
9306 * the CTK+ core; many widgets ignore this flag entirely. For widgets
9307 * that do pay attention to the flag, such as #CtkEventBox and #CtkWindow,
9308 * the effect is to suppress default themed drawing of the widget's
9309 * background. (Children of the widget will still be drawn.) The application
9310 * is then entirely responsible for drawing the widget background.
9311 *
9312 * Note that the background is still drawn when the widget is mapped.
9313 **/
9314void
9315ctk_widget_set_app_paintable (CtkWidget *widget,
9316 gboolean app_paintable)
9317{
9318 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9319
9320 app_paintable = (app_paintable != FALSE(0));
9321
9322 if (widget->priv->app_paintable != app_paintable)
9323 {
9324 widget->priv->app_paintable = app_paintable;
9325
9326 if (_ctk_widget_is_drawable (widget))
9327 ctk_widget_queue_draw (widget);
9328
9329 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_APP_PAINTABLE]);
9330 }
9331}
9332
9333/**
9334 * ctk_widget_get_app_paintable:
9335 * @widget: a #CtkWidget
9336 *
9337 * Determines whether the application intends to draw on the widget in
9338 * an #CtkWidget::draw handler.
9339 *
9340 * See ctk_widget_set_app_paintable()
9341 *
9342 * Returns: %TRUE if the widget is app paintable
9343 *
9344 * Since: 2.18
9345 **/
9346gboolean
9347ctk_widget_get_app_paintable (CtkWidget *widget)
9348{
9349 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9350
9351 return widget->priv->app_paintable;
9352}
9353
9354/**
9355 * ctk_widget_set_double_buffered:
9356 * @widget: a #CtkWidget
9357 * @double_buffered: %TRUE to double-buffer a widget
9358 *
9359 * Widgets are double buffered by default; you can use this function
9360 * to turn off the buffering. “Double buffered” simply means that
9361 * cdk_window_begin_draw_frame() and cdk_window_end_draw_frame() are called
9362 * automatically around expose events sent to the
9363 * widget. cdk_window_begin_draw_frame() diverts all drawing to a widget's
9364 * window to an offscreen buffer, and cdk_window_end_draw_frame() draws the
9365 * buffer to the screen. The result is that users see the window
9366 * update in one smooth step, and don’t see individual graphics
9367 * primitives being rendered.
9368 *
9369 * In very simple terms, double buffered widgets don’t flicker,
9370 * so you would only use this function to turn off double buffering
9371 * if you had special needs and really knew what you were doing.
9372 *
9373 * Note: if you turn off double-buffering, you have to handle
9374 * expose events, since even the clearing to the background color or
9375 * pixmap will not happen automatically (as it is done in
9376 * cdk_window_begin_draw_frame()).
9377 *
9378 * In 3.10 CTK and CDK have been restructured for translucent drawing. Since
9379 * then expose events for double-buffered widgets are culled into a single
9380 * event to the toplevel CDK window. If you now unset double buffering, you
9381 * will cause a separate rendering pass for every widget. This will likely
9382 * cause rendering problems - in particular related to stacking - and usually
9383 * increases rendering times significantly.
9384 **/
9385void
9386ctk_widget_set_double_buffered (CtkWidget *widget,
9387 gboolean double_buffered)
9388{
9389 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9390
9391 double_buffered = (double_buffered != FALSE(0));
9392
9393 if (widget->priv->double_buffered != double_buffered)
9394 {
9395 widget->priv->double_buffered = double_buffered;
9396
9397 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_DOUBLE_BUFFERED]);
9398 }
9399}
9400
9401/**
9402 * ctk_widget_get_double_buffered:
9403 * @widget: a #CtkWidget
9404 *
9405 * Determines whether the widget is double buffered.
9406 *
9407 * See ctk_widget_set_double_buffered()
9408 *
9409 * Returns: %TRUE if the widget is double buffered
9410 *
9411 * Since: 2.18
9412 **/
9413gboolean
9414ctk_widget_get_double_buffered (CtkWidget *widget)
9415{
9416 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9417
9418 return widget->priv->double_buffered;
9419}
9420
9421/**
9422 * ctk_widget_set_redraw_on_allocate:
9423 * @widget: a #CtkWidget
9424 * @redraw_on_allocate: if %TRUE, the entire widget will be redrawn
9425 * when it is allocated to a new size. Otherwise, only the
9426 * new portion of the widget will be redrawn.
9427 *
9428 * Sets whether the entire widget is queued for drawing when its size
9429 * allocation changes. By default, this setting is %TRUE and
9430 * the entire widget is redrawn on every size change. If your widget
9431 * leaves the upper left unchanged when made bigger, turning this
9432 * setting off will improve performance.
9433
9434 * Note that for widgets where ctk_widget_get_has_window() is %FALSE
9435 * setting this flag to %FALSE turns off all allocation on resizing:
9436 * the widget will not even redraw if its position changes; this is to
9437 * allow containers that don’t draw anything to avoid excess
9438 * invalidations. If you set this flag on a widget with no window that
9439 * does draw on @widget->window, you are
9440 * responsible for invalidating both the old and new allocation of the
9441 * widget when the widget is moved and responsible for invalidating
9442 * regions newly when the widget increases size.
9443 **/
9444void
9445ctk_widget_set_redraw_on_allocate (CtkWidget *widget,
9446 gboolean redraw_on_allocate)
9447{
9448 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9449
9450 widget->priv->redraw_on_alloc = redraw_on_allocate;
9451}
9452
9453/**
9454 * ctk_widget_set_sensitive:
9455 * @widget: a #CtkWidget
9456 * @sensitive: %TRUE to make the widget sensitive
9457 *
9458 * Sets the sensitivity of a widget. A widget is sensitive if the user
9459 * can interact with it. Insensitive widgets are “grayed out” and the
9460 * user can’t interact with them. Insensitive widgets are known as
9461 * “inactive”, “disabled”, or “ghosted” in some other toolkits.
9462 **/
9463void
9464ctk_widget_set_sensitive (CtkWidget *widget,
9465 gboolean sensitive)
9466{
9467 CtkWidgetPrivate *priv;
9468
9469 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9470
9471 priv = widget->priv;
9472
9473 sensitive = (sensitive != FALSE(0));
9474
9475 if (priv->sensitive == sensitive)
9476 return;
9477
9478 priv->sensitive = sensitive;
9479
9480 if (priv->parent == NULL((void*)0)
9481 || ctk_widget_is_sensitive (priv->parent))
9482 {
9483 CtkStateData data;
9484
9485 data.old_scale_factor = ctk_widget_get_scale_factor (widget);
9486
9487 if (sensitive)
9488 {
9489 data.flags_to_set = 0;
9490 data.flags_to_unset = CTK_STATE_FLAG_INSENSITIVE;
9491 }
9492 else
9493 {
9494 data.flags_to_set = CTK_STATE_FLAG_INSENSITIVE;
9495 data.flags_to_unset = 0;
9496 }
9497
9498 ctk_widget_propagate_state (widget, &data);
9499 }
9500
9501 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_SENSITIVE]);
9502}
9503
9504/**
9505 * ctk_widget_get_sensitive:
9506 * @widget: a #CtkWidget
9507 *
9508 * Returns the widget’s sensitivity (in the sense of returning
9509 * the value that has been set using ctk_widget_set_sensitive()).
9510 *
9511 * The effective sensitivity of a widget is however determined by both its
9512 * own and its parent widget’s sensitivity. See ctk_widget_is_sensitive().
9513 *
9514 * Returns: %TRUE if the widget is sensitive
9515 *
9516 * Since: 2.18
9517 */
9518gboolean
9519ctk_widget_get_sensitive (CtkWidget *widget)
9520{
9521 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9522
9523 return widget->priv->sensitive;
9524}
9525
9526/**
9527 * ctk_widget_is_sensitive:
9528 * @widget: a #CtkWidget
9529 *
9530 * Returns the widget’s effective sensitivity, which means
9531 * it is sensitive itself and also its parent widget is sensitive
9532 *
9533 * Returns: %TRUE if the widget is effectively sensitive
9534 *
9535 * Since: 2.18
9536 */
9537gboolean
9538ctk_widget_is_sensitive (CtkWidget *widget)
9539{
9540 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
9541
9542 return !(widget->priv->state_flags & CTK_STATE_FLAG_INSENSITIVE);
9543}
9544
9545/**
9546 * ctk_widget_set_parent:
9547 * @widget: a #CtkWidget
9548 * @parent: parent container
9549 *
9550 * This function is useful only when implementing subclasses of
9551 * #CtkContainer.
9552 * Sets the container as the parent of @widget, and takes care of
9553 * some details such as updating the state and style of the child
9554 * to reflect its new location. The opposite function is
9555 * ctk_widget_unparent().
9556 **/
9557void
9558ctk_widget_set_parent (CtkWidget *widget,
9559 CtkWidget *parent)
9560{
9561 CtkStateFlags parent_flags;
9562 CtkWidgetPrivate *priv;
9563 CtkStateData data;
9564
9565 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9566 g_return_if_fail (CTK_IS_WIDGET (parent))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((parent)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (parent)"); return; } } while (0)
;
9567 g_return_if_fail (widget != parent)do { if ((widget != parent)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "widget != parent"); return
; } } while (0)
;
9568
9569 priv = widget->priv;
9570
9571 if (priv->parent != NULL((void*)0))
9572 {
9573 g_warning ("Can't set a parent on widget which has a parent");
9574 return;
9575 }
9576 if (_ctk_widget_is_toplevel (widget))
9577 {
9578 g_warning ("Can't set a parent on a toplevel widget");
9579 return;
9580 }
9581
9582 data.old_scale_factor = ctk_widget_get_scale_factor (widget);
9583
9584 /* keep this function in sync with ctk_menu_attach_to_widget()
9585 */
9586
9587 g_object_ref_sink (widget)((__typeof__ (widget)) (g_object_ref_sink) (widget));
9588
9589 ctk_widget_push_verify_invariants (widget);
9590
9591 priv->parent = parent;
9592
9593 parent_flags = _ctk_widget_get_state_flags (parent);
9594
9595 /* Merge both old state and current parent state,
9596 * making sure to only propagate the right states */
9597 data.flags_to_set = parent_flags & CTK_STATE_FLAGS_DO_PROPAGATE(CTK_STATE_FLAG_INSENSITIVE|CTK_STATE_FLAG_BACKDROP);
9598 data.flags_to_unset = 0;
9599 ctk_widget_propagate_state (widget, &data);
9600
9601 if (ctk_css_node_get_parent (widget->priv->cssnode) == NULL((void*)0))
9602 ctk_css_node_set_parent (widget->priv->cssnode, parent->priv->cssnode);
9603 if (priv->context)
9604 ctk_style_context_set_parent (priv->context,
9605 _ctk_widget_get_style_context (parent));
9606
9607 _ctk_widget_update_parent_muxer (widget);
9608
9609 g_signal_emit (widget, widget_signals[PARENT_SET], 0, NULL((void*)0));
9610 if (priv->parent->priv->anchored)
9611 _ctk_widget_propagate_hierarchy_changed (widget, NULL((void*)0));
9612 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_PARENT]);
9613
9614 /* Enforce realized/mapped invariants
9615 */
9616 if (_ctk_widget_get_realized (priv->parent))
9617 ctk_widget_realize (widget);
9618
9619 if (_ctk_widget_get_visible (priv->parent) &&
9620 _ctk_widget_get_visible (widget))
9621 {
9622 if (_ctk_widget_get_child_visible (widget) &&
9623 _ctk_widget_get_mapped (priv->parent))
9624 ctk_widget_map (widget);
9625
9626 ctk_widget_queue_resize (priv->parent);
9627 }
9628
9629 /* child may cause parent's expand to change, if the child is
9630 * expanded. If child is not expanded, then it can't modify the
9631 * parent's expand. If the child becomes expanded later then it will
9632 * queue compute_expand then. This optimization plus defaulting
9633 * newly-constructed widgets to need_compute_expand=FALSE should
9634 * mean that initially building a widget tree doesn't have to keep
9635 * walking up setting need_compute_expand on parents over and over.
9636 *
9637 * We can't change a parent to need to expand unless we're visible.
9638 */
9639 if (_ctk_widget_get_visible (widget) &&
9640 (priv->need_compute_expand ||
9641 priv->computed_hexpand ||
9642 priv->computed_vexpand))
9643 {
9644 ctk_widget_queue_compute_expand (parent);
9645 }
9646
9647 ctk_widget_pop_verify_invariants (widget);
9648}
9649
9650/**
9651 * ctk_widget_get_parent:
9652 * @widget: a #CtkWidget
9653 *
9654 * Returns the parent container of @widget.
9655 *
9656 * Returns: (transfer none) (nullable): the parent container of @widget, or %NULL
9657 **/
9658CtkWidget *
9659ctk_widget_get_parent (CtkWidget *widget)
9660{
9661 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
9662
9663 return widget->priv->parent;
9664}
9665
9666static CtkModifierStyle *
9667_ctk_widget_get_modifier_properties (CtkWidget *widget)
9668{
9669 CtkModifierStyle *style;
9670
9671 style = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_modifier_style);
9672
9673 if (G_UNLIKELY (!style)(!style))
9674 {
9675 CtkStyleContext *context;
9676
9677 style = _ctk_modifier_style_new ();
9678 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
9679 quark_modifier_style,
9680 style,
9681 (GDestroyNotify) g_object_unref);
9682
9683 context = _ctk_widget_get_style_context (widget);
9684
9685 ctk_style_context_add_provider (context,
9686 CTK_STYLE_PROVIDER (style)((((CtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((style)), ((ctk_style_provider_get_type ()))
))))
,
9687 CTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
9688 }
9689
9690 return style;
9691}
9692
9693/**
9694 * ctk_widget_override_color:
9695 * @widget: a #CtkWidget
9696 * @state: the state for which to set the color
9697 * @color: (allow-none): the color to assign, or %NULL to undo the effect
9698 * of previous calls to ctk_widget_override_color()
9699 *
9700 * Sets the color to use for a widget.
9701 *
9702 * All other style values are left untouched.
9703 *
9704 * This function does not act recursively. Setting the color of a
9705 * container does not affect its children. Note that some widgets that
9706 * you may not think of as containers, for instance #CtkButtons,
9707 * are actually containers.
9708 *
9709 * This API is mostly meant as a quick way for applications to
9710 * change a widget appearance. If you are developing a widgets
9711 * library and intend this change to be themeable, it is better
9712 * done by setting meaningful CSS classes in your
9713 * widget/container implementation through ctk_style_context_add_class().
9714 *
9715 * This way, your widget library can install a #CtkCssProvider
9716 * with the %CTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority in order
9717 * to provide a default styling for those widgets that need so, and
9718 * this theming may fully overridden by the user’s theme.
9719 *
9720 * Note that for complex widgets this may bring in undesired
9721 * results (such as uniform background color everywhere), in
9722 * these cases it is better to fully style such widgets through a
9723 * #CtkCssProvider with the %CTK_STYLE_PROVIDER_PRIORITY_APPLICATION
9724 * priority.
9725 *
9726 * Since: 3.0
9727 */
9728void
9729ctk_widget_override_color (CtkWidget *widget,
9730 CtkStateFlags state,
9731 const CdkRGBA *color)
9732{
9733 CtkModifierStyle *style;
9734
9735 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9736
9737 style = _ctk_widget_get_modifier_properties (widget);
9738 _ctk_modifier_style_set_color (style, state, color);
9739}
9740
9741/**
9742 * ctk_widget_override_background_color:
9743 * @widget: a #CtkWidget
9744 * @state: the state for which to set the background color
9745 * @color: (allow-none): the color to assign, or %NULL to undo the effect
9746 * of previous calls to ctk_widget_override_background_color()
9747 *
9748 * Sets the background color to use for a widget.
9749 *
9750 * All other style values are left untouched.
9751 * See ctk_widget_override_color().
9752 *
9753 * Since: 3.0
9754 */
9755void
9756ctk_widget_override_background_color (CtkWidget *widget,
9757 CtkStateFlags state,
9758 const CdkRGBA *color)
9759{
9760 CtkModifierStyle *style;
9761
9762 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9763
9764 style = _ctk_widget_get_modifier_properties (widget);
9765 _ctk_modifier_style_set_background_color (style, state, color);
9766}
9767
9768/**
9769 * ctk_widget_override_font:
9770 * @widget: a #CtkWidget
9771 * @font_desc: (allow-none): the font description to use, or %NULL to undo
9772 * the effect of previous calls to ctk_widget_override_font()
9773 *
9774 * Sets the font to use for a widget. All other style values are
9775 * left untouched. See ctk_widget_override_color().
9776 *
9777 * Since: 3.0
9778 */
9779void
9780ctk_widget_override_font (CtkWidget *widget,
9781 const PangoFontDescription *font_desc)
9782{
9783 CtkModifierStyle *style;
9784
9785 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9786
9787 style = _ctk_widget_get_modifier_properties (widget);
9788 _ctk_modifier_style_set_font (style, font_desc);
9789}
9790
9791/**
9792 * ctk_widget_override_symbolic_color:
9793 * @widget: a #CtkWidget
9794 * @name: the name of the symbolic color to modify
9795 * @color: (allow-none): the color to assign (does not need
9796 * to be allocated), or %NULL to undo the effect of previous
9797 * calls to ctk_widget_override_symbolic_color()
9798 *
9799 * Sets a symbolic color for a widget.
9800 *
9801 * All other style values are left untouched.
9802 * See ctk_widget_override_color() for overriding the foreground
9803 * or background color.
9804 *
9805 * Since: 3.0
9806 *
9807 * Deprecated: 3.16: This function is not useful in the context of CSS-based
9808 * rendering. If you wish to change the color used to render symbolic icons
9809 * you should use a custom CSS style, through an application-specific
9810 * #CtkStyleProvider and a CSS style class.
9811 */
9812void
9813ctk_widget_override_symbolic_color (CtkWidget *widget,
9814 const gchar *name,
9815 const CdkRGBA *color)
9816{
9817 CtkModifierStyle *style;
9818
9819 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9820
9821 style = _ctk_widget_get_modifier_properties (widget);
9822 _ctk_modifier_style_map_color (style, name, color);
9823}
9824
9825/**
9826 * ctk_widget_override_cursor:
9827 * @widget: a #CtkWidget
9828 * @cursor: (allow-none): the color to use for primary cursor (does not need to be
9829 * allocated), or %NULL to undo the effect of previous calls to
9830 * of ctk_widget_override_cursor().
9831 * @secondary_cursor: (allow-none): the color to use for secondary cursor (does not
9832 * need to be allocated), or %NULL to undo the effect of previous
9833 * calls to of ctk_widget_override_cursor().
9834 *
9835 * Sets the cursor color to use in a widget, overriding the
9836 * cursor-color and secondary-cursor-color
9837 * style properties. All other style values are left untouched.
9838 * See also ctk_widget_modify_style().
9839 *
9840 * Note that the underlying properties have the #CdkColor type,
9841 * so the alpha value in @primary and @secondary will be ignored.
9842 *
9843 * Since: 3.0
9844 *
9845 * Deprecated: 3.16: This function is not useful in the context of CSS-based
9846 * rendering. If you wish to change the color used to render the primary
9847 * and secondary cursors you should use a custom CSS style, through an
9848 * application-specific #CtkStyleProvider and a CSS style class.
9849 */
9850void
9851ctk_widget_override_cursor (CtkWidget *widget,
9852 const CdkRGBA *cursor,
9853 const CdkRGBA *secondary_cursor)
9854{
9855 CtkModifierStyle *style;
9856
9857 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
9858
9859 style = _ctk_widget_get_modifier_properties (widget);
9860 _ctk_modifier_style_set_color_property (style,
9861 CTK_TYPE_WIDGET(ctk_widget_get_type ()),
9862 "cursor-color", cursor);
9863 _ctk_modifier_style_set_color_property (style,
9864 CTK_TYPE_WIDGET(ctk_widget_get_type ()),
9865 "secondary-cursor-color",
9866 secondary_cursor);
9867}
9868
9869static void
9870ctk_widget_real_direction_changed (CtkWidget *widget,
9871 CtkTextDirection previous_direction G_GNUC_UNUSED__attribute__ ((__unused__)))
9872{
9873 ctk_widget_queue_resize (widget);
9874}
9875
9876static void
9877ctk_widget_real_style_set (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
9878 CtkStyle *previous_style G_GNUC_UNUSED__attribute__ ((__unused__)))
9879{
9880}
9881
9882typedef struct {
9883 CtkWidget *previous_toplevel;
9884 CdkScreen *previous_screen;
9885 CdkScreen *new_screen;
9886} HierarchyChangedInfo;
9887
9888static void
9889do_screen_change (CtkWidget *widget,
9890 CdkScreen *old_screen,
9891 CdkScreen *new_screen)
9892{
9893 if (old_screen != new_screen)
9894 {
9895 CtkWidgetPrivate *priv = widget->priv;
9896
9897 if (old_screen)
9898 {
9899 PangoContext *context = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_pango_context);
9900 if (context)
9901 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_pango_context, NULL((void*)0));
9902 }
9903
9904 _ctk_tooltip_hide (widget);
9905
9906 if (new_screen && priv->context)
9907 ctk_style_context_set_screen (priv->context, new_screen);
9908
9909 g_signal_emit (widget, widget_signals[SCREEN_CHANGED], 0, old_screen);
9910 }
9911}
9912
9913static void
9914ctk_widget_propagate_hierarchy_changed_recurse (CtkWidget *widget,
9915 gpointer client_data)
9916{
9917 CtkWidgetPrivate *priv = widget->priv;
9918 HierarchyChangedInfo *info = client_data;
9919 gboolean new_anchored = _ctk_widget_is_toplevel (widget) ||
9920 (priv->parent && priv->parent->priv->anchored);
9921
9922 if (priv->anchored != new_anchored)
9923 {
9924 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
9925
9926 priv->anchored = new_anchored;
9927
9928 /* This can only happen with ctk_widget_reparent() */
9929 if (priv->realized)
9930 {
9931 if (new_anchored)
9932 ctk_widget_connect_frame_clock (widget,
9933 ctk_widget_get_frame_clock (widget));
9934 else
9935 ctk_widget_disconnect_frame_clock (widget,
9936 ctk_widget_get_frame_clock (info->previous_toplevel));
9937 }
9938
9939 g_signal_emit (widget, widget_signals[HIERARCHY_CHANGED], 0, info->previous_toplevel);
9940 do_screen_change (widget, info->previous_screen, info->new_screen);
9941
9942 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
9943 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
9944 ctk_widget_propagate_hierarchy_changed_recurse,
9945 client_data);
9946
9947 g_object_unref (widget);
9948 }
9949}
9950
9951/**
9952 * _ctk_widget_propagate_hierarchy_changed:
9953 * @widget: a #CtkWidget
9954 * @previous_toplevel: Previous toplevel
9955 *
9956 * Propagates changes in the anchored state to a widget and all
9957 * children, unsetting or setting the %ANCHORED flag, and
9958 * emitting #CtkWidget::hierarchy-changed.
9959 **/
9960void
9961_ctk_widget_propagate_hierarchy_changed (CtkWidget *widget,
9962 CtkWidget *previous_toplevel)
9963{
9964 CtkWidgetPrivate *priv = widget->priv;
9965 HierarchyChangedInfo info;
9966
9967 info.previous_toplevel = previous_toplevel;
9968 info.previous_screen = previous_toplevel ? ctk_widget_get_screen (previous_toplevel) : NULL((void*)0);
9969
9970 if (_ctk_widget_is_toplevel (widget) ||
9971 (priv->parent && priv->parent->priv->anchored))
9972 info.new_screen = ctk_widget_get_screen (widget);
9973 else
9974 info.new_screen = NULL((void*)0);
9975
9976 if (info.previous_screen)
9977 g_object_ref (info.previous_screen)((__typeof__ (info.previous_screen)) (g_object_ref) (info.previous_screen
))
;
9978 if (previous_toplevel)
9979 g_object_ref (previous_toplevel)((__typeof__ (previous_toplevel)) (g_object_ref) (previous_toplevel
))
;
9980
9981 ctk_widget_propagate_hierarchy_changed_recurse (widget, &info);
9982
9983 if (previous_toplevel)
9984 g_object_unref (previous_toplevel);
9985 if (info.previous_screen)
9986 g_object_unref (info.previous_screen);
9987}
9988
9989static void
9990ctk_widget_propagate_screen_changed_recurse (CtkWidget *widget,
9991 gpointer client_data)
9992{
9993 HierarchyChangedInfo *info = client_data;
9994
9995 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
9996
9997 do_screen_change (widget, info->previous_screen, info->new_screen);
9998
9999 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
10000 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
10001 ctk_widget_propagate_screen_changed_recurse,
10002 client_data);
10003
10004 g_object_unref (widget);
10005}
10006
10007/**
10008 * ctk_widget_is_composited:
10009 * @widget: a #CtkWidget
10010 *
10011 * Whether @widget can rely on having its alpha channel
10012 * drawn correctly. On X11 this function returns whether a
10013 * compositing manager is running for @widget’s screen.
10014 *
10015 * Please note that the semantics of this call will change
10016 * in the future if used on a widget that has a composited
10017 * window in its hierarchy (as set by cdk_window_set_composited()).
10018 *
10019 * Returns: %TRUE if the widget can rely on its alpha
10020 * channel being drawn correctly.
10021 *
10022 * Since: 2.10
10023 *
10024 * Deprecated: 3.22: Use cdk_screen_is_composited() instead.
10025 */
10026gboolean
10027ctk_widget_is_composited (CtkWidget *widget)
10028{
10029 CdkScreen *screen;
10030
10031 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
10032
10033 screen = ctk_widget_get_screen (widget);
10034
10035 return cdk_screen_is_composited (screen);
10036}
10037
10038static void
10039propagate_composited_changed (CtkWidget *widget,
10040 gpointer dummy G_GNUC_UNUSED__attribute__ ((__unused__)))
10041{
10042 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
10043 {
10044 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
10045 propagate_composited_changed,
10046 NULL((void*)0));
10047 }
10048
10049 g_signal_emit (widget, widget_signals[COMPOSITED_CHANGED], 0);
10050}
10051
10052void
10053_ctk_widget_propagate_composited_changed (CtkWidget *widget)
10054{
10055 propagate_composited_changed (widget, NULL((void*)0));
10056}
10057
10058/**
10059 * _ctk_widget_propagate_screen_changed:
10060 * @widget: a #CtkWidget
10061 * @previous_screen: Previous screen
10062 *
10063 * Propagates changes in the screen for a widget to all
10064 * children, emitting #CtkWidget::screen-changed.
10065 **/
10066void
10067_ctk_widget_propagate_screen_changed (CtkWidget *widget,
10068 CdkScreen *previous_screen)
10069{
10070 HierarchyChangedInfo info;
10071
10072 info.previous_screen = previous_screen;
10073 info.new_screen = ctk_widget_get_screen (widget);
10074
10075 if (previous_screen)
10076 g_object_ref (previous_screen)((__typeof__ (previous_screen)) (g_object_ref) (previous_screen
))
;
10077
10078 ctk_widget_propagate_screen_changed_recurse (widget, &info);
10079
10080 if (previous_screen)
10081 g_object_unref (previous_screen);
10082}
10083
10084static void
10085reset_style_recurse (CtkWidget *widget,
10086 gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
10087{
10088 _ctk_widget_invalidate_style_context (widget, CTK_CSS_CHANGE_ANY((1 << 19) - 1));
10089
10090 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
10091 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
10092 reset_style_recurse,
10093 NULL((void*)0));
10094}
10095
10096/**
10097 * ctk_widget_reset_style:
10098 * @widget: a #CtkWidget
10099 *
10100 * Updates the style context of @widget and all descendants
10101 * by updating its widget path. #CtkContainers may want
10102 * to use this on a child when reordering it in a way that a different
10103 * style might apply to it. See also ctk_container_get_path_for_child().
10104 *
10105 * Since: 3.0
10106 */
10107void
10108ctk_widget_reset_style (CtkWidget *widget)
10109{
10110 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
10111
10112 reset_style_recurse (widget, NULL((void*)0));
10113
10114 g_list_foreach (widget->priv->attached_windows,
10115 (GFunc) reset_style_recurse, NULL((void*)0));
10116}
10117
10118#ifdef G_ENABLE_CONSISTENCY_CHECKS1
10119
10120/* Verify invariants, see docs/widget_system.txt for notes on much of
10121 * this. Invariants may be temporarily broken while we’re in the
10122 * process of updating state, of course, so you can only
10123 * verify_invariants() after a given operation is complete.
10124 * Use push/pop_verify_invariants to help with that.
10125 */
10126static void
10127ctk_widget_verify_invariants (CtkWidget *widget)
10128{
10129 CtkWidget *parent;
10130
10131 if (widget->priv->verifying_invariants_count > 0)
10132 return;
10133
10134 parent = widget->priv->parent;
10135
10136 if (widget->priv->mapped)
10137 {
10138 /* Mapped implies ... */
10139
10140 if (!widget->priv->realized)
10141 g_warning ("%s %p is mapped but not realized",
10142 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10143
10144 if (!widget->priv->visible)
10145 g_warning ("%s %p is mapped but not visible",
10146 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10147
10148 if (!widget->priv->toplevel)
10149 {
10150 if (!widget->priv->child_visible)
10151 g_warning ("%s %p is mapped but not child_visible",
10152 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10153 }
10154 }
10155 else
10156 {
10157 /* Not mapped implies... */
10158
10159#if 0
10160 /* This check makes sense for normal toplevels, but for
10161 * something like a toplevel that is embedded within a clutter
10162 * state, mapping may depend on external factors.
10163 */
10164 if (widget->priv->toplevel)
10165 {
10166 if (widget->priv->visible)
10167 g_warning ("%s %p toplevel is visible but not mapped",
10168 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10169 }
10170#endif
10171 }
10172
10173 /* Parent related checks aren't possible if parent has
10174 * verifying_invariants_count > 0 because parent needs to recurse
10175 * children first before the invariants will hold.
10176 */
10177 if (parent == NULL((void*)0) || parent->priv->verifying_invariants_count == 0)
10178 {
10179 if (parent &&
10180 parent->priv->realized)
10181 {
10182 /* Parent realized implies... */
10183
10184#if 0
10185 /* This is in widget_system.txt but appears to fail
10186 * because there's no ctk_container_realize() that
10187 * realizes all children... instead we just lazily
10188 * wait for map to fix things up.
10189 */
10190 if (!widget->priv->realized)
10191 g_warning ("%s %p is realized but child %s %p is not realized",
10192 G_OBJECT_TYPE_NAME (parent)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (parent))->
g_class))->g_type)))))
, parent,
10193 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10194#endif
10195 }
10196 else if (!widget->priv->toplevel)
10197 {
10198 /* No parent or parent not realized on non-toplevel implies... */
10199
10200 if (widget->priv->realized && !widget->priv->in_reparent)
10201 g_warning ("%s %p is not realized but child %s %p is realized",
10202 parent ? G_OBJECT_TYPE_NAME (parent)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (parent))->
g_class))->g_type)))))
: "no parent", parent,
10203 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10204 }
10205
10206 if (parent &&
10207 parent->priv->mapped &&
10208 widget->priv->visible &&
10209 widget->priv->child_visible)
10210 {
10211 /* Parent mapped and we are visible implies... */
10212
10213 if (!widget->priv->mapped)
10214 g_warning ("%s %p is mapped but visible child %s %p is not mapped",
10215 G_OBJECT_TYPE_NAME (parent)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (parent))->
g_class))->g_type)))))
, parent,
10216 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10217 }
10218 else if (!widget->priv->toplevel)
10219 {
10220 /* No parent or parent not mapped on non-toplevel implies... */
10221
10222 if (widget->priv->mapped && !widget->priv->in_reparent)
10223 g_warning ("%s %p is mapped but visible=%d child_visible=%d parent %s %p mapped=%d",
10224 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget,
10225 widget->priv->visible,
10226 widget->priv->child_visible,
10227 parent ? G_OBJECT_TYPE_NAME (parent)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (parent))->
g_class))->g_type)))))
: "no parent", parent,
10228 parent ? parent->priv->mapped : FALSE(0));
10229 }
10230 }
10231
10232 if (!widget->priv->realized)
10233 {
10234 /* Not realized implies... */
10235
10236#if 0
10237 /* widget_system.txt says these hold, but they don't. */
10238 if (widget->priv->alloc_needed)
10239 g_warning ("%s %p alloc needed but not realized",
10240 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10241
10242 if (widget->priv->width_request_needed)
10243 g_warning ("%s %p width request needed but not realized",
10244 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10245
10246 if (widget->priv->height_request_needed)
10247 g_warning ("%s %p height request needed but not realized",
10248 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
, widget);
10249#endif
10250 }
10251}
10252
10253/* The point of this push/pop is that invariants may not hold while
10254 * we’re busy making changes. So we only check at the outermost call
10255 * on the call stack, after we finish updating everything.
10256 */
10257static void
10258ctk_widget_push_verify_invariants (CtkWidget *widget)
10259{
10260 widget->priv->verifying_invariants_count += 1;
10261}
10262
10263static void
10264ctk_widget_verify_child_invariants (CtkWidget *widget,
10265 gpointer client_data G_GNUC_UNUSED__attribute__ ((__unused__)))
10266{
10267 /* We don't recurse further; this is a one-level check. */
10268 ctk_widget_verify_invariants (widget);
10269}
10270
10271static void
10272ctk_widget_pop_verify_invariants (CtkWidget *widget)
10273{
10274 g_assert (widget->priv->verifying_invariants_count > 0)do { if (widget->priv->verifying_invariants_count > 0
) ; else g_assertion_message_expr ("Ctk", "ctkwidget.c", 10274
, ((const char*) (__func__)), "widget->priv->verifying_invariants_count > 0"
); } while (0)
;
10275
10276 widget->priv->verifying_invariants_count -= 1;
10277
10278 if (widget->priv->verifying_invariants_count == 0)
10279 {
10280 ctk_widget_verify_invariants (widget);
10281
10282 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
10283 {
10284 /* Check one level of children, because our
10285 * push_verify_invariants() will have prevented some of the
10286 * checks. This does not recurse because if recursion is
10287 * needed, it will happen naturally as each child has a
10288 * push/pop on that child. For example if we're recursively
10289 * mapping children, we'll push/pop on each child as we map
10290 * it.
10291 */
10292 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
10293 ctk_widget_verify_child_invariants,
10294 NULL((void*)0));
10295 }
10296 }
10297}
10298#endif /* G_ENABLE_CONSISTENCY_CHECKS */
10299
10300static PangoContext *
10301ctk_widget_peek_pango_context (CtkWidget *widget)
10302{
10303 return g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_pango_context);
10304}
10305
10306/**
10307 * ctk_widget_get_pango_context:
10308 * @widget: a #CtkWidget
10309 *
10310 * Gets a #PangoContext with the appropriate font map, font description,
10311 * and base direction for this widget. Unlike the context returned
10312 * by ctk_widget_create_pango_context(), this context is owned by
10313 * the widget (it can be used until the screen for the widget changes
10314 * or the widget is removed from its toplevel), and will be updated to
10315 * match any changes to the widget’s attributes. This can be tracked
10316 * by using the #CtkWidget::screen-changed signal on the widget.
10317 *
10318 * Returns: (transfer none): the #PangoContext for the widget.
10319 **/
10320PangoContext *
10321ctk_widget_get_pango_context (CtkWidget *widget)
10322{
10323 PangoContext *context;
10324
10325 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10326
10327 context = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_pango_context);
10328 if (!context)
10329 {
10330 context = ctk_widget_create_pango_context (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_widget_get_type ()))))))
);
10331 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
10332 quark_pango_context,
10333 context,
10334 g_object_unref);
10335 }
10336
10337 return context;
10338}
10339
10340static PangoFontMap *
10341ctk_widget_get_effective_font_map (CtkWidget *widget)
10342{
10343 PangoFontMap *font_map;
10344
10345 font_map = PANGO_FONT_MAP (g_object_get_qdata (G_OBJECT (widget), quark_font_map))((((PangoFontMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_font_map))), ((pango_font_map_get_type ()))))))
;
10346 if (font_map)
10347 return font_map;
10348 else if (widget->priv->parent)
10349 return ctk_widget_get_effective_font_map (widget->priv->parent);
10350 else
10351 return pango_cairo_font_map_get_default ();
10352}
10353
10354static void
10355update_pango_context (CtkWidget *widget,
10356 PangoContext *context)
10357{
10358 PangoFontDescription *font_desc;
10359 CtkStyleContext *style_context;
10360 CdkScreen *screen;
10361 cairo_font_options_t *font_options;
10362
10363 style_context = _ctk_widget_get_style_context (widget);
10364 ctk_style_context_get (style_context,
10365 ctk_style_context_get_state (style_context),
10366 "font", &font_desc,
10367 NULL((void*)0));
10368
10369 pango_context_set_font_description (context, font_desc);
10370
10371 pango_font_description_free (font_desc);
10372
10373 pango_context_set_base_dir (context,
10374 _ctk_widget_get_direction (widget) == CTK_TEXT_DIR_LTR ?
10375 PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
10376
10377 pango_cairo_context_set_resolution (context,
10378 _ctk_css_number_value_get (
10379 _ctk_style_context_peek_property (style_context,
10380 CTK_CSS_PROPERTY_DPI),
10381 100));
10382
10383 screen = ctk_widget_get_screen_unchecked (widget);
10384 font_options = (cairo_font_options_t*)g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_font_options);
10385 if (screen && font_options)
10386 {
10387 cairo_font_options_t *options;
10388
10389 options = cairo_font_options_copy (cdk_screen_get_font_options (screen));
10390 cairo_font_options_merge (options, font_options);
10391 pango_cairo_context_set_font_options (context, options);
10392 cairo_font_options_destroy (options);
10393 }
10394 else if (screen)
10395 {
10396 pango_cairo_context_set_font_options (context,
10397 cdk_screen_get_font_options (screen));
10398 }
10399
10400 pango_context_set_font_map (context, ctk_widget_get_effective_font_map (widget));
10401}
10402
10403static void
10404ctk_widget_update_pango_context (CtkWidget *widget)
10405{
10406 PangoContext *context = ctk_widget_peek_pango_context (widget);
10407
10408 if (context)
10409 update_pango_context (widget, context);
10410}
10411
10412/**
10413 * ctk_widget_set_font_options:
10414 * @widget: a #CtkWidget
10415 * @options: (allow-none): a #cairo_font_options_t, or %NULL to unset any
10416 * previously set default font options.
10417 *
10418 * Sets the #cairo_font_options_t used for Pango rendering in this widget.
10419 * When not set, the default font options for the #CdkScreen will be used.
10420 *
10421 * Since: 3.18
10422 **/
10423void
10424ctk_widget_set_font_options (CtkWidget *widget,
10425 const cairo_font_options_t *options)
10426{
10427 cairo_font_options_t *font_options;
10428
10429 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
10430
10431 font_options = (cairo_font_options_t *)g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_font_options);
10432 if (font_options != options)
10433 {
10434 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
10435 quark_font_options,
10436 options ? cairo_font_options_copy (options) : NULL((void*)0),
10437 (GDestroyNotify)cairo_font_options_destroy);
10438
10439 ctk_widget_update_pango_context (widget);
10440 }
10441}
10442
10443/**
10444 * ctk_widget_get_font_options:
10445 * @widget: a #CtkWidget
10446 *
10447 * Returns the #cairo_font_options_t used for Pango rendering. When not set,
10448 * the defaults font options for the #CdkScreen will be used.
10449 *
10450 * Returns: (transfer none) (nullable): the #cairo_font_options_t or %NULL if not set
10451 *
10452 * Since: 3.18
10453 **/
10454const cairo_font_options_t *
10455ctk_widget_get_font_options (CtkWidget *widget)
10456{
10457 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10458
10459 return (cairo_font_options_t *)g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_font_options);
10460}
10461
10462static void
10463ctk_widget_set_font_map_recurse (CtkWidget *widget, gpointer data)
10464{
10465 if (g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_font_map))
10466 return;
10467
10468 ctk_widget_update_pango_context (widget);
10469
10470 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
10471 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
10472 ctk_widget_set_font_map_recurse,
10473 data);
10474}
10475
10476/**
10477 * ctk_widget_set_font_map:
10478 * @widget: a #CtkWidget
10479 * @font_map: (allow-none): a #PangoFontMap, or %NULL to unset any previously
10480 * set font map
10481 *
10482 * Sets the font map to use for Pango rendering. When not set, the widget
10483 * will inherit the font map from its parent.
10484 *
10485 * Since: 3.18
10486 */
10487void
10488ctk_widget_set_font_map (CtkWidget *widget,
10489 PangoFontMap *font_map)
10490{
10491 PangoFontMap *map;
10492
10493 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
10494
10495 map = PANGO_FONT_MAP (g_object_get_qdata (G_OBJECT (widget), quark_font_map))((((PangoFontMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_font_map))), ((pango_font_map_get_type ()))))))
;
10496 if (map == font_map)
10497 return;
10498
10499 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
10500 quark_font_map,
10501 g_object_ref (font_map)((__typeof__ (font_map)) (g_object_ref) (font_map)),
10502 g_object_unref);
10503
10504 ctk_widget_update_pango_context (widget);
10505 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
10506 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
10507 ctk_widget_set_font_map_recurse,
10508 NULL((void*)0));
10509}
10510
10511/**
10512 * ctk_widget_get_font_map:
10513 * @widget: a #CtkWidget
10514 *
10515 * Gets the font map that has been set with ctk_widget_set_font_map().
10516 *
10517 * Returns: (transfer none) (nullable): A #PangoFontMap, or %NULL
10518 *
10519 * Since: 3.18
10520 */
10521PangoFontMap *
10522ctk_widget_get_font_map (CtkWidget *widget)
10523{
10524 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10525
10526 return PANGO_FONT_MAP (g_object_get_qdata (G_OBJECT (widget), quark_font_map))((((PangoFontMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_font_map))), ((pango_font_map_get_type ()))))))
;
10527}
10528
10529/**
10530 * ctk_widget_create_pango_context:
10531 * @widget: a #CtkWidget
10532 *
10533 * Creates a new #PangoContext with the appropriate font map,
10534 * font options, font description, and base direction for drawing
10535 * text for this widget. See also ctk_widget_get_pango_context().
10536 *
10537 * Returns: (transfer full): the new #PangoContext
10538 **/
10539PangoContext *
10540ctk_widget_create_pango_context (CtkWidget *widget)
10541{
10542 CdkDisplay *display;
10543 PangoContext *context;
10544
10545 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10546
10547 display = ctk_widget_get_display (widget);
10548 context = cdk_pango_context_get_for_display (display);
10549 update_pango_context (widget, context);
10550 pango_context_set_language (context, ctk_get_default_language ());
10551
10552 return context;
10553}
10554
10555/**
10556 * ctk_widget_create_pango_layout:
10557 * @widget: a #CtkWidget
10558 * @text: (nullable): text to set on the layout (can be %NULL)
10559 *
10560 * Creates a new #PangoLayout with the appropriate font map,
10561 * font description, and base direction for drawing text for
10562 * this widget.
10563 *
10564 * If you keep a #PangoLayout created in this way around, you need
10565 * to re-create it when the widget #PangoContext is replaced.
10566 * This can be tracked by using the #CtkWidget::screen-changed signal
10567 * on the widget.
10568 *
10569 * Returns: (transfer full): the new #PangoLayout
10570 **/
10571PangoLayout *
10572ctk_widget_create_pango_layout (CtkWidget *widget,
10573 const gchar *text)
10574{
10575 PangoLayout *layout;
10576 PangoContext *context;
10577
10578 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10579
10580 context = ctk_widget_get_pango_context (widget);
10581 layout = pango_layout_new (context);
10582
10583 if (text)
10584 pango_layout_set_text (layout, text, -1);
10585
10586 return layout;
10587}
10588
10589/**
10590 * ctk_widget_render_icon_pixbuf:
10591 * @widget: a #CtkWidget
10592 * @stock_id: a stock ID
10593 * @size: (type int): a stock size (#CtkIconSize). A size of `(CtkIconSize)-1`
10594 * means render at the size of the source and don’t scale (if there are
10595 * multiple source sizes, CTK+ picks one of the available sizes).
10596 *
10597 * A convenience function that uses the theme engine and style
10598 * settings for @widget to look up @stock_id and render it to
10599 * a pixbuf. @stock_id should be a stock icon ID such as
10600 * #CTK_STOCK_OPEN or #CTK_STOCK_OK. @size should be a size
10601 * such as #CTK_ICON_SIZE_MENU.
10602 *
10603 * The pixels in the returned #GdkPixbuf are shared with the rest of
10604 * the application and should not be modified. The pixbuf should be freed
10605 * after use with g_object_unref().
10606 *
10607 * Returns: (transfer full) (nullable): a new pixbuf, or %NULL if the
10608 * stock ID wasn’t known
10609 *
10610 * Since: 3.0
10611 **/
10612GdkPixbuf*
10613ctk_widget_render_icon_pixbuf (CtkWidget *widget,
10614 const gchar *stock_id,
10615 CtkIconSize size)
10616{
10617 CtkStyleContext *context;
10618 CtkIconSet *icon_set;
10619
10620 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10621 g_return_val_if_fail (stock_id != NULL, NULL)do { if ((stock_id != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "stock_id != NULL"); return
(((void*)0)); } } while (0)
;
10622 g_return_val_if_fail (size > CTK_ICON_SIZE_INVALID || size == -1, NULL)do { if ((size > CTK_ICON_SIZE_INVALID || size == -1)) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "size > CTK_ICON_SIZE_INVALID || size == -1"); return (
((void*)0)); } } while (0)
;
10623
10624 context = _ctk_widget_get_style_context (widget);
10625 icon_set = ctk_style_context_lookup_icon_set (context, stock_id);
10626
10627 if (icon_set == NULL((void*)0))
10628 return NULL((void*)0);
10629
10630 return ctk_icon_set_render_icon_pixbuf (icon_set, context, size);
10631}
10632
10633/**
10634 * ctk_widget_set_parent_window:
10635 * @widget: a #CtkWidget.
10636 * @parent_window: the new parent window.
10637 *
10638 * Sets a non default parent window for @widget.
10639 *
10640 * For #CtkWindow classes, setting a @parent_window effects whether
10641 * the window is a toplevel window or can be embedded into other
10642 * widgets.
10643 *
10644 * For #CtkWindow classes, this needs to be called before the
10645 * window is realized.
10646 */
10647void
10648ctk_widget_set_parent_window (CtkWidget *widget,
10649 CdkWindow *parent_window)
10650{
10651 CdkWindow *old_parent_window;
10652
10653 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
10654
10655 old_parent_window = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
10656 quark_parent_window);
10657
10658 if (parent_window != old_parent_window)
10659 {
10660 gboolean is_plug;
10661
10662 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_parent_window,
10663 parent_window);
10664 if (old_parent_window)
10665 g_object_unref (old_parent_window);
10666 if (parent_window)
10667 g_object_ref (parent_window)((__typeof__ (parent_window)) (g_object_ref) (parent_window));
10668
10669 /* Unset toplevel flag when adding a parent window to a widget,
10670 * this is the primary entry point to allow toplevels to be
10671 * embeddable.
10672 */
10673#ifdef CDK_WINDOWING_X11
10674 is_plug = CTK_IS_PLUG (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_plug_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; }))))
;
10675#else
10676 is_plug = FALSE(0);
10677#endif
10678 if (CTK_IS_WINDOW (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_window_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; }))))
&& !is_plug)
10679 _ctk_window_set_is_toplevel (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_window_get_type ()))))))
, parent_window == NULL((void*)0));
10680 }
10681}
10682
10683/**
10684 * ctk_widget_get_parent_window:
10685 * @widget: a #CtkWidget.
10686 *
10687 * Gets @widget’s parent window, or %NULL if it does not have one.
10688 *
10689 * Returns: (transfer none) (nullable): the parent window of @widget, or %NULL
10690 * if it does not have a parent window.
10691 **/
10692CdkWindow *
10693ctk_widget_get_parent_window (CtkWidget *widget)
10694{
10695 CtkWidgetPrivate *priv;
10696 CdkWindow *parent_window;
10697
10698 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10699
10700 priv = widget->priv;
10701
10702 parent_window = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_parent_window);
10703
10704 return (parent_window != NULL((void*)0)) ? parent_window :
10705 (priv->parent != NULL((void*)0)) ? priv->parent->priv->window : NULL((void*)0);
10706}
10707
10708
10709/**
10710 * ctk_widget_set_child_visible:
10711 * @widget: a #CtkWidget
10712 * @is_visible: if %TRUE, @widget should be mapped along with its parent.
10713 *
10714 * Sets whether @widget should be mapped along with its when its parent
10715 * is mapped and @widget has been shown with ctk_widget_show().
10716 *
10717 * The child visibility can be set for widget before it is added to
10718 * a container with ctk_widget_set_parent(), to avoid mapping
10719 * children unnecessary before immediately unmapping them. However
10720 * it will be reset to its default state of %TRUE when the widget
10721 * is removed from a container.
10722 *
10723 * Note that changing the child visibility of a widget does not
10724 * queue a resize on the widget. Most of the time, the size of
10725 * a widget is computed from all visible children, whether or
10726 * not they are mapped. If this is not the case, the container
10727 * can queue a resize itself.
10728 *
10729 * This function is only useful for container implementations and
10730 * never should be called by an application.
10731 **/
10732void
10733ctk_widget_set_child_visible (CtkWidget *widget,
10734 gboolean is_visible)
10735{
10736 CtkWidgetPrivate *priv;
10737
10738 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
10739 g_return_if_fail (!_ctk_widget_is_toplevel (widget))do { if ((!_ctk_widget_is_toplevel (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "!_ctk_widget_is_toplevel (widget)"
); return; } } while (0)
;
10740
10741 priv = widget->priv;
10742
10743 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
10744 ctk_widget_verify_invariants (widget);
10745
10746 if (is_visible)
10747 priv->child_visible = TRUE(!(0));
10748 else
10749 {
10750 CtkWidget *toplevel;
10751
10752 priv->child_visible = FALSE(0);
10753
10754 toplevel = _ctk_widget_get_toplevel (widget);
10755 if (toplevel != widget && _ctk_widget_is_toplevel (toplevel))
10756 _ctk_window_unset_focus_and_default (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
, widget);
10757 }
10758
10759 if (priv->parent && _ctk_widget_get_realized (priv->parent))
10760 {
10761 if (_ctk_widget_get_mapped (priv->parent) &&
10762 priv->child_visible &&
10763 _ctk_widget_get_visible (widget))
10764 ctk_widget_map (widget);
10765 else
10766 ctk_widget_unmap (widget);
10767 }
10768
10769 ctk_widget_verify_invariants (widget);
10770 g_object_unref (widget);
10771}
10772
10773/**
10774 * ctk_widget_get_child_visible:
10775 * @widget: a #CtkWidget
10776 *
10777 * Gets the value set with ctk_widget_set_child_visible().
10778 * If you feel a need to use this function, your code probably
10779 * needs reorganization.
10780 *
10781 * This function is only useful for container implementations and
10782 * never should be called by an application.
10783 *
10784 * Returns: %TRUE if the widget is mapped with the parent.
10785 **/
10786gboolean
10787ctk_widget_get_child_visible (CtkWidget *widget)
10788{
10789 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
10790
10791 return widget->priv->child_visible;
10792}
10793
10794static CdkScreen *
10795ctk_widget_get_screen_unchecked (CtkWidget *widget)
10796{
10797 CtkWidget *toplevel;
10798
10799 toplevel = _ctk_widget_get_toplevel (widget);
10800
10801 if (_ctk_widget_is_toplevel (toplevel))
10802 {
10803 if (CTK_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((ctk_window_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; }))))
)
10804 return _ctk_window_get_screen (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
);
10805 else if (CTK_IS_INVISIBLE (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((ctk_invisible_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; }))))
)
10806 return ctk_invisible_get_screen (CTK_INVISIBLE (widget)((((CtkInvisible*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_invisible_get_type ()))))))
);
10807 }
10808
10809 return NULL((void*)0);
10810}
10811
10812/**
10813 * ctk_widget_get_screen:
10814 * @widget: a #CtkWidget
10815 *
10816 * Get the #CdkScreen from the toplevel window associated with
10817 * this widget. This function can only be called after the widget
10818 * has been added to a widget hierarchy with a #CtkWindow
10819 * at the top.
10820 *
10821 * In general, you should only create screen specific
10822 * resources when a widget has been realized, and you should
10823 * free those resources when the widget is unrealized.
10824 *
10825 * Returns: (transfer none): the #CdkScreen for the toplevel for this widget.
10826 *
10827 * Since: 2.2
10828 **/
10829CdkScreen*
10830ctk_widget_get_screen (CtkWidget *widget)
10831{
10832 CdkScreen *screen;
10833
10834 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10835
10836 screen = ctk_widget_get_screen_unchecked (widget);
10837
10838 if (screen)
10839 return screen;
10840 else
10841 return cdk_screen_get_default ();
10842}
10843
10844/**
10845 * ctk_widget_has_screen:
10846 * @widget: a #CtkWidget
10847 *
10848 * Checks whether there is a #CdkScreen is associated with
10849 * this widget. All toplevel widgets have an associated
10850 * screen, and all widgets added into a hierarchy with a toplevel
10851 * window at the top.
10852 *
10853 * Returns: %TRUE if there is a #CdkScreen associated
10854 * with the widget.
10855 *
10856 * Since: 2.2
10857 **/
10858gboolean
10859ctk_widget_has_screen (CtkWidget *widget)
10860{
10861 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
10862
10863 return (ctk_widget_get_screen_unchecked (widget) != NULL((void*)0));
10864}
10865
10866void
10867_ctk_widget_scale_changed (CtkWidget *widget)
10868{
10869 CtkWidgetPrivate *priv;
10870
10871 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
10872
10873 priv = widget->priv;
10874
10875 if (priv->context)
10876 ctk_style_context_set_scale (priv->context, ctk_widget_get_scale_factor (widget));
10877
10878 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_SCALE_FACTOR]);
10879
10880 ctk_widget_queue_draw (widget);
10881
10882 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
10883 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
10884 (CtkCallback) _ctk_widget_scale_changed,
10885 NULL((void*)0));
10886}
10887
10888/**
10889 * ctk_widget_get_scale_factor:
10890 * @widget: a #CtkWidget
10891 *
10892 * Retrieves the internal scale factor that maps from window coordinates
10893 * to the actual device pixels. On traditional systems this is 1, on
10894 * high density outputs, it can be a higher value (typically 2).
10895 *
10896 * See cdk_window_get_scale_factor().
10897 *
10898 * Returns: the scale factor for @widget
10899 *
10900 * Since: 3.10
10901 */
10902gint
10903ctk_widget_get_scale_factor (CtkWidget *widget)
10904{
10905 CtkWidget *toplevel;
10906 CdkDisplay *display;
10907 CdkMonitor *monitor;
10908
10909 g_return_val_if_fail (CTK_IS_WIDGET (widget), 1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (1); } } while (0)
;
10910
10911 if (_ctk_widget_get_realized (widget))
10912 return cdk_window_get_scale_factor (_ctk_widget_get_window (widget));
10913
10914 toplevel = _ctk_widget_get_toplevel (widget);
10915 if (toplevel && toplevel != widget)
10916 return ctk_widget_get_scale_factor (toplevel);
10917
10918 /* else fall back to something that is more likely to be right than
10919 * just returning 1:
10920 */
10921 display = ctk_widget_get_display (widget);
10922 monitor = cdk_display_get_monitor (display, 0);
10923
10924 return cdk_monitor_get_scale_factor (monitor);
10925}
10926
10927/**
10928 * ctk_widget_get_display:
10929 * @widget: a #CtkWidget
10930 *
10931 * Get the #CdkDisplay for the toplevel window associated with
10932 * this widget. This function can only be called after the widget
10933 * has been added to a widget hierarchy with a #CtkWindow at the top.
10934 *
10935 * In general, you should only create display specific
10936 * resources when a widget has been realized, and you should
10937 * free those resources when the widget is unrealized.
10938 *
10939 * Returns: (transfer none): the #CdkDisplay for the toplevel for this widget.
10940 *
10941 * Since: 2.2
10942 **/
10943CdkDisplay*
10944ctk_widget_get_display (CtkWidget *widget)
10945{
10946 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10947
10948 return cdk_screen_get_display (ctk_widget_get_screen (widget));
10949}
10950
10951/**
10952 * ctk_widget_get_root_window:
10953 * @widget: a #CtkWidget
10954 *
10955 * Get the root window where this widget is located. This function can
10956 * only be called after the widget has been added to a widget
10957 * hierarchy with #CtkWindow at the top.
10958 *
10959 * The root window is useful for such purposes as creating a popup
10960 * #CdkWindow associated with the window. In general, you should only
10961 * create display specific resources when a widget has been realized,
10962 * and you should free those resources when the widget is unrealized.
10963 *
10964 * Returns: (transfer none): the #CdkWindow root window for the toplevel for this widget.
10965 *
10966 * Since: 2.2
10967 *
10968 * Deprecated: 3.12: Use cdk_screen_get_root_window() instead
10969 */
10970CdkWindow*
10971ctk_widget_get_root_window (CtkWidget *widget)
10972{
10973 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
10974
10975 return cdk_screen_get_root_window (ctk_widget_get_screen (widget));
10976}
10977
10978/**
10979 * ctk_widget_child_focus:
10980 * @widget: a #CtkWidget
10981 * @direction: direction of focus movement
10982 *
10983 * This function is used by custom widget implementations; if you're
10984 * writing an app, you’d use ctk_widget_grab_focus() to move the focus
10985 * to a particular widget, and ctk_container_set_focus_chain() to
10986 * change the focus tab order. So you may want to investigate those
10987 * functions instead.
10988 *
10989 * ctk_widget_child_focus() is called by containers as the user moves
10990 * around the window using keyboard shortcuts. @direction indicates
10991 * what kind of motion is taking place (up, down, left, right, tab
10992 * forward, tab backward). ctk_widget_child_focus() emits the
10993 * #CtkWidget::focus signal; widgets override the default handler
10994 * for this signal in order to implement appropriate focus behavior.
10995 *
10996 * The default ::focus handler for a widget should return %TRUE if
10997 * moving in @direction left the focus on a focusable location inside
10998 * that widget, and %FALSE if moving in @direction moved the focus
10999 * outside the widget. If returning %TRUE, widgets normally
11000 * call ctk_widget_grab_focus() to place the focus accordingly;
11001 * if returning %FALSE, they don’t modify the current focus location.
11002 *
11003 * Returns: %TRUE if focus ended up inside @widget
11004 **/
11005gboolean
11006ctk_widget_child_focus (CtkWidget *widget,
11007 CtkDirectionType direction)
11008{
11009 gboolean return_val;
11010
11011 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
11012
11013 if (!_ctk_widget_get_visible (widget) ||
11014 !ctk_widget_is_sensitive (widget))
11015 return FALSE(0);
11016
11017 /* child widgets must set CAN_FOCUS, containers
11018 * don't have to though.
11019 */
11020 if (!CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&&
11021 !ctk_widget_get_can_focus (widget))
11022 return FALSE(0);
11023
11024 g_signal_emit (widget,
11025 widget_signals[FOCUS],
11026 0,
11027 direction, &return_val);
11028
11029 return return_val;
11030}
11031
11032/**
11033 * ctk_widget_keynav_failed:
11034 * @widget: a #CtkWidget
11035 * @direction: direction of focus movement
11036 *
11037 * This function should be called whenever keyboard navigation within
11038 * a single widget hits a boundary. The function emits the
11039 * #CtkWidget::keynav-failed signal on the widget and its return
11040 * value should be interpreted in a way similar to the return value of
11041 * ctk_widget_child_focus():
11042 *
11043 * When %TRUE is returned, stay in the widget, the failed keyboard
11044 * navigation is OK and/or there is nowhere we can/should move the
11045 * focus to.
11046 *
11047 * When %FALSE is returned, the caller should continue with keyboard
11048 * navigation outside the widget, e.g. by calling
11049 * ctk_widget_child_focus() on the widget’s toplevel.
11050 *
11051 * The default ::keynav-failed handler returns %FALSE for
11052 * %CTK_DIR_TAB_FORWARD and %CTK_DIR_TAB_BACKWARD. For the other
11053 * values of #CtkDirectionType it returns %TRUE.
11054 *
11055 * Whenever the default handler returns %TRUE, it also calls
11056 * ctk_widget_error_bell() to notify the user of the failed keyboard
11057 * navigation.
11058 *
11059 * A use case for providing an own implementation of ::keynav-failed
11060 * (either by connecting to it or by overriding it) would be a row of
11061 * #CtkEntry widgets where the user should be able to navigate the
11062 * entire row with the cursor keys, as e.g. known from user interfaces
11063 * that require entering license keys.
11064 *
11065 * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
11066 * if the emitting widget should try to handle the keyboard
11067 * navigation attempt in its parent container(s).
11068 *
11069 * Since: 2.12
11070 **/
11071gboolean
11072ctk_widget_keynav_failed (CtkWidget *widget,
11073 CtkDirectionType direction)
11074{
11075 gboolean return_val;
11076
11077 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
11078
11079 g_signal_emit (widget, widget_signals[KEYNAV_FAILED], 0,
11080 direction, &return_val);
11081
11082 return return_val;
11083}
11084
11085/**
11086 * ctk_widget_error_bell:
11087 * @widget: a #CtkWidget
11088 *
11089 * Notifies the user about an input-related error on this widget.
11090 * If the #CtkSettings:ctk-error-bell setting is %TRUE, it calls
11091 * cdk_window_beep(), otherwise it does nothing.
11092 *
11093 * Note that the effect of cdk_window_beep() can be configured in many
11094 * ways, depending on the windowing backend and the desktop environment
11095 * or window manager that is used.
11096 *
11097 * Since: 2.12
11098 **/
11099void
11100ctk_widget_error_bell (CtkWidget *widget)
11101{
11102 CtkWidgetPrivate *priv;
11103 CtkSettings* settings;
11104 gboolean beep;
11105
11106 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11107
11108 priv = widget->priv;
11109
11110 settings = ctk_widget_get_settings (widget);
11111 if (!settings)
11112 return;
11113
11114 g_object_get (settings,
11115 "ctk-error-bell", &beep,
11116 NULL((void*)0));
11117
11118 if (beep && priv->window)
11119 cdk_window_beep (priv->window);
11120}
11121
11122static void
11123ctk_widget_set_usize_internal (CtkWidget *widget,
11124 gint width,
11125 gint height)
11126{
11127 CtkWidgetPrivate *priv = widget->priv;
11128 gboolean changed = FALSE(0);
11129
11130 g_object_freeze_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
11131
11132 if (width > -2 && priv->width != width)
11133 {
11134 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_WIDTH_REQUEST]);
11135 priv->width = width;
11136 changed = TRUE(!(0));
11137 }
11138 if (height > -2 && priv->height != height)
11139 {
11140 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_HEIGHT_REQUEST]);
11141 priv->height = height;
11142 changed = TRUE(!(0));
11143 }
11144
11145 if (_ctk_widget_get_visible (widget) && changed)
11146 {
11147 ctk_widget_queue_resize (widget);
11148 }
11149
11150 g_object_thaw_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
11151}
11152
11153/**
11154 * ctk_widget_set_size_request:
11155 * @widget: a #CtkWidget
11156 * @width: width @widget should request, or -1 to unset
11157 * @height: height @widget should request, or -1 to unset
11158 *
11159 * Sets the minimum size of a widget; that is, the widget’s size
11160 * request will be at least @width by @height. You can use this
11161 * function to force a widget to be larger than it normally would be.
11162 *
11163 * In most cases, ctk_window_set_default_size() is a better choice for
11164 * toplevel windows than this function; setting the default size will
11165 * still allow users to shrink the window. Setting the size request
11166 * will force them to leave the window at least as large as the size
11167 * request. When dealing with window sizes,
11168 * ctk_window_set_geometry_hints() can be a useful function as well.
11169 *
11170 * Note the inherent danger of setting any fixed size - themes,
11171 * translations into other languages, different fonts, and user action
11172 * can all change the appropriate size for a given widget. So, it's
11173 * basically impossible to hardcode a size that will always be
11174 * correct.
11175 *
11176 * The size request of a widget is the smallest size a widget can
11177 * accept while still functioning well and drawing itself correctly.
11178 * However in some strange cases a widget may be allocated less than
11179 * its requested size, and in many cases a widget may be allocated more
11180 * space than it requested.
11181 *
11182 * If the size request in a given direction is -1 (unset), then
11183 * the “natural” size request of the widget will be used instead.
11184 *
11185 * The size request set here does not include any margin from the
11186 * #CtkWidget properties margin-left, margin-right, margin-top, and
11187 * margin-bottom, but it does include pretty much all other padding
11188 * or border properties set by any subclass of #CtkWidget.
11189 **/
11190void
11191ctk_widget_set_size_request (CtkWidget *widget,
11192 gint width,
11193 gint height)
11194{
11195 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11196 g_return_if_fail (width >= -1)do { if ((width >= -1)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "width >= -1"); return
; } } while (0)
;
11197 g_return_if_fail (height >= -1)do { if ((height >= -1)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "height >= -1"); return
; } } while (0)
;
11198
11199 if (width == 0)
11200 width = 1;
11201 if (height == 0)
11202 height = 1;
11203
11204 ctk_widget_set_usize_internal (widget, width, height);
11205}
11206
11207
11208/**
11209 * ctk_widget_get_size_request:
11210 * @widget: a #CtkWidget
11211 * @width: (out) (allow-none): return location for width, or %NULL
11212 * @height: (out) (allow-none): return location for height, or %NULL
11213 *
11214 * Gets the size request that was explicitly set for the widget using
11215 * ctk_widget_set_size_request(). A value of -1 stored in @width or
11216 * @height indicates that that dimension has not been set explicitly
11217 * and the natural requisition of the widget will be used instead. See
11218 * ctk_widget_set_size_request(). To get the size a widget will
11219 * actually request, call ctk_widget_get_preferred_size() instead of
11220 * this function.
11221 **/
11222void
11223ctk_widget_get_size_request (CtkWidget *widget,
11224 gint *width,
11225 gint *height)
11226{
11227 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11228
11229 if (width)
11230 *width = widget->priv->width;
11231
11232 if (height)
11233 *height = widget->priv->height;
11234}
11235
11236/*< private >
11237 * ctk_widget_has_size_request:
11238 * @widget: a #CtkWidget
11239 *
11240 * Returns if the widget has a size request set (anything besides -1 for height
11241 * or width)
11242 */
11243gboolean
11244ctk_widget_has_size_request (CtkWidget *widget)
11245{
11246 return !(widget->priv->width == -1 && widget->priv->height == -1);
11247}
11248
11249/**
11250 * ctk_widget_set_events:
11251 * @widget: a #CtkWidget
11252 * @events: event mask
11253 *
11254 * Sets the event mask (see #CdkEventMask) for a widget. The event
11255 * mask determines which events a widget will receive. Keep in mind
11256 * that different widgets have different default event masks, and by
11257 * changing the event mask you may disrupt a widget’s functionality,
11258 * so be careful. This function must be called while a widget is
11259 * unrealized. Consider ctk_widget_add_events() for widgets that are
11260 * already realized, or if you want to preserve the existing event
11261 * mask. This function can’t be used with widgets that have no window.
11262 * (See ctk_widget_get_has_window()). To get events on those widgets,
11263 * place them inside a #CtkEventBox and receive events on the event
11264 * box.
11265 **/
11266void
11267ctk_widget_set_events (CtkWidget *widget,
11268 gint events)
11269{
11270 gint e;
11271
11272 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11273 g_return_if_fail (!_ctk_widget_get_realized (widget))do { if ((!_ctk_widget_get_realized (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "!_ctk_widget_get_realized (widget)"
); return; } } while (0)
;
11274
11275 e = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask))((gint) (glong) (g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_event_mask)))
;
11276 if (e != events)
11277 {
11278 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_event_mask,
11279 GINT_TO_POINTER (events)((gpointer) (glong) (events)));
11280 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_EVENTS]);
11281 }
11282}
11283
11284/**
11285 * ctk_widget_set_device_events:
11286 * @widget: a #CtkWidget
11287 * @device: a #CdkDevice
11288 * @events: event mask
11289 *
11290 * Sets the device event mask (see #CdkEventMask) for a widget. The event
11291 * mask determines which events a widget will receive from @device. Keep
11292 * in mind that different widgets have different default event masks, and by
11293 * changing the event mask you may disrupt a widget’s functionality,
11294 * so be careful. This function must be called while a widget is
11295 * unrealized. Consider ctk_widget_add_device_events() for widgets that are
11296 * already realized, or if you want to preserve the existing event
11297 * mask. This function can’t be used with windowless widgets (which return
11298 * %FALSE from ctk_widget_get_has_window());
11299 * to get events on those widgets, place them inside a #CtkEventBox
11300 * and receive events on the event box.
11301 *
11302 * Since: 3.0
11303 **/
11304void
11305ctk_widget_set_device_events (CtkWidget *widget,
11306 CdkDevice *device,
11307 CdkEventMask events)
11308{
11309 GHashTable *device_events;
11310
11311 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11312 g_return_if_fail (CDK_IS_DEVICE (device))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_device_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__
)), "CDK_IS_DEVICE (device)"); return; } } while (0)
;
11313 g_return_if_fail (!_ctk_widget_get_realized (widget))do { if ((!_ctk_widget_get_realized (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "!_ctk_widget_get_realized (widget)"
); return; } } while (0)
;
11314
11315 device_events = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_device_event_mask);
11316
11317 if (G_UNLIKELY (!device_events)(!device_events))
11318 {
11319 device_events = g_hash_table_new (NULL((void*)0), NULL((void*)0));
11320 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_device_event_mask, device_events,
11321 (GDestroyNotify) g_hash_table_unref);
11322 }
11323
11324 g_hash_table_insert (device_events, device, GUINT_TO_POINTER (events)((gpointer) (gulong) (events)));
11325}
11326
11327/**
11328 * ctk_widget_set_device_enabled:
11329 * @widget: a #CtkWidget
11330 * @device: a #CdkDevice
11331 * @enabled: whether to enable the device
11332 *
11333 * Enables or disables a #CdkDevice to interact with @widget
11334 * and all its children.
11335 *
11336 * It does so by descending through the #CdkWindow hierarchy
11337 * and enabling the same mask that is has for core events
11338 * (i.e. the one that cdk_window_get_events() returns).
11339 *
11340 * Since: 3.0
11341 */
11342void
11343ctk_widget_set_device_enabled (CtkWidget *widget,
11344 CdkDevice *device,
11345 gboolean enabled)
11346{
11347 GList *enabled_devices;
11348
11349 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11350 g_return_if_fail (CDK_IS_DEVICE (device))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_device_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__
)), "CDK_IS_DEVICE (device)"); return; } } while (0)
;
11351
11352 enabled_devices = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_enabled_devices);
11353 enabled_devices = g_list_append (enabled_devices, device);
11354
11355 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_enabled_devices,
11356 enabled_devices, (GDestroyNotify) g_list_free);;
11357
11358 if (_ctk_widget_get_realized (widget))
11359 ctk_widget_set_device_enabled_internal (widget, device, TRUE(!(0)), enabled);
11360}
11361
11362/**
11363 * ctk_widget_get_device_enabled:
11364 * @widget: a #CtkWidget
11365 * @device: a #CdkDevice
11366 *
11367 * Returns whether @device can interact with @widget and its
11368 * children. See ctk_widget_set_device_enabled().
11369 *
11370 * Returns: %TRUE is @device is enabled for @widget
11371 *
11372 * Since: 3.0
11373 */
11374gboolean
11375ctk_widget_get_device_enabled (CtkWidget *widget,
11376 CdkDevice *device)
11377{
11378 GList *enabled_devices;
11379
11380 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
11381 g_return_val_if_fail (CDK_IS_DEVICE (device), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_device_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__
)), "CDK_IS_DEVICE (device)"); return ((0)); } } while (0)
;
11382
11383 enabled_devices = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_enabled_devices);
11384
11385 return g_list_find (enabled_devices, device) != NULL((void*)0);
11386}
11387
11388static void
11389ctk_widget_add_events_internal_list (CtkWidget *widget,
11390 CdkDevice *device,
11391 CdkEventMask events,
11392 GList *window_list)
11393{
11394 CdkEventMask controllers_mask;
11395 GList *l;
11396
11397 controllers_mask = _ctk_widget_get_controllers_evmask (widget);
11398
11399 for (l = window_list; l != NULL((void*)0); l = l->next)
11400 {
11401 CdkWindow *window = l->data;
11402 CtkWidget *window_widget;
11403
11404 cdk_window_get_user_data (window, (gpointer *)&window_widget);
11405 if (window_widget == widget)
11406 {
11407 GList *children;
11408
11409 if (device)
11410 cdk_window_set_device_events (window, device,
11411 cdk_window_get_events (window)
11412 | events
11413 | controllers_mask);
11414 else
11415 cdk_window_set_events (window,
11416 cdk_window_get_events (window)
11417 | events
11418 | controllers_mask);
11419
11420 children = cdk_window_peek_children (window);
11421 ctk_widget_add_events_internal_list (widget, device, events, children);
11422 }
11423 }
11424}
11425
11426static void
11427ctk_widget_add_events_internal (CtkWidget *widget,
11428 CdkDevice *device,
11429 gint events)
11430{
11431 CtkWidgetPrivate *priv = widget->priv;
11432 GList *window_list;
11433 GList win;
11434
11435 if (!_ctk_widget_get_has_window (widget))
11436 window_list = cdk_window_peek_children (priv->window);
11437 else
11438 {
11439 win.data = priv->window;
11440 win.prev = win.next = NULL((void*)0);
11441 window_list = &win;
11442 }
11443
11444 ctk_widget_add_events_internal_list (widget, device, events, window_list);
11445}
11446
11447/**
11448 * ctk_widget_add_events:
11449 * @widget: a #CtkWidget
11450 * @events: an event mask, see #CdkEventMask
11451 *
11452 * Adds the events in the bitfield @events to the event mask for
11453 * @widget. See ctk_widget_set_events() and the
11454 * [input handling overview][event-masks] for details.
11455 **/
11456void
11457ctk_widget_add_events (CtkWidget *widget,
11458 gint events)
11459{
11460 gint old_events;
11461
11462 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11463
11464 old_events = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask))((gint) (glong) (g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_event_mask)))
;
11465 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_event_mask,
11466 GINT_TO_POINTER (old_events | events)((gpointer) (glong) (old_events | events)));
11467
11468 if (_ctk_widget_get_realized (widget))
11469 {
11470 ctk_widget_add_events_internal (widget, NULL((void*)0), events);
11471 ctk_widget_update_devices_mask (widget, FALSE(0));
11472 }
11473
11474 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_EVENTS]);
11475}
11476
11477/**
11478 * ctk_widget_add_device_events:
11479 * @widget: a #CtkWidget
11480 * @device: a #CdkDevice
11481 * @events: an event mask, see #CdkEventMask
11482 *
11483 * Adds the device events in the bitfield @events to the event mask for
11484 * @widget. See ctk_widget_set_device_events() for details.
11485 *
11486 * Since: 3.0
11487 **/
11488void
11489ctk_widget_add_device_events (CtkWidget *widget,
11490 CdkDevice *device,
11491 CdkEventMask events)
11492{
11493 CdkEventMask old_events;
11494 GHashTable *device_events;
11495
11496 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11497 g_return_if_fail (CDK_IS_DEVICE (device))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_device_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__
)), "CDK_IS_DEVICE (device)"); return; } } while (0)
;
11498
11499 old_events = ctk_widget_get_device_events (widget, device);
11500
11501 device_events = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_device_event_mask);
11502
11503 if (G_UNLIKELY (!device_events)(!device_events))
11504 {
11505 device_events = g_hash_table_new (NULL((void*)0), NULL((void*)0));
11506 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_device_event_mask, device_events,
11507 (GDestroyNotify) g_hash_table_unref);
11508 }
11509
11510 g_hash_table_insert (device_events, device,
11511 GUINT_TO_POINTER (old_events | events)((gpointer) (gulong) (old_events | events)));
11512
11513 if (_ctk_widget_get_realized (widget))
11514 ctk_widget_add_events_internal (widget, device, events);
11515
11516 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_EVENTS]);
11517}
11518
11519/**
11520 * ctk_widget_get_toplevel:
11521 * @widget: a #CtkWidget
11522 *
11523 * This function returns the topmost widget in the container hierarchy
11524 * @widget is a part of. If @widget has no parent widgets, it will be
11525 * returned as the topmost widget. No reference will be added to the
11526 * returned widget; it should not be unreferenced.
11527 *
11528 * Note the difference in behavior vs. ctk_widget_get_ancestor();
11529 * `ctk_widget_get_ancestor (widget, CTK_TYPE_WINDOW)`
11530 * would return
11531 * %NULL if @widget wasn’t inside a toplevel window, and if the
11532 * window was inside a #CtkWindow-derived widget which was in turn
11533 * inside the toplevel #CtkWindow. While the second case may
11534 * seem unlikely, it actually happens when a #CtkPlug is embedded
11535 * inside a #CtkSocket within the same application.
11536 *
11537 * To reliably find the toplevel #CtkWindow, use
11538 * ctk_widget_get_toplevel() and call CTK_IS_WINDOW()
11539 * on the result. For instance, to get the title of a widget's toplevel
11540 * window, one might use:
11541 * |[<!-- language="C" -->
11542 * static const char *
11543 * get_widget_toplevel_title (CtkWidget *widget)
11544 * {
11545 * CtkWidget *toplevel = ctk_widget_get_toplevel (widget);
11546 * if (CTK_IS_WINDOW (toplevel))
11547 * {
11548 * return ctk_window_get_title (CTK_WINDOW (toplevel));
11549 * }
11550 *
11551 * return NULL;
11552 * }
11553 * ]|
11554 *
11555 * Returns: (transfer none): the topmost ancestor of @widget, or @widget itself
11556 * if there’s no ancestor.
11557 **/
11558CtkWidget*
11559ctk_widget_get_toplevel (CtkWidget *widget)
11560{
11561 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
11562
11563 while (widget->priv->parent)
11564 widget = widget->priv->parent;
11565
11566 return widget;
11567}
11568
11569/**
11570 * ctk_widget_get_ancestor:
11571 * @widget: a #CtkWidget
11572 * @widget_type: ancestor type
11573 *
11574 * Gets the first ancestor of @widget with type @widget_type. For example,
11575 * `ctk_widget_get_ancestor (widget, CTK_TYPE_BOX)` gets
11576 * the first #CtkBox that’s an ancestor of @widget. No reference will be
11577 * added to the returned widget; it should not be unreferenced. See note
11578 * about checking for a toplevel #CtkWindow in the docs for
11579 * ctk_widget_get_toplevel().
11580 *
11581 * Note that unlike ctk_widget_is_ancestor(), ctk_widget_get_ancestor()
11582 * considers @widget to be an ancestor of itself.
11583 *
11584 * Returns: (transfer none) (nullable): the ancestor widget, or %NULL if not found
11585 **/
11586CtkWidget*
11587ctk_widget_get_ancestor (CtkWidget *widget,
11588 GType widget_type)
11589{
11590 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
11591
11592 while (widget && !g_type_is_a (G_OBJECT_TYPE (widget), widget_type)(((((((GTypeClass*) (((GTypeInstance*) (widget))->g_class)
)->g_type)))) == (widget_type) || (g_type_is_a) (((((((GTypeClass
*) (((GTypeInstance*) (widget))->g_class))->g_type)))),
(widget_type)))
)
11593 widget = widget->priv->parent;
11594
11595 if (!(widget && g_type_is_a (G_OBJECT_TYPE (widget), widget_type)(((((((GTypeClass*) (((GTypeInstance*) (widget))->g_class)
)->g_type)))) == (widget_type) || (g_type_is_a) (((((((GTypeClass
*) (((GTypeInstance*) (widget))->g_class))->g_type)))),
(widget_type)))
))
11596 return NULL((void*)0);
11597
11598 return widget;
11599}
11600
11601/**
11602 * ctk_widget_set_visual:
11603 * @widget: a #CtkWidget
11604 * @visual: (allow-none): visual to be used or %NULL to unset a previous one
11605 *
11606 * Sets the visual that should be used for by widget and its children for
11607 * creating #CdkWindows. The visual must be on the same #CdkScreen as
11608 * returned by ctk_widget_get_screen(), so handling the
11609 * #CtkWidget::screen-changed signal is necessary.
11610 *
11611 * Setting a new @visual will not cause @widget to recreate its windows,
11612 * so you should call this function before @widget is realized.
11613 **/
11614void
11615ctk_widget_set_visual (CtkWidget *widget,
11616 CdkVisual *visual)
11617{
11618 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11619 g_return_if_fail (visual == NULL || CDK_IS_VISUAL (visual))do { if ((visual == ((void*)0) || (((__extension__ ({ GTypeInstance
*__inst = (GTypeInstance*) ((visual)); GType __t = ((cdk_visual_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__)), "visual == NULL || CDK_IS_VISUAL (visual)"
); return; } } while (0)
;
11620
11621 if (visual)
11622 g_return_if_fail (ctk_widget_get_screen (widget) == cdk_visual_get_screen (visual))do { if ((ctk_widget_get_screen (widget) == cdk_visual_get_screen
(visual))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "ctk_widget_get_screen (widget) == cdk_visual_get_screen (visual)"
); return; } } while (0)
;
11623
11624 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
11625 quark_visual,
11626 visual ? g_object_ref (visual)((__typeof__ (visual)) (g_object_ref) (visual)) : NULL((void*)0),
11627 g_object_unref);
11628}
11629
11630/**
11631 * ctk_widget_get_visual:
11632 * @widget: a #CtkWidget
11633 *
11634 * Gets the visual that will be used to render @widget.
11635 *
11636 * Returns: (transfer none): the visual for @widget
11637 **/
11638CdkVisual*
11639ctk_widget_get_visual (CtkWidget *widget)
11640{
11641 CtkWidget *w;
11642 CdkVisual *visual;
11643 CdkScreen *screen;
11644
11645 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
11646
11647 if (!_ctk_widget_get_has_window (widget) &&
11648 widget->priv->window)
11649 return cdk_window_get_visual (widget->priv->window);
11650
11651 screen = ctk_widget_get_screen (widget);
11652
11653 for (w = widget; w != NULL((void*)0); w = w->priv->parent)
11654 {
11655 visual = g_object_get_qdata (G_OBJECT (w)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((w)), (((GType) ((20) << (2))))))))
, quark_visual);
11656 if (visual)
11657 {
11658 if (cdk_visual_get_screen (visual) == screen)
11659 return visual;
11660
11661 g_warning ("Ignoring visual set on widget '%s' that is not on the correct screen.",
11662 ctk_widget_get_name (widget));
11663 }
11664 }
11665
11666 return cdk_screen_get_system_visual (screen);
11667}
11668
11669/**
11670 * ctk_widget_get_settings:
11671 * @widget: a #CtkWidget
11672 *
11673 * Gets the settings object holding the settings used for this widget.
11674 *
11675 * Note that this function can only be called when the #CtkWidget
11676 * is attached to a toplevel, since the settings object is specific
11677 * to a particular #CdkScreen.
11678 *
11679 * Returns: (transfer none): the relevant #CtkSettings object
11680 */
11681CtkSettings*
11682ctk_widget_get_settings (CtkWidget *widget)
11683{
11684 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
11685
11686 return ctk_settings_get_for_screen (ctk_widget_get_screen (widget));
11687}
11688
11689/**
11690 * ctk_widget_get_events:
11691 * @widget: a #CtkWidget
11692 *
11693 * Returns the event mask (see #CdkEventMask) for the widget. These are the
11694 * events that the widget will receive.
11695 *
11696 * Note: Internally, the widget event mask will be the logical OR of the event
11697 * mask set through ctk_widget_set_events() or ctk_widget_add_events(), and the
11698 * event mask necessary to cater for every #CtkEventController created for the
11699 * widget.
11700 *
11701 * Returns: event mask for @widget
11702 **/
11703gint
11704ctk_widget_get_events (CtkWidget *widget)
11705{
11706 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
11707
11708 return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask))((gint) (glong) (g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_event_mask)))
|
11709 _ctk_widget_get_controllers_evmask (widget);
11710}
11711
11712/**
11713 * ctk_widget_get_device_events:
11714 * @widget: a #CtkWidget
11715 * @device: a #CdkDevice
11716 *
11717 * Returns the events mask for the widget corresponding to an specific device. These
11718 * are the events that the widget will receive when @device operates on it.
11719 *
11720 * Returns: device event mask for @widget
11721 *
11722 * Since: 3.0
11723 **/
11724CdkEventMask
11725ctk_widget_get_device_events (CtkWidget *widget,
11726 CdkDevice *device)
11727{
11728 GHashTable *device_events;
11729
11730 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
11731 g_return_val_if_fail (CDK_IS_DEVICE (device), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_device_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__
)), "CDK_IS_DEVICE (device)"); return (0); } } while (0)
;
11732
11733 device_events = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_device_event_mask);
11734
11735 if (!device_events)
11736 return 0;
11737
11738 return GPOINTER_TO_UINT (g_hash_table_lookup (device_events, device))((guint) (gulong) (g_hash_table_lookup (device_events, device
)))
;
11739}
11740
11741/**
11742 * ctk_widget_get_pointer:
11743 * @widget: a #CtkWidget
11744 * @x: (out) (allow-none): return location for the X coordinate, or %NULL
11745 * @y: (out) (allow-none): return location for the Y coordinate, or %NULL
11746 *
11747 * Obtains the location of the mouse pointer in widget coordinates.
11748 * Widget coordinates are a bit odd; for historical reasons, they are
11749 * defined as @widget->window coordinates for widgets that return %TRUE for
11750 * ctk_widget_get_has_window(); and are relative to @widget->allocation.x,
11751 * @widget->allocation.y otherwise.
11752 *
11753 * Deprecated: 3.4: Use cdk_window_get_device_position() instead.
11754 **/
11755void
11756ctk_widget_get_pointer (CtkWidget *widget,
11757 gint *x,
11758 gint *y)
11759{
11760 CtkWidgetPrivate *priv;
11761
11762 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11763
11764 priv = widget->priv;
11765
11766 if (x)
11767 *x = -1;
11768 if (y)
11769 *y = -1;
11770
11771 if (_ctk_widget_get_realized (widget))
11772 {
11773 CdkSeat *seat;
11774
11775 seat = cdk_display_get_default_seat (ctk_widget_get_display (widget));
11776 cdk_window_get_device_position (priv->window,
11777 cdk_seat_get_pointer (seat),
11778 x, y, NULL((void*)0));
11779
11780 if (!_ctk_widget_get_has_window (widget))
11781 {
11782 if (x)
11783 *x -= priv->allocation.x;
11784 if (y)
11785 *y -= priv->allocation.y;
11786 }
11787 }
11788}
11789
11790/**
11791 * ctk_widget_is_ancestor:
11792 * @widget: a #CtkWidget
11793 * @ancestor: another #CtkWidget
11794 *
11795 * Determines whether @widget is somewhere inside @ancestor, possibly with
11796 * intermediate containers.
11797 *
11798 * Returns: %TRUE if @ancestor contains @widget as a child,
11799 * grandchild, great grandchild, etc.
11800 **/
11801gboolean
11802ctk_widget_is_ancestor (CtkWidget *widget,
11803 CtkWidget *ancestor)
11804{
11805 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
11806 g_return_val_if_fail (ancestor != NULL, FALSE)do { if ((ancestor != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "ancestor != NULL"); return
((0)); } } while (0)
;
11807
11808 while (widget)
11809 {
11810 if (widget->priv->parent == ancestor)
11811 return TRUE(!(0));
11812 widget = widget->priv->parent;
11813 }
11814
11815 return FALSE(0);
11816}
11817
11818static GQuark quark_composite_name = 0;
11819
11820/**
11821 * ctk_widget_set_composite_name:
11822 * @widget: a #CtkWidget.
11823 * @name: the name to set
11824 *
11825 * Sets a widgets composite name. The widget must be
11826 * a composite child of its parent; see ctk_widget_push_composite_child().
11827 *
11828 * Deprecated: 3.10: Use ctk_widget_class_set_template(), or don’t use this API at all.
11829 **/
11830void
11831ctk_widget_set_composite_name (CtkWidget *widget,
11832 const gchar *name)
11833{
11834 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11835 g_return_if_fail (widget->priv->composite_child)do { if ((widget->priv->composite_child)) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "widget->priv->composite_child"
); return; } } while (0)
;
11836 g_return_if_fail (name != NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "name != NULL"); return;
} } while (0)
;
11837
11838 if (!quark_composite_name)
11839 quark_composite_name = g_quark_from_static_string ("ctk-composite-name");
11840
11841 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
11842 quark_composite_name,
11843 g_strdup (name)g_strdup_inline (name),
11844 g_free);
11845}
11846
11847/**
11848 * ctk_widget_get_composite_name:
11849 * @widget: a #CtkWidget
11850 *
11851 * Obtains the composite name of a widget.
11852 *
11853 * Returns: the composite name of @widget, or %NULL if @widget is not
11854 * a composite child. The string should be freed when it is no
11855 * longer needed.
11856 *
11857 * Deprecated: 3.10: Use ctk_widget_class_set_template(), or don’t use this API at all.
11858 **/
11859gchar*
11860ctk_widget_get_composite_name (CtkWidget *widget)
11861{
11862 CtkWidgetPrivate *priv;
11863
11864 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
11865
11866 priv = widget->priv;
11867
11868 if (widget->priv->composite_child && priv->parent)
11869 return _ctk_container_child_composite_name (CTK_CONTAINER (priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->parent)), ((ctk_container_get_type ()))))))
,
11870 widget);
11871 else
11872 return NULL((void*)0);
11873}
11874
11875/**
11876 * ctk_widget_push_composite_child:
11877 *
11878 * Makes all newly-created widgets as composite children until
11879 * the corresponding ctk_widget_pop_composite_child() call.
11880 *
11881 * A composite child is a child that’s an implementation detail of the
11882 * container it’s inside and should not be visible to people using the
11883 * container. Composite children aren’t treated differently by CTK+ (but
11884 * see ctk_container_foreach() vs. ctk_container_forall()), but e.g. GUI
11885 * builders might want to treat them in a different way.
11886 *
11887 * Deprecated: 3.10: This API never really worked well and was mostly unused, now
11888 * we have a more complete mechanism for composite children, see ctk_widget_class_set_template().
11889 **/
11890void
11891ctk_widget_push_composite_child (void)
11892{
11893 composite_child_stack++;
11894}
11895
11896/**
11897 * ctk_widget_pop_composite_child:
11898 *
11899 * Cancels the effect of a previous call to ctk_widget_push_composite_child().
11900 *
11901 * Deprecated: 3.10: Use ctk_widget_class_set_template(), or don’t use this API at all.
11902 **/
11903void
11904ctk_widget_pop_composite_child (void)
11905{
11906 if (composite_child_stack)
11907 composite_child_stack--;
11908}
11909
11910static void
11911ctk_widget_emit_direction_changed (CtkWidget *widget,
11912 CtkTextDirection old_dir)
11913{
11914 CtkTextDirection direction;
11915 CtkStateFlags state;
11916
11917 ctk_widget_update_pango_context (widget);
11918
11919 direction = _ctk_widget_get_direction (widget);
11920
11921 switch (direction)
11922 {
11923 case CTK_TEXT_DIR_LTR:
11924 state = CTK_STATE_FLAG_DIR_LTR;
11925 break;
11926
11927 case CTK_TEXT_DIR_RTL:
11928 state = CTK_STATE_FLAG_DIR_RTL;
11929 break;
11930
11931 case CTK_TEXT_DIR_NONE:
11932 default:
11933 g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkwidget.c", 11933, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
11934 break;
11935 }
11936
11937 ctk_widget_update_state_flags (widget,
11938 state,
11939 state ^ (CTK_STATE_FLAG_DIR_LTR | CTK_STATE_FLAG_DIR_RTL));
11940
11941 g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
11942}
11943
11944/**
11945 * ctk_widget_set_direction:
11946 * @widget: a #CtkWidget
11947 * @dir: the new direction
11948 *
11949 * Sets the reading direction on a particular widget. This direction
11950 * controls the primary direction for widgets containing text,
11951 * and also the direction in which the children of a container are
11952 * packed. The ability to set the direction is present in order
11953 * so that correct localization into languages with right-to-left
11954 * reading directions can be done. Generally, applications will
11955 * let the default reading direction present, except for containers
11956 * where the containers are arranged in an order that is explicitly
11957 * visual rather than logical (such as buttons for text justification).
11958 *
11959 * If the direction is set to %CTK_TEXT_DIR_NONE, then the value
11960 * set by ctk_widget_set_default_direction() will be used.
11961 **/
11962void
11963ctk_widget_set_direction (CtkWidget *widget,
11964 CtkTextDirection dir)
11965{
11966 CtkTextDirection old_dir;
11967
11968 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
11969 g_return_if_fail (dir >= CTK_TEXT_DIR_NONE && dir <= CTK_TEXT_DIR_RTL)do { if ((dir >= CTK_TEXT_DIR_NONE && dir <= CTK_TEXT_DIR_RTL
)) { } else { g_return_if_fail_warning ("Ctk", ((const char*)
(__func__)), "dir >= CTK_TEXT_DIR_NONE && dir <= CTK_TEXT_DIR_RTL"
); return; } } while (0)
;
11970
11971 old_dir = _ctk_widget_get_direction (widget);
11972
11973 widget->priv->direction = dir;
11974
11975 if (old_dir != _ctk_widget_get_direction (widget))
11976 ctk_widget_emit_direction_changed (widget, old_dir);
11977}
11978
11979/**
11980 * ctk_widget_get_direction:
11981 * @widget: a #CtkWidget
11982 *
11983 * Gets the reading direction for a particular widget. See
11984 * ctk_widget_set_direction().
11985 *
11986 * Returns: the reading direction for the widget.
11987 **/
11988CtkTextDirection
11989ctk_widget_get_direction (CtkWidget *widget)
11990{
11991 g_return_val_if_fail (CTK_IS_WIDGET (widget), CTK_TEXT_DIR_LTR)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (CTK_TEXT_DIR_LTR); } }
while (0)
;
11992
11993 if (widget->priv->direction == CTK_TEXT_DIR_NONE)
11994 return ctk_default_direction;
11995 else
11996 return widget->priv->direction;
11997}
11998
11999static void
12000ctk_widget_set_default_direction_recurse (CtkWidget *widget, gpointer data)
12001{
12002 CtkTextDirection old_dir = GPOINTER_TO_UINT (data)((guint) (gulong) (data));
12003
12004 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
12005
12006 if (widget->priv->direction == CTK_TEXT_DIR_NONE)
12007 ctk_widget_emit_direction_changed (widget, old_dir);
12008
12009 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
12010 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
12011 ctk_widget_set_default_direction_recurse,
12012 data);
12013
12014 g_object_unref (widget);
12015}
12016
12017/**
12018 * ctk_widget_set_default_direction:
12019 * @dir: the new default direction. This cannot be
12020 * %CTK_TEXT_DIR_NONE.
12021 *
12022 * Sets the default reading direction for widgets where the
12023 * direction has not been explicitly set by ctk_widget_set_direction().
12024 **/
12025void
12026ctk_widget_set_default_direction (CtkTextDirection dir)
12027{
12028 g_return_if_fail (dir == CTK_TEXT_DIR_RTL || dir == CTK_TEXT_DIR_LTR)do { if ((dir == CTK_TEXT_DIR_RTL || dir == CTK_TEXT_DIR_LTR)
) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (
__func__)), "dir == CTK_TEXT_DIR_RTL || dir == CTK_TEXT_DIR_LTR"
); return; } } while (0)
;
12029
12030 if (dir != ctk_default_direction)
12031 {
12032 GList *toplevels, *tmp_list;
12033 CtkTextDirection old_dir = ctk_default_direction;
12034
12035 ctk_default_direction = dir;
12036
12037 tmp_list = toplevels = ctk_window_list_toplevels ();
12038 g_list_foreach (toplevels, (GFunc)g_object_ref, NULL((void*)0));
12039
12040 while (tmp_list)
12041 {
12042 ctk_widget_set_default_direction_recurse (tmp_list->data,
12043 GUINT_TO_POINTER (old_dir)((gpointer) (gulong) (old_dir)));
12044 g_object_unref (tmp_list->data);
12045 tmp_list = tmp_list->next;
12046 }
12047
12048 g_list_free (toplevels);
12049 }
12050}
12051
12052/**
12053 * ctk_widget_get_default_direction:
12054 *
12055 * Obtains the current default reading direction. See
12056 * ctk_widget_set_default_direction().
12057 *
12058 * Returns: the current default direction.
12059 **/
12060CtkTextDirection
12061ctk_widget_get_default_direction (void)
12062{
12063 return ctk_default_direction;
12064}
12065
12066static void
12067ctk_widget_constructed (GObject *object)
12068{
12069 CtkWidget *widget = CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
;
12070 CtkWidgetPath *path;
12071
12072 /* As strange as it may seem, this may happen on object construction.
12073 * init() implementations of parent types may eventually call this function,
12074 * each with its corresponding GType, which could leave a child
12075 * implementation with a wrong widget type in the widget path
12076 */
12077 path = (CtkWidgetPath*)g_object_get_qdata (object, quark_widget_path);
12078 if (path && G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
!= ctk_widget_path_get_object_type (path))
12079 g_object_set_qdata (object, quark_widget_path, NULL((void*)0));
12080
12081 G_OBJECT_CLASS (ctk_widget_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_widget_parent_class)), (((GType) ((20) << (2))
))))))
->constructed (object);
12082}
12083
12084static void
12085ctk_widget_dispose (GObject *object)
12086{
12087 CtkWidget *widget = CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
;
12088 CtkWidgetPrivate *priv = widget->priv;
12089 GSList *sizegroups;
12090
12091 if (priv->parent)
12092 ctk_container_remove (CTK_CONTAINER (priv->parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->parent)), ((ctk_container_get_type ()))))))
, widget);
12093 else if (_ctk_widget_get_visible (widget))
12094 ctk_widget_hide (widget);
12095
12096 priv->visible = FALSE(0);
12097 if (_ctk_widget_get_realized (widget))
12098 ctk_widget_unrealize (widget);
12099
12100 if (!priv->in_destruction)
12101 {
12102 priv->in_destruction = TRUE(!(0));
12103 g_signal_emit (object, widget_signals[DESTROY], 0);
12104 priv->in_destruction = FALSE(0);
12105 }
12106
12107 sizegroups = _ctk_widget_get_sizegroups (widget);
12108 while (sizegroups)
12109 {
12110 CtkSizeGroup *size_group;
12111
12112 size_group = sizegroups->data;
12113 sizegroups = sizegroups->next;
12114 ctk_size_group_remove_widget (size_group, widget);
12115 }
12116
12117 g_object_set_qdata (object, quark_action_muxer, NULL((void*)0));
12118
12119 while (priv->attached_windows)
12120 ctk_window_set_attached_to (priv->attached_windows->data, NULL((void*)0));
12121
12122 G_OBJECT_CLASS (ctk_widget_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_widget_parent_class)), (((GType) ((20) << (2))
))))))
->dispose (object);
12123}
12124
12125#ifdef G_ENABLE_CONSISTENCY_CHECKS1
12126typedef struct {
12127 AutomaticChildClass *child_class;
12128 GType widget_type;
12129 GObject *object;
12130 gboolean did_finalize;
12131} FinalizeAssertion;
12132
12133static void
12134finalize_assertion_weak_ref (gpointer data,
12135 GObject *where_the_object_was G_GNUC_UNUSED__attribute__ ((__unused__)))
12136{
12137 FinalizeAssertion *assertion = (FinalizeAssertion *)data;
12138 assertion->did_finalize = TRUE(!(0));
12139}
12140
12141static FinalizeAssertion *
12142finalize_assertion_new (CtkWidget *widget,
12143 GType widget_type,
12144 AutomaticChildClass *child_class)
12145{
12146 FinalizeAssertion *assertion = NULL((void*)0);
12147 GObject *object;
12148
12149 object = ctk_widget_get_template_child (widget, widget_type, child_class->name);
12150
12151 /* We control the hash table entry, the object should never be NULL
12152 */
12153 g_assert (object)do { if (object) ; else g_assertion_message_expr ("Ctk", "ctkwidget.c"
, 12153, ((const char*) (__func__)), "object"); } while (0)
;
12154 if (!G_IS_OBJECT (object)(((g_type_check_instance_is_fundamentally_a ((GTypeInstance*)
((object)), (((GType) ((20) << (2))))))))
)
12155 g_critical ("Automated component '%s' of class '%s' seems to have been prematurely finalized",
12156 child_class->name, g_type_name (widget_type));
12157 else
12158 {
12159 assertion = g_slice_new0 (FinalizeAssertion)((FinalizeAssertion*) g_slice_alloc0 ((sizeof (FinalizeAssertion
) > 0 ? sizeof (FinalizeAssertion) : 1)))
;
12160 assertion->child_class = child_class;
12161 assertion->widget_type = widget_type;
12162 assertion->object = object;
12163
12164 g_object_weak_ref (object, finalize_assertion_weak_ref, assertion);
12165 }
12166
12167 return assertion;
12168}
12169
12170static GSList *
12171build_finalize_assertion_list (CtkWidget *widget)
12172{
12173 GType class_type;
12174 CtkWidgetClass *class;
12175 GSList *l, *list = NULL((void*)0);
12176
12177 for (class = CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
;
12178 CTK_IS_WIDGET_CLASS (class)(((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((class
)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (
!__class) __r = (0); else if (__class->g_type == __t) __r =
(!(0)); else __r = g_type_check_class_is_a (__class, __t); __r
; }))))
;
12179 class = g_type_class_peek_parent (class))
12180 {
12181 if (!class->priv->template)
12182 continue;
12183
12184 class_type = G_OBJECT_CLASS_TYPE (class)((((GTypeClass*) (class))->g_type));
12185
12186 for (l = class->priv->template->children; l; l = l->next)
12187 {
12188 AutomaticChildClass *child_class = l->data;
12189 FinalizeAssertion *assertion;
12190
12191 assertion = finalize_assertion_new (widget, class_type, child_class);
12192 list = g_slist_prepend (list, assertion);
12193 }
12194 }
12195
12196 return list;
12197}
12198#endif /* G_ENABLE_CONSISTENCY_CHECKS */
12199
12200static void
12201ctk_widget_real_destroy (CtkWidget *object)
12202{
12203 /* ctk_object_destroy() will already hold a refcount on object */
12204 CtkWidget *widget = CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
;
12205 CtkWidgetPrivate *priv = widget->priv;
12206
12207 if (g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_auto_children))
12208 {
12209 CtkWidgetClass *class;
12210 GSList *l;
12211
12212#ifdef G_ENABLE_CONSISTENCY_CHECKS1
12213 GSList *assertions = NULL((void*)0);
12214
12215 /* Note, CTK_WIDGET_ASSERT_COMPONENTS is very useful
12216 * to catch ref counting bugs, but can only be used in
12217 * test cases which simply create and destroy a composite
12218 * widget.
12219 *
12220 * This is because some API can expose components explicitly,
12221 * and so we cannot assert that a component is expected to finalize
12222 * in a full application ecosystem.
12223 */
12224 if (g_getenv ("CTK_WIDGET_ASSERT_COMPONENTS") != NULL((void*)0))
12225 assertions = build_finalize_assertion_list (widget);
12226#endif /* G_ENABLE_CONSISTENCY_CHECKS */
12227
12228 /* Release references to all automated children */
12229 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_auto_children, NULL((void*)0));
12230
12231#ifdef G_ENABLE_CONSISTENCY_CHECKS1
12232 for (l = assertions; l; l = l->next)
12233 {
12234 FinalizeAssertion *assertion = l->data;
12235
12236 if (!assertion->did_finalize)
12237 g_critical ("Automated component '%s' of class '%s' did not finalize in ctk_widget_destroy(). "
12238 "Current reference count is %d",
12239 assertion->child_class->name,
12240 g_type_name (assertion->widget_type),
12241 assertion->object->ref_count);
12242
12243 g_slice_free (FinalizeAssertion, assertion)do { if (1) g_slice_free1 (sizeof (FinalizeAssertion), (assertion
)); else (void) ((FinalizeAssertion*) 0 == (assertion)); } while
(0)
;
12244 }
12245 g_slist_free (assertions);
12246#endif /* G_ENABLE_CONSISTENCY_CHECKS */
12247
12248 /* Set any automatic private data pointers to NULL */
12249 for (class = CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
;
12250 CTK_IS_WIDGET_CLASS (class)(((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((class
)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (
!__class) __r = (0); else if (__class->g_type == __t) __r =
(!(0)); else __r = g_type_check_class_is_a (__class, __t); __r
; }))))
;
12251 class = g_type_class_peek_parent (class))
12252 {
12253 if (!class->priv->template)
12254 continue;
12255
12256 for (l = class->priv->template->children; l; l = l->next)
12257 {
12258 AutomaticChildClass *child_class = l->data;
12259
12260 if (child_class->offset != 0)
12261 {
12262 gpointer field_p;
12263
12264 /* Nullify instance private data for internal children */
12265 field_p = G_STRUCT_MEMBER_P (widget, child_class->offset)((gpointer) ((guint8*) (widget) + (glong) (child_class->offset
)))
;
12266 (* (gpointer *) field_p) = NULL((void*)0);
12267 }
12268 }
12269 }
12270 }
12271
12272 if (priv->accessible)
12273 {
12274 ctk_accessible_set_widget (CTK_ACCESSIBLE (priv->accessible)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->accessible)), ((ctk_accessible_get_type ())))))
)
, NULL((void*)0));
12275 g_object_unref (priv->accessible);
12276 priv->accessible = NULL((void*)0);
12277 }
12278
12279 /* wipe accelerator closures (keep order) */
12280 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_accel_path, NULL((void*)0));
12281 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_accel_closures, NULL((void*)0));
12282
12283 /* Callers of add_mnemonic_label() should disconnect on ::destroy */
12284 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_mnemonic_labels, NULL((void*)0));
12285
12286 ctk_grab_remove (widget);
12287
12288 destroy_tick_callbacks (widget);
12289
12290 if (priv->style)
12291 g_object_unref (priv->style);
12292 priv->style = ctk_widget_get_default_style ();
12293 g_object_ref (priv->style)((__typeof__ (priv->style)) (g_object_ref) (priv->style
))
;
12294}
12295
12296static void
12297ctk_widget_finalize (GObject *object)
12298{
12299 CtkWidget *widget = CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_widget_get_type ()))))))
;
12300 CtkWidgetPrivate *priv = widget->priv;
12301 GList *l;
12302
12303 ctk_grab_remove (widget);
12304
12305 g_clear_object (&priv->style)do { _Static_assert (sizeof *((&priv->style)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->style))) _pp = ((&priv->style)); __typeof__
(*((&priv->style))) _ptr = *_pp; *_pp = ((void*)0); if
(_ptr) (g_object_unref) (_ptr); } while (0)
;
12306
12307 g_free (priv->name);
12308
12309 g_clear_object (&priv->accessible)do { _Static_assert (sizeof *((&priv->accessible)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->accessible))) _pp = ((&priv->accessible)
); __typeof__ (*((&priv->accessible))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
12310
12311 ctk_widget_clear_path (widget);
12312
12313 ctk_css_widget_node_widget_destroyed (CTK_CSS_WIDGET_NODE (priv->cssnode)((((CtkCssWidgetNode*) (void *) g_type_check_instance_cast ((
GTypeInstance*) (priv->cssnode), ((ctk_css_widget_node_get_type
()))))))
);
12314 g_object_unref (priv->cssnode);
12315
12316 g_clear_object (&priv->context)do { _Static_assert (sizeof *((&priv->context)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->context))) _pp = ((&priv->context)); __typeof__
(*((&priv->context))) _ptr = *_pp; *_pp = ((void*)0);
if (_ptr) (g_object_unref) (_ptr); } while (0)
;
12317
12318 _ctk_size_request_cache_free (&priv->requests);
12319
12320 for (l = priv->event_controllers; l; l = l->next)
12321 {
12322 EventControllerData *data = l->data;
12323 if (data->controller)
12324 _ctk_widget_remove_controller (widget, data->controller);
12325 }
12326 g_list_free_full (priv->event_controllers, g_free);
12327 priv->event_controllers = NULL((void*)0);
12328
12329 if (g_object_is_floating (object))
12330 g_warning ("A floating object was finalized. This means that someone\n"
12331 "called g_object_unref() on an object that had only a floating\n"
12332 "reference; the initial floating reference is not owned by anyone\n"
12333 "and must be removed with g_object_ref_sink().");
12334
12335 G_OBJECT_CLASS (ctk_widget_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_widget_parent_class)), (((GType) ((20) << (2))
))))))
->finalize (object);
12336}
12337
12338/*****************************************
12339 * ctk_widget_real_map:
12340 *
12341 * arguments:
12342 *
12343 * results:
12344 *****************************************/
12345
12346static void
12347ctk_widget_real_map (CtkWidget *widget)
12348{
12349 CtkWidgetPrivate *priv = widget->priv;
12350
12351 g_assert (_ctk_widget_get_realized (widget))do { if (_ctk_widget_get_realized (widget)) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 12351, ((const char*) (__func__)), "_ctk_widget_get_realized (widget)"
); } while (0)
;
12352
12353 if (!_ctk_widget_get_mapped (widget))
12354 {
12355 ctk_widget_set_mapped (widget, TRUE(!(0)));
12356
12357 if (_ctk_widget_get_has_window (widget))
12358 cdk_window_show (priv->window);
12359 }
12360}
12361
12362/*****************************************
12363 * ctk_widget_real_unmap:
12364 *
12365 * arguments:
12366 *
12367 * results:
12368 *****************************************/
12369
12370static void
12371ctk_widget_real_unmap (CtkWidget *widget)
12372{
12373 CtkWidgetPrivate *priv = widget->priv;
12374
12375 if (_ctk_widget_get_mapped (widget))
12376 {
12377 ctk_widget_set_mapped (widget, FALSE(0));
12378
12379 if (_ctk_widget_get_has_window (widget))
12380 cdk_window_hide (priv->window);
12381 }
12382}
12383
12384/*****************************************
12385 * ctk_widget_real_realize:
12386 *
12387 * arguments:
12388 *
12389 * results:
12390 *****************************************/
12391
12392static void
12393ctk_widget_real_realize (CtkWidget *widget)
12394{
12395 CtkWidgetPrivate *priv = widget->priv;
12396
12397 g_assert (!_ctk_widget_get_has_window (widget))do { if (!_ctk_widget_get_has_window (widget)) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 12397, ((const char*) (__func__)), "!_ctk_widget_get_has_window (widget)"
); } while (0)
;
12398
12399 ctk_widget_set_realized (widget, TRUE(!(0)));
12400 if (priv->parent)
12401 {
12402 priv->window = ctk_widget_get_parent_window (widget);
12403 g_object_ref (priv->window)((__typeof__ (priv->window)) (g_object_ref) (priv->window
))
;
12404 }
12405}
12406
12407/*****************************************
12408 * ctk_widget_real_unrealize:
12409 *
12410 * arguments:
12411 *
12412 * results:
12413 *****************************************/
12414
12415static void
12416ctk_widget_real_unrealize (CtkWidget *widget)
12417{
12418 CtkWidgetPrivate *priv = widget->priv;
12419
12420 g_assert (!widget->priv->mapped)do { if (!widget->priv->mapped) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 12420, ((const char*) (__func__)), "!widget->priv->mapped"
); } while (0)
;
12421
12422 /* We must do unrealize child widget BEFORE container widget.
12423 * cdk_window_destroy() destroys specified xwindow and its sub-xwindows.
12424 * So, unrealizing container widget before its children causes the problem
12425 * (for example, cdk_ic_destroy () with destroyed window causes crash.)
12426 */
12427
12428 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
12429 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
12430 (CtkCallback) ctk_widget_unrealize,
12431 NULL((void*)0));
12432
12433 if (_ctk_widget_get_has_window (widget))
12434 {
12435 ctk_widget_unregister_window (widget, priv->window);
12436 cdk_window_destroy (priv->window);
12437 priv->window = NULL((void*)0);
12438 }
12439 else
12440 {
12441 g_object_unref (priv->window);
12442 priv->window = NULL((void*)0);
12443 }
12444
12445 ctk_selection_remove_all (widget);
12446
12447 ctk_widget_set_realized (widget, FALSE(0));
12448}
12449
12450static void
12451ctk_widget_real_adjust_size_request (CtkWidget *widget,
12452 CtkOrientation orientation,
12453 gint *minimum_size,
12454 gint *natural_size)
12455{
12456 CtkWidgetPrivate *priv = widget->priv;
12457
12458 if (orientation == CTK_ORIENTATION_HORIZONTAL && priv->width > 0)
12459 *minimum_size = MAX (*minimum_size, priv->width)(((*minimum_size) > (priv->width)) ? (*minimum_size) : (
priv->width))
;
12460 else if (orientation == CTK_ORIENTATION_VERTICAL && priv->height > 0)
12461 *minimum_size = MAX (*minimum_size, priv->height)(((*minimum_size) > (priv->height)) ? (*minimum_size) :
(priv->height))
;
12462
12463 /* Fix it if set_size_request made natural size smaller than min size.
12464 * This would also silently fix broken widgets, but we warn about them
12465 * in ctksizerequest.c when calling their size request vfuncs.
12466 */
12467 *natural_size = MAX (*natural_size, *minimum_size)(((*natural_size) > (*minimum_size)) ? (*natural_size) : (
*minimum_size))
;
12468
12469 if (orientation == CTK_ORIENTATION_HORIZONTAL)
12470 {
12471 *minimum_size += priv->margin.left + priv->margin.right;
12472 *natural_size += priv->margin.left + priv->margin.right;
12473 }
12474 else
12475 {
12476 *minimum_size += priv->margin.top + priv->margin.bottom;
12477 *natural_size += priv->margin.top + priv->margin.bottom;
12478 }
12479}
12480
12481static void
12482ctk_widget_real_adjust_baseline_request (CtkWidget *widget,
12483 gint *minimum_baseline,
12484 gint *natural_baseline)
12485{
12486 CtkWidgetPrivate *priv = widget->priv;
12487
12488 if (priv->height >= 0)
12489 {
12490 /* No baseline support for explicitly set height */
12491 *minimum_baseline = -1;
12492 *natural_baseline = -1;
12493 }
12494 else
12495 {
12496 *minimum_baseline += priv->margin.top;
12497 *natural_baseline += priv->margin.top;
12498 }
12499}
12500
12501static gboolean
12502is_my_window (CtkWidget *widget,
12503 CdkWindow *window)
12504{
12505 gpointer user_data;
12506
12507 cdk_window_get_user_data (window, &user_data);
12508 return (user_data == widget);
12509}
12510
12511/*
12512 * _ctk_widget_get_device_window:
12513 * @widget: a #CtkWidget
12514 * @device: a #CdkDevice
12515 *
12516 * Returns: (nullable): the window of @widget that @device is in, or %NULL
12517 */
12518CdkWindow *
12519_ctk_widget_get_device_window (CtkWidget *widget,
12520 CdkDevice *device)
12521{
12522 CdkWindow *window;
12523
12524 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
12525 g_return_val_if_fail (CDK_IS_DEVICE (device), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_device_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__
)), "CDK_IS_DEVICE (device)"); return (((void*)0)); } } while
(0)
;
12526
12527 if (cdk_device_get_source (device) == CDK_SOURCE_KEYBOARD)
12528 return NULL((void*)0);
12529
12530 window = cdk_device_get_last_event_window (device);
12531 if (window && is_my_window (widget, window))
12532 return window;
12533 else
12534 return NULL((void*)0);
12535}
12536
12537static void
12538list_devices (CtkWidget *widget,
12539 CdkDeviceManager *device_manager,
12540 CdkDeviceType device_type,
12541 GList **result)
12542{
12543 GList *devices;
12544 GList *l;
12545
12546 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
12547 devices = cdk_device_manager_list_devices (device_manager, device_type);
12548 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
12549
12550 for (l = devices; l; l = l->next)
12551 {
12552 CdkDevice *device = l->data;
12553 if (cdk_device_get_source (device) != CDK_SOURCE_KEYBOARD)
12554 {
12555 CdkWindow *window = cdk_device_get_last_event_window (device);
12556 if (window && is_my_window (widget, window))
12557 *result = g_list_prepend (*result, device);
12558 }
12559 }
12560 g_list_free (devices);
12561}
12562
12563/*
12564 * _ctk_widget_list_devices:
12565 * @widget: a #CtkWidget
12566 *
12567 * Returns the list of #CdkDevices that is currently on top
12568 * of any window belonging to @widget.
12569 * Free the list with g_list_free(), the elements are owned
12570 * by CTK+ and must not be freed.
12571 */
12572GList *
12573_ctk_widget_list_devices (CtkWidget *widget)
12574{
12575 CdkDisplay *display;
12576 CdkDeviceManager *device_manager;
12577 GList *result = NULL((void*)0);
12578
12579 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
12580
12581 if (!_ctk_widget_get_mapped (widget))
12582 return NULL((void*)0);
12583
12584 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
12585 display = ctk_widget_get_display (widget);
12586 device_manager = cdk_display_get_device_manager (display);
12587 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
12588
12589 list_devices (widget, device_manager, CDK_DEVICE_TYPE_MASTER, &result);
12590 /* Rare, but we can get events for grabbed slave devices */
12591 list_devices (widget, device_manager, CDK_DEVICE_TYPE_SLAVE, &result);
12592
12593 return result;
12594}
12595
12596static void
12597synth_crossing (CtkWidget *widget,
12598 CdkEventType type,
12599 CdkWindow *window,
12600 CdkDevice *device,
12601 CdkCrossingMode mode,
12602 CdkNotifyType detail)
12603{
12604 CdkEvent *event;
12605
12606 event = cdk_event_new (type);
12607
12608 event->crossing.window = g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window));
12609 event->crossing.send_event = TRUE(!(0));
12610 event->crossing.subwindow = g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window));
12611 event->crossing.time = CDK_CURRENT_TIME0L;
12612 cdk_device_get_position_double (device,
12613 NULL((void*)0),
12614 &event->crossing.x_root,
12615 &event->crossing.y_root);
12616 cdk_window_get_device_position_double (window,
12617 device,
12618 &event->crossing.x,
12619 &event->crossing.y,
12620 NULL((void*)0));
12621 event->crossing.mode = mode;
12622 event->crossing.detail = detail;
12623 event->crossing.focus = FALSE(0);
12624 event->crossing.state = 0;
12625 cdk_event_set_device (event, device);
12626
12627 if (!widget)
12628 widget = ctk_get_event_widget (event);
12629
12630 if (widget)
12631 ctk_widget_event_internal (widget, event);
12632
12633 cdk_event_free (event);
12634}
12635
12636/*
12637 * _ctk_widget_synthesize_crossing:
12638 * @from: the #CtkWidget the virtual pointer is leaving.
12639 * @to: the #CtkWidget the virtual pointer is moving to.
12640 * @mode: the #CdkCrossingMode to place on the synthesized events.
12641 *
12642 * Generate crossing event(s) on widget state (sensitivity) or CTK+ grab change.
12643 *
12644 * The real pointer window is the window that most recently received an enter notify
12645 * event. Windows that don’t select for crossing events can’t become the real
12646 * pointer window. The real pointer widget that owns the real pointer window. The
12647 * effective pointer window is the same as the real pointer window unless the real
12648 * pointer widget is either insensitive or there is a grab on a widget that is not
12649 * an ancestor of the real pointer widget (in which case the effective pointer
12650 * window should be the root window).
12651 *
12652 * When the effective pointer window is the same as the real pointer window, we
12653 * receive crossing events from the windowing system. When the effective pointer
12654 * window changes to become different from the real pointer window we synthesize
12655 * crossing events, attempting to follow X protocol rules:
12656 *
12657 * When the root window becomes the effective pointer window:
12658 * - leave notify on real pointer window, detail Ancestor
12659 * - leave notify on all of its ancestors, detail Virtual
12660 * - enter notify on root window, detail Inferior
12661 *
12662 * When the root window ceases to be the effective pointer window:
12663 * - leave notify on root window, detail Inferior
12664 * - enter notify on all ancestors of real pointer window, detail Virtual
12665 * - enter notify on real pointer window, detail Ancestor
12666 */
12667void
12668_ctk_widget_synthesize_crossing (CtkWidget *from,
12669 CtkWidget *to,
12670 CdkDevice *device,
12671 CdkCrossingMode mode)
12672{
12673 CdkWindow *from_window = NULL((void*)0), *to_window = NULL((void*)0);
12674
12675 g_return_if_fail (from != NULL || to != NULL)do { if ((from != ((void*)0) || to != ((void*)0))) { } else {
g_return_if_fail_warning ("Ctk", ((const char*) (__func__)),
"from != NULL || to != NULL"); return; } } while (0)
;
12676
12677 if (from != NULL((void*)0))
12678 {
12679 from_window = _ctk_widget_get_device_window (from, device);
12680
12681 if (!from_window)
12682 from_window = from->priv->window;
12683 }
12684
12685 if (to != NULL((void*)0))
12686 {
12687 to_window = _ctk_widget_get_device_window (to, device);
12688
12689 if (!to_window)
12690 to_window = to->priv->window;
12691 }
12692
12693 if (from_window == NULL((void*)0) && to_window == NULL((void*)0))
12694 ;
12695 else if (from_window != NULL((void*)0) && to_window == NULL((void*)0))
12696 {
12697 GList *from_ancestors = NULL((void*)0), *list;
12698 CdkWindow *from_ancestor = from_window;
12699
12700 while (from_ancestor != NULL((void*)0))
12701 {
12702 from_ancestor = cdk_window_get_effective_parent (from_ancestor);
12703 if (from_ancestor == NULL((void*)0))
12704 break;
12705 from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
12706 }
12707
12708 synth_crossing (from, CDK_LEAVE_NOTIFY, from_window,
12709 device, mode, CDK_NOTIFY_ANCESTOR);
12710 for (list = g_list_last (from_ancestors); list; list = list->prev)
12711 {
12712 synth_crossing (NULL((void*)0), CDK_LEAVE_NOTIFY, (CdkWindow *) list->data,
12713 device, mode, CDK_NOTIFY_VIRTUAL);
12714 }
12715
12716 /* XXX: enter/inferior on root window? */
12717
12718 g_list_free (from_ancestors);
12719 }
12720 else if (from_window == NULL((void*)0) && to_window != NULL((void*)0))
12721 {
12722 GList *to_ancestors = NULL((void*)0), *list;
12723 CdkWindow *to_ancestor = to_window;
12724
12725 while (to_ancestor != NULL((void*)0))
12726 {
12727 to_ancestor = cdk_window_get_effective_parent (to_ancestor);
12728 if (to_ancestor == NULL((void*)0))
12729 break;
12730 to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
12731 }
12732
12733 /* XXX: leave/inferior on root window? */
12734
12735 for (list = to_ancestors; list; list = list->next)
12736 {
12737 synth_crossing (NULL((void*)0), CDK_ENTER_NOTIFY, (CdkWindow *) list->data,
12738 device, mode, CDK_NOTIFY_VIRTUAL);
12739 }
12740 synth_crossing (to, CDK_ENTER_NOTIFY, to_window,
12741 device, mode, CDK_NOTIFY_ANCESTOR);
12742
12743 g_list_free (to_ancestors);
12744 }
12745 else if (from_window == to_window)
12746 ;
12747 else
12748 {
12749 GList *from_ancestors = NULL((void*)0), *to_ancestors = NULL((void*)0), *list;
12750 CdkWindow *from_ancestor = from_window, *to_ancestor = to_window;
12751
12752 while (from_ancestor != NULL((void*)0) || to_ancestor != NULL((void*)0))
12753 {
12754 if (from_ancestor != NULL((void*)0))
12755 {
12756 from_ancestor = cdk_window_get_effective_parent (from_ancestor);
12757 if (from_ancestor == to_window)
12758 break;
12759 if (from_ancestor)
12760 from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
12761 }
12762 if (to_ancestor != NULL((void*)0))
12763 {
12764 to_ancestor = cdk_window_get_effective_parent (to_ancestor);
12765 if (to_ancestor == from_window)
12766 break;
12767 if (to_ancestor)
12768 to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
12769 }
12770 }
12771 if (to_ancestor == from_window)
12772 {
12773 if (mode != CDK_CROSSING_CTK_UNGRAB)
12774 synth_crossing (from, CDK_LEAVE_NOTIFY, from_window,
12775 device, mode, CDK_NOTIFY_INFERIOR);
12776 for (list = to_ancestors; list; list = list->next)
12777 synth_crossing (NULL((void*)0), CDK_ENTER_NOTIFY, (CdkWindow *) list->data,
12778 device, mode, CDK_NOTIFY_VIRTUAL);
12779 synth_crossing (to, CDK_ENTER_NOTIFY, to_window,
12780 device, mode, CDK_NOTIFY_ANCESTOR);
12781 }
12782 else if (from_ancestor == to_window)
12783 {
12784 synth_crossing (from, CDK_LEAVE_NOTIFY, from_window,
12785 device, mode, CDK_NOTIFY_ANCESTOR);
12786 for (list = g_list_last (from_ancestors); list; list = list->prev)
12787 {
12788 synth_crossing (NULL((void*)0), CDK_LEAVE_NOTIFY, (CdkWindow *) list->data,
12789 device, mode, CDK_NOTIFY_VIRTUAL);
12790 }
12791 if (mode != CDK_CROSSING_CTK_GRAB)
12792 synth_crossing (to, CDK_ENTER_NOTIFY, to_window,
12793 device, mode, CDK_NOTIFY_INFERIOR);
12794 }
12795 else
12796 {
12797 while (from_ancestors != NULL((void*)0) && to_ancestors != NULL((void*)0)
12798 && from_ancestors->data == to_ancestors->data)
12799 {
12800 from_ancestors = g_list_delete_link (from_ancestors,
12801 from_ancestors);
12802 to_ancestors = g_list_delete_link (to_ancestors, to_ancestors);
12803 }
12804
12805 synth_crossing (from, CDK_LEAVE_NOTIFY, from_window,
12806 device, mode, CDK_NOTIFY_NONLINEAR);
12807
12808 for (list = g_list_last (from_ancestors); list; list = list->prev)
12809 {
12810 synth_crossing (NULL((void*)0), CDK_LEAVE_NOTIFY, (CdkWindow *) list->data,
12811 device, mode, CDK_NOTIFY_NONLINEAR_VIRTUAL);
12812 }
12813 for (list = to_ancestors; list; list = list->next)
12814 {
12815 synth_crossing (NULL((void*)0), CDK_ENTER_NOTIFY, (CdkWindow *) list->data,
12816 device, mode, CDK_NOTIFY_NONLINEAR_VIRTUAL);
12817 }
12818 synth_crossing (to, CDK_ENTER_NOTIFY, to_window,
12819 device, mode, CDK_NOTIFY_NONLINEAR);
12820 }
12821 g_list_free (from_ancestors);
12822 g_list_free (to_ancestors);
12823 }
12824}
12825
12826static void
12827ctk_widget_propagate_state (CtkWidget *widget,
12828 CtkStateData *data)
12829{
12830 CtkWidgetPrivate *priv = widget->priv;
12831 CtkStateFlags new_flags, old_flags = priv->state_flags;
12832 CtkStateType old_state;
12833 gint new_scale_factor = ctk_widget_get_scale_factor (widget);
12834
12835 old_state = ctk_widget_get_state (widget);
12836
12837 priv->state_flags |= data->flags_to_set;
12838 priv->state_flags &= ~(data->flags_to_unset);
12839
12840 /* make insensitivity unoverridable */
12841 if (!priv->sensitive)
12842 priv->state_flags |= CTK_STATE_FLAG_INSENSITIVE;
12843
12844 if (ctk_widget_is_focus (widget) && !ctk_widget_is_sensitive (widget))
12845 {
12846 CtkWidget *window;
12847
12848 window = _ctk_widget_get_toplevel (widget);
12849
12850 if (window && _ctk_widget_is_toplevel (window))
12851 ctk_window_set_focus (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, NULL((void*)0));
12852 }
12853
12854 new_flags = priv->state_flags;
12855
12856 if (data->old_scale_factor != new_scale_factor)
12857 _ctk_widget_scale_changed (widget);
12858
12859 if (old_flags != new_flags)
12860 {
12861 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
12862
12863 if (!ctk_widget_is_sensitive (widget) && ctk_widget_has_grab (widget))
12864 ctk_grab_remove (widget);
12865
12866 ctk_style_context_set_state (_ctk_widget_get_style_context (widget), new_flags);
12867
12868 g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
12869 g_signal_emit (widget, widget_signals[STATE_FLAGS_CHANGED], 0, old_flags);
12870
12871 if (!priv->shadowed &&
12872 (new_flags & CTK_STATE_FLAG_INSENSITIVE) != (old_flags & CTK_STATE_FLAG_INSENSITIVE))
12873 {
12874 GList *event_windows = NULL((void*)0);
12875 GList *devices, *d;
12876
12877 devices = _ctk_widget_list_devices (widget);
12878
12879 for (d = devices; d; d = d->next)
12880 {
12881 CdkWindow *window;
12882 CdkDevice *device;
12883
12884 device = d->data;
12885 window = _ctk_widget_get_device_window (widget, device);
12886
12887 /* Do not propagate more than once to the
12888 * same window if non-multidevice aware.
12889 */
12890 if (!cdk_window_get_support_multidevice (window) &&
12891 g_list_find (event_windows, window))
12892 continue;
12893
12894 if (!ctk_widget_is_sensitive (widget))
12895 _ctk_widget_synthesize_crossing (widget, NULL((void*)0), d->data,
12896 CDK_CROSSING_STATE_CHANGED);
12897 else
12898 _ctk_widget_synthesize_crossing (NULL((void*)0), widget, d->data,
12899 CDK_CROSSING_STATE_CHANGED);
12900
12901 event_windows = g_list_prepend (event_windows, window);
12902 }
12903
12904 g_list_free (event_windows);
12905 g_list_free (devices);
12906 }
12907
12908 if (!ctk_widget_is_sensitive (widget))
12909 ctk_widget_reset_controllers (widget);
12910
12911 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
12912 {
12913 CtkStateData child_data;
12914
12915 /* Make sure to only propagate the right states further */
12916 child_data.old_scale_factor = new_scale_factor;
12917 child_data.flags_to_set = data->flags_to_set & CTK_STATE_FLAGS_DO_PROPAGATE(CTK_STATE_FLAG_INSENSITIVE|CTK_STATE_FLAG_BACKDROP);
12918 child_data.flags_to_unset = data->flags_to_unset & CTK_STATE_FLAGS_DO_PROPAGATE(CTK_STATE_FLAG_INSENSITIVE|CTK_STATE_FLAG_BACKDROP);
12919
12920 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
12921 (CtkCallback) ctk_widget_propagate_state,
12922 &child_data);
12923 }
12924
12925 g_object_unref (widget);
12926 }
12927}
12928
12929/**
12930 * ctk_widget_shape_combine_region:
12931 * @widget: a #CtkWidget
12932 * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
12933 *
12934 * Sets a shape for this widget’s CDK window. This allows for
12935 * transparent windows etc., see cdk_window_shape_combine_region()
12936 * for more information.
12937 *
12938 * Since: 3.0
12939 **/
12940void
12941ctk_widget_shape_combine_region (CtkWidget *widget,
12942 cairo_region_t *region)
12943{
12944 CtkWidgetPrivate *priv;
12945
12946 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
12947 /* set_shape doesn't work on widgets without CDK window */
12948 g_return_if_fail (_ctk_widget_get_has_window (widget))do { if ((_ctk_widget_get_has_window (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "_ctk_widget_get_has_window (widget)"
); return; } } while (0)
;
12949
12950 priv = widget->priv;
12951
12952 if (region == NULL((void*)0))
12953 {
12954 priv->has_shape_mask = FALSE(0);
12955
12956 if (priv->window)
12957 cdk_window_shape_combine_region (priv->window, NULL((void*)0), 0, 0);
12958
12959 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_shape_info, NULL((void*)0));
12960 }
12961 else
12962 {
12963 priv->has_shape_mask = TRUE(!(0));
12964
12965 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_shape_info,
12966 cairo_region_copy (region),
12967 (GDestroyNotify) cairo_region_destroy);
12968
12969 /* set shape if widget has a CDK window already.
12970 * otherwise the shape is scheduled to be set by ctk_widget_realize().
12971 */
12972 if (priv->window)
12973 cdk_window_shape_combine_region (priv->window, region, 0, 0);
12974 }
12975}
12976
12977static void
12978ctk_widget_update_input_shape (CtkWidget *widget)
12979{
12980 CtkWidgetPrivate *priv = widget->priv;
12981
12982 /* set shape if widget has a CDK window already.
12983 * otherwise the shape is scheduled to be set by ctk_widget_realize().
12984 */
12985 if (priv->window)
12986 {
12987 cairo_region_t *region;
12988 cairo_region_t *csd_region;
12989 cairo_region_t *app_region;
12990 gboolean free_region;
12991
12992 app_region = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_input_shape_info);
12993 csd_region = g_object_get_data (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "csd-region");
12994
12995 free_region = FALSE(0);
12996
12997 if (app_region && csd_region)
12998 {
12999 free_region = TRUE(!(0));
13000 region = cairo_region_copy (app_region);
13001 cairo_region_intersect (region, csd_region);
13002 }
13003 else if (app_region)
13004 region = app_region;
13005 else if (csd_region)
13006 region = csd_region;
13007 else
13008 region = NULL((void*)0);
13009
13010 cdk_window_input_shape_combine_region (priv->window, region, 0, 0);
13011
13012 if (free_region)
13013 cairo_region_destroy (region);
13014 }
13015}
13016
13017void
13018ctk_widget_set_csd_input_shape (CtkWidget *widget,
13019 const cairo_region_t *region)
13020{
13021 if (region == NULL((void*)0))
13022 g_object_set_data (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "csd-region", NULL((void*)0));
13023 else
13024 g_object_set_data_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "csd-region",
13025 cairo_region_copy (region),
13026 (GDestroyNotify) cairo_region_destroy);
13027 ctk_widget_update_input_shape (widget);
13028}
13029
13030/**
13031 * ctk_widget_input_shape_combine_region:
13032 * @widget: a #CtkWidget
13033 * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
13034 *
13035 * Sets an input shape for this widget’s CDK window. This allows for
13036 * windows which react to mouse click in a nonrectangular region, see
13037 * cdk_window_input_shape_combine_region() for more information.
13038 *
13039 * Since: 3.0
13040 **/
13041void
13042ctk_widget_input_shape_combine_region (CtkWidget *widget,
13043 cairo_region_t *region)
13044{
13045 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13046 /* set_shape doesn't work on widgets without CDK window */
13047 g_return_if_fail (_ctk_widget_get_has_window (widget))do { if ((_ctk_widget_get_has_window (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "_ctk_widget_get_has_window (widget)"
); return; } } while (0)
;
13048
13049 if (region == NULL((void*)0))
13050 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_input_shape_info, NULL((void*)0));
13051 else
13052 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_input_shape_info,
13053 cairo_region_copy (region),
13054 (GDestroyNotify) cairo_region_destroy);
13055 ctk_widget_update_input_shape (widget);
13056}
13057
13058
13059/* style properties
13060 */
13061
13062/**
13063 * ctk_widget_class_install_style_property_parser: (skip)
13064 * @klass: a #CtkWidgetClass
13065 * @pspec: the #GParamSpec for the style property
13066 * @parser: the parser for the style property
13067 *
13068 * Installs a style property on a widget class.
13069 **/
13070void
13071ctk_widget_class_install_style_property_parser (CtkWidgetClass *klass,
13072 GParamSpec *pspec,
13073 CtkRcPropertyParser parser)
13074{
13075 g_return_if_fail (CTK_IS_WIDGET_CLASS (klass))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((klass)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (klass)");
return; } } while (0)
;
13076 g_return_if_fail (G_IS_PARAM_SPEC (pspec))do { if (((((g_type_check_instance_is_fundamentally_a ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2)))))))))) { } else {
g_return_if_fail_warning ("Ctk", ((const char*) (__func__)),
"G_IS_PARAM_SPEC (pspec)"); return; } } while (0)
;
13077 g_return_if_fail (pspec->flags & G_PARAM_READABLE)do { if ((pspec->flags & G_PARAM_READABLE)) { } else {
g_return_if_fail_warning ("Ctk", ((const char*) (__func__)),
"pspec->flags & G_PARAM_READABLE"); return; } } while
(0)
;
13078 g_return_if_fail (!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT)))do { if ((!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT
)))) { } else { g_return_if_fail_warning ("Ctk", ((const char
*) (__func__)), "!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT))"
); return; } } while (0)
;
13079
13080 if (g_param_spec_pool_lookup (style_property_spec_pool, pspec->name, G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)), FALSE(0)))
13081 {
13082 g_warning (G_STRLOC"ctkwidget.c" ":" "13082" ": class '%s' already contains a style property named '%s'",
13083 G_OBJECT_CLASS_NAME (klass)(g_type_name (((((GTypeClass*) (klass))->g_type)))),
13084 pspec->name);
13085 return;
13086 }
13087
13088 g_param_spec_ref_sink (pspec);
13089 g_param_spec_set_qdata (pspec, quark_property_parser, (gpointer) parser);
13090 g_param_spec_pool_insert (style_property_spec_pool, pspec, G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)));
13091}
13092
13093/**
13094 * ctk_widget_class_install_style_property:
13095 * @klass: a #CtkWidgetClass
13096 * @pspec: the #GParamSpec for the property
13097 *
13098 * Installs a style property on a widget class. The parser for the
13099 * style property is determined by the value type of @pspec.
13100 **/
13101void
13102ctk_widget_class_install_style_property (CtkWidgetClass *klass,
13103 GParamSpec *pspec)
13104{
13105 CtkRcPropertyParser parser;
13106
13107 g_return_if_fail (CTK_IS_WIDGET_CLASS (klass))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((klass)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (klass)");
return; } } while (0)
;
13108 g_return_if_fail (G_IS_PARAM_SPEC (pspec))do { if (((((g_type_check_instance_is_fundamentally_a ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2)))))))))) { } else {
g_return_if_fail_warning ("Ctk", ((const char*) (__func__)),
"G_IS_PARAM_SPEC (pspec)"); return; } } while (0)
;
13109
13110 parser = _ctk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2))))))))->value_type
)
);
13111
13112 ctk_widget_class_install_style_property_parser (klass, pspec, parser);
13113}
13114
13115/**
13116 * ctk_widget_class_find_style_property:
13117 * @klass: a #CtkWidgetClass
13118 * @property_name: the name of the style property to find
13119 *
13120 * Finds a style property of a widget class by name.
13121 *
13122 * Returns: (transfer none): the #GParamSpec of the style property or
13123 * %NULL if @class has no style property with that name.
13124 *
13125 * Since: 2.2
13126 */
13127GParamSpec*
13128ctk_widget_class_find_style_property (CtkWidgetClass *klass,
13129 const gchar *property_name)
13130{
13131 g_return_val_if_fail (property_name != NULL, NULL)do { if ((property_name != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "property_name != NULL")
; return (((void*)0)); } } while (0)
;
13132
13133 return g_param_spec_pool_lookup (style_property_spec_pool,
13134 property_name,
13135 G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)),
13136 TRUE(!(0)));
13137}
13138
13139/**
13140 * ctk_widget_class_list_style_properties:
13141 * @klass: a #CtkWidgetClass
13142 * @n_properties: (out): location to return the number of style properties found
13143 *
13144 * Returns all style properties of a widget class.
13145 *
13146 * Returns: (array length=n_properties) (transfer container): a
13147 * newly allocated array of #GParamSpec*. The array must be
13148 * freed with g_free().
13149 *
13150 * Since: 2.2
13151 */
13152GParamSpec**
13153ctk_widget_class_list_style_properties (CtkWidgetClass *klass,
13154 guint *n_properties)
13155{
13156 GParamSpec **pspecs;
13157 guint n;
13158
13159 pspecs = g_param_spec_pool_list (style_property_spec_pool,
13160 G_OBJECT_CLASS_TYPE (klass)((((GTypeClass*) (klass))->g_type)),
13161 &n);
13162 if (n_properties)
13163 *n_properties = n;
13164
13165 return pspecs;
13166}
13167
13168/**
13169 * ctk_widget_style_get_property:
13170 * @widget: a #CtkWidget
13171 * @property_name: the name of a style property
13172 * @value: location to return the property value
13173 *
13174 * Gets the value of a style property of @widget.
13175 */
13176void
13177ctk_widget_style_get_property (CtkWidget *widget,
13178 const gchar *property_name,
13179 GValue *value)
13180{
13181 GParamSpec *pspec;
13182
13183 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13184 g_return_if_fail (property_name != NULL)do { if ((property_name != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "property_name != NULL")
; return; } } while (0)
;
13185 g_return_if_fail (G_IS_VALUE (value))do { if (((((g_type_check_value ((GValue*) (value))))))) { } else
{ g_return_if_fail_warning ("Ctk", ((const char*) (__func__)
), "G_IS_VALUE (value)"); return; } } while (0)
;
13186
13187 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
13188 pspec = g_param_spec_pool_lookup (style_property_spec_pool,
13189 property_name,
13190 G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
,
13191 TRUE(!(0)));
13192 if (!pspec)
13193 g_warning ("%s: widget class '%s' has no property named '%s'",
13194 G_STRLOC"ctkwidget.c" ":" "13194",
13195 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
,
13196 property_name);
13197 else
13198 {
13199 CtkStyleContext *context;
13200 const GValue *peek_value;
13201
13202 context = _ctk_widget_get_style_context (widget);
13203
13204 peek_value = _ctk_style_context_peek_style_property (context,
13205 G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
,
13206 pspec);
13207
13208 /* auto-conversion of the caller's value type
13209 */
13210 if (G_VALUE_TYPE (value)(((GValue*) (value))->g_type) == G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2))))))))->value_type
)
)
13211 g_value_copy (peek_value, value);
13212 else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2))))))))->value_type
)
, G_VALUE_TYPE (value)(((GValue*) (value))->g_type)))
13213 g_value_transform (peek_value, value);
13214 else
13215 g_warning ("can't retrieve style property '%s' of type '%s' as value of type '%s'",
13216 pspec->name,
13217 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pspec)), (((GType) ((19) << (2))))))))->value_type
)
),
13218 G_VALUE_TYPE_NAME (value)(g_type_name ((((GValue*) (value))->g_type))));
13219 }
13220 g_object_unref (widget);
13221}
13222
13223/**
13224 * ctk_widget_style_get_valist:
13225 * @widget: a #CtkWidget
13226 * @first_property_name: the name of the first property to get
13227 * @var_args: a va_list of pairs of property names and
13228 * locations to return the property values, starting with the location
13229 * for @first_property_name.
13230 *
13231 * Non-vararg variant of ctk_widget_style_get(). Used primarily by language
13232 * bindings.
13233 */
13234void
13235ctk_widget_style_get_valist (CtkWidget *widget,
13236 const gchar *first_property_name,
13237 va_list var_args)
13238{
13239 CtkStyleContext *context;
13240 const gchar *name;
13241
13242 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13243
13244 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
13245 context = _ctk_widget_get_style_context (widget);
13246
13247 name = first_property_name;
13248 while (name)
13249 {
13250 const GValue *peek_value;
13251 GParamSpec *pspec;
13252 gchar *error;
13253
13254 pspec = g_param_spec_pool_lookup (style_property_spec_pool,
13255 name,
13256 G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
,
13257 TRUE(!(0)));
13258 if (!pspec)
13259 {
13260 g_warning ("%s: widget class '%s' has no property named '%s'",
13261 G_STRLOC"ctkwidget.c" ":" "13261",
13262 G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
,
13263 name);
13264 break;
13265 }
13266 /* style pspecs are always readable so we can spare that check here */
13267
13268 peek_value = _ctk_style_context_peek_style_property (context,
13269 G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
,
13270 pspec);
13271
13272 G_VALUE_LCOPY (peek_value, var_args, 0, &error)do { const GValue *g_vl_value = (peek_value); guint g_vl_flags
= (0); GType g_vl_value_type = (((GValue*) (g_vl_value))->
g_type); GTypeValueTable *g_vl_vtable = g_type_value_table_peek
(g_vl_value_type); const gchar *g_vl_lcopy_format = g_vl_vtable
->lcopy_format; GTypeCValue g_vl_cvalues[(8)] = { { 0, }, }
; guint g_vl_n_values = 0; while (*g_vl_lcopy_format) { GTypeCValue
*g_vl_cvalue = g_vl_cvalues + g_vl_n_values++; switch (*g_vl_lcopy_format
++) { case G_VALUE_COLLECT_INT: g_vl_cvalue->v_int = __builtin_va_arg
((var_args), gint); break; case G_VALUE_COLLECT_LONG: g_vl_cvalue
->v_long = __builtin_va_arg((var_args), glong); break; case
G_VALUE_COLLECT_INT64: g_vl_cvalue->v_int64 = __builtin_va_arg
((var_args), gint64); break; case G_VALUE_COLLECT_DOUBLE: g_vl_cvalue
->v_double = __builtin_va_arg((var_args), gdouble); break;
case G_VALUE_COLLECT_POINTER: g_vl_cvalue->v_pointer = __builtin_va_arg
((var_args), gpointer); break; default: do { g_assertion_message_expr
("Ctk", "ctkwidget.c", 13272, ((const char*) (__func__)), ((
void*)0)); } while (0); } } *(&error) = g_vl_vtable->lcopy_value
(g_vl_value, g_vl_n_values, g_vl_cvalues, g_vl_flags); } while
(0)
;
13273 if (error)
13274 {
13275 g_warning ("%s: %s", G_STRLOC"ctkwidget.c" ":" "13275", error);
13276 g_free (error);
13277 break;
13278 }
13279
13280 name = va_arg (var_args, gchar*)__builtin_va_arg(var_args, gchar*);
13281 }
13282
13283 g_object_unref (widget);
13284}
13285
13286/**
13287 * ctk_widget_style_get:
13288 * @widget: a #CtkWidget
13289 * @first_property_name: the name of the first property to get
13290 * @...: pairs of property names and locations to return the
13291 * property values, starting with the location for
13292 * @first_property_name, terminated by %NULL.
13293 *
13294 * Gets the values of a multiple style properties of @widget.
13295 */
13296void
13297ctk_widget_style_get (CtkWidget *widget,
13298 const gchar *first_property_name,
13299 ...)
13300{
13301 va_list var_args;
13302
13303 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13304
13305 va_start (var_args, first_property_name)__builtin_va_start(var_args, first_property_name);
13306 ctk_widget_style_get_valist (widget, first_property_name, var_args);
13307 va_end (var_args)__builtin_va_end(var_args);
13308}
13309
13310/**
13311 * ctk_requisition_new:
13312 *
13313 * Allocates a new #CtkRequisition-struct and initializes its elements to zero.
13314 *
13315 * Returns: a new empty #CtkRequisition. The newly allocated #CtkRequisition should
13316 * be freed with ctk_requisition_free().
13317 *
13318 * Since: 3.0
13319 */
13320CtkRequisition *
13321ctk_requisition_new (void)
13322{
13323 return g_slice_new0 (CtkRequisition)((CtkRequisition*) g_slice_alloc0 ((sizeof (CtkRequisition) >
0 ? sizeof (CtkRequisition) : 1)))
;
13324}
13325
13326/**
13327 * ctk_requisition_copy:
13328 * @requisition: a #CtkRequisition
13329 *
13330 * Copies a #CtkRequisition.
13331 *
13332 * Returns: a copy of @requisition
13333 **/
13334CtkRequisition *
13335ctk_requisition_copy (const CtkRequisition *requisition)
13336{
13337 return g_slice_dup (CtkRequisition, requisition)(1 ? (CtkRequisition*) g_slice_copy ((sizeof (CtkRequisition)
> 0 ? sizeof (CtkRequisition) : 1), (requisition)) : ((void
) ((CtkRequisition*) 0 == (requisition)), (CtkRequisition*) 0
))
;
13338}
13339
13340/**
13341 * ctk_requisition_free:
13342 * @requisition: a #CtkRequisition
13343 *
13344 * Frees a #CtkRequisition.
13345 **/
13346void
13347ctk_requisition_free (CtkRequisition *requisition)
13348{
13349 g_slice_free (CtkRequisition, requisition)do { if (1) g_slice_free1 (sizeof (CtkRequisition), (requisition
)); else (void) ((CtkRequisition*) 0 == (requisition)); } while
(0)
;
13350}
13351
13352G_DEFINE_BOXED_TYPE (CtkRequisition, ctk_requisition,static GType ctk_requisition_get_type_once (void); GType ctk_requisition_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_requisition_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_requisition_get_type_once (void
) { GType (* _g_register_boxed) (const gchar *, union { CtkRequisition
* (*do_copy_type) (CtkRequisition *); CtkRequisition * (*do_const_copy_type
) (const CtkRequisition *); GBoxedCopyFunc do_copy_boxed; } __attribute__
((__transparent_union__)), union { void (* do_free_type) (CtkRequisition
*); GBoxedFreeFunc do_free_boxed; } __attribute__((__transparent_union__
)) ) = g_boxed_type_register_static; GType g_define_type_id =
_g_register_boxed (g_intern_static_string ("CtkRequisition")
, ctk_requisition_copy, ctk_requisition_free); { {{};} } return
g_define_type_id; }
13353 ctk_requisition_copy,static GType ctk_requisition_get_type_once (void); GType ctk_requisition_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_requisition_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_requisition_get_type_once (void
) { GType (* _g_register_boxed) (const gchar *, union { CtkRequisition
* (*do_copy_type) (CtkRequisition *); CtkRequisition * (*do_const_copy_type
) (const CtkRequisition *); GBoxedCopyFunc do_copy_boxed; } __attribute__
((__transparent_union__)), union { void (* do_free_type) (CtkRequisition
*); GBoxedFreeFunc do_free_boxed; } __attribute__((__transparent_union__
)) ) = g_boxed_type_register_static; GType g_define_type_id =
_g_register_boxed (g_intern_static_string ("CtkRequisition")
, ctk_requisition_copy, ctk_requisition_free); { {{};} } return
g_define_type_id; }
13354 ctk_requisition_free)static GType ctk_requisition_get_type_once (void); GType ctk_requisition_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_requisition_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_requisition_get_type_once (void
) { GType (* _g_register_boxed) (const gchar *, union { CtkRequisition
* (*do_copy_type) (CtkRequisition *); CtkRequisition * (*do_const_copy_type
) (const CtkRequisition *); GBoxedCopyFunc do_copy_boxed; } __attribute__
((__transparent_union__)), union { void (* do_free_type) (CtkRequisition
*); GBoxedFreeFunc do_free_boxed; } __attribute__((__transparent_union__
)) ) = g_boxed_type_register_static; GType g_define_type_id =
_g_register_boxed (g_intern_static_string ("CtkRequisition")
, ctk_requisition_copy, ctk_requisition_free); { {{};} } return
g_define_type_id; }
13355
13356/**
13357 * ctk_widget_class_set_accessible_type:
13358 * @widget_class: class to set the accessible type for
13359 * @type: The object type that implements the accessible for @widget_class
13360 *
13361 * Sets the type to be used for creating accessibles for widgets of
13362 * @widget_class. The given @type must be a subtype of the type used for
13363 * accessibles of the parent class.
13364 *
13365 * This function should only be called from class init functions of widgets.
13366 *
13367 * Since: 3.2
13368 **/
13369void
13370ctk_widget_class_set_accessible_type (CtkWidgetClass *widget_class,
13371 GType type)
13372{
13373 CtkWidgetClassPrivate *priv;
13374
13375 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
13376 g_return_if_fail (g_type_is_a (type, widget_class->priv->accessible_type))do { if ((((type) == (widget_class->priv->accessible_type
) || (g_type_is_a) ((type), (widget_class->priv->accessible_type
))))) { } else { g_return_if_fail_warning ("Ctk", ((const char
*) (__func__)), "g_type_is_a (type, widget_class->priv->accessible_type)"
); return; } } while (0)
;
13377
13378 priv = widget_class->priv;
13379
13380 priv->accessible_type = type;
13381 /* reset this - honoring the type's role is better. */
13382 priv->accessible_role = ATK_ROLE_INVALID;
13383}
13384
13385/**
13386 * ctk_widget_class_set_accessible_role:
13387 * @widget_class: class to set the accessible role for
13388 * @role: The role to use for accessibles created for @widget_class
13389 *
13390 * Sets the default #AtkRole to be set on accessibles created for
13391 * widgets of @widget_class. Accessibles may decide to not honor this
13392 * setting if their role reporting is more refined. Calls to
13393 * ctk_widget_class_set_accessible_type() will reset this value.
13394 *
13395 * In cases where you want more fine-grained control over the role of
13396 * accessibles created for @widget_class, you should provide your own
13397 * accessible type and use ctk_widget_class_set_accessible_type()
13398 * instead.
13399 *
13400 * If @role is #ATK_ROLE_INVALID, the default role will not be changed
13401 * and the accessible’s default role will be used instead.
13402 *
13403 * This function should only be called from class init functions of widgets.
13404 *
13405 * Since: 3.2
13406 **/
13407void
13408ctk_widget_class_set_accessible_role (CtkWidgetClass *widget_class,
13409 AtkRole role)
13410{
13411 CtkWidgetClassPrivate *priv;
13412
13413 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
13414
13415 priv = widget_class->priv;
13416
13417 priv->accessible_role = role;
13418}
13419
13420/**
13421 * _ctk_widget_peek_accessible:
13422 * @widget: a #CtkWidget
13423 *
13424 * Gets the accessible for @widget, if it has been created yet.
13425 * Otherwise, this function returns %NULL. If the @widget’s implementation
13426 * does not use the default way to create accessibles, %NULL will always be
13427 * returned.
13428 *
13429 * Returns: (nullable): the accessible for @widget or %NULL if none has been
13430 * created yet.
13431 **/
13432AtkObject *
13433_ctk_widget_peek_accessible (CtkWidget *widget)
13434{
13435 return widget->priv->accessible;
13436}
13437
13438/**
13439 * ctk_widget_get_accessible:
13440 * @widget: a #CtkWidget
13441 *
13442 * Returns the accessible object that describes the widget to an
13443 * assistive technology.
13444 *
13445 * If accessibility support is not available, this #AtkObject
13446 * instance may be a no-op. Likewise, if no class-specific #AtkObject
13447 * implementation is available for the widget instance in question,
13448 * it will inherit an #AtkObject implementation from the first ancestor
13449 * class for which such an implementation is defined.
13450 *
13451 * The documentation of the
13452 * [ATK](http://developer.gnome.org/atk/stable/)
13453 * library contains more information about accessible objects and their uses.
13454 *
13455 * Returns: (transfer none): the #AtkObject associated with @widget
13456 */
13457AtkObject*
13458ctk_widget_get_accessible (CtkWidget *widget)
13459{
13460 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
13461
13462 return CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->get_accessible (widget);
13463}
13464
13465static AtkObject*
13466ctk_widget_real_get_accessible (CtkWidget *widget)
13467{
13468 AtkObject* accessible;
13469
13470 accessible = widget->priv->accessible;
13471
13472 if (!accessible)
13473 {
13474 CtkWidgetClass *widget_class;
13475 CtkWidgetClassPrivate *priv;
13476 AtkObjectFactory *factory;
13477 AtkRegistry *default_registry;
13478
13479 widget_class = CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
;
13480 priv = widget_class->priv;
13481
13482 if (priv->accessible_type == CTK_TYPE_ACCESSIBLE(ctk_accessible_get_type ()))
13483 {
13484 default_registry = atk_get_default_registry ();
13485 factory = atk_registry_get_factory (default_registry,
13486 G_TYPE_FROM_INSTANCE (widget)((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type))
);
13487 accessible = atk_object_factory_create_accessible (factory, G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
13488
13489 if (priv->accessible_role != ATK_ROLE_INVALID)
13490 atk_object_set_role (accessible, priv->accessible_role);
13491
13492 widget->priv->accessible = accessible;
13493 }
13494 else
13495 {
13496 accessible = g_object_new (priv->accessible_type,
13497 "widget", widget,
13498 NULL((void*)0));
13499 if (priv->accessible_role != ATK_ROLE_INVALID)
13500 atk_object_set_role (accessible, priv->accessible_role);
13501
13502 widget->priv->accessible = accessible;
13503
13504 atk_object_initialize (accessible, widget);
13505
13506 /* Set the role again, since we don't want a role set
13507 * in some parent initialize() function to override
13508 * our own.
13509 */
13510 if (priv->accessible_role != ATK_ROLE_INVALID)
13511 atk_object_set_role (accessible, priv->accessible_role);
13512 }
13513
13514 }
13515
13516 return accessible;
13517}
13518
13519/*
13520 * Initialize a AtkImplementorIface instance’s virtual pointers as
13521 * appropriate to this implementor’s class (CtkWidget).
13522 */
13523static void
13524ctk_widget_accessible_interface_init (AtkImplementorIface *iface)
13525{
13526 iface->ref_accessible = ctk_widget_ref_accessible;
13527}
13528
13529static AtkObject*
13530ctk_widget_ref_accessible (AtkImplementor *implementor)
13531{
13532 AtkObject *accessible;
13533
13534 accessible = ctk_widget_get_accessible (CTK_WIDGET (implementor)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((implementor)), ((ctk_widget_get_type ()))))))
);
13535 if (accessible)
13536 g_object_ref (accessible)((__typeof__ (accessible)) (g_object_ref) (accessible));
13537 return accessible;
13538}
13539
13540/*
13541 * Expand flag management
13542 */
13543
13544static void
13545ctk_widget_update_computed_expand (CtkWidget *widget)
13546{
13547 CtkWidgetPrivate *priv;
13548
13549 priv = widget->priv;
13550
13551 if (priv->need_compute_expand)
13552 {
13553 gboolean h, v;
13554
13555 if (priv->hexpand_set)
13556 h = priv->hexpand;
13557 else
13558 h = FALSE(0);
13559
13560 if (priv->vexpand_set)
13561 v = priv->vexpand;
13562 else
13563 v = FALSE(0);
13564
13565 /* we don't need to use compute_expand if both expands are
13566 * forced by the app
13567 */
13568 if (!(priv->hexpand_set && priv->vexpand_set))
13569 {
13570 if (CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->compute_expand != NULL((void*)0))
13571 {
13572 gboolean ignored;
13573
13574 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->compute_expand (widget,
13575 priv->hexpand_set ? &ignored : &h,
13576 priv->vexpand_set ? &ignored : &v);
13577 }
13578 }
13579
13580 priv->need_compute_expand = FALSE(0);
13581 priv->computed_hexpand = h != FALSE(0);
13582 priv->computed_vexpand = v != FALSE(0);
13583 }
13584}
13585
13586/**
13587 * ctk_widget_queue_compute_expand:
13588 * @widget: a #CtkWidget
13589 *
13590 * Mark @widget as needing to recompute its expand flags. Call
13591 * this function when setting legacy expand child properties
13592 * on the child of a container.
13593 *
13594 * See ctk_widget_compute_expand().
13595 */
13596void
13597ctk_widget_queue_compute_expand (CtkWidget *widget)
13598{
13599 CtkWidget *parent;
13600 gboolean changed_anything;
13601
13602 if (widget->priv->need_compute_expand)
13603 return;
13604
13605 changed_anything = FALSE(0);
13606 parent = widget;
13607 while (parent != NULL((void*)0))
13608 {
13609 if (!parent->priv->need_compute_expand)
13610 {
13611 parent->priv->need_compute_expand = TRUE(!(0));
13612 changed_anything = TRUE(!(0));
13613 }
13614
13615 /* Note: if we had an invariant that "if a child needs to
13616 * compute expand, its parents also do" then we could stop going
13617 * up when we got to a parent that already needed to
13618 * compute. However, in general we compute expand lazily (as
13619 * soon as we see something in a subtree that is expand, we know
13620 * we're expanding) and so this invariant does not hold and we
13621 * have to always walk all the way up in case some ancestor
13622 * is not currently need_compute_expand.
13623 */
13624
13625 parent = parent->priv->parent;
13626 }
13627
13628 /* recomputing expand always requires
13629 * a relayout as well
13630 */
13631 if (changed_anything)
13632 ctk_widget_queue_resize (widget);
13633}
13634
13635/**
13636 * ctk_widget_compute_expand:
13637 * @widget: the widget
13638 * @orientation: expand direction
13639 *
13640 * Computes whether a container should give this widget extra space
13641 * when possible. Containers should check this, rather than
13642 * looking at ctk_widget_get_hexpand() or ctk_widget_get_vexpand().
13643 *
13644 * This function already checks whether the widget is visible, so
13645 * visibility does not need to be checked separately. Non-visible
13646 * widgets are not expanded.
13647 *
13648 * The computed expand value uses either the expand setting explicitly
13649 * set on the widget itself, or, if none has been explicitly set,
13650 * the widget may expand if some of its children do.
13651 *
13652 * Returns: whether widget tree rooted here should be expanded
13653 */
13654gboolean
13655ctk_widget_compute_expand (CtkWidget *widget,
13656 CtkOrientation orientation)
13657{
13658 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
13659
13660 /* We never make a widget expand if not even showing. */
13661 if (!_ctk_widget_get_visible (widget))
13662 return FALSE(0);
13663
13664 ctk_widget_update_computed_expand (widget);
13665
13666 if (orientation == CTK_ORIENTATION_HORIZONTAL)
13667 return widget->priv->computed_hexpand;
13668 else
13669 return widget->priv->computed_vexpand;
13670}
13671
13672static void
13673ctk_widget_set_expand (CtkWidget *widget,
13674 CtkOrientation orientation,
13675 gboolean expand)
13676{
13677 gint expand_prop;
13678 gint expand_set_prop;
13679 gboolean was_both;
13680 CtkWidgetPrivate *priv;
13681
13682 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13683
13684 priv = widget->priv;
13685
13686 expand = expand != FALSE(0);
13687
13688 was_both = priv->hexpand && priv->vexpand;
13689
13690 if (orientation == CTK_ORIENTATION_HORIZONTAL)
13691 {
13692 if (priv->hexpand_set &&
13693 priv->hexpand == expand)
13694 return;
13695
13696 priv->hexpand_set = TRUE(!(0));
13697 priv->hexpand = expand;
13698
13699 expand_prop = PROP_HEXPAND;
13700 expand_set_prop = PROP_HEXPAND_SET;
13701 }
13702 else
13703 {
13704 if (priv->vexpand_set &&
13705 priv->vexpand == expand)
13706 return;
13707
13708 priv->vexpand_set = TRUE(!(0));
13709 priv->vexpand = expand;
13710
13711 expand_prop = PROP_VEXPAND;
13712 expand_set_prop = PROP_VEXPAND_SET;
13713 }
13714
13715 ctk_widget_queue_compute_expand (widget);
13716
13717 g_object_freeze_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
13718 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[expand_prop]);
13719 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[expand_set_prop]);
13720 if (was_both != (priv->hexpand && priv->vexpand))
13721 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_EXPAND]);
13722 g_object_thaw_notify (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
13723}
13724
13725static void
13726ctk_widget_set_expand_set (CtkWidget *widget,
13727 CtkOrientation orientation,
13728 gboolean set)
13729{
13730 CtkWidgetPrivate *priv;
13731 gint prop;
13732
13733 priv = widget->priv;
13734
13735 set = set != FALSE(0);
13736
13737 if (orientation == CTK_ORIENTATION_HORIZONTAL)
13738 {
13739 if (set == priv->hexpand_set)
13740 return;
13741
13742 priv->hexpand_set = set;
13743 prop = PROP_HEXPAND_SET;
13744 }
13745 else
13746 {
13747 if (set == priv->vexpand_set)
13748 return;
13749
13750 priv->vexpand_set = set;
13751 prop = PROP_VEXPAND_SET;
13752 }
13753
13754 ctk_widget_queue_compute_expand (widget);
13755
13756 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[prop]);
13757}
13758
13759/**
13760 * ctk_widget_get_hexpand:
13761 * @widget: the widget
13762 *
13763 * Gets whether the widget would like any available extra horizontal
13764 * space. When a user resizes a #CtkWindow, widgets with expand=TRUE
13765 * generally receive the extra space. For example, a list or
13766 * scrollable area or document in your window would often be set to
13767 * expand.
13768 *
13769 * Containers should use ctk_widget_compute_expand() rather than
13770 * this function, to see whether a widget, or any of its children,
13771 * has the expand flag set. If any child of a widget wants to
13772 * expand, the parent may ask to expand also.
13773 *
13774 * This function only looks at the widget’s own hexpand flag, rather
13775 * than computing whether the entire widget tree rooted at this widget
13776 * wants to expand.
13777 *
13778 * Returns: whether hexpand flag is set
13779 */
13780gboolean
13781ctk_widget_get_hexpand (CtkWidget *widget)
13782{
13783 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
13784
13785 return widget->priv->hexpand;
13786}
13787
13788/**
13789 * ctk_widget_set_hexpand:
13790 * @widget: the widget
13791 * @expand: whether to expand
13792 *
13793 * Sets whether the widget would like any available extra horizontal
13794 * space. When a user resizes a #CtkWindow, widgets with expand=TRUE
13795 * generally receive the extra space. For example, a list or
13796 * scrollable area or document in your window would often be set to
13797 * expand.
13798 *
13799 * Call this function to set the expand flag if you would like your
13800 * widget to become larger horizontally when the window has extra
13801 * room.
13802 *
13803 * By default, widgets automatically expand if any of their children
13804 * want to expand. (To see if a widget will automatically expand given
13805 * its current children and state, call ctk_widget_compute_expand(). A
13806 * container can decide how the expandability of children affects the
13807 * expansion of the container by overriding the compute_expand virtual
13808 * method on #CtkWidget.).
13809 *
13810 * Setting hexpand explicitly with this function will override the
13811 * automatic expand behavior.
13812 *
13813 * This function forces the widget to expand or not to expand,
13814 * regardless of children. The override occurs because
13815 * ctk_widget_set_hexpand() sets the hexpand-set property (see
13816 * ctk_widget_set_hexpand_set()) which causes the widget’s hexpand
13817 * value to be used, rather than looking at children and widget state.
13818 */
13819void
13820ctk_widget_set_hexpand (CtkWidget *widget,
13821 gboolean expand)
13822{
13823 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13824
13825 ctk_widget_set_expand (widget, CTK_ORIENTATION_HORIZONTAL, expand);
13826}
13827
13828/**
13829 * ctk_widget_get_hexpand_set:
13830 * @widget: the widget
13831 *
13832 * Gets whether ctk_widget_set_hexpand() has been used to
13833 * explicitly set the expand flag on this widget.
13834 *
13835 * If hexpand is set, then it overrides any computed
13836 * expand value based on child widgets. If hexpand is not
13837 * set, then the expand value depends on whether any
13838 * children of the widget would like to expand.
13839 *
13840 * There are few reasons to use this function, but it’s here
13841 * for completeness and consistency.
13842 *
13843 * Returns: whether hexpand has been explicitly set
13844 */
13845gboolean
13846ctk_widget_get_hexpand_set (CtkWidget *widget)
13847{
13848 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
13849
13850 return widget->priv->hexpand_set;
13851}
13852
13853/**
13854 * ctk_widget_set_hexpand_set:
13855 * @widget: the widget
13856 * @set: value for hexpand-set property
13857 *
13858 * Sets whether the hexpand flag (see ctk_widget_get_hexpand()) will
13859 * be used.
13860 *
13861 * The hexpand-set property will be set automatically when you call
13862 * ctk_widget_set_hexpand() to set hexpand, so the most likely
13863 * reason to use this function would be to unset an explicit expand
13864 * flag.
13865 *
13866 * If hexpand is set, then it overrides any computed
13867 * expand value based on child widgets. If hexpand is not
13868 * set, then the expand value depends on whether any
13869 * children of the widget would like to expand.
13870 *
13871 * There are few reasons to use this function, but it’s here
13872 * for completeness and consistency.
13873 */
13874void
13875ctk_widget_set_hexpand_set (CtkWidget *widget,
13876 gboolean set)
13877{
13878 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13879
13880 ctk_widget_set_expand_set (widget, CTK_ORIENTATION_HORIZONTAL, set);
13881}
13882
13883
13884/**
13885 * ctk_widget_get_vexpand:
13886 * @widget: the widget
13887 *
13888 * Gets whether the widget would like any available extra vertical
13889 * space.
13890 *
13891 * See ctk_widget_get_hexpand() for more detail.
13892 *
13893 * Returns: whether vexpand flag is set
13894 */
13895gboolean
13896ctk_widget_get_vexpand (CtkWidget *widget)
13897{
13898 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
13899
13900 return widget->priv->vexpand;
13901}
13902
13903/**
13904 * ctk_widget_set_vexpand:
13905 * @widget: the widget
13906 * @expand: whether to expand
13907 *
13908 * Sets whether the widget would like any available extra vertical
13909 * space.
13910 *
13911 * See ctk_widget_set_hexpand() for more detail.
13912 */
13913void
13914ctk_widget_set_vexpand (CtkWidget *widget,
13915 gboolean expand)
13916{
13917 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13918
13919 ctk_widget_set_expand (widget, CTK_ORIENTATION_VERTICAL, expand);
13920}
13921
13922/**
13923 * ctk_widget_get_vexpand_set:
13924 * @widget: the widget
13925 *
13926 * Gets whether ctk_widget_set_vexpand() has been used to
13927 * explicitly set the expand flag on this widget.
13928 *
13929 * See ctk_widget_get_hexpand_set() for more detail.
13930 *
13931 * Returns: whether vexpand has been explicitly set
13932 */
13933gboolean
13934ctk_widget_get_vexpand_set (CtkWidget *widget)
13935{
13936 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
13937
13938 return widget->priv->vexpand_set;
13939}
13940
13941/**
13942 * ctk_widget_set_vexpand_set:
13943 * @widget: the widget
13944 * @set: value for vexpand-set property
13945 *
13946 * Sets whether the vexpand flag (see ctk_widget_get_vexpand()) will
13947 * be used.
13948 *
13949 * See ctk_widget_set_hexpand_set() for more detail.
13950 */
13951void
13952ctk_widget_set_vexpand_set (CtkWidget *widget,
13953 gboolean set)
13954{
13955 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
13956
13957 ctk_widget_set_expand_set (widget, CTK_ORIENTATION_VERTICAL, set);
13958}
13959
13960/*
13961 * CtkBuildable implementation
13962 */
13963static GQuark quark_builder_has_default = 0;
13964static GQuark quark_builder_has_focus = 0;
13965static GQuark quark_builder_atk_relations = 0;
13966static GQuark quark_builder_set_name = 0;
13967
13968static void
13969ctk_widget_buildable_interface_init (CtkBuildableIface *iface)
13970{
13971 quark_builder_has_default = g_quark_from_static_string ("ctk-builder-has-default");
13972 quark_builder_has_focus = g_quark_from_static_string ("ctk-builder-has-focus");
13973 quark_builder_atk_relations = g_quark_from_static_string ("ctk-builder-atk-relations");
13974 quark_builder_set_name = g_quark_from_static_string ("ctk-builder-set-name");
13975
13976 iface->set_name = ctk_widget_buildable_set_name;
13977 iface->get_name = ctk_widget_buildable_get_name;
13978 iface->get_internal_child = ctk_widget_buildable_get_internal_child;
13979 iface->set_buildable_property = ctk_widget_buildable_set_buildable_property;
13980 iface->parser_finished = ctk_widget_buildable_parser_finished;
13981 iface->custom_tag_start = ctk_widget_buildable_custom_tag_start;
13982 iface->custom_finished = ctk_widget_buildable_custom_finished;
13983}
13984
13985static void
13986ctk_widget_buildable_set_name (CtkBuildable *buildable,
13987 const gchar *name)
13988{
13989 g_object_set_qdata_full (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_set_name,
13990 g_strdup (name)g_strdup_inline (name), g_free);
13991}
13992
13993static const gchar *
13994ctk_widget_buildable_get_name (CtkBuildable *buildable)
13995{
13996 return g_object_get_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_set_name);
13997}
13998
13999static GObject *
14000ctk_widget_buildable_get_internal_child (CtkBuildable *buildable,
14001 CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)),
14002 const gchar *childname)
14003{
14004 CtkWidgetClass *class;
14005 GSList *l;
14006 GType internal_child_type = 0;
14007
14008 if (strcmp (childname, "accessible") == 0)
14009 return G_OBJECT (ctk_widget_get_accessible (CTK_WIDGET (buildable)))((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_widget_get_accessible (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((buildable)), ((ctk_widget_get_type ())))
)))))), (((GType) ((20) << (2))))))))
;
14010
14011 /* Find a widget type which has declared an automated child as internal by
14012 * the name 'childname', if any.
14013 */
14014 for (class = CTK_WIDGET_GET_CLASS (buildable)((((CtkWidgetClass*) (((GTypeInstance*) ((buildable)))->g_class
))))
;
14015 CTK_IS_WIDGET_CLASS (class)(((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((class
)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (
!__class) __r = (0); else if (__class->g_type == __t) __r =
(!(0)); else __r = g_type_check_class_is_a (__class, __t); __r
; }))))
;
14016 class = g_type_class_peek_parent (class))
14017 {
14018 CtkWidgetTemplate *template = class->priv->template;
14019
14020 if (!template)
14021 continue;
14022
14023 for (l = template->children; l && internal_child_type == 0; l = l->next)
14024 {
14025 AutomaticChildClass *child_class = l->data;
14026
14027 if (child_class->internal_child && strcmp (childname, child_class->name) == 0)
14028 internal_child_type = G_OBJECT_CLASS_TYPE (class)((((GTypeClass*) (class))->g_type));
14029 }
14030 }
14031
14032 /* Now return the 'internal-child' from the class which declared it, note
14033 * that ctk_widget_get_template_child() an API used to access objects
14034 * which are in the private scope of a given class.
14035 */
14036 if (internal_child_type != 0)
14037 return ctk_widget_get_template_child (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
, internal_child_type, childname);
14038
14039 return NULL((void*)0);
14040}
14041
14042static void
14043ctk_widget_buildable_set_buildable_property (CtkBuildable *buildable,
14044 CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)),
14045 const gchar *name,
14046 const GValue *value)
14047{
14048 if (strcmp (name, "has-default") == 0 && g_value_get_boolean (value))
14049 g_object_set_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_has_default,
14050 GINT_TO_POINTER (TRUE)((gpointer) (glong) ((!(0)))));
14051 else if (strcmp (name, "has-focus") == 0 && g_value_get_boolean (value))
14052 g_object_set_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_has_focus,
14053 GINT_TO_POINTER (TRUE)((gpointer) (glong) ((!(0)))));
14054 else
14055 g_object_set_property (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, name, value);
14056}
14057
14058typedef struct
14059{
14060 gchar *action_name;
14061 GString *description;
14062 gchar *context;
14063 gboolean translatable;
14064} AtkActionData;
14065
14066typedef struct
14067{
14068 gchar *target;
14069 AtkRelationType type;
14070 gint line;
14071 gint col;
14072} AtkRelationData;
14073
14074static void
14075free_action (AtkActionData *data,
14076 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
14077{
14078 g_free (data->action_name);
14079 g_string_free (data->description, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(data->description), ((!(0)))) : g_string_free_and_steal (
data->description)) : (g_string_free) ((data->description
), ((!(0)))))
;
14080 g_free (data->context);
14081 g_slice_free (AtkActionData, data)do { if (1) g_slice_free1 (sizeof (AtkActionData), (data)); else
(void) ((AtkActionData*) 0 == (data)); } while (0)
;
14082}
14083
14084static void
14085free_relation (AtkRelationData *data,
14086 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
14087{
14088 g_free (data->target);
14089 g_slice_free (AtkRelationData, data)do { if (1) g_slice_free1 (sizeof (AtkRelationData), (data));
else (void) ((AtkRelationData*) 0 == (data)); } while (0)
;
14090}
14091
14092static void
14093ctk_widget_buildable_parser_finished (CtkBuildable *buildable,
14094 CtkBuilder *builder)
14095{
14096 GSList *atk_relations;
14097
14098 if (g_object_get_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_has_default))
14099 {
14100 ctk_widget_grab_default (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
);
14101 g_object_steal_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_has_default);
14102 }
14103
14104 if (g_object_get_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_has_focus))
14105 {
14106 ctk_widget_grab_focus (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
);
14107 g_object_steal_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_has_focus);
14108 }
14109
14110 atk_relations = g_object_get_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
,
14111 quark_builder_atk_relations);
14112 if (atk_relations)
14113 {
14114 AtkObject *accessible;
14115 AtkRelationSet *relation_set;
14116 GSList *l;
14117 GObject *target;
14118 AtkObject *target_accessible;
14119
14120 accessible = ctk_widget_get_accessible (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
);
14121 relation_set = atk_object_ref_relation_set (accessible);
14122
14123 for (l = atk_relations; l; l = l->next)
14124 {
14125 AtkRelationData *relation = (AtkRelationData*)l->data;
14126
14127 target = _ctk_builder_lookup_object (builder, relation->target, relation->line, relation->col);
14128 if (!target)
14129 continue;
14130 target_accessible = ctk_widget_get_accessible (CTK_WIDGET (target)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((target)), ((ctk_widget_get_type ()))))))
);
14131 g_assert (target_accessible != NULL)do { if (target_accessible != ((void*)0)) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 14131, ((const char*) (__func__)), "target_accessible != NULL"
); } while (0)
;
14132
14133 atk_relation_set_add_relation_by_type (relation_set, relation->type, target_accessible);
14134 }
14135 g_object_unref (relation_set);
14136
14137 g_slist_free_full (atk_relations, (GDestroyNotify) free_relation);
14138 g_object_steal_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_atk_relations);
14139 }
14140}
14141
14142typedef struct
14143{
14144 CtkBuilder *builder;
14145 GSList *actions;
14146 GSList *relations;
14147} AccessibilitySubParserData;
14148
14149static void
14150accessibility_start_element (GMarkupParseContext *context,
14151 const gchar *element_name,
14152 const gchar **names,
14153 const gchar **values,
14154 gpointer user_data,
14155 GError **error)
14156{
14157 AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
14158
14159 if (strcmp (element_name, "relation") == 0)
14160 {
14161 gchar *target = NULL((void*)0);
14162 gchar *type = NULL((void*)0);
14163 AtkRelationData *relation;
14164 AtkRelationType relation_type;
14165
14166 if (!_ctk_builder_check_parent (data->builder, context, "accessibility", error))
14167 return;
14168
14169 if (!g_markup_collect_attributes (element_name, names, values, error,
14170 G_MARKUP_COLLECT_STRING, "target", &target,
14171 G_MARKUP_COLLECT_STRING, "type", &type,
14172 G_MARKUP_COLLECT_INVALID))
14173 {
14174 _ctk_builder_prefix_error (data->builder, context, error);
14175 return;
14176 }
14177
14178 relation_type = atk_relation_type_for_name (type);
14179 if (relation_type == ATK_RELATION_NULL)
14180 {
14181 g_set_error (error,
14182 CTK_BUILDER_ERROR(ctk_builder_error_quark ()),
14183 CTK_BUILDER_ERROR_INVALID_VALUE,
14184 "No such relation type: '%s'", type);
14185 _ctk_builder_prefix_error (data->builder, context, error);
14186 return;
14187 }
14188
14189 relation = g_slice_new (AtkRelationData)((AtkRelationData*) g_slice_alloc ((sizeof (AtkRelationData) >
0 ? sizeof (AtkRelationData) : 1)))
;
14190 relation->target = g_strdup (target)g_strdup_inline (target);
14191 relation->type = relation_type;
14192
14193 data->relations = g_slist_prepend (data->relations, relation);
14194 }
14195 else if (strcmp (element_name, "action") == 0)
14196 {
14197 const gchar *action_name;
14198 const gchar *description = NULL((void*)0);
14199 const gchar *msg_context = NULL((void*)0);
14200 gboolean translatable = FALSE(0);
14201 AtkActionData *action;
14202
14203 if (!_ctk_builder_check_parent (data->builder, context, "accessibility", error))
14204 return;
14205
14206 if (!g_markup_collect_attributes (element_name, names, values, error,
14207 G_MARKUP_COLLECT_STRING, "action_name", &action_name,
14208 G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "description", &description,
14209 G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "comments", NULL((void*)0),
14210 G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &msg_context,
14211 G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable", &translatable,
14212 G_MARKUP_COLLECT_INVALID))
14213 {
14214 _ctk_builder_prefix_error (data->builder, context, error);
14215 return;
14216 }
14217
14218 action = g_slice_new (AtkActionData)((AtkActionData*) g_slice_alloc ((sizeof (AtkActionData) >
0 ? sizeof (AtkActionData) : 1)))
;
14219 action->action_name = g_strdup (action_name)g_strdup_inline (action_name);
14220 action->description = g_string_new (description);
14221 action->context = g_strdup (msg_context)g_strdup_inline (msg_context);
14222 action->translatable = translatable;
14223
14224 data->actions = g_slist_prepend (data->actions, action);
14225 }
14226 else if (strcmp (element_name, "accessibility") == 0)
14227 {
14228 if (!_ctk_builder_check_parent (data->builder, context, "object", error))
14229 return;
14230
14231 if (!g_markup_collect_attributes (element_name, names, values, error,
14232 G_MARKUP_COLLECT_INVALID, NULL((void*)0), NULL((void*)0),
14233 G_MARKUP_COLLECT_INVALID))
14234 _ctk_builder_prefix_error (data->builder, context, error);
14235 }
14236 else
14237 {
14238 _ctk_builder_error_unhandled_tag (data->builder, context,
14239 "CtkWidget", element_name,
14240 error);
14241 }
14242}
14243
14244static void
14245accessibility_text (GMarkupParseContext *context,
14246 const gchar *text,
14247 gsize text_len,
14248 gpointer user_data,
14249 GError **error G_GNUC_UNUSED__attribute__ ((__unused__)))
14250{
14251 AccessibilitySubParserData *data = (AccessibilitySubParserData*)user_data;
14252
14253 if (strcmp (g_markup_parse_context_get_element (context), "action") == 0)
14254 {
14255 AtkActionData *action = data->actions->data;
14256
14257 g_string_append_len (action->description, text, text_len)g_string_append_len_inline (action->description, text, text_len
)
;
14258 }
14259}
14260
14261static const GMarkupParser accessibility_parser =
14262 {
14263 .start_element = accessibility_start_element,
14264 .text = accessibility_text,
14265 };
14266
14267typedef struct
14268{
14269 GObject *object;
14270 CtkBuilder *builder;
14271 guint key;
14272 guint modifiers;
14273 gchar *signal;
14274} AccelGroupParserData;
14275
14276static void
14277accel_group_start_element (GMarkupParseContext *context,
14278 const gchar *element_name,
14279 const gchar **names,
14280 const gchar **values,
14281 gpointer user_data,
14282 GError **error)
14283{
14284 AccelGroupParserData *data = (AccelGroupParserData*)user_data;
14285
14286 if (strcmp (element_name, "accelerator") == 0)
14287 {
14288 const gchar *key_str = NULL((void*)0);
14289 const gchar *signal = NULL((void*)0);
14290 const gchar *modifiers_str = NULL((void*)0);
14291 guint key = 0;
14292 guint modifiers = 0;
14293
14294 if (!_ctk_builder_check_parent (data->builder, context, "object", error))
14295 return;
14296
14297 if (!g_markup_collect_attributes (element_name, names, values, error,
14298 G_MARKUP_COLLECT_STRING, "key", &key_str,
14299 G_MARKUP_COLLECT_STRING, "signal", &signal,
14300 G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "modifiers", &modifiers_str,
14301 G_MARKUP_COLLECT_INVALID))
14302 {
14303 _ctk_builder_prefix_error (data->builder, context, error);
14304 return;
14305 }
14306
14307 key = cdk_keyval_from_name (key_str);
14308 if (key == 0)
14309 {
14310 g_set_error (error,
14311 CTK_BUILDER_ERROR(ctk_builder_error_quark ()), CTK_BUILDER_ERROR_INVALID_VALUE,
14312 "Could not parse key '%s'", key_str);
14313 _ctk_builder_prefix_error (data->builder, context, error);
14314 return;
14315 }
14316
14317 if (modifiers_str != NULL((void*)0))
14318 {
14319 GFlagsValue aliases[2] = {
14320 { 0, "primary", "primary" },
14321 { 0, NULL((void*)0), NULL((void*)0) }
14322 };
14323
14324 aliases[0].value = _ctk_get_primary_accel_mod ();
14325
14326 if (!_ctk_builder_flags_from_string (CDK_TYPE_MODIFIER_TYPE(cdk_modifier_type_get_type ()), aliases,
14327 modifiers_str, &modifiers, error))
14328 {
14329 _ctk_builder_prefix_error (data->builder, context, error);
14330 return;
14331 }
14332 }
14333
14334 data->key = key;
14335 data->modifiers = modifiers;
14336 data->signal = g_strdup (signal)g_strdup_inline (signal);
14337 }
14338 else
14339 {
14340 _ctk_builder_error_unhandled_tag (data->builder, context,
14341 "CtkWidget", element_name,
14342 error);
14343 }
14344}
14345
14346static const GMarkupParser accel_group_parser =
14347 {
14348 .start_element = accel_group_start_element,
14349 };
14350
14351typedef struct
14352{
14353 CtkBuilder *builder;
14354 GSList *classes;
14355} StyleParserData;
14356
14357static void
14358style_start_element (GMarkupParseContext *context,
14359 const gchar *element_name,
14360 const gchar **names,
14361 const gchar **values,
14362 gpointer user_data,
14363 GError **error)
14364{
14365 StyleParserData *data = (StyleParserData *)user_data;
14366
14367 if (strcmp (element_name, "class") == 0)
14368 {
14369 const gchar *name;
14370
14371 if (!_ctk_builder_check_parent (data->builder, context, "style", error))
14372 return;
14373
14374 if (!g_markup_collect_attributes (element_name, names, values, error,
14375 G_MARKUP_COLLECT_STRING, "name", &name,
14376 G_MARKUP_COLLECT_INVALID))
14377 {
14378 _ctk_builder_prefix_error (data->builder, context, error);
14379 return;
14380 }
14381
14382 data->classes = g_slist_prepend (data->classes, g_strdup (name)g_strdup_inline (name));
14383 }
14384 else if (strcmp (element_name, "style") == 0)
14385 {
14386 if (!_ctk_builder_check_parent (data->builder, context, "object", error))
14387 return;
14388
14389 if (!g_markup_collect_attributes (element_name, names, values, error,
14390 G_MARKUP_COLLECT_INVALID, NULL((void*)0), NULL((void*)0),
14391 G_MARKUP_COLLECT_INVALID))
14392 _ctk_builder_prefix_error (data->builder, context, error);
14393 }
14394 else
14395 {
14396 _ctk_builder_error_unhandled_tag (data->builder, context,
14397 "CtkWidget", element_name,
14398 error);
14399 }
14400}
14401
14402static const GMarkupParser style_parser =
14403 {
14404 .start_element = style_start_element,
14405 };
14406
14407static gboolean
14408ctk_widget_buildable_custom_tag_start (CtkBuildable *buildable,
14409 CtkBuilder *builder,
14410 GObject *child G_GNUC_UNUSED__attribute__ ((__unused__)),
14411 const gchar *tagname,
14412 GMarkupParser *parser,
14413 gpointer *parser_data)
14414{
14415 if (strcmp (tagname, "accelerator") == 0)
14416 {
14417 AccelGroupParserData *data;
14418
14419 data = g_slice_new0 (AccelGroupParserData)((AccelGroupParserData*) g_slice_alloc0 ((sizeof (AccelGroupParserData
) > 0 ? sizeof (AccelGroupParserData) : 1)))
;
14420 data->object = G_OBJECT (g_object_ref (buildable))((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((__typeof__ (buildable)) (g_object_ref) (buildable)))),
(((GType) ((20) << (2))))))))
;
14421 data->builder = builder;
14422
14423 *parser = accel_group_parser;
14424 *parser_data = data;
14425
14426 return TRUE(!(0));
14427 }
14428
14429 if (strcmp (tagname, "accessibility") == 0)
14430 {
14431 AccessibilitySubParserData *data;
14432
14433 data = g_slice_new0 (AccessibilitySubParserData)((AccessibilitySubParserData*) g_slice_alloc0 ((sizeof (AccessibilitySubParserData
) > 0 ? sizeof (AccessibilitySubParserData) : 1)))
;
14434 data->builder = builder;
14435
14436 *parser = accessibility_parser;
14437 *parser_data = data;
14438
14439 return TRUE(!(0));
14440 }
14441
14442 if (strcmp (tagname, "style") == 0)
14443 {
14444 StyleParserData *data;
14445
14446 data = g_slice_new0 (StyleParserData)((StyleParserData*) g_slice_alloc0 ((sizeof (StyleParserData)
> 0 ? sizeof (StyleParserData) : 1)))
;
14447 data->builder = builder;
14448
14449 *parser = style_parser;
14450 *parser_data = data;
14451
14452 return TRUE(!(0));
14453 }
14454
14455 return FALSE(0);
14456}
14457
14458void
14459_ctk_widget_buildable_finish_accelerator (CtkWidget *widget,
14460 CtkWidget *toplevel,
14461 gpointer user_data)
14462{
14463 AccelGroupParserData *accel_data;
14464 GSList *accel_groups;
14465 CtkAccelGroup *accel_group;
14466
14467 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14468 g_return_if_fail (CTK_IS_WIDGET (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (toplevel)"); return; } } while (0)
;
14469 g_return_if_fail (user_data != NULL)do { if ((user_data != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "user_data != NULL"); return
; } } while (0)
;
14470
14471 accel_data = (AccelGroupParserData*)user_data;
14472 accel_groups = ctk_accel_groups_from_object (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
14473 if (g_slist_length (accel_groups) == 0)
14474 {
14475 accel_group = ctk_accel_group_new ();
14476 ctk_window_add_accel_group (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
, accel_group);
14477 }
14478 else
14479 {
14480 g_assert (g_slist_length (accel_groups) == 1)do { if (g_slist_length (accel_groups) == 1) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 14480, ((const char*) (__func__)), "g_slist_length (accel_groups) == 1"
); } while (0)
;
14481 accel_group = g_slist_nth_data (accel_groups, 0);
14482 }
14483
14484 ctk_widget_add_accelerator (CTK_WIDGET (accel_data->object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((accel_data->object)), ((ctk_widget_get_type ()))))))
,
14485 accel_data->signal,
14486 accel_group,
14487 accel_data->key,
14488 accel_data->modifiers,
14489 CTK_ACCEL_VISIBLE);
14490
14491 g_object_unref (accel_data->object);
14492 g_free (accel_data->signal);
14493 g_slice_free (AccelGroupParserData, accel_data)do { if (1) g_slice_free1 (sizeof (AccelGroupParserData), (accel_data
)); else (void) ((AccelGroupParserData*) 0 == (accel_data)); }
while (0)
;
14494}
14495
14496static void
14497ctk_widget_buildable_custom_finished (CtkBuildable *buildable,
14498 CtkBuilder *builder,
14499 GObject *child G_GNUC_UNUSED__attribute__ ((__unused__)),
14500 const gchar *tagname,
14501 gpointer user_data)
14502{
14503 if (strcmp (tagname, "accelerator") == 0)
14504 {
14505 AccelGroupParserData *accel_data;
14506 CtkWidget *toplevel;
14507
14508 accel_data = (AccelGroupParserData*)user_data;
14509 g_assert (accel_data->object)do { if (accel_data->object) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 14509, ((const char*) (__func__)), "accel_data->object"
); } while (0)
;
14510
14511 toplevel = _ctk_widget_get_toplevel (CTK_WIDGET (accel_data->object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((accel_data->object)), ((ctk_widget_get_type ()))))))
);
14512
14513 _ctk_widget_buildable_finish_accelerator (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
, toplevel, user_data);
14514 }
14515 else if (strcmp (tagname, "accessibility") == 0)
14516 {
14517 AccessibilitySubParserData *a11y_data;
14518
14519 a11y_data = (AccessibilitySubParserData*)user_data;
14520
14521 if (a11y_data->actions)
14522 {
14523 AtkObject *accessible;
14524 AtkAction *action;
14525 gint i, n_actions;
14526 GSList *l;
14527
14528 accessible = ctk_widget_get_accessible (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
);
14529
14530 if (ATK_IS_ACTION (accessible)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(accessible)); GType __t = ((atk_action_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; })))
)
14531 {
14532 action = ATK_ACTION (accessible)(((AtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((accessible)), ((atk_action_get_type ())))))
;
14533 n_actions = atk_action_get_n_actions (action);
14534
14535 for (l = a11y_data->actions; l; l = l->next)
14536 {
14537 AtkActionData *action_data = (AtkActionData*)l->data;
14538
14539 for (i = 0; i < n_actions; i++)
14540 if (strcmp (atk_action_get_name (action, i),
14541 action_data->action_name) == 0)
14542 break;
14543
14544 if (i < n_actions)
14545 {
14546 const gchar *description;
14547
14548 if (action_data->translatable && action_data->description->len)
14549 description = _ctk_builder_parser_translate (ctk_builder_get_translation_domain (builder),
14550 action_data->context,
14551 action_data->description->str);
14552 else
14553 description = action_data->description->str;
14554
14555 atk_action_set_description (action, i, description);
14556 }
14557 }
14558 }
14559 else
14560 g_warning ("accessibility action on a widget that does not implement AtkAction");
14561
14562 g_slist_free_full (a11y_data->actions, (GDestroyNotify) free_action);
14563 }
14564
14565 if (a11y_data->relations)
14566 g_object_set_qdata (G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), (((GType) ((20) << (2))))))))
, quark_builder_atk_relations,
14567 a11y_data->relations);
14568
14569 g_slice_free (AccessibilitySubParserData, a11y_data)do { if (1) g_slice_free1 (sizeof (AccessibilitySubParserData
), (a11y_data)); else (void) ((AccessibilitySubParserData*) 0
== (a11y_data)); } while (0)
;
14570 }
14571 else if (strcmp (tagname, "style") == 0)
14572 {
14573 StyleParserData *style_data = (StyleParserData *)user_data;
14574 CtkStyleContext *context;
14575 GSList *l;
14576
14577 context = _ctk_widget_get_style_context (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
);
14578
14579 for (l = style_data->classes; l; l = l->next)
14580 ctk_style_context_add_class (context, (const gchar *)l->data);
14581
14582 ctk_widget_reset_style (CTK_WIDGET (buildable)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_widget_get_type ()))))))
);
14583
14584 g_slist_free_full (style_data->classes, g_free);
14585 g_slice_free (StyleParserData, style_data)do { if (1) g_slice_free1 (sizeof (StyleParserData), (style_data
)); else (void) ((StyleParserData*) 0 == (style_data)); } while
(0)
;
14586 }
14587}
14588
14589static CtkSizeRequestMode
14590ctk_widget_real_get_request_mode (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)))
14591{
14592 /* By default widgets don't trade size at all. */
14593 return CTK_SIZE_REQUEST_CONSTANT_SIZE;
14594}
14595
14596static void
14597ctk_widget_real_get_width (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
14598 gint *minimum_size,
14599 gint *natural_size)
14600{
14601 *minimum_size = 0;
14602 *natural_size = 0;
14603}
14604
14605static void
14606ctk_widget_real_get_height (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
14607 gint *minimum_size,
14608 gint *natural_size)
14609{
14610 *minimum_size = 0;
14611 *natural_size = 0;
14612}
14613
14614static void
14615ctk_widget_real_get_height_for_width (CtkWidget *widget,
14616 gint width G_GNUC_UNUSED__attribute__ ((__unused__)),
14617 gint *minimum_height,
14618 gint *natural_height)
14619{
14620 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->get_preferred_height (widget, minimum_height, natural_height);
14621}
14622
14623static void
14624ctk_widget_real_get_width_for_height (CtkWidget *widget,
14625 gint height G_GNUC_UNUSED__attribute__ ((__unused__)),
14626 gint *minimum_width,
14627 gint *natural_width)
14628{
14629 CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->get_preferred_width (widget, minimum_width, natural_width);
14630}
14631
14632/**
14633 * ctk_widget_get_halign:
14634 * @widget: a #CtkWidget
14635 *
14636 * Gets the value of the #CtkWidget:halign property.
14637 *
14638 * For backwards compatibility reasons this method will never return
14639 * %CTK_ALIGN_BASELINE, but instead it will convert it to
14640 * %CTK_ALIGN_FILL. Baselines are not supported for horizontal
14641 * alignment.
14642 *
14643 * Returns: the horizontal alignment of @widget
14644 */
14645CtkAlign
14646ctk_widget_get_halign (CtkWidget *widget)
14647{
14648 CtkAlign align;
14649
14650 g_return_val_if_fail (CTK_IS_WIDGET (widget), CTK_ALIGN_FILL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (CTK_ALIGN_FILL); } } while
(0)
;
14651
14652 align = widget->priv->halign;
14653 if (align == CTK_ALIGN_BASELINE)
14654 return CTK_ALIGN_FILL;
14655 return align;
14656}
14657
14658/**
14659 * ctk_widget_set_halign:
14660 * @widget: a #CtkWidget
14661 * @align: the horizontal alignment
14662 *
14663 * Sets the horizontal alignment of @widget.
14664 * See the #CtkWidget:halign property.
14665 */
14666void
14667ctk_widget_set_halign (CtkWidget *widget,
14668 CtkAlign align)
14669{
14670 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14671
14672 if (widget->priv->halign == align)
14673 return;
14674
14675 widget->priv->halign = align;
14676 ctk_widget_queue_allocate (widget);
14677 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_HALIGN]);
14678}
14679
14680/**
14681 * ctk_widget_get_valign_with_baseline:
14682 * @widget: a #CtkWidget
14683 *
14684 * Gets the value of the #CtkWidget:valign property, including
14685 * %CTK_ALIGN_BASELINE.
14686 *
14687 * Returns: the vertical alignment of @widget
14688 *
14689 * Since: 3.10
14690 */
14691CtkAlign
14692ctk_widget_get_valign_with_baseline (CtkWidget *widget)
14693{
14694 g_return_val_if_fail (CTK_IS_WIDGET (widget), CTK_ALIGN_FILL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (CTK_ALIGN_FILL); } } while
(0)
;
14695 return widget->priv->valign;
14696}
14697
14698/**
14699 * ctk_widget_get_valign:
14700 * @widget: a #CtkWidget
14701 *
14702 * Gets the value of the #CtkWidget:valign property.
14703 *
14704 * For backwards compatibility reasons this method will never return
14705 * %CTK_ALIGN_BASELINE, but instead it will convert it to
14706 * %CTK_ALIGN_FILL. If your widget want to support baseline aligned
14707 * children it must use ctk_widget_get_valign_with_baseline(), or
14708 * `g_object_get (widget, "valign", &value, NULL)`, which will
14709 * also report the true value.
14710 *
14711 * Returns: the vertical alignment of @widget, ignoring baseline alignment
14712 */
14713CtkAlign
14714ctk_widget_get_valign (CtkWidget *widget)
14715{
14716 CtkAlign align;
14717
14718 align = ctk_widget_get_valign_with_baseline (widget);
14719 if (align == CTK_ALIGN_BASELINE)
14720 return CTK_ALIGN_FILL;
14721 return align;
14722}
14723
14724/**
14725 * ctk_widget_set_valign:
14726 * @widget: a #CtkWidget
14727 * @align: the vertical alignment
14728 *
14729 * Sets the vertical alignment of @widget.
14730 * See the #CtkWidget:valign property.
14731 */
14732void
14733ctk_widget_set_valign (CtkWidget *widget,
14734 CtkAlign align)
14735{
14736 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14737
14738 if (widget->priv->valign == align)
14739 return;
14740
14741 widget->priv->valign = align;
14742 ctk_widget_queue_allocate (widget);
14743 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_VALIGN]);
14744}
14745
14746/**
14747 * ctk_widget_get_margin_left:
14748 * @widget: a #CtkWidget
14749 *
14750 * Gets the value of the #CtkWidget:margin-left property.
14751 *
14752 * Returns: The left margin of @widget
14753 *
14754 * Deprecated: 3.12: Use ctk_widget_get_margin_start() instead.
14755 *
14756 * Since: 3.0
14757 */
14758gint
14759ctk_widget_get_margin_left (CtkWidget *widget)
14760{
14761 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
14762
14763 return widget->priv->margin.left;
14764}
14765
14766/**
14767 * ctk_widget_set_margin_left:
14768 * @widget: a #CtkWidget
14769 * @margin: the left margin
14770 *
14771 * Sets the left margin of @widget.
14772 * See the #CtkWidget:margin-left property.
14773 *
14774 * Deprecated: 3.12: Use ctk_widget_set_margin_start() instead.
14775 *
14776 * Since: 3.0
14777 */
14778void
14779ctk_widget_set_margin_left (CtkWidget *widget,
14780 gint margin)
14781{
14782 gboolean rtl;
14783
14784 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14785 g_return_if_fail (margin <= G_MAXINT16)do { if ((margin <= ((gint16) 0x7fff))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "margin <= G_MAXINT16"
); return; } } while (0)
;
14786
14787 rtl = _ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL;
14788
14789 if (widget->priv->margin.left == margin)
14790 return;
14791
14792 widget->priv->margin.left = margin;
14793 ctk_widget_queue_resize (widget);
14794 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_MARGIN_LEFT]);
14795 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[rtl ? PROP_MARGIN_END : PROP_MARGIN_START]);
14796}
14797
14798/**
14799 * ctk_widget_get_margin_right:
14800 * @widget: a #CtkWidget
14801 *
14802 * Gets the value of the #CtkWidget:margin-right property.
14803 *
14804 * Returns: The right margin of @widget
14805 *
14806 * Deprecated: 3.12: Use ctk_widget_get_margin_end() instead.
14807 *
14808 * Since: 3.0
14809 */
14810gint
14811ctk_widget_get_margin_right (CtkWidget *widget)
14812{
14813 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
14814
14815 return widget->priv->margin.right;
14816}
14817
14818/**
14819 * ctk_widget_set_margin_right:
14820 * @widget: a #CtkWidget
14821 * @margin: the right margin
14822 *
14823 * Sets the right margin of @widget.
14824 * See the #CtkWidget:margin-right property.
14825 *
14826 * Deprecated: 3.12: Use ctk_widget_set_margin_end() instead.
14827 *
14828 * Since: 3.0
14829 */
14830void
14831ctk_widget_set_margin_right (CtkWidget *widget,
14832 gint margin)
14833{
14834 gboolean rtl;
14835
14836 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14837 g_return_if_fail (margin <= G_MAXINT16)do { if ((margin <= ((gint16) 0x7fff))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "margin <= G_MAXINT16"
); return; } } while (0)
;
14838
14839 rtl = _ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL;
14840
14841 if (widget->priv->margin.right == margin)
14842 return;
14843
14844 widget->priv->margin.right = margin;
14845 ctk_widget_queue_resize (widget);
14846 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_MARGIN_RIGHT]);
14847 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[rtl ? PROP_MARGIN_START : PROP_MARGIN_END]);
14848}
14849
14850/**
14851 * ctk_widget_get_margin_start:
14852 * @widget: a #CtkWidget
14853 *
14854 * Gets the value of the #CtkWidget:margin-start property.
14855 *
14856 * Returns: The start margin of @widget
14857 *
14858 * Since: 3.12
14859 */
14860gint
14861ctk_widget_get_margin_start (CtkWidget *widget)
14862{
14863 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
14864
14865 if (_ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL)
14866 return widget->priv->margin.right;
14867 else
14868 return widget->priv->margin.left;
14869}
14870
14871/**
14872 * ctk_widget_set_margin_start:
14873 * @widget: a #CtkWidget
14874 * @margin: the start margin
14875 *
14876 * Sets the start margin of @widget.
14877 * See the #CtkWidget:margin-start property.
14878 *
14879 * Since: 3.12
14880 */
14881void
14882ctk_widget_set_margin_start (CtkWidget *widget,
14883 gint margin)
14884{
14885 gint16 *start;
14886 gboolean rtl;
14887
14888 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14889 g_return_if_fail (margin <= G_MAXINT16)do { if ((margin <= ((gint16) 0x7fff))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "margin <= G_MAXINT16"
); return; } } while (0)
;
14890
14891 rtl = _ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL;
14892
14893 if (rtl)
14894 start = &widget->priv->margin.right;
14895 else
14896 start = &widget->priv->margin.left;
14897
14898 if (*start == margin)
14899 return;
14900
14901 *start = margin;
14902 ctk_widget_queue_resize (widget);
14903 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_MARGIN_START]);
14904 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[rtl ? PROP_MARGIN_RIGHT : PROP_MARGIN_LEFT]);
14905}
14906
14907/**
14908 * ctk_widget_get_margin_end:
14909 * @widget: a #CtkWidget
14910 *
14911 * Gets the value of the #CtkWidget:margin-end property.
14912 *
14913 * Returns: The end margin of @widget
14914 *
14915 * Since: 3.12
14916 */
14917gint
14918ctk_widget_get_margin_end (CtkWidget *widget)
14919{
14920 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
14921
14922 if (_ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL)
14923 return widget->priv->margin.left;
14924 else
14925 return widget->priv->margin.right;
14926}
14927
14928/**
14929 * ctk_widget_set_margin_end:
14930 * @widget: a #CtkWidget
14931 * @margin: the end margin
14932 *
14933 * Sets the end margin of @widget.
14934 * See the #CtkWidget:margin-end property.
14935 *
14936 * Since: 3.12
14937 */
14938void
14939ctk_widget_set_margin_end (CtkWidget *widget,
14940 gint margin)
14941{
14942 gint16 *end;
14943 gboolean rtl;
14944
14945 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14946 g_return_if_fail (margin <= G_MAXINT16)do { if ((margin <= ((gint16) 0x7fff))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "margin <= G_MAXINT16"
); return; } } while (0)
;
14947
14948 rtl = _ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL;
14949
14950 if (rtl)
14951 end = &widget->priv->margin.left;
14952 else
14953 end = &widget->priv->margin.right;
14954
14955 if (*end == margin)
14956 return;
14957
14958 *end = margin;
14959 ctk_widget_queue_resize (widget);
14960 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_MARGIN_END]);
14961 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[rtl ? PROP_MARGIN_LEFT : PROP_MARGIN_RIGHT]);
14962}
14963
14964/**
14965 * ctk_widget_get_margin_top:
14966 * @widget: a #CtkWidget
14967 *
14968 * Gets the value of the #CtkWidget:margin-top property.
14969 *
14970 * Returns: The top margin of @widget
14971 *
14972 * Since: 3.0
14973 */
14974gint
14975ctk_widget_get_margin_top (CtkWidget *widget)
14976{
14977 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
14978
14979 return widget->priv->margin.top;
14980}
14981
14982/**
14983 * ctk_widget_set_margin_top:
14984 * @widget: a #CtkWidget
14985 * @margin: the top margin
14986 *
14987 * Sets the top margin of @widget.
14988 * See the #CtkWidget:margin-top property.
14989 *
14990 * Since: 3.0
14991 */
14992void
14993ctk_widget_set_margin_top (CtkWidget *widget,
14994 gint margin)
14995{
14996 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
14997 g_return_if_fail (margin <= G_MAXINT16)do { if ((margin <= ((gint16) 0x7fff))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "margin <= G_MAXINT16"
); return; } } while (0)
;
14998
14999 if (widget->priv->margin.top == margin)
15000 return;
15001
15002 widget->priv->margin.top = margin;
15003 ctk_widget_queue_resize (widget);
15004 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_MARGIN_TOP]);
15005}
15006
15007/**
15008 * ctk_widget_get_margin_bottom:
15009 * @widget: a #CtkWidget
15010 *
15011 * Gets the value of the #CtkWidget:margin-bottom property.
15012 *
15013 * Returns: The bottom margin of @widget
15014 *
15015 * Since: 3.0
15016 */
15017gint
15018ctk_widget_get_margin_bottom (CtkWidget *widget)
15019{
15020 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
15021
15022 return widget->priv->margin.bottom;
15023}
15024
15025/**
15026 * ctk_widget_set_margin_bottom:
15027 * @widget: a #CtkWidget
15028 * @margin: the bottom margin
15029 *
15030 * Sets the bottom margin of @widget.
15031 * See the #CtkWidget:margin-bottom property.
15032 *
15033 * Since: 3.0
15034 */
15035void
15036ctk_widget_set_margin_bottom (CtkWidget *widget,
15037 gint margin)
15038{
15039 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15040 g_return_if_fail (margin <= G_MAXINT16)do { if ((margin <= ((gint16) 0x7fff))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "margin <= G_MAXINT16"
); return; } } while (0)
;
15041
15042 if (widget->priv->margin.bottom == margin)
15043 return;
15044
15045 widget->priv->margin.bottom = margin;
15046 ctk_widget_queue_resize (widget);
15047 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_MARGIN_BOTTOM]);
15048}
15049
15050/**
15051 * ctk_widget_get_clipboard:
15052 * @widget: a #CtkWidget
15053 * @selection: a #CdkAtom which identifies the clipboard
15054 * to use. %CDK_SELECTION_CLIPBOARD gives the
15055 * default clipboard. Another common value
15056 * is %CDK_SELECTION_PRIMARY, which gives
15057 * the primary X selection.
15058 *
15059 * Returns the clipboard object for the given selection to
15060 * be used with @widget. @widget must have a #CdkDisplay
15061 * associated with it, so must be attached to a toplevel
15062 * window.
15063 *
15064 * Returns: (transfer none): the appropriate clipboard object. If no
15065 * clipboard already exists, a new one will
15066 * be created. Once a clipboard object has
15067 * been created, it is persistent for all time.
15068 *
15069 * Since: 2.2
15070 **/
15071CtkClipboard *
15072ctk_widget_get_clipboard (CtkWidget *widget, CdkAtom selection)
15073{
15074 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
15075 g_return_val_if_fail (ctk_widget_has_screen (widget), NULL)do { if ((ctk_widget_has_screen (widget))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "ctk_widget_has_screen (widget)"
); return (((void*)0)); } } while (0)
;
15076
15077 return ctk_clipboard_get_for_display (ctk_widget_get_display (widget),
15078 selection);
15079}
15080
15081/**
15082 * ctk_widget_list_mnemonic_labels:
15083 * @widget: a #CtkWidget
15084 *
15085 * Returns a newly allocated list of the widgets, normally labels, for
15086 * which this widget is the target of a mnemonic (see for example,
15087 * ctk_label_set_mnemonic_widget()).
15088
15089 * The widgets in the list are not individually referenced. If you
15090 * want to iterate through the list and perform actions involving
15091 * callbacks that might destroy the widgets, you
15092 * must call `g_list_foreach (result,
15093 * (GFunc)g_object_ref, NULL)` first, and then unref all the
15094 * widgets afterwards.
15095
15096 * Returns: (element-type CtkWidget) (transfer container): the list of
15097 * mnemonic labels; free this list
15098 * with g_list_free() when you are done with it.
15099 *
15100 * Since: 2.4
15101 **/
15102GList *
15103ctk_widget_list_mnemonic_labels (CtkWidget *widget)
15104{
15105 GList *list = NULL((void*)0);
15106 GSList *l;
15107
15108 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
15109
15110 for (l = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_mnemonic_labels); l; l = l->next)
15111 list = g_list_prepend (list, l->data);
15112
15113 return list;
15114}
15115
15116/**
15117 * ctk_widget_add_mnemonic_label:
15118 * @widget: a #CtkWidget
15119 * @label: a #CtkWidget that acts as a mnemonic label for @widget
15120 *
15121 * Adds a widget to the list of mnemonic labels for
15122 * this widget. (See ctk_widget_list_mnemonic_labels()). Note the
15123 * list of mnemonic labels for the widget is cleared when the
15124 * widget is destroyed, so the caller must make sure to update
15125 * its internal state at this point as well, by using a connection
15126 * to the #CtkWidget::destroy signal or a weak notifier.
15127 *
15128 * Since: 2.4
15129 **/
15130void
15131ctk_widget_add_mnemonic_label (CtkWidget *widget,
15132 CtkWidget *label)
15133{
15134 GSList *old_list, *new_list;
15135
15136 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15137 g_return_if_fail (CTK_IS_WIDGET (label))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((label)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (label)"); return; } } while (0)
;
15138
15139 old_list = g_object_steal_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_mnemonic_labels);
15140 new_list = g_slist_prepend (old_list, label);
15141
15142 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_mnemonic_labels,
15143 new_list, (GDestroyNotify) g_slist_free);
15144}
15145
15146/**
15147 * ctk_widget_remove_mnemonic_label:
15148 * @widget: a #CtkWidget
15149 * @label: a #CtkWidget that was previously set as a mnemonic label for
15150 * @widget with ctk_widget_add_mnemonic_label().
15151 *
15152 * Removes a widget from the list of mnemonic labels for
15153 * this widget. (See ctk_widget_list_mnemonic_labels()). The widget
15154 * must have previously been added to the list with
15155 * ctk_widget_add_mnemonic_label().
15156 *
15157 * Since: 2.4
15158 **/
15159void
15160ctk_widget_remove_mnemonic_label (CtkWidget *widget,
15161 CtkWidget *label)
15162{
15163 GSList *old_list, *new_list;
15164
15165 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15166 g_return_if_fail (CTK_IS_WIDGET (label))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((label)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (label)"); return; } } while (0)
;
15167
15168 old_list = g_object_steal_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_mnemonic_labels);
15169 new_list = g_slist_remove (old_list, label);
15170
15171 if (new_list)
15172 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_mnemonic_labels,
15173 new_list, (GDestroyNotify) g_slist_free);
15174}
15175
15176/**
15177 * ctk_widget_get_no_show_all:
15178 * @widget: a #CtkWidget
15179 *
15180 * Returns the current value of the #CtkWidget:no-show-all property,
15181 * which determines whether calls to ctk_widget_show_all()
15182 * will affect this widget.
15183 *
15184 * Returns: the current value of the “no-show-all” property.
15185 *
15186 * Since: 2.4
15187 **/
15188gboolean
15189ctk_widget_get_no_show_all (CtkWidget *widget)
15190{
15191 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
15192
15193 return widget->priv->no_show_all;
15194}
15195
15196/**
15197 * ctk_widget_set_no_show_all:
15198 * @widget: a #CtkWidget
15199 * @no_show_all: the new value for the “no-show-all” property
15200 *
15201 * Sets the #CtkWidget:no-show-all property, which determines whether
15202 * calls to ctk_widget_show_all() will affect this widget.
15203 *
15204 * This is mostly for use in constructing widget hierarchies with externally
15205 * controlled visibility, see #CtkUIManager.
15206 *
15207 * Since: 2.4
15208 **/
15209void
15210ctk_widget_set_no_show_all (CtkWidget *widget,
15211 gboolean no_show_all)
15212{
15213 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15214
15215 no_show_all = (no_show_all != FALSE(0));
15216
15217 if (widget->priv->no_show_all != no_show_all)
15218 {
15219 widget->priv->no_show_all = no_show_all;
15220
15221 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_NO_SHOW_ALL]);
15222 }
15223}
15224
15225
15226static void
15227ctk_widget_real_set_has_tooltip (CtkWidget *widget,
15228 gboolean has_tooltip,
15229 gboolean force)
15230{
15231 CtkWidgetPrivate *priv = widget->priv;
15232
15233 if (priv->has_tooltip != has_tooltip || force)
15234 {
15235 priv->has_tooltip = has_tooltip;
15236
15237 if (priv->has_tooltip)
15238 {
15239 if (_ctk_widget_get_realized (widget) && !_ctk_widget_get_has_window (widget))
15240 cdk_window_set_events (priv->window,
15241 cdk_window_get_events (priv->window) |
15242 CDK_LEAVE_NOTIFY_MASK |
15243 CDK_POINTER_MOTION_MASK);
15244
15245 if (_ctk_widget_get_has_window (widget))
15246 ctk_widget_add_events (widget,
15247 CDK_LEAVE_NOTIFY_MASK |
15248 CDK_POINTER_MOTION_MASK);
15249 }
15250
15251 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_HAS_TOOLTIP]);
15252 }
15253}
15254
15255/**
15256 * ctk_widget_set_tooltip_window:
15257 * @widget: a #CtkWidget
15258 * @custom_window: (allow-none): a #CtkWindow, or %NULL
15259 *
15260 * Replaces the default window used for displaying
15261 * tooltips with @custom_window. CTK+ will take care of showing and
15262 * hiding @custom_window at the right moment, to behave likewise as
15263 * the default tooltip window. If @custom_window is %NULL, the default
15264 * tooltip window will be used.
15265 *
15266 * Since: 2.12
15267 */
15268void
15269ctk_widget_set_tooltip_window (CtkWidget *widget,
15270 CtkWindow *custom_window)
15271{
15272 gboolean has_tooltip;
15273 gchar *tooltip_markup;
15274
15275 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15276 g_return_if_fail (custom_window == NULL || CTK_IS_WINDOW (custom_window))do { if ((custom_window == ((void*)0) || (((__extension__ ({ GTypeInstance
*__inst = (GTypeInstance*) ((custom_window)); GType __t = ((
ctk_window_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__)), "custom_window == NULL || CTK_IS_WINDOW (custom_window)"
); return; } } while (0)
;
15277
15278 tooltip_markup = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_tooltip_markup);
15279
15280 if (custom_window)
15281 g_object_ref (custom_window)((__typeof__ (custom_window)) (g_object_ref) (custom_window));
15282
15283 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_tooltip_window,
15284 custom_window, g_object_unref);
15285
15286 has_tooltip = (custom_window != NULL((void*)0) || tooltip_markup != NULL((void*)0));
15287 ctk_widget_real_set_has_tooltip (widget, has_tooltip, FALSE(0));
15288
15289 if (has_tooltip && _ctk_widget_get_visible (widget))
15290 ctk_widget_queue_tooltip_query (widget);
15291}
15292
15293/**
15294 * ctk_widget_get_tooltip_window:
15295 * @widget: a #CtkWidget
15296 *
15297 * Returns the #CtkWindow of the current tooltip. This can be the
15298 * CtkWindow created by default, or the custom tooltip window set
15299 * using ctk_widget_set_tooltip_window().
15300 *
15301 * Returns: (transfer none): The #CtkWindow of the current tooltip.
15302 *
15303 * Since: 2.12
15304 */
15305CtkWindow *
15306ctk_widget_get_tooltip_window (CtkWidget *widget)
15307{
15308 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
15309
15310 return g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_tooltip_window);
15311}
15312
15313/**
15314 * ctk_widget_trigger_tooltip_query:
15315 * @widget: a #CtkWidget
15316 *
15317 * Triggers a tooltip query on the display where the toplevel of @widget
15318 * is located. See ctk_tooltip_trigger_tooltip_query() for more
15319 * information.
15320 *
15321 * Since: 2.12
15322 */
15323void
15324ctk_widget_trigger_tooltip_query (CtkWidget *widget)
15325{
15326 ctk_tooltip_trigger_tooltip_query (ctk_widget_get_display (widget));
15327}
15328
15329static guint tooltip_query_id;
15330static GSList *tooltip_query_displays;
15331
15332static gboolean
15333tooltip_query_idle (gpointer data G_GNUC_UNUSED__attribute__ ((__unused__)))
15334{
15335 g_slist_foreach (tooltip_query_displays, (GFunc)ctk_tooltip_trigger_tooltip_query, NULL((void*)0));
15336 g_slist_free_full (tooltip_query_displays, g_object_unref);
15337
15338 tooltip_query_displays = NULL((void*)0);
15339 tooltip_query_id = 0;
15340
15341 return FALSE(0);
15342}
15343
15344static void
15345ctk_widget_queue_tooltip_query (CtkWidget *widget)
15346{
15347 CdkDisplay *display;
15348
15349 display = ctk_widget_get_display (widget);
15350
15351 if (!g_slist_find (tooltip_query_displays, display))
15352 tooltip_query_displays = g_slist_prepend (tooltip_query_displays, g_object_ref (display)((__typeof__ (display)) (g_object_ref) (display)));
15353
15354 if (tooltip_query_id == 0)
15355 {
15356 tooltip_query_id = cdk_threads_add_idle (tooltip_query_idle, NULL((void*)0));
15357 g_source_set_name_by_id (tooltip_query_id, "[ctk+] tooltip_query_idle");
15358 }
15359}
15360
15361/**
15362 * ctk_widget_set_tooltip_text:
15363 * @widget: a #CtkWidget
15364 * @text: (allow-none): the contents of the tooltip for @widget
15365 *
15366 * Sets @text as the contents of the tooltip. This function will take
15367 * care of setting #CtkWidget:has-tooltip to %TRUE and of the default
15368 * handler for the #CtkWidget::query-tooltip signal.
15369 *
15370 * See also the #CtkWidget:tooltip-text property and ctk_tooltip_set_text().
15371 *
15372 * Since: 2.12
15373 */
15374void
15375ctk_widget_set_tooltip_text (CtkWidget *widget,
15376 const gchar *text)
15377{
15378 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15379
15380 g_object_set (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "tooltip-text", text, NULL((void*)0));
15381}
15382
15383/**
15384 * ctk_widget_get_tooltip_text:
15385 * @widget: a #CtkWidget
15386 *
15387 * Gets the contents of the tooltip for @widget.
15388 *
15389 * Returns: (nullable): the tooltip text, or %NULL. You should free the
15390 * returned string with g_free() when done.
15391 *
15392 * Since: 2.12
15393 */
15394gchar *
15395ctk_widget_get_tooltip_text (CtkWidget *widget)
15396{
15397 gchar *text = NULL((void*)0);
15398
15399 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
15400
15401 g_object_get (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "tooltip-text", &text, NULL((void*)0));
15402
15403 return text;
15404}
15405
15406/**
15407 * ctk_widget_set_tooltip_markup:
15408 * @widget: a #CtkWidget
15409 * @markup: (allow-none): the contents of the tooltip for @widget, or %NULL
15410 *
15411 * Sets @markup as the contents of the tooltip, which is marked up with
15412 * the [Pango text markup language][PangoMarkupFormat].
15413 *
15414 * This function will take care of setting #CtkWidget:has-tooltip to %TRUE
15415 * and of the default handler for the #CtkWidget::query-tooltip signal.
15416 *
15417 * See also the #CtkWidget:tooltip-markup property and
15418 * ctk_tooltip_set_markup().
15419 *
15420 * Since: 2.12
15421 */
15422void
15423ctk_widget_set_tooltip_markup (CtkWidget *widget,
15424 const gchar *markup)
15425{
15426 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15427
15428 g_object_set (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "tooltip-markup", markup, NULL((void*)0));
15429}
15430
15431/**
15432 * ctk_widget_get_tooltip_markup:
15433 * @widget: a #CtkWidget
15434 *
15435 * Gets the contents of the tooltip for @widget.
15436 *
15437 * Returns: (nullable): the tooltip text, or %NULL. You should free the
15438 * returned string with g_free() when done.
15439 *
15440 * Since: 2.12
15441 */
15442gchar *
15443ctk_widget_get_tooltip_markup (CtkWidget *widget)
15444{
15445 gchar *text = NULL((void*)0);
15446
15447 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
15448
15449 g_object_get (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, "tooltip-markup", &text, NULL((void*)0));
15450
15451 return text;
15452}
15453
15454/**
15455 * ctk_widget_set_has_tooltip:
15456 * @widget: a #CtkWidget
15457 * @has_tooltip: whether or not @widget has a tooltip.
15458 *
15459 * Sets the has-tooltip property on @widget to @has_tooltip. See
15460 * #CtkWidget:has-tooltip for more information.
15461 *
15462 * Since: 2.12
15463 */
15464void
15465ctk_widget_set_has_tooltip (CtkWidget *widget,
15466 gboolean has_tooltip)
15467{
15468 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15469
15470 ctk_widget_real_set_has_tooltip (widget, has_tooltip, FALSE(0));
15471}
15472
15473/**
15474 * ctk_widget_get_has_tooltip:
15475 * @widget: a #CtkWidget
15476 *
15477 * Returns the current value of the has-tooltip property. See
15478 * #CtkWidget:has-tooltip for more information.
15479 *
15480 * Returns: current value of has-tooltip on @widget.
15481 *
15482 * Since: 2.12
15483 */
15484gboolean
15485ctk_widget_get_has_tooltip (CtkWidget *widget)
15486{
15487 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
15488
15489 return widget->priv->has_tooltip;
15490}
15491
15492/**
15493 * ctk_widget_get_clip:
15494 * @widget: a #CtkWidget
15495 * @clip: (out): a pointer to a #CtkAllocation to copy to
15496 *
15497 * Retrieves the widget’s clip area.
15498 *
15499 * The clip area is the area in which all of @widget's drawing will
15500 * happen. Other toolkits call it the bounding box.
15501 *
15502 * Historically, in CTK+ the clip area has been equal to the allocation
15503 * retrieved via ctk_widget_get_allocation().
15504 *
15505 * Since: 3.14
15506 */
15507void
15508ctk_widget_get_clip (CtkWidget *widget,
15509 CtkAllocation *clip)
15510{
15511 CtkWidgetPrivate *priv;
15512
15513 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15514 g_return_if_fail (clip != NULL)do { if ((clip != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "clip != NULL"); return;
} } while (0)
;
15515
15516 priv = widget->priv;
15517
15518 *clip = priv->clip;
15519}
15520
15521/**
15522 * ctk_widget_set_clip:
15523 * @widget: a #CtkWidget
15524 * @clip: a pointer to a #CtkAllocation to copy from
15525 *
15526 * Sets the widget’s clip. This must not be used directly,
15527 * but from within a widget’s size_allocate method.
15528 * It must be called after ctk_widget_set_allocation() (or after chaining up
15529 * to the parent class), because that function resets the clip.
15530 *
15531 * The clip set should be the area that @widget draws on. If @widget is a
15532 * #CtkContainer, the area must contain all children's clips.
15533 *
15534 * If this function is not called by @widget during a ::size-allocate handler,
15535 * the clip will be set to @widget's allocation.
15536 *
15537 * Since: 3.14
15538 */
15539void
15540ctk_widget_set_clip (CtkWidget *widget,
15541 const CtkAllocation *clip)
15542{
15543 CtkWidgetPrivate *priv;
15544
15545 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15546 g_return_if_fail (_ctk_widget_get_visible (widget) || _ctk_widget_is_toplevel (widget))do { if ((_ctk_widget_get_visible (widget) || _ctk_widget_is_toplevel
(widget))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "_ctk_widget_get_visible (widget) || _ctk_widget_is_toplevel (widget)"
); return; } } while (0)
;
15547 g_return_if_fail (clip != NULL)do { if ((clip != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "clip != NULL"); return;
} } while (0)
;
15548
15549 priv = widget->priv;
15550
15551#ifdef G_ENABLE_DEBUG1
15552 if (CTK_DEBUG_CHECK (GEOMETRY)(ctk_get_debug_flags () & CTK_DEBUG_GEOMETRY))
15553 {
15554 gint depth;
15555 CtkWidget *parent;
15556 const gchar *name;
15557
15558 depth = 0;
15559 parent = widget;
15560 while (parent)
15561 {
15562 depth++;
15563 parent = _ctk_widget_get_parent (parent);
15564 }
15565
15566 name = g_type_name (G_OBJECT_TYPE (G_OBJECT (widget))(((((GTypeClass*) (((GTypeInstance*) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
)))))))->g_class))->g_type)))
);
15567 g_message ("ctk_widget_set_clip: %*s%s %d %d %d %d",
15568 2 * depth, " ", name,
15569 clip->x, clip->y,
15570 clip->width, clip->height);
15571 }
15572#endif /* G_ENABLE_DEBUG */
15573
15574 priv->clip = *clip;
15575
15576 while (priv->parent &&
15577 _ctk_widget_get_window (widget) == _ctk_widget_get_window (priv->parent))
15578 {
15579 CtkWidgetPrivate *parent_priv = priv->parent->priv;
15580 CdkRectangle union_rect;
15581
15582 cdk_rectangle_union (&priv->clip,
15583 &parent_priv->clip,
15584 &union_rect);
15585
15586 if (cdk_rectangle_equal (&parent_priv->clip, &union_rect))
15587 break;
15588
15589 parent_priv->clip = union_rect;
15590 priv = parent_priv;
15591 }
15592}
15593
15594/*
15595 * _ctk_widget_set_simple_clip:
15596 * @widget: a #CtkWidget
15597 * @content_clip: (nullable): Clipping area of the contents
15598 * or %NULL, if the contents
15599 * do not extent the allocation.
15600 *
15601 * This is a convenience function for ctk_widget_set_clip(), if you
15602 * just want to set the clip for @widget based on its allocation,
15603 * CSS properties and - if the widget is a #CtkContainer - its
15604 * children. ctk_widget_set_allocation() must have been called
15605 * and all children must have been allocated with
15606 * ctk_widget_size_allocate() before calling this function.
15607 * It is therefore a good idea to call this function last in
15608 * your implementation of CtkWidget::size_allocate().
15609 *
15610 * If your widget overdraws its contents, you cannot use this
15611 * function and must call ctk_widget_set_clip() yourself.
15612 **/
15613void
15614_ctk_widget_set_simple_clip (CtkWidget *widget,
15615 CtkAllocation *content_clip)
15616{
15617 CtkStyleContext *context;
15618 CtkAllocation clip, allocation;
15619 CtkBorder extents;
15620
15621 context = _ctk_widget_get_style_context (widget);
15622
15623 _ctk_widget_get_allocation (widget, &allocation);
15624
15625 _ctk_css_shadows_value_get_extents (_ctk_style_context_peek_property (context,
15626 CTK_CSS_PROPERTY_BOX_SHADOW),
15627 &extents);
15628
15629 clip = allocation;
15630 clip.x -= extents.left;
15631 clip.y -= extents.top;
15632 clip.width += extents.left + extents.right;
15633 clip.height += extents.top + extents.bottom;
15634
15635 if (content_clip)
15636 cdk_rectangle_union (content_clip, &clip, &clip);
15637
15638 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
15639 {
15640 CdkRectangle children_clip;
15641
15642 ctk_container_get_children_clip (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
, &children_clip);
15643
15644 if (_ctk_widget_get_has_window (widget))
15645 {
15646 children_clip.x += allocation.x;
15647 children_clip.y += allocation.y;
15648 }
15649
15650 cdk_rectangle_union (&children_clip, &clip, &clip);
15651 }
15652
15653 ctk_widget_set_clip (widget, &clip);
15654}
15655
15656/**
15657 * ctk_widget_get_allocated_size:
15658 * @widget: a #CtkWidget
15659 * @allocation: (out): a pointer to a #CtkAllocation to copy to
15660 * @baseline: (out) (allow-none): a pointer to an integer to copy to
15661 *
15662 * Retrieves the widget’s allocated size.
15663 *
15664 * This function returns the last values passed to
15665 * ctk_widget_size_allocate_with_baseline(). The value differs from
15666 * the size returned in ctk_widget_get_allocation() in that functions
15667 * like ctk_widget_set_halign() can adjust the allocation, but not
15668 * the value returned by this function.
15669 *
15670 * If a widget is not visible, its allocated size is 0.
15671 *
15672 * Since: 3.20
15673 */
15674void
15675ctk_widget_get_allocated_size (CtkWidget *widget,
15676 CtkAllocation *allocation,
15677 int *baseline)
15678{
15679 CtkWidgetPrivate *priv;
15680
15681 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15682 g_return_if_fail (allocation != NULL)do { if ((allocation != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "allocation != NULL"); return
; } } while (0)
;
15683
15684 priv = widget->priv;
15685
15686 *allocation = priv->allocated_size;
15687
15688 if (baseline)
15689 *baseline = priv->allocated_size_baseline;
15690}
15691
15692/**
15693 * ctk_widget_get_allocation:
15694 * @widget: a #CtkWidget
15695 * @allocation: (out): a pointer to a #CtkAllocation to copy to
15696 *
15697 * Retrieves the widget’s allocation.
15698 *
15699 * Note, when implementing a #CtkContainer: a widget’s allocation will
15700 * be its “adjusted” allocation, that is, the widget’s parent
15701 * container typically calls ctk_widget_size_allocate() with an
15702 * allocation, and that allocation is then adjusted (to handle margin
15703 * and alignment for example) before assignment to the widget.
15704 * ctk_widget_get_allocation() returns the adjusted allocation that
15705 * was actually assigned to the widget. The adjusted allocation is
15706 * guaranteed to be completely contained within the
15707 * ctk_widget_size_allocate() allocation, however. So a #CtkContainer
15708 * is guaranteed that its children stay inside the assigned bounds,
15709 * but not that they have exactly the bounds the container assigned.
15710 * There is no way to get the original allocation assigned by
15711 * ctk_widget_size_allocate(), since it isn’t stored; if a container
15712 * implementation needs that information it will have to track it itself.
15713 *
15714 * Since: 2.18
15715 */
15716void
15717ctk_widget_get_allocation (CtkWidget *widget,
15718 CtkAllocation *allocation)
15719{
15720 CtkWidgetPrivate *priv;
15721
15722 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15723 g_return_if_fail (allocation != NULL)do { if ((allocation != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "allocation != NULL"); return
; } } while (0)
;
15724
15725 priv = widget->priv;
15726
15727 *allocation = priv->allocation;
15728}
15729
15730/**
15731 * ctk_widget_set_allocation:
15732 * @widget: a #CtkWidget
15733 * @allocation: a pointer to a #CtkAllocation to copy from
15734 *
15735 * Sets the widget’s allocation. This should not be used
15736 * directly, but from within a widget’s size_allocate method.
15737 *
15738 * The allocation set should be the “adjusted” or actual
15739 * allocation. If you’re implementing a #CtkContainer, you want to use
15740 * ctk_widget_size_allocate() instead of ctk_widget_set_allocation().
15741 * The CtkWidgetClass::adjust_size_allocation virtual method adjusts the
15742 * allocation inside ctk_widget_size_allocate() to create an adjusted
15743 * allocation.
15744 *
15745 * Since: 2.18
15746 */
15747void
15748ctk_widget_set_allocation (CtkWidget *widget,
15749 const CtkAllocation *allocation)
15750{
15751 CtkWidgetPrivate *priv;
15752
15753 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15754 g_return_if_fail (_ctk_widget_get_visible (widget) || _ctk_widget_is_toplevel (widget))do { if ((_ctk_widget_get_visible (widget) || _ctk_widget_is_toplevel
(widget))) { } else { g_return_if_fail_warning ("Ctk", ((const
char*) (__func__)), "_ctk_widget_get_visible (widget) || _ctk_widget_is_toplevel (widget)"
); return; } } while (0)
;
15755 g_return_if_fail (allocation != NULL)do { if ((allocation != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "allocation != NULL"); return
; } } while (0)
;
15756
15757 priv = widget->priv;
15758
15759 priv->allocation = *allocation;
15760 priv->clip = *allocation;
15761}
15762
15763/**
15764 * ctk_widget_get_allocated_width:
15765 * @widget: the widget to query
15766 *
15767 * Returns the width that has currently been allocated to @widget.
15768 * This function is intended to be used when implementing handlers
15769 * for the #CtkWidget::draw function.
15770 *
15771 * Returns: the width of the @widget
15772 **/
15773int
15774ctk_widget_get_allocated_width (CtkWidget *widget)
15775{
15776 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
15777
15778 return widget->priv->allocation.width;
15779}
15780
15781/**
15782 * ctk_widget_get_allocated_height:
15783 * @widget: the widget to query
15784 *
15785 * Returns the height that has currently been allocated to @widget.
15786 * This function is intended to be used when implementing handlers
15787 * for the #CtkWidget::draw function.
15788 *
15789 * Returns: the height of the @widget
15790 **/
15791int
15792ctk_widget_get_allocated_height (CtkWidget *widget)
15793{
15794 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
15795
15796 return widget->priv->allocation.height;
15797}
15798
15799/**
15800 * ctk_widget_get_allocated_baseline:
15801 * @widget: the widget to query
15802 *
15803 * Returns the baseline that has currently been allocated to @widget.
15804 * This function is intended to be used when implementing handlers
15805 * for the #CtkWidget::draw function, and when allocating child
15806 * widgets in #CtkWidget::size_allocate.
15807 *
15808 * Returns: the baseline of the @widget, or -1 if none
15809 *
15810 * Since: 3.10
15811 **/
15812int
15813ctk_widget_get_allocated_baseline (CtkWidget *widget)
15814{
15815 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
15816
15817 return widget->priv->allocated_baseline;
15818}
15819
15820/**
15821 * ctk_widget_get_requisition:
15822 * @widget: a #CtkWidget
15823 * @requisition: (out): a pointer to a #CtkRequisition to copy to
15824 *
15825 * Retrieves the widget’s requisition.
15826 *
15827 * This function should only be used by widget implementations in
15828 * order to figure whether the widget’s requisition has actually
15829 * changed after some internal state change (so that they can call
15830 * ctk_widget_queue_resize() instead of ctk_widget_queue_draw()).
15831 *
15832 * Normally, ctk_widget_size_request() should be used.
15833 *
15834 * Since: 2.20
15835 *
15836 * Deprecated: 3.0: The #CtkRequisition cache on the widget was
15837 * removed, If you need to cache sizes across requests and allocations,
15838 * add an explicit cache to the widget in question instead.
15839 */
15840void
15841ctk_widget_get_requisition (CtkWidget *widget,
15842 CtkRequisition *requisition)
15843{
15844 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15845 g_return_if_fail (requisition != NULL)do { if ((requisition != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "requisition != NULL"); return
; } } while (0)
;
15846
15847 ctk_widget_get_preferred_size (widget, requisition, NULL((void*)0));
15848}
15849
15850/**
15851 * ctk_widget_set_window:
15852 * @widget: a #CtkWidget
15853 * @window: (transfer full): a #CdkWindow
15854 *
15855 * Sets a widget’s window. This function should only be used in a
15856 * widget’s #CtkWidget::realize implementation. The %window passed is
15857 * usually either new window created with cdk_window_new(), or the
15858 * window of its parent widget as returned by
15859 * ctk_widget_get_parent_window().
15860 *
15861 * Widgets must indicate whether they will create their own #CdkWindow
15862 * by calling ctk_widget_set_has_window(). This is usually done in the
15863 * widget’s init() function.
15864 *
15865 * Note that this function does not add any reference to @window.
15866 *
15867 * Since: 2.18
15868 */
15869void
15870ctk_widget_set_window (CtkWidget *widget,
15871 CdkWindow *window)
15872{
15873 CtkWidgetPrivate *priv;
15874
15875 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15876 g_return_if_fail (window == NULL || CDK_IS_WINDOW (window))do { if ((window == ((void*)0) || (((__extension__ ({ GTypeInstance
*__inst = (GTypeInstance*) ((window)); GType __t = ((cdk_window_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__)), "window == NULL || CDK_IS_WINDOW (window)"
); return; } } while (0)
;
15877
15878 priv = widget->priv;
15879
15880 if (priv->window != window)
15881 {
15882 priv->window = window;
15883
15884 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_WINDOW]);
15885 }
15886}
15887
15888/**
15889 * ctk_widget_register_window:
15890 * @widget: a #CtkWidget
15891 * @window: a #CdkWindow
15892 *
15893 * Registers a #CdkWindow with the widget and sets it up so that
15894 * the widget receives events for it. Call ctk_widget_unregister_window()
15895 * when destroying the window.
15896 *
15897 * Before 3.8 you needed to call cdk_window_set_user_data() directly to set
15898 * this up. This is now deprecated and you should use ctk_widget_register_window()
15899 * instead. Old code will keep working as is, although some new features like
15900 * transparency might not work perfectly.
15901 *
15902 * Since: 3.8
15903 */
15904void
15905ctk_widget_register_window (CtkWidget *widget,
15906 CdkWindow *window)
15907{
15908 CtkWidgetPrivate *priv;
15909 gpointer user_data;
15910
15911 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15912 g_return_if_fail (CDK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((cdk_window_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__
)), "CDK_IS_WINDOW (window)"); return; } } while (0)
;
15913
15914 cdk_window_get_user_data (window, &user_data);
15915 g_assert (user_data == NULL)do { if (user_data == ((void*)0)) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 15915, ((const char*) (__func__)), "user_data == NULL"
); } while (0)
;
15916
15917 priv = widget->priv;
15918
15919 cdk_window_set_user_data (window, widget);
15920 priv->registered_windows = g_list_prepend (priv->registered_windows, window);
15921}
15922
15923/**
15924 * ctk_widget_unregister_window:
15925 * @widget: a #CtkWidget
15926 * @window: a #CdkWindow
15927 *
15928 * Unregisters a #CdkWindow from the widget that was previously set up with
15929 * ctk_widget_register_window(). You need to call this when the window is
15930 * no longer used by the widget, such as when you destroy it.
15931 *
15932 * Since: 3.8
15933 */
15934void
15935ctk_widget_unregister_window (CtkWidget *widget,
15936 CdkWindow *window)
15937{
15938 CtkWidgetPrivate *priv;
15939 gpointer user_data;
15940
15941 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
15942 g_return_if_fail (CDK_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((cdk_window_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__
)), "CDK_IS_WINDOW (window)"); return; } } while (0)
;
15943
15944 priv = widget->priv;
15945
15946 cdk_window_get_user_data (window, &user_data);
15947 g_assert (user_data == widget)do { if (user_data == widget) ; else g_assertion_message_expr
("Ctk", "ctkwidget.c", 15947, ((const char*) (__func__)), "user_data == widget"
); } while (0)
;
15948 cdk_window_set_user_data (window, NULL((void*)0));
15949 priv->registered_windows = g_list_remove (priv->registered_windows, window);
15950}
15951
15952/**
15953 * ctk_widget_get_window:
15954 * @widget: a #CtkWidget
15955 *
15956 * Returns the widget’s window if it is realized, %NULL otherwise
15957 *
15958 * Returns: (transfer none) (nullable): @widget’s window.
15959 *
15960 * Since: 2.14
15961 */
15962CdkWindow*
15963ctk_widget_get_window (CtkWidget *widget)
15964{
15965 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
15966
15967 return widget->priv->window;
15968}
15969
15970/**
15971 * ctk_widget_get_support_multidevice:
15972 * @widget: a #CtkWidget
15973 *
15974 * Returns %TRUE if @widget is multiple pointer aware. See
15975 * ctk_widget_set_support_multidevice() for more information.
15976 *
15977 * Returns: %TRUE if @widget is multidevice aware.
15978 **/
15979gboolean
15980ctk_widget_get_support_multidevice (CtkWidget *widget)
15981{
15982 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
15983
15984 return widget->priv->multidevice;
15985}
15986
15987/**
15988 * ctk_widget_set_support_multidevice:
15989 * @widget: a #CtkWidget
15990 * @support_multidevice: %TRUE to support input from multiple devices.
15991 *
15992 * Enables or disables multiple pointer awareness. If this setting is %TRUE,
15993 * @widget will start receiving multiple, per device enter/leave events. Note
15994 * that if custom #CdkWindows are created in #CtkWidget::realize,
15995 * cdk_window_set_support_multidevice() will have to be called manually on them.
15996 *
15997 * Since: 3.0
15998 **/
15999void
16000ctk_widget_set_support_multidevice (CtkWidget *widget,
16001 gboolean support_multidevice)
16002{
16003 CtkWidgetPrivate *priv;
16004
16005 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
16006
16007 priv = widget->priv;
16008 priv->multidevice = (support_multidevice == TRUE(!(0)));
16009
16010 if (_ctk_widget_get_realized (widget))
16011 cdk_window_set_support_multidevice (priv->window, support_multidevice);
16012}
16013
16014/* There are multiple alpha related sources. First of all the user can specify alpha
16015 * in ctk_widget_set_opacity, secondly we can get it from the CSS opacity. These two
16016 * are multiplied together to form the total alpha. Secondly, the user can specify
16017 * an opacity group for a widget, which means we must essentially handle it as having alpha.
16018 */
16019
16020static void
16021ctk_widget_update_alpha (CtkWidget *widget)
16022{
16023 CtkWidgetPrivate *priv;
16024 CtkStyleContext *context;
16025 gdouble opacity;
16026 guint8 alpha;
16027
16028 priv = widget->priv;
16029
16030 context = _ctk_widget_get_style_context (widget);
16031 opacity =
16032 _ctk_css_number_value_get (_ctk_style_context_peek_property (context,
16033 CTK_CSS_PROPERTY_OPACITY),
16034 100);
16035 opacity = CLAMP (opacity, 0.0, 1.0)(((opacity) > (1.0)) ? (1.0) : (((opacity) < (0.0)) ? (
0.0) : (opacity)))
;
16036 alpha = round (priv->user_alpha * opacity);
16037
16038 if (alpha == priv->alpha)
16039 return;
16040
16041 priv->alpha = alpha;
16042
16043 if (_ctk_widget_get_realized (widget))
16044 {
16045 if (_ctk_widget_is_toplevel (widget) &&
16046 ctk_widget_get_visual (widget) != cdk_screen_get_rgba_visual (ctk_widget_get_screen (widget)))
16047 cdk_window_set_opacity (priv->window, priv->alpha / 255.0);
16048
16049 ctk_widget_queue_draw (widget);
16050 }
16051}
16052
16053/**
16054 * ctk_widget_set_opacity:
16055 * @widget: a #CtkWidget
16056 * @opacity: desired opacity, between 0 and 1
16057 *
16058 * Request the @widget to be rendered partially transparent,
16059 * with opacity 0 being fully transparent and 1 fully opaque. (Opacity values
16060 * are clamped to the [0,1] range.).
16061 * This works on both toplevel widget, and child widgets, although there
16062 * are some limitations:
16063 *
16064 * For toplevel widgets this depends on the capabilities of the windowing
16065 * system. On X11 this has any effect only on X screens with a compositing manager
16066 * running. See ctk_widget_is_composited(). On Windows it should work
16067 * always, although setting a window’s opacity after the window has been
16068 * shown causes it to flicker once on Windows.
16069 *
16070 * For child widgets it doesn’t work if any affected widget has a native window, or
16071 * disables double buffering.
16072 *
16073 * Since: 3.8
16074 **/
16075void
16076ctk_widget_set_opacity (CtkWidget *widget,
16077 gdouble opacity)
16078{
16079 CtkWidgetPrivate *priv;
16080 guint8 alpha;
16081
16082 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
16083
16084 priv = widget->priv;
16085
16086 opacity = CLAMP (opacity, 0.0, 1.0)(((opacity) > (1.0)) ? (1.0) : (((opacity) < (0.0)) ? (
0.0) : (opacity)))
;
16087
16088 alpha = round (opacity * 255);
16089
16090 if (alpha == priv->user_alpha)
16091 return;
16092
16093 priv->user_alpha = alpha;
16094
16095 ctk_widget_update_alpha (widget);
16096
16097 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_OPACITY]);
16098}
16099
16100/**
16101 * ctk_widget_get_opacity:
16102 * @widget: a #CtkWidget
16103 *
16104 * Fetches the requested opacity for this widget.
16105 * See ctk_widget_set_opacity().
16106 *
16107 * Returns: the requested opacity for this widget.
16108 *
16109 * Since: 3.8
16110 **/
16111gdouble
16112ctk_widget_get_opacity (CtkWidget *widget)
16113{
16114 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0.0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0.0); } } while (0)
;
16115
16116 return widget->priv->user_alpha / 255.0;
16117}
16118
16119static void
16120_ctk_widget_set_has_focus (CtkWidget *widget,
16121 gboolean has_focus)
16122{
16123 widget->priv->has_focus = has_focus;
16124
16125 if (has_focus)
16126 ctk_widget_set_state_flags (widget, CTK_STATE_FLAG_FOCUSED, FALSE(0));
16127 else
16128 ctk_widget_unset_state_flags (widget, CTK_STATE_FLAG_FOCUSED);
16129}
16130
16131/**
16132 * ctk_widget_send_focus_change:
16133 * @widget: a #CtkWidget
16134 * @event: a #CdkEvent of type CDK_FOCUS_CHANGE
16135 *
16136 * Sends the focus change @event to @widget
16137 *
16138 * This function is not meant to be used by applications. The only time it
16139 * should be used is when it is necessary for a #CtkWidget to assign focus
16140 * to a widget that is semantically owned by the first widget even though
16141 * it’s not a direct child - for instance, a search entry in a floating
16142 * window similar to the quick search in #CtkTreeView.
16143 *
16144 * An example of its usage is:
16145 *
16146 * |[<!-- language="C" -->
16147 * CdkEvent *fevent = cdk_event_new (CDK_FOCUS_CHANGE);
16148 *
16149 * fevent->focus_change.type = CDK_FOCUS_CHANGE;
16150 * fevent->focus_change.in = TRUE;
16151 * fevent->focus_change.window = _ctk_widget_get_window (widget);
16152 * if (fevent->focus_change.window != NULL)
16153 * g_object_ref (fevent->focus_change.window);
16154 *
16155 * ctk_widget_send_focus_change (widget, fevent);
16156 *
16157 * cdk_event_free (event);
16158 * ]|
16159 *
16160 * Returns: the return value from the event signal emission: %TRUE
16161 * if the event was handled, and %FALSE otherwise
16162 *
16163 * Since: 2.20
16164 */
16165gboolean
16166ctk_widget_send_focus_change (CtkWidget *widget,
16167 CdkEvent *event)
16168{
16169 gboolean res;
16170
16171 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
16172 g_return_val_if_fail (event != NULL && event->type == CDK_FOCUS_CHANGE, FALSE)do { if ((event != ((void*)0) && event->type == CDK_FOCUS_CHANGE
)) { } else { g_return_if_fail_warning ("Ctk", ((const char*)
(__func__)), "event != NULL && event->type == CDK_FOCUS_CHANGE"
); return ((0)); } } while (0)
;
16173
16174 g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget));
16175
16176 _ctk_widget_set_has_focus (widget, event->focus_change.in);
16177
16178 res = ctk_widget_event (widget, event);
16179
16180 g_object_notify_by_pspec (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, widget_props[PROP_HAS_FOCUS]);
16181
16182 g_object_unref (widget);
16183
16184 return res;
16185}
16186
16187/**
16188 * ctk_widget_in_destruction:
16189 * @widget: a #CtkWidget
16190 *
16191 * Returns whether the widget is currently being destroyed.
16192 * This information can sometimes be used to avoid doing
16193 * unnecessary work.
16194 *
16195 * Returns: %TRUE if @widget is being destroyed
16196 */
16197gboolean
16198ctk_widget_in_destruction (CtkWidget *widget)
16199{
16200 return widget->priv->in_destruction;
16201}
16202
16203gboolean
16204_ctk_widget_get_in_reparent (CtkWidget *widget)
16205{
16206 return widget->priv->in_reparent;
16207}
16208
16209void
16210_ctk_widget_set_in_reparent (CtkWidget *widget,
16211 gboolean in_reparent)
16212{
16213 widget->priv->in_reparent = in_reparent;
16214}
16215
16216gboolean
16217_ctk_widget_get_anchored (CtkWidget *widget)
16218{
16219 return widget->priv->anchored;
16220}
16221
16222void
16223_ctk_widget_set_anchored (CtkWidget *widget,
16224 gboolean anchored)
16225{
16226 widget->priv->anchored = anchored;
16227}
16228
16229gboolean
16230_ctk_widget_get_shadowed (CtkWidget *widget)
16231{
16232 return widget->priv->shadowed;
16233}
16234
16235void
16236_ctk_widget_set_shadowed (CtkWidget *widget,
16237 gboolean shadowed)
16238{
16239 widget->priv->shadowed = shadowed;
16240}
16241
16242gboolean
16243_ctk_widget_get_alloc_needed (CtkWidget *widget)
16244{
16245 return widget->priv->alloc_needed;
16246}
16247
16248static void
16249ctk_widget_set_alloc_needed (CtkWidget *widget)
16250{
16251 CtkWidgetPrivate *priv = widget->priv;
16252
16253 priv->alloc_needed = TRUE(!(0));
16254
16255 do
16256 {
16257 if (priv->alloc_needed_on_child)
16258 break;
16259
16260 priv->alloc_needed_on_child = TRUE(!(0));
16261
16262 if (!priv->visible)
16263 break;
16264
16265G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
16266 if (CTK_IS_RESIZE_CONTAINER (widget)((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*)
((widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))) &&
(ctk_container_get_resize_mode (((((CtkContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((ctk_container_get_type ())))
)))) != CTK_RESIZE_PARENT))
)
16267 {
16268 ctk_container_queue_resize_handler (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
);
16269 break;
16270 }
16271G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
16272
16273 widget = priv->parent;
16274 if (widget == NULL((void*)0))
16275 break;
16276
16277 priv = widget->priv;
16278 }
16279 while (TRUE(!(0)));
16280}
16281
16282gboolean
16283ctk_widget_needs_allocate (CtkWidget *widget)
16284{
16285 CtkWidgetPrivate *priv = widget->priv;
16286
16287 if (!priv->visible || !priv->child_visible)
16288 return FALSE(0);
16289
16290 if (priv->resize_needed || priv->alloc_needed || priv->alloc_needed_on_child)
16291 return TRUE(!(0));
16292
16293 return FALSE(0);
16294}
16295
16296void
16297ctk_widget_ensure_allocate (CtkWidget *widget)
16298{
16299 CtkWidgetPrivate *priv = widget->priv;
16300
16301 if (!ctk_widget_needs_allocate (widget))
16302 return;
16303
16304 ctk_widget_ensure_resize (widget);
16305
16306 /* This code assumes that we only reach here if the previous
16307 * allocation is still valid (ie no resize was queued).
16308 * If that wasn't true, the parent would have taken care of
16309 * things.
16310 */
16311 if (priv->alloc_needed)
16312 {
16313 CtkAllocation allocation;
16314 int baseline;
16315
16316 ctk_widget_get_allocated_size (widget, &allocation, &baseline);
16317 ctk_widget_size_allocate_with_baseline (widget, &allocation, baseline);
16318 }
16319 else if (priv->alloc_needed_on_child)
16320 {
16321 priv->alloc_needed_on_child = FALSE(0);
16322
16323 if (CTK_IS_CONTAINER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_container_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
16324 ctk_container_forall (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_container_get_type ()))))))
,
16325 (CtkCallback) ctk_widget_ensure_allocate,
16326 NULL((void*)0));
16327 }
16328}
16329
16330void
16331ctk_widget_queue_resize_on_widget (CtkWidget *widget)
16332{
16333 CtkWidgetPrivate *priv = widget->priv;
16334
16335 priv->resize_needed = TRUE(!(0));
16336 ctk_widget_set_alloc_needed (widget);
16337}
16338
16339void
16340ctk_widget_ensure_resize (CtkWidget *widget)
16341{
16342 CtkWidgetPrivate *priv = widget->priv;
16343
16344 if (!priv->resize_needed)
16345 return;
16346
16347 priv->resize_needed = FALSE(0);
16348 _ctk_size_request_cache_clear (&priv->requests);
16349}
16350
16351void
16352_ctk_widget_add_sizegroup (CtkWidget *widget,
16353 gpointer group)
16354{
16355 GSList *groups;
16356
16357 groups = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_size_groups);
16358 groups = g_slist_prepend (groups, group);
16359 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_size_groups, groups);
16360
16361 widget->priv->have_size_groups = TRUE(!(0));
16362}
16363
16364void
16365_ctk_widget_remove_sizegroup (CtkWidget *widget,
16366 gpointer group)
16367{
16368 GSList *groups;
16369
16370 groups = g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_size_groups);
16371 groups = g_slist_remove (groups, group);
16372 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_size_groups, groups);
16373
16374 widget->priv->have_size_groups = groups != NULL((void*)0);
16375}
16376
16377GSList *
16378_ctk_widget_get_sizegroups (CtkWidget *widget)
16379{
16380 if (widget->priv->have_size_groups)
16381 return g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_size_groups);
16382
16383 return NULL((void*)0);
16384}
16385
16386void
16387_ctk_widget_add_attached_window (CtkWidget *widget,
16388 CtkWindow *window)
16389{
16390 widget->priv->attached_windows = g_list_prepend (widget->priv->attached_windows, window);
16391}
16392
16393void
16394_ctk_widget_remove_attached_window (CtkWidget *widget,
16395 CtkWindow *window)
16396{
16397 widget->priv->attached_windows = g_list_remove (widget->priv->attached_windows, window);
16398}
16399
16400/**
16401 * ctk_widget_path_append_for_widget:
16402 * @path: a widget path
16403 * @widget: the widget to append to the widget path
16404 *
16405 * Appends the data from @widget to the widget hierarchy represented
16406 * by @path. This function is a shortcut for adding information from
16407 * @widget to the given @path. This includes setting the name or
16408 * adding the style classes from @widget.
16409 *
16410 * Returns: the position where the data was inserted
16411 *
16412 * Since: 3.2
16413 */
16414gint
16415ctk_widget_path_append_for_widget (CtkWidgetPath *path,
16416 CtkWidget *widget)
16417{
16418 const GQuark *classes;
16419 guint n_classes, i;
16420 gint pos;
16421
16422 g_return_val_if_fail (path != NULL, 0)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "path != NULL"); return (
0); } } while (0)
;
16423 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
16424
16425 pos = ctk_widget_path_append_type (path, ctk_css_node_get_widget_type (widget->priv->cssnode));
16426 ctk_widget_path_iter_set_object_name (path, pos, ctk_css_node_get_name (widget->priv->cssnode));
16427
16428 if (widget->priv->name)
16429 ctk_widget_path_iter_set_name (path, pos, widget->priv->name);
16430
16431 ctk_widget_path_iter_set_state (path, pos, widget->priv->state_flags);
16432
16433 classes = ctk_css_node_list_classes (widget->priv->cssnode, &n_classes);
16434
16435 for (i = n_classes; i-- > 0;)
16436 ctk_widget_path_iter_add_qclass (path, pos, classes[i]);
16437
16438 return pos;
16439}
16440
16441CtkWidgetPath *
16442_ctk_widget_create_path (CtkWidget *widget)
16443{
16444 CtkWidget *parent;
16445
16446 parent = widget->priv->parent;
16447
16448 if (parent)
16449 return ctk_container_get_path_for_child (CTK_CONTAINER (parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((parent)), ((ctk_container_get_type ()))))))
, widget);
16450 else
16451 {
16452 /* Widget is either toplevel or unparented, treat both
16453 * as toplevels style wise, since there are situations
16454 * where style properties might be retrieved on that
16455 * situation.
16456 */
16457 CtkWidget *attach_widget = NULL((void*)0);
16458 CtkWidgetPath *result;
16459
16460 if (CTK_IS_WINDOW (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_window_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; }))))
)
16461 attach_widget = ctk_window_get_attached_to (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_window_get_type ()))))))
);
16462
16463 if (attach_widget != NULL((void*)0))
16464 result = ctk_widget_path_copy (ctk_widget_get_path (attach_widget));
16465 else
16466 result = ctk_widget_path_new ();
16467
16468 ctk_widget_path_append_for_widget (result, widget);
16469
16470 return result;
16471 }
16472}
16473
16474/**
16475 * ctk_widget_get_path:
16476 * @widget: a #CtkWidget
16477 *
16478 * Returns the #CtkWidgetPath representing @widget, if the widget
16479 * is not connected to a toplevel widget, a partial path will be
16480 * created.
16481 *
16482 * Returns: (transfer none): The #CtkWidgetPath representing @widget
16483 **/
16484CtkWidgetPath *
16485ctk_widget_get_path (CtkWidget *widget)
16486{
16487 CtkWidgetPath *path;
16488
16489 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
16490
16491 path = (CtkWidgetPath*)g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_widget_path);
16492 if (!path)
16493 {
16494 path = _ctk_widget_create_path (widget);
16495 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
16496 quark_widget_path,
16497 path,
16498 (GDestroyNotify)ctk_widget_path_free);
16499 }
16500
16501 return path;
16502}
16503
16504void
16505ctk_widget_clear_path (CtkWidget *widget)
16506{
16507 g_object_set_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_widget_path, NULL((void*)0));
16508}
16509
16510/**
16511 * ctk_widget_class_set_css_name:
16512 * @widget_class: class to set the name on
16513 * @name: name to use
16514 *
16515 * Sets the name to be used for CSS matching of widgets.
16516 *
16517 * If this function is not called for a given class, the name
16518 * of the parent class is used.
16519 *
16520 * Since: 3.20
16521 */
16522void
16523ctk_widget_class_set_css_name (CtkWidgetClass *widget_class,
16524 const char *name)
16525{
16526 CtkWidgetClassPrivate *priv;
16527
16528 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
16529 g_return_if_fail (name != NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "name != NULL"); return;
} } while (0)
;
16530
16531 priv = widget_class->priv;
16532
16533 priv->css_name = g_intern_string (name);
16534}
16535
16536/**
16537 * ctk_widget_class_get_css_name:
16538 * @widget_class: class to set the name on
16539 *
16540 * Gets the name used by this class for matching in CSS code. See
16541 * ctk_widget_class_set_css_name() for details.
16542 *
16543 * Returns: the CSS name of the given class
16544 *
16545 * Since: 3.20
16546 */
16547const char *
16548ctk_widget_class_get_css_name (CtkWidgetClass *widget_class)
16549{
16550 g_return_val_if_fail (CTK_IS_WIDGET_CLASS (widget_class), NULL)do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return (((void*)0)); } } while (0)
;
16551
16552 return widget_class->priv->css_name;
16553}
16554
16555void
16556_ctk_widget_style_context_invalidated (CtkWidget *widget)
16557{
16558 g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
16559}
16560
16561CtkCssNode *
16562ctk_widget_get_css_node (CtkWidget *widget)
16563{
16564 return widget->priv->cssnode;
16565}
16566
16567CtkStyleContext *
16568_ctk_widget_peek_style_context (CtkWidget *widget)
16569{
16570 return widget->priv->context;
16571}
16572
16573
16574/**
16575 * ctk_widget_get_style_context:
16576 * @widget: a #CtkWidget
16577 *
16578 * Returns the style context associated to @widget. The returned object is
16579 * guaranteed to be the same for the lifetime of @widget.
16580 *
16581 * Returns: (transfer none): a #CtkStyleContext. This memory is owned by @widget and
16582 * must not be freed.
16583 **/
16584CtkStyleContext *
16585ctk_widget_get_style_context (CtkWidget *widget)
16586{
16587 CtkWidgetPrivate *priv;
16588
16589 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
16590
16591 priv = widget->priv;
16592
16593 if (G_UNLIKELY (priv->context == NULL)(priv->context == ((void*)0)))
16594 {
16595 CdkScreen *screen;
16596 CdkFrameClock *frame_clock;
16597
16598 priv->context = ctk_style_context_new_for_node (priv->cssnode);
16599
16600 ctk_style_context_set_id (priv->context, priv->name);
16601 ctk_style_context_set_state (priv->context, priv->state_flags);
16602 ctk_style_context_set_scale (priv->context, ctk_widget_get_scale_factor (widget));
16603
16604 screen = ctk_widget_get_screen (widget);
16605 if (screen)
16606 ctk_style_context_set_screen (priv->context, screen);
16607
16608 frame_clock = ctk_widget_get_frame_clock (widget);
16609 if (frame_clock)
16610 ctk_style_context_set_frame_clock (priv->context, frame_clock);
16611
16612 if (priv->parent)
16613 ctk_style_context_set_parent (priv->context,
16614 _ctk_widget_get_style_context (priv->parent));
16615 }
16616
16617 return widget->priv->context;
16618}
16619
16620void
16621_ctk_widget_invalidate_style_context (CtkWidget *widget,
16622 CtkCssChange change)
16623{
16624 ctk_css_node_invalidate (widget->priv->cssnode, change);
16625}
16626
16627/**
16628 * ctk_widget_get_modifier_mask:
16629 * @widget: a #CtkWidget
16630 * @intent: the use case for the modifier mask
16631 *
16632 * Returns the modifier mask the @widget’s windowing system backend
16633 * uses for a particular purpose.
16634 *
16635 * See cdk_keymap_get_modifier_mask().
16636 *
16637 * Returns: the modifier mask used for @intent.
16638 *
16639 * Since: 3.4
16640 **/
16641CdkModifierType
16642ctk_widget_get_modifier_mask (CtkWidget *widget,
16643 CdkModifierIntent intent)
16644{
16645 CdkDisplay *display;
16646
16647 g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (0); } } while (0)
;
16648
16649 display = ctk_widget_get_display (widget);
16650
16651 return cdk_keymap_get_modifier_mask (cdk_keymap_get_for_display (display),
16652 intent);
16653}
16654
16655CtkStyle *
16656_ctk_widget_get_style (CtkWidget *widget)
16657{
16658 return widget->priv->style;
16659}
16660
16661void
16662_ctk_widget_set_style (CtkWidget *widget,
16663 CtkStyle *style)
16664{
16665 widget->priv->style = style;
16666 g_signal_emit (widget, widget_signals[STYLE_SET], 0, widget->priv->style);
16667}
16668
16669CtkActionMuxer *
16670_ctk_widget_get_parent_muxer (CtkWidget *widget,
16671 gboolean create)
16672{
16673 CtkWidget *parent;
16674
16675 if (CTK_IS_WINDOW (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_window_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; }))))
)
16676 return ctk_application_get_parent_muxer_for_window (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_window_get_type ()))))))
);
16677
16678 if (CTK_IS_MENU (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_menu_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; }))))
)
16679 parent = ctk_menu_get_attach_widget (CTK_MENU (widget)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_menu_get_type ()))))))
);
16680 else if (CTK_IS_POPOVER (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = ((ctk_popover_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; }))))
)
16681 parent = ctk_popover_get_relative_to (CTK_POPOVER (widget)((((CtkPopover*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_popover_get_type ()))))))
);
16682 else
16683 parent = _ctk_widget_get_parent (widget);
16684
16685 if (parent)
16686 return _ctk_widget_get_action_muxer (parent, create);
16687
16688 return NULL((void*)0);
16689}
16690
16691void
16692_ctk_widget_update_parent_muxer (CtkWidget *widget)
16693{
16694 CtkActionMuxer *muxer;
16695
16696 muxer = (CtkActionMuxer*)g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_action_muxer);
16697 if (muxer == NULL((void*)0))
16698 return;
16699
16700 ctk_action_muxer_set_parent (muxer,
16701 _ctk_widget_get_parent_muxer (widget, TRUE(!(0))));
16702}
16703
16704CtkActionMuxer *
16705_ctk_widget_get_action_muxer (CtkWidget *widget,
16706 gboolean create)
16707{
16708 CtkActionMuxer *muxer;
16709
16710 muxer = (CtkActionMuxer*)g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_action_muxer);
16711 if (muxer)
16712 return muxer;
16713
16714 if (create)
16715 {
16716 muxer = ctk_action_muxer_new ();
16717 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
16718 quark_action_muxer,
16719 muxer,
16720 g_object_unref);
16721 _ctk_widget_update_parent_muxer (widget);
16722
16723 return muxer;
16724 }
16725 else
16726 return _ctk_widget_get_parent_muxer (widget, FALSE(0));
16727}
16728
16729/**
16730 * ctk_widget_insert_action_group:
16731 * @widget: a #CtkWidget
16732 * @name: the prefix for actions in @group
16733 * @group: (allow-none): a #GActionGroup, or %NULL
16734 *
16735 * Inserts @group into @widget. Children of @widget that implement
16736 * #CtkActionable can then be associated with actions in @group by
16737 * setting their “action-name” to
16738 * @prefix.`action-name`.
16739 *
16740 * If @group is %NULL, a previously inserted group for @name is removed
16741 * from @widget.
16742 *
16743 * Since: 3.6
16744 */
16745void
16746ctk_widget_insert_action_group (CtkWidget *widget,
16747 const gchar *name,
16748 GActionGroup *group)
16749{
16750 CtkActionMuxer *muxer;
16751
16752 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
16753 g_return_if_fail (name != NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "name != NULL"); return;
} } while (0)
;
16754
16755 muxer = _ctk_widget_get_action_muxer (widget, TRUE(!(0)));
16756
16757 if (group)
16758 ctk_action_muxer_insert (muxer, name, group);
16759 else
16760 ctk_action_muxer_remove (muxer, name);
16761}
16762
16763/****************************************************************
16764 * CtkBuilder automated templates *
16765 ****************************************************************/
16766static AutomaticChildClass *
16767template_child_class_new (const gchar *name,
16768 gboolean internal_child,
16769 gssize offset)
16770{
16771 AutomaticChildClass *child_class = g_slice_new0 (AutomaticChildClass)((AutomaticChildClass*) g_slice_alloc0 ((sizeof (AutomaticChildClass
) > 0 ? sizeof (AutomaticChildClass) : 1)))
;
16772
16773 child_class->name = g_strdup (name)g_strdup_inline (name);
16774 child_class->internal_child = internal_child;
16775 child_class->offset = offset;
16776
16777 return child_class;
16778}
16779
16780static void
16781template_child_class_free (AutomaticChildClass *child_class)
16782{
16783 if (child_class)
16784 {
16785 g_free (child_class->name);
16786 g_slice_free (AutomaticChildClass, child_class)do { if (1) g_slice_free1 (sizeof (AutomaticChildClass), (child_class
)); else (void) ((AutomaticChildClass*) 0 == (child_class)); }
while (0)
;
16787 }
16788}
16789
16790static CallbackSymbol *
16791callback_symbol_new (const gchar *name,
16792 GCallback callback)
16793{
16794 CallbackSymbol *cb = g_slice_new0 (CallbackSymbol)((CallbackSymbol*) g_slice_alloc0 ((sizeof (CallbackSymbol) >
0 ? sizeof (CallbackSymbol) : 1)))
;
16795
16796 cb->callback_name = g_strdup (name)g_strdup_inline (name);
16797 cb->callback_symbol = callback;
16798
16799 return cb;
16800}
16801
16802static void
16803callback_symbol_free (CallbackSymbol *callback)
16804{
16805 if (callback)
16806 {
16807 g_free (callback->callback_name);
16808 g_slice_free (CallbackSymbol, callback)do { if (1) g_slice_free1 (sizeof (CallbackSymbol), (callback
)); else (void) ((CallbackSymbol*) 0 == (callback)); } while (
0)
;
16809 }
16810}
16811
16812static void
16813template_data_free (CtkWidgetTemplate *template_data)
16814{
16815 if (template_data)
16816 {
16817 g_bytes_unref (template_data->data);
16818 g_slist_free_full (template_data->children, (GDestroyNotify)template_child_class_free);
16819 g_slist_free_full (template_data->callbacks, (GDestroyNotify)callback_symbol_free);
16820
16821 if (template_data->connect_data &&
16822 template_data->destroy_notify)
16823 template_data->destroy_notify (template_data->connect_data);
16824
16825 g_slice_free (CtkWidgetTemplate, template_data)do { if (1) g_slice_free1 (sizeof (CtkWidgetTemplate), (template_data
)); else (void) ((CtkWidgetTemplate*) 0 == (template_data)); }
while (0)
;
16826 }
16827}
16828
16829static GHashTable *
16830get_auto_child_hash (CtkWidget *widget,
16831 GType type,
16832 gboolean create)
16833{
16834 GHashTable *auto_children;
16835 GHashTable *auto_child_hash;
16836
16837 auto_children = (GHashTable *)g_object_get_qdata (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, quark_auto_children);
16838 if (auto_children == NULL((void*)0))
16839 {
16840 if (!create)
16841 return NULL((void*)0);
16842
16843 auto_children = g_hash_table_new_full (g_direct_hash,
16844 NULL((void*)0),
16845 NULL((void*)0), (GDestroyNotify)g_hash_table_destroy);
16846 g_object_set_qdata_full (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
,
16847 quark_auto_children,
16848 auto_children,
16849 (GDestroyNotify)g_hash_table_destroy);
16850 }
16851
16852 auto_child_hash =
16853 g_hash_table_lookup (auto_children, GSIZE_TO_POINTER (type)((gpointer) (guintptr) (gsize) (type)));
16854
16855 if (!auto_child_hash && create)
16856 {
16857 auto_child_hash = g_hash_table_new_full (g_str_hash,
16858 g_str_equal,
16859 NULL((void*)0),
16860 (GDestroyNotify)g_object_unref);
16861
16862 g_hash_table_insert (auto_children,
16863 GSIZE_TO_POINTER (type)((gpointer) (guintptr) (gsize) (type)),
16864 auto_child_hash);
16865 }
16866
16867 return auto_child_hash;
16868}
16869
16870static gboolean
16871setup_template_child (CtkWidgetTemplate *template_data G_GNUC_UNUSED__attribute__ ((__unused__)),
16872 GType class_type,
16873 AutomaticChildClass *child_class,
16874 CtkWidget *widget,
16875 CtkBuilder *builder)
16876{
16877 GHashTable *auto_child_hash;
16878 GObject *object;
16879
16880 object = ctk_builder_get_object (builder, child_class->name);
16881 if (!object)
16882 {
16883 g_critical ("Unable to retrieve object '%s' from class template for type '%s' while building a '%s'",
16884 child_class->name, g_type_name (class_type), G_OBJECT_TYPE_NAME (widget)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (widget))->
g_class))->g_type)))))
);
16885 return FALSE(0);
16886 }
16887
16888 /* Insert into the hash so that it can be fetched with
16889 * ctk_widget_get_template_child() and also in automated
16890 * implementations of CtkBuildable.get_internal_child()
16891 */
16892 auto_child_hash = get_auto_child_hash (widget, class_type, TRUE(!(0)));
16893 g_hash_table_insert (auto_child_hash, child_class->name, g_object_ref (object)((__typeof__ (object)) (g_object_ref) (object)));
16894
16895 if (child_class->offset != 0)
16896 {
16897 gpointer field_p;
16898
16899 /* Assign 'object' to the specified offset in the instance (or private) data */
16900 field_p = G_STRUCT_MEMBER_P (widget, child_class->offset)((gpointer) ((guint8*) (widget) + (glong) (child_class->offset
)))
;
16901 (* (gpointer *) field_p) = object;
16902 }
16903
16904 return TRUE(!(0));
16905}
16906
16907/**
16908 * ctk_widget_init_template:
16909 * @widget: a #CtkWidget
16910 *
16911 * Creates and initializes child widgets defined in templates. This
16912 * function must be called in the instance initializer for any
16913 * class which assigned itself a template using ctk_widget_class_set_template()
16914 *
16915 * It is important to call this function in the instance initializer
16916 * of a #CtkWidget subclass and not in #GObject.constructed() or
16917 * #GObject.constructor() for two reasons.
16918 *
16919 * One reason is that generally derived widgets will assume that parent
16920 * class composite widgets have been created in their instance
16921 * initializers.
16922 *
16923 * Another reason is that when calling g_object_new() on a widget with
16924 * composite templates, it’s important to build the composite widgets
16925 * before the construct properties are set. Properties passed to g_object_new()
16926 * should take precedence over properties set in the private template XML.
16927 *
16928 * Since: 3.10
16929 */
16930void
16931ctk_widget_init_template (CtkWidget *widget)
16932{
16933 CtkWidgetTemplate *template;
16934 CtkBuilder *builder;
16935 GError *error = NULL((void*)0);
16936 GObject *object;
16937 GSList *l;
16938 GType class_type;
16939
16940 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
16941
16942 object = G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
;
16943 class_type = G_OBJECT_TYPE (widget)(((((GTypeClass*) (((GTypeInstance*) (widget))->g_class))->
g_type)))
;
16944
16945 template = CTK_WIDGET_GET_CLASS (widget)((((CtkWidgetClass*) (((GTypeInstance*) ((widget)))->g_class
))))
->priv->template;
16946 g_return_if_fail (template != NULL)do { if ((template != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "template != NULL"); return
; } } while (0)
;
16947
16948 builder = ctk_builder_new ();
16949
16950 /* Add any callback symbols declared for this GType to the CtkBuilder namespace */
16951 for (l = template->callbacks; l; l = l->next)
16952 {
16953 CallbackSymbol *callback = l->data;
16954
16955 ctk_builder_add_callback_symbol (builder, callback->callback_name, callback->callback_symbol);
16956 }
16957
16958 /* This will build the template XML as children to the widget instance, also it
16959 * will validate that the template is created for the correct GType and assert that
16960 * there is no infinite recursion.
16961 */
16962 if (!ctk_builder_extend_with_template (builder, widget, class_type,
16963 (const gchar *)g_bytes_get_data (template->data, NULL((void*)0)),
16964 g_bytes_get_size (template->data),
16965 &error))
16966 {
16967 g_critical ("Error building template class '%s' for an instance of type '%s': %s",
16968 g_type_name (class_type), G_OBJECT_TYPE_NAME (object)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (object))->
g_class))->g_type)))))
, error->message);
16969 g_error_free (error);
16970
16971 /* This should never happen, if the template XML cannot be built
16972 * then it is a critical programming error.
16973 */
16974 g_object_unref (builder);
16975 return;
16976 }
16977
16978 /* Build the automatic child data
16979 */
16980 for (l = template->children; l; l = l->next)
16981 {
16982 AutomaticChildClass *child_class = l->data;
16983
16984 /* This will setup the pointer of an automated child, and cause
16985 * it to be available in any CtkBuildable.get_internal_child()
16986 * invocations which may follow by reference in child classes.
16987 */
16988 if (!setup_template_child (template,
16989 class_type,
16990 child_class,
16991 widget,
16992 builder))
16993 {
16994 g_object_unref (builder);
This statement is never executed
16995 return;
16996 }
16997 }
16998
16999 /* Connect signals. All signal data from a template receive the
17000 * template instance as user data automatically.
17001 *
17002 * A CtkBuilderConnectFunc can be provided to ctk_widget_class_set_signal_connect_func()
17003 * in order for templates to be usable by bindings.
17004 */
17005 if (template->connect_func)
17006 ctk_builder_connect_signals_full (builder, template->connect_func, template->connect_data);
17007 else
17008 ctk_builder_connect_signals (builder, object);
17009
17010 g_object_unref (builder);
17011}
17012
17013/**
17014 * ctk_widget_class_set_template:
17015 * @widget_class: A #CtkWidgetClass
17016 * @template_bytes: A #GBytes holding the #CtkBuilder XML
17017 *
17018 * This should be called at class initialization time to specify
17019 * the CtkBuilder XML to be used to extend a widget.
17020 *
17021 * For convenience, ctk_widget_class_set_template_from_resource() is also provided.
17022 *
17023 * Note that any class that installs templates must call ctk_widget_init_template()
17024 * in the widget’s instance initializer.
17025 *
17026 * Since: 3.10
17027 */
17028void
17029ctk_widget_class_set_template (CtkWidgetClass *widget_class,
17030 GBytes *template_bytes)
17031{
17032 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
17033 g_return_if_fail (widget_class->priv->template == NULL)do { if ((widget_class->priv->template == ((void*)0))) {
} else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "widget_class->priv->template == NULL"); return; } }
while (0)
;
17034 g_return_if_fail (template_bytes != NULL)do { if ((template_bytes != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "template_bytes != NULL"
); return; } } while (0)
;
17035
17036 widget_class->priv->template = g_slice_new0 (CtkWidgetTemplate)((CtkWidgetTemplate*) g_slice_alloc0 ((sizeof (CtkWidgetTemplate
) > 0 ? sizeof (CtkWidgetTemplate) : 1)))
;
17037 widget_class->priv->template->data = g_bytes_ref (template_bytes);
17038}
17039
17040/**
17041 * ctk_widget_class_set_template_from_resource:
17042 * @widget_class: A #CtkWidgetClass
17043 * @resource_name: The name of the resource to load the template from
17044 *
17045 * A convenience function to call ctk_widget_class_set_template().
17046 *
17047 * Note that any class that installs templates must call ctk_widget_init_template()
17048 * in the widget’s instance initializer.
17049 *
17050 * Since: 3.10
17051 */
17052void
17053ctk_widget_class_set_template_from_resource (CtkWidgetClass *widget_class,
17054 const gchar *resource_name)
17055{
17056 GError *error = NULL((void*)0);
17057 GBytes *bytes = NULL((void*)0);
17058
17059 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
17060 g_return_if_fail (widget_class->priv->template == NULL)do { if ((widget_class->priv->template == ((void*)0))) {
} else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "widget_class->priv->template == NULL"); return; } }
while (0)
;
17061 g_return_if_fail (resource_name && resource_name[0])do { if ((resource_name && resource_name[0])) { } else
{ g_return_if_fail_warning ("Ctk", ((const char*) (__func__)
), "resource_name && resource_name[0]"); return; } } while
(0)
;
17062
17063 /* This is a hack, because class initializers now access resources
17064 * and GIR/gtk-doc initializes classes without initializing CTK+,
17065 * we ensure that our base resources are registered here and
17066 * avoid warnings which building GIRs/documentation.
17067 */
17068 _ctk_ensure_resources ();
17069
17070 bytes = g_resources_lookup_data (resource_name, 0, &error);
17071 if (!bytes)
17072 {
17073 g_critical ("Unable to load resource for composite template for type '%s': %s",
17074 G_OBJECT_CLASS_NAME (widget_class)(g_type_name (((((GTypeClass*) (widget_class))->g_type)))), error->message);
17075 g_error_free (error);
17076 return;
17077 }
17078
17079 ctk_widget_class_set_template (widget_class, bytes);
17080 g_bytes_unref (bytes);
17081}
17082
17083/**
17084 * ctk_widget_class_bind_template_callback_full:
17085 * @widget_class: A #CtkWidgetClass
17086 * @callback_name: The name of the callback as expected in the template XML
17087 * @callback_symbol: (scope async): The callback symbol
17088 *
17089 * Declares a @callback_symbol to handle @callback_name from the template XML
17090 * defined for @widget_type. See ctk_builder_add_callback_symbol().
17091 *
17092 * Note that this must be called from a composite widget classes class
17093 * initializer after calling ctk_widget_class_set_template().
17094 *
17095 * Since: 3.10
17096 */
17097void
17098ctk_widget_class_bind_template_callback_full (CtkWidgetClass *widget_class,
17099 const gchar *callback_name,
17100 GCallback callback_symbol)
17101{
17102 CallbackSymbol *cb;
17103
17104 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
17105 g_return_if_fail (widget_class->priv->template != NULL)do { if ((widget_class->priv->template != ((void*)0))) {
} else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "widget_class->priv->template != NULL"); return; } }
while (0)
;
17106 g_return_if_fail (callback_name && callback_name[0])do { if ((callback_name && callback_name[0])) { } else
{ g_return_if_fail_warning ("Ctk", ((const char*) (__func__)
), "callback_name && callback_name[0]"); return; } } while
(0)
;
17107 g_return_if_fail (callback_symbol != NULL)do { if ((callback_symbol != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "callback_symbol != NULL"
); return; } } while (0)
;
17108
17109 cb = callback_symbol_new (callback_name, callback_symbol);
17110 widget_class->priv->template->callbacks = g_slist_prepend (widget_class->priv->template->callbacks, cb);
17111}
17112
17113/**
17114 * ctk_widget_class_set_connect_func:
17115 * @widget_class: A #CtkWidgetClass
17116 * @connect_func: The #CtkBuilderConnectFunc to use when connecting signals in the class template
17117 * @connect_data: The data to pass to @connect_func
17118 * @connect_data_destroy: The #GDestroyNotify to free @connect_data, this will only be used at
17119 * class finalization time, when no classes of type @widget_type are in use anymore.
17120 *
17121 * For use in language bindings, this will override the default #CtkBuilderConnectFunc to be
17122 * used when parsing CtkBuilder XML from this class’s template data.
17123 *
17124 * Note that this must be called from a composite widget classes class
17125 * initializer after calling ctk_widget_class_set_template().
17126 *
17127 * Since: 3.10
17128 */
17129void
17130ctk_widget_class_set_connect_func (CtkWidgetClass *widget_class,
17131 CtkBuilderConnectFunc connect_func,
17132 gpointer connect_data,
17133 GDestroyNotify connect_data_destroy)
17134{
17135 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
17136 g_return_if_fail (widget_class->priv->template != NULL)do { if ((widget_class->priv->template != ((void*)0))) {
} else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "widget_class->priv->template != NULL"); return; } }
while (0)
;
17137
17138 /* Defensive, destroy any previously set data */
17139 if (widget_class->priv->template->connect_data &&
17140 widget_class->priv->template->destroy_notify)
17141 widget_class->priv->template->destroy_notify (widget_class->priv->template->connect_data);
17142
17143 widget_class->priv->template->connect_func = connect_func;
17144 widget_class->priv->template->connect_data = connect_data;
17145 widget_class->priv->template->destroy_notify = connect_data_destroy;
17146}
17147
17148/**
17149 * ctk_widget_class_bind_template_child_full:
17150 * @widget_class: A #CtkWidgetClass
17151 * @name: The “id” of the child defined in the template XML
17152 * @internal_child: Whether the child should be accessible as an “internal-child”
17153 * when this class is used in CtkBuilder XML
17154 * @struct_offset: The structure offset into the composite widget’s instance public or private structure
17155 * where the automated child pointer should be set, or 0 to not assign the pointer.
17156 *
17157 * Automatically assign an object declared in the class template XML to be set to a location
17158 * on a freshly built instance’s private data, or alternatively accessible via ctk_widget_get_template_child().
17159 *
17160 * The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member)
17161 * for @struct_offset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).
17162 *
17163 * An explicit strong reference will be held automatically for the duration of your
17164 * instance’s life cycle, it will be released automatically when #GObjectClass.dispose() runs
17165 * on your instance and if a @struct_offset that is != 0 is specified, then the automatic location
17166 * in your instance public or private data will be set to %NULL. You can however access an automated child
17167 * pointer the first time your classes #GObjectClass.dispose() runs, or alternatively in
17168 * #CtkWidgetClass.destroy().
17169 *
17170 * If @internal_child is specified, #CtkBuildableIface.get_internal_child() will be automatically
17171 * implemented by the #CtkWidget class so there is no need to implement it manually.
17172 *
17173 * The wrapper macros ctk_widget_class_bind_template_child(), ctk_widget_class_bind_template_child_internal(),
17174 * ctk_widget_class_bind_template_child_private() and ctk_widget_class_bind_template_child_internal_private()
17175 * might be more convenient to use.
17176 *
17177 * Note that this must be called from a composite widget classes class
17178 * initializer after calling ctk_widget_class_set_template().
17179 *
17180 * Since: 3.10
17181 */
17182void
17183ctk_widget_class_bind_template_child_full (CtkWidgetClass *widget_class,
17184 const gchar *name,
17185 gboolean internal_child,
17186 gssize struct_offset)
17187{
17188 AutomaticChildClass *child_class;
17189
17190 g_return_if_fail (CTK_IS_WIDGET_CLASS (widget_class))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass
*) ((widget_class)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__class) __r = (0); else if (__class->g_type ==
__t) __r = (!(0)); else __r = g_type_check_class_is_a (__class
, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "CTK_IS_WIDGET_CLASS (widget_class)"
); return; } } while (0)
;
17191 g_return_if_fail (widget_class->priv->template != NULL)do { if ((widget_class->priv->template != ((void*)0))) {
} else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "widget_class->priv->template != NULL"); return; } }
while (0)
;
17192 g_return_if_fail (name && name[0])do { if ((name && name[0])) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "name && name[0]"
); return; } } while (0)
;
17193
17194 child_class = template_child_class_new (name,
17195 internal_child,
17196 struct_offset);
17197 widget_class->priv->template->children =
17198 g_slist_prepend (widget_class->priv->template->children, child_class);
17199}
17200
17201/**
17202 * ctk_widget_get_template_child:
17203 * @widget: A #CtkWidget
17204 * @widget_type: The #GType to get a template child for
17205 * @name: The “id” of the child defined in the template XML
17206 *
17207 * Fetch an object build from the template XML for @widget_type in this @widget instance.
17208 *
17209 * This will only report children which were previously declared with
17210 * ctk_widget_class_bind_template_child_full() or one of its
17211 * variants.
17212 *
17213 * This function is only meant to be called for code which is private to the @widget_type which
17214 * declared the child and is meant for language bindings which cannot easily make use
17215 * of the GObject structure offsets.
17216 *
17217 * Returns: (transfer none): The object built in the template XML with the id @name
17218 */
17219GObject *
17220ctk_widget_get_template_child (CtkWidget *widget,
17221 GType widget_type,
17222 const gchar *name)
17223{
17224 GHashTable *auto_child_hash;
17225 GObject *ret = NULL((void*)0);
17226
17227 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
17228 g_return_val_if_fail (g_type_name (widget_type) != NULL, NULL)do { if ((g_type_name (widget_type) != ((void*)0))) { } else {
g_return_if_fail_warning ("Ctk", ((const char*) (__func__)),
"g_type_name (widget_type) != NULL"); return (((void*)0)); }
} while (0)
;
17229 g_return_val_if_fail (name && name[0], NULL)do { if ((name && name[0])) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "name && name[0]"
); return (((void*)0)); } } while (0)
;
17230
17231 auto_child_hash = get_auto_child_hash (widget, widget_type, FALSE(0));
17232
17233 if (auto_child_hash)
17234 ret = g_hash_table_lookup (auto_child_hash, name);
17235
17236 return ret;
17237}
17238
17239/**
17240 * ctk_widget_list_action_prefixes:
17241 * @widget: A #CtkWidget
17242 *
17243 * Retrieves a %NULL-terminated array of strings containing the prefixes of
17244 * #GActionGroup's available to @widget.
17245 *
17246 * Returns: (transfer container): a %NULL-terminated array of strings.
17247 *
17248 * Since: 3.16
17249 */
17250const gchar **
17251ctk_widget_list_action_prefixes (CtkWidget *widget)
17252{
17253 CtkActionMuxer *muxer;
17254
17255 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
17256
17257 muxer = _ctk_widget_get_action_muxer (widget, FALSE(0));
17258 if (muxer)
17259 return ctk_action_muxer_list_prefixes (muxer);
17260
17261 return g_new0 (const gchar *, 1)((const gchar * *) g_malloc0_n ((1), sizeof (const gchar *)));
17262}
17263
17264/**
17265 * ctk_widget_get_action_group:
17266 * @widget: A #CtkWidget
17267 * @prefix: The “prefix” of the action group.
17268 *
17269 * Retrieves the #GActionGroup that was registered using @prefix. The resulting
17270 * #GActionGroup may have been registered to @widget or any #CtkWidget in its
17271 * ancestry.
17272 *
17273 * If no action group was found matching @prefix, then %NULL is returned.
17274 *
17275 * Returns: (transfer none) (nullable): A #GActionGroup or %NULL.
17276 *
17277 * Since: 3.16
17278 */
17279GActionGroup *
17280ctk_widget_get_action_group (CtkWidget *widget,
17281 const gchar *prefix)
17282{
17283 CtkActionMuxer *muxer;
17284
17285 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
17286 g_return_val_if_fail (prefix, NULL)do { if ((prefix)) { } else { g_return_if_fail_warning ("Ctk"
, ((const char*) (__func__)), "prefix"); return (((void*)0));
} } while (0)
;
17287
17288 muxer = _ctk_widget_get_action_muxer (widget, FALSE(0));
17289 if (muxer)
17290 return ctk_action_muxer_lookup (muxer, prefix);
17291
17292 return NULL((void*)0);
17293}
17294
17295static void
17296event_controller_grab_notify (CtkWidget *widget,
17297 gboolean was_grabbed G_GNUC_UNUSED__attribute__ ((__unused__)),
17298 EventControllerData *data)
17299{
17300 CdkDevice *device = NULL((void*)0);
17301
17302 if (CTK_IS_GESTURE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_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; }))))
)
17303 device = ctk_gesture_get_device (CTK_GESTURE (data->controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), ((ctk_gesture_get_type ()))))))
);
17304
17305 if (!device || !ctk_widget_device_is_shadowed (widget, device))
17306 return;
17307
17308 ctk_event_controller_reset (data->controller);
17309}
17310
17311static void
17312_ctk_widget_update_evmask (CtkWidget *widget)
17313{
17314 if (_ctk_widget_get_realized (widget))
17315 {
17316 gint events = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget),((gint) (glong) (g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_event_mask)))
17317 quark_event_mask))((gint) (glong) (g_object_get_qdata (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), quark_event_mask)))
;
17318 ctk_widget_add_events_internal (widget, NULL((void*)0), events);
17319 }
17320}
17321
17322static void
17323event_controller_sequence_state_changed (CtkGesture *gesture,
17324 CdkEventSequence *sequence,
17325 CtkEventSequenceState state,
17326 CtkWidget *widget)
17327{
17328 gboolean handled = FALSE(0);
17329 CtkWidget *event_widget;
17330 const CdkEvent *event;
17331
17332 handled = _ctk_widget_set_sequence_state_internal (widget, sequence,
17333 state, gesture);
17334
17335 if (!handled || state != CTK_EVENT_SEQUENCE_CLAIMED)
17336 return;
17337
17338 event = _ctk_widget_get_last_event (widget, sequence);
17339
17340 if (!event)
17341 return;
17342
17343 event_widget = ctk_get_event_widget ((CdkEvent *) event);
17344 cancel_event_sequence_on_hierarchy (widget, event_widget, sequence);
17345}
17346
17347static EventControllerData *
17348_ctk_widget_has_controller (CtkWidget *widget,
17349 CtkEventController *controller)
17350{
17351 EventControllerData *data;
17352 CtkWidgetPrivate *priv;
17353 GList *l;
17354
17355 priv = widget->priv;
17356
17357 for (l = priv->event_controllers; l; l = l->next)
17358 {
17359 data = l->data;
17360
17361 if (data->controller == controller)
17362 return data;
17363 }
17364
17365 return NULL((void*)0);
17366}
17367
17368void
17369_ctk_widget_add_controller (CtkWidget *widget,
17370 CtkEventController *controller)
17371{
17372 EventControllerData *data;
17373 CtkWidgetPrivate *priv;
17374
17375 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
17376 g_return_if_fail (CTK_IS_EVENT_CONTROLLER (controller))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((controller)); GType __t = ((ctk_event_controller_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_EVENT_CONTROLLER (controller)");
return; } } while (0)
;
17377 g_return_if_fail (widget == ctk_event_controller_get_widget (controller))do { if ((widget == ctk_event_controller_get_widget (controller
))) { } else { g_return_if_fail_warning ("Ctk", ((const char*
) (__func__)), "widget == ctk_event_controller_get_widget (controller)"
); return; } } while (0)
;
17378
17379 priv = widget->priv;
17380 data = _ctk_widget_has_controller (widget, controller);
17381
17382 if (data)
17383 return;
17384
17385 data = g_new0 (EventControllerData, 1)((EventControllerData *) g_malloc0_n ((1), sizeof (EventControllerData
)))
;
17386 data->controller = controller;
17387 data->grab_notify_id =
17388 g_signal_connect (widget, "grab-notify",g_signal_connect_data ((widget), ("grab-notify"), (((GCallback
) (event_controller_grab_notify))), (data), ((void*)0), (GConnectFlags
) 0)
17389 G_CALLBACK (event_controller_grab_notify), data)g_signal_connect_data ((widget), ("grab-notify"), (((GCallback
) (event_controller_grab_notify))), (data), ((void*)0), (GConnectFlags
) 0)
;
17390
17391 g_object_add_weak_pointer (G_OBJECT (data->controller)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), (((GType) ((20) << (2))))))
))
, (gpointer *) &data->controller);
17392
17393 if (CTK_IS_GESTURE (controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(controller)); GType __t = ((ctk_gesture_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; }))))
)
17394 {
17395 data->sequence_state_changed_id =
17396 g_signal_connect (controller, "sequence-state-changed",g_signal_connect_data ((controller), ("sequence-state-changed"
), (((GCallback) (event_controller_sequence_state_changed))),
(widget), ((void*)0), (GConnectFlags) 0)
17397 G_CALLBACK (event_controller_sequence_state_changed),g_signal_connect_data ((controller), ("sequence-state-changed"
), (((GCallback) (event_controller_sequence_state_changed))),
(widget), ((void*)0), (GConnectFlags) 0)
17398 widget)g_signal_connect_data ((controller), ("sequence-state-changed"
), (((GCallback) (event_controller_sequence_state_changed))),
(widget), ((void*)0), (GConnectFlags) 0)
;
17399 }
17400
17401 priv->event_controllers = g_list_prepend (priv->event_controllers, data);
17402 _ctk_widget_update_evmask (widget);
17403}
17404
17405void
17406_ctk_widget_remove_controller (CtkWidget *widget,
17407 CtkEventController *controller)
17408{
17409 EventControllerData *data;
17410
17411 g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return; } } while (0)
;
17412 g_return_if_fail (CTK_IS_EVENT_CONTROLLER (controller))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((controller)); GType __t = ((ctk_event_controller_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_EVENT_CONTROLLER (controller)");
return; } } while (0)
;
17413
17414 data = _ctk_widget_has_controller (widget, controller);
17415
17416 if (!data)
17417 return;
17418
17419 g_object_remove_weak_pointer (G_OBJECT (data->controller)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), (((GType) ((20) << (2))))))
))
, (gpointer *) &data->controller);
17420
17421 if (g_signal_handler_is_connected (widget, data->grab_notify_id))
17422 g_signal_handler_disconnect (widget, data->grab_notify_id);
17423
17424 if (data->sequence_state_changed_id)
17425 g_signal_handler_disconnect (data->controller, data->sequence_state_changed_id);
17426
17427 data->controller = NULL((void*)0);
17428}
17429
17430GList *
17431_ctk_widget_list_controllers (CtkWidget *widget,
17432 CtkPropagationPhase phase)
17433{
17434 EventControllerData *data;
17435 CtkWidgetPrivate *priv;
17436 GList *l, *retval = NULL((void*)0);
17437
17438 g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while
(0)
;
17439
17440 priv = widget->priv;
17441
17442 for (l = priv->event_controllers; l; l = l->next)
17443 {
17444 data = l->data;
17445
17446 if (data->controller != NULL((void*)0) &&
17447 phase == ctk_event_controller_get_propagation_phase (data->controller))
17448 retval = g_list_prepend (retval, data->controller);
17449 }
17450
17451 return retval;
17452}
17453
17454gboolean
17455_ctk_widget_consumes_motion (CtkWidget *widget,
17456 CdkEventSequence *sequence)
17457{
17458 EventControllerData *data;
17459 CtkWidgetPrivate *priv;
17460 GList *l;
17461
17462 g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0)
;
17463
17464 priv = widget->priv;
17465
17466 for (l = priv->event_controllers; l; l = l->next)
17467 {
17468 data = l->data;
17469
17470 if (data->controller == NULL((void*)0))
17471 continue;
17472
17473 if ((!CTK_IS_GESTURE_SINGLE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_single_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; }))))
||
17474 CTK_IS_GESTURE_DRAG (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_drag_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; }))))
||
17475 CTK_IS_GESTURE_SWIPE (data->controller)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data->controller)); GType __t = ((ctk_gesture_swipe_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; }))))
) &&
17476 ctk_gesture_handles_sequence (CTK_GESTURE (data->controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->controller)), ((ctk_gesture_get_type ()))))))
, sequence))
17477 return TRUE(!(0));
17478 }
17479
17480 return FALSE(0);
17481}
17482
17483void
17484ctk_widget_reset_controllers (CtkWidget *widget)
17485{
17486 EventControllerData *controller_data;
17487 CtkWidgetPrivate *priv = widget->priv;
17488 GList *l;
17489
17490 /* Reset all controllers */
17491 for (l = priv->event_controllers; l; l = l->next)
17492 {
17493 controller_data = l->data;
17494
17495 if (controller_data->controller == NULL((void*)0))
17496 continue;
17497
17498 ctk_event_controller_reset (controller_data->controller);
17499 }
17500}
17501
17502void
17503ctk_widget_render (CtkWidget *widget,
17504 CdkWindow *window,
17505 const cairo_region_t *region)
17506{
17507 CtkWidgetPrivate *priv = ctk_widget_get_instance_private (widget);
17508 CdkDrawingContext *context;
17509 gboolean do_clip;
17510 cairo_t *cr;
17511 int x, y;
17512 gboolean is_double_buffered;
17513
17514 /* We take the value here, in case somebody manages to changes
17515 * the double_buffered value inside a ::draw call, and ends up
17516 * breaking everything.
17517 */
17518 is_double_buffered = priv->double_buffered;
17519 if (is_double_buffered)
17520 {
17521 /* We only render double buffered on native windows */
17522 if (!cdk_window_has_native (window))
17523 return;
17524
17525 context = cdk_window_begin_draw_frame (window, region);
17526 cr = cdk_drawing_context_get_cairo_context (context);
17527 }
17528 else
17529 {
17530 /* This is annoying, but it has to stay because Firefox
17531 * disables double buffering on a top-level CdkWindow,
17532 * which breaks the drawing context.
17533 *
17534 * Candidate for deletion in the next major API bump.
17535 */
17536 cr = cdk_cairo_create (window);
17537 }
17538
17539 do_clip = _ctk_widget_get_translation_to_window (widget, window, &x, &y);
17540 cairo_translate (cr, -x, -y);
17541
17542 ctk_widget_draw_internal (widget, cr, do_clip);
17543
17544 if (is_double_buffered)
17545 cdk_window_end_draw_frame (window, context);
17546 else
17547 cairo_destroy (cr);
17548}