From 0155a052ca0944b213a4d1ec2a81a7252f8d5b5d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 15 Nov 2011 19:37:51 +0100 Subject: [PATCH 1/1] we can create new pages --- src/CurlyTxSettings.py | 35 ++++++++++++++++++++++++++++++++--- src/config.py | 24 ++++++++++++++++-------- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/CurlyTxSettings.py b/src/CurlyTxSettings.py index 3a58ecb..0863b8c 100644 --- a/src/CurlyTxSettings.py +++ b/src/CurlyTxSettings.py @@ -3,6 +3,7 @@ from Components.ActionMap import ActionMap, NumberActionMap from Components.Sources.StaticText import StaticText from . import config +from config import createPage from Components.config import config, getConfigListEntry from Components.ConfigList import ConfigList, ConfigListScreen @@ -71,19 +72,47 @@ class CurlyTxSettings(ConfigListScreen, Screen): id = self["config"].getCurrentIndex() del config.plugins.CurlyTx.pages[id] - config.plugins.CurlyTx.pageCount.value -= 1 self["config"].setList(self.getConfigList()) def newPage(self): - # FIXME + from CurlyTxSettings import CurlyTxSettings + self.session.openWithCallback(self.newPageCreated, CurlyTxPageEdit, createPage(), True) + + def newPageCreated(self, page, new): + if new: + config.plugins.CurlyTx.pages.append(page) + + self["config"].setList(self.getConfigList()) pass class CurlyTxPageEdit(Screen, ConfigListScreen): - def __init__(self, session): + def __init__(self, session, page, new = False): Screen.__init__(self, session) + self.skinName = [ "CurlyTxPageEdit", "Setup" ] self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) + + self["setupActions"] = ActionMap(["SetupActions"], + { + "save": self.save, + "cancel": self.keyCancel + }, -1) + + self.page = page + self.new = new + list = [ + getConfigListEntry(_("Page URL"), page.uri), + getConfigListEntry(_("Title"), page.title), + ] + ConfigListScreen.__init__(self, list, session = self.session) + + def save(self): + self.close(self.page, self.new) + #FIXME: pass page to parent + + def keyCancel(self): + self.close() diff --git a/src/config.py b/src/config.py index 7c527b8..9a98357 100644 --- a/src/config.py +++ b/src/config.py @@ -5,12 +5,20 @@ config.plugins.CurlyTx = ConfigSubsection() config.plugins.CurlyTx.menuMain = ConfigYesNo(default = True) config.plugins.CurlyTx.menuTitle = ConfigText(default = "CurlyTx") config.plugins.CurlyTx.pages = ConfigSubList() -i = 0 -while i < len(config.plugins.CurlyTx.pages): - s = ConfigSubsection() - s.uri = ConfigText(default="http://", fixed_size=False) - config.plugins.CurlyTx.pages.append(s) - i += 1 - del s -del i +#i = 0 +#while i < len(config.plugins.CurlyTx.pages): +# config.plugins.CurlyTx.pages.append(createPage) +# i += 1 +# del s +#del i #config.plugins.CurlyTx.defaultPage = ConfigNumber(default=0) + + +def createPage(): + s = ConfigSubsection() + s.uri = ConfigText(default="http://", fixed_size=False) + s.title = ConfigText( + default = "Page #" + str(len(config.plugins.CurlyTx.pages) + 1), + fixed_size = False + ) + return s -- 2.30.2