diff options
| author | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2005-12-21 04:41:36 +0000 |
|---|---|---|
| committer | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2005-12-21 04:41:36 +0000 |
| commit | ccb8d260ed5e51f6f65205be04744a9e8322aa6f (patch) | |
| tree | c8243a30d7b7627229186ca13a463952b92c1322 | |
| parent | 8589eb49ec20d3503a476f398ec84d7ad0307d26 (diff) | |
| download | enigma2-ccb8d260ed5e51f6f65205be04744a9e8322aa6f.tar.gz enigma2-ccb8d260ed5e51f6f65205be04744a9e8322aa6f.zip | |
add plugins
to test it: uncomment the example.py in lib/python/Plugins/Makefile.am
plugins can be added at runtime
| -rw-r--r-- | configure.ac | 1 | ||||
| -rw-r--r-- | data/menu.xml | 2 | ||||
| -rw-r--r-- | data/skin.xml | 7 | ||||
| -rw-r--r-- | lib/python/Components/Makefile.am | 3 | ||||
| -rw-r--r-- | lib/python/Components/PluginComponent.py | 33 | ||||
| -rw-r--r-- | lib/python/Components/PluginList.py | 42 | ||||
| -rw-r--r-- | lib/python/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/python/Plugins/Makefile.am | 5 | ||||
| -rw-r--r-- | lib/python/Plugins/__init__.py | 0 | ||||
| -rw-r--r-- | lib/python/Plugins/example.py | 34 | ||||
| -rw-r--r-- | lib/python/Screens/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/python/Screens/PluginBrowser.py | 46 |
12 files changed, 169 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index 0f52031c..3179c57a 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,7 @@ lib/nav/Makefile lib/python/Makefile lib/python/Components/Makefile lib/python/Screens/Makefile +lib/python/Plugins/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/data/menu.xml b/data/menu.xml index dabdd76e..be0119fc 100644 --- a/data/menu.xml +++ b/data/menu.xml @@ -24,7 +24,7 @@ <item text="About..."><screen module="About" /></item> </menu> - <item text="Games / Plugins"><screen module="PluginBrowser" /></item> + <item text="Games / Plugins"><screen module="PluginBrowser" screen="PluginBrowser" /></item> <menu text="Setup"> <!--<menu text="Service Organising"> <item text="New Bouquets"></item> diff --git a/data/skin.xml b/data/skin.xml index a98d1099..2724612f 100644 --- a/data/skin.xml +++ b/data/skin.xml @@ -73,6 +73,9 @@ <screen name="LanguageSelection" position="200,125" size="220,250" title="Language selection"> <widget name="list" position="10,0" size="190,240" scrollbarMode="showOnDemand" /> </screen> + <screen name="PluginBrowser" position="100,125" size="400,350" title="Plugin browser"> + <widget name="list" position="10,0" size="380,340" scrollbarMode="showOnDemand" /> + </screen> <screen name="NimSelection" position="140,165" size="400,100" title="select Slot"> <widget name="nimlist" position="20,10" size="360,75" /> </screen> @@ -113,10 +116,6 @@ <widget name="config" position="10,50" size="420,175" scrollbarMode="showOnDemand" /> <widget name="introduction" position="10,230" size="400,30" font="Arial;23" /> </screen> - <screen name="PluginBrowser" position="190,125" size="360,250" title="Plugins"> - <widget name="title" position="10,10" size="280,35" font="Arial;23" /> - <widget name="pluginlist" position="10,50" size="320,200" /> - </screen> <screen name="About" position="140,125" size="360,250" title="About"> <widget name="text" position="10,30" size="420,40" font="Arial;18"/> <widget name="tuner" position="10,80" size="420,20" font="Arial;18"/> diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index f83403b4..340730a6 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -10,4 +10,5 @@ install_PYTHON = \ 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 HelpMenuList.py \ - BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py + BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py \ + PluginList.py PluginComponent.py diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py new file mode 100644 index 00000000..26382063 --- /dev/null +++ b/lib/python/Components/PluginComponent.py @@ -0,0 +1,33 @@ +import os + +from Tools.Directories import * +#import Plugins + +class PluginComponent: + def __init__(self): + self.plugins = [] + self.setPluginPrefix("Plugins.") + + def setPluginPrefix(self, prefix): + self.prefix = prefix + + def getPluginList(self): + list = [] + dir = os.listdir("/usr/lib/enigma2/python/Plugins/") + for x in dir: + if x[-3:] == ".py" and x[:-3] != "__init__": + #try: + print "trying to import " + self.prefix + x[:-3] + exec "import " + self.prefix + x[:-3] + picturepath = eval(self.prefix + x[:-3]).getPicturePath() + pluginname = eval(self.prefix + x[:-3]).getPluginName() + list.append((picturepath, pluginname , x[:-3])) + #except: + #print "Failed to open module - wrong plugin!" + return list + + def runPlugin(self, plugin, session): + exec "import " + self.prefix + plugin[2] + eval(self.prefix + plugin[2]).main(session) + +plugins = PluginComponent() diff --git a/lib/python/Components/PluginList.py b/lib/python/Components/PluginList.py new file mode 100644 index 00000000..d2ae64a7 --- /dev/null +++ b/lib/python/Components/PluginList.py @@ -0,0 +1,42 @@ +from HTMLComponent import * +from GUIComponent import * + +from MenuList import MenuList + +from Tools.Directories import * + +from enigma import * + +RT_HALIGN_LEFT = 0 +RT_HALIGN_RIGHT = 1 +RT_HALIGN_CENTER = 2 +RT_HALIGN_BLOCK = 4 + +RT_VALIGN_TOP = 0 +RT_VALIGN_CENTER = 8 +RT_VALIGN_BOTTOM = 16 + +def PluginEntryComponent(picture, name): + res = [ None ] + res.append((80, 10, 200, 50, 0, RT_HALIGN_LEFT , name)) + png = loadPNG(picture) + if png == None: + png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "/countries/missing.png")) + res.append((10, 5, 60, 40, png)) + + return res + + +class PluginList(HTMLComponent, GUIComponent, MenuList): + def __init__(self, list): + GUIComponent.__init__(self) + self.l = eListboxPythonMultiContent() + self.list = list + self.l.setList(list) + self.l.setFont(0, gFont("Arial", 20)) + self.l.setFont(1, gFont("Arial", 10)) + + def GUIcreate(self, parent): + self.instance = eListbox(parent) + self.instance.setContent(self.l) + self.instance.setItemHeight(50)
\ No newline at end of file diff --git a/lib/python/Makefile.am b/lib/python/Makefile.am index e94d36f4..1cc01544 100644 --- a/lib/python/Makefile.am +++ b/lib/python/Makefile.am @@ -2,7 +2,7 @@ INCLUDES = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src -SUBDIRS = Components Tools Screens +SUBDIRS = Components Tools Screens Plugins noinst_LIBRARIES = libenigma_python.a diff --git a/lib/python/Plugins/Makefile.am b/lib/python/Plugins/Makefile.am new file mode 100644 index 00000000..d963b3c0 --- /dev/null +++ b/lib/python/Plugins/Makefile.am @@ -0,0 +1,5 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins + +install_PYTHON = \ + __init__.py \ + example.py
\ No newline at end of file diff --git a/lib/python/Plugins/__init__.py b/lib/python/Plugins/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/lib/python/Plugins/__init__.py diff --git a/lib/python/Plugins/example.py b/lib/python/Plugins/example.py new file mode 100644 index 00000000..86e2cd14 --- /dev/null +++ b/lib/python/Plugins/example.py @@ -0,0 +1,34 @@ +from enigma import * +from Screens.Screen import Screen +from Components.ActionMap import ActionMap +from Components.Label import Label + +class Example(Screen): + skin = """ + <screen position="100,100" size="200,200" title="Example plugin..." > + <widget name="text" position="0,0" size="100,50" font="Arial;23" /> + </screen>""" + + def __init__(self, session): + self.skin = Example.skin + Screen.__init__(self, session) + + self["text"] = Label("Small test") + + self["actions"] = ActionMap(["WizardActions"], + { + "ok": self.ok + }, -1) + + def ok(self): + self.close() + +def main(session): + session.open(Example) + + +def getPicturePath(): + return "/usr/share/enigma2/record.png" + +def getPluginName(): + return "Fancy example-plugin"
\ No newline at end of file diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index 15b56d41..d191a5ba 100644 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -8,4 +8,4 @@ install_PYTHON = \ EpgSelection.py EventView.py Mute.py Standby.py ServiceInfo.py \ AudioSelection.py InfoBarGenerics.py HelpMenu.py Wizard.py __init__.py \ Dish.py SubserviceSelection.py LanguageSelection.py StartWizard.py \ - TutorialWizard.py + TutorialWizard.py PluginBrowser.py diff --git a/lib/python/Screens/PluginBrowser.py b/lib/python/Screens/PluginBrowser.py new file mode 100644 index 00000000..c03aa910 --- /dev/null +++ b/lib/python/Screens/PluginBrowser.py @@ -0,0 +1,46 @@ +from Screen import Screen + +from Components.MenuList import MenuList +from Components.ActionMap import ActionMap +from Components.PluginComponent import plugins +from Components.PluginList import * +from Components.config import config + + +class PluginBrowser(Screen): + def __init__(self, session): + Screen.__init__(self, session) + + self.list = [] + self["list"] = PluginList(self.list) + self.updateList() + + self["actions"] = ActionMap(["WizardActions"], + { + "ok": self.save, + "back": self.close, + "up": self.up, + "down": self.down + }, -1) + + def save(self): + #self.close() + self.run() + + def run(self): + plugin = self.pluginlist[self["list"].l.getCurrentSelectionIndex()] + plugins.runPlugin(plugin, self.session) + + def updateList(self): + self.list = [] + self.pluginlist = plugins.getPluginList() + for x in self.pluginlist: + self.list.append(PluginEntryComponent(x[0], x[1])) + + self["list"].l.setList(self.list) + + def up(self): + self["list"].instance.moveSelection(self["list"].instance.moveUp) + + def down(self): + self["list"].instance.moveSelection(self["list"].instance.moveDown) |
