2 # MovieSelectionQuickButton E2
6 # Coded by Dr.Best (c) 2009
7 # Support: www.dreambox-tools.info
9 # This plugin is licensed under the Creative Commons
10 # Attribution-NonCommercial-ShareAlike 3.0 Unported
11 # License. To view a copy of this license, visit
12 # http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
13 # Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
15 # Alternatively, this plugin may be distributed and executed on hardware which
16 # is licensed by Dream Multimedia GmbH.
18 # This plugin is NOT free software. It is open source, you are allowed to
19 # modify it (if you keep the license), but it may not be commercially
20 # distributed other than under the conditions noted above.
23 from Plugins.Plugin import PluginDescriptor
24 from Screens.Screen import Screen
25 from Screens.MovieSelection import MovieSelection, MovieContextMenu
26 from Components.MovieList import MovieList
27 from Components.ActionMap import HelpableActionMap, ActionMap
28 from Components.Button import Button
29 from Components.PluginComponent import plugins
30 from Components.ConfigList import ConfigList, ConfigListScreen
31 from Components.config import ConfigSubsection, ConfigText, configfile, ConfigSelection, getConfigListEntry
32 from Components.config import config
33 from Screens.MessageBox import MessageBox
34 # for localized messages
37 config.plugins.MovieSelectionQuickButton = ConfigSubsection()
38 config.plugins.MovieSelectionQuickButton.red = ConfigText(default = _("Delete"), visible_width = 50, fixed_size = False)
39 config.plugins.MovieSelectionQuickButton.green = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
40 config.plugins.MovieSelectionQuickButton.yellow = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
41 config.plugins.MovieSelectionQuickButton.blue = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
42 config.plugins.MovieSelectionQuickButton.buttoncaption = ConfigSelection(default="0", choices = [("0", _("display plugin name")),("1", _("display plugin description"))])
44 ###########################################
46 ###########################################
47 baseMovieSelection__init__ = None
49 def MovieSelectionInit():
50 global baseMovieSelection__init__, baseupdateTags
51 if baseMovieSelection__init__ is None:
52 baseMovieSelection__init__ = MovieSelection.__init__
53 if baseupdateTags is None:
54 baseupdateTags = MovieSelection.updateTags
55 MovieSelection.__init__ = MovieSelection__init__
56 MovieSelection.updateTags = noUpdateTages
58 MovieSelection.redpressed = redpressed
59 MovieSelection.greenpressed = greenpressed
60 MovieSelection.yellowpressed = yellowpressed
61 MovieSelection.bluepressed = bluepressed
62 MovieSelection.getPluginCaption = getPluginCaption
64 def MovieSelection__init__(self, session, selectedmovie = None):
65 baseMovieSelection__init__ (self, session, selectedmovie)
66 self["key_red"] = Button(self.getPluginCaption(str(config.plugins.MovieSelectionQuickButton.red.value)))
67 self["key_green"] = Button(self.getPluginCaption(str(config.plugins.MovieSelectionQuickButton.green.value)))
68 self["key_yellow"] = Button(self.getPluginCaption(str(config.plugins.MovieSelectionQuickButton.yellow.value)))
69 self["key_blue"] = Button(self.getPluginCaption(str(config.plugins.MovieSelectionQuickButton.blue.value)))
70 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
72 "red": (self.redpressed, _("Assign plugin to red key pressed")),
73 "green": (self.greenpressed, _("Assign plugin to green key pressed")),
74 "yellow": (self.yellowpressed, _("Assign plugin to yellow key pressed")),
75 "blue": (self.bluepressed, _("Assign plugin to blue key pressed")),
79 startPlugin(self,str(config.plugins.MovieSelectionQuickButton.red.value),0)
81 def greenpressed(self):
82 startPlugin(self,str(config.plugins.MovieSelectionQuickButton.green.value),1)
84 def yellowpressed(self):
85 startPlugin(self,str(config.plugins.MovieSelectionQuickButton.yellow.value),2)
87 def bluepressed(self):
88 startPlugin(self,str(config.plugins.MovieSelectionQuickButton.blue.value),3)
90 def getPluginCaption(self,pname):
91 if pname != _("Nothing"):
92 if pname == _("Delete"):
94 elif pname == _("Home"):
96 elif pname == _("Sort"):
97 if config.movielist.moviesort.value == MovieList.SORT_ALPHANUMERIC:
98 return _("sort by date")
100 return _("alphabetic sort")
102 for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_MOVIELIST]):
103 if pname == str(p.name):
104 if config.plugins.MovieSelectionQuickButton.buttoncaption.value == "1":
110 def startPlugin(self,pname, index):
113 msgText = _("Unknown Error")
114 current = self.getCurrent()
115 if current is not None:
116 if pname != _("Nothing"):
117 if pname == _("Delete"):
118 MCM = MovieContextMenu(self.session,self,current)
121 elif pname == _("Home"):
122 self.gotFilename(config.usage.default_path.value)
124 elif pname == _("Sort"):
125 if config.movielist.moviesort.value == MovieList.SORT_ALPHANUMERIC:
126 newType = MovieList.SORT_RECORDED
127 newCaption = _("alphabetic sort")
129 newType = MovieList.SORT_ALPHANUMERIC
130 newCaption = _("sort by date")
131 config.movielist.moviesort.value = newType
132 self.setSortType(newType)
135 self["key_red"].setText(newCaption)
137 self["key_green"].setText(newCaption)
139 self["key_yellow"].setText(newCaption)
141 self["key_blue"].setText(newCaption)
144 for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_MOVIELIST]):
145 if pname == str(p.name):
147 if plugin is not None:
149 plugin(self.session, current)
152 msgText = _("Error!\nError Text: %s"%e)
154 msgText = _("Plugin not found!")
156 msgText = _("No plugin assigned!")
158 self.session.open(MessageBox,msgText, MessageBox.TYPE_INFO)
160 def noUpdateTages(self):
161 pass #nothing to do here, just ovewrite the method
163 class MovieSelectionButtonSetup(ConfigListScreen, Screen):
165 <screen position="center,center" size="550,400" title="MovieSelection QuickButton Setup" >
166 <widget name="config" position="20,10" size="510,330" scrollbarMode="showOnDemand" />
167 <widget name="key_red" position="0,350" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
168 <widget name="key_green" position="140,350" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
169 <ePixmap name="red" pixmap="skin_default/buttons/red.png" position="0,350" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
170 <ePixmap name="green" pixmap="skin_default/buttons/green.png" position="140,350" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
173 def __init__(self, session, args = None):
174 Screen.__init__(self, session)
175 self["key_red"] = Button(_("Cancel"))
176 self["key_green"] = Button(_("OK"))
177 self.entryguilist = []
178 self.entryguilist.append(("0",_("Nothing")))
179 self.entryguilist.append(("1",_("Delete")))
180 self.entryguilist.append(("2",_("Home")))
181 self.entryguilist.append(("3",_("Sort")))
183 red_selectedindex = self.getStaticName(config.plugins.MovieSelectionQuickButton.red.value)
184 green_selectedindex = self.getStaticName(config.plugins.MovieSelectionQuickButton.green.value)
185 yellow_selectedindex = self.getStaticName(config.plugins.MovieSelectionQuickButton.yellow.value)
186 blue_selectedindex = self.getStaticName(config.plugins.MovieSelectionQuickButton.blue.value)
187 for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_MOVIELIST]):
188 self.entryguilist.append((str(index),str(p.name)))
189 if config.plugins.MovieSelectionQuickButton.red.value == str(p.name):
190 red_selectedindex = str(index)
191 if config.plugins.MovieSelectionQuickButton.green.value == str(p.name):
192 green_selectedindex = str(index)
193 if config.plugins.MovieSelectionQuickButton.yellow.value == str(p.name):
194 yellow_selectedindex = str(index)
195 if config.plugins.MovieSelectionQuickButton.blue.value == str(p.name):
196 blue_selectedindex = str(index)
198 self.redchoice = ConfigSelection(default = red_selectedindex, choices = self.entryguilist)
199 self.greenchoice = ConfigSelection(default = green_selectedindex, choices = self.entryguilist)
200 self.yellowchoice = ConfigSelection(default = yellow_selectedindex, choices = self.entryguilist)
201 self.bluechoice = ConfigSelection(default = blue_selectedindex, choices = self.entryguilist)
203 getConfigListEntry(_("assigned to red"), self.redchoice),
204 getConfigListEntry(_("assigned to green"), self.greenchoice),
205 getConfigListEntry(_("assigned to yellow"), self.yellowchoice),
206 getConfigListEntry(_("assigned to blue"), self.bluechoice),
207 getConfigListEntry(_("button caption"), config.plugins.MovieSelectionQuickButton.buttoncaption),
209 ConfigListScreen.__init__(self, cfglist, session)
210 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
212 "green": self.keySave,
213 "cancel": self.keyClose,
218 config.plugins.MovieSelectionQuickButton.red.value = self.entryguilist[int(self.redchoice.value)][1]
219 config.plugins.MovieSelectionQuickButton.green.value = self.entryguilist[int(self.greenchoice.value)][1]
220 config.plugins.MovieSelectionQuickButton.yellow.value = self.entryguilist[int(self.yellowchoice.value)][1]
221 config.plugins.MovieSelectionQuickButton.blue.value = self.entryguilist[int(self.bluechoice.value)][1]
222 config.plugins.MovieSelectionQuickButton.save()
229 def getStaticName(self,value):
230 if value == _("Delete"):
232 elif value == _("Home"):
234 elif value == _("Sort"):
239 def setup(session,**kwargs):
240 session.open(MovieSelectionButtonSetup)
242 def main(session, **kwargs):
243 try: MovieSelectionInit()
246 def Plugins(**kwargs):
247 list = [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = main)]
248 list.append(PluginDescriptor(name="Setup MovieSelection QuickButton", description=_("Setup for MovieSelection QuickButton"), where = [PluginDescriptor.WHERE_PLUGINMENU],
249 icon = "plugin.png", fnc=setup))