add help stuff
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 18 Nov 2005 02:53:40 +0000 (02:53 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 18 Nov 2005 02:53:40 +0000 (02:53 +0000)
12 files changed:
data/keymap.xml
data/skin.xml
lib/python/Components/ActionMap.py
lib/python/Components/HelpMenuList.py [new file with mode: 0644]
lib/python/Components/Makefile.am
lib/python/Components/__init__.py
lib/python/Screens/HelpMenu.py [new file with mode: 0644]
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/Makefile.am
lib/python/Screens/Screen.py
lib/python/Screens/__init__.py

index d0a2f38..fac7cca 100644 (file)
                
        </map>
        
+       <map context="HelpActions">
+               <key id="KEY_HELP" mapto="displayHelp" flags="m" />
+       </map>
+
        <map context="ShortcutActions">
                <key id="KEY_F1" mapto="red" flags="mr" />
                <key id="KEY_F2" mapto="yellow" flags="mr" />
index b6937ae..990b054 100644 (file)
                        <widget name="end" position="508,150" size="72,35" font="Arial;25" />
                        <widget name="apply" position="10,240" size="250,35" />
                </screen>
+               <screen name="HelpMenu" flags="wfNoBorder" position="0,0" size="720,576" title="Menu">
+                       <widget name="list" position="100,100" size="550,375" />
+               </screen>
                <screen name="MessageBox" position="0,300" size="720,10" title="Message">
                        <widget name="text" position="0,0" size="650,0" font="Arial;22" />
                        <applet type="onLayoutFinish">
index 2ed2fcc..046a92d 100644 (file)
@@ -33,3 +33,31 @@ class NumberActionMap(ActionMap):
                        return 1
                else:
                        return ActionMap.action(self, contexts, action)
+
+class HelpableActionMap(ActionMap):
+       """An Actionmap which automatically puts the actions into the helpList.
+
+       Note that you can only use ONE context here!"""
+       
+       # sorry for this complicated code.
+       # it's not more than converting a "documented" actionmap 
+       # (where the values are possibly (function, help)-tuples)
+       # into a "classic" actionmap, where values are just functions.
+       # the classic actionmap is then passed to the ActionMap constructor,
+       # the collected helpstrings (with correct context, action) is
+       # added to the screen's "helpList", which will be picked up by
+       # the "HelpableScreen".
+       def __init__(self, parent, context, actions = { }, prio=0):
+               alist = [ ]
+               adict = { }
+               for (action, funchelp) in actions.iteritems():
+                       # check if this is a tuple
+                       if type(funchelp) is type(()):
+                               alist.append((action, funchelp[1]))
+                               adict[action] = funchelp[0]
+                       else:
+                               adict[action] = funchelp
+
+               ActionMap.__init__(self, [context], adict, prio)
+
+               parent.helpList.append((self, context, alist))
diff --git a/lib/python/Components/HelpMenuList.py b/lib/python/Components/HelpMenuList.py
new file mode 100644 (file)
index 0000000..34eb411
--- /dev/null
@@ -0,0 +1,50 @@
+from GUIComponent import *
+
+from enigma import eListboxPythonMultiContent, eListbox, gFont
+
+# [ ( actionmap, context, [(action, help), (action, help), ...] ), (actionmap, ... ), ... ]
+
+class HelpMenuList(GUIComponent):
+       def __init__(self, list, callback):
+               GUIComponent.__init__(self)
+               
+               self.l = eListboxPythonMultiContent()
+               self.callback = callback
+               
+               l = [ ]
+               for (actionmap, context, actions) in list:
+                       
+                       print "actionmap:"  + str(actionmap)
+                       print "context: " + str(context)
+                       print "actions: " + str(actions)
+                       
+                       for (action, help) in actions:
+                               entry = [ ]
+                               
+                               entry.append( (actionmap, context, action) )
+                               entry.append( (0, 36, 200, 20, 1, 0, "you can also press a secret button") )
+                               entry.append( (0, 0, 200, 36, 0, 0, help) )
+                               
+                               l.append(entry)
+               
+               self.l.setList(l)
+               
+               self.l.setFont(0, gFont("Arial", 36))
+               self.l.setFont(1, gFont("Arial", 18))
+       
+       def GUIcreate(self, parent):
+               self.instance = eListbox(parent)
+               self.instance.setContent(self.l)
+               self.instance.setItemHeight(75)
+       
+       def GUIdelete(self):
+               self.instance.setContent(None)
+               self.instance = None
+
+       def ok(self):
+               # a list entry has a "private" tuple as first entry...
+               l = self.l.getCurrentSelection()[0]
+               
+               # ...containing (Actionmap, Context, Action).
+               # we returns this tuple to the callback.
+               self.callback(l[0], l[1], l[2])
index f49c754..c2787d9 100644 (file)
@@ -9,4 +9,4 @@ install_PYTHON = \
        GUIComponent.py MenuList.py TextInput.py __init__.py MovieList.py                               \
        InputDevice.py ServicePosition.py SetupDevices.py Harddisk.py                                           \
        AVSwitch.py Network.py RFmod.py DiskInfo.py NimManager.py Lcd.py                                \
-       EpgList.py ScrollLabel.py Timezones.py Language.py
+       EpgList.py ScrollLabel.py Timezones.py Language.py HelpMenuList.py
index ed74427..0582a90 100644 (file)
@@ -6,4 +6,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo",
        "components", "config", "TimerList", "TimeInput", "MovieList", 
        "InputDevice",  "ServicePosition", "IPAddress", "VariableIP", "IPGateway",
        "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry",
-       "Lcd", "EpgList" "ScrollLabel", "Timezones"]
+       "Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList"]
diff --git a/lib/python/Screens/HelpMenu.py b/lib/python/Screens/HelpMenu.py
new file mode 100644 (file)
index 0000000..4e1d1c4
--- /dev/null
@@ -0,0 +1,30 @@
+from Screen import Screen
+
+from Components.ActionMap import ActionMap
+from Components.HelpMenuList import HelpMenuList
+
+class HelpMenu(Screen):
+       def __init__(self, session, list):
+               Screen.__init__(self, session)
+               
+               self["list"] = HelpMenuList(list, self.close)
+               self["actions"] = ActionMap(["OkCancelActions"],
+                       {
+                               "cancel": self.close,
+                               "ok": self["list"].ok,
+                       })
+
+class HelpableScreen:
+       def __init__(self):
+               self["helpActions"] = ActionMap( [ "HelpActions" ],
+                       {
+                               "displayHelp": self.showHelp,
+                       })
+
+       def showHelp(self):
+               self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
+
+       def callHelpAction(self, *args):
+               if len(args):
+                       (actionmap, context, action) = args
+                       actionmap.action(context, action)
index 9059424..49e2cb5 100644 (file)
@@ -12,13 +12,16 @@ from Screens.InfoBarGenerics import InfoBarVolumeControl, InfoBarShowHide, \
        InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarPVR, InfoBarInstantRecord, \
        InfoBarAudioSelection
 
