summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c91b3a6)
raw | patch | inline | side by side (parent: c91b3a6)
author | joncruz <joncruz@users.sourceforge.net> | |
Fri, 26 May 2006 07:10:40 +0000 (07:10 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Fri, 26 May 2006 07:10:40 +0000 (07:10 +0000) |
ChangeLog | patch | blob | history | |
src/layer-manager.cpp | patch | blob | history | |
src/layer-manager.h | patch | blob | history | |
src/widgets/layer-selector.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 394ac602e21992a5d0997e05c16aef2e7c79e899..722f97376b2802d11680ee1df20f907a2bce59c5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-05-26 Jon A. Cruz <jon@joncruz.org>
+
+ * src/layer-manager.cpp, src/layer-manager.h,
+ src/widgets/layer-selector.cpp:
+
+ Cleaned up propagation of status changes.
+ Fixes bug #1495333.
+
2006-05-26 Michael Wybrow <mjwybrow@users.sourceforge.net>
* src/path-prefix.h: Add missing CREATE_* directory locations
diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp
index ab2dff10762028c4244684fedfddc6c4e45936c0..840d123800cf98c3453582121a290863a229e321 100644 (file)
--- a/src/layer-manager.cpp
+++ b/src/layer-manager.cpp
#include "ui/view/view.h"
#include "sp-object.h"
#include "xml/node.h"
+#include "xml/node-observer.h"
namespace Inkscape {
+
+using Inkscape::XML::Node;
+
+class LayerManager::LayerWatcher : public Inkscape::XML::NodeObserver {
+public:
+ LayerWatcher(LayerManager* mgr, SPObject* obj) :
+ _mgr(mgr),
+ _obj(obj),
+ _lockedAttr(g_quark_from_string("sodipodi:insensitive")),
+ _labelAttr(g_quark_from_string("inkscape:label"))
+ {}
+
+ virtual void notifyChildAdded( Node &node, Node &child, Node *prev ) {}
+ virtual void notifyChildRemoved( Node &node, Node &child, Node *prev ) {}
+ virtual void notifyChildOrderChanged( Node &node, Node &child, Node *old_prev, Node *new_prev ) {}
+ virtual void notifyContentChanged( Node &node, Util::ptr_shared<char> old_content, Util::ptr_shared<char> new_content ) {}
+ virtual void notifyAttributeChanged( Node &node, GQuark name, Util::ptr_shared<char> old_value, Util::ptr_shared<char> new_value ) {
+ if ( name == _lockedAttr || name == _labelAttr ) {
+ if ( _mgr && _obj ) {
+ _mgr->_objectModified( _obj, 0 );
+ }
+ }
+ }
+
+ LayerManager* _mgr;
+ SPObject* _obj;
+ GQuark _lockedAttr;
+ GQuark _labelAttr;
+};
+
+
LayerManager::LayerManager(SPDesktop *desktop)
: _desktop(desktop), _document(NULL)
{
}
void LayerManager::_rebuild() {
+ while ( !_watchers.empty() ) {
+ LayerWatcher* one = _watchers.back();
+ _watchers.pop_back();
+ if ( one->_obj ) {
+ Node* node = SP_OBJECT_REPR(one->_obj);
+ if ( node ) {
+ node->removeObserver(*one);
+ }
+ }
+ }
+
_clear();
+
GSList const *layers=sp_document_get_resource_list(_document, "layer");
SPObject *root=_desktop->currentRoot();
if ( root ) {
while ( higher && (SP_OBJECT_PARENT(higher) != root) ) {
higher = SP_OBJECT_PARENT(higher);
}
- Inkscape::XML::Node* node = higher ? SP_OBJECT_REPR(higher) : 0;
+ Node* node = higher ? SP_OBJECT_REPR(higher) : 0;
if ( node && node->parent() ) {
g_signal_connect( G_OBJECT(curr), "modified", G_CALLBACK( _objectModifiedCB ), this );
+ LayerWatcher* eye = new LayerWatcher(this, curr);
+ _watchers.push_back( eye );
+ SP_OBJECT_REPR(curr)->addObserver(*eye);
+
_addOne(curr);
}
}
diff --git a/src/layer-manager.h b/src/layer-manager.h
index b4d827089ce0238d401289c92d22be649a21f5db..d92946a4c3af0660a1db5b002d71571255de83cc 100644 (file)
--- a/src/layer-manager.h
+++ b/src/layer-manager.h
#include "document-subset.h"
#include "gc-finalized.h"
#include "gc-soft-ptr.h"
+#include <vector>
class SPDesktop;
class SPDocument;
}
private:
+ friend class LayerWatcher;
+ class LayerWatcher;
+
static void _objectModifiedCB( SPObject* obj, guint flags, LayerManager* mgr );
void _objectModified( SPObject* obj, guint flags );
GC::soft_ptr<SPDesktop> _desktop;
SPDocument *_document;
+ std::vector<LayerWatcher*> _watchers;
+
sigc::signal<void, SPObject *> _layer_changed_signal;
sigc::signal<void, SPObject *> _details_changed_signal;
};
index 8fe0c928e73da187c9a086efe4eab5be704bfa98..bf23dcfcac1bbad8d03eccbf621bb6557f59f686 100644 (file)
_visibility_toggled_connection.block(true);
_lock_toggled_connection.block(true);
slot();
+
+ SPObject *layer = _desktop ? _desktop->currentLayer() : 0;
+ if ( layer ) {
+ bool wantedValue = ( SP_IS_ITEM(layer) ? SP_ITEM(layer)->isLocked() : false );
+ if ( _lock_toggle.get_active() != wantedValue ) {
+ _lock_toggle.set_active( wantedValue );
+ }
+ wantedValue = ( SP_IS_ITEM(layer) ? SP_ITEM(layer)->isHidden() : false );
+ if ( _visibility_toggle.get_active() != wantedValue ) {
+ _visibility_toggle.set_active( wantedValue );
+ }
+ }
_visibility_toggled_connection.block(visibility_blocked);
_lock_toggled_connection.block(lock_blocked);
}