show pages in settings screen
[enigma2-curlytx.git] / src / CurlyTxSettings.py
1 from Screens.Screen import Screen
2 from Components.ActionMap import ActionMap, NumberActionMap
3 from Components.Sources.StaticText import StaticText
4
5 from . import config
6 from Components.config import config, getConfigListEntry
7 from Components.ConfigList import ConfigList, ConfigListScreen
8
9 class CurlyTxSettings(ConfigListScreen, Screen):
10     skin = """
11         <screen name="Setup" position="center,center" size="560,430" title="Setup">
12           <ePixmap pixmap="skin_default/buttons/red.png"    position="0,0"   size="140,40" transparent="1" alphatest="on" />
13           <ePixmap pixmap="skin_default/buttons/green.png"  position="140,0" size="140,40" transparent="1" alphatest="on" />
14           <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
15           <ePixmap pixmap="skin_default/buttons/blue.png"   position="420,0" size="140,40" transparent="1" alphatest="on" />
16           <widget source="key_red"    render="Label" position="0,0"   zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
17           <widget source="key_green"  render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
18           <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#a08500" transparent="1" />
19           <widget source="key_blue"   render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1" />
20           <widget name="config" position="5,50" size="550,325" scrollbarMode="showOnDemand" />
21         </screen>"""
22
23     def __init__(self, session):
24         self.skin = CurlyTxSettings.skin
25         Screen.__init__(self, session)
26         #self.skinName = [ "CurlyTxSettings", "Setup" ]
27         self.setup_title = _("Settings")
28
29         self["actions"] = ActionMap(["SetupActions","ColorActions"],
30             {
31                 "cancel": self.keyCancel,
32                 "save": self.keySave,
33                 #"ok": self.ok,
34                 "blue": self.deletePage,
35                 "yellow": self.newPage
36             }, -2)
37
38         self["key_red"]    = StaticText(_("Cancel"))
39         self["key_green"]  = StaticText(_("OK"))
40         self["key_yellow"] = StaticText(_("New"))
41         self["key_blue"]   = StaticText(_("Delete"))
42
43         ConfigListScreen.__init__(self, self.getConfigList(), session = self.session)
44
45     def getConfigList(self):
46         list = [
47             getConfigListEntry(_("Page"), x.uri)
48                 for x in config.plugins.CurlyTx.pages
49             ]
50         list.append(getConfigListEntry(_("Show in main menu"), config.plugins.CurlyTx.menuMain))
51         list.append(getConfigListEntry(_("Menu title"), config.plugins.CurlyTx.menuTitle))
52         return list
53
54     def keyLeft(self):
55         ConfigListScreen.keyLeft(self)
56
57     def keyRight(self):
58         ConfigListScreen.keyRight(self)
59
60     def deletePage(self):
61         from Screens.MessageBox import MessageBox
62         self.session.openWithCallback(
63             self.deletePageConfirm,
64             MessageBox,
65             _("Really delete this page?\nIt cannot be recovered!")
66         )
67
68     def deletePageConfirm(self, result):
69         if not result:
70             return
71
72         id = self["config"].getCurrentIndex()
73         del config.plugins.CurlyTx.pages[id]
74         config.plugins.CurlyTx.pageCount.value -= 1
75
76         self["config"].setList(self.getConfigList())
77
78     def newPage(self):
79         # FIXME
80         pass
81
82
83
84 class CurlyTxPageEdit(Screen, ConfigListScreen):
85     def __init__(self, session):
86         Screen.__init__(self, session)
87
88         self["key_red"]   = StaticText(_("Cancel"))
89         self["key_green"] = StaticText(_("OK"))