[gnome-boxes] collection-view: Prelight for running machines
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] collection-view: Prelight for running machines
- Date: Thu, 6 Mar 2014 16:01:13 +0000 (UTC)
commit fff165f47924eee0d1d375d3373f9fbef439c4fa
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Mar 5 15:57:23 2014 +0000
collection-view: Prelight for running machines
as well.
https://bugzilla.gnome.org/show_bug.cgi?id=710279
src/collection-view.vala | 2 +-
src/machine.vala | 31 +++++++++++++++++++++++++++++--
2 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 6299550..3cca7c6 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -57,7 +57,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
store.get (iter, ModelColumns.ITEM, out item);
Machine machine = item as Machine;
return_if_fail (machine != null);
- var pixbuf = (iter == prelight_iter)? machine.orig_pixbuf : machine.pixbuf;
+ var pixbuf = (iter == prelight_iter)? machine.prelight_pixbuf : machine.pixbuf;
if ("favorite" in machine.config.categories)
emblem_icons += create_symbolic_emblem ("emblem-favorite");
diff --git a/src/machine.vala b/src/machine.vala
index 5f0b39a..2d5dc96 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -35,7 +35,8 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
public Cancellable connecting_cancellable { get; protected set; }
// The current screenshot without running status applied
- public Gdk.Pixbuf? orig_pixbuf { get; private set; }
+ private Gdk.Pixbuf? orig_pixbuf;
+ public Gdk.Pixbuf? prelight_pixbuf { get; private set; }
public enum MachineState {
UNKNOWN,
@@ -62,8 +63,10 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
set_screenshot (null, false);
else {
// Update existing screenshot based on machine status
- if (orig_pixbuf != null)
+ if (orig_pixbuf != null) {
pixbuf = draw_vm (orig_pixbuf, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
+ prelight_pixbuf = draw_prelighted_vm (orig_pixbuf, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
+ }
}
// If the display is active and the VM goes to a non-running
@@ -368,6 +371,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
orig_pixbuf = small_screenshot;
pixbuf = draw_vm (small_screenshot, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
+ prelight_pixbuf = draw_prelighted_vm (small_screenshot, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
if (App.app.current_item == this)
App.window.sidebar.screenshot.set_from_pixbuf (pixbuf);
if (save)
@@ -435,6 +439,29 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
return Gdk.pixbuf_get_from_surface (surface, 0, 0, width, height);
}
+ private Gdk.Pixbuf draw_prelighted_vm (Gdk.Pixbuf pixbuf, int width, int height) {
+ var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height);
+ var context = new Cairo.Context (surface);
+
+ var pw = pixbuf.get_width ();
+ var ph = pixbuf.get_height ();
+ var x = (width - pw) / 2;
+ var y = (height - ph) / 2;
+
+ context.rectangle (x, y, pw, ph);
+ context.clip ();
+
+ Gdk.cairo_set_source_pixbuf (context, pixbuf, x, y);
+ context.set_operator (Cairo.Operator.SOURCE);
+ context.paint ();
+
+ context.set_source_rgba (0.2, 0.2, 0.2, 0.2);
+ context.set_operator (Cairo.Operator.SCREEN);
+ context.paint ();
+
+ return Gdk.pixbuf_get_from_surface (surface, 0, 0, width, height);
+ }
+
private static Gdk.Pixbuf draw_stopped_vm (int width = SCREENSHOT_WIDTH,
int height = SCREENSHOT_HEIGHT) {
var surface = new Cairo.ImageSurface (Cairo.Format.RGB24, width, height);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]