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