summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2fb33ea)
raw | patch | inline | side by side (parent: 2fb33ea)
author | joncruz <joncruz@users.sourceforge.net> | |
Sun, 21 May 2006 15:58:09 +0000 (15:58 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sun, 21 May 2006 15:58:09 +0000 (15:58 +0000) |
diff --git a/ChangeLog b/ChangeLog
index 8b601381e65e6d856c0ec60ad7108bd10950afb2..f14540efc43b09eb2de33d7b76e117ef5a529f56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-05-21 Jon A. Cruz <jon@joncruz.org>
+
+ * src/layer-manager.cpp, src/layer-manager.h,
+ src/dialogs/layers-panel.cpp, src/dialogs/layers-panel.h:
+ Adding notification when managed layers change.
+
2006-05-21 Michael Wybrow <mjwybrow@users.sourceforge.net>
* src/extension/internal/pdf.cpp: Compilation fix. For versions
index 0ee6ac7e7191ef8a2f84cd4d6d30038e722ed20e..21b3102eff88105ffe162c21a636bb800013bc58 100644 (file)
Gtk::TreeModelColumn<bool> _colLocked;
};
+void LayersPanel::_updateLayer( SPObject *layer ) {
+ _store->foreach( sigc::bind<SPObject*>(sigc::mem_fun(*this, &LayersPanel::_checkForUpdated), layer) );
+}
+
+bool LayersPanel::_checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer)
+{
+ bool stopGoing = false;
+ Gtk::TreeModel::Row row = *iter;
+ Glib::ustring tmp = row[_model->_colLabel];
+ if ( layer == row[_model->_colObject] )
+ {
+ row[_model->_colLabel] = layer->label() ? layer->label() : SP_OBJECT_ID(layer);
+ row[_model->_colVisible] = SP_IS_ITEM(layer) ? !SP_ITEM(layer)->isHidden() : false;
+ row[_model->_colLocked] = SP_IS_ITEM(layer) ? SP_ITEM(layer)->isLocked() : false;
+
+ stopGoing = true;
+ }
+
+ return stopGoing;
+}
+
void LayersPanel::_selectLayer( SPObject *layer ) {
if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->root)) ) {
if ( _tree.get_selection()->count_selected_rows() != 0 ) {
{
if ( desktop != _desktop ) {
_layerChangedConnection.disconnect();
+ _layerUpdatedConnection.disconnect();
_changedConnection.disconnect();
if ( _mgr ) {
_mgr = 0;
_desktop = SP_ACTIVE_DESKTOP;
if ( _desktop ) {
- _layerChangedConnection = _desktop->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) );
-
setLabel( _desktop->doc()->name );
_mgr = _desktop->layer_manager;
if ( _mgr ) {
- _mgr->connectChanged( sigc::mem_fun(*this, &LayersPanel::_layersChanged) );
+ _layerChangedConnection = _mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) );
+ _layerUpdatedConnection = _mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) );
+ _changedConnection = _mgr->connectChanged( sigc::mem_fun(*this, &LayersPanel::_layersChanged) );
}
_layersChanged();
index bdfab6b29d29a4075138a13008d1e99c3e486d6b..f7a9f079959050e7cfc299e74418b4580d211c6b 100644 (file)
void _takeAction( int val );
bool _executeAction();
+ void _updateLayer(SPObject *layer);
+ bool _checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer);
+
void _selectLayer(SPObject *layer);
bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPObject* layer);
SPObject* _selectedLayer();
- // Hooked to the desktop:
- sigc::connection _layerChangedConnection;
-
// Hooked to the layer manager:
+ sigc::connection _layerChangedConnection;
+ sigc::connection _layerUpdatedConnection;
sigc::connection _changedConnection;
sigc::connection _addedConnection;
sigc::connection _removedConnection;
diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp
index c2999f6c80c4bc2ea925ee65a12f0239fb7f0775..ab2dff10762028c4244684fedfddc6c4e45936c0 100644 (file)
--- a/src/layer-manager.cpp
+++ b/src/layer-manager.cpp
LayerManager::LayerManager(SPDesktop *desktop)
: _desktop(desktop), _document(NULL)
{
-// _layer_connection = desktop->connectCurrentLayerChanged( sigc::hide<0>( sigc::mem_fun(*this, &LayerManager::_rebuild) ) );
+ _layer_connection = desktop->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayerManager::_selectedLayerChanged) );
sigc::bound_mem_functor1<void, Inkscape::LayerManager, SPDocument*> first = sigc::mem_fun(*this, &LayerManager::_setDocument);
_rebuild();
}
+
+void LayerManager::_objectModifiedCB( SPObject* obj, guint flags, LayerManager* mgr )
+{
+ mgr->_objectModified( obj, flags );
+}
+
+void LayerManager::_objectModified( SPObject* obj, guint flags )
+{
+ _details_changed_signal.emit( obj );
+}
+
void LayerManager::_rebuild() {
_clear();
GSList const *layers=sp_document_get_resource_list(_document, "layer");
}
Inkscape::XML::Node* node = higher ? SP_OBJECT_REPR(higher) : 0;
if ( node && node->parent() ) {
+ g_signal_connect( G_OBJECT(curr), "modified", G_CALLBACK( _objectModifiedCB ), this );
+
_addOne(curr);
}
}
}
}
+// Connected to the desktop's CurrentLayerChanged signal
+void LayerManager::_selectedLayerChanged(SPObject *layer)
+{
+ // notify anyone who's listening to this instead of directly to the desktop
+ _layer_changed_signal.emit(layer);
+}
+
}
/*
diff --git a/src/layer-manager.h b/src/layer-manager.h
index 48ef73c73585de665f2c85dd1f55c3698010a235..b4d827089ce0238d401289c92d22be649a21f5db 100644 (file)
--- a/src/layer-manager.h
+++ b/src/layer-manager.h
public:
LayerManager(SPDesktop *desktop);
+ sigc::connection connectCurrentLayerChanged(const sigc::slot<void, SPObject *> & slot) {
+ return _layer_changed_signal.connect(slot);
+ }
+
+ sigc::connection connectLayerDetailsChanged(const sigc::slot<void, SPObject *> & slot) {
+ return _details_changed_signal.connect(slot);
+ }
+
private:
+ static void _objectModifiedCB( SPObject* obj, guint flags, LayerManager* mgr );
+ void _objectModified( SPObject* obj, guint flags );
void _setDocument(SPDocument *document);
void _rebuild();
+ void _selectedLayerChanged(SPObject *layer);
sigc::connection _layer_connection;
sigc::connection _document_connection;
GC::soft_ptr<SPDesktop> _desktop;
SPDocument *_document;
+
+ sigc::signal<void, SPObject *> _layer_changed_signal;
+ sigc::signal<void, SPObject *> _details_changed_signal;
};
}