From 031c1ce2c15dd363d31354919d779ae66e71be49 Mon Sep 17 00:00:00 2001 From: mental Date: Fri, 28 Jul 2006 03:29:37 +0000 Subject: [PATCH] switch to sigc++ SPObject signals for SPAttributeWidget and SPAttributeTable --- ChangeLog | 4 ++- src/dialogs/sp-attribute-widget.cpp | 51 +++++++++++++++++++---------- src/dialogs/sp-attribute-widget.h | 8 ++++- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1addd370..0f7ee39e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2006-06-27 MenTaLguY - * src/sp-offset.cpp, src/sp-offset.h, src/sp-shape.cpp, src/sp-shape.h: + * src/dialogs/sp-attribute-widget.cpp, + src/dialogs/sp-attribute-widget.h, src/sp-offset.cpp, + src/sp-offset.h, src/sp-shape.cpp, src/sp-shape.h: switch to sigc++ SPObject signals diff --git a/src/dialogs/sp-attribute-widget.cpp b/src/dialogs/sp-attribute-widget.cpp index 670da965e..d0391a2ec 100644 --- a/src/dialogs/sp-attribute-widget.cpp +++ b/src/dialogs/sp-attribute-widget.cpp @@ -24,6 +24,9 @@ #include "sp-object.h" #include +#include +#include + #include "sp-attribute-widget.h" static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass); @@ -94,6 +97,9 @@ sp_attribute_widget_init (SPAttributeWidget *spaw) spaw->src.object = NULL; spaw->attribute = NULL; + + new (&spaw->modified_connection) sigc::connection(); + new (&spaw->release_connection) sigc::connection(); } @@ -115,7 +121,8 @@ sp_attribute_widget_destroy (GtkObject *object) if (spaw->hasobj) { if (spaw->src.object) { - sp_signal_disconnect_by_data (spaw->src.object, spaw); + spaw->modified_connection.disconnect(); + spaw->release_connection.disconnect(); spaw->src.object = NULL; } } else { @@ -124,6 +131,9 @@ sp_attribute_widget_destroy (GtkObject *object) spaw->src.repr = Inkscape::GC::release(spaw->src.repr); } } // end of if() + + spaw->modified_connection.~connection(); + spaw->release_connection.~connection(); ((GtkObjectClass *) parent_class)->destroy (object); @@ -228,7 +238,8 @@ sp_attribute_widget_set_object ( SPAttributeWidget *spaw, if (spaw->hasobj) { if (spaw->src.object) { - sp_signal_disconnect_by_data (spaw->src.object, spaw); + spaw->modified_connection.disconnect(); + spaw->release_connection.disconnect(); spaw->src.object = NULL; } } else { @@ -245,12 +256,9 @@ sp_attribute_widget_set_object ( SPAttributeWidget *spaw, spaw->blocked = TRUE; spaw->src.object = object; - g_signal_connect ( G_OBJECT (object), "modified", - G_CALLBACK (sp_attribute_widget_object_modified), - spaw ); - g_signal_connect ( G_OBJECT (object), "release", - G_CALLBACK (sp_attribute_widget_object_release), - spaw ); + + spaw->modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), spaw)); + spaw->release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), spaw)); spaw->attribute = g_strdup (attribute); @@ -283,7 +291,8 @@ sp_attribute_widget_set_repr ( SPAttributeWidget *spaw, if (spaw->hasobj) { if (spaw->src.object) { - sp_signal_disconnect_by_data (spaw->src.object, spaw); + spaw->modified_connection.disconnect(); + spaw->release_connection.disconnect(); spaw->src.object = NULL; } } else { @@ -415,6 +424,9 @@ sp_attribute_table_init ( SPAttributeTable *spat ) spat->num_attr = 0; spat->attributes = NULL; spat->entries = NULL; + + new (&spat->modified_connection) sigc::connection(); + new (&spat->release_connection) sigc::connection(); } static void @@ -436,7 +448,8 @@ sp_attribute_table_destroy ( GtkObject *object ) if (spat->hasobj) { if (spat->src.object) { - sp_signal_disconnect_by_data (spat->src.object, spat); + spat->modified_connection.disconnect(); + spat->release_connection.disconnect(); spat->src.object = NULL; } } else { @@ -445,6 +458,8 @@ sp_attribute_table_destroy ( GtkObject *object ) } } // end of if() + spat->modified_connection.~connection(); + spat->release_connection.~connection(); if (spat->entries) { g_free (spat->entries); @@ -540,7 +555,8 @@ sp_attribute_table_set_object ( SPAttributeTable *spat, if (spat->hasobj) { if (spat->src.object) { - sp_signal_disconnect_by_data (spat->src.object, spat); + spat->modified_connection.disconnect(); + spat->release_connection.disconnect(); spat->src.object = NULL; } } else { @@ -559,12 +575,10 @@ sp_attribute_table_set_object ( SPAttributeTable *spat, /* Set up object */ spat->src.object = object; spat->num_attr = num_attr; - g_signal_connect ( G_OBJECT (object), "modified", - G_CALLBACK (sp_attribute_table_object_modified), - spat ); - g_signal_connect ( G_OBJECT (object), "release", - G_CALLBACK (sp_attribute_table_object_release), - spat ); + + spat->modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), spat)); + spat->modified_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), spat)); + /* Create table */ spat->table = gtk_table_new (num_attr, 2, FALSE); gtk_container_add (GTK_CONTAINER (spat), spat->table); @@ -642,7 +656,8 @@ sp_attribute_table_set_repr ( SPAttributeTable *spat, if (spat->hasobj) { if (spat->src.object) { - sp_signal_disconnect_by_data (spat->src.object, spat); + spat->modified_connection.disconnect(); + spat->release_connection.disconnect(); spat->src.object = NULL; } } else { diff --git a/src/dialogs/sp-attribute-widget.h b/src/dialogs/sp-attribute-widget.h index d5b2075ce..dc27c5a24 100644 --- a/src/dialogs/sp-attribute-widget.h +++ b/src/dialogs/sp-attribute-widget.h @@ -17,7 +17,7 @@ #include - +#include #define SP_TYPE_ATTRIBUTE_WIDGET (sp_attribute_widget_get_type ()) #define SP_ATTRIBUTE_WIDGET(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidget)) @@ -58,6 +58,9 @@ struct SPAttributeWidget { Inkscape::XML::Node *repr; } src; gchar *attribute; + + sigc::connection modified_connection; + sigc::connection release_connection; }; struct SPAttributeWidgetClass { @@ -90,6 +93,9 @@ struct SPAttributeTable { gint num_attr; gchar **attributes; GtkWidget **entries; + + sigc::connection modified_connection; + sigc::connection release_connection; }; struct SPAttributeTableClass { -- 2.30.2