]>
code.delx.au - bg-scripts/blob - bin/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([
29 '/home/greg/images_sfw/Futakoi',
30 '/home/greg/images_sfw/Moon Phase',
31 '/home/greg/images_sfw/Ouran High',
32 '/home/greg/images_sfw/Paniponi',
33 '/home/greg/images_sfw/Popotan',
34 '/home/greg/images_sfw/Rozen Maiden',
35 '/home/greg/images_sfw/Yotsuba',
36 '/home/greg/images_sfw/chobits',
37 '/home/greg/images_sfw/ichigo Mashimaro',
38 '/home/greg/images_sfw/カードキャプターさくら',
39 '/home/greg/images_sfw/涼宮ハルヒの憂鬱',
40 '/home/greg/images_sfw/灼眼のシャナ',
41 '/home/greg/images_sfw/舞-乙HiME',
42 '/home/greg/images_sfw/舞HiME',
43 '/home/greg/images_sfw/魔法先生ネギま',
44 '/home/greg/images_sfw/魔法少女リリカルなのは'])
45 #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/魔法少女リリカルなのは']:
46 # self.filelist.doAddPath(path)
47 if not self
.filelist
.attemptCacheLoad(randombg2
.CACHE_LOCATION
):
48 self
.filelist
.doScanPaths()
49 self
.randombg
= randombg2
.RandomBG(self
.filelist
)
52 return self
.filelist
.getLastImage()
54 def changeTo(self
, wallpaper
):
55 self
.randombg
._randombg
(wallpaper
)
58 self
.randombg
.cycleNext()
61 self
.randombg
.cyclePrev()
64 if self
.filelist
.doStoreCache(randombg2
.CACHE_LOCATION
):
69 description
= "A basic application template"
71 aboutData
= KAboutData ("testdcopexport", "randombg",\
72 version
, description
, KAboutData
.License_GPL
,\
73 "(C) 2006 Greg Darke")
75 aboutData
.addAuthor ("James Bunton", "Origional Version", "jbun5313@usyd.edu.au")
76 aboutData
.addAuthor ("Greg Darke", "Coded the WMaker/KDE backends, the persistent random lists, and general bug fixes", "gdar9540@usyd.edu.au")
78 KCmdLineArgs
.init (sys
.argv
, aboutData
)
80 KCmdLineArgs
.addCmdLineOptions ([("+paths", "Paths to scan for images")])
84 dcop
= app
.dcopClient()
85 appid
= str(dcop
.registerAs(MYAPPID
, False))
87 print >>sys
.stderr
, 'Failed to get the applicationid of "%s", this means this program is already running' % MYAPPID
88 print 'Got "%s"' % appid
91 print "DCOP Application: %s starting" % appid
93 randombgIface
= RandomBGIface()
97 randombgIface
.filelist
.doStoreCache(randombg2
.CACHE_LOCATION
)