[totem/wip/hadess/save-file-fixes: 6/11] save-file: Split off helper to guess destination filename



commit 43358a9e8226d729db35b26d0da8651a56d1b007
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Feb 5 17:39:51 2019 +0100

    save-file: Split off helper to guess destination filename

 src/plugins/save-file/totem-save-file.c | 51 +++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 22 deletions(-)
---
diff --git a/src/plugins/save-file/totem-save-file.c b/src/plugins/save-file/totem-save-file.c
index b7aa4c90c..396a943dd 100644
--- a/src/plugins/save-file/totem-save-file.c
+++ b/src/plugins/save-file/totem-save-file.c
@@ -133,32 +133,25 @@ get_videos_dir (void)
        return videos_dir;
 }
 
-static void
-totem_save_file_plugin_copy (GSimpleAction       *action,
-                            GVariant            *parameter,
-                            TotemSaveFilePlugin *pi)
+static char *
+totem_save_file_get_filename (TotemSaveFilePlugin *pi)
 {
-       char *filename;
-
-       g_assert (pi->priv->mrl != NULL);
+       char *filename, *basename;
+       GFile *file;
 
-       if (pi->priv->name != NULL) {
-               filename = g_strdup (pi->priv->name);
-       } else {
-               GFile *file;
-               char *basename;
+       if (pi->priv->name != NULL)
+               return g_strdup (pi->priv->name);
 
-               /* Try to get a nice filename from the URI */
-               file = g_file_new_for_uri (pi->priv->mrl);
-               basename = g_file_get_basename (file);
-               g_object_unref (file);
+       /* Try to get a nice filename from the URI */
+       file = g_file_new_for_uri (pi->priv->mrl);
+       basename = g_file_get_basename (file);
+       g_object_unref (file);
 
-               if (g_utf8_validate (basename, -1, NULL) == FALSE) {
-                       g_free (basename);
-                       filename = NULL;
-               } else {
-                       filename = basename;
-               }
+       if (g_utf8_validate (basename, -1, NULL) == FALSE) {
+               g_free (basename);
+               filename = NULL;
+       } else {
+               filename = basename;
        }
 
        if (filename == NULL) {
@@ -167,6 +160,20 @@ totem_save_file_plugin_copy (GSimpleAction       *action,
                filename = g_strdup (_("Movie"));
        }
 
+       return filename;
+}
+
+static void
+totem_save_file_plugin_copy (GSimpleAction       *action,
+                            GVariant            *parameter,
+                            TotemSaveFilePlugin *pi)
+{
+       char *filename;
+
+       g_assert (pi->priv->mrl != NULL);
+
+       filename = totem_save_file_get_filename (pi);
+
        if (pi->priv->is_tmp) {
                char *dest_dir, *dest_name, *dest_path;
                char *src_path;


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