Code

switch to sigc++ signal for "release"
authormental <mental@users.sourceforge.net>
Fri, 21 Jul 2006 21:28:48 +0000 (21:28 +0000)
committermental <mental@users.sourceforge.net>
Fri, 21 Jul 2006 21:28:48 +0000 (21:28 +0000)
ChangeLog
src/object-hierarchy.cpp
src/object-hierarchy.h

index fb82617144e84327cc01ef5bdec7b52f22d9579b..23dafb1eab0aabcd087a21ee8aada01de625f8e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2006-07-21  MenTaLguY  <mental@rydia.net>
 
-       * 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:
        
index 658bcb511ea251b5ead33f5b91e6b9f98c5d1b83..49de16d0baf00de0c664a99c7899215c3480bc57 100644 (file)
@@ -12,6 +12,8 @@
 #include "sp-object.h"
 #include "object-hierarchy.h"
 
+#include <sigc++/functors/mem_fun.h>
+
 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);
 }
 
index 92da163ea3185103e7f128baa3763d8478af20f7..e5f44b413ea916edc383a57e62ecd6f006ae29d6 100644 (file)
@@ -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<Record> _hierarchy;
     sigc::signal<void, SPObject *> _added_signal;