[gnome-boxes] Factor out MachineActor.update_display()
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Factor out MachineActor.update_display()
- Date: Mon, 30 Jul 2012 17:14:35 +0000 (UTC)
commit 188f9e352b91e9086185bb0b0912eda054ed79b5
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Jul 20 03:39:22 2012 +0200
Factor out MachineActor.update_display()
In a following patch, we will update the display widget while in
Properties page. That new function take care of that.
Note: I don't know what the Idle was used for, it doesn't seem to
change anything.
Note2: The animation duration seems to be longer now, so I divided it
herer arbitrarily by 2.., I suspect this is related to the multiple
size_alloc() events (and no, the Idle was not helping with this
problem)
https://bugzilla.gnome.org/show_bug.cgi?id=680293
src/machine.vala | 76 ++++++++++++++++++++++++++++++++----------------------
src/util.vala | 2 +
2 files changed, 47 insertions(+), 31 deletions(-)
---
diff --git a/src/machine.vala b/src/machine.vala
index 92f8219..ff3c0b4 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -420,6 +420,46 @@ private class Boxes.MachineActor: Boxes.UI {
return password_entry.text;
}
+ public void update_display (Gtk.Widget widget, bool zoom = true) {
+ if (display != null) {
+ actor_remove (display);
+ display.contents = null;
+ }
+
+ if (ui_state == UIState.PROPERTIES) {
+ display = new GtkClutter.Actor.with_contents (widget);
+ display.name = "properties-thumbnail";
+ App.app.overlay_bin.add (display,
+ Clutter.BinAlignment.FILL,
+ Clutter.BinAlignment.FILL);
+
+ machine.display.set_enable_inputs (widget, false);
+
+ Boxes.ActorFunc update_screenshot_alloc = (display) => {
+ Gtk.Allocation alloc;
+
+ App.app.properties.screenshot_placeholder.get_allocation (out alloc);
+ App.app.topbar.actor.show ();
+ App.app.overlay_bin.set_alignment (display,
+ Clutter.BinAlignment.FIXED,
+ Clutter.BinAlignment.FIXED);
+ display.x = alloc.x;
+ display.y = alloc.y;
+ display.width = alloc.width;
+ display.height = alloc.height;
+ };
+
+ if (track_screenshot_id != 0)
+ App.app.properties.screenshot_placeholder.disconnect (track_screenshot_id);
+ track_screenshot_id = App.app.properties.screenshot_placeholder.size_allocate.connect (() => { update_screenshot_alloc (display); });
+
+ if (!zoom) {
+ display.set_easing_duration (0);
+ update_screenshot_alloc (display);
+ }
+ }
+ }
+
public override void ui_state_changed () {
int window_width, window_height;
int width, height;
@@ -475,50 +515,24 @@ private class Boxes.MachineActor: Boxes.UI {
case UIState.PROPERTIES:
var widget = App.app.display_page.remove_display ();
- machine.display.set_enable_inputs (widget, false);
- display = new GtkClutter.Actor.with_contents (widget);
- display.name = "properties-thumbnail";
- display.set_easing_mode (Clutter.AnimationMode.LINEAR);
- App.app.overlay_bin.add (display,
- Clutter.BinAlignment.FILL,
- Clutter.BinAlignment.FILL);
-
+ update_display (widget);
Clutter.ActorBox box = { 0, 0, width, height};
display.allocate (box, 0);
- display.show ();
// Temporarily hide toolbar in fullscreen so that the the animation
// actor doesn't get pushed down before zooming to the sidebar
if (App.app.fullscreen)
App.app.topbar.actor.hide ();
- bool completed_zoom = false;
+ display.set_easing_mode (Clutter.AnimationMode.LINEAR);
+ display.set_easing_duration (App.app.duration / 2); // FIXME / 2 why?
ulong completed_id = 0;
completed_id = display.transitions_completed.connect (() => {
display.disconnect (completed_id);
- completed_zoom = true;
+ display.set_easing_duration (0);
});
- track_screenshot_id = App.app.properties.screenshot_placeholder.size_allocate.connect ( (alloc) => {
- Idle.add_full (Priority.HIGH, () => {
- App.app.topbar.actor.show ();
- App.app.overlay_bin.set_alignment (display,
- Clutter.BinAlignment.FIXED,
- Clutter.BinAlignment.FIXED);
-
- // Don't animate x/y/width/height
- display.set_easing_duration (0);
- display.x = alloc.x;
- display.y = alloc.y;
- display.width = alloc.width;
- display.height = alloc.height;
-
- if (!completed_zoom)
- display.set_easing_duration (App.app.duration);
-
- return false;
- });
- });
+ display.show ();
break;
diff --git a/src/util.vala b/src/util.vala
index 48df49b..52d2bb5 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -245,6 +245,8 @@ namespace Boxes {
actor.restore_easing_state ();
}
+ public delegate void ActorFunc (Clutter.Actor actor);
+
public void actor_add (Clutter.Actor actor, Clutter.Actor container) {
if (actor.get_parent () == container)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]