From 4315461a6c356da07e304b2bab63bd1c966d45df Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Tue, 4 Aug 2020 16:52:59 +0200 Subject: [PATCH] wfd-source: Update the switch state using set_state The Gtk.Switch representing the p2p.Device's Enabled property should use the "delayed state change" logic as described in Gtk.Switch docs, i.e. we need to use .set_state() instead of .set_active() when we get confirmation of the property having changed its value in the PropertiesChanged handler. The ::active property is automatically changed by Gtk.Switch on user input. This way the UI gives visual feedback of when the device enable/disable op starts and ends (or fails). --- test/wfd-source | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/wfd-source b/test/wfd-source index a83cd0cb..e99ae818 100755 --- a/test/wfd-source +++ b/test/wfd-source @@ -1116,7 +1116,7 @@ class WFDSource(Gtk.Window): dev_str = self.get_dev_string(path) name = str(device.props['Name']) label.set_markup(dev_str + '\n' + ('Local name: ' + name + '\n' if dev_str != name else '') + 'State: ' + state + '') - switch.set_active(device.props['Enabled']) + switch.set_state(device.props['Enabled']) def update_peer_props(self, dev_path, path): device = self.devices[dev_path] @@ -1560,7 +1560,6 @@ class WFDSource(Gtk.Window): device = self.devices[path] if device.props['Enabled'] == state: return - device.props['Enabled'] = state device.props_proxy.Set(DEVICE_IF, 'Enabled', state) return True