[gnome-boxes] app-window: Move select_item() from App



commit 1132dcacfbbf1f2c3ad25693ecd4662cd019658d
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Jul 16 10:14:44 2014 +0200

    app-window: Move select_item() from App
    
    As the 'current-item' property is moving from App to AppWindow,
    select_item () should follow it.
    
    This is needed to drop the use of AppWindow singleton and therefore to
    make multiple windows possible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732098

 src/app-window.vala      |   20 ++++++++++++++++++++
 src/app.vala             |   24 ++----------------------
 src/collection-view.vala |    2 +-
 src/vm-creator.vala      |    2 +-
 src/wizard.vala          |    2 +-
 5 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 6892831..0d7b7b2 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -10,6 +10,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
     public UIState ui_state { get; protected set; }
 
     public CollectionItem current_item { get; set; } // current object/vm manipulated
+    public signal void item_selected (CollectionItem item);
 
     public GLib.Binding status_bind { get; set; }
     public ulong got_error_id { get; set; }
@@ -182,6 +183,25 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
             App.app.set_state (UIState.CREDS); // Start the CREDS state
     }
 
+    public void select_item (CollectionItem item) {
+        if (App.app.ui_state == UIState.COLLECTION && !App.app.selection_mode) {
+            current_item = item;
+
+            if (current_item is Machine) {
+                var machine = current_item as Machine;
+
+                connect_to (machine);
+            } else
+                warning ("unknown item, fix your code");
+
+            item_selected (item);
+        } else if (ui_state == UIState.WIZARD) {
+            current_item = item;
+
+            App.app.set_state (UIState.PROPERTIES);
+        }
+    }
+
     [GtkCallback]
     public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
         var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
diff --git a/src/app.vala b/src/app.vala
index 7651511..62d87ad 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -29,7 +29,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
 
     private bool is_ready;
     public signal void ready ();
-    public signal void item_selected (CollectionItem item);
 
     // A callback to notify that deletion of machines was undone by user.
     public delegate void UndoNotifyCallback ();
@@ -292,7 +291,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
         // after "ready" all items should be listed
         foreach (var item in collection.items.data) {
             if (item.name == name) {
-                select_item (item);
+                window.select_item (item);
 
                 break;
             }
@@ -311,7 +310,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
             if (machine.config.uuid != uuid)
                 continue;
 
-            select_item (item);
+            window.select_item (item);
             return true;
         }
 
@@ -524,23 +523,4 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
 
         delete_machines_undoable ((owned) selected_items, message);
     }
-
-    public void select_item (CollectionItem item) {
-        if (ui_state == UIState.COLLECTION && !selection_mode) {
-            current_item = item;
-
-            if (current_item is Machine) {
-                var machine = current_item as Machine;
-
-                window.connect_to (machine);
-            } else
-                warning ("unknown item, fix your code");
-
-            item_selected (item);
-        } else if (ui_state == UIState.WIZARD) {
-            current_item = item;
-
-            set_state (UIState.PROPERTIES);
-        }
-    }
 }
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 175264c..1da54fd 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -269,7 +269,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
             var item = get_item_for_path (path);
             if (item is LibvirtMachine && (item as LibvirtMachine).importing)
                 return;
-            App.app.select_item (item);
+            App.window.select_item (item);
         });
         view_selection_changed.connect (() => {
             queue_draw ();
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 06ce5a9..8ae872f 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -72,7 +72,7 @@ private class Boxes.VMCreator {
                 if (App.app.ui_state != UIState.COLLECTION)
                     return;
 
-                App.app.select_item (machine); // This also starts the domain for us
+                App.window.select_item (machine); // This also starts the domain for us
                 App.app.disconnect (signal_id);
 
                 return;
diff --git a/src/wizard.vala b/src/wizard.vala
index 4ca36a7..651a9de 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -540,7 +540,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
         if (machine != null)
             summary.append_customize_button (() => {
                 // Selecting an item in UIState.WIZARD implies changing state to UIState.PROPERTIES
-                App.app.select_item (machine);
+                App.window.select_item (machine);
             });
 
         return true;


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