diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp
index 6884c352f170125389ce4523262ea3eea5dd6d8e..19c014b9b50e76c46168158a2f3eda7b8bcf34ce 100644 (file)
--- a/src/sp-switch.cpp
+++ b/src/sp-switch.cpp
-#define __SP_SWITCH_CPP__
-
/*
* SVG <switch> implementation
*
* Authors:
* Andrius R. <knutux@gmail.com>
+ * MenTaLguY <mental@rydia.net>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006 authors
*
#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_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child)))
- return child;
+ SPObject *first = 0;
+ for (SPObject *child = _group->firstChild() ; child && !first ; child = child->getNext() ) {
+ if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) {
+ first = child;
+ }
}
- return NULL;
+ return first;
}
-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();
@@ -111,7 +117,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;
}
@@ -162,19 +164,29 @@ void CSwitch::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key,
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)) {
child = SP_ITEM (o);
child->setEvaluated(o == evaluated_child);
- ac = sp_item_invoke_show (child, arena, key, flags);
+ ac = child->invoke_show (arena, key, flags);
if (ac) {
nr_arena_item_add_child (ai, ac, ar);
ar = ac;
- nr_arena_item_unref (ac);
}
}
l = g_slist_remove (l, o);
}
}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :