[Xfce4-commits] <xfce4-screenshooter:master> Use the XDG pictures directory as the default save location.

Jérôme Guelfucci jeromeg at xfce.org
Fri Aug 14 00:26:19 CEST 2009


Updating branch refs/heads/master
         to c5ad669c42f554b4f0d1b7fbd00817cb8627b605 (commit)
       from 28f2d4297e70799ff745f7796c3c7a3feeaf4194 (commit)

commit c5ad669c42f554b4f0d1b7fbd00817cb8627b605
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Sat Aug 8 19:38:28 2009 +0200

    Use the XDG pictures directory as the default save location.
    
    If it does not exist, use the home directory as a fallback.

 ChangeLog                   |    6 ++++++
 TODO                        |    2 --
 lib/screenshooter-actions.c |    2 +-
 lib/screenshooter-utils.c   |   22 +++++++++++++++++++---
 lib/screenshooter-utils.h   |   27 ++++++++++++++-------------
 src/main.c                  |    6 ------
 6 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index db86861..f0aed25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-08-08 jeromeg
 
+Use the XDG pictures directory as the default save location.
+
+If it does not exist, use the home directory as a fallback.
+
+2009-08-08 jeromeg
+
 Remove the horodate checkbox and title entry.
 
 Try to set some sane defaults: always append the date and the time to
diff --git a/TODO b/TODO
index 86238ea..c0bffe2 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 Before next release:
 
-* Save captures in the XDG images directory by default, fallback to home
-if it does not exist.
 * Port "select a region" to use cairo to have transparent rubber banding
 as in thunar and xfdesktop (only when the screen is composited).
 
diff --git a/lib/screenshooter-actions.c b/lib/screenshooter-actions.c
index 839cf70..ebf45bc 100644
--- a/lib/screenshooter-actions.c
+++ b/lib/screenshooter-actions.c
@@ -81,7 +81,7 @@ gboolean screenshooter_action_idle (ScreenshotData *sd)
   if (sd->action == SAVE)
     {
       if (sd->screenshot_dir == NULL)
-        sd->screenshot_dir = screenshooter_get_home_uri ();
+        sd->screenshot_dir = screenshooter_get_xdg_image_dir_uri ();
 
       screenshooter_save_screenshot (sd->screenshot,
                                      sd->screenshot_dir,
diff --git a/lib/screenshooter-utils.c b/lib/screenshooter-utils.c
index a1fc665..9596567 100644
--- a/lib/screenshooter-utils.c
+++ b/lib/screenshooter-utils.c
@@ -54,7 +54,7 @@ screenshooter_copy_to_clipboard (GdkPixbuf *screenshot)
 void
 screenshooter_read_rc_file (const gchar *file, ScreenshotData *sd)
 {
-  const gchar *home_uri = screenshooter_get_home_uri ();
+  const gchar *default_uri = screenshooter_get_xdg_image_dir_uri ();
 
   XfceRc *rc;
   gint delay = 0;
@@ -62,7 +62,7 @@ screenshooter_read_rc_file (const gchar *file, ScreenshotData *sd)
   gint action = SAVE;
   gint show_mouse = 1;
   gboolean horodate = FALSE;
-  gchar *screenshot_dir = g_strdup (home_uri);
+  gchar *screenshot_dir = g_strdup (default_uri);
   gchar *title = g_strdup ("Screenshot");
   gchar *app = g_strdup ("none");
   gchar *last_user = g_strdup ("");
@@ -91,7 +91,7 @@ screenshooter_read_rc_file (const gchar *file, ScreenshotData *sd)
 
           g_free (screenshot_dir);
           screenshot_dir =
-            g_strdup (xfce_rc_read_entry (rc, "screenshot_dir", home_uri));
+            g_strdup (xfce_rc_read_entry (rc, "screenshot_dir", default_uri));
 
           g_free (title);
           title = g_strdup (xfce_rc_read_entry (rc, "title", "Screenshot"));
@@ -205,6 +205,22 @@ gchar *screenshooter_get_home_uri (void)
 
 
 
+gchar *screenshooter_get_xdg_image_dir_uri (void)
+{
+  gchar *result, *tmp;
+
+  tmp = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES));
+
+  if (tmp == NULL)
+    return screenshooter_get_home_uri ();
+
+  result = g_strconcat ("file://", tmp, NULL);
+  g_free (tmp);
+
+  return result;
+}
+
+
 gboolean screenshooter_is_remote_uri (const gchar *uri)
 {
   g_return_val_if_fail(uri != NULL, FALSE);
diff --git a/lib/screenshooter-utils.h b/lib/screenshooter-utils.h
index 2fd368f..d32933f 100644
--- a/lib/screenshooter-utils.h
+++ b/lib/screenshooter-utils.h
@@ -35,19 +35,20 @@
 
 
 
-void screenshooter_copy_to_clipboard (GdkPixbuf      *screenshot) ;
-void screenshooter_read_rc_file      (const gchar    *file,
-                                      ScreenshotData *sd);
-void screenshooter_write_rc_file     (const gchar    *file,
-                                      ScreenshotData *sd);
-void screenshooter_open_screenshot   (const gchar    *screenshot_path,
-                                      const gchar    *application);
-gchar *screenshooter_get_home_uri    ();
-gboolean screenshooter_is_remote_uri (const gchar    *uri);
-gchar *rot13                         (gchar          *string);
-void screenshooter_error             (const gchar    *format,
-                                      ...);
-gchar *screenshooter_get_date_hour   (void);
+void screenshooter_copy_to_clipboard       (GdkPixbuf      *screenshot);
+void screenshooter_read_rc_file            (const gchar    *file,
+                                            ScreenshotData *sd);
+void screenshooter_write_rc_file           (const gchar    *file,
+                                            ScreenshotData *sd);
+void screenshooter_open_screenshot         (const gchar    *screenshot_path,
+                                            const gchar    *application);
+gchar *screenshooter_get_home_uri          (void);
+gchar *screenshooter_get_xdg_image_dir_uri (void);
+gboolean screenshooter_is_remote_uri       (const gchar    *uri);
+gchar *rot13                               (gchar          *string);
+void screenshooter_error                   (const gchar    *format,
+                                            ...);
+gchar *screenshooter_get_date_hour         (void);
 
 
 #endif
diff --git a/src/main.c b/src/main.c
index dbd8afe..6f829d5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -290,12 +290,6 @@ int main (int argc, char **argv)
           g_object_unref (default_save_dir);
           g_free (screenshot_dir);
         }
-      /* Else we fallback to the home directory */
-      else
-        {
-          g_free (sd->screenshot_dir);
-          sd->screenshot_dir = screenshooter_get_home_uri ();
-        }
 
       g_idle_add ((GSourceFunc) screenshooter_take_screenshot_idle, sd);
     }



More information about the Xfce4-commits mailing list