3 from Screens.Screen import Screen
4 from Screens.HelpMenu import HelpableScreen
5 from Components.ActionMap import ActionMap, NumberActionMap
6 from Components.Sources.StaticText import StaticText
9 from config import createPage, loadDefaultPageOptions
10 from Components.config import config, getConfigListEntry, ConfigSelection
11 from Components.ConfigList import ConfigList, ConfigListScreen
13 class CurlyTxSettings(ConfigListScreen, HelpableScreen, Screen):
15 <screen name="Setup" position="center,center" size="560,430" title="Setup">
16 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
17 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
18 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
19 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
20 <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" />
21 <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" />
22 <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" />
23 <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" />
24 <widget name="config" position="5,50" size="550,325" scrollbarMode="showOnDemand" />
27 def __init__(self, session):
28 self.skin = CurlyTxSettings.skin
29 Screen.__init__(self, session)
30 HelpableScreen.__init__(self)
31 #self.skinName = [ "CurlyTxSettings", "Setup" ]
32 self.setup_title = _("Settings")
34 self["actions"] = ActionMap(["SetupActions","ColorActions"],
36 "cancel": self.keyCancel,
39 "yellow": self.newPage,
40 "blue": self.deletePage
43 self["key_red"] = StaticText(_("Cancel"))
44 self["key_green"] = StaticText(_("OK"))
45 self["key_yellow"] = StaticText(_("New"))
46 self["key_blue"] = StaticText(_("Delete"))
48 ConfigListScreen.__init__(self, self.getConfigList(), session = self.session)
51 self.onClose.append(self.abort)
53 def getConfigList(self):
55 loadDefaultPageOptions()
58 getConfigListEntry(_("Page:") + " " + x.title.value, x.uri)
59 for x in config.plugins.CurlyTx.pages
61 if len(config.plugins.CurlyTx.pages):
62 list.append(getConfigListEntry(_("Default page"), config.plugins.CurlyTx.defaultPage))
63 list.append(getConfigListEntry(_("Show in main menu"), config.plugins.CurlyTx.menuMain))
64 list.append(getConfigListEntry(_("Show in extensions menu"), config.plugins.CurlyTx.menuExtensions))
65 list.append(getConfigListEntry(_("Menu title"), config.plugins.CurlyTx.menuTitle))
69 self.helpList.append((
70 self["actions"], "SetupActions",
71 [("cancel", _("Dismiss all setting changes"))]))
72 self.helpList.append((
73 self["actions"], "SetupActions",
74 [("save", _("Save settings and close screen"))]))
75 self.helpList.append((
76 self["actions"], "SetupActions",
77 [("ok", _("Edit selected page"))]))
78 self.helpList.append((
79 self["actions"], "ColorActions",
80 [("yellow", _("Add new page"))]))
81 self.helpList.append((
82 self["actions"], "ColorActions",
83 [("blue", _("Delete selected page"))]))
86 ConfigListScreen.keyLeft(self)
89 ConfigListScreen.keyRight(self)
92 if len(config.plugins.CurlyTx.pages) == 0:
95 from Screens.MessageBox import MessageBox
96 self.session.openWithCallback(
97 self.deletePageConfirm,
99 _("Really delete this page?\nIt cannot be recovered!")
102 def deletePageConfirm(self, result):
106 id = self["config"].getCurrentIndex()
107 del config.plugins.CurlyTx.pages[id]
109 config.plugins.CurlyTx.pages.save()
111 self["config"].setList(self.getConfigList())
114 from CurlyTxSettings import CurlyTxSettings
115 self.session.openWithCallback(self.pageEdited, CurlyTxPageEdit, createPage(), True)
118 id = self["config"].getCurrentIndex()
119 if id < len(config.plugins.CurlyTx.pages):
120 self.session.openWithCallback(
121 self.pageEdited, CurlyTxPageEdit,
122 config.plugins.CurlyTx.pages[id], False
125 def pageEdited(self, page, new):
130 config.plugins.CurlyTx.pages.append(page)
132 self["config"].setList(self.getConfigList())
136 for i in range(0, len(config.plugins.CurlyTx.pages)):
137 config.plugins.CurlyTx.pages[i].save()
139 config.plugins.CurlyTx.pages.save()
140 ConfigListScreen.keySave(self)
147 class CurlyTxPageEdit(Screen, ConfigListScreen):
148 def __init__(self, session, page, new = False):
149 Screen.__init__(self, session)
150 self.skinName = [ "CurlyTxPageEdit", "Setup" ]
152 self["key_red"] = StaticText(_("Cancel"))
153 self["key_green"] = StaticText(_("OK"))
155 self["setupActions"] = ActionMap(["SetupActions"],
158 "cancel": self.keyCancel
164 getConfigListEntry(_("Page URL"), page.uri),
165 getConfigListEntry(_("Title"), page.title),
166 getConfigListEntry(_("Font size"), page.fontSize),
168 ConfigListScreen.__init__(self, list, session = self.session)
171 self.close(self.page, self.new)
174 self.close(None, self.new)