[gnome-boxes] libvirt-machine: Add a boolean 'run-in-bg' property



commit 324bdf2f88937ccf18c34da87487d35c065b1f7b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Jul 9 19:50:06 2015 +0100

    libvirt-machine: Add a boolean 'run-in-bg' property
    
    This property dictates whether or not Boxes should automatically
    pause/save the machine or not. By default this is set to false.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746754

 src/libvirt-machine.vala |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 45ec7d8..ee55f97 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -29,16 +29,19 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         set { source.set_boolean ("source", "save-on-quit", value); }
     }
 
-    public override bool suspend_at_exit { get { return connection == App.app.default_connection; } }
+    public override bool suspend_at_exit { get { return connection == App.app.default_connection && 
!run_in_bg; } }
     public override bool can_save { get { return !saving && state != MachineState.SAVED; } }
     protected override bool should_autosave {
         get {
             return (base.should_autosave &&
                     connection == App.app.default_connection &&
+                    !run_in_bg &&
                     (vm_creator == null || !vm_creator.express_install));
         }
     }
 
+    public bool run_in_bg { get; set; } // If true, machine will never be paused automatically by Boxes.
+
     public override void disconnect_display () {
         stay_on_display = false;
 
@@ -113,6 +116,8 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
 
     private GVir.Connection system_virt_connection;
 
+    private BoxConfig.SyncProperty[] sync_properties;
+
     construct {
         stats = new MachineStat[STATS_SIZE];
         stats_cancellable = new Cancellable ();
@@ -222,6 +227,12 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         }
 
         update_info ();
+
+        sync_properties = {
+            BoxConfig.SyncProperty () { name = "run-in-bg", default_value = false },
+        };
+
+        this.config.sync_properties (this, sync_properties);
     }
 
     private void update_cpu_stat (DomainInfo info, ref MachineStat stat) {


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