[gnome-boxes] app: Remove 'current-item' prop



commit 395395dbbf67f0ef40e3c9559833433ea36b8db4
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Jul 16 10:33:30 2014 +0200

    app: Remove 'current-item' prop
    
    Removes the 'current-item' property from App. Also makes the
    'current-item' property of AppWindow an attribute as it was only needed
    to bind current items during the move. It finishes its move from App to
    AppWindow.
    
    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   |    6 +++---
 src/app.vala          |    7 -------
 src/display-page.vala |    2 +-
 src/machine.vala      |    6 +++---
 src/properties.vala   |   12 ++++++------
 src/sidebar.vala      |    2 +-
 src/topbar.vala       |    4 ++--
 7 files changed, 16 insertions(+), 23 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index ead8e00..213b386 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -9,11 +9,11 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
 
-    public CollectionItem current_item { get; set; } // current object/vm manipulated
+    public CollectionItem current_item; // 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; }
+    private GLib.Binding status_bind;
+    private ulong got_error_id;
 
     [CCode (notify = false)]
     public bool fullscreened {
diff --git a/src/app.vala b/src/app.vala
index 3af12f4..510c50c 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -22,7 +22,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
 
-    public CollectionItem current_item { get; set; } // current object/vm manipulated
     public string? uri { get; set; }
     public Collection collection;
     public CollectionFilter filter;
@@ -38,9 +37,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
     public GVir.Connection default_connection { owned get { return LibvirtBroker.get_default 
().get_connection ("QEMU Session"); } }
     public CollectionSource default_source { get { return sources.get ("QEMU Session"); } }
 
-    public GLib.Binding status_bind { get; set; }
-    public ulong got_error_id { get; set; }
-
     public App () {
         application_id = "org.gnome.Boxes";
         flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
@@ -165,9 +161,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
 
         window = new Boxes.AppWindow (this);
         window.setup_ui ();
-        bind_property ("current-item", window, "current-item", BindingFlags.BIDIRECTIONAL);
-        bind_property ("status-bind", window, "status-bind", BindingFlags.BIDIRECTIONAL);
-        bind_property ("got-error-id", window, "got-error-id", BindingFlags.BIDIRECTIONAL);
         set_state (UIState.COLLECTION);
 
         window.present ();
diff --git a/src/display-page.vala b/src/display-page.vala
index b96384f..439d01e 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -81,7 +81,7 @@ private class Boxes.DisplayPage: Gtk.Box {
     }
 
     public void update_title () {
-        var machine = App.app.current_item as Boxes.Machine;
+        var machine = App.window.current_item as Boxes.Machine;
         return_if_fail (machine != null);
 
         var title = machine.name;
diff --git a/src/machine.vala b/src/machine.vala
index a444f42..d9b3c98 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -70,7 +70,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
             // state, we got to exit, as there is no way for the user
             // to progress in the vm display anymore
             if (display != null && !stay_on_display &&
-                App.app.current_item == this &&
+                App.window.current_item == this &&
                 value != MachineState.RUNNING &&
                 value != MachineState.UNKNOWN) {
                 App.app.set_state (Boxes.UIState.COLLECTION);
@@ -135,7 +135,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
 
             disconnected_id = _display.disconnected.connect ((failed) => {
                 message (@"display $name disconnected");
-                if (!stay_on_display && App.app.current_item == this)
+                if (!stay_on_display && App.window.current_item == this)
                     App.app.set_state (Boxes.UIState.COLLECTION);
                 if (failed)
                     App.window.notificationbar.display_error (_("Connection to '%s' failed").printf (name));
@@ -368,7 +368,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
 
             orig_pixbuf = small_screenshot;
             pixbuf = draw_vm (small_screenshot, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
-            if (App.app.current_item == this)
+            if (App.window.current_item == this)
                 App.window.sidebar.screenshot.set_from_pixbuf (pixbuf);
             if (save)
                 save_pixbuf_as_screenshot (small_screenshot);
diff --git a/src/properties.vala b/src/properties.vala
index 084bf65..13b5f51 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -137,8 +137,8 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
         foreach (var page in get_children ())
             remove (page);
 
-        var machine = App.app.current_item as Machine;
-        var libvirt_machine = App.app.current_item as LibvirtMachine;
+        var machine = App.window.current_item as Machine;
+        var libvirt_machine = App.window.current_item as LibvirtMachine;
 
         App.window.sidebar.shutdown_button.sensitive = libvirt_machine != null && libvirt_machine.is_running 
();
 
@@ -182,7 +182,7 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
 
     private void ui_state_changed () {
         if (stats_id != 0) {
-            App.app.current_item.disconnect (stats_id);
+            App.window.current_item.disconnect (stats_id);
             stats_id = 0;
         }
 
@@ -190,8 +190,8 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
             restore_fullscreen = (previous_ui_state == UIState.DISPLAY && App.window.fullscreened);
             App.window.fullscreened = false;
 
-            if (App.app.current_item is LibvirtMachine) {
-                var libvirt_machine = App.app.current_item as LibvirtMachine;
+            if (App.window.current_item is LibvirtMachine) {
+                var libvirt_machine = App.window.current_item as LibvirtMachine;
                 stats_id = libvirt_machine.stats_updated.connect (() => {
                     App.window.sidebar.cpu_graph.points = libvirt_machine.cpu_stats;
                     App.window.sidebar.net_graph.points = libvirt_machine.net_stats;
@@ -208,7 +208,7 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
                 reboot_required |= page.flush_changes ();
             }
 
-            var machine = App.app.current_item as Machine;
+            var machine = App.window.current_item as Machine;
             if (reboot_required && (machine.is_on () || machine.state == Machine.MachineState.SAVED)) {
                 var message = _("Changes require restart of '%s'.").printf (machine.name);
                 App.window.notificationbar.display_for_action (message, _("_Restart"), () => {
diff --git a/src/sidebar.vala b/src/sidebar.vala
index a009699..a7831a0 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -103,7 +103,7 @@ private class Boxes.Sidebar: Gtk.Revealer, Boxes.UI {
 
     [GtkCallback]
     private void on_shutdown_button_clicked () {
-        var machine = App.app.current_item as LibvirtMachine;
+        var machine = App.window.current_item as LibvirtMachine;
         if (machine != null)
             machine.force_shutdown ();
     }
diff --git a/src/topbar.vala b/src/topbar.vala
index a40e07f..f047331 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -75,7 +75,7 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
     public string properties_title {
         set {
             // Translators: The %s will be replaced with the name of the VM
-            props_toolbar.title = _("%s - Properties").printf (App.app.current_item.name);
+            props_toolbar.title = _("%s - Properties").printf (App.window.current_item.name);
         }
     }
 
@@ -127,7 +127,7 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
 
         case UIState.PROPERTIES:
             page = TopbarPage.PROPERTIES;
-            props_name_bind = App.app.current_item.bind_property ("name",
+            props_name_bind = App.window.current_item.bind_property ("name",
                                                                   this, "properties-title",
                                                                   BindingFlags.SYNC_CREATE);
             break;


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