Skip to main content

gtk4/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#![allow(deprecated)]
5
6use crate::{
7    Accessible, Align, Allocation, Buildable, ConstraintTarget, DirectionType, EventController,
8    LayoutManager, Native, Orientation, Overflow, PickFlags, Requisition, Root, Settings,
9    SizeRequestMode, Snapshot, StateFlags, StyleContext, TextDirection, Tooltip, ffi,
10};
11use glib::{
12    object::ObjectType as _,
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20    /// The base class for all widgets.
21    ///
22    /// It manages the widget lifecycle, layout, states and style.
23    ///
24    /// ### Minimum and natural size
25    ///
26    /// In order to understand geometry management of widgets in GTK, it is
27    /// helpful to understand the different terminology surrounding sizing of
28    /// widgets.
29    ///
30    /// The two primary terms are: *minimum size* and *natural size*.
31    ///
32    /// As a general rule: the *minimum size* is the size required to display
33    /// the minimum amount of content in a widget. A widget cannot be
34    /// allocated less than the minimum size it requires.
35    ///
36    /// The *natural size* is the amount of content that a widget prefers to
37    /// display in normal conditions.
38    ///
39    /// A widget may be allocated more than the natural size it prefers, or
40    /// less, depending on the layout management of its parent container.
41    /// What to do when the widget is allocated a different size than
42    /// the one it prefers is entirely left to the widget implementation:
43    /// some widgets decide to add extra room, other widgets may disclose
44    /// additional content, other widgets may decide to hide content, or show
45    /// a different layout entirely.
46    ///
47    /// ### Height-for-width Geometry Management
48    ///
49    /// GTK uses a height-for-width (and width-for-height) geometry management
50    /// system. Height-for-width means that a widget can change how much
51    /// vertical space it needs, depending on the amount of horizontal space
52    /// that it is given (and similar for width-for-height). The most common
53    /// example is a label that reflows to fill up the available width, wraps
54    /// to fewer lines, and therefore needs less height.
55    ///
56    /// Height-for-width geometry management is implemented in GTK by way
57    /// of two virtual methods:
58    ///
59    /// - [`WidgetImpl::request_mode()`][crate::subclass::prelude::WidgetImpl::request_mode()]
60    /// - [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()]
61    ///
62    /// There are some important things to keep in mind when implementing
63    /// height-for-width and when using it in widget implementations.
64    ///
65    /// If you implement a direct [`Widget`][crate::Widget] subclass that supports
66    /// height-for-width or width-for-height geometry management for itself
67    /// or its child widgets, the [`WidgetImpl::request_mode()`][crate::subclass::prelude::WidgetImpl::request_mode()] virtual
68    /// function must be implemented as well and return the widget's preferred
69    /// request mode. The default implementation of this virtual function
70    /// returns [`SizeRequestMode::ConstantSize`][crate::SizeRequestMode::ConstantSize], which means that the widget will
71    /// only ever get -1 passed as the for_size value to its
72    /// [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()] implementation.
73    ///
74    /// The geometry management system will query a widget hierarchy in
75    /// only one orientation at a time. When widgets are initially queried
76    /// for their minimum sizes it is generally done in two initial passes
77    /// in the [`SizeRequestMode`][crate::SizeRequestMode] chosen by the toplevel.
78    ///
79    /// For example, when queried in the normal [`SizeRequestMode::HeightForWidth`][crate::SizeRequestMode::HeightForWidth] mode:
80    ///
81    /// First, the default minimum and natural width for each widget
82    /// in the interface will be computed using [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()] with an
83    /// orientation of [`Orientation::Horizontal`][crate::Orientation::Horizontal] and a for_size of -1.
84    /// Because the preferred widths for each widget depend on the preferred
85    /// widths of their children, this information propagates up the hierarchy,
86    /// and finally a minimum and natural width is determined for the entire
87    /// toplevel. Next, the toplevel will use the minimum width to query for the
88    /// minimum height contextual to that width using [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()] with an
89    /// orientation of [`Orientation::Vertical`][crate::Orientation::Vertical] and a for_size of the just computed
90    /// width. This will also be a highly recursive operation. The minimum height
91    /// for the minimum width is normally used to set the minimum size constraint
92    /// on the toplevel.
93    ///
94    /// After the toplevel window has initially requested its size in both
95    /// dimensions it can go on to allocate itself a reasonable size (or a size
96    /// previously specified with [`GtkWindowExt::set_default_size()`][crate::prelude::GtkWindowExt::set_default_size()]). During the
97    /// recursive allocation process it’s important to note that request cycles
98    /// will be recursively executed while widgets allocate their children.
99    /// Each widget, once allocated a size, will go on to first share the
100    /// space in one orientation among its children and then request each child's
101    /// height for its target allocated width or its width for allocated height,
102    /// depending. In this way a widget will typically be requested its size
103    /// a number of times before actually being allocated a size. The size a
104    /// widget is finally allocated can of course differ from the size it has
105    /// requested. For this reason, [`Widget`][crate::Widget] caches a  small number of results
106    /// to avoid re-querying for the same sizes in one allocation cycle.
107    ///
108    /// If a widget does move content around to intelligently use up the
109    /// allocated size then it must support the request in both
110    /// [`SizeRequestMode`][crate::SizeRequestMode]s even if the widget in question only
111    /// trades sizes in a single orientation.
112    ///
113    /// For instance, a [`Label`][crate::Label] that does height-for-width word wrapping
114    /// will not expect to have [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()] with an orientation of
115    /// [`Orientation::Vertical`][crate::Orientation::Vertical] called because that call is specific to a
116    /// width-for-height request. In this case the label must return the height
117    /// required for its own minimum possible width. By following this rule any
118    /// widget that handles height-for-width or width-for-height requests will
119    /// always be allocated at least enough space to fit its own content.
120    ///
121    /// Here are some examples of how a [`SizeRequestMode::HeightForWidth`][crate::SizeRequestMode::HeightForWidth] widget
122    /// generally deals with width-for-height requests:
123    ///
124    /// **⚠️ The following code is in c ⚠️**
125    ///
126    /// ```c
127    /// static void
128    /// foo_widget_measure (GtkWidget      *widget,
129    ///                     GtkOrientation  orientation,
130    ///                     int             for_size,
131    ///                     int            *minimum_size,
132    ///                     int            *natural_size,
133    ///                     int            *minimum_baseline,
134    ///                     int            *natural_baseline)
135    /// {
136    ///   if (orientation == GTK_ORIENTATION_HORIZONTAL)
137    ///     {
138    ///       // Calculate minimum and natural width
139    ///     }
140    ///   else // VERTICAL
141    ///     {
142    ///       if (i_am_in_height_for_width_mode)
143    ///         {
144    ///           int min_width, dummy;
145    ///
146    ///           // First, get the minimum width of our widget
147    ///           GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
148    ///                                                   &min_width, &dummy, &dummy, &dummy);
149    ///
150    ///           // Now use the minimum width to retrieve the minimum and natural height to display
151    ///           // that width.
152    ///           GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_VERTICAL, min_width,
153    ///                                                   minimum_size, natural_size, &dummy, &dummy);
154    ///         }
155    ///       else
156    ///         {
157    ///           // ... some widgets do both.
158    ///         }
159    ///     }
160    /// }
161    /// ```
162    ///
163    /// Often a widget needs to get its own request during size request or
164    /// allocation. For example, when computing height it may need to also
165    /// compute width. Or when deciding how to use an allocation, the widget
166    /// may need to know its natural size. In these cases, the widget should
167    /// be careful to call its virtual methods directly, like in the code
168    /// example above.
169    ///
170    /// It will not work to use the wrapper function [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()]
171    /// inside your own [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()] implementation.
172    /// These return a request adjusted by [`SizeGroup`][crate::SizeGroup], the widget's
173    /// align and expand flags, as well as its CSS style.
174    ///
175    /// If a widget used the wrappers inside its virtual method implementations,
176    /// then the adjustments (such as widget margins) would be applied
177    /// twice. GTK therefore does not allow this and will warn if you try
178    /// to do it.
179    ///
180    /// Of course if you are getting the size request for another widget, such
181    /// as a child widget, you must use [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()]; otherwise, you
182    /// would not properly consider widget margins, [`SizeGroup`][crate::SizeGroup], and
183    /// so forth.
184    ///
185    /// GTK also supports baseline vertical alignment of widgets. This
186    /// means that widgets are positioned such that the typographical baseline of
187    /// widgets in the same row are aligned. This happens if a widget supports
188    /// baselines, has a vertical alignment using baselines, and is inside
189    /// a widget that supports baselines and has a natural “row” that it aligns to
190    /// the baseline, or a baseline assigned to it by the grandparent.
191    ///
192    /// Baseline alignment support for a widget is also done by the
193    /// [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()] virtual function. It allows you to report
194    /// both a minimum and natural size.
195    ///
196    /// If a widget ends up baseline aligned it will be allocated all the space in
197    /// the parent as if it was [`Align::Fill`][crate::Align::Fill], but the selected baseline can be
198    /// found via [`WidgetExt::baseline()`][crate::prelude::WidgetExt::baseline()]. If the baseline has a
199    /// value other than -1 you need to align the widget such that the baseline
200    /// appears at the position.
201    ///
202    /// ### GtkWidget as GtkBuildable
203    ///
204    /// The [`Widget`][crate::Widget] implementation of the [`Buildable`][crate::Buildable] interface
205    /// supports various custom elements to specify additional aspects of widgets
206    /// that are not directly expressed as properties.
207    ///
208    /// If the widget uses a [`LayoutManager`][crate::LayoutManager], [`Widget`][crate::Widget] supports
209    /// a custom `<layout>` element, used to define layout properties:
210    ///
211    /// ```xml
212    /// <object class="GtkGrid" id="my_grid">
213    ///   <child>
214    ///     <object class="GtkLabel" id="label1">
215    ///       <property name="label">Description</property>
216    ///       <layout>
217    ///         <property name="column">0</property>
218    ///         <property name="row">0</property>
219    ///         <property name="row-span">1</property>
220    ///         <property name="column-span">1</property>
221    ///       </layout>
222    ///     </object>
223    ///   </child>
224    ///   <child>
225    ///     <object class="GtkEntry" id="description_entry">
226    ///       <layout>
227    ///         <property name="column">1</property>
228    ///         <property name="row">0</property>
229    ///         <property name="row-span">1</property>
230    ///         <property name="column-span">1</property>
231    ///       </layout>
232    ///     </object>
233    ///   </child>
234    /// </object>
235    /// ```
236    ///
237    /// [`Widget`][crate::Widget] allows style information such as style classes to
238    /// be associated with widgets, using the custom `<style>` element:
239    ///
240    /// ```xml
241    /// <object class="GtkButton" id="button1">
242    ///   <style>
243    ///     <class name="my-special-button-class"/>
244    ///     <class name="dark-button"/>
245    ///   </style>
246    /// </object>
247    /// ```
248    ///
249    /// [`Widget`][crate::Widget] allows defining accessibility information, such as properties,
250    /// relations, and states, using the custom `<accessibility>` element:
251    ///
252    /// ```xml
253    /// <object class="GtkButton" id="button1">
254    ///   <accessibility>
255    ///     <property name="label">Download</property>
256    ///     <relation name="labelled-by">label1</relation>
257    ///   </accessibility>
258    /// </object>
259    /// ```
260    ///
261    /// ### Building composite widgets from template XML
262    ///
263    /// `GtkWidget `exposes some facilities to automate the procedure
264    /// of creating composite widgets using "templates".
265    ///
266    /// To create composite widgets with [`Builder`][crate::Builder] XML, one must associate
267    /// the interface description with the widget class at class initialization
268    /// time using [`WidgetClassExt::set_template()`][crate::subclass::prelude::WidgetClassExt::set_template()].
269    ///
270    /// The interface description semantics expected in composite template descriptions
271    /// is slightly different from regular [`Builder`][crate::Builder] XML.
272    ///
273    /// Unlike regular interface descriptions, [`WidgetClassExt::set_template()`][crate::subclass::prelude::WidgetClassExt::set_template()]
274    /// will expect a `<template>` tag as a direct child of the toplevel
275    /// `<interface>` tag. The `<template>` tag must specify the “class” attribute
276    /// which must be the type name of the widget. Optionally, the “parent”
277    /// attribute may be specified to specify the direct parent type of the widget
278    /// type; this is ignored by [`Builder`][crate::Builder] but can be used by UI design tools to
279    /// introspect what kind of properties and internal children exist for a given
280    /// type when the actual type does not exist.
281    ///
282    /// The XML which is contained inside the `<template>` tag behaves as if it were
283    /// added to the `<object>` tag defining the widget itself. You may set properties
284    /// on a widget by inserting `<property>` tags into the `<template>` tag, and also
285    /// add `<child>` tags to add children and extend a widget in the normal way you
286    /// would with `<object>` tags.
287    ///
288    /// Additionally, `<object>` tags can also be added before and after the initial
289    /// `<template>` tag in the normal way, allowing one to define auxiliary objects
290    /// which might be referenced by other widgets declared as children of the
291    /// `<template>` tag.
292    ///
293    /// Since, unlike the `<object>` tag, the `<template>` tag does not contain an
294    /// “id” attribute, if you need to refer to the instance of the object itself that
295    /// the template will create, simply refer to the template class name in an
296    /// applicable element content.
297    ///
298    /// Here is an example of a template definition, which includes an example of
299    /// this in the `<signal>` tag:
300    ///
301    /// ```xml
302    /// <interface>
303    ///   <template class="FooWidget" parent="GtkBox">
304    ///     <property name="orientation">horizontal</property>
305    ///     <property name="spacing">4</property>
306    ///     <child>
307    ///       <object class="GtkButton" id="hello_button">
308    ///         <property name="label">Hello World</property>
309    ///         <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/>
310    ///       </object>
311    ///     </child>
312    ///     <child>
313    ///       <object class="GtkButton" id="goodbye_button">
314    ///         <property name="label">Goodbye World</property>
315    ///       </object>
316    ///     </child>
317    ///   </template>
318    /// </interface>
319    /// ```
320    ///
321    /// Typically, you'll place the template fragment into a file that is
322    /// bundled with your project, using `GResource`. In order to load the
323    /// template, you need to call [`WidgetClassExt::set_template_from_resource()`][crate::subclass::prelude::WidgetClassExt::set_template_from_resource()]
324    /// from the class initialization of your [`Widget`][crate::Widget] type:
325    ///
326    /// **⚠️ The following code is in c ⚠️**
327    ///
328    /// ```c
329    /// static void
330    /// foo_widget_class_init (FooWidgetClass *klass)
331    /// {
332    ///   // ...
333    ///
334    ///   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
335    ///                                                "/com/example/ui/foowidget.ui");
336    /// }
337    /// ```
338    ///
339    /// You will also need to call `Gtk::Widget::init_template()` from the
340    /// instance initialization function:
341    ///
342    /// **⚠️ The following code is in c ⚠️**
343    ///
344    /// ```c
345    /// static void
346    /// foo_widget_init (FooWidget *self)
347    /// {
348    ///   gtk_widget_init_template (GTK_WIDGET (self));
349    ///
350    ///   // Initialize the rest of the widget...
351    /// }
352    /// ```
353    ///
354    /// as well as calling `Gtk::Widget::dispose_template()` from the dispose
355    /// function:
356    ///
357    /// **⚠️ The following code is in c ⚠️**
358    ///
359    /// ```c
360    /// static void
361    /// foo_widget_dispose (GObject *gobject)
362    /// {
363    ///   FooWidget *self = FOO_WIDGET (gobject);
364    ///
365    ///   // Dispose objects for which you have a reference...
366    ///
367    ///   // Clear the template children for this widget type
368    ///   gtk_widget_dispose_template (GTK_WIDGET (self), FOO_TYPE_WIDGET);
369    ///
370    ///   G_OBJECT_CLASS (foo_widget_parent_class)->dispose (gobject);
371    /// }
372    /// ```
373    ///
374    /// You can access widgets defined in the template using the
375    /// `Gtk::Widget::get_template_child()` function, but you will typically declare
376    /// a pointer in the instance private data structure of your type using the same
377    /// name as the widget in the template definition, and call
378    /// [`WidgetClassExt::bind_template_child_full()`][crate::subclass::prelude::WidgetClassExt::bind_template_child_full()] (or one of its wrapper macros
379    /// `widget_class_bind_template_child()` and `widget_class_bind_template_child_private()`)
380    /// with that name, e.g.
381    ///
382    /// **⚠️ The following code is in c ⚠️**
383    ///
384    /// ```c
385    /// typedef struct {
386    ///   GtkWidget *hello_button;
387    ///   GtkWidget *goodbye_button;
388    /// } FooWidgetPrivate;
389    ///
390    /// G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, GTK_TYPE_BOX)
391    ///
392    /// static void
393    /// foo_widget_dispose (GObject *gobject)
394    /// {
395    ///   gtk_widget_dispose_template (GTK_WIDGET (gobject), FOO_TYPE_WIDGET);
396    ///
397    ///   G_OBJECT_CLASS (foo_widget_parent_class)->dispose (gobject);
398    /// }
399    ///
400    /// static void
401    /// foo_widget_class_init (FooWidgetClass *klass)
402    /// {
403    ///   // ...
404    ///   G_OBJECT_CLASS (klass)->dispose = foo_widget_dispose;
405    ///
406    ///   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
407    ///                                                "/com/example/ui/foowidget.ui");
408    ///   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
409    ///                                                 FooWidget, hello_button);
410    ///   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
411    ///                                                 FooWidget, goodbye_button);
412    /// }
413    ///
414    /// static void
415    /// foo_widget_init (FooWidget *widget)
416    /// {
417    ///   gtk_widget_init_template (GTK_WIDGET (widget));
418    /// }
419    /// ```
420    ///
421    /// You can also use [`WidgetClassExt::bind_template_callback_full()`][crate::subclass::prelude::WidgetClassExt::bind_template_callback_full()] (or
422    /// is wrapper macro `widget_class_bind_template_callback()`) to connect
423    /// a signal callback defined in the template with a function visible in the
424    /// scope of the class, e.g.
425    ///
426    /// **⚠️ The following code is in c ⚠️**
427    ///
428    /// ```c
429    /// // the signal handler has the instance and user data swapped
430    /// // because of the swapped="yes" attribute in the template XML
431    /// static void
432    /// hello_button_clicked (FooWidget *self,
433    ///                       GtkButton *button)
434    /// {
435    ///   g_print ("Hello, world!\n");
436    /// }
437    ///
438    /// static void
439    /// foo_widget_class_init (FooWidgetClass *klass)
440    /// {
441    ///   // ...
442    ///   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
443    ///                                                "/com/example/ui/foowidget.ui");
444    ///   gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked);
445    /// }
446    /// ```
447    ///
448    /// This is an Abstract Base Class, you cannot instantiate it.
449    ///
450    /// ## Properties
451    ///
452    ///
453    /// #### `can-focus`
454    ///  Whether the widget or any of its descendents can accept
455    /// the input focus.
456    ///
457    /// This property is meant to be set by widget implementations,
458    /// typically in their instance init function.
459    ///
460    /// Readable | Writeable
461    ///
462    ///
463    /// #### `can-target`
464    ///  Whether the widget can receive pointer events.
465    ///
466    /// Readable | Writeable
467    ///
468    ///
469    /// #### `css-classes`
470    ///  A list of css classes applied to this widget.
471    ///
472    /// Readable | Writeable
473    ///
474    ///
475    /// #### `css-name`
476    ///  The name of this widget in the CSS tree.
477    ///
478    /// This property is meant to be set by widget implementations,
479    /// typically in their instance init function.
480    ///
481    /// Readable | Writeable | Construct Only
482    ///
483    ///
484    /// #### `cursor`
485    ///  The cursor used by @widget.
486    ///
487    /// Readable | Writeable
488    ///
489    ///
490    /// #### `focus-on-click`
491    ///  Whether the widget should grab focus when it is clicked with the mouse.
492    ///
493    /// This property is only relevant for widgets that can take focus.
494    ///
495    /// Readable | Writeable
496    ///
497    ///
498    /// #### `focusable`
499    ///  Whether this widget itself will accept the input focus.
500    ///
501    /// Readable | Writeable
502    ///
503    ///
504    /// #### `halign`
505    ///  How to distribute horizontal space if widget gets extra space.
506    ///
507    /// Readable | Writeable
508    ///
509    ///
510    /// #### `has-default`
511    ///  Whether the widget is the default widget.
512    ///
513    /// Readable
514    ///
515    ///
516    /// #### `has-focus`
517    ///  Whether the widget has the input focus.
518    ///
519    /// Readable
520    ///
521    ///
522    /// #### `has-tooltip`
523    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
524    /// signal on @widget.
525    ///
526    /// A true value indicates that @widget can have a tooltip, in this case
527    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
528    /// determine whether it will provide a tooltip or not.
529    ///
530    /// Readable | Writeable
531    ///
532    ///
533    /// #### `height-request`
534    ///  Overrides for height request of the widget.
535    ///
536    /// If this is -1, the natural request will be used.
537    ///
538    /// Readable | Writeable
539    ///
540    ///
541    /// #### `hexpand`
542    ///  Whether to expand horizontally.
543    ///
544    /// Readable | Writeable
545    ///
546    ///
547    /// #### `hexpand-set`
548    ///  Whether to use the `hexpand` property.
549    ///
550    /// Readable | Writeable
551    ///
552    ///
553    /// #### `layout-manager`
554    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
555    /// the preferred size of the widget, and allocate its children.
556    ///
557    /// This property is meant to be set by widget implementations,
558    /// typically in their instance init function.
559    ///
560    /// Readable | Writeable
561    ///
562    ///
563    /// #### `limit-events`
564    ///  Makes this widget act like a modal dialog, with respect to
565    /// event delivery.
566    ///
567    /// Global event controllers will not handle events with targets
568    /// inside the widget, unless they are set up to ignore propagation
569    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
570    ///
571    /// Readable | Writeable
572    ///
573    ///
574    /// #### `margin-bottom`
575    ///  Margin on bottom side of widget.
576    ///
577    /// This property adds margin outside of the widget's normal size
578    /// request, the margin will be added in addition to the size from
579    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
580    ///
581    /// Readable | Writeable
582    ///
583    ///
584    /// #### `margin-end`
585    ///  Margin on end of widget, horizontally.
586    ///
587    /// This property supports left-to-right and right-to-left text
588    /// directions.
589    ///
590    /// This property adds margin outside of the widget's normal size
591    /// request, the margin will be added in addition to the size from
592    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
593    ///
594    /// Readable | Writeable
595    ///
596    ///
597    /// #### `margin-start`
598    ///  Margin on start of widget, horizontally.
599    ///
600    /// This property supports left-to-right and right-to-left text
601    /// directions.
602    ///
603    /// This property adds margin outside of the widget's normal size
604    /// request, the margin will be added in addition to the size from
605    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
606    ///
607    /// Readable | Writeable
608    ///
609    ///
610    /// #### `margin-top`
611    ///  Margin on top side of widget.
612    ///
613    /// This property adds margin outside of the widget's normal size
614    /// request, the margin will be added in addition to the size from
615    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
616    ///
617    /// Readable | Writeable
618    ///
619    ///
620    /// #### `name`
621    ///  The name of the widget.
622    ///
623    /// Readable | Writeable
624    ///
625    ///
626    /// #### `opacity`
627    ///  The requested opacity of the widget.
628    ///
629    /// Readable | Writeable
630    ///
631    ///
632    /// #### `overflow`
633    ///  How content outside the widget's content area is treated.
634    ///
635    /// This property is meant to be set by widget implementations,
636    /// typically in their instance init function.
637    ///
638    /// Readable | Writeable
639    ///
640    ///
641    /// #### `parent`
642    ///  The parent widget of this widget.
643    ///
644    /// Readable
645    ///
646    ///
647    /// #### `receives-default`
648    ///  Whether the widget will receive the default action when it is focused.
649    ///
650    /// Readable | Writeable
651    ///
652    ///
653    /// #### `root`
654    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
655    ///
656    /// This will be `NULL` if the widget is not contained in a root widget.
657    ///
658    /// Readable
659    ///
660    ///
661    /// #### `scale-factor`
662    ///  The scale factor of the widget.
663    ///
664    /// Readable
665    ///
666    ///
667    /// #### `sensitive`
668    ///  Whether the widget responds to input.
669    ///
670    /// Readable | Writeable
671    ///
672    ///
673    /// #### `tooltip-markup`
674    ///  Sets the text of tooltip to be the given string, which is marked up
675    /// with Pango markup.
676    ///
677    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
678    ///
679    /// This is a convenience property which will take care of getting the
680    /// tooltip shown if the given string is not `NULL`:
681    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
682    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
683    /// the default signal handler.
684    ///
685    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
686    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
687    ///
688    /// Readable | Writeable
689    ///
690    ///
691    /// #### `tooltip-text`
692    ///  Sets the text of tooltip to be the given string.
693    ///
694    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
695    ///
696    /// This is a convenience property which will take care of getting the
697    /// tooltip shown if the given string is not `NULL`:
698    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
699    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
700    /// the default signal handler.
701    ///
702    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
703    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
704    ///
705    /// Readable | Writeable
706    ///
707    ///
708    /// #### `valign`
709    ///  How to distribute vertical space if widget gets extra space.
710    ///
711    /// Readable | Writeable
712    ///
713    ///
714    /// #### `vexpand`
715    ///  Whether to expand vertically.
716    ///
717    /// Readable | Writeable
718    ///
719    ///
720    /// #### `vexpand-set`
721    ///  Whether to use the `vexpand` property.
722    ///
723    /// Readable | Writeable
724    ///
725    ///
726    /// #### `visible`
727    ///  Whether the widget is visible.
728    ///
729    /// Readable | Writeable
730    ///
731    ///
732    /// #### `width-request`
733    ///  Overrides for width request of the widget.
734    ///
735    /// If this is -1, the natural request will be used.
736    ///
737    /// Readable | Writeable
738    /// <details><summary><h4>Accessible</h4></summary>
739    ///
740    ///
741    /// #### `accessible-role`
742    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
743    ///
744    /// The accessible role cannot be changed once set.
745    ///
746    /// Readable | Writeable
747    /// </details>
748    ///
749    /// ## Signals
750    ///
751    ///
752    /// #### `destroy`
753    ///  Signals that all holders of a reference to the widget should release
754    /// the reference that they hold.
755    ///
756    /// May result in finalization of the widget if all references are released.
757    ///
758    /// This signal is not suitable for saving widget state.
759    ///
760    ///
761    ///
762    ///
763    /// #### `direction-changed`
764    ///  Emitted when the text direction of a widget changes.
765    ///
766    ///
767    ///
768    ///
769    /// #### `hide`
770    ///  Emitted when @widget is hidden.
771    ///
772    ///
773    ///
774    ///
775    /// #### `keynav-failed`
776    ///  Emitted if keyboard navigation fails.
777    ///
778    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
779    ///
780    ///
781    ///
782    ///
783    /// #### `map`
784    ///  Emitted when @widget is going to be mapped.
785    ///
786    /// A widget is mapped when the widget is visible (which is controlled with
787    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
788    /// are also visible.
789    ///
790    /// The `::map` signal can be used to determine whether a widget will be drawn,
791    /// for instance it can resume an animation that was stopped during the
792    /// emission of [`unmap`][struct@crate::Widget#unmap].
793    ///
794    ///
795    ///
796    ///
797    /// #### `mnemonic-activate`
798    ///  Emitted when a widget is activated via a mnemonic.
799    ///
800    /// The default handler for this signal activates @widget if @group_cycling
801    /// is false, or just makes @widget grab focus if @group_cycling is true.
802    ///
803    ///
804    ///
805    ///
806    /// #### `move-focus`
807    ///  Emitted when the focus is moved.
808    ///
809    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
810    ///
811    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
812    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
813    ///
814    /// Action
815    ///
816    ///
817    /// #### `query-tooltip`
818    ///  Emitted when the widget’s tooltip is about to be shown.
819    ///
820    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
821    /// is true and the hover timeout has expired with the cursor hovering
822    /// above @widget; or emitted when @widget got focus in keyboard mode.
823    ///
824    /// Using the given coordinates, the signal handler should determine
825    /// whether a tooltip should be shown for @widget. If this is the case
826    /// true should be returned, false otherwise. Note that if @keyboard_mode
827    /// is true, the values of @x and @y are undefined and should not be used.
828    ///
829    /// The signal handler is free to manipulate @tooltip with the therefore
830    /// destined function calls.
831    ///
832    ///
833    ///
834    ///
835    /// #### `realize`
836    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
837    ///
838    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
839    /// or the widget has been mapped (that is, it is going to be drawn).
840    ///
841    ///
842    ///
843    ///
844    /// #### `show`
845    ///  Emitted when @widget is shown.
846    ///
847    ///
848    ///
849    ///
850    /// #### `state-flags-changed`
851    ///  Emitted when the widget state changes.
852    ///
853    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
854    ///
855    ///
856    ///
857    ///
858    /// #### `unmap`
859    ///  Emitted when @widget is going to be unmapped.
860    ///
861    /// A widget is unmapped when either it or any of its parents up to the
862    /// toplevel widget have been set as hidden.
863    ///
864    /// As `::unmap` indicates that a widget will not be shown any longer,
865    /// it can be used to, for example, stop an animation on the widget.
866    ///
867    ///
868    ///
869    ///
870    /// #### `unrealize`
871    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
872    ///
873    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
874    /// or the widget has been unmapped (that is, it is going to be hidden).
875    ///
876    ///
877    ///
878    /// # Implements
879    ///
880    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
881    #[doc(alias = "GtkWidget")]
882    pub struct Widget(Object<ffi::GtkWidget, ffi::GtkWidgetClass>) @implements Accessible, Buildable, ConstraintTarget;
883
884    match fn {
885        type_ => || ffi::gtk_widget_get_type(),
886    }
887}
888
889impl Widget {
890    pub const NONE: Option<&'static Widget> = None;
891
892    /// Obtains the default reading direction.
893    ///
894    /// See [`set_default_direction()`][Self::set_default_direction()].
895    ///
896    /// # Returns
897    ///
898    /// the current default direction
899    #[doc(alias = "gtk_widget_get_default_direction")]
900    #[doc(alias = "get_default_direction")]
901    pub fn default_direction() -> TextDirection {
902        assert_initialized_main_thread!();
903        unsafe { from_glib(ffi::gtk_widget_get_default_direction()) }
904    }
905
906    /// Sets the default reading direction for widgets.
907    ///
908    /// See [`WidgetExt::set_direction()`][crate::prelude::WidgetExt::set_direction()].
909    /// ## `dir`
910    /// the new default direction, either [enum@Gtk.TextDirection.ltr]
911    ///   or [enum@Gtk.TextDirection.rtl]
912    #[doc(alias = "gtk_widget_set_default_direction")]
913    pub fn set_default_direction(dir: TextDirection) {
914        assert_initialized_main_thread!();
915        unsafe {
916            ffi::gtk_widget_set_default_direction(dir.into_glib());
917        }
918    }
919}
920
921impl std::fmt::Display for Widget {
922    #[inline]
923    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
924        f.write_str(&WidgetExt::widget_name(self))
925    }
926}
927
928/// Trait containing all [`struct@Widget`] methods.
929///
930/// # Implementors
931///
932/// [`ActionBar`][struct@crate::ActionBar], [`Actionable`][struct@crate::Actionable], [`AppChooserButton`][struct@crate::AppChooserButton], [`AppChooserWidget`][struct@crate::AppChooserWidget], [`AppChooser`][struct@crate::AppChooser], [`AspectFrame`][struct@crate::AspectFrame], [`Box`][struct@crate::Box], [`Button`][struct@crate::Button], [`Calendar`][struct@crate::Calendar], [`CellEditable`][struct@crate::CellEditable], [`CellView`][struct@crate::CellView], [`CenterBox`][struct@crate::CenterBox], [`CheckButton`][struct@crate::CheckButton], [`ColorButton`][struct@crate::ColorButton], [`ColorChooserWidget`][struct@crate::ColorChooserWidget], [`ColorDialogButton`][struct@crate::ColorDialogButton], [`ColumnView`][struct@crate::ColumnView], [`ComboBox`][struct@crate::ComboBox], [`DragIcon`][struct@crate::DragIcon], [`DrawingArea`][struct@crate::DrawingArea], [`DropDown`][struct@crate::DropDown], [`EditableLabel`][struct@crate::EditableLabel], [`Editable`][struct@crate::Editable], [`Entry`][struct@crate::Entry], [`Expander`][struct@crate::Expander], [`FileChooserWidget`][struct@crate::FileChooserWidget], [`Fixed`][struct@crate::Fixed], [`FlowBoxChild`][struct@crate::FlowBoxChild], [`FlowBox`][struct@crate::FlowBox], [`FontButton`][struct@crate::FontButton], [`FontChooserWidget`][struct@crate::FontChooserWidget], [`FontDialogButton`][struct@crate::FontDialogButton], [`Frame`][struct@crate::Frame], [`GLArea`][struct@crate::GLArea], [`GraphicsOffload`][struct@crate::GraphicsOffload], [`Grid`][struct@crate::Grid], [`HeaderBar`][struct@crate::HeaderBar], [`IconView`][struct@crate::IconView], [`Image`][struct@crate::Image], [`InfoBar`][struct@crate::InfoBar], [`Inscription`][struct@crate::Inscription], [`Label`][struct@crate::Label], [`LevelBar`][struct@crate::LevelBar], [`ListBase`][struct@crate::ListBase], [`ListBoxRow`][struct@crate::ListBoxRow], [`ListBox`][struct@crate::ListBox], [`MediaControls`][struct@crate::MediaControls], [`MenuButton`][struct@crate::MenuButton], [`Native`][struct@crate::Native], [`Notebook`][struct@crate::Notebook], [`Overlay`][struct@crate::Overlay], [`Paned`][struct@crate::Paned], [`PasswordEntry`][struct@crate::PasswordEntry], [`Picture`][struct@crate::Picture], [`PopoverBin`][struct@crate::PopoverBin], [`PopoverMenuBar`][struct@crate::PopoverMenuBar], [`Popover`][struct@crate::Popover], [`ProgressBar`][struct@crate::ProgressBar], [`Range`][struct@crate::Range], [`Revealer`][struct@crate::Revealer], [`Root`][struct@crate::Root], [`ScaleButton`][struct@crate::ScaleButton], [`Scrollbar`][struct@crate::Scrollbar], [`ScrolledWindow`][struct@crate::ScrolledWindow], [`SearchBar`][struct@crate::SearchBar], [`SearchEntry`][struct@crate::SearchEntry], [`Separator`][struct@crate::Separator], [`ShortcutLabel`][struct@crate::ShortcutLabel], [`ShortcutsShortcut`][struct@crate::ShortcutsShortcut], [`SpinButton`][struct@crate::SpinButton], [`Spinner`][struct@crate::Spinner], [`StackSidebar`][struct@crate::StackSidebar], [`StackSwitcher`][struct@crate::StackSwitcher], [`Stack`][struct@crate::Stack], [`Statusbar`][struct@crate::Statusbar], [`Switch`][struct@crate::Switch], [`TextView`][struct@crate::TextView], [`Text`][struct@crate::Text], [`TreeExpander`][struct@crate::TreeExpander], [`TreeView`][struct@crate::TreeView], [`Video`][struct@crate::Video], [`Viewport`][struct@crate::Viewport], [`Widget`][struct@crate::Widget], [`WindowControls`][struct@crate::WindowControls], [`WindowHandle`][struct@crate::WindowHandle], [`Window`][struct@crate::Window]
933pub trait WidgetExt: IsA<Widget> + 'static {
934    /// Enables or disables an action installed with
935    /// [`WidgetClassExt::install_action()`][crate::subclass::prelude::WidgetClassExt::install_action()].
936    /// ## `action_name`
937    /// action name, such as "clipboard.paste"
938    /// ## `enabled`
939    /// whether the action is now enabled
940    #[doc(alias = "gtk_widget_action_set_enabled")]
941    fn action_set_enabled(&self, action_name: &str, enabled: bool) {
942        unsafe {
943            ffi::gtk_widget_action_set_enabled(
944                self.as_ref().to_glib_none().0,
945                action_name.to_glib_none().0,
946                enabled.into_glib(),
947            );
948        }
949    }
950
951    /// Activates the widget.
952    ///
953    /// The activation will emit the signal set using
954    /// [`WidgetClassExt::set_activate_signal()`][crate::subclass::prelude::WidgetClassExt::set_activate_signal()]
955    /// during class initialization.
956    ///
957    /// Activation is what happens when you press <kbd>Enter</kbd>
958    /// on a widget.
959    ///
960    /// If you wish to handle the activation keybinding yourself,
961    /// it is recommended to use [`WidgetClassExt::add_shortcut()`][crate::subclass::prelude::WidgetClassExt::add_shortcut()]
962    /// with an action created with [`SignalAction::new()`][crate::SignalAction::new()].
963    ///
964    /// If @self is not activatable, the function returns false.
965    ///
966    /// # Returns
967    ///
968    /// true if the widget was activated
969    #[doc(alias = "gtk_widget_activate")]
970    fn activate(&self) -> bool {
971        unsafe { from_glib(ffi::gtk_widget_activate(self.as_ref().to_glib_none().0)) }
972    }
973
974    /// Activates an action for the widget.
975    ///
976    /// The action is looked up in the action groups associated with
977    /// @self and its ancestors.
978    ///
979    /// If the action is in an action group added with
980    /// [`insert_action_group()`][Self::insert_action_group()], the @name is expected
981    /// to be prefixed with the prefix that was used when the group was
982    /// inserted.
983    ///
984    /// The arguments must match the actions expected parameter type,
985    /// as returned by [`ActionExtManual::parameter_type()`][crate::gio::prelude::ActionExtManual::parameter_type()].
986    /// ## `name`
987    /// the name of the action to activate
988    /// ## `args`
989    /// parameters to use
990    ///
991    /// # Returns
992    ///
993    /// true if the action was activated
994    #[doc(alias = "gtk_widget_activate_action_variant")]
995    #[doc(alias = "activate_action_variant")]
996    fn activate_action(
997        &self,
998        name: &str,
999        args: Option<&glib::Variant>,
1000    ) -> Result<(), glib::error::BoolError> {
1001        unsafe {
1002            glib::result_from_gboolean!(
1003                ffi::gtk_widget_activate_action_variant(
1004                    self.as_ref().to_glib_none().0,
1005                    name.to_glib_none().0,
1006                    args.to_glib_none().0
1007                ),
1008                "Action does not exist"
1009            )
1010        }
1011    }
1012
1013    /// Activates the `default.activate` action for the widget.
1014    ///
1015    /// The action is looked up in the same was as for
1016    /// `Gtk::Widget::activate_action()`.
1017    #[doc(alias = "gtk_widget_activate_default")]
1018    fn activate_default(&self) {
1019        unsafe {
1020            ffi::gtk_widget_activate_default(self.as_ref().to_glib_none().0);
1021        }
1022    }
1023
1024    /// Adds an event controller to the widget.
1025    ///
1026    /// The event controllers of a widget handle the events that are
1027    /// propagated to the widget.
1028    ///
1029    /// You will usually want to call this function right after
1030    /// creating any kind of [`EventController`][crate::EventController].
1031    /// ## `controller`
1032    /// an event controller that hasn't been
1033    ///   added to a widget yet
1034    #[doc(alias = "gtk_widget_add_controller")]
1035    fn add_controller(&self, controller: impl IsA<EventController>) {
1036        unsafe {
1037            ffi::gtk_widget_add_controller(
1038                self.as_ref().to_glib_none().0,
1039                controller.upcast().into_glib_ptr(),
1040            );
1041        }
1042    }
1043
1044    /// Adds a style class to the widget.
1045    ///
1046    /// After calling this function, the widget’s style will match
1047    /// for @css_class, according to CSS matching rules.
1048    ///
1049    /// Use [`remove_css_class()`][Self::remove_css_class()] to remove the
1050    /// style again.
1051    /// ## `css_class`
1052    /// style class to add to @self, without the leading period
1053    #[doc(alias = "gtk_widget_add_css_class")]
1054    fn add_css_class(&self, css_class: &str) {
1055        unsafe {
1056            ffi::gtk_widget_add_css_class(
1057                self.as_ref().to_glib_none().0,
1058                css_class.to_glib_none().0,
1059            );
1060        }
1061    }
1062
1063    /// Adds a widget to the list of mnemonic labels for this widget.
1064    ///
1065    /// See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()].
1066    ///
1067    /// Note that the list of mnemonic labels for the widget is cleared
1068    /// when the widget is destroyed, so the caller must make sure
1069    /// to update its internal state at this point as well.
1070    /// ## `label`
1071    /// a widget that acts as a mnemonic label for @self
1072    #[doc(alias = "gtk_widget_add_mnemonic_label")]
1073    fn add_mnemonic_label(&self, label: &impl IsA<Widget>) {
1074        unsafe {
1075            ffi::gtk_widget_add_mnemonic_label(
1076                self.as_ref().to_glib_none().0,
1077                label.as_ref().to_glib_none().0,
1078            );
1079        }
1080    }
1081
1082    /// Assigns size, position, (optionally) a baseline and transform
1083    /// to a child widget.
1084    ///
1085    /// In this function, the allocation and baseline may be adjusted.
1086    /// The given allocation will be forced to be bigger than the
1087    /// widget's minimum size, as well as at least 0×0 in size.
1088    ///
1089    /// This function is only used by widget implementations.
1090    ///
1091    /// For a version that does not take a transform, see
1092    /// [`size_allocate()`][Self::size_allocate()].
1093    /// ## `width`
1094    /// new width
1095    /// ## `height`
1096    /// new height
1097    /// ## `baseline`
1098    /// new baseline, or -1
1099    /// ## `transform`
1100    /// transformation to be applied
1101    #[doc(alias = "gtk_widget_allocate")]
1102    fn allocate(&self, width: i32, height: i32, baseline: i32, transform: Option<gsk::Transform>) {
1103        unsafe {
1104            ffi::gtk_widget_allocate(
1105                self.as_ref().to_glib_none().0,
1106                width,
1107                height,
1108                baseline,
1109                transform.into_glib_ptr(),
1110            );
1111        }
1112    }
1113
1114    /// Called by widgets as the user moves around the window using
1115    /// keyboard shortcuts.
1116    ///
1117    /// The @direction argument indicates what kind of motion is taking
1118    /// place (up, down, left, right, tab forward, tab backward).
1119    ///
1120    /// This function calls the [`WidgetImpl::focus()`][crate::subclass::prelude::WidgetImpl::focus()] virtual function;
1121    /// widgets can override the virtual function in order to implement
1122    /// appropriate focus behavior.
1123    ///
1124    /// The default `focus()` virtual function for a widget should return
1125    /// true if moving in @direction left the focus on a focusable location
1126    /// inside that widget, and false if moving in @direction moved the focus
1127    /// outside the widget. When returning true, widgets normally call
1128    /// [`grab_focus()`][Self::grab_focus()] to place the focus accordingly;
1129    /// when returning false, they don’t modify the current focus location.
1130    ///
1131    /// This function is used by custom widget implementations; if you're
1132    /// writing an app, you’d use [`grab_focus()`][Self::grab_focus()] to move
1133    /// the focus to a particular widget.
1134    /// ## `direction`
1135    /// direction of focus movement
1136    ///
1137    /// # Returns
1138    ///
1139    /// true if focus ended up inside @self
1140    #[doc(alias = "gtk_widget_child_focus")]
1141    fn child_focus(&self, direction: DirectionType) -> bool {
1142        unsafe {
1143            from_glib(ffi::gtk_widget_child_focus(
1144                self.as_ref().to_glib_none().0,
1145                direction.into_glib(),
1146            ))
1147        }
1148    }
1149
1150    /// Computes the bounds for @self in the coordinate space of @target.
1151    ///
1152    /// The bounds of widget are (the bounding box of) the region that it is
1153    /// expected to draw in. See the [coordinate system](coordinates.html)
1154    /// overview to learn more.
1155    ///
1156    /// If the operation is successful, true is returned. If @self has no
1157    /// bounds or the bounds cannot be expressed in @target's coordinate space
1158    /// (for example if both widgets are in different windows), false is
1159    /// returned and @bounds is set to the zero rectangle.
1160    ///
1161    /// It is valid for @self and @target to be the same widget.
1162    /// ## `target`
1163    /// the target widget
1164    ///
1165    /// # Returns
1166    ///
1167    /// true if the bounds could be computed
1168    ///
1169    /// ## `out_bounds`
1170    /// the rectangle taking the bounds
1171    #[doc(alias = "gtk_widget_compute_bounds")]
1172    fn compute_bounds(&self, target: &impl IsA<Widget>) -> Option<graphene::Rect> {
1173        unsafe {
1174            let mut out_bounds = graphene::Rect::uninitialized();
1175            let ret = from_glib(ffi::gtk_widget_compute_bounds(
1176                self.as_ref().to_glib_none().0,
1177                target.as_ref().to_glib_none().0,
1178                out_bounds.to_glib_none_mut().0,
1179            ));
1180            if ret { Some(out_bounds) } else { None }
1181        }
1182    }
1183
1184    /// Computes whether a parent widget should give this widget
1185    /// extra space when possible.
1186    ///
1187    /// Widgets with children should check this, rather than looking at
1188    /// [`hexpands()`][Self::hexpands()] or [`vexpands()`][Self::vexpands()].
1189    ///
1190    /// This function already checks whether the widget is visible, so
1191    /// visibility does not need to be checked separately. Non-visible
1192    /// widgets are not expanded.
1193    ///
1194    /// The computed expand value uses either the expand setting explicitly
1195    /// set on the widget itself, or, if none has been explicitly set,
1196    /// the widget may expand if some of its children do.
1197    /// ## `orientation`
1198    /// expand direction
1199    ///
1200    /// # Returns
1201    ///
1202    /// whether widget tree rooted here should be expanded
1203    #[doc(alias = "gtk_widget_compute_expand")]
1204    fn compute_expand(&self, orientation: Orientation) -> bool {
1205        unsafe {
1206            from_glib(ffi::gtk_widget_compute_expand(
1207                self.as_ref().to_glib_none().0,
1208                orientation.into_glib(),
1209            ))
1210        }
1211    }
1212
1213    /// Translates the given @point in @self's coordinates to coordinates
1214    /// in @target’s coordinate system.
1215    ///
1216    /// In order to perform this operation, both widgets must share a
1217    /// a common ancestor. If that is not the case, @out_point is set
1218    /// to (0, 0) and false is returned.
1219    /// ## `target`
1220    /// the widget to transform into
1221    /// ## `point`
1222    /// a point in @self's coordinate system
1223    ///
1224    /// # Returns
1225    ///
1226    /// true if @src_widget and @dest_widget have a common
1227    ///   ancestor, false otherwise
1228    ///
1229    /// ## `out_point`
1230    /// set to the corresponding coordinates in
1231    ///   @target's coordinate system
1232    #[doc(alias = "gtk_widget_compute_point")]
1233    fn compute_point(
1234        &self,
1235        target: &impl IsA<Widget>,
1236        point: &graphene::Point,
1237    ) -> Option<graphene::Point> {
1238        unsafe {
1239            let mut out_point = graphene::Point::uninitialized();
1240            let ret = from_glib(ffi::gtk_widget_compute_point(
1241                self.as_ref().to_glib_none().0,
1242                target.as_ref().to_glib_none().0,
1243                point.to_glib_none().0,
1244                out_point.to_glib_none_mut().0,
1245            ));
1246            if ret { Some(out_point) } else { None }
1247        }
1248    }
1249
1250    /// Computes a matrix suitable to describe a transformation from
1251    /// @self's coordinate system into @target's coordinate system.
1252    ///
1253    /// The transform can not be computed in certain cases, for example
1254    /// when @self and @target do not share a common ancestor. In that
1255    /// case @out_transform gets set to the identity matrix.
1256    ///
1257    /// To learn more about widget coordinate systems, see the coordinate
1258    /// system [overview](coordinates.html).
1259    /// ## `target`
1260    /// the target widget that the matrix will transform to
1261    ///
1262    /// # Returns
1263    ///
1264    /// true if the transform could be computed
1265    ///
1266    /// ## `out_transform`
1267    /// location to
1268    ///   store the final transformation
1269    #[doc(alias = "gtk_widget_compute_transform")]
1270    fn compute_transform(&self, target: &impl IsA<Widget>) -> Option<graphene::Matrix> {
1271        unsafe {
1272            let mut out_transform = graphene::Matrix::uninitialized();
1273            let ret = from_glib(ffi::gtk_widget_compute_transform(
1274                self.as_ref().to_glib_none().0,
1275                target.as_ref().to_glib_none().0,
1276                out_transform.to_glib_none_mut().0,
1277            ));
1278            if ret { Some(out_transform) } else { None }
1279        }
1280    }
1281
1282    /// Tests if a given point is contained in the widget.
1283    ///
1284    /// The coordinates for (x, y) must be in widget coordinates, so
1285    /// (0, 0) is assumed to be the top left of @self's content area.
1286    /// ## `x`
1287    /// X coordinate to test, relative to @self's origin
1288    /// ## `y`
1289    /// Y coordinate to test, relative to @self's origin
1290    ///
1291    /// # Returns
1292    ///
1293    /// true if @self contains the point (x, y)
1294    #[doc(alias = "gtk_widget_contains")]
1295    fn contains(&self, x: f64, y: f64) -> bool {
1296        unsafe {
1297            from_glib(ffi::gtk_widget_contains(
1298                self.as_ref().to_glib_none().0,
1299                x,
1300                y,
1301            ))
1302        }
1303    }
1304
1305    /// Creates a new [`pango::Context`][crate::pango::Context] that is configured for the widget.
1306    ///
1307    /// The [`pango::Context`][crate::pango::Context] will have the appropriate font map,
1308    /// font options, font description, and base direction set.
1309    ///
1310    /// See also [`pango_context()`][Self::pango_context()].
1311    ///
1312    /// # Returns
1313    ///
1314    /// the new [`pango::Context`][crate::pango::Context]
1315    #[doc(alias = "gtk_widget_create_pango_context")]
1316    fn create_pango_context(&self) -> pango::Context {
1317        unsafe {
1318            from_glib_full(ffi::gtk_widget_create_pango_context(
1319                self.as_ref().to_glib_none().0,
1320            ))
1321        }
1322    }
1323
1324    /// Creates a new [`pango::Layout`][crate::pango::Layout] that is configured for the widget.
1325    ///
1326    /// The [`pango::Layout`][crate::pango::Layout] will have the appropriate font map,
1327    /// font description, and base direction set.
1328    ///
1329    /// If you keep a [`pango::Layout`][crate::pango::Layout] created in this way around,
1330    /// you need to re-create it when the widgets [`pango::Context`][crate::pango::Context]
1331    /// is replaced. This can be tracked by listening to changes
1332    /// of the [`root`][struct@crate::Widget#root] property on the widget.
1333    /// ## `text`
1334    /// text to set on the layout
1335    ///
1336    /// # Returns
1337    ///
1338    /// the new [`pango::Layout`][crate::pango::Layout]
1339    #[doc(alias = "gtk_widget_create_pango_layout")]
1340    fn create_pango_layout(&self, text: Option<&str>) -> pango::Layout {
1341        unsafe {
1342            from_glib_full(ffi::gtk_widget_create_pango_layout(
1343                self.as_ref().to_glib_none().0,
1344                text.to_glib_none().0,
1345            ))
1346        }
1347    }
1348
1349    /// Checks to see if a drag movement has passed the GTK drag threshold.
1350    /// ## `start_x`
1351    /// X coordinate of start of drag
1352    /// ## `start_y`
1353    /// Y coordinate of start of drag
1354    /// ## `current_x`
1355    /// current X coordinate
1356    /// ## `current_y`
1357    /// current Y coordinate
1358    ///
1359    /// # Returns
1360    ///
1361    /// true if the drag threshold has been passed
1362    #[doc(alias = "gtk_drag_check_threshold")]
1363    fn drag_check_threshold(
1364        &self,
1365        start_x: i32,
1366        start_y: i32,
1367        current_x: i32,
1368        current_y: i32,
1369    ) -> bool {
1370        unsafe {
1371            from_glib(ffi::gtk_drag_check_threshold(
1372                self.as_ref().to_glib_none().0,
1373                start_x,
1374                start_y,
1375                current_x,
1376                current_y,
1377            ))
1378        }
1379    }
1380
1381    /// Notifies the user about an input-related error on the widget.
1382    ///
1383    /// If the [`gtk-error-bell`][struct@crate::Settings#gtk-error-bell] setting is true,
1384    /// it calls `Gdk::Surface::beep()`, otherwise it does nothing.
1385    ///
1386    /// Note that the effect of `Gdk::Surface::beep()` can be configured
1387    /// in many ways, depending on the windowing backend and the desktop
1388    /// environment or window manager that is used.
1389    #[doc(alias = "gtk_widget_error_bell")]
1390    fn error_bell(&self) {
1391        unsafe {
1392            ffi::gtk_widget_error_bell(self.as_ref().to_glib_none().0);
1393        }
1394    }
1395
1396    /// Returns the baseline that has currently been allocated to the widget.
1397    ///
1398    /// This function is intended to be used when implementing handlers
1399    /// for the [`Widget`][crate::Widget]Class.snapshot() function, and when allocating
1400    /// child widgets in [`Widget`][crate::Widget]Class.size_allocate().
1401    ///
1402    /// # Deprecated since 4.12
1403    ///
1404    /// Use [`baseline()`][Self::baseline()] instead
1405    ///
1406    /// # Returns
1407    ///
1408    /// the baseline of the @self, or -1 if none
1409    #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
1410    #[allow(deprecated)]
1411    #[doc(alias = "gtk_widget_get_allocated_baseline")]
1412    #[doc(alias = "get_allocated_baseline")]
1413    fn allocated_baseline(&self) -> i32 {
1414        unsafe { ffi::gtk_widget_get_allocated_baseline(self.as_ref().to_glib_none().0) }
1415    }
1416
1417    /// Returns the height that has currently been allocated to the widget.
1418    ///
1419    /// To learn more about widget sizes, see the coordinate
1420    /// system [overview](coordinates.html).
1421    ///
1422    /// # Deprecated since 4.12
1423    ///
1424    /// Use [`height()`][Self::height()] instead
1425    ///
1426    /// # Returns
1427    ///
1428    /// the height of the @self
1429    #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
1430    #[allow(deprecated)]
1431    #[doc(alias = "gtk_widget_get_allocated_height")]
1432    #[doc(alias = "get_allocated_height")]
1433    fn allocated_height(&self) -> i32 {
1434        unsafe { ffi::gtk_widget_get_allocated_height(self.as_ref().to_glib_none().0) }
1435    }
1436
1437    /// Returns the width that has currently been allocated to the widget.
1438    ///
1439    /// To learn more about widget sizes, see the coordinate
1440    /// system [overview](coordinates.html).
1441    ///
1442    /// # Deprecated since 4.12
1443    ///
1444    /// Use [`width()`][Self::width()] instead
1445    ///
1446    /// # Returns
1447    ///
1448    /// the width of the @self
1449    #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
1450    #[allow(deprecated)]
1451    #[doc(alias = "gtk_widget_get_allocated_width")]
1452    #[doc(alias = "get_allocated_width")]
1453    fn allocated_width(&self) -> i32 {
1454        unsafe { ffi::gtk_widget_get_allocated_width(self.as_ref().to_glib_none().0) }
1455    }
1456
1457    /// Retrieves the widget’s allocation.
1458    ///
1459    /// Note, when implementing a layout widget: a widget’s allocation
1460    /// will be its “adjusted” allocation, that is, the widget’s parent
1461    /// typically calls [`size_allocate()`][Self::size_allocate()] with an allocation,
1462    /// and that allocation is then adjusted (to handle margin
1463    /// and alignment for example) before assignment to the widget.
1464    /// [`allocation()`][Self::allocation()] returns the adjusted allocation that
1465    /// was actually assigned to the widget. The adjusted allocation is
1466    /// guaranteed to be completely contained within the
1467    /// [`size_allocate()`][Self::size_allocate()] allocation, however.
1468    ///
1469    /// So a layout widget is guaranteed that its children stay inside
1470    /// the assigned bounds, but not that they have exactly the bounds the
1471    /// widget assigned.
1472    ///
1473    /// # Deprecated since 4.12
1474    ///
1475    /// Use [`compute_bounds()`][Self::compute_bounds()],
1476    /// [`width()`][Self::width()] or [`height()`][Self::height()] instead.
1477    ///
1478    /// # Returns
1479    ///
1480    ///
1481    /// ## `allocation`
1482    /// a pointer to a `GtkAllocation` to copy to
1483    #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
1484    #[allow(deprecated)]
1485    #[doc(alias = "gtk_widget_get_allocation")]
1486    #[doc(alias = "get_allocation")]
1487    fn allocation(&self) -> Allocation {
1488        unsafe {
1489            let mut allocation = Allocation::uninitialized();
1490            ffi::gtk_widget_get_allocation(
1491                self.as_ref().to_glib_none().0,
1492                allocation.to_glib_none_mut().0,
1493            );
1494            allocation
1495        }
1496    }
1497
1498    /// Gets the first ancestor of the widget with type @widget_type.
1499    ///
1500    /// For example, `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)`
1501    /// gets the first [`Box`][crate::Box] that’s an ancestor of @self. No
1502    /// reference will be added to the returned widget; it should
1503    /// not be unreferenced.
1504    ///
1505    /// Note that unlike [`is_ancestor()`][Self::is_ancestor()], this function
1506    /// considers @self to be an ancestor of itself.
1507    /// ## `widget_type`
1508    /// ancestor type
1509    ///
1510    /// # Returns
1511    ///
1512    /// the ancestor widget
1513    #[doc(alias = "gtk_widget_get_ancestor")]
1514    #[doc(alias = "get_ancestor")]
1515    #[must_use]
1516    fn ancestor(&self, widget_type: glib::types::Type) -> Option<Widget> {
1517        unsafe {
1518            from_glib_none(ffi::gtk_widget_get_ancestor(
1519                self.as_ref().to_glib_none().0,
1520                widget_type.into_glib(),
1521            ))
1522        }
1523    }
1524
1525    /// Returns the baseline that has currently been allocated to the widget.
1526    ///
1527    /// This function is intended to be used when implementing handlers
1528    /// for the `GtkWidgetClass.snapshot()` function, and when allocating
1529    /// child widgets in `GtkWidgetClass.size_allocate()`.
1530    ///
1531    /// # Returns
1532    ///
1533    /// the baseline of the @self, or -1 if none
1534    #[cfg(feature = "v4_12")]
1535    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1536    #[doc(alias = "gtk_widget_get_baseline")]
1537    #[doc(alias = "get_baseline")]
1538    fn baseline(&self) -> i32 {
1539        unsafe { ffi::gtk_widget_get_baseline(self.as_ref().to_glib_none().0) }
1540    }
1541
1542    /// Determines whether the input focus can enter the widget or any
1543    /// of its children.
1544    ///
1545    /// See [`set_can_focus()`][Self::set_can_focus()].
1546    ///
1547    /// # Returns
1548    ///
1549    /// true if the input focus can enter @self
1550    #[doc(alias = "gtk_widget_get_can_focus")]
1551    #[doc(alias = "get_can_focus")]
1552    #[doc(alias = "can-focus")]
1553    fn can_focus(&self) -> bool {
1554        unsafe {
1555            from_glib(ffi::gtk_widget_get_can_focus(
1556                self.as_ref().to_glib_none().0,
1557            ))
1558        }
1559    }
1560
1561    /// Queries whether the widget can be the target of pointer events.
1562    ///
1563    /// # Returns
1564    ///
1565    /// true if @self can receive pointer events
1566    #[doc(alias = "gtk_widget_get_can_target")]
1567    #[doc(alias = "get_can_target")]
1568    #[doc(alias = "can-target")]
1569    fn can_target(&self) -> bool {
1570        unsafe {
1571            from_glib(ffi::gtk_widget_get_can_target(
1572                self.as_ref().to_glib_none().0,
1573            ))
1574        }
1575    }
1576
1577    /// Gets the value set with [`set_child_visible()`][Self::set_child_visible()].
1578    ///
1579    /// If you feel a need to use this function, your code probably
1580    /// needs reorganization.
1581    ///
1582    /// This function is only useful for widget implementations
1583    /// and should never be called by an application.
1584    ///
1585    /// # Returns
1586    ///
1587    /// true if the widget is mapped with the parent
1588    #[doc(alias = "gtk_widget_get_child_visible")]
1589    #[doc(alias = "get_child_visible")]
1590    fn is_child_visible(&self) -> bool {
1591        unsafe {
1592            from_glib(ffi::gtk_widget_get_child_visible(
1593                self.as_ref().to_glib_none().0,
1594            ))
1595        }
1596    }
1597
1598    /// Gets the clipboard object for the widget.
1599    ///
1600    /// This is a utility function to get the clipboard object for the
1601    /// display that @self is using.
1602    ///
1603    /// Note that this function always works, even when @self is not
1604    /// realized yet.
1605    ///
1606    /// # Returns
1607    ///
1608    /// the appropriate clipboard object
1609    #[doc(alias = "gtk_widget_get_clipboard")]
1610    #[doc(alias = "get_clipboard")]
1611    fn clipboard(&self) -> gdk::Clipboard {
1612        unsafe {
1613            from_glib_none(ffi::gtk_widget_get_clipboard(
1614                self.as_ref().to_glib_none().0,
1615            ))
1616        }
1617    }
1618
1619    /// Gets the current foreground color for the widget’s style.
1620    ///
1621    /// This function should only be used in snapshot
1622    /// implementations that need to do custom drawing
1623    /// with the foreground color.
1624    ///
1625    /// # Returns
1626    ///
1627    ///
1628    /// ## `color`
1629    /// return location for the color
1630    #[cfg(feature = "v4_10")]
1631    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
1632    #[doc(alias = "gtk_widget_get_color")]
1633    #[doc(alias = "get_color")]
1634    fn color(&self) -> gdk::RGBA {
1635        unsafe {
1636            let mut color = gdk::RGBA::uninitialized();
1637            ffi::gtk_widget_get_color(self.as_ref().to_glib_none().0, color.to_glib_none_mut().0);
1638            color
1639        }
1640    }
1641
1642    /// Returns the list of style classes applied to the widget.
1643    ///
1644    /// # Returns
1645    ///
1646    /// a `NULL`-terminated list of
1647    ///   css classes currently applied to @self
1648    #[doc(alias = "gtk_widget_get_css_classes")]
1649    #[doc(alias = "get_css_classes")]
1650    #[doc(alias = "css-classes")]
1651    fn css_classes(&self) -> Vec<glib::GString> {
1652        unsafe {
1653            FromGlibPtrContainer::from_glib_full(ffi::gtk_widget_get_css_classes(
1654                self.as_ref().to_glib_none().0,
1655            ))
1656        }
1657    }
1658
1659    /// Returns the CSS name of the widget.
1660    ///
1661    /// # Returns
1662    ///
1663    /// the CSS name
1664    #[doc(alias = "gtk_widget_get_css_name")]
1665    #[doc(alias = "get_css_name")]
1666    #[doc(alias = "css-name")]
1667    fn css_name(&self) -> glib::GString {
1668        unsafe { from_glib_none(ffi::gtk_widget_get_css_name(self.as_ref().to_glib_none().0)) }
1669    }
1670
1671    /// Gets the cursor set on the widget.
1672    ///
1673    /// See [`set_cursor()`][Self::set_cursor()] for details.
1674    ///
1675    /// # Returns
1676    ///
1677    /// the cursor
1678    ///   that is set on @self
1679    #[doc(alias = "gtk_widget_get_cursor")]
1680    #[doc(alias = "get_cursor")]
1681    fn cursor(&self) -> Option<gdk::Cursor> {
1682        unsafe { from_glib_none(ffi::gtk_widget_get_cursor(self.as_ref().to_glib_none().0)) }
1683    }
1684
1685    /// Gets the reading direction for the widget.
1686    ///
1687    /// See [`set_direction()`][Self::set_direction()].
1688    ///
1689    /// # Returns
1690    ///
1691    /// the reading direction for the widget
1692    #[doc(alias = "gtk_widget_get_direction")]
1693    #[doc(alias = "get_direction")]
1694    fn direction(&self) -> TextDirection {
1695        unsafe {
1696            from_glib(ffi::gtk_widget_get_direction(
1697                self.as_ref().to_glib_none().0,
1698            ))
1699        }
1700    }
1701
1702    /// Get the display for the window that the widget belongs to.
1703    ///
1704    /// This function can only be called after the widget has been
1705    /// added to a widget hierarchy with a [`Root`][crate::Root] at the top.
1706    ///
1707    /// In general, you should only create display-specific
1708    /// resources when a widget has been realized, and you should
1709    /// free those resources when the widget is unrealized.
1710    ///
1711    /// # Returns
1712    ///
1713    /// the display for this widget
1714    #[doc(alias = "gtk_widget_get_display")]
1715    #[doc(alias = "get_display")]
1716    fn display(&self) -> gdk::Display {
1717        unsafe { from_glib_none(ffi::gtk_widget_get_display(self.as_ref().to_glib_none().0)) }
1718    }
1719
1720    /// Returns the widget’s first child.
1721    ///
1722    /// This function is primarily meant for widget implementations.
1723    ///
1724    /// # Returns
1725    ///
1726    /// the widget's first child
1727    #[doc(alias = "gtk_widget_get_first_child")]
1728    #[doc(alias = "get_first_child")]
1729    #[must_use]
1730    fn first_child(&self) -> Option<Widget> {
1731        unsafe {
1732            from_glib_none(ffi::gtk_widget_get_first_child(
1733                self.as_ref().to_glib_none().0,
1734            ))
1735        }
1736    }
1737
1738    /// Returns the focus child of the widget.
1739    ///
1740    /// # Returns
1741    ///
1742    /// the current focus
1743    ///   child of @self
1744    #[doc(alias = "gtk_widget_get_focus_child")]
1745    #[doc(alias = "get_focus_child")]
1746    #[must_use]
1747    fn focus_child(&self) -> Option<Widget> {
1748        unsafe {
1749            from_glib_none(ffi::gtk_widget_get_focus_child(
1750                self.as_ref().to_glib_none().0,
1751            ))
1752        }
1753    }
1754
1755    /// Returns whether the widget should grab focus when it is clicked
1756    /// with the mouse.
1757    ///
1758    /// See [`set_focus_on_click()`][Self::set_focus_on_click()].
1759    ///
1760    /// # Returns
1761    ///
1762    /// true if the widget should grab focus when it is
1763    ///   clicked with the mouse
1764    #[doc(alias = "gtk_widget_get_focus_on_click")]
1765    #[doc(alias = "get_focus_on_click")]
1766    #[doc(alias = "focus-on-click")]
1767    fn gets_focus_on_click(&self) -> bool {
1768        unsafe {
1769            from_glib(ffi::gtk_widget_get_focus_on_click(
1770                self.as_ref().to_glib_none().0,
1771            ))
1772        }
1773    }
1774
1775    /// Determines whether the widget can own the input focus.
1776    ///
1777    /// See [`set_focusable()`][Self::set_focusable()].
1778    ///
1779    /// # Returns
1780    ///
1781    /// true if @self can own the input focus
1782    #[doc(alias = "gtk_widget_get_focusable")]
1783    #[doc(alias = "get_focusable")]
1784    #[doc(alias = "focusable")]
1785    fn is_focusable(&self) -> bool {
1786        unsafe {
1787            from_glib(ffi::gtk_widget_get_focusable(
1788                self.as_ref().to_glib_none().0,
1789            ))
1790        }
1791    }
1792
1793    /// Gets the font map of the widget.
1794    ///
1795    /// See [`set_font_map()`][Self::set_font_map()].
1796    ///
1797    /// # Returns
1798    ///
1799    /// the font map of @self
1800    #[doc(alias = "gtk_widget_get_font_map")]
1801    #[doc(alias = "get_font_map")]
1802    fn font_map(&self) -> Option<pango::FontMap> {
1803        unsafe { from_glib_none(ffi::gtk_widget_get_font_map(self.as_ref().to_glib_none().0)) }
1804    }
1805
1806    /// Returns the [`cairo::FontOptions`][crate::cairo::FontOptions] of the widget.
1807    ///
1808    /// Seee [`set_font_options()`][Self::set_font_options()].
1809    ///
1810    /// # Deprecated since 4.16
1811    ///
1812    ///
1813    /// # Returns
1814    ///
1815    /// the [`cairo::FontOptions`][crate::cairo::FontOptions] of widget
1816    #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
1817    #[allow(deprecated)]
1818    #[doc(alias = "gtk_widget_get_font_options")]
1819    #[doc(alias = "get_font_options")]
1820    fn font_options(&self) -> Option<cairo::FontOptions> {
1821        unsafe {
1822            from_glib_none(ffi::gtk_widget_get_font_options(
1823                self.as_ref().to_glib_none().0,
1824            ))
1825        }
1826    }
1827
1828    /// Obtains the frame clock for a widget.
1829    ///
1830    /// The frame clock is a global “ticker” that can be used to drive
1831    /// animations and repaints. The most common reason to get the frame
1832    /// clock is to call [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], in order
1833    /// to get a time to use for animating. For example you might record
1834    /// the start of the animation with an initial value from
1835    /// [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], and then update the animation
1836    /// by calling [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()] again during each repaint.
1837    ///
1838    /// [`FrameClock::request_phase()`][crate::gdk::FrameClock::request_phase()] will result in a new frame on the
1839    /// clock, but won’t necessarily repaint any widgets. To repaint a widget,
1840    /// you have to use [`queue_draw()`][Self::queue_draw()] which invalidates the
1841    /// widget (thus scheduling it to receive a draw on the next frame).
1842    /// [`queue_draw()`][Self::queue_draw()] will also end up requesting a frame
1843    /// on the appropriate frame clock.
1844    ///
1845    /// A widget’s frame clock will not change while the widget is mapped.
1846    /// Reparenting a widget (which implies a temporary unmap) can change
1847    /// the widget’s frame clock.
1848    ///
1849    /// Unrealized widgets do not have a frame clock.
1850    ///
1851    /// # Returns
1852    ///
1853    /// the frame clock
1854    #[doc(alias = "gtk_widget_get_frame_clock")]
1855    #[doc(alias = "get_frame_clock")]
1856    fn frame_clock(&self) -> Option<gdk::FrameClock> {
1857        unsafe {
1858            from_glib_none(ffi::gtk_widget_get_frame_clock(
1859                self.as_ref().to_glib_none().0,
1860            ))
1861        }
1862    }
1863
1864    /// Gets the horizontal alignment of the widget.
1865    ///
1866    /// For backwards compatibility reasons this method will never return
1867    /// one of the baseline alignments, but instead it will convert it to
1868    /// [enum@Gtk.Align.fill] or [enum@Gtk.Align.center].
1869    ///
1870    /// Baselines are not supported for horizontal alignment.
1871    ///
1872    /// # Returns
1873    ///
1874    /// the horizontal alignment of @self
1875    #[doc(alias = "gtk_widget_get_halign")]
1876    #[doc(alias = "get_halign")]
1877    fn halign(&self) -> Align {
1878        unsafe { from_glib(ffi::gtk_widget_get_halign(self.as_ref().to_glib_none().0)) }
1879    }
1880
1881    /// Returns the current value of the `has-tooltip` property.
1882    ///
1883    /// # Returns
1884    ///
1885    /// current value of `has-tooltip` on @self
1886    #[doc(alias = "gtk_widget_get_has_tooltip")]
1887    #[doc(alias = "get_has_tooltip")]
1888    #[doc(alias = "has-tooltip")]
1889    fn has_tooltip(&self) -> bool {
1890        unsafe {
1891            from_glib(ffi::gtk_widget_get_has_tooltip(
1892                self.as_ref().to_glib_none().0,
1893            ))
1894        }
1895    }
1896
1897    /// Returns the content height of the widget.
1898    ///
1899    /// This function returns the height passed to its
1900    /// size-allocate implementation, which is the height you
1901    /// should be using in [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()].
1902    ///
1903    /// For pointer events, see [`contains()`][Self::contains()].
1904    ///
1905    /// To learn more about widget sizes, see the coordinate
1906    /// system [overview](coordinates.html).
1907    ///
1908    /// # Returns
1909    ///
1910    /// The height of @self
1911    #[doc(alias = "gtk_widget_get_height")]
1912    #[doc(alias = "get_height")]
1913    fn height(&self) -> i32 {
1914        unsafe { ffi::gtk_widget_get_height(self.as_ref().to_glib_none().0) }
1915    }
1916
1917    /// Gets whether the widget would like any available extra horizontal
1918    /// space.
1919    ///
1920    /// When a user resizes a window, widgets with expand set to true generally
1921    /// receive the extra space. For example, a list or scrollable area
1922    /// or document in your window would often be set to expand.
1923    ///
1924    /// Widgets with children should use [`compute_expand()`][Self::compute_expand()]
1925    /// rather than this function, to see whether any of its children,
1926    /// has the expand flag set. If any child of a widget wants to
1927    /// expand, the parent may ask to expand also.
1928    ///
1929    /// This function only looks at the widget’s own hexpand flag, rather
1930    /// than computing whether the entire widget tree rooted at this widget
1931    /// wants to expand.
1932    ///
1933    /// # Returns
1934    ///
1935    /// whether hexpand flag is set
1936    #[doc(alias = "gtk_widget_get_hexpand")]
1937    #[doc(alias = "get_hexpand")]
1938    #[doc(alias = "hexpand")]
1939    fn hexpands(&self) -> bool {
1940        unsafe { from_glib(ffi::gtk_widget_get_hexpand(self.as_ref().to_glib_none().0)) }
1941    }
1942
1943    /// Gets whether the `hexpand` flag has been explicitly set.
1944    ///
1945    /// If [`hexpand`][struct@crate::Widget#hexpand] property is set, then it
1946    /// overrides any computed expand value based on child widgets.
1947    /// If `hexpand` is not set, then the expand value depends on
1948    /// whether any children of the widget would like to expand.
1949    ///
1950    /// There are few reasons to use this function, but it’s here
1951    /// for completeness and consistency.
1952    ///
1953    /// # Returns
1954    ///
1955    /// whether hexpand has been explicitly set
1956    #[doc(alias = "gtk_widget_get_hexpand_set")]
1957    #[doc(alias = "get_hexpand_set")]
1958    #[doc(alias = "hexpand-set")]
1959    fn is_hexpand_set(&self) -> bool {
1960        unsafe {
1961            from_glib(ffi::gtk_widget_get_hexpand_set(
1962                self.as_ref().to_glib_none().0,
1963            ))
1964        }
1965    }
1966
1967    /// Returns the widget’s last child.
1968    ///
1969    /// This function is primarily meant for widget implementations.
1970    ///
1971    /// # Returns
1972    ///
1973    /// the widget's last child
1974    #[doc(alias = "gtk_widget_get_last_child")]
1975    #[doc(alias = "get_last_child")]
1976    #[must_use]
1977    fn last_child(&self) -> Option<Widget> {
1978        unsafe {
1979            from_glib_none(ffi::gtk_widget_get_last_child(
1980                self.as_ref().to_glib_none().0,
1981            ))
1982        }
1983    }
1984
1985    /// Retrieves the layout manager of the widget.
1986    ///
1987    /// See [`set_layout_manager()`][Self::set_layout_manager()].
1988    ///
1989    /// # Returns
1990    ///
1991    /// the layout manager of @self
1992    #[doc(alias = "gtk_widget_get_layout_manager")]
1993    #[doc(alias = "get_layout_manager")]
1994    #[doc(alias = "layout-manager")]
1995    fn layout_manager(&self) -> Option<LayoutManager> {
1996        unsafe {
1997            from_glib_none(ffi::gtk_widget_get_layout_manager(
1998                self.as_ref().to_glib_none().0,
1999            ))
2000        }
2001    }
2002
2003    /// Gets the value of the [`limit-events`][struct@crate::Widget#limit-events] property.
2004    #[cfg(feature = "v4_18")]
2005    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2006    #[doc(alias = "gtk_widget_get_limit_events")]
2007    #[doc(alias = "get_limit_events")]
2008    #[doc(alias = "limit-events")]
2009    fn is_limit_events(&self) -> bool {
2010        unsafe {
2011            from_glib(ffi::gtk_widget_get_limit_events(
2012                self.as_ref().to_glib_none().0,
2013            ))
2014        }
2015    }
2016
2017    /// Returns whether the widget is mapped.
2018    ///
2019    /// # Returns
2020    ///
2021    /// true if the widget is mapped
2022    #[doc(alias = "gtk_widget_get_mapped")]
2023    #[doc(alias = "get_mapped")]
2024    fn is_mapped(&self) -> bool {
2025        unsafe { from_glib(ffi::gtk_widget_get_mapped(self.as_ref().to_glib_none().0)) }
2026    }
2027
2028    /// Gets the bottom margin of the widget.
2029    ///
2030    /// # Returns
2031    ///
2032    /// The bottom margin of @self
2033    #[doc(alias = "gtk_widget_get_margin_bottom")]
2034    #[doc(alias = "get_margin_bottom")]
2035    #[doc(alias = "margin-bottom")]
2036    fn margin_bottom(&self) -> i32 {
2037        unsafe { ffi::gtk_widget_get_margin_bottom(self.as_ref().to_glib_none().0) }
2038    }
2039
2040    /// Gets the end margin of the widget.
2041    ///
2042    /// # Returns
2043    ///
2044    /// The end margin of @self
2045    #[doc(alias = "gtk_widget_get_margin_end")]
2046    #[doc(alias = "get_margin_end")]
2047    #[doc(alias = "margin-end")]
2048    fn margin_end(&self) -> i32 {
2049        unsafe { ffi::gtk_widget_get_margin_end(self.as_ref().to_glib_none().0) }
2050    }
2051
2052    /// Gets the start margin of the widget.
2053    ///
2054    /// # Returns
2055    ///
2056    /// The start margin of @self
2057    #[doc(alias = "gtk_widget_get_margin_start")]
2058    #[doc(alias = "get_margin_start")]
2059    #[doc(alias = "margin-start")]
2060    fn margin_start(&self) -> i32 {
2061        unsafe { ffi::gtk_widget_get_margin_start(self.as_ref().to_glib_none().0) }
2062    }
2063
2064    /// Gets the top margin of the widget.
2065    ///
2066    /// # Returns
2067    ///
2068    /// The top margin of @self
2069    #[doc(alias = "gtk_widget_get_margin_top")]
2070    #[doc(alias = "get_margin_top")]
2071    #[doc(alias = "margin-top")]
2072    fn margin_top(&self) -> i32 {
2073        unsafe { ffi::gtk_widget_get_margin_top(self.as_ref().to_glib_none().0) }
2074    }
2075
2076    /// Retrieves the name of a widget.
2077    ///
2078    /// See [`set_widget_name()`][Self::set_widget_name()] for the significance of widget names.
2079    ///
2080    /// # Returns
2081    ///
2082    /// name of the widget
2083    #[doc(alias = "gtk_widget_get_name")]
2084    #[doc(alias = "get_name")]
2085    #[doc(alias = "name")]
2086    fn widget_name(&self) -> glib::GString {
2087        unsafe { from_glib_none(ffi::gtk_widget_get_name(self.as_ref().to_glib_none().0)) }
2088    }
2089
2090    /// Returns the nearest [`Native`][crate::Native] ancestor of the widget.
2091    ///
2092    /// This function will return `NULL` if the widget is not
2093    /// contained inside a widget tree with a native ancestor.
2094    ///
2095    /// [`Native`][crate::Native] widgets will return themselves here.
2096    ///
2097    /// # Returns
2098    ///
2099    /// the [`Native`][crate::Native] ancestor of @self
2100    #[doc(alias = "gtk_widget_get_native")]
2101    #[doc(alias = "get_native")]
2102    fn native(&self) -> Option<Native> {
2103        unsafe { from_glib_none(ffi::gtk_widget_get_native(self.as_ref().to_glib_none().0)) }
2104    }
2105
2106    /// Returns the widget’s next sibling.
2107    ///
2108    /// This function is primarily meant for widget implementations.
2109    ///
2110    /// # Returns
2111    ///
2112    /// the widget's next sibling
2113    #[doc(alias = "gtk_widget_get_next_sibling")]
2114    #[doc(alias = "get_next_sibling")]
2115    #[must_use]
2116    fn next_sibling(&self) -> Option<Widget> {
2117        unsafe {
2118            from_glib_none(ffi::gtk_widget_get_next_sibling(
2119                self.as_ref().to_glib_none().0,
2120            ))
2121        }
2122    }
2123
2124    /// Fetches the requested opacity for the widget.
2125    ///
2126    /// See [`set_opacity()`][Self::set_opacity()].
2127    ///
2128    /// # Returns
2129    ///
2130    /// the requested opacity for this widget
2131    #[doc(alias = "gtk_widget_get_opacity")]
2132    #[doc(alias = "get_opacity")]
2133    fn opacity(&self) -> f64 {
2134        unsafe { ffi::gtk_widget_get_opacity(self.as_ref().to_glib_none().0) }
2135    }
2136
2137    /// Returns the widget’s overflow value.
2138    ///
2139    /// # Returns
2140    ///
2141    /// The widget's overflow value
2142    #[doc(alias = "gtk_widget_get_overflow")]
2143    #[doc(alias = "get_overflow")]
2144    fn overflow(&self) -> Overflow {
2145        unsafe { from_glib(ffi::gtk_widget_get_overflow(self.as_ref().to_glib_none().0)) }
2146    }
2147
2148    /// Gets a [`pango::Context`][crate::pango::Context] that is configured for the widget.
2149    ///
2150    /// The [`pango::Context`][crate::pango::Context] will have the appropriate font map, font description,
2151    /// and base direction set.
2152    ///
2153    /// Unlike the context returned by [`create_pango_context()`][Self::create_pango_context()],
2154    /// this context is owned by the widget (it can be used until the screen
2155    /// for the widget changes or the widget is removed from its toplevel),
2156    /// and will be updated to match any changes to the widget’s attributes.
2157    /// This can be tracked by listening to changes of the
2158    /// [`root`][struct@crate::Widget#root] property on the widget.
2159    ///
2160    /// # Returns
2161    ///
2162    /// the [`pango::Context`][crate::pango::Context] for the widget
2163    #[doc(alias = "gtk_widget_get_pango_context")]
2164    #[doc(alias = "get_pango_context")]
2165    fn pango_context(&self) -> pango::Context {
2166        unsafe {
2167            from_glib_none(ffi::gtk_widget_get_pango_context(
2168                self.as_ref().to_glib_none().0,
2169            ))
2170        }
2171    }
2172
2173    /// Returns the parent widget of the widget.
2174    ///
2175    /// # Returns
2176    ///
2177    /// the parent widget of @self
2178    #[doc(alias = "gtk_widget_get_parent")]
2179    #[doc(alias = "get_parent")]
2180    #[must_use]
2181    fn parent(&self) -> Option<Widget> {
2182        unsafe { from_glib_none(ffi::gtk_widget_get_parent(self.as_ref().to_glib_none().0)) }
2183    }
2184
2185    /// Retrieves the minimum and natural size of a widget, taking
2186    /// into account the widget’s preference for height-for-width management.
2187    ///
2188    /// This is used to retrieve a suitable size by container widgets which do
2189    /// not impose any restrictions on the child placement. It can be used
2190    /// to deduce toplevel window and menu sizes as well as child widgets in
2191    /// free-form containers such as [`Fixed`][crate::Fixed].
2192    ///
2193    /// Handle with care. Note that the natural height of a height-for-width
2194    /// widget will generally be a smaller size than the minimum height, since
2195    /// the required height for the natural width is generally smaller than the
2196    /// required height for the minimum width.
2197    ///
2198    /// Use [`measure()`][Self::measure()] if you want to support baseline alignment.
2199    ///
2200    /// # Returns
2201    ///
2202    ///
2203    /// ## `minimum_size`
2204    /// location for storing the minimum size
2205    ///
2206    /// ## `natural_size`
2207    /// location for storing the natural size
2208    #[doc(alias = "gtk_widget_get_preferred_size")]
2209    #[doc(alias = "get_preferred_size")]
2210    fn preferred_size(&self) -> (Requisition, Requisition) {
2211        unsafe {
2212            let mut minimum_size = Requisition::uninitialized();
2213            let mut natural_size = Requisition::uninitialized();
2214            ffi::gtk_widget_get_preferred_size(
2215                self.as_ref().to_glib_none().0,
2216                minimum_size.to_glib_none_mut().0,
2217                natural_size.to_glib_none_mut().0,
2218            );
2219            (minimum_size, natural_size)
2220        }
2221    }
2222
2223    /// Returns the widget’s previous sibling.
2224    ///
2225    /// This function is primarily meant for widget implementations.
2226    ///
2227    /// # Returns
2228    ///
2229    /// the widget's previous sibling
2230    #[doc(alias = "gtk_widget_get_prev_sibling")]
2231    #[doc(alias = "get_prev_sibling")]
2232    #[must_use]
2233    fn prev_sibling(&self) -> Option<Widget> {
2234        unsafe {
2235            from_glib_none(ffi::gtk_widget_get_prev_sibling(
2236                self.as_ref().to_glib_none().0,
2237            ))
2238        }
2239    }
2240
2241    /// Gets the primary clipboard of the widget.
2242    ///
2243    /// This is a utility function to get the primary clipboard object
2244    /// for the display that @self is using.
2245    ///
2246    /// Note that this function always works, even when @self is not
2247    /// realized yet.
2248    ///
2249    /// # Returns
2250    ///
2251    /// the appropriate clipboard object
2252    #[doc(alias = "gtk_widget_get_primary_clipboard")]
2253    #[doc(alias = "get_primary_clipboard")]
2254    fn primary_clipboard(&self) -> gdk::Clipboard {
2255        unsafe {
2256            from_glib_none(ffi::gtk_widget_get_primary_clipboard(
2257                self.as_ref().to_glib_none().0,
2258            ))
2259        }
2260    }
2261
2262    /// Determines whether the widget is realized.
2263    ///
2264    /// # Returns
2265    ///
2266    /// true if @self is realized
2267    #[doc(alias = "gtk_widget_get_realized")]
2268    #[doc(alias = "get_realized")]
2269    fn is_realized(&self) -> bool {
2270        unsafe { from_glib(ffi::gtk_widget_get_realized(self.as_ref().to_glib_none().0)) }
2271    }
2272
2273    /// Determines whether the widget is always treated as the default widget
2274    /// within its toplevel when it has the focus, even if another widget
2275    /// is the default.
2276    ///
2277    /// See [`set_receives_default()`][Self::set_receives_default()].
2278    ///
2279    /// # Returns
2280    ///
2281    /// true if @self acts as the default widget when focused
2282    #[doc(alias = "gtk_widget_get_receives_default")]
2283    #[doc(alias = "get_receives_default")]
2284    #[doc(alias = "receives-default")]
2285    fn receives_default(&self) -> bool {
2286        unsafe {
2287            from_glib(ffi::gtk_widget_get_receives_default(
2288                self.as_ref().to_glib_none().0,
2289            ))
2290        }
2291    }
2292
2293    /// Gets whether the widget prefers a height-for-width layout
2294    /// or a width-for-height layout.
2295    ///
2296    /// Single-child widgets generally propagate the preference of
2297    /// their child, more complex widgets need to request something
2298    /// either in context of their children or in context of their
2299    /// allocation capabilities.
2300    ///
2301    /// # Returns
2302    ///
2303    /// The [`SizeRequestMode`][crate::SizeRequestMode] preferred by @self.
2304    #[doc(alias = "gtk_widget_get_request_mode")]
2305    #[doc(alias = "get_request_mode")]
2306    fn request_mode(&self) -> SizeRequestMode {
2307        unsafe {
2308            from_glib(ffi::gtk_widget_get_request_mode(
2309                self.as_ref().to_glib_none().0,
2310            ))
2311        }
2312    }
2313
2314    /// Returns the [`Root`][crate::Root] widget of the widget.
2315    ///
2316    /// This function will return `NULL` if the widget is not contained
2317    /// inside a widget tree with a root widget.
2318    ///
2319    /// [`Root`][crate::Root] widgets will return themselves here.
2320    ///
2321    /// # Returns
2322    ///
2323    /// the root widget of @self
2324    #[doc(alias = "gtk_widget_get_root")]
2325    #[doc(alias = "get_root")]
2326    fn root(&self) -> Option<Root> {
2327        unsafe { from_glib_none(ffi::gtk_widget_get_root(self.as_ref().to_glib_none().0)) }
2328    }
2329
2330    /// Retrieves the internal scale factor that maps from window
2331    /// coordinates to the actual device pixels.
2332    ///
2333    /// On traditional systems this is 1, on high density outputs,
2334    /// it can be a higher value (typically 2).
2335    ///
2336    /// See `Gdk::Surface::get_scale_factor()`.
2337    ///
2338    /// Note that modern systems may support *fractional* scaling,
2339    /// where the scale factor is not an integer. On such systems,
2340    /// this function will return the next higher integer value,
2341    /// but you probably want to use [`SurfaceExtManual::scale()`][crate::gdk::prelude::SurfaceExtManual::scale()]
2342    /// to get the fractional scale value.
2343    ///
2344    /// # Returns
2345    ///
2346    /// the scale factor for @self
2347    #[doc(alias = "gtk_widget_get_scale_factor")]
2348    #[doc(alias = "get_scale_factor")]
2349    #[doc(alias = "scale-factor")]
2350    fn scale_factor(&self) -> i32 {
2351        unsafe { ffi::gtk_widget_get_scale_factor(self.as_ref().to_glib_none().0) }
2352    }
2353
2354    /// Returns the widget’s sensitivity.
2355    ///
2356    /// This function returns the value that has been set using
2357    /// [`set_sensitive()`][Self::set_sensitive()]).
2358    ///
2359    /// The effective sensitivity of a widget is however determined
2360    /// by both its own and its parent widget’s sensitivity.
2361    /// See [`is_sensitive()`][Self::is_sensitive()].
2362    ///
2363    /// # Returns
2364    ///
2365    /// true if the widget is sensitive
2366    #[doc(alias = "gtk_widget_get_sensitive")]
2367    #[doc(alias = "sensitive")]
2368    fn get_sensitive(&self) -> bool {
2369        unsafe {
2370            from_glib(ffi::gtk_widget_get_sensitive(
2371                self.as_ref().to_glib_none().0,
2372            ))
2373        }
2374    }
2375
2376    /// Gets the settings object holding the settings used for the widget.
2377    ///
2378    /// Note that this function can only be called when the [`Widget`][crate::Widget]
2379    /// is attached to a toplevel, since the settings object is specific
2380    /// to a particular display. If you want to monitor the widget for
2381    /// changes in its settings, connect to the `notify::display` signal.
2382    ///
2383    /// # Returns
2384    ///
2385    /// the relevant settings object
2386    #[doc(alias = "gtk_widget_get_settings")]
2387    #[doc(alias = "get_settings")]
2388    fn settings(&self) -> Settings {
2389        unsafe { from_glib_none(ffi::gtk_widget_get_settings(self.as_ref().to_glib_none().0)) }
2390    }
2391
2392    /// Returns the content width or height of the widget.
2393    ///
2394    /// Which dimension is returned depends on @orientation.
2395    ///
2396    /// This is equivalent to calling [`width()`][Self::width()]
2397    /// for [enum@Gtk.Orientation.horizontal] or [`height()`][Self::height()]
2398    /// for [enum@Gtk.Orientation.vertical], but can be used when
2399    /// writing orientation-independent code, such as when
2400    /// implementing [`Orientable`][crate::Orientable] widgets.
2401    ///
2402    /// To learn more about widget sizes, see the coordinate
2403    /// system [overview](coordinates.html).
2404    /// ## `orientation`
2405    /// the orientation to query
2406    ///
2407    /// # Returns
2408    ///
2409    /// the size of @self in @orientation
2410    #[doc(alias = "gtk_widget_get_size")]
2411    #[doc(alias = "get_size")]
2412    fn size(&self, orientation: Orientation) -> i32 {
2413        unsafe { ffi::gtk_widget_get_size(self.as_ref().to_glib_none().0, orientation.into_glib()) }
2414    }
2415
2416    /// Gets the size request that was explicitly set for the widget.
2417    ///
2418    /// A value of -1 stored in @width or @height indicates that that
2419    /// dimension has not been set explicitly and the natural requisition
2420    /// of the widget will be used instead.
2421    ///
2422    /// See [`set_size_request()`][Self::set_size_request()].
2423    ///
2424    /// To get the size a widget will actually request, call
2425    /// [`measure()`][Self::measure()] instead of this function.
2426    ///
2427    /// # Returns
2428    ///
2429    ///
2430    /// ## `width`
2431    /// return location for width
2432    ///
2433    /// ## `height`
2434    /// return location for height
2435    #[doc(alias = "gtk_widget_get_size_request")]
2436    #[doc(alias = "get_size_request")]
2437    fn size_request(&self) -> (i32, i32) {
2438        unsafe {
2439            let mut width = std::mem::MaybeUninit::uninit();
2440            let mut height = std::mem::MaybeUninit::uninit();
2441            ffi::gtk_widget_get_size_request(
2442                self.as_ref().to_glib_none().0,
2443                width.as_mut_ptr(),
2444                height.as_mut_ptr(),
2445            );
2446            (width.assume_init(), height.assume_init())
2447        }
2448    }
2449
2450    /// Returns the widget state as a flag set.
2451    ///
2452    /// It is worth mentioning that the effective [flags@Gtk.StateFlags.insensitive]
2453    /// state will be returned, that is, also based on parent insensitivity,
2454    /// even if @self itself is sensitive.
2455    ///
2456    /// Also note that if you are looking for a way to obtain the
2457    /// [`StateFlags`][crate::StateFlags] to pass to a [`StyleContext`][crate::StyleContext]
2458    /// method, you should look at [`StyleContextExt::state()`][crate::prelude::StyleContextExt::state()].
2459    ///
2460    /// # Returns
2461    ///
2462    /// the state flags of widget
2463    #[doc(alias = "gtk_widget_get_state_flags")]
2464    #[doc(alias = "get_state_flags")]
2465    fn state_flags(&self) -> StateFlags {
2466        unsafe {
2467            from_glib(ffi::gtk_widget_get_state_flags(
2468                self.as_ref().to_glib_none().0,
2469            ))
2470        }
2471    }
2472
2473    /// Returns the style context associated to the widget.
2474    ///
2475    /// The returned object is guaranteed to be the same
2476    /// for the lifetime of @self.
2477    ///
2478    /// # Deprecated since 4.10
2479    ///
2480    /// Style contexts will be removed in GTK 5
2481    ///
2482    /// # Returns
2483    ///
2484    /// the widgets style context
2485    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
2486    #[allow(deprecated)]
2487    #[doc(alias = "gtk_widget_get_style_context")]
2488    #[doc(alias = "get_style_context")]
2489    fn style_context(&self) -> StyleContext {
2490        unsafe {
2491            from_glib_none(ffi::gtk_widget_get_style_context(
2492                self.as_ref().to_glib_none().0,
2493            ))
2494        }
2495    }
2496
2497    /// Gets the contents of the tooltip for the widget.
2498    ///
2499    /// If the tooltip has not been set using
2500    /// [`set_tooltip_markup()`][Self::set_tooltip_markup()], this
2501    /// function returns `NULL`.
2502    ///
2503    /// # Returns
2504    ///
2505    /// the tooltip text
2506    #[doc(alias = "gtk_widget_get_tooltip_markup")]
2507    #[doc(alias = "get_tooltip_markup")]
2508    #[doc(alias = "tooltip-markup")]
2509    fn tooltip_markup(&self) -> Option<glib::GString> {
2510        unsafe {
2511            from_glib_none(ffi::gtk_widget_get_tooltip_markup(
2512                self.as_ref().to_glib_none().0,
2513            ))
2514        }
2515    }
2516
2517    /// Gets the contents of the tooltip for the widget.
2518    ///
2519    /// If the @self's tooltip was set using
2520    /// [`set_tooltip_markup()`][Self::set_tooltip_markup()],
2521    /// this function will return the escaped text.
2522    ///
2523    /// # Returns
2524    ///
2525    /// the tooltip text
2526    #[doc(alias = "gtk_widget_get_tooltip_text")]
2527    #[doc(alias = "get_tooltip_text")]
2528    #[doc(alias = "tooltip-text")]
2529    fn tooltip_text(&self) -> Option<glib::GString> {
2530        unsafe {
2531            from_glib_none(ffi::gtk_widget_get_tooltip_text(
2532                self.as_ref().to_glib_none().0,
2533            ))
2534        }
2535    }
2536
2537    /// Gets the vertical alignment of the widget.
2538    ///
2539    /// # Returns
2540    ///
2541    /// the vertical alignment of @self
2542    #[doc(alias = "gtk_widget_get_valign")]
2543    #[doc(alias = "get_valign")]
2544    fn valign(&self) -> Align {
2545        unsafe { from_glib(ffi::gtk_widget_get_valign(self.as_ref().to_glib_none().0)) }
2546    }
2547
2548    /// Gets whether the widget would like any available extra vertical
2549    /// space.
2550    ///
2551    /// See [`hexpands()`][Self::hexpands()] for more detail.
2552    ///
2553    /// # Returns
2554    ///
2555    /// whether vexpand flag is set
2556    #[doc(alias = "gtk_widget_get_vexpand")]
2557    #[doc(alias = "get_vexpand")]
2558    #[doc(alias = "vexpand")]
2559    fn vexpands(&self) -> bool {
2560        unsafe { from_glib(ffi::gtk_widget_get_vexpand(self.as_ref().to_glib_none().0)) }
2561    }
2562
2563    /// Gets whether the `vexpand` flag has been explicitly set.
2564    ///
2565    /// See [`is_hexpand_set()`][Self::is_hexpand_set()] for more detail.
2566    ///
2567    /// # Returns
2568    ///
2569    /// whether vexpand has been explicitly set
2570    #[doc(alias = "gtk_widget_get_vexpand_set")]
2571    #[doc(alias = "get_vexpand_set")]
2572    #[doc(alias = "vexpand-set")]
2573    fn is_vexpand_set(&self) -> bool {
2574        unsafe {
2575            from_glib(ffi::gtk_widget_get_vexpand_set(
2576                self.as_ref().to_glib_none().0,
2577            ))
2578        }
2579    }
2580
2581    /// Determines whether the widget is visible.
2582    ///
2583    /// If you want to take into account whether the widget’s
2584    /// parent is also marked as visible, use
2585    /// [`is_visible()`][Self::is_visible()] instead.
2586    ///
2587    /// This function does not check if the widget is
2588    /// obscured in any way.
2589    ///
2590    /// See [`set_visible()`][Self::set_visible()].
2591    ///
2592    /// # Returns
2593    ///
2594    /// true if the widget is visible
2595    #[doc(alias = "gtk_widget_get_visible")]
2596    #[doc(alias = "visible")]
2597    fn get_visible(&self) -> bool {
2598        unsafe { from_glib(ffi::gtk_widget_get_visible(self.as_ref().to_glib_none().0)) }
2599    }
2600
2601    /// Returns the content width of the widget.
2602    ///
2603    /// This function returns the width passed to its
2604    /// size-allocate implementation, which is the width you
2605    /// should be using in [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()].
2606    ///
2607    /// For pointer events, see [`contains()`][Self::contains()].
2608    ///
2609    /// To learn more about widget sizes, see the coordinate
2610    /// system [overview](coordinates.html).
2611    ///
2612    /// # Returns
2613    ///
2614    /// The width of @self
2615    #[doc(alias = "gtk_widget_get_width")]
2616    #[doc(alias = "get_width")]
2617    fn width(&self) -> i32 {
2618        unsafe { ffi::gtk_widget_get_width(self.as_ref().to_glib_none().0) }
2619    }
2620
2621    /// Causes @self to have the keyboard focus for the window
2622    /// that it belongs to.
2623    ///
2624    /// If @self is not focusable, or its [`WidgetImpl::grab_focus()`][crate::subclass::prelude::WidgetImpl::grab_focus()]
2625    /// implementation cannot transfer the focus to a descendant of @self
2626    /// that is focusable, it will not take focus and false will be returned.
2627    ///
2628    /// Calling [`grab_focus()`][Self::grab_focus()] on an already focused widget
2629    /// is allowed, should not have an effect, and return true.
2630    ///
2631    /// # Returns
2632    ///
2633    /// true if focus is now inside @self
2634    #[doc(alias = "gtk_widget_grab_focus")]
2635    fn grab_focus(&self) -> bool {
2636        unsafe { from_glib(ffi::gtk_widget_grab_focus(self.as_ref().to_glib_none().0)) }
2637    }
2638
2639    /// Returns whether a style class is currently applied to the widget.
2640    /// ## `css_class`
2641    /// style class, without the leading period
2642    ///
2643    /// # Returns
2644    ///
2645    /// true if @css_class is currently applied to @self
2646    #[doc(alias = "gtk_widget_has_css_class")]
2647    fn has_css_class(&self, css_class: &str) -> bool {
2648        unsafe {
2649            from_glib(ffi::gtk_widget_has_css_class(
2650                self.as_ref().to_glib_none().0,
2651                css_class.to_glib_none().0,
2652            ))
2653        }
2654    }
2655
2656    /// Determines whether the widget is the current default widget
2657    /// within its toplevel.
2658    ///
2659    /// # Returns
2660    ///
2661    /// true if @self is the current default widget
2662    ///   within its toplevel
2663    #[doc(alias = "gtk_widget_has_default")]
2664    #[doc(alias = "has-default")]
2665    fn has_default(&self) -> bool {
2666        unsafe { from_glib(ffi::gtk_widget_has_default(self.as_ref().to_glib_none().0)) }
2667    }
2668
2669    /// Determines if the widget has the global input focus.
2670    ///
2671    /// See [`is_focus()`][Self::is_focus()] for the difference between
2672    /// having the global input focus, and only having the focus
2673    /// within a toplevel.
2674    ///
2675    /// # Returns
2676    ///
2677    /// true if the widget has the global input focus
2678    #[doc(alias = "gtk_widget_has_focus")]
2679    #[doc(alias = "has-focus")]
2680    fn has_focus(&self) -> bool {
2681        unsafe { from_glib(ffi::gtk_widget_has_focus(self.as_ref().to_glib_none().0)) }
2682    }
2683
2684    /// Determines if the widget should show a visible indication that
2685    /// it has the global input focus.
2686    ///
2687    /// This is a convenience function that takes into account whether
2688    /// focus indication should currently be shown in the toplevel window
2689    /// of @self. See [`GtkWindowExt::gets_focus_visible()`][crate::prelude::GtkWindowExt::gets_focus_visible()] for more
2690    /// information about focus indication.
2691    ///
2692    /// To find out if the widget has the global input focus, use
2693    /// [`has_focus()`][Self::has_focus()].
2694    ///
2695    /// # Returns
2696    ///
2697    /// true if the widget should display a “focus rectangle”
2698    #[doc(alias = "gtk_widget_has_visible_focus")]
2699    fn has_visible_focus(&self) -> bool {
2700        unsafe {
2701            from_glib(ffi::gtk_widget_has_visible_focus(
2702                self.as_ref().to_glib_none().0,
2703            ))
2704        }
2705    }
2706
2707    /// Reverses the effects of [method.Gtk.Widget.show].
2708    ///
2709    /// This is causing the widget to be hidden (invisible to the user).
2710    ///
2711    /// # Deprecated since 4.10
2712    ///
2713    /// Use [`set_visible()`][Self::set_visible()] instead
2714    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
2715    #[allow(deprecated)]
2716    #[doc(alias = "gtk_widget_hide")]
2717    fn hide(&self) {
2718        unsafe {
2719            ffi::gtk_widget_hide(self.as_ref().to_glib_none().0);
2720        }
2721    }
2722
2723    /// Returns whether the widget is currently being destroyed.
2724    ///
2725    /// This information can sometimes be used to avoid doing
2726    /// unnecessary work.
2727    ///
2728    /// # Returns
2729    ///
2730    /// true if @self is being destroyed
2731    #[doc(alias = "gtk_widget_in_destruction")]
2732    fn in_destruction(&self) -> bool {
2733        unsafe {
2734            from_glib(ffi::gtk_widget_in_destruction(
2735                self.as_ref().to_glib_none().0,
2736            ))
2737        }
2738    }
2739
2740    /// Inserts an action group into the widget's actions.
2741    ///
2742    /// Children of @self that implement [`Actionable`][crate::Actionable] can
2743    /// then be associated with actions in @group by setting their
2744    /// “action-name” to @prefix.`action-name`.
2745    ///
2746    /// Note that inheritance is defined for individual actions. I.e.
2747    /// even if you insert a group with prefix @prefix, actions with
2748    /// the same prefix will still be inherited from the parent, unless
2749    /// the group contains an action with the same name.
2750    ///
2751    /// If @group is `NULL`, a previously inserted group for @name is
2752    /// removed from @self.
2753    /// ## `name`
2754    /// the prefix for actions in @group
2755    /// ## `group`
2756    /// an action group
2757    #[doc(alias = "gtk_widget_insert_action_group")]
2758    fn insert_action_group(&self, name: &str, group: Option<&impl IsA<gio::ActionGroup>>) {
2759        unsafe {
2760            ffi::gtk_widget_insert_action_group(
2761                self.as_ref().to_glib_none().0,
2762                name.to_glib_none().0,
2763                group.map(|p| p.as_ref()).to_glib_none().0,
2764            );
2765        }
2766    }
2767
2768    /// Sets the parent widget of the widget.
2769    ///
2770    /// In contrast to [`set_parent()`][Self::set_parent()], this function
2771    /// inserts @self at a specific position into the list of children
2772    /// of the @parent widget.
2773    ///
2774    /// It will be placed after @previous_sibling, or at the beginning if
2775    /// @previous_sibling is `NULL`.
2776    ///
2777    /// After calling this function, `gtk_widget_get_prev_sibling (widget)`
2778    /// will return @previous_sibling.
2779    ///
2780    /// If @parent is already set as the parent widget of @self, this
2781    /// function can also be used to reorder @self in the child widget
2782    /// list of @parent.
2783    ///
2784    /// This function is primarily meant for widget implementations; if you are
2785    /// just using a widget, you *must* use its own API for adding children.
2786    /// ## `parent`
2787    /// the parent widget to insert @self into
2788    /// ## `previous_sibling`
2789    /// the new previous sibling of @self
2790    #[doc(alias = "gtk_widget_insert_after")]
2791    fn insert_after(&self, parent: &impl IsA<Widget>, previous_sibling: Option<&impl IsA<Widget>>) {
2792        unsafe {
2793            ffi::gtk_widget_insert_after(
2794                self.as_ref().to_glib_none().0,
2795                parent.as_ref().to_glib_none().0,
2796                previous_sibling.map(|p| p.as_ref()).to_glib_none().0,
2797            );
2798        }
2799    }
2800
2801    /// Sets the parent widget of the widget.
2802    ///
2803    /// In contrast to [`set_parent()`][Self::set_parent()], this function
2804    /// inserts @self at a specific position into the list of children
2805    /// of the @parent widget.
2806    ///
2807    /// It will be placed before @next_sibling, or at the end if
2808    /// @next_sibling is `NULL`.
2809    ///
2810    /// After calling this function, `gtk_widget_get_next_sibling (widget)`
2811    /// will return @next_sibling.
2812    ///
2813    /// If @parent is already set as the parent widget of @self, this function
2814    /// can also be used to reorder @self in the child widget list of @parent.
2815    ///
2816    /// This function is primarily meant for widget implementations; if you are
2817    /// just using a widget, you *must* use its own API for adding children.
2818    /// ## `parent`
2819    /// the parent widget to insert @self into
2820    /// ## `next_sibling`
2821    /// the new next sibling of @self
2822    #[doc(alias = "gtk_widget_insert_before")]
2823    fn insert_before(&self, parent: &impl IsA<Widget>, next_sibling: Option<&impl IsA<Widget>>) {
2824        unsafe {
2825            ffi::gtk_widget_insert_before(
2826                self.as_ref().to_glib_none().0,
2827                parent.as_ref().to_glib_none().0,
2828                next_sibling.map(|p| p.as_ref()).to_glib_none().0,
2829            );
2830        }
2831    }
2832
2833    /// Determines whether the widget is a descendent of @ancestor.
2834    /// ## `ancestor`
2835    /// another [`Widget`][crate::Widget]
2836    ///
2837    /// # Returns
2838    ///
2839    /// true if @ancestor contains @self as a child,
2840    ///   grandchild, great grandchild, etc
2841    #[doc(alias = "gtk_widget_is_ancestor")]
2842    fn is_ancestor(&self, ancestor: &impl IsA<Widget>) -> bool {
2843        unsafe {
2844            from_glib(ffi::gtk_widget_is_ancestor(
2845                self.as_ref().to_glib_none().0,
2846                ancestor.as_ref().to_glib_none().0,
2847            ))
2848        }
2849    }
2850
2851    /// Determines whether the widget can be drawn to.
2852    ///
2853    /// A widget can be drawn if it is mapped and visible.
2854    ///
2855    /// # Returns
2856    ///
2857    /// true if @self is drawable
2858    #[doc(alias = "gtk_widget_is_drawable")]
2859    fn is_drawable(&self) -> bool {
2860        unsafe { from_glib(ffi::gtk_widget_is_drawable(self.as_ref().to_glib_none().0)) }
2861    }
2862
2863    /// Determines if the widget is the focus widget within its
2864    /// toplevel.
2865    ///
2866    /// This does not mean that the [`has-focus`][struct@crate::Widget#has-focus]
2867    /// property is necessarily set; [`has-focus`][struct@crate::Widget#has-focus]
2868    /// will only be set if the toplevel widget additionally has the
2869    /// global input focus.
2870    ///
2871    /// # Returns
2872    ///
2873    /// true if the widget is the focus widget
2874    #[doc(alias = "gtk_widget_is_focus")]
2875    fn is_focus(&self) -> bool {
2876        unsafe { from_glib(ffi::gtk_widget_is_focus(self.as_ref().to_glib_none().0)) }
2877    }
2878
2879    /// Returns the widget’s effective sensitivity.
2880    ///
2881    /// This means it is sensitive itself and also its
2882    /// parent widget is sensitive.
2883    ///
2884    /// # Returns
2885    ///
2886    /// true if the widget is effectively sensitive
2887    #[doc(alias = "gtk_widget_is_sensitive")]
2888    fn is_sensitive(&self) -> bool {
2889        unsafe { from_glib(ffi::gtk_widget_is_sensitive(self.as_ref().to_glib_none().0)) }
2890    }
2891
2892    /// Determines whether the widget and all its parents are marked as
2893    /// visible.
2894    ///
2895    /// This function does not check if the widget is obscured in any way.
2896    ///
2897    /// See also [`get_visible()`][Self::get_visible()] and
2898    /// [`set_visible()`][Self::set_visible()].
2899    ///
2900    /// # Returns
2901    ///
2902    /// true if the widget and all its parents are visible
2903    #[doc(alias = "gtk_widget_is_visible")]
2904    fn is_visible(&self) -> bool {
2905        unsafe { from_glib(ffi::gtk_widget_is_visible(self.as_ref().to_glib_none().0)) }
2906    }
2907
2908    /// Emits the [`keynav-failed`][struct@crate::Widget#keynav-failed] signal on the widget.
2909    ///
2910    /// This function should be called whenever keyboard navigation
2911    /// within a single widget hits a boundary.
2912    ///
2913    /// The return value of this function should be interpreted
2914    /// in a way similar to the return value of
2915    /// [`child_focus()`][Self::child_focus()]. When true is returned,
2916    /// stay in the widget, the failed keyboard navigation is ok
2917    /// and/or there is nowhere we can/should move the focus to.
2918    /// When false is returned, the caller should continue with
2919    /// keyboard navigation outside the widget, e.g. by calling
2920    /// [`child_focus()`][Self::child_focus()] on the widget’s toplevel.
2921    ///
2922    /// The default [`keynav-failed`][struct@crate::Widget#keynav-failed] handler returns
2923    /// false for [enum@Gtk.DirectionType.tab-forward] and
2924    /// [enum@Gtk.DirectionType.tab-backward]. For the other values
2925    /// of [`DirectionType`][crate::DirectionType] it returns true.
2926    ///
2927    /// Whenever the default handler returns true, it also calls
2928    /// [`error_bell()`][Self::error_bell()] to notify the user of the
2929    /// failed keyboard navigation.
2930    ///
2931    /// A use case for providing an own implementation of `::keynav-failed`
2932    /// (either by connecting to it or by overriding it) would be a row of
2933    /// [`Entry`][crate::Entry] widgets where the user should be able to navigate
2934    /// the entire row with the cursor keys, as e.g. known from user
2935    /// interfaces that require entering license keys.
2936    /// ## `direction`
2937    /// direction of focus movement
2938    ///
2939    /// # Returns
2940    ///
2941    /// true if stopping keyboard navigation is fine, false
2942    ///   if the emitting widget should try to handle the keyboard
2943    ///   navigation attempt in its parent widget
2944    #[doc(alias = "gtk_widget_keynav_failed")]
2945    fn keynav_failed(&self, direction: DirectionType) -> bool {
2946        unsafe {
2947            from_glib(ffi::gtk_widget_keynav_failed(
2948                self.as_ref().to_glib_none().0,
2949                direction.into_glib(),
2950            ))
2951        }
2952    }
2953
2954    /// Returns the widgets for which this widget is the target of a
2955    /// mnemonic.
2956    ///
2957    /// Typically, these widgets will be labels. See, for example,
2958    /// [`Label::set_mnemonic_widget()`][crate::Label::set_mnemonic_widget()].
2959    ///
2960    /// The widgets in the list are not individually referenced.
2961    /// If you want to iterate through the list and perform actions
2962    /// involving callbacks that might destroy the widgets, you
2963    /// must call `g_list_foreach (result, (GFunc)g_object_ref, NULL)`
2964    /// first, and then unref all the widgets afterwards.
2965    ///
2966    /// # Returns
2967    ///
2968    /// the list
2969    ///   of mnemonic labels
2970    #[doc(alias = "gtk_widget_list_mnemonic_labels")]
2971    fn list_mnemonic_labels(&self) -> Vec<Widget> {
2972        unsafe {
2973            FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_mnemonic_labels(
2974                self.as_ref().to_glib_none().0,
2975            ))
2976        }
2977    }
2978
2979    /// Causes a widget to be mapped if it isn’t already.
2980    ///
2981    /// This function is only for use in widget implementations.
2982    #[doc(alias = "gtk_widget_map")]
2983    fn map(&self) {
2984        unsafe {
2985            ffi::gtk_widget_map(self.as_ref().to_glib_none().0);
2986        }
2987    }
2988
2989    /// Measures @self in the orientation @orientation and for the given @for_size.
2990    ///
2991    /// As an example, if @orientation is [`Orientation::Horizontal`][crate::Orientation::Horizontal] and @for_size
2992    /// is 300, this functions will compute the minimum and natural width of @self
2993    /// if it is allocated at a height of 300 pixels.
2994    ///
2995    /// See [GtkWidget’s geometry management section](class.Widget.html#height-for-width-geometry-management) for
2996    /// a more details on implementing `GtkWidgetClass.measure()`.
2997    /// ## `orientation`
2998    /// the orientation to measure
2999    /// ## `for_size`
3000    /// Size for the opposite of @orientation, i.e.
3001    ///   if @orientation is [`Orientation::Horizontal`][crate::Orientation::Horizontal], this is
3002    ///   the height the widget should be measured with. The [`Orientation::Vertical`][crate::Orientation::Vertical]
3003    ///   case is analogous. This way, both height-for-width and width-for-height
3004    ///   requests can be implemented. If no size is known, -1 can be passed.
3005    ///
3006    /// # Returns
3007    ///
3008    ///
3009    /// ## `minimum`
3010    /// location to store the minimum size
3011    ///
3012    /// ## `natural`
3013    /// location to store the natural size
3014    ///
3015    /// ## `minimum_baseline`
3016    /// location to store the baseline
3017    ///   position for the minimum size, or -1 to report no baseline
3018    ///
3019    /// ## `natural_baseline`
3020    /// location to store the baseline
3021    ///   position for the natural size, or -1 to report no baseline
3022    #[doc(alias = "gtk_widget_measure")]
3023    fn measure(&self, orientation: Orientation, for_size: i32) -> (i32, i32, i32, i32) {
3024        unsafe {
3025            let mut minimum = std::mem::MaybeUninit::uninit();
3026            let mut natural = std::mem::MaybeUninit::uninit();
3027            let mut minimum_baseline = std::mem::MaybeUninit::uninit();
3028            let mut natural_baseline = std::mem::MaybeUninit::uninit();
3029            ffi::gtk_widget_measure(
3030                self.as_ref().to_glib_none().0,
3031                orientation.into_glib(),
3032                for_size,
3033                minimum.as_mut_ptr(),
3034                natural.as_mut_ptr(),
3035                minimum_baseline.as_mut_ptr(),
3036                natural_baseline.as_mut_ptr(),
3037            );
3038            (
3039                minimum.assume_init(),
3040                natural.assume_init(),
3041                minimum_baseline.assume_init(),
3042                natural_baseline.assume_init(),
3043            )
3044        }
3045    }
3046
3047    /// Emits the [`mnemonic-activate`][struct@crate::Widget#mnemonic-activate] signal.
3048    /// ## `group_cycling`
3049    /// true if there are other widgets with the same mnemonic
3050    ///
3051    /// # Returns
3052    ///
3053    /// true if the signal has been handled
3054    #[doc(alias = "gtk_widget_mnemonic_activate")]
3055    fn mnemonic_activate(&self, group_cycling: bool) -> bool {
3056        unsafe {
3057            from_glib(ffi::gtk_widget_mnemonic_activate(
3058                self.as_ref().to_glib_none().0,
3059                group_cycling.into_glib(),
3060            ))
3061        }
3062    }
3063
3064    /// Returns a list model to track the children of the widget.
3065    ///
3066    /// Calling this function will enable extra internal bookkeeping
3067    /// to track children and emit signals on the returned listmodel.
3068    /// It may slow down operations a lot.
3069    ///
3070    /// Applications should try hard to avoid calling this function
3071    /// because of the slowdowns.
3072    ///
3073    /// # Returns
3074    ///
3075    ///
3076    ///   a list model tracking @self's children
3077    #[doc(alias = "gtk_widget_observe_children")]
3078    fn observe_children(&self) -> gio::ListModel {
3079        unsafe {
3080            from_glib_full(ffi::gtk_widget_observe_children(
3081                self.as_ref().to_glib_none().0,
3082            ))
3083        }
3084    }
3085
3086    /// Returns a list model to track the event controllers of the widget.
3087    ///
3088    /// Calling this function will enable extra internal bookkeeping
3089    /// to track controllers and emit signals on the returned listmodel.
3090    /// It may slow down operations a lot.
3091    ///
3092    /// Applications should try hard to avoid calling this function
3093    /// because of the slowdowns.
3094    ///
3095    /// # Returns
3096    ///
3097    ///
3098    ///   a list model tracking @self's controllers
3099    #[doc(alias = "gtk_widget_observe_controllers")]
3100    fn observe_controllers(&self) -> gio::ListModel {
3101        unsafe {
3102            from_glib_full(ffi::gtk_widget_observe_controllers(
3103                self.as_ref().to_glib_none().0,
3104            ))
3105        }
3106    }
3107
3108    /// Finds the descendant of the widget closest to a point.
3109    ///
3110    /// The point (x, y) must be given in widget coordinates, so (0, 0)
3111    /// is assumed to be the top left of @self's content area.
3112    ///
3113    /// Usually widgets will return `NULL` if the given coordinate is not
3114    /// contained in @self checked via [`contains()`][Self::contains()].
3115    /// Otherwise they will recursively try to find a child that does
3116    /// not return `NULL`. Widgets are however free to customize their
3117    /// picking algorithm.
3118    ///
3119    /// This function is used on the toplevel to determine the widget
3120    /// below the mouse cursor for purposes of hover highlighting and
3121    /// delivering events.
3122    /// ## `x`
3123    /// x coordinate to test, relative to @self's origin
3124    /// ## `y`
3125    /// y coordinate to test, relative to @self's origin
3126    /// ## `flags`
3127    /// flags to influence what is picked
3128    ///
3129    /// # Returns
3130    ///
3131    /// the widget's descendant at (x, y)
3132    #[doc(alias = "gtk_widget_pick")]
3133    #[must_use]
3134    fn pick(&self, x: f64, y: f64, flags: PickFlags) -> Option<Widget> {
3135        unsafe {
3136            from_glib_none(ffi::gtk_widget_pick(
3137                self.as_ref().to_glib_none().0,
3138                x,
3139                y,
3140                flags.into_glib(),
3141            ))
3142        }
3143    }
3144
3145    /// Flags the widget for a rerun of the [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()]
3146    /// function.
3147    ///
3148    /// Use this function instead of [`queue_resize()`][Self::queue_resize()]
3149    /// when the @self's size request didn't change but it wants to
3150    /// reposition its contents.
3151    ///
3152    /// An example user of this function is [`set_halign()`][Self::set_halign()].
3153    ///
3154    /// This function is only for use in widget implementations.
3155    #[doc(alias = "gtk_widget_queue_allocate")]
3156    fn queue_allocate(&self) {
3157        unsafe {
3158            ffi::gtk_widget_queue_allocate(self.as_ref().to_glib_none().0);
3159        }
3160    }
3161
3162    /// Schedules this widget to be redrawn.
3163    ///
3164    /// The redraw will happen in the paint phase
3165    /// of the current or the next frame.
3166    ///
3167    /// This means @self's [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()]
3168    /// implementation will be called.
3169    #[doc(alias = "gtk_widget_queue_draw")]
3170    fn queue_draw(&self) {
3171        unsafe {
3172            ffi::gtk_widget_queue_draw(self.as_ref().to_glib_none().0);
3173        }
3174    }
3175
3176    /// Flags a widget to have its size renegotiated.
3177    ///
3178    /// This should be called when a widget for some reason has a new
3179    /// size request. For example, when you change the text in a
3180    /// [`Label`][crate::Label], the label queues a resize to ensure there’s
3181    /// enough space for the new text.
3182    ///
3183    /// Note that you cannot call gtk_widget_queue_resize() on a widget
3184    /// from inside its implementation of the [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()]
3185    /// virtual method. Calls to gtk_widget_queue_resize() from inside
3186    /// [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()] will be silently ignored.
3187    ///
3188    /// This function is only for use in widget implementations.
3189    #[doc(alias = "gtk_widget_queue_resize")]
3190    fn queue_resize(&self) {
3191        unsafe {
3192            ffi::gtk_widget_queue_resize(self.as_ref().to_glib_none().0);
3193        }
3194    }
3195
3196    /// Creates the GDK resources associated with a widget.
3197    ///
3198    /// Normally realization happens implicitly; if you show a widget
3199    /// and all its parent containers, then the widget will be realized
3200    /// and mapped automatically.
3201    ///
3202    /// Realizing a widget requires all the widget’s parent widgets to be
3203    /// realized; calling this function realizes the widget’s parents
3204    /// in addition to @self itself. If a widget is not yet inside a
3205    /// toplevel window when you realize it, bad things will happen.
3206    ///
3207    /// This function is primarily used in widget implementations, and
3208    /// isn’t very useful otherwise. Many times when you think you might
3209    /// need it, a better approach is to connect to a signal that will be
3210    /// called after the widget is realized automatically, such as
3211    /// [`realize`][struct@crate::Widget#realize].
3212    #[doc(alias = "gtk_widget_realize")]
3213    fn realize(&self) {
3214        unsafe {
3215            ffi::gtk_widget_realize(self.as_ref().to_glib_none().0);
3216        }
3217    }
3218
3219    /// Removes an event controller from the widget.
3220    ///
3221    /// The removed event controller will not receive any more events,
3222    /// and should not be used again.
3223    ///
3224    /// Widgets will remove all event controllers automatically when they
3225    /// are destroyed, there is normally no need to call this function.
3226    /// ## `controller`
3227    /// an event controller
3228    #[doc(alias = "gtk_widget_remove_controller")]
3229    fn remove_controller(&self, controller: &impl IsA<EventController>) {
3230        unsafe {
3231            ffi::gtk_widget_remove_controller(
3232                self.as_ref().to_glib_none().0,
3233                controller.as_ref().to_glib_none().0,
3234            );
3235        }
3236    }
3237
3238    /// Removes a style from the widget.
3239    ///
3240    /// After this, the style of @self will stop matching for @css_class.
3241    /// ## `css_class`
3242    /// style class to remove from @self, without the leading period
3243    #[doc(alias = "gtk_widget_remove_css_class")]
3244    fn remove_css_class(&self, css_class: &str) {
3245        unsafe {
3246            ffi::gtk_widget_remove_css_class(
3247                self.as_ref().to_glib_none().0,
3248                css_class.to_glib_none().0,
3249            );
3250        }
3251    }
3252
3253    /// Removes a widget from the list of mnemonic labels for this widget.
3254    ///
3255    /// See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()].
3256    ///
3257    /// The widget must have previously been added to the list with
3258    /// [`add_mnemonic_label()`][Self::add_mnemonic_label()].
3259    /// ## `label`
3260    /// a widget that is a mnemonic label for @self
3261    #[doc(alias = "gtk_widget_remove_mnemonic_label")]
3262    fn remove_mnemonic_label(&self, label: &impl IsA<Widget>) {
3263        unsafe {
3264            ffi::gtk_widget_remove_mnemonic_label(
3265                self.as_ref().to_glib_none().0,
3266                label.as_ref().to_glib_none().0,
3267            );
3268        }
3269    }
3270
3271    /// Sets whether the input focus can enter the widget or
3272    /// any of its children.
3273    ///
3274    /// Applications should set @can_focus to false to mark a
3275    /// widget as for pointer/touch use only.
3276    ///
3277    /// Note that having @can_focus be true is only one of the
3278    /// necessary conditions for being focusable. A widget must
3279    /// also be sensitive and focusable and not have an ancestor
3280    /// that is marked as not can-focus in order to receive input
3281    /// focus.
3282    ///
3283    /// See [`grab_focus()`][Self::grab_focus()] for actually setting
3284    /// the input focus on a widget.
3285    /// ## `can_focus`
3286    /// whether the input focus can enter
3287    ///   the widget or any of its children
3288    #[doc(alias = "gtk_widget_set_can_focus")]
3289    #[doc(alias = "can-focus")]
3290    fn set_can_focus(&self, can_focus: bool) {
3291        unsafe {
3292            ffi::gtk_widget_set_can_focus(self.as_ref().to_glib_none().0, can_focus.into_glib());
3293        }
3294    }
3295
3296    /// Sets whether the widget can be the target of pointer events.
3297    /// ## `can_target`
3298    /// whether this widget should be able to
3299    ///   receive pointer events
3300    #[doc(alias = "gtk_widget_set_can_target")]
3301    #[doc(alias = "can-target")]
3302    fn set_can_target(&self, can_target: bool) {
3303        unsafe {
3304            ffi::gtk_widget_set_can_target(self.as_ref().to_glib_none().0, can_target.into_glib());
3305        }
3306    }
3307
3308    /// Sets whether the widget should be mapped along with its parent.
3309    ///
3310    /// The child visibility can be set for widget before it is added
3311    /// to a container with [`set_parent()`][Self::set_parent()], to avoid
3312    /// mapping children unnecessary before immediately unmapping them.
3313    /// However it will be reset to its default state of true when the
3314    /// widget is removed from a container.
3315    ///
3316    /// Note that changing the child visibility of a widget does not
3317    /// queue a resize on the widget. Most of the time, the size of
3318    /// a widget is computed from all visible children, whether or
3319    /// not they are mapped. If this is not the case, the container
3320    /// can queue a resize itself.
3321    ///
3322    /// This function is only useful for widget implementations
3323    /// and should never be called by an application.
3324    /// ## `child_visible`
3325    /// whether @self should be mapped along
3326    ///   with its parent
3327    #[doc(alias = "gtk_widget_set_child_visible")]
3328    fn set_child_visible(&self, child_visible: bool) {
3329        unsafe {
3330            ffi::gtk_widget_set_child_visible(
3331                self.as_ref().to_glib_none().0,
3332                child_visible.into_glib(),
3333            );
3334        }
3335    }
3336
3337    /// Replaces the current style classes of the widget with @classes.
3338    /// ## `classes`
3339    ///
3340    ///   `NULL`-terminated list of style classes
3341    #[doc(alias = "gtk_widget_set_css_classes")]
3342    #[doc(alias = "css-classes")]
3343    fn set_css_classes(&self, classes: &[&str]) {
3344        unsafe {
3345            ffi::gtk_widget_set_css_classes(
3346                self.as_ref().to_glib_none().0,
3347                classes.to_glib_none().0,
3348            );
3349        }
3350    }
3351
3352    /// Sets the cursor to be shown when the pointer hovers over
3353    /// the widget.
3354    ///
3355    /// If the @cursor is `NULL`, @self will use the cursor
3356    /// inherited from its parent.
3357    /// ## `cursor`
3358    /// the new cursor
3359    #[doc(alias = "gtk_widget_set_cursor")]
3360    #[doc(alias = "cursor")]
3361    fn set_cursor(&self, cursor: Option<&gdk::Cursor>) {
3362        unsafe {
3363            ffi::gtk_widget_set_cursor(self.as_ref().to_glib_none().0, cursor.to_glib_none().0);
3364        }
3365    }
3366
3367    /// Sets the cursor to be shown when the pointer hovers over
3368    /// the widget.
3369    ///
3370    /// This is a utility function that creates a cursor via
3371    /// [`gdk::Cursor::from_name()`][crate::gdk::Cursor::from_name()] and then sets it on @self
3372    /// with [`set_cursor()`][Self::set_cursor()]. See those functions for
3373    /// details.
3374    ///
3375    /// On top of that, this function allows @name to be `NULL`, which
3376    /// will do the same as calling [`set_cursor()`][Self::set_cursor()]
3377    /// with a `NULL` cursor.
3378    /// ## `name`
3379    /// the name of the cursor
3380    #[doc(alias = "gtk_widget_set_cursor_from_name")]
3381    fn set_cursor_from_name(&self, name: Option<&str>) {
3382        unsafe {
3383            ffi::gtk_widget_set_cursor_from_name(
3384                self.as_ref().to_glib_none().0,
3385                name.to_glib_none().0,
3386            );
3387        }
3388    }
3389
3390    /// Sets the reading direction on the widget.
3391    ///
3392    /// This direction controls the primary direction for widgets
3393    /// containing text, and also the direction in which the children
3394    /// of a container are packed. The ability to set the direction is
3395    /// present in order so that correct localization into languages with
3396    /// right-to-left reading directions can be done.
3397    ///
3398    /// Generally, applications will let the default reading direction
3399    /// prevail, except for widgets where the children are arranged in
3400    /// an order that is explicitly visual rather than logical (such as
3401    /// buttons for text justification).
3402    ///
3403    /// If the direction is set to [enum@Gtk.TextDirection.none], then
3404    /// the value set by [`Widget::set_default_direction()`][crate::Widget::set_default_direction()] will be used.
3405    /// ## `dir`
3406    /// the new direction
3407    #[doc(alias = "gtk_widget_set_direction")]
3408    fn set_direction(&self, dir: TextDirection) {
3409        unsafe {
3410            ffi::gtk_widget_set_direction(self.as_ref().to_glib_none().0, dir.into_glib());
3411        }
3412    }
3413
3414    /// Set the focus child of the widget.
3415    ///
3416    /// This function is only suitable for widget implementations.
3417    /// If you want a certain widget to get the input focus, call
3418    /// [`grab_focus()`][Self::grab_focus()] on it.
3419    /// ## `child`
3420    /// a direct child widget of @self
3421    ///   or `NULL` to unset the focus child
3422    #[doc(alias = "gtk_widget_set_focus_child")]
3423    fn set_focus_child(&self, child: Option<&impl IsA<Widget>>) {
3424        unsafe {
3425            ffi::gtk_widget_set_focus_child(
3426                self.as_ref().to_glib_none().0,
3427                child.map(|p| p.as_ref()).to_glib_none().0,
3428            );
3429        }
3430    }
3431
3432    /// Sets whether the widget should grab focus when it is clicked
3433    /// with the mouse.
3434    ///
3435    /// Making mouse clicks not grab focus is useful in places like
3436    /// toolbars where you don’t want the keyboard focus removed from
3437    /// the main area of the application.
3438    /// ## `focus_on_click`
3439    /// whether the widget should grab focus when clicked
3440    ///   with the mouse
3441    #[doc(alias = "gtk_widget_set_focus_on_click")]
3442    #[doc(alias = "focus-on-click")]
3443    fn set_focus_on_click(&self, focus_on_click: bool) {
3444        unsafe {
3445            ffi::gtk_widget_set_focus_on_click(
3446                self.as_ref().to_glib_none().0,
3447                focus_on_click.into_glib(),
3448            );
3449        }
3450    }
3451
3452    /// Sets whether the widget can own the input focus.
3453    ///
3454    /// Widget implementations should set @focusable to true in
3455    /// their init() function if they want to receive keyboard input.
3456    ///
3457    /// Note that having @focusable be true is only one of the
3458    /// necessary conditions for being focusable. A widget must
3459    /// also be sensitive and can-focus and not have an ancestor
3460    /// that is marked as not can-focus in order to receive input
3461    /// focus.
3462    ///
3463    /// See [`grab_focus()`][Self::grab_focus()] for actually setting
3464    /// the input focus on a widget.
3465    /// ## `focusable`
3466    /// whether or not @self can own the input focus
3467    #[doc(alias = "gtk_widget_set_focusable")]
3468    #[doc(alias = "focusable")]
3469    fn set_focusable(&self, focusable: bool) {
3470        unsafe {
3471            ffi::gtk_widget_set_focusable(self.as_ref().to_glib_none().0, focusable.into_glib());
3472        }
3473    }
3474
3475    /// Sets the font map to use for text rendering in the widget.
3476    ///
3477    /// The font map is the object that is used to look up fonts.
3478    /// Setting a custom font map can be useful in special situations,
3479    /// e.g. when you need to add application-specific fonts to the set
3480    /// of available fonts.
3481    ///
3482    /// When not set, the widget will inherit the font map from its parent.
3483    /// ## `font_map`
3484    /// a [`pango::FontMap`][crate::pango::FontMap]
3485    #[doc(alias = "gtk_widget_set_font_map")]
3486    fn set_font_map(&self, font_map: Option<&impl IsA<pango::FontMap>>) {
3487        unsafe {
3488            ffi::gtk_widget_set_font_map(
3489                self.as_ref().to_glib_none().0,
3490                font_map.map(|p| p.as_ref()).to_glib_none().0,
3491            );
3492        }
3493    }
3494
3495    /// Sets the [`cairo::FontOptions`][crate::cairo::FontOptions] used for text rendering
3496    /// in the widget.
3497    ///
3498    /// When not set, the default font options for the [`gdk::Display`][crate::gdk::Display]
3499    /// will be used.
3500    ///
3501    /// # Deprecated since 4.16
3502    ///
3503    /// ## `options`
3504    /// a [`cairo::FontOptions`][crate::cairo::FontOptions] struct
3505    ///   to unset any previously set default font options
3506    #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
3507    #[allow(deprecated)]
3508    #[doc(alias = "gtk_widget_set_font_options")]
3509    fn set_font_options(&self, options: Option<&cairo::FontOptions>) {
3510        unsafe {
3511            ffi::gtk_widget_set_font_options(
3512                self.as_ref().to_glib_none().0,
3513                options.to_glib_none().0,
3514            );
3515        }
3516    }
3517
3518    /// Sets the horizontal alignment of the widget.
3519    /// ## `align`
3520    /// the horizontal alignment
3521    #[doc(alias = "gtk_widget_set_halign")]
3522    #[doc(alias = "halign")]
3523    fn set_halign(&self, align: Align) {
3524        unsafe {
3525            ffi::gtk_widget_set_halign(self.as_ref().to_glib_none().0, align.into_glib());
3526        }
3527    }
3528
3529    /// Sets the `has-tooltip` property on the widget.
3530    /// ## `has_tooltip`
3531    /// whether or not @self has a tooltip
3532    #[doc(alias = "gtk_widget_set_has_tooltip")]
3533    #[doc(alias = "has-tooltip")]
3534    fn set_has_tooltip(&self, has_tooltip: bool) {
3535        unsafe {
3536            ffi::gtk_widget_set_has_tooltip(
3537                self.as_ref().to_glib_none().0,
3538                has_tooltip.into_glib(),
3539            );
3540        }
3541    }
3542
3543    /// Sets whether the widget would like any available extra horizontal
3544    /// space.
3545    ///
3546    /// When a user resizes a window, widgets with expand set to true generally
3547    /// receive the extra space. For example, a list or scrollable area
3548    /// or document in your window would often be set to expand.
3549    ///
3550    /// Call this function to set the expand flag if you would like your
3551    /// widget to become larger horizontally when the window has extra
3552    /// room.
3553    ///
3554    /// By default, widgets automatically expand if any of their children
3555    /// want to expand. (To see if a widget will automatically expand given
3556    /// its current children and state, call [`compute_expand()`][Self::compute_expand()].
3557    /// A widget can decide how the expandability of children affects its
3558    /// own expansion by overriding the `compute_expand` virtual method on
3559    /// [`Widget`][crate::Widget].).
3560    ///
3561    /// Setting hexpand explicitly with this function will override the
3562    /// automatic expand behavior.
3563    ///
3564    /// This function forces the widget to expand or not to expand,
3565    /// regardless of children. The override occurs because
3566    /// [`set_hexpand()`][Self::set_hexpand()] sets the hexpand-set property (see
3567    /// [`set_hexpand_set()`][Self::set_hexpand_set()]) which causes the widget’s hexpand
3568    /// value to be used, rather than looking at children and widget state.
3569    /// ## `expand`
3570    /// whether to expand
3571    #[doc(alias = "gtk_widget_set_hexpand")]
3572    #[doc(alias = "hexpand")]
3573    fn set_hexpand(&self, expand: bool) {
3574        unsafe {
3575            ffi::gtk_widget_set_hexpand(self.as_ref().to_glib_none().0, expand.into_glib());
3576        }
3577    }
3578
3579    /// Sets whether the hexpand flag will be used.
3580    ///
3581    /// The [`hexpand-set`][struct@crate::Widget#hexpand-set] property will be set
3582    /// automatically when you call [`set_hexpand()`][Self::set_hexpand()]
3583    /// to set hexpand, so the most likely reason to use this function
3584    /// would be to unset an explicit expand flag.
3585    ///
3586    /// If hexpand is set, then it overrides any computed
3587    /// expand value based on child widgets. If hexpand is not
3588    /// set, then the expand value depends on whether any
3589    /// children of the widget would like to expand.
3590    ///
3591    /// There are few reasons to use this function, but it’s here
3592    /// for completeness and consistency.
3593    /// ## `set`
3594    /// value for hexpand-set property
3595    #[doc(alias = "gtk_widget_set_hexpand_set")]
3596    #[doc(alias = "hexpand-set")]
3597    fn set_hexpand_set(&self, set: bool) {
3598        unsafe {
3599            ffi::gtk_widget_set_hexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
3600        }
3601    }
3602
3603    /// Sets the layout manager to use for measuring and allocating children
3604    /// of the widget.
3605    /// ## `layout_manager`
3606    /// a layout manager
3607    #[doc(alias = "gtk_widget_set_layout_manager")]
3608    #[doc(alias = "layout-manager")]
3609    fn set_layout_manager(&self, layout_manager: Option<impl IsA<LayoutManager>>) {
3610        unsafe {
3611            ffi::gtk_widget_set_layout_manager(
3612                self.as_ref().to_glib_none().0,
3613                layout_manager.map(|p| p.upcast()).into_glib_ptr(),
3614            );
3615        }
3616    }
3617
3618    /// Sets whether the widget acts like a modal dialog,
3619    /// with respect to event delivery.
3620    /// ## `limit_events`
3621    /// whether to limit events
3622    #[cfg(feature = "v4_18")]
3623    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
3624    #[doc(alias = "gtk_widget_set_limit_events")]
3625    #[doc(alias = "limit-events")]
3626    fn set_limit_events(&self, limit_events: bool) {
3627        unsafe {
3628            ffi::gtk_widget_set_limit_events(
3629                self.as_ref().to_glib_none().0,
3630                limit_events.into_glib(),
3631            );
3632        }
3633    }
3634
3635    /// Sets the bottom margin of the widget.
3636    /// ## `margin`
3637    /// the bottom margin
3638    #[doc(alias = "gtk_widget_set_margin_bottom")]
3639    #[doc(alias = "margin-bottom")]
3640    fn set_margin_bottom(&self, margin: i32) {
3641        unsafe {
3642            ffi::gtk_widget_set_margin_bottom(self.as_ref().to_glib_none().0, margin);
3643        }
3644    }
3645
3646    /// Sets the end margin of the widget.
3647    /// ## `margin`
3648    /// the end margin
3649    #[doc(alias = "gtk_widget_set_margin_end")]
3650    #[doc(alias = "margin-end")]
3651    fn set_margin_end(&self, margin: i32) {
3652        unsafe {
3653            ffi::gtk_widget_set_margin_end(self.as_ref().to_glib_none().0, margin);
3654        }
3655    }
3656
3657    /// Sets the start margin of the widget.
3658    /// ## `margin`
3659    /// the start margin
3660    #[doc(alias = "gtk_widget_set_margin_start")]
3661    #[doc(alias = "margin-start")]
3662    fn set_margin_start(&self, margin: i32) {
3663        unsafe {
3664            ffi::gtk_widget_set_margin_start(self.as_ref().to_glib_none().0, margin);
3665        }
3666    }
3667
3668    /// Sets the top margin of the widget.
3669    /// ## `margin`
3670    /// the top margin
3671    #[doc(alias = "gtk_widget_set_margin_top")]
3672    #[doc(alias = "margin-top")]
3673    fn set_margin_top(&self, margin: i32) {
3674        unsafe {
3675            ffi::gtk_widget_set_margin_top(self.as_ref().to_glib_none().0, margin);
3676        }
3677    }
3678
3679    /// Sets a widgets name.
3680    ///
3681    /// Setting a name allows you to refer to the widget from a
3682    /// CSS file. You can apply a style to widgets with a particular name
3683    /// in the CSS file. See the documentation for the CSS syntax (on the
3684    /// same page as the docs for [`StyleContext`][crate::StyleContext].
3685    ///
3686    /// Note that the CSS syntax has certain special characters to delimit
3687    /// and represent elements in a selector (period, #, >, *...), so using
3688    /// these will make your widget impossible to match by name. Any combination
3689    /// of alphanumeric symbols, dashes and underscores will suffice.
3690    /// ## `name`
3691    /// name for the widget
3692    #[doc(alias = "gtk_widget_set_name")]
3693    #[doc(alias = "set_name")]
3694    #[doc(alias = "name")]
3695    fn set_widget_name(&self, name: &str) {
3696        unsafe {
3697            ffi::gtk_widget_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
3698        }
3699    }
3700
3701    /// Requests the widget to be rendered partially transparent.
3702    ///
3703    /// An opacity of 0 is fully transparent and an opacity of 1
3704    /// is fully opaque.
3705    ///
3706    /// Opacity works on both toplevel widgets and child widgets, although
3707    /// there are some limitations: For toplevel widgets, applying opacity
3708    /// depends on the capabilities of the windowing system. On X11, this
3709    /// has any effect only on X displays with a compositing manager, see
3710    /// `Gdk::Display::is_composited()`. On Windows and Wayland it will
3711    /// always work, although setting a window’s opacity after the window
3712    /// has been shown may cause some flicker.
3713    ///
3714    /// Note that the opacity is inherited through inclusion — if you set
3715    /// a toplevel to be partially translucent, all of its content will
3716    /// appear translucent, since it is ultimatively rendered on that
3717    /// toplevel. The opacity value itself is not inherited by child
3718    /// widgets (since that would make widgets deeper in the hierarchy
3719    /// progressively more translucent). As a consequence, [`Popover`][crate::Popover]
3720    /// instances and other [`Native`][crate::Native] widgets with their own surface
3721    /// will use their own opacity value, and thus by default appear
3722    /// non-translucent, even if they are attached to a toplevel that
3723    /// is translucent.
3724    /// ## `opacity`
3725    /// desired opacity, between 0 and 1
3726    #[doc(alias = "gtk_widget_set_opacity")]
3727    #[doc(alias = "opacity")]
3728    fn set_opacity(&self, opacity: f64) {
3729        unsafe {
3730            ffi::gtk_widget_set_opacity(self.as_ref().to_glib_none().0, opacity);
3731        }
3732    }
3733
3734    /// Sets how the widget treats content that is drawn outside the
3735    /// it's content area.
3736    ///
3737    /// See the definition of [`Overflow`][crate::Overflow] for details.
3738    ///
3739    /// This setting is provided for widget implementations and
3740    /// should not be used by application code.
3741    ///
3742    /// The default value is [enum@Gtk.Overflow.visible].
3743    /// ## `overflow`
3744    /// desired overflow value
3745    #[doc(alias = "gtk_widget_set_overflow")]
3746    #[doc(alias = "overflow")]
3747    fn set_overflow(&self, overflow: Overflow) {
3748        unsafe {
3749            ffi::gtk_widget_set_overflow(self.as_ref().to_glib_none().0, overflow.into_glib());
3750        }
3751    }
3752
3753    /// Sets the parent widget of the widget.
3754    ///
3755    /// This takes care of details such as updating the state and style
3756    /// of the child to reflect its new location and resizing the parent.
3757    /// The opposite function is [`unparent()`][Self::unparent()].
3758    ///
3759    /// This function is useful only when implementing subclasses of
3760    /// [`Widget`][crate::Widget].
3761    /// ## `parent`
3762    /// parent widget
3763    #[doc(alias = "gtk_widget_set_parent")]
3764    fn set_parent(&self, parent: &impl IsA<Widget>) {
3765        unsafe {
3766            ffi::gtk_widget_set_parent(
3767                self.as_ref().to_glib_none().0,
3768                parent.as_ref().to_glib_none().0,
3769            );
3770        }
3771    }
3772
3773    /// Sets whether the widget will be treated as the default
3774    /// widget within its toplevel when it has the focus, even if
3775    /// another widget is the default.
3776    /// ## `receives_default`
3777    /// whether or not @self can be a default widget
3778    #[doc(alias = "gtk_widget_set_receives_default")]
3779    #[doc(alias = "receives-default")]
3780    fn set_receives_default(&self, receives_default: bool) {
3781        unsafe {
3782            ffi::gtk_widget_set_receives_default(
3783                self.as_ref().to_glib_none().0,
3784                receives_default.into_glib(),
3785            );
3786        }
3787    }
3788
3789    /// Sets the sensitivity of the widget.
3790    ///
3791    /// A widget is sensitive if the user can interact with it.
3792    /// Insensitive widgets are “grayed out” and the user can’t
3793    /// interact with them. Insensitive widgets are known as
3794    /// “inactive”, “disabled”, or “ghosted” in some other toolkits.
3795    /// ## `sensitive`
3796    /// true to make the widget sensitive
3797    #[doc(alias = "gtk_widget_set_sensitive")]
3798    #[doc(alias = "sensitive")]
3799    fn set_sensitive(&self, sensitive: bool) {
3800        unsafe {
3801            ffi::gtk_widget_set_sensitive(self.as_ref().to_glib_none().0, sensitive.into_glib());
3802        }
3803    }
3804
3805    /// Sets the minimum size of the widget.
3806    ///
3807    /// That is, the widget’s size request will be at least @width
3808    /// by @height. You can use this function to force a widget to
3809    /// be larger than it normally would be.
3810    ///
3811    /// In most cases, [`GtkWindowExt::set_default_size()`][crate::prelude::GtkWindowExt::set_default_size()] is a better
3812    /// choice for toplevel windows than this function; setting the default
3813    /// size will still allow users to shrink the window. Setting the size
3814    /// request will force them to leave the window at least as large as
3815    /// the size request.
3816    ///
3817    /// Note the inherent danger of setting any fixed size - themes,
3818    /// translations into other languages, different fonts, and user action
3819    /// can all change the appropriate size for a given widget. So, it is
3820    /// basically impossible to hardcode a size that will always work.
3821    ///
3822    /// The size request of a widget is the smallest size a widget can
3823    /// accept while still functioning well and drawing itself correctly.
3824    /// However in some strange cases a widget may be allocated less than
3825    /// its requested size, and in many cases a widget may be allocated more
3826    /// space than it requested.
3827    ///
3828    /// If the size request in a given direction is -1 (unset), then
3829    /// the “natural” size request of the widget will be used instead.
3830    ///
3831    /// The size request set here does not include any margin from the
3832    /// properties
3833    /// [`margin-start`][struct@crate::Widget#margin-start],
3834    /// [`margin-end`][struct@crate::Widget#margin-end],
3835    /// [`margin-top`][struct@crate::Widget#margin-top], and
3836    /// [`margin-bottom`][struct@crate::Widget#margin-bottom], but it does include pretty
3837    /// much all other padding or border properties set by any subclass
3838    /// of [`Widget`][crate::Widget].
3839    /// ## `width`
3840    /// width @self should request, or -1 to unset
3841    /// ## `height`
3842    /// height @self should request, or -1 to unset
3843    #[doc(alias = "gtk_widget_set_size_request")]
3844    fn set_size_request(&self, width: i32, height: i32) {
3845        unsafe {
3846            ffi::gtk_widget_set_size_request(self.as_ref().to_glib_none().0, width, height);
3847        }
3848    }
3849
3850    /// Turns on flag values in the current widget state.
3851    ///
3852    /// Typical widget states are insensitive, prelighted, etc.
3853    ///
3854    /// This function accepts the values [flags@Gtk.StateFlags.dir-ltr] and
3855    /// [flags@Gtk.StateFlags.dir-rtl] but ignores them. If you want to set
3856    /// the widget's direction, use [`set_direction()`][Self::set_direction()].
3857    ///
3858    /// This function is for use in widget implementations.
3859    /// ## `flags`
3860    /// state flags to turn on
3861    /// ## `clear`
3862    /// whether to clear state before turning on @flags
3863    #[doc(alias = "gtk_widget_set_state_flags")]
3864    fn set_state_flags(&self, flags: StateFlags, clear: bool) {
3865        unsafe {
3866            ffi::gtk_widget_set_state_flags(
3867                self.as_ref().to_glib_none().0,
3868                flags.into_glib(),
3869                clear.into_glib(),
3870            );
3871        }
3872    }
3873
3874    /// Sets the contents of the tooltip for widget.
3875    ///
3876    /// @markup must contain Pango markup.
3877    ///
3878    /// This function will take care of setting the
3879    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] as a side effect, and of the
3880    /// default handler for the [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
3881    ///
3882    /// See also [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
3883    /// ## `markup`
3884    /// the contents of the tooltip for @self
3885    #[doc(alias = "gtk_widget_set_tooltip_markup")]
3886    #[doc(alias = "tooltip-markup")]
3887    fn set_tooltip_markup(&self, markup: Option<&str>) {
3888        unsafe {
3889            ffi::gtk_widget_set_tooltip_markup(
3890                self.as_ref().to_glib_none().0,
3891                markup.to_glib_none().0,
3892            );
3893        }
3894    }
3895
3896    /// Sets the contents of the tooltip for the widget.
3897    ///
3898    /// If @text contains any markup, it will be escaped.
3899    ///
3900    /// This function will take care of setting
3901    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] as a side effect,
3902    /// and of the default handler for the
3903    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
3904    ///
3905    /// See also [`Tooltip::set_text()`][crate::Tooltip::set_text()].
3906    /// ## `text`
3907    /// the contents of the tooltip for @self
3908    #[doc(alias = "gtk_widget_set_tooltip_text")]
3909    #[doc(alias = "tooltip-text")]
3910    fn set_tooltip_text(&self, text: Option<&str>) {
3911        unsafe {
3912            ffi::gtk_widget_set_tooltip_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
3913        }
3914    }
3915
3916    /// Sets the vertical alignment of the widget.
3917    /// ## `align`
3918    /// the vertical alignment
3919    #[doc(alias = "gtk_widget_set_valign")]
3920    #[doc(alias = "valign")]
3921    fn set_valign(&self, align: Align) {
3922        unsafe {
3923            ffi::gtk_widget_set_valign(self.as_ref().to_glib_none().0, align.into_glib());
3924        }
3925    }
3926
3927    /// Sets whether the widget would like any available extra vertical
3928    /// space.
3929    ///
3930    /// See [`set_hexpand()`][Self::set_hexpand()] for more detail.
3931    /// ## `expand`
3932    /// whether to expand
3933    #[doc(alias = "gtk_widget_set_vexpand")]
3934    #[doc(alias = "vexpand")]
3935    fn set_vexpand(&self, expand: bool) {
3936        unsafe {
3937            ffi::gtk_widget_set_vexpand(self.as_ref().to_glib_none().0, expand.into_glib());
3938        }
3939    }
3940
3941    /// Sets whether the vexpand flag will be used.
3942    ///
3943    /// See [`set_hexpand_set()`][Self::set_hexpand_set()] for more detail.
3944    /// ## `set`
3945    /// value for vexpand-set property
3946    #[doc(alias = "gtk_widget_set_vexpand_set")]
3947    #[doc(alias = "vexpand-set")]
3948    fn set_vexpand_set(&self, set: bool) {
3949        unsafe {
3950            ffi::gtk_widget_set_vexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
3951        }
3952    }
3953
3954    /// Sets the visibility state of @self.
3955    ///
3956    /// Note that setting this to true doesn’t mean the widget is
3957    /// actually viewable, see [`get_visible()`][Self::get_visible()].
3958    /// ## `visible`
3959    /// whether the widget should be shown or not
3960    #[doc(alias = "gtk_widget_set_visible")]
3961    #[doc(alias = "visible")]
3962    fn set_visible(&self, visible: bool) {
3963        unsafe {
3964            ffi::gtk_widget_set_visible(self.as_ref().to_glib_none().0, visible.into_glib());
3965        }
3966    }
3967
3968    /// Returns whether the widget should contribute to
3969    /// the measuring and allocation of its parent.
3970    ///
3971    /// This is false for invisible children, but also
3972    /// for children that have their own surface, such
3973    /// as [`Popover`][crate::Popover] instances.
3974    ///
3975    /// # Returns
3976    ///
3977    /// true if child should be included in
3978    ///   measuring and allocating
3979    #[doc(alias = "gtk_widget_should_layout")]
3980    fn should_layout(&self) -> bool {
3981        unsafe {
3982            from_glib(ffi::gtk_widget_should_layout(
3983                self.as_ref().to_glib_none().0,
3984            ))
3985        }
3986    }
3987
3988    /// Flags a widget to be displayed.
3989    ///
3990    /// Any widget that isn’t shown will not appear on the screen.
3991    ///
3992    /// Remember that you have to show the containers containing a widget,
3993    /// in addition to the widget itself, before it will appear onscreen.
3994    ///
3995    /// When a toplevel widget is shown, it is immediately realized and
3996    /// mapped; other shown widgets are realized and mapped when their
3997    /// toplevel widget is realized and mapped.
3998    ///
3999    /// # Deprecated since 4.10
4000    ///
4001    /// Use [`set_visible()`][Self::set_visible()] instead
4002    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
4003    #[allow(deprecated)]
4004    #[doc(alias = "gtk_widget_show")]
4005    fn show(&self) {
4006        unsafe {
4007            ffi::gtk_widget_show(self.as_ref().to_glib_none().0);
4008        }
4009    }
4010
4011    /// Allocates widget with a transformation that translates
4012    /// the origin to the position in @allocation.
4013    ///
4014    /// This is a simple form of [`allocate()`][Self::allocate()].
4015    /// ## `allocation`
4016    /// position and size to be allocated to @self
4017    /// ## `baseline`
4018    /// the baseline of the child, or -1
4019    #[doc(alias = "gtk_widget_size_allocate")]
4020    fn size_allocate(&self, allocation: &Allocation, baseline: i32) {
4021        unsafe {
4022            ffi::gtk_widget_size_allocate(
4023                self.as_ref().to_glib_none().0,
4024                allocation.to_glib_none().0,
4025                baseline,
4026            );
4027        }
4028    }
4029
4030    /// Snapshots a child of the widget.
4031    ///
4032    /// When a widget receives a call to the snapshot function,
4033    /// it must send synthetic [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()] calls
4034    /// to all children. This function provides a convenient way
4035    /// of doing this. A widget, when it receives a call to its
4036    /// [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()] function, calls
4037    /// gtk_widget_snapshot_child() once for each child, passing in
4038    /// the @snapshot the widget received.
4039    ///
4040    /// This function takes care of translating the origin of @snapshot,
4041    /// and deciding whether the child needs to be snapshot.
4042    ///
4043    /// It does nothing for children that implement [`Native`][crate::Native].
4044    /// ## `child`
4045    /// a child of @self
4046    /// ## `snapshot`
4047    /// snapshot as passed to the widget. In particular, no
4048    ///   calls to [`SnapshotExt::translate()`][crate::prelude::SnapshotExt::translate()] or other transform calls
4049    ///   should have been made
4050    #[doc(alias = "gtk_widget_snapshot_child")]
4051    fn snapshot_child(&self, child: &impl IsA<Widget>, snapshot: &impl IsA<Snapshot>) {
4052        unsafe {
4053            ffi::gtk_widget_snapshot_child(
4054                self.as_ref().to_glib_none().0,
4055                child.as_ref().to_glib_none().0,
4056                snapshot.as_ref().to_glib_none().0,
4057            );
4058        }
4059    }
4060
4061    /// Translates coordinates relative to @self’s allocation
4062    /// to coordinates relative to @dest_widget’s allocations.
4063    ///
4064    /// In order to perform this operation, both widget must share
4065    /// a common ancestor. If that is not the case, @dest_x and @dest_y
4066    /// are set to 0 and false is returned.
4067    ///
4068    /// # Deprecated since 4.12
4069    ///
4070    /// Use [`compute_point()`][Self::compute_point()] instead
4071    /// ## `dest_widget`
4072    /// another widget
4073    /// ## `src_x`
4074    /// X position in widget coordinates of @self
4075    /// ## `src_y`
4076    /// Y position in widget coordinates of @self
4077    ///
4078    /// # Returns
4079    ///
4080    /// true if @self and @dest_widget have a common
4081    ///   ancestor, false otherwise
4082    ///
4083    /// ## `dest_x`
4084    /// location to store X position in widget coordinates of @dest_widget
4085    ///
4086    /// ## `dest_y`
4087    /// location to store Y position in widget coordinates of @dest_widget
4088    #[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
4089    #[allow(deprecated)]
4090    #[doc(alias = "gtk_widget_translate_coordinates")]
4091    fn translate_coordinates(
4092        &self,
4093        dest_widget: &impl IsA<Widget>,
4094        src_x: f64,
4095        src_y: f64,
4096    ) -> Option<(f64, f64)> {
4097        unsafe {
4098            let mut dest_x = std::mem::MaybeUninit::uninit();
4099            let mut dest_y = std::mem::MaybeUninit::uninit();
4100            let ret = from_glib(ffi::gtk_widget_translate_coordinates(
4101                self.as_ref().to_glib_none().0,
4102                dest_widget.as_ref().to_glib_none().0,
4103                src_x,
4104                src_y,
4105                dest_x.as_mut_ptr(),
4106                dest_y.as_mut_ptr(),
4107            ));
4108            if ret {
4109                Some((dest_x.assume_init(), dest_y.assume_init()))
4110            } else {
4111                None
4112            }
4113        }
4114    }
4115
4116    /// Triggers a tooltip query on the display of the widget.
4117    #[doc(alias = "gtk_widget_trigger_tooltip_query")]
4118    fn trigger_tooltip_query(&self) {
4119        unsafe {
4120            ffi::gtk_widget_trigger_tooltip_query(self.as_ref().to_glib_none().0);
4121        }
4122    }
4123
4124    /// Causes a widget to be unmapped if it’s currently mapped.
4125    ///
4126    /// This function is only for use in widget implementations.
4127    #[doc(alias = "gtk_widget_unmap")]
4128    fn unmap(&self) {
4129        unsafe {
4130            ffi::gtk_widget_unmap(self.as_ref().to_glib_none().0);
4131        }
4132    }
4133
4134    /// Removes @self from its parent.
4135    ///
4136    /// This function is only for use in widget implementations,
4137    /// typically in dispose.
4138    #[doc(alias = "gtk_widget_unparent")]
4139    fn unparent(&self) {
4140        unsafe {
4141            ffi::gtk_widget_unparent(self.as_ref().to_glib_none().0);
4142        }
4143    }
4144
4145    /// Causes a widget to be unrealized.
4146    ///
4147    /// This frees all GDK resources associated with the widget.
4148    ///
4149    /// This function is only useful in widget implementations.
4150    #[doc(alias = "gtk_widget_unrealize")]
4151    fn unrealize(&self) {
4152        unsafe {
4153            ffi::gtk_widget_unrealize(self.as_ref().to_glib_none().0);
4154        }
4155    }
4156
4157    /// Turns off flag values for the current widget state.
4158    ///
4159    /// See [`set_state_flags()`][Self::set_state_flags()].
4160    ///
4161    /// This function is for use in widget implementations.
4162    /// ## `flags`
4163    /// state flags to turn off
4164    #[doc(alias = "gtk_widget_unset_state_flags")]
4165    fn unset_state_flags(&self, flags: StateFlags) {
4166        unsafe {
4167            ffi::gtk_widget_unset_state_flags(self.as_ref().to_glib_none().0, flags.into_glib());
4168        }
4169    }
4170
4171    /// Overrides for height request of the widget.
4172    ///
4173    /// If this is -1, the natural request will be used.
4174    #[doc(alias = "height-request")]
4175    fn height_request(&self) -> i32 {
4176        ObjectExt::property(self.as_ref(), "height-request")
4177    }
4178
4179    /// Overrides for height request of the widget.
4180    ///
4181    /// If this is -1, the natural request will be used.
4182    #[doc(alias = "height-request")]
4183    fn set_height_request(&self, height_request: i32) {
4184        ObjectExt::set_property(self.as_ref(), "height-request", height_request)
4185    }
4186
4187    /// Overrides for width request of the widget.
4188    ///
4189    /// If this is -1, the natural request will be used.
4190    #[doc(alias = "width-request")]
4191    fn width_request(&self) -> i32 {
4192        ObjectExt::property(self.as_ref(), "width-request")
4193    }
4194
4195    /// Overrides for width request of the widget.
4196    ///
4197    /// If this is -1, the natural request will be used.
4198    #[doc(alias = "width-request")]
4199    fn set_width_request(&self, width_request: i32) {
4200        ObjectExt::set_property(self.as_ref(), "width-request", width_request)
4201    }
4202
4203    /// Signals that all holders of a reference to the widget should release
4204    /// the reference that they hold.
4205    ///
4206    /// May result in finalization of the widget if all references are released.
4207    ///
4208    /// This signal is not suitable for saving widget state.
4209    #[doc(alias = "destroy")]
4210    fn connect_destroy<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4211        unsafe extern "C" fn destroy_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4212            this: *mut ffi::GtkWidget,
4213            f: glib::ffi::gpointer,
4214        ) {
4215            unsafe {
4216                let f: &F = &*(f as *const F);
4217                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4218            }
4219        }
4220        unsafe {
4221            let f: Box_<F> = Box_::new(f);
4222            connect_raw(
4223                self.as_ptr() as *mut _,
4224                c"destroy".as_ptr(),
4225                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4226                    destroy_trampoline::<Self, F> as *const (),
4227                )),
4228                Box_::into_raw(f),
4229            )
4230        }
4231    }
4232
4233    /// Emitted when the text direction of a widget changes.
4234    /// ## `previous_direction`
4235    /// the previous text direction
4236    #[doc(alias = "direction-changed")]
4237    fn connect_direction_changed<F: Fn(&Self, TextDirection) + 'static>(
4238        &self,
4239        f: F,
4240    ) -> SignalHandlerId {
4241        unsafe extern "C" fn direction_changed_trampoline<
4242            P: IsA<Widget>,
4243            F: Fn(&P, TextDirection) + 'static,
4244        >(
4245            this: *mut ffi::GtkWidget,
4246            previous_direction: ffi::GtkTextDirection,
4247            f: glib::ffi::gpointer,
4248        ) {
4249            unsafe {
4250                let f: &F = &*(f as *const F);
4251                f(
4252                    Widget::from_glib_borrow(this).unsafe_cast_ref(),
4253                    from_glib(previous_direction),
4254                )
4255            }
4256        }
4257        unsafe {
4258            let f: Box_<F> = Box_::new(f);
4259            connect_raw(
4260                self.as_ptr() as *mut _,
4261                c"direction-changed".as_ptr(),
4262                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4263                    direction_changed_trampoline::<Self, F> as *const (),
4264                )),
4265                Box_::into_raw(f),
4266            )
4267        }
4268    }
4269
4270    /// Emitted when @widget is hidden.
4271    #[doc(alias = "hide")]
4272    fn connect_hide<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4273        unsafe extern "C" fn hide_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4274            this: *mut ffi::GtkWidget,
4275            f: glib::ffi::gpointer,
4276        ) {
4277            unsafe {
4278                let f: &F = &*(f as *const F);
4279                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4280            }
4281        }
4282        unsafe {
4283            let f: Box_<F> = Box_::new(f);
4284            connect_raw(
4285                self.as_ptr() as *mut _,
4286                c"hide".as_ptr(),
4287                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4288                    hide_trampoline::<Self, F> as *const (),
4289                )),
4290                Box_::into_raw(f),
4291            )
4292        }
4293    }
4294
4295    /// Emitted if keyboard navigation fails.
4296    ///
4297    /// See [`keynav_failed()`][Self::keynav_failed()] for details.
4298    /// ## `direction`
4299    /// the direction of movement
4300    ///
4301    /// # Returns
4302    ///
4303    /// true if stopping keyboard navigation is fine, false
4304    ///   if the emitting widget should try to handle the keyboard
4305    ///   navigation attempt in its parent widget
4306    #[doc(alias = "keynav-failed")]
4307    fn connect_keynav_failed<F: Fn(&Self, DirectionType) -> glib::Propagation + 'static>(
4308        &self,
4309        f: F,
4310    ) -> SignalHandlerId {
4311        unsafe extern "C" fn keynav_failed_trampoline<
4312            P: IsA<Widget>,
4313            F: Fn(&P, DirectionType) -> glib::Propagation + 'static,
4314        >(
4315            this: *mut ffi::GtkWidget,
4316            direction: ffi::GtkDirectionType,
4317            f: glib::ffi::gpointer,
4318        ) -> glib::ffi::gboolean {
4319            unsafe {
4320                let f: &F = &*(f as *const F);
4321                f(
4322                    Widget::from_glib_borrow(this).unsafe_cast_ref(),
4323                    from_glib(direction),
4324                )
4325                .into_glib()
4326            }
4327        }
4328        unsafe {
4329            let f: Box_<F> = Box_::new(f);
4330            connect_raw(
4331                self.as_ptr() as *mut _,
4332                c"keynav-failed".as_ptr(),
4333                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4334                    keynav_failed_trampoline::<Self, F> as *const (),
4335                )),
4336                Box_::into_raw(f),
4337            )
4338        }
4339    }
4340
4341    /// Emitted when @widget is going to be mapped.
4342    ///
4343    /// A widget is mapped when the widget is visible (which is controlled with
4344    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
4345    /// are also visible.
4346    ///
4347    /// The `::map` signal can be used to determine whether a widget will be drawn,
4348    /// for instance it can resume an animation that was stopped during the
4349    /// emission of [`unmap`][struct@crate::Widget#unmap].
4350    #[doc(alias = "map")]
4351    fn connect_map<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4352        unsafe extern "C" fn map_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4353            this: *mut ffi::GtkWidget,
4354            f: glib::ffi::gpointer,
4355        ) {
4356            unsafe {
4357                let f: &F = &*(f as *const F);
4358                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4359            }
4360        }
4361        unsafe {
4362            let f: Box_<F> = Box_::new(f);
4363            connect_raw(
4364                self.as_ptr() as *mut _,
4365                c"map".as_ptr(),
4366                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4367                    map_trampoline::<Self, F> as *const (),
4368                )),
4369                Box_::into_raw(f),
4370            )
4371        }
4372    }
4373
4374    /// Emitted when a widget is activated via a mnemonic.
4375    ///
4376    /// The default handler for this signal activates @widget if @group_cycling
4377    /// is false, or just makes @widget grab focus if @group_cycling is true.
4378    /// ## `group_cycling`
4379    /// true if there are other widgets with the same mnemonic
4380    ///
4381    /// # Returns
4382    ///
4383    /// true to stop other handlers from being invoked for the event,
4384    ///   false to propagate the event further
4385    #[doc(alias = "mnemonic-activate")]
4386    fn connect_mnemonic_activate<F: Fn(&Self, bool) -> glib::Propagation + 'static>(
4387        &self,
4388        f: F,
4389    ) -> SignalHandlerId {
4390        unsafe extern "C" fn mnemonic_activate_trampoline<
4391            P: IsA<Widget>,
4392            F: Fn(&P, bool) -> glib::Propagation + 'static,
4393        >(
4394            this: *mut ffi::GtkWidget,
4395            group_cycling: glib::ffi::gboolean,
4396            f: glib::ffi::gpointer,
4397        ) -> glib::ffi::gboolean {
4398            unsafe {
4399                let f: &F = &*(f as *const F);
4400                f(
4401                    Widget::from_glib_borrow(this).unsafe_cast_ref(),
4402                    from_glib(group_cycling),
4403                )
4404                .into_glib()
4405            }
4406        }
4407        unsafe {
4408            let f: Box_<F> = Box_::new(f);
4409            connect_raw(
4410                self.as_ptr() as *mut _,
4411                c"mnemonic-activate".as_ptr(),
4412                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4413                    mnemonic_activate_trampoline::<Self, F> as *const (),
4414                )),
4415                Box_::into_raw(f),
4416            )
4417        }
4418    }
4419
4420    /// Emitted when the focus is moved.
4421    ///
4422    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
4423    ///
4424    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
4425    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
4426    /// ## `direction`
4427    /// the direction of the focus move
4428    #[doc(alias = "move-focus")]
4429    fn connect_move_focus<F: Fn(&Self, DirectionType) + 'static>(&self, f: F) -> SignalHandlerId {
4430        unsafe extern "C" fn move_focus_trampoline<
4431            P: IsA<Widget>,
4432            F: Fn(&P, DirectionType) + 'static,
4433        >(
4434            this: *mut ffi::GtkWidget,
4435            direction: ffi::GtkDirectionType,
4436            f: glib::ffi::gpointer,
4437        ) {
4438            unsafe {
4439                let f: &F = &*(f as *const F);
4440                f(
4441                    Widget::from_glib_borrow(this).unsafe_cast_ref(),
4442                    from_glib(direction),
4443                )
4444            }
4445        }
4446        unsafe {
4447            let f: Box_<F> = Box_::new(f);
4448            connect_raw(
4449                self.as_ptr() as *mut _,
4450                c"move-focus".as_ptr(),
4451                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4452                    move_focus_trampoline::<Self, F> as *const (),
4453                )),
4454                Box_::into_raw(f),
4455            )
4456        }
4457    }
4458
4459    fn emit_move_focus(&self, direction: DirectionType) {
4460        self.emit_by_name::<()>("move-focus", &[&direction]);
4461    }
4462
4463    /// Emitted when the widget’s tooltip is about to be shown.
4464    ///
4465    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
4466    /// is true and the hover timeout has expired with the cursor hovering
4467    /// above @widget; or emitted when @widget got focus in keyboard mode.
4468    ///
4469    /// Using the given coordinates, the signal handler should determine
4470    /// whether a tooltip should be shown for @widget. If this is the case
4471    /// true should be returned, false otherwise. Note that if @keyboard_mode
4472    /// is true, the values of @x and @y are undefined and should not be used.
4473    ///
4474    /// The signal handler is free to manipulate @tooltip with the therefore
4475    /// destined function calls.
4476    /// ## `x`
4477    /// the x coordinate of the cursor position in widget coordinates
4478    /// ## `y`
4479    /// the y coordinate of the cursor position in widget coordinates
4480    /// ## `keyboard_mode`
4481    /// true if the tooltip was triggered using the keyboard
4482    /// ## `tooltip`
4483    /// a [`Tooltip`][crate::Tooltip]
4484    ///
4485    /// # Returns
4486    ///
4487    /// true if @tooltip should be shown right now, false otherwise
4488    #[doc(alias = "query-tooltip")]
4489    fn connect_query_tooltip<F: Fn(&Self, i32, i32, bool, &Tooltip) -> bool + 'static>(
4490        &self,
4491        f: F,
4492    ) -> SignalHandlerId {
4493        unsafe extern "C" fn query_tooltip_trampoline<
4494            P: IsA<Widget>,
4495            F: Fn(&P, i32, i32, bool, &Tooltip) -> bool + 'static,
4496        >(
4497            this: *mut ffi::GtkWidget,
4498            x: std::ffi::c_int,
4499            y: std::ffi::c_int,
4500            keyboard_mode: glib::ffi::gboolean,
4501            tooltip: *mut ffi::GtkTooltip,
4502            f: glib::ffi::gpointer,
4503        ) -> glib::ffi::gboolean {
4504            unsafe {
4505                let f: &F = &*(f as *const F);
4506                f(
4507                    Widget::from_glib_borrow(this).unsafe_cast_ref(),
4508                    x,
4509                    y,
4510                    from_glib(keyboard_mode),
4511                    &from_glib_borrow(tooltip),
4512                )
4513                .into_glib()
4514            }
4515        }
4516        unsafe {
4517            let f: Box_<F> = Box_::new(f);
4518            connect_raw(
4519                self.as_ptr() as *mut _,
4520                c"query-tooltip".as_ptr(),
4521                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4522                    query_tooltip_trampoline::<Self, F> as *const (),
4523                )),
4524                Box_::into_raw(f),
4525            )
4526        }
4527    }
4528
4529    /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
4530    ///
4531    /// This means that [`realize()`][Self::realize()] has been called
4532    /// or the widget has been mapped (that is, it is going to be drawn).
4533    #[doc(alias = "realize")]
4534    fn connect_realize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4535        unsafe extern "C" fn realize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4536            this: *mut ffi::GtkWidget,
4537            f: glib::ffi::gpointer,
4538        ) {
4539            unsafe {
4540                let f: &F = &*(f as *const F);
4541                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4542            }
4543        }
4544        unsafe {
4545            let f: Box_<F> = Box_::new(f);
4546            connect_raw(
4547                self.as_ptr() as *mut _,
4548                c"realize".as_ptr(),
4549                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4550                    realize_trampoline::<Self, F> as *const (),
4551                )),
4552                Box_::into_raw(f),
4553            )
4554        }
4555    }
4556
4557    /// Emitted when @widget is shown.
4558    #[doc(alias = "show")]
4559    fn connect_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4560        unsafe extern "C" fn show_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4561            this: *mut ffi::GtkWidget,
4562            f: glib::ffi::gpointer,
4563        ) {
4564            unsafe {
4565                let f: &F = &*(f as *const F);
4566                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4567            }
4568        }
4569        unsafe {
4570            let f: Box_<F> = Box_::new(f);
4571            connect_raw(
4572                self.as_ptr() as *mut _,
4573                c"show".as_ptr(),
4574                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4575                    show_trampoline::<Self, F> as *const (),
4576                )),
4577                Box_::into_raw(f),
4578            )
4579        }
4580    }
4581
4582    /// Emitted when the widget state changes.
4583    ///
4584    /// See [`state_flags()`][Self::state_flags()].
4585    /// ## `flags`
4586    /// the previous state flags
4587    #[doc(alias = "state-flags-changed")]
4588    fn connect_state_flags_changed<F: Fn(&Self, StateFlags) + 'static>(
4589        &self,
4590        f: F,
4591    ) -> SignalHandlerId {
4592        unsafe extern "C" fn state_flags_changed_trampoline<
4593            P: IsA<Widget>,
4594            F: Fn(&P, StateFlags) + 'static,
4595        >(
4596            this: *mut ffi::GtkWidget,
4597            flags: ffi::GtkStateFlags,
4598            f: glib::ffi::gpointer,
4599        ) {
4600            unsafe {
4601                let f: &F = &*(f as *const F);
4602                f(
4603                    Widget::from_glib_borrow(this).unsafe_cast_ref(),
4604                    from_glib(flags),
4605                )
4606            }
4607        }
4608        unsafe {
4609            let f: Box_<F> = Box_::new(f);
4610            connect_raw(
4611                self.as_ptr() as *mut _,
4612                c"state-flags-changed".as_ptr(),
4613                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4614                    state_flags_changed_trampoline::<Self, F> as *const (),
4615                )),
4616                Box_::into_raw(f),
4617            )
4618        }
4619    }
4620
4621    /// Emitted when @widget is going to be unmapped.
4622    ///
4623    /// A widget is unmapped when either it or any of its parents up to the
4624    /// toplevel widget have been set as hidden.
4625    ///
4626    /// As `::unmap` indicates that a widget will not be shown any longer,
4627    /// it can be used to, for example, stop an animation on the widget.
4628    #[doc(alias = "unmap")]
4629    fn connect_unmap<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4630        unsafe extern "C" fn unmap_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4631            this: *mut ffi::GtkWidget,
4632            f: glib::ffi::gpointer,
4633        ) {
4634            unsafe {
4635                let f: &F = &*(f as *const F);
4636                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4637            }
4638        }
4639        unsafe {
4640            let f: Box_<F> = Box_::new(f);
4641            connect_raw(
4642                self.as_ptr() as *mut _,
4643                c"unmap".as_ptr(),
4644                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4645                    unmap_trampoline::<Self, F> as *const (),
4646                )),
4647                Box_::into_raw(f),
4648            )
4649        }
4650    }
4651
4652    /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
4653    ///
4654    /// This means that [`unrealize()`][Self::unrealize()] has been called
4655    /// or the widget has been unmapped (that is, it is going to be hidden).
4656    #[doc(alias = "unrealize")]
4657    fn connect_unrealize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4658        unsafe extern "C" fn unrealize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4659            this: *mut ffi::GtkWidget,
4660            f: glib::ffi::gpointer,
4661        ) {
4662            unsafe {
4663                let f: &F = &*(f as *const F);
4664                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4665            }
4666        }
4667        unsafe {
4668            let f: Box_<F> = Box_::new(f);
4669            connect_raw(
4670                self.as_ptr() as *mut _,
4671                c"unrealize".as_ptr(),
4672                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4673                    unrealize_trampoline::<Self, F> as *const (),
4674                )),
4675                Box_::into_raw(f),
4676            )
4677        }
4678    }
4679
4680    #[doc(alias = "can-focus")]
4681    fn connect_can_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4682        unsafe extern "C" fn notify_can_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4683            this: *mut ffi::GtkWidget,
4684            _param_spec: glib::ffi::gpointer,
4685            f: glib::ffi::gpointer,
4686        ) {
4687            unsafe {
4688                let f: &F = &*(f as *const F);
4689                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4690            }
4691        }
4692        unsafe {
4693            let f: Box_<F> = Box_::new(f);
4694            connect_raw(
4695                self.as_ptr() as *mut _,
4696                c"notify::can-focus".as_ptr(),
4697                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4698                    notify_can_focus_trampoline::<Self, F> as *const (),
4699                )),
4700                Box_::into_raw(f),
4701            )
4702        }
4703    }
4704
4705    #[doc(alias = "can-target")]
4706    fn connect_can_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4707        unsafe extern "C" fn notify_can_target_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4708            this: *mut ffi::GtkWidget,
4709            _param_spec: glib::ffi::gpointer,
4710            f: glib::ffi::gpointer,
4711        ) {
4712            unsafe {
4713                let f: &F = &*(f as *const F);
4714                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4715            }
4716        }
4717        unsafe {
4718            let f: Box_<F> = Box_::new(f);
4719            connect_raw(
4720                self.as_ptr() as *mut _,
4721                c"notify::can-target".as_ptr(),
4722                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4723                    notify_can_target_trampoline::<Self, F> as *const (),
4724                )),
4725                Box_::into_raw(f),
4726            )
4727        }
4728    }
4729
4730    #[doc(alias = "css-classes")]
4731    fn connect_css_classes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4732        unsafe extern "C" fn notify_css_classes_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4733            this: *mut ffi::GtkWidget,
4734            _param_spec: glib::ffi::gpointer,
4735            f: glib::ffi::gpointer,
4736        ) {
4737            unsafe {
4738                let f: &F = &*(f as *const F);
4739                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4740            }
4741        }
4742        unsafe {
4743            let f: Box_<F> = Box_::new(f);
4744            connect_raw(
4745                self.as_ptr() as *mut _,
4746                c"notify::css-classes".as_ptr(),
4747                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4748                    notify_css_classes_trampoline::<Self, F> as *const (),
4749                )),
4750                Box_::into_raw(f),
4751            )
4752        }
4753    }
4754
4755    #[doc(alias = "cursor")]
4756    fn connect_cursor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4757        unsafe extern "C" fn notify_cursor_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4758            this: *mut ffi::GtkWidget,
4759            _param_spec: glib::ffi::gpointer,
4760            f: glib::ffi::gpointer,
4761        ) {
4762            unsafe {
4763                let f: &F = &*(f as *const F);
4764                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4765            }
4766        }
4767        unsafe {
4768            let f: Box_<F> = Box_::new(f);
4769            connect_raw(
4770                self.as_ptr() as *mut _,
4771                c"notify::cursor".as_ptr(),
4772                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4773                    notify_cursor_trampoline::<Self, F> as *const (),
4774                )),
4775                Box_::into_raw(f),
4776            )
4777        }
4778    }
4779
4780    #[doc(alias = "focus-on-click")]
4781    fn connect_focus_on_click_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4782        unsafe extern "C" fn notify_focus_on_click_trampoline<
4783            P: IsA<Widget>,
4784            F: Fn(&P) + 'static,
4785        >(
4786            this: *mut ffi::GtkWidget,
4787            _param_spec: glib::ffi::gpointer,
4788            f: glib::ffi::gpointer,
4789        ) {
4790            unsafe {
4791                let f: &F = &*(f as *const F);
4792                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4793            }
4794        }
4795        unsafe {
4796            let f: Box_<F> = Box_::new(f);
4797            connect_raw(
4798                self.as_ptr() as *mut _,
4799                c"notify::focus-on-click".as_ptr(),
4800                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4801                    notify_focus_on_click_trampoline::<Self, F> as *const (),
4802                )),
4803                Box_::into_raw(f),
4804            )
4805        }
4806    }
4807
4808    #[doc(alias = "focusable")]
4809    fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4810        unsafe extern "C" fn notify_focusable_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4811            this: *mut ffi::GtkWidget,
4812            _param_spec: glib::ffi::gpointer,
4813            f: glib::ffi::gpointer,
4814        ) {
4815            unsafe {
4816                let f: &F = &*(f as *const F);
4817                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4818            }
4819        }
4820        unsafe {
4821            let f: Box_<F> = Box_::new(f);
4822            connect_raw(
4823                self.as_ptr() as *mut _,
4824                c"notify::focusable".as_ptr(),
4825                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4826                    notify_focusable_trampoline::<Self, F> as *const (),
4827                )),
4828                Box_::into_raw(f),
4829            )
4830        }
4831    }
4832
4833    #[doc(alias = "halign")]
4834    fn connect_halign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4835        unsafe extern "C" fn notify_halign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4836            this: *mut ffi::GtkWidget,
4837            _param_spec: glib::ffi::gpointer,
4838            f: glib::ffi::gpointer,
4839        ) {
4840            unsafe {
4841                let f: &F = &*(f as *const F);
4842                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4843            }
4844        }
4845        unsafe {
4846            let f: Box_<F> = Box_::new(f);
4847            connect_raw(
4848                self.as_ptr() as *mut _,
4849                c"notify::halign".as_ptr(),
4850                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4851                    notify_halign_trampoline::<Self, F> as *const (),
4852                )),
4853                Box_::into_raw(f),
4854            )
4855        }
4856    }
4857
4858    #[doc(alias = "has-default")]
4859    fn connect_has_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4860        unsafe extern "C" fn notify_has_default_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4861            this: *mut ffi::GtkWidget,
4862            _param_spec: glib::ffi::gpointer,
4863            f: glib::ffi::gpointer,
4864        ) {
4865            unsafe {
4866                let f: &F = &*(f as *const F);
4867                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4868            }
4869        }
4870        unsafe {
4871            let f: Box_<F> = Box_::new(f);
4872            connect_raw(
4873                self.as_ptr() as *mut _,
4874                c"notify::has-default".as_ptr(),
4875                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4876                    notify_has_default_trampoline::<Self, F> as *const (),
4877                )),
4878                Box_::into_raw(f),
4879            )
4880        }
4881    }
4882
4883    #[doc(alias = "has-focus")]
4884    fn connect_has_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4885        unsafe extern "C" fn notify_has_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4886            this: *mut ffi::GtkWidget,
4887            _param_spec: glib::ffi::gpointer,
4888            f: glib::ffi::gpointer,
4889        ) {
4890            unsafe {
4891                let f: &F = &*(f as *const F);
4892                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4893            }
4894        }
4895        unsafe {
4896            let f: Box_<F> = Box_::new(f);
4897            connect_raw(
4898                self.as_ptr() as *mut _,
4899                c"notify::has-focus".as_ptr(),
4900                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4901                    notify_has_focus_trampoline::<Self, F> as *const (),
4902                )),
4903                Box_::into_raw(f),
4904            )
4905        }
4906    }
4907
4908    #[doc(alias = "has-tooltip")]
4909    fn connect_has_tooltip_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4910        unsafe extern "C" fn notify_has_tooltip_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4911            this: *mut ffi::GtkWidget,
4912            _param_spec: glib::ffi::gpointer,
4913            f: glib::ffi::gpointer,
4914        ) {
4915            unsafe {
4916                let f: &F = &*(f as *const F);
4917                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4918            }
4919        }
4920        unsafe {
4921            let f: Box_<F> = Box_::new(f);
4922            connect_raw(
4923                self.as_ptr() as *mut _,
4924                c"notify::has-tooltip".as_ptr(),
4925                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4926                    notify_has_tooltip_trampoline::<Self, F> as *const (),
4927                )),
4928                Box_::into_raw(f),
4929            )
4930        }
4931    }
4932
4933    #[doc(alias = "height-request")]
4934    fn connect_height_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4935        unsafe extern "C" fn notify_height_request_trampoline<
4936            P: IsA<Widget>,
4937            F: Fn(&P) + 'static,
4938        >(
4939            this: *mut ffi::GtkWidget,
4940            _param_spec: glib::ffi::gpointer,
4941            f: glib::ffi::gpointer,
4942        ) {
4943            unsafe {
4944                let f: &F = &*(f as *const F);
4945                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4946            }
4947        }
4948        unsafe {
4949            let f: Box_<F> = Box_::new(f);
4950            connect_raw(
4951                self.as_ptr() as *mut _,
4952                c"notify::height-request".as_ptr(),
4953                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4954                    notify_height_request_trampoline::<Self, F> as *const (),
4955                )),
4956                Box_::into_raw(f),
4957            )
4958        }
4959    }
4960
4961    #[doc(alias = "hexpand")]
4962    fn connect_hexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4963        unsafe extern "C" fn notify_hexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4964            this: *mut ffi::GtkWidget,
4965            _param_spec: glib::ffi::gpointer,
4966            f: glib::ffi::gpointer,
4967        ) {
4968            unsafe {
4969                let f: &F = &*(f as *const F);
4970                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4971            }
4972        }
4973        unsafe {
4974            let f: Box_<F> = Box_::new(f);
4975            connect_raw(
4976                self.as_ptr() as *mut _,
4977                c"notify::hexpand".as_ptr(),
4978                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4979                    notify_hexpand_trampoline::<Self, F> as *const (),
4980                )),
4981                Box_::into_raw(f),
4982            )
4983        }
4984    }
4985
4986    #[doc(alias = "hexpand-set")]
4987    fn connect_hexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4988        unsafe extern "C" fn notify_hexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
4989            this: *mut ffi::GtkWidget,
4990            _param_spec: glib::ffi::gpointer,
4991            f: glib::ffi::gpointer,
4992        ) {
4993            unsafe {
4994                let f: &F = &*(f as *const F);
4995                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
4996            }
4997        }
4998        unsafe {
4999            let f: Box_<F> = Box_::new(f);
5000            connect_raw(
5001                self.as_ptr() as *mut _,
5002                c"notify::hexpand-set".as_ptr(),
5003                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5004                    notify_hexpand_set_trampoline::<Self, F> as *const (),
5005                )),
5006                Box_::into_raw(f),
5007            )
5008        }
5009    }
5010
5011    #[doc(alias = "layout-manager")]
5012    fn connect_layout_manager_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5013        unsafe extern "C" fn notify_layout_manager_trampoline<
5014            P: IsA<Widget>,
5015            F: Fn(&P) + 'static,
5016        >(
5017            this: *mut ffi::GtkWidget,
5018            _param_spec: glib::ffi::gpointer,
5019            f: glib::ffi::gpointer,
5020        ) {
5021            unsafe {
5022                let f: &F = &*(f as *const F);
5023                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5024            }
5025        }
5026        unsafe {
5027            let f: Box_<F> = Box_::new(f);
5028            connect_raw(
5029                self.as_ptr() as *mut _,
5030                c"notify::layout-manager".as_ptr(),
5031                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5032                    notify_layout_manager_trampoline::<Self, F> as *const (),
5033                )),
5034                Box_::into_raw(f),
5035            )
5036        }
5037    }
5038
5039    #[cfg(feature = "v4_18")]
5040    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
5041    #[doc(alias = "limit-events")]
5042    fn connect_limit_events_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5043        unsafe extern "C" fn notify_limit_events_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5044            this: *mut ffi::GtkWidget,
5045            _param_spec: glib::ffi::gpointer,
5046            f: glib::ffi::gpointer,
5047        ) {
5048            unsafe {
5049                let f: &F = &*(f as *const F);
5050                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5051            }
5052        }
5053        unsafe {
5054            let f: Box_<F> = Box_::new(f);
5055            connect_raw(
5056                self.as_ptr() as *mut _,
5057                c"notify::limit-events".as_ptr(),
5058                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5059                    notify_limit_events_trampoline::<Self, F> as *const (),
5060                )),
5061                Box_::into_raw(f),
5062            )
5063        }
5064    }
5065
5066    #[doc(alias = "margin-bottom")]
5067    fn connect_margin_bottom_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5068        unsafe extern "C" fn notify_margin_bottom_trampoline<
5069            P: IsA<Widget>,
5070            F: Fn(&P) + 'static,
5071        >(
5072            this: *mut ffi::GtkWidget,
5073            _param_spec: glib::ffi::gpointer,
5074            f: glib::ffi::gpointer,
5075        ) {
5076            unsafe {
5077                let f: &F = &*(f as *const F);
5078                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5079            }
5080        }
5081        unsafe {
5082            let f: Box_<F> = Box_::new(f);
5083            connect_raw(
5084                self.as_ptr() as *mut _,
5085                c"notify::margin-bottom".as_ptr(),
5086                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5087                    notify_margin_bottom_trampoline::<Self, F> as *const (),
5088                )),
5089                Box_::into_raw(f),
5090            )
5091        }
5092    }
5093
5094    #[doc(alias = "margin-end")]
5095    fn connect_margin_end_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5096        unsafe extern "C" fn notify_margin_end_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5097            this: *mut ffi::GtkWidget,
5098            _param_spec: glib::ffi::gpointer,
5099            f: glib::ffi::gpointer,
5100        ) {
5101            unsafe {
5102                let f: &F = &*(f as *const F);
5103                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5104            }
5105        }
5106        unsafe {
5107            let f: Box_<F> = Box_::new(f);
5108            connect_raw(
5109                self.as_ptr() as *mut _,
5110                c"notify::margin-end".as_ptr(),
5111                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5112                    notify_margin_end_trampoline::<Self, F> as *const (),
5113                )),
5114                Box_::into_raw(f),
5115            )
5116        }
5117    }
5118
5119    #[doc(alias = "margin-start")]
5120    fn connect_margin_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5121        unsafe extern "C" fn notify_margin_start_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5122            this: *mut ffi::GtkWidget,
5123            _param_spec: glib::ffi::gpointer,
5124            f: glib::ffi::gpointer,
5125        ) {
5126            unsafe {
5127                let f: &F = &*(f as *const F);
5128                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5129            }
5130        }
5131        unsafe {
5132            let f: Box_<F> = Box_::new(f);
5133            connect_raw(
5134                self.as_ptr() as *mut _,
5135                c"notify::margin-start".as_ptr(),
5136                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5137                    notify_margin_start_trampoline::<Self, F> as *const (),
5138                )),
5139                Box_::into_raw(f),
5140            )
5141        }
5142    }
5143
5144    #[doc(alias = "margin-top")]
5145    fn connect_margin_top_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5146        unsafe extern "C" fn notify_margin_top_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5147            this: *mut ffi::GtkWidget,
5148            _param_spec: glib::ffi::gpointer,
5149            f: glib::ffi::gpointer,
5150        ) {
5151            unsafe {
5152                let f: &F = &*(f as *const F);
5153                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5154            }
5155        }
5156        unsafe {
5157            let f: Box_<F> = Box_::new(f);
5158            connect_raw(
5159                self.as_ptr() as *mut _,
5160                c"notify::margin-top".as_ptr(),
5161                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5162                    notify_margin_top_trampoline::<Self, F> as *const (),
5163                )),
5164                Box_::into_raw(f),
5165            )
5166        }
5167    }
5168
5169    #[doc(alias = "name")]
5170    fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5171        unsafe extern "C" fn notify_name_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5172            this: *mut ffi::GtkWidget,
5173            _param_spec: glib::ffi::gpointer,
5174            f: glib::ffi::gpointer,
5175        ) {
5176            unsafe {
5177                let f: &F = &*(f as *const F);
5178                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5179            }
5180        }
5181        unsafe {
5182            let f: Box_<F> = Box_::new(f);
5183            connect_raw(
5184                self.as_ptr() as *mut _,
5185                c"notify::name".as_ptr(),
5186                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5187                    notify_name_trampoline::<Self, F> as *const (),
5188                )),
5189                Box_::into_raw(f),
5190            )
5191        }
5192    }
5193
5194    #[doc(alias = "opacity")]
5195    fn connect_opacity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5196        unsafe extern "C" fn notify_opacity_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5197            this: *mut ffi::GtkWidget,
5198            _param_spec: glib::ffi::gpointer,
5199            f: glib::ffi::gpointer,
5200        ) {
5201            unsafe {
5202                let f: &F = &*(f as *const F);
5203                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5204            }
5205        }
5206        unsafe {
5207            let f: Box_<F> = Box_::new(f);
5208            connect_raw(
5209                self.as_ptr() as *mut _,
5210                c"notify::opacity".as_ptr(),
5211                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5212                    notify_opacity_trampoline::<Self, F> as *const (),
5213                )),
5214                Box_::into_raw(f),
5215            )
5216        }
5217    }
5218
5219    #[doc(alias = "overflow")]
5220    fn connect_overflow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5221        unsafe extern "C" fn notify_overflow_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5222            this: *mut ffi::GtkWidget,
5223            _param_spec: glib::ffi::gpointer,
5224            f: glib::ffi::gpointer,
5225        ) {
5226            unsafe {
5227                let f: &F = &*(f as *const F);
5228                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5229            }
5230        }
5231        unsafe {
5232            let f: Box_<F> = Box_::new(f);
5233            connect_raw(
5234                self.as_ptr() as *mut _,
5235                c"notify::overflow".as_ptr(),
5236                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5237                    notify_overflow_trampoline::<Self, F> as *const (),
5238                )),
5239                Box_::into_raw(f),
5240            )
5241        }
5242    }
5243
5244    #[doc(alias = "parent")]
5245    fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5246        unsafe extern "C" fn notify_parent_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5247            this: *mut ffi::GtkWidget,
5248            _param_spec: glib::ffi::gpointer,
5249            f: glib::ffi::gpointer,
5250        ) {
5251            unsafe {
5252                let f: &F = &*(f as *const F);
5253                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5254            }
5255        }
5256        unsafe {
5257            let f: Box_<F> = Box_::new(f);
5258            connect_raw(
5259                self.as_ptr() as *mut _,
5260                c"notify::parent".as_ptr(),
5261                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5262                    notify_parent_trampoline::<Self, F> as *const (),
5263                )),
5264                Box_::into_raw(f),
5265            )
5266        }
5267    }
5268
5269    #[doc(alias = "receives-default")]
5270    fn connect_receives_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5271        unsafe extern "C" fn notify_receives_default_trampoline<
5272            P: IsA<Widget>,
5273            F: Fn(&P) + 'static,
5274        >(
5275            this: *mut ffi::GtkWidget,
5276            _param_spec: glib::ffi::gpointer,
5277            f: glib::ffi::gpointer,
5278        ) {
5279            unsafe {
5280                let f: &F = &*(f as *const F);
5281                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5282            }
5283        }
5284        unsafe {
5285            let f: Box_<F> = Box_::new(f);
5286            connect_raw(
5287                self.as_ptr() as *mut _,
5288                c"notify::receives-default".as_ptr(),
5289                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5290                    notify_receives_default_trampoline::<Self, F> as *const (),
5291                )),
5292                Box_::into_raw(f),
5293            )
5294        }
5295    }
5296
5297    #[doc(alias = "root")]
5298    fn connect_root_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5299        unsafe extern "C" fn notify_root_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5300            this: *mut ffi::GtkWidget,
5301            _param_spec: glib::ffi::gpointer,
5302            f: glib::ffi::gpointer,
5303        ) {
5304            unsafe {
5305                let f: &F = &*(f as *const F);
5306                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5307            }
5308        }
5309        unsafe {
5310            let f: Box_<F> = Box_::new(f);
5311            connect_raw(
5312                self.as_ptr() as *mut _,
5313                c"notify::root".as_ptr(),
5314                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5315                    notify_root_trampoline::<Self, F> as *const (),
5316                )),
5317                Box_::into_raw(f),
5318            )
5319        }
5320    }
5321
5322    #[doc(alias = "scale-factor")]
5323    fn connect_scale_factor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5324        unsafe extern "C" fn notify_scale_factor_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5325            this: *mut ffi::GtkWidget,
5326            _param_spec: glib::ffi::gpointer,
5327            f: glib::ffi::gpointer,
5328        ) {
5329            unsafe {
5330                let f: &F = &*(f as *const F);
5331                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5332            }
5333        }
5334        unsafe {
5335            let f: Box_<F> = Box_::new(f);
5336            connect_raw(
5337                self.as_ptr() as *mut _,
5338                c"notify::scale-factor".as_ptr(),
5339                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5340                    notify_scale_factor_trampoline::<Self, F> as *const (),
5341                )),
5342                Box_::into_raw(f),
5343            )
5344        }
5345    }
5346
5347    #[doc(alias = "sensitive")]
5348    fn connect_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5349        unsafe extern "C" fn notify_sensitive_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5350            this: *mut ffi::GtkWidget,
5351            _param_spec: glib::ffi::gpointer,
5352            f: glib::ffi::gpointer,
5353        ) {
5354            unsafe {
5355                let f: &F = &*(f as *const F);
5356                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5357            }
5358        }
5359        unsafe {
5360            let f: Box_<F> = Box_::new(f);
5361            connect_raw(
5362                self.as_ptr() as *mut _,
5363                c"notify::sensitive".as_ptr(),
5364                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5365                    notify_sensitive_trampoline::<Self, F> as *const (),
5366                )),
5367                Box_::into_raw(f),
5368            )
5369        }
5370    }
5371
5372    #[doc(alias = "tooltip-markup")]
5373    fn connect_tooltip_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5374        unsafe extern "C" fn notify_tooltip_markup_trampoline<
5375            P: IsA<Widget>,
5376            F: Fn(&P) + 'static,
5377        >(
5378            this: *mut ffi::GtkWidget,
5379            _param_spec: glib::ffi::gpointer,
5380            f: glib::ffi::gpointer,
5381        ) {
5382            unsafe {
5383                let f: &F = &*(f as *const F);
5384                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5385            }
5386        }
5387        unsafe {
5388            let f: Box_<F> = Box_::new(f);
5389            connect_raw(
5390                self.as_ptr() as *mut _,
5391                c"notify::tooltip-markup".as_ptr(),
5392                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5393                    notify_tooltip_markup_trampoline::<Self, F> as *const (),
5394                )),
5395                Box_::into_raw(f),
5396            )
5397        }
5398    }
5399
5400    #[doc(alias = "tooltip-text")]
5401    fn connect_tooltip_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5402        unsafe extern "C" fn notify_tooltip_text_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5403            this: *mut ffi::GtkWidget,
5404            _param_spec: glib::ffi::gpointer,
5405            f: glib::ffi::gpointer,
5406        ) {
5407            unsafe {
5408                let f: &F = &*(f as *const F);
5409                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5410            }
5411        }
5412        unsafe {
5413            let f: Box_<F> = Box_::new(f);
5414            connect_raw(
5415                self.as_ptr() as *mut _,
5416                c"notify::tooltip-text".as_ptr(),
5417                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5418                    notify_tooltip_text_trampoline::<Self, F> as *const (),
5419                )),
5420                Box_::into_raw(f),
5421            )
5422        }
5423    }
5424
5425    #[doc(alias = "valign")]
5426    fn connect_valign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5427        unsafe extern "C" fn notify_valign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5428            this: *mut ffi::GtkWidget,
5429            _param_spec: glib::ffi::gpointer,
5430            f: glib::ffi::gpointer,
5431        ) {
5432            unsafe {
5433                let f: &F = &*(f as *const F);
5434                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5435            }
5436        }
5437        unsafe {
5438            let f: Box_<F> = Box_::new(f);
5439            connect_raw(
5440                self.as_ptr() as *mut _,
5441                c"notify::valign".as_ptr(),
5442                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5443                    notify_valign_trampoline::<Self, F> as *const (),
5444                )),
5445                Box_::into_raw(f),
5446            )
5447        }
5448    }
5449
5450    #[doc(alias = "vexpand")]
5451    fn connect_vexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5452        unsafe extern "C" fn notify_vexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5453            this: *mut ffi::GtkWidget,
5454            _param_spec: glib::ffi::gpointer,
5455            f: glib::ffi::gpointer,
5456        ) {
5457            unsafe {
5458                let f: &F = &*(f as *const F);
5459                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5460            }
5461        }
5462        unsafe {
5463            let f: Box_<F> = Box_::new(f);
5464            connect_raw(
5465                self.as_ptr() as *mut _,
5466                c"notify::vexpand".as_ptr(),
5467                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5468                    notify_vexpand_trampoline::<Self, F> as *const (),
5469                )),
5470                Box_::into_raw(f),
5471            )
5472        }
5473    }
5474
5475    #[doc(alias = "vexpand-set")]
5476    fn connect_vexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5477        unsafe extern "C" fn notify_vexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5478            this: *mut ffi::GtkWidget,
5479            _param_spec: glib::ffi::gpointer,
5480            f: glib::ffi::gpointer,
5481        ) {
5482            unsafe {
5483                let f: &F = &*(f as *const F);
5484                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5485            }
5486        }
5487        unsafe {
5488            let f: Box_<F> = Box_::new(f);
5489            connect_raw(
5490                self.as_ptr() as *mut _,
5491                c"notify::vexpand-set".as_ptr(),
5492                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5493                    notify_vexpand_set_trampoline::<Self, F> as *const (),
5494                )),
5495                Box_::into_raw(f),
5496            )
5497        }
5498    }
5499
5500    #[doc(alias = "visible")]
5501    fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5502        unsafe extern "C" fn notify_visible_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5503            this: *mut ffi::GtkWidget,
5504            _param_spec: glib::ffi::gpointer,
5505            f: glib::ffi::gpointer,
5506        ) {
5507            unsafe {
5508                let f: &F = &*(f as *const F);
5509                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5510            }
5511        }
5512        unsafe {
5513            let f: Box_<F> = Box_::new(f);
5514            connect_raw(
5515                self.as_ptr() as *mut _,
5516                c"notify::visible".as_ptr(),
5517                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5518                    notify_visible_trampoline::<Self, F> as *const (),
5519                )),
5520                Box_::into_raw(f),
5521            )
5522        }
5523    }
5524
5525    #[doc(alias = "width-request")]
5526    fn connect_width_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5527        unsafe extern "C" fn notify_width_request_trampoline<
5528            P: IsA<Widget>,
5529            F: Fn(&P) + 'static,
5530        >(
5531            this: *mut ffi::GtkWidget,
5532            _param_spec: glib::ffi::gpointer,
5533            f: glib::ffi::gpointer,
5534        ) {
5535            unsafe {
5536                let f: &F = &*(f as *const F);
5537                f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5538            }
5539        }
5540        unsafe {
5541            let f: Box_<F> = Box_::new(f);
5542            connect_raw(
5543                self.as_ptr() as *mut _,
5544                c"notify::width-request".as_ptr(),
5545                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5546                    notify_width_request_trampoline::<Self, F> as *const (),
5547                )),
5548                Box_::into_raw(f),
5549            )
5550        }
5551    }
5552}
5553
5554impl<O: IsA<Widget>> WidgetExt for O {}