]>
code.delx.au - bg-scripts/blob - kde_randombg.py
3 # This is an example of a DCOP enabled application written in Python, using
4 # PyKDE and the dcopexport module. Taken from server.py example in kde-bindings
5 # which was written by Torben Weis and Julian Rockey
9 from kdecore
import KApplication
, KCmdLineArgs
, KAboutData
10 from dcopexport
import DCOPExObj
11 from qt
import QString
, QStringList
13 # the class which will expose methods to DCOP - the methods do NOT
14 # need to be a member of this class.
15 class RandomBGIface (DCOPExObj
):
16 def __init__ (self
, id = 'RandomBGIface'):
17 DCOPExObj
.__init
__ (self
, id)
19 # the methods available from this app via DCOP
20 # addMethod (<signature>, <Python method>)
21 self
.addMethod('QString getCurrentWallpaper()', self
.getCurrent
)
22 self
.addMethod('void setCurrentWallpaper(QString)', self
.changeTo
)
23 self
.addMethod('void cycleNextWallpaper()', self
.cycleNext
)
24 self
.addMethod('void cyclePrevWallpaper()', self
.cyclePrev
)
25 self
.addMethod('bool writeCache()', self
.writeCache
)
27 self
.filelist
= randombg2
.AllRandomFileList()
28 self
.filelist
.doAddPaths([
31 if not self
.filelist
.attemptCacheLoad(randombg2
.CACHE_LOCATION
):
32 self
.filelist
.doScanPaths()
33 self
.randombg
= randombg2
.RandomBG(self
.filelist
)
36 return self
.filelist
.getLastImage()
38 def changeTo(self
, wallpaper
):
39 self
.randombg
._randombg
(wallpaper
)
42 self
.randombg
.cycleNext()
45 self
.randombg
.cyclePrev()
48 if self
.filelist
.doStoreCache(randombg2
.CACHE_LOCATION
):
53 description
= "A basic application template"
55 aboutData
= KAboutData ("testdcopexport", "randombg",\
56 version
, description
, KAboutData
.License_GPL
,\
57 "(C) 2006 Greg Darke")
59 aboutData
.addAuthor ("James Bunton", "Origional Version", "jbun5313@usyd.edu.au")
60 aboutData
.addAuthor ("Greg Darke", "Coded the WMaker/KDE backends, the persistent random lists, and general bug fixes", "gdar9540@usyd.edu.au")
62 KCmdLineArgs
.init (sys
.argv
, aboutData
)
64 KCmdLineArgs
.addCmdLineOptions ([("+paths", "Paths to scan for images")])
68 dcop
= app
.dcopClient()
69 appid
= str(dcop
.registerAs(MYAPPID
, False))
71 print >>sys
.stderr
, 'Failed to get the applicationid of "%s", this means this program is already running' % MYAPPID
72 print 'Got "%s"' % appid
75 print "DCOP Application: %s starting" % appid
77 randombgIface
= RandomBGIface()
81 randombgIface
.filelist
.doStoreCache(randombg2
.CACHE_LOCATION
)