From c2c37d3685d43545e3a0f623e563b85640aed80a Mon Sep 17 00:00:00 2001
From: Maximilian Albert <maximilian.albert@gmail.com>
Date: Thu, 17 Sep 2009 16:46:18 +0200
Subject: [PATCH] Add option to preferences to choose between current working dir and last used dir for 'Save As ...'

---
 src/extension/system.cpp               |    9 +++++++++
 src/ui/dialog/inkscape-preferences.cpp |   27 ++++++++++++++++-----------
 src/ui/dialog/inkscape-preferences.h   |   15 ++++++++-------
 3 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index 43e7af4..f412179 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -588,6 +588,15 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) {
     Glib::ustring path;
     switch (method) {
         case FILE_SAVE_METHOD_SAVE_AS:
+        {
+            bool use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir");
+            if (doc->uri && use_current_dir) {
+                path = Glib::path_get_dirname(doc->uri);
+            } else {
+                path = prefs->getString("/dialogs/save_as/path");
+            }
+            break;
+        }
         case FILE_SAVE_METHOD_TEMPORARY:
             path = prefs->getString("/dialogs/save_as/path");
             break;
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 3e202d6..00a995e 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -120,7 +120,7 @@ InkscapePreferences::InkscapePreferences()
     initPageCMS();
     initPageGrids();
     initPageSVGOutput();
-    initPageAutosave();
+    initPageSave();
     initPageImportExport();
     initPageMouse();
     initPageScrolling();
@@ -1109,19 +1109,24 @@ void InkscapePreferences::initPageUI()
 }
 
 
-void InkscapePreferences::initPageAutosave()
+void InkscapePreferences::initPageSave()
 {
+    _save_use_current_dir.init( _("Use current directory for \"Save As ...\""), "/dialogs/save_as/use_current_dir", true);
+    _page_save.add_line( false, "", _save_use_current_dir, "",
+                         _("When on, the \"Save As ...\" dialog uses the current working directory for saving (in case the file was already saved before so that this notion makes sense). Otherwise, the most recent \"Save As ...\" directory is used."), true);
+
+
     // Autosave options
-    _autosave_autosave_enable.init( _("Enable autosave (requires restart)"), "/options/autosave/enable", false);
-    _page_autosave.add_line(false, "", _autosave_autosave_enable, "", _("Automatically save the current document(s) at a given interval, thus minimizing loss in case of a crash"), false);
-    _autosave_autosave_interval.init("/options/autosave/interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false);
-    _page_autosave.add_line(true, _("Interval (in minutes):"), _autosave_autosave_interval, "", _("Interval (in minutes) at which document will be autosaved"), false);
-    _autosave_autosave_path.init("/options/autosave/path", true);
+    _save_autosave_enable.init( _("Enable autosave (requires restart)"), "/options/autosave/enable", false);
+    _page_save.add_line(false, "", _save_autosave_enable, "", _("Automatically save the current document(s) at a given interval, thus minimizing loss in case of a crash"), false);
+    _save_autosave_interval.init("/options/autosave/interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false);
+    _page_save.add_line(true, _("Interval (in minutes):"), _save_autosave_interval, "", _("Interval (in minutes) at which document will be autosaved"), false);
+    _save_autosave_path.init("/options/autosave/path", true);
     //TRANSLATORS: only translate "string" in "context|string".
     // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
-    _page_autosave.add_line(true, Q_("filesystem|Path:"), _autosave_autosave_path, "", _("The directory where autosaves will be written"), false);
-    _autosave_autosave_max.init("/options/autosave/max", 1.0, 100.0, 1.0, 10.0, 10.0, true, false);
-    _page_autosave.add_line(true, _("Maximum number of autosaves:"), _autosave_autosave_max, "", _("Maximum number of autosaved files; use this to limit the storage space used"), false);
+    _page_save.add_line(true, Q_("filesystem|Path:"), _save_autosave_path, "", _("The directory where autosaves will be written"), false);
+    _save_autosave_max.init("/options/autosave/max", 1.0, 100.0, 1.0, 10.0, 10.0, true, false);
+    _page_save.add_line(true, _("Maximum number of autosaves:"), _save_autosave_max, "", _("Maximum number of autosaved files; use this to limit the storage space used"), false);
 
     /* When changing the interval or enabling/disabling the autosave function,
      * update our running configuration
@@ -1137,7 +1142,7 @@ void InkscapePreferences::initPageAutosave()
 
     // -----------
 
-    this->AddPage(_page_autosave, _("Autosave"), PREFS_PAGE_AUTOSAVE);
+    this->AddPage(_page_save, _("Save"), PREFS_PAGE_SAVE);
 }
 
 void InkscapePreferences::initPageBitmaps()
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index aa0da3a..364b0eb 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -69,7 +69,7 @@ enum {
     PREFS_PAGE_CMS,
     PREFS_PAGE_GRIDS,
     PREFS_PAGE_SVGOUTPUT,
-    PREFS_PAGE_AUTOSAVE,
+    PREFS_PAGE_SAVE,
     PREFS_PAGE_IMPORTEXPORT,
     PREFS_PAGE_MOUSE,
     PREFS_PAGE_SCROLLING,
@@ -117,7 +117,7 @@ protected:
     DialogPage _page_mouse, _page_scrolling, _page_snapping, _page_steps, _page_tools, _page_windows,
         _page_clones, _page_mask, _page_transforms, _page_filters, _page_select,
         _page_importexport, _page_cms, _page_grids, _page_svgoutput, _page_misc,
-        _page_ui, _page_autosave, _page_bitmaps, _page_spellcheck;
+        _page_ui, _page_save, _page_bitmaps, _page_spellcheck;
     DialogPage _page_selector, _page_node, _page_tweak, _page_zoom, _page_shapes, _page_pencil, _page_pen,
                _page_calligraphy, _page_text, _page_gradient, _page_connector, _page_dropper, _page_lpetool;
     DialogPage _page_rectangle, _page_3dbox, _page_ellipse, _page_star, _page_spiral, _page_paintbucket, _page_eraser;
@@ -209,10 +209,11 @@ protected:
     PrefCheckButton _misc_bitmap_autoreload;
     PrefSpinButton  _bitmap_copy_res;
 
-    PrefCheckButton _autosave_autosave_enable;
-    PrefSpinButton  _autosave_autosave_interval;
-    PrefEntry       _autosave_autosave_path;
-    PrefSpinButton  _autosave_autosave_max;
+    PrefCheckButton _save_use_current_dir;
+    PrefCheckButton _save_autosave_enable;
+    PrefSpinButton  _save_autosave_interval;
+    PrefEntry       _save_autosave_path;
+    PrefSpinButton  _save_autosave_max;
 
     Gtk::ComboBoxText   _cms_display_profile;
     PrefCheckButton     _cms_from_display;
@@ -298,7 +299,7 @@ protected:
     void initPageSVGOutput();
     void initPageUI();
     void initPageSpellcheck();
-    void initPageAutosave();
+    void initPageSave();
     void initPageBitmaps();
     void initPageMisc();
     void initPageI18n();
-- 
1.6.0.4

