emission: initial checkin to this repository
[enigma2-plugins.git] / emission / src / EmissionSetup.py
1 # GUI (Screens)
2 from Screens.Screen import Screen
3 from Components.ConfigList import ConfigListScreen
4
5 # GUI (Summary)
6 from Screens.Setup import SetupSummary
7
8 # GUI (Components)
9 from Components.ActionMap import ActionMap
10 from Components.Sources.StaticText import StaticText
11
12 # Configuration
13 from Components.config import config, getConfigListEntry
14
15 class EmissionSetup(Screen, ConfigListScreen):
16         def __init__(self, session):
17                 Screen.__init__(self, session)
18                 self.skinName = [ "EmissionSetup", "Setup" ]
19
20                 # Summary
21                 self.setup_title = _("eMission settings")
22                 self.onChangedEntry = []
23
24                 ConfigListScreen.__init__(
25                         self,
26                         [
27                                 getConfigListEntry(_("Hostname"), config.plugins.emission.hostname),
28                                 getConfigListEntry(_("Username"), config.plugins.emission.username),
29                                 getConfigListEntry(_("Password"), config.plugins.emission.password),
30                                 getConfigListEntry(_("Port"), config.plugins.emission.port),
31                                 getConfigListEntry(_("Auto-add torrent enclosures from SimpleRSS"), config.plugins.emission.autodownload_from_simplerss),
32                         ],
33                         session = session,
34                         on_change = self.changed
35                 )
36
37                 # Initialize widgets
38                 self["key_green"] = StaticText(_("OK"))
39                 self["key_red"] = StaticText(_("Cancel"))
40
41                 # Define Actions
42                 self["actions"] = ActionMap(["SetupActions"],
43                         {
44                                 "cancel": self.keyCancel,
45                                 "save": self.keySave,
46                         }
47                 )
48
49                 # Trigger change
50                 self.changed()
51
52                 self.onLayoutFinish.append(self.setCustomTitle)
53
54         def setCustomTitle(self):
55                 self.setTitle(self.setup_title)
56
57         def changed(self):
58                 for x in self.onChangedEntry:
59                         x()
60
61         def getCurrentEntry(self):
62                 return self["config"].getCurrent()[0]
63
64         def getCurrentValue(self):
65                 return str(self["config"].getCurrent()[1].getText())
66
67         def createSummary(self):
68                 return SetupSummary
69