Class: Gtk::MenuShell

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#activate_item(menu_item, force_deactivate) ⇒ nil

Activates the menu item within the menu shell.

Parameters:

  • menu_item (Gtk::Widget)

    the Gtk::MenuItem to activate

  • force_deactivate (TrueClass)

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

Returns:

  • (nil)

#append(child) ⇒ nil

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

Parameters:

Returns:

  • (nil)

#bind_model(model, action_namespace, with_separators) ⇒ nil

Establishes a binding between a Gtk::MenuShell and a #GMenuModel.

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 nil 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-nil 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 Gtk::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 Gtk::MenuShell outside of a #GtkApplicationWindow, then you will need to attach your own action group to the widget hierarchy using gtk_widget_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 GMenu::Model.

For most cases you are probably better off using gtk_menu_new_from_model() or gtk_menu_bar_new_from_model() or just directly passing the GMenu::Model to gtk_application_set_app_menu() or gtk_application_set_menubar().

Parameters:

  • model (Gio::MenuModel)

    the GMenu::Model to bind to or nil to remove binding

  • action_namespace (String)

    the namespace for actions in model

  • with_separators (TrueClass)

    true if toplevel items in shell should have separators between them

Returns:

  • (nil)

#cancelnil

Cancels the selection within the menu shell.

Returns:

  • (nil)

#deactivatenil

Deactivates the menu shell.

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

Returns:

  • (nil)

#deselectnil

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

Returns:

  • (nil)

#insert(child, position) ⇒ nil

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

Parameters:

  • child (Gtk::Widget)

    The Gtk::MenuItem to add

  • position (Integer)

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

Returns:

  • (nil)

#parent_shellGtk::Widget

Gets the parent menu shell.

The parent menu shell of a submenu is the Gtk::Menu or #GtkMenuBar from which it was opened up.

Returns:

#prepend(child) ⇒ nil

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

Parameters:

Returns:

  • (nil)

#select_first(search_sensitive) ⇒ nil

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

Parameters:

  • search_sensitive (TrueClass)

    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.

Returns:

  • (nil)

#select_item(menu_item) ⇒ nil

Selects the menu item from the menu shell.

Parameters:

  • menu_item (Gtk::Widget)

    The Gtk::MenuItem to select

Returns:

  • (nil)

#selected_itemGtk::Widget

Gets the currently selected item.

Returns:

#take_focusTrueClass

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

Returns:

  • (TrueClass)

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

#take_focus=(take_focus) ⇒ TrueClass

A boolean that determines whether the menu and its submenus grab the keyboard focus. See gtk_menu_shell_set_take_focus() and gtk_menu_shell_get_take_focus().

Parameters:

  • take_focus (TrueClass)

Returns:

  • (TrueClass)

    take-focus

  • (TrueClass)

    take-focus

#take_focus?TrueClass

A boolean that determines whether the menu and its submenus grab the keyboard focus. See gtk_menu_shell_set_take_focus() and gtk_menu_shell_get_take_focus().

Returns:

  • (TrueClass)

    take-focus