mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2024-12-22 13:33:58 +03:00
remote-viewer: add a default extension to screenshot filenames
When doing a screenshot, if the user provides a filename without a file extension, an error occurs because the image format could not be determined. This patch adds a .png extension to such filenames, so that there is a default file format for screenshots. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1752514 Reviewed-by: Victor Toso <victortoso@redhat.com> Signed-off-by: Julien Ropé <jrope@redhat.com>
This commit is contained in:
parent
e279712281
commit
e4bacb8fde
@ -1069,6 +1069,14 @@ virt_viewer_window_menu_file_screenshot(GtkWidget *menu G_GNUC_UNUSED,
|
||||
GError *error = NULL;
|
||||
|
||||
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
|
||||
if (g_strrstr(filename, ".") == NULL) {
|
||||
// no extension provided: add the .png default
|
||||
char *tmp_filename ;
|
||||
tmp_filename = g_strdup_printf("%s.png", filename) ;
|
||||
g_free(filename) ;
|
||||
filename = tmp_filename ;
|
||||
}
|
||||
|
||||
if (!virt_viewer_window_save_screenshot(self, filename, &error)) {
|
||||
virt_viewer_app_simple_message_dialog(self->priv->app,
|
||||
error->message);
|
||||
|
Loading…
Reference in New Issue
Block a user