[gtkmm] Add and use WidgetPath.



commit 63240babd82896bf77fb4ceed6eda254bac1fe77
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Dec 6 13:02:54 2010 +0100

    Add and use WidgetPath.
    
    * gtk/gtkmm.h:
    * gtk/src/filelist.am:
    * gtk/src/widgetpath.[hg|ccg]: Added WidgetPath, though not all methods are
    wrapped yet.
    * gtk/src/widget.[hg|ccg]: replace path() with get_path(), which uses
    WidgetPath.
    * tools/m4/convert_gtk.m4: Added necessary conversion.

 ChangeLog               |   12 ++++++++
 gtk/gtkmm.h             |    1 +
 gtk/src/filelist.am     |    1 +
 gtk/src/widget.ccg      |   32 +--------------------
 gtk/src/widget.hg       |   14 +++------
 gtk/src/widgetpath.ccg  |   25 ++++++++++++++++
 gtk/src/widgetpath.hg   |   73 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/m4/convert_gtk.m4 |    3 +-
 8 files changed, 120 insertions(+), 41 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d1fa8cb..45bda14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2010-12-06  Murray Cumming  <murrayc murrayc com>
 
+	Add and use WidgetPath.
+
+	* gtk/gtkmm.h:
+	* gtk/src/filelist.am:
+	* gtk/src/widgetpath.[hg|ccg]: Added WidgetPath, though not all methods are 
+	wrapped yet.
+	* gtk/src/widget.[hg|ccg]: replace path() with get_path(), which uses 
+	WidgetPath.
+	* tools/m4/convert_gtk.m4: Added necessary conversion.
+
+2010-12-06  Murray Cumming  <murrayc murrayc com>
+
 	Improved StyleContext. Removed Style and RcStyle classes.
 
 	* gtk/src/rc.[hg|ccg]
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index e389d70..3ea518a 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -247,6 +247,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/uimanager.h>
 #include <gtkmm/viewport.h>
 #include <gtkmm/widget.h>
+#include <gtkmm/widgetpath.h>
 #include <gtkmm/window.h>
 
 #endif /* #ifndef GTKMM_H */
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 4e7338d..569a938 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -180,6 +180,7 @@ gtkmm_files_any_hg =		\
 	viewport.hg		\
 	volumebutton.hg		\
 	widget.hg		\
+	widgetpath.hg		\
 	window.hg
 
 gtkmm_files_posix_hg =		\
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index bf19f94..7b5368b 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -197,31 +197,7 @@ void Widget::remove_modal_grab()
 Widget* Widget::get_current_modal_grab()
 {
   return Glib::wrap(gtk_grab_get_current());
-}
-
-void Widget::path(Glib::ustring& path_arg, Glib::ustring& path_reversed)
-{
-  guint path_length = 0;
-  Glib::ScopedPtr<gchar> path_ptr;
-  Glib::ScopedPtr<gchar> rpath_ptr;
-
-  gtk_widget_path(gobj(), &path_length, path_ptr.addr(), rpath_ptr.addr());
-
-  path_arg.assign(path_ptr.get(), path_ptr.get() + path_length);
-  path_reversed.assign(rpath_ptr.get(), rpath_ptr.get() + path_length);
-}
-
-void Widget::class_path(Glib::ustring& path_arg, Glib::ustring& path_reversed)
-{
-  guint path_length = 0;
-  Glib::ScopedPtr<gchar> path_ptr;
-  Glib::ScopedPtr<gchar> rpath_ptr;
-
-  gtk_widget_class_path(gobj(), &path_length, path_ptr.addr(), rpath_ptr.addr());
-
-  path_arg.assign(path_ptr.get(), path_ptr.get() + path_length);
-  path_reversed.assign(rpath_ptr.get(), rpath_ptr.get() + path_length);
-}
+} 
 
 Allocation Widget::get_allocation() const
 {
@@ -423,12 +399,6 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
   #endif
 }
 
