Class: Gio::Menu

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

Overview

#GMenu is a simple implementation of GMenu::Model. You populate a #GMenu by adding GMenu::Item instances to it.

There are some convenience functions to allow you to directly add items (avoiding GMenu::Item) for the common cases. To add a regular item, use g_menu_insert(). To add a section, use g_menu_insert_section(). To add a submenu, use g_menu_insert_submenu().

Instance Method Summary collapse

Instance Method Details

#append(label, detailed_action) ⇒ nil

Convenience function for appending a normal menu item to the end of menu. Combine g_menu_item_new() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • label (String)

    the section label, or nil

  • detailed_action (String)

    the detailed action string, or nil

Returns:

  • (nil)

#append_item(item) ⇒ nil

Appends item to the end of menu.

See g_menu_insert_item() for more information.

Parameters:

Returns:

  • (nil)

#append_section(label, section) ⇒ nil

Convenience function for appending a section menu item to the end of menu. Combine g_menu_item_new_section() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • label (String)

    the section label, or nil

  • section (Gio::MenuModel)

    a GMenu::Model with the items of the section

Returns:

  • (nil)

#append_submenu(label, submenu) ⇒ nil

Convenience function for appending a submenu menu item to the end of menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • label (String)

    the section label, or nil

  • submenu (Gio::MenuModel)

    a GMenu::Model with the items of the submenu

Returns:

  • (nil)

#freezenil

Marks menu as frozen.

After the menu is frozen, it is an error to attempt to make any changes to it. In effect this means that the #GMenu API must no longer be used.

This function causes g_menu_model_is_mutable() to begin returning false, which has some positive performance implications.

Returns:

  • (nil)

#insert(position, label, detailed_action) ⇒ nil

Convenience function for inserting a normal menu item into menu. Combine g_menu_item_new() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • position (Integer)

    the position at which to insert the item

  • label (String)

    the section label, or nil

  • detailed_action (String)

    the detailed action string, or nil

Returns:

  • (nil)

#insert_item(position, item) ⇒ nil

Inserts item into menu.

The “insertion” is actually done by copying all of the attribute and link values of item and using them to form a new item within menu. As such, item itself is not really inserted, but rather, a menu item that is exactly the same as the one presently described by item.

This means that item is essentially useless after the insertion occurs. Any changes you make to it are ignored unless it is inserted again (at which point its updated values will be copied).

You should probably just free item once you’re done.

There are many convenience functions to take care of common cases. See g_menu_insert(), g_menu_insert_section() and g_menu_insert_submenu() as well as “prepend” and “append” variants of each of these functions.

Parameters:

  • position (Integer)

    the position at which to insert the item

  • item (Gio::MenuItem)

    the GMenu::Item to insert

Returns:

  • (nil)

#insert_section(position, label, section) ⇒ nil

Convenience function for inserting a section menu item into menu. Combine g_menu_item_new_section() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • position (Integer)

    the position at which to insert the item

  • label (String)

    the section label, or nil

  • section (Gio::MenuModel)

    a GMenu::Model with the items of the section

Returns:

  • (nil)

#insert_submenu(position, label, submenu) ⇒ nil

Convenience function for inserting a submenu menu item into menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • position (Integer)

    the position at which to insert the item

  • label (String)

    the section label, or nil

  • submenu (Gio::MenuModel)

    a GMenu::Model with the items of the submenu

Returns:

  • (nil)

#newGio::Menu

Creates a new #GMenu.

The new menu has no items.

Returns:

#prepend(label, detailed_action) ⇒ nil

Convenience function for prepending a normal menu item to the start of menu. Combine g_menu_item_new() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • label (String)

    the section label, or nil

  • detailed_action (String)

    the detailed action string, or nil

Returns:

  • (nil)

#prepend_item(item) ⇒ nil

Prepends item to the start of menu.

See g_menu_insert_item() for more information.

Parameters:

Returns:

  • (nil)

#prepend_section(label, section) ⇒ nil

Convenience function for prepending a section menu item to the start of menu. Combine g_menu_item_new_section() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • label (String)

    the section label, or nil

  • section (Gio::MenuModel)

    a GMenu::Model with the items of the section

Returns:

  • (nil)

#prepend_submenu(label, submenu) ⇒ nil

Convenience function for prepending a submenu menu item to the start of menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for a more flexible alternative.

Parameters:

  • label (String)

    the section label, or nil

  • submenu (Gio::MenuModel)

    a GMenu::Model with the items of the submenu

Returns:

  • (nil)

#remove(position) ⇒ nil

Removes an item from the menu.

position gives the index of the item to remove.

It is an error if position is not in range the range from 0 to one less than the number of items in the menu.

It is not possible to remove items by identity since items are added to the menu simply by copying their links and attributes (ie: identity of the item itself is not preserved).

Parameters:

  • position (Integer)

    the position of the item to remove

Returns:

  • (nil)

#remove_allnil

Removes all items in the menu.

Returns:

  • (nil)