[LastFM] Show playing track on LCD screen
[enigma2-plugins.git] / lastfm / src / LastFMConfig.py
1 from Screens.Screen import Screen
2 from Components.config import config, getConfigListEntry, ConfigSubsection
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
9     config.plugins.LastFM = ConfigSubsection()
10     
11     skin = """
12         <screen position="center,center" size="600,480" title="%s" >
13         
14         <widget name="config" position="10,0" size="580,400" scrollbarMode="showOnDemand" />
15         
16         <widget name="buttonred" position="10,430" size="140,40" valign=\"center\" halign=\"center\" zPosition=\"2\" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" font=\"Regular;18\" />          
17         <widget name="buttongreen" position="150,430" size="140,40" valign=\"center\" halign=\"center\" zPosition=\"2\" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" font=\"Regular;18\"/>            
18         <ePixmap pixmap="skin_default/buttons/red.png" position="10,430" zPosition="1" size="140,40" transparent="1" alphatest="on" />
19         <ePixmap pixmap="skin_default/buttons/green.png" position="150,430" zPosition="1" size="140,40" transparent="1" alphatest="on" />
20
21         </screen>""" %(
22             "Last.FM" + " " + _("Setup")  # title
23             #config.plugins.LastFM.name.value + " " + _("Setup") # commented out, because I couldn't get it working :-(
24         ) 
25                         
26     def __init__(self, session, args = 0):
27         self.session = session
28         Screen.__init__(self, session)
29         self.list = [
30                         getConfigListEntry(_("Show in (needs GUI restart)"), config.plugins.LastFM.menu),
31                         getConfigListEntry(_("Name (needs GUI restart)"), config.plugins.LastFM.name),
32                         getConfigListEntry(_("Description"), config.plugins.LastFM.description),
33                         getConfigListEntry(_("Last.FM Username"), config.plugins.LastFM.username),
34                         getConfigListEntry(_("Password"), config.plugins.LastFM.password),
35                         getConfigListEntry(_("Send now playing Audio Tracks"), config.plugins.LastFM.sendSubmissions),
36                         getConfigListEntry(_("Use LastFM Proxy"), config.plugins.LastFM.useproxy),
37                         getConfigListEntry(_("LastFM Proxy port"), config.plugins.LastFM.proxyport),
38                         getConfigListEntry(_("Recommendation level"), config.plugins.LastFM.recommendedlevel),
39                         getConfigListEntry(_("Show Coverart"), config.plugins.LastFM.showcoverart),
40                         getConfigListEntry(_("Timeout Statustext (seconds)"), config.plugins.LastFM.timeoutstatustext),
41                         getConfigListEntry(_("Timeout to select a Tab (seconds)"), config.plugins.LastFM.timeouttabselect),
42                         getConfigListEntry(_("Interval to refresh Metadata (seconds)"), config.plugins.LastFM.metadatarefreshinterval),
43                         getConfigListEntry(_("Use Screensaver"), config.plugins.LastFM.sreensaver.use),
44                         getConfigListEntry(_("Wait before Screensaver (seconds)"), config.plugins.LastFM.sreensaver.wait),
45                         getConfigListEntry(_("Show Coverart in Screensaver"), config.plugins.LastFM.sreensaver.showcoverart),
46                         getConfigListEntry(_("Show Coverart Animation in Screensaver"), config.plugins.LastFM.sreensaver.coverartanimation),
47                         getConfigListEntry(_("Speed for Coverart Animation"), config.plugins.LastFM.sreensaver.coverartspeed),
48                         getConfigListEntry(_("Interval for Coverart Animation"), config.plugins.LastFM.sreensaver.coverartinterval),
49                                 ]
50         ConfigListScreen.__init__(self, self.list)
51         self["buttonred"] = Label(_("Cancel"))
52         self["buttongreen"] = Label(_("OK"))
53         self["setupActions"] = ActionMap(["SetupActions"],
54         {
55             "green": self.save,
56             "red": self.cancel,
57             "save": self.save,
58             "cancel": self.cancel,
59             "ok": self.save,
60         }, -2)
61
62     def save(self):
63         print "saving"
64
65         
66         for x in self["config"].list:
67             x[1].save()
68         self.close(True)
69
70     def cancel(self):
71         print "cancel"
72         for x in self["config"].list:
73             x[1].cancel()
74         self.close(False)