[totem] screenshot: Save screenshots into ~/Pictures/Screenshots



commit 4746e2854be614b1912b7d1d2e3576d9ab250b95
Author: Jake Dane <3689-jakedane users noreply gitlab gnome org>
Date:   Fri Jul 15 10:21:57 2022 +0000

    screenshot: Save screenshots into ~/Pictures/Screenshots
    
    Same as GNOME Shell 42 uses.
    
    Fixes #529

 data/org.gnome.totem.gschema.xml.in                |  2 +-
 help/C/screenshot.page                             |  2 +-
 .../screenshot/screenshot-filename-builder.c       |  3 ++-
 src/plugins/screenshot/totem-screenshot-plugin.c   |  6 +++---
 src/totem-uri.c                                    | 25 ++++++++++++++++++++--
 src/totem-uri.h                                    |  2 +-
 6 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/data/org.gnome.totem.gschema.xml.in b/data/org.gnome.totem.gschema.xml.in
index bc9c68dfe..abd21384e 100644
--- a/data/org.gnome.totem.gschema.xml.in
+++ b/data/org.gnome.totem.gschema.xml.in
@@ -58,7 +58,7 @@
                <key name="screenshot-save-uri" type="s">
                        <default>''</default>
                        <summary>Default location for the “Take Screenshot” dialogs</summary>
-                       <description>Default location for the “Take Screenshot” dialogs. Default is the 
Pictures directory.</description>
+                       <description>Default location for the “Take Screenshot” dialogs. Default is the 
Screenshots directory.</description>
                </key>
                <key name="disable-user-plugins" type="b">
                        <default>false</default>
diff --git a/help/C/screenshot.page b/help/C/screenshot.page
index a66469edb..d53658d95 100644
--- a/help/C/screenshot.page
+++ b/help/C/screenshot.page
@@ -34,7 +34,7 @@
   </steps>
 
   <note>
-    <p>Your screenshot will be saved in your <gui>Pictures</gui> folder under
+    <p>Your screenshot will be saved in your <gui>Screenshots</gui> folder under
     the name <file>Screenshot from Name-of-the-Video.png</file>.</p>
   </note>
 
diff --git a/src/plugins/screenshot/screenshot-filename-builder.c 
b/src/plugins/screenshot/screenshot-filename-builder.c
index 49f9dda64..99056d487 100644
--- a/src/plugins/screenshot/screenshot-filename-builder.c
+++ b/src/plugins/screenshot/screenshot-filename-builder.c
@@ -28,6 +28,7 @@
 #include <string.h>
 
 #include "screenshot-filename-builder.h"
+#include "totem-uri.h"
 
 typedef enum
 {
@@ -84,7 +85,7 @@ get_fallback_screenshot_dir (void)
 static gchar *
 get_default_screenshot_dir (void)
 {
-  return g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES));
+  return totem_screenshots_dir ();
 }
 
 static gchar *
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c 
b/src/plugins/screenshot/totem-screenshot-plugin.c
index a47ced57e..aad7cd710 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -398,11 +398,11 @@ totem_screenshot_plugin_setup_file_chooser (const char *filename_format, const c
        path = g_settings_get_string (settings, "screenshot-save-uri");
        g_object_unref (settings);
 
-       /* Default to the Pictures directory */
+       /* Default to the Screenshots directory */
        if (*path == '\0') {
                g_free (path);
-               path = totem_pictures_dir ();
-               /* No pictures dir, then it's the home dir */
+               path = totem_screenshots_dir ();
+               /* No Screenshots dir, then it's the home dir */
                if (path == NULL)
                        path = g_strdup (g_get_home_dir ());
        }
diff --git a/src/totem-uri.c b/src/totem-uri.c
index 2eb7f67e7..e37c7f81e 100644
--- a/src/totem-uri.c
+++ b/src/totem-uri.c
@@ -98,9 +98,30 @@ totem_data_dot_dir (void)
 }
 
 char *
-totem_pictures_dir (void)
+totem_screenshots_dir (void)
 {
-       return g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES));
+       const char *special_dir = NULL;
+       char *screenshots_dir = NULL;
+       g_autoptr(GFile) file = NULL;
+       gboolean ret;
+       g_autoptr(GError) error = NULL;
+
+       special_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
+       if (special_dir == NULL)
+               return NULL;
+
+       /* Translators: "Screenshots" is the name of the folder under ~/Pictures for screenshots,
+        * same as used in GNOME Shell:
+        * https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/gnome-42/js/ui/screenshot.js#L2072 */
+       screenshots_dir = g_build_filename (special_dir, _("Screenshots"), NULL);
+
+       /* ensure that the "Screenshots" folder exists */
+       file = g_file_new_for_path (screenshots_dir);
+       ret = g_file_make_directory_with_parents (file, NULL, &error);
+       if (!ret && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+               g_clear_pointer (&screenshots_dir, g_free);
+
+       return screenshots_dir;
 }
 
 static GMount *
diff --git a/src/totem-uri.h b/src/totem-uri.h
index b5aef7833..d4b4cef43 100644
--- a/src/totem-uri.h
+++ b/src/totem-uri.h
@@ -28,7 +28,7 @@
 
 const char *   totem_dot_dir                   (void);
 const char *   totem_data_dot_dir              (void);
-char *         totem_pictures_dir              (void);
+char *         totem_screenshots_dir           (void);
 char *         totem_create_full_path          (const char *path);
 GMount *       totem_get_mount_for_media       (const char *uri);
 gboolean       totem_playing_dvd               (const char *uri);


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