[gnome-boxes/use-better-drawing-for-thumbnails: 8/8] thumbnail: Use our custom logic to draw thumbnails
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/use-better-drawing-for-thumbnails: 8/8] thumbnail: Use our custom logic to draw thumbnails
- Date: Tue, 19 Apr 2022 15:05:04 +0000 (UTC)
commit b5b4d8a8280690ce35d4dc11b7ad972ae0b30b5f
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Mar 29 16:21:27 2022 +0200
thumbnail: Use our custom logic to draw thumbnails
Our Machine.set_screenshot method already implements some nice
heuristic to polish the display screenshot for thumbnails.
src/machine.vala | 2 +-
src/ui/thumbnail.vala | 19 ++++++++++++-------
2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/src/machine.vala b/src/machine.vala
index de495b88..c23cc24c 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -340,7 +340,7 @@ protected virtual async void save_real () throws GLib.Error {
// just before going back to the collection view. Taking regular
// screenshots can have its use in case of an abnormal gnome-boxes
// termination.
- protected async virtual Gdk.Pixbuf? take_screenshot () throws GLib.Error {
+ public async virtual Gdk.Pixbuf? take_screenshot () throws GLib.Error {
if (display == null)
return null;
diff --git a/src/ui/thumbnail.vala b/src/ui/thumbnail.vala
index 7105c690..8ed313f2 100644
--- a/src/ui/thumbnail.vala
+++ b/src/ui/thumbnail.vala
@@ -31,13 +31,18 @@ public void update (Machine machine) {
}
if (machine.pixbuf != null && !machine.is_stopped) {
- live_thumbnail.set_from_pixbuf (
- machine.pixbuf.scale_simple (width_request,
- height_request,
- Gdk.InterpType.BILINEAR));
- stack.visible_child = live_thumbnail;
-
- return;
+ machine.take_screenshot.begin ((source, result) => {
+ try {
+ var screenshot = machine.take_screenshot.end (result);
+ var scaled = screenshot.scale_simple (width_request,
+ height_request,
+ Gdk.InterpType.BILINEAR);
+ live_thumbnail.set_from_pixbuf (scaled);
+ stack.visible_child = live_thumbnail;
+ } catch (GLib.Error error) {
+ debug (error.message);
+ }
+ });
}
stack.visible_child = blank_thumbnail;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]