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