From a06c4627fac215a02736eeaa7b2f0c29e3757850 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 21 May 2006 15:58:09 +0000 Subject: Adding notification when managed layers change. (bzr r917) --- src/dialogs/layers-panel.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/dialogs/layers-panel.cpp') diff --git a/src/dialogs/layers-panel.cpp b/src/dialogs/layers-panel.cpp index 0ee6ac7e7..21b3102ef 100644 --- a/src/dialogs/layers-panel.cpp +++ b/src/dialogs/layers-panel.cpp @@ -350,6 +350,27 @@ public: Gtk::TreeModelColumn _colLocked; }; +void LayersPanel::_updateLayer( SPObject *layer ) { + _store->foreach( sigc::bind(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 ) { @@ -705,6 +726,7 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) { if ( desktop != _desktop ) { _layerChangedConnection.disconnect(); + _layerUpdatedConnection.disconnect(); _changedConnection.disconnect(); if ( _mgr ) { _mgr = 0; @@ -715,13 +737,13 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) _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(); -- cgit v1.2.3