[gnome-boxes] Move most App.current_item.actor stuff to App from CollectionView



commit 102a8260480bbcae7cfecc2effcf1253d31defe6
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Nov 16 15:57:46 2012 +0100

    Move most App.current_item.actor stuff to App from CollectionView
    
    Its really confusion how this actor is modified from multiple files.
    current_item is a member of App, lets manage it from there.
    
    This just copied the code over and minimally modifies it to work.
    Further commits will clean up the code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688473

 src/app.vala             |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 src/collection-view.vala |   39 +--------------------------------------
 2 files changed, 45 insertions(+), 39 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 1e358d2..9b0ad43 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -577,11 +577,51 @@ private class Boxes.App: Boxes.UI {
             view.visible = true;
             searchbar_revealer.revealed = searchbar.visible;
 
+            // Animate current_item actor to collection position
+            if (current_item != null) {
+                float item_x, item_y;
+                view.get_item_pos (current_item, out item_x, out item_y);
+
+                var actor = current_item.actor;
+                actor.set_easing_duration (0);
+                actor.show ();
+
+                actor.fixed_x = item_x;
+                actor.fixed_y = item_y;
+                actor.min_width = actor.natural_width = Machine.SCREENSHOT_WIDTH;
+
+                actor.set_easing_duration (App.app.duration);
+                var id = view.icon_view.size_allocate.connect ((allocation) => {
+                    Idle.add_full (Priority.HIGH, () => {
+                        float item_x2, item_y2;
+                        view.get_item_pos (current_item, out item_x2, out item_y2);
+                        actor.x = item_x2;
+                        actor.y = item_y2;
+                        return false;
+                    });
+                });
+                ulong completed_id = 0;
+                completed_id = actor.transitions_completed.connect (() => {
+                    actor.disconnect (completed_id);
+                    view.icon_view.disconnect (id);
+                    if (App.app.ui_state == UIState.COLLECTION ||
+                        App.app.current_item.actor != actor)
+                        actor_remove (actor);
+                });
+            }
+
             break;
 
         case UIState.CREDS:
-        case UIState.PROPERTIES:
+            break;
+
         case UIState.WIZARD:
+            if (current_item != null)
+                actor_remove (current_item.actor);
+            break;
+
+        case UIState.PROPERTIES:
+            current_item.actor.hide ();
             break;
 
         case UIState.DISPLAY:
@@ -591,6 +631,9 @@ private class Boxes.App: Boxes.UI {
             warning ("Unhandled UI state %s".printf (ui_state.to_string ()));
             break;
         }
+
+        if (current_item != null)
+            current_item.ui_state = ui_state;
     }
 
     public void suspend_machines () {
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 0cd8645..e05baf3 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -31,7 +31,7 @@ private class Boxes.CollectionView: Boxes.UI {
         LAST
     }
 
-    private Gd.MainIconView icon_view;
+    public Gd.MainIconView icon_view;
     private Gtk.ListStore model;
     private Gtk.TreeModelFilter model_filter;
 
@@ -66,60 +66,23 @@ private class Boxes.CollectionView: Boxes.UI {
 
     public override void ui_state_changed () {
         uint opacity = 0;
-        var current_item = App.app.current_item;
         switch (ui_state) {
         case UIState.COLLECTION:
             opacity = 255;
             icon_view.unselect_all ();
-            if (current_item != null) {
-                var actor = current_item.actor;
-                actor.set_easing_duration (0);
-                actor.show ();
-
-                float item_x, item_y;
-                get_item_pos (current_item, out item_x, out item_y);
-                actor.fixed_x = item_x;
-                actor.fixed_y = item_y;
-                actor.min_width = actor.natural_width = Machine.SCREENSHOT_WIDTH;
-
-                actor.set_easing_duration (App.app.duration);
-                var id = icon_view.size_allocate.connect ((allocation) => {
-                    Idle.add_full (Priority.HIGH, () => {
-                        float item_x2, item_y2;
-                        get_item_pos (current_item, out item_x2, out item_y2);
-                        actor.x = item_x2;
-                        actor.y = item_y2;
-                        return false;
-                    });
-                });
-                ulong completed_id = 0;
-                completed_id = actor.transitions_completed.connect (() => {
-                    actor.disconnect (completed_id);
-                    icon_view.disconnect (id);
-                    if (App.app.ui_state == UIState.COLLECTION ||
-                        App.app.current_item.actor != actor)
-                        actor_remove (actor);
-                });
-            }
             break;
 
         case UIState.CREDS:
             break;
 
         case UIState.WIZARD:
-            if (current_item != null)
-                actor_remove (current_item.actor);
             break;
 
         case UIState.PROPERTIES:
-            current_item.actor.hide ();
             break;
         }
 
         fade_actor (actor, opacity);
-
-        if (current_item != null)
-            current_item.ui_state = ui_state;
     }
 
     public void update_item_visible (CollectionItem item) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]