-
-void Widget::unset_style()
-{
-  gtk_widget_set_style(gobj(), 0 /* See GTK+ docs */);
-}
-
 Glib::ustring Widget::drag_dest_find_target(const Glib::RefPtr<Gdk::DragContext>& context) const
 {
   return Gdk::AtomString::to_cpp_type(gtk_drag_dest_find_target(const_cast<GtkWidget*>(gobj()), Glib::unwrap(context), 0 /* See GTK+ docs */));
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 22d65f3..e295a72 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -41,6 +41,7 @@ _CONFIGINCLUDE(gtkmmconfig.h)
 #include <gtkmm/rc.h>
 #include <gtkmm/clipboard.h>
 #include <gtkmm/requisition.h>
+#include <gtkmm/widgetpath.h>
 
 _DEFS(gtkmm,gtk)
 _PINCLUDE(gtkmm/private/object_p.h)
@@ -347,7 +348,8 @@ public:
 					       int& dest_x, int& dest_y), gtk_widget_translate_coordinates)
 
   _IGNORE(gtk_widget_set_style, gtk_widget_get_style, gtk_widget_has_rc_style, gtk_widget_ensure_style,
-    gtk_widget_modify_style, gtk_widget_get_modifier_style, gtk_widget_get_default_style) //deprecated broadly in favour of StyleContext.;
+    gtk_widget_modify_style, gtk_widget_get_modifier_style, gtk_widget_get_default_style,
+    gtk_widget_reset_rc_styles) //deprecated broadly in favour of StyleContext.;
 
 
 //TODO: Add unset_*() methods?
@@ -374,9 +376,6 @@ public:
   void unset_composite_name();
   _WRAP_METHOD(Glib::ustring get_composite_name() const, gtk_widget_get_composite_name)
 
-  _WRAP_METHOD(void reset_rc_styles(),gtk_widget_reset_rc_styles)
-
-
   _WRAP_METHOD(static void push_composite_child(), gtk_widget_push_composite_child)
   _WRAP_METHOD(static void pop_composite_child(), gtk_widget_pop_composite_child)
 
@@ -398,11 +397,8 @@ public:
   // must be realized
   _WRAP_METHOD(void reset_shapes(),gtk_widget_reset_shapes)
 
-/* Paths */
-  /// Compute a widget's path of the form "GtkWindow.MyLabel"
-  void path(Glib::ustring& path, Glib::ustring& path_reversed);
-  void class_path(Glib::ustring& path, Glib::ustring& path_reversed);
-  _IGNORE(gtk_widget_path, gtk_widget_class_path)
+  _WRAP_METHOD(WidgetPath get_path() const, gtk_widget_get_path)
+  _IGNORE(gtk_widget_path, gtk_widget_class_path) //deprecated
 
  _WRAP_METHOD(Glib::ListHandle<Widget*> list_mnemonic_labels(), gtk_widget_list_mnemonic_labels)
  _WRAP_METHOD(Glib::ListHandle<const Widget*> list_mnemonic_labels() const, gtk_widget_list_mnemonic_labels)
