pub trait MenuShellExt: 'static {
Show 27 methods fn activate_item(&self, menu_item: &impl IsA<Widget>, force_deactivate: bool); fn append(&self, child: &impl IsA<MenuItem>); fn bind_model(
        &self,
        model: Option<&impl IsA<MenuModel>>,
        action_namespace: Option<&str>,
        with_separators: bool
    ); fn cancel(&self); fn deactivate(&self); fn deselect(&self); fn parent_shell(&self) -> Option<Widget>; fn selected_item(&self) -> Option<Widget>; fn takes_focus(&self) -> bool; fn insert(&self, child: &impl IsA<Widget>, position: i32); fn prepend(&self, child: &impl IsA<Widget>); fn select_first(&self, search_sensitive: bool); fn select_item(&self, menu_item: &impl IsA<Widget>); fn set_take_focus(&self, take_focus: bool); fn connect_activate_current<F: Fn(&Self, bool) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn emit_activate_current(&self, force_hide: bool); fn connect_cancel<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn emit_cancel(&self); fn connect_cycle_focus<F: Fn(&Self, DirectionType) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn emit_cycle_focus(&self, direction: DirectionType); fn connect_deactivate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_insert<F: Fn(&Self, &Widget, i32) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_move_current<F: Fn(&Self, MenuDirectionType) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn emit_move_current(&self, direction: MenuDirectionType); fn connect_move_selected<F: Fn(&Self, i32) -> Inhibit + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_selection_done<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_take_focus_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Trait containing all MenuShell methods.

Implementors

MenuBar, MenuShell, Menu

Required Methods

Activates the menu item within the menu shell.

the MenuItem to activate

force_deactivate

if true, force the deactivation of the menu shell after the menu item is activated

Adds a new MenuItem to the end of the menu shell’s item list.

child

The MenuItem to add

Establishes a binding between a MenuShell and a gio::MenuModel.

The contents of shell are removed and then refilled with menu items according to model. When model changes, shell is updated. Calling this function twice on shell with different model will cause the first binding to be replaced with a binding to the new model. If model is None then any previous binding is undone and all children are removed.

with_separators determines if toplevel items (eg: sections) have separators inserted between them. This is typically desired for menus but doesn’t make sense for menubars.

If action_namespace is non-None then the effect is as if all actions mentioned in the model have their names prefixed with the namespace, plus a dot. For example, if the action “quit” is mentioned and action_namespace is “app” then the effective action name is “app.quit”.

This function uses Actionable to define the action name and target values on the created menu items. If you want to use an action group other than “app” and “win”, or if you want to use a MenuShell outside of a ApplicationWindow, then you will need to attach your own action group to the widget hierarchy using WidgetExt::insert_action_group(). As an example, if you created a group with a “quit” action and inserted it with the name “mygroup” then you would use the action name “mygroup.quit” in your gio::MenuModel.

For most cases you are probably better off using Menu::from_model() or MenuBar::from_model() or just directly passing the gio::MenuModel to GtkApplicationExt::set_app_menu() or GtkApplicationExt::set_menubar().

model

the gio::MenuModel to bind to or None to remove binding

action_namespace

the namespace for actions in model

with_separators

true if toplevel items in shell should have separators between them

Cancels the selection within the menu shell.

Deactivates the menu shell.

Typically this results in the menu shell being erased from the screen.

Deselects the currently selected item from the menu shell, if any.

Gets the parent menu shell.

The parent menu shell of a submenu is the Menu or MenuBar from which it was opened up.

Returns

the parent MenuShell

Gets the currently selected item.

Returns

the currently selected item

Returns true if the menu shell will take the keyboard focus on popup.

Returns

true if the menu shell will take the keyboard focus on popup.

Adds a new MenuItem to the menu shell’s item list at the position indicated by position.

child

The MenuItem to add

position

The position in the item list where child is added. Positions are numbered from 0 to n-1

Adds a new MenuItem to the beginning of the menu shell’s item list.

child

The MenuItem to add

Select the first visible or selectable child of the menu shell; don’t select tearoff items unless the only item is a tearoff item.

search_sensitive

if true, search for the first selectable menu item, otherwise select nothing if the first item isn’t sensitive. This should be false if the menu is being popped up initially.

Selects the menu item from the menu shell.

The MenuItem to select

If take_focus is true (the default) the menu shell will take the keyboard focus so that it will receive all keyboard events which is needed to enable keyboard navigation in menus.

Setting take_focus to false is useful only for special applications like virtual keyboard implementations which should not take keyboard focus.

The take_focus state of a menu or menu bar is automatically propagated to submenus whenever a submenu is popped up, so you don’t have to worry about recursively setting it for your entire menu hierarchy. Only when programmatically picking a submenu and popping it up manually, the take_focus property of the submenu needs to be set explicitly.

Note that setting it to false has side-effects:

If the focus is in some other app, it keeps the focus and keynav in the menu doesn’t work. Consequently, keynav on the menu will only work if the focus is on some toplevel owned by the onscreen keyboard.

To avoid confusing the user, menus with take_focus set to false should not display mnemonics or accelerators, since it cannot be guaranteed that they will work.

See also gdk_keyboard_grab()

take_focus

true if the menu shell should take the keyboard focus on popup

An action signal that activates the current menu item within the menu shell.

force_hide

if true, hide the menu after activating the menu item

An action signal which cancels the selection within the menu shell. Causes the signal::MenuShell::selection-done signal to be emitted.

A keybinding signal which moves the focus in the given direction.

direction

the direction to cycle in

This signal is emitted when a menu shell is deactivated.

The ::insert signal is emitted when a new MenuItem is added to a MenuShell. A separate signal is used instead of GtkContainer::add because of the need for an additional position parameter.

The inverse of this signal is the GtkContainer::removed signal.

child

the MenuItem that is being inserted

position

the position at which the insert occurs

An keybinding signal which moves the current menu item in the direction specified by direction.

direction

the direction to move

The ::move-selected signal is emitted to move the selection to another item.

distance

+1 to move to the next item, -1 to move to the previous

Returns

true to stop the signal emission, false to continue

This signal is emitted when a selection has been completed within a menu shell.

Implementors