From: Jon A. Cruz Date: Sun, 25 Jul 2010 03:57:50 +0000 (-0700) Subject: Added preference to keep last selected item shown. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0103439eefd32684148364d995d32c769e68020d;p=inkscape.git Added preference to keep last selected item shown. --- diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 283960b80..e117e85a5 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -393,6 +393,7 @@ static char const preferences_skeleton[] = " \n" " \n" diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 7be667383..d3a28d96f 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -86,6 +86,7 @@ IconPreviewPanel::IconPreviewPanel() : document(0), timer(0), pending(false), + targetId(), hot(1), selectionButton(0), desktopChangeConn(), @@ -302,28 +303,33 @@ void IconPreviewPanel::refreshPreview() // Do not refresh too quickly queueRefresh(); } else if ( desktop ) { + bool hold = Inkscape::Preferences::get()->getBool("/iconpreview/selectionHold", false); if ( selectionButton && selectionButton->get_active() ) { - Inkscape::Selection * sel = sp_desktop_selection(desktop); - if ( sel ) { - //g_message("found a selection to play with"); - - GSList const *items = sel->itemList(); - SPObject *target = 0; - while ( items && !target ) { - SPItem* item = SP_ITEM( items->data ); - SPObject * obj = SP_OBJECT(item); - gchar const *id = obj->getId(); - if ( id ) { - target = obj; + SPObject *target = (hold && !targetId.empty()) ? desktop->doc()->getObjectById( targetId.c_str() ) : 0; + if ( !target ) { + targetId.clear(); + Inkscape::Selection * sel = sp_desktop_selection(desktop); + if ( sel ) { + //g_message("found a selection to play with"); + + GSList const *items = sel->itemList(); + while ( items && !target ) { + SPItem* item = SP_ITEM( items->data ); + SPObject * obj = SP_OBJECT(item); + gchar const *id = obj->getId(); + if ( id ) { + targetId = id; + target = obj; + } + + items = g_slist_next(items); } - - items = g_slist_next(items); - } - if ( target ) { - renderPreview(target); } } + if ( target ) { + renderPreview(target); + } } else { SPObject *target = desktop->currentRoot(); if ( target ) { @@ -362,7 +368,11 @@ void IconPreviewPanel::queueRefresh() void IconPreviewPanel::modeToggled() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool("/iconpreview/selectionOnly", (selectionButton && selectionButton->get_active())); + bool selectionOnly = (selectionButton && selectionButton->get_active()); + prefs->setBool("/iconpreview/selectionOnly", selectionOnly); + if ( !selectionOnly ) { + targetId.clear(); + } refreshPreview(); } diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h index 9de882569..0842c3c5e 100644 --- a/src/ui/dialog/icon-preview.h +++ b/src/ui/dialog/icon-preview.h @@ -68,6 +68,7 @@ private: Gtk::VBox iconBox; Gtk::HPaned splitter; + Glib::ustring targetId; int hot; int numEntries; int* sizes;