--- /dev/null
+#!/usr/bin/env python
+# coding:utf-8
+# This is an example of a DCOP enabled application written in Python, using
+# PyKDE and the dcopexport module. Taken from server.py example in kde-bindings
+# which was written by Torben Weis and Julian Rockey
+
+import sys
+import randombg2
+from kdecore import KApplication, KCmdLineArgs, KAboutData
+from dcopexport import DCOPExObj
+from qt import QString, QStringList
+
+# the class which will expose methods to DCOP - the methods do NOT
+# need to be a member of this class.
+class RandomBGIface (DCOPExObj):
+ def __init__ (self, id = 'RandomBGIface'):
+ DCOPExObj.__init__ (self, id)
+
+ # the methods available from this app via DCOP
+ # addMethod (<signature>, <Python method>)
+ self.addMethod('QString getCurrentWallpaper()', self.getCurrent)
+ self.addMethod('void setCurrentWallpaper(QString)', self.changeTo)
+ self.addMethod('void cycleNextWallpaper()', self.cycleNext)
+ self.addMethod('void cyclePrevWallpaper()', self.cyclePrev)
+ self.addMethod('bool writeCache()', self.writeCache)
+
+ self.filelist = randombg2.AllRandomFileList()
+ self.filelist.doAddPaths([
+ '/home/greg/images_sfw/Futakoi',
+ '/home/greg/images_sfw/Moon Phase',
+ '/home/greg/images_sfw/Ouran High',
+ '/home/greg/images_sfw/Paniponi',
+ '/home/greg/images_sfw/Popotan',
+ '/home/greg/images_sfw/Rozen Maiden',
+ '/home/greg/images_sfw/Yotsuba',
+ '/home/greg/images_sfw/chobits',
+ '/home/greg/images_sfw/ichigo Mashimaro',
+ '/home/greg/images_sfw/カードキャプターさくら',
+ '/home/greg/images_sfw/涼宮ハルヒの憂鬱',
+ '/home/greg/images_sfw/灼眼のシャナ',
+ '/home/greg/images_sfw/舞-乙HiME',
+ '/home/greg/images_sfw/舞HiME',
+ '/home/greg/images_sfw/魔法先生ネギま',
+ '/home/greg/images_sfw/魔法少女リリカルなのは'])
+ #for path in ['/home/greg/images_sfw/Air','/home/greg/images_sfw/Azumanga Daioh','/home/greg/images_sfw/Futakoi','/home/greg/images_sfw/Karin','/home/greg/images_sfw/Love Hina','/home/greg/images_sfw/Moon Phase','/home/greg/images_sfw/Neon Genesis','/home/greg/images_sfw/Ouran High','/home/greg/images_sfw/Paniponi','/home/greg/images_sfw/Popotan','/home/greg/images_sfw/Rozen Maiden','/home/greg/images_sfw/Yotsuba','/home/greg/images_sfw/chobits','/home/greg/images_sfw/dot Hack','/home/greg/images_sfw/ichigo Mashimaro','/home/greg/images_sfw/kasimasi','/home/greg/images_sfw/カードキャププターさくら','/home/greg/images_sfw/涼宮ハルヒの憂鬱','/home/greg/images_sfw/灼眼のシャナ','/home/greg/images_sfw/舞-乙HiME','/home/greg/images_sfw/舞HiME','/home/greg/images_sfw/魔法先生ネギま','/home/greg/images_sfw/魔法少女リリカルなのは']:
+ # self.filelist.doAddPath(path)
+ if not self.filelist.attemptCacheLoad(randombg2.CACHE_LOCATION):
+ self.filelist.doScanPaths()
+ self.randombg = randombg2.RandomBG(self.filelist)
+
+ def getCurrent(self):
+ return self.filelist.getLastImage()
+
+ def changeTo(self, wallpaper):
+ self.randombg._randombg(wallpaper)
+
+ def cycleNext(self):
+ self.randombg.cycleNext()
+
+ def cyclePrev(self):
+ self.randombg.cyclePrev()
+
+ def writeCache(self):
+ if self.filelist.doStoreCache(randombg2.CACHE_LOCATION):
+ return True
+ else:
+ return False
+
+description = "A basic application template"
+version = "1.0"
+aboutData = KAboutData ("testdcopexport", "randombg",\
+ version, description, KAboutData.License_GPL,\
+ "(C) 2006 Greg Darke")
+
+aboutData.addAuthor ("James Bunton", "Origional Version", "jbun5313@usyd.edu.au")
+aboutData.addAuthor ("Greg Darke", "Coded the WMaker/KDE backends, the persistent random lists, and general bug fixes", "gdar9540@usyd.edu.au")
+
+KCmdLineArgs.init (sys.argv, aboutData)
+
+KCmdLineArgs.addCmdLineOptions ([("+paths", "Paths to scan for images")])
+
+MYAPPID = 'randombg'
+app = KApplication()
+dcop = app.dcopClient()
+appid = str(dcop.registerAs(MYAPPID, False))
+if appid != MYAPPID:
+ print >>sys.stderr, 'Failed to get the applicationid of "%s", this means this program is already running' % MYAPPID
+ print 'Got "%s"' % appid
+ sys.exit(1)
+
+print "DCOP Application: %s starting" % appid
+
+randombgIface = RandomBGIface()
+
+app.exec_loop()
+
+randombgIface.filelist.doStoreCache(randombg2.CACHE_LOCATION)