[][src]Trait gtk::prelude::MenuShellExt

pub trait MenuShellExt: 'static {
    fn activate_item<P: IsA<Widget>>(
        &self,
        menu_item: &P,
        force_deactivate: bool
    );
fn append<P: IsA<MenuItem>>(&self, child: &P);
fn bind_model<P: IsA<MenuModel>>(
        &self,
        model: Option<&P>,
        action_namespace: Option<&str>,
        with_separators: bool
    );
fn cancel(&self);
fn deactivate(&self);
fn deselect(&self);
fn get_parent_shell(&self) -> Option<Widget>;
fn get_selected_item(&self) -> Option<Widget>;
fn get_take_focus(&self) -> bool;
fn insert<P: IsA<Widget>>(&self, child: &P, position: i32);
fn prepend<P: IsA<Widget>>(&self, child: &P);
fn select_first(&self, search_sensitive: bool);
fn select_item<P: IsA<Widget>>(&self, menu_item: &P);
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_property_take_focus_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all MenuShell methods.

Implementors

MenuBar, MenuShell, Menu

Required methods

fn activate_item<P: IsA<Widget>>(&self, menu_item: &P, force_deactivate: bool)

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

fn append<P: IsA<MenuItem>>(&self, child: &P)

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

child

The MenuItem to add

fn bind_model<P: IsA<MenuModel>>(
    &self,
    model: Option<&P>,
    action_namespace: Option<&str>,
    with_separators: bool
)

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::new_from_model or MenuBar::new_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

fn cancel(&self)

Cancels the selection within the menu shell.

fn deactivate(&self)

Deactivates the menu shell.

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

fn deselect(&self)

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

fn get_parent_shell(&self) -> Option<Widget>

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

fn get_selected_item(&self) -> Option<Widget>

Gets the currently selected item.

Returns

the currently selected item

fn get_take_focus(&self) -> bool

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.

fn insert<P: IsA<Widget>>(&self, child: &P, position: i32)

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

fn prepend<P: IsA<Widget>>(&self, child: &P)

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

child

The MenuItem to add

fn select_first(&self, search_sensitive: bool)

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.

fn select_item<P: IsA<Widget>>(&self, menu_item: &P)

Selects the menu item from the menu shell.

The MenuItem to select

fn set_take_focus(&self, take_focus: bool)

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

fn connect_activate_current<F: Fn(&Self, bool) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

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

fn emit_activate_current(&self, force_hide: bool)

fn connect_cancel<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

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

fn emit_cancel(&self)

fn connect_cycle_focus<F: Fn(&Self, DirectionType) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

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

direction

the direction to cycle in

fn emit_cycle_focus(&self, direction: DirectionType)

fn connect_deactivate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

This signal is emitted when a menu shell is deactivated.

fn connect_insert<F: Fn(&Self, &Widget, i32) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

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

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

child

the MenuItem that is being inserted

position

the position at which the insert occurs

fn connect_move_current<F: Fn(&Self, MenuDirectionType) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

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

direction

the direction to move

fn emit_move_current(&self, direction: MenuDirectionType)

fn connect_move_selected<F: Fn(&Self, i32) -> Inhibit + 'static>(
    &self,
    f: F
) -> SignalHandlerId

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

fn connect_selection_done<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

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

fn connect_property_take_focus_notify<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

Loading content...

Implementors

impl<O: IsA<MenuShell>> MenuShellExt for O[src]

Loading content...