1/* Copyright (C) 2012 The giomm Development Team 2 * 3 * This library is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU Lesser General Public 5 * License as published by the Free Software Foundation; either 6 * version 2.1 of the License, or (at your option) any later version. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public 14 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17#include <giomm/menumodel.h> 18#include <giomm/menuitem.h> 19 20_DEFS(giomm,gio) 21_PINCLUDE(giomm/private/menumodel_p.h) 22 23namespace Gio 24{ 25 26/** A simple implementation of MenuModel. 27 * You populate a Menu by adding MenuItem instances to it. 28 * 29 * There are some convenience methods to allow you to directly 30 * add items (avoiding MenuItem) for the common cases. To add 31 * a regular item, use insert(). To add a section, use 32 * insert_section(). To add a submenu, use 33 * insert_submenu(). 34 * 35 * @newin{2,32} 36 */ 37class GIOMM_API Menu : public Gio::MenuModel 38{ 39 _CLASS_GOBJECT(Menu, GMenu, G_MENU, ::Gio::MenuModel, GMenuModel, , , GIOMM_API) 40 41protected: 42 _CTOR_DEFAULT 43 _IGNORE(g_menu_new) 44 45public: 46 _WRAP_CREATE() 47 48 _WRAP_METHOD(void freeze(), g_menu_freeze) 49 50 //TODO: Make the item "const Glib::RefPtr<const MenuItem>&" when we can break ABI? The function is documented as just copying its attributes. 51 _WRAP_METHOD(void insert_item(int position, const Glib::RefPtr<MenuItem>& item), g_menu_insert_item) 52 _WRAP_METHOD(void prepend_item(const Glib::RefPtr<MenuItem>& item), g_menu_prepend_item) 53 _WRAP_METHOD(void append_item(const Glib::RefPtr<MenuItem>& item), g_menu_append_item) 54 _WRAP_METHOD(void remove(int position), g_menu_remove) 55 _WRAP_METHOD(void remove_all(), g_menu_remove_all) 56 57// The glib docs says that label can be null in all insert/prepend/append functions. 58// But except in the xxx_section() functions, a null label results in a critical message, 59// and does not seem useful. See https://bugzilla.gnome.org/show_bug.cgi?id=733203 60//We don't return the MenuItem* because the C API can't give us something modifiable: See https://bugzilla.gnome.org/show_bug.cgi?id=708906 61 _WRAP_METHOD(void insert(int position, const Glib::ustring& label, const Glib::ustring& detailed_action{?}), g_menu_insert) 62 _WRAP_METHOD(void prepend(const Glib::ustring& label, const Glib::ustring& detailed_action{?}), g_menu_prepend) 63 _WRAP_METHOD(void append(const Glib::ustring& label, const Glib::ustring& detailed_action{?}), g_menu_append) 64 65 _WRAP_METHOD(void insert_section(int position, const Glib::ustring& label{?}, const Glib::RefPtr<MenuModel>& section), g_menu_insert_section) 66 _WRAP_METHOD(void prepend_section(const Glib::ustring& label{?}, const Glib::RefPtr<MenuModel>& section), g_menu_prepend_section) 67 _WRAP_METHOD(void append_section(const Glib::ustring& label{?}, const Glib::RefPtr<MenuModel>& section), g_menu_append_section) 68 69 _WRAP_METHOD(void insert_submenu(int position, const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu), g_menu_insert_submenu) 70 _WRAP_METHOD(void prepend_submenu(const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu), g_menu_prepend_submenu) 71 _WRAP_METHOD(void append_submenu(const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu), g_menu_append_submenu) 72 73}; 74 75} // namespace Gio 76