[totem/wip/hadess/screenshot-slash] screenshot: Remove '/' in screenshot filenames




commit a9636c580cecfcbe8bfa02d0f9e7ac0bbd257e9d
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Aug 20 13:41:38 2020 +0200

    screenshot: Remove '/' in screenshot filenames
    
    Make sure we don't use a slash in the pattern for screenshots or we
    wouldn't be able to save the screenshot at all.
    
    Totem-WARNING **: Could not find a valid location to save the screenshot: Failed to find a valid place to 
save
    
    Closes: #427

 src/plugins/screenshot/totem-screenshot-plugin.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c 
b/src/plugins/screenshot/totem-screenshot-plugin.c
index 2d488b542..ce8481a26 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -200,6 +200,16 @@ flash_area (GtkWidget *widget)
                           NULL);
 }
 
+static char *
+escape_video_name (const char *orig)
+{
+       g_auto(GStrv) elems = NULL;
+
+       /* '/' can't be in a filename */
+       elems = g_strsplit (orig, "/", -1);
+       return g_strjoinv ("–", elems);
+}
+
 static void
 take_screenshot_action_cb (GSimpleAction         *action,
                           GVariant              *parameter,
@@ -209,7 +219,8 @@ take_screenshot_action_cb (GSimpleAction         *action,
        GdkPixbuf *pixbuf;
        GError *err = NULL;
        ScreenshotSaveJob *job;
-       char *video_name;
+       g_autofree char *video_name = NULL;
+       g_autofree char *escaped_video_name = NULL;
 
        if (bacon_video_widget_get_logo_mode (priv->bvw) != FALSE)
                return;
@@ -232,14 +243,13 @@ take_screenshot_action_cb (GSimpleAction         *action,
        }
 
        video_name = totem_object_get_short_title (self->priv->totem);
+       escaped_video_name = escape_video_name (video_name);
 
        job = g_slice_new (ScreenshotSaveJob);
        job->plugin = self;
        job->pixbuf = pixbuf;
 
        screenshot_build_filename_async (NULL, video_name, screenshot_name_ready_cb, job);
-
-       g_free (video_name);
 }
 
 static void


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