From d890608fa0adbafbb70f71df0f7fb076eaf35b44 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 21 Aug 2018 18:15:32 +0200 Subject: Enable autosaves by default, puts them in user cache dir --- src/inkscape.cpp | 7 +++++-- src/preferences-skeleton.h | 2 +- src/ui/dialog/inkscape-preferences.cpp | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 05b5aeec1..67bedb1f8 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -19,6 +19,7 @@ #endif #include +#include #include @@ -212,7 +213,7 @@ int Application::autosave() if (!tmp.empty()) { autosave_dir = tmp; } else { - autosave_dir = Glib::get_tmp_dir(); + autosave_dir = Glib::build_filename(Glib::get_user_cache_dir(), "inkscape"); } } @@ -239,6 +240,7 @@ int Application::autosave() gint autosave_max = prefs->getInt("/options/autosave/max", 10); gint docnum = 0; + int pid = ::getpid(); SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Autosaving documents...")); for (std::map::iterator iter = _document_set.begin(); @@ -251,6 +253,7 @@ int Application::autosave() Inkscape::XML::Node *repr = doc->getReprRoot(); + if (doc->isModifiedSinceSave()) { gchar *oldest_autosave = nullptr; const gchar *filename = nullptr; @@ -296,7 +299,7 @@ int Application::autosave() // Set the filename we will actually save to g_free(baseName); - baseName = g_strdup_printf("inkscape-autosave-%d-%s-%03d.svg", uid, sptstr, docnum); + baseName = g_strdup_printf("inkscape-autosave-%d-%d-%s-%03d.svg", uid, pid, sptstr, docnum); gchar* full_path = g_build_filename(autosave_dir.c_str(), baseName, NULL); g_free(baseName); baseName = nullptr; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index c9479e90e..2fb76923c 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -352,7 +352,7 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" -" \n" +" \n" " \n" " AddPage(_page_cms, _("Color management"), iter_io, PREFS_PAGE_IO_CMS); // Autosave options - _save_autosave_enable.init( _("Enable autosave (requires restart)"), "/options/autosave/enable", false); + _save_autosave_enable.init( _("Enable autosave (requires restart)"), "/options/autosave/enable", true); _page_autosave.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_path.init("/options/autosave/path", true); if (prefs->getString("/options/autosave/path").empty()) { // Show the default fallback "tmp dir" if autosave path is not set. - _save_autosave_path.set_text(Glib::get_tmp_dir()); + _save_autosave_path.set_text(Glib::build_filename(Glib::get_user_cache_dir(), "inkscape")); } _page_autosave.add_line(false, C_("Filesystem", "Autosave _directory:"), _save_autosave_path, "", _("The directory where autosaves will be written. This should be an absolute path (starts with / on UNIX or a drive letter such as C: on Windows). "), false); _save_autosave_interval.init("/options/autosave/interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false); @@ -2238,7 +2238,7 @@ void InkscapePreferences::initPageSystem() Glib::ustring tmp_dir = prefs->getString("/options/autosave/path"); if (tmp_dir.empty()) { - tmp_dir = Glib::get_tmp_dir(); + tmp_dir = Glib::build_filename(Glib::get_user_cache_dir(), "inkscape"); } _sys_tmp_files.set_text(tmp_dir); _sys_tmp_files.set_editable(false); -- cgit v1.2.3