[totem/wip/hadess/screenshot-slash: 1/2] screenshot: Remove '/' in screenshot filenames
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem/wip/hadess/screenshot-slash: 1/2] screenshot: Remove '/' in screenshot filenames
- Date: Thu, 20 Aug 2020 12:23:57 +0000 (UTC)
commit 227c6b88367c3b492e9dd07158a7e05b3a06344f
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 | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c
b/src/plugins/screenshot/totem-screenshot-plugin.c
index 2d488b542..6808b3443 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);
+ screenshot_build_filename_async (NULL, escaped_video_name, screenshot_name_ready_cb, job);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]