Code

switch to sigc++ SPObject signals for SPSwitch
authormental <mental@users.sourceforge.net>
Sat, 29 Jul 2006 21:25:37 +0000 (21:25 +0000)
committermental <mental@users.sourceforge.net>
Sat, 29 Jul 2006 21:25:37 +0000 (21:25 +0000)
ChangeLog
src/sp-switch.cpp
src/sp-switch.h

index af5c3eb0b2c653b3e85e007ba7aafacf97173442..056d54fc4836ed39490d9caa13a03a8a5546f18f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,9 +2,10 @@
 
        * src/desktop.cpp, src/desktop.h, src/sp-gradient.cpp,
          src/sp-gradient.h, src/sp-pattern.cpp, src/sp-pattern.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:
+         src/sp-switch.cpp, src/sp-switch.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
 
index 65ecc5442ffbe0a3824b444d33c8672a0fba8086..bafb9de18241b8cac4bab43a7ee1873b855ab452 100644 (file)
@@ -5,6 +5,7 @@
  *
  * Authors:
  *   Andrius R. <knutux@gmail.com>
+ *   MenTaLguY  <mental@rydia.net>
  *
  * Copyright (C) 2006 authors
  *
@@ -21,6 +22,9 @@
 #include "display/nr-arena-group.h"
 #include "conditions.h"
 
+#include <sigc++/functors/ptr_fun.h>
+#include <sigc++/adaptors/bind.h>
+
 static void sp_switch_class_init (SPSwitchClass *klass);
 static void sp_switch_init (SPSwitch *group);
 
@@ -60,7 +64,7 @@ static void sp_switch_init (SPSwitch *group)
     group->group = new CSwitch(group);
 }
 
-CSwitch::CSwitch(SPGroup *group) : CGroup(group), _cached_item(NULL), _release_handler_id(0) {
+CSwitch::CSwitch(SPGroup *group) : CGroup(group), _cached_item(NULL) {
 }
 
 CSwitch::~CSwitch() {
@@ -133,10 +137,7 @@ void CSwitch::_reevaluate(bool add_to_arena) {
     }
 
     _cached_item = evaluated_child;
-    _release_handler_id = g_signal_connect(
-                                    G_OBJECT(evaluated_child), "release",
-                                    G_CALLBACK(&CSwitch::_releaseItem),
-                                    this);
+    _release_connection = evaluated_child->connectRelease(sigc::bind(sigc::ptr_fun(&CSwitch::_releaseItem), this));
 
     _group->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
 }
@@ -151,8 +152,7 @@ void CSwitch::_releaseLastItem(SPObject *obj)
     if (NULL == _cached_item || _cached_item != obj)
         return;
 
-    g_signal_handler_disconnect(G_OBJECT(_cached_item), _release_handler_id);
-    _release_handler_id = 0;
+    _release_connection.disconnect();
     _cached_item = NULL;
 }
 
index 421d562ab0e772c88b5d280b05111202a97e8008..91fdcae46f23c09ef3ce2c888efcf3fe3c57ef51 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "sp-item-group.h"
 
+#include <sigc++/connection.h>
+
 #define SP_TYPE_SWITCH            (CSwitch::getType())
 #define SP_SWITCH(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SWITCH, SPSwitch))
 #define SP_SWITCH_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SWITCH, SPSwitchClass))
@@ -48,7 +50,7 @@ protected:
 
 private:
     SPObject *_cached_item;
-    gulong _release_handler_id;
+    sigc::connection _release_connection;
 };
 
 struct SPSwitch : public SPGroup {