we can create new pages
authorChristian Weiske <cweiske@cweiske.de>
Tue, 15 Nov 2011 18:37:51 +0000 (19:37 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 15 Nov 2011 18:37:51 +0000 (19:37 +0100)
src/CurlyTxSettings.py
src/config.py

index 3a58ecb13da11dcfd8fb9759d8fefdf70bf869d7..0863b8c129279e8802445eadbc9be1f6cd803174 100644 (file)
@@ -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()
index 7c527b8d74a66469b704cef0e6cdd1550537bab0..9a98357d48fa7066300805ddfa4af0c9fd6e3d5b 100644 (file)
@@ -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