[glibmm] giomm: Add the MenuModel and Menu[Attribute|Link]Iter classes.



commit 40e6a8e55e6558d44fa601b1549e2788fa15dd76
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date:   Wed Feb 22 16:44:33 2012 -0500

    giomm: Add the MenuModel and Menu[Attribute|Link]Iter classes.
    
    	* gio/src/menuattributeiter.{ccg,hg}:
    	* gio/src/menulinkiter.{ccg,hg}:
    	* gio/src/menumodel.{ccg,hg}:
    	* gio/src/filelist.am: Add the sources for the classes and include
    	them in the list of source files to build.
    	* tools/m4/convert_gio.m4:
    	* tools/m4/convert_glib.m4: Add the necessary conversions.

 ChangeLog                     |   12 +++++++++
 gio/src/filelist.am           |    3 ++
 gio/src/menuattributeiter.ccg |   38 +++++++++++++++++++++++++++
 gio/src/menuattributeiter.hg  |   47 ++++++++++++++++++++++++++++++++++
 gio/src/menulinkiter.ccg      |   37 +++++++++++++++++++++++++++
 gio/src/menulinkiter.hg       |   49 +++++++++++++++++++++++++++++++++++
 gio/src/menumodel.ccg         |   25 ++++++++++++++++++
 gio/src/menumodel.hg          |   56 +++++++++++++++++++++++++++++++++++++++++
 tools/m4/convert_gio.m4       |    9 ++++++
 tools/m4/convert_glib.m4      |    1 +
 10 files changed, 277 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bcfbf65..e2c149f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2012-02-22  Josà Alburquerque  <jaalburquerque gmail com>
 
+	giomm: Add the MenuModel and Menu[Attribute|Link]Iter classes.
+
+	* gio/src/menuattributeiter.{ccg,hg}:
+	* gio/src/menulinkiter.{ccg,hg}:
+	* gio/src/menumodel.{ccg,hg}:
+	* gio/src/filelist.am: Add the sources for the classes and include
+	them in the list of source files to build.
+	* tools/m4/convert_gio.m4:
+	* tools/m4/convert_glib.m4: Add the necessary conversions.
+
+2012-02-22  Josà Alburquerque  <jaalburquerque gmail com>
+
 	Gio::Application: Derive from the ActionGroup interface.
 
 	* gio/src/application.hg: As is done in the C API.
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 5d94eb1..c98b331 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -70,6 +70,9 @@ giomm_files_any_hg =			\
 	loadableicon.hg			\
 	memoryinputstream.hg		\
 	memoryoutputstream.hg		\
+	menuattributeiter.hg		\
+	menulinkiter.hg		\
+	menumodel.hg		\
 	mount.hg			\
 	mountoperation.hg		\
 	networkaddress.hg		\
