Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Menu

[18:7] extends: object

GMenu is a simple implementation of [class@Gio.MenuModel]. You populate a GMenu by adding [class@Gio.MenuItem] instances to it. There are some convenience functions to allow you to directly add items (avoiding [class@Gio.MenuItem]) for the common cases. To add a regular item, use [method@Gio.Menu.insert]. To add a section, use [method@Gio.Menu.insert_section]. To add a submenu, use [method@Gio.Menu.insert_submenu].

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • Menu ()

    Creates a new #GMenu. The new menu has no items.

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asMenuModel ()

    Wraps this handle as MenuModel.

    • @r A MenuModel object.
  • append (string label, string detailed_action)

    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.
    • @p label is the section label, or %NULL.
    • @p detailed_action is the detailed action string, or %NULL.
    • @r None.
  • append_item (object item)

    Appends @item to the end of @menu. See g_menu_insert_item() for more information.

    • @p item is a #GMenuItem to append.
    • @r None.
  • append_section (string label, object section)

    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.
    • @p label is the section label, or %NULL.
    • @p section is a #GMenuModel with the items of the section.
    • @r None.
  • append_submenu (string label, object submenu)

    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.
    • @p label is the section label, or %NULL.
    • @p submenu is a #GMenuModel with the items of the submenu.
    • @r None.
  • freeze ()

    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.

    • @r None.
  • insert (int position, string label, string detailed_action)

    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.

    • @p position is the position at which to insert the item.
    • @p label is the section label, or %NULL.
    • @p detailed_action is the detailed action string, or %NULL.
    • @r None.
  • insert_item (int position, object item)

    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.

    • @p position is the position at which to insert the item.
    • @p item is the #GMenuItem to insert.
    • @r None.
  • insert_section (int position, string label, object section)

    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.

    • @p position is the position at which to insert the item.
    • @p label is the section label, or %NULL.
    • @p section is a #GMenuModel with the items of the section.
    • @r None.
  • insert_submenu (int position, string label, object submenu)

    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.

    • @p position is the position at which to insert the item.
    • @p label is the section label, or %NULL.
    • @p submenu is a #GMenuModel with the items of the submenu.
    • @r None.
  • prepend (string label, string detailed_action)

    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.
    • @p label is the section label, or %NULL.
    • @p detailed_action is the detailed action string, or %NULL.
    • @r None.
  • prepend_item (object item)

    Prepends @item to the start of @menu. See g_menu_insert_item() for more information.

    • @p item is a #GMenuItem to prepend.
    • @r None.
  • prepend_section (string label, object section)

    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.
    • @p label is the section label, or %NULL.
    • @p section is a #GMenuModel with the items of the section.
    • @r None.
  • prepend_submenu (string label, object submenu)

    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.
    • @p label is the section label, or %NULL.
    • @p submenu is a #GMenuModel with the items of the submenu.
    • @r None.
  • remove (int position)

    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).

    • @p position is the position of the item to remove.
    • @r None.
  • remove_all ()

    Removes all items in the menu.

    • @r None.