6 # Coded by Dr.Best (c) 2009
7 # Support: www.dreambox-tools.info
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
20 from Screens.Screen import Screen
21 from Screens.ChannelSelection import ChannelSelection
22 from Plugins.Plugin import PluginDescriptor
23 from Components.ActionMap import ActionMap, HelpableActionMap
24 from Components.PluginComponent import plugins
25 from Plugins.Plugin import PluginDescriptor
26 from Components.ConfigList import ConfigList, ConfigListScreen
27 from Components.config import ConfigSubsection, ConfigText, configfile, ConfigSelection, getConfigListEntry
28 from Components.config import config
29 from Components.Button import Button
30 from Screens.MessageBox import MessageBox
31 from Tools.HardwareInfo import HardwareInfo
32 # for localized messages
35 config.plugins.Quickbutton = ConfigSubsection()
36 config.plugins.Quickbutton.red = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
37 config.plugins.Quickbutton.red_b = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
38 config.plugins.Quickbutton.green = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
39 config.plugins.Quickbutton.yellow = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
40 config.plugins.Quickbutton.blue = ConfigText(default = _("Nothing"), visible_width = 50, fixed_size = False)
43 from Screens.InfoBarGenerics import InfoBarPlugins
44 baseInfoBarPlugins__init__ = None
46 StartOnlyOneTime = False
50 def autostart(reason, **kwargs):
51 global baseInfoBarPlugins__init__, baserunPlugin, DM8000
52 if "session" in kwargs:
53 session = kwargs["session"]
54 if baseInfoBarPlugins__init__ is None:
55 baseInfoBarPlugins__init__ = InfoBarPlugins.__init__
56 if baserunPlugin is None:
57 baserunPlugin = InfoBarPlugins.runPlugin
58 InfoBarPlugins.__init__ = InfoBarPlugins__init__
59 InfoBarPlugins.runPlugin = runPlugin
60 InfoBarPlugins.greenlong = greenlong
61 InfoBarPlugins.yellowlong = yellowlong
62 InfoBarPlugins.redlong = redlong
63 InfoBarPlugins.bluelong = bluelong
64 if HardwareInfo().get_device_name() == "dm8000":
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], fnc=setup))
77 def InfoBarPlugins__init__(self):
78 global StartOnlyOneTime
79 if not StartOnlyOneTime:
80 StartOnlyOneTime = True
81 x = { "green_l": (self.greenlong, _("Assign plugin to long green key pressed")),
82 "yellow_l": (self.yellowlong, _("Assign plugin to long yellow key pressed")),
83 "red_l": (self.redlong, _("Assign plugin to long red key pressed")),
84 "blue_l": (self.bluelong, _("Assign plugin to long blue key pressed"))}
86 x["red_b"] = (self.red, _("Assign plugin to red key pressed"))
87 self["QuickbuttonActions"] = HelpableActionMap(self, "QuickbuttonActions",x)
89 InfoBarPlugins.__init__ = InfoBarPlugins.__init__
90 InfoBarPlugins.runPlugin = InfoBarPlugins.runPlugin
91 InfoBarPlugins.greenlong = None
92 InfoBarPlugins.yellowlong = None
93 InfoBarPlugins.redlong = None
94 InfoBarPlugins.bluelong = None
96 InfoBarPlugins.red = None
97 baseInfoBarPlugins__init__(self)
99 def runPlugin(self, plugin):
100 baserunPlugin(self,plugin)
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 == _("EPG List"):
122 from Screens.EpgSelection import EPGSelection
123 self.session.open(EPGSelection, self.session.nav.getCurrentlyPlayingServiceReference())
125 elif pname == _("MediaPlayer"):
126 try: # falls es nicht installiert ist
127 from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer
128 self.session.open(MediaPlayer)
131 msgText = _("Error!\nError Text: %s"%e)
132 elif pname == _("Plugin browser"):
133 from Screens.PluginBrowser import PluginBrowser
134 self.session.open(PluginBrowser)
136 elif pname == _("switch 4:3 content display"):
137 ar = { "pillarbox": _("Pillarbox"),
138 "panscan": _("Pan&Scan"),
139 "scale": _("Just Scale")}
140 switch = { "pillarbox":"panscan", "panscan":"scale", "scale":"pillarbox" }
141 config.av.policy_43.value = switch[config.av.policy_43.value]
142 config.av.policy_43.save()
143 self.session.open(MessageBox,_("Display 4:3 content as") + " " + ar[config.av.policy_43.value], MessageBox.TYPE_INFO, timeout = 3)
145 elif pname == _("Timer"):
146 from Screens.TimerEdit import TimerEditList
147 self.session.open(TimerEditList)
151 for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU]):
152 if pname == str(p.name):
154 if plugin is not None:
156 runPlugin(self,plugin)
159 msgText = _("Error!\nError Text: %s"%e)
161 msgText = _("Plugin not found!")
163 msgText = _("No plugin assigned!")
165 self.session.open(MessageBox,msgText, MessageBox.TYPE_INFO)
168 class QuickbuttonSetup(ConfigListScreen, Screen):
170 <screen position="center,center" size="550,400" title="Quickbutton Setup" >
171 <widget name="config" position="20,10" size="510,330" scrollbarMode="showOnDemand" />
172 <widget name="key_red" position="0,350" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
173 <widget name="key_green" position="140,350" size="140,40" valign="center" halign="center" zPosition="5" transparent="1" foregroundColor="white" font="Regular;18"/>
174 <ePixmap name="red" pixmap="skin_default/buttons/red.png" position="0,350" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
175 <ePixmap name="green" pixmap="skin_default/buttons/green.png" position="140,350" size="140,40" zPosition="4" transparent="1" alphatest="on"/>
178 def __init__(self, session, args = None):
179 Screen.__init__(self, session)
180 self["key_red"] = Button(_("Cancel"))
181 self["key_green"] = Button(_("OK"))
182 self.entryguilist = []
183 red_b_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.red_b.value)
184 red_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.red.value)
185 green_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.green.value)
186 yellow_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.yellow.value)
187 blue_selectedindex = self.getStaticPluginName(config.plugins.Quickbutton.blue.value)
188 # feste Vorgaben...koennte man noch erweitern, da hole ich mir sinnvolle Vorschlaege aus Foren noch ein...
189 self.entryguilist.append(("0",_("Nothing")))
190 self.entryguilist.append(("1",_("EPG List")))
191 self.entryguilist.append(("2",_("MediaPlayer")))
192 self.entryguilist.append(("3",_("Plugin browser")))
193 self.entryguilist.append(("4",_("switch 4:3 content display")))
194 self.entryguilist.append(("5",_("Timer")))
195 # Vorgaben aus EXTENSIONSMENU, PLUGINMENU
197 for p in plugins.getPlugins(where = [PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU]):
198 self.entryguilist.append((str(index),str(p.name)))
199 if config.plugins.Quickbutton.red.value == str(p.name):
200 red_selectedindex = str(index)
201 if config.plugins.Quickbutton.red_b.value == str(p.name):
202 red_b_selectedindex = str(index)
203 if config.plugins.Quickbutton.green.value == str(p.name):
204 green_selectedindex = str(index)
205 if config.plugins.Quickbutton.yellow.value == str(p.name):
206 yellow_selectedindex = str(index)
207 if config.plugins.Quickbutton.blue.value == str(p.name):
208 blue_selectedindex = str(index)
211 self.redchoice = ConfigSelection(default = red_selectedindex, choices = self.entryguilist)
212 self.greenchoice = ConfigSelection(default = green_selectedindex, choices = self.entryguilist)
213 self.yellowchoice = ConfigSelection(default = yellow_selectedindex, choices = self.entryguilist)
214 self.bluechoice = ConfigSelection(default = blue_selectedindex, choices = self.entryguilist)
216 getConfigListEntry(_("assigned to long red"), self.redchoice),
217 getConfigListEntry(_("assigned to long green"), self.greenchoice),
218 getConfigListEntry(_("assigned to long yellow"), self.yellowchoice),
219 getConfigListEntry(_("assigned to long blue"), self.bluechoice)
223 self.red_b_choice = ConfigSelection(default = red_b_selectedindex, choices = self.entryguilist)
224 cfglist.append(getConfigListEntry(_("assigned to red"), self.red_b_choice))
225 ConfigListScreen.__init__(self, cfglist, session)
226 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
228 "green": self.keySave,
229 "cancel": self.keyClose,
233 def getStaticPluginName(self,value):
234 if value == _("EPG List"):
236 elif value == _("MediaPlayer"):
238 elif value == _("Plugin browser"):
240 elif value == _("switch 4:3 content display"):
242 if value == _("Timer"):
248 config.plugins.Quickbutton.red.value = self.entryguilist[int(self.redchoice.value)][1]
249 config.plugins.Quickbutton.green.value = self.entryguilist[int(self.greenchoice.value)][1]
250 config.plugins.Quickbutton.yellow.value = self.entryguilist[int(self.yellowchoice.value)][1]
251 config.plugins.Quickbutton.blue.value = self.entryguilist[int(self.bluechoice.value)][1]
253 config.plugins.Quickbutton.red_b.value = self.entryguilist[int(self.red_b_choice.value)][1]
254 config.plugins.Quickbutton.save()