Code

switch to sigc++ SPObject signals for SPGradient
authormental <mental@users.sourceforge.net>
Sat, 29 Jul 2006 21:06:37 +0000 (21:06 +0000)
committermental <mental@users.sourceforge.net>
Sat, 29 Jul 2006 21:06:37 +0000 (21:06 +0000)
ChangeLog
src/sp-gradient.cpp
src/sp-gradient.h

index c4869d4feb029c2635833dfd36650ea82e7c8fc0..9cb88be4f034ac5ad122a93a67bef581cdf1d9c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2006-06-29  MenTaLguY  <mental@rydia.net>
 
-       * src/desktop.cpp, src/desktop.h, src/widgets/desktop-widget.cpp,
+       * src/desktop.cpp, src/desktop.h, src/sp-gradient.cpp,
+         src/sp-gradient.cpp, src/widgets/desktop-widget.cpp,
          src/widgets/desktop-widget.h, src/widgets/gradient-image.cpp,
          src/widgets/gradient-image.h, src/widgets/gradient-toolbar.cpp,
          src/widgets/gradient-toolbar.cpp:
index dd7b7b257aa6659a0fe50616b896d529c3107007..2e6d2a37c303b746b860850942b82ad726f15aec 100644 (file)
@@ -26,6 +26,8 @@
 #include <libnr/nr-matrix-translate-ops.h>
 #include "libnr/nr-scale-translate-ops.h"
 
+#include <sigc++/functors/ptr_fun.h>
+#include <sigc++/adaptors/bind.h>
 
 #include "display/nr-gradient-gpl.h"
 #include "svg/svg.h"
@@ -377,6 +379,8 @@ sp_gradient_init(SPGradient *gr)
     gr->vector.stops.clear();
 
     gr->color = NULL;
+
+    new (&gr->modified_connection) sigc::connection();
 }
 
 /**
@@ -425,9 +429,7 @@ sp_gradient_release(SPObject *object)
     }
 
     if (gradient->ref) {
-        if (gradient->ref->getObject()) {
-            sp_signal_disconnect_by_data(gradient->ref->getObject(), gradient);
-        }
+        gradient->modified_connection.disconnect();
         gradient->ref->detach();
         delete gradient->ref;
         gradient->ref = NULL;
@@ -438,6 +440,8 @@ sp_gradient_release(SPObject *object)
         gradient->color = NULL;
     }
 
+    gradient->modified_connection.~connection();
+
     if (((SPObjectClass *) gradient_parent_class)->release)
         ((SPObjectClass *) gradient_parent_class)->release(object);
 }
@@ -518,12 +522,12 @@ static void
 gradient_ref_changed(SPObject *old_ref, SPObject *ref, SPGradient *gr)
 {
     if (old_ref) {
-        sp_signal_disconnect_by_data(old_ref, gr);
+        gr->modified_connection.disconnect();
     }
     if ( SP_IS_GRADIENT(ref)
          && ref != gr )
     {
-        g_signal_connect(G_OBJECT(ref), "modified", G_CALLBACK(gradient_ref_modified), gr);
+        gr->modified_connection = ref->connectModified(sigc::bind<2>(sigc::ptr_fun(&gradient_ref_modified), gr));
     }
     /// \todo Fixme: what should the flags (second) argument be? */
     gradient_ref_modified(ref, 0, gr);
index 9c152598b3a033063dbac03591e7def38f0ee866..b0ed49c0023d8205c8c6202da7870899eda718cb 100644 (file)
@@ -20,6 +20,8 @@
 #include "sp-gradient-units.h"
 #include "sp-gradient-vector.h"
 
+#include <sigc++/connection.h>
+
 struct SPGradientReference;
 
 typedef enum {
@@ -69,6 +71,8 @@ struct SPGradient : public SPPaintServer {
        SPGradientVector vector;
        /** Rendered color array (4 * 1024 bytes) */
        guchar *color;
+
+        sigc::connection modified_connection;
 };
 
 /**