import cleanup
[enigma2-plugins.git] / lastfm / src / LastFMConfig.py
1 from Screens.Screen import Screen
2 from Components.config import config, getConfigListEntry
3 from Components.ConfigList import ConfigListScreen
4 from Components.Label import Label
5 from Components.ActionMap import ActionMap
6        
7 class LastFMConfigScreen(ConfigListScreen,Screen):
8     skin = """
9         <screen position="100,100" size="550,400" title="Last.FM Setup" >
10         <widget name="config" position="0,0" size="550,360" scrollbarMode="showOnDemand" />
11         <widget name="buttonred" position="10,360" size="100,40" backgroundColor="red" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/> 
12         <widget name="buttongreen" position="120,360" size="100,40" backgroundColor="green" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/> 
13         </screen>"""
14     def __init__(self, session, args = 0):
15         self.session = session
16         Screen.__init__(self, session)
17         self.list = []
18         self.list.append(getConfigListEntry(_("Last.FM Username"), config.plugins.LastFM.username))
19         self.list.append(getConfigListEntry(_("Password"), config.plugins.LastFM.password))
20         self.list.append(getConfigListEntry(_("send now playing Audio Tracks"), config.plugins.LastFM.sendSubmissions))
21         self.list.append(getConfigListEntry(_("Recommentation Level"), config.plugins.LastFM.recommendedlevel))
22         self.list.append(getConfigListEntry(_("show Coverart"), config.plugins.LastFM.showcoverart))
23         self.list.append(getConfigListEntry(_("Timeout Statustext (Seconds)"), config.plugins.LastFM.timeoutstatustext))
24         self.list.append(getConfigListEntry(_("Timeout to select a Tab (Seconds)"), config.plugins.LastFM.timeouttabselect))
25         self.list.append(getConfigListEntry(_("Interval to refresh Metadata (Seconds)"), config.plugins.LastFM.metadatarefreshinterval))
26
27         self.list.append(getConfigListEntry(_("use Screensaver"), config.plugins.LastFM.sreensaver.use))
28         self.list.append(getConfigListEntry(_("wait before Screensaver"), config.plugins.LastFM.sreensaver.wait))
29         self.list.append(getConfigListEntry(_("show Coverart in Screensaver"), config.plugins.LastFM.sreensaver.showcoverart))
30         self.list.append(getConfigListEntry(_("do Coverartanimation in Screensaver"), config.plugins.LastFM.sreensaver.coverartanimation))
31         self.list.append(getConfigListEntry(_("Speed for Coverartanimation"), config.plugins.LastFM.sreensaver.coverartspeed))
32         self.list.append(getConfigListEntry(_("Interval for Coverartanimation"), config.plugins.LastFM.sreensaver.coverartinterval))
33         
34         ConfigListScreen.__init__(self, self.list)
35         self["buttonred"] = Label(_("cancel"))
36         self["buttongreen"] = Label(_("ok"))
37         self["setupActions"] = ActionMap(["SetupActions"],
38         {
39             "green": self.save,
40             "red": self.cancel,
41             "save": self.save,
42             "cancel": self.cancel,
43             "ok": self.save,
44         }, -2)
45
46     def save(self):
47         print "saving"
48
49         
50         for x in self["config"].list:
51             x[1].save()
52         self.close(True)
53
54     def cancel(self):
55         print "cancel"
56         for x in self["config"].list:
57             x[1].cancel()
58         self.close(False)