[gnome-boxes/wip/wizard-n-props-in-win: 16/19] libvirt-machine-props: Add 'Force Shutdown' button



commit 37528e1d64e05f0247b03e0604c666c875ec040b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Nov 22 18:21:17 2014 +0000

    libvirt-machine-props: Add 'Force Shutdown' button
    
    Add'Force Shutdown' button to properties under 'System' page, next to
    'Troubleshooting log' button.
    
    This is part of move of sidebar contents to main view before sidebar can
    be dropped.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733367

 src/libvirt-machine-properties.vala |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index d6d896e..0c18d7a 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -141,7 +141,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
         case PropertiesPage.SYSTEM:
             add_resource_usage_graphs (ref list);
 
-            add_troubleshoot_log_button (ref list);
+            add_system_props_buttons (ref list);
 
             var ram_property = add_ram_property (ref list);
             var storage_property = add_storage_property (ref list);
@@ -419,11 +419,14 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
         });
     }
 
-    private void add_troubleshoot_log_button (ref List<Boxes.Property> list) {
+    private void add_system_props_buttons (ref List<Boxes.Property> list) {
+        var grid = new Gtk.Grid ();
+        grid.margin_top = 5;
+        grid.column_spacing = 5;
+        grid.halign = Gtk.Align.START;
+
         var button = new Gtk.Button.with_label (_("Troubleshooting log"));
-        button.halign = Gtk.Align.START;
-        button.margin_top = 5;
-        add_property (ref list, null, button);
+        grid.attach (button, 0, 0, 1, 1);
         button.clicked.connect (() => {
             var log = collect_logs ();
             var dialog = new Gtk.Dialog.with_buttons (_("Troubleshooting log"),
@@ -483,6 +486,24 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
                 }
             });
         });
+
+        button = new Gtk.Button.with_label (_("Force Shutdown"));
+        button.clicked.connect (() => {
+            machine.force_shutdown ();
+        });
+        grid.attach (button, 1, 0, 1, 1);
+
+        button.sensitive = machine.is_running ();
+        var state_notify_id = machine.notify["state"].connect (() => {
+            button.sensitive = machine.is_running ();
+        });
+
+        var prop = add_property (ref list, null, grid);
+        ulong flushed_id = 0;
+        flushed_id = prop.flushed.connect (() => {
+            machine.disconnect (state_notify_id);
+            prop.disconnect (flushed_id);
+        });
     }
 
     private SizeProperty? add_ram_property (ref List<Boxes.Property> list) {


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