summaryrefslogtreecommitdiff
path: root/src/plugins/screenshot/totem-screenshot-plugin.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2020-08-20 13:41:38 +0200
committerBastien Nocera <hadess@hadess.net>2020-08-20 14:13:36 +0200
commit227c6b88367c3b492e9dd07158a7e05b3a06344f (patch)
tree209b5fe04b927f5fdb4225b28cb31fc149acc23b /src/plugins/screenshot/totem-screenshot-plugin.c
parentb2ffceb89521901775d99a6bc7fe8c9b8811c74c (diff)
downloadtotem-227c6b88367c3b492e9dd07158a7e05b3a06344f.tar.gz
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
Diffstat (limited to 'src/plugins/screenshot/totem-screenshot-plugin.c')
-rw-r--r--src/plugins/screenshot/totem-screenshot-plugin.c18
1 files 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