summaryrefslogtreecommitdiffstats
path: root/src/selection.cpp
diff options
context:
space:
mode:
authorAndrius Ramanauskas <knutux@gmail.com>2006-03-31 11:50:44 +0000
committerknutux <knutux@users.sourceforge.net>2006-03-31 11:50:44 +0000
commit70cbab466d2a3e414b3b75584f6ef0f2d8d2fcb5 (patch)
treea4a9893ff183ecb63275ed59195e91da54e76ccd /src/selection.cpp
parentcleanup: (sp_style_paint_clear): All callers were passing hunref=TRUE, unset=... (diff)
downloadinkscape-70cbab466d2a3e414b3b75584f6ef0f2d8d2fcb5.tar.gz
inkscape-70cbab466d2a3e414b3b75584f6ef0f2d8d2fcb5.zip
patch #1450307 - option for select all to work in layer with it's sub-layers:
* Replaced check-box in preferences with 3 radio buttons (in all document in current layer only, in current layer with sub-layers) * Altered "Select all" functionality to include objects in sub-layers (if preference is on) * Altered TAB functionality to include sub-layers (had to introduce "context layer" concept in Selection class - without it TAB'ing would end in deepest child, but it needs to return to parent on subsequent TAB key press) (bzr r380)
Diffstat (limited to 'src/selection.cpp')
-rw-r--r--src/selection.cpp49
1 files changed, 44 insertions, 5 deletions
diff --git a/src/selection.cpp b/src/selection.cpp
index 473a7202e..0b17eefe9 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -5,7 +5,9 @@
* Lauris Kaplinski <lauris@kaplinski.com>
* MenTaLguY <mental@rydia.net>
* bulia byak <buliabyak@users.sf.net>
+ * Andrius R. <knutux@gmail.com>
*
+ * Copyright (C) 2006 Andrius R.
* Copyright (C) 2004-2005 MenTaLguY
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2001-2002 Ximian, Inc.
@@ -36,6 +38,8 @@ Selection::Selection(SPDesktop *desktop) :
_reprs(NULL),
_items(NULL),
_desktop(desktop),
+ _selection_context(NULL),
+ _context_release_handler_id(0),
_flags(0),
_idle(0)
{
@@ -89,11 +93,40 @@ void Selection::_emitModified(guint flags) {
_modified_signal.emit(this, flags);
}
-void Selection::_emitChanged() {
+void Selection::_emitChanged(bool persist_selection_context/* = false */) {
+ if (persist_selection_context) {
+ if (NULL == _selection_context) {
+ _selection_context = desktop()->currentLayer();
+ sp_object_ref(_selection_context, NULL);
+ g_signal_connect(G_OBJECT(_selection_context), "release",
+ G_CALLBACK(&Selection::_releaseSelectionContext), this);
+ }
+ } else {
+ _releaseContext(_selection_context);
+ }
+
inkscape_selection_changed(this);
_changed_signal.emit(this);
}
+void
+Selection::_releaseSelectionContext(SPObject *obj, Selection *selection)
+{
+ selection->_releaseContext(obj);
+}
+
+void
+Selection::_releaseContext(SPObject *obj)
+{
+ if (NULL == _selection_context || _selection_context != obj)
+ return;
+
+ g_signal_handler_disconnect(G_OBJECT(_selection_context), _context_release_handler_id);
+ sp_object_unref(_selection_context, NULL);
+ _context_release_handler_id = 0;
+ _selection_context = NULL;
+}
+
void Selection::_invalidateCachedLists() {
g_slist_free(_items);
_items = NULL;
@@ -111,6 +144,12 @@ void Selection::_clear() {
}
}
+SPObject *Selection::activeContext() {
+ if (NULL != _selection_context)
+ return _selection_context;
+ return desktop()->currentLayer();
+ }
+
bool Selection::includes(SPObject *obj) const {
if (obj == NULL)
return FALSE;
@@ -120,7 +159,7 @@ bool Selection::includes(SPObject *obj) const {
return ( g_slist_find(_objs, obj) != NULL );
}
-void Selection::add(SPObject *obj) {
+void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) {
g_return_if_fail(obj != NULL);
g_return_if_fail(SP_IS_OBJECT(obj));
@@ -130,7 +169,7 @@ void Selection::add(SPObject *obj) {
_invalidateCachedLists();
_add(obj);
- _emitChanged();
+ _emitChanged(persist_selection_context);
}
void Selection::_add(SPObject *obj) {
@@ -152,9 +191,9 @@ void Selection::_add(SPObject *obj) {
*/
}
-void Selection::set(SPObject *object) {
+void Selection::set(SPObject *object, bool persist_selection_context) {
_clear();
- add(object);
+ add(object, persist_selection_context);
}
void Selection::toggle(SPObject *obj) {