[gnome-screenshot] screenshot: fall back to $HOME when saving into XDG_PICTURES_DIR fails



commit 7a67741093a5ea0229dd7e7bfae7032f625ee3bd
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 26 08:56:32 2012 -0400

    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

 src/screenshot-filename-builder.c |   18 +++++++++++++++---
 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;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]