diff --git a/gio/src/menuattributeiter.ccg b/gio/src/menuattributeiter.ccg
new file mode 100644
index 0000000..a6f9f68
--- /dev/null
+++ b/gio/src/menuattributeiter.ccg
@@ -0,0 +1,38 @@
+/* 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
+{
+
+bool MenuAttributeIter::get_next(Glib::ustring& out_name,
+  Glib::VariantBase& value)
+{
+  const char* g_out_name = 0;
+  GVariant* g_value = 0;
+
+  bool const result = g_menu_attribute_iter_get_next(gobj(), &g_out_name,
+    &g_value);
+
+  out_name = g_out_name;
+  value.init(g_value);
+
+  return result;
+}
+
+} // namespace Gio
diff --git a/gio/src/menuattributeiter.hg b/gio/src/menuattributeiter.hg
new file mode 100644
index 0000000..8ce070d
--- /dev/null
+++ b/gio/src/menuattributeiter.hg
@@ -0,0 +1,47 @@
+/* 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>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+/** TODO (When the docs is available from the C API).
+ */
+class MenuAttributeIter : public Glib::Object
+{
+  _CLASS_GOBJECT(MenuAttributeIter, GMenuAttributeIter, G_MENU_ATTRIBUTE_ITER, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT
+
+public:
+  _WRAP_METHOD_DOCS_ONLY(get_next g_menu_attribute_iter_get_next)
+  bool get_next(Glib::ustring& out_name, Glib::VariantBase& value);
+
+  _WRAP_METHOD(Glib::ustring get_name() const, g_menu_attribute_iter_get_name)
+
+  _WRAP_METHOD(Glib::VariantBase get_value(), g_menu_attribute_iter_get_value)
+  _WRAP_METHOD(const Glib::VariantBase get_value() const, g_menu_attribute_iter_get_value, constversion)
+
+  _WRAP_METHOD(bool next(), g_menu_attribute_iter_next)
+};
+
+} // namespace Gio
diff --git a/gio/src/menulinkiter.ccg b/gio/src/menulinkiter.ccg
new file mode 100644
index 0000000..9fb93b5
--- /dev/null
+++ b/gio/src/menulinkiter.ccg
@@ -0,0 +1,37 @@
+/* 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>
+#include <giomm/menumodel.h>
+
+namespace Gio
+{
+
+bool MenuLinkIter::get_next(Glib::ustring& out_link,
+  Glib::RefPtr<MenuModel>& value)
+{
+  const char* g_out_link = 0;
+  GMenuModel* g_value = 0;
+
+  bool const result = g_menu_link_iter_get_next(gobj(), &g_out_link, &g_value);
+  out_link = g_out_link;
+  value = Glib::wrap(g_value);
+
+  return result;
+}
+
+} // namespace Gio
diff --git a/gio/src/menulinkiter.hg b/gio/src/menulinkiter.hg
new file mode 100644
index 0000000..d2b406a
--- /dev/null
+++ b/gio/src/menulinkiter.hg
@@ -0,0 +1,49 @@
+/* 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>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+class MenuModel;
+
+/** TODO (When the docs is available from the C API).
+ */
+class MenuLinkIter : public Glib::Object
+{
+  _CLASS_GOBJECT(MenuLinkIter, GMenuLinkIter, G_MENU_LINK_ITER, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT
+
+public:
+  _WRAP_METHOD(Glib::ustring get_name() const, g_menu_link_iter_get_name)
+
+  _WRAP_METHOD_DOCS_ONLY(g_menu_link_iter_get_next)
+  bool get_next(Glib::ustring& out_link, Glib::RefPtr<MenuModel>& value);
+
+  _WRAP_METHOD(Glib::RefPtr<MenuModel> get_value(), g_menu_link_iter_get_value)
+  _WRAP_METHOD(Glib::RefPtr<const MenuModel> get_value() const, g_menu_link_iter_get_value, constversion)
+
+  _WRAP_METHOD(bool next(), g_menu_link_iter_next)
+};
+
+} // namespace Gio
diff --git a/gio/src/menumodel.ccg b/gio/src/menumodel.ccg
new file mode 100644
index 0000000..b63ae10
--- /dev/null
+++ b/gio/src/menumodel.ccg
@@ -0,0 +1,25 @@
+/* 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>
+#include <giomm/menuattributeiter.h>
+#include <giomm/menulinkiter.h>
+
+namespace Gio
+{
+
+}// namespace Gio
diff --git a/gio/src/menumodel.hg b/gio/src/menumodel.hg
new file mode 100644
index 0000000..181fd25
--- /dev/null
+++ b/gio/src/menumodel.hg
@@ -0,0 +1,56 @@
+/* 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>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+class MenuAttributeIter;
+class MenuLinkIter;
+
+/** TODO (When the docs is available from the C API).
+ */
+class MenuModel : public Glib::Object
+{
+  _CLASS_GOBJECT(MenuModel, GMenuModel, G_MENU_MODEL, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT
+
+public:
+  _WRAP_METHOD(Glib::VariantBase get_item_attribute(int item_index, const Glib::ustring& attribute, const Glib::VariantType& expected_type), g_menu_model_get_item_attribute_value)
+  _WRAP_METHOD(const Glib::VariantBase get_item_attribute(int item_index, const Glib::ustring& attribute, const Glib::VariantType& expected_type) const, g_menu_model_get_item_attribute_value, constversion)
+
+  //TODO?: _WRAP_METHOD(bool get_item_attribute(int item_index, const Glib::ustring& attribute, const Glib::ustring& format_string, ...), g_menu_model_get_item_attribute)
+
+  _WRAP_METHOD(Glib::RefPtr<MenuModel> get_item_link(int item_index, const Glib::ustring& link), g_menu_model_get_item_link)
+  _WRAP_METHOD(Glib::RefPtr<const MenuModel> get_item_link(int item_index, const Glib::ustring& link) const, g_menu_model_get_item_link, constversion)
+
+  _WRAP_METHOD(Glib::RefPtr<MenuAttributeIter> iterate_item_attributes(int item_index), g_menu_model_iterate_item_attributes)
+  _WRAP_METHOD(Glib::RefPtr<const MenuAttributeIter> iterate_item_attributes(int item_index) const, g_menu_model_iterate_item_attributes, constversion)
+
+  _WRAP_METHOD(Glib::RefPtr<MenuLinkIter> iterate_item_links(int item_index), g_menu_model_iterate_item_links)
+  _WRAP_METHOD(Glib::RefPtr<const MenuLinkIter> iterate_item_links(int item_index) const, g_menu_model_iterate_item_links, constversion)
+
+  _WRAP_METHOD(void items_changed(int position, int removed, int added), g_menu_model_items_changed)
+};
+
+} // namespace Gio
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 18862c6..61fcdb3 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -166,6 +166,15 @@ _CONVERSION(`const Glib::RefPtr<InputStream>&',`GInputStream*',__CONVERT_CONST_R
 _CONVERSION(`const Glib::RefPtr<Gio::InputStream>&',`GInputStream*',__CONVERT_CONST_REFPTR_TO_P)
 _CONVERSION(`GInputStream*',`Glib::RefPtr<InputStream>',`Glib::wrap($3)')
 
+# MenuAttributeIter
+_CONVERSION(`GMenuAttributeIter*',`Glib::RefPtr<MenuAttributeIter>',`Glib::wrap($3)')
+
+# MenuLinkIter
+_CONVERSION(`GMenuLinkIter*',`Glib::RefPtr<MenuLinkIter>',`Glib::wrap($3)')
+
+# MenuModel
+_CONVERSION(`GMenuModel*',`Glib::RefPtr<MenuModel>',`Glib::wrap($3)')
+
 # Mount
 _CONVERSION(`GMount*',`Glib::RefPtr<Mount>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<Mount>&',`GMount*',__CONVERT_CONST_REFPTR_TO_P)
diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4
index f5a3bbe..55de647 100644
--- a/tools/m4/convert_glib.m4
+++ b/tools/m4/convert_glib.m4
@@ -143,6 +143,7 @@ _CONVERSION(`const GValue*', `const Glib::ValueBase&', `*reinterpret_cast<const
 
 dnl VariantType
 _CONVERSION(`const VariantType&',`const GVariantType*',`($3).gobj()')
+_CONVERSION(`const Glib::VariantType&',`const GVariantType*',`($3).gobj()')
 _CONVERSION(`const GVariantType*',`VariantType',`Glib::wrap(const_cast<GVariantType*>($3), true)')
 _CONVERSION(`GVariantType*',`VariantType',`Glib::wrap(($3), true)')
 



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