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




commit c4543e679579cf8e2a0121c7b45b6f2ee0272dd5
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]