[glibmm] Gio: Add Menu and MenuItem.



commit a22076a82e4ac83fc3db28e4bdb761288966e4c7
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Mar 22 20:42:52 2012 +0100

    Gio: Add Menu and MenuItem.
    
    * tools/extra_defs_gen/generate_defs_gio.cc: Mention the new GTypes here,
    though they do not seem to have any properties or signals.
    
    * gio/src/filelist.am:
    * gio/src/menu.[hg|ccg]:
    * gio/src/menuitem.[hg|ccg]: Add these classes, as a way to create
    the Gio::MenuModel for Gtk::Application::set_app_menu() and set_menubar().
    * tools/m4/convert_gio.m4: Add MenuItem conversion.
    * gio/giomm.h: Mention the new headers here.

 ChangeLog                                 |   14 ++++++
 gio/giomm.h                               |    4 ++
 gio/src/application.hg                    |    4 +-
 gio/src/filelist.am                       |    2 +
 gio/src/menu.ccg                          |   23 +++++++++++
 gio/src/menu.hg                           |   62 +++++++++++++++++++++++++++++
 gio/src/menuitem.ccg                      |   23 +++++++++++
 gio/src/menuitem.hg                       |   62 +++++++++++++++++++++++++++++
 tools/extra_defs_gen/generate_defs_gio.cc |    3 +
 tools/m4/convert_gio.m4                   |    4 ++
 10 files changed, 199 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b4b2271..c853bb0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-03-22  Murray Cumming  <murrayc murrayc com>
+
+	Gio: Add Menu and MenuItem.
+
+	* tools/extra_defs_gen/generate_defs_gio.cc: Mention the new GTypes here,
+	though they do not seem to have any properties or signals.
+
+	* gio/src/filelist.am:
+	* gio/src/menu.[hg|ccg]:
+	* gio/src/menuitem.[hg|ccg]: Add these classes, as a way to create
+	the Gio::MenuModel for Gtk::Application::set_app_menu() and set_menubar().
+	* tools/m4/convert_gio.m4: Add MenuItem conversion.
+	* gio/giomm.h: Mention the new headers here.
+
 2012-03-22  Kjell Ahlstedt  <kjell ahlstedt bredband net>
 
 	Dispatcher examples: Use Glib::signal_idle().connect_once().
diff --git a/gio/giomm.h b/gio/giomm.h
index 207d43f..a98f33a 100644
--- a/gio/giomm.h
+++ b/gio/giomm.h
@@ -40,6 +40,7 @@
 #include <giomm/dbuserror.h>
 #include <giomm/dbuserrorutils.h>
 #include <giomm/dbusintrospection.h>
+#include <giomm/dbusmenumodel.h>
 #include <giomm/dbusmessage.h>
 #include <giomm/dbusmethodinvocation.h>
 #include <giomm/dbusownname.h>
@@ -76,6 +77,9 @@
 #include <giomm/inputstream.h>
 #include <giomm/iostream.h>
 #include <giomm/loadableicon.h>
+#include <giomm/menu.h>
+#include <giomm/menuitem.h>
+#include <giomm/menumodel.h>
 #include <giomm/memoryinputstream.h>
 #include <giomm/memoryoutputstream.h>
 #include <giomm/mount.h>
diff --git a/gio/src/application.hg b/gio/src/application.hg
index 13643f0..edaf38f 100644
--- a/gio/src/application.hg
+++ b/gio/src/application.hg
@@ -90,11 +90,11 @@ class Application : public Glib::Object, public ActionGroup, public ActionMap
   _IMPLEMENTS_INTERFACE(ActionMap)
 
 protected:
-  explicit Application(const Glib::ustring& application_id, ApplicationFlags flags=APPLICATION_FLAGS_NONE);
+  explicit Application(const Glib::ustring& application_id, ApplicationFlags flags = APPLICATION_FLAGS_NONE);
   _IGNORE(g_application_new)
 
 public:
-  _WRAP_CREATE(const Glib::ustring& application_id, ApplicationFlags flags=APPLICATION_FLAGS_NONE)
+  _WRAP_CREATE(const Glib::ustring& application_id, ApplicationFlags flags = APPLICATION_FLAGS_NONE)
 
   _WRAP_METHOD(static bool id_is_valid(const Glib::ustring& application_id), g_application_id_is_valid)
 
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 95c1ebe..ee2334a 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -75,6 +75,8 @@ giomm_files_any_hg =			\
 	memoryoutputstream.hg		\
 	menuattributeiter.hg		\
 	menulinkiter.hg			\
+	menu.hg \
+	menuitem.hg \
 	menumodel.hg			\
 	mount.hg			\
 	mountoperation.hg		\