diff --git a/gtk/src/widgetpath.ccg b/gtk/src/widgetpath.ccg
new file mode 100644
index 0000000..ead3aaa
--- /dev/null
+++ b/gtk/src/widgetpath.ccg
@@ -0,0 +1,25 @@
+/* Copyright 2010 The gtkmm 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 <gtk/gtk.h>
+
+namespace Gtk
+{
+
+} /* namespace Gtk */
+
+
diff --git a/gtk/src/widgetpath.hg b/gtk/src/widgetpath.hg
new file mode 100644
index 0000000..690594b
--- /dev/null
+++ b/gtk/src/widgetpath.hg
@@ -0,0 +1,73 @@
+/* Copyright 2010 The gtkmm 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 <gtkmm/enums.h>
+
+_DEFS(gtkmm,gtk)
+
+namespace Gtk
+{
+
+/** TODO
+ *
+ * @newin{3,0}
+ */
+class WidgetPath
+{
+  _CLASS_BOXEDTYPE(WidgetPath, GtkWidgetPath, gtk_widget_path_new, gtk_widget_path_copy, gtk_widget_path_free)
+  _IGNORE(gtk_widget_path_new, gtk_widget_path_copy, gtk_widget_path_free)
+public:
+
+  _WRAP_METHOD(int path_length() const, gtk_widget_path_length)
+
+  _WRAP_METHOD(int path_append_type(GType type), gtk_widget_path_append_type)
+  _WRAP_METHOD(void prepend_type(GType type), gtk_widget_path_prepend_type)
+
+  _WRAP_METHOD(GType get_widget_type(int pos) const, gtk_widget_path_iter_get_widget_type)
+  _WRAP_METHOD(void set_widget_type(int pos, GType type), gtk_widget_path_iter_set_widget_type)
+
+  _WRAP_METHOD(Glib::ustring iter_get_name(int pos) const, gtk_widget_path_iter_get_name)
+  _WRAP_METHOD(void iter_set_name(int pos, const Glib::ustring& name), gtk_widget_path_iter_set_name)
+  _WRAP_METHOD(bool iter_has_name(int pos, const Glib::ustring& name) const, gtk_widget_path_iter_has_name)
+  //TODO: _WRAP_METHOD(bool iter_has_qname(int pos, GQuark qname) const, gtk_widget_path_iter_has_qname)
+
+  _WRAP_METHOD(void iter_add_class(int pos, const Glib::ustring& name), gtk_widget_path_iter_add_class)
+  _WRAP_METHOD(void iter_remove_class(int pos, const Glib::ustring& name), gtk_widget_path_iter_remove_class)
+  _WRAP_METHOD(void iter_clear_classes(int pos), gtk_widget_path_iter_clear_classes)
+  //TODO: _WRAP_METHOD(GSList * gtk_widget_path_iter_list_classes(const GtkWidgetPath *path, int pos), gtk_widget_path_iter_list_classes)
+  _WRAP_METHOD(bool iter_has_class(int pos, const Glib::ustring& name) const, gtk_widget_path_iter_has_class)
+  //TODOL_WRAP_METHOD(bool iter_has_qclass(int pos, GQuark qname) const, gtk_widget_path_iter_has_qclass)
+
+  _WRAP_METHOD(void iter_add_region(int  pos, const Glib::ustring& name,  RegionFlags flags), gtk_widget_path_iter_add_region)
+  _WRAP_METHOD(void iter_remove_region(int pos, const Glib::ustring& name), gtk_widget_path_iter_remove_region)
+  _WRAP_METHOD(void iter_clear_regions(int pos), gtk_widget_path_iter_clear_regions)
+
+  //TODO: _WRAP_METHOD(GSList* iter_list_regions(int pos), gtk_widget_path_iter_list_regions)
+
+  _WRAP_METHOD(bool iter_has_region(int pos, const Glib::ustring& name, RegionFlags& flags) const, gtk_widget_path_iter_has_region)
+  //TODO: _WRAP_METHOD(bool iter_has_qregion(int pos, GQuark qname,  RegionFlags& flags), gtk_widget_path_iter_has_qregion)
+
+  _WRAP_METHOD(GType get_widget_type() const,  gtk_widget_path_get_widget_type)
+
+  _WRAP_METHOD(bool is_type(GType type) const, gtk_widget_path_is_type)
+  _WRAP_METHOD(bool has_parent(GType type) const, gtk_widget_path_has_parent)
+
+};
+
+} /* namespace Gtk */
+
+
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index 8536275..aeb2d98 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -665,5 +665,6 @@ _CONVERSION(`const Glib::RefPtr<Gio::Cancellable>&',`GCancellable*',__CONVERT_CO
 _CONVERSION(`const Glib::RefPtr<Gio::InputStream>&',`GInputStream*',__CONVERT_CONST_REFPTR_TO_P)
 
 
-
 _CONVERSION(`GtkDragResult',`DragResult',`($2)$3')
+
+_CONVERSION(`GtkWidgetPath*',`WidgetPath',`Glib::wrap($3, true)')



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