From 0f201e31b850b4b97592ea8198e3ecd5cac73ae4 Mon Sep 17 00:00:00 2001 From: mental Date: Fri, 21 Jul 2006 21:28:48 +0000 Subject: [PATCH] switch to sigc++ signal for "release" --- ChangeLog | 3 ++- src/object-hierarchy.cpp | 30 +++++++++++++++++------------- src/object-hierarchy.h | 9 +++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb8261714..23dafb1ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2006-07-21 MenTaLguY - * src/document-subset.cpp, src/selection.cpp, src/selection.h, + * src/document-subset.cpp, src/object-hierarchy.cpp, + src/object-hierarchy.h, src/selection.cpp, src/selection.h, src/ui/view/edit-widget.cpp, src/ui/view/edit-widget.h, src/uri-references.cpp, src/uri-references.h: diff --git a/src/object-hierarchy.cpp b/src/object-hierarchy.cpp index 658bcb511..49de16d0b 100644 --- a/src/object-hierarchy.cpp +++ b/src/object-hierarchy.cpp @@ -12,6 +12,8 @@ #include "sp-object.h" #include "object-hierarchy.h" +#include + namespace Inkscape { /** @@ -173,29 +175,31 @@ void ObjectHierarchy::_addBottom(SPObject *object) { _added_signal.emit(object); } -void ObjectHierarchy::_trim_for_release(SPObject *object, ObjectHierarchy *hier) -{ - hier->_trimBelow(object); - g_assert(!hier->_hierarchy.empty()); - g_assert(hier->_hierarchy.front().object == object); +void ObjectHierarchy::_trim_for_release(SPObject *object) { + this->_trimBelow(object); + g_assert(!this->_hierarchy.empty()); + g_assert(this->_hierarchy.front().object == object); sp_object_ref(object, NULL); - hier->_detach(hier->_hierarchy.front()); - hier->_hierarchy.pop_front(); - hier->_removed_signal.emit(object); + this->_detach(this->_hierarchy.front()); + this->_hierarchy.pop_front(); + this->_removed_signal.emit(object); sp_object_unref(object, NULL); - hier->_changed_signal.emit(hier->top(), hier->bottom()); + this->_changed_signal.emit(this->top(), this->bottom()); } ObjectHierarchy::Record ObjectHierarchy::_attach(SPObject *object) { sp_object_ref(object, NULL); - gulong id = g_signal_connect(G_OBJECT(object), "release", GCallback(&ObjectHierarchy::_trim_for_release), this); - return Record(object, id); + sigc::connection connection + = object->connectRelease( + sigc::mem_fun(*this, &ObjectHierarchy::_trim_for_release) + ); + return Record(object, connection); } -void ObjectHierarchy::_detach(ObjectHierarchy::Record const &rec) { - g_signal_handler_disconnect(G_OBJECT(rec.object), rec.handler_id); +void ObjectHierarchy::_detach(ObjectHierarchy::Record &rec) { + rec.connection.disconnect(); sp_object_unref(rec.object, NULL); } diff --git a/src/object-hierarchy.h b/src/object-hierarchy.h index 92da163ea..e5f44b413 100644 --- a/src/object-hierarchy.h +++ b/src/object-hierarchy.h @@ -68,10 +68,11 @@ public: private: struct Record { - Record(SPObject *o, gulong id) : object(o), handler_id(id) {} + Record(SPObject *o, sigc::connection c) + : object(o), connection(c) {} SPObject *object; - gulong handler_id; + sigc::connection connection; }; ObjectHierarchy(ObjectHierarchy const &); // no copy @@ -92,11 +93,11 @@ private: void _trimBelow(SPObject *limit); Record _attach(SPObject *object); - void _detach(Record const &record); + void _detach(Record &record); void _clear() { _trimBelow(NULL); } - static void _trim_for_release(SPObject *released, ObjectHierarchy *hier); + void _trim_for_release(SPObject *released); std::list _hierarchy; sigc::signal _added_signal; -- 2.30.2