[gtkmm] Widget: Simplify the get_request_mode vfunc wrapping.



commit 3fadc846ec4fb1ce9736a96919a372380e006449
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jan 28 09:50:33 2011 +0100

    Widget: Simplify the get_request_mode vfunc wrapping.
    
    * gtk/src/widget.[hg|ccg]: Use a simple _WRAP_VFUNC() now that the C code
    behaves properly. See https://bugzilla.gnome.org/show_bug.cgi?id=639073#c17

 ChangeLog          |    7 +++++
 gtk/src/widget.ccg |   70 ----------------------------------------------------
 gtk/src/widget.hg  |   12 +--------
 3 files changed, 8 insertions(+), 81 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 970e9b5..924ad48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-01-28  Murray Cumming  <murrayc murrayc com>
 
+	Widget: Simplify the get_request_mode vfunc wrapping.
+
+	* gtk/src/widget.[hg|ccg]: Use a simple _WRAP_VFUNC() now that the C code 
+	behaves properly. See https://bugzilla.gnome.org/show_bug.cgi?id=639073#c17
+
+2011-01-28  Murray Cumming  <murrayc murrayc com>
+
 	Wrapped some new GTK+ functions, removing some too.
 
 	* gtk/src/gtk_methods.defs: Regenerated with h2defs.py.
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index eba7aa3..4527370 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -160,76 +160,6 @@ void Widget_Class::drag_data_get_callback(GtkWidget* self, GdkDragContext* p0, G
   }
 }
 
-// This callback is custom implemented, because the return value RType(),
-// generated by _WRAP_VFUNC may not be appropriate.
-GtkSizeRequestMode Widget_Class::get_request_mode_vfunc_callback(GtkWidget* self)
-{
-  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
-      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
-
-  // Non-gtkmmproc-generated custom classes implicitly call the default
-  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
-  // generated classes can use this optimisation, which avoids the unnecessary
-  // parameter conversions if there is no possibility of the virtual function
-  // being overridden:
-  if(obj_base && obj_base->is_derived_())
-  {
-    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
-    if(obj) // This can be NULL during destruction.
-    {
-      #ifdef GLIBMM_EXCEPTIONS_ENABLED
-      try // Trap C++ exceptions which would normally be lost because this is a C callback.
-      {
-      #endif //GLIBMM_EXCEPTIONS_ENABLED
-        // Call the virtual member method, which derived classes might override.
-        return ((GtkSizeRequestMode)(obj->get_request_mode_vfunc()));
-      #ifdef GLIBMM_EXCEPTIONS_ENABLED
-      }
-      catch(...)
-      {
-        Glib::exception_handlers_invoke();
-      }
-      #endif //GLIBMM_EXCEPTIONS_ENABLED
-    }
-  }
-  
-  BaseClassType *const base = static_cast<BaseClassType*>(
-      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
-  );
-
-  // Call the original underlying C function:
-  if(base && base->get_request_mode)
-    return (*base->get_request_mode)(self);
-
-  // By default widgets are height-for-width.
-  // This is the default value of gtk_widget_get_request_mode().
-  return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
-  // Don't assume that the following code returns the same value. (It might,
-  // but it's unwise to depend on it.)
-  // typedef GtkSizeRequestMode RType;
-  // return RType();
-}
-
-// This vfunc is custom implemented, because the return value RType(),
-// generated by _WRAP_VFUNC may not be appropriate.
-SizeRequestMode Gtk::Widget::get_request_mode_vfunc() const
-{
-  BaseClassType *const base = static_cast<BaseClassType*>(
-      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
-  );
-
-  if(base && base->get_request_mode)
-    return ((SizeRequestMode)((*base->get_request_mode)(const_cast<GtkWidget*>(gobj()))));
-
-  // By default widgets are height-for-width.
-  // This is the default value of gtk_widget_get_request_mode().
-  return SIZE_REQUEST_HEIGHT_FOR_WIDTH;
-  // Don't assume that the following code returns the same value. (It might,
-  // but it's unwise to depend on it.)
-  // typedef SizeRequestMode RType;
-  // return RType();
-}
-
 Widget::~Widget()
 {}
 
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 0debddb..ea9829e 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -812,17 +812,7 @@ protected:
   _WRAP_VFUNC(void show_all(), "show_all")
   _WRAP_VFUNC(Glib::RefPtr<Atk::Object> get_accessible(), "get_accessible", refreturn, ifdef GTKMM_ATKMM_ENABLED)
 
-  virtual SizeRequestMode get_request_mode_vfunc() const;
-#m4begin
-dnl // _WRAP_VFUNC(SizeRequestMode get_request_mode() const, get_request_mode)
-dnl // Custom implementation because the default return value RType() may not be appropriate.
-dnl // _VFUNC_H is not used. It obscures the code. Prototype is written above.
-dnl // _VFUNC_CC is not used. Custom vfunc is implemented in widget.ccg.
-dnl // _VFUNC_PCC is not used. Custom vfunc_callback is implemented in widget.ccg.
-dnl // _VFUNC_PH(gtkname, crettype, cargs and names)
-  _VFUNC_PH(get_request_mode, GtkSizeRequestMode, `GtkWidget* self')
-#m4end
-
+  _WRAP_VFUNC(SizeRequestMode get_request_mode() const, get_request_mode)
   _WRAP_VFUNC(void get_preferred_width(int* minimum_width, int* natural_width) const, get_preferred_width)
   _WRAP_VFUNC(void get_preferred_height_for_width(int width, int* minimum_height, int* natural_height) const, get_preferred_height_for_width)
   _WRAP_VFUNC(void get_preferred_height(int* minimum_height, int* natural_height) const, get_preferred_height)



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