gtk/auto/menu.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 AccelGroup, Align, Buildable, Container, MenuItem, MenuShell, ResizeMode, ScrollType, Widget,
7};
8use glib::{
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::{boxed::Box as Box_, fmt, mem::transmute};
14
15glib::wrapper! {
16 /// A [`Menu`][crate::Menu] is a [`MenuShell`][crate::MenuShell] that implements a drop down menu
17 /// consisting of a list of [`MenuItem`][crate::MenuItem] objects which can be navigated
18 /// and activated by the user to perform application functions.
19 ///
20 /// A [`Menu`][crate::Menu] is most commonly dropped down by activating a
21 /// [`MenuItem`][crate::MenuItem] in a [`MenuBar`][crate::MenuBar] or popped up by activating a
22 /// [`MenuItem`][crate::MenuItem] in another [`Menu`][crate::Menu].
23 ///
24 /// A [`Menu`][crate::Menu] can also be popped up by activating a [`ComboBox`][crate::ComboBox].
25 /// Other composite widgets such as the [`Notebook`][crate::Notebook] can pop up a
26 /// [`Menu`][crate::Menu] as well.
27 ///
28 /// Applications can display a [`Menu`][crate::Menu] as a popup menu by calling the
29 /// `gtk_menu_popup()` function. The example below shows how an application
30 /// can pop up a menu when the 3rd mouse button is pressed.
31 ///
32 /// ## Connecting the popup signal handler.
33 ///
34 ///
35 ///
36 /// **⚠️ The following code is in C ⚠️**
37 ///
38 /// ```C
39 /// // connect our handler which will popup the menu
40 /// g_signal_connect_swapped (window, "button_press_event",
41 /// G_CALLBACK (my_popup_handler), menu);
42 /// ```
43 ///
44 /// ## Signal handler which displays a popup menu.
45 ///
46 ///
47 ///
48 /// **⚠️ The following code is in C ⚠️**
49 ///
50 /// ```C
51 /// static gint
52 /// my_popup_handler (GtkWidget *widget, GdkEvent *event)
53 /// {
54 /// GtkMenu *menu;
55 /// GdkEventButton *event_button;
56 ///
57 /// g_return_val_if_fail (widget != NULL, FALSE);
58 /// g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
59 /// g_return_val_if_fail (event != NULL, FALSE);
60 ///
61 /// // The "widget" is the menu that was supplied when
62 /// // g_signal_connect_swapped() was called.
63 /// menu = GTK_MENU (widget);
64 ///
65 /// if (event->type == GDK_BUTTON_PRESS)
66 /// {
67 /// event_button = (GdkEventButton *) event;
68 /// if (event_button->button == GDK_BUTTON_SECONDARY)
69 /// {
70 /// gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
71 /// event_button->button, event_button->time);
72 /// return TRUE;
73 /// }
74 /// }
75 ///
76 /// return FALSE;
77 /// }
78 /// ```
79 ///
80 /// # CSS nodes
81 ///
82 ///
83 ///
84 /// **⚠️ The following code is in plain ⚠️**
85 ///
86 /// ```plain
87 /// menu
88 /// ├── arrow.top
89 /// ├── <child>
90 /// ┊
91 /// ├── <child>
92 /// ╰── arrow.bottom
93 /// ```
94 ///
95 /// The main CSS node of GtkMenu has name menu, and there are two subnodes
96 /// with name arrow, for scrolling menu arrows. These subnodes get the
97 /// .top and .bottom style classes.
98 ///
99 /// ## Properties
100 ///
101 ///
102 /// #### `accel-group`
103 /// The accel group holding accelerators for the menu.
104 ///
105 /// Readable | Writeable
106 ///
107 ///
108 /// #### `accel-path`
109 /// An accel path used to conveniently construct accel paths of child items.
110 ///
111 /// Readable | Writeable
112 ///
113 ///
114 /// #### `active`
115 /// The index of the currently selected menu item, or -1 if no
116 /// menu item is selected.
117 ///
118 /// Readable | Writeable
119 ///
120 ///
121 /// #### `anchor-hints`
122 /// Positioning hints for aligning the menu relative to a rectangle.
123 ///
124 /// These hints determine how the menu should be positioned in the case that
125 /// the menu would fall off-screen if placed in its ideal position.
126 ///
127 /// 
128 ///
129 /// For example, [`gdk::AnchorHints::FLIP_Y`][crate::gdk::AnchorHints::FLIP_Y] will replace [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] with
130 /// [`gdk::Gravity::SouthWest`][crate::gdk::Gravity::SouthWest] and vice versa if the menu extends beyond the
131 /// bottom edge of the monitor.
132 ///
133 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
134 /// gtk_menu_popup_at_pointer (), [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx],
135 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
136 ///
137 /// Readable | Writeable | Construct
138 ///
139 ///
140 /// #### `attach-widget`
141 /// The widget the menu is attached to. Setting this property attaches
142 /// the menu without a `GtkMenuDetachFunc`. If you need to use a detacher,
143 /// use `gtk_menu_attach_to_widget()` directly.
144 ///
145 /// Readable | Writeable
146 ///
147 ///
148 /// #### `menu-type-hint`
149 /// The [`gdk::WindowTypeHint`][crate::gdk::WindowTypeHint] to use for the menu's [`gdk::Window`][crate::gdk::Window].
150 ///
151 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
152 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
153 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and [`popped-up`][struct@crate::Menu#popped-up].
154 ///
155 /// Readable | Writeable | Construct
156 ///
157 ///
158 /// #### `monitor`
159 /// The monitor the menu will be popped up on.
160 ///
161 /// Readable | Writeable
162 ///
163 ///
164 /// #### `rect-anchor-dx`
165 /// Horizontal offset to apply to the menu, i.e. the rectangle or widget
166 /// anchor.
167 ///
168 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
169 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
170 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
171 ///
172 /// Readable | Writeable | Construct
173 ///
174 ///
175 /// #### `rect-anchor-dy`
176 /// Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
177 ///
178 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
179 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
180 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
181 ///
182 /// Readable | Writeable | Construct
183 ///
184 ///
185 /// #### `reserve-toggle-size`
186 /// A boolean that indicates whether the menu reserves space for
187 /// toggles and icons, regardless of their actual presence.
188 ///
189 /// This property should only be changed from its default value
190 /// for special-purposes such as tabular menus. Regular menus that
191 /// are connected to a menu bar or context menus should reserve
192 /// toggle space for consistency.
193 ///
194 /// Readable | Writeable
195 ///
196 ///
197 /// #### `tearoff-state`
198 /// A boolean that indicates whether the menu is torn-off.
199 ///
200 /// Readable | Writeable
201 ///
202 ///
203 /// #### `tearoff-title`
204 /// A title that may be displayed by the window manager when this
205 /// menu is torn-off.
206 ///
207 /// Readable | Writeable
208 /// <details><summary><h4>MenuShell</h4></summary>
209 ///
210 ///
211 /// #### `take-focus`
212 /// A boolean that determines whether the menu and its submenus grab the
213 /// keyboard focus. See [`MenuShellExt::set_take_focus()`][crate::prelude::MenuShellExt::set_take_focus()] and
214 /// [`MenuShellExt::takes_focus()`][crate::prelude::MenuShellExt::takes_focus()].
215 ///
216 /// Readable | Writeable
217 /// </details>
218 /// <details><summary><h4>Container</h4></summary>
219 ///
220 ///
221 /// #### `border-width`
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `child`
226 /// Writeable
227 ///
228 ///
229 /// #### `resize-mode`
230 /// Readable | Writeable
231 /// </details>
232 /// <details><summary><h4>Widget</h4></summary>
233 ///
234 ///
235 /// #### `app-paintable`
236 /// Readable | Writeable
237 ///
238 ///
239 /// #### `can-default`
240 /// Readable | Writeable
241 ///
242 ///
243 /// #### `can-focus`
244 /// Readable | Writeable
245 ///
246 ///
247 /// #### `composite-child`
248 /// Readable
249 ///
250 ///
251 /// #### `double-buffered`
252 /// Whether the widget is double buffered.
253 ///
254 /// Readable | Writeable
255 ///
256 ///
257 /// #### `events`
258 /// Readable | Writeable
259 ///
260 ///
261 /// #### `expand`
262 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
263 ///
264 /// Readable | Writeable
265 ///
266 ///
267 /// #### `focus-on-click`
268 /// Whether the widget should grab focus when it is clicked with the mouse.
269 ///
270 /// This property is only relevant for widgets that can take focus.
271 ///
272 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
273 /// GtkComboBox) implemented this property individually.
274 ///
275 /// Readable | Writeable
276 ///
277 ///
278 /// #### `halign`
279 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
280 ///
281 /// Readable | Writeable
282 ///
283 ///
284 /// #### `has-default`
285 /// Readable | Writeable
286 ///
287 ///
288 /// #### `has-focus`
289 /// Readable | Writeable
290 ///
291 ///
292 /// #### `has-tooltip`
293 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
294 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
295 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
296 /// whether it will provide a tooltip or not.
297 ///
298 /// Note that setting this property to [`true`] for the first time will change
299 /// the event masks of the GdkWindows of this widget to include leave-notify
300 /// and motion-notify events. This cannot and will not be undone when the
301 /// property is set to [`false`] again.
302 ///
303 /// Readable | Writeable
304 ///
305 ///
306 /// #### `height-request`
307 /// Readable | Writeable
308 ///
309 ///
310 /// #### `hexpand`
311 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
312 ///
313 /// Readable | Writeable
314 ///
315 ///
316 /// #### `hexpand-set`
317 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
318 ///
319 /// Readable | Writeable
320 ///
321 ///
322 /// #### `is-focus`
323 /// Readable | Writeable
324 ///
325 ///
326 /// #### `margin`
327 /// Sets all four sides' margin at once. If read, returns max
328 /// margin on any side.
329 ///
330 /// Readable | Writeable
331 ///
332 ///
333 /// #### `margin-bottom`
334 /// Margin on bottom side of widget.
335 ///
336 /// This property adds margin outside of the widget's normal size
337 /// request, the margin will be added in addition to the size from
338 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
339 ///
340 /// Readable | Writeable
341 ///
342 ///
343 /// #### `margin-end`
344 /// Margin on end of widget, horizontally. This property supports
345 /// left-to-right and right-to-left text directions.
346 ///
347 /// This property adds margin outside of the widget's normal size
348 /// request, the margin will be added in addition to the size from
349 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
350 ///
351 /// Readable | Writeable
352 ///
353 ///
354 /// #### `margin-left`
355 /// Margin on left side of widget.
356 ///
357 /// This property adds margin outside of the widget's normal size
358 /// request, the margin will be added in addition to the size from
359 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
360 ///
361 /// Readable | Writeable
362 ///
363 ///
364 /// #### `margin-right`
365 /// Margin on right side of widget.
366 ///
367 /// This property adds margin outside of the widget's normal size
368 /// request, the margin will be added in addition to the size from
369 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
370 ///
371 /// Readable | Writeable
372 ///
373 ///
374 /// #### `margin-start`
375 /// Margin on start of widget, horizontally. This property supports
376 /// left-to-right and right-to-left text directions.
377 ///
378 /// This property adds margin outside of the widget's normal size
379 /// request, the margin will be added in addition to the size from
380 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
381 ///
382 /// Readable | Writeable
383 ///
384 ///
385 /// #### `margin-top`
386 /// Margin on top side of widget.
387 ///
388 /// This property adds margin outside of the widget's normal size
389 /// request, the margin will be added in addition to the size from
390 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
391 ///
392 /// Readable | Writeable
393 ///
394 ///
395 /// #### `name`
396 /// Readable | Writeable
397 ///
398 ///
399 /// #### `no-show-all`
400 /// Readable | Writeable
401 ///
402 ///
403 /// #### `opacity`
404 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
405 /// more details about window opacity.
406 ///
407 /// Before 3.8 this was only available in GtkWindow
408 ///
409 /// Readable | Writeable
410 ///
411 ///
412 /// #### `parent`
413 /// Readable | Writeable
414 ///
415 ///
416 /// #### `receives-default`
417 /// Readable | Writeable
418 ///
419 ///
420 /// #### `scale-factor`
421 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
422 /// more details about widget scaling.
423 ///
424 /// Readable
425 ///
426 ///
427 /// #### `sensitive`
428 /// Readable | Writeable
429 ///
430 ///
431 /// #### `style`
432 /// The style of the widget, which contains information about how it will look (colors, etc).
433 ///
434 /// Readable | Writeable
435 ///
436 ///
437 /// #### `tooltip-markup`
438 /// Sets the text of tooltip to be the given string, which is marked up
439 /// with the [Pango text markup language][PangoMarkupFormat].
440 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
441 ///
442 /// This is a convenience property which will take care of getting the
443 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
444 /// will automatically be set to [`true`] and there will be taken care of
445 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
446 ///
447 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
448 /// are set, the last one wins.
449 ///
450 /// Readable | Writeable
451 ///
452 ///
453 /// #### `tooltip-text`
454 /// Sets the text of tooltip to be the given string.
455 ///
456 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
457 ///
458 /// This is a convenience property which will take care of getting the
459 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
460 /// will automatically be set to [`true`] and there will be taken care of
461 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
462 ///
463 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
464 /// are set, the last one wins.
465 ///
466 /// Readable | Writeable
467 ///
468 ///
469 /// #### `valign`
470 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
471 ///
472 /// Readable | Writeable
473 ///
474 ///
475 /// #### `vexpand`
476 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
477 ///
478 /// Readable | Writeable
479 ///
480 ///
481 /// #### `vexpand-set`
482 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
483 ///
484 /// Readable | Writeable
485 ///
486 ///
487 /// #### `visible`
488 /// Readable | Writeable
489 ///
490 ///
491 /// #### `width-request`
492 /// Readable | Writeable
493 ///
494 ///
495 /// #### `window`
496 /// The widget's window if it is realized, [`None`] otherwise.
497 ///
498 /// Readable
499 /// </details>
500 ///
501 /// ## Signals
502 ///
503 ///
504 /// #### `move-scroll`
505 /// Action
506 ///
507 ///
508 /// #### `popped-up`
509 /// Emitted when the position of `menu` is finalized after being popped up
510 /// using gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), or
511 /// gtk_menu_popup_at_pointer ().
512 ///
513 /// `menu` might be flipped over the anchor rectangle in order to keep it
514 /// on-screen, in which case `flipped_x` and `flipped_y` will be set to [`true`]
515 /// accordingly.
516 ///
517 /// `flipped_rect` is the ideal position of `menu` after any possible flipping,
518 /// but before any possible sliding. `final_rect` is `flipped_rect`, but possibly
519 /// translated in the case that flipping is still ineffective in keeping `menu`
520 /// on-screen.
521 ///
522 /// 
523 ///
524 /// The blue menu is `menu`'s ideal position, the green menu is `flipped_rect`,
525 /// and the red menu is `final_rect`.
526 ///
527 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
528 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
529 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and
530 /// [`menu-type-hint`][struct@crate::Menu#menu-type-hint].
531 ///
532 ///
533 /// <details><summary><h4>MenuShell</h4></summary>
534 ///
535 ///
536 /// #### `activate-current`
537 /// An action signal that activates the current menu item within
538 /// the menu shell.
539 ///
540 /// Action
541 ///
542 ///
543 /// #### `cancel`
544 /// An action signal which cancels the selection within the menu shell.
545 /// Causes the [`selection-done`][struct@crate::MenuShell#selection-done] signal to be emitted.
546 ///
547 /// Action
548 ///
549 ///
550 /// #### `cycle-focus`
551 /// A keybinding signal which moves the focus in the
552 /// given `direction`.
553 ///
554 /// Action
555 ///
556 ///
557 /// #### `deactivate`
558 /// This signal is emitted when a menu shell is deactivated.
559 ///
560 ///
561 ///
562 ///
563 /// #### `insert`
564 /// The ::insert signal is emitted when a new [`MenuItem`][crate::MenuItem] is added to
565 /// a [`MenuShell`][crate::MenuShell]. A separate signal is used instead of
566 /// GtkContainer::add because of the need for an additional position
567 /// parameter.
568 ///
569 /// The inverse of this signal is the GtkContainer::removed signal.
570 ///
571 ///
572 ///
573 ///
574 /// #### `move-current`
575 /// An keybinding signal which moves the current menu item
576 /// in the direction specified by `direction`.
577 ///
578 /// Action
579 ///
580 ///
581 /// #### `move-selected`
582 /// The ::move-selected signal is emitted to move the selection to
583 /// another item.
584 ///
585 ///
586 ///
587 ///
588 /// #### `selection-done`
589 /// This signal is emitted when a selection has been
590 /// completed within a menu shell.
591 ///
592 ///
593 /// </details>
594 /// <details><summary><h4>Container</h4></summary>
595 ///
596 ///
597 /// #### `add`
598 ///
599 ///
600 ///
601 /// #### `check-resize`
602 ///
603 ///
604 ///
605 /// #### `remove`
606 ///
607 ///
608 ///
609 /// #### `set-focus-child`
610 ///
611 /// </details>
612 /// <details><summary><h4>Widget</h4></summary>
613 ///
614 ///
615 /// #### `accel-closures-changed`
616 ///
617 ///
618 ///
619 /// #### `button-press-event`
620 /// The ::button-press-event signal will be emitted when a button
621 /// (typically from a mouse) is pressed.
622 ///
623 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
624 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
625 ///
626 /// This signal will be sent to the grab widget if there is one.
627 ///
628 ///
629 ///
630 ///
631 /// #### `button-release-event`
632 /// The ::button-release-event signal will be emitted when a button
633 /// (typically from a mouse) is released.
634 ///
635 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
636 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
637 ///
638 /// This signal will be sent to the grab widget if there is one.
639 ///
640 ///
641 ///
642 ///
643 /// #### `can-activate-accel`
644 /// Determines whether an accelerator that activates the signal
645 /// identified by `signal_id` can currently be activated.
646 /// This signal is present to allow applications and derived
647 /// widgets to override the default [`Widget`][crate::Widget] handling
648 /// for determining whether an accelerator can be activated.
649 ///
650 ///
651 ///
652 ///
653 /// #### `child-notify`
654 /// The ::child-notify signal is emitted for each
655 /// [child property][child-properties] that has
656 /// changed on an object. The signal's detail holds the property name.
657 ///
658 /// Detailed
659 ///
660 ///
661 /// #### `composited-changed`
662 /// The ::composited-changed signal is emitted when the composited
663 /// status of `widgets` screen changes.
664 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
665 ///
666 /// Action
667 ///
668 ///
669 /// #### `configure-event`
670 /// The ::configure-event signal will be emitted when the size, position or
671 /// stacking of the `widget`'s window has changed.
672 ///
673 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
674 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
675 /// automatically for all new windows.
676 ///
677 ///
678 ///
679 ///
680 /// #### `damage-event`
681 /// Emitted when a redirected window belonging to `widget` gets drawn into.
682 /// The region/area members of the event shows what area of the redirected
683 /// drawable was drawn into.
684 ///
685 ///
686 ///
687 ///
688 /// #### `delete-event`
689 /// The ::delete-event signal is emitted if a user requests that
690 /// a toplevel window is closed. The default handler for this signal
691 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
692 /// this signal will cause the window to be hidden instead, so that
693 /// it can later be shown again without reconstructing it.
694 ///
695 ///
696 ///
697 ///
698 /// #### `destroy`
699 /// Signals that all holders of a reference to the widget should release
700 /// the reference that they hold. May result in finalization of the widget
701 /// if all references are released.
702 ///
703 /// This signal is not suitable for saving widget state.
704 ///
705 ///
706 ///
707 ///
708 /// #### `destroy-event`
709 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
710 /// You rarely get this signal, because most widgets disconnect themselves
711 /// from their window before they destroy it, so no widget owns the
712 /// window at destroy time.
713 ///
714 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
715 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
716 /// automatically for all new windows.
717 ///
718 ///
719 ///
720 ///
721 /// #### `direction-changed`
722 /// The ::direction-changed signal is emitted when the text direction
723 /// of a widget changes.
724 ///
725 ///
726 ///
727 ///
728 /// #### `drag-begin`
729 /// The ::drag-begin signal is emitted on the drag source when a drag is
730 /// started. A typical reason to connect to this signal is to set up a
731 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
732 ///
733 /// Note that some widgets set up a drag icon in the default handler of
734 /// this signal, so you may have to use `g_signal_connect_after()` to
735 /// override what the default handler did.
736 ///
737 ///
738 ///
739 ///
740 /// #### `drag-data-delete`
741 /// The ::drag-data-delete signal is emitted on the drag source when a drag
742 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
743 /// handler is responsible for deleting the data that has been dropped. What
744 /// "delete" means depends on the context of the drag operation.
745 ///
746 ///
747 ///
748 ///
749 /// #### `drag-data-get`
750 /// The ::drag-data-get signal is emitted on the drag source when the drop
751 /// site requests the data which is dragged. It is the responsibility of
752 /// the signal handler to fill `data` with the data in the format which
753 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
754 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
755 ///
756 ///
757 ///
758 ///
759 /// #### `drag-data-received`
760 /// The ::drag-data-received signal is emitted on the drop site when the
761 /// dragged data has been received. If the data was received in order to
762 /// determine whether the drop will be accepted, the handler is expected
763 /// to call `gdk_drag_status()` and not finish the drag.
764 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
765 /// (and this is the last target to be received), the handler for this
766 /// signal is expected to process the received data and then call
767 /// `gtk_drag_finish()`, setting the `success` parameter depending on
768 /// whether the data was processed successfully.
769 ///
770 /// Applications must create some means to determine why the signal was emitted
771 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
772 ///
773 /// The handler may inspect the selected action with
774 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
775 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
776 /// shown in the following example:
777 ///
778 ///
779 /// **⚠️ The following code is in C ⚠️**
780 ///
781 /// ```C
782 /// void
783 /// drag_data_received (GtkWidget *widget,
784 /// GdkDragContext *context,
785 /// gint x,
786 /// gint y,
787 /// GtkSelectionData *data,
788 /// guint info,
789 /// guint time)
790 /// {
791 /// if ((data->length >= 0) && (data->format == 8))
792 /// {
793 /// GdkDragAction action;
794 ///
795 /// // handle data here
796 ///
797 /// action = gdk_drag_context_get_selected_action (context);
798 /// if (action == GDK_ACTION_ASK)
799 /// {
800 /// GtkWidget *dialog;
801 /// gint response;
802 ///
803 /// dialog = gtk_message_dialog_new (NULL,
804 /// GTK_DIALOG_MODAL |
805 /// GTK_DIALOG_DESTROY_WITH_PARENT,
806 /// GTK_MESSAGE_INFO,
807 /// GTK_BUTTONS_YES_NO,
808 /// "Move the data ?\n");
809 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
810 /// gtk_widget_destroy (dialog);
811 ///
812 /// if (response == GTK_RESPONSE_YES)
813 /// action = GDK_ACTION_MOVE;
814 /// else
815 /// action = GDK_ACTION_COPY;
816 /// }
817 ///
818 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
819 /// }
820 /// else
821 /// gtk_drag_finish (context, FALSE, FALSE, time);
822 /// }
823 /// ```
824 ///
825 ///
826 ///
827 ///
828 /// #### `drag-drop`
829 /// The ::drag-drop signal is emitted on the drop site when the user drops
830 /// the data onto the widget. The signal handler must determine whether
831 /// the cursor position is in a drop zone or not. If it is not in a drop
832 /// zone, it returns [`false`] and no further processing is necessary.
833 /// Otherwise, the handler returns [`true`]. In this case, the handler must
834 /// ensure that `gtk_drag_finish()` is called to let the source know that
835 /// the drop is done. The call to `gtk_drag_finish()` can be done either
836 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
837 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
838 /// or more of the supported targets.
839 ///
840 ///
841 ///
842 ///
843 /// #### `drag-end`
844 /// The ::drag-end signal is emitted on the drag source when a drag is
845 /// finished. A typical reason to connect to this signal is to undo
846 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
847 ///
848 ///
849 ///
850 ///
851 /// #### `drag-failed`
852 /// The ::drag-failed signal is emitted on the drag source when a drag has
853 /// failed. The signal handler may hook custom code to handle a failed DnD
854 /// operation based on the type of error, it returns [`true`] is the failure has
855 /// been already handled (not showing the default "drag operation failed"
856 /// animation), otherwise it returns [`false`].
857 ///
858 ///
859 ///
860 ///
861 /// #### `drag-leave`
862 /// The ::drag-leave signal is emitted on the drop site when the cursor
863 /// leaves the widget. A typical reason to connect to this signal is to
864 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
865 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
866 ///
867 ///
868 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
869 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
870 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
871 ///
872 ///
873 ///
874 ///
875 /// #### `drag-motion`
876 /// The ::drag-motion signal is emitted on the drop site when the user
877 /// moves the cursor over the widget during a drag. The signal handler
878 /// must determine whether the cursor position is in a drop zone or not.
879 /// If it is not in a drop zone, it returns [`false`] and no further processing
880 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
881 /// handler is responsible for providing the necessary information for
882 /// displaying feedback to the user, by calling `gdk_drag_status()`.
883 ///
884 /// If the decision whether the drop will be accepted or rejected can't be
885 /// made based solely on the cursor position and the type of the data, the
886 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
887 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
888 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
889 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
890 /// when using the drag-motion signal that way.
891 ///
892 /// Also note that there is no drag-enter signal. The drag receiver has to
893 /// keep track of whether he has received any drag-motion signals since the
894 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
895 /// an "enter" signal. Upon an "enter", the handler will typically highlight
896 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
897 ///
898 ///
899 /// **⚠️ The following code is in C ⚠️**
900 ///
901 /// ```C
902 /// static void
903 /// drag_motion (GtkWidget *widget,
904 /// GdkDragContext *context,
905 /// gint x,
906 /// gint y,
907 /// guint time)
908 /// {
909 /// GdkAtom target;
910 ///
911 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
912 ///
913 /// if (!private_data->drag_highlight)
914 /// {
915 /// private_data->drag_highlight = 1;
916 /// gtk_drag_highlight (widget);
917 /// }
918 ///
919 /// target = gtk_drag_dest_find_target (widget, context, NULL);
920 /// if (target == GDK_NONE)
921 /// gdk_drag_status (context, 0, time);
922 /// else
923 /// {
924 /// private_data->pending_status
925 /// = gdk_drag_context_get_suggested_action (context);
926 /// gtk_drag_get_data (widget, context, target, time);
927 /// }
928 ///
929 /// return TRUE;
930 /// }
931 ///
932 /// static void
933 /// drag_data_received (GtkWidget *widget,
934 /// GdkDragContext *context,
935 /// gint x,
936 /// gint y,
937 /// GtkSelectionData *selection_data,
938 /// guint info,
939 /// guint time)
940 /// {
941 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
942 ///
943 /// if (private_data->suggested_action)
944 /// {
945 /// private_data->suggested_action = 0;
946 ///
947 /// // We are getting this data due to a request in drag_motion,
948 /// // rather than due to a request in drag_drop, so we are just
949 /// // supposed to call gdk_drag_status(), not actually paste in
950 /// // the data.
951 ///
952 /// str = gtk_selection_data_get_text (selection_data);
953 /// if (!data_is_acceptable (str))
954 /// gdk_drag_status (context, 0, time);
955 /// else
956 /// gdk_drag_status (context,
957 /// private_data->suggested_action,
958 /// time);
959 /// }
960 /// else
961 /// {
962 /// // accept the drop
963 /// }
964 /// }
965 /// ```
966 ///
967 ///
968 ///
969 ///
970 /// #### `draw`
971 /// This signal is emitted when a widget is supposed to render itself.
972 /// The `widget`'s top left corner must be painted at the origin of
973 /// the passed in context and be sized to the values returned by
974 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
975 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
976 ///
977 /// Signal handlers connected to this signal can modify the cairo
978 /// context passed as `cr` in any way they like and don't need to
979 /// restore it. The signal emission takes care of calling `cairo_save()`
980 /// before and `cairo_restore()` after invoking the handler.
981 ///
982 /// The signal handler will get a `cr` with a clip region already set to the
983 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
984 /// widgets that want to avoid redrawing themselves completely can get the full
985 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
986 /// get a finer-grained representation of the dirty region with
987 /// `cairo_copy_clip_rectangle_list()`.
988 ///
989 ///
990 ///
991 ///
992 /// #### `enter-notify-event`
993 /// The ::enter-notify-event will be emitted when the pointer enters
994 /// the `widget`'s window.
995 ///
996 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
997 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
998 ///
999 /// This signal will be sent to the grab widget if there is one.
1000 ///
1001 ///
1002 ///
1003 ///
1004 /// #### `event`
1005 /// The GTK+ main loop will emit three signals for each GDK event delivered
1006 /// to a widget: one generic ::event signal, another, more specific,
1007 /// signal that matches the type of event delivered (e.g.
1008 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
1009 /// [`event-after`][struct@crate::Widget#event-after] signal.
1010 ///
1011 ///
1012 ///
1013 ///
1014 /// #### `event-after`
1015 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
1016 /// the second more specific signal, ::event-after will be emitted
1017 /// regardless of the previous two signals handlers return values.
1018 ///
1019 ///
1020 ///
1021 ///
1022 /// #### `focus`
1023 ///
1024 ///
1025 ///
1026 /// #### `focus-in-event`
1027 /// The ::focus-in-event signal will be emitted when the keyboard focus
1028 /// enters the `widget`'s window.
1029 ///
1030 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1031 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1032 ///
1033 ///
1034 ///
1035 ///
1036 /// #### `focus-out-event`
1037 /// The ::focus-out-event signal will be emitted when the keyboard focus
1038 /// leaves the `widget`'s window.
1039 ///
1040 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1041 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1042 ///
1043 ///
1044 ///
1045 ///
1046 /// #### `grab-broken-event`
1047 /// Emitted when a pointer or keyboard grab on a window belonging
1048 /// to `widget` gets broken.
1049 ///
1050 /// On X11, this happens when the grab window becomes unviewable
1051 /// (i.e. it or one of its ancestors is unmapped), or if the same
1052 /// application grabs the pointer or keyboard again.
1053 ///
1054 ///
1055 ///
1056 ///
1057 /// #### `grab-focus`
1058 /// Action
1059 ///
1060 ///
1061 /// #### `grab-notify`
1062 /// The ::grab-notify signal is emitted when a widget becomes
1063 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1064 /// another widget, or when it becomes unshadowed due to a grab
1065 /// being removed.
1066 ///
1067 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
1068 /// grab widget in the grab stack of its window group is not
1069 /// its ancestor.
1070 ///
1071 ///
1072 ///
1073 ///
1074 /// #### `hide`
1075 /// The ::hide signal is emitted when `widget` is hidden, for example with
1076 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
1077 ///
1078 ///
1079 ///
1080 ///
1081 /// #### `hierarchy-changed`
1082 /// The ::hierarchy-changed signal is emitted when the
1083 /// anchored state of a widget changes. A widget is
1084 /// “anchored” when its toplevel
1085 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
1086 /// a widget changes from un-anchored to anchored or vice-versa.
1087 ///
1088 ///
1089 ///
1090 ///
1091 /// #### `key-press-event`
1092 /// The ::key-press-event signal is emitted when a key is pressed. The signal
1093 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
1094 ///
1095 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1096 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
1097 ///
1098 /// This signal will be sent to the grab widget if there is one.
1099 ///
1100 ///
1101 ///
1102 ///
1103 /// #### `key-release-event`
1104 /// The ::key-release-event signal is emitted when a key is released.
1105 ///
1106 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1107 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
1108 ///
1109 /// This signal will be sent to the grab widget if there is one.
1110 ///
1111 ///
1112 ///
1113 ///
1114 /// #### `keynav-failed`
1115 /// Gets emitted if keyboard navigation fails.
1116 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
1117 ///
1118 ///
1119 ///
1120 ///
1121 /// #### `leave-notify-event`
1122 /// The ::leave-notify-event will be emitted when the pointer leaves
1123 /// the `widget`'s window.
1124 ///
1125 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1126 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1127 ///
1128 /// This signal will be sent to the grab widget if there is one.
1129 ///
1130 ///
1131 ///
1132 ///
1133 /// #### `map`
1134 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1135 /// when the widget is visible (which is controlled with
1136 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1137 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1138 /// be emitted.
1139 ///
1140 /// The ::map signal can be used to determine whether a widget will be drawn,
1141 /// for instance it can resume an animation that was stopped during the
1142 /// emission of [`unmap`][struct@crate::Widget#unmap].
1143 ///
1144 ///
1145 ///
1146 ///
1147 /// #### `map-event`
1148 /// The ::map-event signal will be emitted when the `widget`'s window is
1149 /// mapped. A window is mapped when it becomes visible on the screen.
1150 ///
1151 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1152 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1153 /// automatically for all new windows.
1154 ///
1155 ///
1156 ///
1157 ///
1158 /// #### `mnemonic-activate`
1159 /// The default handler for this signal activates `widget` if `group_cycling`
1160 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1161 ///
1162 ///
1163 ///
1164 ///
1165 /// #### `motion-notify-event`
1166 /// The ::motion-notify-event signal is emitted when the pointer moves
1167 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1168 ///
1169 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1170 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1171 ///
1172 /// This signal will be sent to the grab widget if there is one.
1173 ///
1174 ///
1175 ///
1176 ///
1177 /// #### `move-focus`
1178 /// Action
1179 ///
1180 ///
1181 /// #### `parent-set`
1182 /// The ::parent-set signal is emitted when a new parent
1183 /// has been set on a widget.
1184 ///
1185 ///
1186 ///
1187 ///
1188 /// #### `popup-menu`
1189 /// This signal gets emitted whenever a widget should pop up a context
1190 /// menu. This usually happens through the standard key binding mechanism;
1191 /// by pressing a certain key while a widget is focused, the user can cause
1192 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1193 /// a menu with clipboard commands. See the
1194 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1195 /// for an example of how to use this signal.
1196 ///
1197 /// Action
1198 ///
1199 ///
1200 /// #### `property-notify-event`
1201 /// The ::property-notify-event signal will be emitted when a property on
1202 /// the `widget`'s window has been changed or deleted.
1203 ///
1204 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1205 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1206 ///
1207 ///
1208 ///
1209 ///
1210 /// #### `proximity-in-event`
1211 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1212 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1213 ///
1214 /// This signal will be sent to the grab widget if there is one.
1215 ///
1216 ///
1217 ///
1218 ///
1219 /// #### `proximity-out-event`
1220 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1221 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1222 ///
1223 /// This signal will be sent to the grab widget if there is one.
1224 ///
1225 ///
1226 ///
1227 ///
1228 /// #### `query-tooltip`
1229 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1230 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1231 /// focus in keyboard mode.
1232 ///
1233 /// Using the given coordinates, the signal handler should determine
1234 /// whether a tooltip should be shown for `widget`. If this is the case
1235 /// [`true`] should be returned, [`false`] otherwise. Note that if
1236 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1237 /// should not be used.
1238 ///
1239 /// The signal handler is free to manipulate `tooltip` with the therefore
1240 /// destined function calls.
1241 ///
1242 ///
1243 ///
1244 ///
1245 /// #### `realize`
1246 /// The ::realize signal is emitted when `widget` is associated with a
1247 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1248 /// widget has been mapped (that is, it is going to be drawn).
1249 ///
1250 ///
1251 ///
1252 ///
1253 /// #### `screen-changed`
1254 /// The ::screen-changed signal gets emitted when the
1255 /// screen of a widget has changed.
1256 ///
1257 ///
1258 ///
1259 ///
1260 /// #### `scroll-event`
1261 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1262 /// range is pressed. Wheel mice are usually configured to generate
1263 /// button press events for buttons 4 and 5 when the wheel is turned.
1264 ///
1265 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1266 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1267 ///
1268 /// This signal will be sent to the grab widget if there is one.
1269 ///
1270 ///
1271 ///
1272 ///
1273 /// #### `selection-clear-event`
1274 /// The ::selection-clear-event signal will be emitted when the
1275 /// the `widget`'s window has lost ownership of a selection.
1276 ///
1277 ///
1278 ///
1279 ///
1280 /// #### `selection-get`
1281 ///
1282 ///
1283 ///
1284 /// #### `selection-notify-event`
1285 ///
1286 ///
1287 ///
1288 /// #### `selection-received`
1289 ///
1290 ///
1291 ///
1292 /// #### `selection-request-event`
1293 /// The ::selection-request-event signal will be emitted when
1294 /// another client requests ownership of the selection owned by
1295 /// the `widget`'s window.
1296 ///
1297 ///
1298 ///
1299 ///
1300 /// #### `show`
1301 /// The ::show signal is emitted when `widget` is shown, for example with
1302 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1303 ///
1304 ///
1305 ///
1306 ///
1307 /// #### `show-help`
1308 /// Action
1309 ///
1310 ///
1311 /// #### `size-allocate`
1312 ///
1313 ///
1314 ///
1315 /// #### `state-changed`
1316 /// The ::state-changed signal is emitted when the widget state changes.
1317 /// See `gtk_widget_get_state()`.
1318 ///
1319 ///
1320 ///
1321 ///
1322 /// #### `state-flags-changed`
1323 /// The ::state-flags-changed signal is emitted when the widget state
1324 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1325 ///
1326 ///
1327 ///
1328 ///
1329 /// #### `style-set`
1330 /// The ::style-set signal is emitted when a new style has been set
1331 /// on a widget. Note that style-modifying functions like
1332 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1333 ///
1334 /// Note that this signal is emitted for changes to the deprecated
1335 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1336 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1337 ///
1338 ///
1339 ///
1340 ///
1341 /// #### `style-updated`
1342 /// The ::style-updated signal is a convenience signal that is emitted when the
1343 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1344 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1345 ///
1346 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1347 /// cause this signal to be emitted.
1348 ///
1349 ///
1350 ///
1351 ///
1352 /// #### `touch-event`
1353 ///
1354 ///
1355 ///
1356 /// #### `unmap`
1357 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1358 /// means that either it or any of its parents up to the toplevel widget have
1359 /// been set as hidden.
1360 ///
1361 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1362 /// used to, for example, stop an animation on the widget.
1363 ///
1364 ///
1365 ///
1366 ///
1367 /// #### `unmap-event`
1368 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1369 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1370 ///
1371 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1372 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1373 /// automatically for all new windows.
1374 ///
1375 ///
1376 ///
1377 ///
1378 /// #### `unrealize`
1379 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1380 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1381 /// called or the widget has been unmapped (that is, it is going to be
1382 /// hidden).
1383 ///
1384 ///
1385 ///
1386 ///
1387 /// #### `visibility-notify-event`
1388 /// The ::visibility-notify-event will be emitted when the `widget`'s
1389 /// window is obscured or unobscured.
1390 ///
1391 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1392 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1393 ///
1394 ///
1395 ///
1396 ///
1397 /// #### `window-state-event`
1398 /// The ::window-state-event will be emitted when the state of the
1399 /// toplevel window associated to the `widget` changes.
1400 ///
1401 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1402 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1403 /// this mask automatically for all new windows.
1404 ///
1405 ///
1406 /// </details>
1407 ///
1408 /// # Implements
1409 ///
1410 /// [`GtkMenuExt`][trait@crate::prelude::GtkMenuExt], [`MenuShellExt`][trait@crate::prelude::MenuShellExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`GtkMenuExtManual`][trait@crate::prelude::GtkMenuExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1411 #[doc(alias = "GtkMenu")]
1412 pub struct Menu(Object<ffi::GtkMenu, ffi::GtkMenuClass>) @extends MenuShell, Container, Widget, @implements Buildable;
1413
1414 match fn {
1415 type_ => || ffi::gtk_menu_get_type(),
1416 }
1417}
1418
1419impl Menu {
1420 pub const NONE: Option<&'static Menu> = None;
1421
1422 /// Creates a new [`Menu`][crate::Menu]
1423 ///
1424 /// # Returns
1425 ///
1426 /// a new [`Menu`][crate::Menu]
1427 #[doc(alias = "gtk_menu_new")]
1428 pub fn new() -> Menu {
1429 assert_initialized_main_thread!();
1430 unsafe { Widget::from_glib_none(ffi::gtk_menu_new()).unsafe_cast() }
1431 }
1432
1433 /// Creates a [`Menu`][crate::Menu] and populates it with menu items and
1434 /// submenus according to `model`.
1435 ///
1436 /// The created menu items are connected to actions found in the
1437 /// [`ApplicationWindow`][crate::ApplicationWindow] to which the menu belongs - typically
1438 /// by means of being attached to a widget (see `gtk_menu_attach_to_widget()`)
1439 /// that is contained within the `GtkApplicationWindows` widget hierarchy.
1440 ///
1441 /// Actions can also be added using [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()] on the menu's
1442 /// attach widget or on any of its parent widgets.
1443 /// ## `model`
1444 /// a [`gio::MenuModel`][crate::gio::MenuModel]
1445 ///
1446 /// # Returns
1447 ///
1448 /// a new [`Menu`][crate::Menu]
1449 #[doc(alias = "gtk_menu_new_from_model")]
1450 #[doc(alias = "new_from_model")]
1451 pub fn from_model(model: &impl IsA<gio::MenuModel>) -> Menu {
1452 assert_initialized_main_thread!();
1453 unsafe {
1454 Widget::from_glib_none(ffi::gtk_menu_new_from_model(
1455 model.as_ref().to_glib_none().0,
1456 ))
1457 .unsafe_cast()
1458 }
1459 }
1460
1461 // rustdoc-stripper-ignore-next
1462 /// Creates a new builder-pattern struct instance to construct [`Menu`] objects.
1463 ///
1464 /// This method returns an instance of [`MenuBuilder`](crate::builders::MenuBuilder) which can be used to create [`Menu`] objects.
1465 pub fn builder() -> MenuBuilder {
1466 MenuBuilder::new()
1467 }
1468
1469 /// Returns a list of the menus which are attached to this widget.
1470 /// This list is owned by GTK+ and must not be modified.
1471 /// ## `widget`
1472 /// a [`Widget`][crate::Widget]
1473 ///
1474 /// # Returns
1475 ///
1476 /// the list
1477 /// of menus attached to his widget.
1478 #[doc(alias = "gtk_menu_get_for_attach_widget")]
1479 #[doc(alias = "get_for_attach_widget")]
1480 pub fn for_attach_widget(widget: &impl IsA<Widget>) -> Vec<Widget> {
1481 skip_assert_initialized!();
1482 unsafe {
1483 FromGlibPtrContainer::from_glib_none(ffi::gtk_menu_get_for_attach_widget(
1484 widget.as_ref().to_glib_none().0,
1485 ))
1486 }
1487 }
1488}
1489
1490impl Default for Menu {
1491 fn default() -> Self {
1492 Self::new()
1493 }
1494}
1495
1496// rustdoc-stripper-ignore-next
1497/// A [builder-pattern] type to construct [`Menu`] objects.
1498///
1499/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1500#[must_use = "The builder must be built to be used"]
1501pub struct MenuBuilder {
1502 builder: glib::object::ObjectBuilder<'static, Menu>,
1503}
1504
1505impl MenuBuilder {
1506 fn new() -> Self {
1507 Self {
1508 builder: glib::object::Object::builder(),
1509 }
1510 }
1511
1512 /// The accel group holding accelerators for the menu.
1513 pub fn accel_group(self, accel_group: &impl IsA<AccelGroup>) -> Self {
1514 Self {
1515 builder: self
1516 .builder
1517 .property("accel-group", accel_group.clone().upcast()),
1518 }
1519 }
1520
1521 /// An accel path used to conveniently construct accel paths of child items.
1522 pub fn accel_path(self, accel_path: impl Into<glib::GString>) -> Self {
1523 Self {
1524 builder: self.builder.property("accel-path", accel_path.into()),
1525 }
1526 }
1527
1528 /// The index of the currently selected menu item, or -1 if no
1529 /// menu item is selected.
1530 pub fn active(self, active: i32) -> Self {
1531 Self {
1532 builder: self.builder.property("active", active),
1533 }
1534 }
1535
1536 /// Positioning hints for aligning the menu relative to a rectangle.
1537 ///
1538 /// These hints determine how the menu should be positioned in the case that
1539 /// the menu would fall off-screen if placed in its ideal position.
1540 ///
1541 /// 
1542 ///
1543 /// For example, [`gdk::AnchorHints::FLIP_Y`][crate::gdk::AnchorHints::FLIP_Y] will replace [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] with
1544 /// [`gdk::Gravity::SouthWest`][crate::gdk::Gravity::SouthWest] and vice versa if the menu extends beyond the
1545 /// bottom edge of the monitor.
1546 ///
1547 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
1548 /// gtk_menu_popup_at_pointer (), [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx],
1549 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
1550 pub fn anchor_hints(self, anchor_hints: gdk::AnchorHints) -> Self {
1551 Self {
1552 builder: self.builder.property("anchor-hints", anchor_hints),
1553 }
1554 }
1555
1556 /// The widget the menu is attached to. Setting this property attaches
1557 /// the menu without a `GtkMenuDetachFunc`. If you need to use a detacher,
1558 /// use `gtk_menu_attach_to_widget()` directly.
1559 pub fn attach_widget(self, attach_widget: &impl IsA<Widget>) -> Self {
1560 Self {
1561 builder: self
1562 .builder
1563 .property("attach-widget", attach_widget.clone().upcast()),
1564 }
1565 }
1566
1567 /// The [`gdk::WindowTypeHint`][crate::gdk::WindowTypeHint] to use for the menu's [`gdk::Window`][crate::gdk::Window].
1568 ///
1569 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
1570 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
1571 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and [`popped-up`][struct@crate::Menu#popped-up].
1572 pub fn menu_type_hint(self, menu_type_hint: gdk::WindowTypeHint) -> Self {
1573 Self {
1574 builder: self.builder.property("menu-type-hint", menu_type_hint),
1575 }
1576 }
1577
1578 /// The monitor the menu will be popped up on.
1579 pub fn monitor(self, monitor: i32) -> Self {
1580 Self {
1581 builder: self.builder.property("monitor", monitor),
1582 }
1583 }
1584
1585 /// Horizontal offset to apply to the menu, i.e. the rectangle or widget
1586 /// anchor.
1587 ///
1588 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
1589 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
1590 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
1591 pub fn rect_anchor_dx(self, rect_anchor_dx: i32) -> Self {
1592 Self {
1593 builder: self.builder.property("rect-anchor-dx", rect_anchor_dx),
1594 }
1595 }
1596
1597 /// Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
1598 ///
1599 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
1600 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
1601 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
1602 pub fn rect_anchor_dy(self, rect_anchor_dy: i32) -> Self {
1603 Self {
1604 builder: self.builder.property("rect-anchor-dy", rect_anchor_dy),
1605 }
1606 }
1607
1608 /// A boolean that indicates whether the menu reserves space for
1609 /// toggles and icons, regardless of their actual presence.
1610 ///
1611 /// This property should only be changed from its default value
1612 /// for special-purposes such as tabular menus. Regular menus that
1613 /// are connected to a menu bar or context menus should reserve
1614 /// toggle space for consistency.
1615 pub fn reserve_toggle_size(self, reserve_toggle_size: bool) -> Self {
1616 Self {
1617 builder: self
1618 .builder
1619 .property("reserve-toggle-size", reserve_toggle_size),
1620 }
1621 }
1622
1623 /// A boolean that determines whether the menu and its submenus grab the
1624 /// keyboard focus. See [`MenuShellExt::set_take_focus()`][crate::prelude::MenuShellExt::set_take_focus()] and
1625 /// [`MenuShellExt::takes_focus()`][crate::prelude::MenuShellExt::takes_focus()].
1626 pub fn take_focus(self, take_focus: bool) -> Self {
1627 Self {
1628 builder: self.builder.property("take-focus", take_focus),
1629 }
1630 }
1631
1632 pub fn border_width(self, border_width: u32) -> Self {
1633 Self {
1634 builder: self.builder.property("border-width", border_width),
1635 }
1636 }
1637
1638 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1639 Self {
1640 builder: self.builder.property("child", child.clone().upcast()),
1641 }
1642 }
1643
1644 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1645 Self {
1646 builder: self.builder.property("resize-mode", resize_mode),
1647 }
1648 }
1649
1650 pub fn app_paintable(self, app_paintable: bool) -> Self {
1651 Self {
1652 builder: self.builder.property("app-paintable", app_paintable),
1653 }
1654 }
1655
1656 pub fn can_default(self, can_default: bool) -> Self {
1657 Self {
1658 builder: self.builder.property("can-default", can_default),
1659 }
1660 }
1661
1662 pub fn can_focus(self, can_focus: bool) -> Self {
1663 Self {
1664 builder: self.builder.property("can-focus", can_focus),
1665 }
1666 }
1667
1668 pub fn events(self, events: gdk::EventMask) -> Self {
1669 Self {
1670 builder: self.builder.property("events", events),
1671 }
1672 }
1673
1674 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1675 pub fn expand(self, expand: bool) -> Self {
1676 Self {
1677 builder: self.builder.property("expand", expand),
1678 }
1679 }
1680
1681 /// Whether the widget should grab focus when it is clicked with the mouse.
1682 ///
1683 /// This property is only relevant for widgets that can take focus.
1684 ///
1685 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1686 /// GtkComboBox) implemented this property individually.
1687 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1688 Self {
1689 builder: self.builder.property("focus-on-click", focus_on_click),
1690 }
1691 }
1692
1693 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1694 pub fn halign(self, halign: Align) -> Self {
1695 Self {
1696 builder: self.builder.property("halign", halign),
1697 }
1698 }
1699
1700 pub fn has_default(self, has_default: bool) -> Self {
1701 Self {
1702 builder: self.builder.property("has-default", has_default),
1703 }
1704 }
1705
1706 pub fn has_focus(self, has_focus: bool) -> Self {
1707 Self {
1708 builder: self.builder.property("has-focus", has_focus),
1709 }
1710 }
1711
1712 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1713 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1714 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1715 /// whether it will provide a tooltip or not.
1716 ///
1717 /// Note that setting this property to [`true`] for the first time will change
1718 /// the event masks of the GdkWindows of this widget to include leave-notify
1719 /// and motion-notify events. This cannot and will not be undone when the
1720 /// property is set to [`false`] again.
1721 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1722 Self {
1723 builder: self.builder.property("has-tooltip", has_tooltip),
1724 }
1725 }
1726
1727 pub fn height_request(self, height_request: i32) -> Self {
1728 Self {
1729 builder: self.builder.property("height-request", height_request),
1730 }
1731 }
1732
1733 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1734 pub fn hexpand(self, hexpand: bool) -> Self {
1735 Self {
1736 builder: self.builder.property("hexpand", hexpand),
1737 }
1738 }
1739
1740 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1741 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1742 Self {
1743 builder: self.builder.property("hexpand-set", hexpand_set),
1744 }
1745 }
1746
1747 pub fn is_focus(self, is_focus: bool) -> Self {
1748 Self {
1749 builder: self.builder.property("is-focus", is_focus),
1750 }
1751 }
1752
1753 /// Sets all four sides' margin at once. If read, returns max
1754 /// margin on any side.
1755 pub fn margin(self, margin: i32) -> Self {
1756 Self {
1757 builder: self.builder.property("margin", margin),
1758 }
1759 }
1760
1761 /// Margin on bottom side of widget.
1762 ///
1763 /// This property adds margin outside of the widget's normal size
1764 /// request, the margin will be added in addition to the size from
1765 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1766 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1767 Self {
1768 builder: self.builder.property("margin-bottom", margin_bottom),
1769 }
1770 }
1771
1772 /// Margin on end of widget, horizontally. This property supports
1773 /// left-to-right and right-to-left text directions.
1774 ///
1775 /// This property adds margin outside of the widget's normal size
1776 /// request, the margin will be added in addition to the size from
1777 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1778 pub fn margin_end(self, margin_end: i32) -> Self {
1779 Self {
1780 builder: self.builder.property("margin-end", margin_end),
1781 }
1782 }
1783
1784 /// Margin on start of widget, horizontally. This property supports
1785 /// left-to-right and right-to-left text directions.
1786 ///
1787 /// This property adds margin outside of the widget's normal size
1788 /// request, the margin will be added in addition to the size from
1789 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1790 pub fn margin_start(self, margin_start: i32) -> Self {
1791 Self {
1792 builder: self.builder.property("margin-start", margin_start),
1793 }
1794 }
1795
1796 /// Margin on top side of widget.
1797 ///
1798 /// This property adds margin outside of the widget's normal size
1799 /// request, the margin will be added in addition to the size from
1800 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1801 pub fn margin_top(self, margin_top: i32) -> Self {
1802 Self {
1803 builder: self.builder.property("margin-top", margin_top),
1804 }
1805 }
1806
1807 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1808 Self {
1809 builder: self.builder.property("name", name.into()),
1810 }
1811 }
1812
1813 pub fn no_show_all(self, no_show_all: bool) -> Self {
1814 Self {
1815 builder: self.builder.property("no-show-all", no_show_all),
1816 }
1817 }
1818
1819 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1820 /// more details about window opacity.
1821 ///
1822 /// Before 3.8 this was only available in GtkWindow
1823 pub fn opacity(self, opacity: f64) -> Self {
1824 Self {
1825 builder: self.builder.property("opacity", opacity),
1826 }
1827 }
1828
1829 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1830 Self {
1831 builder: self.builder.property("parent", parent.clone().upcast()),
1832 }
1833 }
1834
1835 pub fn receives_default(self, receives_default: bool) -> Self {
1836 Self {
1837 builder: self.builder.property("receives-default", receives_default),
1838 }
1839 }
1840
1841 pub fn sensitive(self, sensitive: bool) -> Self {
1842 Self {
1843 builder: self.builder.property("sensitive", sensitive),
1844 }
1845 }
1846
1847 /// Sets the text of tooltip to be the given string, which is marked up
1848 /// with the [Pango text markup language][PangoMarkupFormat].
1849 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1850 ///
1851 /// This is a convenience property which will take care of getting the
1852 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1853 /// will automatically be set to [`true`] and there will be taken care of
1854 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1855 ///
1856 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1857 /// are set, the last one wins.
1858 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1859 Self {
1860 builder: self
1861 .builder
1862 .property("tooltip-markup", tooltip_markup.into()),
1863 }
1864 }
1865
1866 /// Sets the text of tooltip to be the given string.
1867 ///
1868 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1869 ///
1870 /// This is a convenience property which will take care of getting the
1871 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1872 /// will automatically be set to [`true`] and there will be taken care of
1873 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1874 ///
1875 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1876 /// are set, the last one wins.
1877 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1878 Self {
1879 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1880 }
1881 }
1882
1883 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1884 pub fn valign(self, valign: Align) -> Self {
1885 Self {
1886 builder: self.builder.property("valign", valign),
1887 }
1888 }
1889
1890 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1891 pub fn vexpand(self, vexpand: bool) -> Self {
1892 Self {
1893 builder: self.builder.property("vexpand", vexpand),
1894 }
1895 }
1896
1897 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1898 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1899 Self {
1900 builder: self.builder.property("vexpand-set", vexpand_set),
1901 }
1902 }
1903
1904 pub fn visible(self, visible: bool) -> Self {
1905 Self {
1906 builder: self.builder.property("visible", visible),
1907 }
1908 }
1909
1910 pub fn width_request(self, width_request: i32) -> Self {
1911 Self {
1912 builder: self.builder.property("width-request", width_request),
1913 }
1914 }
1915
1916 // rustdoc-stripper-ignore-next
1917 /// Build the [`Menu`].
1918 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1919 pub fn build(self) -> Menu {
1920 self.builder.build()
1921 }
1922}
1923
1924mod sealed {
1925 pub trait Sealed {}
1926 impl<T: super::IsA<super::Menu>> Sealed for T {}
1927}
1928
1929/// Trait containing all [`struct@Menu`] methods.
1930///
1931/// # Implementors
1932///
1933/// [`Menu`][struct@crate::Menu], [`RecentChooserMenu`][struct@crate::RecentChooserMenu]
1934pub trait GtkMenuExt: IsA<Menu> + sealed::Sealed + 'static {
1935 /// Adds a new [`MenuItem`][crate::MenuItem] to a (table) menu. The number of “cells” that
1936 /// an item will occupy is specified by `left_attach`, `right_attach`,
1937 /// `top_attach` and `bottom_attach`. These each represent the leftmost,
1938 /// rightmost, uppermost and lower column and row numbers of the table.
1939 /// (Columns and rows are indexed from zero).
1940 ///
1941 /// Note that this function is not related to [`detach()`][Self::detach()].
1942 /// ## `child`
1943 /// a [`MenuItem`][crate::MenuItem]
1944 /// ## `left_attach`
1945 /// The column number to attach the left side of the item to
1946 /// ## `right_attach`
1947 /// The column number to attach the right side of the item to
1948 /// ## `top_attach`
1949 /// The row number to attach the top of the item to
1950 /// ## `bottom_attach`
1951 /// The row number to attach the bottom of the item to
1952 #[doc(alias = "gtk_menu_attach")]
1953 fn attach(
1954 &self,
1955 child: &impl IsA<Widget>,
1956 left_attach: u32,
1957 right_attach: u32,
1958 top_attach: u32,
1959 bottom_attach: u32,
1960 ) {
1961 unsafe {
1962 ffi::gtk_menu_attach(
1963 self.as_ref().to_glib_none().0,
1964 child.as_ref().to_glib_none().0,
1965 left_attach,
1966 right_attach,
1967 top_attach,
1968 bottom_attach,
1969 );
1970 }
1971 }
1972
1973 /// Detaches the menu from the widget to which it had been attached.
1974 /// This function will call the callback function, `detacher`, provided
1975 /// when the `gtk_menu_attach_to_widget()` function was called.
1976 #[doc(alias = "gtk_menu_detach")]
1977 fn detach(&self) {
1978 unsafe {
1979 ffi::gtk_menu_detach(self.as_ref().to_glib_none().0);
1980 }
1981 }
1982
1983 /// Gets the [`AccelGroup`][crate::AccelGroup] which holds global accelerators for the
1984 /// menu. See [`set_accel_group()`][Self::set_accel_group()].
1985 ///
1986 /// # Returns
1987 ///
1988 /// the [`AccelGroup`][crate::AccelGroup] associated with the menu
1989 #[doc(alias = "gtk_menu_get_accel_group")]
1990 #[doc(alias = "get_accel_group")]
1991 fn accel_group(&self) -> Option<AccelGroup> {
1992 unsafe {
1993 from_glib_none(ffi::gtk_menu_get_accel_group(
1994 self.as_ref().to_glib_none().0,
1995 ))
1996 }
1997 }
1998
1999 /// Retrieves the accelerator path set on the menu.
2000 ///
2001 /// # Returns
2002 ///
2003 /// the accelerator path set on the menu.
2004 #[doc(alias = "gtk_menu_get_accel_path")]
2005 #[doc(alias = "get_accel_path")]
2006 fn accel_path(&self) -> Option<glib::GString> {
2007 unsafe { from_glib_none(ffi::gtk_menu_get_accel_path(self.as_ref().to_glib_none().0)) }
2008 }
2009
2010 /// Returns the selected menu item from the menu. This is used by the
2011 /// [`ComboBox`][crate::ComboBox].
2012 ///
2013 /// # Returns
2014 ///
2015 /// the [`MenuItem`][crate::MenuItem] that was last selected
2016 /// in the menu. If a selection has not yet been made, the
2017 /// first menu item is selected.
2018 #[doc(alias = "gtk_menu_get_active")]
2019 #[doc(alias = "get_active")]
2020 fn active(&self) -> Option<Widget> {
2021 unsafe { from_glib_none(ffi::gtk_menu_get_active(self.as_ref().to_glib_none().0)) }
2022 }
2023
2024 /// Returns the [`Widget`][crate::Widget] that the menu is attached to.
2025 ///
2026 /// # Returns
2027 ///
2028 /// the [`Widget`][crate::Widget] that the menu is attached to
2029 #[doc(alias = "gtk_menu_get_attach_widget")]
2030 #[doc(alias = "get_attach_widget")]
2031 fn attach_widget(&self) -> Option<Widget> {
2032 unsafe {
2033 from_glib_none(ffi::gtk_menu_get_attach_widget(
2034 self.as_ref().to_glib_none().0,
2035 ))
2036 }
2037 }
2038
2039 /// Retrieves the number of the monitor on which to show the menu.
2040 ///
2041 /// # Returns
2042 ///
2043 /// the number of the monitor on which the menu should
2044 /// be popped up or -1, if no monitor has been set
2045 #[doc(alias = "gtk_menu_get_monitor")]
2046 #[doc(alias = "get_monitor")]
2047 fn monitor(&self) -> i32 {
2048 unsafe { ffi::gtk_menu_get_monitor(self.as_ref().to_glib_none().0) }
2049 }
2050
2051 /// Returns whether the menu reserves space for toggles and
2052 /// icons, regardless of their actual presence.
2053 ///
2054 /// # Returns
2055 ///
2056 /// Whether the menu reserves toggle space
2057 #[doc(alias = "gtk_menu_get_reserve_toggle_size")]
2058 #[doc(alias = "get_reserve_toggle_size")]
2059 fn must_reserve_toggle_size(&self) -> bool {
2060 unsafe {
2061 from_glib(ffi::gtk_menu_get_reserve_toggle_size(
2062 self.as_ref().to_glib_none().0,
2063 ))
2064 }
2065 }
2066
2067 /// Places `self` on the given monitor.
2068 /// ## `monitor`
2069 /// the monitor to place the menu on
2070 #[doc(alias = "gtk_menu_place_on_monitor")]
2071 fn place_on_monitor(&self, monitor: &gdk::Monitor) {
2072 unsafe {
2073 ffi::gtk_menu_place_on_monitor(
2074 self.as_ref().to_glib_none().0,
2075 monitor.to_glib_none().0,
2076 );
2077 }
2078 }
2079
2080 /// Removes the menu from the screen.
2081 #[doc(alias = "gtk_menu_popdown")]
2082 fn popdown(&self) {
2083 unsafe {
2084 ffi::gtk_menu_popdown(self.as_ref().to_glib_none().0);
2085 }
2086 }
2087
2088 /// Displays `self` and makes it available for selection.
2089 ///
2090 /// See gtk_menu_popup_at_widget () to pop up a menu at a widget.
2091 /// gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary
2092 /// rectangle.
2093 ///
2094 /// `self` will be positioned at the pointer associated with `trigger_event`.
2095 ///
2096 /// Properties that influence the behaviour of this function are
2097 /// [`anchor-hints`][struct@crate::Menu#anchor-hints], [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and
2098 /// [`menu-type-hint`][struct@crate::Menu#menu-type-hint]. Connect to the [`popped-up`][struct@crate::Menu#popped-up] signal to find
2099 /// out how it was actually positioned.
2100 /// ## `trigger_event`
2101 /// the `GdkEvent` that initiated this request or
2102 /// [`None`] if it's the current event
2103 #[doc(alias = "gtk_menu_popup_at_pointer")]
2104 fn popup_at_pointer(&self, trigger_event: Option<&gdk::Event>) {
2105 unsafe {
2106 ffi::gtk_menu_popup_at_pointer(
2107 self.as_ref().to_glib_none().0,
2108 trigger_event.to_glib_none().0,
2109 );
2110 }
2111 }
2112
2113 /// Displays `self` and makes it available for selection.
2114 ///
2115 /// See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which
2116 /// handle more common cases for popping up menus.
2117 ///
2118 /// `self` will be positioned at `rect`, aligning their anchor points. `rect` is
2119 /// relative to the top-left corner of `rect_window`. `rect_anchor` and
2120 /// `menu_anchor` determine anchor points on `rect` and `self` to pin together.
2121 /// `self` can optionally be offset by [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx] and
2122 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy].
2123 ///
2124 /// Anchors should be specified under the assumption that the text direction is
2125 /// left-to-right; they will be flipped horizontally automatically if the text
2126 /// direction is right-to-left.
2127 ///
2128 /// Other properties that influence the behaviour of this function are
2129 /// [`anchor-hints`][struct@crate::Menu#anchor-hints] and [`menu-type-hint`][struct@crate::Menu#menu-type-hint]. Connect to the
2130 /// [`popped-up`][struct@crate::Menu#popped-up] signal to find out how it was actually positioned.
2131 /// ## `rect_window`
2132 /// the [`gdk::Window`][crate::gdk::Window] `rect` is relative to
2133 /// ## `rect`
2134 /// the [`gdk::Rectangle`][crate::gdk::Rectangle] to align `self` with
2135 /// ## `rect_anchor`
2136 /// the point on `rect` to align with `self`'s anchor point
2137 /// ## `menu_anchor`
2138 /// the point on `self` to align with `rect`'s anchor point
2139 /// ## `trigger_event`
2140 /// the `GdkEvent` that initiated this request or
2141 /// [`None`] if it's the current event
2142 #[doc(alias = "gtk_menu_popup_at_rect")]
2143 fn popup_at_rect(
2144 &self,
2145 rect_window: &gdk::Window,
2146 rect: &gdk::Rectangle,
2147 rect_anchor: gdk::Gravity,
2148 menu_anchor: gdk::Gravity,
2149 trigger_event: Option<&gdk::Event>,
2150 ) {
2151 unsafe {
2152 ffi::gtk_menu_popup_at_rect(
2153 self.as_ref().to_glib_none().0,
2154 rect_window.to_glib_none().0,
2155 rect.to_glib_none().0,
2156 rect_anchor.into_glib(),
2157 menu_anchor.into_glib(),
2158 trigger_event.to_glib_none().0,
2159 );
2160 }
2161 }
2162
2163 /// Displays `self` and makes it available for selection.
2164 ///
2165 /// See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer.
2166 /// gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary
2167 /// rectangle.
2168 ///
2169 /// 
2170 ///
2171 /// `self` will be positioned at `widget`, aligning their anchor points.
2172 /// `widget_anchor` and `menu_anchor` determine anchor points on `widget` and `self`
2173 /// to pin together. `self` can optionally be offset by [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx]
2174 /// and [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy].
2175 ///
2176 /// Anchors should be specified under the assumption that the text direction is
2177 /// left-to-right; they will be flipped horizontally automatically if the text
2178 /// direction is right-to-left.
2179 ///
2180 /// Other properties that influence the behaviour of this function are
2181 /// [`anchor-hints`][struct@crate::Menu#anchor-hints] and [`menu-type-hint`][struct@crate::Menu#menu-type-hint]. Connect to the
2182 /// [`popped-up`][struct@crate::Menu#popped-up] signal to find out how it was actually positioned.
2183 /// ## `widget`
2184 /// the [`Widget`][crate::Widget] to align `self` with
2185 /// ## `widget_anchor`
2186 /// the point on `widget` to align with `self`'s anchor point
2187 /// ## `menu_anchor`
2188 /// the point on `self` to align with `widget`'s anchor point
2189 /// ## `trigger_event`
2190 /// the `GdkEvent` that initiated this request or
2191 /// [`None`] if it's the current event
2192 #[doc(alias = "gtk_menu_popup_at_widget")]
2193 fn popup_at_widget(
2194 &self,
2195 widget: &impl IsA<Widget>,
2196 widget_anchor: gdk::Gravity,
2197 menu_anchor: gdk::Gravity,
2198 trigger_event: Option<&gdk::Event>,
2199 ) {
2200 unsafe {
2201 ffi::gtk_menu_popup_at_widget(
2202 self.as_ref().to_glib_none().0,
2203 widget.as_ref().to_glib_none().0,
2204 widget_anchor.into_glib(),
2205 menu_anchor.into_glib(),
2206 trigger_event.to_glib_none().0,
2207 );
2208 }
2209 }
2210
2211 /// Moves `child` to a new `position` in the list of `self`
2212 /// children.
2213 /// ## `child`
2214 /// the [`MenuItem`][crate::MenuItem] to move
2215 /// ## `position`
2216 /// the new position to place `child`.
2217 /// Positions are numbered from 0 to n - 1
2218 #[doc(alias = "gtk_menu_reorder_child")]
2219 fn reorder_child(&self, child: &impl IsA<Widget>, position: i32) {
2220 unsafe {
2221 ffi::gtk_menu_reorder_child(
2222 self.as_ref().to_glib_none().0,
2223 child.as_ref().to_glib_none().0,
2224 position,
2225 );
2226 }
2227 }
2228
2229 /// Repositions the menu according to its position function.
2230 #[doc(alias = "gtk_menu_reposition")]
2231 fn reposition(&self) {
2232 unsafe {
2233 ffi::gtk_menu_reposition(self.as_ref().to_glib_none().0);
2234 }
2235 }
2236
2237 /// Set the [`AccelGroup`][crate::AccelGroup] which holds global accelerators for the
2238 /// menu. This accelerator group needs to also be added to all windows
2239 /// that this menu is being used in with [`GtkWindowExt::add_accel_group()`][crate::prelude::GtkWindowExt::add_accel_group()],
2240 /// in order for those windows to support all the accelerators
2241 /// contained in this group.
2242 /// ## `accel_group`
2243 /// the [`AccelGroup`][crate::AccelGroup] to be associated
2244 /// with the menu.
2245 #[doc(alias = "gtk_menu_set_accel_group")]
2246 fn set_accel_group(&self, accel_group: Option<&impl IsA<AccelGroup>>) {
2247 unsafe {
2248 ffi::gtk_menu_set_accel_group(
2249 self.as_ref().to_glib_none().0,
2250 accel_group.map(|p| p.as_ref()).to_glib_none().0,
2251 );
2252 }
2253 }
2254
2255 /// Sets an accelerator path for this menu from which accelerator paths
2256 /// for its immediate children, its menu items, can be constructed.
2257 /// The main purpose of this function is to spare the programmer the
2258 /// inconvenience of having to call [`GtkMenuItemExt::set_accel_path()`][crate::prelude::GtkMenuItemExt::set_accel_path()] on
2259 /// each menu item that should support runtime user changable accelerators.
2260 /// Instead, by just calling [`set_accel_path()`][Self::set_accel_path()] on their parent,
2261 /// each menu item of this menu, that contains a label describing its
2262 /// purpose, automatically gets an accel path assigned.
2263 ///
2264 /// For example, a menu containing menu items “New” and “Exit”, will, after
2265 /// `gtk_menu_set_accel_path (menu, "`<Gnumeric-Sheet>`/File");` has been
2266 /// called, assign its items the accel paths: `"`<Gnumeric-Sheet>`/File/New"`
2267 /// and `"`<Gnumeric-Sheet>`/File/Exit"`.
2268 ///
2269 /// Assigning accel paths to menu items then enables the user to change
2270 /// their accelerators at runtime. More details about accelerator paths
2271 /// and their default setups can be found at `gtk_accel_map_add_entry()`.
2272 ///
2273 /// Note that `accel_path` string will be stored in a `GQuark`. Therefore,
2274 /// if you pass a static string, you can save some memory by interning
2275 /// it first with `g_intern_static_string()`.
2276 /// ## `accel_path`
2277 /// a valid accelerator path, or [`None`] to unset the path
2278 #[doc(alias = "gtk_menu_set_accel_path")]
2279 fn set_accel_path(&self, accel_path: Option<&str>) {
2280 unsafe {
2281 ffi::gtk_menu_set_accel_path(
2282 self.as_ref().to_glib_none().0,
2283 accel_path.to_glib_none().0,
2284 );
2285 }
2286 }
2287
2288 /// Selects the specified menu item within the menu. This is used by
2289 /// the [`ComboBox`][crate::ComboBox] and should not be used by anyone else.
2290 /// ## `index`
2291 /// the index of the menu item to select. Index values are
2292 /// from 0 to n-1
2293 #[doc(alias = "gtk_menu_set_active")]
2294 fn set_active(&self, index: u32) {
2295 unsafe {
2296 ffi::gtk_menu_set_active(self.as_ref().to_glib_none().0, index);
2297 }
2298 }
2299
2300 /// Informs GTK+ on which monitor a menu should be popped up.
2301 /// See [`Monitor::geometry()`][crate::gdk::Monitor::geometry()].
2302 ///
2303 /// This function should be called from a `GtkMenuPositionFunc`
2304 /// if the menu should not appear on the same monitor as the pointer.
2305 /// This information can’t be reliably inferred from the coordinates
2306 /// returned by a `GtkMenuPositionFunc`, since, for very long menus,
2307 /// these coordinates may extend beyond the monitor boundaries or even
2308 /// the screen boundaries.
2309 /// ## `monitor_num`
2310 /// the number of the monitor on which the menu should
2311 /// be popped up
2312 #[doc(alias = "gtk_menu_set_monitor")]
2313 fn set_monitor(&self, monitor_num: i32) {
2314 unsafe {
2315 ffi::gtk_menu_set_monitor(self.as_ref().to_glib_none().0, monitor_num);
2316 }
2317 }
2318
2319 /// Sets whether the menu should reserve space for drawing toggles
2320 /// or icons, regardless of their actual presence.
2321 /// ## `reserve_toggle_size`
2322 /// whether to reserve size for toggles
2323 #[doc(alias = "gtk_menu_set_reserve_toggle_size")]
2324 fn set_reserve_toggle_size(&self, reserve_toggle_size: bool) {
2325 unsafe {
2326 ffi::gtk_menu_set_reserve_toggle_size(
2327 self.as_ref().to_glib_none().0,
2328 reserve_toggle_size.into_glib(),
2329 );
2330 }
2331 }
2332
2333 /// Sets the [`gdk::Screen`][crate::gdk::Screen] on which the menu will be displayed.
2334 /// ## `screen`
2335 /// a [`gdk::Screen`][crate::gdk::Screen], or [`None`] if the screen should be
2336 /// determined by the widget the menu is attached to
2337 #[doc(alias = "gtk_menu_set_screen")]
2338 fn set_screen(&self, screen: Option<&gdk::Screen>) {
2339 unsafe {
2340 ffi::gtk_menu_set_screen(self.as_ref().to_glib_none().0, screen.to_glib_none().0);
2341 }
2342 }
2343
2344 /// Positioning hints for aligning the menu relative to a rectangle.
2345 ///
2346 /// These hints determine how the menu should be positioned in the case that
2347 /// the menu would fall off-screen if placed in its ideal position.
2348 ///
2349 /// 
2350 ///
2351 /// For example, [`gdk::AnchorHints::FLIP_Y`][crate::gdk::AnchorHints::FLIP_Y] will replace [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] with
2352 /// [`gdk::Gravity::SouthWest`][crate::gdk::Gravity::SouthWest] and vice versa if the menu extends beyond the
2353 /// bottom edge of the monitor.
2354 ///
2355 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2356 /// gtk_menu_popup_at_pointer (), [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx],
2357 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
2358 #[doc(alias = "anchor-hints")]
2359 fn anchor_hints(&self) -> gdk::AnchorHints {
2360 ObjectExt::property(self.as_ref(), "anchor-hints")
2361 }
2362
2363 /// Positioning hints for aligning the menu relative to a rectangle.
2364 ///
2365 /// These hints determine how the menu should be positioned in the case that
2366 /// the menu would fall off-screen if placed in its ideal position.
2367 ///
2368 /// 
2369 ///
2370 /// For example, [`gdk::AnchorHints::FLIP_Y`][crate::gdk::AnchorHints::FLIP_Y] will replace [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] with
2371 /// [`gdk::Gravity::SouthWest`][crate::gdk::Gravity::SouthWest] and vice versa if the menu extends beyond the
2372 /// bottom edge of the monitor.
2373 ///
2374 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2375 /// gtk_menu_popup_at_pointer (), [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx],
2376 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
2377 #[doc(alias = "anchor-hints")]
2378 fn set_anchor_hints(&self, anchor_hints: gdk::AnchorHints) {
2379 ObjectExt::set_property(self.as_ref(), "anchor-hints", anchor_hints)
2380 }
2381
2382 /// The widget the menu is attached to. Setting this property attaches
2383 /// the menu without a `GtkMenuDetachFunc`. If you need to use a detacher,
2384 /// use `gtk_menu_attach_to_widget()` directly.
2385 #[doc(alias = "attach-widget")]
2386 fn set_attach_widget<P: IsA<Widget>>(&self, attach_widget: Option<&P>) {
2387 ObjectExt::set_property(self.as_ref(), "attach-widget", attach_widget)
2388 }
2389
2390 /// The [`gdk::WindowTypeHint`][crate::gdk::WindowTypeHint] to use for the menu's [`gdk::Window`][crate::gdk::Window].
2391 ///
2392 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2393 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
2394 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and [`popped-up`][struct@crate::Menu#popped-up].
2395 #[doc(alias = "menu-type-hint")]
2396 fn menu_type_hint(&self) -> gdk::WindowTypeHint {
2397 ObjectExt::property(self.as_ref(), "menu-type-hint")
2398 }
2399
2400 /// The [`gdk::WindowTypeHint`][crate::gdk::WindowTypeHint] to use for the menu's [`gdk::Window`][crate::gdk::Window].
2401 ///
2402 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2403 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
2404 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and [`popped-up`][struct@crate::Menu#popped-up].
2405 #[doc(alias = "menu-type-hint")]
2406 fn set_menu_type_hint(&self, menu_type_hint: gdk::WindowTypeHint) {
2407 ObjectExt::set_property(self.as_ref(), "menu-type-hint", menu_type_hint)
2408 }
2409
2410 /// Horizontal offset to apply to the menu, i.e. the rectangle or widget
2411 /// anchor.
2412 ///
2413 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2414 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
2415 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
2416 #[doc(alias = "rect-anchor-dx")]
2417 fn rect_anchor_dx(&self) -> i32 {
2418 ObjectExt::property(self.as_ref(), "rect-anchor-dx")
2419 }
2420
2421 /// Horizontal offset to apply to the menu, i.e. the rectangle or widget
2422 /// anchor.
2423 ///
2424 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2425 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
2426 /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
2427 #[doc(alias = "rect-anchor-dx")]
2428 fn set_rect_anchor_dx(&self, rect_anchor_dx: i32) {
2429 ObjectExt::set_property(self.as_ref(), "rect-anchor-dx", rect_anchor_dx)
2430 }
2431
2432 /// Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
2433 ///
2434 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2435 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
2436 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
2437 #[doc(alias = "rect-anchor-dy")]
2438 fn rect_anchor_dy(&self) -> i32 {
2439 ObjectExt::property(self.as_ref(), "rect-anchor-dy")
2440 }
2441
2442 /// Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
2443 ///
2444 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
2445 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
2446 /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
2447 #[doc(alias = "rect-anchor-dy")]
2448 fn set_rect_anchor_dy(&self, rect_anchor_dy: i32) {
2449 ObjectExt::set_property(self.as_ref(), "rect-anchor-dy", rect_anchor_dy)
2450 }
2451
2452 #[doc(alias = "item.bottom-attach")]
2453 fn item_bottom_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32 {
2454 crate::prelude::ContainerExtManual::child_property(
2455 self.as_ref(),
2456 &item.clone().upcast(),
2457 "bottom-attach",
2458 )
2459 }
2460
2461 #[doc(alias = "item.bottom-attach")]
2462 fn set_item_bottom_attach<T: IsA<MenuItem>>(&self, item: &T, bottom_attach: i32) {
2463 crate::prelude::ContainerExtManual::child_set_property(
2464 self.as_ref(),
2465 &item.clone().upcast(),
2466 "bottom-attach",
2467 &bottom_attach,
2468 )
2469 }
2470
2471 #[doc(alias = "item.left-attach")]
2472 fn item_left_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32 {
2473 crate::prelude::ContainerExtManual::child_property(
2474 self.as_ref(),
2475 &item.clone().upcast(),
2476 "left-attach",
2477 )
2478 }
2479
2480 #[doc(alias = "item.left-attach")]
2481 fn set_item_left_attach<T: IsA<MenuItem>>(&self, item: &T, left_attach: i32) {
2482 crate::prelude::ContainerExtManual::child_set_property(
2483 self.as_ref(),
2484 &item.clone().upcast(),
2485 "left-attach",
2486 &left_attach,
2487 )
2488 }
2489
2490 #[doc(alias = "item.right-attach")]
2491 fn item_right_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32 {
2492 crate::prelude::ContainerExtManual::child_property(
2493 self.as_ref(),
2494 &item.clone().upcast(),
2495 "right-attach",
2496 )
2497 }
2498
2499 #[doc(alias = "item.right-attach")]
2500 fn set_item_right_attach<T: IsA<MenuItem>>(&self, item: &T, right_attach: i32) {
2501 crate::prelude::ContainerExtManual::child_set_property(
2502 self.as_ref(),
2503 &item.clone().upcast(),
2504 "right-attach",
2505 &right_attach,
2506 )
2507 }
2508
2509 #[doc(alias = "item.top-attach")]
2510 fn item_top_attach<T: IsA<MenuItem>>(&self, item: &T) -> i32 {
2511 crate::prelude::ContainerExtManual::child_property(
2512 self.as_ref(),
2513 &item.clone().upcast(),
2514 "top-attach",
2515 )
2516 }
2517
2518 #[doc(alias = "item.top-attach")]
2519 fn set_item_top_attach<T: IsA<MenuItem>>(&self, item: &T, top_attach: i32) {
2520 crate::prelude::ContainerExtManual::child_set_property(
2521 self.as_ref(),
2522 &item.clone().upcast(),
2523 "top-attach",
2524 &top_attach,
2525 )
2526 }
2527
2528 /// ## `scroll_type`
2529 /// a [`ScrollType`][crate::ScrollType]
2530 #[doc(alias = "move-scroll")]
2531 fn connect_move_scroll<F: Fn(&Self, ScrollType) + 'static>(&self, f: F) -> SignalHandlerId {
2532 unsafe extern "C" fn move_scroll_trampoline<
2533 P: IsA<Menu>,
2534 F: Fn(&P, ScrollType) + 'static,
2535 >(
2536 this: *mut ffi::GtkMenu,
2537 scroll_type: ffi::GtkScrollType,
2538 f: glib::ffi::gpointer,
2539 ) {
2540 let f: &F = &*(f as *const F);
2541 f(
2542 Menu::from_glib_borrow(this).unsafe_cast_ref(),
2543 from_glib(scroll_type),
2544 )
2545 }
2546 unsafe {
2547 let f: Box_<F> = Box_::new(f);
2548 connect_raw(
2549 self.as_ptr() as *mut _,
2550 b"move-scroll\0".as_ptr() as *const _,
2551 Some(transmute::<_, unsafe extern "C" fn()>(
2552 move_scroll_trampoline::<Self, F> as *const (),
2553 )),
2554 Box_::into_raw(f),
2555 )
2556 }
2557 }
2558
2559 fn emit_move_scroll(&self, scroll_type: ScrollType) {
2560 self.emit_by_name::<()>("move-scroll", &[&scroll_type]);
2561 }
2562
2563 //#[doc(alias = "popped-up")]
2564 //fn connect_popped_up<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
2565 // Unimplemented flipped_rect: *.Pointer
2566 // Unimplemented final_rect: *.Pointer
2567 //}
2568
2569 #[doc(alias = "accel-group")]
2570 fn connect_accel_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2571 unsafe extern "C" fn notify_accel_group_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2572 this: *mut ffi::GtkMenu,
2573 _param_spec: glib::ffi::gpointer,
2574 f: glib::ffi::gpointer,
2575 ) {
2576 let f: &F = &*(f as *const F);
2577 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2578 }
2579 unsafe {
2580 let f: Box_<F> = Box_::new(f);
2581 connect_raw(
2582 self.as_ptr() as *mut _,
2583 b"notify::accel-group\0".as_ptr() as *const _,
2584 Some(transmute::<_, unsafe extern "C" fn()>(
2585 notify_accel_group_trampoline::<Self, F> as *const (),
2586 )),
2587 Box_::into_raw(f),
2588 )
2589 }
2590 }
2591
2592 #[doc(alias = "accel-path")]
2593 fn connect_accel_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2594 unsafe extern "C" fn notify_accel_path_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2595 this: *mut ffi::GtkMenu,
2596 _param_spec: glib::ffi::gpointer,
2597 f: glib::ffi::gpointer,
2598 ) {
2599 let f: &F = &*(f as *const F);
2600 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2601 }
2602 unsafe {
2603 let f: Box_<F> = Box_::new(f);
2604 connect_raw(
2605 self.as_ptr() as *mut _,
2606 b"notify::accel-path\0".as_ptr() as *const _,
2607 Some(transmute::<_, unsafe extern "C" fn()>(
2608 notify_accel_path_trampoline::<Self, F> as *const (),
2609 )),
2610 Box_::into_raw(f),
2611 )
2612 }
2613 }
2614
2615 #[doc(alias = "active")]
2616 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2617 unsafe extern "C" fn notify_active_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2618 this: *mut ffi::GtkMenu,
2619 _param_spec: glib::ffi::gpointer,
2620 f: glib::ffi::gpointer,
2621 ) {
2622 let f: &F = &*(f as *const F);
2623 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2624 }
2625 unsafe {
2626 let f: Box_<F> = Box_::new(f);
2627 connect_raw(
2628 self.as_ptr() as *mut _,
2629 b"notify::active\0".as_ptr() as *const _,
2630 Some(transmute::<_, unsafe extern "C" fn()>(
2631 notify_active_trampoline::<Self, F> as *const (),
2632 )),
2633 Box_::into_raw(f),
2634 )
2635 }
2636 }
2637
2638 #[doc(alias = "anchor-hints")]
2639 fn connect_anchor_hints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2640 unsafe extern "C" fn notify_anchor_hints_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2641 this: *mut ffi::GtkMenu,
2642 _param_spec: glib::ffi::gpointer,
2643 f: glib::ffi::gpointer,
2644 ) {
2645 let f: &F = &*(f as *const F);
2646 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2647 }
2648 unsafe {
2649 let f: Box_<F> = Box_::new(f);
2650 connect_raw(
2651 self.as_ptr() as *mut _,
2652 b"notify::anchor-hints\0".as_ptr() as *const _,
2653 Some(transmute::<_, unsafe extern "C" fn()>(
2654 notify_anchor_hints_trampoline::<Self, F> as *const (),
2655 )),
2656 Box_::into_raw(f),
2657 )
2658 }
2659 }
2660
2661 #[doc(alias = "attach-widget")]
2662 fn connect_attach_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2663 unsafe extern "C" fn notify_attach_widget_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2664 this: *mut ffi::GtkMenu,
2665 _param_spec: glib::ffi::gpointer,
2666 f: glib::ffi::gpointer,
2667 ) {
2668 let f: &F = &*(f as *const F);
2669 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2670 }
2671 unsafe {
2672 let f: Box_<F> = Box_::new(f);
2673 connect_raw(
2674 self.as_ptr() as *mut _,
2675 b"notify::attach-widget\0".as_ptr() as *const _,
2676 Some(transmute::<_, unsafe extern "C" fn()>(
2677 notify_attach_widget_trampoline::<Self, F> as *const (),
2678 )),
2679 Box_::into_raw(f),
2680 )
2681 }
2682 }
2683
2684 #[doc(alias = "menu-type-hint")]
2685 fn connect_menu_type_hint_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2686 unsafe extern "C" fn notify_menu_type_hint_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2687 this: *mut ffi::GtkMenu,
2688 _param_spec: glib::ffi::gpointer,
2689 f: glib::ffi::gpointer,
2690 ) {
2691 let f: &F = &*(f as *const F);
2692 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2693 }
2694 unsafe {
2695 let f: Box_<F> = Box_::new(f);
2696 connect_raw(
2697 self.as_ptr() as *mut _,
2698 b"notify::menu-type-hint\0".as_ptr() as *const _,
2699 Some(transmute::<_, unsafe extern "C" fn()>(
2700 notify_menu_type_hint_trampoline::<Self, F> as *const (),
2701 )),
2702 Box_::into_raw(f),
2703 )
2704 }
2705 }
2706
2707 #[doc(alias = "monitor")]
2708 fn connect_monitor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2709 unsafe extern "C" fn notify_monitor_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2710 this: *mut ffi::GtkMenu,
2711 _param_spec: glib::ffi::gpointer,
2712 f: glib::ffi::gpointer,
2713 ) {
2714 let f: &F = &*(f as *const F);
2715 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2716 }
2717 unsafe {
2718 let f: Box_<F> = Box_::new(f);
2719 connect_raw(
2720 self.as_ptr() as *mut _,
2721 b"notify::monitor\0".as_ptr() as *const _,
2722 Some(transmute::<_, unsafe extern "C" fn()>(
2723 notify_monitor_trampoline::<Self, F> as *const (),
2724 )),
2725 Box_::into_raw(f),
2726 )
2727 }
2728 }
2729
2730 #[doc(alias = "rect-anchor-dx")]
2731 fn connect_rect_anchor_dx_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2732 unsafe extern "C" fn notify_rect_anchor_dx_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2733 this: *mut ffi::GtkMenu,
2734 _param_spec: glib::ffi::gpointer,
2735 f: glib::ffi::gpointer,
2736 ) {
2737 let f: &F = &*(f as *const F);
2738 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2739 }
2740 unsafe {
2741 let f: Box_<F> = Box_::new(f);
2742 connect_raw(
2743 self.as_ptr() as *mut _,
2744 b"notify::rect-anchor-dx\0".as_ptr() as *const _,
2745 Some(transmute::<_, unsafe extern "C" fn()>(
2746 notify_rect_anchor_dx_trampoline::<Self, F> as *const (),
2747 )),
2748 Box_::into_raw(f),
2749 )
2750 }
2751 }
2752
2753 #[doc(alias = "rect-anchor-dy")]
2754 fn connect_rect_anchor_dy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2755 unsafe extern "C" fn notify_rect_anchor_dy_trampoline<P: IsA<Menu>, F: Fn(&P) + 'static>(
2756 this: *mut ffi::GtkMenu,
2757 _param_spec: glib::ffi::gpointer,
2758 f: glib::ffi::gpointer,
2759 ) {
2760 let f: &F = &*(f as *const F);
2761 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2762 }
2763 unsafe {
2764 let f: Box_<F> = Box_::new(f);
2765 connect_raw(
2766 self.as_ptr() as *mut _,
2767 b"notify::rect-anchor-dy\0".as_ptr() as *const _,
2768 Some(transmute::<_, unsafe extern "C" fn()>(
2769 notify_rect_anchor_dy_trampoline::<Self, F> as *const (),
2770 )),
2771 Box_::into_raw(f),
2772 )
2773 }
2774 }
2775
2776 #[doc(alias = "reserve-toggle-size")]
2777 fn connect_reserve_toggle_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2778 unsafe extern "C" fn notify_reserve_toggle_size_trampoline<
2779 P: IsA<Menu>,
2780 F: Fn(&P) + 'static,
2781 >(
2782 this: *mut ffi::GtkMenu,
2783 _param_spec: glib::ffi::gpointer,
2784 f: glib::ffi::gpointer,
2785 ) {
2786 let f: &F = &*(f as *const F);
2787 f(Menu::from_glib_borrow(this).unsafe_cast_ref())
2788 }
2789 unsafe {
2790 let f: Box_<F> = Box_::new(f);
2791 connect_raw(
2792 self.as_ptr() as *mut _,
2793 b"notify::reserve-toggle-size\0".as_ptr() as *const _,
2794 Some(transmute::<_, unsafe extern "C" fn()>(
2795 notify_reserve_toggle_size_trampoline::<Self, F> as *const (),
2796 )),
2797 Box_::into_raw(f),
2798 )
2799 }
2800 }
2801}
2802
2803impl<O: IsA<Menu>> GtkMenuExt for O {}
2804
2805impl fmt::Display for Menu {
2806 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2807 f.write_str("Menu")
2808 }
2809}