summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Dane <3689-jakedane@users.noreply.gitlab.gnome.org>2022-07-15 10:21:57 +0000
committerBastien Nocera <hadess@hadess.net>2022-08-18 10:43:21 +0200
commit4746e2854be614b1912b7d1d2e3576d9ab250b95 (patch)
tree728f7331dc1a466e90d8797a6db9b014de3f3166
parent3158cfb7cd5e239b14850b8228f11b4f47e6a450 (diff)
downloadtotem-4746e2854be614b1912b7d1d2e3576d9ab250b95.tar.gz
screenshot: Save screenshots into ~/Pictures/Screenshots
Same as GNOME Shell 42 uses. Fixes #529
-rw-r--r--data/org.gnome.totem.gschema.xml.in2
-rw-r--r--help/C/screenshot.page2
-rw-r--r--src/plugins/screenshot/screenshot-filename-builder.c3
-rw-r--r--src/plugins/screenshot/totem-screenshot-plugin.c6
-rw-r--r--src/totem-uri.c25
-rw-r--r--src/totem-uri.h2
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);