[virt-viewer 3/3] Make sure png screenshots have a .png extensions

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

 



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.
---
 src/virt-viewer-window.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index aec51ae..1c2a63b 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);
-- 
1.8.0


[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux