[gnome-boxes/fix-preferences-box-renaming: 5/5] libvirt-machine: Bind "name" property to GVirConfig.Domain.name




commit d26cabb26e20f0b146dfd8e4c9201f0cef78c10a
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue May 17 13:57:15 2022 +0200

    libvirt-machine: Bind "name" property to GVirConfig.Domain.name
    
    This way the Preferences dialog can simply bind to the LibvirtMachine
    "name" property to keep the name entry synced with the backend.
    
    This fixes the issue where users are unable to rename the VM in the
    new Preferences dialog, since the name changes weren't properly
    getting reflected on the backend side.
    
    Fixes #792

 src/libvirt-machine.vala | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 054f7228..7a5b9ba1 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -24,6 +24,21 @@
         }
     }
 
+    public new string name {
+        set {
+            try {
+                domain_config.set_title (value);
+                domain.set_config (domain_config);
+            } catch (GLib.Error error) {
+                warning ("Failed to rename box: %s", error.message);
+            }
+        }
+
+        get {
+            return domain_config.get_title ();
+        }
+    }
+
     // If this machine is currently being imported
     public bool importing { get { return vm_creator != null && vm_creator is VMImporter; } }
 


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