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



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

    app-window: Close on machine deletion
    
    If current machine is deleted and window is not main, close the window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735045

 src/app-window.vala |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 4b77433..949ee60 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -20,6 +20,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
             if (_current_item != null) {
                 _current_item.disconnect (machine_state_notify_id);
                 machine_state_notify_id = 0;
+                machine_deleted_notify_id = 0;
             }
 
             _current_item = value;
@@ -27,6 +28,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
                 var machine = (_current_item as Machine);
 
                 machine_state_notify_id = machine.notify["state"].connect (on_machine_state_notify);
+                machine_deleted_notify_id = machine.notify["deleted"].connect (on_machine_deleted_notify);
             }
         }
     }
@@ -35,6 +37,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
     private GLib.Binding status_bind;
     private ulong got_error_id;
     private ulong machine_state_notify_id;
+    private ulong machine_deleted_notify_id;
 
     [CCode (notify = false)]
     public bool fullscreened {
@@ -62,6 +65,11 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
            on_delete_event ();
     }
 
+    private void on_machine_deleted_notify () {
+       if (this != App.app.main_window && (current_item as Machine).deleted)
+           on_delete_event ();
+    }
+
     [GtkChild]
     public Searchbar searchbar;
     [GtkChild]


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