[gnome-boxes] app-window: Close on machine stopping



commit 054039f2922aafd7f3336651d3241e861b1008a7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Sep 4 14:06:10 2014 +0100

    app-window: Close on machine stopping
    
    If current machine changes state to a non-running state and window is
    not main, close the window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735045

 src/app-window.vala |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 64e3421..4b77433 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -17,13 +17,24 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
         }
 
         set {
+            if (_current_item != null) {
+                _current_item.disconnect (machine_state_notify_id);
+                machine_state_notify_id = 0;
+            }
+
             _current_item = value;
+            if (_current_item != null) {
+                var machine = (_current_item as Machine);
+
+                machine_state_notify_id = machine.notify["state"].connect (on_machine_state_notify);
+            }
         }
     }
     public signal void item_selected (CollectionItem item);
 
     private GLib.Binding status_bind;
     private ulong got_error_id;
+    private ulong machine_state_notify_id;
 
     [CCode (notify = false)]
     public bool fullscreened {
@@ -46,6 +57,11 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
         }
     }
 
+    private void on_machine_state_notify () {
+       if (this != App.app.main_window && (current_item as Machine).state != Machine.MachineState.RUNNING)
+           on_delete_event ();
+    }
+
     [GtkChild]
     public Searchbar searchbar;
     [GtkChild]


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