[virt-tools-list] [RFC PATCH v3 6/7] virtManager: config: Correctly reflect global defaults change

Michael Weiser michael.weiser at gmx.de
Mon Dec 9 21:53:16 UTC 2019


The VM window has a number of checkbox menu items that have a tri-state
logic: They either reflect the global default as long as the per-vm
setting is still -1 or they show the per-vm setting as enabled or
disabled. Since they only listen to the per-vm dconf setting, they will
not be updated if the global default changes.

Extend add_gsettings_handle() to accept an iterable of handles for
whose tiggering of a notification should trigger an update of object
state and wire the menu items in question to be updated on global
defaults change as well.

Signed-off-by: Michael Weiser <michael.weiser at gmx.de>
---
 virtManager/baseclass.py     |  5 ++++-
 virtManager/object/domain.py | 16 ++++++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/virtManager/baseclass.py b/virtManager/baseclass.py
index b2c90263..451e8a8a 100644
--- a/virtManager/baseclass.py
+++ b/virtManager/baseclass.py
@@ -174,7 +174,10 @@ class vmmGObject(GObject.GObject):
         return GObject.GObject.emit(self, signal_name, *args)
 
     def add_gsettings_handle(self, handle):
-        self._gsettings_handles.append(handle)
+        if hasattr(handle, '__iter__'):
+            self._gsettings_handles.extend(handle)
+        else:
+            self._gsettings_handles.append(handle)
     def remove_gsettings_handle(self, handle):
         self.config.remove_notifier(handle)
         self._gsettings_handles.remove(handle)
diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py
index ea6fad62..590babec 100644
--- a/virtManager/object/domain.py
+++ b/virtManager/object/domain.py
@@ -1571,8 +1571,9 @@ class vmmDomain(vmmLibvirtObject):
     ##################
 
     def on_console_scaling_changed(self, *args, **kwargs):
-        return self.config.listen_pervm(self.get_uuid(), "/scaling",
-                                        *args, **kwargs)
+        return (self.config.listen_pervm(self.get_uuid(), "/scaling",
+                                         *args, **kwargs),
+                self.config.on_console_scaling_changed(*args, *kwargs))
     def set_console_scaling(self, value):
         self.config.set_pervm(self.get_uuid(), "/scaling", value)
     def get_console_scaling(self):
@@ -1582,8 +1583,9 @@ class vmmDomain(vmmLibvirtObject):
         return ret
 
     def on_console_resizeguest_changed(self, *args, **kwargs):
-        return self.config.listen_pervm(self.get_uuid(), "/resize-guest",
-                                        *args, **kwargs)
+        return (self.config.listen_pervm(self.get_uuid(), "/resize-guest",
+                                         *args, **kwargs),
+                self.config.on_console_resizeguest_changed(*args, *kwargs))
     def set_console_resizeguest(self, value):
         self.config.set_pervm(self.get_uuid(), "/resize-guest", value)
     def get_console_resizeguest(self):
@@ -1608,9 +1610,11 @@ class vmmDomain(vmmLibvirtObject):
                                      ("", -1))
 
     def on_sync_guest_time_on_resume_changed(self, *args, **kwargs):
-        return self.config.listen_pervm(self.get_uuid(),
+        return (self.config.listen_pervm(self.get_uuid(),
                                         "/sync-guest-time-on-resume",
-                                        *args, **kwargs)
+                                        *args, **kwargs),
+                self.config.on_sync_guest_time_on_resume_changed(
+                                        *args, **kwargs))
     def set_sync_guest_time_on_resume(self, value):
         self.config.set_pervm(self.get_uuid(), "/sync-guest-time-on-resume",
                               value)
-- 
2.24.0





More information about the virt-tools-list mailing list