5 # Coded by Dr.Best (c) 2009
6 # Support: www.dreambox-tools.info
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
19 from Screens.Screen import Screen
20 from Screens.ChannelSelection import ChannelSelection
21 from Plugins.Plugin import PluginDescriptor
22 from Components.ActionMap import ActionMap, HelpableActionMap
23 from Components.PluginComponent import plugins
24 from Plugins.Plugin import PluginDescriptor
25 from Components.ConfigList import ConfigList, ConfigListScreen
26 from Components.config import ConfigSubsection, ConfigText, configfile, ConfigSelection, getConfigListEntry, ConfigYesNo
27 from Components.config import config
28 from Components.Button import Button
29 from Screens.MessageBox import MessageBox
30 # for localized messages
33 config.plugins.Quickbutton = ConfigSubsection()
34 config.plugins.Quickbutton.overwritehbbtvredbutton = ConfigYesNo(default = False)
35 config.plugins.Quickbutton.red = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
36 config.plugins.Quickbutton.red_b = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
37 config.plugins.Quickbutton.green = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
38 config.plugins.Quickbutton.yellow = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
39 config.plugins.Quickbutton.blue = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
42 from Screens.InfoBarGenerics import InfoBarPlugins
43 baseInfoBarPlugins__init__ = None
44 ENABLE_RED_BUTTON = False
46 def getHBBTVInstalled():
48 from Plugins.Extensions.HbbTV.HbbTV import HbbTV
49 return config.plugins.hbbtv.enabled.value
53 def autostart(reason, **kwargs):
54 global baseInfoBarPlugins__init__,ENABLE_RED_BUTTON
55 if "session" in kwargs:
56 session = kwargs["session"]
57 if baseInfoBarPlugins__init__ is None:
58 baseInfoBarPlugins__init__ = InfoBarPlugins.__init__
59 InfoBarPlugins.__init__ = InfoBarPlugins__init__
60 InfoBarPlugins.greenlong = greenlong
61 InfoBarPlugins.yellowlong = yellowlong
62 InfoBarPlugins.redlong = redlong
63 InfoBarPlugins.bluelong = bluelong
64 if config.misc.rcused.value != 1:
65 ENABLE_RED_BUTTON = True
66 InfoBarPlugins.red = red
68 def setup(session,**kwargs):
69 session.open(QuickbuttonSetup)
71 def Plugins(**kwargs):
73 list = [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = autostart)]
74 list.append(PluginDescriptor(name="Setup Quickbutton", description=_("setup for Quickbutton"), where = [PluginDescriptor.WHERE_PLUGINMENU], icon = "setup_quickbutton.png", fnc=setup))
77 def InfoBarPlugins__init__(self):
78 from Screens.InfoBarGenerics import InfoBarEPG
79 if isinstance(self, InfoBarEPG):
80 x = { "green_l": (self.greenlong, _("Assign plugin to long green key pressed")),
81 "yellow_l": (self.yellowlong, _("Assign plugin to long yellow key pressed")),
82 "red_l": (self.redlong, _("Assign plugin to long red key pressed")),
83 "blue_l": (self.bluelong, _("Assign plugin to long blue key pressed"))}
85 x["red_b"] = (self.red, _("Assign plugin to red key pressed"))
86 hbbtvinstalled = getHBBTVInstalled()
87 if config.plugins.Quickbutton.overwritehbbtvredbutton.value and hbbtvinstalled:
88 self["HbbtvActions"].setEnabled(False)
89 self["QuickbuttonActions"] = HelpableActionMap(self, "QuickbuttonActions",x)
93 InfoBarPlugins.__init__ = InfoBarPlugins.__init__
94 InfoBarPlugins.greenlong = None
95 InfoBarPlugins.yellowlong = None
96 InfoBarPlugins.redlong = None
97 InfoBarPlugins.bluelong = None
99 InfoBarPlugins.red = None
100 baseInfoBarPlugins__init__(self)
103 startPlugin(self,str(config.plugins.Quickbutton.green.value))
105 def yellowlong(self):
106 startPlugin(self, str(config.plugins.Quickbutton.yellow.value))
109 startPlugin(self, str(config.plugins.Quickbutton.red.value))
112 startPlugin(self, str(config.plugins.Quickbutton.blue.value))
115 startPlugin(self, str(config.plugins.Quickbutton.red_b.value))
117 def startPlugin(self,pname):
118 msgText = _("Unknown Error")
120 if pname != _("Nothing"):
121 if pname == _("Single EPG"):
122 from Screens.InfoBarGenerics import InfoBarEPG
123 if isinstance(self, InfoBarEPG):
124 self.openSingleServiceEPG()
126 elif pname == _("Multi EPG"):
127 from Screens.InfoBarGenerics import InfoBarEPG
128 if isinstance(self, InfoBarEPG):
129 self.openMultiServiceEPG()
131 elif pname == _("MediaPlayer"):
132 try: # falls es nicht installiert ist
133 from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer
134 self.session.open(MediaPlayer)
137 msgText = _("Error!\nError Text: %s"%e)
138 elif pname == _("Plugin browser"):
139 from Screens.PluginBrowser import PluginBrowser
140 self.session.open(PluginBrowser)
142 elif pname == _("switch 4:3 content display"):
143 ar = { "pillarbox": _("Pillarbox"),
144 "panscan": _("Pan&Scan"),
145 "scale": _("Just Scale")}
146 switch = { "pillarbox":"panscan", "panscan":"scale", "scale":"pillarbox" }
147 config.av.policy_43.value = switch[config.av.policy_43.value]
148 config.av.policy_43.save()
149 self.session.open(MessageBox,_("Display 4:3 content as") + " " + ar[config.av.policy_43.value], MessageBox.TYPE_INFO, timeout = 3)
151 elif pname == _("Timer"):
152 from Screens.TimerEdit import TimerEditList
153 self.session.open(TimerEditList)
155 elif pname == _("HbbTV Applications"):
157 from Plugins.Extensions.HbbTV.HbbTV import HbbTV
158 no_plugin = not config.plugins.hbbtv.enabled.value
163 hbbtv_instance = HbbTV.instance
165 hbbtv_instance._showApplicationList()
168 for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU]):
169 if pname == str(p.name):
171 if plugin is not None:
173 self.runPlugin(plugin)
176 msgText = _("Error!\nError Text: %s"%e)
178 msgText = _("Plugin not found!")
180 msgText = _("No plugin assigned!")
182 self.session.open(MessageBox,msgText, MessageBox.TYPE_INFO)
185 class QuickbuttonSetup(ConfigListScreen, Screen):
187 <screen position="center,center" size="720,310" title="Quickbutton Setup">
188 <ePixmap pixmap="skin_default/buttons/red.png" position="10,5" size="200,40" alphatest="on" />
189 <ePixmap pixmap="skin_default/buttons/green.png" position="210,5" size="200,40" alphatest="on" />
190 <widget name="key_red" position="10,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
191 <widget name="key_green" position="210,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" shadowColor="black" shadowOffset="-2,-2" />
192 <eLabel position="10,50" size="700,1" backgroundColor="grey" />
193 <widget name="config" position="10,60" size="700,240" enableWrapAround="1" scrollbarMode="showOnDemand" />
196 def __init__(self, session, args = None):
197 Screen.__init__(self, session)
198 self["key_red"] = Button(_("Cancel"))
199 self["key_green"] = Button(_("OK"))
200 self.entryguilist = []
201 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
203 "green": self.keySave,
204 "cancel": self.keyClose,
206 "left": self.keyLeft,
207 "right": self.keyRight,
209 ConfigListScreen.__init__(self, [], session = session)
210 self.hbbtvinstalled = getHBBTVInstalled()
211 self.overwriteHBBTVButton = config.plugins.Quickbutton.overwritehbbtvredbutton
212 self.createSetup("config")
214 def createSetup(self, widget):
216 red_b_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.red_b.value)
217 red_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.red.value)
218 green_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.green.value)
219 yellow_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.yellow.value)
220 blue_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.blue.value)
221 # feste Vorgaben...koennte man noch erweitern, da hole ich mir sinnvolle Vorschlaege aus Foren noch ein...
222 self.entryguilist.append(("0",_("Nothing")))
223 self.entryguilist.append(("1",_("Single EPG")))
224 self.entryguilist.append(("2",_("Multi EPG")))
225 self.entryguilist.append(("3",_("MediaPlayer")))
226 self.entryguilist.append(("4",_("Plugin browser")))
227 self.entryguilist.append(("5",_("switch 4:3 content display")))
228 self.entryguilist.append(("6",_("Timer")))
229 if self.hbbtvinstalled:
230 self.entryguilist.append(("7",_("HbbTV Applications")))
234 # Vorgaben aus EXTENSIONSMENU, PLUGINMENU
235 for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU]):
236 self.entryguilist.append((str(index),str(p.name)))
237 if config.plugins.Quickbutton.red.value == str(p.name):
238 red_selectedindex = str(index)
239 if config.plugins.Quickbutton.red_b.value == str(p.name):
240 red_b_selectedindex = str(index)
241 if config.plugins.Quickbutton.green.value == str(p.name):
242 green_selectedindex = str(index)
243 if config.plugins.Quickbutton.yellow.value == str(p.name):
244 yellow_selectedindex = str(index)
245 if config.plugins.Quickbutton.blue.value == str(p.name):
246 blue_selectedindex = str(index)
248 self.overwriteHBBTVButtonEntry = None
249 if self.hbbtvinstalled and ENABLE_RED_BUTTON:
250 self.overwriteHBBTVButtonEntry = getConfigListEntry(_("Overwrite HBBTV-red-button"), self.overwriteHBBTVButton)
251 cfglist.append(self.overwriteHBBTVButtonEntry)
252 self.redchoice = ConfigSelection(default = red_selectedindex, choices = self.entryguilist)
253 self.greenchoice = ConfigSelection(default = green_selectedindex, choices = self.entryguilist)
254 self.yellowchoice = ConfigSelection(default = yellow_selectedindex, choices = self.entryguilist)
255 self.bluechoice = ConfigSelection(default = blue_selectedindex, choices = self.entryguilist)
256 cfglist.append(getConfigListEntry(_("assigned to long red"), self.redchoice))
257 cfglist.append(getConfigListEntry(_("assigned to long green"), self.greenchoice))
258 cfglist.append(getConfigListEntry(_("assigned to long yellow"), self.yellowchoice))
259 cfglist.append(getConfigListEntry(_("assigned to long blue"), self.bluechoice))
260 if ENABLE_RED_BUTTON and (self.overwriteHBBTVButton.value or not self.hbbtvinstalled):
261 self.red_b_choice = ConfigSelection(default = red_b_selectedindex, choices = self.entryguilist)
262 cfglist.append(getConfigListEntry(_("assigned to red"), self.red_b_choice))
263 self[widget].list = cfglist
264 self[widget].l.setList(cfglist)
266 def getStaticPluginName(self,value):
267 if value == _("Single EPG"):
269 elif value == _("Multi EPG"):
271 elif value == _("MediaPlayer"):
273 elif value == _("Plugin browser"):
275 elif value == _("switch 4:3 content display"):
277 elif value == _("Timer"):
279 elif value == _("HbbTV Applications"):
285 ConfigListScreen.keyLeft(self)
289 ConfigListScreen.keyRight(self)
293 cur = self["config"].getCurrent()
294 if cur and (cur == self.overwriteHBBTVButtonEntry):
295 self.createSetup("config")
298 config.plugins.Quickbutton.red.value = self.entryguilist[int(self.redchoice.value)][1]
299 config.plugins.Quickbutton.green.value = self.entryguilist[int(self.greenchoice.value)][1]
300 config.plugins.Quickbutton.yellow.value = self.entryguilist[int(self.yellowchoice.value)][1]
301 config.plugins.Quickbutton.blue.value = self.entryguilist[int(self.bluechoice.value)][1]
302 if ENABLE_RED_BUTTON and (self.overwriteHBBTVButton.value or not self.hbbtvinstalled):
303 config.plugins.Quickbutton.red_b.value = self.entryguilist[int(self.red_b_choice.value)][1]
304 self.overwriteHBBTVButton.save()
305 config.plugins.Quickbutton.save()