diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-10-31 14:35:53 -0700 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2015-12-04 15:09:02 +0000 |
commit | 246e5b03a137e64611c6f1e368250804d66f73f6 (patch) | |
tree | aaf7438e429f51ac4f8ae3224b7dc6db46a6979a /examples | |
parent | 6185aeb81969b82da804c66958d64bc628cb5aa4 (diff) |
Fix GConf examples
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85720
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[smcv: separate out some changes into separate commits]
Diffstat (limited to 'examples')
-rwxr-xr-x[-rw-r--r--] | examples/gconf-proxy-client.py | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/gconf-proxy-service2.py | 43 |
2 files changed, 23 insertions, 25 deletions
diff --git a/examples/gconf-proxy-client.py b/examples/gconf-proxy-client.py index e485796..2e440f4 100644..100755 --- a/examples/gconf-proxy-client.py +++ b/examples/gconf-proxy-client.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -print "WARNING: this hasn't been updated to current API yet, and might not work" - # Copyright (C) 2004-2006 Red Hat Inc. <http://www.redhat.com/> # Copyright (C) 2005-2007 Collabora Ltd. <http://www.collabora.co.uk/> # @@ -30,8 +28,7 @@ import dbus gconf_key = "/desktop/gnome/file_views/icon_theme" bus = dbus.SessionBus() -gconf_service = bus.get_service("org.gnome.GConf") -gconf_key_object = gconf_service.get_object("/org/gnome/GConf" + gconf_key, "org.gnome.GConf") +gconf_key_object = dbus.Interface(bus.get_object("org.gnome.GConf.Example", "/org/gnome/GConf" + gconf_key), "org.gnome.GConf") value = gconf_key_object.getString() diff --git a/examples/gconf-proxy-service2.py b/examples/gconf-proxy-service2.py index f805b77..7ce132b 100644..100755 --- a/examples/gconf-proxy-service2.py +++ b/examples/gconf-proxy-service2.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -print "WARNING: this hasn't been updated to current API yet, and might not work" -#FIXME: doesn't work with the new bindings # Copyright (C) 2004-2006 Red Hat Inc. <http://www.redhat.com/> # Copyright (C) 2005-2007 Collabora Ltd. <http://www.collabora.co.uk/> @@ -26,36 +24,39 @@ print "WARNING: this hasn't been updated to current API yet, and might not work" # DEALINGS IN THE SOFTWARE. import dbus +import dbus.mainloop.glib +import dbus.service import gobject import gconf -class GConfService(dbus.Service): +dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) +# there is a real service called "org.gnome.GConf"; don't collide with it. +name = dbus.service.BusName("org.gnome.GConf.Example", dbus.SessionBus()) + +class GConfObject(dbus.service.FallbackObject): def __init__(self): - dbus.Service.__init__(self, "org.gnome.GConf", dbus.SessionBus()) + dbus.service.FallbackObject.__init__(self, dbus.SessionBus(), '/org/gnome/GConf') + self.client = gconf.client_get_default() - gconf_object_tree = self.GConfObjectTree(self) - - class GConfObjectTree(dbus.ObjectTree): - def __init__(self, service): - dbus.ObjectTree.__init__(self, "/org/gnome/GConf", service) + @dbus.service.method("org.gnome.GConf", in_signature='', out_signature='s', rel_path_keyword='object_path') + def getString(self, object_path): + return self.client.get_string(object_path) - self.client = gconf.client_get_default() + @dbus.service.method("org.gnome.GConf", in_signature='s', out_signature='', rel_path_keyword='object_path') + def setString(self, value, object_path): + self.client.set_string(object_path, value) - def object_method_called(self, message, object_path, method_name, argument_list): - print ("Method %s called on GConf key %s" % (method_name, object_path)) + @dbus.service.method("org.gnome.GConf", in_signature='', out_signature='i', rel_path_keyword='object_path') + def getInt(self, object_path): + return self.client.get_int(object_path) - if "getString" == method_name: - return self.client.get_string(object_path) - elif "setString" == method_name: - self.client.set_int(object_path, argument_list[0]) - elif "getInt" == method_name: - return self.client.get_int(object_path) - elif "setInt" == method_name: - self.client.set_int(object_path, argument_list[0]) + @dbus.service.method("org.gnome.GConf", in_signature='i', out_signature='', rel_path_keyword='object_path') + def setInt(self, value, object_path): + self.client.set_int(object_path, value) -gconf_service = GConfService() +gconf_service = GConfObject() print ("GConf Proxy service started.") print ("Run 'gconf-proxy-client.py' to fetch a GConf key through the proxy...") |