Skip to main content

gtk/auto/
menu_shell.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::{Buildable, Container, DirectionType, MenuDirectionType, MenuItem, Widget, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// A [`MenuShell`][crate::MenuShell] is the abstract base class used to derive the
16    /// [`Menu`][crate::Menu] and [`MenuBar`][crate::MenuBar] subclasses.
17    ///
18    /// A [`MenuShell`][crate::MenuShell] is a container of [`MenuItem`][crate::MenuItem] objects arranged
19    /// in a list which can be navigated, selected, and activated by the
20    /// user to perform application functions. A [`MenuItem`][crate::MenuItem] can have a
21    /// submenu associated with it, allowing for nested hierarchical menus.
22    ///
23    /// # Terminology
24    ///
25    /// A menu item can be “selected”, this means that it is displayed
26    /// in the prelight state, and if it has a submenu, that submenu
27    /// will be popped up.
28    ///
29    /// A menu is “active” when it is visible onscreen and the user
30    /// is selecting from it. A menubar is not active until the user
31    /// clicks on one of its menuitems. When a menu is active,
32    /// passing the mouse over a submenu will pop it up.
33    ///
34    /// There is also is a concept of the current menu and a current
35    /// menu item. The current menu item is the selected menu item
36    /// that is furthest down in the hierarchy. (Every active menu shell
37    /// does not necessarily contain a selected menu item, but if
38    /// it does, then the parent menu shell must also contain
39    /// a selected menu item.) The current menu is the menu that
40    /// contains the current menu item. It will always have a GTK
41    /// grab and receive all key presses.
42    ///
43    /// This is an Abstract Base Class, you cannot instantiate it.
44    ///
45    /// ## Properties
46    ///
47    ///
48    /// #### `take-focus`
49    ///  A boolean that determines whether the menu and its submenus grab the
50    /// keyboard focus. See [`MenuShellExt::set_take_focus()`][crate::prelude::MenuShellExt::set_take_focus()] and
51    /// [`MenuShellExt::takes_focus()`][crate::prelude::MenuShellExt::takes_focus()].
52    ///
53    /// Readable | Writable
54    /// <details><summary><h4>Container</h4></summary>
55    ///
56    ///
57    /// #### `border-width`
58    ///  Readable | Writable
59    ///
60    ///
61    /// #### `child`
62    ///  Writable
63    ///
64    ///
65    /// #### `resize-mode`
66    ///  Readable | Writable
67    /// </details>
68    /// <details><summary><h4>Widget</h4></summary>
69    ///
70    ///
71    /// #### `app-paintable`
72    ///  Readable | Writable
73    ///
74    ///
75    /// #### `can-default`
76    ///  Readable | Writable
77    ///
78    ///
79    /// #### `can-focus`
80    ///  Readable | Writable
81    ///
82    ///
83    /// #### `composite-child`
84    ///  Readable
85    ///
86    ///
87    /// #### `double-buffered`
88    ///  Whether the widget is double buffered.
89    ///
90    /// Readable | Writable
91    ///
92    ///
93    /// #### `events`
94    ///  Readable | Writable
95    ///
96    ///
97    /// #### `expand`
98    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
99    ///
100    /// Readable | Writable
101    ///
102    ///
103    /// #### `focus-on-click`
104    ///  Whether the widget should grab focus when it is clicked with the mouse.
105    ///
106    /// This property is only relevant for widgets that can take focus.
107    ///
108    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
109    /// GtkComboBox) implemented this property individually.
110    ///
111    /// Readable | Writable
112    ///
113    ///
114    /// #### `halign`
115    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
116    ///
117    /// Readable | Writable
118    ///
119    ///
120    /// #### `has-default`
121    ///  Readable | Writable
122    ///
123    ///
124    /// #### `has-focus`
125    ///  Readable | Writable
126    ///
127    ///
128    /// #### `has-tooltip`
129    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
130    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
131    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
132    /// whether it will provide a tooltip or not.
133    ///
134    /// Note that setting this property to [`true`] for the first time will change
135    /// the event masks of the GdkWindows of this widget to include leave-notify
136    /// and motion-notify events. This cannot and will not be undone when the
137    /// property is set to [`false`] again.
138    ///
139    /// Readable | Writable
140    ///
141    ///
142    /// #### `height-request`
143    ///  Readable | Writable
144    ///
145    ///
146    /// #### `hexpand`
147    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
148    ///
149    /// Readable | Writable
150    ///
151    ///
152    /// #### `hexpand-set`
153    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
154    ///
155    /// Readable | Writable
156    ///
157    ///
158    /// #### `is-focus`
159    ///  Readable | Writable
160    ///
161    ///
162    /// #### `margin`
163    ///  Sets all four sides' margin at once. If read, returns max
164    /// margin on any side.
165    ///
166    /// Readable | Writable
167    ///
168    ///
169    /// #### `margin-bottom`
170    ///  Margin on bottom side of widget.
171    ///
172    /// This property adds margin outside of the widget's normal size
173    /// request, the margin will be added in addition to the size from
174    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
175    ///
176    /// Readable | Writable
177    ///
178    ///
179    /// #### `margin-end`
180    ///  Margin on end of widget, horizontally. This property supports
181    /// left-to-right and right-to-left text directions.
182    ///
183    /// This property adds margin outside of the widget's normal size
184    /// request, the margin will be added in addition to the size from
185    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
186    ///
187    /// Readable | Writable
188    ///
189    ///
190    /// #### `margin-left`
191    ///  Margin on left side of widget.
192    ///
193    /// This property adds margin outside of the widget's normal size
194    /// request, the margin will be added in addition to the size from
195    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
196    ///
197    /// Readable | Writable
198    ///
199    ///
200    /// #### `margin-right`
201    ///  Margin on right side of widget.
202    ///
203    /// This property adds margin outside of the widget's normal size
204    /// request, the margin will be added in addition to the size from
205    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
206    ///
207    /// Readable | Writable
208    ///
209    ///
210    /// #### `margin-start`
211    ///  Margin on start of widget, horizontally. This property supports
212    /// left-to-right and right-to-left text directions.
213    ///
214    /// This property adds margin outside of the widget's normal size
215    /// request, the margin will be added in addition to the size from
216    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
217    ///
218    /// Readable | Writable
219    ///
220    ///
221    /// #### `margin-top`
222    ///  Margin on top side of widget.
223    ///
224    /// This property adds margin outside of the widget's normal size
225    /// request, the margin will be added in addition to the size from
226    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
227    ///
228    /// Readable | Writable
229    ///
230    ///
231    /// #### `name`
232    ///  Readable | Writable
233    ///
234    ///
235    /// #### `no-show-all`
236    ///  Readable | Writable
237    ///
238    ///
239    /// #### `opacity`
240    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
241    /// more details about window opacity.
242    ///
243    /// Before 3.8 this was only available in GtkWindow
244    ///
245    /// Readable | Writable
246    ///
247    ///
248    /// #### `parent`
249    ///  Readable | Writable
250    ///
251    ///
252    /// #### `receives-default`
253    ///  Readable | Writable
254    ///
255    ///
256    /// #### `scale-factor`
257    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
258    /// more details about widget scaling.
259    ///
260    /// Readable
261    ///
262    ///
263    /// #### `sensitive`
264    ///  Readable | Writable
265    ///
266    ///
267    /// #### `style`
268    ///  The style of the widget, which contains information about how it will look (colors, etc).
269    ///
270    /// Readable | Writable
271    ///
272    ///
273    /// #### `tooltip-markup`
274    ///  Sets the text of tooltip to be the given string, which is marked up
275    /// with the [Pango text markup language][PangoMarkupFormat].
276    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
277    ///
278    /// This is a convenience property which will take care of getting the
279    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
280    /// will automatically be set to [`true`] and there will be taken care of
281    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
282    ///
283    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
284    /// are set, the last one wins.
285    ///
286    /// Readable | Writable
287    ///
288    ///
289    /// #### `tooltip-text`
290    ///  Sets the text of tooltip to be the given string.
291    ///
292    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
293    ///
294    /// This is a convenience property which will take care of getting the
295    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
296    /// will automatically be set to [`true`] and there will be taken care of
297    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
298    ///
299    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
300    /// are set, the last one wins.
301    ///
302    /// Readable | Writable
303    ///
304    ///
305    /// #### `valign`
306    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
307    ///
308    /// Readable | Writable
309    ///
310    ///
311    /// #### `vexpand`
312    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
313    ///
314    /// Readable | Writable
315    ///
316    ///
317    /// #### `vexpand-set`
318    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
319    ///
320    /// Readable | Writable
321    ///
322    ///
323    /// #### `visible`
324    ///  Readable | Writable
325    ///
326    ///
327    /// #### `width-request`
328    ///  Readable | Writable
329    ///
330    ///
331    /// #### `window`
332    ///  The widget's window if it is realized, [`None`] otherwise.
333    ///
334    /// Readable
335    /// </details>
336    ///
337    /// ## Signals
338    ///
339    ///
340    /// #### `activate-current`
341    ///  An action signal that activates the current menu item within
342    /// the menu shell.
343    ///
344    /// Action
345    ///
346    ///
347    /// #### `cancel`
348    ///  An action signal which cancels the selection within the menu shell.
349    /// Causes the [`selection-done`][struct@crate::MenuShell#selection-done] signal to be emitted.
350    ///
351    /// Action
352    ///
353    ///
354    /// #### `cycle-focus`
355    ///  A keybinding signal which moves the focus in the
356    /// given `direction`.
357    ///
358    /// Action
359    ///
360    ///
361    /// #### `deactivate`
362    ///  This signal is emitted when a menu shell is deactivated.
363    ///
364    ///
365    ///
366    ///
367    /// #### `insert`
368    ///  The ::insert signal is emitted when a new [`MenuItem`][crate::MenuItem] is added to
369    /// a [`MenuShell`][crate::MenuShell]. A separate signal is used instead of
370    /// GtkContainer::add because of the need for an additional position
371    /// parameter.
372    ///
373    /// The inverse of this signal is the GtkContainer::removed signal.
374    ///
375    ///
376    ///
377    ///
378    /// #### `move-current`
379    ///  An keybinding signal which moves the current menu item
380    /// in the direction specified by `direction`.
381    ///
382    /// Action
383    ///
384    ///
385    /// #### `move-selected`
386    ///  The ::move-selected signal is emitted to move the selection to
387    /// another item.
388    ///
389    ///
390    ///
391    ///
392    /// #### `selection-done`
393    ///  This signal is emitted when a selection has been
394    /// completed within a menu shell.
395    ///
396    ///
397    /// <details><summary><h4>Container</h4></summary>
398    ///
399    ///
400    /// #### `add`
401    ///
402    ///
403    ///
404    /// #### `check-resize`
405    ///
406    ///
407    ///
408    /// #### `remove`
409    ///
410    ///
411    ///
412    /// #### `set-focus-child`
413    ///
414    /// </details>
415    /// <details><summary><h4>Widget</h4></summary>
416    ///
417    ///
418    /// #### `accel-closures-changed`
419    ///
420    ///
421    ///
422    /// #### `button-press-event`
423    ///  The ::button-press-event signal will be emitted when a button
424    /// (typically from a mouse) is pressed.
425    ///
426    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
427    /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
428    ///
429    /// This signal will be sent to the grab widget if there is one.
430    ///
431    ///
432    ///
433    ///
434    /// #### `button-release-event`
435    ///  The ::button-release-event signal will be emitted when a button
436    /// (typically from a mouse) is released.
437    ///
438    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
439    /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
440    ///
441    /// This signal will be sent to the grab widget if there is one.
442    ///
443    ///
444    ///
445    ///
446    /// #### `can-activate-accel`
447    ///  Determines whether an accelerator that activates the signal
448    /// identified by `signal_id` can currently be activated.
449    /// This signal is present to allow applications and derived
450    /// widgets to override the default [`Widget`][crate::Widget] handling
451    /// for determining whether an accelerator can be activated.
452    ///
453    ///
454    ///
455    ///
456    /// #### `child-notify`
457    ///  The ::child-notify signal is emitted for each
458    /// [child property][child-properties] that has
459    /// changed on an object. The signal's detail holds the property name.
460    ///
461    /// Detailed
462    ///
463    ///
464    /// #### `composited-changed`
465    ///  The ::composited-changed signal is emitted when the composited
466    /// status of `widgets` screen changes.
467    /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
468    ///
469    /// Action
470    ///
471    ///
472    /// #### `configure-event`
473    ///  The ::configure-event signal will be emitted when the size, position or
474    /// stacking of the `widget`'s window has changed.
475    ///
476    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
477    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
478    /// automatically for all new windows.
479    ///
480    ///
481    ///
482    ///
483    /// #### `damage-event`
484    ///  Emitted when a redirected window belonging to `widget` gets drawn into.
485    /// The region/area members of the event shows what area of the redirected
486    /// drawable was drawn into.
487    ///
488    ///
489    ///
490    ///
491    /// #### `delete-event`
492    ///  The ::delete-event signal is emitted if a user requests that
493    /// a toplevel window is closed. The default handler for this signal
494    /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
495    /// this signal will cause the window to be hidden instead, so that
496    /// it can later be shown again without reconstructing it.
497    ///
498    ///
499    ///
500    ///
501    /// #### `destroy`
502    ///  Signals that all holders of a reference to the widget should release
503    /// the reference that they hold. May result in finalization of the widget
504    /// if all references are released.
505    ///
506    /// This signal is not suitable for saving widget state.
507    ///
508    ///
509    ///
510    ///
511    /// #### `destroy-event`
512    ///  The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
513    /// You rarely get this signal, because most widgets disconnect themselves
514    /// from their window before they destroy it, so no widget owns the
515    /// window at destroy time.
516    ///
517    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
518    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
519    /// automatically for all new windows.
520    ///
521    ///
522    ///
523    ///
524    /// #### `direction-changed`
525    ///  The ::direction-changed signal is emitted when the text direction
526    /// of a widget changes.
527    ///
528    ///
529    ///
530    ///
531    /// #### `drag-begin`
532    ///  The ::drag-begin signal is emitted on the drag source when a drag is
533    /// started. A typical reason to connect to this signal is to set up a
534    /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
535    ///
536    /// Note that some widgets set up a drag icon in the default handler of
537    /// this signal, so you may have to use `g_signal_connect_after()` to
538    /// override what the default handler did.
539    ///
540    ///
541    ///
542    ///
543    /// #### `drag-data-delete`
544    ///  The ::drag-data-delete signal is emitted on the drag source when a drag
545    /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
546    /// handler is responsible for deleting the data that has been dropped. What
547    /// "delete" means depends on the context of the drag operation.
548    ///
549    ///
550    ///
551    ///
552    /// #### `drag-data-get`
553    ///  The ::drag-data-get signal is emitted on the drag source when the drop
554    /// site requests the data which is dragged. It is the responsibility of
555    /// the signal handler to fill `data` with the data in the format which
556    /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
557    /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
558    ///
559    ///
560    ///
561    ///
562    /// #### `drag-data-received`
563    ///  format == 8))
564    ///  {
565    ///  GdkDragAction action;
566    ///
567    ///  // handle data here
568    ///
569    ///  action = gdk_drag_context_get_selected_action (context);
570    ///  if (action == GDK_ACTION_ASK)
571    ///  {
572    ///  GtkWidget *dialog;
573    ///  gint response;
574    ///
575    ///  dialog = gtk_message_dialog_new (NULL,
576    ///  GTK_DIALOG_MODAL |
577    ///  GTK_DIALOG_DESTROY_WITH_PARENT,
578    ///  GTK_MESSAGE_INFO,
579    ///  GTK_BUTTONS_YES_NO,
580    ///  "Move the data ?\n");
581    ///  response = gtk_dialog_run (GTK_DIALOG (dialog));
582    ///  gtk_widget_destroy (dialog);
583    ///
584    ///  if (response == GTK_RESPONSE_YES)
585    ///  action = GDK_ACTION_MOVE;
586    ///  else
587    ///  action = GDK_ACTION_COPY;
588    ///  }
589    ///
590    ///  gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
591    ///  }
592    ///  else
593    ///  gtk_drag_finish (context, FALSE, FALSE, time);
594    ///  }
595    /// ]|
596    ///
597    ///
598    ///
599    ///
600    /// #### `drag-drop`
601    ///  The ::drag-drop signal is emitted on the drop site when the user drops
602    /// the data onto the widget. The signal handler must determine whether
603    /// the cursor position is in a drop zone or not. If it is not in a drop
604    /// zone, it returns [`false`] and no further processing is necessary.
605    /// Otherwise, the handler returns [`true`]. In this case, the handler must
606    /// ensure that `gtk_drag_finish()` is called to let the source know that
607    /// the drop is done. The call to `gtk_drag_finish()` can be done either
608    /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
609    /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
610    /// or more of the supported targets.
611    ///
612    ///
613    ///
614    ///
615    /// #### `drag-end`
616    ///  The ::drag-end signal is emitted on the drag source when a drag is
617    /// finished. A typical reason to connect to this signal is to undo
618    /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
619    ///
620    ///
621    ///
622    ///
623    /// #### `drag-failed`
624    ///  The ::drag-failed signal is emitted on the drag source when a drag has
625    /// failed. The signal handler may hook custom code to handle a failed DnD
626    /// operation based on the type of error, it returns [`true`] is the failure has
627    /// been already handled (not showing the default "drag operation failed"
628    /// animation), otherwise it returns [`false`].
629    ///
630    ///
631    ///
632    ///
633    /// #### `drag-leave`
634    ///  The ::drag-leave signal is emitted on the drop site when the cursor
635    /// leaves the widget. A typical reason to connect to this signal is to
636    /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
637    /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
638    ///
639    ///
640    /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
641    /// ::drag-drop signal, for instance to allow cleaning up of a preview item
642    /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
643    ///
644    ///
645    ///
646    ///
647    /// #### `drag-motion`
648    ///  suggested_action,
649    ///  time);
650    ///  }
651    ///  else
652    ///  {
653    ///  // accept the drop
654    ///  }
655    /// }
656    /// ]|
657    ///
658    ///
659    ///
660    ///
661    /// #### `draw`
662    ///  This signal is emitted when a widget is supposed to render itself.
663    /// The `widget`'s top left corner must be painted at the origin of
664    /// the passed in context and be sized to the values returned by
665    /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
666    /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
667    ///
668    /// Signal handlers connected to this signal can modify the cairo
669    /// context passed as `cr` in any way they like and don't need to
670    /// restore it. The signal emission takes care of calling `cairo_save()`
671    /// before and `cairo_restore()` after invoking the handler.
672    ///
673    /// The signal handler will get a `cr` with a clip region already set to the
674    /// widget's dirty region, i.e. to the area that needs repainting. Complicated
675    /// widgets that want to avoid redrawing themselves completely can get the full
676    /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
677    /// get a finer-grained representation of the dirty region with
678    /// `cairo_copy_clip_rectangle_list()`.
679    ///
680    ///
681    ///
682    ///
683    /// #### `enter-notify-event`
684    ///  The ::enter-notify-event will be emitted when the pointer enters
685    /// the `widget`'s window.
686    ///
687    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
688    /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
689    ///
690    /// This signal will be sent to the grab widget if there is one.
691    ///
692    ///
693    ///
694    ///
695    /// #### `event`
696    ///  The GTK+ main loop will emit three signals for each GDK event delivered
697    /// to a widget: one generic ::event signal, another, more specific,
698    /// signal that matches the type of event delivered (e.g.
699    /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
700    /// [`event-after`][struct@crate::Widget#event-after] signal.
701    ///
702    ///
703    ///
704    ///
705    /// #### `event-after`
706    ///  After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
707    /// the second more specific signal, ::event-after will be emitted
708    /// regardless of the previous two signals handlers return values.
709    ///
710    ///
711    ///
712    ///
713    /// #### `focus`
714    ///
715    ///
716    ///
717    /// #### `focus-in-event`
718    ///  The ::focus-in-event signal will be emitted when the keyboard focus
719    /// enters the `widget`'s window.
720    ///
721    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
722    /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
723    ///
724    ///
725    ///
726    ///
727    /// #### `focus-out-event`
728    ///  The ::focus-out-event signal will be emitted when the keyboard focus
729    /// leaves the `widget`'s window.
730    ///
731    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
732    /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
733    ///
734    ///
735    ///
736    ///
737    /// #### `grab-broken-event`
738    ///  Emitted when a pointer or keyboard grab on a window belonging
739    /// to `widget` gets broken.
740    ///
741    /// On X11, this happens when the grab window becomes unviewable
742    /// (i.e. it or one of its ancestors is unmapped), or if the same
743    /// application grabs the pointer or keyboard again.
744    ///
745    ///
746    ///
747    ///
748    /// #### `grab-focus`
749    ///  Action
750    ///
751    ///
752    /// #### `grab-notify`
753    ///  The ::grab-notify signal is emitted when a widget becomes
754    /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
755    /// another widget, or when it becomes unshadowed due to a grab
756    /// being removed.
757    ///
758    /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
759    /// grab widget in the grab stack of its window group is not
760    /// its ancestor.
761    ///
762    ///
763    ///
764    ///
765    /// #### `hide`
766    ///  The ::hide signal is emitted when `widget` is hidden, for example with
767    /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
768    ///
769    ///
770    ///
771    ///
772    /// #### `hierarchy-changed`
773    ///  The ::hierarchy-changed signal is emitted when the
774    /// anchored state of a widget changes. A widget is
775    /// “anchored” when its toplevel
776    /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
777    /// a widget changes from un-anchored to anchored or vice-versa.
778    ///
779    ///
780    ///
781    ///
782    /// #### `key-press-event`
783    ///  The ::key-press-event signal is emitted when a key is pressed. The signal
784    /// emission will reoccur at the key-repeat rate when the key is kept pressed.
785    ///
786    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
787    /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
788    ///
789    /// This signal will be sent to the grab widget if there is one.
790    ///
791    ///
792    ///
793    ///
794    /// #### `key-release-event`
795    ///  The ::key-release-event signal is emitted when a key is released.
796    ///
797    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
798    /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
799    ///
800    /// This signal will be sent to the grab widget if there is one.
801    ///
802    ///
803    ///
804    ///
805    /// #### `keynav-failed`
806    ///  Gets emitted if keyboard navigation fails.
807    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
808    ///
809    ///
810    ///
811    ///
812    /// #### `leave-notify-event`
813    ///  The ::leave-notify-event will be emitted when the pointer leaves
814    /// the `widget`'s window.
815    ///
816    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
817    /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
818    ///
819    /// This signal will be sent to the grab widget if there is one.
820    ///
821    ///
822    ///
823    ///
824    /// #### `map`
825    ///  The ::map signal is emitted when `widget` is going to be mapped, that is
826    /// when the widget is visible (which is controlled with
827    /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
828    /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
829    /// be emitted.
830    ///
831    /// The ::map signal can be used to determine whether a widget will be drawn,
832    /// for instance it can resume an animation that was stopped during the
833    /// emission of [`unmap`][struct@crate::Widget#unmap].
834    ///
835    ///
836    ///
837    ///
838    /// #### `map-event`
839    ///  The ::map-event signal will be emitted when the `widget`'s window is
840    /// mapped. A window is mapped when it becomes visible on the screen.
841    ///
842    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
843    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
844    /// automatically for all new windows.
845    ///
846    ///
847    ///
848    ///
849    /// #### `mnemonic-activate`
850    ///  The default handler for this signal activates `widget` if `group_cycling`
851    /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
852    ///
853    ///
854    ///
855    ///
856    /// #### `motion-notify-event`
857    ///  The ::motion-notify-event signal is emitted when the pointer moves
858    /// over the widget's [`gdk::Window`][crate::gdk::Window].
859    ///
860    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
861    /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
862    ///
863    /// This signal will be sent to the grab widget if there is one.
864    ///
865    ///
866    ///
867    ///
868    /// #### `move-focus`
869    ///  Action
870    ///
871    ///
872    /// #### `parent-set`
873    ///  The ::parent-set signal is emitted when a new parent
874    /// has been set on a widget.
875    ///
876    ///
877    ///
878    ///
879    /// #### `popup-menu`
880    ///  This signal gets emitted whenever a widget should pop up a context
881    /// menu. This usually happens through the standard key binding mechanism;
882    /// by pressing a certain key while a widget is focused, the user can cause
883    /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
884    /// a menu with clipboard commands. See the
885    /// [Popup Menu Migration Checklist][checklist-popup-menu]
886    /// for an example of how to use this signal.
887    ///
888    /// Action
889    ///
890    ///
891    /// #### `property-notify-event`
892    ///  The ::property-notify-event signal will be emitted when a property on
893    /// the `widget`'s window has been changed or deleted.
894    ///
895    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
896    /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
897    ///
898    ///
899    ///
900    ///
901    /// #### `proximity-in-event`
902    ///  To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
903    /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
904    ///
905    /// This signal will be sent to the grab widget if there is one.
906    ///
907    ///
908    ///
909    ///
910    /// #### `proximity-out-event`
911    ///  To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
912    /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
913    ///
914    /// This signal will be sent to the grab widget if there is one.
915    ///
916    ///
917    ///
918    ///
919    /// #### `query-tooltip`
920    ///  Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
921    /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
922    /// focus in keyboard mode.
923    ///
924    /// Using the given coordinates, the signal handler should determine
925    /// whether a tooltip should be shown for `widget`. If this is the case
926    /// [`true`] should be returned, [`false`] otherwise. Note that if
927    /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
928    /// should not be used.
929    ///
930    /// The signal handler is free to manipulate `tooltip` with the therefore
931    /// destined function calls.
932    ///
933    ///
934    ///
935    ///
936    /// #### `realize`
937    ///  The ::realize signal is emitted when `widget` is associated with a
938    /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
939    /// widget has been mapped (that is, it is going to be drawn).
940    ///
941    ///
942    ///
943    ///
944    /// #### `screen-changed`
945    ///  The ::screen-changed signal gets emitted when the
946    /// screen of a widget has changed.
947    ///
948    ///
949    ///
950    ///
951    /// #### `scroll-event`
952    ///  The ::scroll-event signal is emitted when a button in the 4 to 7
953    /// range is pressed. Wheel mice are usually configured to generate
954    /// button press events for buttons 4 and 5 when the wheel is turned.
955    ///
956    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
957    /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
958    ///
959    /// This signal will be sent to the grab widget if there is one.
960    ///
961    ///
962    ///
963    ///
964    /// #### `selection-clear-event`
965    ///  The ::selection-clear-event signal will be emitted when the
966    /// the `widget`'s window has lost ownership of a selection.
967    ///
968    ///
969    ///
970    ///
971    /// #### `selection-get`
972    ///
973    ///
974    ///
975    /// #### `selection-notify-event`
976    ///
977    ///
978    ///
979    /// #### `selection-received`
980    ///
981    ///
982    ///
983    /// #### `selection-request-event`
984    ///  The ::selection-request-event signal will be emitted when
985    /// another client requests ownership of the selection owned by
986    /// the `widget`'s window.
987    ///
988    ///
989    ///
990    ///
991    /// #### `show`
992    ///  The ::show signal is emitted when `widget` is shown, for example with
993    /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
994    ///
995    ///
996    ///
997    ///
998    /// #### `show-help`
999    ///  Action
1000    ///
1001    ///
1002    /// #### `size-allocate`
1003    ///
1004    ///
1005    ///
1006    /// #### `state-changed`
1007    ///  The ::state-changed signal is emitted when the widget state changes.
1008    /// See `gtk_widget_get_state()`.
1009    ///
1010    ///
1011    ///
1012    ///
1013    /// #### `state-flags-changed`
1014    ///  The ::state-flags-changed signal is emitted when the widget state
1015    /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1016    ///
1017    ///
1018    ///
1019    ///
1020    /// #### `style-set`
1021    ///  The ::style-set signal is emitted when a new style has been set
1022    /// on a widget. Note that style-modifying functions like
1023    /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1024    ///
1025    /// Note that this signal is emitted for changes to the deprecated
1026    /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1027    /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1028    ///
1029    ///
1030    ///
1031    ///
1032    /// #### `style-updated`
1033    ///  The ::style-updated signal is a convenience signal that is emitted when the
1034    /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1035    /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1036    ///
1037    /// Note that style-modifying functions like `gtk_widget_override_color()` also
1038    /// cause this signal to be emitted.
1039    ///
1040    ///
1041    ///
1042    ///
1043    /// #### `touch-event`
1044    ///
1045    ///
1046    ///
1047    /// #### `unmap`
1048    ///  The ::unmap signal is emitted when `widget` is going to be unmapped, which
1049    /// means that either it or any of its parents up to the toplevel widget have
1050    /// been set as hidden.
1051    ///
1052    /// As ::unmap indicates that a widget will not be shown any longer, it can be
1053    /// used to, for example, stop an animation on the widget.
1054    ///
1055    ///
1056    ///
1057    ///
1058    /// #### `unmap-event`
1059    ///  The ::unmap-event signal will be emitted when the `widget`'s window is
1060    /// unmapped. A window is unmapped when it becomes invisible on the screen.
1061    ///
1062    /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1063    /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1064    /// automatically for all new windows.
1065    ///
1066    ///
1067    ///
1068    ///
1069    /// #### `unrealize`
1070    ///  The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1071    /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1072    /// called or the widget has been unmapped (that is, it is going to be
1073    /// hidden).
1074    ///
1075    ///
1076    ///
1077    ///
1078    /// #### `visibility-notify-event`
1079    ///  The ::visibility-notify-event will be emitted when the `widget`'s
1080    /// window is obscured or unobscured.
1081    ///
1082    /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1083    /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1084    ///
1085    ///
1086    ///
1087    ///
1088    /// #### `window-state-event`
1089    ///  The ::window-state-event will be emitted when the state of the
1090    /// toplevel window associated to the `widget` changes.
1091    ///
1092    /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1093    /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1094    /// this mask automatically for all new windows.
1095    ///
1096    ///
1097    /// </details>
1098    ///
1099    /// # Implements
1100    ///
1101    /// [`MenuShellExt`][trait@crate::prelude::MenuShellExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1102    #[doc(alias = "GtkMenuShell")]
1103    pub struct MenuShell(Object<ffi::GtkMenuShell, ffi::GtkMenuShellClass>) @extends Container, Widget, @implements Buildable;
1104
1105    match fn {
1106        type_ => || ffi::gtk_menu_shell_get_type(),
1107    }
1108}
1109
1110impl MenuShell {
1111    pub const NONE: Option<&'static MenuShell> = None;
1112}
1113
1114/// Trait containing all [`struct@MenuShell`] methods.
1115///
1116/// # Implementors
1117///
1118/// [`MenuBar`][struct@crate::MenuBar], [`MenuShell`][struct@crate::MenuShell], [`Menu`][struct@crate::Menu]
1119pub trait MenuShellExt: IsA<MenuShell> + 'static {
1120    /// Activates the menu item within the menu shell.
1121    /// ## `menu_item`
1122    /// the [`MenuItem`][crate::MenuItem] to activate
1123    /// ## `force_deactivate`
1124    /// if [`true`], force the deactivation of the
1125    ///  menu shell after the menu item is activated
1126    #[doc(alias = "gtk_menu_shell_activate_item")]
1127    fn activate_item(&self, menu_item: &impl IsA<Widget>, force_deactivate: bool) {
1128        unsafe {
1129            ffi::gtk_menu_shell_activate_item(
1130                self.as_ref().to_glib_none().0,
1131                menu_item.as_ref().to_glib_none().0,
1132                force_deactivate.into_glib(),
1133            );
1134        }
1135    }
1136
1137    /// Adds a new [`MenuItem`][crate::MenuItem] to the end of the menu shell's
1138    /// item list.
1139    /// ## `child`
1140    /// The [`MenuItem`][crate::MenuItem] to add
1141    #[doc(alias = "gtk_menu_shell_append")]
1142    fn append(&self, child: &impl IsA<MenuItem>) {
1143        unsafe {
1144            ffi::gtk_menu_shell_append(
1145                self.as_ref().to_glib_none().0,
1146                child.as_ref().to_glib_none().0,
1147            );
1148        }
1149    }
1150
1151    /// Establishes a binding between a [`MenuShell`][crate::MenuShell] and a [`gio::MenuModel`][crate::gio::MenuModel].
1152    ///
1153    /// The contents of `shell` are removed and then refilled with menu items
1154    /// according to `model`. When `model` changes, `shell` is updated.
1155    /// Calling this function twice on `shell` with different `model` will
1156    /// cause the first binding to be replaced with a binding to the new
1157    /// model. If `model` is [`None`] then any previous binding is undone and
1158    /// all children are removed.
1159    ///
1160    /// `with_separators` determines if toplevel items (eg: sections) have
1161    /// separators inserted between them. This is typically desired for
1162    /// menus but doesn’t make sense for menubars.
1163    ///
1164    /// If `action_namespace` is non-[`None`] then the effect is as if all
1165    /// actions mentioned in the `model` have their names prefixed with the
1166    /// namespace, plus a dot. For example, if the action “quit” is
1167    /// mentioned and `action_namespace` is “app” then the effective action
1168    /// name is “app.quit”.
1169    ///
1170    /// This function uses [`Actionable`][crate::Actionable] to define the action name and
1171    /// target values on the created menu items. If you want to use an
1172    /// action group other than “app” and “win”, or if you want to use a
1173    /// [`MenuShell`][crate::MenuShell] outside of a [`ApplicationWindow`][crate::ApplicationWindow], then you will need
1174    /// to attach your own action group to the widget hierarchy using
1175    /// [`WidgetExt::insert_action_group()`][crate::prelude::WidgetExt::insert_action_group()]. As an example, if you created a
1176    /// group with a “quit” action and inserted it with the name “mygroup”
1177    /// then you would use the action name “mygroup.quit” in your
1178    /// [`gio::MenuModel`][crate::gio::MenuModel].
1179    ///
1180    /// For most cases you are probably better off using
1181    /// [`Menu::from_model()`][crate::Menu::from_model()] or [`MenuBar::from_model()`][crate::MenuBar::from_model()] or just
1182    /// directly passing the [`gio::MenuModel`][crate::gio::MenuModel] to [`GtkApplicationExt::set_app_menu()`][crate::prelude::GtkApplicationExt::set_app_menu()] or
1183    /// [`GtkApplicationExt::set_menubar()`][crate::prelude::GtkApplicationExt::set_menubar()].
1184    /// ## `model`
1185    /// the [`gio::MenuModel`][crate::gio::MenuModel] to bind to or [`None`] to remove
1186    ///  binding
1187    /// ## `action_namespace`
1188    /// the namespace for actions in `model`
1189    /// ## `with_separators`
1190    /// [`true`] if toplevel items in `shell` should have
1191    ///  separators between them
1192    #[doc(alias = "gtk_menu_shell_bind_model")]
1193    fn bind_model(
1194        &self,
1195        model: Option<&impl IsA<gio::MenuModel>>,
1196        action_namespace: Option<&str>,
1197        with_separators: bool,
1198    ) {
1199        unsafe {
1200            ffi::gtk_menu_shell_bind_model(
1201                self.as_ref().to_glib_none().0,
1202                model.map(|p| p.as_ref()).to_glib_none().0,
1203                action_namespace.to_glib_none().0,
1204                with_separators.into_glib(),
1205            );
1206        }
1207    }
1208
1209    /// Cancels the selection within the menu shell.
1210    #[doc(alias = "gtk_menu_shell_cancel")]
1211    fn cancel(&self) {
1212        unsafe {
1213            ffi::gtk_menu_shell_cancel(self.as_ref().to_glib_none().0);
1214        }
1215    }
1216
1217    /// Deactivates the menu shell.
1218    ///
1219    /// Typically this results in the menu shell being erased
1220    /// from the screen.
1221    #[doc(alias = "gtk_menu_shell_deactivate")]
1222    fn deactivate(&self) {
1223        unsafe {
1224            ffi::gtk_menu_shell_deactivate(self.as_ref().to_glib_none().0);
1225        }
1226    }
1227
1228    /// Deselects the currently selected item from the menu shell,
1229    /// if any.
1230    #[doc(alias = "gtk_menu_shell_deselect")]
1231    fn deselect(&self) {
1232        unsafe {
1233            ffi::gtk_menu_shell_deselect(self.as_ref().to_glib_none().0);
1234        }
1235    }
1236
1237    /// Gets the parent menu shell.
1238    ///
1239    /// The parent menu shell of a submenu is the [`Menu`][crate::Menu] or [`MenuBar`][crate::MenuBar]
1240    /// from which it was opened up.
1241    ///
1242    /// # Returns
1243    ///
1244    /// the parent [`MenuShell`][crate::MenuShell]
1245    #[doc(alias = "gtk_menu_shell_get_parent_shell")]
1246    #[doc(alias = "get_parent_shell")]
1247    fn parent_shell(&self) -> Option<Widget> {
1248        unsafe {
1249            from_glib_none(ffi::gtk_menu_shell_get_parent_shell(
1250                self.as_ref().to_glib_none().0,
1251            ))
1252        }
1253    }
1254
1255    /// Gets the currently selected item.
1256    ///
1257    /// # Returns
1258    ///
1259    /// the currently selected item
1260    #[doc(alias = "gtk_menu_shell_get_selected_item")]
1261    #[doc(alias = "get_selected_item")]
1262    fn selected_item(&self) -> Option<Widget> {
1263        unsafe {
1264            from_glib_none(ffi::gtk_menu_shell_get_selected_item(
1265                self.as_ref().to_glib_none().0,
1266            ))
1267        }
1268    }
1269
1270    /// Returns [`true`] if the menu shell will take the keyboard focus on popup.
1271    ///
1272    /// # Returns
1273    ///
1274    /// [`true`] if the menu shell will take the keyboard focus on popup.
1275    #[doc(alias = "gtk_menu_shell_get_take_focus")]
1276    #[doc(alias = "get_take_focus")]
1277    #[doc(alias = "take-focus")]
1278    fn takes_focus(&self) -> bool {
1279        unsafe {
1280            from_glib(ffi::gtk_menu_shell_get_take_focus(
1281                self.as_ref().to_glib_none().0,
1282            ))
1283        }
1284    }
1285
1286    /// Adds a new [`MenuItem`][crate::MenuItem] to the menu shell’s item list
1287    /// at the position indicated by `position`.
1288    /// ## `child`
1289    /// The [`MenuItem`][crate::MenuItem] to add
1290    /// ## `position`
1291    /// The position in the item list where `child`
1292    ///  is added. Positions are numbered from 0 to n-1
1293    #[doc(alias = "gtk_menu_shell_insert")]
1294    fn insert(&self, child: &impl IsA<Widget>, position: i32) {
1295        unsafe {
1296            ffi::gtk_menu_shell_insert(
1297                self.as_ref().to_glib_none().0,
1298                child.as_ref().to_glib_none().0,
1299                position,
1300            );
1301        }
1302    }
1303
1304    /// Adds a new [`MenuItem`][crate::MenuItem] to the beginning of the menu shell's
1305    /// item list.
1306    /// ## `child`
1307    /// The [`MenuItem`][crate::MenuItem] to add
1308    #[doc(alias = "gtk_menu_shell_prepend")]
1309    fn prepend(&self, child: &impl IsA<Widget>) {
1310        unsafe {
1311            ffi::gtk_menu_shell_prepend(
1312                self.as_ref().to_glib_none().0,
1313                child.as_ref().to_glib_none().0,
1314            );
1315        }
1316    }
1317
1318    /// Select the first visible or selectable child of the menu shell;
1319    /// don’t select tearoff items unless the only item is a tearoff
1320    /// item.
1321    /// ## `search_sensitive`
1322    /// if [`true`], search for the first selectable
1323    ///  menu item, otherwise select nothing if
1324    ///  the first item isn’t sensitive. This
1325    ///  should be [`false`] if the menu is being
1326    ///  popped up initially.
1327    #[doc(alias = "gtk_menu_shell_select_first")]
1328    fn select_first(&self, search_sensitive: bool) {
1329        unsafe {
1330            ffi::gtk_menu_shell_select_first(
1331                self.as_ref().to_glib_none().0,
1332                search_sensitive.into_glib(),
1333            );
1334        }
1335    }
1336
1337    /// Selects the menu item from the menu shell.
1338    /// ## `menu_item`
1339    /// The [`MenuItem`][crate::MenuItem] to select
1340    #[doc(alias = "gtk_menu_shell_select_item")]
1341    fn select_item(&self, menu_item: &impl IsA<Widget>) {
1342        unsafe {
1343            ffi::gtk_menu_shell_select_item(
1344                self.as_ref().to_glib_none().0,
1345                menu_item.as_ref().to_glib_none().0,
1346            );
1347        }
1348    }
1349
1350    /// If `take_focus` is [`true`] (the default) the menu shell will take
1351    /// the keyboard focus so that it will receive all keyboard events
1352    /// which is needed to enable keyboard navigation in menus.
1353    ///
1354    /// Setting `take_focus` to [`false`] is useful only for special applications
1355    /// like virtual keyboard implementations which should not take keyboard
1356    /// focus.
1357    ///
1358    /// The `take_focus` state of a menu or menu bar is automatically
1359    /// propagated to submenus whenever a submenu is popped up, so you
1360    /// don’t have to worry about recursively setting it for your entire
1361    /// menu hierarchy. Only when programmatically picking a submenu and
1362    /// popping it up manually, the `take_focus` property of the submenu
1363    /// needs to be set explicitly.
1364    ///
1365    /// Note that setting it to [`false`] has side-effects:
1366    ///
1367    /// If the focus is in some other app, it keeps the focus and keynav in
1368    /// the menu doesn’t work. Consequently, keynav on the menu will only
1369    /// work if the focus is on some toplevel owned by the onscreen keyboard.
1370    ///
1371    /// To avoid confusing the user, menus with `take_focus` set to [`false`]
1372    /// should not display mnemonics or accelerators, since it cannot be
1373    /// guaranteed that they will work.
1374    ///
1375    /// See also `gdk_keyboard_grab()`
1376    /// ## `take_focus`
1377    /// [`true`] if the menu shell should take the keyboard
1378    ///  focus on popup
1379    #[doc(alias = "gtk_menu_shell_set_take_focus")]
1380    #[doc(alias = "take-focus")]
1381    fn set_take_focus(&self, take_focus: bool) {
1382        unsafe {
1383            ffi::gtk_menu_shell_set_take_focus(
1384                self.as_ref().to_glib_none().0,
1385                take_focus.into_glib(),
1386            );
1387        }
1388    }
1389
1390    /// An action signal that activates the current menu item within
1391    /// the menu shell.
1392    /// ## `force_hide`
1393    /// if [`true`], hide the menu after activating the menu item
1394    #[doc(alias = "activate-current")]
1395    fn connect_activate_current<F: Fn(&Self, bool) + 'static>(&self, f: F) -> SignalHandlerId {
1396        unsafe extern "C" fn activate_current_trampoline<
1397            P: IsA<MenuShell>,
1398            F: Fn(&P, bool) + 'static,
1399        >(
1400            this: *mut ffi::GtkMenuShell,
1401            force_hide: glib::ffi::gboolean,
1402            f: glib::ffi::gpointer,
1403        ) {
1404            unsafe {
1405                let f: &F = &*(f as *const F);
1406                f(
1407                    MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
1408                    from_glib(force_hide),
1409                )
1410            }
1411        }
1412        unsafe {
1413            let f: Box_<F> = Box_::new(f);
1414            connect_raw(
1415                self.as_ptr() as *mut _,
1416                c"activate-current".as_ptr(),
1417                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1418                    activate_current_trampoline::<Self, F> as *const (),
1419                )),
1420                Box_::into_raw(f),
1421            )
1422        }
1423    }
1424
1425    fn emit_activate_current(&self, force_hide: bool) {
1426        self.emit_by_name::<()>("activate-current", &[&force_hide]);
1427    }
1428
1429    /// An action signal which cancels the selection within the menu shell.
1430    /// Causes the [`selection-done`][struct@crate::MenuShell#selection-done] signal to be emitted.
1431    #[doc(alias = "cancel")]
1432    fn connect_cancel<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1433        unsafe extern "C" fn cancel_trampoline<P: IsA<MenuShell>, F: Fn(&P) + 'static>(
1434            this: *mut ffi::GtkMenuShell,
1435            f: glib::ffi::gpointer,
1436        ) {
1437            unsafe {
1438                let f: &F = &*(f as *const F);
1439                f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
1440            }
1441        }
1442        unsafe {
1443            let f: Box_<F> = Box_::new(f);
1444            connect_raw(
1445                self.as_ptr() as *mut _,
1446                c"cancel".as_ptr(),
1447                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1448                    cancel_trampoline::<Self, F> as *const (),
1449                )),
1450                Box_::into_raw(f),
1451            )
1452        }
1453    }
1454
1455    fn emit_cancel(&self) {
1456        self.emit_by_name::<()>("cancel", &[]);
1457    }
1458
1459    /// A keybinding signal which moves the focus in the
1460    /// given `direction`.
1461    /// ## `direction`
1462    /// the direction to cycle in
1463    #[doc(alias = "cycle-focus")]
1464    fn connect_cycle_focus<F: Fn(&Self, DirectionType) + 'static>(&self, f: F) -> SignalHandlerId {
1465        unsafe extern "C" fn cycle_focus_trampoline<
1466            P: IsA<MenuShell>,
1467            F: Fn(&P, DirectionType) + 'static,
1468        >(
1469            this: *mut ffi::GtkMenuShell,
1470            direction: ffi::GtkDirectionType,
1471            f: glib::ffi::gpointer,
1472        ) {
1473            unsafe {
1474                let f: &F = &*(f as *const F);
1475                f(
1476                    MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
1477                    from_glib(direction),
1478                )
1479            }
1480        }
1481        unsafe {
1482            let f: Box_<F> = Box_::new(f);
1483            connect_raw(
1484                self.as_ptr() as *mut _,
1485                c"cycle-focus".as_ptr(),
1486                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1487                    cycle_focus_trampoline::<Self, F> as *const (),
1488                )),
1489                Box_::into_raw(f),
1490            )
1491        }
1492    }
1493
1494    fn emit_cycle_focus(&self, direction: DirectionType) {
1495        self.emit_by_name::<()>("cycle-focus", &[&direction]);
1496    }
1497
1498    /// This signal is emitted when a menu shell is deactivated.
1499    #[doc(alias = "deactivate")]
1500    fn connect_deactivate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1501        unsafe extern "C" fn deactivate_trampoline<P: IsA<MenuShell>, F: Fn(&P) + 'static>(
1502            this: *mut ffi::GtkMenuShell,
1503            f: glib::ffi::gpointer,
1504        ) {
1505            unsafe {
1506                let f: &F = &*(f as *const F);
1507                f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
1508            }
1509        }
1510        unsafe {
1511            let f: Box_<F> = Box_::new(f);
1512            connect_raw(
1513                self.as_ptr() as *mut _,
1514                c"deactivate".as_ptr(),
1515                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1516                    deactivate_trampoline::<Self, F> as *const (),
1517                )),
1518                Box_::into_raw(f),
1519            )
1520        }
1521    }
1522
1523    /// The ::insert signal is emitted when a new [`MenuItem`][crate::MenuItem] is added to
1524    /// a [`MenuShell`][crate::MenuShell]. A separate signal is used instead of
1525    /// GtkContainer::add because of the need for an additional position
1526    /// parameter.
1527    ///
1528    /// The inverse of this signal is the GtkContainer::removed signal.
1529    /// ## `child`
1530    /// the [`MenuItem`][crate::MenuItem] that is being inserted
1531    /// ## `position`
1532    /// the position at which the insert occurs
1533    #[doc(alias = "insert")]
1534    fn connect_insert<F: Fn(&Self, &Widget, i32) + 'static>(&self, f: F) -> SignalHandlerId {
1535        unsafe extern "C" fn insert_trampoline<
1536            P: IsA<MenuShell>,
1537            F: Fn(&P, &Widget, i32) + 'static,
1538        >(
1539            this: *mut ffi::GtkMenuShell,
1540            child: *mut ffi::GtkWidget,
1541            position: std::ffi::c_int,
1542            f: glib::ffi::gpointer,
1543        ) {
1544            unsafe {
1545                let f: &F = &*(f as *const F);
1546                f(
1547                    MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
1548                    &from_glib_borrow(child),
1549                    position,
1550                )
1551            }
1552        }
1553        unsafe {
1554            let f: Box_<F> = Box_::new(f);
1555            connect_raw(
1556                self.as_ptr() as *mut _,
1557                c"insert".as_ptr(),
1558                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1559                    insert_trampoline::<Self, F> as *const (),
1560                )),
1561                Box_::into_raw(f),
1562            )
1563        }
1564    }
1565
1566    /// An keybinding signal which moves the current menu item
1567    /// in the direction specified by `direction`.
1568    /// ## `direction`
1569    /// the direction to move
1570    #[doc(alias = "move-current")]
1571    fn connect_move_current<F: Fn(&Self, MenuDirectionType) + 'static>(
1572        &self,
1573        f: F,
1574    ) -> SignalHandlerId {
1575        unsafe extern "C" fn move_current_trampoline<
1576            P: IsA<MenuShell>,
1577            F: Fn(&P, MenuDirectionType) + 'static,
1578        >(
1579            this: *mut ffi::GtkMenuShell,
1580            direction: ffi::GtkMenuDirectionType,
1581            f: glib::ffi::gpointer,
1582        ) {
1583            unsafe {
1584                let f: &F = &*(f as *const F);
1585                f(
1586                    MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
1587                    from_glib(direction),
1588                )
1589            }
1590        }
1591        unsafe {
1592            let f: Box_<F> = Box_::new(f);
1593            connect_raw(
1594                self.as_ptr() as *mut _,
1595                c"move-current".as_ptr(),
1596                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1597                    move_current_trampoline::<Self, F> as *const (),
1598                )),
1599                Box_::into_raw(f),
1600            )
1601        }
1602    }
1603
1604    fn emit_move_current(&self, direction: MenuDirectionType) {
1605        self.emit_by_name::<()>("move-current", &[&direction]);
1606    }
1607
1608    /// The ::move-selected signal is emitted to move the selection to
1609    /// another item.
1610    /// ## `distance`
1611    /// +1 to move to the next item, -1 to move to the previous
1612    ///
1613    /// # Returns
1614    ///
1615    /// [`true`] to stop the signal emission, [`false`] to continue
1616    #[doc(alias = "move-selected")]
1617    fn connect_move_selected<F: Fn(&Self, i32) -> glib::Propagation + 'static>(
1618        &self,
1619        f: F,
1620    ) -> SignalHandlerId {
1621        unsafe extern "C" fn move_selected_trampoline<
1622            P: IsA<MenuShell>,
1623            F: Fn(&P, i32) -> glib::Propagation + 'static,
1624        >(
1625            this: *mut ffi::GtkMenuShell,
1626            distance: std::ffi::c_int,
1627            f: glib::ffi::gpointer,
1628        ) -> glib::ffi::gboolean {
1629            unsafe {
1630                let f: &F = &*(f as *const F);
1631                f(
1632                    MenuShell::from_glib_borrow(this).unsafe_cast_ref(),
1633                    distance,
1634                )
1635                .into_glib()
1636            }
1637        }
1638        unsafe {
1639            let f: Box_<F> = Box_::new(f);
1640            connect_raw(
1641                self.as_ptr() as *mut _,
1642                c"move-selected".as_ptr(),
1643                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1644                    move_selected_trampoline::<Self, F> as *const (),
1645                )),
1646                Box_::into_raw(f),
1647            )
1648        }
1649    }
1650
1651    /// This signal is emitted when a selection has been
1652    /// completed within a menu shell.
1653    #[doc(alias = "selection-done")]
1654    fn connect_selection_done<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1655        unsafe extern "C" fn selection_done_trampoline<P: IsA<MenuShell>, F: Fn(&P) + 'static>(
1656            this: *mut ffi::GtkMenuShell,
1657            f: glib::ffi::gpointer,
1658        ) {
1659            unsafe {
1660                let f: &F = &*(f as *const F);
1661                f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
1662            }
1663        }
1664        unsafe {
1665            let f: Box_<F> = Box_::new(f);
1666            connect_raw(
1667                self.as_ptr() as *mut _,
1668                c"selection-done".as_ptr(),
1669                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1670                    selection_done_trampoline::<Self, F> as *const (),
1671                )),
1672                Box_::into_raw(f),
1673            )
1674        }
1675    }
1676
1677    #[doc(alias = "take-focus")]
1678    fn connect_take_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1679        unsafe extern "C" fn notify_take_focus_trampoline<
1680            P: IsA<MenuShell>,
1681            F: Fn(&P) + 'static,
1682        >(
1683            this: *mut ffi::GtkMenuShell,
1684            _param_spec: glib::ffi::gpointer,
1685            f: glib::ffi::gpointer,
1686        ) {
1687            unsafe {
1688                let f: &F = &*(f as *const F);
1689                f(MenuShell::from_glib_borrow(this).unsafe_cast_ref())
1690            }
1691        }
1692        unsafe {
1693            let f: Box_<F> = Box_::new(f);
1694            connect_raw(
1695                self.as_ptr() as *mut _,
1696                c"notify::take-focus".as_ptr(),
1697                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1698                    notify_take_focus_trampoline::<Self, F> as *const (),
1699                )),
1700                Box_::into_raw(f),
1701            )
1702        }
1703    }
1704}
1705
1706impl<O: IsA<MenuShell>> MenuShellExt for O {}