[glom] EggSpreadTableDnd: Wrap the wiget_drop_possible signal.



commit 777e265e31a3ad0b2a7f9a644b4c65a23885ffcc
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Apr 18 11:53:59 2011 +0200

    EggSpreadTableDnd: Wrap the wiget_drop_possible signal.
    
    * glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.[h|cc]:
    * glom/utility_widgets/eggspreadtablemm/private/eggspreadtabledndmm
    _p.h: This is unpleasant without gmmproc.

 ChangeLog                                          |   13 ++-
 .../eggspreadtablemm/eggspreadtabledndmm.cc        |  135 +++++++++++++++++++-
 .../eggspreadtablemm/eggspreadtabledndmm.h         |    9 ++
 .../private/eggspreadtabledndmm_p.h                |    2 +
 4 files changed, 155 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9bad776..23fdb77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,17 @@
 2011-04-18  Murray Cumming  <murrayc murrayc com>
 
-	.com
+	EggSpreadTableDnd: Wrap the wiget_drop_possible signal.
+
+	* glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.[h|cc]:
+	* glom/utility_widgets/eggspreadtablemm/private/eggspreadtabledndmm
+	_p.h: This is unpleasant without gmmproc.
+
+2011-04-18  Murray Cumming  <murrayc murrayc com>
+
+	Egg::SpreadTableDnd: Fix typos.
+
+    * glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.cc:
+    Use the correct GTypes.
 
 2011-04-18  Murray Cumming  <murrayc murrayc com>
 
diff --git a/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.cc b/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.cc
index f329874..9e418fe 100644
--- a/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.cc
+++ b/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.cc
@@ -35,6 +35,76 @@ Egg::SpreadTableDnd* wrap(EggSpreadTableDnd* object, bool take_copy)
 
 } /* namespace Glib */
 
+namespace
+{
+
+static gboolean EggSpreadTableDnd_signal_widget_drop_possible_callback(EggSpreadTableDnd* self, GtkWidget* p0, void* data)
+{
+  using namespace Egg;
+  typedef sigc::slot< bool, Gtk::Widget* > SlotType;
+
+  // Do not try to call a signal on a disassociated wrapper.
+  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
+  {
+    #ifdef GLIBMM_EXCEPTIONS_ENABLED
+    try
+    {
+    #endif //GLIBMM_EXCEPTIONS_ENABLED
+      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
+        return static_cast<int>((*static_cast<SlotType*>(slot))(Glib::wrap(p0)
+));
+    #ifdef GLIBMM_EXCEPTIONS_ENABLED
+    }
+    catch(...)
+    {
+      Glib::exception_handlers_invoke();
+    }
+    #endif //GLIBMM_EXCEPTIONS_ENABLED
+  }
+
+  typedef gboolean RType;
+  return RType();
+}
+
+static gboolean EggSpreadTableDnd_signal_widget_drop_possible_notify_callback(EggSpreadTableDnd* self, GtkWidget* p0, void* data)
+{
+  using namespace Egg;
+  typedef sigc::slot< bool, Gtk::Widget* > SlotType;
+
+  // Do not try to call a signal on a disassociated wrapper.
+  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
+  {
+    #ifdef GLIBMM_EXCEPTIONS_ENABLED
+    try
+    {
+    #endif //GLIBMM_EXCEPTIONS_ENABLED
+      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
+        (*static_cast<SlotType*>(slot))(Glib::wrap(p0)
+);
+    #ifdef GLIBMM_EXCEPTIONS_ENABLED
+    }
+    catch(...)
+    {
+      Glib::exception_handlers_invoke();
+    }
+    #endif //GLIBMM_EXCEPTIONS_ENABLED
+  }
+
+  typedef gboolean RType;
+  return RType();
+}
+
+static const Glib::SignalProxyInfo SpreadTableDnd_signal_widget_drop_possible_info =
+{
+  "widget-drop-possible",
+  (GCallback) &EggSpreadTableDnd_signal_widget_drop_possible_callback,
+  (GCallback) &EggSpreadTableDnd_signal_widget_drop_possible_notify_callback
+};
+
+
+} //anonymous namespace
+
+
 namespace Egg
 {
 
@@ -59,13 +129,56 @@ const Glib::Class& SpreadTableDnd_Class::init()
   return *this;
 }
 
-
 void SpreadTableDnd_Class::class_init_function(void* g_class, void* class_data)
 {
   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
   CppClassParent::class_init_function(klass, class_data);
 
+  klass->widget_drop_possible = &widget_drop_possible_callback;
+}
+
+gboolean SpreadTableDnd_Class::widget_drop_possible_callback(EggSpreadTableDnd* self, GtkWidget* p0)
+{
+  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 static_cast<int>(obj->on_widget_drop_possible(Glib::wrap(p0)
+));
+      #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->widget_drop_possible)
+    return (*base->widget_drop_possible)(self, p0);
 
+  typedef gboolean RType;
+  return RType();
 }
 
 
@@ -115,8 +228,6 @@ SpreadTableDnd::SpreadTableDnd()
   Glib::ObjectBase(0),
   SpreadTable(Glib::ConstructParams(spreadtable_class_.init()))
 {
-
-
 }
 
 SpreadTableDnd::SpreadTableDnd(Gtk::Orientation orientation, guint lines)
@@ -127,4 +238,22 @@ SpreadTableDnd::SpreadTableDnd(Gtk::Orientation orientation, guint lines)
 {
 }
 
+
+bool SpreadTableDnd::on_widget_drop_possible(Gtk::Widget* widget)
+{
+  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->widget_drop_possible)
+    return (*base->widget_drop_possible)(gobj(), Glib::unwrap(widget));
+  else
+    return false;
+}
+
+Glib::SignalProxy1< bool, Gtk::Widget* > SpreadTableDnd::signal_widget_drop_possible()
+{
+  return Glib::SignalProxy1< bool, Gtk::Widget* >(this, &SpreadTableDnd_signal_widget_drop_possible_info);
+}
+
 } // namespace Egg
diff --git a/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.h b/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.h
index 069a65b..7d185d3 100644
--- a/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.h
+++ b/glom/utility_widgets/eggspreadtablemm/eggspreadtabledndmm.h
@@ -84,6 +84,7 @@ protected:
 
   //Default Signal Handlers::
 
+  bool on_widget_drop_possible(Gtk::Widget* widget);
 
 private:
 
@@ -91,6 +92,14 @@ private:
 public:
   SpreadTableDnd();
   explicit SpreadTableDnd(Gtk::Orientation orientation, guint lines);
+
+
+  /**
+   * @par Prototype:
+   * <tt>void on_my_%widget_drop_possible()</tt>
+   */
+
+  Glib::SignalProxy1< bool, Gtk::Widget* > signal_widget_drop_possible();
 };
 
 } // namespace Egg
diff --git a/glom/utility_widgets/eggspreadtablemm/private/eggspreadtabledndmm_p.h b/glom/utility_widgets/eggspreadtablemm/private/eggspreadtabledndmm_p.h
index 7acf0f9..af1f917 100644
--- a/glom/utility_widgets/eggspreadtablemm/private/eggspreadtabledndmm_p.h
+++ b/glom/utility_widgets/eggspreadtablemm/private/eggspreadtabledndmm_p.h
@@ -35,6 +35,8 @@ protected:
   //These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
   //You could prevent the original default signal handlers being called by overriding the *_impl method.
 
+  static gboolean widget_drop_possible_callback(EggSpreadTableDnd* self, GtkWidget* p0);
+
   //Callbacks (virtual functions):
 };
 



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