Index: src/ui/dialog/layers.h =================================================================== --- src/ui/dialog/layers.h (revision 22775) +++ src/ui/dialog/layers.h (working copy) @@ -79,6 +79,8 @@ bool _rowSelectFunction( Glib::RefPtr const & model, Gtk::TreeModel::Path const & path, bool b ); + void _updateItemsSelected(Inkscape::Selection *selection); + void _updateLayer(SPObject *layer); bool _checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer); @@ -97,6 +99,9 @@ sigc::connection _addedConnection; sigc::connection _removedConnection; + // Hooked to item selection + sigc::connection _itemSelectionConnection; + // Internal sigc::connection _selectedConnection; Index: src/ui/dialog/layers.cpp =================================================================== --- src/ui/dialog/layers.cpp (revision 22775) +++ src/ui/dialog/layers.cpp (working copy) @@ -20,6 +20,7 @@ #include "desktop.h" #include "desktop-style.h" +#include "desktop-handles.h" #include "document.h" #include "helper/action.h" #include "inkscape.h" @@ -51,7 +52,8 @@ enum { COL_VISIBLE = 1, - COL_LOCKED + COL_LOCKED, + COL_SELECTED }; enum { @@ -284,6 +286,7 @@ add(_colVisible); add(_colLocked); add(_colLabel); + add(_colSelected); } virtual ~ModelColumns() {} @@ -291,6 +294,7 @@ Gtk::TreeModelColumn _colLabel; Gtk::TreeModelColumn _colVisible; Gtk::TreeModelColumn _colLocked; + Gtk::TreeModelColumn _colSelected; }; void LayersPanel::_updateLayer( SPObject *layer ) { @@ -311,6 +315,11 @@ stopGoing = true; } + // update the item selection state of the layers + row[_model->_colSelected] = _desktop ? + sp_desktop_selection(_desktop)->includes(row[_model->_colObject]) : + false; + return stopGoing; } @@ -384,6 +393,7 @@ row[_model->_colLabel] = child->label() ? child->label() : SP_OBJECT_ID(child); row[_model->_colVisible] = SP_IS_ITEM(child) ? !SP_ITEM(child)->isHidden() : false; row[_model->_colLocked] = SP_IS_ITEM(child) ? SP_ITEM(child)->isLocked() : false; + row[_model->_colSelected] = false; if ( target && child == target ) { _tree.expand_to_path( _store->get_path(iter) ); @@ -506,6 +516,23 @@ newValue? _("Lock layer") : _("Unlock layer")); } break; + + case COL_SELECTED: + { + bool newValue = !row[_model->_colSelected]; + row[_model->_colSelected] = newValue; + if (_desktop) { + // maybe sel->toggle() could be used too, if it doesn't get + // out of sync + Inkscape::Selection *sel = sp_desktop_selection(_desktop); + if (newValue) { + sel->add(row[_model->_colObject]); + } + else { + sel->remove(row[_model->_colObject]); + } + } + } } } } @@ -625,9 +652,19 @@ } int nameColNum = _tree.append_column_editable("Name", _model->_colLabel) - 1; - _tree.set_expander_column( *_tree.get_column(nameColNum) ); + Inkscape::UI::Widget::ImageToggler *selRenderer = manage( new Inkscape::UI::Widget::ImageToggler( + INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN) ); + int selectedColNum = _tree.append_column("sel", *selRenderer) - 1; + selRenderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); + selRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_SELECTED) ); + selRenderer->property_activatable() = true; + col = _tree.get_column(selectedColNum); + if ( col ) { + col->add_attribute( selRenderer->property_active(), _model->_colSelected ); + } + _compositeSettings.setSubject(&_subject); _selectedConnection = _tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_pushTreeSelectionToCurrent) ); @@ -752,6 +789,10 @@ } } +void LayersPanel::_updateItemsSelected(Inkscape::Selection */*selection*/) +{ + _updateLayer(0); +} void LayersPanel::setDesktop( SPDesktop* desktop ) { @@ -761,6 +802,7 @@ _layerChangedConnection.disconnect(); _layerUpdatedConnection.disconnect(); _changedConnection.disconnect(); + _itemSelectionConnection.disconnect(); if ( _mgr ) { _mgr = 0; } @@ -779,6 +821,9 @@ _changedConnection = _mgr->connectChanged( sigc::mem_fun(*this, &LayersPanel::_layersChanged) ); } + sp_desktop_selection(_desktop)->connectChanged( + sigc::mem_fun(*this, &LayersPanel::_updateItemsSelected) ); + _layersChanged(); } }