+from Screens.HelpMenu import HelpableScreen, HelpMenu
+
 from enigma import *
 
 import time
 
 class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
        InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
-       InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection):
+       InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection,
+       HelpableScreen):
 
        def __init__(self, session):
                Screen.__init__(self, session)
@@ -28,16 +31,19 @@ class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
                                "showMovies": self.showMovies,
                        })
                
-               for x in InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
-                       InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
-                       InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection:
+               for x in HelpableScreen, \
+                               InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
+                               InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
+                               InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection:
                        x.__init__(self)
 
+               self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
+
                self["CurrentTime"] = Clock()
 
        def showMovies(self):
                self.session.openWithCallback(self.movieSelected, MovieSelection)
-       
+
        def movieSelected(self, service):
                if service is not None:
                        self.session.open(MoviePlayer, service)
index d9c42bd..45c7745 100644 (file)
@@ -1,5 +1,5 @@
 from Screen import Screen
-from Components.ActionMap import ActionMap
+from Components.ActionMap import ActionMap, HelpableActionMap
 from Components.ActionMap import NumberActionMap
 from Components.Label import Label
 from Components.config import configfile, configsequencearg
@@ -235,12 +235,12 @@ class InfoBarChannelSelection:
                #instantiate forever
                self.servicelist = self.session.instantiateDialog(ChannelSelection)
 
-               self["ChannelSelectActions"] = ActionMap( ["InfobarChannelSelection"],
+               self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
                        {
                                "switchChannelUp": self.switchChannelUp,
                                "switchChannelDown": self.switchChannelDown,
-                               "zapUp": self.zapUp,
-                               "zapDown": self.zapDown,
+                               "zapUp": (self.zapUp, _("next channel")),
+                               "zapDown": (self.zapDown, _("previous channel")),
                        })
                        
        def switchChannelUp(self):      
@@ -276,9 +276,9 @@ class InfoBarMenu:
 class InfoBarEPG:
        """ EPG - Opens an EPG list when the showEPGList action fires """
        def __init__(self):
-               self["EPGActions"] = ActionMap( [ "InfobarEPGActions" ]
+               self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions"
                        {
-                               "showEPGList": self.showEPGList,
+                               "showEPGList": (self.showEPGList, _("show EPG...")),
                        })
 
        def showEPGList(self):
index d722f05..ca6e5d1 100644 (file)
@@ -6,4 +6,4 @@ install_PYTHON = \
        MovieSelection.py Setup.py About.py HarddiskSetup.py FixedMenu.py \
        Satconfig.py ScanSetup.py NetworkSetup.py Ci.py TimerEntry.py Volume.py \
        EpgSelection.py EventView.py Mute.py Standby.py ServiceInfo.py \
-       AudioSelection.py InfoBarGenerics.py __init__.py
+       AudioSelection.py InfoBarGenerics.py HelpMenu.py __init__.py
index a95c765..e9f9aff 100644 (file)
@@ -11,6 +11,10 @@ class Screen(dict, HTMLSkin, GUISkin):
                self.session = session
                GUISkin.__init__(self)
                
+               # in order to support screens *without* a help,
+               # we need the list in every screen. how ironic.
+               self.helpList = [ ]
+               
        def execBegin(self):
 #              assert self.session == None, "a screen can only exec one per time"
 #              self.session = session
@@ -25,6 +29,8 @@ class Screen(dict, HTMLSkin, GUISkin):
        
        # never call this directly - it will be called from the session!
        def doClose(self):
+               # fixup circular references
+               del self.helpList
                GUISkin.close(self)
                
                del self.session
index ca1e0b0..157dee5 100644 (file)
@@ -4,4 +4,4 @@ __all__ = ["ChannelSelection", "ClockDisplay", "ConfigMenu",
        "TimerEdit", "Setup", "HarddiskSetup", "FixedMenu",
        "Satconfig", "Scanconfig", "Ci.py", "Volume.py", "Mute.py",
        "EpgSelection", "EventView", "Standby", "ServiceInfo",
-       "AudioSelection", "InfoBarGenerics"]
+       "AudioSelection", "InfoBarGenerics", "HelpMenu"]