show pages in settings screen
authorChristian Weiske <cweiske@cweiske.de>
Tue, 15 Nov 2011 17:00:27 +0000 (18:00 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 15 Nov 2011 17:00:27 +0000 (18:00 +0100)
src/CurlyTxSettings.py

index 04277e4..3a58ecb 100644 (file)
@@ -6,46 +6,84 @@ from . import config
 from Components.config import config, getConfigListEntry
 from Components.ConfigList import ConfigList, ConfigListScreen
 
-class CurlyTxSettings(Screen, ConfigListScreen):
+class CurlyTxSettings(ConfigListScreen, Screen):
+    skin = """
+       <screen name="Setup" position="center,center" size="560,430" title="Setup">
+         <ePixmap pixmap="skin_default/buttons/red.png"    position="0,0"   size="140,40" transparent="1" alphatest="on" />
+         <ePixmap pixmap="skin_default/buttons/green.png"  position="140,0" size="140,40" transparent="1" alphatest="on" />
+         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
+         <ePixmap pixmap="skin_default/buttons/blue.png"   position="420,0" size="140,40" transparent="1" alphatest="on" />
+         <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" />
+         <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" />
+         <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" />
+         <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" />
+         <widget name="config" position="5,50" size="550,325" scrollbarMode="showOnDemand" />
+       </screen>"""
 
     def __init__(self, session):
+        self.skin = CurlyTxSettings.skin
         Screen.__init__(self, session)
-        self.skinName = [ "CurlyTxSettings", "Setup" ]
+        #self.skinName = [ "CurlyTxSettings", "Setup" ]
         self.setup_title = _("Settings")
 
-        self["actions"] = ActionMap(["SetupActions"],
+        self["actions"] = ActionMap(["SetupActions","ColorActions"],
             {
                 "cancel": self.keyCancel,
                 "save": self.keySave,
-                "ok": self.keySave
-                #fixme: open page editor
+                #"ok": self.ok,
+                "blue": self.deletePage,
+                "yellow": self.newPage
             }, -2)
 
-        self["key_red"] = StaticText(_("Cancel"))
-        self["key_green"] = StaticText(_("OK"))
+        self["key_red"]    = StaticText(_("Cancel"))
+        self["key_green"]  = StaticText(_("OK"))
+        self["key_yellow"] = StaticText(_("New"))
+        self["key_blue"]   = StaticText(_("Delete"))
 
-        self.onChangedEntry = [ ]
-        ConfigListScreen.__init__(self, self.getConfigList(), session = self.session, on_change = self.changedEntry)
+        ConfigListScreen.__init__(self, self.getConfigList(), session = self.session)
 
     def getConfigList(self):
-        list = []
+        list = [
+            getConfigListEntry(_("Page"), x.uri)
+                for x in config.plugins.CurlyTx.pages
+            ]
         list.append(getConfigListEntry(_("Show in main menu"), config.plugins.CurlyTx.menuMain))
         list.append(getConfigListEntry(_("Menu title"), config.plugins.CurlyTx.menuTitle))
-        # fixme: automatically set that
-        list.append(getConfigListEntry(_("Number of pages"), config.plugins.CurlyTx.pageCount))
-        # fixme: other way?
-        #list.append(getConfigListEntry(_("Pages"), config.plugins.CurlyTx.pages))
         return list
 
-    def changedEntry(self):
-        # fixme: needed?
-        for x in self.onChangedEntry:
-            x()
-
     def keyLeft(self):
         ConfigListScreen.keyLeft(self)
 
     def keyRight(self):
         ConfigListScreen.keyRight(self)
 
+    def deletePage(self):
+        from Screens.MessageBox import MessageBox
+        self.session.openWithCallback(
+            self.deletePageConfirm,
+            MessageBox,
+            _("Really delete this page?\nIt cannot be recovered!")
+        )
+
+    def deletePageConfirm(self, result):
+        if not result:
+            return
+
+        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
+        pass
 
+
+
+class CurlyTxPageEdit(Screen, ConfigListScreen):
+    def __init__(self, session):
+        Screen.__init__(self, session)
+
+        self["key_red"]   = StaticText(_("Cancel"))
+        self["key_green"] = StaticText(_("OK"))