1 from Screens.Screen import Screen
2 from Components.ActionMap import ActionMap, NumberActionMap
3 from Components.Sources.StaticText import StaticText
6 from config import createPage, loadDefaultPageOptions
7 from Components.config import config, getConfigListEntry, ConfigSelection
8 from Components.ConfigList import ConfigList, ConfigListScreen
10 class CurlyTxSettings(ConfigListScreen, Screen):
12 <screen name="Setup" position="center,center" size="560,430" title="Setup">
13 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
14 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
15 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
16 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
17 <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" />
18 <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" />
19 <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" />
20 <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" />
21 <widget name="config" position="5,50" size="550,325" scrollbarMode="showOnDemand" />
24 def __init__(self, session):
25 self.skin = CurlyTxSettings.skin
26 Screen.__init__(self, session)
27 #self.skinName = [ "CurlyTxSettings", "Setup" ]
28 self.setup_title = _("Settings")
30 self["actions"] = ActionMap(["SetupActions","ColorActions"],
32 "cancel": self.keyCancel,
35 "blue": self.deletePage,
36 "yellow": self.newPage
39 self["key_red"] = StaticText(_("Cancel"))
40 self["key_green"] = StaticText(_("OK"))
41 self["key_yellow"] = StaticText(_("New"))
42 self["key_blue"] = StaticText(_("Delete"))
44 ConfigListScreen.__init__(self, self.getConfigList(), session = self.session)
45 self.onClose.append(self.abort)
47 def getConfigList(self):
49 loadDefaultPageOptions()
52 getConfigListEntry(_("Page:") + " " + x.title.value, x.uri)
53 for x in config.plugins.CurlyTx.pages
55 list.append(getConfigListEntry(_("Default page"), config.plugins.CurlyTx.defaultPage))
56 list.append(getConfigListEntry(_("Show in main menu"), config.plugins.CurlyTx.menuMain))
57 list.append(getConfigListEntry(_("Show in extensions menu"), config.plugins.CurlyTx.menuExtensions))
58 list.append(getConfigListEntry(_("Menu title"), config.plugins.CurlyTx.menuTitle))
62 ConfigListScreen.keyLeft(self)
65 ConfigListScreen.keyRight(self)
68 if len(config.plugins.CurlyTx.pages) == 0:
71 from Screens.MessageBox import MessageBox
72 self.session.openWithCallback(
73 self.deletePageConfirm,
75 _("Really delete this page?\nIt cannot be recovered!")
78 def deletePageConfirm(self, result):
82 id = self["config"].getCurrentIndex()
83 del config.plugins.CurlyTx.pages[id]
85 config.plugins.CurlyTx.pages.save()
87 self["config"].setList(self.getConfigList())
90 from CurlyTxSettings import CurlyTxSettings
91 self.session.openWithCallback(self.pageEdited, CurlyTxPageEdit, createPage(), True)
94 id = self["config"].getCurrentIndex()
95 if id < len(config.plugins.CurlyTx.pages):
96 self.session.openWithCallback(
97 self.pageEdited, CurlyTxPageEdit,
98 config.plugins.CurlyTx.pages[id], False
101 def pageEdited(self, page, new):
106 config.plugins.CurlyTx.pages.append(page)
108 self["config"].setList(self.getConfigList())
112 for i in range(0, len(config.plugins.CurlyTx.pages)):
113 config.plugins.CurlyTx.pages[i].save()
115 config.plugins.CurlyTx.pages.save()
116 ConfigListScreen.keySave(self)
123 class CurlyTxPageEdit(Screen, ConfigListScreen):
124 def __init__(self, session, page, new = False):
125 Screen.__init__(self, session)
126 self.skinName = [ "CurlyTxPageEdit", "Setup" ]
128 self["key_red"] = StaticText(_("Cancel"))
129 self["key_green"] = StaticText(_("OK"))
131 self["setupActions"] = ActionMap(["SetupActions"],
134 "cancel": self.keyCancel
140 getConfigListEntry(_("Page URL"), page.uri),
141 getConfigListEntry(_("Title"), page.title),
143 ConfigListScreen.__init__(self, list, session = self.session)
146 self.close(self.page, self.new)
149 self.close(None, self.new)