diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp
index 64aa868ccd1f39611b395fad99bc3eb8ade5729b..37be6f75eef0b384e418c3ade98eec793fb86b89 100644 (file)
--- a/src/sp-switch.cpp
+++ b/src/sp-switch.cpp
*
* Authors:
* Andrius R. <knutux@gmail.com>
+ * MenTaLguY <mental@rydia.net>
*
* Copyright (C) 2006 authors
*
# include "config.h"
#endif
-#if defined(WIN32) || defined(__APPLE__)
-# include <glibmm/i18n.h>
-#endif
+#include <glibmm/i18n.h>
#include "sp-switch.h"
#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);
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() {
SPObject *CSwitch::_evaluateFirst() {
for (SPObject *child = sp_object_first_child(_group) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
- if (sp_item_evaluate(SP_ITEM(child)))
+ if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child)))
return child;
}
return NULL;
}
-GSList *CSwitch::_childList(bool add_ref, Action action) {
- if ( ActionGeneral != action ) {
- return CGroup::_childList(add_ref, action);
+GSList *CSwitch::_childList(bool add_ref, SPObject::Action action) {
+ if ( action != SPObject::ActionGeneral ) {
+ return _group->childList(add_ref, action);
}
SPObject *child = _evaluateFirst();
@@ -113,7 +115,7 @@ void CSwitch::onOrderChanged (Inkscape::XML::Node *, Inkscape::XML::Node *, Inks
_reevaluate();
}
-void CSwitch::_reevaluate(bool add_to_arena) {
+void CSwitch::_reevaluate(bool /*add_to_arena*/) {
SPObject *evaluated_child = _evaluateFirst();
if (!evaluated_child || _cached_item == evaluated_child) {
return;
_releaseLastItem(_cached_item);
SPItem * child;
- for ( GSList *l = _childList(false, ActionShow);
+ for ( GSList *l = _childList(false, SPObject::ActionShow);
NULL != l ; l = g_slist_remove (l, l->data))
{
SPObject *o = SP_OBJECT (l->data);
}
_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);
}
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;
}
NRArenaItem *ac = NULL;
NRArenaItem *ar = NULL;
SPItem * child;
- GSList *l = _childList(false, ActionShow);
+ GSList *l = _childList(false, SPObject::ActionShow);
while (l) {
SPObject *o = SP_OBJECT (l->data);
if (SP_IS_ITEM (o)) {
if (ac) {
nr_arena_item_add_child (ai, ac, ar);
ar = ac;
- nr_arena_item_unref (ac);
}
}
l = g_slist_remove (l, o);