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