New plugin: Quickbutton - assign long key-press (red/green/yellow/blue) to plugins...
authorDr.Best <dr_best@users.schwerkraft.elitedvb.net>
Sun, 17 May 2009 21:50:32 +0000 (21:50 +0000)
committerDr.Best <dr_best@users.schwerkraft.elitedvb.net>
Sun, 17 May 2009 21:50:32 +0000 (21:50 +0000)
Makefile.am
configure.ac
quickbutton/CONTROL/control [new file with mode: 0644]
quickbutton/Makefile.am [new file with mode: 0755]
quickbutton/src/Makefile.am [new file with mode: 0755]
quickbutton/src/__init__.py [new file with mode: 0644]
quickbutton/src/keymap.xml [new file with mode: 0644]
quickbutton/src/maintainer.info [new file with mode: 0644]
quickbutton/src/plugin.py [new file with mode: 0644]

index c4756b3..94e3753 100644 (file)
@@ -27,6 +27,7 @@ SUBDIRS = \
        partnerbox \
        passwordchanger \
        permanentclock \
+       quickbutton \
        remotetimer \
        rsdownloader \
        simplerss \
index 4d27478..1ac4ef8 100644 (file)
@@ -203,4 +203,7 @@ partnerbox/src/Makefile
 partnerbox/src/servicewebts/Makefile
 partnerbox/src/icons/Makefile
 
+quickbutton/Makefile
+quickbutton/src/Makefile
+
 ])
