plugin to assign plugins from PluginDescriptor.WHERE_MOVIELIST to color buttons in...
authorDr.Best <dr_best@users.schwerkraft.elitedvb.net>
Tue, 1 Dec 2009 22:05:40 +0000 (22:05 +0000)
committerDr.Best <dr_best@users.schwerkraft.elitedvb.net>
Tue, 1 Dec 2009 22:05:40 +0000 (22:05 +0000)
Makefile.am
configure.ac
movieselectionquickbutton/CONTROL/control [new file with mode: 0644]
movieselectionquickbutton/Makefile.am [new file with mode: 0755]
movieselectionquickbutton/po/Makefile.am [new file with mode: 0644]
movieselectionquickbutton/po/MovieSelectionQuickButton.pot [new file with mode: 0644]
movieselectionquickbutton/po/de.po [new file with mode: 0644]
movieselectionquickbutton/src/Makefile.am [new file with mode: 0755]
movieselectionquickbutton/src/__init__.py [new file with mode: 0644]
movieselectionquickbutton/src/maintainer.info [new file with mode: 0644]
movieselectionquickbutton/src/plugin.py [new file with mode: 0644]

index d36fb4c..e7efa3a 100644 (file)
@@ -26,6 +26,7 @@ SUBDIRS = \
        mosaic \
        moviecut \
        movieretitle \
+       movieselectionquickbutton \
        movietagger \
        mytube \
        netcaster \
index 4818306..62249b2 100644 (file)
@@ -250,4 +250,8 @@ weatherplugin/src/Makefile
 startupservice/Makefile
 startupservice/po/Makefile
 startupservice/src/Makefile
+
+movieselectionquickbutton/Makefile
+movieselectionquickbutton/po/Makefile
+movieselectionquickbutton/src/Makefile
 ])
