Fixed saving screenshot to clipboard (#481)

Fixed: #474
This commit is contained in:
Peter Uithoven 2019-03-02 02:12:16 +01:00 committed by Adam Bieńkowski
parent 6da349e939
commit 395670ec3d

View File

@ -181,10 +181,16 @@ namespace Gala
try { try {
var screenshot = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ()); var screenshot = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
var file = File.new_for_path (used_filename); var file = File.new_for_path (used_filename);
var stream = yield file.create_readwrite_async (FileCreateFlags.NONE); FileIOStream stream;
if (file.query_exists ()) {
stream = yield file.open_readwrite_async (FileCreateFlags.NONE);
} else {
stream = yield file.create_readwrite_async (FileCreateFlags.NONE);
}
yield screenshot.save_to_stream_async (stream.output_stream, "png"); yield screenshot.save_to_stream_async (stream.output_stream, "png");
return true; return true;
} catch (GLib.Error e) { } catch (GLib.Error e) {
warning ("could not save file: %s", e.message);
return false; return false;
} }
} }