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