Class Menu

All Implemented Interfaces:
PointerInterface

public class Menu extends MenuModel
#GMenu is a simple implementation of #GMenuModel.
You populate a #GMenu by adding #GMenuItem instances to it.

There are some convenience functions to allow you to directly
add items (avoiding #GMenuItem) 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().

https://docs.gtk.org/gio/class.Menu.html

  • Constructor Details

    • Menu

      public Menu(PointerContainer pointer)
    • Menu

      public Menu()
      Creates a new #GMenu.

      The new menu has no items.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • append

      public void append(@Nullable Str label, @Nullable Str 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.
      Parameters:
      label - the section label, or %NULL
      detailed_action - the detailed action string, or %NULL
    • append

      public void 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.
      Parameters:
      label - the section label, or %NULL
      detailed_action - the detailed action string, or %NULL
    • appendItem

      public void appendItem(@Nonnull MenuItem item)
      Appends @item to the end of @menu.

      See g_menu_insert_item() for more information.
      Parameters:
      item - a #GMenuItem to append
    • appendSection

      public void appendSection(@Nullable Str label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      section - a #GMenuModel with the items of the section
    • appendSection

      public void appendSection(String label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      section - a #GMenuModel with the items of the section
    • appendSubmenu

      public void appendSubmenu(@Nullable Str label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      submenu - a #GMenuModel with the items of the submenu
    • appendSubmenu

      public void appendSubmenu(String label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      submenu - a #GMenuModel with the items of the submenu
    • freeze

      public void 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.
    • insert

      public void insert(int position, @Nullable Str label, @Nullable Str 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.
      Parameters:
      position - the position at which to insert the item
      label - the section label, or %NULL
      detailed_action - the detailed action string, or %NULL
    • insert

      public void 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.
      Parameters:
      position - the position at which to insert the item
      label - the section label, or %NULL
      detailed_action - the detailed action string, or %NULL
    • insertItem

      public void insertItem(int position, @Nonnull MenuItem 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.
      Parameters:
      position - the position at which to insert the item
      item - the #GMenuItem to insert
    • insertSection

      public void insertSection(int position, @Nullable Str label, @Nonnull MenuModel 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.
      Parameters:
      position - the position at which to insert the item
      label - the section label, or %NULL
      section - a #GMenuModel with the items of the section
    • insertSection

      public void insertSection(int position, String label, @Nonnull MenuModel 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.
      Parameters:
      position - the position at which to insert the item
      label - the section label, or %NULL
      section - a #GMenuModel with the items of the section
    • insertSubmenu

      public void insertSubmenu(int position, @Nullable Str label, @Nonnull MenuModel 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.
      Parameters:
      position - the position at which to insert the item
      label - the section label, or %NULL
      submenu - a #GMenuModel with the items of the submenu
    • insertSubmenu

      public void insertSubmenu(int position, String label, @Nonnull MenuModel 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.
      Parameters:
      position - the position at which to insert the item
      label - the section label, or %NULL
      submenu - a #GMenuModel with the items of the submenu
    • prepend

      public void prepend(@Nullable Str label, @Nullable Str 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.
      Parameters:
      label - the section label, or %NULL
      detailed_action - the detailed action string, or %NULL
    • prepend

      public void 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.
      Parameters:
      label - the section label, or %NULL
      detailed_action - the detailed action string, or %NULL
    • prependItem

      public void prependItem(@Nonnull MenuItem item)
      Prepends @item to the start of @menu.

      See g_menu_insert_item() for more information.
      Parameters:
      item - a #GMenuItem to prepend
    • prependSection

      public void prependSection(@Nullable Str label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      section - a #GMenuModel with the items of the section
    • prependSection

      public void prependSection(String label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      section - a #GMenuModel with the items of the section
    • prependSubmenu

      public void prependSubmenu(@Nullable Str label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      submenu - a #GMenuModel with the items of the submenu
    • prependSubmenu

      public void prependSubmenu(String label, @Nonnull MenuModel 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.
      Parameters:
      label - the section label, or %NULL
      submenu - a #GMenuModel with the items of the submenu
    • remove

      public void 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).
      Parameters:
      position - the position of the item to remove
    • removeAll

      public void removeAll()
      Removes all items in the menu.
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()