diff --git a/gio/src/menu.ccg b/gio/src/menu.ccg
new file mode 100644
index 0000000..969d51e
--- /dev/null
+++ b/gio/src/menu.ccg
@@ -0,0 +1,23 @@
+/* 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+
+namespace Gio
+{
+
+} // namespace Gio
diff --git a/gio/src/menu.hg b/gio/src/menu.hg
new file mode 100644
index 0000000..c3ebb12
--- /dev/null
+++ b/gio/src/menu.hg
@@ -0,0 +1,62 @@
+/* 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <giomm/menumodel.h>
+#include <giomm/menuitem.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(giomm/private/menumodel_p.h)
+
+namespace Gio
+{
+
+/** TODO
+ *
+ * @newin{2,32}
+ */
+class Menu : public Gio::MenuModel
+{
+  _CLASS_GOBJECT(Menu, GMenu, G_MENU, ::Gio::MenuModel, GMenuModel)
+
+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<MenuItem>& item), g_menu_insert_item)
+  _WRAP_METHOD(void prepend_item(const Glib::RefPtr<MenuItem>& item), g_menu_prepend_item)
+  _WRAP_METHOD(void append_item(const Glib::RefPtr<MenuItem>& item), g_menu_append_item)
+  _WRAP_METHOD(void remove(int position), g_menu_remove)
+
+  _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)
+
+  _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 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
diff --git a/gio/src/menuitem.ccg b/gio/src/menuitem.ccg
new file mode 100644
index 0000000..969d51e
--- /dev/null
+++ b/gio/src/menuitem.ccg
@@ -0,0 +1,23 @@
+/* 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+
+namespace Gio
+{
+
+} // namespace Gio
diff --git a/gio/src/menuitem.hg b/gio/src/menuitem.hg
new file mode 100644
index 0000000..f8b240c
--- /dev/null
+++ b/gio/src/menuitem.hg
@@ -0,0 +1,62 @@
+/* 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/object.h>
+#include <giomm/menumodel.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+/** TODO
+ *
+ * @newin{2,32}
+ */
+class MenuItem : public Glib::Object
+{
+  _CLASS_GOBJECT(MenuItem, GMenuItem, G_MENU_ITEM, Glib::Object, GObject)
+
+protected:
+  _WRAP_CTOR(MenuItem(const Glib::ustring& label, const Glib::ustring& detailed_action), g_menu_item_new)
+
+  _WRAP_CTOR(MenuItem(const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu), g_menu_item_new_submenu)
+
+public:
+  _WRAP_CREATE(const Glib::ustring& label, const Glib::ustring& detailed_action)
+
+  _WRAP_CREATE(const Glib::ustring& label, const Glib::RefPtr<MenuModel>& submenu)
+
+            
+
+//TODO: GMenuItem * g_menu_item_new_section                 (const Glib::ustring& label,
+//                                                     const Glib::RefPtr<MenuModel>& section);
+
+  _WRAP_METHOD(void set_attribute_value(const Glib::ustring& attribute, const Glib::VariantBase& value), g_menu_item_set_attribute_value)
+  _IGNORE(g_menu_item_set_attribute)
+
+  _WRAP_METHOD(void set_link(const Glib::ustring& link, const Glib::RefPtr<MenuModel>& model), g_menu_item_set_link)
+  _WRAP_METHOD(void set_label(const Glib::ustring& label), g_menu_item_set_label)
+  _WRAP_METHOD(void set_submenu(const Glib::RefPtr<MenuModel>& submenu), g_menu_item_set_submenu)
+  _WRAP_METHOD(void set_section(const Glib::RefPtr<MenuModel>& section), g_menu_item_set_section)
+  _WRAP_METHOD(void set_action_and_target_value(const Glib::ustring& action, const Glib::VariantBase& target_value), g_menu_item_set_action_and_target_value)
+  _IGNORE(g_menu_item_set_action_and_target)
+  _WRAP_METHOD(void set_detailed_action(const Glib::ustring& detailed_action), g_menu_item_set_detailed_action)
+};
+
+} // namespace Gio
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index ad5aa04..aaf251e 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -72,6 +72,8 @@ int main(int, char**)
             << get_defs(G_TYPE_LOADABLE_ICON)
             << get_defs(G_TYPE_MEMORY_INPUT_STREAM)
             << get_defs(G_TYPE_MEMORY_OUTPUT_STREAM)
+            << get_defs(G_TYPE_MENU)
+            << get_defs(G_TYPE_MENU_MODEL)
             << get_defs(G_TYPE_MOUNT)
             << get_defs(G_TYPE_MOUNT_OPERATION)
             << get_defs(G_TYPE_PROXY)
@@ -119,6 +121,7 @@ int main(int, char**)
             << get_defs(G_TYPE_DBUS_ERROR)
             << get_defs(G_TYPE_DBUS_ANNOTATION_INFO)
             << get_defs(G_TYPE_DBUS_ARG_INFO)
+            << get_defs(G_TYPE_DBUS_MENU_MODEL)
             << get_defs(G_TYPE_DBUS_METHOD_INFO)
             << get_defs(G_TYPE_DBUS_SIGNAL_INFO)
             << get_defs(G_TYPE_DBUS_PROPERTY_INFO)
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 5cd6d26..96604f9 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -191,6 +191,10 @@ _CONVERSION(`GMenuLinkIter*',`Glib::RefPtr<MenuLinkIter>',`Glib::wrap($3)')
 _CONVERSION(`GMenuModel*',`Glib::RefPtr<MenuModel>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<MenuModel>&',`GMenuModel*',__CONVERT_CONST_REFPTR_TO_P)
 
+# MenuItem
+_CONVERSION(`GMenuItem*',`Glib::RefPtr<MenuItem>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<MenuItem>&',`GMenuItem*',__CONVERT_CONST_REFPTR_TO_P)
+
 # Mount
 _CONVERSION(`GMount*',`Glib::RefPtr<Mount>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<Mount>&',`GMount*',__CONVERT_CONST_REFPTR_TO_P)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]