Index: settings.py =================================================================== --- settings.py (revision 4468) +++ settings.py (working copy) @@ -41,7 +41,7 @@ elif dbus.version < (0, 42, 0): # XXX: when did the API break for service in the Python bindings? # The NEWS file implies it was 0.35 which is (0,42,0) - from settings2x import * + from settings33 import * else: from settings3x import * Index: session_dbus.py =================================================================== --- session_dbus.py (revision 4468) +++ session_dbus.py (working copy) @@ -2,6 +2,7 @@ from logging import info import mydbus as dbus dbus_version = dbus.dbus_version +broken_dbus3x = dbus.broken_dbus3x import constants Index: settings33.py =================================================================== --- settings33.py (revision 0) +++ settings33.py (revision 0) @@ -0,0 +1,54 @@ +from logging import info +import sys + +import constants +import mydbus as dbus +import xsettings + +class Settings(dbus.Object): + def __init__(self, service, manager): + dbus.Object.__init__(self, "/Settings", service) + self.xsettings_manager = manager + + def SetString(self, key, value): + self.set(key, str(value)) + SetString=dbus.method(constants.settings_interface)(SetString) + + def SetInt(self, key, value): + self.set(key, int(value)) + SetInt=dbus.method(constants.settings_interface)(SetInt) + + def set(self, key, value): + info("Setting %s = %s", key, value) + self.xsettings_manager.set(key, value) + self.xsettings_manager.notify() + self.xsettings_manager.save() + + def GetSetting(self, key): + try: + value = self.get(key, default = None) + if value is not None: + if isinstance(value, str): + return ["string", value] + else: + return ["int", str(value)] + raise Exception('Missing setting') + except Exception, ex: + print >>sys.stderr, ex + raise ex + GetSetting=dbus.method(constants.settings_interface)(GetSetting) + + + def get(self, key, default): + return self.xsettings_manager.get(key, default) + +def real_init(manager): + session_bus = dbus.SessionBus() + service = dbus.Service(constants.session_service, + bus = session_bus) + settings = Settings(service, manager) + info('now settings=%s', settings) + return settings + +def destroy(): + info("destroy settings") Index: main.py =================================================================== --- main.py (revision 4468) +++ main.py (working copy) @@ -34,8 +34,12 @@ bus = session_dbus.session_bus) SessionObject(service) elif dbus.dbus_version == 3: - service = dbus.service.BusName(constants.session_service, - bus = session_dbus.get_session_bus()) + if dbus.broken_dbus3x == 1: + service = dbus.Service(constants.session_service, + bus = session_dbus.get_session_bus()) + else: + service = dbus.service.BusName(constants.session_service, + bus = session_dbus.get_session_bus()) SessionObject3x(service) # This is like the D-BUS service, except using XML-RPC-over-X @@ -127,6 +131,27 @@ def ShowMessages(self, message): log.log.show_log_window() +elif session_dbus.dbus_version == 3 and dbus.broken_dbus3x: + class SessionObject3x(dbus.Object): + def __init__(self, service): + dbus.Object.__init__(self, "/Session", service) + + # Prefered syntax, but requires python 2.4 or later + #@dbus.service.method(constants.control_interface) + def LogoutWithoutConfirm(self): + g.main_quit() + ShowMessages=dbus.method(constants.control_interface)(LogoutWithoutConfirm) + + + def ShowOptions(self): + rox.edit_options() + ShowOptions=dbus.method(constants.control_interface)(ShowOptions) + + + def ShowMessages(self): + log.log.show_log_window() + ShowMessages=dbus.method(constants.control_interface)(ShowMessages) + elif session_dbus.dbus_version == 3: class SessionObject3x(dbus.service.Object): def __init__(self, service): Index: mydbus.py =================================================================== --- mydbus.py (revision 4468) +++ mydbus.py (working copy) @@ -5,11 +5,14 @@ sys.modules['dbus.services'] = dbus_compat dbus_version = 0 +broken_dbus3x = 0 try: from dbus import * if 'version' in globals() and version >= (0, 40, 0): dbus_version = 3 dbus_daemon = 'dbus-daemon' + if version <= (0, 42, 0): + broken_dbus3x = 1 info("D-BUS 0.3x detected") else: dbus_version = 2