From 33ac04c1d2903b1c2340cb55f2f6067003b80f4b Mon Sep 17 00:00:00 2001 From: mental Date: Fri, 21 Jul 2006 17:10:38 +0000 Subject: [PATCH] switched to using sigc++ "modified" signal --- ChangeLog | 6 ++++++ src/ui/view/edit-widget.cpp | 29 ++++++++++++++--------------- src/ui/view/edit-widget.h | 4 +++- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index afffdfe09..878b79a90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-07-21 MenTaLguY + + * src/ui/view/edit-widget.cpp, src/ui/view/edit-widget.cpp: + + switched to using sigc++ "modified" signal + 2006-07-21 MenTaLguY * src/document.cpp, src/sp-object.cpp, src/sp-object.h: diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 8eb96b291..626c30941 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -38,6 +38,8 @@ #include #include +#include + #include "macros.h" #include "path-prefix.h" #include "prefs-utils.h" @@ -1472,17 +1474,15 @@ EditWidget::warnDialog (gchar* msg) } -/// \todo make this a member function when the signal is a sigc++ signal -void _namedview_modified (SPNamedView* nv, guint flags, EditWidget* ew) -{ - if (flags & SP_OBJECT_MODIFIED_FLAG) - { - ew->_dt2r = 1.0 / nv->doc_units->unittobase; - ew->_top_ruler.update_metric(); - ew->_left_ruler.update_metric(); - ew->_tooltips.set_tip (ew->_top_ruler, ew->_top_ruler.get_tip()); - ew->_tooltips.set_tip (ew->_left_ruler, ew->_left_ruler.get_tip()); - ew->updateRulers(); +void EditWidget::_namedview_modified (SPObject *obj, guint flags) { + SPNamedView *nv = static_cast(obj); + if (flags & SP_OBJECT_MODIFIED_FLAG) { + this->_dt2r = 1.0 / nv->doc_units->unittobase; + this->_top_ruler.update_metric(); + this->_left_ruler.update_metric(); + this->_tooltips.set_tip(this->_top_ruler, this->_top_ruler.get_tip()); + this->_tooltips.set_tip(this->_left_ruler, this->_left_ruler.get_tip()); + this->updateRulers(); } } @@ -1500,8 +1500,7 @@ EditWidget::initEdit (SPDocument *doc) /// \todo convert to sigc++ when SPObject hierarchy gets converted /* Listen on namedview modification */ - g_signal_connect (G_OBJECT (_desktop->namedview), "modified", - G_CALLBACK (_namedview_modified), this); + _namedview_modified_connection = _desktop->namedview->connectModified(sigc::mem_fun(*this, &EditWidget::_namedview_modified)); _layer_selector.setDesktop (_desktop); _selected_style_status.setDesktop (_desktop); @@ -1519,7 +1518,7 @@ EditWidget::destroyEdit() if (_desktop) { _layer_selector.unreference(); Inkscape::NSApplication::Editor::removeDesktop (_desktop); // clears selection too - sp_signal_disconnect_by_data (G_OBJECT (_desktop->namedview), this); + _namedview_modified_connection.disconnect(); _desktop->destroy(); Inkscape::GC::release (_desktop); _desktop = 0; @@ -1601,7 +1600,7 @@ EditWidget::onWindowRealize() } _desktop->set_display_area(d.min()[NR::X], d.min()[NR::Y], d.max()[NR::X], d.max()[NR::Y], 10); - _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG, this); + _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG); setTitle (SP_DOCUMENT_NAME(_desktop->doc())); } diff --git a/src/ui/view/edit-widget.h b/src/ui/view/edit-widget.h index 73e6f048e..0beb77b53 100644 --- a/src/ui/view/edit-widget.h +++ b/src/ui/view/edit-widget.h @@ -125,7 +125,7 @@ public: virtual bool warnDialog (gchar*); protected: - friend void _namedview_modified (SPNamedView*, guint, EditWidget*); + void _namedview_modified(SPObject *namedview, guint); Gtk::Tooltips _tooltips; @@ -192,6 +192,8 @@ private: void onAdjValueChanged(); bool _update_s_f, _update_a_f; + + sigc::connection _namedview_modified_connection; }; } // namespace View } // namespace UI -- 2.30.2