[gnome-boxes/wip/wizard-n-props-in-dialog2: 9/12] libvirt-machine-props: Add 'Force Shutdown' button



commit 79fcbb19222b010739bd5a6d3897626201b58c4a
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.

 src/libvirt-machine-properties.vala |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index bfc3996..c304fcc 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,10 +419,13 @@ 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.column_spacing = 5;
+        grid.halign = Gtk.Align.START;
+
         var button = new Gtk.Button.with_label (_("Troubleshooting log"));
-        button.halign = Gtk.Align.START;
-        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"),
@@ -479,6 +482,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]