Code

switch to sigc++ SPObject signals for SPGradientImage
authormental <mental@users.sourceforge.net>
Sat, 29 Jul 2006 20:09:47 +0000 (20:09 +0000)
committermental <mental@users.sourceforge.net>
Sat, 29 Jul 2006 20:09:47 +0000 (20:09 +0000)
ChangeLog
src/widgets/gradient-image.cpp
src/widgets/gradient-image.h

index 3031f428a6060790a8ec45a9b8ba2a8d4f9c0fa8..0053906a4c60810c8d42286310bbc2fab293b947 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2006-06-29  MenTaLguY  <mental@rydia.net>
 
-       * src/widgets/gradient-toolbar.cpp, src/widgets/gradient-toolbar.cpp:
+       * src/widgets/gradient-image.cpp, src/widgets/gradient-image.h,
+         src/widgets/gradient-toolbar.cpp, src/widgets/gradient-toolbar.cpp:
 
          switch to sigc++ SPObject signals
 
index 38300426db84822baa6b0a7fe65257be157f6cea..2393e407ac37583219ec1f26d01a46f825c29062 100644 (file)
 #include "../display/nr-plain-stuff.h"
 #include "../display/nr-plain-stuff-gdk.h"
 #include "gradient-image.h"
+#include "sp-gradient.h"
 #include "sp-gradient-fns.h"
 
+#include <sigc++/functors/ptr_fun.h>
+#include <sigc++/adaptors/bind.h>
+
 #define VBLOCK 16
 
 static void sp_gradient_image_class_init (SPGradientImageClass *klass);
@@ -31,8 +35,8 @@ static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *r
 static void sp_gradient_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
 static gint sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event);
 
-static void sp_gradient_image_gradient_release (SPGradient *gr, SPGradientImage *im);
-static void sp_gradient_image_gradient_modified (SPGradient *gr, guint flags, SPGradientImage *im);
+static void sp_gradient_image_gradient_release (SPObject *, SPGradientImage *im);
+static void sp_gradient_image_gradient_modified (SPObject *, guint flags, SPGradientImage *im);
 static void sp_gradient_image_update (SPGradientImage *img);
 
 static GtkWidgetClass *parent_class;
@@ -82,6 +86,9 @@ sp_gradient_image_init (SPGradientImage *image)
 
        image->gradient = NULL;
        image->px = NULL;
+
+       new (&image->release_connection) sigc::connection();
+       new (&image->modified_connection) sigc::connection();
 }
 
 static void
@@ -92,10 +99,14 @@ sp_gradient_image_destroy (GtkObject *object)
        image = SP_GRADIENT_IMAGE (object);
 
        if (image->gradient) {
-               sp_signal_disconnect_by_data (image->gradient, image);
+               image->release_connection.disconnect();
+               image->modified_connection.disconnect();
                image->gradient = NULL;
        }
 
+       image->release_connection.~connection();
+       image->modified_connection.~connection();
+
        if (((GtkObjectClass *) (parent_class))->destroy)
                (* ((GtkObjectClass *) (parent_class))->destroy) (object);
 }
@@ -217,24 +228,26 @@ void
 sp_gradient_image_set_gradient (SPGradientImage *image, SPGradient *gradient)
 {
        if (image->gradient) {
-               sp_signal_disconnect_by_data (image->gradient, image);
+               image->release_connection.disconnect();
+               image->modified_connection.disconnect();
        }
 
        image->gradient = gradient;
 
        if (gradient) {
-               g_signal_connect (G_OBJECT (gradient), "release", G_CALLBACK (sp_gradient_image_gradient_release), image);
-               g_signal_connect (G_OBJECT (gradient), "modified", G_CALLBACK (sp_gradient_image_gradient_modified), image);
+               image->release_connection = gradient->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gradient_image_gradient_release), image));
+               image->modified_connection = gradient->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gradient_image_gradient_modified), image));
        }
 
        sp_gradient_image_update (image);
 }
 
 static void
-sp_gradient_image_gradient_release (SPGradient *gradient, SPGradientImage *image)
+sp_gradient_image_gradient_release (SPObject *, SPGradientImage *image)
 {
        if (image->gradient) {
-               sp_signal_disconnect_by_data (image->gradient, image);
+               image->release_connection.disconnect();
+               image->modified_connection.disconnect();
        }
 
        image->gradient = NULL;
@@ -243,7 +256,7 @@ sp_gradient_image_gradient_release (SPGradient *gradient, SPGradientImage *image
 }
 
 static void
-sp_gradient_image_gradient_modified (SPGradient *gradient, guint flags, SPGradientImage *image)
+sp_gradient_image_gradient_modified (SPObject *, guint flags, SPGradientImage *image)
 {
        sp_gradient_image_update (image);
 }
index 0e0241ac7c22fef2e4f317b836e5de9cdf54c74c..d0864b6e8d7e342817358fcfb3ef9fdb2baec2f8 100644 (file)
@@ -19,6 +19,7 @@ class SPGradient;
 
 #include <glib.h>
 
+#include <sigc++/connection.h>
 
 #define SP_TYPE_GRADIENT_IMAGE (sp_gradient_image_get_type ())
 #define SP_GRADIENT_IMAGE(o) (GTK_CHECK_CAST ((o), SP_TYPE_GRADIENT_IMAGE, SPGradientImage))
@@ -30,6 +31,9 @@ struct SPGradientImage {
        GtkWidget widget;
        SPGradient *gradient;
        guchar *px;
+
+       sigc::connection release_connection;
+       sigc::connection modified_connection;
 };
 
 struct SPGradientImageClass {