hide default page config option when no page defined
[enigma2-curlytx.git] / src / CurlyTxSettings.py
index 42b054a..154bf37 100644 (file)
@@ -1,13 +1,16 @@
+from . import _
+
 from Screens.Screen import Screen
+from Screens.HelpMenu import HelpableScreen
 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 config import createPage, loadDefaultPageOptions
+from Components.config import config, getConfigListEntry, ConfigSelection
 from Components.ConfigList import ConfigList, ConfigListScreen
 
-class CurlyTxSettings(ConfigListScreen, Screen):
+class CurlyTxSettings(ConfigListScreen, HelpableScreen, 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" />
@@ -24,6 +27,7 @@ class CurlyTxSettings(ConfigListScreen, Screen):
     def __init__(self, session):
         self.skin = CurlyTxSettings.skin
         Screen.__init__(self, session)
+        HelpableScreen.__init__(self)
         #self.skinName = [ "CurlyTxSettings", "Setup" ]
         self.setup_title = _("Settings")
 
@@ -32,8 +36,8 @@ class CurlyTxSettings(ConfigListScreen, Screen):
                 "cancel": self.keyCancel,
                 "save": self.keySave,
                 "ok": self.editPage,
-                "blue": self.deletePage,
-                "yellow": self.newPage
+                "yellow": self.newPage,
+                "blue": self.deletePage
             }, -2)
 
         self["key_red"]    = StaticText(_("Cancel"))
@@ -42,17 +46,42 @@ class CurlyTxSettings(ConfigListScreen, Screen):
         self["key_blue"]   = StaticText(_("Delete"))
 
         ConfigListScreen.__init__(self, self.getConfigList(), session = self.session)
+
+        self.loadHelp()
         self.onClose.append(self.abort)
 
     def getConfigList(self):
+        #reload titles
+        loadDefaultPageOptions()
+
         list = [
-            getConfigListEntry(_("Page"), x.uri)
+            getConfigListEntry(_("Page:") + " " + x.title.value, x.uri)
                 for x in config.plugins.CurlyTx.pages
             ]
+        if len(config.plugins.CurlyTx.pages):
+            list.append(getConfigListEntry(_("Default page"), config.plugins.CurlyTx.defaultPage))
         list.append(getConfigListEntry(_("Show in main menu"), config.plugins.CurlyTx.menuMain))
+        list.append(getConfigListEntry(_("Show in extensions menu"), config.plugins.CurlyTx.menuExtensions))
         list.append(getConfigListEntry(_("Menu title"), config.plugins.CurlyTx.menuTitle))
         return list
 
+    def loadHelp(self):
+        self.helpList.append((
+                self["actions"], "SetupActions",
+                [("cancel", _("Dismiss all setting changes"))]))
+        self.helpList.append((
+                self["actions"], "SetupActions",
+                [("save", _("Save settings and close screen"))]))
+        self.helpList.append((
+                self["actions"], "SetupActions",
+                [("ok", _("Edit selected page"))]))
+        self.helpList.append((
+                self["actions"], "ColorActions",
+                [("yellow", _("Add new page"))]))
+        self.helpList.append((
+                self["actions"], "ColorActions",
+                [("blue", _("Delete selected page"))]))
+
     def keyLeft(self):
         ConfigListScreen.keyLeft(self)
 
@@ -60,12 +89,15 @@ class CurlyTxSettings(ConfigListScreen, Screen):
         ConfigListScreen.keyRight(self)
 
     def deletePage(self):
+        if len(config.plugins.CurlyTx.pages) == 0:
+            return
+
         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:
@@ -88,7 +120,7 @@ class CurlyTxSettings(ConfigListScreen, Screen):
             self.session.openWithCallback(
                 self.pageEdited, CurlyTxPageEdit,
                 config.plugins.CurlyTx.pages[id], False
-            )
+                )
 
     def pageEdited(self, page, new):
         if not page:
@@ -136,7 +168,6 @@ class CurlyTxPageEdit(Screen, ConfigListScreen):
 
     def save(self):
         self.close(self.page, self.new)
-        #FIXME: pass page to parent
 
     def keyCancel(self):
         self.close(None, self.new)