summaryrefslogtreecommitdiff
path: root/gio/src/menu.hg
blob: 725f3eb940bc7802d94efcc18e8be7492e4f46d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* Copyright (C) 2012 The giomm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <giomm/menumodel.h>
#include <giomm/menuitem.h>

_DEFS(giomm,gio)
_PINCLUDE(giomm/private/menumodel_p.h)

namespace Gio
{

/** A simple implementation of MenuModel.
 * You populate a Menu by adding MenuItem instances to it.
 *
 * There are some convenience methods to allow you to directly
 * add items (avoiding MenuItem) for the common cases. To add
 * a regular item, use insert(). To add a section, use
 * insert_section(). To add a submenu, use
 * insert_submenu().
 *
 * @newin{2,32}
 */
class GIOMM_API Menu : public Gio::MenuModel
{
  _CLASS_GOBJECT(Menu, GMenu, G_MENU, ::Gio::MenuModel, GMenuModel, , , GIOMM_API)

protected:
  _CTOR_DEFAULT
  _IGNORE(g_menu_new)

public:
  _WRAP_CREATE()

  _WRAP_METHOD(void freeze(), g_menu_freeze)

  _WRAP_METHOD(void insert_item(int position, const Glib::RefPtr<const MenuItem>& item), g_menu_insert_item)
  _WRAP_METHOD(void prepend_item(const Glib::RefPtr<const MenuItem>& item), g_menu_prepend_item)
  _WRAP_METHOD(void append_item(const Glib::RefPtr<const MenuItem>& item), g_menu_append_item)
  _WRAP_METHOD(void remove(int position), g_menu_remove)
  _WRAP_METHOD(void remove_all(), g_menu_remove_all)

// The glib docs says that label can be null in all insert/prepend/append functions.
// But except in the xxx_section() functions, a null label results in a critical message,
// and does not seem useful. See https://bugzilla.gnome.org/show_bug.cgi?id=733203
//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
  _WRAP_METHOD(void insert(int position, const Glib::ustring& label, const Glib::ustring& detailed_action{?}), g_menu_insert)
  _WRAP_METHOD(void prepend(const Glib::ustring& label, const Glib::ustring& detailed_action{?}), g_menu_prepend)
  _WRAP_METHOD(void append(const Glib::ustring& label, const Glib::ustring& detailed_action{?}), g_menu_append)

// TODO: Should the MenuModel be const too?
  _WRAP_METHOD(void insert_section(int position, const Glib::ustring& label{?}, const Glib::RefPtr<MenuModel>& section), g_menu_insert_section)
  _WRAP_METHOD(void prepend_section(const Glib::ustring& label{?}, const Glib::RefPtr<MenuModel>& section), g_menu_prepend_section)
  _WRAP_METHOD(void append_section(const Glib::ustring& label{?}, const Glib::RefPtr<MenuModel>& section), g_menu_append_section)

  _WRAP_METHOD(void insert_submenu(int position, const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu), g_menu_insert_submenu)
  _WRAP_METHOD(void prepend_submenu(const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu), g_menu_prepend_submenu)
  _WRAP_METHOD(void append_submenu(const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu), g_menu_append_submenu)

};

} // namespace Gio