class XSettingsManager(object): def __init__(self, screen_number=0): selection = "_XSETTINGS_S%i" % screen_number self._manager = ManagerSelection(display_get_default(), selection) # Technically I suppose ICCCM says we should use FORCE, but it's not # like a window manager where you have to wait for the old wm to clean # things up before you can do anything... as soon as the selection is # gone, the settings are gone. (Also, if we're stealing from # ourselves, we probably don't clean up the window properly.) self._manager.acquire(self._manager.FORCE_AND_RETURN) self._window = self._manager.window() def set_settings(self, settings): if isinstance(settings, list): settings = tuple(settings) elif not isinstance(settings, tuple): log.warn( "Warning: discarding xsettings because of incompatible format: %s", type(settings)) return try: prop_set(self._window, XSETTINGS, XSETTINGS_TYPE, settings) except XError as e: log.error("Error: XSettings not applied") log.error(" %s", e)
class XSettingsManager(object): def __init__(self, screen_number=0): selection = "_XSETTINGS_S%s" % screen_number self._manager = ManagerSelection(gtk.gdk.display_get_default(), selection) # Technically I suppose ICCCM says we should use FORCE, but it's not # like a window manager where you have to wait for the old wm to clean # things up before you can do anything... as soon as the selection is # gone, the settings are gone. (Also, if we're stealing from # ourselves, we probably don't clean up the window properly.) self._manager.acquire(self._manager.FORCE_AND_RETURN) self._window = self._manager.window() def set_settings(self, settings): if type(settings)!=tuple: log.warn("discarding xsettings because of incompatible format: %s", type(settings)) return prop_set(self._window, XSETTINGS, XSETTINGS_TYPE, settings)
class XSettingsManager(object): def __init__(self, screen_number=0): selection = "_XSETTINGS_S%s" % screen_number self._manager = ManagerSelection(gtk.gdk.display_get_default(), selection) # Technically I suppose ICCCM says we should use FORCE, but it's not # like a window manager where you have to wait for the old wm to clean # things up before you can do anything... as soon as the selection is # gone, the settings are gone. (Also, if we're stealing from # ourselves, we probably don't clean up the window properly.) self._manager.acquire(self._manager.FORCE_AND_RETURN) self._window = self._manager.window() # This is factored out as a separate function to make it easier to test # XSettingsWatcher: def set_blob_in_place(self, settings_blob): if type(settings_blob)!=tuple: log.warn("discarding xsettings because of incompatible format: %s", type(settings_blob)) return prop_set(self._window, XSETTINGS, XSETTINGS_TYPE, settings_blob)