Code

Option to keep selection when changing layers
[inkscape.git] / src / layer-manager.cpp
index 81e8698b05f083a537a4e95f7c7fd4d9e236247c..e2e40340f6dff1d4d94e3594eba369429aa21585 100644 (file)
 #include "gc-finalized.h"
 #include "document.h"
 #include "desktop.h"
+#include "desktop-handles.h"
 #include "layer-manager.h"
+#include "prefs-utils.h"
 #include "ui/view/view.h"
+#include "selection.h"
 #include "sp-object.h"
 #include "xml/node.h"
 #include "xml/node-observer.h"
@@ -70,6 +73,15 @@ LayerManager::LayerManager(SPDesktop *desktop)
 }
 
 
+void LayerManager::setCurrentLayer( SPObject* obj )
+{
+    _desktop->setCurrentLayer( obj );
+
+    if ( prefs_get_int_attribute_limited("options.selection", "layerdeselect", 1, 0, 1) ) {
+        sp_desktop_selection( _desktop )->clear();
+    }
+}
+
 void LayerManager::renameLayer( SPObject* obj, gchar const *label )
 {
     Glib::ustring incoming( label ? label : "" );