aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-11-18 02:53:40 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-11-18 02:53:40 +0000
commitbf7e40884d7add91e219e9e70e83988ae7752bd8 (patch)
tree3e1048ad0c2b1e32a5c7b3b24dbcb59cf1a7045a /lib/python
parent81b381e1f5dd38ad1b80a3b3d96060b89a5fab6c (diff)
downloadenigma2-bf7e40884d7add91e219e9e70e83988ae7752bd8.tar.gz
enigma2-bf7e40884d7add91e219e9e70e83988ae7752bd8.zip
add help stuff
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Components/ActionMap.py28
-rw-r--r--lib/python/Components/HelpMenuList.py50
-rw-r--r--lib/python/Components/Makefile.am2
-rw-r--r--lib/python/Components/__init__.py2
-rw-r--r--lib/python/Screens/HelpMenu.py30
-rw-r--r--lib/python/Screens/InfoBar.py16
-rw-r--r--lib/python/Screens/InfoBarGenerics.py12
-rw-r--r--lib/python/Screens/Makefile.am2
-rw-r--r--lib/python/Screens/Screen.py6
-rw-r--r--lib/python/Screens/__init__.py2
10 files changed, 135 insertions, 15 deletions
diff --git a/lib/python/Components/ActionMap.py b/lib/python/Components/ActionMap.py
index 2ed2fcc3..046a92d9 100644
--- a/lib/python/Components/ActionMap.py
+++ b/lib/python/Components/ActionMap.py
@@ -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
index 00000000..34eb4119
--- /dev/null
+++ b/lib/python/Components/HelpMenuList.py
@@ -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])
diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am
index f49c7545..c2787d9c 100644
--- a/lib/python/Components/Makefile.am
+++ b/lib/python/Components/Makefile.am
@@ -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
diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py
index ed74427a..0582a908 100644
--- a/lib/python/Components/__init__.py
+++ b/lib/python/Components/__init__.py
@@ -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
index 00000000..4e1d1c49
--- /dev/null
+++ b/lib/python/Screens/HelpMenu.py
@@ -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)
diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py
index 90594241..49e2cb5a 100644
--- a/lib/python/Screens/InfoBar.py
+++ b/lib/python/Screens/InfoBar.py
@@ -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)
diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py
index d9c42bdb..45c7745e 100644
--- a/lib/python/Screens/InfoBarGenerics.py
+++ b/lib/python/Screens/InfoBarGenerics.py
@@ -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):
diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am
index d722f05d..ca6e5d15 100644
--- a/lib/python/Screens/Makefile.am
+++ b/lib/python/Screens/Makefile.am
@@ -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
diff --git a/lib/python/Screens/Screen.py b/lib/python/Screens/Screen.py
index a95c7655..e9f9affd 100644
--- a/lib/python/Screens/Screen.py
+++ b/lib/python/Screens/Screen.py
@@ -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
diff --git a/lib/python/Screens/__init__.py b/lib/python/Screens/__init__.py
index ca1e0b03..157dee5d 100644
--- a/lib/python/Screens/__init__.py
+++ b/lib/python/Screens/__init__.py
@@ -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"]