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