summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2012-11-13 12:52:31 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2012-11-15 10:21:03 +0100
commit8a7aa6a1e15dfc2adbb9627ec5e914e445f434ab (patch)
tree3ed867694162620353a0d1e1ea661b140ac8a157 /src
parentf9935c832b84a31bc91f5fcdfdf459ee3a0913fe (diff)
Make sure png screenshots have a .png extensions
When falling back to saving to .png, the filename might not end with .png. This commit appends the .png extension to the screenshot filename if it's missing.
Diffstat (limited to 'src')
-rw-r--r--src/virt-viewer-window.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 5e263f1..a260366 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -801,8 +801,16 @@ virt_viewer_window_save_screenshot(VirtViewerWindow *self,
if (format == NULL) {
g_debug("unknown file extension, falling back to png");
- gdk_pixbuf_save(pix, file, "png", NULL,
- "tEXt::Generator App", PACKAGE, NULL);
+ if (!g_str_has_suffix(file, ".png")) {
+ char *png_filename;
+ png_filename = g_strconcat(file, ".png", NULL);
+ gdk_pixbuf_save(pix, png_filename, "png", NULL,
+ "tEXt::Generator App", PACKAGE, NULL);
+ g_free(png_filename);
+ } else {
+ gdk_pixbuf_save(pix, file, "png", NULL,
+ "tEXt::Generator App", PACKAGE, NULL);
+ }
} else {
char *type = gdk_pixbuf_format_get_name(format);
g_debug("saving to %s", type);