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