diff --git a/quickbutton/CONTROL/control b/quickbutton/CONTROL/control
new file mode 100644 (file)
index 0000000..113b18f
--- /dev/null
@@ -0,0 +1,10 @@
+Package: enigma2-plugin-extensions-quickbutton
+Version: 1.0
+Description: Quickbutton - assign long key-press (red/green/yellow/blue) to plugins or E2 functions
+Architecture: mipsel
+Section: extra
+Priority: optional
+Maintainer: Dr. Best <dr.best@dreambox-tools.info>
+Homepage: http://www.dreambox-tools.info
+Depends: enigma2(>2.6git20090518)
+Source: http://enigma2-plugins.schwerkraft.elitedvb.net/
diff --git a/quickbutton/Makefile.am b/quickbutton/Makefile.am
new file mode 100755 (executable)
index 0000000..af437a6
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src
diff --git a/quickbutton/src/Makefile.am b/quickbutton/src/Makefile.am
new file mode 100755 (executable)
index 0000000..d9efe20
--- /dev/null
@@ -0,0 +1,5 @@
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/Quickbutton
+
+install_PYTHON = *.py
+
+install_DATA = keymap.xml maintainer.info
diff --git a/quickbutton/src/__init__.py b/quickbutton/src/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/quickbutton/src/keymap.xml b/quickbutton/src/keymap.xml
new file mode 100644 (file)
index 0000000..3217def
--- /dev/null
@@ -0,0 +1,8 @@
+<keymap>
+<map context="QuickbuttonActions">
+       <key id="KEY_GREEN" mapto="green_l" flags="l" />
+       <key id="KEY_YELLOW" mapto="yellow_l" flags="l" />
+       <key id="KEY_RED" mapto="red_l" flags="l" />
+       <key id="KEY_BLUE" mapto="blue_l" flags="l" />
+</map>
+</keymap>
diff --git a/quickbutton/src/maintainer.info b/quickbutton/src/maintainer.info
new file mode 100644 (file)
index 0000000..f7598a6
--- /dev/null
@@ -0,0 +1,2 @@
+dr.best@dreambox-tools.info
+Quickbutton
diff --git a/quickbutton/src/plugin.py b/quickbutton/src/plugin.py
new file mode 100644 (file)
index 0000000..138c8e4
--- /dev/null
@@ -0,0 +1,181 @@
+
+#  Quickbutton
+#
+#  $Id$
+#
+#  Coded by Dr.Best (c) 2009
+#  Support: www.dreambox-tools.info
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+
+from Screens.Screen import Screen
+from Screens.ChannelSelection import ChannelSelection
+from Plugins.Plugin import PluginDescriptor
+from Components.ActionMap import ActionMap
+from Components.PluginComponent import plugins
+from Plugins.Plugin import PluginDescriptor
+from Components.ConfigList import ConfigList, ConfigListScreen
+from Components.config import ConfigSubsection, ConfigText, configfile, ConfigSelection, getConfigListEntry
+from Components.config import config
+from Components.Button import Button
+from Screens.MessageBox import MessageBox
+
+
+config.plugins.Quickbutton = ConfigSubsection()
+config.plugins.Quickbutton.red = ConfigText(default = "", visible_width = 50, fixed_size = False)
+config.plugins.Quickbutton.green = ConfigText(default = "", visible_width = 50, fixed_size = False)
+config.plugins.Quickbutton.yellow = ConfigText(default = "", visible_width = 50, fixed_size = False)
+config.plugins.Quickbutton.blue = ConfigText(default = "", visible_width = 50, fixed_size = False)
+
+EPGListTitle = _("EPG List")
+
+def autostart(reason, **kwargs):
+       if "session" in kwargs:
+               session = kwargs["session"]
+               Quickbutton(session)
+
+def setup(session,**kwargs):
+       session.open(QuickbuttonSetup)
+
+def Plugins(**kwargs):
+
+       list = [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = autostart)] 
+       list.append(PluginDescriptor(name="Setup Quickbutton", description=_("setup for Quickbutton"), where = [PluginDescriptor.WHERE_PLUGINMENU], fnc=setup))
+       return list
+
+class QuickbuttonSetup(ConfigListScreen, Screen):
+       skin = """
+               <screen position="100,100" size="550,400" title="Quickbutton Setup" >
+                       <widget name="config" position="20,10" size="510,330" scrollbarMode="showOnDemand" />
+                       <widget name="key_red" position="0,350" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
+                       <widget name="key_green" position="140,350" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
+                       <ePixmap name="red" pixmap="skin_default/buttons/red.png" position="0,350" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
+                       <ePixmap name="green" pixmap="skin_default/buttons/green.png" position="140,350" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
+               </screen>"""
+
+       def __init__(self, session, args = None):
+               Screen.__init__(self, session)
+               self["key_red"] = Button(_("Cancel"))
+               self["key_green"] = Button(_("OK"))
+               self.entryguilist = []
+               red_selectedindex = "0"
+               if config.plugins.Quickbutton.red.value == EPGListTitle:
+                       red_selectedindex = "1"
+               green_selectedindex = "0"
+               if config.plugins.Quickbutton.green.value == EPGListTitle:
+                       green_selectedindex = "1"
+               yellow_selectedindex = "0"
+               if config.plugins.Quickbutton.yellow.value == EPGListTitle:
+                       yellow_selectedindex = "1"
+               blue_selectedindex = "0"
+               if config.plugins.Quickbutton.blue.value == EPGListTitle:
+                       blue_selectedindex = "1"
+               # feste Vorgaben...koennte man noch erweitern, da hole ich mir sinnvolle Vorschlaege aus Foren noch ein...
+               self.entryguilist.append(("0",_("Nothing")))
+               self.entryguilist.append(("1",EPGListTitle))
+               # Vorgaben aus EXTENSIONSMENU
+               index = 2
+               for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU):
+                       self.entryguilist.append((str(index),str(p.name)))
+                       if config.plugins.Quickbutton.red.value == str(p.name):
+                               red_selectedindex = str(index)
+                       if config.plugins.Quickbutton.green.value == str(p.name):
+                               green_selectedindex = str(index)
+                       if config.plugins.Quickbutton.yellow.value == str(p.name):
+                               yellow_selectedindex = str(index)
+                       if config.plugins.Quickbutton.blue.value == str(p.name):
+                               blue_selectedindex = str(index)
+                       index = index + 1
+
+               self.redchoice = ConfigSelection(default = red_selectedindex, choices = self.entryguilist)
+               self.greenchoice = ConfigSelection(default = green_selectedindex, choices = self.entryguilist)
+               self.yellowchoice = ConfigSelection(default = yellow_selectedindex, choices = self.entryguilist)
+               self.bluechoice = ConfigSelection(default = blue_selectedindex, choices = self.entryguilist)
+
+               cfglist = [
+                       getConfigListEntry(_("assigned to long red"), self.redchoice),
+                       getConfigListEntry(_("assigned to long green"), self.greenchoice),
+                       getConfigListEntry(_("assigned to long yellow"), self.yellowchoice),
+                       getConfigListEntry(_("assigned to long blue"), self.bluechoice)
+
+                       ]
+               ConfigListScreen.__init__(self, cfglist, session)
+               self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "green": self.keySave,
+                       "cancel": self.keyClose,
+                       "ok": self.keySave,
+               }, -2)
+
+       def keySave(self):
+               config.plugins.Quickbutton.red.value = self.entryguilist[int(self.redchoice.value)][1]
+               config.plugins.Quickbutton.green.value = self.entryguilist[int(self.greenchoice.value)][1]
+               config.plugins.Quickbutton.yellow.value = self.entryguilist[int(self.yellowchoice.value)][1]
+               config.plugins.Quickbutton.blue.value = self.entryguilist[int(self.bluechoice.value)][1]
+               config.plugins.Quickbutton.save()
+               configfile.save()
+               self.close()
+
+       def keyClose(self):
+               self.close()
+
+class Quickbutton(object):
+       def __init__(self, session):
+               self.session = session
+               QuickbuttonActionMap = ActionMap(["QuickbuttonActions"])
+               QuickbuttonActionMap.execBegin()
+               QuickbuttonActionMap.actions["green_l"] = self.greenlong
+               QuickbuttonActionMap.actions["yellow_l"] = self.yellowlong
+               QuickbuttonActionMap.actions["red_l"] = self.redlong 
+               QuickbuttonActionMap.actions["blue_l"] = self.bluelong
+
+       def greenlong(self):
+               self.getPlugin(str(config.plugins.Quickbutton.green.value))
+       
+       def yellowlong(self):
+               self.getPlugin(str(config.plugins.Quickbutton.yellow.value))
+       
+       def redlong(self):
+               self.getPlugin(str(config.plugins.Quickbutton.red.value))
+
+       def bluelong(self):
+               self.getPlugin(str(config.plugins.Quickbutton.blue.value))
+       
+       def getPlugin(self, pname):
+               msgText = _("Unknown Error")
+               error = True
+               if pname != "":
+                       if pname == EPGListTitle:
+                               print "[Quickbutton] EPG List"
+                               from Screens.EpgSelection import EPGSelection
+                               self.session.open(EPGSelection, self.session.nav.getCurrentlyPlayingServiceReference())
+                               error = False
+                       else:
+                               ca = None
+                               for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU):
+                                       if pname == str(p.name):
+                                               print "[Quickbutton] %s"%p.name
+                                               ca = p
+                               if ca is not None:
+                                       try: 
+                                               servicelist = self.session.instantiateDialog(ChannelSelection)
+                                               ca(session = self.session, servicelist = servicelist)
+                                               error = False
+                                       except Exception, e:
+                                               msgText = _("Error!\nError Text: %s"%e)
+                               else: 
+                                       msgText = _("Plugin not found!")
+               else:
+                       msgText = _("No plugin assigned!")
+               if error:
+                       self.session.open(MessageBox,msgText, MessageBox.TYPE_INFO)
+