def test_watching(self): blob1 = "blob1" manager1 = XSettingsManager(blob1) watcher = XSettingsWatcher() assert watcher.get_settings_blob() == blob1 blob2 = "blob2" manager2 = XSettingsManager(blob2) assert_mainloop_emits(watcher, "xsettings-changed") assert watcher.get_settings_blob() == blob2 # It's likely that (due to how the GTK+ clipboard code works # underneath) all of the managers that we create within a single # process are actually using the same selection window, and thus the # previous tests could work right even if we only watch for # PropertyNotify *or* only watch for selection owner changes. # Test where the property change but no manager change message # is sent: blob3 = "blob3" manager2._set_blob_in_place(blob3) assert_mainloop_emits(watcher, "xsettings-changed") assert watcher.get_settings_blob() == blob3 # Test where the property does not change, but a manager change # message is sent: manager3 = XSettingsManager(blob3) assert_mainloop_emits(watcher, "xsettings-changed") assert watcher.get_settings_blob() == blob3
class ClientExtras(object): def __init__(self, send_packet_cb): self.send = send_packet_cb def handshake_complete(self, capabilities): self._xsettings_watcher = XSettingsWatcher() self._xsettings_watcher.connect("xsettings-changed", self._handle_xsettings_changed) self._handle_xsettings_changed() self._root_props_watcher = XRootPropWatcher(self.ROOT_PROPS.keys()) self._root_props_watcher.connect("root-prop-changed", self._handle_root_prop_changed) self._root_props_watcher.notify_all() def _handle_xsettings_changed(self, *args): blob = self._xsettings_watcher.get_settings_blob() if blob is not None: self.send(["server-settings", {"xsettings-blob": blob}]) ROOT_PROPS = { "RESOURCE_MANAGER": "resource-manager", "PULSE_COOKIE": "pulse-cookie", "PULSE_ID": "pulse-id", "PULSE_SERVER": "pulse-server", } def _handle_root_prop_changed(self, obj, prop, value): assert prop in self.ROOT_PROPS if value is not None: self.send([ "server-settings", { self.ROOT_PROPS[prop]: value.encode("utf-8") } ])
def handshake_complete(self, capabilities): self._xsettings_watcher = XSettingsWatcher() self._xsettings_watcher.connect("xsettings-changed", self._handle_xsettings_changed) self._handle_xsettings_changed() self._root_props_watcher = XRootPropWatcher(self.ROOT_PROPS.keys()) self._root_props_watcher.connect("root-prop-changed", self._handle_root_prop_changed) self._root_props_watcher.notify_all()
def test_basic_set_get(self): blob = "asdfwheeeee" manager = XSettingsManager(blob) watcher = XSettingsWatcher() assert watcher.get_settings_blob() == blob