Commit d890608f authored by Marc Jeanmougin's avatar Marc Jeanmougin 👹

Enable autosaves by default, puts them in user cache dir

parent 0830f5ba
Pipeline #28372199 (#1393) passed with stages
in 55 minutes and 13 seconds
......@@ -19,6 +19,7 @@
#endif
#include <cerrno>
#include <unistd.h>
#include <map>
......@@ -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<SPDocument*,int>::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;
......
......@@ -352,7 +352,7 @@ static char const preferences_skeleton[] =
" </group>\n"
" <group id=\"forkgradientvectors\" value=\"1\"/>\n"
" <group id=\"iconrender\" named_nodelay=\"0\"/>\n"
" <group id=\"autosave\" enable=\"0\" interval=\"10\" path=\"\" max=\"10\"/>\n"
" <group id=\"autosave\" enable=\"1\" interval=\"10\" path=\"\" max=\"10\"/>\n"
" <group id=\"grids\""
" no_emphasize_when_zoomedout=\"0\">\n"
" <group id=\"xy\" "
......
......@@ -1339,12 +1339,12 @@ void InkscapePreferences::initPageIO()
this->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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment