glibmm: Gio::Menu Class Reference

glibmm 2.33.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions
Gio::Menu Class Reference

TODO. More...

`#include <giomm/menu.h>`

Inheritance diagram for Gio::Menu:
[legend]

List of all members.

## Public Member Functions
virtual | ~Menu ()
GMenu* | gobj ()
| Provides access to the underlying C GObject.
const GMenu* | gobj () const
| Provides access to the underlying C GObject.
GMenu* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | freeze ()
| Marks menu as frozen.
void | insert_item (int position, const Glib::RefPtr< MenuItem >& item)
| Inserts item into menu.
void | prepend_item (const Glib::RefPtr< MenuItem >& item)
| Prepends item to the start of menu.
void | append_item (const Glib::RefPtr< MenuItem >& item)
| Appends item to the end of menu.
void | remove (int position)
| Removes an item from the menu.
void | insert (int position, const Glib::ustring& label, const Glib::ustring& detailed_action=Glib::ustring())
| Convenience function for inserting a normal menu item into menu.
void | prepend (const Glib::ustring& label, const Glib::ustring& detailed_action=Glib::ustring())
| Convenience function for prepending a normal menu item to the start of menu.
void | append (const Glib::ustring& label, const Glib::ustring& detailed_action=Glib::ustring())
| Convenience function for appending a normal menu item to the end of menu.
void | insert_section (int position, const Glib::ustring& label, const Glib::RefPtr< MenuModel >& section)
| Convenience function for inserting a section menu item into menu.
void | prepend_section (const Glib::ustring& label, const Glib::RefPtr< MenuModel >& section)
| Convenience function for prepending a section menu item to the start of menu.
void | insert_submenu (int position, const Glib::ustring& label, const Glib::RefPtr< MenuModel >& submenu)
| Convenience function for inserting a submenu menu item into menu.
void | prepend_submenu (const Glib::ustring& label, const Glib::RefPtr< MenuModel >& submenu)
| Convenience function for prepending a submenu menu item to the start of menu.
void | append_submenu (const Glib::ustring& label, const Glib::RefPtr< MenuModel >& submenu)
| Convenience function for appending a submenu menu item to the end of menu.
## Static Public Member Functions
static Glib::RefPtr< Menu > | create ()
## Protected Member Functions
| Menu ()
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::Menu > | wrap (GMenu* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

TODO.

Since glibmm 2.32:

## Constructor & Destructor Documentation

virtual Gio::Menu::~Menu | ( |  | ) | `[virtual]`

Gio::Menu::Menu | ( |  | ) | `[protected]`

## Member Function Documentation

void Gio::Menu::append | ( | const Glib::ustring& | label,
|  | const Glib::ustring& | detailed_action = `Glib::ustring()`
| ) |  |

Convenience function for appending a normal menu item to the end of menu.

Combine g_menu_new() and g_menu_insert_item() for a more flexible alternative.

Since glibmm 2.32:

Parameters:

  label | The section label, or `0`.
  detailed_action | The detailed action string, or `0`.

void Gio::Menu::append_item | ( | const Glib::RefPtr< MenuItem >& | item | ) |

Appends item to the end of menu.

See g_menu_insert_item() for more information.

Since glibmm 2.32:

Parameters:

  item | A MenuItem to append.

void Gio::Menu::append_submenu | ( | const Glib::ustring& | label,
|  | const Glib::RefPtr< 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.

Since glibmm 2.32:

Parameters:

  label | The section label, or `0`.
  submenu | A MenuModel with the items of the submenu.

static Glib::RefPtr<Menu> Gio::Menu::create | ( |  | ) | `[static]`

void Gio::Menu::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 Menu API must no longer be used.

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

Since glibmm 2.32:

GMenu* Gio::Menu::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::MenuModel.

const GMenu* Gio::Menu::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::MenuModel.

GMenu* Gio::Menu::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Reimplemented from Gio::MenuModel.

void Gio::Menu::insert | ( | int | position,
|  | const Glib::ustring& | label,
|  | const Glib::ustring& | detailed_action = `Glib::ustring()`
| ) |  |

Convenience function for inserting a normal menu item into menu.

Combine g_menu_new() and g_menu_insert_item() for a more flexible alternative.

Since glibmm 2.32:

Parameters:

  position | The position at which to insert the item.
  label | The section label, or `0`.
  detailed_action | The detailed action string, or `0`.

void Gio::Menu::insert_item | ( | int | position,
|  | const Glib::RefPtr< 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.

Since glibmm 2.32:

Parameters:

  position | The position at which to insert the item.
  item | The MenuItem to insert.

void Gio::Menu::insert_section | ( | int | position,
|  | const Glib::ustring& | label,
|  | const Glib::RefPtr< 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.

Since glibmm 2.32:

Parameters:

  position | The position at which to insert the item.
  label | The section label, or `0`.
  section | A MenuModel with the items of the section.

void Gio::Menu::insert_submenu | ( | int | position,
|  | const Glib::ustring& | label,
|  | const Glib::RefPtr< 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.

Since glibmm 2.32:

Parameters:

  position | The position at which to insert the item.
  label | The section label, or `0`.
  submenu | A MenuModel with the items of the submenu.

void Gio::Menu::prepend | ( | const Glib::ustring& | label,
|  | const Glib::ustring& | detailed_action = `Glib::ustring()`
| ) |  |

Convenience function for prepending a normal menu item to the start of menu.

Combine g_menu_new() and g_menu_insert_item() for a more flexible alternative.

Since glibmm 2.32:

Parameters:

  label | The section label, or `0`.
  detailed_action | The detailed action string, or `0`.

void Gio::Menu::prepend_item | ( | const Glib::RefPtr< MenuItem >& | item | ) |

Prepends item to the start of menu.

See g_menu_insert_item() for more information.

Since glibmm 2.32:

Parameters:

  item | A MenuItem to prepend.

void Gio::Menu::prepend_section | ( | const Glib::ustring& | label,
|  | const Glib::RefPtr< 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.

Since glibmm 2.32:

Parameters:

  label | The section label, or `0`.
  section | A MenuModel with the items of the section.

void Gio::Menu::prepend_submenu | ( | const Glib::ustring& | label,
|  | const Glib::RefPtr< 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.

Since glibmm 2.32:

Parameters:

  label | The section label, or `0`.
  submenu | A MenuModel with the items of the submenu.

void Gio::Menu::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).

Since glibmm 2.32:

Parameters:

  position | The position of the item to remove.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::Menu > wrap | ( | GMenu * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.