gtk/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
5use crate::{
6 AccelFlags, AccelGroup, Align, Allocation, Buildable, Clipboard, DirectionType, DragResult,
7 Orientation, Requisition, SelectionData, Settings, SizeRequestMode, StateFlags, StyleContext,
8 TargetList, TextDirection, Tooltip, WidgetHelpType, WidgetPath, Window, ffi,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 ///
20 /// // the signal handler has the instance and user data swapped
21 /// // because of the swapped="yes" attribute in the template XML
22 /// static void
23 /// hello_button_clicked (FooWidget *self,
24 /// GtkButton *button)
25 /// {
26 /// g_print ("Hello, world!\n");
27 /// }
28 ///
29 /// static void
30 /// foo_widget_class_init (FooWidgetClass *klass)
31 /// {
32 /// // ...
33 /// gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
34 /// "/com/example/ui/foowidget.ui");
35 /// gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked);
36 /// }
37 /// ]|
38 ///
39 /// This is an Abstract Base Class, you cannot instantiate it.
40 ///
41 /// ## Properties
42 ///
43 ///
44 /// #### `app-paintable`
45 /// Readable | Writable
46 ///
47 ///
48 /// #### `can-default`
49 /// Readable | Writable
50 ///
51 ///
52 /// #### `can-focus`
53 /// Readable | Writable
54 ///
55 ///
56 /// #### `composite-child`
57 /// Readable
58 ///
59 ///
60 /// #### `double-buffered`
61 /// Whether the widget is double buffered.
62 ///
63 /// Readable | Writable
64 ///
65 ///
66 /// #### `events`
67 /// Readable | Writable
68 ///
69 ///
70 /// #### `expand`
71 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
72 ///
73 /// Readable | Writable
74 ///
75 ///
76 /// #### `focus-on-click`
77 /// Whether the widget should grab focus when it is clicked with the mouse.
78 ///
79 /// This property is only relevant for widgets that can take focus.
80 ///
81 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
82 /// GtkComboBox) implemented this property individually.
83 ///
84 /// Readable | Writable
85 ///
86 ///
87 /// #### `halign`
88 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
89 ///
90 /// Readable | Writable
91 ///
92 ///
93 /// #### `has-default`
94 /// Readable | Writable
95 ///
96 ///
97 /// #### `has-focus`
98 /// Readable | Writable
99 ///
100 ///
101 /// #### `has-tooltip`
102 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
103 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
104 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
105 /// whether it will provide a tooltip or not.
106 ///
107 /// Note that setting this property to [`true`] for the first time will change
108 /// the event masks of the GdkWindows of this widget to include leave-notify
109 /// and motion-notify events. This cannot and will not be undone when the
110 /// property is set to [`false`] again.
111 ///
112 /// Readable | Writable
113 ///
114 ///
115 /// #### `height-request`
116 /// Readable | Writable
117 ///
118 ///
119 /// #### `hexpand`
120 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
121 ///
122 /// Readable | Writable
123 ///
124 ///
125 /// #### `hexpand-set`
126 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
127 ///
128 /// Readable | Writable
129 ///
130 ///
131 /// #### `is-focus`
132 /// Readable | Writable
133 ///
134 ///
135 /// #### `margin`
136 /// Sets all four sides' margin at once. If read, returns max
137 /// margin on any side.
138 ///
139 /// Readable | Writable
140 ///
141 ///
142 /// #### `margin-bottom`
143 /// Margin on bottom side of widget.
144 ///
145 /// This property adds margin outside of the widget's normal size
146 /// request, the margin will be added in addition to the size from
147 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
148 ///
149 /// Readable | Writable
150 ///
151 ///
152 /// #### `margin-end`
153 /// Margin on end of widget, horizontally. This property supports
154 /// left-to-right and right-to-left text directions.
155 ///
156 /// This property adds margin outside of the widget's normal size
157 /// request, the margin will be added in addition to the size from
158 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
159 ///
160 /// Readable | Writable
161 ///
162 ///
163 /// #### `margin-left`
164 /// Margin on left side of widget.
165 ///
166 /// This property adds margin outside of the widget's normal size
167 /// request, the margin will be added in addition to the size from
168 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
169 ///
170 /// Readable | Writable
171 ///
172 ///
173 /// #### `margin-right`
174 /// Margin on right side of widget.
175 ///
176 /// This property adds margin outside of the widget's normal size
177 /// request, the margin will be added in addition to the size from
178 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
179 ///
180 /// Readable | Writable
181 ///
182 ///
183 /// #### `margin-start`
184 /// Margin on start of widget, horizontally. This property supports
185 /// left-to-right and right-to-left text directions.
186 ///
187 /// This property adds margin outside of the widget's normal size
188 /// request, the margin will be added in addition to the size from
189 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
190 ///
191 /// Readable | Writable
192 ///
193 ///
194 /// #### `margin-top`
195 /// Margin on top 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 /// #### `name`
205 /// Readable | Writable
206 ///
207 ///
208 /// #### `no-show-all`
209 /// Readable | Writable
210 ///
211 ///
212 /// #### `opacity`
213 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
214 /// more details about window opacity.
215 ///
216 /// Before 3.8 this was only available in GtkWindow
217 ///
218 /// Readable | Writable
219 ///
220 ///
221 /// #### `parent`
222 /// Readable | Writable
223 ///
224 ///
225 /// #### `receives-default`
226 /// Readable | Writable
227 ///
228 ///
229 /// #### `scale-factor`
230 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
231 /// more details about widget scaling.
232 ///
233 /// Readable
234 ///
235 ///
236 /// #### `sensitive`
237 /// Readable | Writable
238 ///
239 ///
240 /// #### `style`
241 /// The style of the widget, which contains information about how it will look (colors, etc).
242 ///
243 /// Readable | Writable
244 ///
245 ///
246 /// #### `tooltip-markup`
247 /// Sets the text of tooltip to be the given string, which is marked up
248 /// with the [Pango text markup language][PangoMarkupFormat].
249 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
250 ///
251 /// This is a convenience property which will take care of getting the
252 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
253 /// will automatically be set to [`true`] and there will be taken care of
254 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
255 ///
256 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
257 /// are set, the last one wins.
258 ///
259 /// Readable | Writable
260 ///
261 ///
262 /// #### `tooltip-text`
263 /// Sets the text of tooltip to be the given string.
264 ///
265 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
266 ///
267 /// This is a convenience property which will take care of getting the
268 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
269 /// will automatically be set to [`true`] and there will be taken care of
270 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
271 ///
272 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
273 /// are set, the last one wins.
274 ///
275 /// Readable | Writable
276 ///
277 ///
278 /// #### `valign`
279 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
280 ///
281 /// Readable | Writable
282 ///
283 ///
284 /// #### `vexpand`
285 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
286 ///
287 /// Readable | Writable
288 ///
289 ///
290 /// #### `vexpand-set`
291 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
292 ///
293 /// Readable | Writable
294 ///
295 ///
296 /// #### `visible`
297 /// Readable | Writable
298 ///
299 ///
300 /// #### `width-request`
301 /// Readable | Writable
302 ///
303 ///
304 /// #### `window`
305 /// The widget's window if it is realized, [`None`] otherwise.
306 ///
307 /// Readable
308 ///
309 /// ## Signals
310 ///
311 ///
312 /// #### `accel-closures-changed`
313 ///
314 ///
315 ///
316 /// #### `button-press-event`
317 /// The ::button-press-event signal will be emitted when a button
318 /// (typically from a mouse) is pressed.
319 ///
320 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
321 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
322 ///
323 /// This signal will be sent to the grab widget if there is one.
324 ///
325 ///
326 ///
327 ///
328 /// #### `button-release-event`
329 /// The ::button-release-event signal will be emitted when a button
330 /// (typically from a mouse) is released.
331 ///
332 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
333 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
334 ///
335 /// This signal will be sent to the grab widget if there is one.
336 ///
337 ///
338 ///
339 ///
340 /// #### `can-activate-accel`
341 /// Determines whether an accelerator that activates the signal
342 /// identified by `signal_id` can currently be activated.
343 /// This signal is present to allow applications and derived
344 /// widgets to override the default [`Widget`][crate::Widget] handling
345 /// for determining whether an accelerator can be activated.
346 ///
347 ///
348 ///
349 ///
350 /// #### `child-notify`
351 /// The ::child-notify signal is emitted for each
352 /// [child property][child-properties] that has
353 /// changed on an object. The signal's detail holds the property name.
354 ///
355 /// Detailed
356 ///
357 ///
358 /// #### `composited-changed`
359 /// The ::composited-changed signal is emitted when the composited
360 /// status of `widgets` screen changes.
361 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
362 ///
363 /// Action
364 ///
365 ///
366 /// #### `configure-event`
367 /// The ::configure-event signal will be emitted when the size, position or
368 /// stacking of the `widget`'s window has changed.
369 ///
370 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
371 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
372 /// automatically for all new windows.
373 ///
374 ///
375 ///
376 ///
377 /// #### `damage-event`
378 /// Emitted when a redirected window belonging to `widget` gets drawn into.
379 /// The region/area members of the event shows what area of the redirected
380 /// drawable was drawn into.
381 ///
382 ///
383 ///
384 ///
385 /// #### `delete-event`
386 /// The ::delete-event signal is emitted if a user requests that
387 /// a toplevel window is closed. The default handler for this signal
388 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
389 /// this signal will cause the window to be hidden instead, so that
390 /// it can later be shown again without reconstructing it.
391 ///
392 ///
393 ///
394 ///
395 /// #### `destroy`
396 /// Signals that all holders of a reference to the widget should release
397 /// the reference that they hold. May result in finalization of the widget
398 /// if all references are released.
399 ///
400 /// This signal is not suitable for saving widget state.
401 ///
402 ///
403 ///
404 ///
405 /// #### `destroy-event`
406 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
407 /// You rarely get this signal, because most widgets disconnect themselves
408 /// from their window before they destroy it, so no widget owns the
409 /// window at destroy time.
410 ///
411 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
412 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
413 /// automatically for all new windows.
414 ///
415 ///
416 ///
417 ///
418 /// #### `direction-changed`
419 /// The ::direction-changed signal is emitted when the text direction
420 /// of a widget changes.
421 ///
422 ///
423 ///
424 ///
425 /// #### `drag-begin`
426 /// The ::drag-begin signal is emitted on the drag source when a drag is
427 /// started. A typical reason to connect to this signal is to set up a
428 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
429 ///
430 /// Note that some widgets set up a drag icon in the default handler of
431 /// this signal, so you may have to use `g_signal_connect_after()` to
432 /// override what the default handler did.
433 ///
434 ///
435 ///
436 ///
437 /// #### `drag-data-delete`
438 /// The ::drag-data-delete signal is emitted on the drag source when a drag
439 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
440 /// handler is responsible for deleting the data that has been dropped. What
441 /// "delete" means depends on the context of the drag operation.
442 ///
443 ///
444 ///
445 ///
446 /// #### `drag-data-get`
447 /// The ::drag-data-get signal is emitted on the drag source when the drop
448 /// site requests the data which is dragged. It is the responsibility of
449 /// the signal handler to fill `data` with the data in the format which
450 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
451 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
452 ///
453 ///
454 ///
455 ///
456 /// #### `drag-data-received`
457 /// format == 8))
458 /// {
459 /// GdkDragAction action;
460 ///
461 /// // handle data here
462 ///
463 /// action = gdk_drag_context_get_selected_action (context);
464 /// if (action == GDK_ACTION_ASK)
465 /// {
466 /// GtkWidget *dialog;
467 /// gint response;
468 ///
469 /// dialog = gtk_message_dialog_new (NULL,
470 /// GTK_DIALOG_MODAL |
471 /// GTK_DIALOG_DESTROY_WITH_PARENT,
472 /// GTK_MESSAGE_INFO,
473 /// GTK_BUTTONS_YES_NO,
474 /// "Move the data ?\n");
475 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
476 /// gtk_widget_destroy (dialog);
477 ///
478 /// if (response == GTK_RESPONSE_YES)
479 /// action = GDK_ACTION_MOVE;
480 /// else
481 /// action = GDK_ACTION_COPY;
482 /// }
483 ///
484 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
485 /// }
486 /// else
487 /// gtk_drag_finish (context, FALSE, FALSE, time);
488 /// }
489 /// ]|
490 ///
491 ///
492 ///
493 ///
494 /// #### `drag-drop`
495 /// The ::drag-drop signal is emitted on the drop site when the user drops
496 /// the data onto the widget. The signal handler must determine whether
497 /// the cursor position is in a drop zone or not. If it is not in a drop
498 /// zone, it returns [`false`] and no further processing is necessary.
499 /// Otherwise, the handler returns [`true`]. In this case, the handler must
500 /// ensure that `gtk_drag_finish()` is called to let the source know that
501 /// the drop is done. The call to `gtk_drag_finish()` can be done either
502 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
503 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
504 /// or more of the supported targets.
505 ///
506 ///
507 ///
508 ///
509 /// #### `drag-end`
510 /// The ::drag-end signal is emitted on the drag source when a drag is
511 /// finished. A typical reason to connect to this signal is to undo
512 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
513 ///
514 ///
515 ///
516 ///
517 /// #### `drag-failed`
518 /// The ::drag-failed signal is emitted on the drag source when a drag has
519 /// failed. The signal handler may hook custom code to handle a failed DnD
520 /// operation based on the type of error, it returns [`true`] is the failure has
521 /// been already handled (not showing the default "drag operation failed"
522 /// animation), otherwise it returns [`false`].
523 ///
524 ///
525 ///
526 ///
527 /// #### `drag-leave`
528 /// The ::drag-leave signal is emitted on the drop site when the cursor
529 /// leaves the widget. A typical reason to connect to this signal is to
530 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
531 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
532 ///
533 ///
534 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
535 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
536 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
537 ///
538 ///
539 ///
540 ///
541 /// #### `drag-motion`
542 /// suggested_action,
543 /// time);
544 /// }
545 /// else
546 /// {
547 /// // accept the drop
548 /// }
549 /// }
550 /// ]|
551 ///
552 ///
553 ///
554 ///
555 /// #### `draw`
556 /// This signal is emitted when a widget is supposed to render itself.
557 /// The `widget`'s top left corner must be painted at the origin of
558 /// the passed in context and be sized to the values returned by
559 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
560 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
561 ///
562 /// Signal handlers connected to this signal can modify the cairo
563 /// context passed as `cr` in any way they like and don't need to
564 /// restore it. The signal emission takes care of calling `cairo_save()`
565 /// before and `cairo_restore()` after invoking the handler.
566 ///
567 /// The signal handler will get a `cr` with a clip region already set to the
568 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
569 /// widgets that want to avoid redrawing themselves completely can get the full
570 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
571 /// get a finer-grained representation of the dirty region with
572 /// `cairo_copy_clip_rectangle_list()`.
573 ///
574 ///
575 ///
576 ///
577 /// #### `enter-notify-event`
578 /// The ::enter-notify-event will be emitted when the pointer enters
579 /// the `widget`'s window.
580 ///
581 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
582 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
583 ///
584 /// This signal will be sent to the grab widget if there is one.
585 ///
586 ///
587 ///
588 ///
589 /// #### `event`
590 /// The GTK+ main loop will emit three signals for each GDK event delivered
591 /// to a widget: one generic ::event signal, another, more specific,
592 /// signal that matches the type of event delivered (e.g.
593 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
594 /// [`event-after`][struct@crate::Widget#event-after] signal.
595 ///
596 ///
597 ///
598 ///
599 /// #### `event-after`
600 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
601 /// the second more specific signal, ::event-after will be emitted
602 /// regardless of the previous two signals handlers return values.
603 ///
604 ///
605 ///
606 ///
607 /// #### `focus`
608 ///
609 ///
610 ///
611 /// #### `focus-in-event`
612 /// The ::focus-in-event signal will be emitted when the keyboard focus
613 /// enters the `widget`'s window.
614 ///
615 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
616 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
617 ///
618 ///
619 ///
620 ///
621 /// #### `focus-out-event`
622 /// The ::focus-out-event signal will be emitted when the keyboard focus
623 /// leaves the `widget`'s window.
624 ///
625 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
626 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
627 ///
628 ///
629 ///
630 ///
631 /// #### `grab-broken-event`
632 /// Emitted when a pointer or keyboard grab on a window belonging
633 /// to `widget` gets broken.
634 ///
635 /// On X11, this happens when the grab window becomes unviewable
636 /// (i.e. it or one of its ancestors is unmapped), or if the same
637 /// application grabs the pointer or keyboard again.
638 ///
639 ///
640 ///
641 ///
642 /// #### `grab-focus`
643 /// Action
644 ///
645 ///
646 /// #### `grab-notify`
647 /// The ::grab-notify signal is emitted when a widget becomes
648 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
649 /// another widget, or when it becomes unshadowed due to a grab
650 /// being removed.
651 ///
652 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
653 /// grab widget in the grab stack of its window group is not
654 /// its ancestor.
655 ///
656 ///
657 ///
658 ///
659 /// #### `hide`
660 /// The ::hide signal is emitted when `widget` is hidden, for example with
661 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
662 ///
663 ///
664 ///
665 ///
666 /// #### `hierarchy-changed`
667 /// The ::hierarchy-changed signal is emitted when the
668 /// anchored state of a widget changes. A widget is
669 /// “anchored” when its toplevel
670 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
671 /// a widget changes from un-anchored to anchored or vice-versa.
672 ///
673 ///
674 ///
675 ///
676 /// #### `key-press-event`
677 /// The ::key-press-event signal is emitted when a key is pressed. The signal
678 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
679 ///
680 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
681 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
682 ///
683 /// This signal will be sent to the grab widget if there is one.
684 ///
685 ///
686 ///
687 ///
688 /// #### `key-release-event`
689 /// The ::key-release-event signal is emitted when a key is released.
690 ///
691 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
692 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
693 ///
694 /// This signal will be sent to the grab widget if there is one.
695 ///
696 ///
697 ///
698 ///
699 /// #### `keynav-failed`
700 /// Gets emitted if keyboard navigation fails.
701 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
702 ///
703 ///
704 ///
705 ///
706 /// #### `leave-notify-event`
707 /// The ::leave-notify-event will be emitted when the pointer leaves
708 /// the `widget`'s window.
709 ///
710 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
711 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
712 ///
713 /// This signal will be sent to the grab widget if there is one.
714 ///
715 ///
716 ///
717 ///
718 /// #### `map`
719 /// The ::map signal is emitted when `widget` is going to be mapped, that is
720 /// when the widget is visible (which is controlled with
721 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
722 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
723 /// be emitted.
724 ///
725 /// The ::map signal can be used to determine whether a widget will be drawn,
726 /// for instance it can resume an animation that was stopped during the
727 /// emission of [`unmap`][struct@crate::Widget#unmap].
728 ///
729 ///
730 ///
731 ///
732 /// #### `map-event`
733 /// The ::map-event signal will be emitted when the `widget`'s window is
734 /// mapped. A window is mapped when it becomes visible on the screen.
735 ///
736 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
737 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
738 /// automatically for all new windows.
739 ///
740 ///
741 ///
742 ///
743 /// #### `mnemonic-activate`
744 /// The default handler for this signal activates `widget` if `group_cycling`
745 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
746 ///
747 ///
748 ///
749 ///
750 /// #### `motion-notify-event`
751 /// The ::motion-notify-event signal is emitted when the pointer moves
752 /// over the widget's [`gdk::Window`][crate::gdk::Window].
753 ///
754 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
755 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
756 ///
757 /// This signal will be sent to the grab widget if there is one.
758 ///
759 ///
760 ///
761 ///
762 /// #### `move-focus`
763 /// Action
764 ///
765 ///
766 /// #### `parent-set`
767 /// The ::parent-set signal is emitted when a new parent
768 /// has been set on a widget.
769 ///
770 ///
771 ///
772 ///
773 /// #### `popup-menu`
774 /// This signal gets emitted whenever a widget should pop up a context
775 /// menu. This usually happens through the standard key binding mechanism;
776 /// by pressing a certain key while a widget is focused, the user can cause
777 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
778 /// a menu with clipboard commands. See the
779 /// [Popup Menu Migration Checklist][checklist-popup-menu]
780 /// for an example of how to use this signal.
781 ///
782 /// Action
783 ///
784 ///
785 /// #### `property-notify-event`
786 /// The ::property-notify-event signal will be emitted when a property on
787 /// the `widget`'s window has been changed or deleted.
788 ///
789 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
790 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
791 ///
792 ///
793 ///
794 ///
795 /// #### `proximity-in-event`
796 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
797 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
798 ///
799 /// This signal will be sent to the grab widget if there is one.
800 ///
801 ///
802 ///
803 ///
804 /// #### `proximity-out-event`
805 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
806 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
807 ///
808 /// This signal will be sent to the grab widget if there is one.
809 ///
810 ///
811 ///
812 ///
813 /// #### `query-tooltip`
814 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
815 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
816 /// focus in keyboard mode.
817 ///
818 /// Using the given coordinates, the signal handler should determine
819 /// whether a tooltip should be shown for `widget`. If this is the case
820 /// [`true`] should be returned, [`false`] otherwise. Note that if
821 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
822 /// should not be used.
823 ///
824 /// The signal handler is free to manipulate `tooltip` with the therefore
825 /// destined function calls.
826 ///
827 ///
828 ///
829 ///
830 /// #### `realize`
831 /// The ::realize signal is emitted when `widget` is associated with a
832 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
833 /// widget has been mapped (that is, it is going to be drawn).
834 ///
835 ///
836 ///
837 ///
838 /// #### `screen-changed`
839 /// The ::screen-changed signal gets emitted when the
840 /// screen of a widget has changed.
841 ///
842 ///
843 ///
844 ///
845 /// #### `scroll-event`
846 /// The ::scroll-event signal is emitted when a button in the 4 to 7
847 /// range is pressed. Wheel mice are usually configured to generate
848 /// button press events for buttons 4 and 5 when the wheel is turned.
849 ///
850 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
851 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
852 ///
853 /// This signal will be sent to the grab widget if there is one.
854 ///
855 ///
856 ///
857 ///
858 /// #### `selection-clear-event`
859 /// The ::selection-clear-event signal will be emitted when the
860 /// the `widget`'s window has lost ownership of a selection.
861 ///
862 ///
863 ///
864 ///
865 /// #### `selection-get`
866 ///
867 ///
868 ///
869 /// #### `selection-notify-event`
870 ///
871 ///
872 ///
873 /// #### `selection-received`
874 ///
875 ///
876 ///
877 /// #### `selection-request-event`
878 /// The ::selection-request-event signal will be emitted when
879 /// another client requests ownership of the selection owned by
880 /// the `widget`'s window.
881 ///
882 ///
883 ///
884 ///
885 /// #### `show`
886 /// The ::show signal is emitted when `widget` is shown, for example with
887 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
888 ///
889 ///
890 ///
891 ///
892 /// #### `show-help`
893 /// Action
894 ///
895 ///
896 /// #### `size-allocate`
897 ///
898 ///
899 ///
900 /// #### `state-changed`
901 /// The ::state-changed signal is emitted when the widget state changes.
902 /// See `gtk_widget_get_state()`.
903 ///
904 ///
905 ///
906 ///
907 /// #### `state-flags-changed`
908 /// The ::state-flags-changed signal is emitted when the widget state
909 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
910 ///
911 ///
912 ///
913 ///
914 /// #### `style-set`
915 /// The ::style-set signal is emitted when a new style has been set
916 /// on a widget. Note that style-modifying functions like
917 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
918 ///
919 /// Note that this signal is emitted for changes to the deprecated
920 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
921 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
922 ///
923 ///
924 ///
925 ///
926 /// #### `style-updated`
927 /// The ::style-updated signal is a convenience signal that is emitted when the
928 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
929 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
930 ///
931 /// Note that style-modifying functions like `gtk_widget_override_color()` also
932 /// cause this signal to be emitted.
933 ///
934 ///
935 ///
936 ///
937 /// #### `touch-event`
938 ///
939 ///
940 ///
941 /// #### `unmap`
942 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
943 /// means that either it or any of its parents up to the toplevel widget have
944 /// been set as hidden.
945 ///
946 /// As ::unmap indicates that a widget will not be shown any longer, it can be
947 /// used to, for example, stop an animation on the widget.
948 ///
949 ///
950 ///
951 ///
952 /// #### `unmap-event`
953 /// The ::unmap-event signal will be emitted when the `widget`'s window is
954 /// unmapped. A window is unmapped when it becomes invisible on the screen.
955 ///
956 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
957 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
958 /// automatically for all new windows.
959 ///
960 ///
961 ///
962 ///
963 /// #### `unrealize`
964 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
965 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
966 /// called or the widget has been unmapped (that is, it is going to be
967 /// hidden).
968 ///
969 ///
970 ///
971 ///
972 /// #### `visibility-notify-event`
973 /// The ::visibility-notify-event will be emitted when the `widget`'s
974 /// window is obscured or unobscured.
975 ///
976 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
977 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
978 ///
979 ///
980 ///
981 ///
982 /// #### `window-state-event`
983 /// The ::window-state-event will be emitted when the state of the
984 /// toplevel window associated to the `widget` changes.
985 ///
986 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
987 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
988 /// this mask automatically for all new windows.
989 ///
990 ///
991 ///
992 /// # Implements
993 ///
994 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
995 #[doc(alias = "GtkWidget")]
996 pub struct Widget(Object<ffi::GtkWidget, ffi::GtkWidgetClass>) @implements Buildable;
997
998 match fn {
999 type_ => || ffi::gtk_widget_get_type(),
1000 }
1001}
1002
1003impl Widget {
1004 pub const NONE: Option<&'static Widget> = None;
1005
1006 //#[doc(alias = "gtk_widget_new")]
1007 //pub fn new(type_: glib::types::Type, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Widget {
1008 // unsafe { TODO: call ffi:gtk_widget_new() }
1009 //}
1010
1011 /// Obtains the current default reading direction. See
1012 /// [`set_default_direction()`][Self::set_default_direction()].
1013 ///
1014 /// # Returns
1015 ///
1016 /// the current default direction.
1017 #[doc(alias = "gtk_widget_get_default_direction")]
1018 #[doc(alias = "get_default_direction")]
1019 pub fn default_direction() -> TextDirection {
1020 assert_initialized_main_thread!();
1021 unsafe { from_glib(ffi::gtk_widget_get_default_direction()) }
1022 }
1023
1024 /// Sets the default reading direction for widgets where the
1025 /// direction has not been explicitly set by [`WidgetExt::set_direction()`][crate::prelude::WidgetExt::set_direction()].
1026 /// ## `dir`
1027 /// the new default direction. This cannot be
1028 /// [`TextDirection::None`][crate::TextDirection::None].
1029 #[doc(alias = "gtk_widget_set_default_direction")]
1030 pub fn set_default_direction(dir: TextDirection) {
1031 assert_initialized_main_thread!();
1032 unsafe {
1033 ffi::gtk_widget_set_default_direction(dir.into_glib());
1034 }
1035 }
1036}
1037
1038impl std::fmt::Display for Widget {
1039 #[inline]
1040 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1041 f.write_str(&WidgetExt::widget_name(self))
1042 }
1043}
1044
1045/// Trait containing all [`struct@Widget`] methods.
1046///
1047/// # Implementors
1048///
1049/// [`Actionable`][struct@crate::Actionable], [`AppChooser`][struct@crate::AppChooser], [`Calendar`][struct@crate::Calendar], [`CellEditable`][struct@crate::CellEditable], [`CellView`][struct@crate::CellView], [`Container`][struct@crate::Container], [`DrawingArea`][struct@crate::DrawingArea], [`Entry`][struct@crate::Entry], [`GLArea`][struct@crate::GLArea], [`Invisible`][struct@crate::Invisible], [`LevelBar`][struct@crate::LevelBar], [`Misc`][struct@crate::Misc], [`ProgressBar`][struct@crate::ProgressBar], [`Range`][struct@crate::Range], [`Separator`][struct@crate::Separator], [`Spinner`][struct@crate::Spinner], [`Switch`][struct@crate::Switch], [`ToolShell`][struct@crate::ToolShell], [`Widget`][struct@crate::Widget]
1050pub trait WidgetExt: IsA<Widget> + 'static {
1051 /// For widgets that can be “activated” (buttons, menu items, etc.)
1052 /// this function activates them. Activation is what happens when you
1053 /// press Enter on a widget during key navigation. If `self` isn't
1054 /// activatable, the function returns [`false`].
1055 ///
1056 /// # Returns
1057 ///
1058 /// [`true`] if the widget was activatable
1059 #[doc(alias = "gtk_widget_activate")]
1060 fn activate(&self) -> bool {
1061 unsafe { from_glib(ffi::gtk_widget_activate(self.as_ref().to_glib_none().0)) }
1062 }
1063
1064 /// Installs an accelerator for this `self` in `accel_group` that causes
1065 /// `accel_signal` to be emitted if the accelerator is activated.
1066 /// The `accel_group` needs to be added to the widget’s toplevel via
1067 /// [`GtkWindowExt::add_accel_group()`][crate::prelude::GtkWindowExt::add_accel_group()], and the signal must be of type `G_SIGNAL_ACTION`.
1068 /// Accelerators added through this function are not user changeable during
1069 /// runtime. If you want to support accelerators that can be changed by the
1070 /// user, use `gtk_accel_map_add_entry()` and [`set_accel_path()`][Self::set_accel_path()] or
1071 /// [`GtkMenuItemExt::set_accel_path()`][crate::prelude::GtkMenuItemExt::set_accel_path()] instead.
1072 /// ## `accel_signal`
1073 /// widget signal to emit on accelerator activation
1074 /// ## `accel_group`
1075 /// accel group for this widget, added to its toplevel
1076 /// ## `accel_key`
1077 /// GDK keyval of the accelerator
1078 /// ## `accel_mods`
1079 /// modifier key combination of the accelerator
1080 /// ## `accel_flags`
1081 /// flag accelerators, e.g. [`AccelFlags::VISIBLE`][crate::AccelFlags::VISIBLE]
1082 #[doc(alias = "gtk_widget_add_accelerator")]
1083 fn add_accelerator(
1084 &self,
1085 accel_signal: &str,
1086 accel_group: &impl IsA<AccelGroup>,
1087 accel_key: u32,
1088 accel_mods: gdk::ModifierType,
1089 accel_flags: AccelFlags,
1090 ) {
1091 unsafe {
1092 ffi::gtk_widget_add_accelerator(
1093 self.as_ref().to_glib_none().0,
1094 accel_signal.to_glib_none().0,
1095 accel_group.as_ref().to_glib_none().0,
1096 accel_key,
1097 accel_mods.into_glib(),
1098 accel_flags.into_glib(),
1099 );
1100 }
1101 }
1102
1103 /// Adds the device events in the bitfield `events` to the event mask for
1104 /// `self`. See [`set_device_events()`][Self::set_device_events()] for details.
1105 /// ## `device`
1106 /// a [`gdk::Device`][crate::gdk::Device]
1107 /// ## `events`
1108 /// an event mask, see [`gdk::EventMask`][crate::gdk::EventMask]
1109 #[doc(alias = "gtk_widget_add_device_events")]
1110 fn add_device_events(&self, device: &gdk::Device, events: gdk::EventMask) {
1111 unsafe {
1112 ffi::gtk_widget_add_device_events(
1113 self.as_ref().to_glib_none().0,
1114 device.to_glib_none().0,
1115 events.into_glib(),
1116 );
1117 }
1118 }
1119
1120 /// Adds a widget to the list of mnemonic labels for
1121 /// this widget. (See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()]). Note the
1122 /// list of mnemonic labels for the widget is cleared when the
1123 /// widget is destroyed, so the caller must make sure to update
1124 /// its internal state at this point as well, by using a connection
1125 /// to the [`destroy`][struct@crate::Widget#destroy] signal or a weak notifier.
1126 /// ## `label`
1127 /// a [`Widget`][crate::Widget] that acts as a mnemonic label for `self`
1128 #[doc(alias = "gtk_widget_add_mnemonic_label")]
1129 fn add_mnemonic_label(&self, label: &impl IsA<Widget>) {
1130 unsafe {
1131 ffi::gtk_widget_add_mnemonic_label(
1132 self.as_ref().to_glib_none().0,
1133 label.as_ref().to_glib_none().0,
1134 );
1135 }
1136 }
1137
1138 /// Determines whether an accelerator that activates the signal
1139 /// identified by `signal_id` can currently be activated.
1140 /// This is done by emitting the [`can-activate-accel`][struct@crate::Widget#can-activate-accel]
1141 /// signal on `self`; if the signal isn’t overridden by a
1142 /// handler or in a derived widget, then the default check is
1143 /// that the widget must be sensitive, and the widget and all
1144 /// its ancestors mapped.
1145 /// ## `signal_id`
1146 /// the ID of a signal installed on `self`
1147 ///
1148 /// # Returns
1149 ///
1150 /// [`true`] if the accelerator can be activated.
1151 #[doc(alias = "gtk_widget_can_activate_accel")]
1152 fn can_activate_accel(&self, signal_id: u32) -> bool {
1153 unsafe {
1154 from_glib(ffi::gtk_widget_can_activate_accel(
1155 self.as_ref().to_glib_none().0,
1156 signal_id,
1157 ))
1158 }
1159 }
1160
1161 /// This function is used by custom widget implementations; if you're
1162 /// writing an app, you’d use [`grab_focus()`][Self::grab_focus()] to move the focus
1163 /// to a particular widget, and [`ContainerExt::set_focus_chain()`][crate::prelude::ContainerExt::set_focus_chain()] to
1164 /// change the focus tab order. So you may want to investigate those
1165 /// functions instead.
1166 ///
1167 /// [`child_focus()`][Self::child_focus()] is called by containers as the user moves
1168 /// around the window using keyboard shortcuts. `direction` indicates
1169 /// what kind of motion is taking place (up, down, left, right, tab
1170 /// forward, tab backward). [`child_focus()`][Self::child_focus()] emits the
1171 /// [`focus`][struct@crate::Widget#focus] signal; widgets override the default handler
1172 /// for this signal in order to implement appropriate focus behavior.
1173 ///
1174 /// The default ::focus handler for a widget should return [`true`] if
1175 /// moving in `direction` left the focus on a focusable location inside
1176 /// that widget, and [`false`] if moving in `direction` moved the focus
1177 /// outside the widget. If returning [`true`], widgets normally
1178 /// call [`grab_focus()`][Self::grab_focus()] to place the focus accordingly;
1179 /// if returning [`false`], they don’t modify the current focus location.
1180 /// ## `direction`
1181 /// direction of focus movement
1182 ///
1183 /// # Returns
1184 ///
1185 /// [`true`] if focus ended up inside `self`
1186 #[doc(alias = "gtk_widget_child_focus")]
1187 fn child_focus(&self, direction: DirectionType) -> bool {
1188 unsafe {
1189 from_glib(ffi::gtk_widget_child_focus(
1190 self.as_ref().to_glib_none().0,
1191 direction.into_glib(),
1192 ))
1193 }
1194 }
1195
1196 /// Emits a [`child-notify`][struct@crate::Widget#child-notify] signal for the
1197 /// [child property][child-properties] `child_property`
1198 /// on `self`.
1199 ///
1200 /// This is the analogue of [`ObjectExt::notify()`][crate::glib::prelude::ObjectExt::notify()] for child properties.
1201 ///
1202 /// Also see [`ContainerExt::child_notify()`][crate::prelude::ContainerExt::child_notify()].
1203 /// ## `child_property`
1204 /// the name of a child property installed on the
1205 /// class of `self`’s parent
1206 #[doc(alias = "gtk_widget_child_notify")]
1207 fn child_notify(&self, child_property: &str) {
1208 unsafe {
1209 ffi::gtk_widget_child_notify(
1210 self.as_ref().to_glib_none().0,
1211 child_property.to_glib_none().0,
1212 );
1213 }
1214 }
1215
1216 /// Computes whether a container should give this widget extra space
1217 /// when possible. Containers should check this, rather than
1218 /// looking at [`hexpands()`][Self::hexpands()] or [`vexpands()`][Self::vexpands()].
1219 ///
1220 /// This function already checks whether the widget is visible, so
1221 /// visibility does not need to be checked separately. Non-visible
1222 /// widgets are not expanded.
1223 ///
1224 /// The computed expand value uses either the expand setting explicitly
1225 /// set on the widget itself, or, if none has been explicitly set,
1226 /// the widget may expand if some of its children do.
1227 /// ## `orientation`
1228 /// expand direction
1229 ///
1230 /// # Returns
1231 ///
1232 /// whether widget tree rooted here should be expanded
1233 #[doc(alias = "gtk_widget_compute_expand")]
1234 fn compute_expand(&self, orientation: Orientation) -> bool {
1235 unsafe {
1236 from_glib(ffi::gtk_widget_compute_expand(
1237 self.as_ref().to_glib_none().0,
1238 orientation.into_glib(),
1239 ))
1240 }
1241 }
1242
1243 /// Creates a new [`pango::Context`][crate::pango::Context] with the appropriate font map,
1244 /// font options, font description, and base direction for drawing
1245 /// text for this widget. See also [`pango_context()`][Self::pango_context()].
1246 ///
1247 /// # Returns
1248 ///
1249 /// the new [`pango::Context`][crate::pango::Context]
1250 #[doc(alias = "gtk_widget_create_pango_context")]
1251 fn create_pango_context(&self) -> pango::Context {
1252 unsafe {
1253 from_glib_full(ffi::gtk_widget_create_pango_context(
1254 self.as_ref().to_glib_none().0,
1255 ))
1256 }
1257 }
1258
1259 /// Creates a new [`pango::Layout`][crate::pango::Layout] with the appropriate font map,
1260 /// font description, and base direction for drawing text for
1261 /// this widget.
1262 ///
1263 /// If you keep a [`pango::Layout`][crate::pango::Layout] created in this way around, you need
1264 /// to re-create it when the widget [`pango::Context`][crate::pango::Context] is replaced.
1265 /// This can be tracked by using the [`screen-changed`][struct@crate::Widget#screen-changed] signal
1266 /// on the widget.
1267 /// ## `text`
1268 /// text to set on the layout (can be [`None`])
1269 ///
1270 /// # Returns
1271 ///
1272 /// the new [`pango::Layout`][crate::pango::Layout]
1273 #[doc(alias = "gtk_widget_create_pango_layout")]
1274 fn create_pango_layout(&self, text: Option<&str>) -> pango::Layout {
1275 unsafe {
1276 from_glib_full(ffi::gtk_widget_create_pango_layout(
1277 self.as_ref().to_glib_none().0,
1278 text.to_glib_none().0,
1279 ))
1280 }
1281 }
1282
1283 //#[doc(alias = "gtk_widget_destroyed")]
1284 //fn destroyed(&self, widget_pointer: /*Unimplemented*/Widget) {
1285 // unsafe { TODO: call ffi:gtk_widget_destroyed() }
1286 //}
1287
1288 /// Returns [`true`] if `device` has been shadowed by a GTK+
1289 /// device grab on another widget, so it would stop sending
1290 /// events to `self`. This may be used in the
1291 /// [`grab-notify`][struct@crate::Widget#grab-notify] signal to check for specific
1292 /// devices. See [`device_grab_add()`][crate::device_grab_add()].
1293 /// ## `device`
1294 /// a [`gdk::Device`][crate::gdk::Device]
1295 ///
1296 /// # Returns
1297 ///
1298 /// [`true`] if there is an ongoing grab on `device`
1299 /// by another [`Widget`][crate::Widget] than `self`.
1300 #[doc(alias = "gtk_widget_device_is_shadowed")]
1301 fn device_is_shadowed(&self, device: &gdk::Device) -> bool {
1302 unsafe {
1303 from_glib(ffi::gtk_widget_device_is_shadowed(
1304 self.as_ref().to_glib_none().0,
1305 device.to_glib_none().0,
1306 ))
1307 }
1308 }
1309
1310 /// Initiates a drag on the source side. The function only needs to be used
1311 /// when the application is starting drags itself, and is not needed when
1312 /// [`WidgetExtManual::drag_source_set()`][crate::prelude::WidgetExtManual::drag_source_set()] is used.
1313 ///
1314 /// The `event` is used to retrieve the timestamp that will be used internally to
1315 /// grab the pointer. If `event` is [`None`], then `GDK_CURRENT_TIME` will be used.
1316 /// However, you should try to pass a real event in all cases, since that can be
1317 /// used to get information about the drag.
1318 ///
1319 /// Generally there are three cases when you want to start a drag by hand by
1320 /// calling this function:
1321 ///
1322 /// 1. During a [`button-press-event`][struct@crate::Widget#button-press-event] handler, if you want to start a drag
1323 /// immediately when the user presses the mouse button. Pass the `event`
1324 /// that you have in your [`button-press-event`][struct@crate::Widget#button-press-event] handler.
1325 ///
1326 /// 2. During a [`motion-notify-event`][struct@crate::Widget#motion-notify-event] handler, if you want to start a drag
1327 /// when the mouse moves past a certain threshold distance after a button-press.
1328 /// Pass the `event` that you have in your [`motion-notify-event`][struct@crate::Widget#motion-notify-event] handler.
1329 ///
1330 /// 3. During a timeout handler, if you want to start a drag after the mouse
1331 /// button is held down for some time. Try to save the last event that you got
1332 /// from the mouse, using `gdk_event_copy()`, and pass it to this function
1333 /// (remember to free the event with `gdk_event_free()` when you are done).
1334 /// If you really cannot pass a real event, pass [`None`] instead.
1335 /// ## `targets`
1336 /// The targets (data formats) in which the
1337 /// source can provide the data
1338 /// ## `actions`
1339 /// A bitmask of the allowed drag actions for this drag
1340 /// ## `button`
1341 /// The button the user clicked to start the drag
1342 /// ## `event`
1343 /// The event that triggered the start of the drag,
1344 /// or [`None`] if none can be obtained.
1345 /// ## `x`
1346 /// The initial x coordinate to start dragging from, in the coordinate space
1347 /// of `self`. If -1 is passed, the coordinates are retrieved from `event` or
1348 /// the current pointer position
1349 /// ## `y`
1350 /// The initial y coordinate to start dragging from, in the coordinate space
1351 /// of `self`. If -1 is passed, the coordinates are retrieved from `event` or
1352 /// the current pointer position
1353 ///
1354 /// # Returns
1355 ///
1356 /// the context for this drag
1357 #[doc(alias = "gtk_drag_begin_with_coordinates")]
1358 fn drag_begin_with_coordinates(
1359 &self,
1360 targets: &TargetList,
1361 actions: gdk::DragAction,
1362 button: i32,
1363 event: Option<&gdk::Event>,
1364 x: i32,
1365 y: i32,
1366 ) -> Option<gdk::DragContext> {
1367 unsafe {
1368 from_glib_none(ffi::gtk_drag_begin_with_coordinates(
1369 self.as_ref().to_glib_none().0,
1370 targets.to_glib_none().0,
1371 actions.into_glib(),
1372 button,
1373 mut_override(event.to_glib_none().0),
1374 x,
1375 y,
1376 ))
1377 }
1378 }
1379
1380 /// Checks to see if a mouse drag starting at (`start_x`, `start_y`) and ending
1381 /// at (`current_x`, `current_y`) has passed the GTK+ drag threshold, and thus
1382 /// should trigger the beginning of a drag-and-drop operation.
1383 /// ## `start_x`
1384 /// X coordinate of start of drag
1385 /// ## `start_y`
1386 /// Y coordinate of start of drag
1387 /// ## `current_x`
1388 /// current X coordinate
1389 /// ## `current_y`
1390 /// current Y coordinate
1391 ///
1392 /// # Returns
1393 ///
1394 /// [`true`] if the drag threshold has been passed.
1395 #[doc(alias = "gtk_drag_check_threshold")]
1396 fn drag_check_threshold(
1397 &self,
1398 start_x: i32,
1399 start_y: i32,
1400 current_x: i32,
1401 current_y: i32,
1402 ) -> bool {
1403 unsafe {
1404 from_glib(ffi::gtk_drag_check_threshold(
1405 self.as_ref().to_glib_none().0,
1406 start_x,
1407 start_y,
1408 current_x,
1409 current_y,
1410 ))
1411 }
1412 }
1413
1414 /// Add the image targets supported by [`SelectionData`][crate::SelectionData] to
1415 /// the target list of the drag destination. The targets
1416 /// are added with `info` = 0. If you need another value,
1417 /// use [`TargetList::add_image_targets()`][crate::TargetList::add_image_targets()] and
1418 /// [`drag_dest_set_target_list()`][Self::drag_dest_set_target_list()].
1419 #[doc(alias = "gtk_drag_dest_add_image_targets")]
1420 fn drag_dest_add_image_targets(&self) {
1421 unsafe {
1422 ffi::gtk_drag_dest_add_image_targets(self.as_ref().to_glib_none().0);
1423 }
1424 }
1425
1426 /// Add the text targets supported by [`SelectionData`][crate::SelectionData] to
1427 /// the target list of the drag destination. The targets
1428 /// are added with `info` = 0. If you need another value,
1429 /// use [`TargetList::add_text_targets()`][crate::TargetList::add_text_targets()] and
1430 /// [`drag_dest_set_target_list()`][Self::drag_dest_set_target_list()].
1431 #[doc(alias = "gtk_drag_dest_add_text_targets")]
1432 fn drag_dest_add_text_targets(&self) {
1433 unsafe {
1434 ffi::gtk_drag_dest_add_text_targets(self.as_ref().to_glib_none().0);
1435 }
1436 }
1437
1438 /// Add the URI targets supported by [`SelectionData`][crate::SelectionData] to
1439 /// the target list of the drag destination. The targets
1440 /// are added with `info` = 0. If you need another value,
1441 /// use [`TargetList::add_uri_targets()`][crate::TargetList::add_uri_targets()] and
1442 /// [`drag_dest_set_target_list()`][Self::drag_dest_set_target_list()].
1443 #[doc(alias = "gtk_drag_dest_add_uri_targets")]
1444 fn drag_dest_add_uri_targets(&self) {
1445 unsafe {
1446 ffi::gtk_drag_dest_add_uri_targets(self.as_ref().to_glib_none().0);
1447 }
1448 }
1449
1450 /// Looks for a match between the supported targets of `context` and the
1451 /// `dest_target_list`, returning the first matching target, otherwise
1452 /// returning `GDK_NONE`. `dest_target_list` should usually be the return
1453 /// value from [`drag_dest_get_target_list()`][Self::drag_dest_get_target_list()], but some widgets may
1454 /// have different valid targets for different parts of the widget; in
1455 /// that case, they will have to implement a drag_motion handler that
1456 /// passes the correct target list to this function.
1457 /// ## `context`
1458 /// drag context
1459 /// ## `target_list`
1460 /// list of droppable targets, or [`None`] to use
1461 /// gtk_drag_dest_get_target_list (`self`).
1462 ///
1463 /// # Returns
1464 ///
1465 /// first target that the source offers
1466 /// and the dest can accept, or `GDK_NONE`
1467 #[doc(alias = "gtk_drag_dest_find_target")]
1468 fn drag_dest_find_target(
1469 &self,
1470 context: &gdk::DragContext,
1471 target_list: Option<&TargetList>,
1472 ) -> Option<gdk::Atom> {
1473 unsafe {
1474 from_glib_none(ffi::gtk_drag_dest_find_target(
1475 self.as_ref().to_glib_none().0,
1476 context.to_glib_none().0,
1477 target_list.to_glib_none().0,
1478 ))
1479 }
1480 }
1481
1482 /// Returns the list of targets this widget can accept from
1483 /// drag-and-drop.
1484 ///
1485 /// # Returns
1486 ///
1487 /// the [`TargetList`][crate::TargetList], or [`None`] if none
1488 #[doc(alias = "gtk_drag_dest_get_target_list")]
1489 fn drag_dest_get_target_list(&self) -> Option<TargetList> {
1490 unsafe {
1491 from_glib_none(ffi::gtk_drag_dest_get_target_list(
1492 self.as_ref().to_glib_none().0,
1493 ))
1494 }
1495 }
1496
1497 /// Returns whether the widget has been configured to always
1498 /// emit [`drag-motion`][struct@crate::Widget#drag-motion] signals.
1499 ///
1500 /// # Returns
1501 ///
1502 /// [`true`] if the widget always emits
1503 /// [`drag-motion`][struct@crate::Widget#drag-motion] events
1504 #[doc(alias = "gtk_drag_dest_get_track_motion")]
1505 fn drag_dest_get_track_motion(&self) -> bool {
1506 unsafe {
1507 from_glib(ffi::gtk_drag_dest_get_track_motion(
1508 self.as_ref().to_glib_none().0,
1509 ))
1510 }
1511 }
1512
1513 /// Sets the target types that this widget can accept from drag-and-drop.
1514 /// The widget must first be made into a drag destination with
1515 /// [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()].
1516 /// ## `target_list`
1517 /// list of droppable targets, or [`None`] for none
1518 #[doc(alias = "gtk_drag_dest_set_target_list")]
1519 fn drag_dest_set_target_list(&self, target_list: Option<&TargetList>) {
1520 unsafe {
1521 ffi::gtk_drag_dest_set_target_list(
1522 self.as_ref().to_glib_none().0,
1523 target_list.to_glib_none().0,
1524 );
1525 }
1526 }
1527
1528 /// Tells the widget to emit [`drag-motion`][struct@crate::Widget#drag-motion] and
1529 /// [`drag-leave`][struct@crate::Widget#drag-leave] events regardless of the targets and the
1530 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] flag.
1531 ///
1532 /// This may be used when a widget wants to do generic
1533 /// actions regardless of the targets that the source offers.
1534 /// ## `track_motion`
1535 /// whether to accept all targets
1536 #[doc(alias = "gtk_drag_dest_set_track_motion")]
1537 fn drag_dest_set_track_motion(&self, track_motion: bool) {
1538 unsafe {
1539 ffi::gtk_drag_dest_set_track_motion(
1540 self.as_ref().to_glib_none().0,
1541 track_motion.into_glib(),
1542 );
1543 }
1544 }
1545
1546 /// Clears information about a drop destination set with
1547 /// [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]. The widget will no longer receive
1548 /// notification of drags.
1549 #[doc(alias = "gtk_drag_dest_unset")]
1550 fn drag_dest_unset(&self) {
1551 unsafe {
1552 ffi::gtk_drag_dest_unset(self.as_ref().to_glib_none().0);
1553 }
1554 }
1555
1556 /// Gets the data associated with a drag. When the data
1557 /// is received or the retrieval fails, GTK+ will emit a
1558 /// [`drag-data-received`][struct@crate::Widget#drag-data-received] signal. Failure of the retrieval
1559 /// is indicated by the length field of the `selection_data`
1560 /// signal parameter being negative. However, when [`drag_get_data()`][Self::drag_get_data()]
1561 /// is called implicitely because the [`DestDefaults::DROP`][crate::DestDefaults::DROP] was set,
1562 /// then the widget will not receive notification of failed
1563 /// drops.
1564 /// ## `context`
1565 /// the drag context
1566 /// ## `target`
1567 /// the target (form of the data) to retrieve
1568 /// ## `time_`
1569 /// a timestamp for retrieving the data. This will
1570 /// generally be the time received in a [`drag-motion`][struct@crate::Widget#drag-motion]
1571 /// or [`drag-drop`][struct@crate::Widget#drag-drop] signal
1572 #[doc(alias = "gtk_drag_get_data")]
1573 fn drag_get_data(&self, context: &gdk::DragContext, target: &gdk::Atom, time_: u32) {
1574 unsafe {
1575 ffi::gtk_drag_get_data(
1576 self.as_ref().to_glib_none().0,
1577 context.to_glib_none().0,
1578 target.to_glib_none().0,
1579 time_,
1580 );
1581 }
1582 }
1583
1584 /// Highlights a widget as a currently hovered drop target.
1585 /// To end the highlight, call [`drag_unhighlight()`][Self::drag_unhighlight()].
1586 /// GTK+ calls this automatically if [`DestDefaults::HIGHLIGHT`][crate::DestDefaults::HIGHLIGHT] is set.
1587 #[doc(alias = "gtk_drag_highlight")]
1588 fn drag_highlight(&self) {
1589 unsafe {
1590 ffi::gtk_drag_highlight(self.as_ref().to_glib_none().0);
1591 }
1592 }
1593
1594 /// Add the writable image targets supported by [`SelectionData`][crate::SelectionData] to
1595 /// the target list of the drag source. The targets
1596 /// are added with `info` = 0. If you need another value,
1597 /// use [`TargetList::add_image_targets()`][crate::TargetList::add_image_targets()] and
1598 /// [`drag_source_set_target_list()`][Self::drag_source_set_target_list()].
1599 #[doc(alias = "gtk_drag_source_add_image_targets")]
1600 fn drag_source_add_image_targets(&self) {
1601 unsafe {
1602 ffi::gtk_drag_source_add_image_targets(self.as_ref().to_glib_none().0);
1603 }
1604 }
1605
1606 /// Add the text targets supported by [`SelectionData`][crate::SelectionData] to
1607 /// the target list of the drag source. The targets
1608 /// are added with `info` = 0. If you need another value,
1609 /// use [`TargetList::add_text_targets()`][crate::TargetList::add_text_targets()] and
1610 /// [`drag_source_set_target_list()`][Self::drag_source_set_target_list()].
1611 #[doc(alias = "gtk_drag_source_add_text_targets")]
1612 fn drag_source_add_text_targets(&self) {
1613 unsafe {
1614 ffi::gtk_drag_source_add_text_targets(self.as_ref().to_glib_none().0);
1615 }
1616 }
1617
1618 /// Add the URI targets supported by [`SelectionData`][crate::SelectionData] to
1619 /// the target list of the drag source. The targets
1620 /// are added with `info` = 0. If you need another value,
1621 /// use [`TargetList::add_uri_targets()`][crate::TargetList::add_uri_targets()] and
1622 /// [`drag_source_set_target_list()`][Self::drag_source_set_target_list()].
1623 #[doc(alias = "gtk_drag_source_add_uri_targets")]
1624 fn drag_source_add_uri_targets(&self) {
1625 unsafe {
1626 ffi::gtk_drag_source_add_uri_targets(self.as_ref().to_glib_none().0);
1627 }
1628 }
1629
1630 /// Gets the list of targets this widget can provide for
1631 /// drag-and-drop.
1632 ///
1633 /// # Returns
1634 ///
1635 /// the [`TargetList`][crate::TargetList], or [`None`] if none
1636 #[doc(alias = "gtk_drag_source_get_target_list")]
1637 fn drag_source_get_target_list(&self) -> Option<TargetList> {
1638 unsafe {
1639 from_glib_none(ffi::gtk_drag_source_get_target_list(
1640 self.as_ref().to_glib_none().0,
1641 ))
1642 }
1643 }
1644
1645 /// Sets the icon that will be used for drags from a particular source
1646 /// to `icon`. See the docs for [`IconTheme`][crate::IconTheme] for more details.
1647 /// ## `icon`
1648 /// A [`gio::Icon`][crate::gio::Icon]
1649 #[doc(alias = "gtk_drag_source_set_icon_gicon")]
1650 fn drag_source_set_icon_gicon(&self, icon: &impl IsA<gio::Icon>) {
1651 unsafe {
1652 ffi::gtk_drag_source_set_icon_gicon(
1653 self.as_ref().to_glib_none().0,
1654 icon.as_ref().to_glib_none().0,
1655 );
1656 }
1657 }
1658
1659 /// Sets the icon that will be used for drags from a particular source
1660 /// to a themed icon. See the docs for [`IconTheme`][crate::IconTheme] for more details.
1661 /// ## `icon_name`
1662 /// name of icon to use
1663 #[doc(alias = "gtk_drag_source_set_icon_name")]
1664 fn drag_source_set_icon_name(&self, icon_name: &str) {
1665 unsafe {
1666 ffi::gtk_drag_source_set_icon_name(
1667 self.as_ref().to_glib_none().0,
1668 icon_name.to_glib_none().0,
1669 );
1670 }
1671 }
1672
1673 /// Sets the icon that will be used for drags from a particular widget
1674 /// from a [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf]. GTK+ retains a reference for `pixbuf` and will
1675 /// release it when it is no longer needed.
1676 /// ## `pixbuf`
1677 /// the [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf] for the drag icon
1678 #[doc(alias = "gtk_drag_source_set_icon_pixbuf")]
1679 fn drag_source_set_icon_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf) {
1680 unsafe {
1681 ffi::gtk_drag_source_set_icon_pixbuf(
1682 self.as_ref().to_glib_none().0,
1683 pixbuf.to_glib_none().0,
1684 );
1685 }
1686 }
1687
1688 /// Changes the target types that this widget offers for drag-and-drop.
1689 /// The widget must first be made into a drag source with
1690 /// [`WidgetExtManual::drag_source_set()`][crate::prelude::WidgetExtManual::drag_source_set()].
1691 /// ## `target_list`
1692 /// list of draggable targets, or [`None`] for none
1693 #[doc(alias = "gtk_drag_source_set_target_list")]
1694 fn drag_source_set_target_list(&self, target_list: Option<&TargetList>) {
1695 unsafe {
1696 ffi::gtk_drag_source_set_target_list(
1697 self.as_ref().to_glib_none().0,
1698 target_list.to_glib_none().0,
1699 );
1700 }
1701 }
1702
1703 /// Undoes the effects of [`WidgetExtManual::drag_source_set()`][crate::prelude::WidgetExtManual::drag_source_set()].
1704 #[doc(alias = "gtk_drag_source_unset")]
1705 fn drag_source_unset(&self) {
1706 unsafe {
1707 ffi::gtk_drag_source_unset(self.as_ref().to_glib_none().0);
1708 }
1709 }
1710
1711 /// Removes a highlight set by [`drag_highlight()`][Self::drag_highlight()] from
1712 /// a widget.
1713 #[doc(alias = "gtk_drag_unhighlight")]
1714 fn drag_unhighlight(&self) {
1715 unsafe {
1716 ffi::gtk_drag_unhighlight(self.as_ref().to_glib_none().0);
1717 }
1718 }
1719
1720 /// Draws `self` to `cr`. The top left corner of the widget will be
1721 /// drawn to the currently set origin point of `cr`.
1722 ///
1723 /// You should pass a cairo context as `cr` argument that is in an
1724 /// original state. Otherwise the resulting drawing is undefined. For
1725 /// example changing the operator using `cairo_set_operator()` or the
1726 /// line width using `cairo_set_line_width()` might have unwanted side
1727 /// effects.
1728 /// You may however change the context’s transform matrix - like with
1729 /// `cairo_scale()`, `cairo_translate()` or `cairo_set_matrix()` and clip
1730 /// region with `cairo_clip()` prior to calling this function. Also, it
1731 /// is fine to modify the context with `cairo_save()` and
1732 /// `cairo_push_group()` prior to calling this function.
1733 ///
1734 /// Note that special-purpose widgets may contain special code for
1735 /// rendering to the screen and might appear differently on screen
1736 /// and when rendered using [`draw()`][Self::draw()].
1737 /// ## `cr`
1738 /// a cairo context to draw to
1739 #[doc(alias = "gtk_widget_draw")]
1740 fn draw(&self, cr: &cairo::Context) {
1741 unsafe {
1742 ffi::gtk_widget_draw(
1743 self.as_ref().to_glib_none().0,
1744 mut_override(cr.to_glib_none().0),
1745 );
1746 }
1747 }
1748
1749 /// Notifies the user about an input-related error on this widget.
1750 /// If the [`gtk-error-bell`][struct@crate::Settings#gtk-error-bell] setting is [`true`], it calls
1751 /// [`Window::beep()`][crate::gdk::Window::beep()], otherwise it does nothing.
1752 ///
1753 /// Note that the effect of [`Window::beep()`][crate::gdk::Window::beep()] can be configured in many
1754 /// ways, depending on the windowing backend and the desktop environment
1755 /// or window manager that is used.
1756 #[doc(alias = "gtk_widget_error_bell")]
1757 fn error_bell(&self) {
1758 unsafe {
1759 ffi::gtk_widget_error_bell(self.as_ref().to_glib_none().0);
1760 }
1761 }
1762
1763 /// Rarely-used function. This function is used to emit
1764 /// the event signals on a widget (those signals should never
1765 /// be emitted without using this function to do so).
1766 /// If you want to synthesize an event though, don’t use this function;
1767 /// instead, use [`main_do_event()`][crate::main_do_event()] so the event will behave as if
1768 /// it were in the event queue. Don’t synthesize expose events; instead,
1769 /// use [`Window::invalidate_rect()`][crate::gdk::Window::invalidate_rect()] to invalidate a region of the
1770 /// window.
1771 /// ## `event`
1772 /// a `GdkEvent`
1773 ///
1774 /// # Returns
1775 ///
1776 /// return from the event signal emission ([`true`] if
1777 /// the event was handled)
1778 #[doc(alias = "gtk_widget_event")]
1779 fn event(&self, event: &gdk::Event) -> bool {
1780 unsafe {
1781 from_glib(ffi::gtk_widget_event(
1782 self.as_ref().to_glib_none().0,
1783 mut_override(event.to_glib_none().0),
1784 ))
1785 }
1786 }
1787
1788 /// Stops emission of [`child-notify`][struct@crate::Widget#child-notify] signals on `self`. The
1789 /// signals are queued until [`thaw_child_notify()`][Self::thaw_child_notify()] is called
1790 /// on `self`.
1791 ///
1792 /// This is the analogue of [`ObjectExt::freeze_notify()`][crate::glib::prelude::ObjectExt::freeze_notify()] for child properties.
1793 #[doc(alias = "gtk_widget_freeze_child_notify")]
1794 fn freeze_child_notify(&self) {
1795 unsafe {
1796 ffi::gtk_widget_freeze_child_notify(self.as_ref().to_glib_none().0);
1797 }
1798 }
1799
1800 /// Returns the accessible object that describes the widget to an
1801 /// assistive technology.
1802 ///
1803 /// If accessibility support is not available, this [`atk::Object`][crate::atk::Object]
1804 /// instance may be a no-op. Likewise, if no class-specific [`atk::Object`][crate::atk::Object]
1805 /// implementation is available for the widget instance in question,
1806 /// it will inherit an [`atk::Object`][crate::atk::Object] implementation from the first ancestor
1807 /// class for which such an implementation is defined.
1808 ///
1809 /// The documentation of the
1810 /// [ATK](http://developer.gnome.org/atk/stable/)
1811 /// library contains more information about accessible objects and their uses.
1812 ///
1813 /// # Returns
1814 ///
1815 /// the [`atk::Object`][crate::atk::Object] associated with `self`
1816 #[doc(alias = "gtk_widget_get_accessible")]
1817 #[doc(alias = "get_accessible")]
1818 fn accessible(&self) -> Option<atk::Object> {
1819 unsafe {
1820 from_glib_none(ffi::gtk_widget_get_accessible(
1821 self.as_ref().to_glib_none().0,
1822 ))
1823 }
1824 }
1825
1826 /// Retrieves the [`gio::ActionGroup`][crate::gio::ActionGroup] that was registered using `prefix`. The resulting
1827 /// [`gio::ActionGroup`][crate::gio::ActionGroup] may have been registered to `self` or any [`Widget`][crate::Widget] in its
1828 /// ancestry.
1829 ///
1830 /// If no action group was found matching `prefix`, then [`None`] is returned.
1831 /// ## `prefix`
1832 /// The “prefix” of the action group.
1833 ///
1834 /// # Returns
1835 ///
1836 /// A [`gio::ActionGroup`][crate::gio::ActionGroup] or [`None`].
1837 #[doc(alias = "gtk_widget_get_action_group")]
1838 #[doc(alias = "get_action_group")]
1839 fn action_group(&self, prefix: &str) -> Option<gio::ActionGroup> {
1840 unsafe {
1841 from_glib_none(ffi::gtk_widget_get_action_group(
1842 self.as_ref().to_glib_none().0,
1843 prefix.to_glib_none().0,
1844 ))
1845 }
1846 }
1847
1848 /// Returns the baseline that has currently been allocated to `self`.
1849 /// This function is intended to be used when implementing handlers
1850 /// for the [`draw`][struct@crate::Widget#draw] function, and when allocating child
1851 /// widgets in [`size_allocate`][struct@crate::Widget#size_allocate].
1852 ///
1853 /// # Returns
1854 ///
1855 /// the baseline of the `self`, or -1 if none
1856 #[doc(alias = "gtk_widget_get_allocated_baseline")]
1857 #[doc(alias = "get_allocated_baseline")]
1858 fn allocated_baseline(&self) -> i32 {
1859 unsafe { ffi::gtk_widget_get_allocated_baseline(self.as_ref().to_glib_none().0) }
1860 }
1861
1862 /// Returns the height that has currently been allocated to `self`.
1863 /// This function is intended to be used when implementing handlers
1864 /// for the [`draw`][struct@crate::Widget#draw] function.
1865 ///
1866 /// # Returns
1867 ///
1868 /// the height of the `self`
1869 #[doc(alias = "gtk_widget_get_allocated_height")]
1870 #[doc(alias = "get_allocated_height")]
1871 fn allocated_height(&self) -> i32 {
1872 unsafe { ffi::gtk_widget_get_allocated_height(self.as_ref().to_glib_none().0) }
1873 }
1874
1875 /// Retrieves the widget’s allocated size.
1876 ///
1877 /// This function returns the last values passed to
1878 /// [`size_allocate_with_baseline()`][Self::size_allocate_with_baseline()]. The value differs from
1879 /// the size returned in [`allocation()`][Self::allocation()] in that functions
1880 /// like [`set_halign()`][Self::set_halign()] can adjust the allocation, but not
1881 /// the value returned by this function.
1882 ///
1883 /// If a widget is not visible, its allocated size is 0.
1884 ///
1885 /// # Returns
1886 ///
1887 ///
1888 /// ## `allocation`
1889 /// a pointer to a `GtkAllocation` to copy to
1890 ///
1891 /// ## `baseline`
1892 /// a pointer to an integer to copy to
1893 #[doc(alias = "gtk_widget_get_allocated_size")]
1894 #[doc(alias = "get_allocated_size")]
1895 fn allocated_size(&self) -> (Allocation, i32) {
1896 unsafe {
1897 let mut allocation = Allocation::uninitialized();
1898 let mut baseline = std::mem::MaybeUninit::uninit();
1899 ffi::gtk_widget_get_allocated_size(
1900 self.as_ref().to_glib_none().0,
1901 allocation.to_glib_none_mut().0,
1902 baseline.as_mut_ptr(),
1903 );
1904 (allocation, baseline.assume_init())
1905 }
1906 }
1907
1908 /// Returns the width that has currently been allocated to `self`.
1909 /// This function is intended to be used when implementing handlers
1910 /// for the [`draw`][struct@crate::Widget#draw] function.
1911 ///
1912 /// # Returns
1913 ///
1914 /// the width of the `self`
1915 #[doc(alias = "gtk_widget_get_allocated_width")]
1916 #[doc(alias = "get_allocated_width")]
1917 fn allocated_width(&self) -> i32 {
1918 unsafe { ffi::gtk_widget_get_allocated_width(self.as_ref().to_glib_none().0) }
1919 }
1920
1921 /// Retrieves the widget’s allocation.
1922 ///
1923 /// Note, when implementing a [`Container`][crate::Container]: a widget’s allocation will
1924 /// be its “adjusted” allocation, that is, the widget’s parent
1925 /// container typically calls [`size_allocate()`][Self::size_allocate()] with an
1926 /// allocation, and that allocation is then adjusted (to handle margin
1927 /// and alignment for example) before assignment to the widget.
1928 /// [`allocation()`][Self::allocation()] returns the adjusted allocation that
1929 /// was actually assigned to the widget. The adjusted allocation is
1930 /// guaranteed to be completely contained within the
1931 /// [`size_allocate()`][Self::size_allocate()] allocation, however. So a [`Container`][crate::Container]
1932 /// is guaranteed that its children stay inside the assigned bounds,
1933 /// but not that they have exactly the bounds the container assigned.
1934 /// There is no way to get the original allocation assigned by
1935 /// [`size_allocate()`][Self::size_allocate()], since it isn’t stored; if a container
1936 /// implementation needs that information it will have to track it itself.
1937 ///
1938 /// # Returns
1939 ///
1940 ///
1941 /// ## `allocation`
1942 /// a pointer to a `GtkAllocation` to copy to
1943 #[doc(alias = "gtk_widget_get_allocation")]
1944 #[doc(alias = "get_allocation")]
1945 fn allocation(&self) -> Allocation {
1946 unsafe {
1947 let mut allocation = Allocation::uninitialized();
1948 ffi::gtk_widget_get_allocation(
1949 self.as_ref().to_glib_none().0,
1950 allocation.to_glib_none_mut().0,
1951 );
1952 allocation
1953 }
1954 }
1955
1956 /// Gets the first ancestor of `self` with type `widget_type`. For example,
1957 /// `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets
1958 /// the first [`Box`][crate::Box] that’s an ancestor of `self`. No reference will be
1959 /// added to the returned widget; it should not be unreferenced. See note
1960 /// about checking for a toplevel [`Window`][crate::Window] in the docs for
1961 /// [`toplevel()`][Self::toplevel()].
1962 ///
1963 /// Note that unlike [`is_ancestor()`][Self::is_ancestor()], [`ancestor()`][Self::ancestor()]
1964 /// considers `self` to be an ancestor of itself.
1965 /// ## `widget_type`
1966 /// ancestor type
1967 ///
1968 /// # Returns
1969 ///
1970 /// the ancestor widget, or [`None`] if not found
1971 #[doc(alias = "gtk_widget_get_ancestor")]
1972 #[doc(alias = "get_ancestor")]
1973 #[must_use]
1974 fn ancestor(&self, widget_type: glib::types::Type) -> Option<Widget> {
1975 unsafe {
1976 from_glib_none(ffi::gtk_widget_get_ancestor(
1977 self.as_ref().to_glib_none().0,
1978 widget_type.into_glib(),
1979 ))
1980 }
1981 }
1982
1983 /// Determines whether the application intends to draw on the widget in
1984 /// an [`draw`][struct@crate::Widget#draw] handler.
1985 ///
1986 /// See [`set_app_paintable()`][Self::set_app_paintable()]
1987 ///
1988 /// # Returns
1989 ///
1990 /// [`true`] if the widget is app paintable
1991 #[doc(alias = "gtk_widget_get_app_paintable")]
1992 #[doc(alias = "get_app_paintable")]
1993 #[doc(alias = "app-paintable")]
1994 fn is_app_paintable(&self) -> bool {
1995 unsafe {
1996 from_glib(ffi::gtk_widget_get_app_paintable(
1997 self.as_ref().to_glib_none().0,
1998 ))
1999 }
2000 }
2001
2002 /// Determines whether `self` can be a default widget. See
2003 /// [`set_can_default()`][Self::set_can_default()].
2004 ///
2005 /// # Returns
2006 ///
2007 /// [`true`] if `self` can be a default widget, [`false`] otherwise
2008 #[doc(alias = "gtk_widget_get_can_default")]
2009 #[doc(alias = "get_can_default")]
2010 #[doc(alias = "can-default")]
2011 fn can_default(&self) -> bool {
2012 unsafe {
2013 from_glib(ffi::gtk_widget_get_can_default(
2014 self.as_ref().to_glib_none().0,
2015 ))
2016 }
2017 }
2018
2019 /// Determines whether `self` can own the input focus. See
2020 /// [`set_can_focus()`][Self::set_can_focus()].
2021 ///
2022 /// # Returns
2023 ///
2024 /// [`true`] if `self` can own the input focus, [`false`] otherwise
2025 #[doc(alias = "gtk_widget_get_can_focus")]
2026 #[doc(alias = "get_can_focus")]
2027 #[doc(alias = "can-focus")]
2028 fn can_focus(&self) -> bool {
2029 unsafe {
2030 from_glib(ffi::gtk_widget_get_can_focus(
2031 self.as_ref().to_glib_none().0,
2032 ))
2033 }
2034 }
2035
2036 /// Gets the value set with [`set_child_visible()`][Self::set_child_visible()].
2037 /// If you feel a need to use this function, your code probably
2038 /// needs reorganization.
2039 ///
2040 /// This function is only useful for container implementations and
2041 /// never should be called by an application.
2042 ///
2043 /// # Returns
2044 ///
2045 /// [`true`] if the widget is mapped with the parent.
2046 #[doc(alias = "gtk_widget_get_child_visible")]
2047 #[doc(alias = "get_child_visible")]
2048 fn is_child_visible(&self) -> bool {
2049 unsafe {
2050 from_glib(ffi::gtk_widget_get_child_visible(
2051 self.as_ref().to_glib_none().0,
2052 ))
2053 }
2054 }
2055
2056 /// Retrieves the widget’s clip area.
2057 ///
2058 /// The clip area is the area in which all of `self`'s drawing will
2059 /// happen. Other toolkits call it the bounding box.
2060 ///
2061 /// Historically, in GTK+ the clip area has been equal to the allocation
2062 /// retrieved via [`allocation()`][Self::allocation()].
2063 ///
2064 /// # Returns
2065 ///
2066 ///
2067 /// ## `clip`
2068 /// a pointer to a `GtkAllocation` to copy to
2069 #[doc(alias = "gtk_widget_get_clip")]
2070 #[doc(alias = "get_clip")]
2071 fn clip(&self) -> Allocation {
2072 unsafe {
2073 let mut clip = Allocation::uninitialized();
2074 ffi::gtk_widget_get_clip(self.as_ref().to_glib_none().0, clip.to_glib_none_mut().0);
2075 clip
2076 }
2077 }
2078
2079 /// Returns the clipboard object for the given selection to
2080 /// be used with `self`. `self` must have a [`gdk::Display`][crate::gdk::Display]
2081 /// associated with it, so must be attached to a toplevel
2082 /// window.
2083 /// ## `selection`
2084 /// a [`gdk::Atom`][crate::gdk::Atom] which identifies the clipboard
2085 /// to use. `GDK_SELECTION_CLIPBOARD` gives the
2086 /// default clipboard. Another common value
2087 /// is `GDK_SELECTION_PRIMARY`, which gives
2088 /// the primary X selection.
2089 ///
2090 /// # Returns
2091 ///
2092 /// the appropriate clipboard object. If no
2093 /// clipboard already exists, a new one will
2094 /// be created. Once a clipboard object has
2095 /// been created, it is persistent for all time.
2096 #[doc(alias = "gtk_widget_get_clipboard")]
2097 #[doc(alias = "get_clipboard")]
2098 fn clipboard(&self, selection: &gdk::Atom) -> Clipboard {
2099 unsafe {
2100 from_glib_none(ffi::gtk_widget_get_clipboard(
2101 self.as_ref().to_glib_none().0,
2102 selection.to_glib_none().0,
2103 ))
2104 }
2105 }
2106
2107 /// Returns whether `device` can interact with `self` and its
2108 /// children. See [`set_device_enabled()`][Self::set_device_enabled()].
2109 /// ## `device`
2110 /// a [`gdk::Device`][crate::gdk::Device]
2111 ///
2112 /// # Returns
2113 ///
2114 /// [`true`] is `device` is enabled for `self`
2115 #[doc(alias = "gtk_widget_get_device_enabled")]
2116 #[doc(alias = "get_device_enabled")]
2117 fn device_is_enabled(&self, device: &gdk::Device) -> bool {
2118 unsafe {
2119 from_glib(ffi::gtk_widget_get_device_enabled(
2120 self.as_ref().to_glib_none().0,
2121 device.to_glib_none().0,
2122 ))
2123 }
2124 }
2125
2126 /// Returns the events mask for the widget corresponding to an specific device. These
2127 /// are the events that the widget will receive when `device` operates on it.
2128 /// ## `device`
2129 /// a [`gdk::Device`][crate::gdk::Device]
2130 ///
2131 /// # Returns
2132 ///
2133 /// device event mask for `self`
2134 #[doc(alias = "gtk_widget_get_device_events")]
2135 #[doc(alias = "get_device_events")]
2136 fn device_events(&self, device: &gdk::Device) -> gdk::EventMask {
2137 unsafe {
2138 from_glib(ffi::gtk_widget_get_device_events(
2139 self.as_ref().to_glib_none().0,
2140 device.to_glib_none().0,
2141 ))
2142 }
2143 }
2144
2145 /// Gets the reading direction for a particular widget. See
2146 /// [`set_direction()`][Self::set_direction()].
2147 ///
2148 /// # Returns
2149 ///
2150 /// the reading direction for the widget.
2151 #[doc(alias = "gtk_widget_get_direction")]
2152 #[doc(alias = "get_direction")]
2153 fn direction(&self) -> TextDirection {
2154 unsafe {
2155 from_glib(ffi::gtk_widget_get_direction(
2156 self.as_ref().to_glib_none().0,
2157 ))
2158 }
2159 }
2160
2161 /// Get the [`gdk::Display`][crate::gdk::Display] for the toplevel window associated with
2162 /// this widget. This function can only be called after the widget
2163 /// has been added to a widget hierarchy with a [`Window`][crate::Window] at the top.
2164 ///
2165 /// In general, you should only create display specific
2166 /// resources when a widget has been realized, and you should
2167 /// free those resources when the widget is unrealized.
2168 ///
2169 /// # Returns
2170 ///
2171 /// the [`gdk::Display`][crate::gdk::Display] for the toplevel for this widget.
2172 #[doc(alias = "gtk_widget_get_display")]
2173 #[doc(alias = "get_display")]
2174 fn display(&self) -> gdk::Display {
2175 unsafe { from_glib_none(ffi::gtk_widget_get_display(self.as_ref().to_glib_none().0)) }
2176 }
2177
2178 /// Determines whether the widget is double buffered.
2179 ///
2180 /// See `gtk_widget_set_double_buffered()`
2181 ///
2182 /// # Returns
2183 ///
2184 /// [`true`] if the widget is double buffered
2185 #[doc(alias = "gtk_widget_get_double_buffered")]
2186 #[doc(alias = "get_double_buffered")]
2187 #[doc(alias = "double-buffered")]
2188 fn is_double_buffered(&self) -> bool {
2189 unsafe {
2190 from_glib(ffi::gtk_widget_get_double_buffered(
2191 self.as_ref().to_glib_none().0,
2192 ))
2193 }
2194 }
2195
2196 /// Returns whether the widget should grab focus when it is clicked with the mouse.
2197 /// See [`set_focus_on_click()`][Self::set_focus_on_click()].
2198 ///
2199 /// # Returns
2200 ///
2201 /// [`true`] if the widget should grab focus when it is clicked with
2202 /// the mouse.
2203 #[doc(alias = "gtk_widget_get_focus_on_click")]
2204 #[doc(alias = "get_focus_on_click")]
2205 #[doc(alias = "focus-on-click")]
2206 fn gets_focus_on_click(&self) -> bool {
2207 unsafe {
2208 from_glib(ffi::gtk_widget_get_focus_on_click(
2209 self.as_ref().to_glib_none().0,
2210 ))
2211 }
2212 }
2213
2214 /// Gets the font map that has been set with [`set_font_map()`][Self::set_font_map()].
2215 ///
2216 /// # Returns
2217 ///
2218 /// A [`pango::FontMap`][crate::pango::FontMap], or [`None`]
2219 #[doc(alias = "gtk_widget_get_font_map")]
2220 #[doc(alias = "get_font_map")]
2221 fn font_map(&self) -> Option<pango::FontMap> {
2222 unsafe { from_glib_none(ffi::gtk_widget_get_font_map(self.as_ref().to_glib_none().0)) }
2223 }
2224
2225 /// Returns the [`cairo::FontOptions`][crate::cairo::FontOptions] used for Pango rendering. When not set,
2226 /// the defaults font options for the [`gdk::Screen`][crate::gdk::Screen] will be used.
2227 ///
2228 /// # Returns
2229 ///
2230 /// the [`cairo::FontOptions`][crate::cairo::FontOptions] or [`None`] if not set
2231 #[doc(alias = "gtk_widget_get_font_options")]
2232 #[doc(alias = "get_font_options")]
2233 fn font_options(&self) -> Option<cairo::FontOptions> {
2234 unsafe {
2235 from_glib_none(ffi::gtk_widget_get_font_options(
2236 self.as_ref().to_glib_none().0,
2237 ))
2238 }
2239 }
2240
2241 /// Obtains the frame clock for a widget. The frame clock is a global
2242 /// “ticker” that can be used to drive animations and repaints. The
2243 /// most common reason to get the frame clock is to call
2244 /// [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], in order to get a time to use for
2245 /// animating. For example you might record the start of the animation
2246 /// with an initial value from [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], and
2247 /// then update the animation by calling
2248 /// [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()] again during each repaint.
2249 ///
2250 /// [`FrameClock::request_phase()`][crate::gdk::FrameClock::request_phase()] will result in a new frame on the
2251 /// clock, but won’t necessarily repaint any widgets. To repaint a
2252 /// widget, you have to use [`queue_draw()`][Self::queue_draw()] which invalidates
2253 /// the widget (thus scheduling it to receive a draw on the next
2254 /// frame). [`queue_draw()`][Self::queue_draw()] will also end up requesting a frame
2255 /// on the appropriate frame clock.
2256 ///
2257 /// A widget’s frame clock will not change while the widget is
2258 /// mapped. Reparenting a widget (which implies a temporary unmap) can
2259 /// change the widget’s frame clock.
2260 ///
2261 /// Unrealized widgets do not have a frame clock.
2262 ///
2263 /// # Returns
2264 ///
2265 /// a [`gdk::FrameClock`][crate::gdk::FrameClock],
2266 /// or [`None`] if widget is unrealized
2267 #[doc(alias = "gtk_widget_get_frame_clock")]
2268 #[doc(alias = "get_frame_clock")]
2269 fn frame_clock(&self) -> Option<gdk::FrameClock> {
2270 unsafe {
2271 from_glib_none(ffi::gtk_widget_get_frame_clock(
2272 self.as_ref().to_glib_none().0,
2273 ))
2274 }
2275 }
2276
2277 /// Gets the value of the [`halign`][struct@crate::Widget#halign] property.
2278 ///
2279 /// For backwards compatibility reasons this method will never return
2280 /// [`Align::Baseline`][crate::Align::Baseline], but instead it will convert it to
2281 /// [`Align::Fill`][crate::Align::Fill]. Baselines are not supported for horizontal
2282 /// alignment.
2283 ///
2284 /// # Returns
2285 ///
2286 /// the horizontal alignment of `self`
2287 #[doc(alias = "gtk_widget_get_halign")]
2288 #[doc(alias = "get_halign")]
2289 fn halign(&self) -> Align {
2290 unsafe { from_glib(ffi::gtk_widget_get_halign(self.as_ref().to_glib_none().0)) }
2291 }
2292
2293 /// Returns the current value of the has-tooltip property. See
2294 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] for more information.
2295 ///
2296 /// # Returns
2297 ///
2298 /// current value of has-tooltip on `self`.
2299 #[doc(alias = "gtk_widget_get_has_tooltip")]
2300 #[doc(alias = "get_has_tooltip")]
2301 #[doc(alias = "has-tooltip")]
2302 fn has_tooltip(&self) -> bool {
2303 unsafe {
2304 from_glib(ffi::gtk_widget_get_has_tooltip(
2305 self.as_ref().to_glib_none().0,
2306 ))
2307 }
2308 }
2309
2310 /// Determines whether `self` has a [`gdk::Window`][crate::gdk::Window] of its own. See
2311 /// [`set_has_window()`][Self::set_has_window()].
2312 ///
2313 /// # Returns
2314 ///
2315 /// [`true`] if `self` has a window, [`false`] otherwise
2316 #[doc(alias = "gtk_widget_get_has_window")]
2317 #[doc(alias = "get_has_window")]
2318 fn has_window(&self) -> bool {
2319 unsafe {
2320 from_glib(ffi::gtk_widget_get_has_window(
2321 self.as_ref().to_glib_none().0,
2322 ))
2323 }
2324 }
2325
2326 /// Gets whether the widget would like any available extra horizontal
2327 /// space. When a user resizes a [`Window`][crate::Window], widgets with expand=TRUE
2328 /// generally receive the extra space. For example, a list or
2329 /// scrollable area or document in your window would often be set to
2330 /// expand.
2331 ///
2332 /// Containers should use [`compute_expand()`][Self::compute_expand()] rather than
2333 /// this function, to see whether a widget, or any of its children,
2334 /// has the expand flag set. If any child of a widget wants to
2335 /// expand, the parent may ask to expand also.
2336 ///
2337 /// This function only looks at the widget’s own hexpand flag, rather
2338 /// than computing whether the entire widget tree rooted at this widget
2339 /// wants to expand.
2340 ///
2341 /// # Returns
2342 ///
2343 /// whether hexpand flag is set
2344 #[doc(alias = "gtk_widget_get_hexpand")]
2345 #[doc(alias = "get_hexpand")]
2346 #[doc(alias = "hexpand")]
2347 fn hexpands(&self) -> bool {
2348 unsafe { from_glib(ffi::gtk_widget_get_hexpand(self.as_ref().to_glib_none().0)) }
2349 }
2350
2351 /// Gets whether [`set_hexpand()`][Self::set_hexpand()] has been used to
2352 /// explicitly set the expand flag on this widget.
2353 ///
2354 /// If hexpand is set, then it overrides any computed
2355 /// expand value based on child widgets. If hexpand is not
2356 /// set, then the expand value depends on whether any
2357 /// children of the widget would like to expand.
2358 ///
2359 /// There are few reasons to use this function, but it’s here
2360 /// for completeness and consistency.
2361 ///
2362 /// # Returns
2363 ///
2364 /// whether hexpand has been explicitly set
2365 #[doc(alias = "gtk_widget_get_hexpand_set")]
2366 #[doc(alias = "get_hexpand_set")]
2367 #[doc(alias = "hexpand-set")]
2368 fn is_hexpand_set(&self) -> bool {
2369 unsafe {
2370 from_glib(ffi::gtk_widget_get_hexpand_set(
2371 self.as_ref().to_glib_none().0,
2372 ))
2373 }
2374 }
2375
2376 /// Whether the widget is mapped.
2377 ///
2378 /// # Returns
2379 ///
2380 /// [`true`] if the widget is mapped, [`false`] otherwise.
2381 #[doc(alias = "gtk_widget_get_mapped")]
2382 #[doc(alias = "get_mapped")]
2383 fn is_mapped(&self) -> bool {
2384 unsafe { from_glib(ffi::gtk_widget_get_mapped(self.as_ref().to_glib_none().0)) }
2385 }
2386
2387 /// Gets the value of the [`margin-bottom`][struct@crate::Widget#margin-bottom] property.
2388 ///
2389 /// # Returns
2390 ///
2391 /// The bottom margin of `self`
2392 #[doc(alias = "gtk_widget_get_margin_bottom")]
2393 #[doc(alias = "get_margin_bottom")]
2394 #[doc(alias = "margin-bottom")]
2395 fn margin_bottom(&self) -> i32 {
2396 unsafe { ffi::gtk_widget_get_margin_bottom(self.as_ref().to_glib_none().0) }
2397 }
2398
2399 /// Gets the value of the [`margin-end`][struct@crate::Widget#margin-end] property.
2400 ///
2401 /// # Returns
2402 ///
2403 /// The end margin of `self`
2404 #[doc(alias = "gtk_widget_get_margin_end")]
2405 #[doc(alias = "get_margin_end")]
2406 #[doc(alias = "margin-end")]
2407 fn margin_end(&self) -> i32 {
2408 unsafe { ffi::gtk_widget_get_margin_end(self.as_ref().to_glib_none().0) }
2409 }
2410
2411 /// Gets the value of the [`margin-start`][struct@crate::Widget#margin-start] property.
2412 ///
2413 /// # Returns
2414 ///
2415 /// The start margin of `self`
2416 #[doc(alias = "gtk_widget_get_margin_start")]
2417 #[doc(alias = "get_margin_start")]
2418 #[doc(alias = "margin-start")]
2419 fn margin_start(&self) -> i32 {
2420 unsafe { ffi::gtk_widget_get_margin_start(self.as_ref().to_glib_none().0) }
2421 }
2422
2423 /// Gets the value of the [`margin-top`][struct@crate::Widget#margin-top] property.
2424 ///
2425 /// # Returns
2426 ///
2427 /// The top margin of `self`
2428 #[doc(alias = "gtk_widget_get_margin_top")]
2429 #[doc(alias = "get_margin_top")]
2430 #[doc(alias = "margin-top")]
2431 fn margin_top(&self) -> i32 {
2432 unsafe { ffi::gtk_widget_get_margin_top(self.as_ref().to_glib_none().0) }
2433 }
2434
2435 /// Returns the modifier mask the `self`’s windowing system backend
2436 /// uses for a particular purpose.
2437 ///
2438 /// See `gdk_keymap_get_modifier_mask()`.
2439 /// ## `intent`
2440 /// the use case for the modifier mask
2441 ///
2442 /// # Returns
2443 ///
2444 /// the modifier mask used for `intent`.
2445 #[doc(alias = "gtk_widget_get_modifier_mask")]
2446 #[doc(alias = "get_modifier_mask")]
2447 fn modifier_mask(&self, intent: gdk::ModifierIntent) -> gdk::ModifierType {
2448 unsafe {
2449 from_glib(ffi::gtk_widget_get_modifier_mask(
2450 self.as_ref().to_glib_none().0,
2451 intent.into_glib(),
2452 ))
2453 }
2454 }
2455
2456 /// Retrieves the name of a widget. See [`set_widget_name()`][Self::set_widget_name()] for the
2457 /// significance of widget names.
2458 ///
2459 /// # Returns
2460 ///
2461 /// name of the widget. This string is owned by GTK+ and
2462 /// should not be modified or freed
2463 #[doc(alias = "gtk_widget_get_name")]
2464 #[doc(alias = "get_name")]
2465 #[doc(alias = "name")]
2466 fn widget_name(&self) -> glib::GString {
2467 unsafe { from_glib_none(ffi::gtk_widget_get_name(self.as_ref().to_glib_none().0)) }
2468 }
2469
2470 /// Returns the current value of the [`no-show-all`][struct@crate::Widget#no-show-all] property,
2471 /// which determines whether calls to [`show_all()`][Self::show_all()]
2472 /// will affect this widget.
2473 ///
2474 /// # Returns
2475 ///
2476 /// the current value of the “no-show-all” property.
2477 #[doc(alias = "gtk_widget_get_no_show_all")]
2478 #[doc(alias = "get_no_show_all")]
2479 #[doc(alias = "no-show-all")]
2480 fn is_no_show_all(&self) -> bool {
2481 unsafe {
2482 from_glib(ffi::gtk_widget_get_no_show_all(
2483 self.as_ref().to_glib_none().0,
2484 ))
2485 }
2486 }
2487
2488 /// Fetches the requested opacity for this widget.
2489 /// See [`set_opacity()`][Self::set_opacity()].
2490 ///
2491 /// # Returns
2492 ///
2493 /// the requested opacity for this widget.
2494 #[doc(alias = "gtk_widget_get_opacity")]
2495 #[doc(alias = "get_opacity")]
2496 fn opacity(&self) -> f64 {
2497 unsafe { ffi::gtk_widget_get_opacity(self.as_ref().to_glib_none().0) }
2498 }
2499
2500 /// Gets a [`pango::Context`][crate::pango::Context] with the appropriate font map, font description,
2501 /// and base direction for this widget. Unlike the context returned
2502 /// by [`create_pango_context()`][Self::create_pango_context()], this context is owned by
2503 /// the widget (it can be used until the screen for the widget changes
2504 /// or the widget is removed from its toplevel), and will be updated to
2505 /// match any changes to the widget’s attributes. This can be tracked
2506 /// by using the [`screen-changed`][struct@crate::Widget#screen-changed] signal on the widget.
2507 ///
2508 /// # Returns
2509 ///
2510 /// the [`pango::Context`][crate::pango::Context] for the widget.
2511 #[doc(alias = "gtk_widget_get_pango_context")]
2512 #[doc(alias = "get_pango_context")]
2513 fn pango_context(&self) -> pango::Context {
2514 unsafe {
2515 from_glib_none(ffi::gtk_widget_get_pango_context(
2516 self.as_ref().to_glib_none().0,
2517 ))
2518 }
2519 }
2520
2521 /// Returns the parent container of `self`.
2522 ///
2523 /// # Returns
2524 ///
2525 /// the parent container of `self`, or [`None`]
2526 #[doc(alias = "gtk_widget_get_parent")]
2527 #[doc(alias = "get_parent")]
2528 #[must_use]
2529 fn parent(&self) -> Option<Widget> {
2530 unsafe { from_glib_none(ffi::gtk_widget_get_parent(self.as_ref().to_glib_none().0)) }
2531 }
2532
2533 /// Gets `self`’s parent window, or [`None`] if it does not have one.
2534 ///
2535 /// # Returns
2536 ///
2537 /// the parent window of `self`, or [`None`]
2538 /// if it does not have a parent window.
2539 #[doc(alias = "gtk_widget_get_parent_window")]
2540 #[doc(alias = "get_parent_window")]
2541 fn parent_window(&self) -> Option<gdk::Window> {
2542 unsafe {
2543 from_glib_none(ffi::gtk_widget_get_parent_window(
2544 self.as_ref().to_glib_none().0,
2545 ))
2546 }
2547 }
2548
2549 /// Returns the [`WidgetPath`][crate::WidgetPath] representing `self`, if the widget
2550 /// is not connected to a toplevel widget, a partial path will be
2551 /// created.
2552 ///
2553 /// # Returns
2554 ///
2555 /// The [`WidgetPath`][crate::WidgetPath] representing `self`
2556 #[doc(alias = "gtk_widget_get_path")]
2557 #[doc(alias = "get_path")]
2558 fn path(&self) -> WidgetPath {
2559 unsafe { from_glib_none(ffi::gtk_widget_get_path(self.as_ref().to_glib_none().0)) }
2560 }
2561
2562 /// Retrieves a widget’s initial minimum and natural height.
2563 ///
2564 /// This call is specific to width-for-height requests.
2565 ///
2566 /// The returned request will be modified by the
2567 /// GtkWidgetClass::adjust_size_request virtual method and by any
2568 /// `GtkSizeGroups` that have been applied. That is, the returned request
2569 /// is the one that should be used for layout, not necessarily the one
2570 /// returned by the widget itself.
2571 ///
2572 /// # Returns
2573 ///
2574 ///
2575 /// ## `minimum_height`
2576 /// location to store the minimum height, or [`None`]
2577 ///
2578 /// ## `natural_height`
2579 /// location to store the natural height, or [`None`]
2580 #[doc(alias = "gtk_widget_get_preferred_height")]
2581 #[doc(alias = "get_preferred_height")]
2582 fn preferred_height(&self) -> (i32, i32) {
2583 unsafe {
2584 let mut minimum_height = std::mem::MaybeUninit::uninit();
2585 let mut natural_height = std::mem::MaybeUninit::uninit();
2586 ffi::gtk_widget_get_preferred_height(
2587 self.as_ref().to_glib_none().0,
2588 minimum_height.as_mut_ptr(),
2589 natural_height.as_mut_ptr(),
2590 );
2591 (minimum_height.assume_init(), natural_height.assume_init())
2592 }
2593 }
2594
2595 /// Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given
2596 /// the specified `width`, or the default height if `width` is -1. The baselines may be -1 which means
2597 /// that no baseline is requested for this widget.
2598 ///
2599 /// The returned request will be modified by the
2600 /// GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods
2601 /// and by any `GtkSizeGroups` that have been applied. That is, the returned request
2602 /// is the one that should be used for layout, not necessarily the one
2603 /// returned by the widget itself.
2604 /// ## `width`
2605 /// the width which is available for allocation, or -1 if none
2606 ///
2607 /// # Returns
2608 ///
2609 ///
2610 /// ## `minimum_height`
2611 /// location for storing the minimum height, or [`None`]
2612 ///
2613 /// ## `natural_height`
2614 /// location for storing the natural height, or [`None`]
2615 ///
2616 /// ## `minimum_baseline`
2617 /// location for storing the baseline for the minimum height, or [`None`]
2618 ///
2619 /// ## `natural_baseline`
2620 /// location for storing the baseline for the natural height, or [`None`]
2621 #[doc(alias = "gtk_widget_get_preferred_height_and_baseline_for_width")]
2622 #[doc(alias = "get_preferred_height_and_baseline_for_width")]
2623 fn preferred_height_and_baseline_for_width(&self, width: i32) -> (i32, i32, i32, i32) {
2624 unsafe {
2625 let mut minimum_height = std::mem::MaybeUninit::uninit();
2626 let mut natural_height = std::mem::MaybeUninit::uninit();
2627 let mut minimum_baseline = std::mem::MaybeUninit::uninit();
2628 let mut natural_baseline = std::mem::MaybeUninit::uninit();
2629 ffi::gtk_widget_get_preferred_height_and_baseline_for_width(
2630 self.as_ref().to_glib_none().0,
2631 width,
2632 minimum_height.as_mut_ptr(),
2633 natural_height.as_mut_ptr(),
2634 minimum_baseline.as_mut_ptr(),
2635 natural_baseline.as_mut_ptr(),
2636 );
2637 (
2638 minimum_height.assume_init(),
2639 natural_height.assume_init(),
2640 minimum_baseline.assume_init(),
2641 natural_baseline.assume_init(),
2642 )
2643 }
2644 }
2645
2646 /// Retrieves a widget’s minimum and natural height if it would be given
2647 /// the specified `width`.
2648 ///
2649 /// The returned request will be modified by the
2650 /// GtkWidgetClass::adjust_size_request virtual method and by any
2651 /// `GtkSizeGroups` that have been applied. That is, the returned request
2652 /// is the one that should be used for layout, not necessarily the one
2653 /// returned by the widget itself.
2654 /// ## `width`
2655 /// the width which is available for allocation
2656 ///
2657 /// # Returns
2658 ///
2659 ///
2660 /// ## `minimum_height`
2661 /// location for storing the minimum height, or [`None`]
2662 ///
2663 /// ## `natural_height`
2664 /// location for storing the natural height, or [`None`]
2665 #[doc(alias = "gtk_widget_get_preferred_height_for_width")]
2666 #[doc(alias = "get_preferred_height_for_width")]
2667 fn preferred_height_for_width(&self, width: i32) -> (i32, i32) {
2668 unsafe {
2669 let mut minimum_height = std::mem::MaybeUninit::uninit();
2670 let mut natural_height = std::mem::MaybeUninit::uninit();
2671 ffi::gtk_widget_get_preferred_height_for_width(
2672 self.as_ref().to_glib_none().0,
2673 width,
2674 minimum_height.as_mut_ptr(),
2675 natural_height.as_mut_ptr(),
2676 );
2677 (minimum_height.assume_init(), natural_height.assume_init())
2678 }
2679 }
2680
2681 /// Retrieves the minimum and natural size of a widget, taking
2682 /// into account the widget’s preference for height-for-width management.
2683 ///
2684 /// This is used to retrieve a suitable size by container widgets which do
2685 /// not impose any restrictions on the child placement. It can be used
2686 /// to deduce toplevel window and menu sizes as well as child widgets in
2687 /// free-form containers such as GtkLayout.
2688 ///
2689 /// Handle with care. Note that the natural height of a height-for-width
2690 /// widget will generally be a smaller size than the minimum height, since the required
2691 /// height for the natural width is generally smaller than the required height for
2692 /// the minimum width.
2693 ///
2694 /// Use [`preferred_height_and_baseline_for_width()`][Self::preferred_height_and_baseline_for_width()] if you want to support
2695 /// baseline alignment.
2696 ///
2697 /// # Returns
2698 ///
2699 ///
2700 /// ## `minimum_size`
2701 /// location for storing the minimum size, or [`None`]
2702 ///
2703 /// ## `natural_size`
2704 /// location for storing the natural size, or [`None`]
2705 #[doc(alias = "gtk_widget_get_preferred_size")]
2706 #[doc(alias = "get_preferred_size")]
2707 fn preferred_size(&self) -> (Requisition, Requisition) {
2708 unsafe {
2709 let mut minimum_size = Requisition::uninitialized();
2710 let mut natural_size = Requisition::uninitialized();
2711 ffi::gtk_widget_get_preferred_size(
2712 self.as_ref().to_glib_none().0,
2713 minimum_size.to_glib_none_mut().0,
2714 natural_size.to_glib_none_mut().0,
2715 );
2716 (minimum_size, natural_size)
2717 }
2718 }
2719
2720 /// Retrieves a widget’s initial minimum and natural width.
2721 ///
2722 /// This call is specific to height-for-width requests.
2723 ///
2724 /// The returned request will be modified by the
2725 /// GtkWidgetClass::adjust_size_request virtual method and by any
2726 /// `GtkSizeGroups` that have been applied. That is, the returned request
2727 /// is the one that should be used for layout, not necessarily the one
2728 /// returned by the widget itself.
2729 ///
2730 /// # Returns
2731 ///
2732 ///
2733 /// ## `minimum_width`
2734 /// location to store the minimum width, or [`None`]
2735 ///
2736 /// ## `natural_width`
2737 /// location to store the natural width, or [`None`]
2738 #[doc(alias = "gtk_widget_get_preferred_width")]
2739 #[doc(alias = "get_preferred_width")]
2740 fn preferred_width(&self) -> (i32, i32) {
2741 unsafe {
2742 let mut minimum_width = std::mem::MaybeUninit::uninit();
2743 let mut natural_width = std::mem::MaybeUninit::uninit();
2744 ffi::gtk_widget_get_preferred_width(
2745 self.as_ref().to_glib_none().0,
2746 minimum_width.as_mut_ptr(),
2747 natural_width.as_mut_ptr(),
2748 );
2749 (minimum_width.assume_init(), natural_width.assume_init())
2750 }
2751 }
2752
2753 /// Retrieves a widget’s minimum and natural width if it would be given
2754 /// the specified `height`.
2755 ///
2756 /// The returned request will be modified by the
2757 /// GtkWidgetClass::adjust_size_request virtual method and by any
2758 /// `GtkSizeGroups` that have been applied. That is, the returned request
2759 /// is the one that should be used for layout, not necessarily the one
2760 /// returned by the widget itself.
2761 /// ## `height`
2762 /// the height which is available for allocation
2763 ///
2764 /// # Returns
2765 ///
2766 ///
2767 /// ## `minimum_width`
2768 /// location for storing the minimum width, or [`None`]
2769 ///
2770 /// ## `natural_width`
2771 /// location for storing the natural width, or [`None`]
2772 #[doc(alias = "gtk_widget_get_preferred_width_for_height")]
2773 #[doc(alias = "get_preferred_width_for_height")]
2774 fn preferred_width_for_height(&self, height: i32) -> (i32, i32) {
2775 unsafe {
2776 let mut minimum_width = std::mem::MaybeUninit::uninit();
2777 let mut natural_width = std::mem::MaybeUninit::uninit();
2778 ffi::gtk_widget_get_preferred_width_for_height(
2779 self.as_ref().to_glib_none().0,
2780 height,
2781 minimum_width.as_mut_ptr(),
2782 natural_width.as_mut_ptr(),
2783 );
2784 (minimum_width.assume_init(), natural_width.assume_init())
2785 }
2786 }
2787
2788 /// Determines whether `self` is realized.
2789 ///
2790 /// # Returns
2791 ///
2792 /// [`true`] if `self` is realized, [`false`] otherwise
2793 #[doc(alias = "gtk_widget_get_realized")]
2794 #[doc(alias = "get_realized")]
2795 fn is_realized(&self) -> bool {
2796 unsafe { from_glib(ffi::gtk_widget_get_realized(self.as_ref().to_glib_none().0)) }
2797 }
2798
2799 /// Determines whether `self` is always treated as the default widget
2800 /// within its toplevel when it has the focus, even if another widget
2801 /// is the default.
2802 ///
2803 /// See [`set_receives_default()`][Self::set_receives_default()].
2804 ///
2805 /// # Returns
2806 ///
2807 /// [`true`] if `self` acts as the default widget when focused,
2808 /// [`false`] otherwise
2809 #[doc(alias = "gtk_widget_get_receives_default")]
2810 #[doc(alias = "get_receives_default")]
2811 #[doc(alias = "receives-default")]
2812 fn receives_default(&self) -> bool {
2813 unsafe {
2814 from_glib(ffi::gtk_widget_get_receives_default(
2815 self.as_ref().to_glib_none().0,
2816 ))
2817 }
2818 }
2819
2820 /// Gets whether the widget prefers a height-for-width layout
2821 /// or a width-for-height layout.
2822 ///
2823 /// [`Bin`][crate::Bin] widgets generally propagate the preference of
2824 /// their child, container widgets need to request something either in
2825 /// context of their children or in context of their allocation
2826 /// capabilities.
2827 ///
2828 /// # Returns
2829 ///
2830 /// The [`SizeRequestMode`][crate::SizeRequestMode] preferred by `self`.
2831 #[doc(alias = "gtk_widget_get_request_mode")]
2832 #[doc(alias = "get_request_mode")]
2833 fn request_mode(&self) -> SizeRequestMode {
2834 unsafe {
2835 from_glib(ffi::gtk_widget_get_request_mode(
2836 self.as_ref().to_glib_none().0,
2837 ))
2838 }
2839 }
2840
2841 /// Retrieves the internal scale factor that maps from window coordinates
2842 /// to the actual device pixels. On traditional systems this is 1, on
2843 /// high density outputs, it can be a higher value (typically 2).
2844 ///
2845 /// See [`Window::scale_factor()`][crate::gdk::Window::scale_factor()].
2846 ///
2847 /// # Returns
2848 ///
2849 /// the scale factor for `self`
2850 #[doc(alias = "gtk_widget_get_scale_factor")]
2851 #[doc(alias = "get_scale_factor")]
2852 #[doc(alias = "scale-factor")]
2853 fn scale_factor(&self) -> i32 {
2854 unsafe { ffi::gtk_widget_get_scale_factor(self.as_ref().to_glib_none().0) }
2855 }
2856
2857 /// Get the [`gdk::Screen`][crate::gdk::Screen] from the toplevel window associated with
2858 /// this widget. This function can only be called after the widget
2859 /// has been added to a widget hierarchy with a [`Window`][crate::Window]
2860 /// at the top.
2861 ///
2862 /// In general, you should only create screen specific
2863 /// resources when a widget has been realized, and you should
2864 /// free those resources when the widget is unrealized.
2865 ///
2866 /// # Returns
2867 ///
2868 /// the [`gdk::Screen`][crate::gdk::Screen] for the toplevel for this widget.
2869 #[doc(alias = "gtk_widget_get_screen")]
2870 #[doc(alias = "get_screen")]
2871 fn screen(&self) -> Option<gdk::Screen> {
2872 unsafe { from_glib_none(ffi::gtk_widget_get_screen(self.as_ref().to_glib_none().0)) }
2873 }
2874
2875 /// Returns the widget’s sensitivity (in the sense of returning
2876 /// the value that has been set using [`set_sensitive()`][Self::set_sensitive()]).
2877 ///
2878 /// The effective sensitivity of a widget is however determined by both its
2879 /// own and its parent widget’s sensitivity. See [`is_sensitive()`][Self::is_sensitive()].
2880 ///
2881 /// # Returns
2882 ///
2883 /// [`true`] if the widget is sensitive
2884 #[doc(alias = "gtk_widget_get_sensitive")]
2885 #[doc(alias = "sensitive")]
2886 fn get_sensitive(&self) -> bool {
2887 unsafe {
2888 from_glib(ffi::gtk_widget_get_sensitive(
2889 self.as_ref().to_glib_none().0,
2890 ))
2891 }
2892 }
2893
2894 /// Gets the settings object holding the settings used for this widget.
2895 ///
2896 /// Note that this function can only be called when the [`Widget`][crate::Widget]
2897 /// is attached to a toplevel, since the settings object is specific
2898 /// to a particular [`gdk::Screen`][crate::gdk::Screen].
2899 ///
2900 /// # Returns
2901 ///
2902 /// the relevant [`Settings`][crate::Settings] object
2903 #[doc(alias = "gtk_widget_get_settings")]
2904 #[doc(alias = "get_settings")]
2905 fn settings(&self) -> Option<Settings> {
2906 unsafe { from_glib_none(ffi::gtk_widget_get_settings(self.as_ref().to_glib_none().0)) }
2907 }
2908
2909 /// Gets the size request that was explicitly set for the widget using
2910 /// [`set_size_request()`][Self::set_size_request()]. A value of -1 stored in `width` or
2911 /// `height` indicates that that dimension has not been set explicitly
2912 /// and the natural requisition of the widget will be used instead. See
2913 /// [`set_size_request()`][Self::set_size_request()]. To get the size a widget will
2914 /// actually request, call [`preferred_size()`][Self::preferred_size()] instead of
2915 /// this function.
2916 ///
2917 /// # Returns
2918 ///
2919 ///
2920 /// ## `width`
2921 /// return location for width, or [`None`]
2922 ///
2923 /// ## `height`
2924 /// return location for height, or [`None`]
2925 #[doc(alias = "gtk_widget_get_size_request")]
2926 #[doc(alias = "get_size_request")]
2927 fn size_request(&self) -> (i32, i32) {
2928 unsafe {
2929 let mut width = std::mem::MaybeUninit::uninit();
2930 let mut height = std::mem::MaybeUninit::uninit();
2931 ffi::gtk_widget_get_size_request(
2932 self.as_ref().to_glib_none().0,
2933 width.as_mut_ptr(),
2934 height.as_mut_ptr(),
2935 );
2936 (width.assume_init(), height.assume_init())
2937 }
2938 }
2939
2940 /// Returns the widget state as a flag set. It is worth mentioning
2941 /// that the effective [`StateFlags::INSENSITIVE`][crate::StateFlags::INSENSITIVE] state will be
2942 /// returned, that is, also based on parent insensitivity, even if
2943 /// `self` itself is sensitive.
2944 ///
2945 /// Also note that if you are looking for a way to obtain the
2946 /// [`StateFlags`][crate::StateFlags] to pass to a [`StyleContext`][crate::StyleContext] method, you
2947 /// should look at [`StyleContextExt::state()`][crate::prelude::StyleContextExt::state()].
2948 ///
2949 /// # Returns
2950 ///
2951 /// The state flags for widget
2952 #[doc(alias = "gtk_widget_get_state_flags")]
2953 #[doc(alias = "get_state_flags")]
2954 fn state_flags(&self) -> StateFlags {
2955 unsafe {
2956 from_glib(ffi::gtk_widget_get_state_flags(
2957 self.as_ref().to_glib_none().0,
2958 ))
2959 }
2960 }
2961
2962 /// Returns the style context associated to `self`. The returned object is
2963 /// guaranteed to be the same for the lifetime of `self`.
2964 ///
2965 /// # Returns
2966 ///
2967 /// a [`StyleContext`][crate::StyleContext]. This memory is owned by `self` and
2968 /// must not be freed.
2969 #[doc(alias = "gtk_widget_get_style_context")]
2970 #[doc(alias = "get_style_context")]
2971 fn style_context(&self) -> StyleContext {
2972 unsafe {
2973 from_glib_none(ffi::gtk_widget_get_style_context(
2974 self.as_ref().to_glib_none().0,
2975 ))
2976 }
2977 }
2978
2979 /// Returns [`true`] if `self` is multiple pointer aware. See
2980 /// [`set_support_multidevice()`][Self::set_support_multidevice()] for more information.
2981 ///
2982 /// # Returns
2983 ///
2984 /// [`true`] if `self` is multidevice aware.
2985 #[doc(alias = "gtk_widget_get_support_multidevice")]
2986 #[doc(alias = "get_support_multidevice")]
2987 fn supports_multidevice(&self) -> bool {
2988 unsafe {
2989 from_glib(ffi::gtk_widget_get_support_multidevice(
2990 self.as_ref().to_glib_none().0,
2991 ))
2992 }
2993 }
2994
2995 /// Fetch an object build from the template XML for `widget_type` in this `self` instance.
2996 ///
2997 /// This will only report children which were previously declared with
2998 /// `gtk_widget_class_bind_template_child_full()` or one of its
2999 /// variants.
3000 ///
3001 /// This function is only meant to be called for code which is private to the `widget_type` which
3002 /// declared the child and is meant for language bindings which cannot easily make use
3003 /// of the GObject structure offsets.
3004 /// ## `widget_type`
3005 /// The `GType` to get a template child for
3006 /// ## `name`
3007 /// The “id” of the child defined in the template XML
3008 ///
3009 /// # Returns
3010 ///
3011 /// The object built in the template XML with the id `name`
3012 #[doc(alias = "gtk_widget_get_template_child")]
3013 #[doc(alias = "get_template_child")]
3014 fn template_child(&self, widget_type: glib::types::Type, name: &str) -> Option<glib::Object> {
3015 unsafe {
3016 from_glib_none(ffi::gtk_widget_get_template_child(
3017 self.as_ref().to_glib_none().0,
3018 widget_type.into_glib(),
3019 name.to_glib_none().0,
3020 ))
3021 }
3022 }
3023
3024 /// Gets the contents of the tooltip for `self`.
3025 ///
3026 /// # Returns
3027 ///
3028 /// the tooltip text, or [`None`]. You should free the
3029 /// returned string with `g_free()` when done.
3030 #[doc(alias = "gtk_widget_get_tooltip_markup")]
3031 #[doc(alias = "get_tooltip_markup")]
3032 #[doc(alias = "tooltip-markup")]
3033 fn tooltip_markup(&self) -> Option<glib::GString> {
3034 unsafe {
3035 from_glib_full(ffi::gtk_widget_get_tooltip_markup(
3036 self.as_ref().to_glib_none().0,
3037 ))
3038 }
3039 }
3040
3041 /// Gets the contents of the tooltip for `self`.
3042 ///
3043 /// # Returns
3044 ///
3045 /// the tooltip text, or [`None`]. You should free the
3046 /// returned string with `g_free()` when done.
3047 #[doc(alias = "gtk_widget_get_tooltip_text")]
3048 #[doc(alias = "get_tooltip_text")]
3049 #[doc(alias = "tooltip-text")]
3050 fn tooltip_text(&self) -> Option<glib::GString> {
3051 unsafe {
3052 from_glib_full(ffi::gtk_widget_get_tooltip_text(
3053 self.as_ref().to_glib_none().0,
3054 ))
3055 }
3056 }
3057
3058 /// Returns the [`Window`][crate::Window] of the current tooltip. This can be the
3059 /// GtkWindow created by default, or the custom tooltip window set
3060 /// using [`set_tooltip_window()`][Self::set_tooltip_window()].
3061 ///
3062 /// # Returns
3063 ///
3064 /// The [`Window`][crate::Window] of the current tooltip.
3065 #[doc(alias = "gtk_widget_get_tooltip_window")]
3066 #[doc(alias = "get_tooltip_window")]
3067 fn tooltip_window(&self) -> Option<Window> {
3068 unsafe {
3069 from_glib_none(ffi::gtk_widget_get_tooltip_window(
3070 self.as_ref().to_glib_none().0,
3071 ))
3072 }
3073 }
3074
3075 ///
3076 /// static const char *
3077 /// get_widget_toplevel_title (GtkWidget *widget)
3078 /// {
3079 /// GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
3080 /// if (GTK_IS_WINDOW (toplevel))
3081 /// {
3082 /// return gtk_window_get_title (GTK_WINDOW (toplevel));
3083 /// }
3084 ///
3085 /// return NULL;
3086 /// }
3087 /// ]|
3088 ///
3089 /// # Returns
3090 ///
3091 /// the topmost ancestor of `self`, or `self` itself
3092 /// if there’s no ancestor.
3093 #[doc(alias = "gtk_widget_get_toplevel")]
3094 #[doc(alias = "get_toplevel")]
3095 #[must_use]
3096 fn toplevel(&self) -> Option<Widget> {
3097 unsafe { from_glib_none(ffi::gtk_widget_get_toplevel(self.as_ref().to_glib_none().0)) }
3098 }
3099
3100 /// value, NULL)`, which will
3101 /// also report the true value.
3102 ///
3103 /// # Returns
3104 ///
3105 /// the vertical alignment of `self`, ignoring baseline alignment
3106 #[doc(alias = "gtk_widget_get_valign")]
3107 #[doc(alias = "get_valign")]
3108 fn valign(&self) -> Align {
3109 unsafe { from_glib(ffi::gtk_widget_get_valign(self.as_ref().to_glib_none().0)) }
3110 }
3111
3112 /// Gets the value of the [`valign`][struct@crate::Widget#valign] property, including
3113 /// [`Align::Baseline`][crate::Align::Baseline].
3114 ///
3115 /// # Returns
3116 ///
3117 /// the vertical alignment of `self`
3118 #[doc(alias = "gtk_widget_get_valign_with_baseline")]
3119 #[doc(alias = "get_valign_with_baseline")]
3120 fn valign_with_baseline(&self) -> Align {
3121 unsafe {
3122 from_glib(ffi::gtk_widget_get_valign_with_baseline(
3123 self.as_ref().to_glib_none().0,
3124 ))
3125 }
3126 }
3127
3128 /// Gets whether the widget would like any available extra vertical
3129 /// space.
3130 ///
3131 /// See [`hexpands()`][Self::hexpands()] for more detail.
3132 ///
3133 /// # Returns
3134 ///
3135 /// whether vexpand flag is set
3136 #[doc(alias = "gtk_widget_get_vexpand")]
3137 #[doc(alias = "get_vexpand")]
3138 #[doc(alias = "vexpand")]
3139 fn vexpands(&self) -> bool {
3140 unsafe { from_glib(ffi::gtk_widget_get_vexpand(self.as_ref().to_glib_none().0)) }
3141 }
3142
3143 /// Gets whether [`set_vexpand()`][Self::set_vexpand()] has been used to
3144 /// explicitly set the expand flag on this widget.
3145 ///
3146 /// See [`is_hexpand_set()`][Self::is_hexpand_set()] for more detail.
3147 ///
3148 /// # Returns
3149 ///
3150 /// whether vexpand has been explicitly set
3151 #[doc(alias = "gtk_widget_get_vexpand_set")]
3152 #[doc(alias = "get_vexpand_set")]
3153 #[doc(alias = "vexpand-set")]
3154 fn is_vexpand_set(&self) -> bool {
3155 unsafe {
3156 from_glib(ffi::gtk_widget_get_vexpand_set(
3157 self.as_ref().to_glib_none().0,
3158 ))
3159 }
3160 }
3161
3162 /// Determines whether the widget is visible. If you want to
3163 /// take into account whether the widget’s parent is also marked as
3164 /// visible, use [`is_visible()`][Self::is_visible()] instead.
3165 ///
3166 /// This function does not check if the widget is obscured in any way.
3167 ///
3168 /// See [`set_visible()`][Self::set_visible()].
3169 ///
3170 /// # Returns
3171 ///
3172 /// [`true`] if the widget is visible
3173 #[doc(alias = "gtk_widget_get_visible")]
3174 #[doc(alias = "visible")]
3175 fn get_visible(&self) -> bool {
3176 unsafe { from_glib(ffi::gtk_widget_get_visible(self.as_ref().to_glib_none().0)) }
3177 }
3178
3179 /// Gets the visual that will be used to render `self`.
3180 ///
3181 /// # Returns
3182 ///
3183 /// the visual for `self`
3184 #[doc(alias = "gtk_widget_get_visual")]
3185 #[doc(alias = "get_visual")]
3186 fn visual(&self) -> Option<gdk::Visual> {
3187 unsafe { from_glib_none(ffi::gtk_widget_get_visual(self.as_ref().to_glib_none().0)) }
3188 }
3189
3190 /// Returns the widget’s window if it is realized, [`None`] otherwise
3191 ///
3192 /// # Returns
3193 ///
3194 /// `self`’s window.
3195 #[doc(alias = "gtk_widget_get_window")]
3196 #[doc(alias = "get_window")]
3197 fn window(&self) -> Option<gdk::Window> {
3198 unsafe { from_glib_none(ffi::gtk_widget_get_window(self.as_ref().to_glib_none().0)) }
3199 }
3200
3201 /// Makes `self` the current grabbed widget.
3202 ///
3203 /// This means that interaction with other widgets in the same
3204 /// application is blocked and mouse as well as keyboard events
3205 /// are delivered to this widget.
3206 ///
3207 /// If `self` is not sensitive, it is not set as the current
3208 /// grabbed widget and this function does nothing.
3209 #[doc(alias = "gtk_grab_add")]
3210 fn grab_add(&self) {
3211 unsafe {
3212 ffi::gtk_grab_add(self.as_ref().to_glib_none().0);
3213 }
3214 }
3215
3216 /// Causes `self` to become the default widget. `self` must be able to be
3217 /// a default widget; typically you would ensure this yourself
3218 /// by calling [`set_can_default()`][Self::set_can_default()] with a [`true`] value.
3219 /// The default widget is activated when
3220 /// the user presses Enter in a window. Default widgets must be
3221 /// activatable, that is, [`activate()`][Self::activate()] should affect them. Note
3222 /// that [`Entry`][crate::Entry] widgets require the “activates-default” property
3223 /// set to [`true`] before they activate the default widget when Enter
3224 /// is pressed and the [`Entry`][crate::Entry] is focused.
3225 #[doc(alias = "gtk_widget_grab_default")]
3226 fn grab_default(&self) {
3227 unsafe {
3228 ffi::gtk_widget_grab_default(self.as_ref().to_glib_none().0);
3229 }
3230 }
3231
3232 /// Causes `self` to have the keyboard focus for the [`Window`][crate::Window] it's
3233 /// inside. `self` must be a focusable widget, such as a [`Entry`][crate::Entry];
3234 /// something like [`Frame`][crate::Frame] won’t work.
3235 ///
3236 /// More precisely, it must have the `GTK_CAN_FOCUS` flag set. Use
3237 /// [`set_can_focus()`][Self::set_can_focus()] to modify that flag.
3238 ///
3239 /// The widget also needs to be realized and mapped. This is indicated by the
3240 /// related signals. Grabbing the focus immediately after creating the widget
3241 /// will likely fail and cause critical warnings.
3242 #[doc(alias = "gtk_widget_grab_focus")]
3243 fn grab_focus(&self) {
3244 unsafe {
3245 ffi::gtk_widget_grab_focus(self.as_ref().to_glib_none().0);
3246 }
3247 }
3248
3249 /// Removes the grab from the given widget.
3250 ///
3251 /// You have to pair calls to [`grab_add()`][Self::grab_add()] and [`grab_remove()`][Self::grab_remove()].
3252 ///
3253 /// If `self` does not have the grab, this function does nothing.
3254 #[doc(alias = "gtk_grab_remove")]
3255 fn grab_remove(&self) {
3256 unsafe {
3257 ffi::gtk_grab_remove(self.as_ref().to_glib_none().0);
3258 }
3259 }
3260
3261 /// Determines whether `self` is the current default widget within its
3262 /// toplevel. See [`set_can_default()`][Self::set_can_default()].
3263 ///
3264 /// # Returns
3265 ///
3266 /// [`true`] if `self` is the current default widget within
3267 /// its toplevel, [`false`] otherwise
3268 #[doc(alias = "gtk_widget_has_default")]
3269 fn has_default(&self) -> bool {
3270 unsafe { from_glib(ffi::gtk_widget_has_default(self.as_ref().to_glib_none().0)) }
3271 }
3272
3273 /// Determines if the widget has the global input focus. See
3274 /// [`is_focus()`][Self::is_focus()] for the difference between having the global
3275 /// input focus, and only having the focus within a toplevel.
3276 ///
3277 /// # Returns
3278 ///
3279 /// [`true`] if the widget has the global input focus.
3280 #[doc(alias = "gtk_widget_has_focus")]
3281 fn has_focus(&self) -> bool {
3282 unsafe { from_glib(ffi::gtk_widget_has_focus(self.as_ref().to_glib_none().0)) }
3283 }
3284
3285 /// Determines whether the widget is currently grabbing events, so it
3286 /// is the only widget receiving input events (keyboard and mouse).
3287 ///
3288 /// See also [`grab_add()`][Self::grab_add()].
3289 ///
3290 /// # Returns
3291 ///
3292 /// [`true`] if the widget is in the grab_widgets stack
3293 #[doc(alias = "gtk_widget_has_grab")]
3294 fn has_grab(&self) -> bool {
3295 unsafe { from_glib(ffi::gtk_widget_has_grab(self.as_ref().to_glib_none().0)) }
3296 }
3297
3298 /// Checks whether there is a [`gdk::Screen`][crate::gdk::Screen] is associated with
3299 /// this widget. All toplevel widgets have an associated
3300 /// screen, and all widgets added into a hierarchy with a toplevel
3301 /// window at the top.
3302 ///
3303 /// # Returns
3304 ///
3305 /// [`true`] if there is a [`gdk::Screen`][crate::gdk::Screen] associated
3306 /// with the widget.
3307 #[doc(alias = "gtk_widget_has_screen")]
3308 fn has_screen(&self) -> bool {
3309 unsafe { from_glib(ffi::gtk_widget_has_screen(self.as_ref().to_glib_none().0)) }
3310 }
3311
3312 /// Determines if the widget should show a visible indication that
3313 /// it has the global input focus. This is a convenience function for
3314 /// use in ::draw handlers that takes into account whether focus
3315 /// indication should currently be shown in the toplevel window of
3316 /// `self`. See [`GtkWindowExt::gets_focus_visible()`][crate::prelude::GtkWindowExt::gets_focus_visible()] for more information
3317 /// about focus indication.
3318 ///
3319 /// To find out if the widget has the global input focus, use
3320 /// [`has_focus()`][Self::has_focus()].
3321 ///
3322 /// # Returns
3323 ///
3324 /// [`true`] if the widget should display a “focus rectangle”
3325 #[doc(alias = "gtk_widget_has_visible_focus")]
3326 fn has_visible_focus(&self) -> bool {
3327 unsafe {
3328 from_glib(ffi::gtk_widget_has_visible_focus(
3329 self.as_ref().to_glib_none().0,
3330 ))
3331 }
3332 }
3333
3334 /// Reverses the effects of [`show()`][Self::show()], causing the widget to be
3335 /// hidden (invisible to the user).
3336 #[doc(alias = "gtk_widget_hide")]
3337 fn hide(&self) {
3338 unsafe {
3339 ffi::gtk_widget_hide(self.as_ref().to_glib_none().0);
3340 }
3341 }
3342
3343 /// Returns whether the widget is currently being destroyed.
3344 /// This information can sometimes be used to avoid doing
3345 /// unnecessary work.
3346 ///
3347 /// # Returns
3348 ///
3349 /// [`true`] if `self` is being destroyed
3350 #[doc(alias = "gtk_widget_in_destruction")]
3351 fn in_destruction(&self) -> bool {
3352 unsafe {
3353 from_glib(ffi::gtk_widget_in_destruction(
3354 self.as_ref().to_glib_none().0,
3355 ))
3356 }
3357 }
3358
3359 /// Creates and initializes child widgets defined in templates. This
3360 /// function must be called in the instance initializer for any
3361 /// class which assigned itself a template using `gtk_widget_class_set_template()`
3362 ///
3363 /// It is important to call this function in the instance initializer
3364 /// of a [`Widget`][crate::Widget] subclass and not in `GObject.constructed()` or
3365 /// `GObject.constructor()` for two reasons.
3366 ///
3367 /// One reason is that generally derived widgets will assume that parent
3368 /// class composite widgets have been created in their instance
3369 /// initializers.
3370 ///
3371 /// Another reason is that when calling [`glib::Object::new()`][crate::glib::Object::new()] on a widget with
3372 /// composite templates, it’s important to build the composite widgets
3373 /// before the construct properties are set. Properties passed to [`glib::Object::new()`][crate::glib::Object::new()]
3374 /// should take precedence over properties set in the private template XML.
3375 #[doc(alias = "gtk_widget_init_template")]
3376 fn init_template(&self) {
3377 unsafe {
3378 ffi::gtk_widget_init_template(self.as_ref().to_glib_none().0);
3379 }
3380 }
3381
3382 /// Sets an input shape for this widget’s GDK window. This allows for
3383 /// windows which react to mouse click in a nonrectangular region, see
3384 /// [`Window::input_shape_combine_region()`][crate::gdk::Window::input_shape_combine_region()] for more information.
3385 /// ## `region`
3386 /// shape to be added, or [`None`] to remove an existing shape
3387 #[doc(alias = "gtk_widget_input_shape_combine_region")]
3388 fn input_shape_combine_region(&self, region: Option<&cairo::Region>) {
3389 unsafe {
3390 ffi::gtk_widget_input_shape_combine_region(
3391 self.as_ref().to_glib_none().0,
3392 mut_override(region.to_glib_none().0),
3393 );
3394 }
3395 }
3396
3397 /// Inserts `group` into `self`. Children of `self` that implement
3398 /// [`Actionable`][crate::Actionable] can then be associated with actions in `group` by
3399 /// setting their “action-name” to
3400 /// `prefix`.`action-name`.
3401 ///
3402 /// If `group` is [`None`], a previously inserted group for `name` is removed
3403 /// from `self`.
3404 /// ## `name`
3405 /// the prefix for actions in `group`
3406 /// ## `group`
3407 /// a [`gio::ActionGroup`][crate::gio::ActionGroup], or [`None`]
3408 #[doc(alias = "gtk_widget_insert_action_group")]
3409 fn insert_action_group(&self, name: &str, group: Option<&impl IsA<gio::ActionGroup>>) {
3410 unsafe {
3411 ffi::gtk_widget_insert_action_group(
3412 self.as_ref().to_glib_none().0,
3413 name.to_glib_none().0,
3414 group.map(|p| p.as_ref()).to_glib_none().0,
3415 );
3416 }
3417 }
3418
3419 /// Determines whether `self` is somewhere inside `ancestor`, possibly with
3420 /// intermediate containers.
3421 /// ## `ancestor`
3422 /// another [`Widget`][crate::Widget]
3423 ///
3424 /// # Returns
3425 ///
3426 /// [`true`] if `ancestor` contains `self` as a child,
3427 /// grandchild, great grandchild, etc.
3428 #[doc(alias = "gtk_widget_is_ancestor")]
3429 fn is_ancestor(&self, ancestor: &impl IsA<Widget>) -> bool {
3430 unsafe {
3431 from_glib(ffi::gtk_widget_is_ancestor(
3432 self.as_ref().to_glib_none().0,
3433 ancestor.as_ref().to_glib_none().0,
3434 ))
3435 }
3436 }
3437
3438 /// Determines whether `self` can be drawn to. A widget can be drawn
3439 /// to if it is mapped and visible.
3440 ///
3441 /// # Returns
3442 ///
3443 /// [`true`] if `self` is drawable, [`false`] otherwise
3444 #[doc(alias = "gtk_widget_is_drawable")]
3445 fn is_drawable(&self) -> bool {
3446 unsafe { from_glib(ffi::gtk_widget_is_drawable(self.as_ref().to_glib_none().0)) }
3447 }
3448
3449 /// Determines if the widget is the focus widget within its
3450 /// toplevel. (This does not mean that the [`has-focus`][struct@crate::Widget#has-focus] property is
3451 /// necessarily set; [`has-focus`][struct@crate::Widget#has-focus] will only be set if the
3452 /// toplevel widget additionally has the global input focus.)
3453 ///
3454 /// # Returns
3455 ///
3456 /// [`true`] if the widget is the focus widget.
3457 #[doc(alias = "gtk_widget_is_focus")]
3458 fn is_focus(&self) -> bool {
3459 unsafe { from_glib(ffi::gtk_widget_is_focus(self.as_ref().to_glib_none().0)) }
3460 }
3461
3462 /// Returns the widget’s effective sensitivity, which means
3463 /// it is sensitive itself and also its parent widget is sensitive
3464 ///
3465 /// # Returns
3466 ///
3467 /// [`true`] if the widget is effectively sensitive
3468 #[doc(alias = "gtk_widget_is_sensitive")]
3469 fn is_sensitive(&self) -> bool {
3470 unsafe { from_glib(ffi::gtk_widget_is_sensitive(self.as_ref().to_glib_none().0)) }
3471 }
3472
3473 /// Determines whether `self` is a toplevel widget.
3474 ///
3475 /// Currently only [`Window`][crate::Window] and [`Invisible`][crate::Invisible] (and out-of-process
3476 /// `GtkPlugs`) are toplevel widgets. Toplevel widgets have no parent
3477 /// widget.
3478 ///
3479 /// # Returns
3480 ///
3481 /// [`true`] if `self` is a toplevel, [`false`] otherwise
3482 #[doc(alias = "gtk_widget_is_toplevel")]
3483 fn is_toplevel(&self) -> bool {
3484 unsafe { from_glib(ffi::gtk_widget_is_toplevel(self.as_ref().to_glib_none().0)) }
3485 }
3486
3487 /// Determines whether the widget and all its parents are marked as
3488 /// visible.
3489 ///
3490 /// This function does not check if the widget is obscured in any way.
3491 ///
3492 /// See also [`get_visible()`][Self::get_visible()] and [`set_visible()`][Self::set_visible()]
3493 ///
3494 /// # Returns
3495 ///
3496 /// [`true`] if the widget and all its parents are visible
3497 #[doc(alias = "gtk_widget_is_visible")]
3498 fn is_visible(&self) -> bool {
3499 unsafe { from_glib(ffi::gtk_widget_is_visible(self.as_ref().to_glib_none().0)) }
3500 }
3501
3502 /// This function should be called whenever keyboard navigation within
3503 /// a single widget hits a boundary. The function emits the
3504 /// [`keynav-failed`][struct@crate::Widget#keynav-failed] signal on the widget and its return
3505 /// value should be interpreted in a way similar to the return value of
3506 /// [`child_focus()`][Self::child_focus()]:
3507 ///
3508 /// When [`true`] is returned, stay in the widget, the failed keyboard
3509 /// navigation is OK and/or there is nowhere we can/should move the
3510 /// focus to.
3511 ///
3512 /// When [`false`] is returned, the caller should continue with keyboard
3513 /// navigation outside the widget, e.g. by calling
3514 /// [`child_focus()`][Self::child_focus()] on the widget’s toplevel.
3515 ///
3516 /// The default ::keynav-failed handler returns [`false`] for
3517 /// [`DirectionType::TabForward`][crate::DirectionType::TabForward] and [`DirectionType::TabBackward`][crate::DirectionType::TabBackward]. For the other
3518 /// values of [`DirectionType`][crate::DirectionType] it returns [`true`].
3519 ///
3520 /// Whenever the default handler returns [`true`], it also calls
3521 /// [`error_bell()`][Self::error_bell()] to notify the user of the failed keyboard
3522 /// navigation.
3523 ///
3524 /// A use case for providing an own implementation of ::keynav-failed
3525 /// (either by connecting to it or by overriding it) would be a row of
3526 /// [`Entry`][crate::Entry] widgets where the user should be able to navigate the
3527 /// entire row with the cursor keys, as e.g. known from user interfaces
3528 /// that require entering license keys.
3529 /// ## `direction`
3530 /// direction of focus movement
3531 ///
3532 /// # Returns
3533 ///
3534 /// [`true`] if stopping keyboard navigation is fine, [`false`]
3535 /// if the emitting widget should try to handle the keyboard
3536 /// navigation attempt in its parent container(s).
3537 #[doc(alias = "gtk_widget_keynav_failed")]
3538 fn keynav_failed(&self, direction: DirectionType) -> bool {
3539 unsafe {
3540 from_glib(ffi::gtk_widget_keynav_failed(
3541 self.as_ref().to_glib_none().0,
3542 direction.into_glib(),
3543 ))
3544 }
3545 }
3546
3547 /// Lists the closures used by `self` for accelerator group connections
3548 /// with [`AccelGroupExtManual::connect_accel_group_by_path()`][crate::prelude::AccelGroupExtManual::connect_accel_group_by_path()] or [`AccelGroupExtManual::connect_accel_group()`][crate::prelude::AccelGroupExtManual::connect_accel_group()].
3549 /// The closures can be used to monitor accelerator changes on `self`,
3550 /// by connecting to the [`AccelGroup`][crate::AccelGroup] signal of the
3551 /// [`AccelGroup`][crate::AccelGroup] of a closure which can be found out with
3552 /// [`AccelGroup::from_accel_closure()`][crate::AccelGroup::from_accel_closure()].
3553 ///
3554 /// # Returns
3555 ///
3556 ///
3557 /// a newly allocated `GList` of closures
3558 #[doc(alias = "gtk_widget_list_accel_closures")]
3559 fn list_accel_closures(&self) -> Vec<glib::Closure> {
3560 unsafe {
3561 FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_accel_closures(
3562 self.as_ref().to_glib_none().0,
3563 ))
3564 }
3565 }
3566
3567 /// Retrieves a [`None`]-terminated array of strings containing the prefixes of
3568 /// [`gio::ActionGroup`][crate::gio::ActionGroup]'s available to `self`.
3569 ///
3570 /// # Returns
3571 ///
3572 /// a [`None`]-terminated array of strings.
3573 #[doc(alias = "gtk_widget_list_action_prefixes")]
3574 fn list_action_prefixes(&self) -> Vec<glib::GString> {
3575 unsafe {
3576 FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_action_prefixes(
3577 self.as_ref().to_glib_none().0,
3578 ))
3579 }
3580 }
3581
3582 /// Returns a newly allocated list of the widgets, normally labels, for
3583 /// which this widget is the target of a mnemonic (see for example,
3584 /// [`LabelExt::set_mnemonic_widget()`][crate::prelude::LabelExt::set_mnemonic_widget()]).
3585 ///
3586 /// The widgets in the list are not individually referenced. If you
3587 /// want to iterate through the list and perform actions involving
3588 /// callbacks that might destroy the widgets, you
3589 /// must call `g_list_foreach (result,
3590 /// (GFunc)g_object_ref, NULL)` first, and then unref all the
3591 /// widgets afterwards.
3592 ///
3593 /// # Returns
3594 ///
3595 /// the list of
3596 /// mnemonic labels; free this list
3597 /// with `g_list_free()` when you are done with it.
3598 #[doc(alias = "gtk_widget_list_mnemonic_labels")]
3599 fn list_mnemonic_labels(&self) -> Vec<Widget> {
3600 unsafe {
3601 FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_mnemonic_labels(
3602 self.as_ref().to_glib_none().0,
3603 ))
3604 }
3605 }
3606
3607 /// This function is only for use in widget implementations. Causes
3608 /// a widget to be mapped if it isn’t already.
3609 #[doc(alias = "gtk_widget_map")]
3610 fn map(&self) {
3611 unsafe {
3612 ffi::gtk_widget_map(self.as_ref().to_glib_none().0);
3613 }
3614 }
3615
3616 /// Emits the [`mnemonic-activate`][struct@crate::Widget#mnemonic-activate] signal.
3617 /// ## `group_cycling`
3618 /// [`true`] if there are other widgets with the same mnemonic
3619 ///
3620 /// # Returns
3621 ///
3622 /// [`true`] if the signal has been handled
3623 #[doc(alias = "gtk_widget_mnemonic_activate")]
3624 fn mnemonic_activate(&self, group_cycling: bool) -> bool {
3625 unsafe {
3626 from_glib(ffi::gtk_widget_mnemonic_activate(
3627 self.as_ref().to_glib_none().0,
3628 group_cycling.into_glib(),
3629 ))
3630 }
3631 }
3632
3633 /// This function is only for use in widget implementations.
3634 ///
3635 /// Flags the widget for a rerun of the GtkWidgetClass::size_allocate
3636 /// function. Use this function instead of [`queue_resize()`][Self::queue_resize()]
3637 /// when the `self`'s size request didn't change but it wants to
3638 /// reposition its contents.
3639 ///
3640 /// An example user of this function is [`set_halign()`][Self::set_halign()].
3641 #[doc(alias = "gtk_widget_queue_allocate")]
3642 fn queue_allocate(&self) {
3643 unsafe {
3644 ffi::gtk_widget_queue_allocate(self.as_ref().to_glib_none().0);
3645 }
3646 }
3647
3648 /// Mark `self` as needing to recompute its expand flags. Call
3649 /// this function when setting legacy expand child properties
3650 /// on the child of a container.
3651 ///
3652 /// See [`compute_expand()`][Self::compute_expand()].
3653 #[doc(alias = "gtk_widget_queue_compute_expand")]
3654 fn queue_compute_expand(&self) {
3655 unsafe {
3656 ffi::gtk_widget_queue_compute_expand(self.as_ref().to_glib_none().0);
3657 }
3658 }
3659
3660 /// Equivalent to calling [`queue_draw_area()`][Self::queue_draw_area()] for the
3661 /// entire area of a widget.
3662 #[doc(alias = "gtk_widget_queue_draw")]
3663 fn queue_draw(&self) {
3664 unsafe {
3665 ffi::gtk_widget_queue_draw(self.as_ref().to_glib_none().0);
3666 }
3667 }
3668
3669 /// allocation.y otherwise.
3670 ///
3671 /// `width` or `height` may be 0, in this case this function does
3672 /// nothing. Negative values for `width` and `height` are not allowed.
3673 /// ## `x`
3674 /// x coordinate of upper-left corner of rectangle to redraw
3675 /// ## `y`
3676 /// y coordinate of upper-left corner of rectangle to redraw
3677 /// ## `width`
3678 /// width of region to draw
3679 /// ## `height`
3680 /// height of region to draw
3681 #[doc(alias = "gtk_widget_queue_draw_area")]
3682 fn queue_draw_area(&self, x: i32, y: i32, width: i32, height: i32) {
3683 unsafe {
3684 ffi::gtk_widget_queue_draw_area(self.as_ref().to_glib_none().0, x, y, width, height);
3685 }
3686 }
3687
3688 /// Invalidates the area of `self` defined by `region` by calling
3689 /// [`Window::invalidate_region()`][crate::gdk::Window::invalidate_region()] on the widget’s window and all its
3690 /// child windows. Once the main loop becomes idle (after the current
3691 /// batch of events has been processed, roughly), the window will
3692 /// receive expose events for the union of all regions that have been
3693 /// invalidated.
3694 ///
3695 /// Normally you would only use this function in widget
3696 /// implementations. You might also use it to schedule a redraw of a
3697 /// [`DrawingArea`][crate::DrawingArea] or some portion thereof.
3698 /// ## `region`
3699 /// region to draw
3700 #[doc(alias = "gtk_widget_queue_draw_region")]
3701 fn queue_draw_region(&self, region: &cairo::Region) {
3702 unsafe {
3703 ffi::gtk_widget_queue_draw_region(
3704 self.as_ref().to_glib_none().0,
3705 region.to_glib_none().0,
3706 );
3707 }
3708 }
3709
3710 /// This function is only for use in widget implementations.
3711 /// Flags a widget to have its size renegotiated; should
3712 /// be called when a widget for some reason has a new size request.
3713 /// For example, when you change the text in a [`Label`][crate::Label], [`Label`][crate::Label]
3714 /// queues a resize to ensure there’s enough space for the new text.
3715 ///
3716 /// Note that you cannot call [`queue_resize()`][Self::queue_resize()] on a widget
3717 /// from inside its implementation of the GtkWidgetClass::size_allocate
3718 /// virtual method. Calls to [`queue_resize()`][Self::queue_resize()] from inside
3719 /// GtkWidgetClass::size_allocate will be silently ignored.
3720 #[doc(alias = "gtk_widget_queue_resize")]
3721 fn queue_resize(&self) {
3722 unsafe {
3723 ffi::gtk_widget_queue_resize(self.as_ref().to_glib_none().0);
3724 }
3725 }
3726
3727 /// This function works like [`queue_resize()`][Self::queue_resize()],
3728 /// except that the widget is not invalidated.
3729 #[doc(alias = "gtk_widget_queue_resize_no_redraw")]
3730 fn queue_resize_no_redraw(&self) {
3731 unsafe {
3732 ffi::gtk_widget_queue_resize_no_redraw(self.as_ref().to_glib_none().0);
3733 }
3734 }
3735
3736 /// window will be created when a widget
3737 /// is realized. Normally realization happens implicitly; if you show
3738 /// a widget and all its parent containers, then the widget will be
3739 /// realized and mapped automatically.
3740 ///
3741 /// Realizing a widget requires all
3742 /// the widget’s parent widgets to be realized; calling
3743 /// [`realize()`][Self::realize()] realizes the widget’s parents in addition to
3744 /// `self` itself. If a widget is not yet inside a toplevel window
3745 /// when you realize it, bad things will happen.
3746 ///
3747 /// This function is primarily used in widget implementations, and
3748 /// isn’t very useful otherwise. Many times when you think you might
3749 /// need it, a better approach is to connect to a signal that will be
3750 /// called after the widget is realized automatically, such as
3751 /// [`draw`][struct@crate::Widget#draw]. Or simply g_signal_connect () to the
3752 /// [`realize`][struct@crate::Widget#realize] signal.
3753 #[doc(alias = "gtk_widget_realize")]
3754 fn realize(&self) {
3755 unsafe {
3756 ffi::gtk_widget_realize(self.as_ref().to_glib_none().0);
3757 }
3758 }
3759
3760 /// Registers a [`gdk::Window`][crate::gdk::Window] with the widget and sets it up so that
3761 /// the widget receives events for it. Call [`unregister_window()`][Self::unregister_window()]
3762 /// when destroying the window.
3763 ///
3764 /// Before 3.8 you needed to call [`Window::set_user_data()`][crate::gdk::Window::set_user_data()] directly to set
3765 /// this up. This is now deprecated and you should use [`register_window()`][Self::register_window()]
3766 /// instead. Old code will keep working as is, although some new features like
3767 /// transparency might not work perfectly.
3768 /// ## `window`
3769 /// a [`gdk::Window`][crate::gdk::Window]
3770 #[doc(alias = "gtk_widget_register_window")]
3771 fn register_window(&self, window: &gdk::Window) {
3772 unsafe {
3773 ffi::gtk_widget_register_window(
3774 self.as_ref().to_glib_none().0,
3775 window.to_glib_none().0,
3776 );
3777 }
3778 }
3779
3780 /// Removes an accelerator from `self`, previously installed with
3781 /// [`add_accelerator()`][Self::add_accelerator()].
3782 /// ## `accel_group`
3783 /// accel group for this widget
3784 /// ## `accel_key`
3785 /// GDK keyval of the accelerator
3786 /// ## `accel_mods`
3787 /// modifier key combination of the accelerator
3788 ///
3789 /// # Returns
3790 ///
3791 /// whether an accelerator was installed and could be removed
3792 #[doc(alias = "gtk_widget_remove_accelerator")]
3793 fn remove_accelerator(
3794 &self,
3795 accel_group: &impl IsA<AccelGroup>,
3796 accel_key: u32,
3797 accel_mods: gdk::ModifierType,
3798 ) -> bool {
3799 unsafe {
3800 from_glib(ffi::gtk_widget_remove_accelerator(
3801 self.as_ref().to_glib_none().0,
3802 accel_group.as_ref().to_glib_none().0,
3803 accel_key,
3804 accel_mods.into_glib(),
3805 ))
3806 }
3807 }
3808
3809 /// Removes a widget from the list of mnemonic labels for
3810 /// this widget. (See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()]). The widget
3811 /// must have previously been added to the list with
3812 /// [`add_mnemonic_label()`][Self::add_mnemonic_label()].
3813 /// ## `label`
3814 /// a [`Widget`][crate::Widget] that was previously set as a mnemonic label for
3815 /// `self` with [`add_mnemonic_label()`][Self::add_mnemonic_label()].
3816 #[doc(alias = "gtk_widget_remove_mnemonic_label")]
3817 fn remove_mnemonic_label(&self, label: &impl IsA<Widget>) {
3818 unsafe {
3819 ffi::gtk_widget_remove_mnemonic_label(
3820 self.as_ref().to_glib_none().0,
3821 label.as_ref().to_glib_none().0,
3822 );
3823 }
3824 }
3825
3826 /// Updates the style context of `self` and all descendants
3827 /// by updating its widget path. `GtkContainers` may want
3828 /// to use this on a child when reordering it in a way that a different
3829 /// style might apply to it. See also [`ContainerExt::path_for_child()`][crate::prelude::ContainerExt::path_for_child()].
3830 #[doc(alias = "gtk_widget_reset_style")]
3831 fn reset_style(&self) {
3832 unsafe {
3833 ffi::gtk_widget_reset_style(self.as_ref().to_glib_none().0);
3834 }
3835 }
3836
3837 /// focus_change.window);
3838 ///
3839 /// gtk_widget_send_focus_change (widget, fevent);
3840 ///
3841 /// gdk_event_free (event);
3842 /// ]|
3843 /// ## `event`
3844 /// a `GdkEvent` of type GDK_FOCUS_CHANGE
3845 ///
3846 /// # Returns
3847 ///
3848 /// the return value from the event signal emission: [`true`]
3849 /// if the event was handled, and [`false`] otherwise
3850 #[doc(alias = "gtk_widget_send_focus_change")]
3851 fn send_focus_change(&self, event: &gdk::Event) -> bool {
3852 unsafe {
3853 from_glib(ffi::gtk_widget_send_focus_change(
3854 self.as_ref().to_glib_none().0,
3855 mut_override(event.to_glib_none().0),
3856 ))
3857 }
3858 }
3859
3860 /// Given an accelerator group, `accel_group`, and an accelerator path,
3861 /// `accel_path`, sets up an accelerator in `accel_group` so whenever the
3862 /// key binding that is defined for `accel_path` is pressed, `self`
3863 /// will be activated. This removes any accelerators (for any
3864 /// accelerator group) installed by previous calls to
3865 /// [`set_accel_path()`][Self::set_accel_path()]. Associating accelerators with
3866 /// paths allows them to be modified by the user and the modifications
3867 /// to be saved for future use. (See `gtk_accel_map_save()`.)
3868 ///
3869 /// This function is a low level function that would most likely
3870 /// be used by a menu creation system like `GtkUIManager`. If you
3871 /// use `GtkUIManager`, setting up accelerator paths will be done
3872 /// automatically.
3873 ///
3874 /// Even when you you aren’t using `GtkUIManager`, if you only want to
3875 /// set up accelerators on menu items [`GtkMenuItemExt::set_accel_path()`][crate::prelude::GtkMenuItemExt::set_accel_path()]
3876 /// provides a somewhat more convenient interface.
3877 ///
3878 /// Note that `accel_path` string will be stored in a `GQuark`. Therefore, if you
3879 /// pass a static string, you can save some memory by interning it first with
3880 /// `g_intern_static_string()`.
3881 /// ## `accel_path`
3882 /// path used to look up the accelerator
3883 /// ## `accel_group`
3884 /// a [`AccelGroup`][crate::AccelGroup].
3885 #[doc(alias = "gtk_widget_set_accel_path")]
3886 fn set_accel_path(&self, accel_path: Option<&str>, accel_group: Option<&impl IsA<AccelGroup>>) {
3887 unsafe {
3888 ffi::gtk_widget_set_accel_path(
3889 self.as_ref().to_glib_none().0,
3890 accel_path.to_glib_none().0,
3891 accel_group.map(|p| p.as_ref()).to_glib_none().0,
3892 );
3893 }
3894 }
3895
3896 /// Sets the widget’s allocation. This should not be used
3897 /// directly, but from within a widget’s size_allocate method.
3898 ///
3899 /// The allocation set should be the “adjusted” or actual
3900 /// allocation. If you’re implementing a [`Container`][crate::Container], you want to use
3901 /// [`size_allocate()`][Self::size_allocate()] instead of [`set_allocation()`][Self::set_allocation()].
3902 /// The GtkWidgetClass::adjust_size_allocation virtual method adjusts the
3903 /// allocation inside [`size_allocate()`][Self::size_allocate()] to create an adjusted
3904 /// allocation.
3905 /// ## `allocation`
3906 /// a pointer to a `GtkAllocation` to copy from
3907 #[doc(alias = "gtk_widget_set_allocation")]
3908 fn set_allocation(&self, allocation: &Allocation) {
3909 unsafe {
3910 ffi::gtk_widget_set_allocation(
3911 self.as_ref().to_glib_none().0,
3912 allocation.to_glib_none().0,
3913 );
3914 }
3915 }
3916
3917 /// Sets whether the application intends to draw on the widget in
3918 /// an [`draw`][struct@crate::Widget#draw] handler.
3919 ///
3920 /// This is a hint to the widget and does not affect the behavior of
3921 /// the GTK+ core; many widgets ignore this flag entirely. For widgets
3922 /// that do pay attention to the flag, such as [`EventBox`][crate::EventBox] and [`Window`][crate::Window],
3923 /// the effect is to suppress default themed drawing of the widget's
3924 /// background. (Children of the widget will still be drawn.) The application
3925 /// is then entirely responsible for drawing the widget background.
3926 ///
3927 /// Note that the background is still drawn when the widget is mapped.
3928 /// ## `app_paintable`
3929 /// [`true`] if the application will paint on the widget
3930 #[doc(alias = "gtk_widget_set_app_paintable")]
3931 #[doc(alias = "app-paintable")]
3932 fn set_app_paintable(&self, app_paintable: bool) {
3933 unsafe {
3934 ffi::gtk_widget_set_app_paintable(
3935 self.as_ref().to_glib_none().0,
3936 app_paintable.into_glib(),
3937 );
3938 }
3939 }
3940
3941 /// Specifies whether `self` can be a default widget. See
3942 /// [`grab_default()`][Self::grab_default()] for details about the meaning of
3943 /// “default”.
3944 /// ## `can_default`
3945 /// whether or not `self` can be a default widget.
3946 #[doc(alias = "gtk_widget_set_can_default")]
3947 #[doc(alias = "can-default")]
3948 fn set_can_default(&self, can_default: bool) {
3949 unsafe {
3950 ffi::gtk_widget_set_can_default(
3951 self.as_ref().to_glib_none().0,
3952 can_default.into_glib(),
3953 );
3954 }
3955 }
3956
3957 /// Specifies whether `self` can own the input focus. See
3958 /// [`grab_focus()`][Self::grab_focus()] for actually setting the input focus on a
3959 /// widget.
3960 /// ## `can_focus`
3961 /// whether or not `self` can own the input focus.
3962 #[doc(alias = "gtk_widget_set_can_focus")]
3963 #[doc(alias = "can-focus")]
3964 fn set_can_focus(&self, can_focus: bool) {
3965 unsafe {
3966 ffi::gtk_widget_set_can_focus(self.as_ref().to_glib_none().0, can_focus.into_glib());
3967 }
3968 }
3969
3970 /// Sets whether `self` should be mapped along with its when its parent
3971 /// is mapped and `self` has been shown with [`show()`][Self::show()].
3972 ///
3973 /// The child visibility can be set for widget before it is added to
3974 /// a container with [`set_parent()`][Self::set_parent()], to avoid mapping
3975 /// children unnecessary before immediately unmapping them. However
3976 /// it will be reset to its default state of [`true`] when the widget
3977 /// is removed from a container.
3978 ///
3979 /// Note that changing the child visibility of a widget does not
3980 /// queue a resize on the widget. Most of the time, the size of
3981 /// a widget is computed from all visible children, whether or
3982 /// not they are mapped. If this is not the case, the container
3983 /// can queue a resize itself.
3984 ///
3985 /// This function is only useful for container implementations and
3986 /// never should be called by an application.
3987 /// ## `is_visible`
3988 /// if [`true`], `self` should be mapped along with its parent.
3989 #[doc(alias = "gtk_widget_set_child_visible")]
3990 fn set_child_visible(&self, is_visible: bool) {
3991 unsafe {
3992 ffi::gtk_widget_set_child_visible(
3993 self.as_ref().to_glib_none().0,
3994 is_visible.into_glib(),
3995 );
3996 }
3997 }
3998
3999 /// Sets the widget’s clip. This must not be used directly,
4000 /// but from within a widget’s size_allocate method.
4001 /// It must be called after [`set_allocation()`][Self::set_allocation()] (or after chaining up
4002 /// to the parent class), because that function resets the clip.
4003 ///
4004 /// The clip set should be the area that `self` draws on. If `self` is a
4005 /// [`Container`][crate::Container], the area must contain all children's clips.
4006 ///
4007 /// If this function is not called by `self` during a ::size-allocate handler,
4008 /// the clip will be set to `self`'s allocation.
4009 /// ## `clip`
4010 /// a pointer to a `GtkAllocation` to copy from
4011 #[doc(alias = "gtk_widget_set_clip")]
4012 fn set_clip(&self, clip: &Allocation) {
4013 unsafe {
4014 ffi::gtk_widget_set_clip(self.as_ref().to_glib_none().0, clip.to_glib_none().0);
4015 }
4016 }
4017
4018 /// Enables or disables a [`gdk::Device`][crate::gdk::Device] to interact with `self`
4019 /// and all its children.
4020 ///
4021 /// It does so by descending through the [`gdk::Window`][crate::gdk::Window] hierarchy
4022 /// and enabling the same mask that is has for core events
4023 /// (i.e. the one that [`Window::events()`][crate::gdk::Window::events()] returns).
4024 /// ## `device`
4025 /// a [`gdk::Device`][crate::gdk::Device]
4026 /// ## `enabled`
4027 /// whether to enable the device
4028 #[doc(alias = "gtk_widget_set_device_enabled")]
4029 fn set_device_enabled(&self, device: &gdk::Device, enabled: bool) {
4030 unsafe {
4031 ffi::gtk_widget_set_device_enabled(
4032 self.as_ref().to_glib_none().0,
4033 device.to_glib_none().0,
4034 enabled.into_glib(),
4035 );
4036 }
4037 }
4038
4039 /// Sets the device event mask (see [`gdk::EventMask`][crate::gdk::EventMask]) for a widget. The event
4040 /// mask determines which events a widget will receive from `device`. Keep
4041 /// in mind that different widgets have different default event masks, and by
4042 /// changing the event mask you may disrupt a widget’s functionality,
4043 /// so be careful. This function must be called while a widget is
4044 /// unrealized. Consider [`add_device_events()`][Self::add_device_events()] for widgets that are
4045 /// already realized, or if you want to preserve the existing event
4046 /// mask. This function can’t be used with windowless widgets (which return
4047 /// [`false`] from [`has_window()`][Self::has_window()]);
4048 /// to get events on those widgets, place them inside a [`EventBox`][crate::EventBox]
4049 /// and receive events on the event box.
4050 /// ## `device`
4051 /// a [`gdk::Device`][crate::gdk::Device]
4052 /// ## `events`
4053 /// event mask
4054 #[doc(alias = "gtk_widget_set_device_events")]
4055 fn set_device_events(&self, device: &gdk::Device, events: gdk::EventMask) {
4056 unsafe {
4057 ffi::gtk_widget_set_device_events(
4058 self.as_ref().to_glib_none().0,
4059 device.to_glib_none().0,
4060 events.into_glib(),
4061 );
4062 }
4063 }
4064
4065 /// Sets the reading direction on a particular widget. This direction
4066 /// controls the primary direction for widgets containing text,
4067 /// and also the direction in which the children of a container are
4068 /// packed. The ability to set the direction is present in order
4069 /// so that correct localization into languages with right-to-left
4070 /// reading directions can be done. Generally, applications will
4071 /// let the default reading direction present, except for containers
4072 /// where the containers are arranged in an order that is explicitly
4073 /// visual rather than logical (such as buttons for text justification).
4074 ///
4075 /// If the direction is set to [`TextDirection::None`][crate::TextDirection::None], then the value
4076 /// set by [`Widget::set_default_direction()`][crate::Widget::set_default_direction()] will be used.
4077 /// ## `dir`
4078 /// the new direction
4079 #[doc(alias = "gtk_widget_set_direction")]
4080 fn set_direction(&self, dir: TextDirection) {
4081 unsafe {
4082 ffi::gtk_widget_set_direction(self.as_ref().to_glib_none().0, dir.into_glib());
4083 }
4084 }
4085
4086 /// Sets whether the widget should grab focus when it is clicked with the mouse.
4087 /// Making mouse clicks not grab focus is useful in places like toolbars where
4088 /// you don’t want the keyboard focus removed from the main area of the
4089 /// application.
4090 /// ## `focus_on_click`
4091 /// whether the widget should grab focus when clicked with the mouse
4092 #[doc(alias = "gtk_widget_set_focus_on_click")]
4093 #[doc(alias = "focus-on-click")]
4094 fn set_focus_on_click(&self, focus_on_click: bool) {
4095 unsafe {
4096 ffi::gtk_widget_set_focus_on_click(
4097 self.as_ref().to_glib_none().0,
4098 focus_on_click.into_glib(),
4099 );
4100 }
4101 }
4102
4103 /// Sets the font map to use for Pango rendering. When not set, the widget
4104 /// will inherit the font map from its parent.
4105 /// ## `font_map`
4106 /// a [`pango::FontMap`][crate::pango::FontMap], or [`None`] to unset any previously
4107 /// set font map
4108 #[doc(alias = "gtk_widget_set_font_map")]
4109 fn set_font_map(&self, font_map: Option<&impl IsA<pango::FontMap>>) {
4110 unsafe {
4111 ffi::gtk_widget_set_font_map(
4112 self.as_ref().to_glib_none().0,
4113 font_map.map(|p| p.as_ref()).to_glib_none().0,
4114 );
4115 }
4116 }
4117
4118 /// Sets the [`cairo::FontOptions`][crate::cairo::FontOptions] used for Pango rendering in this widget.
4119 /// When not set, the default font options for the [`gdk::Screen`][crate::gdk::Screen] will be used.
4120 /// ## `options`
4121 /// a [`cairo::FontOptions`][crate::cairo::FontOptions], or [`None`] to unset any
4122 /// previously set default font options.
4123 #[doc(alias = "gtk_widget_set_font_options")]
4124 fn set_font_options(&self, options: Option<&cairo::FontOptions>) {
4125 unsafe {
4126 ffi::gtk_widget_set_font_options(
4127 self.as_ref().to_glib_none().0,
4128 options.to_glib_none().0,
4129 );
4130 }
4131 }
4132
4133 /// Sets the horizontal alignment of `self`.
4134 /// See the [`halign`][struct@crate::Widget#halign] property.
4135 /// ## `align`
4136 /// the horizontal alignment
4137 #[doc(alias = "gtk_widget_set_halign")]
4138 #[doc(alias = "halign")]
4139 fn set_halign(&self, align: Align) {
4140 unsafe {
4141 ffi::gtk_widget_set_halign(self.as_ref().to_glib_none().0, align.into_glib());
4142 }
4143 }
4144
4145 /// Sets the has-tooltip property on `self` to `has_tooltip`. See
4146 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] for more information.
4147 /// ## `has_tooltip`
4148 /// whether or not `self` has a tooltip.
4149 #[doc(alias = "gtk_widget_set_has_tooltip")]
4150 #[doc(alias = "has-tooltip")]
4151 fn set_has_tooltip(&self, has_tooltip: bool) {
4152 unsafe {
4153 ffi::gtk_widget_set_has_tooltip(
4154 self.as_ref().to_glib_none().0,
4155 has_tooltip.into_glib(),
4156 );
4157 }
4158 }
4159
4160 /// Specifies whether `self` has a [`gdk::Window`][crate::gdk::Window] of its own. Note that
4161 /// all realized widgets have a non-[`None`] “window” pointer
4162 /// ([`window()`][Self::window()] never returns a [`None`] window when a widget
4163 /// is realized), but for many of them it’s actually the [`gdk::Window`][crate::gdk::Window] of
4164 /// one of its parent widgets. Widgets that do not create a `window` for
4165 /// themselves in [`realize`][struct@crate::Widget#realize] must announce this by
4166 /// calling this function with `has_window` = [`false`].
4167 ///
4168 /// This function should only be called by widget implementations,
4169 /// and they should call it in their `init()` function.
4170 /// ## `has_window`
4171 /// whether or not `self` has a window.
4172 #[doc(alias = "gtk_widget_set_has_window")]
4173 fn set_has_window(&self, has_window: bool) {
4174 unsafe {
4175 ffi::gtk_widget_set_has_window(self.as_ref().to_glib_none().0, has_window.into_glib());
4176 }
4177 }
4178
4179 /// Sets whether the widget would like any available extra horizontal
4180 /// space. When a user resizes a [`Window`][crate::Window], widgets with expand=TRUE
4181 /// generally receive the extra space. For example, a list or
4182 /// scrollable area or document in your window would often be set to
4183 /// expand.
4184 ///
4185 /// Call this function to set the expand flag if you would like your
4186 /// widget to become larger horizontally when the window has extra
4187 /// room.
4188 ///
4189 /// By default, widgets automatically expand if any of their children
4190 /// want to expand. (To see if a widget will automatically expand given
4191 /// its current children and state, call [`compute_expand()`][Self::compute_expand()]. A
4192 /// container can decide how the expandability of children affects the
4193 /// expansion of the container by overriding the compute_expand virtual
4194 /// method on [`Widget`][crate::Widget].).
4195 ///
4196 /// Setting hexpand explicitly with this function will override the
4197 /// automatic expand behavior.
4198 ///
4199 /// This function forces the widget to expand or not to expand,
4200 /// regardless of children. The override occurs because
4201 /// [`set_hexpand()`][Self::set_hexpand()] sets the hexpand-set property (see
4202 /// [`set_hexpand_set()`][Self::set_hexpand_set()]) which causes the widget’s hexpand
4203 /// value to be used, rather than looking at children and widget state.
4204 /// ## `expand`
4205 /// whether to expand
4206 #[doc(alias = "gtk_widget_set_hexpand")]
4207 #[doc(alias = "hexpand")]
4208 fn set_hexpand(&self, expand: bool) {
4209 unsafe {
4210 ffi::gtk_widget_set_hexpand(self.as_ref().to_glib_none().0, expand.into_glib());
4211 }
4212 }
4213
4214 /// Sets whether the hexpand flag (see [`hexpands()`][Self::hexpands()]) will
4215 /// be used.
4216 ///
4217 /// The hexpand-set property will be set automatically when you call
4218 /// [`set_hexpand()`][Self::set_hexpand()] to set hexpand, so the most likely
4219 /// reason to use this function would be to unset an explicit expand
4220 /// flag.
4221 ///
4222 /// If hexpand is set, then it overrides any computed
4223 /// expand value based on child widgets. If hexpand is not
4224 /// set, then the expand value depends on whether any
4225 /// children of the widget would like to expand.
4226 ///
4227 /// There are few reasons to use this function, but it’s here
4228 /// for completeness and consistency.
4229 /// ## `set`
4230 /// value for hexpand-set property
4231 #[doc(alias = "gtk_widget_set_hexpand_set")]
4232 #[doc(alias = "hexpand-set")]
4233 fn set_hexpand_set(&self, set: bool) {
4234 unsafe {
4235 ffi::gtk_widget_set_hexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
4236 }
4237 }
4238
4239 /// Marks the widget as being mapped.
4240 ///
4241 /// This function should only ever be called in a derived widget's
4242 /// “map” or “unmap” implementation.
4243 /// ## `mapped`
4244 /// [`true`] to mark the widget as mapped
4245 #[doc(alias = "gtk_widget_set_mapped")]
4246 fn set_mapped(&self, mapped: bool) {
4247 unsafe {
4248 ffi::gtk_widget_set_mapped(self.as_ref().to_glib_none().0, mapped.into_glib());
4249 }
4250 }
4251
4252 /// Sets the bottom margin of `self`.
4253 /// See the [`margin-bottom`][struct@crate::Widget#margin-bottom] property.
4254 /// ## `margin`
4255 /// the bottom margin
4256 #[doc(alias = "gtk_widget_set_margin_bottom")]
4257 #[doc(alias = "margin-bottom")]
4258 fn set_margin_bottom(&self, margin: i32) {
4259 unsafe {
4260 ffi::gtk_widget_set_margin_bottom(self.as_ref().to_glib_none().0, margin);
4261 }
4262 }
4263
4264 /// Sets the end margin of `self`.
4265 /// See the [`margin-end`][struct@crate::Widget#margin-end] property.
4266 /// ## `margin`
4267 /// the end margin
4268 #[doc(alias = "gtk_widget_set_margin_end")]
4269 #[doc(alias = "margin-end")]
4270 fn set_margin_end(&self, margin: i32) {
4271 unsafe {
4272 ffi::gtk_widget_set_margin_end(self.as_ref().to_glib_none().0, margin);
4273 }
4274 }
4275
4276 /// Sets the start margin of `self`.
4277 /// See the [`margin-start`][struct@crate::Widget#margin-start] property.
4278 /// ## `margin`
4279 /// the start margin
4280 #[doc(alias = "gtk_widget_set_margin_start")]
4281 #[doc(alias = "margin-start")]
4282 fn set_margin_start(&self, margin: i32) {
4283 unsafe {
4284 ffi::gtk_widget_set_margin_start(self.as_ref().to_glib_none().0, margin);
4285 }
4286 }
4287
4288 /// Sets the top margin of `self`.
4289 /// See the [`margin-top`][struct@crate::Widget#margin-top] property.
4290 /// ## `margin`
4291 /// the top margin
4292 #[doc(alias = "gtk_widget_set_margin_top")]
4293 #[doc(alias = "margin-top")]
4294 fn set_margin_top(&self, margin: i32) {
4295 unsafe {
4296 ffi::gtk_widget_set_margin_top(self.as_ref().to_glib_none().0, margin);
4297 }
4298 }
4299
4300 /// , *...), so using
4301 /// these will make your widget impossible to match by name. Any combination
4302 /// of alphanumeric symbols, dashes and underscores will suffice.
4303 /// ## `name`
4304 /// name for the widget
4305 #[doc(alias = "gtk_widget_set_name")]
4306 #[doc(alias = "set_name")]
4307 #[doc(alias = "name")]
4308 fn set_widget_name(&self, name: &str) {
4309 unsafe {
4310 ffi::gtk_widget_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
4311 }
4312 }
4313
4314 /// Sets the [`no-show-all`][struct@crate::Widget#no-show-all] property, which determines whether
4315 /// calls to [`show_all()`][Self::show_all()] will affect this widget.
4316 ///
4317 /// This is mostly for use in constructing widget hierarchies with externally
4318 /// controlled visibility, see `GtkUIManager`.
4319 /// ## `no_show_all`
4320 /// the new value for the “no-show-all” property
4321 #[doc(alias = "gtk_widget_set_no_show_all")]
4322 #[doc(alias = "no-show-all")]
4323 fn set_no_show_all(&self, no_show_all: bool) {
4324 unsafe {
4325 ffi::gtk_widget_set_no_show_all(
4326 self.as_ref().to_glib_none().0,
4327 no_show_all.into_glib(),
4328 );
4329 }
4330 }
4331
4332 /// Request the `self` to be rendered partially transparent,
4333 /// with opacity 0 being fully transparent and 1 fully opaque. (Opacity values
4334 /// are clamped to the [0,1] range.).
4335 /// This works on both toplevel widget, and child widgets, although there
4336 /// are some limitations:
4337 ///
4338 /// For toplevel widgets this depends on the capabilities of the windowing
4339 /// system. On X11 this has any effect only on X screens with a compositing manager
4340 /// running. See `gtk_widget_is_composited()`. On Windows it should work
4341 /// always, although setting a window’s opacity after the window has been
4342 /// shown causes it to flicker once on Windows.
4343 ///
4344 /// For child widgets it doesn’t work if any affected widget has a native window, or
4345 /// disables double buffering.
4346 /// ## `opacity`
4347 /// desired opacity, between 0 and 1
4348 #[doc(alias = "gtk_widget_set_opacity")]
4349 #[doc(alias = "opacity")]
4350 fn set_opacity(&self, opacity: f64) {
4351 unsafe {
4352 ffi::gtk_widget_set_opacity(self.as_ref().to_glib_none().0, opacity);
4353 }
4354 }
4355
4356 /// This function is useful only when implementing subclasses of
4357 /// [`Container`][crate::Container].
4358 /// Sets the container as the parent of `self`, and takes care of
4359 /// some details such as updating the state and style of the child
4360 /// to reflect its new location. The opposite function is
4361 /// [`unparent()`][Self::unparent()].
4362 /// ## `parent`
4363 /// parent container
4364 #[doc(alias = "gtk_widget_set_parent")]
4365 #[doc(alias = "parent")]
4366 fn set_parent(&self, parent: &impl IsA<Widget>) {
4367 unsafe {
4368 ffi::gtk_widget_set_parent(
4369 self.as_ref().to_glib_none().0,
4370 parent.as_ref().to_glib_none().0,
4371 );
4372 }
4373 }
4374
4375 /// Sets a non default parent window for `self`.
4376 ///
4377 /// For [`Window`][crate::Window] classes, setting a `parent_window` effects whether
4378 /// the window is a toplevel window or can be embedded into other
4379 /// widgets.
4380 ///
4381 /// For [`Window`][crate::Window] classes, this needs to be called before the
4382 /// window is realized.
4383 /// ## `parent_window`
4384 /// the new parent window.
4385 #[doc(alias = "gtk_widget_set_parent_window")]
4386 fn set_parent_window(&self, parent_window: &gdk::Window) {
4387 unsafe {
4388 ffi::gtk_widget_set_parent_window(
4389 self.as_ref().to_glib_none().0,
4390 parent_window.to_glib_none().0,
4391 );
4392 }
4393 }
4394
4395 /// Marks the widget as being realized. This function must only be
4396 /// called after all `GdkWindows` for the `self` have been created
4397 /// and registered.
4398 ///
4399 /// This function should only ever be called in a derived widget's
4400 /// “realize” or “unrealize” implementation.
4401 /// ## `realized`
4402 /// [`true`] to mark the widget as realized
4403 #[doc(alias = "gtk_widget_set_realized")]
4404 fn set_realized(&self, realized: bool) {
4405 unsafe {
4406 ffi::gtk_widget_set_realized(self.as_ref().to_glib_none().0, realized.into_glib());
4407 }
4408 }
4409
4410 /// Specifies whether `self` will be treated as the default widget
4411 /// within its toplevel when it has the focus, even if another widget
4412 /// is the default.
4413 ///
4414 /// See [`grab_default()`][Self::grab_default()] for details about the meaning of
4415 /// “default”.
4416 /// ## `receives_default`
4417 /// whether or not `self` can be a default widget.
4418 #[doc(alias = "gtk_widget_set_receives_default")]
4419 #[doc(alias = "receives-default")]
4420 fn set_receives_default(&self, receives_default: bool) {
4421 unsafe {
4422 ffi::gtk_widget_set_receives_default(
4423 self.as_ref().to_glib_none().0,
4424 receives_default.into_glib(),
4425 );
4426 }
4427 }
4428
4429 /// window, you are
4430 /// responsible for invalidating both the old and new allocation of the
4431 /// widget when the widget is moved and responsible for invalidating
4432 /// regions newly when the widget increases size.
4433 /// ## `redraw_on_allocate`
4434 /// if [`true`], the entire widget will be redrawn
4435 /// when it is allocated to a new size. Otherwise, only the
4436 /// new portion of the widget will be redrawn.
4437 #[doc(alias = "gtk_widget_set_redraw_on_allocate")]
4438 fn set_redraw_on_allocate(&self, redraw_on_allocate: bool) {
4439 unsafe {
4440 ffi::gtk_widget_set_redraw_on_allocate(
4441 self.as_ref().to_glib_none().0,
4442 redraw_on_allocate.into_glib(),
4443 );
4444 }
4445 }
4446
4447 /// Sets the sensitivity of a widget. A widget is sensitive if the user
4448 /// can interact with it. Insensitive widgets are “grayed out” and the
4449 /// user can’t interact with them. Insensitive widgets are known as
4450 /// “inactive”, “disabled”, or “ghosted” in some other toolkits.
4451 /// ## `sensitive`
4452 /// [`true`] to make the widget sensitive
4453 #[doc(alias = "gtk_widget_set_sensitive")]
4454 #[doc(alias = "sensitive")]
4455 fn set_sensitive(&self, sensitive: bool) {
4456 unsafe {
4457 ffi::gtk_widget_set_sensitive(self.as_ref().to_glib_none().0, sensitive.into_glib());
4458 }
4459 }
4460
4461 /// Sets the minimum size of a widget; that is, the widget’s size
4462 /// request will be at least `width` by `height`. You can use this
4463 /// function to force a widget to be larger than it normally would be.
4464 ///
4465 /// In most cases, [`GtkWindowExt::set_default_size()`][crate::prelude::GtkWindowExt::set_default_size()] is a better choice for
4466 /// toplevel windows than this function; setting the default size will
4467 /// still allow users to shrink the window. Setting the size request
4468 /// will force them to leave the window at least as large as the size
4469 /// request. When dealing with window sizes,
4470 /// [`GtkWindowExt::set_geometry_hints()`][crate::prelude::GtkWindowExt::set_geometry_hints()] can be a useful function as well.
4471 ///
4472 /// Note the inherent danger of setting any fixed size - themes,
4473 /// translations into other languages, different fonts, and user action
4474 /// can all change the appropriate size for a given widget. So, it's
4475 /// basically impossible to hardcode a size that will always be
4476 /// correct.
4477 ///
4478 /// The size request of a widget is the smallest size a widget can
4479 /// accept while still functioning well and drawing itself correctly.
4480 /// However in some strange cases a widget may be allocated less than
4481 /// its requested size, and in many cases a widget may be allocated more
4482 /// space than it requested.
4483 ///
4484 /// If the size request in a given direction is -1 (unset), then
4485 /// the “natural” size request of the widget will be used instead.
4486 ///
4487 /// The size request set here does not include any margin from the
4488 /// [`Widget`][crate::Widget] properties margin-left, margin-right, margin-top, and
4489 /// margin-bottom, but it does include pretty much all other padding
4490 /// or border properties set by any subclass of [`Widget`][crate::Widget].
4491 /// ## `width`
4492 /// width `self` should request, or -1 to unset
4493 /// ## `height`
4494 /// height `self` should request, or -1 to unset
4495 #[doc(alias = "gtk_widget_set_size_request")]
4496 fn set_size_request(&self, width: i32, height: i32) {
4497 unsafe {
4498 ffi::gtk_widget_set_size_request(self.as_ref().to_glib_none().0, width, height);
4499 }
4500 }
4501
4502 /// This function is for use in widget implementations. Turns on flag
4503 /// values in the current widget state (insensitive, prelighted, etc.).
4504 ///
4505 /// This function accepts the values [`StateFlags::DIR_LTR`][crate::StateFlags::DIR_LTR] and
4506 /// [`StateFlags::DIR_RTL`][crate::StateFlags::DIR_RTL] but ignores them. If you want to set the widget's
4507 /// direction, use [`set_direction()`][Self::set_direction()].
4508 ///
4509 /// It is worth mentioning that any other state than [`StateFlags::INSENSITIVE`][crate::StateFlags::INSENSITIVE],
4510 /// will be propagated down to all non-internal children if `self` is a
4511 /// [`Container`][crate::Container], while [`StateFlags::INSENSITIVE`][crate::StateFlags::INSENSITIVE] itself will be propagated
4512 /// down to all [`Container`][crate::Container] children by different means than turning on the
4513 /// state flag down the hierarchy, both [`state_flags()`][Self::state_flags()] and
4514 /// [`is_sensitive()`][Self::is_sensitive()] will make use of these.
4515 /// ## `flags`
4516 /// State flags to turn on
4517 /// ## `clear`
4518 /// Whether to clear state before turning on `flags`
4519 #[doc(alias = "gtk_widget_set_state_flags")]
4520 fn set_state_flags(&self, flags: StateFlags, clear: bool) {
4521 unsafe {
4522 ffi::gtk_widget_set_state_flags(
4523 self.as_ref().to_glib_none().0,
4524 flags.into_glib(),
4525 clear.into_glib(),
4526 );
4527 }
4528 }
4529
4530 /// Enables or disables multiple pointer awareness. If this setting is [`true`],
4531 /// `self` will start receiving multiple, per device enter/leave events. Note
4532 /// that if custom `GdkWindows` are created in [`realize`][struct@crate::Widget#realize],
4533 /// [`Window::set_support_multidevice()`][crate::gdk::Window::set_support_multidevice()] will have to be called manually on them.
4534 /// ## `support_multidevice`
4535 /// [`true`] to support input from multiple devices.
4536 #[doc(alias = "gtk_widget_set_support_multidevice")]
4537 fn set_support_multidevice(&self, support_multidevice: bool) {
4538 unsafe {
4539 ffi::gtk_widget_set_support_multidevice(
4540 self.as_ref().to_glib_none().0,
4541 support_multidevice.into_glib(),
4542 );
4543 }
4544 }
4545
4546 /// Sets `markup` as the contents of the tooltip, which is marked up with
4547 /// the [Pango text markup language][PangoMarkupFormat].
4548 ///
4549 /// This function will take care of setting [`has-tooltip`][struct@crate::Widget#has-tooltip] to [`true`]
4550 /// and of the default handler for the [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
4551 ///
4552 /// See also the [`tooltip-markup`][struct@crate::Widget#tooltip-markup] property and
4553 /// [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
4554 /// ## `markup`
4555 /// the contents of the tooltip for `self`, or [`None`]
4556 #[doc(alias = "gtk_widget_set_tooltip_markup")]
4557 #[doc(alias = "tooltip-markup")]
4558 fn set_tooltip_markup(&self, markup: Option<&str>) {
4559 unsafe {
4560 ffi::gtk_widget_set_tooltip_markup(
4561 self.as_ref().to_glib_none().0,
4562 markup.to_glib_none().0,
4563 );
4564 }
4565 }
4566
4567 /// Sets `text` as the contents of the tooltip. This function will take
4568 /// care of setting [`has-tooltip`][struct@crate::Widget#has-tooltip] to [`true`] and of the default
4569 /// handler for the [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
4570 ///
4571 /// See also the [`tooltip-text`][struct@crate::Widget#tooltip-text] property and [`Tooltip::set_text()`][crate::Tooltip::set_text()].
4572 /// ## `text`
4573 /// the contents of the tooltip for `self`
4574 #[doc(alias = "gtk_widget_set_tooltip_text")]
4575 #[doc(alias = "tooltip-text")]
4576 fn set_tooltip_text(&self, text: Option<&str>) {
4577 unsafe {
4578 ffi::gtk_widget_set_tooltip_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
4579 }
4580 }
4581
4582 /// Replaces the default window used for displaying
4583 /// tooltips with `custom_window`. GTK+ will take care of showing and
4584 /// hiding `custom_window` at the right moment, to behave likewise as
4585 /// the default tooltip window. If `custom_window` is [`None`], the default
4586 /// tooltip window will be used.
4587 /// ## `custom_window`
4588 /// a [`Window`][crate::Window], or [`None`]
4589 #[doc(alias = "gtk_widget_set_tooltip_window")]
4590 fn set_tooltip_window(&self, custom_window: Option<&impl IsA<Window>>) {
4591 unsafe {
4592 ffi::gtk_widget_set_tooltip_window(
4593 self.as_ref().to_glib_none().0,
4594 custom_window.map(|p| p.as_ref()).to_glib_none().0,
4595 );
4596 }
4597 }
4598
4599 /// Sets the vertical alignment of `self`.
4600 /// See the [`valign`][struct@crate::Widget#valign] property.
4601 /// ## `align`
4602 /// the vertical alignment
4603 #[doc(alias = "gtk_widget_set_valign")]
4604 #[doc(alias = "valign")]
4605 fn set_valign(&self, align: Align) {
4606 unsafe {
4607 ffi::gtk_widget_set_valign(self.as_ref().to_glib_none().0, align.into_glib());
4608 }
4609 }
4610
4611 /// Sets whether the widget would like any available extra vertical
4612 /// space.
4613 ///
4614 /// See [`set_hexpand()`][Self::set_hexpand()] for more detail.
4615 /// ## `expand`
4616 /// whether to expand
4617 #[doc(alias = "gtk_widget_set_vexpand")]
4618 #[doc(alias = "vexpand")]
4619 fn set_vexpand(&self, expand: bool) {
4620 unsafe {
4621 ffi::gtk_widget_set_vexpand(self.as_ref().to_glib_none().0, expand.into_glib());
4622 }
4623 }
4624
4625 /// Sets whether the vexpand flag (see [`vexpands()`][Self::vexpands()]) will
4626 /// be used.
4627 ///
4628 /// See [`set_hexpand_set()`][Self::set_hexpand_set()] for more detail.
4629 /// ## `set`
4630 /// value for vexpand-set property
4631 #[doc(alias = "gtk_widget_set_vexpand_set")]
4632 #[doc(alias = "vexpand-set")]
4633 fn set_vexpand_set(&self, set: bool) {
4634 unsafe {
4635 ffi::gtk_widget_set_vexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
4636 }
4637 }
4638
4639 /// Sets the visibility state of `self`. Note that setting this to
4640 /// [`true`] doesn’t mean the widget is actually viewable, see
4641 /// [`get_visible()`][Self::get_visible()].
4642 ///
4643 /// This function simply calls [`show()`][Self::show()] or [`hide()`][Self::hide()]
4644 /// but is nicer to use when the visibility of the widget depends on
4645 /// some condition.
4646 /// ## `visible`
4647 /// whether the widget should be shown or not
4648 #[doc(alias = "gtk_widget_set_visible")]
4649 #[doc(alias = "visible")]
4650 fn set_visible(&self, visible: bool) {
4651 unsafe {
4652 ffi::gtk_widget_set_visible(self.as_ref().to_glib_none().0, visible.into_glib());
4653 }
4654 }
4655
4656 /// Sets the visual that should be used for by widget and its children for
4657 /// creating `GdkWindows`. The visual must be on the same [`gdk::Screen`][crate::gdk::Screen] as
4658 /// returned by [`screen()`][Self::screen()], so handling the
4659 /// [`screen-changed`][struct@crate::Widget#screen-changed] signal is necessary.
4660 ///
4661 /// Setting a new `visual` will not cause `self` to recreate its windows,
4662 /// so you should call this function before `self` is realized.
4663 /// ## `visual`
4664 /// visual to be used or [`None`] to unset a previous one
4665 #[doc(alias = "gtk_widget_set_visual")]
4666 fn set_visual(&self, visual: Option<&gdk::Visual>) {
4667 unsafe {
4668 ffi::gtk_widget_set_visual(self.as_ref().to_glib_none().0, visual.to_glib_none().0);
4669 }
4670 }
4671
4672 /// Sets a widget’s window. This function should only be used in a
4673 /// widget’s [`realize`][struct@crate::Widget#realize] implementation. The `window` passed is
4674 /// usually either new window created with [`gdk::Window::new()`][crate::gdk::Window::new()], or the
4675 /// window of its parent widget as returned by
4676 /// [`parent_window()`][Self::parent_window()].
4677 ///
4678 /// Widgets must indicate whether they will create their own [`gdk::Window`][crate::gdk::Window]
4679 /// by calling [`set_has_window()`][Self::set_has_window()]. This is usually done in the
4680 /// widget’s `init()` function.
4681 ///
4682 /// Note that this function does not add any reference to `window`.
4683 /// ## `window`
4684 /// a [`gdk::Window`][crate::gdk::Window]
4685 #[doc(alias = "gtk_widget_set_window")]
4686 fn set_window(&self, window: gdk::Window) {
4687 unsafe {
4688 ffi::gtk_widget_set_window(self.as_ref().to_glib_none().0, window.into_glib_ptr());
4689 }
4690 }
4691
4692 /// Sets a shape for this widget’s GDK window. This allows for
4693 /// transparent windows etc., see [`Window::shape_combine_region()`][crate::gdk::Window::shape_combine_region()]
4694 /// for more information.
4695 /// ## `region`
4696 /// shape to be added, or [`None`] to remove an existing shape
4697 #[doc(alias = "gtk_widget_shape_combine_region")]
4698 fn shape_combine_region(&self, region: Option<&cairo::Region>) {
4699 unsafe {
4700 ffi::gtk_widget_shape_combine_region(
4701 self.as_ref().to_glib_none().0,
4702 mut_override(region.to_glib_none().0),
4703 );
4704 }
4705 }
4706
4707 /// Flags a widget to be displayed. Any widget that isn’t shown will
4708 /// not appear on the screen. If you want to show all the widgets in a
4709 /// container, it’s easier to call [`show_all()`][Self::show_all()] on the
4710 /// container, instead of individually showing the widgets.
4711 ///
4712 /// Remember that you have to show the containers containing a widget,
4713 /// in addition to the widget itself, before it will appear onscreen.
4714 ///
4715 /// When a toplevel container is shown, it is immediately realized and
4716 /// mapped; other shown widgets are realized and mapped when their
4717 /// toplevel container is realized and mapped.
4718 #[doc(alias = "gtk_widget_show")]
4719 fn show(&self) {
4720 unsafe {
4721 ffi::gtk_widget_show(self.as_ref().to_glib_none().0);
4722 }
4723 }
4724
4725 /// Recursively shows a widget, and any child widgets (if the widget is
4726 /// a container).
4727 #[doc(alias = "gtk_widget_show_all")]
4728 fn show_all(&self) {
4729 unsafe {
4730 ffi::gtk_widget_show_all(self.as_ref().to_glib_none().0);
4731 }
4732 }
4733
4734 /// Shows a widget. If the widget is an unmapped toplevel widget
4735 /// (i.e. a [`Window`][crate::Window] that has not yet been shown), enter the main
4736 /// loop and wait for the window to actually be mapped. Be careful;
4737 /// because the main loop is running, anything can happen during
4738 /// this function.
4739 #[doc(alias = "gtk_widget_show_now")]
4740 fn show_now(&self) {
4741 unsafe {
4742 ffi::gtk_widget_show_now(self.as_ref().to_glib_none().0);
4743 }
4744 }
4745
4746 /// This function is only used by [`Container`][crate::Container] subclasses, to assign a size
4747 /// and position to their child widgets.
4748 ///
4749 /// In this function, the allocation may be adjusted. It will be forced
4750 /// to a 1x1 minimum size, and the adjust_size_allocation virtual
4751 /// method on the child will be used to adjust the allocation. Standard
4752 /// adjustments include removing the widget’s margins, and applying the
4753 /// widget’s [`halign`][struct@crate::Widget#halign] and [`valign`][struct@crate::Widget#valign] properties.
4754 ///
4755 /// For baseline support in containers you need to use [`size_allocate_with_baseline()`][Self::size_allocate_with_baseline()]
4756 /// instead.
4757 /// ## `allocation`
4758 /// position and size to be allocated to `self`
4759 #[doc(alias = "gtk_widget_size_allocate")]
4760 fn size_allocate(&self, allocation: &Allocation) {
4761 unsafe {
4762 ffi::gtk_widget_size_allocate(
4763 self.as_ref().to_glib_none().0,
4764 mut_override(allocation.to_glib_none().0),
4765 );
4766 }
4767 }
4768
4769 /// This function is only used by [`Container`][crate::Container] subclasses, to assign a size,
4770 /// position and (optionally) baseline to their child widgets.
4771 ///
4772 /// In this function, the allocation and baseline may be adjusted. It
4773 /// will be forced to a 1x1 minimum size, and the
4774 /// adjust_size_allocation virtual and adjust_baseline_allocation
4775 /// methods on the child will be used to adjust the allocation and
4776 /// baseline. Standard adjustments include removing the widget's
4777 /// margins, and applying the widget’s [`halign`][struct@crate::Widget#halign] and
4778 /// [`valign`][struct@crate::Widget#valign] properties.
4779 ///
4780 /// If the child widget does not have a valign of [`Align::Baseline`][crate::Align::Baseline] the
4781 /// baseline argument is ignored and -1 is used instead.
4782 /// ## `allocation`
4783 /// position and size to be allocated to `self`
4784 /// ## `baseline`
4785 /// The baseline of the child, or -1
4786 #[doc(alias = "gtk_widget_size_allocate_with_baseline")]
4787 fn size_allocate_with_baseline(&self, allocation: &mut Allocation, baseline: i32) {
4788 unsafe {
4789 ffi::gtk_widget_size_allocate_with_baseline(
4790 self.as_ref().to_glib_none().0,
4791 allocation.to_glib_none_mut().0,
4792 baseline,
4793 );
4794 }
4795 }
4796
4797 //#[doc(alias = "gtk_widget_style_get")]
4798 //fn style_get(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
4799 // unsafe { TODO: call ffi:gtk_widget_style_get() }
4800 //}
4801
4802 /// Gets the value of a style property of `self`.
4803 /// ## `property_name`
4804 /// the name of a style property
4805 ///
4806 /// # Returns
4807 ///
4808 ///
4809 /// ## `value`
4810 /// location to return the property value
4811 #[doc(alias = "gtk_widget_style_get_property")]
4812 fn style_get_property(&self, property_name: &str) -> glib::Value {
4813 unsafe {
4814 let mut value = glib::Value::uninitialized();
4815 ffi::gtk_widget_style_get_property(
4816 self.as_ref().to_glib_none().0,
4817 property_name.to_glib_none().0,
4818 value.to_glib_none_mut().0,
4819 );
4820 value
4821 }
4822 }
4823
4824 //#[doc(alias = "gtk_widget_style_get_valist")]
4825 //fn style_get_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
4826 // unsafe { TODO: call ffi:gtk_widget_style_get_valist() }
4827 //}
4828
4829 /// Reverts the effect of a previous call to [`freeze_child_notify()`][Self::freeze_child_notify()].
4830 /// This causes all queued [`child-notify`][struct@crate::Widget#child-notify] signals on `self` to be
4831 /// emitted.
4832 #[doc(alias = "gtk_widget_thaw_child_notify")]
4833 fn thaw_child_notify(&self) {
4834 unsafe {
4835 ffi::gtk_widget_thaw_child_notify(self.as_ref().to_glib_none().0);
4836 }
4837 }
4838
4839 /// Translate coordinates relative to `self`’s allocation to coordinates
4840 /// relative to `dest_widget`’s allocations. In order to perform this
4841 /// operation, both widgets must be realized, and must share a common
4842 /// toplevel.
4843 /// ## `dest_widget`
4844 /// a [`Widget`][crate::Widget]
4845 /// ## `src_x`
4846 /// X position relative to `self`
4847 /// ## `src_y`
4848 /// Y position relative to `self`
4849 ///
4850 /// # Returns
4851 ///
4852 /// [`false`] if either widget was not realized, or there
4853 /// was no common ancestor. In this case, nothing is stored in
4854 /// *`dest_x` and *`dest_y`. Otherwise [`true`].
4855 ///
4856 /// ## `dest_x`
4857 /// location to store X position relative to `dest_widget`
4858 ///
4859 /// ## `dest_y`
4860 /// location to store Y position relative to `dest_widget`
4861 #[doc(alias = "gtk_widget_translate_coordinates")]
4862 fn translate_coordinates(
4863 &self,
4864 dest_widget: &impl IsA<Widget>,
4865 src_x: i32,
4866 src_y: i32,
4867 ) -> Option<(i32, i32)> {
4868 unsafe {
4869 let mut dest_x = std::mem::MaybeUninit::uninit();
4870 let mut dest_y = std::mem::MaybeUninit::uninit();
4871 let ret = from_glib(ffi::gtk_widget_translate_coordinates(
4872 self.as_ref().to_glib_none().0,
4873 dest_widget.as_ref().to_glib_none().0,
4874 src_x,
4875 src_y,
4876 dest_x.as_mut_ptr(),
4877 dest_y.as_mut_ptr(),
4878 ));
4879 if ret {
4880 Some((dest_x.assume_init(), dest_y.assume_init()))
4881 } else {
4882 None
4883 }
4884 }
4885 }
4886
4887 /// Triggers a tooltip query on the display where the toplevel of `self`
4888 /// is located. See [`Tooltip::trigger_tooltip_query()`][crate::Tooltip::trigger_tooltip_query()] for more
4889 /// information.
4890 #[doc(alias = "gtk_widget_trigger_tooltip_query")]
4891 fn trigger_tooltip_query(&self) {
4892 unsafe {
4893 ffi::gtk_widget_trigger_tooltip_query(self.as_ref().to_glib_none().0);
4894 }
4895 }
4896
4897 /// This function is only for use in widget implementations. Causes
4898 /// a widget to be unmapped if it’s currently mapped.
4899 #[doc(alias = "gtk_widget_unmap")]
4900 fn unmap(&self) {
4901 unsafe {
4902 ffi::gtk_widget_unmap(self.as_ref().to_glib_none().0);
4903 }
4904 }
4905
4906 /// This function is only for use in widget implementations.
4907 /// Should be called by implementations of the remove method
4908 /// on [`Container`][crate::Container], to dissociate a child from the container.
4909 #[doc(alias = "gtk_widget_unparent")]
4910 fn unparent(&self) {
4911 unsafe {
4912 ffi::gtk_widget_unparent(self.as_ref().to_glib_none().0);
4913 }
4914 }
4915
4916 /// window).
4917 #[doc(alias = "gtk_widget_unrealize")]
4918 fn unrealize(&self) {
4919 unsafe {
4920 ffi::gtk_widget_unrealize(self.as_ref().to_glib_none().0);
4921 }
4922 }
4923
4924 /// Unregisters a [`gdk::Window`][crate::gdk::Window] from the widget that was previously set up with
4925 /// [`register_window()`][Self::register_window()]. You need to call this when the window is
4926 /// no longer used by the widget, such as when you destroy it.
4927 /// ## `window`
4928 /// a [`gdk::Window`][crate::gdk::Window]
4929 #[doc(alias = "gtk_widget_unregister_window")]
4930 fn unregister_window(&self, window: &gdk::Window) {
4931 unsafe {
4932 ffi::gtk_widget_unregister_window(
4933 self.as_ref().to_glib_none().0,
4934 window.to_glib_none().0,
4935 );
4936 }
4937 }
4938
4939 /// This function is for use in widget implementations. Turns off flag
4940 /// values for the current widget state (insensitive, prelighted, etc.).
4941 /// See [`set_state_flags()`][Self::set_state_flags()].
4942 /// ## `flags`
4943 /// State flags to turn off
4944 #[doc(alias = "gtk_widget_unset_state_flags")]
4945 fn unset_state_flags(&self, flags: StateFlags) {
4946 unsafe {
4947 ffi::gtk_widget_unset_state_flags(self.as_ref().to_glib_none().0, flags.into_glib());
4948 }
4949 }
4950
4951 #[doc(alias = "composite-child")]
4952 fn is_composite_child(&self) -> bool {
4953 ObjectExt::property(self.as_ref(), "composite-child")
4954 }
4955
4956 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
4957 fn expands(&self) -> bool {
4958 ObjectExt::property(self.as_ref(), "expand")
4959 }
4960
4961 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
4962 fn set_expand(&self, expand: bool) {
4963 ObjectExt::set_property(self.as_ref(), "expand", expand)
4964 }
4965
4966 #[doc(alias = "has-default")]
4967 fn set_has_default(&self, has_default: bool) {
4968 ObjectExt::set_property(self.as_ref(), "has-default", has_default)
4969 }
4970
4971 #[doc(alias = "has-focus")]
4972 fn set_has_focus(&self, has_focus: bool) {
4973 ObjectExt::set_property(self.as_ref(), "has-focus", has_focus)
4974 }
4975
4976 #[doc(alias = "height-request")]
4977 fn height_request(&self) -> i32 {
4978 ObjectExt::property(self.as_ref(), "height-request")
4979 }
4980
4981 #[doc(alias = "height-request")]
4982 fn set_height_request(&self, height_request: i32) {
4983 ObjectExt::set_property(self.as_ref(), "height-request", height_request)
4984 }
4985
4986 #[doc(alias = "is-focus")]
4987 fn set_is_focus(&self, is_focus: bool) {
4988 ObjectExt::set_property(self.as_ref(), "is-focus", is_focus)
4989 }
4990
4991 /// Sets all four sides' margin at once. If read, returns max
4992 /// margin on any side.
4993 fn margin(&self) -> i32 {
4994 ObjectExt::property(self.as_ref(), "margin")
4995 }
4996
4997 /// Sets all four sides' margin at once. If read, returns max
4998 /// margin on any side.
4999 fn set_margin(&self, margin: i32) {
5000 ObjectExt::set_property(self.as_ref(), "margin", margin)
5001 }
5002
5003 #[doc(alias = "width-request")]
5004 fn width_request(&self) -> i32 {
5005 ObjectExt::property(self.as_ref(), "width-request")
5006 }
5007
5008 #[doc(alias = "width-request")]
5009 fn set_width_request(&self, width_request: i32) {
5010 ObjectExt::set_property(self.as_ref(), "width-request", width_request)
5011 }
5012
5013 #[doc(alias = "accel-closures-changed")]
5014 fn connect_accel_closures_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5015 unsafe extern "C" fn accel_closures_changed_trampoline<
5016 P: IsA<Widget>,
5017 F: Fn(&P) + 'static,
5018 >(
5019 this: *mut ffi::GtkWidget,
5020 f: glib::ffi::gpointer,
5021 ) {
5022 unsafe {
5023 let f: &F = &*(f as *const F);
5024 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5025 }
5026 }
5027 unsafe {
5028 let f: Box_<F> = Box_::new(f);
5029 connect_raw(
5030 self.as_ptr() as *mut _,
5031 c"accel-closures-changed".as_ptr(),
5032 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5033 accel_closures_changed_trampoline::<Self, F> as *const (),
5034 )),
5035 Box_::into_raw(f),
5036 )
5037 }
5038 }
5039
5040 /// The ::button-press-event signal will be emitted when a button
5041 /// (typically from a mouse) is pressed.
5042 ///
5043 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
5044 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
5045 ///
5046 /// This signal will be sent to the grab widget if there is one.
5047 /// ## `event`
5048 /// the [`gdk::EventButton`][crate::gdk::EventButton] which triggered
5049 /// this signal.
5050 ///
5051 /// # Returns
5052 ///
5053 /// [`true`] to stop other handlers from being invoked for the event.
5054 /// [`false`] to propagate the event further.
5055 #[doc(alias = "button-press-event")]
5056 fn connect_button_press_event<
5057 F: Fn(&Self, &gdk::EventButton) -> glib::Propagation + 'static,
5058 >(
5059 &self,
5060 f: F,
5061 ) -> SignalHandlerId {
5062 unsafe extern "C" fn button_press_event_trampoline<
5063 P: IsA<Widget>,
5064 F: Fn(&P, &gdk::EventButton) -> glib::Propagation + 'static,
5065 >(
5066 this: *mut ffi::GtkWidget,
5067 event: *mut gdk::ffi::GdkEventButton,
5068 f: glib::ffi::gpointer,
5069 ) -> glib::ffi::gboolean {
5070 unsafe {
5071 let f: &F = &*(f as *const F);
5072 f(
5073 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5074 &from_glib_borrow(event),
5075 )
5076 .into_glib()
5077 }
5078 }
5079 unsafe {
5080 let f: Box_<F> = Box_::new(f);
5081 connect_raw(
5082 self.as_ptr() as *mut _,
5083 c"button-press-event".as_ptr(),
5084 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5085 button_press_event_trampoline::<Self, F> as *const (),
5086 )),
5087 Box_::into_raw(f),
5088 )
5089 }
5090 }
5091
5092 /// The ::button-release-event signal will be emitted when a button
5093 /// (typically from a mouse) is released.
5094 ///
5095 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
5096 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
5097 ///
5098 /// This signal will be sent to the grab widget if there is one.
5099 /// ## `event`
5100 /// the [`gdk::EventButton`][crate::gdk::EventButton] which triggered
5101 /// this signal.
5102 ///
5103 /// # Returns
5104 ///
5105 /// [`true`] to stop other handlers from being invoked for the event.
5106 /// [`false`] to propagate the event further.
5107 #[doc(alias = "button-release-event")]
5108 fn connect_button_release_event<
5109 F: Fn(&Self, &gdk::EventButton) -> glib::Propagation + 'static,
5110 >(
5111 &self,
5112 f: F,
5113 ) -> SignalHandlerId {
5114 unsafe extern "C" fn button_release_event_trampoline<
5115 P: IsA<Widget>,
5116 F: Fn(&P, &gdk::EventButton) -> glib::Propagation + 'static,
5117 >(
5118 this: *mut ffi::GtkWidget,
5119 event: *mut gdk::ffi::GdkEventButton,
5120 f: glib::ffi::gpointer,
5121 ) -> glib::ffi::gboolean {
5122 unsafe {
5123 let f: &F = &*(f as *const F);
5124 f(
5125 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5126 &from_glib_borrow(event),
5127 )
5128 .into_glib()
5129 }
5130 }
5131 unsafe {
5132 let f: Box_<F> = Box_::new(f);
5133 connect_raw(
5134 self.as_ptr() as *mut _,
5135 c"button-release-event".as_ptr(),
5136 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5137 button_release_event_trampoline::<Self, F> as *const (),
5138 )),
5139 Box_::into_raw(f),
5140 )
5141 }
5142 }
5143
5144 /// Determines whether an accelerator that activates the signal
5145 /// identified by `signal_id` can currently be activated.
5146 /// This signal is present to allow applications and derived
5147 /// widgets to override the default [`Widget`][crate::Widget] handling
5148 /// for determining whether an accelerator can be activated.
5149 /// ## `signal_id`
5150 /// the ID of a signal installed on `widget`
5151 ///
5152 /// # Returns
5153 ///
5154 /// [`true`] if the signal can be activated.
5155 #[doc(alias = "can-activate-accel")]
5156 fn connect_can_activate_accel<F: Fn(&Self, u32) -> bool + 'static>(
5157 &self,
5158 f: F,
5159 ) -> SignalHandlerId {
5160 unsafe extern "C" fn can_activate_accel_trampoline<
5161 P: IsA<Widget>,
5162 F: Fn(&P, u32) -> bool + 'static,
5163 >(
5164 this: *mut ffi::GtkWidget,
5165 signal_id: std::ffi::c_uint,
5166 f: glib::ffi::gpointer,
5167 ) -> glib::ffi::gboolean {
5168 unsafe {
5169 let f: &F = &*(f as *const F);
5170 f(Widget::from_glib_borrow(this).unsafe_cast_ref(), signal_id).into_glib()
5171 }
5172 }
5173 unsafe {
5174 let f: Box_<F> = Box_::new(f);
5175 connect_raw(
5176 self.as_ptr() as *mut _,
5177 c"can-activate-accel".as_ptr(),
5178 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5179 can_activate_accel_trampoline::<Self, F> as *const (),
5180 )),
5181 Box_::into_raw(f),
5182 )
5183 }
5184 }
5185
5186 /// The ::child-notify signal is emitted for each
5187 /// [child property][child-properties] that has
5188 /// changed on an object. The signal's detail holds the property name.
5189 /// ## `child_property`
5190 /// the [`glib::ParamSpec`][crate::glib::ParamSpec] of the changed child property
5191 #[doc(alias = "child-notify")]
5192 fn connect_child_notify<F: Fn(&Self, &glib::ParamSpec) + 'static>(
5193 &self,
5194 detail: Option<&str>,
5195 f: F,
5196 ) -> SignalHandlerId {
5197 unsafe extern "C" fn child_notify_trampoline<
5198 P: IsA<Widget>,
5199 F: Fn(&P, &glib::ParamSpec) + 'static,
5200 >(
5201 this: *mut ffi::GtkWidget,
5202 child_property: *mut glib::gobject_ffi::GParamSpec,
5203 f: glib::ffi::gpointer,
5204 ) {
5205 unsafe {
5206 let f: &F = &*(f as *const F);
5207 f(
5208 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5209 &from_glib_borrow(child_property),
5210 )
5211 }
5212 }
5213 unsafe {
5214 let f: Box_<F> = Box_::new(f);
5215 let detailed_signal_name = detail.map(|name| format!("child-notify::{name}\0"));
5216 let signal_name = detailed_signal_name.as_ref().map_or(c"child-notify", |n| {
5217 std::ffi::CStr::from_bytes_with_nul_unchecked(n.as_bytes())
5218 });
5219 connect_raw(
5220 self.as_ptr() as *mut _,
5221 signal_name.as_ptr(),
5222 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5223 child_notify_trampoline::<Self, F> as *const (),
5224 )),
5225 Box_::into_raw(f),
5226 )
5227 }
5228 }
5229
5230 /// The ::configure-event signal will be emitted when the size, position or
5231 /// stacking of the `widget`'s window has changed.
5232 ///
5233 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
5234 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
5235 /// automatically for all new windows.
5236 /// ## `event`
5237 /// the [`gdk::EventConfigure`][crate::gdk::EventConfigure] which triggered
5238 /// this signal.
5239 ///
5240 /// # Returns
5241 ///
5242 /// [`true`] to stop other handlers from being invoked for the event.
5243 /// [`false`] to propagate the event further.
5244 #[doc(alias = "configure-event")]
5245 fn connect_configure_event<F: Fn(&Self, &gdk::EventConfigure) -> bool + 'static>(
5246 &self,
5247 f: F,
5248 ) -> SignalHandlerId {
5249 unsafe extern "C" fn configure_event_trampoline<
5250 P: IsA<Widget>,
5251 F: Fn(&P, &gdk::EventConfigure) -> bool + 'static,
5252 >(
5253 this: *mut ffi::GtkWidget,
5254 event: *mut gdk::ffi::GdkEventConfigure,
5255 f: glib::ffi::gpointer,
5256 ) -> glib::ffi::gboolean {
5257 unsafe {
5258 let f: &F = &*(f as *const F);
5259 f(
5260 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5261 &from_glib_borrow(event),
5262 )
5263 .into_glib()
5264 }
5265 }
5266 unsafe {
5267 let f: Box_<F> = Box_::new(f);
5268 connect_raw(
5269 self.as_ptr() as *mut _,
5270 c"configure-event".as_ptr(),
5271 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5272 configure_event_trampoline::<Self, F> as *const (),
5273 )),
5274 Box_::into_raw(f),
5275 )
5276 }
5277 }
5278
5279 /// Emitted when a redirected window belonging to `widget` gets drawn into.
5280 /// The region/area members of the event shows what area of the redirected
5281 /// drawable was drawn into.
5282 /// ## `event`
5283 /// the [`gdk::EventExpose`][crate::gdk::EventExpose] event
5284 ///
5285 /// # Returns
5286 ///
5287 /// [`true`] to stop other handlers from being invoked for the event.
5288 /// [`false`] to propagate the event further.
5289 #[doc(alias = "damage-event")]
5290 fn connect_damage_event<F: Fn(&Self, &gdk::EventExpose) -> bool + 'static>(
5291 &self,
5292 f: F,
5293 ) -> SignalHandlerId {
5294 unsafe extern "C" fn damage_event_trampoline<
5295 P: IsA<Widget>,
5296 F: Fn(&P, &gdk::EventExpose) -> bool + 'static,
5297 >(
5298 this: *mut ffi::GtkWidget,
5299 event: *mut gdk::ffi::GdkEventExpose,
5300 f: glib::ffi::gpointer,
5301 ) -> glib::ffi::gboolean {
5302 unsafe {
5303 let f: &F = &*(f as *const F);
5304 f(
5305 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5306 &from_glib_borrow(event),
5307 )
5308 .into_glib()
5309 }
5310 }
5311 unsafe {
5312 let f: Box_<F> = Box_::new(f);
5313 connect_raw(
5314 self.as_ptr() as *mut _,
5315 c"damage-event".as_ptr(),
5316 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5317 damage_event_trampoline::<Self, F> as *const (),
5318 )),
5319 Box_::into_raw(f),
5320 )
5321 }
5322 }
5323
5324 /// The ::delete-event signal is emitted if a user requests that
5325 /// a toplevel window is closed. The default handler for this signal
5326 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
5327 /// this signal will cause the window to be hidden instead, so that
5328 /// it can later be shown again without reconstructing it.
5329 /// ## `event`
5330 /// the event which triggered this signal
5331 ///
5332 /// # Returns
5333 ///
5334 /// [`true`] to stop other handlers from being invoked for the event.
5335 /// [`false`] to propagate the event further.
5336 #[doc(alias = "delete-event")]
5337 fn connect_delete_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
5338 &self,
5339 f: F,
5340 ) -> SignalHandlerId {
5341 unsafe extern "C" fn delete_event_trampoline<
5342 P: IsA<Widget>,
5343 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
5344 >(
5345 this: *mut ffi::GtkWidget,
5346 event: *mut gdk::ffi::GdkEvent,
5347 f: glib::ffi::gpointer,
5348 ) -> glib::ffi::gboolean {
5349 unsafe {
5350 let f: &F = &*(f as *const F);
5351 f(
5352 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5353 &from_glib_none(event),
5354 )
5355 .into_glib()
5356 }
5357 }
5358 unsafe {
5359 let f: Box_<F> = Box_::new(f);
5360 connect_raw(
5361 self.as_ptr() as *mut _,
5362 c"delete-event".as_ptr(),
5363 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5364 delete_event_trampoline::<Self, F> as *const (),
5365 )),
5366 Box_::into_raw(f),
5367 )
5368 }
5369 }
5370
5371 /// Signals that all holders of a reference to the widget should release
5372 /// the reference that they hold. May result in finalization of the widget
5373 /// if all references are released.
5374 ///
5375 /// This signal is not suitable for saving widget state.
5376 #[doc(alias = "destroy")]
5377 fn connect_destroy<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5378 unsafe extern "C" fn destroy_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
5379 this: *mut ffi::GtkWidget,
5380 f: glib::ffi::gpointer,
5381 ) {
5382 unsafe {
5383 let f: &F = &*(f as *const F);
5384 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
5385 }
5386 }
5387 unsafe {
5388 let f: Box_<F> = Box_::new(f);
5389 connect_raw(
5390 self.as_ptr() as *mut _,
5391 c"destroy".as_ptr(),
5392 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5393 destroy_trampoline::<Self, F> as *const (),
5394 )),
5395 Box_::into_raw(f),
5396 )
5397 }
5398 }
5399
5400 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
5401 /// You rarely get this signal, because most widgets disconnect themselves
5402 /// from their window before they destroy it, so no widget owns the
5403 /// window at destroy time.
5404 ///
5405 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
5406 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
5407 /// automatically for all new windows.
5408 /// ## `event`
5409 /// the event which triggered this signal
5410 ///
5411 /// # Returns
5412 ///
5413 /// [`true`] to stop other handlers from being invoked for the event.
5414 /// [`false`] to propagate the event further.
5415 #[doc(alias = "destroy-event")]
5416 fn connect_destroy_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
5417 &self,
5418 f: F,
5419 ) -> SignalHandlerId {
5420 unsafe extern "C" fn destroy_event_trampoline<
5421 P: IsA<Widget>,
5422 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
5423 >(
5424 this: *mut ffi::GtkWidget,
5425 event: *mut gdk::ffi::GdkEvent,
5426 f: glib::ffi::gpointer,
5427 ) -> glib::ffi::gboolean {
5428 unsafe {
5429 let f: &F = &*(f as *const F);
5430 f(
5431 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5432 &from_glib_none(event),
5433 )
5434 .into_glib()
5435 }
5436 }
5437 unsafe {
5438 let f: Box_<F> = Box_::new(f);
5439 connect_raw(
5440 self.as_ptr() as *mut _,
5441 c"destroy-event".as_ptr(),
5442 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5443 destroy_event_trampoline::<Self, F> as *const (),
5444 )),
5445 Box_::into_raw(f),
5446 )
5447 }
5448 }
5449
5450 /// The ::direction-changed signal is emitted when the text direction
5451 /// of a widget changes.
5452 /// ## `previous_direction`
5453 /// the previous text direction of `widget`
5454 #[doc(alias = "direction-changed")]
5455 fn connect_direction_changed<F: Fn(&Self, TextDirection) + 'static>(
5456 &self,
5457 f: F,
5458 ) -> SignalHandlerId {
5459 unsafe extern "C" fn direction_changed_trampoline<
5460 P: IsA<Widget>,
5461 F: Fn(&P, TextDirection) + 'static,
5462 >(
5463 this: *mut ffi::GtkWidget,
5464 previous_direction: ffi::GtkTextDirection,
5465 f: glib::ffi::gpointer,
5466 ) {
5467 unsafe {
5468 let f: &F = &*(f as *const F);
5469 f(
5470 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5471 from_glib(previous_direction),
5472 )
5473 }
5474 }
5475 unsafe {
5476 let f: Box_<F> = Box_::new(f);
5477 connect_raw(
5478 self.as_ptr() as *mut _,
5479 c"direction-changed".as_ptr(),
5480 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5481 direction_changed_trampoline::<Self, F> as *const (),
5482 )),
5483 Box_::into_raw(f),
5484 )
5485 }
5486 }
5487
5488 /// The ::drag-begin signal is emitted on the drag source when a drag is
5489 /// started. A typical reason to connect to this signal is to set up a
5490 /// custom drag icon with e.g. [`drag_source_set_icon_pixbuf()`][Self::drag_source_set_icon_pixbuf()].
5491 ///
5492 /// Note that some widgets set up a drag icon in the default handler of
5493 /// this signal, so you may have to use `g_signal_connect_after()` to
5494 /// override what the default handler did.
5495 /// ## `context`
5496 /// the drag context
5497 #[doc(alias = "drag-begin")]
5498 fn connect_drag_begin<F: Fn(&Self, &gdk::DragContext) + 'static>(
5499 &self,
5500 f: F,
5501 ) -> SignalHandlerId {
5502 unsafe extern "C" fn drag_begin_trampoline<
5503 P: IsA<Widget>,
5504 F: Fn(&P, &gdk::DragContext) + 'static,
5505 >(
5506 this: *mut ffi::GtkWidget,
5507 context: *mut gdk::ffi::GdkDragContext,
5508 f: glib::ffi::gpointer,
5509 ) {
5510 unsafe {
5511 let f: &F = &*(f as *const F);
5512 f(
5513 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5514 &from_glib_borrow(context),
5515 )
5516 }
5517 }
5518 unsafe {
5519 let f: Box_<F> = Box_::new(f);
5520 connect_raw(
5521 self.as_ptr() as *mut _,
5522 c"drag-begin".as_ptr(),
5523 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5524 drag_begin_trampoline::<Self, F> as *const (),
5525 )),
5526 Box_::into_raw(f),
5527 )
5528 }
5529 }
5530
5531 /// The ::drag-data-delete signal is emitted on the drag source when a drag
5532 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
5533 /// handler is responsible for deleting the data that has been dropped. What
5534 /// "delete" means depends on the context of the drag operation.
5535 /// ## `context`
5536 /// the drag context
5537 #[doc(alias = "drag-data-delete")]
5538 fn connect_drag_data_delete<F: Fn(&Self, &gdk::DragContext) + 'static>(
5539 &self,
5540 f: F,
5541 ) -> SignalHandlerId {
5542 unsafe extern "C" fn drag_data_delete_trampoline<
5543 P: IsA<Widget>,
5544 F: Fn(&P, &gdk::DragContext) + 'static,
5545 >(
5546 this: *mut ffi::GtkWidget,
5547 context: *mut gdk::ffi::GdkDragContext,
5548 f: glib::ffi::gpointer,
5549 ) {
5550 unsafe {
5551 let f: &F = &*(f as *const F);
5552 f(
5553 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5554 &from_glib_borrow(context),
5555 )
5556 }
5557 }
5558 unsafe {
5559 let f: Box_<F> = Box_::new(f);
5560 connect_raw(
5561 self.as_ptr() as *mut _,
5562 c"drag-data-delete".as_ptr(),
5563 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5564 drag_data_delete_trampoline::<Self, F> as *const (),
5565 )),
5566 Box_::into_raw(f),
5567 )
5568 }
5569 }
5570
5571 /// The ::drag-data-get signal is emitted on the drag source when the drop
5572 /// site requests the data which is dragged. It is the responsibility of
5573 /// the signal handler to fill `data` with the data in the format which
5574 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
5575 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
5576 /// ## `context`
5577 /// the drag context
5578 /// ## `data`
5579 /// the [`SelectionData`][crate::SelectionData] to be filled with the dragged data
5580 /// ## `info`
5581 /// the info that has been registered with the target in the
5582 /// [`TargetList`][crate::TargetList]
5583 /// ## `time`
5584 /// the timestamp at which the data was requested
5585 #[doc(alias = "drag-data-get")]
5586 fn connect_drag_data_get<
5587 F: Fn(&Self, &gdk::DragContext, &SelectionData, u32, u32) + 'static,
5588 >(
5589 &self,
5590 f: F,
5591 ) -> SignalHandlerId {
5592 unsafe extern "C" fn drag_data_get_trampoline<
5593 P: IsA<Widget>,
5594 F: Fn(&P, &gdk::DragContext, &SelectionData, u32, u32) + 'static,
5595 >(
5596 this: *mut ffi::GtkWidget,
5597 context: *mut gdk::ffi::GdkDragContext,
5598 data: *mut ffi::GtkSelectionData,
5599 info: std::ffi::c_uint,
5600 time: std::ffi::c_uint,
5601 f: glib::ffi::gpointer,
5602 ) {
5603 unsafe {
5604 let f: &F = &*(f as *const F);
5605 f(
5606 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5607 &from_glib_borrow(context),
5608 &from_glib_borrow(data),
5609 info,
5610 time,
5611 )
5612 }
5613 }
5614 unsafe {
5615 let f: Box_<F> = Box_::new(f);
5616 connect_raw(
5617 self.as_ptr() as *mut _,
5618 c"drag-data-get".as_ptr(),
5619 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5620 drag_data_get_trampoline::<Self, F> as *const (),
5621 )),
5622 Box_::into_raw(f),
5623 )
5624 }
5625 }
5626
5627 /// format == 8))
5628 /// {
5629 /// GdkDragAction action;
5630 ///
5631 /// // handle data here
5632 ///
5633 /// action = gdk_drag_context_get_selected_action (context);
5634 /// if (action == GDK_ACTION_ASK)
5635 /// {
5636 /// GtkWidget *dialog;
5637 /// gint response;
5638 ///
5639 /// dialog = gtk_message_dialog_new (NULL,
5640 /// GTK_DIALOG_MODAL |
5641 /// GTK_DIALOG_DESTROY_WITH_PARENT,
5642 /// GTK_MESSAGE_INFO,
5643 /// GTK_BUTTONS_YES_NO,
5644 /// "Move the data ?\n");
5645 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
5646 /// gtk_widget_destroy (dialog);
5647 ///
5648 /// if (response == GTK_RESPONSE_YES)
5649 /// action = GDK_ACTION_MOVE;
5650 /// else
5651 /// action = GDK_ACTION_COPY;
5652 /// }
5653 ///
5654 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
5655 /// }
5656 /// else
5657 /// gtk_drag_finish (context, FALSE, FALSE, time);
5658 /// }
5659 /// ]|
5660 /// ## `context`
5661 /// the drag context
5662 /// ## `x`
5663 /// where the drop happened
5664 /// ## `y`
5665 /// where the drop happened
5666 /// ## `data`
5667 /// the received data
5668 /// ## `info`
5669 /// the info that has been registered with the target in the
5670 /// [`TargetList`][crate::TargetList]
5671 /// ## `time`
5672 /// the timestamp at which the data was received
5673 #[doc(alias = "drag-data-received")]
5674 fn connect_drag_data_received<
5675 F: Fn(&Self, &gdk::DragContext, i32, i32, &SelectionData, u32, u32) + 'static,
5676 >(
5677 &self,
5678 f: F,
5679 ) -> SignalHandlerId {
5680 unsafe extern "C" fn drag_data_received_trampoline<
5681 P: IsA<Widget>,
5682 F: Fn(&P, &gdk::DragContext, i32, i32, &SelectionData, u32, u32) + 'static,
5683 >(
5684 this: *mut ffi::GtkWidget,
5685 context: *mut gdk::ffi::GdkDragContext,
5686 x: std::ffi::c_int,
5687 y: std::ffi::c_int,
5688 data: *mut ffi::GtkSelectionData,
5689 info: std::ffi::c_uint,
5690 time: std::ffi::c_uint,
5691 f: glib::ffi::gpointer,
5692 ) {
5693 unsafe {
5694 let f: &F = &*(f as *const F);
5695 f(
5696 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5697 &from_glib_borrow(context),
5698 x,
5699 y,
5700 &from_glib_borrow(data),
5701 info,
5702 time,
5703 )
5704 }
5705 }
5706 unsafe {
5707 let f: Box_<F> = Box_::new(f);
5708 connect_raw(
5709 self.as_ptr() as *mut _,
5710 c"drag-data-received".as_ptr(),
5711 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5712 drag_data_received_trampoline::<Self, F> as *const (),
5713 )),
5714 Box_::into_raw(f),
5715 )
5716 }
5717 }
5718
5719 /// The ::drag-drop signal is emitted on the drop site when the user drops
5720 /// the data onto the widget. The signal handler must determine whether
5721 /// the cursor position is in a drop zone or not. If it is not in a drop
5722 /// zone, it returns [`false`] and no further processing is necessary.
5723 /// Otherwise, the handler returns [`true`]. In this case, the handler must
5724 /// ensure that `gtk_drag_finish()` is called to let the source know that
5725 /// the drop is done. The call to `gtk_drag_finish()` can be done either
5726 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
5727 /// triggered by calling [`drag_get_data()`][Self::drag_get_data()] to receive the data for one
5728 /// or more of the supported targets.
5729 /// ## `context`
5730 /// the drag context
5731 /// ## `x`
5732 /// the x coordinate of the current cursor position
5733 /// ## `y`
5734 /// the y coordinate of the current cursor position
5735 /// ## `time`
5736 /// the timestamp of the motion event
5737 ///
5738 /// # Returns
5739 ///
5740 /// whether the cursor position is in a drop zone
5741 #[doc(alias = "drag-drop")]
5742 fn connect_drag_drop<F: Fn(&Self, &gdk::DragContext, i32, i32, u32) -> bool + 'static>(
5743 &self,
5744 f: F,
5745 ) -> SignalHandlerId {
5746 unsafe extern "C" fn drag_drop_trampoline<
5747 P: IsA<Widget>,
5748 F: Fn(&P, &gdk::DragContext, i32, i32, u32) -> bool + 'static,
5749 >(
5750 this: *mut ffi::GtkWidget,
5751 context: *mut gdk::ffi::GdkDragContext,
5752 x: std::ffi::c_int,
5753 y: std::ffi::c_int,
5754 time: std::ffi::c_uint,
5755 f: glib::ffi::gpointer,
5756 ) -> glib::ffi::gboolean {
5757 unsafe {
5758 let f: &F = &*(f as *const F);
5759 f(
5760 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5761 &from_glib_borrow(context),
5762 x,
5763 y,
5764 time,
5765 )
5766 .into_glib()
5767 }
5768 }
5769 unsafe {
5770 let f: Box_<F> = Box_::new(f);
5771 connect_raw(
5772 self.as_ptr() as *mut _,
5773 c"drag-drop".as_ptr(),
5774 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5775 drag_drop_trampoline::<Self, F> as *const (),
5776 )),
5777 Box_::into_raw(f),
5778 )
5779 }
5780 }
5781
5782 /// The ::drag-end signal is emitted on the drag source when a drag is
5783 /// finished. A typical reason to connect to this signal is to undo
5784 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
5785 /// ## `context`
5786 /// the drag context
5787 #[doc(alias = "drag-end")]
5788 fn connect_drag_end<F: Fn(&Self, &gdk::DragContext) + 'static>(&self, f: F) -> SignalHandlerId {
5789 unsafe extern "C" fn drag_end_trampoline<
5790 P: IsA<Widget>,
5791 F: Fn(&P, &gdk::DragContext) + 'static,
5792 >(
5793 this: *mut ffi::GtkWidget,
5794 context: *mut gdk::ffi::GdkDragContext,
5795 f: glib::ffi::gpointer,
5796 ) {
5797 unsafe {
5798 let f: &F = &*(f as *const F);
5799 f(
5800 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5801 &from_glib_borrow(context),
5802 )
5803 }
5804 }
5805 unsafe {
5806 let f: Box_<F> = Box_::new(f);
5807 connect_raw(
5808 self.as_ptr() as *mut _,
5809 c"drag-end".as_ptr(),
5810 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5811 drag_end_trampoline::<Self, F> as *const (),
5812 )),
5813 Box_::into_raw(f),
5814 )
5815 }
5816 }
5817
5818 /// The ::drag-failed signal is emitted on the drag source when a drag has
5819 /// failed. The signal handler may hook custom code to handle a failed DnD
5820 /// operation based on the type of error, it returns [`true`] is the failure has
5821 /// been already handled (not showing the default "drag operation failed"
5822 /// animation), otherwise it returns [`false`].
5823 /// ## `context`
5824 /// the drag context
5825 /// ## `result`
5826 /// the result of the drag operation
5827 ///
5828 /// # Returns
5829 ///
5830 /// [`true`] if the failed drag operation has been already handled.
5831 #[doc(alias = "drag-failed")]
5832 fn connect_drag_failed<
5833 F: Fn(&Self, &gdk::DragContext, DragResult) -> glib::Propagation + 'static,
5834 >(
5835 &self,
5836 f: F,
5837 ) -> SignalHandlerId {
5838 unsafe extern "C" fn drag_failed_trampoline<
5839 P: IsA<Widget>,
5840 F: Fn(&P, &gdk::DragContext, DragResult) -> glib::Propagation + 'static,
5841 >(
5842 this: *mut ffi::GtkWidget,
5843 context: *mut gdk::ffi::GdkDragContext,
5844 result: ffi::GtkDragResult,
5845 f: glib::ffi::gpointer,
5846 ) -> glib::ffi::gboolean {
5847 unsafe {
5848 let f: &F = &*(f as *const F);
5849 f(
5850 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5851 &from_glib_borrow(context),
5852 from_glib(result),
5853 )
5854 .into_glib()
5855 }
5856 }
5857 unsafe {
5858 let f: Box_<F> = Box_::new(f);
5859 connect_raw(
5860 self.as_ptr() as *mut _,
5861 c"drag-failed".as_ptr(),
5862 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5863 drag_failed_trampoline::<Self, F> as *const (),
5864 )),
5865 Box_::into_raw(f),
5866 )
5867 }
5868 }
5869
5870 /// The ::drag-leave signal is emitted on the drop site when the cursor
5871 /// leaves the widget. A typical reason to connect to this signal is to
5872 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
5873 /// with [`drag_unhighlight()`][Self::drag_unhighlight()].
5874 ///
5875 ///
5876 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
5877 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
5878 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
5879 /// ## `context`
5880 /// the drag context
5881 /// ## `time`
5882 /// the timestamp of the motion event
5883 #[doc(alias = "drag-leave")]
5884 fn connect_drag_leave<F: Fn(&Self, &gdk::DragContext, u32) + 'static>(
5885 &self,
5886 f: F,
5887 ) -> SignalHandlerId {
5888 unsafe extern "C" fn drag_leave_trampoline<
5889 P: IsA<Widget>,
5890 F: Fn(&P, &gdk::DragContext, u32) + 'static,
5891 >(
5892 this: *mut ffi::GtkWidget,
5893 context: *mut gdk::ffi::GdkDragContext,
5894 time: std::ffi::c_uint,
5895 f: glib::ffi::gpointer,
5896 ) {
5897 unsafe {
5898 let f: &F = &*(f as *const F);
5899 f(
5900 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5901 &from_glib_borrow(context),
5902 time,
5903 )
5904 }
5905 }
5906 unsafe {
5907 let f: Box_<F> = Box_::new(f);
5908 connect_raw(
5909 self.as_ptr() as *mut _,
5910 c"drag-leave".as_ptr(),
5911 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5912 drag_leave_trampoline::<Self, F> as *const (),
5913 )),
5914 Box_::into_raw(f),
5915 )
5916 }
5917 }
5918
5919 /// suggested_action,
5920 /// time);
5921 /// }
5922 /// else
5923 /// {
5924 /// // accept the drop
5925 /// }
5926 /// }
5927 /// ]|
5928 /// ## `context`
5929 /// the drag context
5930 /// ## `x`
5931 /// the x coordinate of the current cursor position
5932 /// ## `y`
5933 /// the y coordinate of the current cursor position
5934 /// ## `time`
5935 /// the timestamp of the motion event
5936 ///
5937 /// # Returns
5938 ///
5939 /// whether the cursor position is in a drop zone
5940 #[doc(alias = "drag-motion")]
5941 fn connect_drag_motion<F: Fn(&Self, &gdk::DragContext, i32, i32, u32) -> bool + 'static>(
5942 &self,
5943 f: F,
5944 ) -> SignalHandlerId {
5945 unsafe extern "C" fn drag_motion_trampoline<
5946 P: IsA<Widget>,
5947 F: Fn(&P, &gdk::DragContext, i32, i32, u32) -> bool + 'static,
5948 >(
5949 this: *mut ffi::GtkWidget,
5950 context: *mut gdk::ffi::GdkDragContext,
5951 x: std::ffi::c_int,
5952 y: std::ffi::c_int,
5953 time: std::ffi::c_uint,
5954 f: glib::ffi::gpointer,
5955 ) -> glib::ffi::gboolean {
5956 unsafe {
5957 let f: &F = &*(f as *const F);
5958 f(
5959 Widget::from_glib_borrow(this).unsafe_cast_ref(),
5960 &from_glib_borrow(context),
5961 x,
5962 y,
5963 time,
5964 )
5965 .into_glib()
5966 }
5967 }
5968 unsafe {
5969 let f: Box_<F> = Box_::new(f);
5970 connect_raw(
5971 self.as_ptr() as *mut _,
5972 c"drag-motion".as_ptr(),
5973 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5974 drag_motion_trampoline::<Self, F> as *const (),
5975 )),
5976 Box_::into_raw(f),
5977 )
5978 }
5979 }
5980
5981 /// This signal is emitted when a widget is supposed to render itself.
5982 /// The `widget`'s top left corner must be painted at the origin of
5983 /// the passed in context and be sized to the values returned by
5984 /// [`allocated_width()`][Self::allocated_width()] and
5985 /// [`allocated_height()`][Self::allocated_height()].
5986 ///
5987 /// Signal handlers connected to this signal can modify the cairo
5988 /// context passed as `cr` in any way they like and don't need to
5989 /// restore it. The signal emission takes care of calling `cairo_save()`
5990 /// before and `cairo_restore()` after invoking the handler.
5991 ///
5992 /// The signal handler will get a `cr` with a clip region already set to the
5993 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
5994 /// widgets that want to avoid redrawing themselves completely can get the full
5995 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
5996 /// get a finer-grained representation of the dirty region with
5997 /// `cairo_copy_clip_rectangle_list()`.
5998 /// ## `cr`
5999 /// the cairo context to draw to
6000 ///
6001 /// # Returns
6002 ///
6003 /// [`true`] to stop other handlers from being invoked for the event.
6004 /// [`false`] to propagate the event further.
6005 #[doc(alias = "draw")]
6006 fn connect_draw<F: Fn(&Self, &cairo::Context) -> glib::Propagation + 'static>(
6007 &self,
6008 f: F,
6009 ) -> SignalHandlerId {
6010 unsafe extern "C" fn draw_trampoline<
6011 P: IsA<Widget>,
6012 F: Fn(&P, &cairo::Context) -> glib::Propagation + 'static,
6013 >(
6014 this: *mut ffi::GtkWidget,
6015 cr: *mut cairo::ffi::cairo_t,
6016 f: glib::ffi::gpointer,
6017 ) -> glib::ffi::gboolean {
6018 unsafe {
6019 let f: &F = &*(f as *const F);
6020 f(
6021 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6022 &from_glib_borrow(cr),
6023 )
6024 .into_glib()
6025 }
6026 }
6027 unsafe {
6028 let f: Box_<F> = Box_::new(f);
6029 connect_raw(
6030 self.as_ptr() as *mut _,
6031 c"draw".as_ptr(),
6032 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6033 draw_trampoline::<Self, F> as *const (),
6034 )),
6035 Box_::into_raw(f),
6036 )
6037 }
6038 }
6039
6040 /// The ::enter-notify-event will be emitted when the pointer enters
6041 /// the `widget`'s window.
6042 ///
6043 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6044 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
6045 ///
6046 /// This signal will be sent to the grab widget if there is one.
6047 /// ## `event`
6048 /// the [`gdk::EventCrossing`][crate::gdk::EventCrossing] which triggered
6049 /// this signal.
6050 ///
6051 /// # Returns
6052 ///
6053 /// [`true`] to stop other handlers from being invoked for the event.
6054 /// [`false`] to propagate the event further.
6055 #[doc(alias = "enter-notify-event")]
6056 fn connect_enter_notify_event<
6057 F: Fn(&Self, &gdk::EventCrossing) -> glib::Propagation + 'static,
6058 >(
6059 &self,
6060 f: F,
6061 ) -> SignalHandlerId {
6062 unsafe extern "C" fn enter_notify_event_trampoline<
6063 P: IsA<Widget>,
6064 F: Fn(&P, &gdk::EventCrossing) -> glib::Propagation + 'static,
6065 >(
6066 this: *mut ffi::GtkWidget,
6067 event: *mut gdk::ffi::GdkEventCrossing,
6068 f: glib::ffi::gpointer,
6069 ) -> glib::ffi::gboolean {
6070 unsafe {
6071 let f: &F = &*(f as *const F);
6072 f(
6073 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6074 &from_glib_borrow(event),
6075 )
6076 .into_glib()
6077 }
6078 }
6079 unsafe {
6080 let f: Box_<F> = Box_::new(f);
6081 connect_raw(
6082 self.as_ptr() as *mut _,
6083 c"enter-notify-event".as_ptr(),
6084 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6085 enter_notify_event_trampoline::<Self, F> as *const (),
6086 )),
6087 Box_::into_raw(f),
6088 )
6089 }
6090 }
6091
6092 /// The GTK+ main loop will emit three signals for each GDK event delivered
6093 /// to a widget: one generic ::event signal, another, more specific,
6094 /// signal that matches the type of event delivered (e.g.
6095 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
6096 /// [`event-after`][struct@crate::Widget#event-after] signal.
6097 /// ## `event`
6098 /// the `GdkEvent` which triggered this signal
6099 ///
6100 /// # Returns
6101 ///
6102 /// [`true`] to stop other handlers from being invoked for the event
6103 /// and to cancel the emission of the second specific ::event signal.
6104 /// [`false`] to propagate the event further and to allow the emission of
6105 /// the second signal. The ::event-after signal is emitted regardless of
6106 /// the return value.
6107 #[doc(alias = "event")]
6108 fn connect_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
6109 &self,
6110 f: F,
6111 ) -> SignalHandlerId {
6112 unsafe extern "C" fn event_trampoline<
6113 P: IsA<Widget>,
6114 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
6115 >(
6116 this: *mut ffi::GtkWidget,
6117 event: *mut gdk::ffi::GdkEvent,
6118 f: glib::ffi::gpointer,
6119 ) -> glib::ffi::gboolean {
6120 unsafe {
6121 let f: &F = &*(f as *const F);
6122 f(
6123 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6124 &from_glib_none(event),
6125 )
6126 .into_glib()
6127 }
6128 }
6129 unsafe {
6130 let f: Box_<F> = Box_::new(f);
6131 connect_raw(
6132 self.as_ptr() as *mut _,
6133 c"event".as_ptr(),
6134 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6135 event_trampoline::<Self, F> as *const (),
6136 )),
6137 Box_::into_raw(f),
6138 )
6139 }
6140 }
6141
6142 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
6143 /// the second more specific signal, ::event-after will be emitted
6144 /// regardless of the previous two signals handlers return values.
6145 /// ## `event`
6146 /// the `GdkEvent` which triggered this signal
6147 #[doc(alias = "event-after")]
6148 fn connect_event_after<F: Fn(&Self, &gdk::Event) + 'static>(&self, f: F) -> SignalHandlerId {
6149 unsafe extern "C" fn event_after_trampoline<
6150 P: IsA<Widget>,
6151 F: Fn(&P, &gdk::Event) + 'static,
6152 >(
6153 this: *mut ffi::GtkWidget,
6154 event: *mut gdk::ffi::GdkEvent,
6155 f: glib::ffi::gpointer,
6156 ) {
6157 unsafe {
6158 let f: &F = &*(f as *const F);
6159 f(
6160 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6161 &from_glib_none(event),
6162 )
6163 }
6164 }
6165 unsafe {
6166 let f: Box_<F> = Box_::new(f);
6167 connect_raw(
6168 self.as_ptr() as *mut _,
6169 c"event-after".as_ptr(),
6170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6171 event_after_trampoline::<Self, F> as *const (),
6172 )),
6173 Box_::into_raw(f),
6174 )
6175 }
6176 }
6177
6178 ///
6179 /// # Returns
6180 ///
6181 /// [`true`] to stop other handlers from being invoked for the event. [`false`] to propagate the event further.
6182 #[doc(alias = "focus")]
6183 fn connect_focus<F: Fn(&Self, DirectionType) -> glib::Propagation + 'static>(
6184 &self,
6185 f: F,
6186 ) -> SignalHandlerId {
6187 unsafe extern "C" fn focus_trampoline<
6188 P: IsA<Widget>,
6189 F: Fn(&P, DirectionType) -> glib::Propagation + 'static,
6190 >(
6191 this: *mut ffi::GtkWidget,
6192 direction: ffi::GtkDirectionType,
6193 f: glib::ffi::gpointer,
6194 ) -> glib::ffi::gboolean {
6195 unsafe {
6196 let f: &F = &*(f as *const F);
6197 f(
6198 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6199 from_glib(direction),
6200 )
6201 .into_glib()
6202 }
6203 }
6204 unsafe {
6205 let f: Box_<F> = Box_::new(f);
6206 connect_raw(
6207 self.as_ptr() as *mut _,
6208 c"focus".as_ptr(),
6209 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6210 focus_trampoline::<Self, F> as *const (),
6211 )),
6212 Box_::into_raw(f),
6213 )
6214 }
6215 }
6216
6217 /// The ::focus-in-event signal will be emitted when the keyboard focus
6218 /// enters the `widget`'s window.
6219 ///
6220 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6221 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
6222 /// ## `event`
6223 /// the [`gdk::EventFocus`][crate::gdk::EventFocus] which triggered
6224 /// this signal.
6225 ///
6226 /// # Returns
6227 ///
6228 /// [`true`] to stop other handlers from being invoked for the event.
6229 /// [`false`] to propagate the event further.
6230 #[doc(alias = "focus-in-event")]
6231 fn connect_focus_in_event<F: Fn(&Self, &gdk::EventFocus) -> glib::Propagation + 'static>(
6232 &self,
6233 f: F,
6234 ) -> SignalHandlerId {
6235 unsafe extern "C" fn focus_in_event_trampoline<
6236 P: IsA<Widget>,
6237 F: Fn(&P, &gdk::EventFocus) -> glib::Propagation + 'static,
6238 >(
6239 this: *mut ffi::GtkWidget,
6240 event: *mut gdk::ffi::GdkEventFocus,
6241 f: glib::ffi::gpointer,
6242 ) -> glib::ffi::gboolean {
6243 unsafe {
6244 let f: &F = &*(f as *const F);
6245 f(
6246 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6247 &from_glib_borrow(event),
6248 )
6249 .into_glib()
6250 }
6251 }
6252 unsafe {
6253 let f: Box_<F> = Box_::new(f);
6254 connect_raw(
6255 self.as_ptr() as *mut _,
6256 c"focus-in-event".as_ptr(),
6257 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6258 focus_in_event_trampoline::<Self, F> as *const (),
6259 )),
6260 Box_::into_raw(f),
6261 )
6262 }
6263 }
6264
6265 /// The ::focus-out-event signal will be emitted when the keyboard focus
6266 /// leaves the `widget`'s window.
6267 ///
6268 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6269 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
6270 /// ## `event`
6271 /// the [`gdk::EventFocus`][crate::gdk::EventFocus] which triggered this
6272 /// signal.
6273 ///
6274 /// # Returns
6275 ///
6276 /// [`true`] to stop other handlers from being invoked for the event.
6277 /// [`false`] to propagate the event further.
6278 #[doc(alias = "focus-out-event")]
6279 fn connect_focus_out_event<F: Fn(&Self, &gdk::EventFocus) -> glib::Propagation + 'static>(
6280 &self,
6281 f: F,
6282 ) -> SignalHandlerId {
6283 unsafe extern "C" fn focus_out_event_trampoline<
6284 P: IsA<Widget>,
6285 F: Fn(&P, &gdk::EventFocus) -> glib::Propagation + 'static,
6286 >(
6287 this: *mut ffi::GtkWidget,
6288 event: *mut gdk::ffi::GdkEventFocus,
6289 f: glib::ffi::gpointer,
6290 ) -> glib::ffi::gboolean {
6291 unsafe {
6292 let f: &F = &*(f as *const F);
6293 f(
6294 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6295 &from_glib_borrow(event),
6296 )
6297 .into_glib()
6298 }
6299 }
6300 unsafe {
6301 let f: Box_<F> = Box_::new(f);
6302 connect_raw(
6303 self.as_ptr() as *mut _,
6304 c"focus-out-event".as_ptr(),
6305 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6306 focus_out_event_trampoline::<Self, F> as *const (),
6307 )),
6308 Box_::into_raw(f),
6309 )
6310 }
6311 }
6312
6313 /// Emitted when a pointer or keyboard grab on a window belonging
6314 /// to `widget` gets broken.
6315 ///
6316 /// On X11, this happens when the grab window becomes unviewable
6317 /// (i.e. it or one of its ancestors is unmapped), or if the same
6318 /// application grabs the pointer or keyboard again.
6319 /// ## `event`
6320 /// the [`gdk::EventGrabBroken`][crate::gdk::EventGrabBroken] event
6321 ///
6322 /// # Returns
6323 ///
6324 /// [`true`] to stop other handlers from being invoked for
6325 /// the event. [`false`] to propagate the event further.
6326 #[doc(alias = "grab-broken-event")]
6327 fn connect_grab_broken_event<
6328 F: Fn(&Self, &gdk::EventGrabBroken) -> glib::Propagation + 'static,
6329 >(
6330 &self,
6331 f: F,
6332 ) -> SignalHandlerId {
6333 unsafe extern "C" fn grab_broken_event_trampoline<
6334 P: IsA<Widget>,
6335 F: Fn(&P, &gdk::EventGrabBroken) -> glib::Propagation + 'static,
6336 >(
6337 this: *mut ffi::GtkWidget,
6338 event: *mut gdk::ffi::GdkEventGrabBroken,
6339 f: glib::ffi::gpointer,
6340 ) -> glib::ffi::gboolean {
6341 unsafe {
6342 let f: &F = &*(f as *const F);
6343 f(
6344 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6345 &from_glib_borrow(event),
6346 )
6347 .into_glib()
6348 }
6349 }
6350 unsafe {
6351 let f: Box_<F> = Box_::new(f);
6352 connect_raw(
6353 self.as_ptr() as *mut _,
6354 c"grab-broken-event".as_ptr(),
6355 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6356 grab_broken_event_trampoline::<Self, F> as *const (),
6357 )),
6358 Box_::into_raw(f),
6359 )
6360 }
6361 }
6362
6363 #[doc(alias = "grab-focus")]
6364 fn connect_grab_focus<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
6365 unsafe extern "C" fn grab_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
6366 this: *mut ffi::GtkWidget,
6367 f: glib::ffi::gpointer,
6368 ) {
6369 unsafe {
6370 let f: &F = &*(f as *const F);
6371 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
6372 }
6373 }
6374 unsafe {
6375 let f: Box_<F> = Box_::new(f);
6376 connect_raw(
6377 self.as_ptr() as *mut _,
6378 c"grab-focus".as_ptr(),
6379 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6380 grab_focus_trampoline::<Self, F> as *const (),
6381 )),
6382 Box_::into_raw(f),
6383 )
6384 }
6385 }
6386
6387 fn emit_grab_focus(&self) {
6388 self.emit_by_name::<()>("grab-focus", &[]);
6389 }
6390
6391 /// The ::grab-notify signal is emitted when a widget becomes
6392 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
6393 /// another widget, or when it becomes unshadowed due to a grab
6394 /// being removed.
6395 ///
6396 /// A widget is shadowed by a [`grab_add()`][Self::grab_add()] when the topmost
6397 /// grab widget in the grab stack of its window group is not
6398 /// its ancestor.
6399 /// ## `was_grabbed`
6400 /// [`false`] if the widget becomes shadowed, [`true`]
6401 /// if it becomes unshadowed
6402 #[doc(alias = "grab-notify")]
6403 fn connect_grab_notify<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
6404 unsafe extern "C" fn grab_notify_trampoline<P: IsA<Widget>, F: Fn(&P, bool) + 'static>(
6405 this: *mut ffi::GtkWidget,
6406 was_grabbed: glib::ffi::gboolean,
6407 f: glib::ffi::gpointer,
6408 ) {
6409 unsafe {
6410 let f: &F = &*(f as *const F);
6411 f(
6412 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6413 from_glib(was_grabbed),
6414 )
6415 }
6416 }
6417 unsafe {
6418 let f: Box_<F> = Box_::new(f);
6419 connect_raw(
6420 self.as_ptr() as *mut _,
6421 c"grab-notify".as_ptr(),
6422 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6423 grab_notify_trampoline::<Self, F> as *const (),
6424 )),
6425 Box_::into_raw(f),
6426 )
6427 }
6428 }
6429
6430 /// The ::hide signal is emitted when `widget` is hidden, for example with
6431 /// [`hide()`][Self::hide()].
6432 #[doc(alias = "hide")]
6433 fn connect_hide<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
6434 unsafe extern "C" fn hide_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
6435 this: *mut ffi::GtkWidget,
6436 f: glib::ffi::gpointer,
6437 ) {
6438 unsafe {
6439 let f: &F = &*(f as *const F);
6440 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
6441 }
6442 }
6443 unsafe {
6444 let f: Box_<F> = Box_::new(f);
6445 connect_raw(
6446 self.as_ptr() as *mut _,
6447 c"hide".as_ptr(),
6448 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6449 hide_trampoline::<Self, F> as *const (),
6450 )),
6451 Box_::into_raw(f),
6452 )
6453 }
6454 }
6455
6456 /// The ::hierarchy-changed signal is emitted when the
6457 /// anchored state of a widget changes. A widget is
6458 /// “anchored” when its toplevel
6459 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
6460 /// a widget changes from un-anchored to anchored or vice-versa.
6461 /// ## `previous_toplevel`
6462 /// the previous toplevel ancestor, or [`None`]
6463 /// if the widget was previously unanchored
6464 #[doc(alias = "hierarchy-changed")]
6465 fn connect_hierarchy_changed<F: Fn(&Self, Option<&Widget>) + 'static>(
6466 &self,
6467 f: F,
6468 ) -> SignalHandlerId {
6469 unsafe extern "C" fn hierarchy_changed_trampoline<
6470 P: IsA<Widget>,
6471 F: Fn(&P, Option<&Widget>) + 'static,
6472 >(
6473 this: *mut ffi::GtkWidget,
6474 previous_toplevel: *mut ffi::GtkWidget,
6475 f: glib::ffi::gpointer,
6476 ) {
6477 unsafe {
6478 let f: &F = &*(f as *const F);
6479 f(
6480 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6481 Option::<Widget>::from_glib_borrow(previous_toplevel)
6482 .as_ref()
6483 .as_ref(),
6484 )
6485 }
6486 }
6487 unsafe {
6488 let f: Box_<F> = Box_::new(f);
6489 connect_raw(
6490 self.as_ptr() as *mut _,
6491 c"hierarchy-changed".as_ptr(),
6492 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6493 hierarchy_changed_trampoline::<Self, F> as *const (),
6494 )),
6495 Box_::into_raw(f),
6496 )
6497 }
6498 }
6499
6500 /// The ::key-press-event signal is emitted when a key is pressed. The signal
6501 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
6502 ///
6503 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6504 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
6505 ///
6506 /// This signal will be sent to the grab widget if there is one.
6507 /// ## `event`
6508 /// the [`gdk::EventKey`][crate::gdk::EventKey] which triggered this signal.
6509 ///
6510 /// # Returns
6511 ///
6512 /// [`true`] to stop other handlers from being invoked for the event.
6513 /// [`false`] to propagate the event further.
6514 #[doc(alias = "key-press-event")]
6515 fn connect_key_press_event<F: Fn(&Self, &gdk::EventKey) -> glib::Propagation + 'static>(
6516 &self,
6517 f: F,
6518 ) -> SignalHandlerId {
6519 unsafe extern "C" fn key_press_event_trampoline<
6520 P: IsA<Widget>,
6521 F: Fn(&P, &gdk::EventKey) -> glib::Propagation + 'static,
6522 >(
6523 this: *mut ffi::GtkWidget,
6524 event: *mut gdk::ffi::GdkEventKey,
6525 f: glib::ffi::gpointer,
6526 ) -> glib::ffi::gboolean {
6527 unsafe {
6528 let f: &F = &*(f as *const F);
6529 f(
6530 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6531 &from_glib_borrow(event),
6532 )
6533 .into_glib()
6534 }
6535 }
6536 unsafe {
6537 let f: Box_<F> = Box_::new(f);
6538 connect_raw(
6539 self.as_ptr() as *mut _,
6540 c"key-press-event".as_ptr(),
6541 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6542 key_press_event_trampoline::<Self, F> as *const (),
6543 )),
6544 Box_::into_raw(f),
6545 )
6546 }
6547 }
6548
6549 /// The ::key-release-event signal is emitted when a key is released.
6550 ///
6551 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6552 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
6553 ///
6554 /// This signal will be sent to the grab widget if there is one.
6555 /// ## `event`
6556 /// the [`gdk::EventKey`][crate::gdk::EventKey] which triggered this signal.
6557 ///
6558 /// # Returns
6559 ///
6560 /// [`true`] to stop other handlers from being invoked for the event.
6561 /// [`false`] to propagate the event further.
6562 #[doc(alias = "key-release-event")]
6563 fn connect_key_release_event<F: Fn(&Self, &gdk::EventKey) -> glib::Propagation + 'static>(
6564 &self,
6565 f: F,
6566 ) -> SignalHandlerId {
6567 unsafe extern "C" fn key_release_event_trampoline<
6568 P: IsA<Widget>,
6569 F: Fn(&P, &gdk::EventKey) -> glib::Propagation + 'static,
6570 >(
6571 this: *mut ffi::GtkWidget,
6572 event: *mut gdk::ffi::GdkEventKey,
6573 f: glib::ffi::gpointer,
6574 ) -> glib::ffi::gboolean {
6575 unsafe {
6576 let f: &F = &*(f as *const F);
6577 f(
6578 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6579 &from_glib_borrow(event),
6580 )
6581 .into_glib()
6582 }
6583 }
6584 unsafe {
6585 let f: Box_<F> = Box_::new(f);
6586 connect_raw(
6587 self.as_ptr() as *mut _,
6588 c"key-release-event".as_ptr(),
6589 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6590 key_release_event_trampoline::<Self, F> as *const (),
6591 )),
6592 Box_::into_raw(f),
6593 )
6594 }
6595 }
6596
6597 /// Gets emitted if keyboard navigation fails.
6598 /// See [`keynav_failed()`][Self::keynav_failed()] for details.
6599 /// ## `direction`
6600 /// the direction of movement
6601 ///
6602 /// # Returns
6603 ///
6604 /// [`true`] if stopping keyboard navigation is fine, [`false`]
6605 /// if the emitting widget should try to handle the keyboard
6606 /// navigation attempt in its parent container(s).
6607 #[doc(alias = "keynav-failed")]
6608 fn connect_keynav_failed<F: Fn(&Self, DirectionType) -> glib::Propagation + 'static>(
6609 &self,
6610 f: F,
6611 ) -> SignalHandlerId {
6612 unsafe extern "C" fn keynav_failed_trampoline<
6613 P: IsA<Widget>,
6614 F: Fn(&P, DirectionType) -> glib::Propagation + 'static,
6615 >(
6616 this: *mut ffi::GtkWidget,
6617 direction: ffi::GtkDirectionType,
6618 f: glib::ffi::gpointer,
6619 ) -> glib::ffi::gboolean {
6620 unsafe {
6621 let f: &F = &*(f as *const F);
6622 f(
6623 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6624 from_glib(direction),
6625 )
6626 .into_glib()
6627 }
6628 }
6629 unsafe {
6630 let f: Box_<F> = Box_::new(f);
6631 connect_raw(
6632 self.as_ptr() as *mut _,
6633 c"keynav-failed".as_ptr(),
6634 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6635 keynav_failed_trampoline::<Self, F> as *const (),
6636 )),
6637 Box_::into_raw(f),
6638 )
6639 }
6640 }
6641
6642 /// The ::leave-notify-event will be emitted when the pointer leaves
6643 /// the `widget`'s window.
6644 ///
6645 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6646 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
6647 ///
6648 /// This signal will be sent to the grab widget if there is one.
6649 /// ## `event`
6650 /// the [`gdk::EventCrossing`][crate::gdk::EventCrossing] which triggered
6651 /// this signal.
6652 ///
6653 /// # Returns
6654 ///
6655 /// [`true`] to stop other handlers from being invoked for the event.
6656 /// [`false`] to propagate the event further.
6657 #[doc(alias = "leave-notify-event")]
6658 fn connect_leave_notify_event<
6659 F: Fn(&Self, &gdk::EventCrossing) -> glib::Propagation + 'static,
6660 >(
6661 &self,
6662 f: F,
6663 ) -> SignalHandlerId {
6664 unsafe extern "C" fn leave_notify_event_trampoline<
6665 P: IsA<Widget>,
6666 F: Fn(&P, &gdk::EventCrossing) -> glib::Propagation + 'static,
6667 >(
6668 this: *mut ffi::GtkWidget,
6669 event: *mut gdk::ffi::GdkEventCrossing,
6670 f: glib::ffi::gpointer,
6671 ) -> glib::ffi::gboolean {
6672 unsafe {
6673 let f: &F = &*(f as *const F);
6674 f(
6675 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6676 &from_glib_borrow(event),
6677 )
6678 .into_glib()
6679 }
6680 }
6681 unsafe {
6682 let f: Box_<F> = Box_::new(f);
6683 connect_raw(
6684 self.as_ptr() as *mut _,
6685 c"leave-notify-event".as_ptr(),
6686 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6687 leave_notify_event_trampoline::<Self, F> as *const (),
6688 )),
6689 Box_::into_raw(f),
6690 )
6691 }
6692 }
6693
6694 /// The ::map signal is emitted when `widget` is going to be mapped, that is
6695 /// when the widget is visible (which is controlled with
6696 /// [`set_visible()`][Self::set_visible()]) and all its parents up to the toplevel widget
6697 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
6698 /// be emitted.
6699 ///
6700 /// The ::map signal can be used to determine whether a widget will be drawn,
6701 /// for instance it can resume an animation that was stopped during the
6702 /// emission of [`unmap`][struct@crate::Widget#unmap].
6703 #[doc(alias = "map")]
6704 fn connect_map<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
6705 unsafe extern "C" fn map_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
6706 this: *mut ffi::GtkWidget,
6707 f: glib::ffi::gpointer,
6708 ) {
6709 unsafe {
6710 let f: &F = &*(f as *const F);
6711 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
6712 }
6713 }
6714 unsafe {
6715 let f: Box_<F> = Box_::new(f);
6716 connect_raw(
6717 self.as_ptr() as *mut _,
6718 c"map".as_ptr(),
6719 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6720 map_trampoline::<Self, F> as *const (),
6721 )),
6722 Box_::into_raw(f),
6723 )
6724 }
6725 }
6726
6727 /// The default handler for this signal activates `widget` if `group_cycling`
6728 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
6729 /// ## `group_cycling`
6730 /// [`true`] if there are other widgets with the same mnemonic
6731 ///
6732 /// # Returns
6733 ///
6734 /// [`true`] to stop other handlers from being invoked for the event.
6735 /// [`false`] to propagate the event further.
6736 #[doc(alias = "mnemonic-activate")]
6737 fn connect_mnemonic_activate<F: Fn(&Self, bool) -> glib::Propagation + 'static>(
6738 &self,
6739 f: F,
6740 ) -> SignalHandlerId {
6741 unsafe extern "C" fn mnemonic_activate_trampoline<
6742 P: IsA<Widget>,
6743 F: Fn(&P, bool) -> glib::Propagation + 'static,
6744 >(
6745 this: *mut ffi::GtkWidget,
6746 group_cycling: glib::ffi::gboolean,
6747 f: glib::ffi::gpointer,
6748 ) -> glib::ffi::gboolean {
6749 unsafe {
6750 let f: &F = &*(f as *const F);
6751 f(
6752 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6753 from_glib(group_cycling),
6754 )
6755 .into_glib()
6756 }
6757 }
6758 unsafe {
6759 let f: Box_<F> = Box_::new(f);
6760 connect_raw(
6761 self.as_ptr() as *mut _,
6762 c"mnemonic-activate".as_ptr(),
6763 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6764 mnemonic_activate_trampoline::<Self, F> as *const (),
6765 )),
6766 Box_::into_raw(f),
6767 )
6768 }
6769 }
6770
6771 /// The ::motion-notify-event signal is emitted when the pointer moves
6772 /// over the widget's [`gdk::Window`][crate::gdk::Window].
6773 ///
6774 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
6775 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
6776 ///
6777 /// This signal will be sent to the grab widget if there is one.
6778 /// ## `event`
6779 /// the [`gdk::EventMotion`][crate::gdk::EventMotion] which triggered
6780 /// this signal.
6781 ///
6782 /// # Returns
6783 ///
6784 /// [`true`] to stop other handlers from being invoked for the event.
6785 /// [`false`] to propagate the event further.
6786 #[doc(alias = "motion-notify-event")]
6787 fn connect_motion_notify_event<
6788 F: Fn(&Self, &gdk::EventMotion) -> glib::Propagation + 'static,
6789 >(
6790 &self,
6791 f: F,
6792 ) -> SignalHandlerId {
6793 unsafe extern "C" fn motion_notify_event_trampoline<
6794 P: IsA<Widget>,
6795 F: Fn(&P, &gdk::EventMotion) -> glib::Propagation + 'static,
6796 >(
6797 this: *mut ffi::GtkWidget,
6798 event: *mut gdk::ffi::GdkEventMotion,
6799 f: glib::ffi::gpointer,
6800 ) -> glib::ffi::gboolean {
6801 unsafe {
6802 let f: &F = &*(f as *const F);
6803 f(
6804 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6805 &from_glib_borrow(event),
6806 )
6807 .into_glib()
6808 }
6809 }
6810 unsafe {
6811 let f: Box_<F> = Box_::new(f);
6812 connect_raw(
6813 self.as_ptr() as *mut _,
6814 c"motion-notify-event".as_ptr(),
6815 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6816 motion_notify_event_trampoline::<Self, F> as *const (),
6817 )),
6818 Box_::into_raw(f),
6819 )
6820 }
6821 }
6822
6823 #[doc(alias = "move-focus")]
6824 fn connect_move_focus<F: Fn(&Self, DirectionType) + 'static>(&self, f: F) -> SignalHandlerId {
6825 unsafe extern "C" fn move_focus_trampoline<
6826 P: IsA<Widget>,
6827 F: Fn(&P, DirectionType) + 'static,
6828 >(
6829 this: *mut ffi::GtkWidget,
6830 direction: ffi::GtkDirectionType,
6831 f: glib::ffi::gpointer,
6832 ) {
6833 unsafe {
6834 let f: &F = &*(f as *const F);
6835 f(
6836 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6837 from_glib(direction),
6838 )
6839 }
6840 }
6841 unsafe {
6842 let f: Box_<F> = Box_::new(f);
6843 connect_raw(
6844 self.as_ptr() as *mut _,
6845 c"move-focus".as_ptr(),
6846 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6847 move_focus_trampoline::<Self, F> as *const (),
6848 )),
6849 Box_::into_raw(f),
6850 )
6851 }
6852 }
6853
6854 fn emit_move_focus(&self, direction: DirectionType) {
6855 self.emit_by_name::<()>("move-focus", &[&direction]);
6856 }
6857
6858 /// The ::parent-set signal is emitted when a new parent
6859 /// has been set on a widget.
6860 /// ## `old_parent`
6861 /// the previous parent, or [`None`] if the widget
6862 /// just got its initial parent.
6863 #[doc(alias = "parent-set")]
6864 fn connect_parent_set<F: Fn(&Self, Option<&Widget>) + 'static>(&self, f: F) -> SignalHandlerId {
6865 unsafe extern "C" fn parent_set_trampoline<
6866 P: IsA<Widget>,
6867 F: Fn(&P, Option<&Widget>) + 'static,
6868 >(
6869 this: *mut ffi::GtkWidget,
6870 old_parent: *mut ffi::GtkWidget,
6871 f: glib::ffi::gpointer,
6872 ) {
6873 unsafe {
6874 let f: &F = &*(f as *const F);
6875 f(
6876 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6877 Option::<Widget>::from_glib_borrow(old_parent)
6878 .as_ref()
6879 .as_ref(),
6880 )
6881 }
6882 }
6883 unsafe {
6884 let f: Box_<F> = Box_::new(f);
6885 connect_raw(
6886 self.as_ptr() as *mut _,
6887 c"parent-set".as_ptr(),
6888 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6889 parent_set_trampoline::<Self, F> as *const (),
6890 )),
6891 Box_::into_raw(f),
6892 )
6893 }
6894 }
6895
6896 /// This signal gets emitted whenever a widget should pop up a context
6897 /// menu. This usually happens through the standard key binding mechanism;
6898 /// by pressing a certain key while a widget is focused, the user can cause
6899 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
6900 /// a menu with clipboard commands. See the
6901 /// [Popup Menu Migration Checklist][checklist-popup-menu]
6902 /// for an example of how to use this signal.
6903 ///
6904 /// # Returns
6905 ///
6906 /// [`true`] if a menu was activated
6907 #[doc(alias = "popup-menu")]
6908 fn connect_popup_menu<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
6909 unsafe extern "C" fn popup_menu_trampoline<P: IsA<Widget>, F: Fn(&P) -> bool + 'static>(
6910 this: *mut ffi::GtkWidget,
6911 f: glib::ffi::gpointer,
6912 ) -> glib::ffi::gboolean {
6913 unsafe {
6914 let f: &F = &*(f as *const F);
6915 f(Widget::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
6916 }
6917 }
6918 unsafe {
6919 let f: Box_<F> = Box_::new(f);
6920 connect_raw(
6921 self.as_ptr() as *mut _,
6922 c"popup-menu".as_ptr(),
6923 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6924 popup_menu_trampoline::<Self, F> as *const (),
6925 )),
6926 Box_::into_raw(f),
6927 )
6928 }
6929 }
6930
6931 fn emit_popup_menu(&self) -> bool {
6932 self.emit_by_name("popup-menu", &[])
6933 }
6934
6935 /// The ::property-notify-event signal will be emitted when a property on
6936 /// the `widget`'s window has been changed or deleted.
6937 ///
6938 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6939 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
6940 /// ## `event`
6941 /// the [`gdk::EventProperty`][crate::gdk::EventProperty] which triggered
6942 /// this signal.
6943 ///
6944 /// # Returns
6945 ///
6946 /// [`true`] to stop other handlers from being invoked for the event.
6947 /// [`false`] to propagate the event further.
6948 #[doc(alias = "property-notify-event")]
6949 fn connect_property_notify_event<
6950 F: Fn(&Self, &gdk::EventProperty) -> glib::Propagation + 'static,
6951 >(
6952 &self,
6953 f: F,
6954 ) -> SignalHandlerId {
6955 unsafe extern "C" fn property_notify_event_trampoline<
6956 P: IsA<Widget>,
6957 F: Fn(&P, &gdk::EventProperty) -> glib::Propagation + 'static,
6958 >(
6959 this: *mut ffi::GtkWidget,
6960 event: *mut gdk::ffi::GdkEventProperty,
6961 f: glib::ffi::gpointer,
6962 ) -> glib::ffi::gboolean {
6963 unsafe {
6964 let f: &F = &*(f as *const F);
6965 f(
6966 Widget::from_glib_borrow(this).unsafe_cast_ref(),
6967 &from_glib_borrow(event),
6968 )
6969 .into_glib()
6970 }
6971 }
6972 unsafe {
6973 let f: Box_<F> = Box_::new(f);
6974 connect_raw(
6975 self.as_ptr() as *mut _,
6976 c"property-notify-event".as_ptr(),
6977 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
6978 property_notify_event_trampoline::<Self, F> as *const (),
6979 )),
6980 Box_::into_raw(f),
6981 )
6982 }
6983 }
6984
6985 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
6986 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
6987 ///
6988 /// This signal will be sent to the grab widget if there is one.
6989 /// ## `event`
6990 /// the [`gdk::EventProximity`][crate::gdk::EventProximity] which triggered
6991 /// this signal.
6992 ///
6993 /// # Returns
6994 ///
6995 /// [`true`] to stop other handlers from being invoked for the event.
6996 /// [`false`] to propagate the event further.
6997 #[doc(alias = "proximity-in-event")]
6998 fn connect_proximity_in_event<
6999 F: Fn(&Self, &gdk::EventProximity) -> glib::Propagation + 'static,
7000 >(
7001 &self,
7002 f: F,
7003 ) -> SignalHandlerId {
7004 unsafe extern "C" fn proximity_in_event_trampoline<
7005 P: IsA<Widget>,
7006 F: Fn(&P, &gdk::EventProximity) -> glib::Propagation + 'static,
7007 >(
7008 this: *mut ffi::GtkWidget,
7009 event: *mut gdk::ffi::GdkEventProximity,
7010 f: glib::ffi::gpointer,
7011 ) -> glib::ffi::gboolean {
7012 unsafe {
7013 let f: &F = &*(f as *const F);
7014 f(
7015 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7016 &from_glib_borrow(event),
7017 )
7018 .into_glib()
7019 }
7020 }
7021 unsafe {
7022 let f: Box_<F> = Box_::new(f);
7023 connect_raw(
7024 self.as_ptr() as *mut _,
7025 c"proximity-in-event".as_ptr(),
7026 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7027 proximity_in_event_trampoline::<Self, F> as *const (),
7028 )),
7029 Box_::into_raw(f),
7030 )
7031 }
7032 }
7033
7034 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7035 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
7036 ///
7037 /// This signal will be sent to the grab widget if there is one.
7038 /// ## `event`
7039 /// the [`gdk::EventProximity`][crate::gdk::EventProximity] which triggered
7040 /// this signal.
7041 ///
7042 /// # Returns
7043 ///
7044 /// [`true`] to stop other handlers from being invoked for the event.
7045 /// [`false`] to propagate the event further.
7046 #[doc(alias = "proximity-out-event")]
7047 fn connect_proximity_out_event<
7048 F: Fn(&Self, &gdk::EventProximity) -> glib::Propagation + 'static,
7049 >(
7050 &self,
7051 f: F,
7052 ) -> SignalHandlerId {
7053 unsafe extern "C" fn proximity_out_event_trampoline<
7054 P: IsA<Widget>,
7055 F: Fn(&P, &gdk::EventProximity) -> glib::Propagation + 'static,
7056 >(
7057 this: *mut ffi::GtkWidget,
7058 event: *mut gdk::ffi::GdkEventProximity,
7059 f: glib::ffi::gpointer,
7060 ) -> glib::ffi::gboolean {
7061 unsafe {
7062 let f: &F = &*(f as *const F);
7063 f(
7064 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7065 &from_glib_borrow(event),
7066 )
7067 .into_glib()
7068 }
7069 }
7070 unsafe {
7071 let f: Box_<F> = Box_::new(f);
7072 connect_raw(
7073 self.as_ptr() as *mut _,
7074 c"proximity-out-event".as_ptr(),
7075 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7076 proximity_out_event_trampoline::<Self, F> as *const (),
7077 )),
7078 Box_::into_raw(f),
7079 )
7080 }
7081 }
7082
7083 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
7084 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
7085 /// focus in keyboard mode.
7086 ///
7087 /// Using the given coordinates, the signal handler should determine
7088 /// whether a tooltip should be shown for `widget`. If this is the case
7089 /// [`true`] should be returned, [`false`] otherwise. Note that if
7090 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
7091 /// should not be used.
7092 ///
7093 /// The signal handler is free to manipulate `tooltip` with the therefore
7094 /// destined function calls.
7095 /// ## `x`
7096 /// the x coordinate of the cursor position where the request has
7097 /// been emitted, relative to `widget`'s left side
7098 /// ## `y`
7099 /// the y coordinate of the cursor position where the request has
7100 /// been emitted, relative to `widget`'s top
7101 /// ## `keyboard_mode`
7102 /// [`true`] if the tooltip was triggered using the keyboard
7103 /// ## `tooltip`
7104 /// a [`Tooltip`][crate::Tooltip]
7105 ///
7106 /// # Returns
7107 ///
7108 /// [`true`] if `tooltip` should be shown right now, [`false`] otherwise.
7109 #[doc(alias = "query-tooltip")]
7110 fn connect_query_tooltip<F: Fn(&Self, i32, i32, bool, &Tooltip) -> bool + 'static>(
7111 &self,
7112 f: F,
7113 ) -> SignalHandlerId {
7114 unsafe extern "C" fn query_tooltip_trampoline<
7115 P: IsA<Widget>,
7116 F: Fn(&P, i32, i32, bool, &Tooltip) -> bool + 'static,
7117 >(
7118 this: *mut ffi::GtkWidget,
7119 x: std::ffi::c_int,
7120 y: std::ffi::c_int,
7121 keyboard_mode: glib::ffi::gboolean,
7122 tooltip: *mut ffi::GtkTooltip,
7123 f: glib::ffi::gpointer,
7124 ) -> glib::ffi::gboolean {
7125 unsafe {
7126 let f: &F = &*(f as *const F);
7127 f(
7128 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7129 x,
7130 y,
7131 from_glib(keyboard_mode),
7132 &from_glib_borrow(tooltip),
7133 )
7134 .into_glib()
7135 }
7136 }
7137 unsafe {
7138 let f: Box_<F> = Box_::new(f);
7139 connect_raw(
7140 self.as_ptr() as *mut _,
7141 c"query-tooltip".as_ptr(),
7142 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7143 query_tooltip_trampoline::<Self, F> as *const (),
7144 )),
7145 Box_::into_raw(f),
7146 )
7147 }
7148 }
7149
7150 /// The ::realize signal is emitted when `widget` is associated with a
7151 /// [`gdk::Window`][crate::gdk::Window], which means that [`realize()`][Self::realize()] has been called or the
7152 /// widget has been mapped (that is, it is going to be drawn).
7153 #[doc(alias = "realize")]
7154 fn connect_realize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7155 unsafe extern "C" fn realize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7156 this: *mut ffi::GtkWidget,
7157 f: glib::ffi::gpointer,
7158 ) {
7159 unsafe {
7160 let f: &F = &*(f as *const F);
7161 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7162 }
7163 }
7164 unsafe {
7165 let f: Box_<F> = Box_::new(f);
7166 connect_raw(
7167 self.as_ptr() as *mut _,
7168 c"realize".as_ptr(),
7169 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7170 realize_trampoline::<Self, F> as *const (),
7171 )),
7172 Box_::into_raw(f),
7173 )
7174 }
7175 }
7176
7177 /// The ::screen-changed signal gets emitted when the
7178 /// screen of a widget has changed.
7179 /// ## `previous_screen`
7180 /// the previous screen, or [`None`] if the
7181 /// widget was not associated with a screen before
7182 #[doc(alias = "screen-changed")]
7183 fn connect_screen_changed<F: Fn(&Self, Option<&gdk::Screen>) + 'static>(
7184 &self,
7185 f: F,
7186 ) -> SignalHandlerId {
7187 unsafe extern "C" fn screen_changed_trampoline<
7188 P: IsA<Widget>,
7189 F: Fn(&P, Option<&gdk::Screen>) + 'static,
7190 >(
7191 this: *mut ffi::GtkWidget,
7192 previous_screen: *mut gdk::ffi::GdkScreen,
7193 f: glib::ffi::gpointer,
7194 ) {
7195 unsafe {
7196 let f: &F = &*(f as *const F);
7197 f(
7198 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7199 Option::<gdk::Screen>::from_glib_borrow(previous_screen)
7200 .as_ref()
7201 .as_ref(),
7202 )
7203 }
7204 }
7205 unsafe {
7206 let f: Box_<F> = Box_::new(f);
7207 connect_raw(
7208 self.as_ptr() as *mut _,
7209 c"screen-changed".as_ptr(),
7210 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7211 screen_changed_trampoline::<Self, F> as *const (),
7212 )),
7213 Box_::into_raw(f),
7214 )
7215 }
7216 }
7217
7218 /// The ::scroll-event signal is emitted when a button in the 4 to 7
7219 /// range is pressed. Wheel mice are usually configured to generate
7220 /// button press events for buttons 4 and 5 when the wheel is turned.
7221 ///
7222 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
7223 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
7224 ///
7225 /// This signal will be sent to the grab widget if there is one.
7226 /// ## `event`
7227 /// the [`gdk::EventScroll`][crate::gdk::EventScroll] which triggered
7228 /// this signal.
7229 ///
7230 /// # Returns
7231 ///
7232 /// [`true`] to stop other handlers from being invoked for the event.
7233 /// [`false`] to propagate the event further.
7234 #[doc(alias = "scroll-event")]
7235 fn connect_scroll_event<F: Fn(&Self, &gdk::EventScroll) -> glib::Propagation + 'static>(
7236 &self,
7237 f: F,
7238 ) -> SignalHandlerId {
7239 unsafe extern "C" fn scroll_event_trampoline<
7240 P: IsA<Widget>,
7241 F: Fn(&P, &gdk::EventScroll) -> glib::Propagation + 'static,
7242 >(
7243 this: *mut ffi::GtkWidget,
7244 event: *mut gdk::ffi::GdkEventScroll,
7245 f: glib::ffi::gpointer,
7246 ) -> glib::ffi::gboolean {
7247 unsafe {
7248 let f: &F = &*(f as *const F);
7249 f(
7250 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7251 &from_glib_borrow(event),
7252 )
7253 .into_glib()
7254 }
7255 }
7256 unsafe {
7257 let f: Box_<F> = Box_::new(f);
7258 connect_raw(
7259 self.as_ptr() as *mut _,
7260 c"scroll-event".as_ptr(),
7261 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7262 scroll_event_trampoline::<Self, F> as *const (),
7263 )),
7264 Box_::into_raw(f),
7265 )
7266 }
7267 }
7268
7269 /// The ::selection-clear-event signal will be emitted when the
7270 /// the `widget`'s window has lost ownership of a selection.
7271 /// ## `event`
7272 /// the [`gdk::EventSelection`][crate::gdk::EventSelection] which triggered
7273 /// this signal.
7274 ///
7275 /// # Returns
7276 ///
7277 /// [`true`] to stop other handlers from being invoked for the event.
7278 /// [`false`] to propagate the event further.
7279 #[doc(alias = "selection-clear-event")]
7280 fn connect_selection_clear_event<
7281 F: Fn(&Self, &gdk::EventSelection) -> glib::Propagation + 'static,
7282 >(
7283 &self,
7284 f: F,
7285 ) -> SignalHandlerId {
7286 unsafe extern "C" fn selection_clear_event_trampoline<
7287 P: IsA<Widget>,
7288 F: Fn(&P, &gdk::EventSelection) -> glib::Propagation + 'static,
7289 >(
7290 this: *mut ffi::GtkWidget,
7291 event: *mut gdk::ffi::GdkEventSelection,
7292 f: glib::ffi::gpointer,
7293 ) -> glib::ffi::gboolean {
7294 unsafe {
7295 let f: &F = &*(f as *const F);
7296 f(
7297 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7298 &from_glib_borrow(event),
7299 )
7300 .into_glib()
7301 }
7302 }
7303 unsafe {
7304 let f: Box_<F> = Box_::new(f);
7305 connect_raw(
7306 self.as_ptr() as *mut _,
7307 c"selection-clear-event".as_ptr(),
7308 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7309 selection_clear_event_trampoline::<Self, F> as *const (),
7310 )),
7311 Box_::into_raw(f),
7312 )
7313 }
7314 }
7315
7316 #[doc(alias = "selection-get")]
7317 fn connect_selection_get<F: Fn(&Self, &SelectionData, u32, u32) + 'static>(
7318 &self,
7319 f: F,
7320 ) -> SignalHandlerId {
7321 unsafe extern "C" fn selection_get_trampoline<
7322 P: IsA<Widget>,
7323 F: Fn(&P, &SelectionData, u32, u32) + 'static,
7324 >(
7325 this: *mut ffi::GtkWidget,
7326 data: *mut ffi::GtkSelectionData,
7327 info: std::ffi::c_uint,
7328 time: std::ffi::c_uint,
7329 f: glib::ffi::gpointer,
7330 ) {
7331 unsafe {
7332 let f: &F = &*(f as *const F);
7333 f(
7334 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7335 &from_glib_borrow(data),
7336 info,
7337 time,
7338 )
7339 }
7340 }
7341 unsafe {
7342 let f: Box_<F> = Box_::new(f);
7343 connect_raw(
7344 self.as_ptr() as *mut _,
7345 c"selection-get".as_ptr(),
7346 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7347 selection_get_trampoline::<Self, F> as *const (),
7348 )),
7349 Box_::into_raw(f),
7350 )
7351 }
7352 }
7353
7354 ///
7355 /// # Returns
7356 ///
7357 /// [`true`] to stop other handlers from being invoked for the event. [`false`] to propagate the event further.
7358 #[doc(alias = "selection-notify-event")]
7359 fn connect_selection_notify_event<
7360 F: Fn(&Self, &gdk::EventSelection) -> glib::Propagation + 'static,
7361 >(
7362 &self,
7363 f: F,
7364 ) -> SignalHandlerId {
7365 unsafe extern "C" fn selection_notify_event_trampoline<
7366 P: IsA<Widget>,
7367 F: Fn(&P, &gdk::EventSelection) -> glib::Propagation + 'static,
7368 >(
7369 this: *mut ffi::GtkWidget,
7370 event: *mut gdk::ffi::GdkEventSelection,
7371 f: glib::ffi::gpointer,
7372 ) -> glib::ffi::gboolean {
7373 unsafe {
7374 let f: &F = &*(f as *const F);
7375 f(
7376 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7377 &from_glib_borrow(event),
7378 )
7379 .into_glib()
7380 }
7381 }
7382 unsafe {
7383 let f: Box_<F> = Box_::new(f);
7384 connect_raw(
7385 self.as_ptr() as *mut _,
7386 c"selection-notify-event".as_ptr(),
7387 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7388 selection_notify_event_trampoline::<Self, F> as *const (),
7389 )),
7390 Box_::into_raw(f),
7391 )
7392 }
7393 }
7394
7395 #[doc(alias = "selection-received")]
7396 fn connect_selection_received<F: Fn(&Self, &SelectionData, u32) + 'static>(
7397 &self,
7398 f: F,
7399 ) -> SignalHandlerId {
7400 unsafe extern "C" fn selection_received_trampoline<
7401 P: IsA<Widget>,
7402 F: Fn(&P, &SelectionData, u32) + 'static,
7403 >(
7404 this: *mut ffi::GtkWidget,
7405 data: *mut ffi::GtkSelectionData,
7406 time: std::ffi::c_uint,
7407 f: glib::ffi::gpointer,
7408 ) {
7409 unsafe {
7410 let f: &F = &*(f as *const F);
7411 f(
7412 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7413 &from_glib_borrow(data),
7414 time,
7415 )
7416 }
7417 }
7418 unsafe {
7419 let f: Box_<F> = Box_::new(f);
7420 connect_raw(
7421 self.as_ptr() as *mut _,
7422 c"selection-received".as_ptr(),
7423 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7424 selection_received_trampoline::<Self, F> as *const (),
7425 )),
7426 Box_::into_raw(f),
7427 )
7428 }
7429 }
7430
7431 /// The ::selection-request-event signal will be emitted when
7432 /// another client requests ownership of the selection owned by
7433 /// the `widget`'s window.
7434 /// ## `event`
7435 /// the [`gdk::EventSelection`][crate::gdk::EventSelection] which triggered
7436 /// this signal.
7437 ///
7438 /// # Returns
7439 ///
7440 /// [`true`] to stop other handlers from being invoked for the event.
7441 /// [`false`] to propagate the event further.
7442 #[doc(alias = "selection-request-event")]
7443 fn connect_selection_request_event<
7444 F: Fn(&Self, &gdk::EventSelection) -> glib::Propagation + 'static,
7445 >(
7446 &self,
7447 f: F,
7448 ) -> SignalHandlerId {
7449 unsafe extern "C" fn selection_request_event_trampoline<
7450 P: IsA<Widget>,
7451 F: Fn(&P, &gdk::EventSelection) -> glib::Propagation + 'static,
7452 >(
7453 this: *mut ffi::GtkWidget,
7454 event: *mut gdk::ffi::GdkEventSelection,
7455 f: glib::ffi::gpointer,
7456 ) -> glib::ffi::gboolean {
7457 unsafe {
7458 let f: &F = &*(f as *const F);
7459 f(
7460 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7461 &from_glib_borrow(event),
7462 )
7463 .into_glib()
7464 }
7465 }
7466 unsafe {
7467 let f: Box_<F> = Box_::new(f);
7468 connect_raw(
7469 self.as_ptr() as *mut _,
7470 c"selection-request-event".as_ptr(),
7471 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7472 selection_request_event_trampoline::<Self, F> as *const (),
7473 )),
7474 Box_::into_raw(f),
7475 )
7476 }
7477 }
7478
7479 /// The ::show signal is emitted when `widget` is shown, for example with
7480 /// [`show()`][Self::show()].
7481 #[doc(alias = "show")]
7482 fn connect_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7483 unsafe extern "C" fn show_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7484 this: *mut ffi::GtkWidget,
7485 f: glib::ffi::gpointer,
7486 ) {
7487 unsafe {
7488 let f: &F = &*(f as *const F);
7489 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7490 }
7491 }
7492 unsafe {
7493 let f: Box_<F> = Box_::new(f);
7494 connect_raw(
7495 self.as_ptr() as *mut _,
7496 c"show".as_ptr(),
7497 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7498 show_trampoline::<Self, F> as *const (),
7499 )),
7500 Box_::into_raw(f),
7501 )
7502 }
7503 }
7504
7505 ///
7506 /// # Returns
7507 ///
7508 /// [`true`] to stop other handlers from being invoked for the event.
7509 /// [`false`] to propagate the event further.
7510 #[doc(alias = "show-help")]
7511 fn connect_show_help<F: Fn(&Self, WidgetHelpType) -> bool + 'static>(
7512 &self,
7513 f: F,
7514 ) -> SignalHandlerId {
7515 unsafe extern "C" fn show_help_trampoline<
7516 P: IsA<Widget>,
7517 F: Fn(&P, WidgetHelpType) -> bool + 'static,
7518 >(
7519 this: *mut ffi::GtkWidget,
7520 help_type: ffi::GtkWidgetHelpType,
7521 f: glib::ffi::gpointer,
7522 ) -> glib::ffi::gboolean {
7523 unsafe {
7524 let f: &F = &*(f as *const F);
7525 f(
7526 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7527 from_glib(help_type),
7528 )
7529 .into_glib()
7530 }
7531 }
7532 unsafe {
7533 let f: Box_<F> = Box_::new(f);
7534 connect_raw(
7535 self.as_ptr() as *mut _,
7536 c"show-help".as_ptr(),
7537 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7538 show_help_trampoline::<Self, F> as *const (),
7539 )),
7540 Box_::into_raw(f),
7541 )
7542 }
7543 }
7544
7545 fn emit_show_help(&self, help_type: WidgetHelpType) -> bool {
7546 self.emit_by_name("show-help", &[&help_type])
7547 }
7548
7549 /// ## `allocation`
7550 /// the region which has been
7551 /// allocated to the widget.
7552 #[doc(alias = "size-allocate")]
7553 fn connect_size_allocate<F: Fn(&Self, &Allocation) + 'static>(&self, f: F) -> SignalHandlerId {
7554 unsafe extern "C" fn size_allocate_trampoline<
7555 P: IsA<Widget>,
7556 F: Fn(&P, &Allocation) + 'static,
7557 >(
7558 this: *mut ffi::GtkWidget,
7559 allocation: *mut ffi::GtkAllocation,
7560 f: glib::ffi::gpointer,
7561 ) {
7562 unsafe {
7563 let f: &F = &*(f as *const F);
7564 f(
7565 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7566 &from_glib_none(allocation),
7567 )
7568 }
7569 }
7570 unsafe {
7571 let f: Box_<F> = Box_::new(f);
7572 connect_raw(
7573 self.as_ptr() as *mut _,
7574 c"size-allocate".as_ptr(),
7575 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7576 size_allocate_trampoline::<Self, F> as *const (),
7577 )),
7578 Box_::into_raw(f),
7579 )
7580 }
7581 }
7582
7583 /// The ::state-flags-changed signal is emitted when the widget state
7584 /// changes, see [`state_flags()`][Self::state_flags()].
7585 /// ## `flags`
7586 /// The previous state flags.
7587 #[doc(alias = "state-flags-changed")]
7588 fn connect_state_flags_changed<F: Fn(&Self, StateFlags) + 'static>(
7589 &self,
7590 f: F,
7591 ) -> SignalHandlerId {
7592 unsafe extern "C" fn state_flags_changed_trampoline<
7593 P: IsA<Widget>,
7594 F: Fn(&P, StateFlags) + 'static,
7595 >(
7596 this: *mut ffi::GtkWidget,
7597 flags: ffi::GtkStateFlags,
7598 f: glib::ffi::gpointer,
7599 ) {
7600 unsafe {
7601 let f: &F = &*(f as *const F);
7602 f(
7603 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7604 from_glib(flags),
7605 )
7606 }
7607 }
7608 unsafe {
7609 let f: Box_<F> = Box_::new(f);
7610 connect_raw(
7611 self.as_ptr() as *mut _,
7612 c"state-flags-changed".as_ptr(),
7613 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7614 state_flags_changed_trampoline::<Self, F> as *const (),
7615 )),
7616 Box_::into_raw(f),
7617 )
7618 }
7619 }
7620
7621 /// The ::style-updated signal is a convenience signal that is emitted when the
7622 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
7623 /// [`StyleContext`][crate::StyleContext] as returned by [`style_context()`][Self::style_context()].
7624 ///
7625 /// Note that style-modifying functions like `gtk_widget_override_color()` also
7626 /// cause this signal to be emitted.
7627 #[doc(alias = "style-updated")]
7628 fn connect_style_updated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7629 unsafe extern "C" fn style_updated_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7630 this: *mut ffi::GtkWidget,
7631 f: glib::ffi::gpointer,
7632 ) {
7633 unsafe {
7634 let f: &F = &*(f as *const F);
7635 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7636 }
7637 }
7638 unsafe {
7639 let f: Box_<F> = Box_::new(f);
7640 connect_raw(
7641 self.as_ptr() as *mut _,
7642 c"style-updated".as_ptr(),
7643 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7644 style_updated_trampoline::<Self, F> as *const (),
7645 )),
7646 Box_::into_raw(f),
7647 )
7648 }
7649 }
7650
7651 #[doc(alias = "touch-event")]
7652 fn connect_touch_event<F: Fn(&Self, &gdk::Event) -> glib::Propagation + 'static>(
7653 &self,
7654 f: F,
7655 ) -> SignalHandlerId {
7656 unsafe extern "C" fn touch_event_trampoline<
7657 P: IsA<Widget>,
7658 F: Fn(&P, &gdk::Event) -> glib::Propagation + 'static,
7659 >(
7660 this: *mut ffi::GtkWidget,
7661 object: *mut gdk::ffi::GdkEvent,
7662 f: glib::ffi::gpointer,
7663 ) -> glib::ffi::gboolean {
7664 unsafe {
7665 let f: &F = &*(f as *const F);
7666 f(
7667 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7668 &from_glib_none(object),
7669 )
7670 .into_glib()
7671 }
7672 }
7673 unsafe {
7674 let f: Box_<F> = Box_::new(f);
7675 connect_raw(
7676 self.as_ptr() as *mut _,
7677 c"touch-event".as_ptr(),
7678 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7679 touch_event_trampoline::<Self, F> as *const (),
7680 )),
7681 Box_::into_raw(f),
7682 )
7683 }
7684 }
7685
7686 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
7687 /// means that either it or any of its parents up to the toplevel widget have
7688 /// been set as hidden.
7689 ///
7690 /// As ::unmap indicates that a widget will not be shown any longer, it can be
7691 /// used to, for example, stop an animation on the widget.
7692 #[doc(alias = "unmap")]
7693 fn connect_unmap<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7694 unsafe extern "C" fn unmap_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7695 this: *mut ffi::GtkWidget,
7696 f: glib::ffi::gpointer,
7697 ) {
7698 unsafe {
7699 let f: &F = &*(f as *const F);
7700 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7701 }
7702 }
7703 unsafe {
7704 let f: Box_<F> = Box_::new(f);
7705 connect_raw(
7706 self.as_ptr() as *mut _,
7707 c"unmap".as_ptr(),
7708 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7709 unmap_trampoline::<Self, F> as *const (),
7710 )),
7711 Box_::into_raw(f),
7712 )
7713 }
7714 }
7715
7716 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
7717 /// `widget` is destroyed, which means that [`unrealize()`][Self::unrealize()] has been
7718 /// called or the widget has been unmapped (that is, it is going to be
7719 /// hidden).
7720 #[doc(alias = "unrealize")]
7721 fn connect_unrealize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7722 unsafe extern "C" fn unrealize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7723 this: *mut ffi::GtkWidget,
7724 f: glib::ffi::gpointer,
7725 ) {
7726 unsafe {
7727 let f: &F = &*(f as *const F);
7728 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7729 }
7730 }
7731 unsafe {
7732 let f: Box_<F> = Box_::new(f);
7733 connect_raw(
7734 self.as_ptr() as *mut _,
7735 c"unrealize".as_ptr(),
7736 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7737 unrealize_trampoline::<Self, F> as *const (),
7738 )),
7739 Box_::into_raw(f),
7740 )
7741 }
7742 }
7743
7744 /// The ::window-state-event will be emitted when the state of the
7745 /// toplevel window associated to the `widget` changes.
7746 ///
7747 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
7748 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
7749 /// this mask automatically for all new windows.
7750 /// ## `event`
7751 /// the [`gdk::EventWindowState`][crate::gdk::EventWindowState] which
7752 /// triggered this signal.
7753 ///
7754 /// # Returns
7755 ///
7756 /// [`true`] to stop other handlers from being invoked for the
7757 /// event. [`false`] to propagate the event further.
7758 #[doc(alias = "window-state-event")]
7759 fn connect_window_state_event<
7760 F: Fn(&Self, &gdk::EventWindowState) -> glib::Propagation + 'static,
7761 >(
7762 &self,
7763 f: F,
7764 ) -> SignalHandlerId {
7765 unsafe extern "C" fn window_state_event_trampoline<
7766 P: IsA<Widget>,
7767 F: Fn(&P, &gdk::EventWindowState) -> glib::Propagation + 'static,
7768 >(
7769 this: *mut ffi::GtkWidget,
7770 event: *mut gdk::ffi::GdkEventWindowState,
7771 f: glib::ffi::gpointer,
7772 ) -> glib::ffi::gboolean {
7773 unsafe {
7774 let f: &F = &*(f as *const F);
7775 f(
7776 Widget::from_glib_borrow(this).unsafe_cast_ref(),
7777 &from_glib_borrow(event),
7778 )
7779 .into_glib()
7780 }
7781 }
7782 unsafe {
7783 let f: Box_<F> = Box_::new(f);
7784 connect_raw(
7785 self.as_ptr() as *mut _,
7786 c"window-state-event".as_ptr(),
7787 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7788 window_state_event_trampoline::<Self, F> as *const (),
7789 )),
7790 Box_::into_raw(f),
7791 )
7792 }
7793 }
7794
7795 #[doc(alias = "app-paintable")]
7796 fn connect_app_paintable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7797 unsafe extern "C" fn notify_app_paintable_trampoline<
7798 P: IsA<Widget>,
7799 F: Fn(&P) + 'static,
7800 >(
7801 this: *mut ffi::GtkWidget,
7802 _param_spec: glib::ffi::gpointer,
7803 f: glib::ffi::gpointer,
7804 ) {
7805 unsafe {
7806 let f: &F = &*(f as *const F);
7807 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7808 }
7809 }
7810 unsafe {
7811 let f: Box_<F> = Box_::new(f);
7812 connect_raw(
7813 self.as_ptr() as *mut _,
7814 c"notify::app-paintable".as_ptr(),
7815 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7816 notify_app_paintable_trampoline::<Self, F> as *const (),
7817 )),
7818 Box_::into_raw(f),
7819 )
7820 }
7821 }
7822
7823 #[doc(alias = "can-default")]
7824 fn connect_can_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7825 unsafe extern "C" fn notify_can_default_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7826 this: *mut ffi::GtkWidget,
7827 _param_spec: glib::ffi::gpointer,
7828 f: glib::ffi::gpointer,
7829 ) {
7830 unsafe {
7831 let f: &F = &*(f as *const F);
7832 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7833 }
7834 }
7835 unsafe {
7836 let f: Box_<F> = Box_::new(f);
7837 connect_raw(
7838 self.as_ptr() as *mut _,
7839 c"notify::can-default".as_ptr(),
7840 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7841 notify_can_default_trampoline::<Self, F> as *const (),
7842 )),
7843 Box_::into_raw(f),
7844 )
7845 }
7846 }
7847
7848 #[doc(alias = "can-focus")]
7849 fn connect_can_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7850 unsafe extern "C" fn notify_can_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7851 this: *mut ffi::GtkWidget,
7852 _param_spec: glib::ffi::gpointer,
7853 f: glib::ffi::gpointer,
7854 ) {
7855 unsafe {
7856 let f: &F = &*(f as *const F);
7857 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7858 }
7859 }
7860 unsafe {
7861 let f: Box_<F> = Box_::new(f);
7862 connect_raw(
7863 self.as_ptr() as *mut _,
7864 c"notify::can-focus".as_ptr(),
7865 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7866 notify_can_focus_trampoline::<Self, F> as *const (),
7867 )),
7868 Box_::into_raw(f),
7869 )
7870 }
7871 }
7872
7873 #[doc(alias = "composite-child")]
7874 fn connect_composite_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7875 unsafe extern "C" fn notify_composite_child_trampoline<
7876 P: IsA<Widget>,
7877 F: Fn(&P) + 'static,
7878 >(
7879 this: *mut ffi::GtkWidget,
7880 _param_spec: glib::ffi::gpointer,
7881 f: glib::ffi::gpointer,
7882 ) {
7883 unsafe {
7884 let f: &F = &*(f as *const F);
7885 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7886 }
7887 }
7888 unsafe {
7889 let f: Box_<F> = Box_::new(f);
7890 connect_raw(
7891 self.as_ptr() as *mut _,
7892 c"notify::composite-child".as_ptr(),
7893 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7894 notify_composite_child_trampoline::<Self, F> as *const (),
7895 )),
7896 Box_::into_raw(f),
7897 )
7898 }
7899 }
7900
7901 #[doc(alias = "events")]
7902 fn connect_events_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7903 unsafe extern "C" fn notify_events_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7904 this: *mut ffi::GtkWidget,
7905 _param_spec: glib::ffi::gpointer,
7906 f: glib::ffi::gpointer,
7907 ) {
7908 unsafe {
7909 let f: &F = &*(f as *const F);
7910 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7911 }
7912 }
7913 unsafe {
7914 let f: Box_<F> = Box_::new(f);
7915 connect_raw(
7916 self.as_ptr() as *mut _,
7917 c"notify::events".as_ptr(),
7918 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7919 notify_events_trampoline::<Self, F> as *const (),
7920 )),
7921 Box_::into_raw(f),
7922 )
7923 }
7924 }
7925
7926 #[doc(alias = "expand")]
7927 fn connect_expand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7928 unsafe extern "C" fn notify_expand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7929 this: *mut ffi::GtkWidget,
7930 _param_spec: glib::ffi::gpointer,
7931 f: glib::ffi::gpointer,
7932 ) {
7933 unsafe {
7934 let f: &F = &*(f as *const F);
7935 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7936 }
7937 }
7938 unsafe {
7939 let f: Box_<F> = Box_::new(f);
7940 connect_raw(
7941 self.as_ptr() as *mut _,
7942 c"notify::expand".as_ptr(),
7943 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7944 notify_expand_trampoline::<Self, F> as *const (),
7945 )),
7946 Box_::into_raw(f),
7947 )
7948 }
7949 }
7950
7951 #[doc(alias = "focus-on-click")]
7952 fn connect_focus_on_click_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7953 unsafe extern "C" fn notify_focus_on_click_trampoline<
7954 P: IsA<Widget>,
7955 F: Fn(&P) + 'static,
7956 >(
7957 this: *mut ffi::GtkWidget,
7958 _param_spec: glib::ffi::gpointer,
7959 f: glib::ffi::gpointer,
7960 ) {
7961 unsafe {
7962 let f: &F = &*(f as *const F);
7963 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7964 }
7965 }
7966 unsafe {
7967 let f: Box_<F> = Box_::new(f);
7968 connect_raw(
7969 self.as_ptr() as *mut _,
7970 c"notify::focus-on-click".as_ptr(),
7971 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7972 notify_focus_on_click_trampoline::<Self, F> as *const (),
7973 )),
7974 Box_::into_raw(f),
7975 )
7976 }
7977 }
7978
7979 #[doc(alias = "halign")]
7980 fn connect_halign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
7981 unsafe extern "C" fn notify_halign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
7982 this: *mut ffi::GtkWidget,
7983 _param_spec: glib::ffi::gpointer,
7984 f: glib::ffi::gpointer,
7985 ) {
7986 unsafe {
7987 let f: &F = &*(f as *const F);
7988 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
7989 }
7990 }
7991 unsafe {
7992 let f: Box_<F> = Box_::new(f);
7993 connect_raw(
7994 self.as_ptr() as *mut _,
7995 c"notify::halign".as_ptr(),
7996 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
7997 notify_halign_trampoline::<Self, F> as *const (),
7998 )),
7999 Box_::into_raw(f),
8000 )
8001 }
8002 }
8003
8004 #[doc(alias = "has-default")]
8005 fn connect_has_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8006 unsafe extern "C" fn notify_has_default_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8007 this: *mut ffi::GtkWidget,
8008 _param_spec: glib::ffi::gpointer,
8009 f: glib::ffi::gpointer,
8010 ) {
8011 unsafe {
8012 let f: &F = &*(f as *const F);
8013 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8014 }
8015 }
8016 unsafe {
8017 let f: Box_<F> = Box_::new(f);
8018 connect_raw(
8019 self.as_ptr() as *mut _,
8020 c"notify::has-default".as_ptr(),
8021 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8022 notify_has_default_trampoline::<Self, F> as *const (),
8023 )),
8024 Box_::into_raw(f),
8025 )
8026 }
8027 }
8028
8029 #[doc(alias = "has-focus")]
8030 fn connect_has_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8031 unsafe extern "C" fn notify_has_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8032 this: *mut ffi::GtkWidget,
8033 _param_spec: glib::ffi::gpointer,
8034 f: glib::ffi::gpointer,
8035 ) {
8036 unsafe {
8037 let f: &F = &*(f as *const F);
8038 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8039 }
8040 }
8041 unsafe {
8042 let f: Box_<F> = Box_::new(f);
8043 connect_raw(
8044 self.as_ptr() as *mut _,
8045 c"notify::has-focus".as_ptr(),
8046 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8047 notify_has_focus_trampoline::<Self, F> as *const (),
8048 )),
8049 Box_::into_raw(f),
8050 )
8051 }
8052 }
8053
8054 #[doc(alias = "has-tooltip")]
8055 fn connect_has_tooltip_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8056 unsafe extern "C" fn notify_has_tooltip_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8057 this: *mut ffi::GtkWidget,
8058 _param_spec: glib::ffi::gpointer,
8059 f: glib::ffi::gpointer,
8060 ) {
8061 unsafe {
8062 let f: &F = &*(f as *const F);
8063 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8064 }
8065 }
8066 unsafe {
8067 let f: Box_<F> = Box_::new(f);
8068 connect_raw(
8069 self.as_ptr() as *mut _,
8070 c"notify::has-tooltip".as_ptr(),
8071 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8072 notify_has_tooltip_trampoline::<Self, F> as *const (),
8073 )),
8074 Box_::into_raw(f),
8075 )
8076 }
8077 }
8078
8079 #[doc(alias = "height-request")]
8080 fn connect_height_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8081 unsafe extern "C" fn notify_height_request_trampoline<
8082 P: IsA<Widget>,
8083 F: Fn(&P) + 'static,
8084 >(
8085 this: *mut ffi::GtkWidget,
8086 _param_spec: glib::ffi::gpointer,
8087 f: glib::ffi::gpointer,
8088 ) {
8089 unsafe {
8090 let f: &F = &*(f as *const F);
8091 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8092 }
8093 }
8094 unsafe {
8095 let f: Box_<F> = Box_::new(f);
8096 connect_raw(
8097 self.as_ptr() as *mut _,
8098 c"notify::height-request".as_ptr(),
8099 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8100 notify_height_request_trampoline::<Self, F> as *const (),
8101 )),
8102 Box_::into_raw(f),
8103 )
8104 }
8105 }
8106
8107 #[doc(alias = "hexpand")]
8108 fn connect_hexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8109 unsafe extern "C" fn notify_hexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8110 this: *mut ffi::GtkWidget,
8111 _param_spec: glib::ffi::gpointer,
8112 f: glib::ffi::gpointer,
8113 ) {
8114 unsafe {
8115 let f: &F = &*(f as *const F);
8116 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8117 }
8118 }
8119 unsafe {
8120 let f: Box_<F> = Box_::new(f);
8121 connect_raw(
8122 self.as_ptr() as *mut _,
8123 c"notify::hexpand".as_ptr(),
8124 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8125 notify_hexpand_trampoline::<Self, F> as *const (),
8126 )),
8127 Box_::into_raw(f),
8128 )
8129 }
8130 }
8131
8132 #[doc(alias = "hexpand-set")]
8133 fn connect_hexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8134 unsafe extern "C" fn notify_hexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8135 this: *mut ffi::GtkWidget,
8136 _param_spec: glib::ffi::gpointer,
8137 f: glib::ffi::gpointer,
8138 ) {
8139 unsafe {
8140 let f: &F = &*(f as *const F);
8141 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8142 }
8143 }
8144 unsafe {
8145 let f: Box_<F> = Box_::new(f);
8146 connect_raw(
8147 self.as_ptr() as *mut _,
8148 c"notify::hexpand-set".as_ptr(),
8149 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8150 notify_hexpand_set_trampoline::<Self, F> as *const (),
8151 )),
8152 Box_::into_raw(f),
8153 )
8154 }
8155 }
8156
8157 #[doc(alias = "is-focus")]
8158 fn connect_is_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8159 unsafe extern "C" fn notify_is_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8160 this: *mut ffi::GtkWidget,
8161 _param_spec: glib::ffi::gpointer,
8162 f: glib::ffi::gpointer,
8163 ) {
8164 unsafe {
8165 let f: &F = &*(f as *const F);
8166 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8167 }
8168 }
8169 unsafe {
8170 let f: Box_<F> = Box_::new(f);
8171 connect_raw(
8172 self.as_ptr() as *mut _,
8173 c"notify::is-focus".as_ptr(),
8174 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8175 notify_is_focus_trampoline::<Self, F> as *const (),
8176 )),
8177 Box_::into_raw(f),
8178 )
8179 }
8180 }
8181
8182 #[doc(alias = "margin")]
8183 fn connect_margin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8184 unsafe extern "C" fn notify_margin_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8185 this: *mut ffi::GtkWidget,
8186 _param_spec: glib::ffi::gpointer,
8187 f: glib::ffi::gpointer,
8188 ) {
8189 unsafe {
8190 let f: &F = &*(f as *const F);
8191 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8192 }
8193 }
8194 unsafe {
8195 let f: Box_<F> = Box_::new(f);
8196 connect_raw(
8197 self.as_ptr() as *mut _,
8198 c"notify::margin".as_ptr(),
8199 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8200 notify_margin_trampoline::<Self, F> as *const (),
8201 )),
8202 Box_::into_raw(f),
8203 )
8204 }
8205 }
8206
8207 #[doc(alias = "margin-bottom")]
8208 fn connect_margin_bottom_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8209 unsafe extern "C" fn notify_margin_bottom_trampoline<
8210 P: IsA<Widget>,
8211 F: Fn(&P) + 'static,
8212 >(
8213 this: *mut ffi::GtkWidget,
8214 _param_spec: glib::ffi::gpointer,
8215 f: glib::ffi::gpointer,
8216 ) {
8217 unsafe {
8218 let f: &F = &*(f as *const F);
8219 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8220 }
8221 }
8222 unsafe {
8223 let f: Box_<F> = Box_::new(f);
8224 connect_raw(
8225 self.as_ptr() as *mut _,
8226 c"notify::margin-bottom".as_ptr(),
8227 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8228 notify_margin_bottom_trampoline::<Self, F> as *const (),
8229 )),
8230 Box_::into_raw(f),
8231 )
8232 }
8233 }
8234
8235 #[doc(alias = "margin-end")]
8236 fn connect_margin_end_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8237 unsafe extern "C" fn notify_margin_end_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8238 this: *mut ffi::GtkWidget,
8239 _param_spec: glib::ffi::gpointer,
8240 f: glib::ffi::gpointer,
8241 ) {
8242 unsafe {
8243 let f: &F = &*(f as *const F);
8244 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8245 }
8246 }
8247 unsafe {
8248 let f: Box_<F> = Box_::new(f);
8249 connect_raw(
8250 self.as_ptr() as *mut _,
8251 c"notify::margin-end".as_ptr(),
8252 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8253 notify_margin_end_trampoline::<Self, F> as *const (),
8254 )),
8255 Box_::into_raw(f),
8256 )
8257 }
8258 }
8259
8260 #[doc(alias = "margin-start")]
8261 fn connect_margin_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8262 unsafe extern "C" fn notify_margin_start_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8263 this: *mut ffi::GtkWidget,
8264 _param_spec: glib::ffi::gpointer,
8265 f: glib::ffi::gpointer,
8266 ) {
8267 unsafe {
8268 let f: &F = &*(f as *const F);
8269 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8270 }
8271 }
8272 unsafe {
8273 let f: Box_<F> = Box_::new(f);
8274 connect_raw(
8275 self.as_ptr() as *mut _,
8276 c"notify::margin-start".as_ptr(),
8277 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8278 notify_margin_start_trampoline::<Self, F> as *const (),
8279 )),
8280 Box_::into_raw(f),
8281 )
8282 }
8283 }
8284
8285 #[doc(alias = "margin-top")]
8286 fn connect_margin_top_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8287 unsafe extern "C" fn notify_margin_top_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8288 this: *mut ffi::GtkWidget,
8289 _param_spec: glib::ffi::gpointer,
8290 f: glib::ffi::gpointer,
8291 ) {
8292 unsafe {
8293 let f: &F = &*(f as *const F);
8294 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8295 }
8296 }
8297 unsafe {
8298 let f: Box_<F> = Box_::new(f);
8299 connect_raw(
8300 self.as_ptr() as *mut _,
8301 c"notify::margin-top".as_ptr(),
8302 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8303 notify_margin_top_trampoline::<Self, F> as *const (),
8304 )),
8305 Box_::into_raw(f),
8306 )
8307 }
8308 }
8309
8310 #[doc(alias = "name")]
8311 fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8312 unsafe extern "C" fn notify_name_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8313 this: *mut ffi::GtkWidget,
8314 _param_spec: glib::ffi::gpointer,
8315 f: glib::ffi::gpointer,
8316 ) {
8317 unsafe {
8318 let f: &F = &*(f as *const F);
8319 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8320 }
8321 }
8322 unsafe {
8323 let f: Box_<F> = Box_::new(f);
8324 connect_raw(
8325 self.as_ptr() as *mut _,
8326 c"notify::name".as_ptr(),
8327 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8328 notify_name_trampoline::<Self, F> as *const (),
8329 )),
8330 Box_::into_raw(f),
8331 )
8332 }
8333 }
8334
8335 #[doc(alias = "no-show-all")]
8336 fn connect_no_show_all_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8337 unsafe extern "C" fn notify_no_show_all_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8338 this: *mut ffi::GtkWidget,
8339 _param_spec: glib::ffi::gpointer,
8340 f: glib::ffi::gpointer,
8341 ) {
8342 unsafe {
8343 let f: &F = &*(f as *const F);
8344 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8345 }
8346 }
8347 unsafe {
8348 let f: Box_<F> = Box_::new(f);
8349 connect_raw(
8350 self.as_ptr() as *mut _,
8351 c"notify::no-show-all".as_ptr(),
8352 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8353 notify_no_show_all_trampoline::<Self, F> as *const (),
8354 )),
8355 Box_::into_raw(f),
8356 )
8357 }
8358 }
8359
8360 #[doc(alias = "opacity")]
8361 fn connect_opacity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8362 unsafe extern "C" fn notify_opacity_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8363 this: *mut ffi::GtkWidget,
8364 _param_spec: glib::ffi::gpointer,
8365 f: glib::ffi::gpointer,
8366 ) {
8367 unsafe {
8368 let f: &F = &*(f as *const F);
8369 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8370 }
8371 }
8372 unsafe {
8373 let f: Box_<F> = Box_::new(f);
8374 connect_raw(
8375 self.as_ptr() as *mut _,
8376 c"notify::opacity".as_ptr(),
8377 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8378 notify_opacity_trampoline::<Self, F> as *const (),
8379 )),
8380 Box_::into_raw(f),
8381 )
8382 }
8383 }
8384
8385 #[doc(alias = "parent")]
8386 fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8387 unsafe extern "C" fn notify_parent_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8388 this: *mut ffi::GtkWidget,
8389 _param_spec: glib::ffi::gpointer,
8390 f: glib::ffi::gpointer,
8391 ) {
8392 unsafe {
8393 let f: &F = &*(f as *const F);
8394 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8395 }
8396 }
8397 unsafe {
8398 let f: Box_<F> = Box_::new(f);
8399 connect_raw(
8400 self.as_ptr() as *mut _,
8401 c"notify::parent".as_ptr(),
8402 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8403 notify_parent_trampoline::<Self, F> as *const (),
8404 )),
8405 Box_::into_raw(f),
8406 )
8407 }
8408 }
8409
8410 #[doc(alias = "receives-default")]
8411 fn connect_receives_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8412 unsafe extern "C" fn notify_receives_default_trampoline<
8413 P: IsA<Widget>,
8414 F: Fn(&P) + 'static,
8415 >(
8416 this: *mut ffi::GtkWidget,
8417 _param_spec: glib::ffi::gpointer,
8418 f: glib::ffi::gpointer,
8419 ) {
8420 unsafe {
8421 let f: &F = &*(f as *const F);
8422 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8423 }
8424 }
8425 unsafe {
8426 let f: Box_<F> = Box_::new(f);
8427 connect_raw(
8428 self.as_ptr() as *mut _,
8429 c"notify::receives-default".as_ptr(),
8430 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8431 notify_receives_default_trampoline::<Self, F> as *const (),
8432 )),
8433 Box_::into_raw(f),
8434 )
8435 }
8436 }
8437
8438 #[doc(alias = "scale-factor")]
8439 fn connect_scale_factor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8440 unsafe extern "C" fn notify_scale_factor_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8441 this: *mut ffi::GtkWidget,
8442 _param_spec: glib::ffi::gpointer,
8443 f: glib::ffi::gpointer,
8444 ) {
8445 unsafe {
8446 let f: &F = &*(f as *const F);
8447 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8448 }
8449 }
8450 unsafe {
8451 let f: Box_<F> = Box_::new(f);
8452 connect_raw(
8453 self.as_ptr() as *mut _,
8454 c"notify::scale-factor".as_ptr(),
8455 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8456 notify_scale_factor_trampoline::<Self, F> as *const (),
8457 )),
8458 Box_::into_raw(f),
8459 )
8460 }
8461 }
8462
8463 #[doc(alias = "sensitive")]
8464 fn connect_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8465 unsafe extern "C" fn notify_sensitive_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8466 this: *mut ffi::GtkWidget,
8467 _param_spec: glib::ffi::gpointer,
8468 f: glib::ffi::gpointer,
8469 ) {
8470 unsafe {
8471 let f: &F = &*(f as *const F);
8472 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8473 }
8474 }
8475 unsafe {
8476 let f: Box_<F> = Box_::new(f);
8477 connect_raw(
8478 self.as_ptr() as *mut _,
8479 c"notify::sensitive".as_ptr(),
8480 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8481 notify_sensitive_trampoline::<Self, F> as *const (),
8482 )),
8483 Box_::into_raw(f),
8484 )
8485 }
8486 }
8487
8488 #[doc(alias = "tooltip-markup")]
8489 fn connect_tooltip_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8490 unsafe extern "C" fn notify_tooltip_markup_trampoline<
8491 P: IsA<Widget>,
8492 F: Fn(&P) + 'static,
8493 >(
8494 this: *mut ffi::GtkWidget,
8495 _param_spec: glib::ffi::gpointer,
8496 f: glib::ffi::gpointer,
8497 ) {
8498 unsafe {
8499 let f: &F = &*(f as *const F);
8500 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8501 }
8502 }
8503 unsafe {
8504 let f: Box_<F> = Box_::new(f);
8505 connect_raw(
8506 self.as_ptr() as *mut _,
8507 c"notify::tooltip-markup".as_ptr(),
8508 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8509 notify_tooltip_markup_trampoline::<Self, F> as *const (),
8510 )),
8511 Box_::into_raw(f),
8512 )
8513 }
8514 }
8515
8516 #[doc(alias = "tooltip-text")]
8517 fn connect_tooltip_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8518 unsafe extern "C" fn notify_tooltip_text_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8519 this: *mut ffi::GtkWidget,
8520 _param_spec: glib::ffi::gpointer,
8521 f: glib::ffi::gpointer,
8522 ) {
8523 unsafe {
8524 let f: &F = &*(f as *const F);
8525 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8526 }
8527 }
8528 unsafe {
8529 let f: Box_<F> = Box_::new(f);
8530 connect_raw(
8531 self.as_ptr() as *mut _,
8532 c"notify::tooltip-text".as_ptr(),
8533 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8534 notify_tooltip_text_trampoline::<Self, F> as *const (),
8535 )),
8536 Box_::into_raw(f),
8537 )
8538 }
8539 }
8540
8541 #[doc(alias = "valign")]
8542 fn connect_valign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8543 unsafe extern "C" fn notify_valign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8544 this: *mut ffi::GtkWidget,
8545 _param_spec: glib::ffi::gpointer,
8546 f: glib::ffi::gpointer,
8547 ) {
8548 unsafe {
8549 let f: &F = &*(f as *const F);
8550 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8551 }
8552 }
8553 unsafe {
8554 let f: Box_<F> = Box_::new(f);
8555 connect_raw(
8556 self.as_ptr() as *mut _,
8557 c"notify::valign".as_ptr(),
8558 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8559 notify_valign_trampoline::<Self, F> as *const (),
8560 )),
8561 Box_::into_raw(f),
8562 )
8563 }
8564 }
8565
8566 #[doc(alias = "vexpand")]
8567 fn connect_vexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8568 unsafe extern "C" fn notify_vexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8569 this: *mut ffi::GtkWidget,
8570 _param_spec: glib::ffi::gpointer,
8571 f: glib::ffi::gpointer,
8572 ) {
8573 unsafe {
8574 let f: &F = &*(f as *const F);
8575 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8576 }
8577 }
8578 unsafe {
8579 let f: Box_<F> = Box_::new(f);
8580 connect_raw(
8581 self.as_ptr() as *mut _,
8582 c"notify::vexpand".as_ptr(),
8583 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8584 notify_vexpand_trampoline::<Self, F> as *const (),
8585 )),
8586 Box_::into_raw(f),
8587 )
8588 }
8589 }
8590
8591 #[doc(alias = "vexpand-set")]
8592 fn connect_vexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8593 unsafe extern "C" fn notify_vexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8594 this: *mut ffi::GtkWidget,
8595 _param_spec: glib::ffi::gpointer,
8596 f: glib::ffi::gpointer,
8597 ) {
8598 unsafe {
8599 let f: &F = &*(f as *const F);
8600 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8601 }
8602 }
8603 unsafe {
8604 let f: Box_<F> = Box_::new(f);
8605 connect_raw(
8606 self.as_ptr() as *mut _,
8607 c"notify::vexpand-set".as_ptr(),
8608 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8609 notify_vexpand_set_trampoline::<Self, F> as *const (),
8610 )),
8611 Box_::into_raw(f),
8612 )
8613 }
8614 }
8615
8616 #[doc(alias = "visible")]
8617 fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8618 unsafe extern "C" fn notify_visible_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8619 this: *mut ffi::GtkWidget,
8620 _param_spec: glib::ffi::gpointer,
8621 f: glib::ffi::gpointer,
8622 ) {
8623 unsafe {
8624 let f: &F = &*(f as *const F);
8625 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8626 }
8627 }
8628 unsafe {
8629 let f: Box_<F> = Box_::new(f);
8630 connect_raw(
8631 self.as_ptr() as *mut _,
8632 c"notify::visible".as_ptr(),
8633 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8634 notify_visible_trampoline::<Self, F> as *const (),
8635 )),
8636 Box_::into_raw(f),
8637 )
8638 }
8639 }
8640
8641 #[doc(alias = "width-request")]
8642 fn connect_width_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8643 unsafe extern "C" fn notify_width_request_trampoline<
8644 P: IsA<Widget>,
8645 F: Fn(&P) + 'static,
8646 >(
8647 this: *mut ffi::GtkWidget,
8648 _param_spec: glib::ffi::gpointer,
8649 f: glib::ffi::gpointer,
8650 ) {
8651 unsafe {
8652 let f: &F = &*(f as *const F);
8653 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8654 }
8655 }
8656 unsafe {
8657 let f: Box_<F> = Box_::new(f);
8658 connect_raw(
8659 self.as_ptr() as *mut _,
8660 c"notify::width-request".as_ptr(),
8661 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8662 notify_width_request_trampoline::<Self, F> as *const (),
8663 )),
8664 Box_::into_raw(f),
8665 )
8666 }
8667 }
8668
8669 #[doc(alias = "window")]
8670 fn connect_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
8671 unsafe extern "C" fn notify_window_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
8672 this: *mut ffi::GtkWidget,
8673 _param_spec: glib::ffi::gpointer,
8674 f: glib::ffi::gpointer,
8675 ) {
8676 unsafe {
8677 let f: &F = &*(f as *const F);
8678 f(Widget::from_glib_borrow(this).unsafe_cast_ref())
8679 }
8680 }
8681 unsafe {
8682 let f: Box_<F> = Box_::new(f);
8683 connect_raw(
8684 self.as_ptr() as *mut _,
8685 c"notify::window".as_ptr(),
8686 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
8687 notify_window_trampoline::<Self, F> as *const (),
8688 )),
8689 Box_::into_raw(f),
8690 )
8691 }
8692 }
8693}
8694
8695impl<O: IsA<Widget>> WidgetExt for O {}