[totem] screenshot: Move screenshot dir code to screenshot plugin



commit 4e1097aa7267ef580678cacefe3cb2e5d2a61355
Author: Jake Dane <3689-jakedane users noreply gitlab gnome org>
Date:   Sun Jul 17 08:34:05 2022 +0000

    screenshot: Move screenshot dir code to screenshot plugin
    
    It wasn't used anywhere else in the codebase.

 .../screenshot/screenshot-filename-builder.c       | 27 +++++++++++++++++++---
 .../screenshot/screenshot-filename-builder.h       |  2 ++
 src/plugins/screenshot/totem-screenshot-plugin.c   |  4 ++--
 src/totem-uri.c                                    | 27 ----------------------
 src/totem-uri.h                                    |  1 -
 5 files changed, 28 insertions(+), 33 deletions(-)
---
diff --git a/src/plugins/screenshot/screenshot-filename-builder.c 
b/src/plugins/screenshot/screenshot-filename-builder.c
index 99056d487..778a5dfc0 100644
--- a/src/plugins/screenshot/screenshot-filename-builder.c
+++ b/src/plugins/screenshot/screenshot-filename-builder.c
@@ -76,16 +76,37 @@ expand_initial_tilde (const char *path)
                       NULL);
 }
 
-static gchar *
+gchar *
 get_fallback_screenshot_dir (void)
 {
   return g_strdup (g_get_home_dir ());
 }
 
-static gchar *
+gchar *
 get_default_screenshot_dir (void)
 {
-  return totem_screenshots_dir ();
+  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 gchar *
diff --git a/src/plugins/screenshot/screenshot-filename-builder.h 
b/src/plugins/screenshot/screenshot-filename-builder.h
index 5543fccc7..bd554aca2 100644
--- a/src/plugins/screenshot/screenshot-filename-builder.h
+++ b/src/plugins/screenshot/screenshot-filename-builder.h
@@ -25,6 +25,8 @@
 
 #include <gio/gio.h>
 
+gchar *get_fallback_screenshot_dir (void);
+gchar *get_default_screenshot_dir (void);
 void screenshot_build_filename_async (const char *save_dir,
                                       const char *screenshot_origin,
                                       GAsyncReadyCallback callback,
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c 
b/src/plugins/screenshot/totem-screenshot-plugin.c
index aad7cd710..671dd27c9 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -401,10 +401,10 @@ totem_screenshot_plugin_setup_file_chooser (const char *filename_format, const c
        /* Default to the Screenshots directory */
        if (*path == '\0') {
                g_free (path);
-               path = totem_screenshots_dir ();
+               path = get_default_screenshot_dir ();
                /* No Screenshots dir, then it's the home dir */
                if (path == NULL)
-                       path = g_strdup (g_get_home_dir ());
+                       path = get_fallback_screenshot_dir ();
        }
 
        filename = make_filename_for_dir (path, filename_format, movie_title);
diff --git a/src/totem-uri.c b/src/totem-uri.c
index e37c7f81e..d8518920b 100644
--- a/src/totem-uri.c
+++ b/src/totem-uri.c
@@ -97,33 +97,6 @@ totem_data_dot_dir (void)
        return (const char *)totem_dir;
 }
 
-char *
-totem_screenshots_dir (void)
-{
-       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 *
 totem_get_mount_for_uri (const char *path)
 {
diff --git a/src/totem-uri.h b/src/totem-uri.h
index d4b4cef43..ce33fbbb9 100644
--- a/src/totem-uri.h
+++ b/src/totem-uri.h
@@ -28,7 +28,6 @@
 
 const char *   totem_dot_dir                   (void);
 const char *   totem_data_dot_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]