summaryrefslogtreecommitdiff
path: root/src/screenshot-filename-builder.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-03-26 08:56:32 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-04-16 14:25:48 -0400
commit7a67741093a5ea0229dd7e7bfae7032f625ee3bd (patch)
tree185c831fa0b9a4b527d7499942015a54bb453f6c /src/screenshot-filename-builder.c
parenta30dc9ea08afaa1ea7e4a296321441455c6dce40 (diff)
downloadgnome-screenshot-7a67741093a5ea0229dd7e7bfae7032f625ee3bd.tar.gz
screenshot: fall back to $HOME when saving into XDG_PICTURES_DIR fails
As a last resort, save screenshots in $HOME when everything else fails. https://bugzilla.gnome.org/show_bug.cgi?id=672833
Diffstat (limited to 'src/screenshot-filename-builder.c')
-rw-r--r--src/screenshot-filename-builder.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/screenshot-filename-builder.c b/src/screenshot-filename-builder.c
index 92c7708..04bb75c 100644
--- a/src/screenshot-filename-builder.c
+++ b/src/screenshot-filename-builder.c
@@ -30,6 +30,7 @@ typedef enum
{
TEST_SAVED_DIR = 0,
TEST_DEFAULT,
+ TEST_FALLBACK,
NUM_TESTS
} TestType;
@@ -73,6 +74,16 @@ expand_initial_tilde (const char *path)
}
static gchar *
+get_fallback_screenshot_dir (void)
+{
+ gchar *shot_dir;
+
+ shot_dir = g_strconcat ("file://", g_get_home_dir (), NULL);
+
+ return shot_dir;
+}
+
+static gchar *
get_default_screenshot_dir (void)
{
gchar *shot_dir;
@@ -222,7 +233,7 @@ retry:
* accessible.
*/
g_free (uri);
- if (job->type == TEST_DEFAULT)
+ if (job->type == (NUM_TESTS - 1))
{
retval = NULL;
goto out;
@@ -265,8 +276,9 @@ screenshot_build_filename_async (GAsyncReadyCallback callback,
job = g_slice_new0 (AsyncExistenceJob);
- job->base_uris[0] = sanitize_save_directory (screenshot_config->save_dir);
- job->base_uris[1] = get_default_screenshot_dir ();
+ job->base_uris[TEST_SAVED_DIR] = sanitize_save_directory (screenshot_config->save_dir);
+ job->base_uris[TEST_DEFAULT] = get_default_screenshot_dir ();
+ job->base_uris[TEST_FALLBACK] = get_fallback_screenshot_dir ();
job->iteration = 0;
job->type = TEST_SAVED_DIR;