summaryrefslogtreecommitdiff
path: root/examples/background-image.py
diff options
context:
space:
mode:
authorYaakov Selkowitz <[email protected]>2012-12-20 00:41:24 -0600
committerStefano Karapetsas <[email protected]>2013-01-22 14:10:00 +0100
commit825c1dd01981c159368a1a7a99931146fbbe60f1 (patch)
tree13a781b2b2023d06a1d8fb52d600e71ff40f911a /examples/background-image.py
parent29149f504a4e5e28a19b92d9ebb831bb53100a01 (diff)
downloadpython-caja-825c1dd01981c159368a1a7a99931146fbbe60f1.tar.bz2
python-caja-825c1dd01981c159368a1a7a99931146fbbe60f1.tar.xz
Port examples to g-i and gsettings
Diffstat (limited to 'examples/background-image.py')
-rw-r--r--examples/background-image.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/examples/background-image.py b/examples/background-image.py
index 0f5bea6..426dc4f 100644
--- a/examples/background-image.py
+++ b/examples/background-image.py
@@ -1,22 +1,18 @@
-import urllib
-
-import mateconf
-import caja
+from gi.repository import Caja, GObject, Gio
SUPPORTED_FORMATS = 'image/jpeg', 'image/png'
-BACKGROUND_KEY = '/desktop/mate/background/picture_filename'
+BACKGROUND_SCHEMA = 'org.mate.desktop.background'
+BACKGROUND_KEY = 'picture-uri'
-class BackgroundImageExtension(caja.MenuProvider):
+class BackgroundImageExtension(GObject.GObject, Caja.MenuProvider):
def __init__(self):
- self.mateconf = mateconf.client_get_default()
+ self.bgsettings = Gio.Settings.new(BACKGROUND_SCHEMA)
def menu_activate_cb(self, menu, file):
if file.is_gone():
return
- # Strip leading file://
- filename = urllib.unquote(file.get_uri()[7:])
- self.mateconf.set_string(BACKGROUND_KEY, filename)
+ self.bgsettings[BACKGROUND_KEY] = file.get_uri()
def get_file_items(self, window, files):
if len(files) != 1:
@@ -33,8 +29,8 @@ class BackgroundImageExtension(caja.MenuProvider):
if file.get_uri_scheme() != 'file':
return
- item = caja.MenuItem('Caja::set_background_image',
- 'Use as background image',
- 'Set the current image as a background image')
+ item = Caja.MenuItem(name='Caja::set_background_image',
+ label='Use as background image',
+ tip='Set the current image as a background image')
item.connect('activate', self.menu_activate_cb, file)
return item,