mirror of
https://github.com/elementary/gala.git
synced 2024-08-16 10:30:40 +03:00
Do not block stage drawing when saving the screenshots (#460)
This commit is contained in:
parent
9493139c78
commit
bbd5963da5
@ -67,7 +67,7 @@ namespace Gala
|
||||
flash_actor.add_transition ("flash", transition);
|
||||
}
|
||||
|
||||
public void screenshot (bool include_cursor, bool flash, string filename, out bool success, out string filename_used) throws DBusError, IOError
|
||||
public async void screenshot (bool include_cursor, bool flash, string filename, out bool success, out string filename_used) throws DBusError, IOError
|
||||
{
|
||||
debug ("Taking screenshot");
|
||||
|
||||
@ -80,7 +80,7 @@ namespace Gala
|
||||
flash_area (0, 0, width, height);
|
||||
}
|
||||
|
||||
success = save_image (image, filename, out filename_used);
|
||||
success = yield save_image (image, filename, out filename_used);
|
||||
}
|
||||
|
||||
public async void screenshot_area (int x, int y, int width, int height, bool flash, string filename, out bool success, out string filename_used) throws DBusError, IOError
|
||||
@ -95,12 +95,12 @@ namespace Gala
|
||||
flash_area (x, y, width, height);
|
||||
}
|
||||
|
||||
success = save_image (image, filename, out filename_used);
|
||||
success = yield save_image (image, filename, out filename_used);
|
||||
if (!success)
|
||||
throw new DBusError.FAILED ("Failed to save image");
|
||||
}
|
||||
|
||||
public void screenshot_window (bool include_frame, bool include_cursor, bool flash, string filename, out bool success, out string filename_used) throws DBusError, IOError
|
||||
public async void screenshot_window (bool include_frame, bool include_cursor, bool flash, string filename, out bool success, out string filename_used) throws DBusError, IOError
|
||||
{
|
||||
debug ("Taking window screenshot");
|
||||
|
||||
@ -126,7 +126,7 @@ namespace Gala
|
||||
flash_area (rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
|
||||
success = save_image (image, filename, out filename_used);
|
||||
success = yield save_image (image, filename, out filename_used);
|
||||
}
|
||||
|
||||
public async void select_area (out int x, out int y, out int width, out int height) throws DBusError, IOError
|
||||
@ -161,7 +161,7 @@ namespace Gala
|
||||
return Environment.get_home_dir ();
|
||||
}
|
||||
|
||||
static bool save_image (Cairo.ImageSurface image, string filename, out string used_filename)
|
||||
static async bool save_image (Cairo.ImageSurface image, string filename, out string used_filename)
|
||||
{
|
||||
if (!Path.is_absolute (filename)) {
|
||||
var path = find_target_path ();
|
||||
@ -176,7 +176,9 @@ namespace Gala
|
||||
|
||||
try {
|
||||
var screenshot = Gdk.pixbuf_get_from_surface (image, 0, 0, image.get_width (), image.get_height ());
|
||||
screenshot.save (used_filename, "png");
|
||||
var file = File.new_for_path (used_filename);
|
||||
var stream = yield file.create_readwrite_async (FileCreateFlags.NONE);
|
||||
yield screenshot.save_to_stream_async (stream.output_stream, "png");
|
||||
return true;
|
||||
} catch (GLib.Error e) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user