From 2295ac55303a57a165ef89fe8461348b4257b818 Mon Sep 17 00:00:00 2001 From: mental Date: Sat, 29 Jul 2006 20:21:27 +0000 Subject: [PATCH] switch to sigc++ SPObject signals for desktop widget --- ChangeLog | 3 ++- src/widgets/desktop-widget.cpp | 18 +++++++++++++----- src/widgets/desktop-widget.h | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0053906a4..ec994c951 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2006-06-29 MenTaLguY - * src/widgets/gradient-image.cpp, src/widgets/gradient-image.h, + * 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: switch to sigc++ SPObject signals diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 0a4536bb1..9590af94c 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -77,7 +77,7 @@ static gint sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDeskt static void sp_desktop_widget_adjustment_value_changed (GtkAdjustment *adj, SPDesktopWidget *dtw); -static void sp_desktop_widget_namedview_modified (SPNamedView *nv, guint flags, SPDesktopWidget *dtw); +static void sp_desktop_widget_namedview_modified (SPObject *obj, guint flags, SPDesktopWidget *dtw); static gdouble sp_dtw_zoom_value_to_display (gdouble value); static gdouble sp_dtw_zoom_display_to_value (gdouble value); @@ -163,6 +163,8 @@ sp_desktop_widget_init (SPDesktopWidget *dtw) GtkWidget *eventbox; GtkStyle *style; + new (&dtw->modified_connection) sigc::connection(); + widget = GTK_WIDGET (dtw); dtw->window = 0; @@ -344,12 +346,14 @@ sp_desktop_widget_destroy (GtkObject *object) if (dtw->desktop) { dtw->layer_selector->unreference(); inkscape_remove_desktop (dtw->desktop); // clears selection too - sp_signal_disconnect_by_data (G_OBJECT (dtw->desktop->namedview), dtw); + dtw->modified_connection.disconnect(); dtw->desktop->destroy(); Inkscape::GC::release (dtw->desktop); dtw->desktop = NULL; } + dtw->modified_connection.~connection(); + if (GTK_OBJECT_CLASS (dtw_parent_class)->destroy) { (* GTK_OBJECT_CLASS (dtw_parent_class)->destroy) (object); } @@ -449,7 +453,10 @@ sp_desktop_widget_realize (GtkWidget *widget) dtw->desktop->set_display_area (d.x0, d.y0, d.x1, d.y1, 10); /* Listen on namedview modification */ - g_signal_connect (G_OBJECT (dtw->desktop->namedview), "modified", G_CALLBACK (sp_desktop_widget_namedview_modified), dtw); + // originally (prior to the sigc++ conversion) the signal was simply + // connected twice rather than disconnecting the first connection + dtw->modified_connection.disconnect(); + dtw->modified_connection = dtw->desktop->namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_desktop_widget_namedview_modified), dtw)); sp_desktop_widget_namedview_modified (dtw->desktop->namedview, SP_OBJECT_MODIFIED_FLAG, dtw); dtw->updateTitle(SP_DOCUMENT_NAME (dtw->desktop->doc())); @@ -897,7 +904,7 @@ sp_desktop_widget_new (SPNamedView *namedview) sp_view_widget_set_view (SP_VIEW_WIDGET (dtw), dtw->desktop); /* Listen on namedview modification */ - g_signal_connect (G_OBJECT (namedview), "modified", G_CALLBACK (sp_desktop_widget_namedview_modified), dtw); + dtw->modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_desktop_widget_namedview_modified), dtw)); dtw->layer_selector->setDesktop(dtw->desktop); @@ -941,8 +948,9 @@ sp_desktop_widget_update_rulers (SPDesktopWidget *dtw) static void -sp_desktop_widget_namedview_modified (SPNamedView *nv, guint flags, SPDesktopWidget *dtw) +sp_desktop_widget_namedview_modified (SPObject *obj, guint flags, SPDesktopWidget *dtw) { + SPNamedView *nv=SP_NAMEDVIEW(obj); if (flags & SP_OBJECT_MODIFIED_FLAG) { dtw->dt2r = 1.0 / nv->doc_units->unittobase; dtw->ruler_origin = nv->gridorigin; diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 5129fbf49..cc66bf180 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -19,6 +19,8 @@ #include "ui/view/view-widget.h" #include "ui/view/edit-widget-interface.h" +#include + #define SP_TYPE_DESKTOP_WIDGET (sp_desktop_widget_get_type ()) #define SP_DESKTOP_WIDGET(o) (GTK_CHECK_CAST ((o), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidget)) #define SP_DESKTOP_WIDGET_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidgetClass)) @@ -55,6 +57,8 @@ struct SPDesktopWidget { unsigned int update : 1; + sigc::connection modified_connection; + GtkTooltips *tt; SPDesktop *desktop; -- 2.30.2