[gtkmm] Builder: Add const versions of get_object() and get_widget[_derived]().



commit cca07a9b3a0490a333308a15183110018b46d528
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Mon Dec 3 12:43:03 2012 +0100

    Builder: Add const versions of get_object() and get_widget[_derived]().
    
    * gtk/src/builder.hg: Add const versions of get_object(), get_widget()
    and get_widget_derived(). Bug #666823.

 ChangeLog          |    7 +++++++
 gtk/src/builder.hg |   30 ++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0504579..1ae48d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-12-03  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Builder: Add const versions of get_object() and get_widget[_derived]().
+
+	* gtk/src/builder.hg: Add const versions of get_object(), get_widget()
+	and get_widget_derived(). Bug #666823.
+
 2012-12-03   Hub FiguiÃre  <hub figuiere net>
 
 	Gtk::Builder: Add get_objects().
diff --git a/gtk/src/builder.hg b/gtk/src/builder.hg
index dc1fae2..7d6edfc 100644
--- a/gtk/src/builder.hg
+++ b/gtk/src/builder.hg
@@ -384,7 +384,20 @@ public:
 
   //TODO: Custom-implement this and prevent it from being used with GTK_WIDGET-derived types?
   //TODO: Make this return a Glib::RefPtr<Gtk::Buildable>? Check what the C API really does - and document that if so.
+  /** Gets the object named @a name.
+   * 
+   * @newin{2,12}
+   * @param name Name of object to get.
+   * @return The object named @a name or <tt>0</tt> if it could not be found in the object tree.
+   */
   _WRAP_METHOD(Glib::RefPtr<Glib::Object> get_object(const Glib::ustring& name), gtk_builder_get_object, refreturn)
+  /** Gets the object named @a name.
+   * 
+   * @newin{3,8}
+   * @param name Name of object to get.
+   * @return The object named @a name or <tt>0</tt> if it could not be found in the object tree.
+   */
+  _WRAP_METHOD(Glib::RefPtr<const Glib::Object> get_object(const Glib::ustring& name) const, gtk_builder_get_object, refreturn, constversion)
 
   /** Get a widget from the Builder file.
    * For instance:
@@ -417,6 +430,15 @@ public:
       g_critical("Gtk::Builder::get_widget(): dynamic_cast<> failed.");
   }
 
+  /** See the non-const version.
+   * @newin{3,8}
+   */
+  template <class T_Widget> inline
+  void get_widget(const Glib::ustring& name, const T_Widget*& widget) const
+  {
+    const_cast<Builder*>(this)->get_widget(name, widget);
+  }
+
   /** This provides a pointer to a widget whose details are specified in the GtkBuilder file, but which is implemented
    * by your own derived class. Your class must have a constructor like so:
    * @code
@@ -474,6 +496,14 @@ public:
      }
   }
 
+  /** See the non-const version.
+   * @newin{3,8}
+   */
+  template <class T_Widget> inline
+  void get_widget_derived(const Glib::ustring& name, const T_Widget*& widget) const
+  {
+    const_cast<Builder*>(this)->get_widget_derived(name, widget);
+  }
 
 #m4 _CONVERSION(`GSList*',`std::vector<Glib::RefPtr<Glib::Object> >',`Glib::SListHandler<Glib::RefPtr<Glib::Object> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
   _WRAP_METHOD(std::vector<Glib::RefPtr<Glib::Object> > get_objects(), gtk_builder_get_objects)



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