diff --git a/movieselectionquickbutton/CONTROL/control b/movieselectionquickbutton/CONTROL/control
new file mode 100644 (file)
index 0000000..8860a74
--- /dev/null
@@ -0,0 +1,10 @@
+Package: enigma2-plugin-extensions-movieselectionquickbutton
+Version: 1.0
+Description: assign buttons (red/green/yellow/blue) to plugins from MOVIELIST
+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/movieselectionquickbutton/Makefile.am b/movieselectionquickbutton/Makefile.am
new file mode 100755 (executable)
index 0000000..dd6709f
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src po
diff --git a/movieselectionquickbutton/po/Makefile.am b/movieselectionquickbutton/po/Makefile.am
new file mode 100644 (file)
index 0000000..caac215
--- /dev/null
@@ -0,0 +1,57 @@
+#
+# to use this for the localisation of other plugins,
+# just change the DOMAIN to the name of the Plugin.
+# It is assumed, that the domain ist the same as
+# the directory name of the plugin.
+#
+
+DOMAIN=MovieSelectionQuickButton
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/$(DOMAIN)
+#GETTEXT=./pygettext.py
+GETTEXT=xgettext
+
+#MSGFMT = ./msgfmt.py
+MSGFMT = msgfmt
+
+LANGS := de
+LANGPO := $(foreach LANG, $(LANGS),$(LANG).po)
+LANGMO := $(foreach LANG, $(LANGS),$(LANG).mo)
+
+default: $(DOMAIN).pot $(LANGPO) merge $(LANGMO)
+       for lang in $(LANGS); do \
+               mkdir -p $$lang/LC_MESSAGES; \
+               cp $$lang.mo $$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
+
+merge:
+       for lang in $(LANGS); do \
+               msgmerge --no-location -s -N -U $$lang.po $(DOMAIN).pot; \
+       done
+
+
+# the TRANSLATORS: allows putting translation comments before the to-be-translated line.
+$(DOMAIN).pot:
+       $(GETTEXT) -L python --add-comments="TRANSLATORS:" -d $(DOMAIN) -s -o $(DOMAIN).pot ../src/*.py
+       msguniq -o $(DOMAIN)uniq.pot $(DOMAIN).pot
+       $(RM) $(DOMAIN).pot
+       mv $(DOMAIN)uniq.pot $(DOMAIN).pot
+
+.PHONY: $(DOMAIN).pot
+
+
+%.mo: %.po
+       $(MSGFMT) -o $@ $<
+
+%.po:
+       msginit -l $@ -o $@ -i $(DOMAIN).pot --no-translator
+
+CLEANFILES = $(foreach LANG, $(LANGS),$(LANG).mo)
+
+clean-local:
+       $(RM) -r $(LANGS)
+
+install-data-am: default
+       for lang in $(LANGS); do \
+               mkdir -p $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES; \
+               cp $$lang.mo $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
diff --git a/movieselectionquickbutton/po/MovieSelectionQuickButton.pot b/movieselectionquickbutton/po/MovieSelectionQuickButton.pot
new file mode 100644 (file)
index 0000000..b09e41d
--- /dev/null
@@ -0,0 +1,92 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-01 22:29+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/plugin.py:34
+#: ../src/plugin.py:35
+#: ../src/plugin.py:36
+#: ../src/plugin.py:62
+#: ../src/plugin.py:66
+#: ../src/plugin.py:70
+#: ../src/plugin.py:102
+#: ../src/plugin.py:137
+msgid "Nothing"
+msgstr ""
+
+#: ../src/plugin.py:60
+msgid "Delete"
+msgstr ""
+
+#: ../src/plugin.py:75
+msgid "delete movie"
+msgstr ""
+
+#: ../src/plugin.py:76
+msgid "Assign plugin to green key pressed"
+msgstr ""
+
+#: ../src/plugin.py:77
+msgid "Assign plugin to yellow key pressed"
+msgstr ""
+
+#: ../src/plugin.py:78
+msgid "Assign plugin to blue key pressed"
+msgstr ""
+
+#: ../src/plugin.py:99
+msgid "Unknown Error"
+msgstr ""
+
+#: ../src/plugin.py:111
+#, python-format
+msgid ""
+"Error!\n"
+"Error Text: %s"
+msgstr ""
+
+#: ../src/plugin.py:113
+msgid "Plugin not found!"
+msgstr ""
+
+#: ../src/plugin.py:115
+msgid "No plugin assigned!"
+msgstr ""
+
+#: ../src/plugin.py:134
+msgid "Cancel"
+msgstr ""
+
+#: ../src/plugin.py:135
+msgid "OK"
+msgstr ""
+
+#: ../src/plugin.py:155
+msgid "assigned to green"
+msgstr ""
+
+#: ../src/plugin.py:156
+msgid "assigned to yellow"
+msgstr ""
+
+#: ../src/plugin.py:157
+msgid "assigned to blue"
+msgstr ""
+
+#: ../src/plugin.py:188
+msgid "Setup for MovieSelection QuickButton"
+msgstr ""
+
diff --git a/movieselectionquickbutton/po/de.po b/movieselectionquickbutton/po/de.po
new file mode 100644 (file)
index 0000000..3bf0b11
--- /dev/null
@@ -0,0 +1,66 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: StartUpService\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-01 22:22+0100\n"
+"PO-Revision-Date: \n"
+"Last-Translator: Dr.Best <dr.best@dreambox-tools.info>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: German\n"
+"X-Poedit-Country: GERMANY\n"
+"X-Poedit-SourceCharset: UTF-8\n"
+
+msgid "Nothing"
+msgstr "Keine Zuordnung"
+
+msgid "Delete"
+msgstr "Löschen"
+
+msgid "delete movie"
+msgstr "Film löschen"
+
+msgid "Assign plugin to green key pressed"
+msgstr "Tastendruck auf Grün"
+
+msgid "Assign plugin to yellow key pressed"
+msgstr "Tastendruck auf Gelb"
+
+msgid "Assign plugin to blue key pressed"
+msgstr "Tastendruck auf Blau"
+
+msgid "Unknown Error"
+msgstr "Unbekannter Fehler"
+
+#, python-format
+msgid ""
+"Error!\n"
+"Error Text: %s"
+msgstr ""
+
+msgid "Plugin not found!"
+msgstr "Plugin wurde nicht gefunden!"
+
+msgid "No plugin assigned!"
+msgstr "Keine Funktion zugeordnet"
+
+msgid "Cancel"
+msgstr "Abbrechen"
+
+msgid "OK"
+msgstr "OK"
+
+msgid "assigned to green"
+msgstr "Tastendruck auf Grün"
+
+msgid "assigned to yellow"
+msgstr "Tastendruck auf Gelb"
+
+msgid "assigned to blue"
+msgstr "Tastendruck auf Blau"
+
+msgid "Setup for MovieSelection QuickButton"
+msgstr "MovieSelection QuickButton Setup"
+
diff --git a/movieselectionquickbutton/src/Makefile.am b/movieselectionquickbutton/src/Makefile.am
new file mode 100755 (executable)
index 0000000..c80604d
--- /dev/null
@@ -0,0 +1,5 @@
+installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/MovieSelectionQuickButton
+
+install_PYTHON = *.py
+
+install_DATA = maintainer.info
diff --git a/movieselectionquickbutton/src/__init__.py b/movieselectionquickbutton/src/__init__.py
new file mode 100644 (file)
index 0000000..74404b0
--- /dev/null
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from Components.Language import language
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
+from os import environ as os_environ
+import gettext
+
+def localeInit():
+       lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
+       os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
+       gettext.bindtextdomain("MovieSelectionQuickButton", resolveFilename(SCOPE_PLUGINS, "Extensions/MovieSelectionQuickButton/locale"))
+
+def _(txt):
+       t = gettext.dgettext("MovieSelectionQuickButton", txt)
+       if t == txt:
+               print "[MovieSelectionQuickButton] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
+
diff --git a/movieselectionquickbutton/src/maintainer.info b/movieselectionquickbutton/src/maintainer.info
new file mode 100644 (file)
index 0000000..981deb3
--- /dev/null
@@ -0,0 +1,2 @@
+dr.best@dreambox-tools.info
+MovieSelectionQuickButton
diff --git a/movieselectionquickbutton/src/plugin.py b/movieselectionquickbutton/src/plugin.py
new file mode 100644 (file)
index 0000000..dff8b99
--- /dev/null
@@ -0,0 +1,190 @@
+#
+#  MovieSelectionQuickButton E2
+#
+#  $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 Plugins.Plugin import PluginDescriptor\r
+from Screens.Screen import Screen\r
+from Screens.MovieSelection import MovieSelection, MovieContextMenu
+from Components.ActionMap import HelpableActionMap, ActionMap
+from Components.Button import Button
+from Components.PluginComponent import plugins
+from Components.ConfigList import ConfigList, ConfigListScreen
+from Components.config import ConfigSubsection, ConfigText, configfile, ConfigSelection, getConfigListEntry
+from Components.config import config
+from Screens.MessageBox import MessageBox
+# for localized messages
+from . import _
+
+config.plugins.MovieSelectionQuickButton = ConfigSubsection()
+config.plugins.MovieSelectionQuickButton.green = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
+config.plugins.MovieSelectionQuickButton.yellow = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
+config.plugins.MovieSelectionQuickButton.blue = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
+
+###########################################
+# MovieSelection
+###########################################
+baseMovieSelection__init__ = None
+baseupdateTags = None
+def MovieSelectionInit():
+       global baseMovieSelection__init__, baseupdateTags\r
+       if baseMovieSelection__init__ is None:
+               baseMovieSelection__init__ = MovieSelection.__init__
+       if baseupdateTags is None:
+               baseupdateTags = MovieSelection.updateTags
+       MovieSelection.__init__ = MovieSelection__init__
+       MovieSelection.updateTags = noUpdateTages
+       # new methods
+       MovieSelection.redpressed = redpressed
+       MovieSelection.greenpressed = greenpressed
+       MovieSelection.yellowpressed = yellowpressed
+       MovieSelection.bluepressed = bluepressed
+
+
+def MovieSelection__init__(self, session, selectedmovie = None):
+       baseMovieSelection__init__ (self, session, selectedmovie)
+       self["key_red"] = Button(_("Delete"))
+       green_text = ""
+       if str(config.plugins.MovieSelectionQuickButton.green.value) != _("Nothing"):
+               green_text = str(config.plugins.MovieSelectionQuickButton.green.value)
+       self["key_green"] = Button(green_text)
+       yellow_text = ""
+       if str(config.plugins.MovieSelectionQuickButton.yellow.value) != _("Nothing"):
+               yellow_text = str(config.plugins.MovieSelectionQuickButton.yellow.value)
+       self["key_yellow"] = Button(yellow_text)
+       blue_text = ""
+       if str(config.plugins.MovieSelectionQuickButton.blue.value) != _("Nothing"):
+               blue_text = str(config.plugins.MovieSelectionQuickButton.blue.value)
+       self["key_blue"] = Button(blue_text)
+       self["ColorActions"] = HelpableActionMap(self, "ColorActions",
+       {
+               "red": (self.redpressed, _("delete movie")),
+               "green": (self.greenpressed, _("Assign plugin to green key pressed")),
+               "yellow": (self.yellowpressed, _("Assign plugin to yellow key pressed")),
+               "blue": (self.bluepressed, _("Assign plugin to blue key pressed")),
+       })
+
+def redpressed(self):
+       current = self.getCurrent()
+       if current is not None:
+               MCM = MovieContextMenu(self.session,self,current)
+               MCM.delete()
+
+def greenpressed(self):
+       startPlugin(self,str(config.plugins.MovieSelectionQuickButton.green.value))
+
+def yellowpressed(self):
+       startPlugin(self,str(config.plugins.MovieSelectionQuickButton.yellow.value))
+
+def bluepressed(self):
+       startPlugin(self,str(config.plugins.MovieSelectionQuickButton.blue.value))
+
+def startPlugin(self,pname):
+       plugin = None
+       no_plugin = True
+       msgText = _("Unknown Error")
+       current = self.getCurrent()
+       if current is not None:
+               if pname != _("Nothing"):
+                       for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_MOVIELIST]):
+                               if pname == str(p.name):
+                                       plugin = p
+                       if plugin is not None:
+                               try:
+                                       plugin(self.session, current)
+                                       no_plugin = False
+                               except Exception, e:
+                                       msgText = _("Error!\nError Text: %s"%e)
+                       else: 
+                               msgText = _("Plugin not found!")
+               else:
+                       msgText = _("No plugin assigned!")
+               if no_plugin:
+                       self.session.open(MessageBox,msgText, MessageBox.TYPE_INFO)
+
+def noUpdateTages(self):
+       pass #nothing to do here, just ovewrite the method
+
+class MovieSelectionButtonSetup(ConfigListScreen, Screen):
+       skin = """
+               <screen position="center,center" size="550,400" title="MovieSelection 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 = []
+               self.entryguilist.append(("0",_("Nothing")))
+               index = 1
+               green_selectedindex = "0"
+               yellow_selectedindex = "0"
+               blue_selectedindex = "0"
+               for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_MOVIELIST]):
+                       self.entryguilist.append((str(index),str(p.name)))
+                       if config.plugins.MovieSelectionQuickButton.green.value == str(p.name):
+                               green_selectedindex = str(index)
+                       if config.plugins.MovieSelectionQuickButton.yellow.value == str(p.name):
+                               yellow_selectedindex = str(index)
+                       if config.plugins.MovieSelectionQuickButton.blue.value == str(p.name):
+                               blue_selectedindex = str(index)
+                       index = index + 1
+               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 green"), self.greenchoice),
+                       getConfigListEntry(_("assigned to yellow"), self.yellowchoice),
+                       getConfigListEntry(_("assigned to 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.MovieSelectionQuickButton.green.value = self.entryguilist[int(self.greenchoice.value)][1]
+               config.plugins.MovieSelectionQuickButton.yellow.value = self.entryguilist[int(self.yellowchoice.value)][1]
+               config.plugins.MovieSelectionQuickButton.blue.value = self.entryguilist[int(self.bluechoice.value)][1]
+               config.plugins.MovieSelectionQuickButton.save()
+               configfile.save()
+               self.close()
+
+       def keyClose(self):
+               self.close()
+
+def setup(session,**kwargs):
+       session.open(MovieSelectionButtonSetup)
+
+def main(session, **kwargs):
+       try: MovieSelectionInit()
+       except: pass
+
+def Plugins(**kwargs):\r
+       list = [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = main)]      
+       list.append(PluginDescriptor(name="Setup MovieSelection QuickButton", description=_("Setup for MovieSelection QuickButton"), where = [PluginDescriptor.WHERE_PLUGINMENU], fnc=setup))
+       return list
+