gtk/auto/widget.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 AccelFlags, AccelGroup, Align, Allocation, Buildable, Clipboard, DirectionType, DragResult,
7 Orientation, Requisition, SelectionData, Settings, SizeRequestMode, StateFlags, StyleContext,
8 TargetList, TextDirection, Tooltip, WidgetHelpType, WidgetPath, Window,
9};
10use glib::{
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::{boxed::Box as Box_, fmt, mem, mem::transmute};
16
17glib::wrapper! {
18 /// GtkWidget is the base class all widgets in GTK+ derive from. It manages the
19 /// widget lifecycle, states and style.
20 ///
21 /// # Height-for-width Geometry Management # {`geometry`-management}
22 ///
23 /// GTK+ uses a height-for-width (and width-for-height) geometry management
24 /// system. Height-for-width means that a widget can change how much
25 /// vertical space it needs, depending on the amount of horizontal space
26 /// that it is given (and similar for width-for-height). The most common
27 /// example is a label that reflows to fill up the available width, wraps
28 /// to fewer lines, and therefore needs less height.
29 ///
30 /// Height-for-width geometry management is implemented in GTK+ by way
31 /// of five virtual methods:
32 ///
33 /// - `GtkWidgetClass.get_request_mode()`
34 /// - `GtkWidgetClass.get_preferred_width()`
35 /// - `GtkWidgetClass.get_preferred_height()`
36 /// - `GtkWidgetClass.get_preferred_height_for_width()`
37 /// - `GtkWidgetClass.get_preferred_width_for_height()`
38 /// - `GtkWidgetClass.get_preferred_height_and_baseline_for_width()`
39 ///
40 /// There are some important things to keep in mind when implementing
41 /// height-for-width and when using it in container implementations.
42 ///
43 /// The geometry management system will query a widget hierarchy in
44 /// only one orientation at a time. When widgets are initially queried
45 /// for their minimum sizes it is generally done in two initial passes
46 /// in the [`SizeRequestMode`][crate::SizeRequestMode] chosen by the toplevel.
47 ///
48 /// For example, when queried in the normal
49 /// [`SizeRequestMode::HeightForWidth`][crate::SizeRequestMode::HeightForWidth] mode:
50 /// First, the default minimum and natural width for each widget
51 /// in the interface will be computed using [`WidgetExt::preferred_width()`][crate::prelude::WidgetExt::preferred_width()].
52 /// Because the preferred widths for each container depend on the preferred
53 /// widths of their children, this information propagates up the hierarchy,
54 /// and finally a minimum and natural width is determined for the entire
55 /// toplevel. Next, the toplevel will use the minimum width to query for the
56 /// minimum height contextual to that width using
57 /// [`WidgetExt::preferred_height_for_width()`][crate::prelude::WidgetExt::preferred_height_for_width()], which will also be a highly
58 /// recursive operation. The minimum height for the minimum width is normally
59 /// used to set the minimum size constraint on the toplevel
60 /// (unless [`GtkWindowExt::set_geometry_hints()`][crate::prelude::GtkWindowExt::set_geometry_hints()] is explicitly used instead).
61 ///
62 /// After the toplevel window has initially requested its size in both
63 /// dimensions it can go on to allocate itself a reasonable size (or a size
64 /// previously specified with [`GtkWindowExt::set_default_size()`][crate::prelude::GtkWindowExt::set_default_size()]). During the
65 /// recursive allocation process it’s important to note that request cycles
66 /// will be recursively executed while container widgets allocate their children.
67 /// Each container widget, once allocated a size, will go on to first share the
68 /// space in one orientation among its children and then request each child's
69 /// height for its target allocated width or its width for allocated height,
70 /// depending. In this way a [`Widget`][crate::Widget] will typically be requested its size
71 /// a number of times before actually being allocated a size. The size a
72 /// widget is finally allocated can of course differ from the size it has
73 /// requested. For this reason, [`Widget`][crate::Widget] caches a small number of results
74 /// to avoid re-querying for the same sizes in one allocation cycle.
75 ///
76 /// See
77 /// [GtkContainer’s geometry management section][container-geometry-management]
78 /// to learn more about how height-for-width allocations are performed
79 /// by container widgets.
80 ///
81 /// If a widget does move content around to intelligently use up the
82 /// allocated size then it must support the request in both
83 /// `GtkSizeRequestModes` even if the widget in question only
84 /// trades sizes in a single orientation.
85 ///
86 /// For instance, a [`Label`][crate::Label] that does height-for-width word wrapping
87 /// will not expect to have `GtkWidgetClass.get_preferred_height()` called
88 /// because that call is specific to a width-for-height request. In this
89 /// case the label must return the height required for its own minimum
90 /// possible width. By following this rule any widget that handles
91 /// height-for-width or width-for-height requests will always be allocated
92 /// at least enough space to fit its own content.
93 ///
94 /// Here are some examples of how a [`SizeRequestMode::HeightForWidth`][crate::SizeRequestMode::HeightForWidth] widget
95 /// generally deals with width-for-height requests, for `GtkWidgetClass.get_preferred_height()`
96 /// it will do:
97 ///
98 ///
99 ///
100 /// **⚠️ The following code is in C ⚠️**
101 ///
102 /// ```C
103 /// static void
104 /// foo_widget_get_preferred_height (GtkWidget *widget,
105 /// gint *min_height,
106 /// gint *nat_height)
107 /// {
108 /// if (i_am_in_height_for_width_mode)
109 /// {
110 /// gint min_width, nat_width;
111 ///
112 /// GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
113 /// &min_width,
114 /// &nat_width);
115 /// GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width
116 /// (widget,
117 /// min_width,
118 /// min_height,
119 /// nat_height);
120 /// }
121 /// else
122 /// {
123 /// ... some widgets do both. For instance, if a GtkLabel is
124 /// rotated to 90 degrees it will return the minimum and
125 /// natural height for the rotated label here.
126 /// }
127 /// }
128 /// ```
129 ///
130 /// And in `GtkWidgetClass.get_preferred_width_for_height()` it will simply return
131 /// the minimum and natural width:
132 ///
133 ///
134 /// **⚠️ The following code is in C ⚠️**
135 ///
136 /// ```C
137 /// static void
138 /// foo_widget_get_preferred_width_for_height (GtkWidget *widget,
139 /// gint for_height,
140 /// gint *min_width,
141 /// gint *nat_width)
142 /// {
143 /// if (i_am_in_height_for_width_mode)
144 /// {
145 /// GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
146 /// min_width,
147 /// nat_width);
148 /// }
149 /// else
150 /// {
151 /// ... again if a widget is sometimes operating in
152 /// width-for-height mode (like a rotated GtkLabel) it can go
153 /// ahead and do its real width for height calculation here.
154 /// }
155 /// }
156 /// ```
157 ///
158 /// Often a widget needs to get its own request during size request or
159 /// allocation. For example, when computing height it may need to also
160 /// compute width. Or when deciding how to use an allocation, the widget
161 /// may need to know its natural size. In these cases, the widget should
162 /// be careful to call its virtual methods directly, like this:
163 ///
164 ///
165 ///
166 /// **⚠️ The following code is in C ⚠️**
167 ///
168 /// ```C
169 /// GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget,
170 /// &min,
171 /// &natural);
172 /// ```
173 ///
174 /// It will not work to use the wrapper functions, such as
175 /// [`WidgetExt::preferred_width()`][crate::prelude::WidgetExt::preferred_width()] inside your own size request
176 /// implementation. These return a request adjusted by [`SizeGroup`][crate::SizeGroup]
177 /// and by the `GtkWidgetClass.adjust_size_request()` virtual method. If a
178 /// widget used the wrappers inside its virtual method implementations,
179 /// then the adjustments (such as widget margins) would be applied
180 /// twice. GTK+ therefore does not allow this and will warn if you try
181 /// to do it.
182 ///
183 /// Of course if you are getting the size request for
184 /// another widget, such as a child of a
185 /// container, you must use the wrapper APIs.
186 /// Otherwise, you would not properly consider widget margins,
187 /// [`SizeGroup`][crate::SizeGroup], and so forth.
188 ///
189 /// Since 3.10 GTK+ also supports baseline vertical alignment of widgets. This
190 /// means that widgets are positioned such that the typographical baseline of
191 /// widgets in the same row are aligned. This happens if a widget supports baselines,
192 /// has a vertical alignment of [`Align::Baseline`][crate::Align::Baseline], and is inside a container
193 /// that supports baselines and has a natural “row” that it aligns to the baseline,
194 /// or a baseline assigned to it by the grandparent.
195 ///
196 /// Baseline alignment support for a widget is done by the `GtkWidgetClass.get_preferred_height_and_baseline_for_width()`
197 /// virtual function. It allows you to report a baseline in combination with the
198 /// minimum and natural height. If there is no baseline you can return -1 to indicate
199 /// this. The default implementation of this virtual function calls into the
200 /// `GtkWidgetClass.get_preferred_height()` and `GtkWidgetClass.get_preferred_height_for_width()`,
201 /// so if baselines are not supported it doesn’t need to be implemented.
202 ///
203 /// If a widget ends up baseline aligned it will be allocated all the space in the parent
204 /// as if it was [`Align::Fill`][crate::Align::Fill], but the selected baseline can be found via [`WidgetExt::allocated_baseline()`][crate::prelude::WidgetExt::allocated_baseline()].
205 /// If this has a value other than -1 you need to align the widget such that the baseline
206 /// appears at the position.
207 ///
208 /// # Style Properties
209 ///
210 /// [`Widget`][crate::Widget] introduces “style
211 /// properties” - these are basically object properties that are stored
212 /// not on the object, but in the style object associated to the widget. Style
213 /// properties are set in [resource files][gtk3-Resource-Files].
214 /// This mechanism is used for configuring such things as the location of the
215 /// scrollbar arrows through the theme, giving theme authors more control over the
216 /// look of applications without the need to write a theme engine in C.
217 ///
218 /// Use `gtk_widget_class_install_style_property()` to install style properties for
219 /// a widget class, `gtk_widget_class_find_style_property()` or
220 /// `gtk_widget_class_list_style_properties()` to get information about existing
221 /// style properties and [`WidgetExt::style_get_property()`][crate::prelude::WidgetExt::style_get_property()], `gtk_widget_style_get()` or
222 /// `gtk_widget_style_get_valist()` to obtain the value of a style property.
223 ///
224 /// # GtkWidget as GtkBuildable
225 ///
226 /// The GtkWidget implementation of the GtkBuildable interface supports a
227 /// custom ``<accelerator>`` element, which has attributes named ”key”, ”modifiers”
228 /// and ”signal” and allows to specify accelerators.
229 ///
230 /// An example of a UI definition fragment specifying an accelerator:
231 ///
232 ///
233 ///
234 /// **⚠️ The following code is in xml ⚠️**
235 ///
236 /// ```xml
237 /// <object class="GtkButton">
238 /// <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
239 /// </object>
240 /// ```
241 ///
242 /// In addition to accelerators, GtkWidget also support a custom ``<accessible>``
243 /// element, which supports actions and relations. Properties on the accessible
244 /// implementation of an object can be set by accessing the internal child
245 /// “accessible” of a [`Widget`][crate::Widget].
246 ///
247 /// An example of a UI definition fragment specifying an accessible:
248 ///
249 ///
250 ///
251 /// **⚠️ The following code is in xml ⚠️**
252 ///
253 /// ```xml
254 /// <object class="GtkLabel" id="label1"/>
255 /// <property name="label">I am a Label for a Button</property>
256 /// </object>
257 /// <object class="GtkButton" id="button1">
258 /// <accessibility>
259 /// <action action_name="click" translatable="yes">Click the button.</action>
260 /// <relation target="label1" type="labelled-by"/>
261 /// </accessibility>
262 /// <child internal-child="accessible">
263 /// <object class="AtkObject" id="a11y-button1">
264 /// <property name="accessible-name">Clickable Button</property>
265 /// </object>
266 /// </child>
267 /// </object>
268 /// ```
269 ///
270 /// Finally, GtkWidget allows style information such as style classes to
271 /// be associated with widgets, using the custom ``<style>`` element:
272 ///
273 ///
274 ///
275 /// **⚠️ The following code is in xml ⚠️**
276 ///
277 /// ```xml
278 /// <object class="GtkButton" id="button1">
279 /// <style>
280 /// <class name="my-special-button-class"/>
281 /// <class name="dark-button"/>
282 /// </style>
283 /// </object>
284 /// ```
285 ///
286 /// # Building composite widgets from template XML ## {`composite`-templates}
287 ///
288 /// GtkWidget exposes some facilities to automate the procedure
289 /// of creating composite widgets using [`Builder`][crate::Builder] interface description
290 /// language.
291 ///
292 /// To create composite widgets with [`Builder`][crate::Builder] XML, one must associate
293 /// the interface description with the widget class at class initialization
294 /// time using `gtk_widget_class_set_template()`.
295 ///
296 /// The interface description semantics expected in composite template descriptions
297 /// is slightly different from regular [`Builder`][crate::Builder] XML.
298 ///
299 /// Unlike regular interface descriptions, `gtk_widget_class_set_template()` will
300 /// expect a ``<template>`` tag as a direct child of the toplevel ``<interface>``
301 /// tag. The ``<template>`` tag must specify the “class” attribute which must be
302 /// the type name of the widget. Optionally, the “parent” attribute may be
303 /// specified to specify the direct parent type of the widget type, this is
304 /// ignored by the GtkBuilder but required for Glade to introspect what kind
305 /// of properties and internal children exist for a given type when the actual
306 /// type does not exist.
307 ///
308 /// The XML which is contained inside the ``<template>`` tag behaves as if it were
309 /// added to the ``<object>`` tag defining "widget" itself. You may set properties
310 /// on `widget` by inserting ``<property>`` tags into the ``<template>`` tag, and also
311 /// add ``<child>`` tags to add children and extend "widget" in the normal way you
312 /// would with ``<object>`` tags.
313 ///
314 /// Additionally, ``<object>`` tags can also be added before and after the initial
315 /// ``<template>`` tag in the normal way, allowing one to define auxiliary objects
316 /// which might be referenced by other widgets declared as children of the
317 /// ``<template>`` tag.
318 ///
319 /// An example of a GtkBuilder Template Definition:
320 ///
321 ///
322 ///
323 /// **⚠️ The following code is in xml ⚠️**
324 ///
325 /// ```xml
326 /// <interface>
327 /// <template class="FooWidget" parent="GtkBox">
328 /// <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
329 /// <property name="spacing">4</property>
330 /// <child>
331 /// <object class="GtkButton" id="hello_button">
332 /// <property name="label">Hello World</property>
333 /// <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/>
334 /// </object>
335 /// </child>
336 /// <child>
337 /// <object class="GtkButton" id="goodbye_button">
338 /// <property name="label">Goodbye World</property>
339 /// </object>
340 /// </child>
341 /// </template>
342 /// </interface>
343 /// ```
344 ///
345 /// Typically, you'll place the template fragment into a file that is
346 /// bundled with your project, using `GResource`. In order to load the
347 /// template, you need to call `gtk_widget_class_set_template_from_resource()`
348 /// from the class initialization of your [`Widget`][crate::Widget] type:
349 ///
350 ///
351 ///
352 /// **⚠️ The following code is in C ⚠️**
353 ///
354 /// ```C
355 /// static void
356 /// foo_widget_class_init (FooWidgetClass *klass)
357 /// {
358 /// // ...
359 ///
360 /// gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
361 /// "/com/example/ui/foowidget.ui");
362 /// }
363 /// ```
364 ///
365 /// You will also need to call [`WidgetExt::init_template()`][crate::prelude::WidgetExt::init_template()] from the instance
366 /// initialization function:
367 ///
368 ///
369 ///
370 /// **⚠️ The following code is in C ⚠️**
371 ///
372 /// ```C
373 /// static void
374 /// foo_widget_init (FooWidget *self)
375 /// {
376 /// // ...
377 /// gtk_widget_init_template (GTK_WIDGET (self));
378 /// }
379 /// ```
380 ///
381 /// You can access widgets defined in the template using the
382 /// [`WidgetExt::template_child()`][crate::prelude::WidgetExt::template_child()] function, but you will typically declare
383 /// a pointer in the instance private data structure of your type using the same
384 /// name as the widget in the template definition, and call
385 /// `gtk_widget_class_bind_template_child_private()` with that name, e.g.
386 ///
387 ///
388 ///
389 /// **⚠️ The following code is in C ⚠️**
390 ///
391 /// ```C
392 /// typedef struct {
393 /// GtkWidget *hello_button;
394 /// GtkWidget *goodbye_button;
395 /// } FooWidgetPrivate;
396 ///
397 /// G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, GTK_TYPE_BOX)
398 ///
399 /// static void
400 /// foo_widget_class_init (FooWidgetClass *klass)
401 /// {
402 /// // ...
403 /// gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
404 /// "/com/example/ui/foowidget.ui");
405 /// gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
406 /// FooWidget, hello_button);
407 /// gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
408 /// FooWidget, goodbye_button);
409 /// }
410 ///
411 /// static void
412 /// foo_widget_init (FooWidget *widget)
413 /// {
414 ///
415 /// }
416 /// ```
417 ///
418 /// You can also use `gtk_widget_class_bind_template_callback()` to connect a signal
419 /// callback defined in the template with a function visible in the scope of the
420 /// class, e.g.
421 ///
422 ///
423 ///
424 /// **⚠️ The following code is in C ⚠️**
425 ///
426 /// ```C
427 /// // the signal handler has the instance and user data swapped
428 /// // because of the swapped="yes" attribute in the template XML
429 /// static void
430 /// hello_button_clicked (FooWidget *self,
431 /// GtkButton *button)
432 /// {
433 /// g_print ("Hello, world!\n");
434 /// }
435 ///
436 /// static void
437 /// foo_widget_class_init (FooWidgetClass *klass)
438 /// {
439 /// // ...
440 /// gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
441 /// "/com/example/ui/foowidget.ui");
442 /// gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked);
443 /// }
444 /// ```
445 ///
446 /// This is an Abstract Base Class, you cannot instantiate it.
447 ///
448 /// ## Properties
449 ///
450 ///
451 /// #### `app-paintable`
452 /// Readable | Writeable
453 ///
454 ///
455 /// #### `can-default`
456 /// Readable | Writeable
457 ///
458 ///
459 /// #### `can-focus`
460 /// Readable | Writeable
461 ///
462 ///
463 /// #### `composite-child`
464 /// Readable
465 ///
466 ///
467 /// #### `double-buffered`
468 /// Whether the widget is double buffered.
469 ///
470 /// Readable | Writeable
471 ///
472 ///
473 /// #### `events`
474 /// Readable | Writeable
475 ///
476 ///
477 /// #### `expand`
478 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
479 ///
480 /// Readable | Writeable
481 ///
482 ///
483 /// #### `focus-on-click`
484 /// Whether the widget should grab focus when it is clicked with the mouse.
485 ///
486 /// This property is only relevant for widgets that can take focus.
487 ///
488 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
489 /// GtkComboBox) implemented this property individually.
490 ///
491 /// Readable | Writeable
492 ///
493 ///
494 /// #### `halign`
495 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
496 ///
497 /// Readable | Writeable
498 ///
499 ///
500 /// #### `has-default`
501 /// Readable | Writeable
502 ///
503 ///
504 /// #### `has-focus`
505 /// Readable | Writeable
506 ///
507 ///
508 /// #### `has-tooltip`
509 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
510 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
511 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
512 /// whether it will provide a tooltip or not.
513 ///
514 /// Note that setting this property to [`true`] for the first time will change
515 /// the event masks of the GdkWindows of this widget to include leave-notify
516 /// and motion-notify events. This cannot and will not be undone when the
517 /// property is set to [`false`] again.
518 ///
519 /// Readable | Writeable
520 ///
521 ///
522 /// #### `height-request`
523 /// Readable | Writeable
524 ///
525 ///
526 /// #### `hexpand`
527 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
528 ///
529 /// Readable | Writeable
530 ///
531 ///
532 /// #### `hexpand-set`
533 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
534 ///
535 /// Readable | Writeable
536 ///
537 ///
538 /// #### `is-focus`
539 /// Readable | Writeable
540 ///
541 ///
542 /// #### `margin`
543 /// Sets all four sides' margin at once. If read, returns max
544 /// margin on any side.
545 ///
546 /// Readable | Writeable
547 ///
548 ///
549 /// #### `margin-bottom`
550 /// Margin on bottom side of widget.
551 ///
552 /// This property adds margin outside of the widget's normal size
553 /// request, the margin will be added in addition to the size from
554 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
555 ///
556 /// Readable | Writeable
557 ///
558 ///
559 /// #### `margin-end`
560 /// Margin on end of widget, horizontally. This property supports
561 /// left-to-right and right-to-left text directions.
562 ///
563 /// This property adds margin outside of the widget's normal size
564 /// request, the margin will be added in addition to the size from
565 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
566 ///
567 /// Readable | Writeable
568 ///
569 ///
570 /// #### `margin-left`
571 /// Margin on left side of widget.
572 ///
573 /// This property adds margin outside of the widget's normal size
574 /// request, the margin will be added in addition to the size from
575 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
576 ///
577 /// Readable | Writeable
578 ///
579 ///
580 /// #### `margin-right`
581 /// Margin on right side of widget.
582 ///
583 /// This property adds margin outside of the widget's normal size
584 /// request, the margin will be added in addition to the size from
585 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
586 ///
587 /// Readable | Writeable
588 ///
589 ///
590 /// #### `margin-start`
591 /// Margin on start of widget, horizontally. This property supports
592 /// left-to-right and right-to-left text directions.
593 ///
594 /// This property adds margin outside of the widget's normal size
595 /// request, the margin will be added in addition to the size from
596 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
597 ///
598 /// Readable | Writeable
599 ///
600 ///
601 /// #### `margin-top`
602 /// Margin on top side of widget.
603 ///
604 /// This property adds margin outside of the widget's normal size
605 /// request, the margin will be added in addition to the size from
606 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
607 ///
608 /// Readable | Writeable
609 ///
610 ///
611 /// #### `name`
612 /// Readable | Writeable
613 ///
614 ///
615 /// #### `no-show-all`
616 /// Readable | Writeable
617 ///
618 ///
619 /// #### `opacity`
620 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
621 /// more details about window opacity.
622 ///
623 /// Before 3.8 this was only available in GtkWindow
624 ///
625 /// Readable | Writeable
626 ///
627 ///
628 /// #### `parent`
629 /// Readable | Writeable
630 ///
631 ///
632 /// #### `receives-default`
633 /// Readable | Writeable
634 ///
635 ///
636 /// #### `scale-factor`
637 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
638 /// more details about widget scaling.
639 ///
640 /// Readable
641 ///
642 ///
643 /// #### `sensitive`
644 /// Readable | Writeable
645 ///
646 ///
647 /// #### `style`
648 /// The style of the widget, which contains information about how it will look (colors, etc).
649 ///
650 /// Readable | Writeable
651 ///
652 ///
653 /// #### `tooltip-markup`
654 /// Sets the text of tooltip to be the given string, which is marked up
655 /// with the [Pango text markup language][PangoMarkupFormat].
656 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
657 ///
658 /// This is a convenience property which will take care of getting the
659 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
660 /// will automatically be set to [`true`] and there will be taken care of
661 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
662 ///
663 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
664 /// are set, the last one wins.
665 ///
666 /// Readable | Writeable
667 ///
668 ///
669 /// #### `tooltip-text`
670 /// Sets the text of tooltip to be the given string.
671 ///
672 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
673 ///
674 /// This is a convenience property which will take care of getting the
675 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
676 /// will automatically be set to [`true`] and there will be taken care of
677 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
678 ///
679 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
680 /// are set, the last one wins.
681 ///
682 /// Readable | Writeable
683 ///
684 ///
685 /// #### `valign`
686 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
687 ///
688 /// Readable | Writeable
689 ///
690 ///
691 /// #### `vexpand`
692 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
693 ///
694 /// Readable | Writeable
695 ///
696 ///
697 /// #### `vexpand-set`
698 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
699 ///
700 /// Readable | Writeable
701 ///
702 ///
703 /// #### `visible`
704 /// Readable | Writeable
705 ///
706 ///
707 /// #### `width-request`
708 /// Readable | Writeable
709 ///
710 ///
711 /// #### `window`
712 /// The widget's window if it is realized, [`None`] otherwise.
713 ///
714 /// Readable
715 ///
716 /// ## Signals
717 ///
718 ///
719 /// #### `accel-closures-changed`
720 ///
721 ///
722 ///
723 /// #### `button-press-event`
724 /// The ::button-press-event signal will be emitted when a button
725 /// (typically from a mouse) is pressed.
726 ///
727 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
728 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
729 ///
730 /// This signal will be sent to the grab widget if there is one.
731 ///
732 ///
733 ///
734 ///
735 /// #### `button-release-event`
736 /// The ::button-release-event signal will be emitted when a button
737 /// (typically from a mouse) is released.
738 ///
739 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
740 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
741 ///
742 /// This signal will be sent to the grab widget if there is one.
743 ///
744 ///
745 ///
746 ///
747 /// #### `can-activate-accel`
748 /// Determines whether an accelerator that activates the signal
749 /// identified by `signal_id` can currently be activated.
750 /// This signal is present to allow applications and derived
751 /// widgets to override the default [`Widget`][crate::Widget] handling
752 /// for determining whether an accelerator can be activated.
753 ///
754 ///
755 ///
756 ///
757 /// #### `child-notify`
758 /// The ::child-notify signal is emitted for each
759 /// [child property][child-properties] that has
760 /// changed on an object. The signal's detail holds the property name.
761 ///
762 /// Detailed
763 ///
764 ///
765 /// #### `composited-changed`
766 /// The ::composited-changed signal is emitted when the composited
767 /// status of `widgets` screen changes.
768 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
769 ///
770 /// Action
771 ///
772 ///
773 /// #### `configure-event`
774 /// The ::configure-event signal will be emitted when the size, position or
775 /// stacking of the `widget`'s window has changed.
776 ///
777 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
778 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
779 /// automatically for all new windows.
780 ///
781 ///
782 ///
783 ///
784 /// #### `damage-event`
785 /// Emitted when a redirected window belonging to `widget` gets drawn into.
786 /// The region/area members of the event shows what area of the redirected
787 /// drawable was drawn into.
788 ///
789 ///
790 ///
791 ///
792 /// #### `delete-event`
793 /// The ::delete-event signal is emitted if a user requests that
794 /// a toplevel window is closed. The default handler for this signal
795 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
796 /// this signal will cause the window to be hidden instead, so that
797 /// it can later be shown again without reconstructing it.
798 ///
799 ///
800 ///
801 ///
802 /// #### `destroy`
803 /// Signals that all holders of a reference to the widget should release
804 /// the reference that they hold. May result in finalization of the widget
805 /// if all references are released.
806 ///
807 /// This signal is not suitable for saving widget state.
808 ///
809 ///
810 ///
811 ///
812 /// #### `destroy-event`
813 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
814 /// You rarely get this signal, because most widgets disconnect themselves
815 /// from their window before they destroy it, so no widget owns the
816 /// window at destroy time.
817 ///
818 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
819 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
820 /// automatically for all new windows.
821 ///
822 ///
823 ///
824 ///
825 /// #### `direction-changed`
826 /// The ::direction-changed signal is emitted when the text direction
827 /// of a widget changes.
828 ///
829 ///
830 ///
831 ///
832 /// #### `drag-begin`
833 /// The ::drag-begin signal is emitted on the drag source when a drag is
834 /// started. A typical reason to connect to this signal is to set up a
835 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
836 ///
837 /// Note that some widgets set up a drag icon in the default handler of
838 /// this signal, so you may have to use `g_signal_connect_after()` to
839 /// override what the default handler did.
840 ///
841 ///
842 ///
843 ///
844 /// #### `drag-data-delete`
845 /// The ::drag-data-delete signal is emitted on the drag source when a drag
846 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
847 /// handler is responsible for deleting the data that has been dropped. What
848 /// "delete" means depends on the context of the drag operation.
849 ///
850 ///
851 ///
852 ///
853 /// #### `drag-data-get`
854 /// The ::drag-data-get signal is emitted on the drag source when the drop
855 /// site requests the data which is dragged. It is the responsibility of
856 /// the signal handler to fill `data` with the data in the format which
857 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
858 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
859 ///
860 ///
861 ///
862 ///
863 /// #### `drag-data-received`
864 /// The ::drag-data-received signal is emitted on the drop site when the
865 /// dragged data has been received. If the data was received in order to
866 /// determine whether the drop will be accepted, the handler is expected
867 /// to call `gdk_drag_status()` and not finish the drag.
868 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
869 /// (and this is the last target to be received), the handler for this
870 /// signal is expected to process the received data and then call
871 /// `gtk_drag_finish()`, setting the `success` parameter depending on
872 /// whether the data was processed successfully.
873 ///
874 /// Applications must create some means to determine why the signal was emitted
875 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
876 ///
877 /// The handler may inspect the selected action with
878 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
879 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
880 /// shown in the following example:
881 ///
882 ///
883 /// **⚠️ The following code is in C ⚠️**
884 ///
885 /// ```C
886 /// void
887 /// drag_data_received (GtkWidget *widget,
888 /// GdkDragContext *context,
889 /// gint x,
890 /// gint y,
891 /// GtkSelectionData *data,
892 /// guint info,
893 /// guint time)
894 /// {
895 /// if ((data->length >= 0) && (data->format == 8))
896 /// {
897 /// GdkDragAction action;
898 ///
899 /// // handle data here
900 ///
901 /// action = gdk_drag_context_get_selected_action (context);
902 /// if (action == GDK_ACTION_ASK)
903 /// {
904 /// GtkWidget *dialog;
905 /// gint response;
906 ///
907 /// dialog = gtk_message_dialog_new (NULL,
908 /// GTK_DIALOG_MODAL |
909 /// GTK_DIALOG_DESTROY_WITH_PARENT,
910 /// GTK_MESSAGE_INFO,
911 /// GTK_BUTTONS_YES_NO,
912 /// "Move the data ?\n");
913 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
914 /// gtk_widget_destroy (dialog);
915 ///
916 /// if (response == GTK_RESPONSE_YES)
917 /// action = GDK_ACTION_MOVE;
918 /// else
919 /// action = GDK_ACTION_COPY;
920 /// }
921 ///
922 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
923 /// }
924 /// else
925 /// gtk_drag_finish (context, FALSE, FALSE, time);
926 /// }
927 /// ```
928 ///
929 ///
930 ///
931 ///
932 /// #### `drag-drop`
933 /// The ::drag-drop signal is emitted on the drop site when the user drops
934 /// the data onto the widget. The signal handler must determine whether
935 /// the cursor position is in a drop zone or not. If it is not in a drop
936 /// zone, it returns [`false`] and no further processing is necessary.
937 /// Otherwise, the handler returns [`true`]. In this case, the handler must
938 /// ensure that `gtk_drag_finish()` is called to let the source know that
939 /// the drop is done. The call to `gtk_drag_finish()` can be done either
940 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
941 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
942 /// or more of the supported targets.
943 ///
944 ///
945 ///
946 ///
947 /// #### `drag-end`
948 /// The ::drag-end signal is emitted on the drag source when a drag is
949 /// finished. A typical reason to connect to this signal is to undo
950 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
951 ///
952 ///
953 ///
954 ///
955 /// #### `drag-failed`
956 /// The ::drag-failed signal is emitted on the drag source when a drag has
957 /// failed. The signal handler may hook custom code to handle a failed DnD
958 /// operation based on the type of error, it returns [`true`] is the failure has
959 /// been already handled (not showing the default "drag operation failed"
960 /// animation), otherwise it returns [`false`].
961 ///
962 ///
963 ///
964 ///
965 /// #### `drag-leave`
966 /// The ::drag-leave signal is emitted on the drop site when the cursor
967 /// leaves the widget. A typical reason to connect to this signal is to
968 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
969 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
970 ///
971 ///
972 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
973 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
974 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
975 ///
976 ///
977 ///
978 ///
979 /// #### `drag-motion`
980 /// The ::drag-motion signal is emitted on the drop site when the user
981 /// moves the cursor over the widget during a drag. The signal handler
982 /// must determine whether the cursor position is in a drop zone or not.
983 /// If it is not in a drop zone, it returns [`false`] and no further processing
984 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
985 /// handler is responsible for providing the necessary information for
986 /// displaying feedback to the user, by calling `gdk_drag_status()`.
987 ///
988 /// If the decision whether the drop will be accepted or rejected can't be
989 /// made based solely on the cursor position and the type of the data, the
990 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
991 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
992 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
993 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
994 /// when using the drag-motion signal that way.
995 ///
996 /// Also note that there is no drag-enter signal. The drag receiver has to
997 /// keep track of whether he has received any drag-motion signals since the
998 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
999 /// an "enter" signal. Upon an "enter", the handler will typically highlight
1000 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
1001 ///
1002 ///
1003 /// **⚠️ The following code is in C ⚠️**
1004 ///
1005 /// ```C
1006 /// static void
1007 /// drag_motion (GtkWidget *widget,
1008 /// GdkDragContext *context,
1009 /// gint x,
1010 /// gint y,
1011 /// guint time)
1012 /// {
1013 /// GdkAtom target;
1014 ///
1015 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
1016 ///
1017 /// if (!private_data->drag_highlight)
1018 /// {
1019 /// private_data->drag_highlight = 1;
1020 /// gtk_drag_highlight (widget);
1021 /// }
1022 ///
1023 /// target = gtk_drag_dest_find_target (widget, context, NULL);
1024 /// if (target == GDK_NONE)
1025 /// gdk_drag_status (context, 0, time);
1026 /// else
1027 /// {
1028 /// private_data->pending_status
1029 /// = gdk_drag_context_get_suggested_action (context);
1030 /// gtk_drag_get_data (widget, context, target, time);
1031 /// }
1032 ///
1033 /// return TRUE;
1034 /// }
1035 ///
1036 /// static void
1037 /// drag_data_received (GtkWidget *widget,
1038 /// GdkDragContext *context,
1039 /// gint x,
1040 /// gint y,
1041 /// GtkSelectionData *selection_data,
1042 /// guint info,
1043 /// guint time)
1044 /// {
1045 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
1046 ///
1047 /// if (private_data->suggested_action)
1048 /// {
1049 /// private_data->suggested_action = 0;
1050 ///
1051 /// // We are getting this data due to a request in drag_motion,
1052 /// // rather than due to a request in drag_drop, so we are just
1053 /// // supposed to call gdk_drag_status(), not actually paste in
1054 /// // the data.
1055 ///
1056 /// str = gtk_selection_data_get_text (selection_data);
1057 /// if (!data_is_acceptable (str))
1058 /// gdk_drag_status (context, 0, time);
1059 /// else
1060 /// gdk_drag_status (context,
1061 /// private_data->suggested_action,
1062 /// time);
1063 /// }
1064 /// else
1065 /// {
1066 /// // accept the drop
1067 /// }
1068 /// }
1069 /// ```
1070 ///
1071 ///
1072 ///
1073 ///
1074 /// #### `draw`
1075 /// This signal is emitted when a widget is supposed to render itself.
1076 /// The `widget`'s top left corner must be painted at the origin of
1077 /// the passed in context and be sized to the values returned by
1078 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
1079 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
1080 ///
1081 /// Signal handlers connected to this signal can modify the cairo
1082 /// context passed as `cr` in any way they like and don't need to
1083 /// restore it. The signal emission takes care of calling `cairo_save()`
1084 /// before and `cairo_restore()` after invoking the handler.
1085 ///
1086 /// The signal handler will get a `cr` with a clip region already set to the
1087 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
1088 /// widgets that want to avoid redrawing themselves completely can get the full
1089 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
1090 /// get a finer-grained representation of the dirty region with
1091 /// `cairo_copy_clip_rectangle_list()`.
1092 ///
1093 ///
1094 ///
1095 ///
1096 /// #### `enter-notify-event`
1097 /// The ::enter-notify-event will be emitted when the pointer enters
1098 /// the `widget`'s window.
1099 ///
1100 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1101 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
1102 ///
1103 /// This signal will be sent to the grab widget if there is one.
1104 ///
1105 ///
1106 ///
1107 ///
1108 /// #### `event`
1109 /// The GTK+ main loop will emit three signals for each GDK event delivered
1110 /// to a widget: one generic ::event signal, another, more specific,
1111 /// signal that matches the type of event delivered (e.g.
1112 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
1113 /// [`event-after`][struct@crate::Widget#event-after] signal.
1114 ///
1115 ///
1116 ///
1117 ///
1118 /// #### `event-after`
1119 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
1120 /// the second more specific signal, ::event-after will be emitted
1121 /// regardless of the previous two signals handlers return values.
1122 ///
1123 ///
1124 ///
1125 ///
1126 /// #### `focus`
1127 ///
1128 ///
1129 ///
1130 /// #### `focus-in-event`
1131 /// The ::focus-in-event signal will be emitted when the keyboard focus
1132 /// enters the `widget`'s window.
1133 ///
1134 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1135 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1136 ///
1137 ///
1138 ///
1139 ///
1140 /// #### `focus-out-event`
1141 /// The ::focus-out-event signal will be emitted when the keyboard focus
1142 /// leaves the `widget`'s window.
1143 ///
1144 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1145 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1146 ///
1147 ///
1148 ///
1149 ///
1150 /// #### `grab-broken-event`
1151 /// Emitted when a pointer or keyboard grab on a window belonging
1152 /// to `widget` gets broken.
1153 ///
1154 /// On X11, this happens when the grab window becomes unviewable
1155 /// (i.e. it or one of its ancestors is unmapped), or if the same
1156 /// application grabs the pointer or keyboard again.
1157 ///
1158 ///
1159 ///
1160 ///
1161 /// #### `grab-focus`
1162 /// Action
1163 ///
1164 ///
1165 /// #### `grab-notify`
1166 /// The ::grab-notify signal is emitted when a widget becomes
1167 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1168 /// another widget, or when it becomes unshadowed due to a grab
1169 /// being removed.
1170 ///
1171 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
1172 /// grab widget in the grab stack of its window group is not
1173 /// its ancestor.
1174 ///
1175 ///
1176 ///
1177 ///
1178 /// #### `hide`
1179 /// The ::hide signal is emitted when `widget` is hidden, for example with
1180 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
1181 ///
1182 ///
1183 ///
1184 ///
1185 /// #### `hierarchy-changed`
1186 /// The ::hierarchy-changed signal is emitted when the
1187 /// anchored state of a widget changes. A widget is
1188 /// “anchored” when its toplevel
1189 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
1190 /// a widget changes from un-anchored to anchored or vice-versa.
1191 ///
1192 ///
1193 ///
1194 ///
1195 /// #### `key-press-event`
1196 /// The ::key-press-event signal is emitted when a key is pressed. The signal
1197 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
1198 ///
1199 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1200 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
1201 ///
1202 /// This signal will be sent to the grab widget if there is one.
1203 ///
1204 ///
1205 ///
1206 ///
1207 /// #### `key-release-event`
1208 /// The ::key-release-event signal is emitted when a key is released.
1209 ///
1210 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1211 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
1212 ///
1213 /// This signal will be sent to the grab widget if there is one.
1214 ///
1215 ///
1216 ///
1217 ///
1218 /// #### `keynav-failed`
1219 /// Gets emitted if keyboard navigation fails.
1220 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
1221 ///
1222 ///
1223 ///
1224 ///
1225 /// #### `leave-notify-event`
1226 /// The ::leave-notify-event will be emitted when the pointer leaves
1227 /// the `widget`'s window.
1228 ///
1229 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1230 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1231 ///
1232 /// This signal will be sent to the grab widget if there is one.
1233 ///
1234 ///
1235 ///
1236 ///
1237 /// #### `map`
1238 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1239 /// when the widget is visible (which is controlled with
1240 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1241 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1242 /// be emitted.
1243 ///
1244 /// The ::map signal can be used to determine whether a widget will be drawn,
1245 /// for instance it can resume an animation that was stopped during the
1246 /// emission of [`unmap`][struct@crate::Widget#unmap].
1247 ///
1248 ///
1249 ///
1250 ///
1251 /// #### `map-event`
1252 /// The ::map-event signal will be emitted when the `widget`'s window is
1253 /// mapped. A window is mapped when it becomes visible on the screen.
1254 ///
1255 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1256 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1257 /// automatically for all new windows.
1258 ///
1259 ///
1260 ///
1261 ///
1262 /// #### `mnemonic-activate`
1263 /// The default handler for this signal activates `widget` if `group_cycling`
1264 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1265 ///
1266 ///
1267 ///
1268 ///
1269 /// #### `motion-notify-event`
1270 /// The ::motion-notify-event signal is emitted when the pointer moves
1271 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1272 ///
1273 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1274 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1275 ///
1276 /// This signal will be sent to the grab widget if there is one.
1277 ///
1278 ///
1279 ///
1280 ///
1281 /// #### `move-focus`
1282 /// Action
1283 ///
1284 ///
1285 /// #### `parent-set`
1286 /// The ::parent-set signal is emitted when a new parent
1287 /// has been set on a widget.
1288 ///
1289 ///
1290 ///
1291 ///
1292 /// #### `popup-menu`
1293 /// This signal gets emitted whenever a widget should pop up a context
1294 /// menu. This usually happens through the standard key binding mechanism;
1295 /// by pressing a certain key while a widget is focused, the user can cause
1296 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1297 /// a menu with clipboard commands. See the
1298 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1299 /// for an example of how to use this signal.
1300 ///
1301 /// Action
1302 ///
1303 ///
1304 /// #### `property-notify-event`
1305 /// The ::property-notify-event signal will be emitted when a property on
1306 /// the `widget`'s window has been changed or deleted.
1307 ///
1308 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1309 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1310 ///
1311 ///
1312 ///
1313 ///
1314 /// #### `proximity-in-event`
1315 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1316 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1317 ///
1318 /// This signal will be sent to the grab widget if there is one.
1319 ///
1320 ///
1321 ///
1322 ///
1323 /// #### `proximity-out-event`
1324 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1325 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1326 ///
1327 /// This signal will be sent to the grab widget if there is one.
1328 ///
1329 ///
1330 ///
1331 ///
1332 /// #### `query-tooltip`
1333 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1334 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1335 /// focus in keyboard mode.
1336 ///
1337 /// Using the given coordinates, the signal handler should determine
1338 /// whether a tooltip should be shown for `widget`. If this is the case
1339 /// [`true`] should be returned, [`false`] otherwise. Note that if
1340 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1341 /// should not be used.
1342 ///
1343 /// The signal handler is free to manipulate `tooltip` with the therefore
1344 /// destined function calls.
1345 ///
1346 ///
1347 ///
1348 ///
1349 /// #### `realize`
1350 /// The ::realize signal is emitted when `widget` is associated with a
1351 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1352 /// widget has been mapped (that is, it is going to be drawn).
1353 ///
1354 ///
1355 ///
1356 ///
1357 /// #### `screen-changed`
1358 /// The ::screen-changed signal gets emitted when the
1359 /// screen of a widget has changed.
1360 ///
1361 ///
1362 ///
1363 ///
1364 /// #### `scroll-event`
1365 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1366 /// range is pressed. Wheel mice are usually configured to generate
1367 /// button press events for buttons 4 and 5 when the wheel is turned.
1368 ///
1369 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1370 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1371 ///
1372 /// This signal will be sent to the grab widget if there is one.
1373 ///
1374 ///
1375 ///
1376 ///
1377 /// #### `selection-clear-event`
1378 /// The ::selection-clear-event signal will be emitted when the
1379 /// the `widget`'s window has lost ownership of a selection.
1380 ///
1381 ///
1382 ///
1383 ///
1384 /// #### `selection-get`
1385 ///
1386 ///
1387 ///
1388 /// #### `selection-notify-event`
1389 ///
1390 ///
1391 ///
1392 /// #### `selection-received`
1393 ///
1394 ///
1395 ///
1396 /// #### `selection-request-event`
1397 /// The ::selection-request-event signal will be emitted when
1398 /// another client requests ownership of the selection owned by
1399 /// the `widget`'s window.
1400 ///
1401 ///
1402 ///
1403 ///
1404 /// #### `show`
1405 /// The ::show signal is emitted when `widget` is shown, for example with
1406 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1407 ///
1408 ///
1409 ///
1410 ///
1411 /// #### `show-help`
1412 /// Action
1413 ///
1414 ///
1415 /// #### `size-allocate`
1416 ///
1417 ///
1418 ///
1419 /// #### `state-changed`
1420 /// The ::state-changed signal is emitted when the widget state changes.
1421 /// See `gtk_widget_get_state()`.
1422 ///
1423 ///
1424 ///
1425 ///
1426 /// #### `state-flags-changed`
1427 /// The ::state-flags-changed signal is emitted when the widget state
1428 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1429 ///
1430 ///
1431 ///
1432 ///
1433 /// #### `style-set`
1434 /// The ::style-set signal is emitted when a new style has been set
1435 /// on a widget. Note that style-modifying functions like
1436 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1437 ///
1438 /// Note that this signal is emitted for changes to the deprecated
1439 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1440 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1441 ///
1442 ///
1443 ///
1444 ///
1445 /// #### `style-updated`
1446 /// The ::style-updated signal is a convenience signal that is emitted when the
1447 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1448 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1449 ///
1450 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1451 /// cause this signal to be emitted.
1452 ///
1453 ///
1454 ///
1455 ///
1456 /// #### `touch-event`
1457 ///
1458 ///
1459 ///
1460 /// #### `unmap`
1461 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1462 /// means that either it or any of its parents up to the toplevel widget have
1463 /// been set as hidden.
1464 ///
1465 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1466 /// used to, for example, stop an animation on the widget.
1467 ///
1468 ///
1469 ///
1470 ///
1471 /// #### `unmap-event`
1472 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1473 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1474 ///
1475 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1476 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1477 /// automatically for all new windows.
1478 ///
1479 ///
1480 ///
1481 ///
1482 /// #### `unrealize`
1483 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1484 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1485 /// called or the widget has been unmapped (that is, it is going to be
1486 /// hidden).
1487 ///
1488 ///
1489 ///
1490 ///
1491 /// #### `visibility-notify-event`
1492 /// The ::visibility-notify-event will be emitted when the `widget`'s
1493 /// window is obscured or unobscured.
1494 ///
1495 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1496 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1497 ///
1498 ///
1499 ///
1500 ///
1501 /// #### `window-state-event`
1502 /// The ::window-state-event will be emitted when the state of the
1503 /// toplevel window associated to the `widget` changes.
1504 ///
1505 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1506 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1507 /// this mask automatically for all new windows.
1508 ///
1509 ///
1510 ///
1511 /// # Implements
1512 ///
1513 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1514 #[doc(alias = "GtkWidget")]
1515 pub struct Widget(Object<ffi::GtkWidget, ffi::GtkWidgetClass>) @implements Buildable;
1516
1517 match fn {
1518 type_ => || ffi::gtk_widget_get_type(),
1519 }
1520}
1521
1522impl Widget {
1523 pub const NONE: Option<&'static Widget> = None;
1524
1525 //#[doc(alias = "gtk_widget_new")]
1526 //pub fn new(type_: glib::types::Type, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Widget {
1527 // unsafe { TODO: call ffi:gtk_widget_new() }
1528 //}
1529
1530 /// Obtains the current default reading direction. See
1531 /// [`set_default_direction()`][Self::set_default_direction()].
1532 ///
1533 /// # Returns
1534 ///
1535 /// the current default direction.
1536 #[doc(alias = "gtk_widget_get_default_direction")]
1537 #[doc(alias = "get_default_direction")]
1538 pub fn default_direction() -> TextDirection {
1539 assert_initialized_main_thread!();
1540 unsafe { from_glib(ffi::gtk_widget_get_default_direction()) }
1541 }
1542
1543 /// Sets the default reading direction for widgets where the
1544 /// direction has not been explicitly set by [`WidgetExt::set_direction()`][crate::prelude::WidgetExt::set_direction()].
1545 /// ## `dir`
1546 /// the new default direction. This cannot be
1547 /// [`TextDirection::None`][crate::TextDirection::None].
1548 #[doc(alias = "gtk_widget_set_default_direction")]
1549 pub fn set_default_direction(dir: TextDirection) {
1550 assert_initialized_main_thread!();
1551 unsafe {
1552 ffi::gtk_widget_set_default_direction(dir.into_glib());
1553 }
1554 }
1555}
1556
1557impl fmt::Display for Widget {
1558 #[inline]
1559 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1560 f.write_str(&WidgetExt::widget_name(self))
1561 }
1562}
1563
1564mod sealed {
1565 pub trait Sealed {}
1566 impl<T: super::IsA<super::Widget>> Sealed for T {}
1567}
1568
1569/// Trait containing all [`struct@Widget`] methods.
1570///
1571/// # Implementors
1572///
1573/// [`Actionable`][struct@crate::Actionable], [`AppChooser`][struct@crate::AppChooser], [`Calendar`][struct@crate::Calendar], [`CellEditable`][struct@crate::CellEditable], [`CellView`][struct@crate::CellView], [`Container`][struct@crate::Container], [`DrawingArea`][struct@crate::DrawingArea], [`Entry`][struct@crate::Entry], [`GLArea`][struct@crate::GLArea], [`Invisible`][struct@crate::Invisible], [`LevelBar`][struct@crate::LevelBar], [`Misc`][struct@crate::Misc], [`ProgressBar`][struct@crate::ProgressBar], [`Range`][struct@crate::Range], [`Separator`][struct@crate::Separator], [`Spinner`][struct@crate::Spinner], [`Switch`][struct@crate::Switch], [`ToolShell`][struct@crate::ToolShell], [`Widget`][struct@crate::Widget]
1574pub trait WidgetExt: IsA<Widget> + sealed::Sealed + 'static {
1575 /// For widgets that can be “activated” (buttons, menu items, etc.)
1576 /// this function activates them. Activation is what happens when you
1577 /// press Enter on a widget during key navigation. If `self` isn't
1578 /// activatable, the function returns [`false`].
1579 ///
1580 /// # Returns
1581 ///
1582 /// [`true`] if the widget was activatable
1583 #[doc(alias = "gtk_widget_activate")]
1584 fn activate(&self) -> bool {
1585 unsafe { from_glib(ffi::gtk_widget_activate(self.as_ref().to_glib_none().0)) }
1586 }
1587
1588 /// Installs an accelerator for this `self` in `accel_group` that causes
1589 /// `accel_signal` to be emitted if the accelerator is activated.
1590 /// The `accel_group` needs to be added to the widget’s toplevel via
1591 /// [`GtkWindowExt::add_accel_group()`][crate::prelude::GtkWindowExt::add_accel_group()], and the signal must be of type `G_SIGNAL_ACTION`.
1592 /// Accelerators added through this function are not user changeable during
1593 /// runtime. If you want to support accelerators that can be changed by the
1594 /// user, use `gtk_accel_map_add_entry()` and [`set_accel_path()`][Self::set_accel_path()] or
1595 /// [`GtkMenuItemExt::set_accel_path()`][crate::prelude::GtkMenuItemExt::set_accel_path()] instead.
1596 /// ## `accel_signal`
1597 /// widget signal to emit on accelerator activation
1598 /// ## `accel_group`
1599 /// accel group for this widget, added to its toplevel
1600 /// ## `accel_key`
1601 /// GDK keyval of the accelerator
1602 /// ## `accel_mods`
1603 /// modifier key combination of the accelerator
1604 /// ## `accel_flags`
1605 /// flag accelerators, e.g. [`AccelFlags::VISIBLE`][crate::AccelFlags::VISIBLE]
1606 #[doc(alias = "gtk_widget_add_accelerator")]
1607 fn add_accelerator(
1608 &self,
1609 accel_signal: &str,
1610 accel_group: &impl IsA<AccelGroup>,
1611 accel_key: u32,
1612 accel_mods: gdk::ModifierType,
1613 accel_flags: AccelFlags,
1614 ) {
1615 unsafe {
1616 ffi::gtk_widget_add_accelerator(
1617 self.as_ref().to_glib_none().0,
1618 accel_signal.to_glib_none().0,
1619 accel_group.as_ref().to_glib_none().0,
1620 accel_key,
1621 accel_mods.into_glib(),
1622 accel_flags.into_glib(),
1623 );
1624 }
1625 }
1626
1627 /// Adds the device events in the bitfield `events` to the event mask for
1628 /// `self`. See [`set_device_events()`][Self::set_device_events()] for details.
1629 /// ## `device`
1630 /// a [`gdk::Device`][crate::gdk::Device]
1631 /// ## `events`
1632 /// an event mask, see [`gdk::EventMask`][crate::gdk::EventMask]
1633 #[doc(alias = "gtk_widget_add_device_events")]
1634 fn add_device_events(&self, device: &gdk::Device, events: gdk::EventMask) {
1635 unsafe {
1636 ffi::gtk_widget_add_device_events(
1637 self.as_ref().to_glib_none().0,
1638 device.to_glib_none().0,
1639 events.into_glib(),
1640 );
1641 }
1642 }
1643
1644 /// Adds a widget to the list of mnemonic labels for
1645 /// this widget. (See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()]). Note the
1646 /// list of mnemonic labels for the widget is cleared when the
1647 /// widget is destroyed, so the caller must make sure to update
1648 /// its internal state at this point as well, by using a connection
1649 /// to the [`destroy`][struct@crate::Widget#destroy] signal or a weak notifier.
1650 /// ## `label`
1651 /// a [`Widget`][crate::Widget] that acts as a mnemonic label for `self`
1652 #[doc(alias = "gtk_widget_add_mnemonic_label")]
1653 fn add_mnemonic_label(&self, label: &impl IsA<Widget>) {
1654 unsafe {
1655 ffi::gtk_widget_add_mnemonic_label(
1656 self.as_ref().to_glib_none().0,
1657 label.as_ref().to_glib_none().0,
1658 );
1659 }
1660 }
1661
1662 /// Determines whether an accelerator that activates the signal
1663 /// identified by `signal_id` can currently be activated.
1664 /// This is done by emitting the [`can-activate-accel`][struct@crate::Widget#can-activate-accel]
1665 /// signal on `self`; if the signal isn’t overridden by a
1666 /// handler or in a derived widget, then the default check is
1667 /// that the widget must be sensitive, and the widget and all
1668 /// its ancestors mapped.
1669 /// ## `signal_id`
1670 /// the ID of a signal installed on `self`
1671 ///
1672 /// # Returns
1673 ///
1674 /// [`true`] if the accelerator can be activated.
1675 #[doc(alias = "gtk_widget_can_activate_accel")]
1676 fn can_activate_accel(&self, signal_id: u32) -> bool {
1677 unsafe {
1678 from_glib(ffi::gtk_widget_can_activate_accel(
1679 self.as_ref().to_glib_none().0,
1680 signal_id,
1681 ))
1682 }
1683 }
1684
1685 /// This function is used by custom widget implementations; if you're
1686 /// writing an app, you’d use [`grab_focus()`][Self::grab_focus()] to move the focus
1687 /// to a particular widget, and [`ContainerExt::set_focus_chain()`][crate::prelude::ContainerExt::set_focus_chain()] to
1688 /// change the focus tab order. So you may want to investigate those
1689 /// functions instead.
1690 ///
1691 /// [`child_focus()`][Self::child_focus()] is called by containers as the user moves
1692 /// around the window using keyboard shortcuts. `direction` indicates
1693 /// what kind of motion is taking place (up, down, left, right, tab
1694 /// forward, tab backward). [`child_focus()`][Self::child_focus()] emits the
1695 /// [`focus`][struct@crate::Widget#focus] signal; widgets override the default handler
1696 /// for this signal in order to implement appropriate focus behavior.
1697 ///
1698 /// The default ::focus handler for a widget should return [`true`] if
1699 /// moving in `direction` left the focus on a focusable location inside
1700 /// that widget, and [`false`] if moving in `direction` moved the focus
1701 /// outside the widget. If returning [`true`], widgets normally
1702 /// call [`grab_focus()`][Self::grab_focus()] to place the focus accordingly;
1703 /// if returning [`false`], they don’t modify the current focus location.
1704 /// ## `direction`
1705 /// direction of focus movement
1706 ///
1707 /// # Returns
1708 ///
1709 /// [`true`] if focus ended up inside `self`
1710 #[doc(alias = "gtk_widget_child_focus")]
1711 fn child_focus(&self, direction: DirectionType) -> bool {
1712 unsafe {
1713 from_glib(ffi::gtk_widget_child_focus(
1714 self.as_ref().to_glib_none().0,
1715 direction.into_glib(),
1716 ))
1717 }
1718 }
1719
1720 /// Emits a [`child-notify`][struct@crate::Widget#child-notify] signal for the
1721 /// [child property][child-properties] `child_property`
1722 /// on `self`.
1723 ///
1724 /// This is the analogue of [`ObjectExt::notify()`][crate::glib::prelude::ObjectExt::notify()] for child properties.
1725 ///
1726 /// Also see [`ContainerExt::child_notify()`][crate::prelude::ContainerExt::child_notify()].
1727 /// ## `child_property`
1728 /// the name of a child property installed on the
1729 /// class of `self`’s parent
1730 #[doc(alias = "gtk_widget_child_notify")]
1731 fn child_notify(&self, child_property: &str) {
1732 unsafe {
1733 ffi::gtk_widget_child_notify(
1734 self.as_ref().to_glib_none().0,
1735 child_property.to_glib_none().0,
1736 );
1737 }
1738 }
1739
1740 /// Computes whether a container should give this widget extra space
1741 /// when possible. Containers should check this, rather than
1742 /// looking at [`hexpands()`][Self::hexpands()] or [`vexpands()`][Self::vexpands()].
1743 ///
1744 /// This function already checks whether the widget is visible, so
1745 /// visibility does not need to be checked separately. Non-visible
1746 /// widgets are not expanded.
1747 ///
1748 /// The computed expand value uses either the expand setting explicitly
1749 /// set on the widget itself, or, if none has been explicitly set,
1750 /// the widget may expand if some of its children do.
1751 /// ## `orientation`
1752 /// expand direction
1753 ///
1754 /// # Returns
1755 ///
1756 /// whether widget tree rooted here should be expanded
1757 #[doc(alias = "gtk_widget_compute_expand")]
1758 fn compute_expand(&self, orientation: Orientation) -> bool {
1759 unsafe {
1760 from_glib(ffi::gtk_widget_compute_expand(
1761 self.as_ref().to_glib_none().0,
1762 orientation.into_glib(),
1763 ))
1764 }
1765 }
1766
1767 /// Creates a new [`pango::Context`][crate::pango::Context] with the appropriate font map,
1768 /// font options, font description, and base direction for drawing
1769 /// text for this widget. See also [`pango_context()`][Self::pango_context()].
1770 ///
1771 /// # Returns
1772 ///
1773 /// the new [`pango::Context`][crate::pango::Context]
1774 #[doc(alias = "gtk_widget_create_pango_context")]
1775 fn create_pango_context(&self) -> pango::Context {
1776 unsafe {
1777 from_glib_full(ffi::gtk_widget_create_pango_context(
1778 self.as_ref().to_glib_none().0,
1779 ))
1780 }
1781 }
1782
1783 /// Creates a new [`pango::Layout`][crate::pango::Layout] with the appropriate font map,
1784 /// font description, and base direction for drawing text for
1785 /// this widget.
1786 ///
1787 /// If you keep a [`pango::Layout`][crate::pango::Layout] created in this way around, you need
1788 /// to re-create it when the widget [`pango::Context`][crate::pango::Context] is replaced.
1789 /// This can be tracked by using the [`screen-changed`][struct@crate::Widget#screen-changed] signal
1790 /// on the widget.
1791 /// ## `text`
1792 /// text to set on the layout (can be [`None`])
1793 ///
1794 /// # Returns
1795 ///
1796 /// the new [`pango::Layout`][crate::pango::Layout]
1797 #[doc(alias = "gtk_widget_create_pango_layout")]
1798 fn create_pango_layout(&self, text: Option<&str>) -> pango::Layout {
1799 unsafe {
1800 from_glib_full(ffi::gtk_widget_create_pango_layout(
1801 self.as_ref().to_glib_none().0,
1802 text.to_glib_none().0,
1803 ))
1804 }
1805 }
1806
1807 //#[doc(alias = "gtk_widget_destroyed")]
1808 //fn destroyed(&self, widget_pointer: impl IsA<Widget>) {
1809 // unsafe { TODO: call ffi:gtk_widget_destroyed() }
1810 //}
1811
1812 /// Returns [`true`] if `device` has been shadowed by a GTK+
1813 /// device grab on another widget, so it would stop sending
1814 /// events to `self`. This may be used in the
1815 /// [`grab-notify`][struct@crate::Widget#grab-notify] signal to check for specific
1816 /// devices. See [`device_grab_add()`][crate::device_grab_add()].
1817 /// ## `device`
1818 /// a [`gdk::Device`][crate::gdk::Device]
1819 ///
1820 /// # Returns
1821 ///
1822 /// [`true`] if there is an ongoing grab on `device`
1823 /// by another [`Widget`][crate::Widget] than `self`.
1824 #[doc(alias = "gtk_widget_device_is_shadowed")]
1825 fn device_is_shadowed(&self, device: &gdk::Device) -> bool {
1826 unsafe {
1827 from_glib(ffi::gtk_widget_device_is_shadowed(
1828 self.as_ref().to_glib_none().0,
1829 device.to_glib_none().0,
1830 ))
1831 }
1832 }
1833
1834 /// Initiates a drag on the source side. The function only needs to be used
1835 /// when the application is starting drags itself, and is not needed when
1836 /// [`WidgetExtManual::drag_source_set()`][crate::prelude::WidgetExtManual::drag_source_set()] is used.
1837 ///
1838 /// The `event` is used to retrieve the timestamp that will be used internally to
1839 /// grab the pointer. If `event` is [`None`], then `GDK_CURRENT_TIME` will be used.
1840 /// However, you should try to pass a real event in all cases, since that can be
1841 /// used to get information about the drag.
1842 ///
1843 /// Generally there are three cases when you want to start a drag by hand by
1844 /// calling this function:
1845 ///
1846 /// 1. During a [`button-press-event`][struct@crate::Widget#button-press-event] handler, if you want to start a drag
1847 /// immediately when the user presses the mouse button. Pass the `event`
1848 /// that you have in your [`button-press-event`][struct@crate::Widget#button-press-event] handler.
1849 ///
1850 /// 2. During a [`motion-notify-event`][struct@crate::Widget#motion-notify-event] handler, if you want to start a drag
1851 /// when the mouse moves past a certain threshold distance after a button-press.
1852 /// Pass the `event` that you have in your [`motion-notify-event`][struct@crate::Widget#motion-notify-event] handler.
1853 ///
1854 /// 3. During a timeout handler, if you want to start a drag after the mouse
1855 /// button is held down for some time. Try to save the last event that you got
1856 /// from the mouse, using `gdk_event_copy()`, and pass it to this function
1857 /// (remember to free the event with `gdk_event_free()` when you are done).
1858 /// If you really cannot pass a real event, pass [`None`] instead.
1859 /// ## `targets`
1860 /// The targets (data formats) in which the
1861 /// source can provide the data
1862 /// ## `actions`
1863 /// A bitmask of the allowed drag actions for this drag
1864 /// ## `button`
1865 /// The button the user clicked to start the drag
1866 /// ## `event`
1867 /// The event that triggered the start of the drag,
1868 /// or [`None`] if none can be obtained.
1869 /// ## `x`
1870 /// The initial x coordinate to start dragging from, in the coordinate space
1871 /// of `self`. If -1 is passed, the coordinates are retrieved from `event` or
1872 /// the current pointer position
1873 /// ## `y`
1874 /// The initial y coordinate to start dragging from, in the coordinate space
1875 /// of `self`. If -1 is passed, the coordinates are retrieved from `event` or
1876 /// the current pointer position
1877 ///
1878 /// # Returns
1879 ///
1880 /// the context for this drag
1881 #[doc(alias = "gtk_drag_begin_with_coordinates")]
1882 fn drag_begin_with_coordinates(
1883 &self,
1884 targets: &TargetList,
1885 actions: gdk::DragAction,
1886 button: i32,
1887 event: Option<&gdk::Event>,
1888 x: i32,
1889 y: i32,
1890 ) -> Option<gdk::DragContext> {
1891 unsafe {
1892 from_glib_none(ffi::gtk_drag_begin_with_coordinates(
1893 self.as_ref().to_glib_none().0,
1894 targets.to_glib_none().0,
1895 actions.into_glib(),
1896 button,
1897 mut_override(event.to_glib_none().0),
1898 x,
1899 y,
1900 ))
1901 }
1902 }
1903
1904 /// Checks to see if a mouse drag starting at (`start_x`, `start_y`) and ending
1905 /// at (`current_x`, `current_y`) has passed the GTK+ drag threshold, and thus
1906 /// should trigger the beginning of a drag-and-drop operation.
1907 /// ## `start_x`
1908 /// X coordinate of start of drag
1909 /// ## `start_y`
1910 /// Y coordinate of start of drag
1911 /// ## `current_x`
1912 /// current X coordinate
1913 /// ## `current_y`
1914 /// current Y coordinate
1915 ///
1916 /// # Returns
1917 ///
1918 /// [`true`] if the drag threshold has been passed.
1919 #[doc(alias = "gtk_drag_check_threshold")]
1920 fn drag_check_threshold(
1921 &self,
1922 start_x: i32,
1923 start_y: i32,
1924 current_x: i32,
1925 current_y: i32,
1926 ) -> bool {
1927 unsafe {
1928 from_glib(ffi::gtk_drag_check_threshold(
1929 self.as_ref().to_glib_none().0,
1930 start_x,
1931 start_y,
1932 current_x,
1933 current_y,
1934 ))
1935 }
1936 }
1937
1938 /// Add the image targets supported by [`SelectionData`][crate::SelectionData] to
1939 /// the target list of the drag destination. The targets
1940 /// are added with `info` = 0. If you need another value,
1941 /// use [`TargetList::add_image_targets()`][crate::TargetList::add_image_targets()] and
1942 /// [`drag_dest_set_target_list()`][Self::drag_dest_set_target_list()].
1943 #[doc(alias = "gtk_drag_dest_add_image_targets")]
1944 fn drag_dest_add_image_targets(&self) {
1945 unsafe {
1946 ffi::gtk_drag_dest_add_image_targets(self.as_ref().to_glib_none().0);
1947 }
1948 }
1949
1950 /// Add the text targets supported by [`SelectionData`][crate::SelectionData] to
1951 /// the target list of the drag destination. The targets
1952 /// are added with `info` = 0. If you need another value,
1953 /// use [`TargetList::add_text_targets()`][crate::TargetList::add_text_targets()] and
1954 /// [`drag_dest_set_target_list()`][Self::drag_dest_set_target_list()].
1955 #[doc(alias = "gtk_drag_dest_add_text_targets")]
1956 fn drag_dest_add_text_targets(&self) {
1957 unsafe {
1958 ffi::gtk_drag_dest_add_text_targets(self.as_ref().to_glib_none().0);
1959 }
1960 }
1961
1962 /// Add the URI targets supported by [`SelectionData`][crate::SelectionData] to
1963 /// the target list of the drag destination. The targets
1964 /// are added with `info` = 0. If you need another value,
1965 /// use [`TargetList::add_uri_targets()`][crate::TargetList::add_uri_targets()] and
1966 /// [`drag_dest_set_target_list()`][Self::drag_dest_set_target_list()].
1967 #[doc(alias = "gtk_drag_dest_add_uri_targets")]
1968 fn drag_dest_add_uri_targets(&self) {
1969 unsafe {
1970 ffi::gtk_drag_dest_add_uri_targets(self.as_ref().to_glib_none().0);
1971 }
1972 }
1973
1974 /// Looks for a match between the supported targets of `context` and the
1975 /// `dest_target_list`, returning the first matching target, otherwise
1976 /// returning `GDK_NONE`. `dest_target_list` should usually be the return
1977 /// value from [`drag_dest_get_target_list()`][Self::drag_dest_get_target_list()], but some widgets may
1978 /// have different valid targets for different parts of the widget; in
1979 /// that case, they will have to implement a drag_motion handler that
1980 /// passes the correct target list to this function.
1981 /// ## `context`
1982 /// drag context
1983 /// ## `target_list`
1984 /// list of droppable targets, or [`None`] to use
1985 /// gtk_drag_dest_get_target_list (`self`).
1986 ///
1987 /// # Returns
1988 ///
1989 /// first target that the source offers
1990 /// and the dest can accept, or `GDK_NONE`
1991 #[doc(alias = "gtk_drag_dest_find_target")]
1992 fn drag_dest_find_target(
1993 &self,
1994 context: &gdk::DragContext,
1995 target_list: Option<&TargetList>,
1996 ) -> Option<gdk::Atom> {
1997 unsafe {
1998 from_glib_none(ffi::gtk_drag_dest_find_target(
1999 self.as_ref().to_glib_none().0,
2000 context.to_glib_none().0,
2001 target_list.to_glib_none().0,
2002 ))
2003 }
2004 }
2005
2006 /// Returns the list of targets this widget can accept from
2007 /// drag-and-drop.
2008 ///
2009 /// # Returns
2010 ///
2011 /// the [`TargetList`][crate::TargetList], or [`None`] if none
2012 #[doc(alias = "gtk_drag_dest_get_target_list")]
2013 fn drag_dest_get_target_list(&self) -> Option<TargetList> {
2014 unsafe {
2015 from_glib_none(ffi::gtk_drag_dest_get_target_list(
2016 self.as_ref().to_glib_none().0,
2017 ))
2018 }
2019 }
2020
2021 /// Returns whether the widget has been configured to always
2022 /// emit [`drag-motion`][struct@crate::Widget#drag-motion] signals.
2023 ///
2024 /// # Returns
2025 ///
2026 /// [`true`] if the widget always emits
2027 /// [`drag-motion`][struct@crate::Widget#drag-motion] events
2028 #[doc(alias = "gtk_drag_dest_get_track_motion")]
2029 fn drag_dest_get_track_motion(&self) -> bool {
2030 unsafe {
2031 from_glib(ffi::gtk_drag_dest_get_track_motion(
2032 self.as_ref().to_glib_none().0,
2033 ))
2034 }
2035 }
2036
2037 /// Sets the target types that this widget can accept from drag-and-drop.
2038 /// The widget must first be made into a drag destination with
2039 /// [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()].
2040 /// ## `target_list`
2041 /// list of droppable targets, or [`None`] for none
2042 #[doc(alias = "gtk_drag_dest_set_target_list")]
2043 fn drag_dest_set_target_list(&self, target_list: Option<&TargetList>) {
2044 unsafe {
2045 ffi::gtk_drag_dest_set_target_list(
2046 self.as_ref().to_glib_none().0,
2047 target_list.to_glib_none().0,
2048 );
2049 }
2050 }
2051
2052 /// Tells the widget to emit [`drag-motion`][struct@crate::Widget#drag-motion] and
2053 /// [`drag-leave`][struct@crate::Widget#drag-leave] events regardless of the targets and the
2054 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] flag.
2055 ///
2056 /// This may be used when a widget wants to do generic
2057 /// actions regardless of the targets that the source offers.
2058 /// ## `track_motion`
2059 /// whether to accept all targets
2060 #[doc(alias = "gtk_drag_dest_set_track_motion")]
2061 fn drag_dest_set_track_motion(&self, track_motion: bool) {
2062 unsafe {
2063 ffi::gtk_drag_dest_set_track_motion(
2064 self.as_ref().to_glib_none().0,
2065 track_motion.into_glib(),
2066 );
2067 }
2068 }
2069
2070 /// Clears information about a drop destination set with
2071 /// [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]. The widget will no longer receive
2072 /// notification of drags.
2073 #[doc(alias = "gtk_drag_dest_unset")]
2074 fn drag_dest_unset(&self) {
2075 unsafe {
2076 ffi::gtk_drag_dest_unset(self.as_ref().to_glib_none().0);
2077 }
2078 }
2079
2080 /// Gets the data associated with a drag. When the data
2081 /// is received or the retrieval fails, GTK+ will emit a
2082 /// [`drag-data-received`][struct@crate::Widget#drag-data-received] signal. Failure of the retrieval
2083 /// is indicated by the length field of the `selection_data`
2084 /// signal parameter being negative. However, when [`drag_get_data()`][Self::drag_get_data()]
2085 /// is called implicitely because the [`DestDefaults::DROP`][crate::DestDefaults::DROP] was set,
2086 /// then the widget will not receive notification of failed
2087 /// drops.
2088 /// ## `context`
2089 /// the drag context
2090 /// ## `target`
2091 /// the target (form of the data) to retrieve
2092 /// ## `time_`
2093 /// a timestamp for retrieving the data. This will
2094 /// generally be the time received in a [`drag-motion`][struct@crate::Widget#drag-motion]
2095 /// or [`drag-drop`][struct@crate::Widget#drag-drop] signal
2096 #[doc(alias = "gtk_drag_get_data")]
2097 fn drag_get_data(&self, context: &gdk::DragContext, target: &gdk::Atom, time_: u32) {
2098 unsafe {
2099 ffi::gtk_drag_get_data(
2100 self.as_ref().to_glib_none().0,
2101 context.to_glib_none().0,
2102 target.to_glib_none().0,
2103 time_,
2104 );
2105 }
2106 }
2107
2108 /// Highlights a widget as a currently hovered drop target.
2109 /// To end the highlight, call [`drag_unhighlight()`][Self::drag_unhighlight()].
2110 /// GTK+ calls this automatically if [`DestDefaults::HIGHLIGHT`][crate::DestDefaults::HIGHLIGHT] is set.
2111 #[doc(alias = "gtk_drag_highlight")]
2112 fn drag_highlight(&self) {
2113 unsafe {
2114 ffi::gtk_drag_highlight(self.as_ref().to_glib_none().0);
2115 }
2116 }
2117
2118 /// Add the writable image targets supported by [`SelectionData`][crate::SelectionData] to
2119 /// the target list of the drag source. The targets
2120 /// are added with `info` = 0. If you need another value,
2121 /// use [`TargetList::add_image_targets()`][crate::TargetList::add_image_targets()] and
2122 /// [`drag_source_set_target_list()`][Self::drag_source_set_target_list()].
2123 #[doc(alias = "gtk_drag_source_add_image_targets")]
2124 fn drag_source_add_image_targets(&self) {
2125 unsafe {
2126 ffi::gtk_drag_source_add_image_targets(self.as_ref().to_glib_none().0);
2127 }
2128 }
2129
2130 /// Add the text targets supported by [`SelectionData`][crate::SelectionData] to
2131 /// the target list of the drag source. The targets
2132 /// are added with `info` = 0. If you need another value,
2133 /// use [`TargetList::add_text_targets()`][crate::TargetList::add_text_targets()] and
2134 /// [`drag_source_set_target_list()`][Self::drag_source_set_target_list()].
2135 #[doc(alias = "gtk_drag_source_add_text_targets")]
2136 fn drag_source_add_text_targets(&self) {
2137 unsafe {
2138 ffi::gtk_drag_source_add_text_targets(self.as_ref().to_glib_none().0);
2139 }
2140 }
2141
2142 /// Add the URI targets supported by [`SelectionData`][crate::SelectionData] to
2143 /// the target list of the drag source. The targets
2144 /// are added with `info` = 0. If you need another value,
2145 /// use [`TargetList::add_uri_targets()`][crate::TargetList::add_uri_targets()] and
2146 /// [`drag_source_set_target_list()`][Self::drag_source_set_target_list()].
2147 #[doc(alias = "gtk_drag_source_add_uri_targets")]
2148 fn drag_source_add_uri_targets(&self) {
2149 unsafe {
2150 ffi::gtk_drag_source_add_uri_targets(self.as_ref().to_glib_none().0);
2151 }
2152 }
2153
2154 /// Gets the list of targets this widget can provide for
2155 /// drag-and-drop.
2156 ///
2157 /// # Returns
2158 ///
2159 /// the [`TargetList`][crate::TargetList], or [`None`] if none
2160 #[doc(alias = "gtk_drag_source_get_target_list")]
2161 fn drag_source_get_target_list(&self) -> Option<TargetList> {
2162 unsafe {
2163 from_glib_none(ffi::gtk_drag_source_get_target_list(
2164 self.as_ref().to_glib_none().0,
2165 ))
2166 }
2167 }
2168
2169 /// Sets the icon that will be used for drags from a particular source
2170 /// to `icon`. See the docs for [`IconTheme`][crate::IconTheme] for more details.
2171 /// ## `icon`
2172 /// A [`gio::Icon`][crate::gio::Icon]
2173 #[doc(alias = "gtk_drag_source_set_icon_gicon")]
2174 fn drag_source_set_icon_gicon(&self, icon: &impl IsA<gio::Icon>) {
2175 unsafe {
2176 ffi::gtk_drag_source_set_icon_gicon(
2177 self.as_ref().to_glib_none().0,
2178 icon.as_ref().to_glib_none().0,
2179 );
2180 }
2181 }
2182
2183 /// Sets the icon that will be used for drags from a particular source
2184 /// to a themed icon. See the docs for [`IconTheme`][crate::IconTheme] for more details.
2185 /// ## `icon_name`
2186 /// name of icon to use
2187 #[doc(alias = "gtk_drag_source_set_icon_name")]
2188 fn drag_source_set_icon_name(&self, icon_name: &str) {
2189 unsafe {
2190 ffi::gtk_drag_source_set_icon_name(
2191 self.as_ref().to_glib_none().0,
2192 icon_name.to_glib_none().0,
2193 );
2194 }
2195 }
2196
2197 /// Sets the icon that will be used for drags from a particular widget
2198 /// from a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf]. GTK+ retains a reference for `pixbuf` and will
2199 /// release it when it is no longer needed.
2200 /// ## `pixbuf`
2201 /// the [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] for the drag icon
2202 #[doc(alias = "gtk_drag_source_set_icon_pixbuf")]
2203 fn drag_source_set_icon_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf) {
2204 unsafe {
2205 ffi::gtk_drag_source_set_icon_pixbuf(
2206 self.as_ref().to_glib_none().0,
2207 pixbuf.to_glib_none().0,
2208 );
2209 }
2210 }
2211
2212 /// Changes the target types that this widget offers for drag-and-drop.
2213 /// The widget must first be made into a drag source with
2214 /// [`WidgetExtManual::drag_source_set()`][crate::prelude::WidgetExtManual::drag_source_set()].
2215 /// ## `target_list`
2216 /// list of draggable targets, or [`None`] for none
2217 #[doc(alias = "gtk_drag_source_set_target_list")]
2218 fn drag_source_set_target_list(&self, target_list: Option<&TargetList>) {
2219 unsafe {
2220 ffi::gtk_drag_source_set_target_list(
2221 self.as_ref().to_glib_none().0,
2222 target_list.to_glib_none().0,
2223 );
2224 }
2225 }
2226
2227 /// Undoes the effects of [`WidgetExtManual::drag_source_set()`][crate::prelude::WidgetExtManual::drag_source_set()].
2228 #[doc(alias = "gtk_drag_source_unset")]
2229 fn drag_source_unset(&self) {
2230 unsafe {
2231 ffi::gtk_drag_source_unset(self.as_ref().to_glib_none().0);
2232 }
2233 }
2234
2235 /// Removes a highlight set by [`drag_highlight()`][Self::drag_highlight()] from
2236 /// a widget.
2237 #[doc(alias = "gtk_drag_unhighlight")]
2238 fn drag_unhighlight(&self) {
2239 unsafe {
2240 ffi::gtk_drag_unhighlight(self.as_ref().to_glib_none().0);
2241 }
2242 }
2243
2244 /// Draws `self` to `cr`. The top left corner of the widget will be
2245 /// drawn to the currently set origin point of `cr`.
2246 ///
2247 /// You should pass a cairo context as `cr` argument that is in an
2248 /// original state. Otherwise the resulting drawing is undefined. For
2249 /// example changing the operator using `cairo_set_operator()` or the
2250 /// line width using `cairo_set_line_width()` might have unwanted side
2251 /// effects.
2252 /// You may however change the context’s transform matrix - like with
2253 /// `cairo_scale()`, `cairo_translate()` or `cairo_set_matrix()` and clip
2254 /// region with `cairo_clip()` prior to calling this function. Also, it
2255 /// is fine to modify the context with `cairo_save()` and
2256 /// `cairo_push_group()` prior to calling this function.
2257 ///
2258 /// Note that special-purpose widgets may contain special code for
2259 /// rendering to the screen and might appear differently on screen
2260 /// and when rendered using [`draw()`][Self::draw()].
2261 /// ## `cr`
2262 /// a cairo context to draw to
2263 #[doc(alias = "gtk_widget_draw")]
2264 fn draw(&self, cr: &cairo::Context) {
2265 unsafe {
2266 ffi::gtk_widget_draw(
2267 self.as_ref().to_glib_none().0,
2268 mut_override(cr.to_glib_none().0),
2269 );
2270 }
2271 }
2272
2273 /// Notifies the user about an input-related error on this widget.
2274 /// If the [`gtk-error-bell`][struct@crate::Settings#gtk-error-bell] setting is [`true`], it calls
2275 /// [`Window::beep()`][crate::gdk::Window::beep()], otherwise it does nothing.
2276 ///
2277 /// Note that the effect of [`Window::beep()`][crate::gdk::Window::beep()] can be configured in many
2278 /// ways, depending on the windowing backend and the desktop environment
2279 /// or window manager that is used.
2280 #[doc(alias = "gtk_widget_error_bell")]
2281 fn error_bell(&self) {
2282 unsafe {
2283 ffi::gtk_widget_error_bell(self.as_ref().to_glib_none().0);
2284 }
2285 }
2286
2287 /// Rarely-used function. This function is used to emit
2288 /// the event signals on a widget (those signals should never
2289 /// be emitted without using this function to do so).
2290 /// If you want to synthesize an event though, don’t use this function;
2291 /// instead, use [`main_do_event()`][crate::main_do_event()] so the event will behave as if
2292 /// it were in the event queue. Don’t synthesize expose events; instead,
2293 /// use [`Window::invalidate_rect()`][crate::gdk::Window::invalidate_rect()] to invalidate a region of the
2294 /// window.
2295 /// ## `event`
2296 /// a `GdkEvent`
2297 ///
2298 /// # Returns
2299 ///
2300 /// return from the event signal emission ([`true`] if
2301 /// the event was handled)
2302 #[doc(alias = "gtk_widget_event")]
2303 fn event(&self, event: &gdk::Event) -> bool {
2304 unsafe {
2305 from_glib(ffi::gtk_widget_event(
2306 self.as_ref().to_glib_none().0,
2307 mut_override(event.to_glib_none().0),
2308 ))
2309 }
2310 }
2311
2312 /// Stops emission of [`child-notify`][struct@crate::Widget#child-notify] signals on `self`. The
2313 /// signals are queued until [`thaw_child_notify()`][Self::thaw_child_notify()] is called
2314 /// on `self`.
2315 ///
2316 /// This is the analogue of [`ObjectExt::freeze_notify()`][crate::glib::prelude::ObjectExt::freeze_notify()] for child properties.
2317 #[doc(alias = "gtk_widget_freeze_child_notify")]
2318 fn freeze_child_notify(&self) {
2319 unsafe {
2320 ffi::gtk_widget_freeze_child_notify(self.as_ref().to_glib_none().0);
2321 }
2322 }
2323
2324 /// Returns the accessible object that describes the widget to an
2325 /// assistive technology.
2326 ///
2327 /// If accessibility support is not available, this [`atk::Object`][crate::atk::Object]
2328 /// instance may be a no-op. Likewise, if no class-specific [`atk::Object`][crate::atk::Object]
2329 /// implementation is available for the widget instance in question,
2330 /// it will inherit an [`atk::Object`][crate::atk::Object] implementation from the first ancestor
2331 /// class for which such an implementation is defined.
2332 ///
2333 /// The documentation of the
2334 /// [ATK](http://developer.gnome.org/atk/stable/)
2335 /// library contains more information about accessible objects and their uses.
2336 ///
2337 /// # Returns
2338 ///
2339 /// the [`atk::Object`][crate::atk::Object] associated with `self`
2340 #[doc(alias = "gtk_widget_get_accessible")]
2341 #[doc(alias = "get_accessible")]
2342 fn accessible(&self) -> Option<atk::Object> {
2343 unsafe {
2344 from_glib_none(ffi::gtk_widget_get_accessible(
2345 self.as_ref().to_glib_none().0,
2346 ))
2347 }
2348 }
2349
2350 /// Retrieves the [`gio::ActionGroup`][crate::gio::ActionGroup] that was registered using `prefix`. The resulting
2351 /// [`gio::ActionGroup`][crate::gio::ActionGroup] may have been registered to `self` or any [`Widget`][crate::Widget] in its
2352 /// ancestry.
2353 ///
2354 /// If no action group was found matching `prefix`, then [`None`] is returned.
2355 /// ## `prefix`
2356 /// The “prefix” of the action group.
2357 ///
2358 /// # Returns
2359 ///
2360 /// A [`gio::ActionGroup`][crate::gio::ActionGroup] or [`None`].
2361 #[doc(alias = "gtk_widget_get_action_group")]
2362 #[doc(alias = "get_action_group")]
2363 fn action_group(&self, prefix: &str) -> Option<gio::ActionGroup> {
2364 unsafe {
2365 from_glib_none(ffi::gtk_widget_get_action_group(
2366 self.as_ref().to_glib_none().0,
2367 prefix.to_glib_none().0,
2368 ))
2369 }
2370 }
2371
2372 /// Returns the baseline that has currently been allocated to `self`.
2373 /// This function is intended to be used when implementing handlers
2374 /// for the [`draw`][struct@crate::Widget#draw] function, and when allocating child
2375 /// widgets in [`size_allocate`][struct@crate::Widget#size_allocate].
2376 ///
2377 /// # Returns
2378 ///
2379 /// the baseline of the `self`, or -1 if none
2380 #[doc(alias = "gtk_widget_get_allocated_baseline")]
2381 #[doc(alias = "get_allocated_baseline")]
2382 fn allocated_baseline(&self) -> i32 {
2383 unsafe { ffi::gtk_widget_get_allocated_baseline(self.as_ref().to_glib_none().0) }
2384 }
2385
2386 /// Returns the height that has currently been allocated to `self`.
2387 /// This function is intended to be used when implementing handlers
2388 /// for the [`draw`][struct@crate::Widget#draw] function.
2389 ///
2390 /// # Returns
2391 ///
2392 /// the height of the `self`
2393 #[doc(alias = "gtk_widget_get_allocated_height")]
2394 #[doc(alias = "get_allocated_height")]
2395 fn allocated_height(&self) -> i32 {
2396 unsafe { ffi::gtk_widget_get_allocated_height(self.as_ref().to_glib_none().0) }
2397 }
2398
2399 /// Retrieves the widget’s allocated size.
2400 ///
2401 /// This function returns the last values passed to
2402 /// [`size_allocate_with_baseline()`][Self::size_allocate_with_baseline()]. The value differs from
2403 /// the size returned in [`allocation()`][Self::allocation()] in that functions
2404 /// like [`set_halign()`][Self::set_halign()] can adjust the allocation, but not
2405 /// the value returned by this function.
2406 ///
2407 /// If a widget is not visible, its allocated size is 0.
2408 ///
2409 /// # Returns
2410 ///
2411 ///
2412 /// ## `allocation`
2413 /// a pointer to a `GtkAllocation` to copy to
2414 ///
2415 /// ## `baseline`
2416 /// a pointer to an integer to copy to
2417 #[doc(alias = "gtk_widget_get_allocated_size")]
2418 #[doc(alias = "get_allocated_size")]
2419 fn allocated_size(&self) -> (Allocation, i32) {
2420 unsafe {
2421 let mut allocation = Allocation::uninitialized();
2422 let mut baseline = mem::MaybeUninit::uninit();
2423 ffi::gtk_widget_get_allocated_size(
2424 self.as_ref().to_glib_none().0,
2425 allocation.to_glib_none_mut().0,
2426 baseline.as_mut_ptr(),
2427 );
2428 (allocation, baseline.assume_init())
2429 }
2430 }
2431
2432 /// Returns the width that has currently been allocated to `self`.
2433 /// This function is intended to be used when implementing handlers
2434 /// for the [`draw`][struct@crate::Widget#draw] function.
2435 ///
2436 /// # Returns
2437 ///
2438 /// the width of the `self`
2439 #[doc(alias = "gtk_widget_get_allocated_width")]
2440 #[doc(alias = "get_allocated_width")]
2441 fn allocated_width(&self) -> i32 {
2442 unsafe { ffi::gtk_widget_get_allocated_width(self.as_ref().to_glib_none().0) }
2443 }
2444
2445 /// Retrieves the widget’s allocation.
2446 ///
2447 /// Note, when implementing a [`Container`][crate::Container]: a widget’s allocation will
2448 /// be its “adjusted” allocation, that is, the widget’s parent
2449 /// container typically calls [`size_allocate()`][Self::size_allocate()] with an
2450 /// allocation, and that allocation is then adjusted (to handle margin
2451 /// and alignment for example) before assignment to the widget.
2452 /// [`allocation()`][Self::allocation()] returns the adjusted allocation that
2453 /// was actually assigned to the widget. The adjusted allocation is
2454 /// guaranteed to be completely contained within the
2455 /// [`size_allocate()`][Self::size_allocate()] allocation, however. So a [`Container`][crate::Container]
2456 /// is guaranteed that its children stay inside the assigned bounds,
2457 /// but not that they have exactly the bounds the container assigned.
2458 /// There is no way to get the original allocation assigned by
2459 /// [`size_allocate()`][Self::size_allocate()], since it isn’t stored; if a container
2460 /// implementation needs that information it will have to track it itself.
2461 ///
2462 /// # Returns
2463 ///
2464 ///
2465 /// ## `allocation`
2466 /// a pointer to a `GtkAllocation` to copy to
2467 #[doc(alias = "gtk_widget_get_allocation")]
2468 #[doc(alias = "get_allocation")]
2469 fn allocation(&self) -> Allocation {
2470 unsafe {
2471 let mut allocation = Allocation::uninitialized();
2472 ffi::gtk_widget_get_allocation(
2473 self.as_ref().to_glib_none().0,
2474 allocation.to_glib_none_mut().0,
2475 );
2476 allocation
2477 }
2478 }
2479
2480 /// Gets the first ancestor of `self` with type `widget_type`. For example,
2481 /// `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets
2482 /// the first [`Box`][crate::Box] that’s an ancestor of `self`. No reference will be
2483 /// added to the returned widget; it should not be unreferenced. See note
2484 /// about checking for a toplevel [`Window`][crate::Window] in the docs for
2485 /// [`toplevel()`][Self::toplevel()].
2486 ///
2487 /// Note that unlike [`is_ancestor()`][Self::is_ancestor()], [`ancestor()`][Self::ancestor()]
2488 /// considers `self` to be an ancestor of itself.
2489 /// ## `widget_type`
2490 /// ancestor type
2491 ///
2492 /// # Returns
2493 ///
2494 /// the ancestor widget, or [`None`] if not found
2495 #[doc(alias = "gtk_widget_get_ancestor")]
2496 #[doc(alias = "get_ancestor")]
2497 #[must_use]
2498 fn ancestor(&self, widget_type: glib::types::Type) -> Option<Widget> {
2499 unsafe {
2500 from_glib_none(ffi::gtk_widget_get_ancestor(
2501 self.as_ref().to_glib_none().0,
2502 widget_type.into_glib(),
2503 ))
2504 }
2505 }
2506
2507 /// Determines whether the application intends to draw on the widget in
2508 /// an [`draw`][struct@crate::Widget#draw] handler.
2509 ///
2510 /// See [`set_app_paintable()`][Self::set_app_paintable()]
2511 ///
2512 /// # Returns
2513 ///
2514 /// [`true`] if the widget is app paintable
2515 #[doc(alias = "gtk_widget_get_app_paintable")]
2516 #[doc(alias = "get_app_paintable")]
2517 fn is_app_paintable(&self) -> bool {
2518 unsafe {
2519 from_glib(ffi::gtk_widget_get_app_paintable(
2520 self.as_ref().to_glib_none().0,
2521 ))
2522 }
2523 }
2524
2525 /// Determines whether `self` can be a default widget. See
2526 /// [`set_can_default()`][Self::set_can_default()].
2527 ///
2528 /// # Returns
2529 ///
2530 /// [`true`] if `self` can be a default widget, [`false`] otherwise
2531 #[doc(alias = "gtk_widget_get_can_default")]
2532 #[doc(alias = "get_can_default")]
2533 fn can_default(&self) -> bool {
2534 unsafe {
2535 from_glib(ffi::gtk_widget_get_can_default(
2536 self.as_ref().to_glib_none().0,
2537 ))
2538 }
2539 }
2540
2541 /// Determines whether `self` can own the input focus. See
2542 /// [`set_can_focus()`][Self::set_can_focus()].
2543 ///
2544 /// # Returns
2545 ///
2546 /// [`true`] if `self` can own the input focus, [`false`] otherwise
2547 #[doc(alias = "gtk_widget_get_can_focus")]
2548 #[doc(alias = "get_can_focus")]
2549 fn can_focus(&self) -> bool {
2550 unsafe {
2551 from_glib(ffi::gtk_widget_get_can_focus(
2552 self.as_ref().to_glib_none().0,
2553 ))
2554 }
2555 }
2556
2557 /// Gets the value set with [`set_child_visible()`][Self::set_child_visible()].
2558 /// If you feel a need to use this function, your code probably
2559 /// needs reorganization.
2560 ///
2561 /// This function is only useful for container implementations and
2562 /// never should be called by an application.
2563 ///
2564 /// # Returns
2565 ///
2566 /// [`true`] if the widget is mapped with the parent.
2567 #[doc(alias = "gtk_widget_get_child_visible")]
2568 #[doc(alias = "get_child_visible")]
2569 fn is_child_visible(&self) -> bool {
2570 unsafe {
2571 from_glib(ffi::gtk_widget_get_child_visible(
2572 self.as_ref().to_glib_none().0,
2573 ))
2574 }
2575 }
2576
2577 /// Retrieves the widget’s clip area.
2578 ///
2579 /// The clip area is the area in which all of `self`'s drawing will
2580 /// happen. Other toolkits call it the bounding box.
2581 ///
2582 /// Historically, in GTK+ the clip area has been equal to the allocation
2583 /// retrieved via [`allocation()`][Self::allocation()].
2584 ///
2585 /// # Returns
2586 ///
2587 ///
2588 /// ## `clip`
2589 /// a pointer to a `GtkAllocation` to copy to
2590 #[doc(alias = "gtk_widget_get_clip")]
2591 #[doc(alias = "get_clip")]
2592 fn clip(&self) -> Allocation {
2593 unsafe {
2594 let mut clip = Allocation::uninitialized();
2595 ffi::gtk_widget_get_clip(self.as_ref().to_glib_none().0, clip.to_glib_none_mut().0);
2596 clip
2597 }
2598 }
2599
2600 /// Returns the clipboard object for the given selection to
2601 /// be used with `self`. `self` must have a [`gdk::Display`][crate::gdk::Display]
2602 /// associated with it, so must be attached to a toplevel
2603 /// window.
2604 /// ## `selection`
2605 /// a [`gdk::Atom`][crate::gdk::Atom] which identifies the clipboard
2606 /// to use. `GDK_SELECTION_CLIPBOARD` gives the
2607 /// default clipboard. Another common value
2608 /// is `GDK_SELECTION_PRIMARY`, which gives
2609 /// the primary X selection.
2610 ///
2611 /// # Returns
2612 ///
2613 /// the appropriate clipboard object. If no
2614 /// clipboard already exists, a new one will
2615 /// be created. Once a clipboard object has
2616 /// been created, it is persistent for all time.
2617 #[doc(alias = "gtk_widget_get_clipboard")]
2618 #[doc(alias = "get_clipboard")]
2619 fn clipboard(&self, selection: &gdk::Atom) -> Clipboard {
2620 unsafe {
2621 from_glib_none(ffi::gtk_widget_get_clipboard(
2622 self.as_ref().to_glib_none().0,
2623 selection.to_glib_none().0,
2624 ))
2625 }
2626 }
2627
2628 /// Returns whether `device` can interact with `self` and its
2629 /// children. See [`set_device_enabled()`][Self::set_device_enabled()].
2630 /// ## `device`
2631 /// a [`gdk::Device`][crate::gdk::Device]
2632 ///
2633 /// # Returns
2634 ///
2635 /// [`true`] is `device` is enabled for `self`
2636 #[doc(alias = "gtk_widget_get_device_enabled")]
2637 #[doc(alias = "get_device_enabled")]
2638 fn device_is_enabled(&self, device: &gdk::Device) -> bool {
2639 unsafe {
2640 from_glib(ffi::gtk_widget_get_device_enabled(
2641 self.as_ref().to_glib_none().0,
2642 device.to_glib_none().0,
2643 ))
2644 }
2645 }
2646
2647 /// Returns the events mask for the widget corresponding to an specific device. These
2648 /// are the events that the widget will receive when `device` operates on it.
2649 /// ## `device`
2650 /// a [`gdk::Device`][crate::gdk::Device]
2651 ///
2652 /// # Returns
2653 ///
2654 /// device event mask for `self`
2655 #[doc(alias = "gtk_widget_get_device_events")]
2656 #[doc(alias = "get_device_events")]
2657 fn device_events(&self, device: &gdk::Device) -> gdk::EventMask {
2658 unsafe {
2659 from_glib(ffi::gtk_widget_get_device_events(
2660 self.as_ref().to_glib_none().0,
2661 device.to_glib_none().0,
2662 ))
2663 }
2664 }
2665
2666 /// Gets the reading direction for a particular widget. See
2667 /// [`set_direction()`][Self::set_direction()].
2668 ///
2669 /// # Returns
2670 ///
2671 /// the reading direction for the widget.
2672 #[doc(alias = "gtk_widget_get_direction")]
2673 #[doc(alias = "get_direction")]
2674 fn direction(&self) -> TextDirection {
2675 unsafe {
2676 from_glib(ffi::gtk_widget_get_direction(
2677 self.as_ref().to_glib_none().0,
2678 ))
2679 }
2680 }
2681
2682 /// Get the [`gdk::Display`][crate::gdk::Display] for the toplevel window associated with
2683 /// this widget. This function can only be called after the widget
2684 /// has been added to a widget hierarchy with a [`Window`][crate::Window] at the top.
2685 ///
2686 /// In general, you should only create display specific
2687 /// resources when a widget has been realized, and you should
2688 /// free those resources when the widget is unrealized.
2689 ///
2690 /// # Returns
2691 ///
2692 /// the [`gdk::Display`][crate::gdk::Display] for the toplevel for this widget.
2693 #[doc(alias = "gtk_widget_get_display")]
2694 #[doc(alias = "get_display")]
2695 fn display(&self) -> gdk::Display {
2696 unsafe { from_glib_none(ffi::gtk_widget_get_display(self.as_ref().to_glib_none().0)) }
2697 }
2698
2699 /// Determines whether the widget is double buffered.
2700 ///
2701 /// See `gtk_widget_set_double_buffered()`
2702 ///
2703 /// # Returns
2704 ///
2705 /// [`true`] if the widget is double buffered
2706 #[doc(alias = "gtk_widget_get_double_buffered")]
2707 #[doc(alias = "get_double_buffered")]
2708 fn is_double_buffered(&self) -> bool {
2709 unsafe {
2710 from_glib(ffi::gtk_widget_get_double_buffered(
2711 self.as_ref().to_glib_none().0,
2712 ))
2713 }
2714 }
2715
2716 /// Returns whether the widget should grab focus when it is clicked with the mouse.
2717 /// See [`set_focus_on_click()`][Self::set_focus_on_click()].
2718 ///
2719 /// # Returns
2720 ///
2721 /// [`true`] if the widget should grab focus when it is clicked with
2722 /// the mouse.
2723 #[doc(alias = "gtk_widget_get_focus_on_click")]
2724 #[doc(alias = "get_focus_on_click")]
2725 fn gets_focus_on_click(&self) -> bool {
2726 unsafe {
2727 from_glib(ffi::gtk_widget_get_focus_on_click(
2728 self.as_ref().to_glib_none().0,
2729 ))
2730 }
2731 }
2732
2733 /// Gets the font map that has been set with [`set_font_map()`][Self::set_font_map()].
2734 ///
2735 /// # Returns
2736 ///
2737 /// A [`pango::FontMap`][crate::pango::FontMap], or [`None`]
2738 #[doc(alias = "gtk_widget_get_font_map")]
2739 #[doc(alias = "get_font_map")]
2740 fn font_map(&self) -> Option<pango::FontMap> {
2741 unsafe { from_glib_none(ffi::gtk_widget_get_font_map(self.as_ref().to_glib_none().0)) }
2742 }
2743
2744 /// Returns the [`cairo::FontOptions`][crate::cairo::FontOptions] used for Pango rendering. When not set,
2745 /// the defaults font options for the [`gdk::Screen`][crate::gdk::Screen] will be used.
2746 ///
2747 /// # Returns
2748 ///
2749 /// the [`cairo::FontOptions`][crate::cairo::FontOptions] or [`None`] if not set
2750 #[doc(alias = "gtk_widget_get_font_options")]
2751 #[doc(alias = "get_font_options")]
2752 fn font_options(&self) -> Option<cairo::FontOptions> {
2753 unsafe {
2754 from_glib_none(ffi::gtk_widget_get_font_options(
2755 self.as_ref().to_glib_none().0,
2756 ))
2757 }
2758 }
2759
2760 /// Obtains the frame clock for a widget. The frame clock is a global
2761 /// “ticker” that can be used to drive animations and repaints. The
2762 /// most common reason to get the frame clock is to call
2763 /// [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], in order to get a time to use for
2764 /// animating. For example you might record the start of the animation
2765 /// with an initial value from [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], and
2766 /// then update the animation by calling
2767 /// [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()] again during each repaint.
2768 ///
2769 /// [`FrameClock::request_phase()`][crate::gdk::FrameClock::request_phase()] will result in a new frame on the
2770 /// clock, but won’t necessarily repaint any widgets. To repaint a
2771 /// widget, you have to use [`queue_draw()`][Self::queue_draw()] which invalidates
2772 /// the widget (thus scheduling it to receive a draw on the next
2773 /// frame). [`queue_draw()`][Self::queue_draw()] will also end up requesting a frame
2774 /// on the appropriate frame clock.
2775 ///
2776 /// A widget’s frame clock will not change while the widget is
2777 /// mapped. Reparenting a widget (which implies a temporary unmap) can
2778 /// change the widget’s frame clock.
2779 ///
2780 /// Unrealized widgets do not have a frame clock.
2781 ///
2782 /// # Returns
2783 ///
2784 /// a [`gdk::FrameClock`][crate::gdk::FrameClock],
2785 /// or [`None`] if widget is unrealized
2786 #[doc(alias = "gtk_widget_get_frame_clock")]
2787 #[doc(alias = "get_frame_clock")]
2788 fn frame_clock(&self) -> Option<gdk::FrameClock> {
2789 unsafe {
2790 from_glib_none(ffi::gtk_widget_get_frame_clock(
2791 self.as_ref().to_glib_none().0,
2792 ))
2793 }
2794 }
2795
2796 /// Gets the value of the [`halign`][struct@crate::Widget#halign] property.
2797 ///
2798 /// For backwards compatibility reasons this method will never return
2799 /// [`Align::Baseline`][crate::Align::Baseline], but instead it will convert it to
2800 /// [`Align::Fill`][crate::Align::Fill]. Baselines are not supported for horizontal
2801 /// alignment.
2802 ///
2803 /// # Returns
2804 ///
2805 /// the horizontal alignment of `self`
2806 #[doc(alias = "gtk_widget_get_halign")]
2807 #[doc(alias = "get_halign")]
2808 fn halign(&self) -> Align {
2809 unsafe { from_glib(ffi::gtk_widget_get_halign(self.as_ref().to_glib_none().0)) }
2810 }
2811
2812 /// Returns the current value of the has-tooltip property. See
2813 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] for more information.
2814 ///
2815 /// # Returns
2816 ///
2817 /// current value of has-tooltip on `self`.
2818 #[doc(alias = "gtk_widget_get_has_tooltip")]
2819 #[doc(alias = "get_has_tooltip")]
2820 fn has_tooltip(&self) -> bool {
2821 unsafe {
2822 from_glib(ffi::gtk_widget_get_has_tooltip(
2823 self.as_ref().to_glib_none().0,
2824 ))
2825 }
2826 }
2827
2828 /// Determines whether `self` has a [`gdk::Window`][crate::gdk::Window] of its own. See
2829 /// [`set_has_window()`][Self::set_has_window()].
2830 ///
2831 /// # Returns
2832 ///
2833 /// [`true`] if `self` has a window, [`false`] otherwise
2834 #[doc(alias = "gtk_widget_get_has_window")]
2835 #[doc(alias = "get_has_window")]
2836 fn has_window(&self) -> bool {
2837 unsafe {
2838 from_glib(ffi::gtk_widget_get_has_window(
2839 self.as_ref().to_glib_none().0,
2840 ))
2841 }
2842 }
2843
2844 /// Gets whether the widget would like any available extra horizontal
2845 /// space. When a user resizes a [`Window`][crate::Window], widgets with expand=TRUE
2846 /// generally receive the extra space. For example, a list or
2847 /// scrollable area or document in your window would often be set to
2848 /// expand.
2849 ///
2850 /// Containers should use [`compute_expand()`][Self::compute_expand()] rather than
2851 /// this function, to see whether a widget, or any of its children,
2852 /// has the expand flag set. If any child of a widget wants to
2853 /// expand, the parent may ask to expand also.
2854 ///
2855 /// This function only looks at the widget’s own hexpand flag, rather
2856 /// than computing whether the entire widget tree rooted at this widget
2857 /// wants to expand.
2858 ///
2859 /// # Returns
2860 ///
2861 /// whether hexpand flag is set
2862 #[doc(alias = "gtk_widget_get_hexpand")]
2863 #[doc(alias = "get_hexpand")]
2864 fn hexpands(&self) -> bool {
2865 unsafe { from_glib(ffi::gtk_widget_get_hexpand(self.as_ref().to_glib_none().0)) }
2866 }
2867
2868 /// Gets whether [`set_hexpand()`][Self::set_hexpand()] has been used to
2869 /// explicitly set the expand flag on this widget.
2870 ///
2871 /// If hexpand is set, then it overrides any computed
2872 /// expand value based on child widgets. If hexpand is not
2873 /// set, then the expand value depends on whether any
2874 /// children of the widget would like to expand.
2875 ///
2876 /// There are few reasons to use this function, but it’s here
2877 /// for completeness and consistency.
2878 ///
2879 /// # Returns
2880 ///
2881 /// whether hexpand has been explicitly set
2882 #[doc(alias = "gtk_widget_get_hexpand_set")]
2883 #[doc(alias = "get_hexpand_set")]
2884 fn is_hexpand_set(&self) -> bool {
2885 unsafe {
2886 from_glib(ffi::gtk_widget_get_hexpand_set(
2887 self.as_ref().to_glib_none().0,
2888 ))
2889 }
2890 }
2891
2892 /// Whether the widget is mapped.
2893 ///
2894 /// # Returns
2895 ///
2896 /// [`true`] if the widget is mapped, [`false`] otherwise.
2897 #[doc(alias = "gtk_widget_get_mapped")]
2898 #[doc(alias = "get_mapped")]
2899 fn is_mapped(&self) -> bool {
2900 unsafe { from_glib(ffi::gtk_widget_get_mapped(self.as_ref().to_glib_none().0)) }
2901 }
2902
2903 /// Gets the value of the [`margin-bottom`][struct@crate::Widget#margin-bottom] property.
2904 ///
2905 /// # Returns
2906 ///
2907 /// The bottom margin of `self`
2908 #[doc(alias = "gtk_widget_get_margin_bottom")]
2909 #[doc(alias = "get_margin_bottom")]
2910 fn margin_bottom(&self) -> i32 {
2911 unsafe { ffi::gtk_widget_get_margin_bottom(self.as_ref().to_glib_none().0) }
2912 }
2913
2914 /// Gets the value of the [`margin-end`][struct@crate::Widget#margin-end] property.
2915 ///
2916 /// # Returns
2917 ///
2918 /// The end margin of `self`
2919 #[doc(alias = "gtk_widget_get_margin_end")]
2920 #[doc(alias = "get_margin_end")]
2921 fn margin_end(&self) -> i32 {
2922 unsafe { ffi::gtk_widget_get_margin_end(self.as_ref().to_glib_none().0) }
2923 }
2924
2925 /// Gets the value of the [`margin-start`][struct@crate::Widget#margin-start] property.
2926 ///
2927 /// # Returns
2928 ///
2929 /// The start margin of `self`
2930 #[doc(alias = "gtk_widget_get_margin_start")]
2931 #[doc(alias = "get_margin_start")]
2932 fn margin_start(&self) -> i32 {
2933 unsafe { ffi::gtk_widget_get_margin_start(self.as_ref().to_glib_none().0) }
2934 }
2935
2936 /// Gets the value of the [`margin-top`][struct@crate::Widget#margin-top] property.
2937 ///
2938 /// # Returns
2939 ///
2940 /// The top margin of `self`
2941 #[doc(alias = "gtk_widget_get_margin_top")]
2942 #[doc(alias = "get_margin_top")]
2943 fn margin_top(&self) -> i32 {
2944 unsafe { ffi::gtk_widget_get_margin_top(self.as_ref().to_glib_none().0) }
2945 }
2946
2947 /// Returns the modifier mask the `self`’s windowing system backend
2948 /// uses for a particular purpose.
2949 ///
2950 /// See `gdk_keymap_get_modifier_mask()`.
2951 /// ## `intent`
2952 /// the use case for the modifier mask
2953 ///
2954 /// # Returns
2955 ///
2956 /// the modifier mask used for `intent`.
2957 #[doc(alias = "gtk_widget_get_modifier_mask")]
2958 #[doc(alias = "get_modifier_mask")]
2959 fn modifier_mask(&self, intent: gdk::ModifierIntent) -> gdk::ModifierType {
2960 unsafe {
2961 from_glib(ffi::gtk_widget_get_modifier_mask(
2962 self.as_ref().to_glib_none().0,
2963 intent.into_glib(),
2964 ))
2965 }
2966 }
2967
2968 /// Retrieves the name of a widget. See [`set_widget_name()`][Self::set_widget_name()] for the
2969 /// significance of widget names.
2970 ///
2971 /// # Returns
2972 ///
2973 /// name of the widget. This string is owned by GTK+ and
2974 /// should not be modified or freed
2975 #[doc(alias = "gtk_widget_get_name")]
2976 #[doc(alias = "get_name")]
2977 fn widget_name(&self) -> glib::GString {
2978 unsafe { from_glib_none(ffi::gtk_widget_get_name(self.as_ref().to_glib_none().0)) }
2979 }
2980
2981 /// Returns the current value of the [`no-show-all`][struct@crate::Widget#no-show-all] property,
2982 /// which determines whether calls to [`show_all()`][Self::show_all()]
2983 /// will affect this widget.
2984 ///
2985 /// # Returns
2986 ///
2987 /// the current value of the “no-show-all” property.
2988 #[doc(alias = "gtk_widget_get_no_show_all")]
2989 #[doc(alias = "get_no_show_all")]
2990 fn is_no_show_all(&self) -> bool {
2991 unsafe {
2992 from_glib(ffi::gtk_widget_get_no_show_all(
2993 self.as_ref().to_glib_none().0,
2994 ))
2995 }
2996 }
2997
2998 /// Fetches the requested opacity for this widget.
2999 /// See [`set_opacity()`][Self::set_opacity()].
3000 ///
3001 /// # Returns
3002 ///
3003 /// the requested opacity for this widget.
3004 #[doc(alias = "gtk_widget_get_opacity")]
3005 #[doc(alias = "get_opacity")]
3006 fn opacity(&self) -> f64 {
3007 unsafe { ffi::gtk_widget_get_opacity(self.as_ref().to_glib_none().0) }
3008 }
3009
3010 /// Gets a [`pango::Context`][crate::pango::Context] with the appropriate font map, font description,
3011 /// and base direction for this widget. Unlike the context returned
3012 /// by [`create_pango_context()`][Self::create_pango_context()], this context is owned by
3013 /// the widget (it can be used until the screen for the widget changes
3014 /// or the widget is removed from its toplevel), and will be updated to
3015 /// match any changes to the widget’s attributes. This can be tracked
3016 /// by using the [`screen-changed`][struct@crate::Widget#screen-changed] signal on the widget.
3017 ///
3018 /// # Returns
3019 ///
3020 /// the [`pango::Context`][crate::pango::Context] for the widget.
3021 #[doc(alias = "gtk_widget_get_pango_context")]
3022 #[doc(alias = "get_pango_context")]
3023 fn pango_context(&self) -> pango::Context {
3024 unsafe {
3025 from_glib_none(ffi::gtk_widget_get_pango_context(
3026 self.as_ref().to_glib_none().0,
3027 ))
3028 }
3029 }
3030
3031 /// Returns the parent container of `self`.
3032 ///
3033 /// # Returns
3034 ///
3035 /// the parent container of `self`, or [`None`]
3036 #[doc(alias = "gtk_widget_get_parent")]
3037 #[doc(alias = "get_parent")]
3038 #[must_use]
3039 fn parent(&self) -> Option<Widget> {
3040 unsafe { from_glib_none(ffi::gtk_widget_get_parent(self.as_ref().to_glib_none().0)) }
3041 }
3042
3043 /// Gets `self`’s parent window, or [`None`] if it does not have one.
3044 ///
3045 /// # Returns
3046 ///
3047 /// the parent window of `self`, or [`None`]
3048 /// if it does not have a parent window.
3049 #[doc(alias = "gtk_widget_get_parent_window")]
3050 #[doc(alias = "get_parent_window")]
3051 fn parent_window(&self) -> Option<gdk::Window> {
3052 unsafe {
3053 from_glib_none(ffi::gtk_widget_get_parent_window(
3054 self.as_ref().to_glib_none().0,
3055 ))
3056 }
3057 }
3058
3059 /// Returns the [`WidgetPath`][crate::WidgetPath] representing `self`, if the widget
3060 /// is not connected to a toplevel widget, a partial path will be
3061 /// created.
3062 ///
3063 /// # Returns
3064 ///
3065 /// The [`WidgetPath`][crate::WidgetPath] representing `self`
3066 #[doc(alias = "gtk_widget_get_path")]
3067 #[doc(alias = "get_path")]
3068 fn path(&self) -> WidgetPath {
3069 unsafe { from_glib_none(ffi::gtk_widget_get_path(self.as_ref().to_glib_none().0)) }
3070 }
3071
3072 /// Retrieves a widget’s initial minimum and natural height.
3073 ///
3074 /// This call is specific to width-for-height requests.
3075 ///
3076 /// The returned request will be modified by the
3077 /// GtkWidgetClass::adjust_size_request virtual method and by any
3078 /// `GtkSizeGroups` that have been applied. That is, the returned request
3079 /// is the one that should be used for layout, not necessarily the one
3080 /// returned by the widget itself.
3081 ///
3082 /// # Returns
3083 ///
3084 ///
3085 /// ## `minimum_height`
3086 /// location to store the minimum height, or [`None`]
3087 ///
3088 /// ## `natural_height`
3089 /// location to store the natural height, or [`None`]
3090 #[doc(alias = "gtk_widget_get_preferred_height")]
3091 #[doc(alias = "get_preferred_height")]
3092 fn preferred_height(&self) -> (i32, i32) {
3093 unsafe {
3094 let mut minimum_height = mem::MaybeUninit::uninit();
3095 let mut natural_height = mem::MaybeUninit::uninit();
3096 ffi::gtk_widget_get_preferred_height(
3097 self.as_ref().to_glib_none().0,
3098 minimum_height.as_mut_ptr(),
3099 natural_height.as_mut_ptr(),
3100 );
3101 (minimum_height.assume_init(), natural_height.assume_init())
3102 }
3103 }
3104
3105 /// Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given
3106 /// the specified `width`, or the default height if `width` is -1. The baselines may be -1 which means
3107 /// that no baseline is requested for this widget.
3108 ///
3109 /// The returned request will be modified by the
3110 /// GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods
3111 /// and by any `GtkSizeGroups` that have been applied. That is, the returned request
3112 /// is the one that should be used for layout, not necessarily the one
3113 /// returned by the widget itself.
3114 /// ## `width`
3115 /// the width which is available for allocation, or -1 if none
3116 ///
3117 /// # Returns
3118 ///
3119 ///
3120 /// ## `minimum_height`
3121 /// location for storing the minimum height, or [`None`]
3122 ///
3123 /// ## `natural_height`
3124 /// location for storing the natural height, or [`None`]
3125 ///
3126 /// ## `minimum_baseline`
3127 /// location for storing the baseline for the minimum height, or [`None`]
3128 ///
3129 /// ## `natural_baseline`
3130 /// location for storing the baseline for the natural height, or [`None`]
3131 #[doc(alias = "gtk_widget_get_preferred_height_and_baseline_for_width")]
3132 #[doc(alias = "get_preferred_height_and_baseline_for_width")]
3133 fn preferred_height_and_baseline_for_width(&self, width: i32) -> (i32, i32, i32, i32) {
3134 unsafe {
3135 let mut minimum_height = mem::MaybeUninit::uninit();
3136 let mut natural_height = mem::MaybeUninit::uninit();
3137 let mut minimum_baseline = mem::MaybeUninit::uninit();
3138 let mut natural_baseline = mem::MaybeUninit::uninit();
3139 ffi::gtk_widget_get_preferred_height_and_baseline_for_width(
3140 self.as_ref().to_glib_none().0,
3141 width,
3142 minimum_height.as_mut_ptr(),
3143 natural_height.as_mut_ptr(),
3144 minimum_baseline.as_mut_ptr(),
3145 natural_baseline.as_mut_ptr(),
3146 );
3147 (
3148 minimum_height.assume_init(),
3149 natural_height.assume_init(),
3150 minimum_baseline.assume_init(),
3151 natural_baseline.assume_init(),
3152 )
3153 }
3154 }
3155
3156 /// Retrieves a widget’s minimum and natural height if it would be given
3157 /// the specified `width`.
3158 ///
3159 /// The returned request will be modified by the
3160 /// GtkWidgetClass::adjust_size_request virtual method and by any
3161 /// `GtkSizeGroups` that have been applied. That is, the returned request
3162 /// is the one that should be used for layout, not necessarily the one
3163 /// returned by the widget itself.
3164 /// ## `width`
3165 /// the width which is available for allocation
3166 ///
3167 /// # Returns
3168 ///
3169 ///
3170 /// ## `minimum_height`
3171 /// location for storing the minimum height, or [`None`]
3172 ///
3173 /// ## `natural_height`
3174 /// location for storing the natural height, or [`None`]
3175 #[doc(alias = "gtk_widget_get_preferred_height_for_width")]
3176 #[doc(alias = "get_preferred_height_for_width")]
3177 fn preferred_height_for_width(&self, width: i32) -> (i32, i32) {
3178 unsafe {
3179 let mut minimum_height = mem::MaybeUninit::uninit();
3180 let mut natural_height = mem::MaybeUninit::uninit();
3181 ffi::gtk_widget_get_preferred_height_for_width(
3182 self.as_ref().to_glib_none().0,
3183 width,
3184 minimum_height.as_mut_ptr(),
3185 natural_height.as_mut_ptr(),
3186 );
3187 (minimum_height.assume_init(), natural_height.assume_init())
3188 }
3189 }
3190
3191 /// Retrieves the minimum and natural size of a widget, taking
3192 /// into account the widget’s preference for height-for-width management.
3193 ///
3194 /// This is used to retrieve a suitable size by container widgets which do
3195 /// not impose any restrictions on the child placement. It can be used
3196 /// to deduce toplevel window and menu sizes as well as child widgets in
3197 /// free-form containers such as GtkLayout.
3198 ///
3199 /// Handle with care. Note that the natural height of a height-for-width
3200 /// widget will generally be a smaller size than the minimum height, since the required
3201 /// height for the natural width is generally smaller than the required height for
3202 /// the minimum width.
3203 ///
3204 /// Use [`preferred_height_and_baseline_for_width()`][Self::preferred_height_and_baseline_for_width()] if you want to support
3205 /// baseline alignment.
3206 ///
3207 /// # Returns
3208 ///
3209 ///
3210 /// ## `minimum_size`
3211 /// location for storing the minimum size, or [`None`]
3212 ///
3213 /// ## `natural_size`
3214 /// location for storing the natural size, or [`None`]
3215 #[doc(alias = "gtk_widget_get_preferred_size")]
3216 #[doc(alias = "get_preferred_size")]
3217 fn preferred_size(&self) -> (Requisition, Requisition) {
3218 unsafe {
3219 let mut minimum_size = Requisition::uninitialized();
3220 let mut natural_size = Requisition::uninitialized();
3221 ffi::gtk_widget_get_preferred_size(
3222 self.as_ref().to_glib_none().0,
3223 minimum_size.to_glib_none_mut().0,
3224 natural_size.to_glib_none_mut().0,
3225 );
3226 (minimum_size, natural_size)
3227 }
3228 }
3229
3230 /// Retrieves a widget’s initial minimum and natural width.
3231 ///
3232 /// This call is specific to height-for-width requests.
3233 ///
3234 /// The returned request will be modified by the
3235 /// GtkWidgetClass::adjust_size_request virtual method and by any
3236 /// `GtkSizeGroups` that have been applied. That is, the returned request
3237 /// is the one that should be used for layout, not necessarily the one
3238 /// returned by the widget itself.
3239 ///
3240 /// # Returns
3241 ///
3242 ///
3243 /// ## `minimum_width`
3244 /// location to store the minimum width, or [`None`]
3245 ///
3246 /// ## `natural_width`
3247 /// location to store the natural width, or [`None`]
3248 #[doc(alias = "gtk_widget_get_preferred_width")]
3249 #[doc(alias = "get_preferred_width")]
3250 fn preferred_width(&self) -> (i32, i32) {
3251 unsafe {
3252 let mut minimum_width = mem::MaybeUninit::uninit();
3253 let mut natural_width = mem::MaybeUninit::uninit();
3254 ffi::gtk_widget_get_preferred_width(
3255 self.as_ref().to_glib_none().0,
3256 minimum_width.as_mut_ptr(),
3257 natural_width.as_mut_ptr(),
3258 );
3259 (minimum_width.assume_init(), natural_width.assume_init())
3260 }
3261 }
3262
3263 /// Retrieves a widget’s minimum and natural width if it would be given
3264 /// the specified `height`.
3265 ///
3266 /// The returned request will be modified by the
3267 /// GtkWidgetClass::adjust_size_request virtual method and by any
3268 /// `GtkSizeGroups` that have been applied. That is, the returned request
3269 /// is the one that should be used for layout, not necessarily the one
3270 /// returned by the widget itself.
3271 /// ## `height`
3272 /// the height which is available for allocation
3273 ///
3274 /// # Returns
3275 ///
3276 ///
3277 /// ## `minimum_width`
3278 /// location for storing the minimum width, or [`None`]
3279 ///
3280 /// ## `natural_width`
3281 /// location for storing the natural width, or [`None`]
3282 #[doc(alias = "gtk_widget_get_preferred_width_for_height")]
3283 #[doc(alias = "get_preferred_width_for_height")]
3284 fn preferred_width_for_height(&self, height: i32) -> (i32, i32) {
3285 unsafe {
3286 let mut minimum_width = mem::MaybeUninit::uninit();
3287 let mut natural_width = mem::MaybeUninit::uninit();
3288 ffi::gtk_widget_get_preferred_width_for_height(
3289 self.as_ref().to_glib_none().0,
3290 height,
3291 minimum_width.as_mut_ptr(),
3292 natural_width.as_mut_ptr(),
3293 );
3294 (minimum_width.assume_init(), natural_width.assume_init())
3295 }
3296 }
3297
3298 /// Determines whether `self` is realized.
3299 ///
3300 /// # Returns
3301 ///
3302 /// [`true`] if `self` is realized, [`false`] otherwise
3303 #[doc(alias = "gtk_widget_get_realized")]
3304 #[doc(alias = "get_realized")]
3305 fn is_realized(&self) -> bool {
3306 unsafe { from_glib(ffi::gtk_widget_get_realized(self.as_ref().to_glib_none().0)) }
3307 }
3308
3309 /// Determines whether `self` is always treated as the default widget
3310 /// within its toplevel when it has the focus, even if another widget
3311 /// is the default.
3312 ///
3313 /// See [`set_receives_default()`][Self::set_receives_default()].
3314 ///
3315 /// # Returns
3316 ///
3317 /// [`true`] if `self` acts as the default widget when focused,
3318 /// [`false`] otherwise
3319 #[doc(alias = "gtk_widget_get_receives_default")]
3320 #[doc(alias = "get_receives_default")]
3321 fn receives_default(&self) -> bool {
3322 unsafe {
3323 from_glib(ffi::gtk_widget_get_receives_default(
3324 self.as_ref().to_glib_none().0,
3325 ))
3326 }
3327 }
3328
3329 /// Gets whether the widget prefers a height-for-width layout
3330 /// or a width-for-height layout.
3331 ///
3332 /// [`Bin`][crate::Bin] widgets generally propagate the preference of
3333 /// their child, container widgets need to request something either in
3334 /// context of their children or in context of their allocation
3335 /// capabilities.
3336 ///
3337 /// # Returns
3338 ///
3339 /// The [`SizeRequestMode`][crate::SizeRequestMode] preferred by `self`.
3340 #[doc(alias = "gtk_widget_get_request_mode")]
3341 #[doc(alias = "get_request_mode")]
3342 fn request_mode(&self) -> SizeRequestMode {
3343 unsafe {
3344 from_glib(ffi::gtk_widget_get_request_mode(
3345 self.as_ref().to_glib_none().0,
3346 ))
3347 }
3348 }
3349
3350 /// Retrieves the internal scale factor that maps from window coordinates
3351 /// to the actual device pixels. On traditional systems this is 1, on
3352 /// high density outputs, it can be a higher value (typically 2).
3353 ///
3354 /// See [`Window::scale_factor()`][crate::gdk::Window::scale_factor()].
3355 ///
3356 /// # Returns
3357 ///
3358 /// the scale factor for `self`
3359 #[doc(alias = "gtk_widget_get_scale_factor")]
3360 #[doc(alias = "get_scale_factor")]
3361 fn scale_factor(&self) -> i32 {
3362 unsafe { ffi::gtk_widget_get_scale_factor(self.as_ref().to_glib_none().0) }
3363 }
3364
3365 /// Get the [`gdk::Screen`][crate::gdk::Screen] from the toplevel window associated with
3366 /// this widget. This function can only be called after the widget
3367 /// has been added to a widget hierarchy with a [`Window`][crate::Window]
3368 /// at the top.
3369 ///
3370 /// In general, you should only create screen specific
3371 /// resources when a widget has been realized, and you should
3372 /// free those resources when the widget is unrealized.
3373 ///
3374 /// # Returns
3375 ///
3376 /// the [`gdk::Screen`][crate::gdk::Screen] for the toplevel for this widget.
3377 #[doc(alias = "gtk_widget_get_screen")]
3378 #[doc(alias = "get_screen")]
3379 fn screen(&self) -> Option<gdk::Screen> {
3380 unsafe { from_glib_none(ffi::gtk_widget_get_screen(self.as_ref().to_glib_none().0)) }
3381 }
3382
3383 /// Returns the widget’s sensitivity (in the sense of returning
3384 /// the value that has been set using [`set_sensitive()`][Self::set_sensitive()]).
3385 ///
3386 /// The effective sensitivity of a widget is however determined by both its
3387 /// own and its parent widget’s sensitivity. See [`is_sensitive()`][Self::is_sensitive()].
3388 ///
3389 /// # Returns
3390 ///
3391 /// [`true`] if the widget is sensitive
3392 #[doc(alias = "gtk_widget_get_sensitive")]
3393 fn get_sensitive(&self) -> bool {
3394 unsafe {
3395 from_glib(ffi::gtk_widget_get_sensitive(
3396 self.as_ref().to_glib_none().0,
3397 ))
3398 }
3399 }
3400
3401 /// Gets the settings object holding the settings used for this widget.
3402 ///
3403 /// Note that this function can only be called when the [`Widget`][crate::Widget]
3404 /// is attached to a toplevel, since the settings object is specific
3405 /// to a particular [`gdk::Screen`][crate::gdk::Screen].
3406 ///
3407 /// # Returns
3408 ///
3409 /// the relevant [`Settings`][crate::Settings] object
3410 #[doc(alias = "gtk_widget_get_settings")]
3411 #[doc(alias = "get_settings")]
3412 fn settings(&self) -> Option<Settings> {
3413 unsafe { from_glib_none(ffi::gtk_widget_get_settings(self.as_ref().to_glib_none().0)) }
3414 }
3415
3416 /// Gets the size request that was explicitly set for the widget using
3417 /// [`set_size_request()`][Self::set_size_request()]. A value of -1 stored in `width` or
3418 /// `height` indicates that that dimension has not been set explicitly
3419 /// and the natural requisition of the widget will be used instead. See
3420 /// [`set_size_request()`][Self::set_size_request()]. To get the size a widget will
3421 /// actually request, call [`preferred_size()`][Self::preferred_size()] instead of
3422 /// this function.
3423 ///
3424 /// # Returns
3425 ///
3426 ///
3427 /// ## `width`
3428 /// return location for width, or [`None`]
3429 ///
3430 /// ## `height`
3431 /// return location for height, or [`None`]
3432 #[doc(alias = "gtk_widget_get_size_request")]
3433 #[doc(alias = "get_size_request")]
3434 fn size_request(&self) -> (i32, i32) {
3435 unsafe {
3436 let mut width = mem::MaybeUninit::uninit();
3437 let mut height = mem::MaybeUninit::uninit();
3438 ffi::gtk_widget_get_size_request(
3439 self.as_ref().to_glib_none().0,
3440 width.as_mut_ptr(),
3441 height.as_mut_ptr(),
3442 );
3443 (width.assume_init(), height.assume_init())
3444 }
3445 }
3446
3447 /// Returns the widget state as a flag set. It is worth mentioning
3448 /// that the effective [`StateFlags::INSENSITIVE`][crate::StateFlags::INSENSITIVE] state will be
3449 /// returned, that is, also based on parent insensitivity, even if
3450 /// `self` itself is sensitive.
3451 ///
3452 /// Also note that if you are looking for a way to obtain the
3453 /// [`StateFlags`][crate::StateFlags] to pass to a [`StyleContext`][crate::StyleContext] method, you
3454 /// should look at [`StyleContextExt::state()`][crate::prelude::StyleContextExt::state()].
3455 ///
3456 /// # Returns
3457 ///
3458 /// The state flags for widget
3459 #[doc(alias = "gtk_widget_get_state_flags")]
3460 #[doc(alias = "get_state_flags")]
3461 fn state_flags(&self) -> StateFlags {
3462 unsafe {
3463 from_glib(ffi::gtk_widget_get_state_flags(
3464 self.as_ref().to_glib_none().0,
3465 ))
3466 }
3467 }
3468
3469 /// Returns the style context associated to `self`. The returned object is
3470 /// guaranteed to be the same for the lifetime of `self`.
3471 ///
3472 /// # Returns
3473 ///
3474 /// a [`StyleContext`][crate::StyleContext]. This memory is owned by `self` and
3475 /// must not be freed.
3476 #[doc(alias = "gtk_widget_get_style_context")]
3477 #[doc(alias = "get_style_context")]
3478 fn style_context(&self) -> StyleContext {
3479 unsafe {
3480 from_glib_none(ffi::gtk_widget_get_style_context(
3481 self.as_ref().to_glib_none().0,
3482 ))
3483 }
3484 }
3485
3486 /// Returns [`true`] if `self` is multiple pointer aware. See
3487 /// [`set_support_multidevice()`][Self::set_support_multidevice()] for more information.
3488 ///
3489 /// # Returns
3490 ///
3491 /// [`true`] if `self` is multidevice aware.
3492 #[doc(alias = "gtk_widget_get_support_multidevice")]
3493 #[doc(alias = "get_support_multidevice")]
3494 fn supports_multidevice(&self) -> bool {
3495 unsafe {
3496 from_glib(ffi::gtk_widget_get_support_multidevice(
3497 self.as_ref().to_glib_none().0,
3498 ))
3499 }
3500 }
3501
3502 /// Fetch an object build from the template XML for `widget_type` in this `self` instance.
3503 ///
3504 /// This will only report children which were previously declared with
3505 /// `gtk_widget_class_bind_template_child_full()` or one of its
3506 /// variants.
3507 ///
3508 /// This function is only meant to be called for code which is private to the `widget_type` which
3509 /// declared the child and is meant for language bindings which cannot easily make use
3510 /// of the GObject structure offsets.
3511 /// ## `widget_type`
3512 /// The `GType` to get a template child for
3513 /// ## `name`
3514 /// The “id” of the child defined in the template XML
3515 ///
3516 /// # Returns
3517 ///
3518 /// The object built in the template XML with the id `name`
3519 #[doc(alias = "gtk_widget_get_template_child")]
3520 #[doc(alias = "get_template_child")]
3521 fn template_child(&self, widget_type: glib::types::Type, name: &str) -> Option<glib::Object> {
3522 unsafe {
3523 from_glib_none(ffi::gtk_widget_get_template_child(
3524 self.as_ref().to_glib_none().0,
3525 widget_type.into_glib(),
3526 name.to_glib_none().0,
3527 ))
3528 }
3529 }
3530
3531 /// Gets the contents of the tooltip for `self`.
3532 ///
3533 /// # Returns
3534 ///
3535 /// the tooltip text, or [`None`]. You should free the
3536 /// returned string with `g_free()` when done.
3537 #[doc(alias = "gtk_widget_get_tooltip_markup")]
3538 #[doc(alias = "get_tooltip_markup")]
3539 fn tooltip_markup(&self) -> Option<glib::GString> {
3540 unsafe {
3541 from_glib_full(ffi::gtk_widget_get_tooltip_markup(
3542 self.as_ref().to_glib_none().0,
3543 ))
3544 }
3545 }
3546
3547 /// Gets the contents of the tooltip for `self`.
3548 ///
3549 /// # Returns
3550 ///
3551 /// the tooltip text, or [`None`]. You should free the
3552 /// returned string with `g_free()` when done.
3553 #[doc(alias = "gtk_widget_get_tooltip_text")]
3554 #[doc(alias = "get_tooltip_text")]
3555 fn tooltip_text(&self) -> Option<glib::GString> {
3556 unsafe {
3557 from_glib_full(ffi::gtk_widget_get_tooltip_text(
3558 self.as_ref().to_glib_none().0,
3559 ))
3560 }
3561 }
3562
3563 /// Returns the [`Window`][crate::Window] of the current tooltip. This can be the
3564 /// GtkWindow created by default, or the custom tooltip window set
3565 /// using [`set_tooltip_window()`][Self::set_tooltip_window()].
3566 ///
3567 /// # Returns
3568 ///
3569 /// The [`Window`][crate::Window] of the current tooltip.
3570 #[doc(alias = "gtk_widget_get_tooltip_window")]
3571 #[doc(alias = "get_tooltip_window")]
3572 fn tooltip_window(&self) -> Option<Window> {
3573 unsafe {
3574 from_glib_none(ffi::gtk_widget_get_tooltip_window(
3575 self.as_ref().to_glib_none().0,
3576 ))
3577 }
3578 }
3579
3580 /// This function returns the topmost widget in the container hierarchy
3581 /// `self` is a part of. If `self` has no parent widgets, it will be
3582 /// returned as the topmost widget. No reference will be added to the
3583 /// returned widget; it should not be unreferenced.
3584 ///
3585 /// Note the difference in behavior vs. [`ancestor()`][Self::ancestor()];
3586 /// `gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)`
3587 /// would return
3588 /// [`None`] if `self` wasn’t inside a toplevel window, and if the
3589 /// window was inside a [`Window`][crate::Window]-derived widget which was in turn
3590 /// inside the toplevel [`Window`][crate::Window]. While the second case may
3591 /// seem unlikely, it actually happens when a [`Plug`][crate::Plug] is embedded
3592 /// inside a [`Socket`][crate::Socket] within the same application.
3593 ///
3594 /// To reliably find the toplevel [`Window`][crate::Window], use
3595 /// [`toplevel()`][Self::toplevel()] and call GTK_IS_WINDOW()
3596 /// on the result. For instance, to get the title of a widget's toplevel
3597 /// window, one might use:
3598 ///
3599 ///
3600 /// **⚠️ The following code is in C ⚠️**
3601 ///
3602 /// ```C
3603 /// static const char *
3604 /// get_widget_toplevel_title (GtkWidget *widget)
3605 /// {
3606 /// GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
3607 /// if (GTK_IS_WINDOW (toplevel))
3608 /// {
3609 /// return gtk_window_get_title (GTK_WINDOW (toplevel));
3610 /// }
3611 ///
3612 /// return NULL;
3613 /// }
3614 /// ```
3615 ///
3616 /// # Returns
3617 ///
3618 /// the topmost ancestor of `self`, or `self` itself
3619 /// if there’s no ancestor.
3620 #[doc(alias = "gtk_widget_get_toplevel")]
3621 #[doc(alias = "get_toplevel")]
3622 #[must_use]
3623 fn toplevel(&self) -> Option<Widget> {
3624 unsafe { from_glib_none(ffi::gtk_widget_get_toplevel(self.as_ref().to_glib_none().0)) }
3625 }
3626
3627 /// Gets the value of the [`valign`][struct@crate::Widget#valign] property.
3628 ///
3629 /// For backwards compatibility reasons this method will never return
3630 /// [`Align::Baseline`][crate::Align::Baseline], but instead it will convert it to
3631 /// [`Align::Fill`][crate::Align::Fill]. If your widget want to support baseline aligned
3632 /// children it must use [`valign_with_baseline()`][Self::valign_with_baseline()], or
3633 /// `g_object_get (widget, "valign", &value, NULL)`, which will
3634 /// also report the true value.
3635 ///
3636 /// # Returns
3637 ///
3638 /// the vertical alignment of `self`, ignoring baseline alignment
3639 #[doc(alias = "gtk_widget_get_valign")]
3640 #[doc(alias = "get_valign")]
3641 fn valign(&self) -> Align {
3642 unsafe { from_glib(ffi::gtk_widget_get_valign(self.as_ref().to_glib_none().0)) }
3643 }
3644
3645 /// Gets the value of the [`valign`][struct@crate::Widget#valign] property, including
3646 /// [`Align::Baseline`][crate::Align::Baseline].
3647 ///
3648 /// # Returns
3649 ///
3650 /// the vertical alignment of `self`
3651 #[doc(alias = "gtk_widget_get_valign_with_baseline")]
3652 #[doc(alias = "get_valign_with_baseline")]
3653 fn valign_with_baseline(&self) -> Align {
3654 unsafe {
3655 from_glib(ffi::gtk_widget_get_valign_with_baseline(
3656 self.as_ref().to_glib_none().0,
3657 ))
3658 }
3659 }
3660
3661 /// Gets whether the widget would like any available extra vertical
3662 /// space.
3663 ///
3664 /// See [`hexpands()`][Self::hexpands()] for more detail.
3665 ///
3666 /// # Returns
3667 ///
3668 /// whether vexpand flag is set
3669 #[doc(alias = "gtk_widget_get_vexpand")]
3670 #[doc(alias = "get_vexpand")]
3671 fn vexpands(&self) -> bool {
3672 unsafe { from_glib(ffi::gtk_widget_get_vexpand(self.as_ref().to_glib_none().0)) }
3673 }
3674
3675 /// Gets whether [`set_vexpand()`][Self::set_vexpand()] has been used to
3676 /// explicitly set the expand flag on this widget.
3677 ///
3678 /// See [`is_hexpand_set()`][Self::is_hexpand_set()] for more detail.
3679 ///
3680 /// # Returns
3681 ///
3682 /// whether vexpand has been explicitly set
3683 #[doc(alias = "gtk_widget_get_vexpand_set")]
3684 #[doc(alias = "get_vexpand_set")]
3685 fn is_vexpand_set(&self) -> bool {
3686 unsafe {
3687 from_glib(ffi::gtk_widget_get_vexpand_set(
3688 self.as_ref().to_glib_none().0,
3689 ))
3690 }
3691 }
3692
3693 /// Determines whether the widget is visible. If you want to
3694 /// take into account whether the widget’s parent is also marked as
3695 /// visible, use [`is_visible()`][Self::is_visible()] instead.
3696 ///
3697 /// This function does not check if the widget is obscured in any way.
3698 ///
3699 /// See [`set_visible()`][Self::set_visible()].
3700 ///
3701 /// # Returns
3702 ///
3703 /// [`true`] if the widget is visible
3704 #[doc(alias = "gtk_widget_get_visible")]
3705 fn get_visible(&self) -> bool {
3706 unsafe { from_glib(ffi::gtk_widget_get_visible(self.as_ref().to_glib_none().0)) }
3707 }
3708
3709 /// Gets the visual that will be used to render `self`.
3710 ///
3711 /// # Returns
3712 ///
3713 /// the visual for `self`
3714 #[doc(alias = "gtk_widget_get_visual")]
3715 #[doc(alias = "get_visual")]
3716 fn visual(&self) -> Option<gdk::Visual> {
3717 unsafe { from_glib_none(ffi::gtk_widget_get_visual(self.as_ref().to_glib_none().0)) }
3718 }
3719
3720 /// Returns the widget’s window if it is realized, [`None`] otherwise
3721 ///
3722 /// # Returns
3723 ///
3724 /// `self`’s window.
3725 #[doc(alias = "gtk_widget_get_window")]
3726 #[doc(alias = "get_window")]
3727 fn window(&self) -> Option<gdk::Window> {
3728 unsafe { from_glib_none(ffi::gtk_widget_get_window(self.as_ref().to_glib_none().0)) }
3729 }
3730
3731 /// Makes `self` the current grabbed widget.
3732 ///
3733 /// This means that interaction with other widgets in the same
3734 /// application is blocked and mouse as well as keyboard events
3735 /// are delivered to this widget.
3736 ///
3737 /// If `self` is not sensitive, it is not set as the current
3738 /// grabbed widget and this function does nothing.
3739 #[doc(alias = "gtk_grab_add")]
3740 fn grab_add(&self) {
3741 unsafe {
3742 ffi::gtk_grab_add(self.as_ref().to_glib_none().0);
3743 }
3744 }
3745
3746 /// Causes `self` to become the default widget. `self` must be able to be
3747 /// a default widget; typically you would ensure this yourself
3748 /// by calling [`set_can_default()`][Self::set_can_default()] with a [`true`] value.
3749 /// The default widget is activated when
3750 /// the user presses Enter in a window. Default widgets must be
3751 /// activatable, that is, [`activate()`][Self::activate()] should affect them. Note
3752 /// that [`Entry`][crate::Entry] widgets require the “activates-default” property
3753 /// set to [`true`] before they activate the default widget when Enter
3754 /// is pressed and the [`Entry`][crate::Entry] is focused.
3755 #[doc(alias = "gtk_widget_grab_default")]
3756 fn grab_default(&self) {
3757 unsafe {
3758 ffi::gtk_widget_grab_default(self.as_ref().to_glib_none().0);
3759 }
3760 }
3761
3762 /// Causes `self` to have the keyboard focus for the [`Window`][crate::Window] it's
3763 /// inside. `self` must be a focusable widget, such as a [`Entry`][crate::Entry];
3764 /// something like [`Frame`][crate::Frame] won’t work.
3765 ///
3766 /// More precisely, it must have the `GTK_CAN_FOCUS` flag set. Use
3767 /// [`set_can_focus()`][Self::set_can_focus()] to modify that flag.
3768 ///
3769 /// The widget also needs to be realized and mapped. This is indicated by the
3770 /// related signals. Grabbing the focus immediately after creating the widget
3771 /// will likely fail and cause critical warnings.
3772 #[doc(alias = "gtk_widget_grab_focus")]
3773 fn grab_focus(&self) {
3774 unsafe {
3775 ffi::gtk_widget_grab_focus(self.as_ref().to_glib_none().0);
3776 }
3777 }
3778
3779 /// Removes the grab from the given widget.
3780 ///
3781 /// You have to pair calls to [`grab_add()`][Self::grab_add()] and [`grab_remove()`][Self::grab_remove()].
3782 ///
3783 /// If `self` does not have the grab, this function does nothing.
3784 #[doc(alias = "gtk_grab_remove")]
3785 fn grab_remove(&self) {
3786 unsafe {
3787 ffi::gtk_grab_remove(self.as_ref().to_glib_none().0);
3788 }
3789 }
3790
3791 /// Determines whether `self` is the current default widget within its
3792 /// toplevel. See [`set_can_default()`][Self::set_can_default()].
3793 ///
3794 /// # Returns
3795 ///
3796 /// [`true`] if `self` is the current default widget within
3797 /// its toplevel, [`false`] otherwise
3798 #[doc(alias = "gtk_widget_has_default")]
3799 fn has_default(&self) -> bool {
3800 unsafe { from_glib(ffi::gtk_widget_has_default(self.as_ref().to_glib_none().0)) }
3801 }
3802
3803 /// Determines if the widget has the global input focus. See
3804 /// [`is_focus()`][Self::is_focus()] for the difference between having the global
3805 /// input focus, and only having the focus within a toplevel.
3806 ///
3807 /// # Returns
3808 ///
3809 /// [`true`] if the widget has the global input focus.
3810 #[doc(alias = "gtk_widget_has_focus")]
3811 fn has_focus(&self) -> bool {
3812 unsafe { from_glib(ffi::gtk_widget_has_focus(self.as_ref().to_glib_none().0)) }
3813 }
3814
3815 /// Determines whether the widget is currently grabbing events, so it
3816 /// is the only widget receiving input events (keyboard and mouse).
3817 ///
3818 /// See also [`grab_add()`][Self::grab_add()].
3819 ///
3820 /// # Returns
3821 ///
3822 /// [`true`] if the widget is in the grab_widgets stack
3823 #[doc(alias = "gtk_widget_has_grab")]
3824 fn has_grab(&self) -> bool {
3825 unsafe { from_glib(ffi::gtk_widget_has_grab(self.as_ref().to_glib_none().0)) }
3826 }
3827
3828 /// Checks whether there is a [`gdk::Screen`][crate::gdk::Screen] is associated with
3829 /// this widget. All toplevel widgets have an associated
3830 /// screen, and all widgets added into a hierarchy with a toplevel
3831 /// window at the top.
3832 ///
3833 /// # Returns
3834 ///
3835 /// [`true`] if there is a [`gdk::Screen`][crate::gdk::Screen] associated
3836 /// with the widget.
3837 #[doc(alias = "gtk_widget_has_screen")]
3838 fn has_screen(&self) -> bool {
3839 unsafe { from_glib(ffi::gtk_widget_has_screen(self.as_ref().to_glib_none().0)) }
3840 }
3841
3842 /// Determines if the widget should show a visible indication that
3843 /// it has the global input focus. This is a convenience function for
3844 /// use in ::draw handlers that takes into account whether focus
3845 /// indication should currently be shown in the toplevel window of
3846 /// `self`. See [`GtkWindowExt::gets_focus_visible()`][crate::prelude::GtkWindowExt::gets_focus_visible()] for more information
3847 /// about focus indication.
3848 ///
3849 /// To find out if the widget has the global input focus, use
3850 /// [`has_focus()`][Self::has_focus()].
3851 ///
3852 /// # Returns
3853 ///
3854 /// [`true`] if the widget should display a “focus rectangle”
3855 #[doc(alias = "gtk_widget_has_visible_focus")]
3856 fn has_visible_focus(&self) -> bool {
3857 unsafe {
3858 from_glib(ffi::gtk_widget_has_visible_focus(
3859 self.as_ref().to_glib_none().0,
3860 ))
3861 }
3862 }
3863
3864 /// Reverses the effects of [`show()`][Self::show()], causing the widget to be
3865 /// hidden (invisible to the user).
3866 #[doc(alias = "gtk_widget_hide")]
3867 fn hide(&self) {
3868 unsafe {
3869 ffi::gtk_widget_hide(self.as_ref().to_glib_none().0);
3870 }
3871 }
3872
3873 /// Returns whether the widget is currently being destroyed.
3874 /// This information can sometimes be used to avoid doing
3875 /// unnecessary work.
3876 ///
3877 /// # Returns
3878 ///
3879 /// [`true`] if `self` is being destroyed
3880 #[doc(alias = "gtk_widget_in_destruction")]
3881 fn in_destruction(&self) -> bool {
3882 unsafe {
3883 from_glib(ffi::gtk_widget_in_destruction(
3884 self.as_ref().to_glib_none().0,
3885 ))
3886 }
3887 }
3888
3889 /// Creates and initializes child widgets defined in templates. This
3890 /// function must be called in the instance initializer for any
3891 /// class which assigned itself a template using `gtk_widget_class_set_template()`
3892 ///
3893 /// It is important to call this function in the instance initializer
3894 /// of a [`Widget`][crate::Widget] subclass and not in `GObject.constructed()` or
3895 /// `GObject.constructor()` for two reasons.
3896 ///
3897 /// One reason is that generally derived widgets will assume that parent
3898 /// class composite widgets have been created in their instance
3899 /// initializers.
3900 ///
3901 /// Another reason is that when calling [`glib::Object::new()`][crate::glib::Object::new()] on a widget with
3902 /// composite templates, it’s important to build the composite widgets
3903 /// before the construct properties are set. Properties passed to [`glib::Object::new()`][crate::glib::Object::new()]
3904 /// should take precedence over properties set in the private template XML.
3905 #[doc(alias = "gtk_widget_init_template")]
3906 fn init_template(&self) {
3907 unsafe {
3908 ffi::gtk_widget_init_template(self.as_ref().to_glib_none().0);
3909 }
3910 }
3911
3912 /// Sets an input shape for this widget’s GDK window. This allows for
3913 /// windows which react to mouse click in a nonrectangular region, see
3914 /// [`Window::input_shape_combine_region()`][crate::gdk::Window::input_shape_combine_region()] for more information.
3915 /// ## `region`
3916 /// shape to be added, or [`None`] to remove an existing shape
3917 #[doc(alias = "gtk_widget_input_shape_combine_region")]
3918 fn input_shape_combine_region(&self, region: Option<&cairo::Region>) {
3919 unsafe {
3920 ffi::gtk_widget_input_shape_combine_region(
3921 self.as_ref().to_glib_none().0,
3922 mut_override(region.to_glib_none().0),
3923 );
3924 }
3925 }
3926
3927 /// Inserts `group` into `self`. Children of `self` that implement
3928 /// [`Actionable`][crate::Actionable] can then be associated with actions in `group` by
3929 /// setting their “action-name” to
3930 /// `prefix`.`action-name`.
3931 ///
3932 /// If `group` is [`None`], a previously inserted group for `name` is removed
3933 /// from `self`.
3934 /// ## `name`
3935 /// the prefix for actions in `group`
3936 /// ## `group`
3937 /// a [`gio::ActionGroup`][crate::gio::ActionGroup], or [`None`]
3938 #[doc(alias = "gtk_widget_insert_action_group")]
3939 fn insert_action_group(&self, name: &str, group: Option<&impl IsA<gio::ActionGroup>>) {
3940 unsafe {
3941 ffi::gtk_widget_insert_action_group(
3942 self.as_ref().to_glib_none().0,
3943 name.to_glib_none().0,
3944 group.map(|p| p.as_ref()).to_glib_none().0,
3945 );
3946 }
3947 }
3948
3949 /// Determines whether `self` is somewhere inside `ancestor`, possibly with
3950 /// intermediate containers.
3951 /// ## `ancestor`
3952 /// another [`Widget`][crate::Widget]
3953 ///
3954 /// # Returns
3955 ///
3956 /// [`true`] if `ancestor` contains `self` as a child,
3957 /// grandchild, great grandchild, etc.
3958 #[doc(alias = "gtk_widget_is_ancestor")]
3959 fn is_ancestor(&self, ancestor: &impl IsA<Widget>) -> bool {
3960 unsafe {
3961 from_glib(ffi::gtk_widget_is_ancestor(
3962 self.as_ref().to_glib_none().0,
3963 ancestor.as_ref().to_glib_none().0,
3964 ))
3965 }
3966 }
3967
3968 /// Determines whether `self` can be drawn to. A widget can be drawn
3969 /// to if it is mapped and visible.
3970 ///
3971 /// # Returns
3972 ///
3973 /// [`true`] if `self` is drawable, [`false`] otherwise
3974 #[doc(alias = "gtk_widget_is_drawable")]
3975 fn is_drawable(&self) -> bool {
3976 unsafe { from_glib(ffi::gtk_widget_is_drawable(self.as_ref().to_glib_none().0)) }
3977 }
3978
3979 /// Determines if the widget is the focus widget within its
3980 /// toplevel. (This does not mean that the [`has-focus`][struct@crate::Widget#has-focus] property is
3981 /// necessarily set; [`has-focus`][struct@crate::Widget#has-focus] will only be set if the
3982 /// toplevel widget additionally has the global input focus.)
3983 ///
3984 /// # Returns
3985 ///
3986 /// [`true`] if the widget is the focus widget.
3987 #[doc(alias = "gtk_widget_is_focus")]
3988 fn is_focus(&self) -> bool {
3989 unsafe { from_glib(ffi::gtk_widget_is_focus(self.as_ref().to_glib_none().0)) }
3990 }
3991
3992 /// Returns the widget’s effective sensitivity, which means
3993 /// it is sensitive itself and also its parent widget is sensitive
3994 ///
3995 /// # Returns
3996 ///
3997 /// [`true`] if the widget is effectively sensitive
3998 #[doc(alias = "gtk_widget_is_sensitive")]
3999 fn is_sensitive(&self) -> bool {
4000 unsafe { from_glib(ffi::gtk_widget_is_sensitive(self.as_ref().to_glib_none().0)) }
4001 }
4002
4003 /// Determines whether `self` is a toplevel widget.
4004 ///
4005 /// Currently only [`Window`][crate::Window] and [`Invisible`][crate::Invisible] (and out-of-process
4006 /// `GtkPlugs`) are toplevel widgets. Toplevel widgets have no parent
4007 /// widget.
4008 ///
4009 /// # Returns
4010 ///
4011 /// [`true`] if `self` is a toplevel, [`false`] otherwise
4012 #[doc(alias = "gtk_widget_is_toplevel")]
4013 fn is_toplevel(&self) -> bool {
4014 unsafe { from_glib(ffi::gtk_widget_is_toplevel(self.as_ref().to_glib_none().0)) }
4015 }
4016
4017 /// Determines whether the widget and all its parents are marked as
4018 /// visible.
4019 ///
4020 /// This function does not check if the widget is obscured in any way.
4021 ///
4022 /// See also [`get_visible()`][Self::get_visible()] and [`set_visible()`][Self::set_visible()]
4023 ///
4024 /// # Returns
4025 ///
4026 /// [`true`] if the widget and all its parents are visible
4027 #[doc(alias = "gtk_widget_is_visible")]
4028 fn is_visible(&self) -> bool {
4029 unsafe { from_glib(ffi::gtk_widget_is_visible(self.as_ref().to_glib_none().0)) }
4030 }
4031
4032 /// This function should be called whenever keyboard navigation within
4033 /// a single widget hits a boundary. The function emits the
4034 /// [`keynav-failed`][struct@crate::Widget#keynav-failed] signal on the widget and its return
4035 /// value should be interpreted in a way similar to the return value of
4036 /// [`child_focus()`][Self::child_focus()]:
4037 ///
4038 /// When [`true`] is returned, stay in the widget, the failed keyboard
4039 /// navigation is OK and/or there is nowhere we can/should move the
4040 /// focus to.
4041 ///
4042 /// When [`false`] is returned, the caller should continue with keyboard
4043 /// navigation outside the widget, e.g. by calling
4044 /// [`child_focus()`][Self::child_focus()] on the widget’s toplevel.
4045 ///
4046 /// The default ::keynav-failed handler returns [`false`] for
4047 /// [`DirectionType::TabForward`][crate::DirectionType::TabForward] and [`DirectionType::TabBackward`][crate::DirectionType::TabBackward]. For the other
4048 /// values of [`DirectionType`][crate::DirectionType] it returns [`true`].
4049 ///
4050 /// Whenever the default handler returns [`true`], it also calls
4051 /// [`error_bell()`][Self::error_bell()] to notify the user of the failed keyboard
4052 /// navigation.
4053 ///
4054 /// A use case for providing an own implementation of ::keynav-failed
4055 /// (either by connecting to it or by overriding it) would be a row of
4056 /// [`Entry`][crate::Entry] widgets where the user should be able to navigate the
4057 /// entire row with the cursor keys, as e.g. known from user interfaces
4058 /// that require entering license keys.
4059 /// ## `direction`
4060 /// direction of focus movement
4061 ///
4062 /// # Returns
4063 ///
4064 /// [`true`] if stopping keyboard navigation is fine, [`false`]
4065 /// if the emitting widget should try to handle the keyboard
4066 /// navigation attempt in its parent container(s).
4067 #[doc(alias = "gtk_widget_keynav_failed")]
4068 fn keynav_failed(&self, direction: DirectionType) -> bool {
4069 unsafe {
4070 from_glib(ffi::gtk_widget_keynav_failed(
4071 self.as_ref().to_glib_none().0,
4072 direction.into_glib(),
4073 ))
4074 }
4075 }
4076
4077 /// Lists the closures used by `self` for accelerator group connections
4078 /// with [`AccelGroupExtManual::connect_accel_group_by_path()`][crate::prelude::AccelGroupExtManual::connect_accel_group_by_path()] or [`AccelGroupExtManual::connect_accel_group()`][crate::prelude::AccelGroupExtManual::connect_accel_group()].
4079 /// The closures can be used to monitor accelerator changes on `self`,
4080 /// by connecting to the [`AccelGroup`][crate::AccelGroup] signal of the
4081 /// [`AccelGroup`][crate::AccelGroup] of a closure which can be found out with
4082 /// [`AccelGroup::from_accel_closure()`][crate::AccelGroup::from_accel_closure()].
4083 ///
4084 /// # Returns
4085 ///
4086 ///
4087 /// a newly allocated `GList` of closures
4088 #[doc(alias = "gtk_widget_list_accel_closures")]
4089 fn list_accel_closures(&self) -> Vec<glib::Closure> {
4090 unsafe {
4091 FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_accel_closures(
4092 self.as_ref().to_glib_none().0,
4093 ))
4094 }
4095 }
4096
4097 /// Retrieves a [`None`]-terminated array of strings containing the prefixes of
4098 /// [`gio::ActionGroup`][crate::gio::ActionGroup]'s available to `self`.
4099 ///
4100 /// # Returns
4101 ///
4102 /// a [`None`]-terminated array of strings.
4103 #[doc(alias = "gtk_widget_list_action_prefixes")]
4104 fn list_action_prefixes(&self) -> Vec<glib::GString> {
4105 unsafe {
4106 FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_action_prefixes(
4107 self.as_ref().to_glib_none().0,
4108 ))
4109 }
4110 }
4111
4112 /// Returns a newly allocated list of the widgets, normally labels, for
4113 /// which this widget is the target of a mnemonic (see for example,
4114 /// [`LabelExt::set_mnemonic_widget()`][crate::prelude::LabelExt::set_mnemonic_widget()]).
4115 ///
4116 /// The widgets in the list are not individually referenced. If you
4117 /// want to iterate through the list and perform actions involving
4118 /// callbacks that might destroy the widgets, you
4119 /// must call `g_list_foreach (result,
4120 /// (GFunc)g_object_ref, NULL)` first, and then unref all the
4121 /// widgets afterwards.
4122 ///
4123 /// # Returns
4124 ///
4125 /// the list of
4126 /// mnemonic labels; free this list
4127 /// with `g_list_free()` when you are done with it.
4128 #[doc(alias = "gtk_widget_list_mnemonic_labels")]
4129 fn list_mnemonic_labels(&self) -> Vec<Widget> {
4130 unsafe {
4131 FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_mnemonic_labels(
4132 self.as_ref().to_glib_none().0,
4133 ))
4134 }
4135 }
4136
4137 /// This function is only for use in widget implementations. Causes
4138 /// a widget to be mapped if it isn’t already.
4139 #[doc(alias = "gtk_widget_map")]
4140 fn map(&self) {
4141 unsafe {
4142 ffi::gtk_widget_map(self.as_ref().to_glib_none().0);
4143 }
4144 }
4145
4146 /// Emits the [`mnemonic-activate`][struct@crate::Widget#mnemonic-activate] signal.
4147 /// ## `group_cycling`
4148 /// [`true`] if there are other widgets with the same mnemonic
4149 ///
4150 /// # Returns
4151 ///
4152 /// [`true`] if the signal has been handled
4153 #[doc(alias = "gtk_widget_mnemonic_activate")]
4154 fn mnemonic_activate(&self, group_cycling: bool) -> bool {
4155 unsafe {
4156 from_glib(ffi::gtk_widget_mnemonic_activate(
4157 self.as_ref().to_glib_none().0,
4158 group_cycling.into_glib(),
4159 ))
4160 }
4161 }
4162
4163 /// This function is only for use in widget implementations.
4164 ///
4165 /// Flags the widget for a rerun of the GtkWidgetClass::size_allocate
4166 /// function. Use this function instead of [`queue_resize()`][Self::queue_resize()]
4167 /// when the `self`'s size request didn't change but it wants to
4168 /// reposition its contents.
4169 ///
4170 /// An example user of this function is [`set_halign()`][Self::set_halign()].
4171 #[doc(alias = "gtk_widget_queue_allocate")]
4172 fn queue_allocate(&self) {
4173 unsafe {
4174 ffi::gtk_widget_queue_allocate(self.as_ref().to_glib_none().0);
4175 }
4176 }
4177
4178 /// Mark `self` as needing to recompute its expand flags. Call
4179 /// this function when setting legacy expand child properties
4180 /// on the child of a container.
4181 ///
4182 /// See [`compute_expand()`][Self::compute_expand()].
4183 #[doc(alias = "gtk_widget_queue_compute_expand")]
4184 fn queue_compute_expand(&self) {
4185 unsafe {
4186 ffi::gtk_widget_queue_compute_expand(self.as_ref().to_glib_none().0);
4187 }
4188 }
4189
4190 /// Equivalent to calling [`queue_draw_area()`][Self::queue_draw_area()] for the
4191 /// entire area of a widget.
4192 #[doc(alias = "gtk_widget_queue_draw")]
4193 fn queue_draw(&self) {
4194 unsafe {
4195 ffi::gtk_widget_queue_draw(self.as_ref().to_glib_none().0);
4196 }
4197 }
4198
4199 /// Convenience function that calls [`queue_draw_region()`][Self::queue_draw_region()] on
4200 /// the region created from the given coordinates.
4201 ///
4202 /// The region here is specified in widget coordinates.
4203 /// Widget coordinates are a bit odd; for historical reasons, they are
4204 /// defined as `self`->window coordinates for widgets that return [`true`] for
4205 /// [`has_window()`][Self::has_window()], and are relative to `self`->allocation.x,
4206 /// `self`->allocation.y otherwise.
4207 ///
4208 /// `width` or `height` may be 0, in this case this function does
4209 /// nothing. Negative values for `width` and `height` are not allowed.
4210 /// ## `x`
4211 /// x coordinate of upper-left corner of rectangle to redraw
4212 /// ## `y`
4213 /// y coordinate of upper-left corner of rectangle to redraw
4214 /// ## `width`
4215 /// width of region to draw
4216 /// ## `height`
4217 /// height of region to draw
4218 #[doc(alias = "gtk_widget_queue_draw_area")]
4219 fn queue_draw_area(&self, x: i32, y: i32, width: i32, height: i32) {
4220 unsafe {
4221 ffi::gtk_widget_queue_draw_area(self.as_ref().to_glib_none().0, x, y, width, height);
4222 }
4223 }
4224
4225 /// Invalidates the area of `self` defined by `region` by calling
4226 /// [`Window::invalidate_region()`][crate::gdk::Window::invalidate_region()] on the widget’s window and all its
4227 /// child windows. Once the main loop becomes idle (after the current
4228 /// batch of events has been processed, roughly), the window will
4229 /// receive expose events for the union of all regions that have been
4230 /// invalidated.
4231 ///
4232 /// Normally you would only use this function in widget
4233 /// implementations. You might also use it to schedule a redraw of a
4234 /// [`DrawingArea`][crate::DrawingArea] or some portion thereof.
4235 /// ## `region`
4236 /// region to draw
4237 #[doc(alias = "gtk_widget_queue_draw_region")]
4238 fn queue_draw_region(&self, region: &cairo::Region) {
4239 unsafe {
4240 ffi::gtk_widget_queue_draw_region(
4241 self.as_ref().to_glib_none().0,
4242 region.to_glib_none().0,
4243 );
4244 }
4245 }
4246
4247 /// This function is only for use in widget implementations.
4248 /// Flags a widget to have its size renegotiated; should
4249 /// be called when a widget for some reason has a new size request.
4250 /// For example, when you change the text in a [`Label`][crate::Label], [`Label`][crate::Label]
4251 /// queues a resize to ensure there’s enough space for the new text.
4252 ///
4253 /// Note that you cannot call [`queue_resize()`][Self::queue_resize()] on a widget
4254 /// from inside its implementation of the GtkWidgetClass::size_allocate
4255 /// virtual method. Calls to [`queue_resize()`][Self::queue_resize()] from inside
4256 /// GtkWidgetClass::size_allocate will be silently ignored.
4257 #[doc(alias = "gtk_widget_queue_resize")]
4258 fn queue_resize(&self) {
4259 unsafe {
4260 ffi::gtk_widget_queue_resize(self.as_ref().to_glib_none().0);
4261 }
4262 }
4263
4264 /// This function works like [`queue_resize()`][Self::queue_resize()],
4265 /// except that the widget is not invalidated.
4266 #[doc(alias = "gtk_widget_queue_resize_no_redraw")]
4267 fn queue_resize_no_redraw(&self) {
4268 unsafe {
4269 ffi::gtk_widget_queue_resize_no_redraw(self.as_ref().to_glib_none().0);
4270 }
4271 }
4272
4273 /// Creates the GDK (windowing system) resources associated with a
4274 /// widget. For example, `self`->window will be created when a widget
4275 /// is realized. Normally realization happens implicitly; if you show
4276 /// a widget and all its parent containers, then the widget will be
4277 /// realized and mapped automatically.
4278 ///
4279 /// Realizing a widget requires all
4280 /// the widget’s parent widgets to be realized; calling
4281 /// [`realize()`][Self::realize()] realizes the widget’s parents in addition to
4282 /// `self` itself. If a widget is not yet inside a toplevel window
4283 /// when you realize it, bad things will happen.
4284 ///
4285 /// This function is primarily used in widget implementations, and
4286 /// isn’t very useful otherwise. Many times when you think you might
4287 /// need it, a better approach is to connect to a signal that will be
4288 /// called after the widget is realized automatically, such as
4289 /// [`draw`][struct@crate::Widget#draw]. Or simply g_signal_connect () to the
4290 /// [`realize`][struct@crate::Widget#realize] signal.
4291 #[doc(alias = "gtk_widget_realize")]
4292 fn realize(&self) {
4293 unsafe {
4294 ffi::gtk_widget_realize(self.as_ref().to_glib_none().0);
4295 }
4296 }
4297
4298 /// Registers a [`gdk::Window`][crate::gdk::Window] with the widget and sets it up so that
4299 /// the widget receives events for it. Call [`unregister_window()`][Self::unregister_window()]
4300 /// when destroying the window.
4301 ///
4302 /// Before 3.8 you needed to call [`Window::set_user_data()`][crate::gdk::Window::set_user_data()] directly to set
4303 /// this up. This is now deprecated and you should use [`register_window()`][Self::register_window()]
4304 /// instead. Old code will keep working as is, although some new features like
4305 /// transparency might not work perfectly.
4306 /// ## `window`
4307 /// a [`gdk::Window`][crate::gdk::Window]
4308 #[doc(alias = "gtk_widget_register_window")]
4309 fn register_window(&self, window: &gdk::Window) {
4310 unsafe {
4311 ffi::gtk_widget_register_window(
4312 self.as_ref().to_glib_none().0,
4313 window.to_glib_none().0,
4314 );
4315 }
4316 }
4317
4318 /// Removes an accelerator from `self`, previously installed with
4319 /// [`add_accelerator()`][Self::add_accelerator()].
4320 /// ## `accel_group`
4321 /// accel group for this widget
4322 /// ## `accel_key`
4323 /// GDK keyval of the accelerator
4324 /// ## `accel_mods`
4325 /// modifier key combination of the accelerator
4326 ///
4327 /// # Returns
4328 ///
4329 /// whether an accelerator was installed and could be removed
4330 #[doc(alias = "gtk_widget_remove_accelerator")]
4331 fn remove_accelerator(
4332 &self,
4333 accel_group: &impl IsA<AccelGroup>,
4334 accel_key: u32,
4335 accel_mods: gdk::ModifierType,
4336 ) -> bool {
4337 unsafe {
4338 from_glib(ffi::gtk_widget_remove_accelerator(
4339 self.as_ref().to_glib_none().0,
4340 accel_group.as_ref().to_glib_none().0,
4341 accel_key,
4342 accel_mods.into_glib(),
4343 ))
4344 }
4345 }
4346
4347 /// Removes a widget from the list of mnemonic labels for
4348 /// this widget. (See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()]). The widget
4349 /// must have previously been added to the list with
4350 /// [`add_mnemonic_label()`][Self::add_mnemonic_label()].
4351 /// ## `label`
4352 /// a [`Widget`][crate::Widget] that was previously set as a mnemonic label for
4353 /// `self` with [`add_mnemonic_label()`][Self::add_mnemonic_label()].
4354 #[doc(alias = "gtk_widget_remove_mnemonic_label")]
4355 fn remove_mnemonic_label(&self, label: &impl IsA<Widget>) {
4356 unsafe {
4357 ffi::gtk_widget_remove_mnemonic_label(
4358 self.as_ref().to_glib_none().0,
4359 label.as_ref().to_glib_none().0,
4360 );
4361 }
4362 }
4363
4364 /// Updates the style context of `self` and all descendants
4365 /// by updating its widget path. `GtkContainers` may want
4366 /// to use this on a child when reordering it in a way that a different
4367 /// style might apply to it. See also [`ContainerExt::path_for_child()`][crate::prelude::ContainerExt::path_for_child()].
4368 #[doc(alias = "gtk_widget_reset_style")]
4369 fn reset_style(&self) {
4370 unsafe {
4371 ffi::gtk_widget_reset_style(self.as_ref().to_glib_none().0);
4372 }
4373 }
4374
4375 /// Sends the focus change `event` to `self`
4376 ///
4377 /// This function is not meant to be used by applications. The only time it
4378 /// should be used is when it is necessary for a [`Widget`][crate::Widget] to assign focus
4379 /// to a widget that is semantically owned by the first widget even though
4380 /// it’s not a direct child - for instance, a search entry in a floating
4381 /// window similar to the quick search in [`TreeView`][crate::TreeView].
4382 ///
4383 /// An example of its usage is:
4384 ///
4385 ///
4386 ///
4387 /// **⚠️ The following code is in C ⚠️**
4388 ///
4389 /// ```C
4390 /// GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
4391 ///
4392 /// fevent->focus_change.type = GDK_FOCUS_CHANGE;
4393 /// fevent->focus_change.in = TRUE;
4394 /// fevent->focus_change.window = _gtk_widget_get_window (widget);
4395 /// if (fevent->focus_change.window != NULL)
4396 /// g_object_ref (fevent->focus_change.window);
4397 ///
4398 /// gtk_widget_send_focus_change (widget, fevent);
4399 ///
4400 /// gdk_event_free (event);
4401 /// ```
4402 /// ## `event`
4403 /// a `GdkEvent` of type GDK_FOCUS_CHANGE
4404 ///
4405 /// # Returns
4406 ///
4407 /// the return value from the event signal emission: [`true`]
4408 /// if the event was handled, and [`false`] otherwise
4409 #[doc(alias = "gtk_widget_send_focus_change")]
4410 fn send_focus_change(&self, event: &gdk::Event) -> bool {
4411 unsafe {
4412 from_glib(ffi::gtk_widget_send_focus_change(
4413 self.as_ref().to_glib_none().0,
4414 mut_override(event.to_glib_none().0),
4415 ))
4416 }
4417 }
4418
4419 /// Given an accelerator group, `accel_group`, and an accelerator path,
4420 /// `accel_path`, sets up an accelerator in `accel_group` so whenever the
4421 /// key binding that is defined for `accel_path` is pressed, `self`
4422 /// will be activated. This removes any accelerators (for any
4423 /// accelerator group) installed by previous calls to
4424 /// [`set_accel_path()`][Self::set_accel_path()]. Associating accelerators with
4425 /// paths allows them to be modified by the user and the modifications
4426 /// to be saved for future use. (See `gtk_accel_map_save()`.)
4427 ///
4428 /// This function is a low level function that would most likely
4429 /// be used by a menu creation system like `GtkUIManager`. If you
4430 /// use `GtkUIManager`, setting up accelerator paths will be done
4431 /// automatically.
4432 ///
4433 /// Even when you you aren’t using `GtkUIManager`, if you only want to
4434 /// set up accelerators on menu items [`GtkMenuItemExt::set_accel_path()`][crate::prelude::GtkMenuItemExt::set_accel_path()]
4435 /// provides a somewhat more convenient interface.
4436 ///
4437 /// Note that `accel_path` string will be stored in a `GQuark`. Therefore, if you
4438 /// pass a static string, you can save some memory by interning it first with
4439 /// `g_intern_static_string()`.
4440 /// ## `accel_path`
4441 /// path used to look up the accelerator
4442 /// ## `accel_group`
4443 /// a [`AccelGroup`][crate::AccelGroup].
4444 #[doc(alias = "gtk_widget_set_accel_path")]
4445 fn set_accel_path(&self, accel_path: Option<&str>, accel_group: Option<&impl IsA<AccelGroup>>) {
4446 unsafe {
4447 ffi::gtk_widget_set_accel_path(
4448 self.as_ref().to_glib_none().0,
4449 accel_path.to_glib_none().0,
4450 accel_group.map(|p| p.as_ref()).to_glib_none().0,
4451 );
4452 }
4453 }
4454
4455 /// Sets the widget’s allocation. This should not be used
4456 /// directly, but from within a widget’s size_allocate method.
4457 ///
4458 /// The allocation set should be the “adjusted” or actual
4459 /// allocation. If you’re implementing a [`Container`][crate::Container], you want to use
4460 /// [`size_allocate()`][Self::size_allocate()] instead of [`set_allocation()`][Self::set_allocation()].
4461 /// The GtkWidgetClass::adjust_size_allocation virtual method adjusts the
4462 /// allocation inside [`size_allocate()`][Self::size_allocate()] to create an adjusted
4463 /// allocation.
4464 /// ## `allocation`
4465 /// a pointer to a `GtkAllocation` to copy from
4466 #[doc(alias = "gtk_widget_set_allocation")]
4467 fn set_allocation(&self, allocation: &Allocation) {
4468 unsafe {
4469 ffi::gtk_widget_set_allocation(
4470 self.as_ref().to_glib_none().0,
4471 allocation.to_glib_none().0,
4472 );
4473 }
4474 }
4475
4476 /// Sets whether the application intends to draw on the widget in
4477 /// an [`draw`][struct@crate::Widget#draw] handler.
4478 ///
4479 /// This is a hint to the widget and does not affect the behavior of
4480 /// the GTK+ core; many widgets ignore this flag entirely. For widgets
4481 /// that do pay attention to the flag, such as [`EventBox`][crate::EventBox] and [`Window`][crate::Window],
4482 /// the effect is to suppress default themed drawing of the widget's
4483 /// background. (Children of the widget will still be drawn.) The application
4484 /// is then entirely responsible for drawing the widget background.
4485 ///
4486 /// Note that the background is still drawn when the widget is mapped.
4487 /// ## `app_paintable`
4488 /// [`true`] if the application will paint on the widget
4489 #[doc(alias = "gtk_widget_set_app_paintable")]
4490 fn set_app_paintable(&self, app_paintable: bool) {
4491 unsafe {
4492 ffi::gtk_widget_set_app_paintable(
4493 self.as_ref().to_glib_none().0,
4494 app_paintable.into_glib(),
4495 );
4496 }
4497 }
4498
4499 /// Specifies whether `self` can be a default widget. See
4500 /// [`grab_default()`][Self::grab_default()] for details about the meaning of
4501 /// “default”.
4502 /// ## `can_default`
4503 /// whether or not `self` can be a default widget.
4504 #[doc(alias = "gtk_widget_set_can_default")]
4505 fn set_can_default(&self, can_default: bool) {
4506 unsafe {
4507 ffi::gtk_widget_set_can_default(
4508 self.as_ref().to_glib_none().0,
4509 can_default.into_glib(),
4510 );
4511 }
4512 }
4513
4514 /// Specifies whether `self` can own the input focus. See
4515 /// [`grab_focus()`][Self::grab_focus()] for actually setting the input focus on a
4516 /// widget.
4517 /// ## `can_focus`
4518 /// whether or not `self` can own the input focus.
4519 #[doc(alias = "gtk_widget_set_can_focus")]
4520 fn set_can_focus(&self, can_focus: bool) {
4521 unsafe {
4522 ffi::gtk_widget_set_can_focus(self.as_ref().to_glib_none().0, can_focus.into_glib());
4523 }
4524 }
4525
4526 /// Sets whether `self` should be mapped along with its when its parent
4527 /// is mapped and `self` has been shown with [`show()`][Self::show()].
4528 ///
4529 /// The child visibility can be set for widget before it is added to
4530 /// a container with [`set_parent()`][Self::set_parent()], to avoid mapping
4531 /// children unnecessary before immediately unmapping them. However
4532 /// it will be reset to its default state of [`true`] when the widget
4533 /// is removed from a container.
4534 ///
4535 /// Note that changing the child visibility of a widget does not
4536 /// queue a resize on the widget. Most of the time, the size of
4537 /// a widget is computed from all visible children, whether or
4538 /// not they are mapped. If this is not the case, the container
4539 /// can queue a resize itself.
4540 ///
4541 /// This function is only useful for container implementations and
4542 /// never should be called by an application.
4543 /// ## `is_visible`
4544 /// if [`true`], `self` should be mapped along with its parent.
4545 #[doc(alias = "gtk_widget_set_child_visible")]
4546 fn set_child_visible(&self, is_visible: bool) {
4547 unsafe {
4548 ffi::gtk_widget_set_child_visible(
4549 self.as_ref().to_glib_none().0,
4550 is_visible.into_glib(),
4551 );
4552 }
4553 }
4554
4555 /// Sets the widget’s clip. This must not be used directly,
4556 /// but from within a widget’s size_allocate method.
4557 /// It must be called after [`set_allocation()`][Self::set_allocation()] (or after chaining up
4558 /// to the parent class), because that function resets the clip.
4559 ///
4560 /// The clip set should be the area that `self` draws on. If `self` is a
4561 /// [`Container`][crate::Container], the area must contain all children's clips.
4562 ///
4563 /// If this function is not called by `self` during a ::size-allocate handler,
4564 /// the clip will be set to `self`'s allocation.
4565 /// ## `clip`
4566 /// a pointer to a `GtkAllocation` to copy from
4567 #[doc(alias = "gtk_widget_set_clip")]
4568 fn set_clip(&self, clip: &Allocation) {
4569 unsafe {
4570 ffi::gtk_widget_set_clip(self.as_ref().to_glib_none().0, clip.to_glib_none().0);
4571 }
4572 }
4573
4574 /// Enables or disables a [`gdk::Device`][crate::gdk::Device] to interact with `self`
4575 /// and all its children.
4576 ///
4577 /// It does so by descending through the [`gdk::Window`][crate::gdk::Window] hierarchy
4578 /// and enabling the same mask that is has for core events
4579 /// (i.e. the one that [`Window::events()`][crate::gdk::Window::events()] returns).
4580 /// ## `device`
4581 /// a [`gdk::Device`][crate::gdk::Device]
4582 /// ## `enabled`
4583 /// whether to enable the device
4584 #[doc(alias = "gtk_widget_set_device_enabled")]
4585 fn set_device_enabled(&self, device: &gdk::Device, enabled: bool) {
4586 unsafe {
4587 ffi::gtk_widget_set_device_enabled(
4588 self.as_ref().to_glib_none().0,
4589 device.to_glib_none().0,
4590 enabled.into_glib(),
4591 );
4592 }
4593 }
4594
4595 /// Sets the device event mask (see [`gdk::EventMask`][crate::gdk::EventMask]) for a widget. The event
4596 /// mask determines which events a widget will receive from `device`. Keep
4597 /// in mind that different widgets have different default event masks, and by
4598 /// changing the event mask you may disrupt a widget’s functionality,
4599 /// so be careful. This function must be called while a widget is
4600 /// unrealized. Consider [`add_device_events()`][Self::add_device_events()] for widgets that are
4601 /// already realized, or if you want to preserve the existing event
4602 /// mask. This function can’t be used with windowless widgets (which return
4603 /// [`false`] from [`has_window()`][Self::has_window()]);
4604 /// to get events on those widgets, place them inside a [`EventBox`][crate::EventBox]
4605 /// and receive events on the event box.
4606 /// ## `device`
4607 /// a [`gdk::Device`][crate::gdk::Device]
4608 /// ## `events`
4609 /// event mask
4610 #[doc(alias = "gtk_widget_set_device_events")]
4611 fn set_device_events(&self, device: &gdk::Device, events: gdk::EventMask) {
4612 unsafe {
4613 ffi::gtk_widget_set_device_events(
4614 self.as_ref().to_glib_none().0,
4615 device.to_glib_none().0,
4616 events.into_glib(),
4617 );
4618 }
4619 }
4620
4621 /// Sets the reading direction on a particular widget. This direction
4622 /// controls the primary direction for widgets containing text,
4623 /// and also the direction in which the children of a container are
4624 /// packed. The ability to set the direction is present in order
4625 /// so that correct localization into languages with right-to-left
4626 /// reading directions can be done. Generally, applications will
4627 /// let the default reading direction present, except for containers
4628 /// where the containers are arranged in an order that is explicitly
4629 /// visual rather than logical (such as buttons for text justification).
4630 ///
4631 /// If the direction is set to [`TextDirection::None`][crate::TextDirection::None], then the value
4632 /// set by [`Widget::set_default_direction()`][crate::Widget::set_default_direction()] will be used.
4633 /// ## `dir`
4634 /// the new direction
4635 #[doc(alias = "gtk_widget_set_direction")]
4636 fn set_direction(&self, dir: TextDirection) {
4637 unsafe {
4638 ffi::gtk_widget_set_direction(self.as_ref().to_glib_none().0, dir.into_glib());
4639 }
4640 }
4641
4642 /// Sets whether the widget should grab focus when it is clicked with the mouse.
4643 /// Making mouse clicks not grab focus is useful in places like toolbars where
4644 /// you don’t want the keyboard focus removed from the main area of the
4645 /// application.
4646 /// ## `focus_on_click`
4647 /// whether the widget should grab focus when clicked with the mouse
4648 #[doc(alias = "gtk_widget_set_focus_on_click")]
4649 fn set_focus_on_click(&self, focus_on_click: bool) {
4650 unsafe {
4651 ffi::gtk_widget_set_focus_on_click(
4652 self.as_ref().to_glib_none().0,
4653 focus_on_click.into_glib(),
4654 );
4655 }
4656 }
4657
4658 /// Sets the font map to use for Pango rendering. When not set, the widget
4659 /// will inherit the font map from its parent.
4660 /// ## `font_map`
4661 /// a [`pango::FontMap`][crate::pango::FontMap], or [`None`] to unset any previously
4662 /// set font map
4663 #[doc(alias = "gtk_widget_set_font_map")]
4664 fn set_font_map(&self, font_map: Option<&impl IsA<pango::FontMap>>) {
4665 unsafe {
4666 ffi::gtk_widget_set_font_map(
4667 self.as_ref().to_glib_none().0,
4668 font_map.map(|p| p.as_ref()).to_glib_none().0,
4669 );
4670 }
4671 }
4672
4673 /// Sets the [`cairo::FontOptions`][crate::cairo::FontOptions] used for Pango rendering in this widget.
4674 /// When not set, the default font options for the [`gdk::Screen`][crate::gdk::Screen] will be used.
4675 /// ## `options`
4676 /// a [`cairo::FontOptions`][crate::cairo::FontOptions], or [`None`] to unset any
4677 /// previously set default font options.
4678 #[doc(alias = "gtk_widget_set_font_options")]
4679 fn set_font_options(&self, options: Option<&cairo::FontOptions>) {
4680 unsafe {
4681 ffi::gtk_widget_set_font_options(
4682 self.as_ref().to_glib_none().0,
4683 options.to_glib_none().0,
4684 );
4685 }
4686 }
4687
4688 /// Sets the horizontal alignment of `self`.
4689 /// See the [`halign`][struct@crate::Widget#halign] property.
4690 /// ## `align`
4691 /// the horizontal alignment
4692 #[doc(alias = "gtk_widget_set_halign")]
4693 fn set_halign(&self, align: Align) {
4694 unsafe {
4695 ffi::gtk_widget_set_halign(self.as_ref().to_glib_none().0, align.into_glib());
4696 }
4697 }
4698
4699 /// Sets the has-tooltip property on `self` to `has_tooltip`. See
4700 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] for more information.
4701 /// ## `has_tooltip`
4702 /// whether or not `self` has a tooltip.
4703 #[doc(alias = "gtk_widget_set_has_tooltip")]
4704 fn set_has_tooltip(&self, has_tooltip: bool) {
4705 unsafe {
4706 ffi::gtk_widget_set_has_tooltip(
4707 self.as_ref().to_glib_none().0,
4708 has_tooltip.into_glib(),
4709 );
4710 }
4711 }
4712
4713 /// Specifies whether `self` has a [`gdk::Window`][crate::gdk::Window] of its own. Note that
4714 /// all realized widgets have a non-[`None`] “window” pointer
4715 /// ([`window()`][Self::window()] never returns a [`None`] window when a widget
4716 /// is realized), but for many of them it’s actually the [`gdk::Window`][crate::gdk::Window] of
4717 /// one of its parent widgets. Widgets that do not create a `window` for
4718 /// themselves in [`realize`][struct@crate::Widget#realize] must announce this by
4719 /// calling this function with `has_window` = [`false`].
4720 ///
4721 /// This function should only be called by widget implementations,
4722 /// and they should call it in their `init()` function.
4723 /// ## `has_window`
4724 /// whether or not `self` has a window.
4725 #[doc(alias = "gtk_widget_set_has_window")]
4726 fn set_has_window(&self, has_window: bool) {
4727 unsafe {
4728 ffi::gtk_widget_set_has_window(self.as_ref().to_glib_none().0, has_window.into_glib());
4729 }
4730 }
4731
4732 /// Sets whether the widget would like any available extra horizontal
4733 /// space. When a user resizes a [`Window`][crate::Window], widgets with expand=TRUE
4734 /// generally receive the extra space. For example, a list or
4735 /// scrollable area or document in your window would often be set to
4736 /// expand.
4737 ///
4738 /// Call this function to set the expand flag if you would like your
4739 /// widget to become larger horizontally when the window has extra
4740 /// room.
4741 ///
4742 /// By default, widgets automatically expand if any of their children
4743 /// want to expand. (To see if a widget will automatically expand given
4744 /// its current children and state, call [`compute_expand()`][Self::compute_expand()]. A
4745 /// container can decide how the expandability of children affects the
4746 /// expansion of the container by overriding the compute_expand virtual
4747 /// method on [`Widget`][crate::Widget].).
4748 ///
4749 /// Setting hexpand explicitly with this function will override the
4750 /// automatic expand behavior.
4751 ///
4752 /// This function forces the widget to expand or not to expand,
4753 /// regardless of children. The override occurs because
4754 /// [`set_hexpand()`][Self::set_hexpand()] sets the hexpand-set property (see
4755 /// [`set_hexpand_set()`][Self::set_hexpand_set()]) which causes the widget’s hexpand
4756 /// value to be used, rather than looking at children and widget state.
4757 /// ## `expand`
4758 /// whether to expand
4759 #[doc(alias = "gtk_widget_set_hexpand")]
4760 fn set_hexpand(&self, expand: bool) {
4761 unsafe {
4762 ffi::gtk_widget_set_hexpand(self.as_ref().to_glib_none().0, expand.into_glib());
4763 }
4764 }
4765
4766 /// Sets whether the hexpand flag (see [`hexpands()`][Self::hexpands()]) will
4767 /// be used.
4768 ///
4769 /// The hexpand-set property will be set automatically when you call
4770 /// [`set_hexpand()`][Self::set_hexpand()] to set hexpand, so the most likely
4771 /// reason to use this function would be to unset an explicit expand
4772 /// flag.
4773 ///
4774 /// If hexpand is set, then it overrides any computed
4775 /// expand value based on child widgets. If hexpand is not
4776 /// set, then the expand value depends on whether any
4777 /// children of the widget would like to expand.
4778 ///
4779 /// There are few reasons to use this function, but it’s here
4780 /// for completeness and consistency.
4781 /// ## `set`
4782 /// value for hexpand-set property
4783 #[doc(alias = "gtk_widget_set_hexpand_set")]
4784 fn set_hexpand_set(&self, set: bool) {
4785 unsafe {
4786 ffi::gtk_widget_set_hexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
4787 }
4788 }
4789
4790 /// Marks the widget as being mapped.
4791 ///
4792 /// This function should only ever be called in a derived widget's
4793 /// “map” or “unmap” implementation.
4794 /// ## `mapped`
4795 /// [`true`] to mark the widget as mapped
4796 #[doc(alias = "gtk_widget_set_mapped")]
4797 fn set_mapped(&self, mapped: bool) {
4798 unsafe {
4799 ffi::gtk_widget_set_mapped(self.as_ref().to_glib_none().0, mapped.into_glib());
4800 }
4801 }
4802
4803 /// Sets the bottom margin of `self`.
4804 /// See the [`margin-bottom`][struct@crate::Widget#margin-bottom] property.
4805 /// ## `margin`
4806 /// the bottom margin
4807 #[doc(alias = "gtk_widget_set_margin_bottom")]
4808 fn set_margin_bottom(&self, margin: i32) {
4809 unsafe {
4810 ffi::gtk_widget_set_margin_bottom(self.as_ref().to_glib_none().0, margin);
4811 }
4812 }
4813
4814 /// Sets the end margin of `self`.
4815 /// See the [`margin-end`][struct@crate::Widget#margin-end] property.
4816 /// ## `margin`
4817 /// the end margin
4818 #[doc(alias = "gtk_widget_set_margin_end")]
4819 fn set_margin_end(&self, margin: i32) {
4820 unsafe {
4821 ffi::gtk_widget_set_margin_end(self.as_ref().to_glib_none().0, margin);
4822 }
4823 }
4824
4825 /// Sets the start margin of `self`.
4826 /// See the [`margin-start`][struct@crate::Widget#margin-start] property.
4827 /// ## `margin`
4828 /// the start margin
4829 #[doc(alias = "gtk_widget_set_margin_start")]
4830 fn set_margin_start(&self, margin: i32) {
4831 unsafe {
4832 ffi::gtk_widget_set_margin_start(self.as_ref().to_glib_none().0, margin);
4833 }
4834 }
4835
4836 /// Sets the top margin of `self`.
4837 /// See the [`margin-top`][struct@crate::Widget#margin-top] property.
4838 /// ## `margin`
4839 /// the top margin
4840 #[doc(alias = "gtk_widget_set_margin_top")]
4841 fn set_margin_top(&self, margin: i32) {
4842 unsafe {
4843 ffi::gtk_widget_set_margin_top(self.as_ref().to_glib_none().0, margin);
4844 }
4845 }
4846
4847 /// Widgets can be named, which allows you to refer to them from a
4848 /// CSS file. You can apply a style to widgets with a particular name
4849 /// in the CSS file. See the documentation for the CSS syntax (on the
4850 /// same page as the docs for [`StyleContext`][crate::StyleContext]).
4851 ///
4852 /// Note that the CSS syntax has certain special characters to delimit
4853 /// and represent elements in a selector (period, #, >, *...), so using
4854 /// these will make your widget impossible to match by name. Any combination
4855 /// of alphanumeric symbols, dashes and underscores will suffice.
4856 /// ## `name`
4857 /// name for the widget
4858 #[doc(alias = "gtk_widget_set_name")]
4859 #[doc(alias = "set_name")]
4860 fn set_widget_name(&self, name: &str) {
4861 unsafe {
4862 ffi::gtk_widget_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
4863 }
4864 }
4865
4866 /// Sets the [`no-show-all`][struct@crate::Widget#no-show-all] property, which determines whether
4867 /// calls to [`show_all()`][Self::show_all()] will affect this widget.
4868 ///
4869 /// This is mostly for use in constructing widget hierarchies with externally
4870 /// controlled visibility, see `GtkUIManager`.
4871 /// ## `no_show_all`
4872 /// the new value for the “no-show-all” property
4873 #[doc(alias = "gtk_widget_set_no_show_all")]
4874 fn set_no_show_all(&self, no_show_all: bool) {
4875 unsafe {
4876 ffi::gtk_widget_set_no_show_all(
4877 self.as_ref().to_glib_none().0,
4878 no_show_all.into_glib(),
4879 );
4880 }
4881 }
4882
4883 /// Request the `self` to be rendered partially transparent,
4884 /// with opacity 0 being fully transparent and 1 fully opaque. (Opacity values
4885 /// are clamped to the [0,1] range.).
4886 /// This works on both toplevel widget, and child widgets, although there
4887 /// are some limitations:
4888 ///
4889 /// For toplevel widgets this depends on the capabilities of the windowing
4890 /// system. On X11 this has any effect only on X screens with a compositing manager
4891 /// running. See `gtk_widget_is_composited()`. On Windows it should work
4892 /// always, although setting a window’s opacity after the window has been
4893 /// shown causes it to flicker once on Windows.
4894 ///
4895 /// For child widgets it doesn’t work if any affected widget has a native window, or
4896 /// disables double buffering.
4897 /// ## `opacity`
4898 /// desired opacity, between 0 and 1
4899 #[doc(alias = "gtk_widget_set_opacity")]
4900 fn set_opacity(&self, opacity: f64) {
4901 unsafe {
4902 ffi::gtk_widget_set_opacity(self.as_ref().to_glib_none().0, opacity);
4903 }
4904 }
4905
4906 /// This function is useful only when implementing subclasses of
4907 /// [`Container`][crate::Container].
4908 /// Sets the container as the parent of `self`, and takes care of
4909 /// some details such as updating the state and style of the child
4910 /// to reflect its new location. The opposite function is
4911 /// [`unparent()`][Self::unparent()].
4912 /// ## `parent`
4913 /// parent container
4914 #[doc(alias = "gtk_widget_set_parent")]
4915 fn set_parent(&self, parent: &impl IsA<Widget>) {
4916 unsafe {
4917 ffi::gtk_widget_set_parent(
4918 self.as_ref().to_glib_none().0,
4919 parent.as_ref().to_glib_none().0,
4920 );
4921 }
4922 }
4923
4924 /// Sets a non default parent window for `self`.
4925 ///
4926 /// For [`Window`][crate::Window] classes, setting a `parent_window` effects whether
4927 /// the window is a toplevel window or can be embedded into other
4928 /// widgets.
4929 ///
4930 /// For [`Window`][crate::Window] classes, this needs to be called before the
4931 /// window is realized.
4932 /// ## `parent_window`
4933 /// the new parent window.
4934 #[doc(alias = "gtk_widget_set_parent_window")]
4935 fn set_parent_window(&self, parent_window: &gdk::Window) {
4936 unsafe {
4937 ffi::gtk_widget_set_parent_window(
4938 self.as_ref().to_glib_none().0,
4939 parent_window.to_glib_none().0,
4940 );
4941 }
4942 }
4943
4944 /// Marks the widget as being realized. This function must only be
4945 /// called after all `GdkWindows` for the `self` have been created
4946 /// and registered.
4947 ///
4948 /// This function should only ever be called in a derived widget's
4949 /// “realize” or “unrealize” implementation.
4950 /// ## `realized`
4951 /// [`true`] to mark the widget as realized
4952 #[doc(alias = "gtk_widget_set_realized")]
4953 fn set_realized(&self, realized: bool) {
4954 unsafe {
4955 ffi::gtk_widget_set_realized(self.as_ref().to_glib_none().0, realized.into_glib());
4956 }
4957 }
4958
4959 /// Specifies whether `self` will be treated as the default widget
4960 /// within its toplevel when it has the focus, even if another widget
4961 /// is the default.
4962 ///
4963 /// See [`grab_default()`][Self::grab_default()] for details about the meaning of
4964 /// “default”.
4965 /// ## `receives_default`
4966 /// whether or not `self` can be a default widget.
4967 #[doc(alias = "gtk_widget_set_receives_default")]
4968 fn set_receives_default(&self, receives_default: bool) {
4969 unsafe {
4970 ffi::gtk_widget_set_receives_default(
4971 self.as_ref().to_glib_none().0,
4972 receives_default.into_glib(),
4973 );
4974 }
4975 }
4976
4977 /// Sets whether the entire widget is queued for drawing when its size
4978 /// allocation changes. By default, this setting is [`true`] and
4979 /// the entire widget is redrawn on every size change. If your widget
4980 /// leaves the upper left unchanged when made bigger, turning this
4981 /// setting off will improve performance.
4982 ///
4983 /// Note that for widgets where [`has_window()`][Self::has_window()] is [`false`]
4984 /// setting this flag to [`false`] turns off all allocation on resizing:
4985 /// the widget will not even redraw if its position changes; this is to
4986 /// allow containers that don’t draw anything to avoid excess
4987 /// invalidations. If you set this flag on a widget with no window that
4988 /// does draw on `self`->window, you are
4989 /// responsible for invalidating both the old and new allocation of the
4990 /// widget when the widget is moved and responsible for invalidating
4991 /// regions newly when the widget increases size.
4992 /// ## `redraw_on_allocate`
4993 /// if [`true`], the entire widget will be redrawn
4994 /// when it is allocated to a new size. Otherwise, only the
4995 /// new portion of the widget will be redrawn.
4996 #[doc(alias = "gtk_widget_set_redraw_on_allocate")]
4997 fn set_redraw_on_allocate(&self, redraw_on_allocate: bool) {
4998 unsafe {
4999 ffi::gtk_widget_set_redraw_on_allocate(
5000 self.as_ref().to_glib_none().0,
5001 redraw_on_allocate.into_glib(),
5002 );
5003 }
5004 }
5005
5006 /// Sets the sensitivity of a widget. A widget is sensitive if the user
5007 /// can interact with it. Insensitive widgets are “grayed out” and the
5008 /// user can’t interact with them. Insensitive widgets are known as
5009 /// “inactive”, “disabled”, or “ghosted” in some other toolkits.
5010 /// ## `sensitive`
5011 /// [`true`] to make the widget sensitive
5012 #[doc(alias = "gtk_widget_set_sensitive")]
5013 fn set_sensitive(&self, sensitive: bool) {
5014 unsafe {
5015 ffi::gtk_widget_set_sensitive(self.as_ref().to_glib_none().0, sensitive.into_glib());
5016 }
5017 }
5018
5019 /// Sets the minimum size of a widget; that is, the widget’s size
5020 /// request will be at least `width` by `height`. You can use this
5021 /// function to force a widget to be larger than it normally would be.
5022 ///
5023 /// In most cases, [`GtkWindowExt::set_default_size()`][crate::prelude::GtkWindowExt::set_default_size()] is a better choice for
5024 /// toplevel windows than this function; setting the default size will
5025 /// still allow users to shrink the window. Setting the size request
5026 /// will force them to leave the window at least as large as the size
5027 /// request. When dealing with window sizes,
5028 /// [`GtkWindowExt::set_geometry_hints()`][crate::prelude::GtkWindowExt::set_geometry_hints()] can be a useful function as well.
5029 ///
5030 /// Note the inherent danger of setting any fixed size - themes,
5031 /// translations into other languages, different fonts, and user action
5032 /// can all change the appropriate size for a given widget. So, it's
5033 /// basically impossible to hardcode a size that will always be
5034 /// correct.
5035 ///
5036 /// The size request of a widget is the smallest size a widget can
5037 /// accept while still functioning well and drawing itself correctly.
5038 /// However in some strange cases a widget may be allocated less than
5039 /// its requested size, and in many cases a widget may be allocated more
5040 /// space than it requested.
5041 ///
5042 /// If the size request in a given direction is -1 (unset), then
5043 /// the “natural” size request of the widget will be used instead.
5044 ///
5045 /// The size request set here does not include any margin from the
5046 /// [`Widget`][crate::Widget] properties margin-left, margin-right, margin-top, and
5047 /// margin-bottom, but it does include pretty much all other padding
5048 /// or border properties set by any subclass of [`Widget`][crate::Widget].
5049 /// ## `width`
5050 /// width `self` should request, or -1 to unset
5051 /// ## `height`
5052 /// height `self` should request, or -1 to unset
5053 #[doc(alias = "gtk_widget_set_size_request")]
5054 fn set_size_request(&self, width: i32, height: i32) {
5055 unsafe {
5056 ffi::gtk_widget_set_size_request(self.as_ref().to_glib_none().0, width, height);
5057 }
5058 }
5059
5060 /// This function is for use in widget implementations. Turns on flag
5061 /// values in the current widget state (insensitive, prelighted, etc.).
5062 ///
5063 /// This function accepts the values [`StateFlags::DIR_LTR`][crate::StateFlags::DIR_LTR] and
5064 /// [`StateFlags::DIR_RTL`][crate::StateFlags::DIR_RTL] but ignores them. If you want to set the widget's
5065 /// direction, use [`set_direction()`][Self::set_direction()].
5066 ///
5067 /// It is worth mentioning that any other state than [`StateFlags::INSENSITIVE`][crate::StateFlags::INSENSITIVE],
5068 /// will be propagated down to all non-internal children if `self` is a
5069 /// [`Container`][crate::Container], while [`StateFlags::INSENSITIVE`][crate::StateFlags::INSENSITIVE] itself will be propagated
5070 /// down to all [`Container`][crate::Container] children by different means than turning on the
5071 /// state flag down the hierarchy, both [`state_flags()`][Self::state_flags()] and
5072 /// [`is_sensitive()`][Self::is_sensitive()] will make use of these.
5073 /// ## `flags`
5074 /// State flags to turn on
5075 /// ## `clear`
5076 /// Whether to clear state before turning on `flags`
5077 #[doc(alias = "gtk_widget_set_state_flags")]
5078 fn set_state_flags(&self, flags: StateFlags, clear: bool) {
5079 unsafe {
5080 ffi::gtk_widget_set_state_flags(
5081 self.as_ref().to_glib_none().0,
5082 flags.into_glib(),
5083 clear.into_glib(),
5084 );
5085 }
5086 }
5087
5088 /// Enables or disables multiple pointer awareness. If this setting is [`true`],
5089 /// `self` will start receiving multiple, per device enter/leave events. Note
5090 /// that if custom `GdkWindows` are created in [`realize`][struct@crate::Widget#realize],
5091 /// [`Window::set_support_multidevice()`][crate::gdk::Window::set_support_multidevice()] will have to be called manually on them.
5092 /// ## `support_multidevice`
5093 /// [`true`] to support input from multiple devices.
5094 #[doc(alias = "gtk_widget_set_support_multidevice")]
5095 fn set_support_multidevice(&self, support_multidevice: bool) {
5096 unsafe {
5097 ffi::gtk_widget_set_support_multidevice(
5098 self.as_ref().to_glib_none().0,
5099 support_multidevice.into_glib(),
5100 );
5101 }
5102 }
5103
5104 /// Sets `markup` as the contents of the tooltip, which is marked up with
5105 /// the [Pango text markup language][PangoMarkupFormat].
5106 ///
5107 /// This function will take care of setting [`has-tooltip`][struct@crate::Widget#has-tooltip] to [`true`]
5108 /// and of the default handler for the [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
5109 ///
5110 /// See also the [`tooltip-markup`][struct@crate::Widget#tooltip-markup] property and
5111 /// [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
5112 /// ## `markup`
5113 /// the contents of the tooltip for `self`, or [`None`]
5114 #[doc(alias = "gtk_widget_set_tooltip_markup")]
5115 fn set_tooltip_markup(&self, markup: Option<&str>) {
5116 unsafe {
5117 ffi::gtk_widget_set_tooltip_markup(
5118 self.as_ref().to_glib_none().0,
5119 markup.to_glib_none().0,
5120 );
5121 }
5122 }
5123
5124 /// Sets `text` as the contents of the tooltip. This function will take
5125 /// care of setting [`has-tooltip`][struct@crate::Widget#has-tooltip] to [`true`] and of the default
5126 /// handler for the [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
5127 ///
5128 /// See also the [`tooltip-text`][struct@crate::Widget#tooltip-text] property and [`Tooltip::set_text()`][crate::Tooltip::set_text()].
5129 /// ## `text`
5130 /// the contents of the tooltip for `self`
5131 #[doc(alias = "gtk_widget_set_tooltip_text")]
5132 fn set_tooltip_text(&self, text: Option<&str>) {
5133 unsafe {
5134 ffi::gtk_widget_set_tooltip_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
5135 }
5136 }
5137
5138 /// Replaces the default window used for displaying
5139 /// tooltips with `custom_window`. GTK+ will take care of showing and
5140 /// hiding `custom_window` at the right moment, to behave likewise as
5141 /// the default tooltip window. If `custom_window` is [`None`], the default
5142 /// tooltip window will be used.
5143 /// ## `custom_window`
5144 /// a [`Window`][crate::Window], or [`None`]
5145 #[doc(alias = "gtk_widget_set_tooltip_window")]
5146 fn set_tooltip_window(&self, custom_window: Option<&impl IsA<Window>>) {
5147 unsafe {
5148 ffi::gtk_widget_set_tooltip_window(
5149 self.as_ref().to_glib_none().0,
5150 custom_window.map(|p| p.as_ref()).to_glib_none().0,
5151 );
5152 }
5153 }
5154
5155 /// Sets the vertical alignment of `self`.
5156 /// See the [`valign`][struct@crate::Widget#valign] property.
5157 /// ## `align`
5158 /// the vertical alignment
5159 #[doc(alias = "gtk_widget_set_valign")]
5160 fn set_valign(&self, align: Align) {
5161 unsafe {
5162 ffi::gtk_widget_set_valign(self.as_ref().to_glib_none().0, align.into_glib());
5163 }
5164 }
5165
5166 /// Sets whether the widget would like any available extra vertical
5167 /// space.
5168 ///
5169 /// See [`set_hexpand()`][Self::set_hexpand()] for more detail.
5170 /// ## `expand`
5171 /// whether to expand
5172 #[doc(alias = "gtk_widget_set_vexpand")]
5173 fn set_vexpand(&self, expand: bool) {
5174 unsafe {
5175 ffi::gtk_widget_set_vexpand(self.as_ref().to_glib_none().0, expand.into_glib());
5176 }
5177 }
5178
5179 /// Sets whether the vexpand flag (see [`vexpands()`][Self::vexpands()]) will
5180 /// be used.
5181 ///
5182 /// See [`set_hexpand_set()`][Self::set_hexpand_set()] for more detail.
5183 /// ## `set`
5184 /// value for vexpand-set property
5185 #[doc(alias = "gtk_widget_set_vexpand_set")]
5186 fn set_vexpand_set(&self, set: bool) {
5187 unsafe {
5188 ffi::gtk_widget_set_vexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
5189 }
5190 }
5191
5192 /// Sets the visibility state of `self`. Note that setting this to
5193 /// [`true`] doesn’t mean the widget is actually viewable, see
5194 /// [`get_visible()`][Self::get_visible()].
5195 ///
5196 /// This function simply calls [`show()`][Self::show()] or [`hide()`][Self::hide()]
5197 /// but is nicer to use when the visibility of the widget depends on
5198 /// some condition.
5199 /// ## `visible`
5200 /// whether the widget should be shown or not
5201 #[doc(alias = "gtk_widget_set_visible")]
5202 fn set_visible(&self, visible: bool) {
5203 unsafe {
5204 ffi::gtk_widget_set_visible(self.as_ref().to_glib_none().0, visible.into_glib());
5205 }
5206 }
5207
5208 /// Sets the visual that should be used for by widget and its children for
5209 /// creating `GdkWindows`. The visual must be on the same [`gdk::Screen`][crate::gdk::Screen] as
5210 /// returned by [`screen()`][Self::screen()], so handling the
5211 /// [`screen-changed`][struct@crate::Widget#screen-changed] signal is necessary.
5212 ///
5213 /// Setting a new `visual` will not cause `self` to recreate its windows,
5214 /// so you should call this function before `self` is realized.
5215 /// ## `visual`
5216 /// visual to be used or [`None`] to unset a previous one
5217 #[doc(alias = "gtk_widget_set_visual")]
5218 fn set_visual(&self, visual: Option<&gdk::Visual>) {
5219 unsafe {
5220 ffi::gtk_widget_set_visual(self.as_ref().to_glib_none().0, visual.to_glib_none().0);
5221 }
5222 }
5223
5224 /// Sets a widget’s window. This function should only be used in a
5225 /// widget’s [`realize`][struct@crate::Widget#realize] implementation. The `window` passed is
5226 /// usually either new window created with [`gdk::Window::new()`][crate::gdk::Window::new()], or the
5227 /// window of its parent widget as returned by
5228 /// [`parent_window()`][Self::parent_window()].
5229 ///
5230 /// Widgets must indicate whether they will create their own [`gdk::Window`][crate::gdk::Window]
5231 /// by calling [`set_has_window()`][Self::set_has_window()]. This is usually done in the
5232 /// widget’s `init()` function.
5233 ///
5234 /// Note that this function does not add any reference to `window`.
5235 /// ## `window`
5236 /// a [`gdk::Window`][crate::gdk::Window]
5237 #[doc(alias = "gtk_widget_set_window")]
5238 fn set_window(&self, window: gdk::Window) {
5239 unsafe {
5240 ffi::gtk_widget_set_window(self.as_ref().to_glib_none().0, window.into_glib_ptr());
5241 }
5242 }
5243
5244 /// Sets a shape for this widget’s GDK window. This allows for
5245 /// transparent windows etc., see [`Window::shape_combine_region()`][crate::gdk::Window::shape_combine_region()]
5246 /// for more information.
5247 /// ## `region`
5248 /// shape to be added, or [`None`] to remove an existing shape
5249 #[doc(alias = "gtk_widget_shape_combine_region")]
5250 fn shape_combine_region(&self, region: Option<&cairo::Region>) {
5251 unsafe {
5252 ffi::gtk_widget_shape_combine_region(
5253 self.as_ref().to_glib_none().0,
5254 mut_override(region.to_glib_none().0),
5255 );
5256 }
5257 }
5258
5259 /// Flags a widget to be displayed. Any widget that isn’t shown will
5260 /// not appear on the screen. If you want to show all the widgets in a
5261 /// container, it’s easier to call [`show_all()`][Self::show_all()] on the
5262 /// container, instead of individually showing the widgets.
5263 ///
5264 /// Remember that you have to show the containers containing a widget,
5265 /// in addition to the widget itself, before it will appear onscreen.
5266 ///
5267 /// When a toplevel container is shown, it is immediately realized and
5268 /// mapped; other shown widgets are realized and mapped when their
5269 /// toplevel container is realized and mapped.
5270 #[doc(alias = "gtk_widget_show")]
5271 fn show(&self) {
5272 unsafe {
5273 ffi::gtk_widget_show(self.as_ref().to_glib_none().0);
5274 }
5275 }
5276
5277 /// Recursively shows a widget, and any child widgets (if the widget is
5278 /// a container).
5279 #[doc(alias = "gtk_widget_show_all")]
5280 fn show_all(&self) {
5281 unsafe {
5282 ffi::gtk_widget_show_all(self.as_ref().to_glib_none().0);
5283 }
5284 }
5285
5286 /// Shows a widget. If the widget is an unmapped toplevel widget
5287 /// (i.e. a [`Window`][crate::Window] that has not yet been shown), enter the main
5288 /// loop and wait for the window to actually be mapped. Be careful;
5289 /// because the main loop is running, anything can happen during
5290 /// this function.
5291 #[doc(alias = "gtk_widget_show_now")]
5292 fn show_now(&self) {
5293 unsafe {
5294 ffi::gtk_widget_show_now(self.as_ref().to_glib_none().0);
5295 }
5296 }
5297
5298 /// This function is only used by [`Container`][crate::Container] subclasses, to assign a size
5299 /// and position to their child widgets.
5300 ///
5301 /// In this function, the allocation may be adjusted. It will be forced
5302 /// to a 1x1 minimum size, and the adjust_size_allocation virtual
5303 /// method on the child will be used to adjust the allocation. Standard
5304 /// adjustments include removing the widget’s margins, and applying the
5305 /// widget’s [`halign`][struct@crate::Widget#halign] and [`valign`][struct@crate::Widget#valign] properties.
5306 ///
5307 /// For baseline support in containers you need to use [`size_allocate_with_baseline()`][Self::size_allocate_with_baseline()]
5308 /// instead.
5309 /// ## `allocation`
5310 /// position and size to be allocated to `self`
5311 #[doc(alias = "gtk_widget_size_allocate")]
5312 fn size_allocate(&self, allocation: &Allocation) {
5313 unsafe {
5314 ffi::gtk_widget_size_allocate(
5315 self.as_ref().to_glib_none().0,
5316 mut_override(allocation.to_glib_none().0),
5317 );
5318 }
5319 }
5320
5321 /// This function is only used by [`Container`][crate::Container] subclasses, to assign a size,
5322 /// position and (optionally) baseline to their child widgets.
5323 ///
5324 /// In this function, the allocation and baseline may be adjusted. It
5325 /// will be forced to a 1x1 minimum size, and the
5326 /// adjust_size_allocation virtual and adjust_baseline_allocation
5327 /// methods on the child will be used to adjust the allocation and
5328 /// baseline. Standard adjustments include removing the widget's
5329 /// margins, and applying the widget’s [`halign`][struct@crate::Widget#halign] and
5330 /// [`valign`][struct@crate::Widget#valign] properties.
5331 ///
5332 /// If the child widget does not have a valign of [`Align::Baseline`][crate::Align::Baseline] the
5333 /// baseline argument is ignored and -1 is used instead.
5334 /// ## `allocation`
5335 /// position and size to be allocated to `self`
5336 /// ## `baseline`
5337 /// The baseline of the child, or -1
5338 #[doc(alias = "gtk_widget_size_allocate_with_baseline")]
5339 fn size_allocate_with_baseline(&self, allocation: &mut Allocation, baseline: i32) {
5340 unsafe {
5341 ffi::gtk_widget_size_allocate_with_baseline(
5342 self.as_ref().to_glib_none().0,
5343 allocation.to_glib_none_mut().0,
5344 baseline,
5345 );
5346 }
5347 }
5348
5349 //#[doc(alias = "gtk_widget_style_get")]
5350 //fn style_get(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
5351 // unsafe { TODO: call ffi:gtk_widget_style_get() }
5352 //}
5353
5354 /// Gets the value of a style property of `self`.
5355 /// ## `property_name`
5356 /// the name of a style property
5357 ///
5358 /// # Returns
5359 ///
5360 ///
5361 /// ## `value`
5362 /// location to return the property value
5363 #[doc(alias = "gtk_widget_style_get_property")]
5364 fn style_get_property(&self, property_name: &str) -> glib::Value {
5365 unsafe {
5366 let mut value = glib::Value::uninitialized();
5367 ffi::gtk_widget_style_get_property(
5368 self.as_ref().to_glib_none().0,
5369 property_name.to_glib_none().0,
5370 value.to_glib_none_mut().0,
5371 );
5372 value
5373 }
5374 }
5375
5376 //#[doc(alias = "gtk_widget_style_get_valist")]
5377 //fn style_get_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
5378 // unsafe { TODO: call ffi:gtk_widget_style_get_valist() }
5379 //}
5380
5381 /// Reverts the effect of a previous call to [`freeze_child_notify()`][Self::freeze_child_notify()].
5382 /// This causes all queued [`child-notify`][struct@crate::Widget#child-notify] signals on `self` to be
5383 /// emitted.
5384 #[doc(alias = "gtk_widget_thaw_child_notify")]
5385 fn thaw_child_notify(&self) {
5386 unsafe {
5387 ffi::gtk_widget_thaw_child_notify(self.as_ref().to_glib_none().0);
5388 }
5389 }
5390
5391 /// Translate coordinates relative to `self`’s allocation to coordinates
5392 /// relative to `dest_widget`’s allocations. In order to perform this
5393 /// operation, both widgets must be realized, and must share a common
5394 /// toplevel.
5395 /// ## `dest_widget`
5396 /// a [`Widget`][crate::Widget]
5397 /// ## `src_x`
5398 /// X position relative to `self`
5399 /// ## `src_y`
5400 /// Y position relative to `self`
5401 ///
5402 /// # Returns
5403 ///
5404 /// [`false`] if either widget was not realized, or there
5405 /// was no common ancestor. In this case, nothing is stored in
5406 /// *`dest_x` and *`dest_y`. Otherwise [`true`].
5407 ///
5408 /// ## `dest_x`
5409 /// location to store X position relative to `dest_widget`
5410 ///
5411 /// ## `dest_y`
5412 /// location to store Y position relative to `dest_widget`
5413 #[doc(alias = "gtk_widget_translate_coordinates")]
5414 fn translate_coordinates(
5415 &self,
5416 dest_widget: &impl IsA<Widget>,
5417 src_x: i32,
5418 src_y: i32,
5419 ) -> Option<(i32, i32)> {
5420 unsafe {
5421 let mut dest_x = mem::MaybeUninit::uninit();
5422 let mut dest_y = mem::MaybeUninit::uninit();
5423 let ret = from_glib(ffi::gtk_widget_translate_coordinates(
5424 self.as_ref().to_glib_none().0,
5425 dest_widget.as_ref().to_glib_none().0,
5426 src_x,
5427 src_y,
5428 dest_x.as_mut_ptr(),
5429 dest_y.as_mut_ptr(),
5430 ));
5431 if ret {
5432 Some((dest_x.assume_init(), dest_y.assume_init()))
5433 } else {
5434 None
5435 }
5436 }
5437 }
5438
5439 /// Triggers a tooltip query on the display where the toplevel of `self`
5440 /// is located. See [`Tooltip::trigger_tooltip_query()`][crate::Tooltip::trigger_tooltip_query()] for more
5441 /// information.
5442 #[doc(alias = "gtk_widget_trigger_tooltip_query")]
5443 fn trigger_tooltip_query(&self) {
5444 unsafe {
5445 ffi::gtk_widget_trigger_tooltip_query(self.as_ref().to_glib_none().0);
5446 }
5447 }
5448
5449 /// This function is only for use in widget implementations. Causes
5450 /// a widget to be unmapped if it’s currently mapped.
5451 #[doc(alias = "gtk_widget_unmap")]
5452 fn unmap(&self) {
5453 unsafe {
5454 ffi::gtk_widget_unmap(self.as_ref().to_glib_none().0);
5455 }
5456 }
5457
5458 /// This function is only for use in widget implementations.
5459 /// Should be called by implementations of the remove method
5460 /// on [`Container`][crate::Container], to dissociate a child from the container.
5461 #[doc(alias = "gtk_widget_unparent")]
5462 fn unparent(&self) {
5463 unsafe {
5464 ffi::gtk_widget_unparent(self.as_ref().to_glib_none().0);
5465 }
5466 }
5467
5468 /// This function is only useful in widget implementations.
5469 /// Causes a widget to be unrealized (frees all GDK resources
5470 /// associated with the widget, such as `self`->window).
5471 #[doc(alias = "gtk_widget_unrealize")]
5472 fn unrealize(&self) {
5473 unsafe {
5474 ffi::gtk_widget_unrealize(self.as_ref().to_glib_none().0);
5475 }
5476 }
5477
5478 /// Unregisters a [`gdk::Window`][crate::gdk::Window] from the widget that was previously set up with
5479 /// [`register_window()`][Self::register_window()]. You need to call this when the window is
5480 /// no longer used by the widget, such as when you destroy it.
5481 /// ## `window`
5482 /// a [`gdk::Window`][crate::gdk::Window]
5483 #[doc(alias = "gtk_widget_unregister_window")]
5484 fn unregister_window(&self, window: &gdk::Window) {
5485 unsafe {
5486 ffi::gtk_widget_unregister_window(
5487 self.as_ref().to_glib_none().0,
5488 window.to_glib_none().0,
5489 );
5490 }
5491 }
5492
5493 /// This function is for use in widget implementations. Turns off flag
5494 /// values for the current widget state (insensitive, prelighted, etc.).
5495 /// See [`set_state_flags()`][Self::set_state_flags()].
5496 /// ## `flags`
5497 /// State flags to turn off
5498 #[doc(alias = "gtk_widget_unset_state_flags")]
5499 fn unset_state_flags(&self, flags: StateFlags) {
5500 unsafe {
5501 ffi::gtk_widget_unset_state_flags(self.as_ref().to_glib_none().0, flags.into_glib());
5502 }
5503 }
5504
5505 #[doc(alias = "composite-child")]
5506 fn is_composite_child(&self) -> bool {
5507 ObjectExt::property(self.as_ref(), "composite-child")
5508 }
5509
5510 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
5511 fn expands(&self) -> bool {
5512 ObjectExt::property(self.as_ref(), "expand")
5513 }
5514
5515 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
5516 fn set_expand(&self, expand: bool) {
5517 ObjectExt::set_property(self.as_ref(), "expand", expand)
5518 }
5519
5520 #[doc(alias = "has-default")]
5521 fn set_has_default(&self, has_default: bool) {
5522 ObjectExt::set_property(self.as_ref(), "has-default", has_default)
5523 }
5524
5525 #[doc(alias = "has-focus")]
5526 fn set_has_focus(&self, has_focus: bool) {
5527 ObjectExt::set_property(self.as_ref(), "has-focus", has_focus)
5528 }
5529
5530 #[doc(alias = "height-request")]
5531 fn height_request(&self) -> i32 {
5532 ObjectExt::property(self.as_ref(), "height-request")
5533 }
5534
5535 #[doc(alias = "height-request")]
5536 fn set_height_request(&self, height_request: i32) {
5537 ObjectExt::set_property(self.as_ref(), "height-request", height_request)
5538 }
5539
5540 #[doc(alias = "is-focus")]
5541 fn set_is_focus(&self, is_focus: bool) {
5542 ObjectExt::set_property(self.as_ref(), "is-focus", is_focus)
5543 }
5544
5545 /// Sets all four sides' margin at once. If read, returns max
5546 /// margin on any side.
5547 fn margin(&self) -> i32 {
5548 ObjectExt::property(self.as_ref(), "margin")
5549 }
5550
5551 /// Sets all four sides' margin at once. If read, returns max
5552 /// margin on any side.
5553 fn set_margin(&self, margin: i32) {
5554 ObjectExt::set_property(self.as_ref(), "margin", margin)
5555 }
5556
5557 #[doc(alias = "width-request")]
5558 fn width_request(&self) -> i32 {
5559 ObjectExt::property(self.as_ref(), "width-request")
5560 }
5561
5562 #[doc(alias = "width-request")]
5563 fn set_width_request(&self, width_request: i32) {
5564 ObjectExt::set_property(self.as_ref(), "width-request", width_request)
5565 }
5566
5567 #[doc(alias = "accel-closures-changed")]
5568 fn connect_accel_closures_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5569 unsafe extern "C" fn accel_closures_changed_trampoline<
5570 P: IsA<Widget>,
5571 F: Fn(&P) + 'static,
5572 >(
5573 this: *mut ffi::GtkWidget,
5574 f: glib::ffi::gpointer,
5575 ) {
5576 let f: &F = &*(f as *const F);
5577 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5578 }
5579 unsafe {
5580 let f: Box_<F> = Box_::new(f);
5581 connect_raw(
5582 self.as_ptr() as *mut _,
5583 b"accel-closures-changed\0".as_ptr() as *const _,
5584 Some(transmute::<_, unsafe extern "C" fn()>(
5585 accel_closures_changed_trampoline::<Self, F> as *const (),
5586 )),
5587 Box_::into_raw(f),
5588 )
5589 }
5590 }
5591
5592 /// The ::button-press-event signal will be emitted when a button
5593 /// (typically from a mouse) is pressed.
5594 ///
5595 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
5596 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
5597 ///
5598 /// This signal will be sent to the grab widget if there is one.
5599 /// ## `event`
5600 /// the [`gdk::EventButton`][crate::gdk::EventButton] which triggered
5601 /// this signal.
5602 ///
5603 /// # Returns
5604 ///
5605 /// [`true`] to stop other handlers from being invoked for the event.
5606 /// [`false`] to propagate the event further.
5607 #[doc(alias = "button-press-event")]
5608 fn connect_button_press_event<
5609 F: Fn(&Self, &gdk::EventButton) -> glib::Propagation + 'static,
5610 >(
5611 &self,
5612 f: F,
5613 ) -> SignalHandlerId {
5614 unsafe extern "C" fn button_press_event_trampoline<
5615 P: IsA<Widget>,
5616 F: Fn(&P, &gdk::EventButton) -> glib::Propagation + 'static,
5617 >(
5618 this: *mut ffi::GtkWidget,
5619 event: *mut gdk::ffi::GdkEventButton,
5620 f: glib::ffi::gpointer,
5621 ) -> glib::ffi::gboolean {
5622 let f: &F = &*(f as *const F);
5623 f(
5624 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5625 &from_glib_borrow(event),
5626 )
5627 .into_glib()
5628 }
5629 unsafe {
5630 let f: Box_<F> = Box_::new(f);
5631 connect_raw(
5632 self.as_ptr() as *mut _,
5633 b"button-press-event\0".as_ptr() as *const _,
5634 Some(transmute::<_, unsafe extern "C" fn()>(
5635 button_press_event_trampoline::<Self, F> as *const (),
5636 )),
5637 Box_::into_raw(f),
5638 )
5639 }
5640 }
5641
5642 /// The ::button-release-event signal will be emitted when a button
5643 /// (typically from a mouse) is released.
5644 ///
5645 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
5646 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
5647 ///
5648 /// This signal will be sent to the grab widget if there is one.
5649 /// ## `event`
5650 /// the [`gdk::EventButton`][crate::gdk::EventButton] which triggered
5651 /// this signal.
5652 ///
5653 /// # Returns
5654 ///
5655 /// [`true`] to stop other handlers from being invoked for the event.
5656 /// [`false`] to propagate the event further.
5657 #[doc(alias = "button-release-event")]
5658 fn connect_button_release_event<
5659 F: Fn(&Self, &gdk::EventButton) -> glib::Propagation + 'static,
5660 >(
5661 &self,
5662 f: F,
5663 ) -> SignalHandlerId {
5664 unsafe extern "C" fn button_release_event_trampoline<
5665 P: IsA<Widget>,
5666 F: Fn(&P, &gdk::EventButton) -> glib::Propagation + 'static,
5667 >(
5668 this: *mut ffi::GtkWidget,
5669 event: *mut gdk::ffi::GdkEventButton,
5670 f: glib::ffi::gpointer,
5671 ) -> glib::ffi::gboolean {
5672 let f: &F = &*(f as *const F);
5673 f(
5674 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5675 &from_glib_borrow(event),
5676 )
5677 .into_glib()
5678 }
5679 unsafe {
5680 let f: Box_<F> = Box_::new(f);
5681 connect_raw(
5682 self.as_ptr() as *mut _,
5683 b"button-release-event\0".as_ptr() as *const _,
5684 Some(transmute::<_, unsafe extern "C" fn()>(
5685 button_release_event_trampoline::<Self, F> as *const (),
5686 )),
5687 Box_::into_raw(f),
5688 )
5689 }
5690 }
5691
5692 /// Determines whether an accelerator that activates the signal
5693 /// identified by `signal_id` can currently be activated.
5694 /// This signal is present to allow applications and derived
5695 /// widgets to override the default [`Widget`][crate::Widget] handling
5696 /// for determining whether an accelerator can be activated.
5697 /// ## `signal_id`
5698 /// the ID of a signal installed on `widget`
5699 ///
5700 /// # Returns
5701 ///
5702 /// [`true`] if the signal can be activated.
5703 #[doc(alias = "can-activate-accel")]
5704 fn connect_can_activate_accel<F: Fn(&Self, u32) -> bool + 'static>(
5705 &self,
5706 f: F,
5707 ) -> SignalHandlerId {
5708 unsafe extern "C" fn can_activate_accel_trampoline<
5709 P: IsA<Widget>,
5710 F: Fn(&P, u32) -> bool + 'static,
5711 >(
5712 this: *mut ffi::GtkWidget,
5713 signal_id: libc::c_uint,
5714 f: glib::ffi::gpointer,
5715 ) -> glib::ffi::gboolean {
5716 let f: &F = &*(f as *const F);
5717 f(Widget::from_glib_borrow(this).unsafe_cast_ref(), signal_id).into_glib()
5718 }
5719 unsafe {
5720 let f: Box_<F> = Box_::new(f);
5721 connect_raw(
5722 self.as_ptr() as *mut _,
5723 b"can-activate-accel\0".as_ptr() as *const _,
5724 Some(transmute::<_, unsafe extern "C" fn()>(
5725 can_activate_accel_trampoline::<Self, F> as *const (),
5726 )),
5727 Box_::into_raw(f),
5728 )
5729 }
5730 }
5731
5732 /// The ::child-notify signal is emitted for each
5733 /// [child property][child-properties] that has
5734 /// changed on an object. The signal's detail holds the property name.
5735 /// ## `child_property`
5736 /// the [`glib::ParamSpec`][crate::glib::ParamSpec] of the changed child property
5737 #[doc(alias = "child-notify")]
5738 fn connect_child_notify<F: Fn(&Self, &glib::ParamSpec) + 'static>(
5739 &self,
5740 detail: Option<&str>,
5741 f: F,
5742 ) -> SignalHandlerId {
5743 unsafe extern "C" fn child_notify_trampoline<
5744 P: IsA<Widget>,
5745 F: Fn(&P, &glib::ParamSpec) + 'static,
5746 >(
5747 this: *mut ffi::GtkWidget,
5748 child_property: *mut glib::gobject_ffi::GParamSpec,
5749 f: glib::ffi::gpointer,
5750 ) {
5751 let f: &F = &*(f as *const F);
5752 f(
5753 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5754 &from_glib_borrow(child_property),
5755 )
5756 }
5757 unsafe {
5758 let f: Box_<F> = Box_::new(f);
5759 let detailed_signal_name = detail.map(|name| format!("child-notify::{name}\0"));
5760 let signal_name: &[u8] = detailed_signal_name
5761 .as_ref()
5762 .map_or(&b"child-notify\0"[..], |n| n.as_bytes());
5763 connect_raw(
5764 self.as_ptr() as *mut _,
5765 signal_name.as_ptr() as *const _,
5766 Some(transmute::<_, unsafe extern "C" fn()>(
5767 child_notify_trampoline::<Self, F> as *const (),
5768 )),
5769 Box_::into_raw(f),
5770 )
5771 }
5772 }
5773
5774 /// The ::configure-event signal will be emitted when the size, position or
5775 /// stacking of the `widget`'s window has changed.
5776 ///
5777 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
5778 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
5779 /// automatically for all new windows.
5780 /// ## `event`
5781 /// the [`gdk::EventConfigure`][crate::gdk::EventConfigure] which triggered
5782 /// this signal.
5783 ///
5784 /// # Returns
5785 ///
5786 /// [`true`] to stop other handlers from being invoked for the event.
5787 /// [`false`] to propagate the event further.
5788 #[doc(alias = "configure-event")]
5789 fn connect_configure_event<F: Fn(&Self, &gdk::EventConfigure) -> bool + 'static>(
5790 &self,
5791 f: F,
5792 ) -> SignalHandlerId {
5793 unsafe extern "C" fn configure_event_trampoline<
5794 P: IsA<Widget>,
5795 F: Fn(&P, &gdk::EventConfigure) -> bool + 'static,
5796 >(
5797 this: *mut ffi::GtkWidget,
5798 event: *mut gdk::ffi::GdkEventConfigure,
5799 f: glib::ffi::gpointer,
5800 ) -> glib::ffi::gboolean {
5801 let f: &F = &*(f as *const F);
5802 f(
5803 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5804 &from_glib_borrow(event),
5805 )
5806 .into_glib()
5807 }
5808 unsafe {
5809 let f: Box_<F> = Box_::new(f);
5810 connect_raw(
5811 self.as_ptr() as *mut _,
5812 b"configure-event\0".as_ptr() as *const _,
5813 Some(transmute::<_, unsafe extern "C" fn()>(
5814 configure_event_trampoline::<Self, F> as *const (),
5815 )),
5816 Box_::into_raw(f),
5817 )
5818 }
5819 }
5820
5821 /// Emitted when a redirected window belonging to `widget` gets drawn into.
5822 /// The region/area members of the event shows what area of the redirected
5823 /// drawable was drawn into.
5824 /// ## `event`
5825 /// the [`gdk::EventExpose`][crate::gdk::EventExpose] event
5826 ///
5827 /// # Returns
5828 ///
5829 /// [`true`] to stop other handlers from being invoked for the event.
5830 /// [`false`] to propagate the event further.
5831 #[doc(alias = "damage-event")]
5832 fn connect_damage_event<F: Fn(&Self, &gdk::EventExpose) -> bool + 'static>(
5833 &self,
5834 f: F,
5835 ) -> SignalHandlerId {
5836 unsafe extern "C" fn damage_event_trampoline<
5837 P: IsA<Widget>,
5838 F: Fn(&P, &gdk::EventExpose) -> bool + 'static,
5839 >(
5840 this: *mut ffi::GtkWidget,
5841 event: *mut gdk::ffi::GdkEventExpose,
5842 f: glib::ffi::gpointer,
5843 ) -> glib::ffi::gboolean {
5844 let f: &F = &*(f as *const F);
5845 f(
5846 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5847 &from_glib_borrow(event),
5848 )
5849 .into_glib()
5850 }
5851 unsafe {
5852 let f: Box_<F> = Box_::new(f);
5853 connect_raw(
5854 self.as_ptr() as *mut _,
5855 b"damage-event\0".as_ptr() as *const _,
5856 Some(transmute::<_, unsafe extern "C" fn()>(
5857 damage_event_trampoline::<Self, F> as *const (),
5858 )),
5859 Box_::into_raw(f),
5860 )
5861 }
5862 }
5863
5864 /// The ::delete-event signal is emitted if a user requests that
5865 /// a toplevel window is closed. The default handler for this signal
5866 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
5867 /// this signal will cause the window to be hidden instead, so that
5868 /// it can later be shown again without reconstructing it.
5869 /// ## `event`
5870 /// the event which triggered this signal
5871 ///
5872 /// # Returns
5873 ///
5874 /// [`true`] to stop other handlers from being invoked for the event.
5875 /// [`false`] to propagate the event further.
5876 #[doc(alias = "delete-event")]
5877 fn connect_delete_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
5878 &self,
5879 f: F,
5880 ) -> SignalHandlerId {
5881 unsafe extern "C" fn delete_event_trampoline<
5882 P: IsA<Widget>,
5883 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
5884 >(
5885 this: *mut ffi::GtkWidget,
5886 event: *mut gdk::ffi::GdkEvent,
5887 f: glib::ffi::gpointer,
5888 ) -> glib::ffi::gboolean {
5889 let f: &F = &*(f as *const F);
5890 f(
5891 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5892 &from_glib_none(event),
5893 )
5894 .into_glib()
5895 }
5896 unsafe {
5897 let f: Box_<F> = Box_::new(f);
5898 connect_raw(
5899 self.as_ptr() as *mut _,
5900 b"delete-event\0".as_ptr() as *const _,
5901 Some(transmute::<_, unsafe extern "C" fn()>(
5902 delete_event_trampoline::<Self, F> as *const (),
5903 )),
5904 Box_::into_raw(f),
5905 )
5906 }
5907 }
5908
5909 /// Signals that all holders of a reference to the widget should release
5910 /// the reference that they hold. May result in finalization of the widget
5911 /// if all references are released.
5912 ///
5913 /// This signal is not suitable for saving widget state.
5914 #[doc(alias = "destroy")]
5915 fn connect_destroy<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5916 unsafe extern "C" fn destroy_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5917 this: *mut ffi::GtkWidget,
5918 f: glib::ffi::gpointer,
5919 ) {
5920 let f: &F = &*(f as *const F);
5921 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5922 }
5923 unsafe {
5924 let f: Box_<F> = Box_::new(f);
5925 connect_raw(
5926 self.as_ptr() as *mut _,
5927 b"destroy\0".as_ptr() as *const _,
5928 Some(transmute::<_, unsafe extern "C" fn()>(
5929 destroy_trampoline::<Self, F> as *const (),
5930 )),
5931 Box_::into_raw(f),
5932 )
5933 }
5934 }
5935
5936 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
5937 /// You rarely get this signal, because most widgets disconnect themselves
5938 /// from their window before they destroy it, so no widget owns the
5939 /// window at destroy time.
5940 ///
5941 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
5942 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
5943 /// automatically for all new windows.
5944 /// ## `event`
5945 /// the event which triggered this signal
5946 ///
5947 /// # Returns
5948 ///
5949 /// [`true`] to stop other handlers from being invoked for the event.
5950 /// [`false`] to propagate the event further.
5951 #[doc(alias = "destroy-event")]
5952 fn connect_destroy_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
5953 &self,
5954 f: F,
5955 ) -> SignalHandlerId {
5956 unsafe extern "C" fn destroy_event_trampoline<
5957 P: IsA<Widget>,
5958 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
5959 >(
5960 this: *mut ffi::GtkWidget,
5961 event: *mut gdk::ffi::GdkEvent,
5962 f: glib::ffi::gpointer,
5963 ) -> glib::ffi::gboolean {
5964 let f: &F = &*(f as *const F);
5965 f(
5966 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5967 &from_glib_none(event),
5968 )
5969 .into_glib()
5970 }
5971 unsafe {
5972 let f: Box_<F> = Box_::new(f);
5973 connect_raw(
5974 self.as_ptr() as *mut _,
5975 b"destroy-event\0".as_ptr() as *const _,
5976 Some(transmute::<_, unsafe extern "C" fn()>(
5977 destroy_event_trampoline::<Self, F> as *const (),
5978 )),
5979 Box_::into_raw(f),
5980 )
5981 }
5982 }
5983
5984 /// The ::direction-changed signal is emitted when the text direction
5985 /// of a widget changes.
5986 /// ## `previous_direction`
5987 /// the previous text direction of `widget`
5988 #[doc(alias = "direction-changed")]
5989 fn connect_direction_changed<F: Fn(&Self, TextDirection) + 'static>(
5990 &self,
5991 f: F,
5992 ) -> SignalHandlerId {
5993 unsafe extern "C" fn direction_changed_trampoline<
5994 P: IsA<Widget>,
5995 F: Fn(&P, TextDirection) + 'static,
5996 >(
5997 this: *mut ffi::GtkWidget,
5998 previous_direction: ffi::GtkTextDirection,
5999 f: glib::ffi::gpointer,
6000 ) {
6001 let f: &F = &*(f as *const F);
6002 f(
6003 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6004 from_glib(previous_direction),
6005 )
6006 }
6007 unsafe {
6008 let f: Box_<F> = Box_::new(f);
6009 connect_raw(
6010 self.as_ptr() as *mut _,
6011 b"direction-changed\0".as_ptr() as *const _,
6012 Some(transmute::<_, unsafe extern "C" fn()>(
6013 direction_changed_trampoline::<Self, F> as *const (),
6014 )),
6015 Box_::into_raw(f),
6016 )
6017 }
6018 }
6019
6020 /// The ::drag-begin signal is emitted on the drag source when a drag is
6021 /// started. A typical reason to connect to this signal is to set up a
6022 /// custom drag icon with e.g. [`drag_source_set_icon_pixbuf()`][Self::drag_source_set_icon_pixbuf()].
6023 ///
6024 /// Note that some widgets set up a drag icon in the default handler of
6025 /// this signal, so you may have to use `g_signal_connect_after()` to
6026 /// override what the default handler did.
6027 /// ## `context`
6028 /// the drag context
6029 #[doc(alias = "drag-begin")]
6030 fn connect_drag_begin<F: Fn(&Self, &gdk::DragContext) + 'static>(
6031 &self,
6032 f: F,
6033 ) -> SignalHandlerId {
6034 unsafe extern "C" fn drag_begin_trampoline<
6035 P: IsA<Widget>,
6036 F: Fn(&P, &gdk::DragContext) + 'static,
6037 >(
6038 this: *mut ffi::GtkWidget,
6039 context: *mut gdk::ffi::GdkDragContext,
6040 f: glib::ffi::gpointer,
6041 ) {
6042 let f: &F = &*(f as *const F);
6043 f(
6044 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6045 &from_glib_borrow(context),
6046 )
6047 }
6048 unsafe {
6049 let f: Box_<F> = Box_::new(f);
6050 connect_raw(
6051 self.as_ptr() as *mut _,
6052 b"drag-begin\0".as_ptr() as *const _,
6053 Some(transmute::<_, unsafe extern "C" fn()>(
6054 drag_begin_trampoline::<Self, F> as *const (),
6055 )),
6056 Box_::into_raw(f),
6057 )
6058 }
6059 }
6060
6061 /// The ::drag-data-delete signal is emitted on the drag source when a drag
6062 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
6063 /// handler is responsible for deleting the data that has been dropped. What
6064 /// "delete" means depends on the context of the drag operation.
6065 /// ## `context`
6066 /// the drag context
6067 #[doc(alias = "drag-data-delete")]
6068 fn connect_drag_data_delete<F: Fn(&Self, &gdk::DragContext) + 'static>(
6069 &self,
6070 f: F,
6071 ) -> SignalHandlerId {
6072 unsafe extern "C" fn drag_data_delete_trampoline<
6073 P: IsA<Widget>,
6074 F: Fn(&P, &gdk::DragContext) + 'static,
6075 >(
6076 this: *mut ffi::GtkWidget,
6077 context: *mut gdk::ffi::GdkDragContext,
6078 f: glib::ffi::gpointer,
6079 ) {
6080 let f: &F = &*(f as *const F);
6081 f(
6082 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6083 &from_glib_borrow(context),
6084 )
6085 }
6086 unsafe {
6087 let f: Box_<F> = Box_::new(f);
6088 connect_raw(
6089 self.as_ptr() as *mut _,
6090 b"drag-data-delete\0".as_ptr() as *const _,
6091 Some(transmute::<_, unsafe extern "C" fn()>(
6092 drag_data_delete_trampoline::<Self, F> as *const (),
6093 )),
6094 Box_::into_raw(f),
6095 )
6096 }
6097 }
6098
6099 /// The ::drag-data-get signal is emitted on the drag source when the drop
6100 /// site requests the data which is dragged. It is the responsibility of
6101 /// the signal handler to fill `data` with the data in the format which
6102 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
6103 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
6104 /// ## `context`
6105 /// the drag context
6106 /// ## `data`
6107 /// the [`SelectionData`][crate::SelectionData] to be filled with the dragged data
6108 /// ## `info`
6109 /// the info that has been registered with the target in the
6110 /// [`TargetList`][crate::TargetList]
6111 /// ## `time`
6112 /// the timestamp at which the data was requested
6113 #[doc(alias = "drag-data-get")]
6114 fn connect_drag_data_get<
6115 F: Fn(&Self, &gdk::DragContext, &SelectionData, u32, u32) + 'static,
6116 >(
6117 &self,
6118 f: F,
6119 ) -> SignalHandlerId {
6120 unsafe extern "C" fn drag_data_get_trampoline<
6121 P: IsA<Widget>,
6122 F: Fn(&P, &gdk::DragContext, &SelectionData, u32, u32) + 'static,
6123 >(
6124 this: *mut ffi::GtkWidget,
6125 context: *mut gdk::ffi::GdkDragContext,
6126 data: *mut ffi::GtkSelectionData,
6127 info: libc::c_uint,
6128 time: libc::c_uint,
6129 f: glib::ffi::gpointer,
6130 ) {
6131 let f: &F = &*(f as *const F);
6132 f(
6133 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6134 &from_glib_borrow(context),
6135 &from_glib_borrow(data),
6136 info,
6137 time,
6138 )
6139 }
6140 unsafe {
6141 let f: Box_<F> = Box_::new(f);
6142 connect_raw(
6143 self.as_ptr() as *mut _,
6144 b"drag-data-get\0".as_ptr() as *const _,
6145 Some(transmute::<_, unsafe extern "C" fn()>(
6146 drag_data_get_trampoline::<Self, F> as *const (),
6147 )),
6148 Box_::into_raw(f),
6149 )
6150 }
6151 }
6152
6153 /// The ::drag-data-received signal is emitted on the drop site when the
6154 /// dragged data has been received. If the data was received in order to
6155 /// determine whether the drop will be accepted, the handler is expected
6156 /// to call `gdk_drag_status()` and not finish the drag.
6157 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
6158 /// (and this is the last target to be received), the handler for this
6159 /// signal is expected to process the received data and then call
6160 /// `gtk_drag_finish()`, setting the `success` parameter depending on
6161 /// whether the data was processed successfully.
6162 ///
6163 /// Applications must create some means to determine why the signal was emitted
6164 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
6165 ///
6166 /// The handler may inspect the selected action with
6167 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
6168 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
6169 /// shown in the following example:
6170 ///
6171 ///
6172 /// **⚠️ The following code is in C ⚠️**
6173 ///
6174 /// ```C
6175 /// void
6176 /// drag_data_received (GtkWidget *widget,
6177 /// GdkDragContext *context,
6178 /// gint x,
6179 /// gint y,
6180 /// GtkSelectionData *data,
6181 /// guint info,
6182 /// guint time)
6183 /// {
6184 /// if ((data->length >= 0) && (data->format == 8))
6185 /// {
6186 /// GdkDragAction action;
6187 ///
6188 /// // handle data here
6189 ///
6190 /// action = gdk_drag_context_get_selected_action (context);
6191 /// if (action == GDK_ACTION_ASK)
6192 /// {
6193 /// GtkWidget *dialog;
6194 /// gint response;
6195 ///
6196 /// dialog = gtk_message_dialog_new (NULL,
6197 /// GTK_DIALOG_MODAL |
6198 /// GTK_DIALOG_DESTROY_WITH_PARENT,
6199 /// GTK_MESSAGE_INFO,
6200 /// GTK_BUTTONS_YES_NO,
6201 /// "Move the data ?\n");
6202 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
6203 /// gtk_widget_destroy (dialog);
6204 ///
6205 /// if (response == GTK_RESPONSE_YES)
6206 /// action = GDK_ACTION_MOVE;
6207 /// else
6208 /// action = GDK_ACTION_COPY;
6209 /// }
6210 ///
6211 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
6212 /// }
6213 /// else
6214 /// gtk_drag_finish (context, FALSE, FALSE, time);
6215 /// }
6216 /// ```
6217 /// ## `context`
6218 /// the drag context
6219 /// ## `x`
6220 /// where the drop happened
6221 /// ## `y`
6222 /// where the drop happened
6223 /// ## `data`
6224 /// the received data
6225 /// ## `info`
6226 /// the info that has been registered with the target in the
6227 /// [`TargetList`][crate::TargetList]
6228 /// ## `time`
6229 /// the timestamp at which the data was received
6230 #[doc(alias = "drag-data-received")]
6231 fn connect_drag_data_received<
6232 F: Fn(&Self, &gdk::DragContext, i32, i32, &SelectionData, u32, u32) + 'static,
6233 >(
6234 &self,
6235 f: F,
6236 ) -> SignalHandlerId {
6237 unsafe extern "C" fn drag_data_received_trampoline<
6238 P: IsA<Widget>,
6239 F: Fn(&P, &gdk::DragContext, i32, i32, &SelectionData, u32, u32) + 'static,
6240 >(
6241 this: *mut ffi::GtkWidget,
6242 context: *mut gdk::ffi::GdkDragContext,
6243 x: libc::c_int,
6244 y: libc::c_int,
6245 data: *mut ffi::GtkSelectionData,
6246 info: libc::c_uint,
6247 time: libc::c_uint,
6248 f: glib::ffi::gpointer,
6249 ) {
6250 let f: &F = &*(f as *const F);
6251 f(
6252 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6253 &from_glib_borrow(context),
6254 x,
6255 y,
6256 &from_glib_borrow(data),
6257 info,
6258 time,
6259 )
6260 }
6261 unsafe {
6262 let f: Box_<F> = Box_::new(f);
6263 connect_raw(
6264 self.as_ptr() as *mut _,
6265 b"drag-data-received\0".as_ptr() as *const _,
6266 Some(transmute::<_, unsafe extern "C" fn()>(
6267 drag_data_received_trampoline::<Self, F> as *const (),
6268 )),
6269 Box_::into_raw(f),
6270 )
6271 }
6272 }
6273
6274 /// The ::drag-drop signal is emitted on the drop site when the user drops
6275 /// the data onto the widget. The signal handler must determine whether
6276 /// the cursor position is in a drop zone or not. If it is not in a drop
6277 /// zone, it returns [`false`] and no further processing is necessary.
6278 /// Otherwise, the handler returns [`true`]. In this case, the handler must
6279 /// ensure that `gtk_drag_finish()` is called to let the source know that
6280 /// the drop is done. The call to `gtk_drag_finish()` can be done either
6281 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
6282 /// triggered by calling [`drag_get_data()`][Self::drag_get_data()] to receive the data for one
6283 /// or more of the supported targets.
6284 /// ## `context`
6285 /// the drag context
6286 /// ## `x`
6287 /// the x coordinate of the current cursor position
6288 /// ## `y`
6289 /// the y coordinate of the current cursor position
6290 /// ## `time`
6291 /// the timestamp of the motion event
6292 ///
6293 /// # Returns
6294 ///
6295 /// whether the cursor position is in a drop zone
6296 #[doc(alias = "drag-drop")]
6297 fn connect_drag_drop<F: Fn(&Self, &gdk::DragContext, i32, i32, u32) -> bool + 'static>(
6298 &self,
6299 f: F,
6300 ) -> SignalHandlerId {
6301 unsafe extern "C" fn drag_drop_trampoline<
6302 P: IsA<Widget>,
6303 F: Fn(&P, &gdk::DragContext, i32, i32, u32) -> bool + 'static,
6304 >(
6305 this: *mut ffi::GtkWidget,
6306 context: *mut gdk::ffi::GdkDragContext,
6307 x: libc::c_int,
6308 y: libc::c_int,
6309 time: libc::c_uint,
6310 f: glib::ffi::gpointer,
6311 ) -> glib::ffi::gboolean {
6312 let f: &F = &*(f as *const F);
6313 f(
6314 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6315 &from_glib_borrow(context),
6316 x,
6317 y,
6318 time,
6319 )
6320 .into_glib()
6321 }
6322 unsafe {
6323 let f: Box_<F> = Box_::new(f);
6324 connect_raw(
6325 self.as_ptr() as *mut _,
6326 b"drag-drop\0".as_ptr() as *const _,
6327 Some(transmute::<_, unsafe extern "C" fn()>(
6328 drag_drop_trampoline::<Self, F> as *const (),
6329 )),
6330 Box_::into_raw(f),
6331 )
6332 }
6333 }
6334
6335 /// The ::drag-end signal is emitted on the drag source when a drag is
6336 /// finished. A typical reason to connect to this signal is to undo
6337 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
6338 /// ## `context`
6339 /// the drag context
6340 #[doc(alias = "drag-end")]
6341 fn connect_drag_end<F: Fn(&Self, &gdk::DragContext) + 'static>(&self, f: F) -> SignalHandlerId {
6342 unsafe extern "C" fn drag_end_trampoline<
6343 P: IsA<Widget>,
6344 F: Fn(&P, &gdk::DragContext) + 'static,
6345 >(
6346 this: *mut ffi::GtkWidget,
6347 context: *mut gdk::ffi::GdkDragContext,
6348 f: glib::ffi::gpointer,
6349 ) {
6350 let f: &F = &*(f as *const F);
6351 f(
6352 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6353 &from_glib_borrow(context),
6354 )
6355 }
6356 unsafe {
6357 let f: Box_<F> = Box_::new(f);
6358 connect_raw(
6359 self.as_ptr() as *mut _,
6360 b"drag-end\0".as_ptr() as *const _,
6361 Some(transmute::<_, unsafe extern "C" fn()>(
6362 drag_end_trampoline::<Self, F> as *const (),
6363 )),
6364 Box_::into_raw(f),
6365 )
6366 }
6367 }
6368
6369 /// The ::drag-failed signal is emitted on the drag source when a drag has
6370 /// failed. The signal handler may hook custom code to handle a failed DnD
6371 /// operation based on the type of error, it returns [`true`] is the failure has
6372 /// been already handled (not showing the default "drag operation failed"
6373 /// animation), otherwise it returns [`false`].
6374 /// ## `context`
6375 /// the drag context
6376 /// ## `result`
6377 /// the result of the drag operation
6378 ///
6379 /// # Returns
6380 ///
6381 /// [`true`] if the failed drag operation has been already handled.
6382 #[doc(alias = "drag-failed")]
6383 fn connect_drag_failed<
6384 F: Fn(&Self, &gdk::DragContext, DragResult) -> glib::Propagation + 'static,
6385 >(
6386 &self,
6387 f: F,
6388 ) -> SignalHandlerId {
6389 unsafe extern "C" fn drag_failed_trampoline<
6390 P: IsA<Widget>,
6391 F: Fn(&P, &gdk::DragContext, DragResult) -> glib::Propagation + 'static,
6392 >(
6393 this: *mut ffi::GtkWidget,
6394 context: *mut gdk::ffi::GdkDragContext,
6395 result: ffi::GtkDragResult,
6396 f: glib::ffi::gpointer,
6397 ) -> glib::ffi::gboolean {
6398 let f: &F = &*(f as *const F);
6399 f(
6400 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6401 &from_glib_borrow(context),
6402 from_glib(result),
6403 )
6404 .into_glib()
6405 }
6406 unsafe {
6407 let f: Box_<F> = Box_::new(f);
6408 connect_raw(
6409 self.as_ptr() as *mut _,
6410 b"drag-failed\0".as_ptr() as *const _,
6411 Some(transmute::<_, unsafe extern "C" fn()>(
6412 drag_failed_trampoline::<Self, F> as *const (),
6413 )),
6414 Box_::into_raw(f),
6415 )
6416 }
6417 }
6418
6419 /// The ::drag-leave signal is emitted on the drop site when the cursor
6420 /// leaves the widget. A typical reason to connect to this signal is to
6421 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
6422 /// with [`drag_unhighlight()`][Self::drag_unhighlight()].
6423 ///
6424 ///
6425 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
6426 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
6427 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
6428 /// ## `context`
6429 /// the drag context
6430 /// ## `time`
6431 /// the timestamp of the motion event
6432 #[doc(alias = "drag-leave")]
6433 fn connect_drag_leave<F: Fn(&Self, &gdk::DragContext, u32) + 'static>(
6434 &self,
6435 f: F,
6436 ) -> SignalHandlerId {
6437 unsafe extern "C" fn drag_leave_trampoline<
6438 P: IsA<Widget>,
6439 F: Fn(&P, &gdk::DragContext, u32) + 'static,
6440 >(
6441 this: *mut ffi::GtkWidget,
6442 context: *mut gdk::ffi::GdkDragContext,
6443 time: libc::c_uint,
6444 f: glib::ffi::gpointer,
6445 ) {
6446 let f: &F = &*(f as *const F);
6447 f(
6448 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6449 &from_glib_borrow(context),
6450 time,
6451 )
6452 }
6453 unsafe {
6454 let f: Box_<F> = Box_::new(f);
6455 connect_raw(
6456 self.as_ptr() as *mut _,
6457 b"drag-leave\0".as_ptr() as *const _,
6458 Some(transmute::<_, unsafe extern "C" fn()>(
6459 drag_leave_trampoline::<Self, F> as *const (),
6460 )),
6461 Box_::into_raw(f),
6462 )
6463 }
6464 }
6465
6466 /// The ::drag-motion signal is emitted on the drop site when the user
6467 /// moves the cursor over the widget during a drag. The signal handler
6468 /// must determine whether the cursor position is in a drop zone or not.
6469 /// If it is not in a drop zone, it returns [`false`] and no further processing
6470 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
6471 /// handler is responsible for providing the necessary information for
6472 /// displaying feedback to the user, by calling `gdk_drag_status()`.
6473 ///
6474 /// If the decision whether the drop will be accepted or rejected can't be
6475 /// made based solely on the cursor position and the type of the data, the
6476 /// handler may inspect the dragged data by calling [`drag_get_data()`][Self::drag_get_data()] and
6477 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
6478 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
6479 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
6480 /// when using the drag-motion signal that way.
6481 ///
6482 /// Also note that there is no drag-enter signal. The drag receiver has to
6483 /// keep track of whether he has received any drag-motion signals since the
6484 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
6485 /// an "enter" signal. Upon an "enter", the handler will typically highlight
6486 /// the drop site with [`drag_highlight()`][Self::drag_highlight()].
6487 ///
6488 ///
6489 /// **⚠️ The following code is in C ⚠️**
6490 ///
6491 /// ```C
6492 /// static void
6493 /// drag_motion (GtkWidget *widget,
6494 /// GdkDragContext *context,
6495 /// gint x,
6496 /// gint y,
6497 /// guint time)
6498 /// {
6499 /// GdkAtom target;
6500 ///
6501 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
6502 ///
6503 /// if (!private_data->drag_highlight)
6504 /// {
6505 /// private_data->drag_highlight = 1;
6506 /// gtk_drag_highlight (widget);
6507 /// }
6508 ///
6509 /// target = gtk_drag_dest_find_target (widget, context, NULL);
6510 /// if (target == GDK_NONE)
6511 /// gdk_drag_status (context, 0, time);
6512 /// else
6513 /// {
6514 /// private_data->pending_status
6515 /// = gdk_drag_context_get_suggested_action (context);
6516 /// gtk_drag_get_data (widget, context, target, time);
6517 /// }
6518 ///
6519 /// return TRUE;
6520 /// }
6521 ///
6522 /// static void
6523 /// drag_data_received (GtkWidget *widget,
6524 /// GdkDragContext *context,
6525 /// gint x,
6526 /// gint y,
6527 /// GtkSelectionData *selection_data,
6528 /// guint info,
6529 /// guint time)
6530 /// {
6531 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
6532 ///
6533 /// if (private_data->suggested_action)
6534 /// {
6535 /// private_data->suggested_action = 0;
6536 ///
6537 /// // We are getting this data due to a request in drag_motion,
6538 /// // rather than due to a request in drag_drop, so we are just
6539 /// // supposed to call gdk_drag_status(), not actually paste in
6540 /// // the data.
6541 ///
6542 /// str = gtk_selection_data_get_text (selection_data);
6543 /// if (!data_is_acceptable (str))
6544 /// gdk_drag_status (context, 0, time);
6545 /// else
6546 /// gdk_drag_status (context,
6547 /// private_data->suggested_action,
6548 /// time);
6549 /// }
6550 /// else
6551 /// {
6552 /// // accept the drop
6553 /// }
6554 /// }
6555 /// ```
6556 /// ## `context`
6557 /// the drag context
6558 /// ## `x`
6559 /// the x coordinate of the current cursor position
6560 /// ## `y`
6561 /// the y coordinate of the current cursor position
6562 /// ## `time`
6563 /// the timestamp of the motion event
6564 ///
6565 /// # Returns
6566 ///
6567 /// whether the cursor position is in a drop zone
6568 #[doc(alias = "drag-motion")]
6569 fn connect_drag_motion<F: Fn(&Self, &gdk::DragContext, i32, i32, u32) -> bool + 'static>(
6570 &self,
6571 f: F,
6572 ) -> SignalHandlerId {
6573 unsafe extern "C" fn drag_motion_trampoline<
6574 P: IsA<Widget>,
6575 F: Fn(&P, &gdk::DragContext, i32, i32, u32) -> bool + 'static,
6576 >(
6577 this: *mut ffi::GtkWidget,
6578 context: *mut gdk::ffi::GdkDragContext,
6579 x: libc::c_int,
6580 y: libc::c_int,
6581 time: libc::c_uint,
6582 f: glib::ffi::gpointer,
6583 ) -> glib::ffi::gboolean {
6584 let f: &F = &*(f as *const F);
6585 f(
6586 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6587 &from_glib_borrow(context),
6588 x,
6589 y,
6590 time,
6591 )
6592 .into_glib()
6593 }
6594 unsafe {
6595 let f: Box_<F> = Box_::new(f);
6596 connect_raw(
6597 self.as_ptr() as *mut _,
6598 b"drag-motion\0".as_ptr() as *const _,
6599 Some(transmute::<_, unsafe extern "C" fn()>(
6600 drag_motion_trampoline::<Self, F> as *const (),
6601 )),
6602 Box_::into_raw(f),
6603 )
6604 }
6605 }
6606
6607 /// This signal is emitted when a widget is supposed to render itself.
6608 /// The `widget`'s top left corner must be painted at the origin of
6609 /// the passed in context and be sized to the values returned by
6610 /// [`allocated_width()`][Self::allocated_width()] and
6611 /// [`allocated_height()`][Self::allocated_height()].
6612 ///
6613 /// Signal handlers connected to this signal can modify the cairo
6614 /// context passed as `cr` in any way they like and don't need to
6615 /// restore it. The signal emission takes care of calling `cairo_save()`
6616 /// before and `cairo_restore()` after invoking the handler.
6617 ///
6618 /// The signal handler will get a `cr` with a clip region already set to the
6619 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
6620 /// widgets that want to avoid redrawing themselves completely can get the full
6621 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
6622 /// get a finer-grained representation of the dirty region with
6623 /// `cairo_copy_clip_rectangle_list()`.
6624 /// ## `cr`
6625 /// the cairo context to draw to
6626 ///
6627 /// # Returns
6628 ///
6629 /// [`true`] to stop other handlers from being invoked for the event.
6630 /// [`false`] to propagate the event further.
6631 #[doc(alias = "draw")]
6632 fn connect_draw<F: Fn(&Self, &cairo::Context) -> glib::Propagation + 'static>(
6633 &self,
6634 f: F,
6635 ) -> SignalHandlerId {
6636 unsafe extern "C" fn draw_trampoline<
6637 P: IsA<Widget>,
6638 F: Fn(&P, &cairo::Context) -> glib::Propagation + 'static,
6639 >(
6640 this: *mut ffi::GtkWidget,
6641 cr: *mut cairo::ffi::cairo_t,
6642 f: glib::ffi::gpointer,
6643 ) -> glib::ffi::gboolean {
6644 let f: &F = &*(f as *const F);
6645 f(
6646 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6647 &from_glib_borrow(cr),
6648 )
6649 .into_glib()
6650 }
6651 unsafe {
6652 let f: Box_<F> = Box_::new(f);
6653 connect_raw(
6654 self.as_ptr() as *mut _,
6655 b"draw\0".as_ptr() as *const _,
6656 Some(transmute::<_, unsafe extern "C" fn()>(
6657 draw_trampoline::<Self, F> as *const (),
6658 )),
6659 Box_::into_raw(f),
6660 )
6661 }
6662 }
6663
6664 /// The ::enter-notify-event will be emitted when the pointer enters
6665 /// the `widget`'s window.
6666 ///
6667 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6668 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
6669 ///
6670 /// This signal will be sent to the grab widget if there is one.
6671 /// ## `event`
6672 /// the [`gdk::EventCrossing`][crate::gdk::EventCrossing] which triggered
6673 /// this signal.
6674 ///
6675 /// # Returns
6676 ///
6677 /// [`true`] to stop other handlers from being invoked for the event.
6678 /// [`false`] to propagate the event further.
6679 #[doc(alias = "enter-notify-event")]
6680 fn connect_enter_notify_event<
6681 F: Fn(&Self, &gdk::EventCrossing) -> glib::Propagation + 'static,
6682 >(
6683 &self,
6684 f: F,
6685 ) -> SignalHandlerId {
6686 unsafe extern "C" fn enter_notify_event_trampoline<
6687 P: IsA<Widget>,
6688 F: Fn(&P, &gdk::EventCrossing) -> glib::Propagation + 'static,
6689 >(
6690 this: *mut ffi::GtkWidget,
6691 event: *mut gdk::ffi::GdkEventCrossing,
6692 f: glib::ffi::gpointer,
6693 ) -> glib::ffi::gboolean {
6694 let f: &F = &*(f as *const F);
6695 f(
6696 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6697 &from_glib_borrow(event),
6698 )
6699 .into_glib()
6700 }
6701 unsafe {
6702 let f: Box_<F> = Box_::new(f);
6703 connect_raw(
6704 self.as_ptr() as *mut _,
6705 b"enter-notify-event\0".as_ptr() as *const _,
6706 Some(transmute::<_, unsafe extern "C" fn()>(
6707 enter_notify_event_trampoline::<Self, F> as *const (),
6708 )),
6709 Box_::into_raw(f),
6710 )
6711 }
6712 }
6713
6714 /// The GTK+ main loop will emit three signals for each GDK event delivered
6715 /// to a widget: one generic ::event signal, another, more specific,
6716 /// signal that matches the type of event delivered (e.g.
6717 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
6718 /// [`event-after`][struct@crate::Widget#event-after] signal.
6719 /// ## `event`
6720 /// the `GdkEvent` which triggered this signal
6721 ///
6722 /// # Returns
6723 ///
6724 /// [`true`] to stop other handlers from being invoked for the event
6725 /// and to cancel the emission of the second specific ::event signal.
6726 /// [`false`] to propagate the event further and to allow the emission of
6727 /// the second signal. The ::event-after signal is emitted regardless of
6728 /// the return value.
6729 #[doc(alias = "event")]
6730 fn connect_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
6731 &self,
6732 f: F,
6733 ) -> SignalHandlerId {
6734 unsafe extern "C" fn event_trampoline<
6735 P: IsA<Widget>,
6736 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
6737 >(
6738 this: *mut ffi::GtkWidget,
6739 event: *mut gdk::ffi::GdkEvent,
6740 f: glib::ffi::gpointer,
6741 ) -> glib::ffi::gboolean {
6742 let f: &F = &*(f as *const F);
6743 f(
6744 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6745 &from_glib_none(event),
6746 )
6747 .into_glib()
6748 }
6749 unsafe {
6750 let f: Box_<F> = Box_::new(f);
6751 connect_raw(
6752 self.as_ptr() as *mut _,
6753 b"event\0".as_ptr() as *const _,
6754 Some(transmute::<_, unsafe extern "C" fn()>(
6755 event_trampoline::<Self, F> as *const (),
6756 )),
6757 Box_::into_raw(f),
6758 )
6759 }
6760 }
6761
6762 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
6763 /// the second more specific signal, ::event-after will be emitted
6764 /// regardless of the previous two signals handlers return values.
6765 /// ## `event`
6766 /// the `GdkEvent` which triggered this signal
6767 #[doc(alias = "event-after")]
6768 fn connect_event_after<F: Fn(&Self, &gdk::Event) + 'static>(&self, f: F) -> SignalHandlerId {
6769 unsafe extern "C" fn event_after_trampoline<
6770 P: IsA<Widget>,
6771 F: Fn(&P, &gdk::Event) + 'static,
6772 >(
6773 this: *mut ffi::GtkWidget,
6774 event: *mut gdk::ffi::GdkEvent,
6775 f: glib::ffi::gpointer,
6776 ) {
6777 let f: &F = &*(f as *const F);
6778 f(
6779 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6780 &from_glib_none(event),
6781 )
6782 }
6783 unsafe {
6784 let f: Box_<F> = Box_::new(f);
6785 connect_raw(
6786 self.as_ptr() as *mut _,
6787 b"event-after\0".as_ptr() as *const _,
6788 Some(transmute::<_, unsafe extern "C" fn()>(
6789 event_after_trampoline::<Self, F> as *const (),
6790 )),
6791 Box_::into_raw(f),
6792 )
6793 }
6794 }
6795
6796 ///
6797 /// # Returns
6798 ///
6799 /// [`true`] to stop other handlers from being invoked for the event. [`false`] to propagate the event further.
6800 #[doc(alias = "focus")]
6801 fn connect_focus<F: Fn(&Self, DirectionType) -> glib::Propagation + 'static>(
6802 &self,
6803 f: F,
6804 ) -> SignalHandlerId {
6805 unsafe extern "C" fn focus_trampoline<
6806 P: IsA<Widget>,
6807 F: Fn(&P, DirectionType) -> glib::Propagation + 'static,
6808 >(
6809 this: *mut ffi::GtkWidget,
6810 direction: ffi::GtkDirectionType,
6811 f: glib::ffi::gpointer,
6812 ) -> glib::ffi::gboolean {
6813 let f: &F = &*(f as *const F);
6814 f(
6815 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6816 from_glib(direction),
6817 )
6818 .into_glib()
6819 }
6820 unsafe {
6821 let f: Box_<F> = Box_::new(f);
6822 connect_raw(
6823 self.as_ptr() as *mut _,
6824 b"focus\0".as_ptr() as *const _,
6825 Some(transmute::<_, unsafe extern "C" fn()>(
6826 focus_trampoline::<Self, F> as *const (),
6827 )),
6828 Box_::into_raw(f),
6829 )
6830 }
6831 }
6832
6833 /// The ::focus-in-event signal will be emitted when the keyboard focus
6834 /// enters the `widget`'s window.
6835 ///
6836 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6837 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
6838 /// ## `event`
6839 /// the [`gdk::EventFocus`][crate::gdk::EventFocus] which triggered
6840 /// this signal.
6841 ///
6842 /// # Returns
6843 ///
6844 /// [`true`] to stop other handlers from being invoked for the event.
6845 /// [`false`] to propagate the event further.
6846 #[doc(alias = "focus-in-event")]
6847 fn connect_focus_in_event<F: Fn(&Self, &gdk::EventFocus) -> glib::Propagation + 'static>(
6848 &self,
6849 f: F,
6850 ) -> SignalHandlerId {
6851 unsafe extern "C" fn focus_in_event_trampoline<
6852 P: IsA<Widget>,
6853 F: Fn(&P, &gdk::EventFocus) -> glib::Propagation + 'static,
6854 >(
6855 this: *mut ffi::GtkWidget,
6856 event: *mut gdk::ffi::GdkEventFocus,
6857 f: glib::ffi::gpointer,
6858 ) -> glib::ffi::gboolean {
6859 let f: &F = &*(f as *const F);
6860 f(
6861 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6862 &from_glib_borrow(event),
6863 )
6864 .into_glib()
6865 }
6866 unsafe {
6867 let f: Box_<F> = Box_::new(f);
6868 connect_raw(
6869 self.as_ptr() as *mut _,
6870 b"focus-in-event\0".as_ptr() as *const _,
6871 Some(transmute::<_, unsafe extern "C" fn()>(
6872 focus_in_event_trampoline::<Self, F> as *const (),
6873 )),
6874 Box_::into_raw(f),
6875 )
6876 }
6877 }
6878
6879 /// The ::focus-out-event signal will be emitted when the keyboard focus
6880 /// leaves the `widget`'s window.
6881 ///
6882 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6883 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
6884 /// ## `event`
6885 /// the [`gdk::EventFocus`][crate::gdk::EventFocus] which triggered this
6886 /// signal.
6887 ///
6888 /// # Returns
6889 ///
6890 /// [`true`] to stop other handlers from being invoked for the event.
6891 /// [`false`] to propagate the event further.
6892 #[doc(alias = "focus-out-event")]
6893 fn connect_focus_out_event<F: Fn(&Self, &gdk::EventFocus) -> glib::Propagation + 'static>(
6894 &self,
6895 f: F,
6896 ) -> SignalHandlerId {
6897 unsafe extern "C" fn focus_out_event_trampoline<
6898 P: IsA<Widget>,
6899 F: Fn(&P, &gdk::EventFocus) -> glib::Propagation + 'static,
6900 >(
6901 this: *mut ffi::GtkWidget,
6902 event: *mut gdk::ffi::GdkEventFocus,
6903 f: glib::ffi::gpointer,
6904 ) -> glib::ffi::gboolean {
6905 let f: &F = &*(f as *const F);
6906 f(
6907 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6908 &from_glib_borrow(event),
6909 )
6910 .into_glib()
6911 }
6912 unsafe {
6913 let f: Box_<F> = Box_::new(f);
6914 connect_raw(
6915 self.as_ptr() as *mut _,
6916 b"focus-out-event\0".as_ptr() as *const _,
6917 Some(transmute::<_, unsafe extern "C" fn()>(
6918 focus_out_event_trampoline::<Self, F> as *const (),
6919 )),
6920 Box_::into_raw(f),
6921 )
6922 }
6923 }
6924
6925 /// Emitted when a pointer or keyboard grab on a window belonging
6926 /// to `widget` gets broken.
6927 ///
6928 /// On X11, this happens when the grab window becomes unviewable
6929 /// (i.e. it or one of its ancestors is unmapped), or if the same
6930 /// application grabs the pointer or keyboard again.
6931 /// ## `event`
6932 /// the [`gdk::EventGrabBroken`][crate::gdk::EventGrabBroken] event
6933 ///
6934 /// # Returns
6935 ///
6936 /// [`true`] to stop other handlers from being invoked for
6937 /// the event. [`false`] to propagate the event further.
6938 #[doc(alias = "grab-broken-event")]
6939 fn connect_grab_broken_event<
6940 F: Fn(&Self, &gdk::EventGrabBroken) -> glib::Propagation + 'static,
6941 >(
6942 &self,
6943 f: F,
6944 ) -> SignalHandlerId {
6945 unsafe extern "C" fn grab_broken_event_trampoline<
6946 P: IsA<Widget>,
6947 F: Fn(&P, &gdk::EventGrabBroken) -> glib::Propagation + 'static,
6948 >(
6949 this: *mut ffi::GtkWidget,
6950 event: *mut gdk::ffi::GdkEventGrabBroken,
6951 f: glib::ffi::gpointer,
6952 ) -> glib::ffi::gboolean {
6953 let f: &F = &*(f as *const F);
6954 f(
6955 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6956 &from_glib_borrow(event),
6957 )
6958 .into_glib()
6959 }
6960 unsafe {
6961 let f: Box_<F> = Box_::new(f);
6962 connect_raw(
6963 self.as_ptr() as *mut _,
6964 b"grab-broken-event\0".as_ptr() as *const _,
6965 Some(transmute::<_, unsafe extern "C" fn()>(
6966 grab_broken_event_trampoline::<Self, F> as *const (),
6967 )),
6968 Box_::into_raw(f),
6969 )
6970 }
6971 }
6972
6973 #[doc(alias = "grab-focus")]
6974 fn connect_grab_focus<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
6975 unsafe extern "C" fn grab_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
6976 this: *mut ffi::GtkWidget,
6977 f: glib::ffi::gpointer,
6978 ) {
6979 let f: &F = &*(f as *const F);
6980 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
6981 }
6982 unsafe {
6983 let f: Box_<F> = Box_::new(f);
6984 connect_raw(
6985 self.as_ptr() as *mut _,
6986 b"grab-focus\0".as_ptr() as *const _,
6987 Some(transmute::<_, unsafe extern "C" fn()>(
6988 grab_focus_trampoline::<Self, F> as *const (),
6989 )),
6990 Box_::into_raw(f),
6991 )
6992 }
6993 }
6994
6995 fn emit_grab_focus(&self) {
6996 self.emit_by_name::<()>("grab-focus", &[]);
6997 }
6998
6999 /// The ::grab-notify signal is emitted when a widget becomes
7000 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
7001 /// another widget, or when it becomes unshadowed due to a grab
7002 /// being removed.
7003 ///
7004 /// A widget is shadowed by a [`grab_add()`][Self::grab_add()] when the topmost
7005 /// grab widget in the grab stack of its window group is not
7006 /// its ancestor.
7007 /// ## `was_grabbed`
7008 /// [`false`] if the widget becomes shadowed, [`true`]
7009 /// if it becomes unshadowed
7010 #[doc(alias = "grab-notify")]
7011 fn connect_grab_notify<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
7012 unsafe extern "C" fn grab_notify_trampoline<P: IsA<Widget>, F: Fn(&P, bool) + 'static>(
7013 this: *mut ffi::GtkWidget,
7014 was_grabbed: glib::ffi::gboolean,
7015 f: glib::ffi::gpointer,
7016 ) {
7017 let f: &F = &*(f as *const F);
7018 f(
7019 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7020 from_glib(was_grabbed),
7021 )
7022 }
7023 unsafe {
7024 let f: Box_<F> = Box_::new(f);
7025 connect_raw(
7026 self.as_ptr() as *mut _,
7027 b"grab-notify\0".as_ptr() as *const _,
7028 Some(transmute::<_, unsafe extern "C" fn()>(
7029 grab_notify_trampoline::<Self, F> as *const (),
7030 )),
7031 Box_::into_raw(f),
7032 )
7033 }
7034 }
7035
7036 /// The ::hide signal is emitted when `widget` is hidden, for example with
7037 /// [`hide()`][Self::hide()].
7038 #[doc(alias = "hide")]
7039 fn connect_hide<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7040 unsafe extern "C" fn hide_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7041 this: *mut ffi::GtkWidget,
7042 f: glib::ffi::gpointer,
7043 ) {
7044 let f: &F = &*(f as *const F);
7045 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7046 }
7047 unsafe {
7048 let f: Box_<F> = Box_::new(f);
7049 connect_raw(
7050 self.as_ptr() as *mut _,
7051 b"hide\0".as_ptr() as *const _,
7052 Some(transmute::<_, unsafe extern "C" fn()>(
7053 hide_trampoline::<Self, F> as *const (),
7054 )),
7055 Box_::into_raw(f),
7056 )
7057 }
7058 }
7059
7060 /// The ::hierarchy-changed signal is emitted when the
7061 /// anchored state of a widget changes. A widget is
7062 /// “anchored” when its toplevel
7063 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
7064 /// a widget changes from un-anchored to anchored or vice-versa.
7065 /// ## `previous_toplevel`
7066 /// the previous toplevel ancestor, or [`None`]
7067 /// if the widget was previously unanchored
7068 #[doc(alias = "hierarchy-changed")]
7069 fn connect_hierarchy_changed<F: Fn(&Self, Option<&Widget>) + 'static>(
7070 &self,
7071 f: F,
7072 ) -> SignalHandlerId {
7073 unsafe extern "C" fn hierarchy_changed_trampoline<
7074 P: IsA<Widget>,
7075 F: Fn(&P, Option<&Widget>) + 'static,
7076 >(
7077 this: *mut ffi::GtkWidget,
7078 previous_toplevel: *mut ffi::GtkWidget,
7079 f: glib::ffi::gpointer,
7080 ) {
7081 let f: &F = &*(f as *const F);
7082 f(
7083 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7084 Option::<Widget>::from_glib_borrow(previous_toplevel)
7085 .as_ref()
7086 .as_ref(),
7087 )
7088 }
7089 unsafe {
7090 let f: Box_<F> = Box_::new(f);
7091 connect_raw(
7092 self.as_ptr() as *mut _,
7093 b"hierarchy-changed\0".as_ptr() as *const _,
7094 Some(transmute::<_, unsafe extern "C" fn()>(
7095 hierarchy_changed_trampoline::<Self, F> as *const (),
7096 )),
7097 Box_::into_raw(f),
7098 )
7099 }
7100 }
7101
7102 /// The ::key-press-event signal is emitted when a key is pressed. The signal
7103 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
7104 ///
7105 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7106 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
7107 ///
7108 /// This signal will be sent to the grab widget if there is one.
7109 /// ## `event`
7110 /// the [`gdk::EventKey`][crate::gdk::EventKey] which triggered this signal.
7111 ///
7112 /// # Returns
7113 ///
7114 /// [`true`] to stop other handlers from being invoked for the event.
7115 /// [`false`] to propagate the event further.
7116 #[doc(alias = "key-press-event")]
7117 fn connect_key_press_event<F: Fn(&Self, &gdk::EventKey) -> glib::Propagation + 'static>(
7118 &self,
7119 f: F,
7120 ) -> SignalHandlerId {
7121 unsafe extern "C" fn key_press_event_trampoline<
7122 P: IsA<Widget>,
7123 F: Fn(&P, &gdk::EventKey) -> glib::Propagation + 'static,
7124 >(
7125 this: *mut ffi::GtkWidget,
7126 event: *mut gdk::ffi::GdkEventKey,
7127 f: glib::ffi::gpointer,
7128 ) -> glib::ffi::gboolean {
7129 let f: &F = &*(f as *const F);
7130 f(
7131 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7132 &from_glib_borrow(event),
7133 )
7134 .into_glib()
7135 }
7136 unsafe {
7137 let f: Box_<F> = Box_::new(f);
7138 connect_raw(
7139 self.as_ptr() as *mut _,
7140 b"key-press-event\0".as_ptr() as *const _,
7141 Some(transmute::<_, unsafe extern "C" fn()>(
7142 key_press_event_trampoline::<Self, F> as *const (),
7143 )),
7144 Box_::into_raw(f),
7145 )
7146 }
7147 }
7148
7149 /// The ::key-release-event signal is emitted when a key is released.
7150 ///
7151 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7152 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
7153 ///
7154 /// This signal will be sent to the grab widget if there is one.
7155 /// ## `event`
7156 /// the [`gdk::EventKey`][crate::gdk::EventKey] which triggered this signal.
7157 ///
7158 /// # Returns
7159 ///
7160 /// [`true`] to stop other handlers from being invoked for the event.
7161 /// [`false`] to propagate the event further.
7162 #[doc(alias = "key-release-event")]
7163 fn connect_key_release_event<F: Fn(&Self, &gdk::EventKey) -> glib::Propagation + 'static>(
7164 &self,
7165 f: F,
7166 ) -> SignalHandlerId {
7167 unsafe extern "C" fn key_release_event_trampoline<
7168 P: IsA<Widget>,
7169 F: Fn(&P, &gdk::EventKey) -> glib::Propagation + 'static,
7170 >(
7171 this: *mut ffi::GtkWidget,
7172 event: *mut gdk::ffi::GdkEventKey,
7173 f: glib::ffi::gpointer,
7174 ) -> glib::ffi::gboolean {
7175 let f: &F = &*(f as *const F);
7176 f(
7177 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7178 &from_glib_borrow(event),
7179 )
7180 .into_glib()
7181 }
7182 unsafe {
7183 let f: Box_<F> = Box_::new(f);
7184 connect_raw(
7185 self.as_ptr() as *mut _,
7186 b"key-release-event\0".as_ptr() as *const _,
7187 Some(transmute::<_, unsafe extern "C" fn()>(
7188 key_release_event_trampoline::<Self, F> as *const (),
7189 )),
7190 Box_::into_raw(f),
7191 )
7192 }
7193 }
7194
7195 /// Gets emitted if keyboard navigation fails.
7196 /// See [`keynav_failed()`][Self::keynav_failed()] for details.
7197 /// ## `direction`
7198 /// the direction of movement
7199 ///
7200 /// # Returns
7201 ///
7202 /// [`true`] if stopping keyboard navigation is fine, [`false`]
7203 /// if the emitting widget should try to handle the keyboard
7204 /// navigation attempt in its parent container(s).
7205 #[doc(alias = "keynav-failed")]
7206 fn connect_keynav_failed<F: Fn(&Self, DirectionType) -> glib::Propagation + 'static>(
7207 &self,
7208 f: F,
7209 ) -> SignalHandlerId {
7210 unsafe extern "C" fn keynav_failed_trampoline<
7211 P: IsA<Widget>,
7212 F: Fn(&P, DirectionType) -> glib::Propagation + 'static,
7213 >(
7214 this: *mut ffi::GtkWidget,
7215 direction: ffi::GtkDirectionType,
7216 f: glib::ffi::gpointer,
7217 ) -> glib::ffi::gboolean {
7218 let f: &F = &*(f as *const F);
7219 f(
7220 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7221 from_glib(direction),
7222 )
7223 .into_glib()
7224 }
7225 unsafe {
7226 let f: Box_<F> = Box_::new(f);
7227 connect_raw(
7228 self.as_ptr() as *mut _,
7229 b"keynav-failed\0".as_ptr() as *const _,
7230 Some(transmute::<_, unsafe extern "C" fn()>(
7231 keynav_failed_trampoline::<Self, F> as *const (),
7232 )),
7233 Box_::into_raw(f),
7234 )
7235 }
7236 }
7237
7238 /// The ::leave-notify-event will be emitted when the pointer leaves
7239 /// the `widget`'s window.
7240 ///
7241 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7242 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
7243 ///
7244 /// This signal will be sent to the grab widget if there is one.
7245 /// ## `event`
7246 /// the [`gdk::EventCrossing`][crate::gdk::EventCrossing] which triggered
7247 /// this signal.
7248 ///
7249 /// # Returns
7250 ///
7251 /// [`true`] to stop other handlers from being invoked for the event.
7252 /// [`false`] to propagate the event further.
7253 #[doc(alias = "leave-notify-event")]
7254 fn connect_leave_notify_event<
7255 F: Fn(&Self, &gdk::EventCrossing) -> glib::Propagation + 'static,
7256 >(
7257 &self,
7258 f: F,
7259 ) -> SignalHandlerId {
7260 unsafe extern "C" fn leave_notify_event_trampoline<
7261 P: IsA<Widget>,
7262 F: Fn(&P, &gdk::EventCrossing) -> glib::Propagation + 'static,
7263 >(
7264 this: *mut ffi::GtkWidget,
7265 event: *mut gdk::ffi::GdkEventCrossing,
7266 f: glib::ffi::gpointer,
7267 ) -> glib::ffi::gboolean {
7268 let f: &F = &*(f as *const F);
7269 f(
7270 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7271 &from_glib_borrow(event),
7272 )
7273 .into_glib()
7274 }
7275 unsafe {
7276 let f: Box_<F> = Box_::new(f);
7277 connect_raw(
7278 self.as_ptr() as *mut _,
7279 b"leave-notify-event\0".as_ptr() as *const _,
7280 Some(transmute::<_, unsafe extern "C" fn()>(
7281 leave_notify_event_trampoline::<Self, F> as *const (),
7282 )),
7283 Box_::into_raw(f),
7284 )
7285 }
7286 }
7287
7288 /// The ::map signal is emitted when `widget` is going to be mapped, that is
7289 /// when the widget is visible (which is controlled with
7290 /// [`set_visible()`][Self::set_visible()]) and all its parents up to the toplevel widget
7291 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
7292 /// be emitted.
7293 ///
7294 /// The ::map signal can be used to determine whether a widget will be drawn,
7295 /// for instance it can resume an animation that was stopped during the
7296 /// emission of [`unmap`][struct@crate::Widget#unmap].
7297 #[doc(alias = "map")]
7298 fn connect_map<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7299 unsafe extern "C" fn map_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7300 this: *mut ffi::GtkWidget,
7301 f: glib::ffi::gpointer,
7302 ) {
7303 let f: &F = &*(f as *const F);
7304 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7305 }
7306 unsafe {
7307 let f: Box_<F> = Box_::new(f);
7308 connect_raw(
7309 self.as_ptr() as *mut _,
7310 b"map\0".as_ptr() as *const _,
7311 Some(transmute::<_, unsafe extern "C" fn()>(
7312 map_trampoline::<Self, F> as *const (),
7313 )),
7314 Box_::into_raw(f),
7315 )
7316 }
7317 }
7318
7319 /// The default handler for this signal activates `widget` if `group_cycling`
7320 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
7321 /// ## `group_cycling`
7322 /// [`true`] if there are other widgets with the same mnemonic
7323 ///
7324 /// # Returns
7325 ///
7326 /// [`true`] to stop other handlers from being invoked for the event.
7327 /// [`false`] to propagate the event further.
7328 #[doc(alias = "mnemonic-activate")]
7329 fn connect_mnemonic_activate<F: Fn(&Self, bool) -> glib::Propagation + 'static>(
7330 &self,
7331 f: F,
7332 ) -> SignalHandlerId {
7333 unsafe extern "C" fn mnemonic_activate_trampoline<
7334 P: IsA<Widget>,
7335 F: Fn(&P, bool) -> glib::Propagation + 'static,
7336 >(
7337 this: *mut ffi::GtkWidget,
7338 group_cycling: glib::ffi::gboolean,
7339 f: glib::ffi::gpointer,
7340 ) -> glib::ffi::gboolean {
7341 let f: &F = &*(f as *const F);
7342 f(
7343 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7344 from_glib(group_cycling),
7345 )
7346 .into_glib()
7347 }
7348 unsafe {
7349 let f: Box_<F> = Box_::new(f);
7350 connect_raw(
7351 self.as_ptr() as *mut _,
7352 b"mnemonic-activate\0".as_ptr() as *const _,
7353 Some(transmute::<_, unsafe extern "C" fn()>(
7354 mnemonic_activate_trampoline::<Self, F> as *const (),
7355 )),
7356 Box_::into_raw(f),
7357 )
7358 }
7359 }
7360
7361 /// The ::motion-notify-event signal is emitted when the pointer moves
7362 /// over the widget's [`gdk::Window`][crate::gdk::Window].
7363 ///
7364 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
7365 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
7366 ///
7367 /// This signal will be sent to the grab widget if there is one.
7368 /// ## `event`
7369 /// the [`gdk::EventMotion`][crate::gdk::EventMotion] which triggered
7370 /// this signal.
7371 ///
7372 /// # Returns
7373 ///
7374 /// [`true`] to stop other handlers from being invoked for the event.
7375 /// [`false`] to propagate the event further.
7376 #[doc(alias = "motion-notify-event")]
7377 fn connect_motion_notify_event<
7378 F: Fn(&Self, &gdk::EventMotion) -> glib::Propagation + 'static,
7379 >(
7380 &self,
7381 f: F,
7382 ) -> SignalHandlerId {
7383 unsafe extern "C" fn motion_notify_event_trampoline<
7384 P: IsA<Widget>,
7385 F: Fn(&P, &gdk::EventMotion) -> glib::Propagation + 'static,
7386 >(
7387 this: *mut ffi::GtkWidget,
7388 event: *mut gdk::ffi::GdkEventMotion,
7389 f: glib::ffi::gpointer,
7390 ) -> glib::ffi::gboolean {
7391 let f: &F = &*(f as *const F);
7392 f(
7393 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7394 &from_glib_borrow(event),
7395 )
7396 .into_glib()
7397 }
7398 unsafe {
7399 let f: Box_<F> = Box_::new(f);
7400 connect_raw(
7401 self.as_ptr() as *mut _,
7402 b"motion-notify-event\0".as_ptr() as *const _,
7403 Some(transmute::<_, unsafe extern "C" fn()>(
7404 motion_notify_event_trampoline::<Self, F> as *const (),
7405 )),
7406 Box_::into_raw(f),
7407 )
7408 }
7409 }
7410
7411 #[doc(alias = "move-focus")]
7412 fn connect_move_focus<F: Fn(&Self, DirectionType) + 'static>(&self, f: F) -> SignalHandlerId {
7413 unsafe extern "C" fn move_focus_trampoline<
7414 P: IsA<Widget>,
7415 F: Fn(&P, DirectionType) + 'static,
7416 >(
7417 this: *mut ffi::GtkWidget,
7418 direction: ffi::GtkDirectionType,
7419 f: glib::ffi::gpointer,
7420 ) {
7421 let f: &F = &*(f as *const F);
7422 f(
7423 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7424 from_glib(direction),
7425 )
7426 }
7427 unsafe {
7428 let f: Box_<F> = Box_::new(f);
7429 connect_raw(
7430 self.as_ptr() as *mut _,
7431 b"move-focus\0".as_ptr() as *const _,
7432 Some(transmute::<_, unsafe extern "C" fn()>(
7433 move_focus_trampoline::<Self, F> as *const (),
7434 )),
7435 Box_::into_raw(f),
7436 )
7437 }
7438 }
7439
7440 fn emit_move_focus(&self, direction: DirectionType) {
7441 self.emit_by_name::<()>("move-focus", &[&direction]);
7442 }
7443
7444 /// The ::parent-set signal is emitted when a new parent
7445 /// has been set on a widget.
7446 /// ## `old_parent`
7447 /// the previous parent, or [`None`] if the widget
7448 /// just got its initial parent.
7449 #[doc(alias = "parent-set")]
7450 fn connect_parent_set<F: Fn(&Self, Option<&Widget>) + 'static>(&self, f: F) -> SignalHandlerId {
7451 unsafe extern "C" fn parent_set_trampoline<
7452 P: IsA<Widget>,
7453 F: Fn(&P, Option<&Widget>) + 'static,
7454 >(
7455 this: *mut ffi::GtkWidget,
7456 old_parent: *mut ffi::GtkWidget,
7457 f: glib::ffi::gpointer,
7458 ) {
7459 let f: &F = &*(f as *const F);
7460 f(
7461 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7462 Option::<Widget>::from_glib_borrow(old_parent)
7463 .as_ref()
7464 .as_ref(),
7465 )
7466 }
7467 unsafe {
7468 let f: Box_<F> = Box_::new(f);
7469 connect_raw(
7470 self.as_ptr() as *mut _,
7471 b"parent-set\0".as_ptr() as *const _,
7472 Some(transmute::<_, unsafe extern "C" fn()>(
7473 parent_set_trampoline::<Self, F> as *const (),
7474 )),
7475 Box_::into_raw(f),
7476 )
7477 }
7478 }
7479
7480 /// This signal gets emitted whenever a widget should pop up a context
7481 /// menu. This usually happens through the standard key binding mechanism;
7482 /// by pressing a certain key while a widget is focused, the user can cause
7483 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
7484 /// a menu with clipboard commands. See the
7485 /// [Popup Menu Migration Checklist][checklist-popup-menu]
7486 /// for an example of how to use this signal.
7487 ///
7488 /// # Returns
7489 ///
7490 /// [`true`] if a menu was activated
7491 #[doc(alias = "popup-menu")]
7492 fn connect_popup_menu<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
7493 unsafe extern "C" fn popup_menu_trampoline<P: IsA<Widget>, F: Fn(&P) -> bool + 'static>(
7494 this: *mut ffi::GtkWidget,
7495 f: glib::ffi::gpointer,
7496 ) -> glib::ffi::gboolean {
7497 let f: &F = &*(f as *const F);
7498 f(Widget::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
7499 }
7500 unsafe {
7501 let f: Box_<F> = Box_::new(f);
7502 connect_raw(
7503 self.as_ptr() as *mut _,
7504 b"popup-menu\0".as_ptr() as *const _,
7505 Some(transmute::<_, unsafe extern "C" fn()>(
7506 popup_menu_trampoline::<Self, F> as *const (),
7507 )),
7508 Box_::into_raw(f),
7509 )
7510 }
7511 }
7512
7513 fn emit_popup_menu(&self) -> bool {
7514 self.emit_by_name("popup-menu", &[])
7515 }
7516
7517 /// The ::property-notify-event signal will be emitted when a property on
7518 /// the `widget`'s window has been changed or deleted.
7519 ///
7520 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7521 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
7522 /// ## `event`
7523 /// the [`gdk::EventProperty`][crate::gdk::EventProperty] which triggered
7524 /// this signal.
7525 ///
7526 /// # Returns
7527 ///
7528 /// [`true`] to stop other handlers from being invoked for the event.
7529 /// [`false`] to propagate the event further.
7530 #[doc(alias = "property-notify-event")]
7531 fn connect_property_notify_event<
7532 F: Fn(&Self, &gdk::EventProperty) -> glib::Propagation + 'static,
7533 >(
7534 &self,
7535 f: F,
7536 ) -> SignalHandlerId {
7537 unsafe extern "C" fn property_notify_event_trampoline<
7538 P: IsA<Widget>,
7539 F: Fn(&P, &gdk::EventProperty) -> glib::Propagation + 'static,
7540 >(
7541 this: *mut ffi::GtkWidget,
7542 event: *mut gdk::ffi::GdkEventProperty,
7543 f: glib::ffi::gpointer,
7544 ) -> glib::ffi::gboolean {
7545 let f: &F = &*(f as *const F);
7546 f(
7547 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7548 &from_glib_borrow(event),
7549 )
7550 .into_glib()
7551 }
7552 unsafe {
7553 let f: Box_<F> = Box_::new(f);
7554 connect_raw(
7555 self.as_ptr() as *mut _,
7556 b"property-notify-event\0".as_ptr() as *const _,
7557 Some(transmute::<_, unsafe extern "C" fn()>(
7558 property_notify_event_trampoline::<Self, F> as *const (),
7559 )),
7560 Box_::into_raw(f),
7561 )
7562 }
7563 }
7564
7565 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7566 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
7567 ///
7568 /// This signal will be sent to the grab widget if there is one.
7569 /// ## `event`
7570 /// the [`gdk::EventProximity`][crate::gdk::EventProximity] which triggered
7571 /// this signal.
7572 ///
7573 /// # Returns
7574 ///
7575 /// [`true`] to stop other handlers from being invoked for the event.
7576 /// [`false`] to propagate the event further.
7577 #[doc(alias = "proximity-in-event")]
7578 fn connect_proximity_in_event<
7579 F: Fn(&Self, &gdk::EventProximity) -> glib::Propagation + 'static,
7580 >(
7581 &self,
7582 f: F,
7583 ) -> SignalHandlerId {
7584 unsafe extern "C" fn proximity_in_event_trampoline<
7585 P: IsA<Widget>,
7586 F: Fn(&P, &gdk::EventProximity) -> glib::Propagation + 'static,
7587 >(
7588 this: *mut ffi::GtkWidget,
7589 event: *mut gdk::ffi::GdkEventProximity,
7590 f: glib::ffi::gpointer,
7591 ) -> glib::ffi::gboolean {
7592 let f: &F = &*(f as *const F);
7593 f(
7594 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7595 &from_glib_borrow(event),
7596 )
7597 .into_glib()
7598 }
7599 unsafe {
7600 let f: Box_<F> = Box_::new(f);
7601 connect_raw(
7602 self.as_ptr() as *mut _,
7603 b"proximity-in-event\0".as_ptr() as *const _,
7604 Some(transmute::<_, unsafe extern "C" fn()>(
7605 proximity_in_event_trampoline::<Self, F> as *const (),
7606 )),
7607 Box_::into_raw(f),
7608 )
7609 }
7610 }
7611
7612 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7613 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
7614 ///
7615 /// This signal will be sent to the grab widget if there is one.
7616 /// ## `event`
7617 /// the [`gdk::EventProximity`][crate::gdk::EventProximity] which triggered
7618 /// this signal.
7619 ///
7620 /// # Returns
7621 ///
7622 /// [`true`] to stop other handlers from being invoked for the event.
7623 /// [`false`] to propagate the event further.
7624 #[doc(alias = "proximity-out-event")]
7625 fn connect_proximity_out_event<
7626 F: Fn(&Self, &gdk::EventProximity) -> glib::Propagation + 'static,
7627 >(
7628 &self,
7629 f: F,
7630 ) -> SignalHandlerId {
7631 unsafe extern "C" fn proximity_out_event_trampoline<
7632 P: IsA<Widget>,
7633 F: Fn(&P, &gdk::EventProximity) -> glib::Propagation + 'static,
7634 >(
7635 this: *mut ffi::GtkWidget,
7636 event: *mut gdk::ffi::GdkEventProximity,
7637 f: glib::ffi::gpointer,
7638 ) -> glib::ffi::gboolean {
7639 let f: &F = &*(f as *const F);
7640 f(
7641 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7642 &from_glib_borrow(event),
7643 )
7644 .into_glib()
7645 }
7646 unsafe {
7647 let f: Box_<F> = Box_::new(f);
7648 connect_raw(
7649 self.as_ptr() as *mut _,
7650 b"proximity-out-event\0".as_ptr() as *const _,
7651 Some(transmute::<_, unsafe extern "C" fn()>(
7652 proximity_out_event_trampoline::<Self, F> as *const (),
7653 )),
7654 Box_::into_raw(f),
7655 )
7656 }
7657 }
7658
7659 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
7660 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
7661 /// focus in keyboard mode.
7662 ///
7663 /// Using the given coordinates, the signal handler should determine
7664 /// whether a tooltip should be shown for `widget`. If this is the case
7665 /// [`true`] should be returned, [`false`] otherwise. Note that if
7666 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
7667 /// should not be used.
7668 ///
7669 /// The signal handler is free to manipulate `tooltip` with the therefore
7670 /// destined function calls.
7671 /// ## `x`
7672 /// the x coordinate of the cursor position where the request has
7673 /// been emitted, relative to `widget`'s left side
7674 /// ## `y`
7675 /// the y coordinate of the cursor position where the request has
7676 /// been emitted, relative to `widget`'s top
7677 /// ## `keyboard_mode`
7678 /// [`true`] if the tooltip was triggered using the keyboard
7679 /// ## `tooltip`
7680 /// a [`Tooltip`][crate::Tooltip]
7681 ///
7682 /// # Returns
7683 ///
7684 /// [`true`] if `tooltip` should be shown right now, [`false`] otherwise.
7685 #[doc(alias = "query-tooltip")]
7686 fn connect_query_tooltip<F: Fn(&Self, i32, i32, bool, &Tooltip) -> bool + 'static>(
7687 &self,
7688 f: F,
7689 ) -> SignalHandlerId {
7690 unsafe extern "C" fn query_tooltip_trampoline<
7691 P: IsA<Widget>,
7692 F: Fn(&P, i32, i32, bool, &Tooltip) -> bool + 'static,
7693 >(
7694 this: *mut ffi::GtkWidget,
7695 x: libc::c_int,
7696 y: libc::c_int,
7697 keyboard_mode: glib::ffi::gboolean,
7698 tooltip: *mut ffi::GtkTooltip,
7699 f: glib::ffi::gpointer,
7700 ) -> glib::ffi::gboolean {
7701 let f: &F = &*(f as *const F);
7702 f(
7703 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7704 x,
7705 y,
7706 from_glib(keyboard_mode),
7707 &from_glib_borrow(tooltip),
7708 )
7709 .into_glib()
7710 }
7711 unsafe {
7712 let f: Box_<F> = Box_::new(f);
7713 connect_raw(
7714 self.as_ptr() as *mut _,
7715 b"query-tooltip\0".as_ptr() as *const _,
7716 Some(transmute::<_, unsafe extern "C" fn()>(
7717 query_tooltip_trampoline::<Self, F> as *const (),
7718 )),
7719 Box_::into_raw(f),
7720 )
7721 }
7722 }
7723
7724 /// The ::realize signal is emitted when `widget` is associated with a
7725 /// [`gdk::Window`][crate::gdk::Window], which means that [`realize()`][Self::realize()] has been called or the
7726 /// widget has been mapped (that is, it is going to be drawn).
7727 #[doc(alias = "realize")]
7728 fn connect_realize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7729 unsafe extern "C" fn realize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7730 this: *mut ffi::GtkWidget,
7731 f: glib::ffi::gpointer,
7732 ) {
7733 let f: &F = &*(f as *const F);
7734 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7735 }
7736 unsafe {
7737 let f: Box_<F> = Box_::new(f);
7738 connect_raw(
7739 self.as_ptr() as *mut _,
7740 b"realize\0".as_ptr() as *const _,
7741 Some(transmute::<_, unsafe extern "C" fn()>(
7742 realize_trampoline::<Self, F> as *const (),
7743 )),
7744 Box_::into_raw(f),
7745 )
7746 }
7747 }
7748
7749 /// The ::screen-changed signal gets emitted when the
7750 /// screen of a widget has changed.
7751 /// ## `previous_screen`
7752 /// the previous screen, or [`None`] if the
7753 /// widget was not associated with a screen before
7754 #[doc(alias = "screen-changed")]
7755 fn connect_screen_changed<F: Fn(&Self, Option<&gdk::Screen>) + 'static>(
7756 &self,
7757 f: F,
7758 ) -> SignalHandlerId {
7759 unsafe extern "C" fn screen_changed_trampoline<
7760 P: IsA<Widget>,
7761 F: Fn(&P, Option<&gdk::Screen>) + 'static,
7762 >(
7763 this: *mut ffi::GtkWidget,
7764 previous_screen: *mut gdk::ffi::GdkScreen,
7765 f: glib::ffi::gpointer,
7766 ) {
7767 let f: &F = &*(f as *const F);
7768 f(
7769 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7770 Option::<gdk::Screen>::from_glib_borrow(previous_screen)
7771 .as_ref()
7772 .as_ref(),
7773 )
7774 }
7775 unsafe {
7776 let f: Box_<F> = Box_::new(f);
7777 connect_raw(
7778 self.as_ptr() as *mut _,
7779 b"screen-changed\0".as_ptr() as *const _,
7780 Some(transmute::<_, unsafe extern "C" fn()>(
7781 screen_changed_trampoline::<Self, F> as *const (),
7782 )),
7783 Box_::into_raw(f),
7784 )
7785 }
7786 }
7787
7788 /// The ::scroll-event signal is emitted when a button in the 4 to 7
7789 /// range is pressed. Wheel mice are usually configured to generate
7790 /// button press events for buttons 4 and 5 when the wheel is turned.
7791 ///
7792 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7793 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
7794 ///
7795 /// This signal will be sent to the grab widget if there is one.
7796 /// ## `event`
7797 /// the [`gdk::EventScroll`][crate::gdk::EventScroll] which triggered
7798 /// this signal.
7799 ///
7800 /// # Returns
7801 ///
7802 /// [`true`] to stop other handlers from being invoked for the event.
7803 /// [`false`] to propagate the event further.
7804 #[doc(alias = "scroll-event")]
7805 fn connect_scroll_event<F: Fn(&Self, &gdk::EventScroll) -> glib::Propagation + 'static>(
7806 &self,
7807 f: F,
7808 ) -> SignalHandlerId {
7809 unsafe extern "C" fn scroll_event_trampoline<
7810 P: IsA<Widget>,
7811 F: Fn(&P, &gdk::EventScroll) -> glib::Propagation + 'static,
7812 >(
7813 this: *mut ffi::GtkWidget,
7814 event: *mut gdk::ffi::GdkEventScroll,
7815 f: glib::ffi::gpointer,
7816 ) -> glib::ffi::gboolean {
7817 let f: &F = &*(f as *const F);
7818 f(
7819 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7820 &from_glib_borrow(event),
7821 )
7822 .into_glib()
7823 }
7824 unsafe {
7825 let f: Box_<F> = Box_::new(f);
7826 connect_raw(
7827 self.as_ptr() as *mut _,
7828 b"scroll-event\0".as_ptr() as *const _,
7829 Some(transmute::<_, unsafe extern "C" fn()>(
7830 scroll_event_trampoline::<Self, F> as *const (),
7831 )),
7832 Box_::into_raw(f),
7833 )
7834 }
7835 }
7836
7837 /// The ::selection-clear-event signal will be emitted when the
7838 /// the `widget`'s window has lost ownership of a selection.
7839 /// ## `event`
7840 /// the [`gdk::EventSelection`][crate::gdk::EventSelection] which triggered
7841 /// this signal.
7842 ///
7843 /// # Returns
7844 ///
7845 /// [`true`] to stop other handlers from being invoked for the event.
7846 /// [`false`] to propagate the event further.
7847 #[doc(alias = "selection-clear-event")]
7848 fn connect_selection_clear_event<
7849 F: Fn(&Self, &gdk::EventSelection) -> glib::Propagation + 'static,
7850 >(
7851 &self,
7852 f: F,
7853 ) -> SignalHandlerId {
7854 unsafe extern "C" fn selection_clear_event_trampoline<
7855 P: IsA<Widget>,
7856 F: Fn(&P, &gdk::EventSelection) -> glib::Propagation + 'static,
7857 >(
7858 this: *mut ffi::GtkWidget,
7859 event: *mut gdk::ffi::GdkEventSelection,
7860 f: glib::ffi::gpointer,
7861 ) -> glib::ffi::gboolean {
7862 let f: &F = &*(f as *const F);
7863 f(
7864 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7865 &from_glib_borrow(event),
7866 )
7867 .into_glib()
7868 }
7869 unsafe {
7870 let f: Box_<F> = Box_::new(f);
7871 connect_raw(
7872 self.as_ptr() as *mut _,
7873 b"selection-clear-event\0".as_ptr() as *const _,
7874 Some(transmute::<_, unsafe extern "C" fn()>(
7875 selection_clear_event_trampoline::<Self, F> as *const (),
7876 )),
7877 Box_::into_raw(f),
7878 )
7879 }
7880 }
7881
7882 #[doc(alias = "selection-get")]
7883 fn connect_selection_get<F: Fn(&Self, &SelectionData, u32, u32) + 'static>(
7884 &self,
7885 f: F,
7886 ) -> SignalHandlerId {
7887 unsafe extern "C" fn selection_get_trampoline<
7888 P: IsA<Widget>,
7889 F: Fn(&P, &SelectionData, u32, u32) + 'static,
7890 >(
7891 this: *mut ffi::GtkWidget,
7892 data: *mut ffi::GtkSelectionData,
7893 info: libc::c_uint,
7894 time: libc::c_uint,
7895 f: glib::ffi::gpointer,
7896 ) {
7897 let f: &F = &*(f as *const F);
7898 f(
7899 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7900 &from_glib_borrow(data),
7901 info,
7902 time,
7903 )
7904 }
7905 unsafe {
7906 let f: Box_<F> = Box_::new(f);
7907 connect_raw(
7908 self.as_ptr() as *mut _,
7909 b"selection-get\0".as_ptr() as *const _,
7910 Some(transmute::<_, unsafe extern "C" fn()>(
7911 selection_get_trampoline::<Self, F> as *const (),
7912 )),
7913 Box_::into_raw(f),
7914 )
7915 }
7916 }
7917
7918 ///
7919 /// # Returns
7920 ///
7921 /// [`true`] to stop other handlers from being invoked for the event. [`false`] to propagate the event further.
7922 #[doc(alias = "selection-notify-event")]
7923 fn connect_selection_notify_event<
7924 F: Fn(&Self, &gdk::EventSelection) -> glib::Propagation + 'static,
7925 >(
7926 &self,
7927 f: F,
7928 ) -> SignalHandlerId {
7929 unsafe extern "C" fn selection_notify_event_trampoline<
7930 P: IsA<Widget>,
7931 F: Fn(&P, &gdk::EventSelection) -> glib::Propagation + 'static,
7932 >(
7933 this: *mut ffi::GtkWidget,
7934 event: *mut gdk::ffi::GdkEventSelection,
7935 f: glib::ffi::gpointer,
7936 ) -> glib::ffi::gboolean {
7937 let f: &F = &*(f as *const F);
7938 f(
7939 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7940 &from_glib_borrow(event),
7941 )
7942 .into_glib()
7943 }
7944 unsafe {
7945 let f: Box_<F> = Box_::new(f);
7946 connect_raw(
7947 self.as_ptr() as *mut _,
7948 b"selection-notify-event\0".as_ptr() as *const _,
7949 Some(transmute::<_, unsafe extern "C" fn()>(
7950 selection_notify_event_trampoline::<Self, F> as *const (),
7951 )),
7952 Box_::into_raw(f),
7953 )
7954 }
7955 }
7956
7957 #[doc(alias = "selection-received")]
7958 fn connect_selection_received<F: Fn(&Self, &SelectionData, u32) + 'static>(
7959 &self,
7960 f: F,
7961 ) -> SignalHandlerId {
7962 unsafe extern "C" fn selection_received_trampoline<
7963 P: IsA<Widget>,
7964 F: Fn(&P, &SelectionData, u32) + 'static,
7965 >(
7966 this: *mut ffi::GtkWidget,
7967 data: *mut ffi::GtkSelectionData,
7968 time: libc::c_uint,
7969 f: glib::ffi::gpointer,
7970 ) {
7971 let f: &F = &*(f as *const F);
7972 f(
7973 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7974 &from_glib_borrow(data),
7975 time,
7976 )
7977 }
7978 unsafe {
7979 let f: Box_<F> = Box_::new(f);
7980 connect_raw(
7981 self.as_ptr() as *mut _,
7982 b"selection-received\0".as_ptr() as *const _,
7983 Some(transmute::<_, unsafe extern "C" fn()>(
7984 selection_received_trampoline::<Self, F> as *const (),
7985 )),
7986 Box_::into_raw(f),
7987 )
7988 }
7989 }
7990
7991 /// The ::selection-request-event signal will be emitted when
7992 /// another client requests ownership of the selection owned by
7993 /// the `widget`'s window.
7994 /// ## `event`
7995 /// the [`gdk::EventSelection`][crate::gdk::EventSelection] which triggered
7996 /// this signal.
7997 ///
7998 /// # Returns
7999 ///
8000 /// [`true`] to stop other handlers from being invoked for the event.
8001 /// [`false`] to propagate the event further.
8002 #[doc(alias = "selection-request-event")]
8003 fn connect_selection_request_event<
8004 F: Fn(&Self, &gdk::EventSelection) -> glib::Propagation + 'static,
8005 >(
8006 &self,
8007 f: F,
8008 ) -> SignalHandlerId {
8009 unsafe extern "C" fn selection_request_event_trampoline<
8010 P: IsA<Widget>,
8011 F: Fn(&P, &gdk::EventSelection) -> glib::Propagation + 'static,
8012 >(
8013 this: *mut ffi::GtkWidget,
8014 event: *mut gdk::ffi::GdkEventSelection,
8015 f: glib::ffi::gpointer,
8016 ) -> glib::ffi::gboolean {
8017 let f: &F = &*(f as *const F);
8018 f(
8019 Widget::from_glib_borrow(this).unsafe_cast_ref(),
8020 &from_glib_borrow(event),
8021 )
8022 .into_glib()
8023 }
8024 unsafe {
8025 let f: Box_<F> = Box_::new(f);
8026 connect_raw(
8027 self.as_ptr() as *mut _,
8028 b"selection-request-event\0".as_ptr() as *const _,
8029 Some(transmute::<_, unsafe extern "C" fn()>(
8030 selection_request_event_trampoline::<Self, F> as *const (),
8031 )),
8032 Box_::into_raw(f),
8033 )
8034 }
8035 }
8036
8037 /// The ::show signal is emitted when `widget` is shown, for example with
8038 /// [`show()`][Self::show()].
8039 #[doc(alias = "show")]
8040 fn connect_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8041 unsafe extern "C" fn show_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8042 this: *mut ffi::GtkWidget,
8043 f: glib::ffi::gpointer,
8044 ) {
8045 let f: &F = &*(f as *const F);
8046 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8047 }
8048 unsafe {
8049 let f: Box_<F> = Box_::new(f);
8050 connect_raw(
8051 self.as_ptr() as *mut _,
8052 b"show\0".as_ptr() as *const _,
8053 Some(transmute::<_, unsafe extern "C" fn()>(
8054 show_trampoline::<Self, F> as *const (),
8055 )),
8056 Box_::into_raw(f),
8057 )
8058 }
8059 }
8060
8061 ///
8062 /// # Returns
8063 ///
8064 /// [`true`] to stop other handlers from being invoked for the event.
8065 /// [`false`] to propagate the event further.
8066 #[doc(alias = "show-help")]
8067 fn connect_show_help<F: Fn(&Self, WidgetHelpType) -> bool + 'static>(
8068 &self,
8069 f: F,
8070 ) -> SignalHandlerId {
8071 unsafe extern "C" fn show_help_trampoline<
8072 P: IsA<Widget>,
8073 F: Fn(&P, WidgetHelpType) -> bool + 'static,
8074 >(
8075 this: *mut ffi::GtkWidget,
8076 help_type: ffi::GtkWidgetHelpType,
8077 f: glib::ffi::gpointer,
8078 ) -> glib::ffi::gboolean {
8079 let f: &F = &*(f as *const F);
8080 f(
8081 Widget::from_glib_borrow(this).unsafe_cast_ref(),
8082 from_glib(help_type),
8083 )
8084 .into_glib()
8085 }
8086 unsafe {
8087 let f: Box_<F> = Box_::new(f);
8088 connect_raw(
8089 self.as_ptr() as *mut _,
8090 b"show-help\0".as_ptr() as *const _,
8091 Some(transmute::<_, unsafe extern "C" fn()>(
8092 show_help_trampoline::<Self, F> as *const (),
8093 )),
8094 Box_::into_raw(f),
8095 )
8096 }
8097 }
8098
8099 fn emit_show_help(&self, help_type: WidgetHelpType) -> bool {
8100 self.emit_by_name("show-help", &[&help_type])
8101 }
8102
8103 /// ## `allocation`
8104 /// the region which has been
8105 /// allocated to the widget.
8106 #[doc(alias = "size-allocate")]
8107 fn connect_size_allocate<F: Fn(&Self, &Allocation) + 'static>(&self, f: F) -> SignalHandlerId {
8108 unsafe extern "C" fn size_allocate_trampoline<
8109 P: IsA<Widget>,
8110 F: Fn(&P, &Allocation) + 'static,
8111 >(
8112 this: *mut ffi::GtkWidget,
8113 allocation: *mut ffi::GtkAllocation,
8114 f: glib::ffi::gpointer,
8115 ) {
8116 let f: &F = &*(f as *const F);
8117 f(
8118 Widget::from_glib_borrow(this).unsafe_cast_ref(),
8119 &from_glib_none(allocation),
8120 )
8121 }
8122 unsafe {
8123 let f: Box_<F> = Box_::new(f);
8124 connect_raw(
8125 self.as_ptr() as *mut _,
8126 b"size-allocate\0".as_ptr() as *const _,
8127 Some(transmute::<_, unsafe extern "C" fn()>(
8128 size_allocate_trampoline::<Self, F> as *const (),
8129 )),
8130 Box_::into_raw(f),
8131 )
8132 }
8133 }
8134
8135 /// The ::state-flags-changed signal is emitted when the widget state
8136 /// changes, see [`state_flags()`][Self::state_flags()].
8137 /// ## `flags`
8138 /// The previous state flags.
8139 #[doc(alias = "state-flags-changed")]
8140 fn connect_state_flags_changed<F: Fn(&Self, StateFlags) + 'static>(
8141 &self,
8142 f: F,
8143 ) -> SignalHandlerId {
8144 unsafe extern "C" fn state_flags_changed_trampoline<
8145 P: IsA<Widget>,
8146 F: Fn(&P, StateFlags) + 'static,
8147 >(
8148 this: *mut ffi::GtkWidget,
8149 flags: ffi::GtkStateFlags,
8150 f: glib::ffi::gpointer,
8151 ) {
8152 let f: &F = &*(f as *const F);
8153 f(
8154 Widget::from_glib_borrow(this).unsafe_cast_ref(),
8155 from_glib(flags),
8156 )
8157 }
8158 unsafe {
8159 let f: Box_<F> = Box_::new(f);
8160 connect_raw(
8161 self.as_ptr() as *mut _,
8162 b"state-flags-changed\0".as_ptr() as *const _,
8163 Some(transmute::<_, unsafe extern "C" fn()>(
8164 state_flags_changed_trampoline::<Self, F> as *const (),
8165 )),
8166 Box_::into_raw(f),
8167 )
8168 }
8169 }
8170
8171 /// The ::style-updated signal is a convenience signal that is emitted when the
8172 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
8173 /// [`StyleContext`][crate::StyleContext] as returned by [`style_context()`][Self::style_context()].
8174 ///
8175 /// Note that style-modifying functions like `gtk_widget_override_color()` also
8176 /// cause this signal to be emitted.
8177 #[doc(alias = "style-updated")]
8178 fn connect_style_updated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8179 unsafe extern "C" fn style_updated_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8180 this: *mut ffi::GtkWidget,
8181 f: glib::ffi::gpointer,
8182 ) {
8183 let f: &F = &*(f as *const F);
8184 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8185 }
8186 unsafe {
8187 let f: Box_<F> = Box_::new(f);
8188 connect_raw(
8189 self.as_ptr() as *mut _,
8190 b"style-updated\0".as_ptr() as *const _,
8191 Some(transmute::<_, unsafe extern "C" fn()>(
8192 style_updated_trampoline::<Self, F> as *const (),
8193 )),
8194 Box_::into_raw(f),
8195 )
8196 }
8197 }
8198
8199 #[doc(alias = "touch-event")]
8200 fn connect_touch_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
8201 &self,
8202 f: F,
8203 ) -> SignalHandlerId {
8204 unsafe extern "C" fn touch_event_trampoline<
8205 P: IsA<Widget>,
8206 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
8207 >(
8208 this: *mut ffi::GtkWidget,
8209 object: *mut gdk::ffi::GdkEvent,
8210 f: glib::ffi::gpointer,
8211 ) -> glib::ffi::gboolean {
8212 let f: &F = &*(f as *const F);
8213 f(
8214 Widget::from_glib_borrow(this).unsafe_cast_ref(),
8215 &from_glib_none(object),
8216 )
8217 .into_glib()
8218 }
8219 unsafe {
8220 let f: Box_<F> = Box_::new(f);
8221 connect_raw(
8222 self.as_ptr() as *mut _,
8223 b"touch-event\0".as_ptr() as *const _,
8224 Some(transmute::<_, unsafe extern "C" fn()>(
8225 touch_event_trampoline::<Self, F> as *const (),
8226 )),
8227 Box_::into_raw(f),
8228 )
8229 }
8230 }
8231
8232 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
8233 /// means that either it or any of its parents up to the toplevel widget have
8234 /// been set as hidden.
8235 ///
8236 /// As ::unmap indicates that a widget will not be shown any longer, it can be
8237 /// used to, for example, stop an animation on the widget.
8238 #[doc(alias = "unmap")]
8239 fn connect_unmap<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8240 unsafe extern "C" fn unmap_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8241 this: *mut ffi::GtkWidget,
8242 f: glib::ffi::gpointer,
8243 ) {
8244 let f: &F = &*(f as *const F);
8245 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8246 }
8247 unsafe {
8248 let f: Box_<F> = Box_::new(f);
8249 connect_raw(
8250 self.as_ptr() as *mut _,
8251 b"unmap\0".as_ptr() as *const _,
8252 Some(transmute::<_, unsafe extern "C" fn()>(
8253 unmap_trampoline::<Self, F> as *const (),
8254 )),
8255 Box_::into_raw(f),
8256 )
8257 }
8258 }
8259
8260 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
8261 /// `widget` is destroyed, which means that [`unrealize()`][Self::unrealize()] has been
8262 /// called or the widget has been unmapped (that is, it is going to be
8263 /// hidden).
8264 #[doc(alias = "unrealize")]
8265 fn connect_unrealize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8266 unsafe extern "C" fn unrealize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8267 this: *mut ffi::GtkWidget,
8268 f: glib::ffi::gpointer,
8269 ) {
8270 let f: &F = &*(f as *const F);
8271 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8272 }
8273 unsafe {
8274 let f: Box_<F> = Box_::new(f);
8275 connect_raw(
8276 self.as_ptr() as *mut _,
8277 b"unrealize\0".as_ptr() as *const _,
8278 Some(transmute::<_, unsafe extern "C" fn()>(
8279 unrealize_trampoline::<Self, F> as *const (),
8280 )),
8281 Box_::into_raw(f),
8282 )
8283 }
8284 }
8285
8286 /// The ::window-state-event will be emitted when the state of the
8287 /// toplevel window associated to the `widget` changes.
8288 ///
8289 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
8290 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
8291 /// this mask automatically for all new windows.
8292 /// ## `event`
8293 /// the [`gdk::EventWindowState`][crate::gdk::EventWindowState] which
8294 /// triggered this signal.
8295 ///
8296 /// # Returns
8297 ///
8298 /// [`true`] to stop other handlers from being invoked for the
8299 /// event. [`false`] to propagate the event further.
8300 #[doc(alias = "window-state-event")]
8301 fn connect_window_state_event<
8302 F: Fn(&Self, &gdk::EventWindowState) -> glib::Propagation + 'static,
8303 >(
8304 &self,
8305 f: F,
8306 ) -> SignalHandlerId {
8307 unsafe extern "C" fn window_state_event_trampoline<
8308 P: IsA<Widget>,
8309 F: Fn(&P, &gdk::EventWindowState) -> glib::Propagation + 'static,
8310 >(
8311 this: *mut ffi::GtkWidget,
8312 event: *mut gdk::ffi::GdkEventWindowState,
8313 f: glib::ffi::gpointer,
8314 ) -> glib::ffi::gboolean {
8315 let f: &F = &*(f as *const F);
8316 f(
8317 Widget::from_glib_borrow(this).unsafe_cast_ref(),
8318 &from_glib_borrow(event),
8319 )
8320 .into_glib()
8321 }
8322 unsafe {
8323 let f: Box_<F> = Box_::new(f);
8324 connect_raw(
8325 self.as_ptr() as *mut _,
8326 b"window-state-event\0".as_ptr() as *const _,
8327 Some(transmute::<_, unsafe extern "C" fn()>(
8328 window_state_event_trampoline::<Self, F> as *const (),
8329 )),
8330 Box_::into_raw(f),
8331 )
8332 }
8333 }
8334
8335 #[doc(alias = "app-paintable")]
8336 fn connect_app_paintable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8337 unsafe extern "C" fn notify_app_paintable_trampoline<
8338 P: IsA<Widget>,
8339 F: Fn(&P) + 'static,
8340 >(
8341 this: *mut ffi::GtkWidget,
8342 _param_spec: glib::ffi::gpointer,
8343 f: glib::ffi::gpointer,
8344 ) {
8345 let f: &F = &*(f as *const F);
8346 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8347 }
8348 unsafe {
8349 let f: Box_<F> = Box_::new(f);
8350 connect_raw(
8351 self.as_ptr() as *mut _,
8352 b"notify::app-paintable\0".as_ptr() as *const _,
8353 Some(transmute::<_, unsafe extern "C" fn()>(
8354 notify_app_paintable_trampoline::<Self, F> as *const (),
8355 )),
8356 Box_::into_raw(f),
8357 )
8358 }
8359 }
8360
8361 #[doc(alias = "can-default")]
8362 fn connect_can_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8363 unsafe extern "C" fn notify_can_default_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8364 this: *mut ffi::GtkWidget,
8365 _param_spec: glib::ffi::gpointer,
8366 f: glib::ffi::gpointer,
8367 ) {
8368 let f: &F = &*(f as *const F);
8369 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8370 }
8371 unsafe {
8372 let f: Box_<F> = Box_::new(f);
8373 connect_raw(
8374 self.as_ptr() as *mut _,
8375 b"notify::can-default\0".as_ptr() as *const _,
8376 Some(transmute::<_, unsafe extern "C" fn()>(
8377 notify_can_default_trampoline::<Self, F> as *const (),
8378 )),
8379 Box_::into_raw(f),
8380 )
8381 }
8382 }
8383
8384 #[doc(alias = "can-focus")]
8385 fn connect_can_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8386 unsafe extern "C" fn notify_can_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8387 this: *mut ffi::GtkWidget,
8388 _param_spec: glib::ffi::gpointer,
8389 f: glib::ffi::gpointer,
8390 ) {
8391 let f: &F = &*(f as *const F);
8392 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8393 }
8394 unsafe {
8395 let f: Box_<F> = Box_::new(f);
8396 connect_raw(
8397 self.as_ptr() as *mut _,
8398 b"notify::can-focus\0".as_ptr() as *const _,
8399 Some(transmute::<_, unsafe extern "C" fn()>(
8400 notify_can_focus_trampoline::<Self, F> as *const (),
8401 )),
8402 Box_::into_raw(f),
8403 )
8404 }
8405 }
8406
8407 #[doc(alias = "composite-child")]
8408 fn connect_composite_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8409 unsafe extern "C" fn notify_composite_child_trampoline<
8410 P: IsA<Widget>,
8411 F: Fn(&P) + 'static,
8412 >(
8413 this: *mut ffi::GtkWidget,
8414 _param_spec: glib::ffi::gpointer,
8415 f: glib::ffi::gpointer,
8416 ) {
8417 let f: &F = &*(f as *const F);
8418 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8419 }
8420 unsafe {
8421 let f: Box_<F> = Box_::new(f);
8422 connect_raw(
8423 self.as_ptr() as *mut _,
8424 b"notify::composite-child\0".as_ptr() as *const _,
8425 Some(transmute::<_, unsafe extern "C" fn()>(
8426 notify_composite_child_trampoline::<Self, F> as *const (),
8427 )),
8428 Box_::into_raw(f),
8429 )
8430 }
8431 }
8432
8433 #[doc(alias = "events")]
8434 fn connect_events_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8435 unsafe extern "C" fn notify_events_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8436 this: *mut ffi::GtkWidget,
8437 _param_spec: glib::ffi::gpointer,
8438 f: glib::ffi::gpointer,
8439 ) {
8440 let f: &F = &*(f as *const F);
8441 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8442 }
8443 unsafe {
8444 let f: Box_<F> = Box_::new(f);
8445 connect_raw(
8446 self.as_ptr() as *mut _,
8447 b"notify::events\0".as_ptr() as *const _,
8448 Some(transmute::<_, unsafe extern "C" fn()>(
8449 notify_events_trampoline::<Self, F> as *const (),
8450 )),
8451 Box_::into_raw(f),
8452 )
8453 }
8454 }
8455
8456 #[doc(alias = "expand")]
8457 fn connect_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8458 unsafe extern "C" fn notify_expand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8459 this: *mut ffi::GtkWidget,
8460 _param_spec: glib::ffi::gpointer,
8461 f: glib::ffi::gpointer,
8462 ) {
8463 let f: &F = &*(f as *const F);
8464 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8465 }
8466 unsafe {
8467 let f: Box_<F> = Box_::new(f);
8468 connect_raw(
8469 self.as_ptr() as *mut _,
8470 b"notify::expand\0".as_ptr() as *const _,
8471 Some(transmute::<_, unsafe extern "C" fn()>(
8472 notify_expand_trampoline::<Self, F> as *const (),
8473 )),
8474 Box_::into_raw(f),
8475 )
8476 }
8477 }
8478
8479 #[doc(alias = "focus-on-click")]
8480 fn connect_focus_on_click_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8481 unsafe extern "C" fn notify_focus_on_click_trampoline<
8482 P: IsA<Widget>,
8483 F: Fn(&P) + 'static,
8484 >(
8485 this: *mut ffi::GtkWidget,
8486 _param_spec: glib::ffi::gpointer,
8487 f: glib::ffi::gpointer,
8488 ) {
8489 let f: &F = &*(f as *const F);
8490 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8491 }
8492 unsafe {
8493 let f: Box_<F> = Box_::new(f);
8494 connect_raw(
8495 self.as_ptr() as *mut _,
8496 b"notify::focus-on-click\0".as_ptr() as *const _,
8497 Some(transmute::<_, unsafe extern "C" fn()>(
8498 notify_focus_on_click_trampoline::<Self, F> as *const (),
8499 )),
8500 Box_::into_raw(f),
8501 )
8502 }
8503 }
8504
8505 #[doc(alias = "halign")]
8506 fn connect_halign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8507 unsafe extern "C" fn notify_halign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8508 this: *mut ffi::GtkWidget,
8509 _param_spec: glib::ffi::gpointer,
8510 f: glib::ffi::gpointer,
8511 ) {
8512 let f: &F = &*(f as *const F);
8513 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8514 }
8515 unsafe {
8516 let f: Box_<F> = Box_::new(f);
8517 connect_raw(
8518 self.as_ptr() as *mut _,
8519 b"notify::halign\0".as_ptr() as *const _,
8520 Some(transmute::<_, unsafe extern "C" fn()>(
8521 notify_halign_trampoline::<Self, F> as *const (),
8522 )),
8523 Box_::into_raw(f),
8524 )
8525 }
8526 }
8527
8528 #[doc(alias = "has-default")]
8529 fn connect_has_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8530 unsafe extern "C" fn notify_has_default_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8531 this: *mut ffi::GtkWidget,
8532 _param_spec: glib::ffi::gpointer,
8533 f: glib::ffi::gpointer,
8534 ) {
8535 let f: &F = &*(f as *const F);
8536 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8537 }
8538 unsafe {
8539 let f: Box_<F> = Box_::new(f);
8540 connect_raw(
8541 self.as_ptr() as *mut _,
8542 b"notify::has-default\0".as_ptr() as *const _,
8543 Some(transmute::<_, unsafe extern "C" fn()>(
8544 notify_has_default_trampoline::<Self, F> as *const (),
8545 )),
8546 Box_::into_raw(f),
8547 )
8548 }
8549 }
8550
8551 #[doc(alias = "has-focus")]
8552 fn connect_has_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8553 unsafe extern "C" fn notify_has_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8554 this: *mut ffi::GtkWidget,
8555 _param_spec: glib::ffi::gpointer,
8556 f: glib::ffi::gpointer,
8557 ) {
8558 let f: &F = &*(f as *const F);
8559 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8560 }
8561 unsafe {
8562 let f: Box_<F> = Box_::new(f);
8563 connect_raw(
8564 self.as_ptr() as *mut _,
8565 b"notify::has-focus\0".as_ptr() as *const _,
8566 Some(transmute::<_, unsafe extern "C" fn()>(
8567 notify_has_focus_trampoline::<Self, F> as *const (),
8568 )),
8569 Box_::into_raw(f),
8570 )
8571 }
8572 }
8573
8574 #[doc(alias = "has-tooltip")]
8575 fn connect_has_tooltip_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8576 unsafe extern "C" fn notify_has_tooltip_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8577 this: *mut ffi::GtkWidget,
8578 _param_spec: glib::ffi::gpointer,
8579 f: glib::ffi::gpointer,
8580 ) {
8581 let f: &F = &*(f as *const F);
8582 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8583 }
8584 unsafe {
8585 let f: Box_<F> = Box_::new(f);
8586 connect_raw(
8587 self.as_ptr() as *mut _,
8588 b"notify::has-tooltip\0".as_ptr() as *const _,
8589 Some(transmute::<_, unsafe extern "C" fn()>(
8590 notify_has_tooltip_trampoline::<Self, F> as *const (),
8591 )),
8592 Box_::into_raw(f),
8593 )
8594 }
8595 }
8596
8597 #[doc(alias = "height-request")]
8598 fn connect_height_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8599 unsafe extern "C" fn notify_height_request_trampoline<
8600 P: IsA<Widget>,
8601 F: Fn(&P) + 'static,
8602 >(
8603 this: *mut ffi::GtkWidget,
8604 _param_spec: glib::ffi::gpointer,
8605 f: glib::ffi::gpointer,
8606 ) {
8607 let f: &F = &*(f as *const F);
8608 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8609 }
8610 unsafe {
8611 let f: Box_<F> = Box_::new(f);
8612 connect_raw(
8613 self.as_ptr() as *mut _,
8614 b"notify::height-request\0".as_ptr() as *const _,
8615 Some(transmute::<_, unsafe extern "C" fn()>(
8616 notify_height_request_trampoline::<Self, F> as *const (),
8617 )),
8618 Box_::into_raw(f),
8619 )
8620 }
8621 }
8622
8623 #[doc(alias = "hexpand")]
8624 fn connect_hexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8625 unsafe extern "C" fn notify_hexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8626 this: *mut ffi::GtkWidget,
8627 _param_spec: glib::ffi::gpointer,
8628 f: glib::ffi::gpointer,
8629 ) {
8630 let f: &F = &*(f as *const F);
8631 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8632 }
8633 unsafe {
8634 let f: Box_<F> = Box_::new(f);
8635 connect_raw(
8636 self.as_ptr() as *mut _,
8637 b"notify::hexpand\0".as_ptr() as *const _,
8638 Some(transmute::<_, unsafe extern "C" fn()>(
8639 notify_hexpand_trampoline::<Self, F> as *const (),
8640 )),
8641 Box_::into_raw(f),
8642 )
8643 }
8644 }
8645
8646 #[doc(alias = "hexpand-set")]
8647 fn connect_hexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8648 unsafe extern "C" fn notify_hexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8649 this: *mut ffi::GtkWidget,
8650 _param_spec: glib::ffi::gpointer,
8651 f: glib::ffi::gpointer,
8652 ) {
8653 let f: &F = &*(f as *const F);
8654 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8655 }
8656 unsafe {
8657 let f: Box_<F> = Box_::new(f);
8658 connect_raw(
8659 self.as_ptr() as *mut _,
8660 b"notify::hexpand-set\0".as_ptr() as *const _,
8661 Some(transmute::<_, unsafe extern "C" fn()>(
8662 notify_hexpand_set_trampoline::<Self, F> as *const (),
8663 )),
8664 Box_::into_raw(f),
8665 )
8666 }
8667 }
8668
8669 #[doc(alias = "is-focus")]
8670 fn connect_is_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8671 unsafe extern "C" fn notify_is_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8672 this: *mut ffi::GtkWidget,
8673 _param_spec: glib::ffi::gpointer,
8674 f: glib::ffi::gpointer,
8675 ) {
8676 let f: &F = &*(f as *const F);
8677 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8678 }
8679 unsafe {
8680 let f: Box_<F> = Box_::new(f);
8681 connect_raw(
8682 self.as_ptr() as *mut _,
8683 b"notify::is-focus\0".as_ptr() as *const _,
8684 Some(transmute::<_, unsafe extern "C" fn()>(
8685 notify_is_focus_trampoline::<Self, F> as *const (),
8686 )),
8687 Box_::into_raw(f),
8688 )
8689 }
8690 }
8691
8692 #[doc(alias = "margin")]
8693 fn connect_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8694 unsafe extern "C" fn notify_margin_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8695 this: *mut ffi::GtkWidget,
8696 _param_spec: glib::ffi::gpointer,
8697 f: glib::ffi::gpointer,
8698 ) {
8699 let f: &F = &*(f as *const F);
8700 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8701 }
8702 unsafe {
8703 let f: Box_<F> = Box_::new(f);
8704 connect_raw(
8705 self.as_ptr() as *mut _,
8706 b"notify::margin\0".as_ptr() as *const _,
8707 Some(transmute::<_, unsafe extern "C" fn()>(
8708 notify_margin_trampoline::<Self, F> as *const (),
8709 )),
8710 Box_::into_raw(f),
8711 )
8712 }
8713 }
8714
8715 #[doc(alias = "margin-bottom")]
8716 fn connect_margin_bottom_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8717 unsafe extern "C" fn notify_margin_bottom_trampoline<
8718 P: IsA<Widget>,
8719 F: Fn(&P) + 'static,
8720 >(
8721 this: *mut ffi::GtkWidget,
8722 _param_spec: glib::ffi::gpointer,
8723 f: glib::ffi::gpointer,
8724 ) {
8725 let f: &F = &*(f as *const F);
8726 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8727 }
8728 unsafe {
8729 let f: Box_<F> = Box_::new(f);
8730 connect_raw(
8731 self.as_ptr() as *mut _,
8732 b"notify::margin-bottom\0".as_ptr() as *const _,
8733 Some(transmute::<_, unsafe extern "C" fn()>(
8734 notify_margin_bottom_trampoline::<Self, F> as *const (),
8735 )),
8736 Box_::into_raw(f),
8737 )
8738 }
8739 }
8740
8741 #[doc(alias = "margin-end")]
8742 fn connect_margin_end_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8743 unsafe extern "C" fn notify_margin_end_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8744 this: *mut ffi::GtkWidget,
8745 _param_spec: glib::ffi::gpointer,
8746 f: glib::ffi::gpointer,
8747 ) {
8748 let f: &F = &*(f as *const F);
8749 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8750 }
8751 unsafe {
8752 let f: Box_<F> = Box_::new(f);
8753 connect_raw(
8754 self.as_ptr() as *mut _,
8755 b"notify::margin-end\0".as_ptr() as *const _,
8756 Some(transmute::<_, unsafe extern "C" fn()>(
8757 notify_margin_end_trampoline::<Self, F> as *const (),
8758 )),
8759 Box_::into_raw(f),
8760 )
8761 }
8762 }
8763
8764 #[doc(alias = "margin-start")]
8765 fn connect_margin_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8766 unsafe extern "C" fn notify_margin_start_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8767 this: *mut ffi::GtkWidget,
8768 _param_spec: glib::ffi::gpointer,
8769 f: glib::ffi::gpointer,
8770 ) {
8771 let f: &F = &*(f as *const F);
8772 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8773 }
8774 unsafe {
8775 let f: Box_<F> = Box_::new(f);
8776 connect_raw(
8777 self.as_ptr() as *mut _,
8778 b"notify::margin-start\0".as_ptr() as *const _,
8779 Some(transmute::<_, unsafe extern "C" fn()>(
8780 notify_margin_start_trampoline::<Self, F> as *const (),
8781 )),
8782 Box_::into_raw(f),
8783 )
8784 }
8785 }
8786
8787 #[doc(alias = "margin-top")]
8788 fn connect_margin_top_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8789 unsafe extern "C" fn notify_margin_top_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8790 this: *mut ffi::GtkWidget,
8791 _param_spec: glib::ffi::gpointer,
8792 f: glib::ffi::gpointer,
8793 ) {
8794 let f: &F = &*(f as *const F);
8795 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8796 }
8797 unsafe {
8798 let f: Box_<F> = Box_::new(f);
8799 connect_raw(
8800 self.as_ptr() as *mut _,
8801 b"notify::margin-top\0".as_ptr() as *const _,
8802 Some(transmute::<_, unsafe extern "C" fn()>(
8803 notify_margin_top_trampoline::<Self, F> as *const (),
8804 )),
8805 Box_::into_raw(f),
8806 )
8807 }
8808 }
8809
8810 #[doc(alias = "name")]
8811 fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8812 unsafe extern "C" fn notify_name_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8813 this: *mut ffi::GtkWidget,
8814 _param_spec: glib::ffi::gpointer,
8815 f: glib::ffi::gpointer,
8816 ) {
8817 let f: &F = &*(f as *const F);
8818 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8819 }
8820 unsafe {
8821 let f: Box_<F> = Box_::new(f);
8822 connect_raw(
8823 self.as_ptr() as *mut _,
8824 b"notify::name\0".as_ptr() as *const _,
8825 Some(transmute::<_, unsafe extern "C" fn()>(
8826 notify_name_trampoline::<Self, F> as *const (),
8827 )),
8828 Box_::into_raw(f),
8829 )
8830 }
8831 }
8832
8833 #[doc(alias = "no-show-all")]
8834 fn connect_no_show_all_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8835 unsafe extern "C" fn notify_no_show_all_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8836 this: *mut ffi::GtkWidget,
8837 _param_spec: glib::ffi::gpointer,
8838 f: glib::ffi::gpointer,
8839 ) {
8840 let f: &F = &*(f as *const F);
8841 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8842 }
8843 unsafe {
8844 let f: Box_<F> = Box_::new(f);
8845 connect_raw(
8846 self.as_ptr() as *mut _,
8847 b"notify::no-show-all\0".as_ptr() as *const _,
8848 Some(transmute::<_, unsafe extern "C" fn()>(
8849 notify_no_show_all_trampoline::<Self, F> as *const (),
8850 )),
8851 Box_::into_raw(f),
8852 )
8853 }
8854 }
8855
8856 #[doc(alias = "opacity")]
8857 fn connect_opacity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8858 unsafe extern "C" fn notify_opacity_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8859 this: *mut ffi::GtkWidget,
8860 _param_spec: glib::ffi::gpointer,
8861 f: glib::ffi::gpointer,
8862 ) {
8863 let f: &F = &*(f as *const F);
8864 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8865 }
8866 unsafe {
8867 let f: Box_<F> = Box_::new(f);
8868 connect_raw(
8869 self.as_ptr() as *mut _,
8870 b"notify::opacity\0".as_ptr() as *const _,
8871 Some(transmute::<_, unsafe extern "C" fn()>(
8872 notify_opacity_trampoline::<Self, F> as *const (),
8873 )),
8874 Box_::into_raw(f),
8875 )
8876 }
8877 }
8878
8879 #[doc(alias = "parent")]
8880 fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8881 unsafe extern "C" fn notify_parent_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8882 this: *mut ffi::GtkWidget,
8883 _param_spec: glib::ffi::gpointer,
8884 f: glib::ffi::gpointer,
8885 ) {
8886 let f: &F = &*(f as *const F);
8887 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8888 }
8889 unsafe {
8890 let f: Box_<F> = Box_::new(f);
8891 connect_raw(
8892 self.as_ptr() as *mut _,
8893 b"notify::parent\0".as_ptr() as *const _,
8894 Some(transmute::<_, unsafe extern "C" fn()>(
8895 notify_parent_trampoline::<Self, F> as *const (),
8896 )),
8897 Box_::into_raw(f),
8898 )
8899 }
8900 }
8901
8902 #[doc(alias = "receives-default")]
8903 fn connect_receives_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8904 unsafe extern "C" fn notify_receives_default_trampoline<
8905 P: IsA<Widget>,
8906 F: Fn(&P) + 'static,
8907 >(
8908 this: *mut ffi::GtkWidget,
8909 _param_spec: glib::ffi::gpointer,
8910 f: glib::ffi::gpointer,
8911 ) {
8912 let f: &F = &*(f as *const F);
8913 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8914 }
8915 unsafe {
8916 let f: Box_<F> = Box_::new(f);
8917 connect_raw(
8918 self.as_ptr() as *mut _,
8919 b"notify::receives-default\0".as_ptr() as *const _,
8920 Some(transmute::<_, unsafe extern "C" fn()>(
8921 notify_receives_default_trampoline::<Self, F> as *const (),
8922 )),
8923 Box_::into_raw(f),
8924 )
8925 }
8926 }
8927
8928 #[doc(alias = "scale-factor")]
8929 fn connect_scale_factor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8930 unsafe extern "C" fn notify_scale_factor_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8931 this: *mut ffi::GtkWidget,
8932 _param_spec: glib::ffi::gpointer,
8933 f: glib::ffi::gpointer,
8934 ) {
8935 let f: &F = &*(f as *const F);
8936 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8937 }
8938 unsafe {
8939 let f: Box_<F> = Box_::new(f);
8940 connect_raw(
8941 self.as_ptr() as *mut _,
8942 b"notify::scale-factor\0".as_ptr() as *const _,
8943 Some(transmute::<_, unsafe extern "C" fn()>(
8944 notify_scale_factor_trampoline::<Self, F> as *const (),
8945 )),
8946 Box_::into_raw(f),
8947 )
8948 }
8949 }
8950
8951 #[doc(alias = "sensitive")]
8952 fn connect_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8953 unsafe extern "C" fn notify_sensitive_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8954 this: *mut ffi::GtkWidget,
8955 _param_spec: glib::ffi::gpointer,
8956 f: glib::ffi::gpointer,
8957 ) {
8958 let f: &F = &*(f as *const F);
8959 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8960 }
8961 unsafe {
8962 let f: Box_<F> = Box_::new(f);
8963 connect_raw(
8964 self.as_ptr() as *mut _,
8965 b"notify::sensitive\0".as_ptr() as *const _,
8966 Some(transmute::<_, unsafe extern "C" fn()>(
8967 notify_sensitive_trampoline::<Self, F> as *const (),
8968 )),
8969 Box_::into_raw(f),
8970 )
8971 }
8972 }
8973
8974 #[doc(alias = "tooltip-markup")]
8975 fn connect_tooltip_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8976 unsafe extern "C" fn notify_tooltip_markup_trampoline<
8977 P: IsA<Widget>,
8978 F: Fn(&P) + 'static,
8979 >(
8980 this: *mut ffi::GtkWidget,
8981 _param_spec: glib::ffi::gpointer,
8982 f: glib::ffi::gpointer,
8983 ) {
8984 let f: &F = &*(f as *const F);
8985 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8986 }
8987 unsafe {
8988 let f: Box_<F> = Box_::new(f);
8989 connect_raw(
8990 self.as_ptr() as *mut _,
8991 b"notify::tooltip-markup\0".as_ptr() as *const _,
8992 Some(transmute::<_, unsafe extern "C" fn()>(
8993 notify_tooltip_markup_trampoline::<Self, F> as *const (),
8994 )),
8995 Box_::into_raw(f),
8996 )
8997 }
8998 }
8999
9000 #[doc(alias = "tooltip-text")]
9001 fn connect_tooltip_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
9002 unsafe extern "C" fn notify_tooltip_text_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
9003 this: *mut ffi::GtkWidget,
9004 _param_spec: glib::ffi::gpointer,
9005 f: glib::ffi::gpointer,
9006 ) {
9007 let f: &F = &*(f as *const F);
9008 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
9009 }
9010 unsafe {
9011 let f: Box_<F> = Box_::new(f);
9012 connect_raw(
9013 self.as_ptr() as *mut _,
9014 b"notify::tooltip-text\0".as_ptr() as *const _,
9015 Some(transmute::<_, unsafe extern "C" fn()>(
9016 notify_tooltip_text_trampoline::<Self, F> as *const (),
9017 )),
9018 Box_::into_raw(f),
9019 )
9020 }
9021 }
9022
9023 #[doc(alias = "valign")]
9024 fn connect_valign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
9025 unsafe extern "C" fn notify_valign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
9026 this: *mut ffi::GtkWidget,
9027 _param_spec: glib::ffi::gpointer,
9028 f: glib::ffi::gpointer,
9029 ) {
9030 let f: &F = &*(f as *const F);
9031 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
9032 }
9033 unsafe {
9034 let f: Box_<F> = Box_::new(f);
9035 connect_raw(
9036 self.as_ptr() as *mut _,
9037 b"notify::valign\0".as_ptr() as *const _,
9038 Some(transmute::<_, unsafe extern "C" fn()>(
9039 notify_valign_trampoline::<Self, F> as *const (),
9040 )),
9041 Box_::into_raw(f),
9042 )
9043 }
9044 }
9045
9046 #[doc(alias = "vexpand")]
9047 fn connect_vexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
9048 unsafe extern "C" fn notify_vexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
9049 this: *mut ffi::GtkWidget,
9050 _param_spec: glib::ffi::gpointer,
9051 f: glib::ffi::gpointer,
9052 ) {
9053 let f: &F = &*(f as *const F);
9054 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
9055 }
9056 unsafe {
9057 let f: Box_<F> = Box_::new(f);
9058 connect_raw(
9059 self.as_ptr() as *mut _,
9060 b"notify::vexpand\0".as_ptr() as *const _,
9061 Some(transmute::<_, unsafe extern "C" fn()>(
9062 notify_vexpand_trampoline::<Self, F> as *const (),
9063 )),
9064 Box_::into_raw(f),
9065 )
9066 }
9067 }
9068
9069 #[doc(alias = "vexpand-set")]
9070 fn connect_vexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
9071 unsafe extern "C" fn notify_vexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
9072 this: *mut ffi::GtkWidget,
9073 _param_spec: glib::ffi::gpointer,
9074 f: glib::ffi::gpointer,
9075 ) {
9076 let f: &F = &*(f as *const F);
9077 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
9078 }
9079 unsafe {
9080 let f: Box_<F> = Box_::new(f);
9081 connect_raw(
9082 self.as_ptr() as *mut _,
9083 b"notify::vexpand-set\0".as_ptr() as *const _,
9084 Some(transmute::<_, unsafe extern "C" fn()>(
9085 notify_vexpand_set_trampoline::<Self, F> as *const (),
9086 )),
9087 Box_::into_raw(f),
9088 )
9089 }
9090 }
9091
9092 #[doc(alias = "visible")]
9093 fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
9094 unsafe extern "C" fn notify_visible_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
9095 this: *mut ffi::GtkWidget,
9096 _param_spec: glib::ffi::gpointer,
9097 f: glib::ffi::gpointer,
9098 ) {
9099 let f: &F = &*(f as *const F);
9100 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
9101 }
9102 unsafe {
9103 let f: Box_<F> = Box_::new(f);
9104 connect_raw(
9105 self.as_ptr() as *mut _,
9106 b"notify::visible\0".as_ptr() as *const _,
9107 Some(transmute::<_, unsafe extern "C" fn()>(
9108 notify_visible_trampoline::<Self, F> as *const (),
9109 )),
9110 Box_::into_raw(f),
9111 )
9112 }
9113 }
9114
9115 #[doc(alias = "width-request")]
9116 fn connect_width_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
9117 unsafe extern "C" fn notify_width_request_trampoline<
9118 P: IsA<Widget>,
9119 F: Fn(&P) + 'static,
9120 >(
9121 this: *mut ffi::GtkWidget,
9122 _param_spec: glib::ffi::gpointer,
9123 f: glib::ffi::gpointer,
9124 ) {
9125 let f: &F = &*(f as *const F);
9126 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
9127 }
9128 unsafe {
9129 let f: Box_<F> = Box_::new(f);
9130 connect_raw(
9131 self.as_ptr() as *mut _,
9132 b"notify::width-request\0".as_ptr() as *const _,
9133 Some(transmute::<_, unsafe extern "C" fn()>(
9134 notify_width_request_trampoline::<Self, F> as *const (),
9135 )),
9136 Box_::into_raw(f),
9137 )
9138 }
9139 }
9140
9141 #[doc(alias = "window")]
9142 fn connect_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
9143 unsafe extern "C" fn notify_window_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
9144 this: *mut ffi::GtkWidget,
9145 _param_spec: glib::ffi::gpointer,
9146 f: glib::ffi::gpointer,
9147 ) {
9148 let f: &F = &*(f as *const F);
9149 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
9150 }
9151 unsafe {
9152 let f: Box_<F> = Box_::new(f);
9153 connect_raw(
9154 self.as_ptr() as *mut _,
9155 b"notify::window\0".as_ptr() as *const _,
9156 Some(transmute::<_, unsafe extern "C" fn()>(
9157 notify_window_trampoline::<Self, F> as *const (),
9158 )),
9159 Box_::into_raw(f),
9160 )
9161 }
9162 }
9163}
9164
9165impl<O: IsA<Widget>> WidgetExt for O {}