1 from Screens.Screen import Screen
2 from Screens.HelpMenu import HelpableScreen
3 from Components.ActionMap import ActionMap, NumberActionMap
4 from Components.Sources.StaticText import StaticText
7 from config import createPage, loadDefaultPageOptions
8 from Components.config import config, getConfigListEntry, ConfigSelection
9 from Components.ConfigList import ConfigList, ConfigListScreen
11 class CurlyTxSettings(ConfigListScreen, HelpableScreen, Screen):
13 <screen name="Setup" position="center,center" size="560,430" title="Setup">
14 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
15 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
16 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
17 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
18 <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" />
19 <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" />
20 <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" />
21 <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" />
22 <widget name="config" position="5,50" size="550,325" scrollbarMode="showOnDemand" />
25 def __init__(self, session):
26 self.skin = CurlyTxSettings.skin
27 Screen.__init__(self, session)
28 HelpableScreen.__init__(self)
29 #self.skinName = [ "CurlyTxSettings", "Setup" ]
30 self.setup_title = _("Settings")
32 self["actions"] = ActionMap(["SetupActions","ColorActions"],
34 "cancel": self.keyCancel,
37 "yellow": self.newPage,
38 "blue": self.deletePage
41 self["key_red"] = StaticText(_("Cancel"))
42 self["key_green"] = StaticText(_("OK"))
43 self["key_yellow"] = StaticText(_("New"))
44 self["key_blue"] = StaticText(_("Delete"))
46 ConfigListScreen.__init__(self, self.getConfigList(), session = self.session)
49 self.onClose.append(self.abort)
51 def getConfigList(self):
53 loadDefaultPageOptions()
56 getConfigListEntry(_("Page:") + " " + x.title.value, x.uri)
57 for x in config.plugins.CurlyTx.pages
59 list.append(getConfigListEntry(_("Default page"), config.plugins.CurlyTx.defaultPage))
60 list.append(getConfigListEntry(_("Show in main menu"), config.plugins.CurlyTx.menuMain))
61 list.append(getConfigListEntry(_("Show in extensions menu"), config.plugins.CurlyTx.menuExtensions))
62 list.append(getConfigListEntry(_("Menu title"), config.plugins.CurlyTx.menuTitle))
66 self.helpList.append((
67 self["actions"], "SetupActions",
68 [("cancel", _("Dismiss all setting changes"))]))
69 self.helpList.append((
70 self["actions"], "SetupActions",
71 [("save", _("Save settings and close screen"))]))
72 self.helpList.append((
73 self["actions"], "SetupActions",
74 [("ok", _("Edit selected page"))]))
75 self.helpList.append((
76 self["actions"], "ColorActions",
77 [("yellow", _("Add new page"))]))
78 self.helpList.append((
79 self["actions"], "ColorActions",
80 [("blue", _("Delete selected page"))]))
83 ConfigListScreen.keyLeft(self)
86 ConfigListScreen.keyRight(self)
89 if len(config.plugins.CurlyTx.pages) == 0:
92 from Screens.MessageBox import MessageBox
93 self.session.openWithCallback(
94 self.deletePageConfirm,
96 _("Really delete this page?\nIt cannot be recovered!")
99 def deletePageConfirm(self, result):
103 id = self["config"].getCurrentIndex()
104 del config.plugins.CurlyTx.pages[id]
106 config.plugins.CurlyTx.pages.save()
108 self["config"].setList(self.getConfigList())
111 from CurlyTxSettings import CurlyTxSettings
112 self.session.openWithCallback(self.pageEdited, CurlyTxPageEdit, createPage(), True)
115 id = self["config"].getCurrentIndex()
116 if id < len(config.plugins.CurlyTx.pages):
117 self.session.openWithCallback(
118 self.pageEdited, CurlyTxPageEdit,
119 config.plugins.CurlyTx.pages[id], False
122 def pageEdited(self, page, new):
127 config.plugins.CurlyTx.pages.append(page)
129 self["config"].setList(self.getConfigList())
133 for i in range(0, len(config.plugins.CurlyTx.pages)):
134 config.plugins.CurlyTx.pages[i].save()
136 config.plugins.CurlyTx.pages.save()
137 ConfigListScreen.keySave(self)
144 class CurlyTxPageEdit(Screen, ConfigListScreen):
145 def __init__(self, session, page, new = False):
146 Screen.__init__(self, session)
147 self.skinName = [ "CurlyTxPageEdit", "Setup" ]
149 self["key_red"] = StaticText(_("Cancel"))
150 self["key_green"] = StaticText(_("OK"))
152 self["setupActions"] = ActionMap(["SetupActions"],
155 "cancel": self.keyCancel
161 getConfigListEntry(_("Page URL"), page.uri),
162 getConfigListEntry(_("Title"), page.title),
164 ConfigListScreen.__init__(self, list, session = self.session)
167 self.close(self.page, self.new)
170 self.close(None, self.new)