add support for 16:10 display aspect ratio
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 0ef08d4313e5b5eb757b817c5e241d673a91dc7c..e96a034d2dbc576fe4c694ae5627ea956e1aafb9 100644 (file)
@@ -1,32 +1,32 @@
-from Screen import Screen
-from Components.ActionMap import ActionMap, HelpableActionMap
-from Components.ActionMap import NumberActionMap
-from Components.Label import *
-from Components.ProgressBar import *
-from Components.config import configfile, configsequencearg
-from Components.config import config, configElement, ConfigSubsection, configSequence
 from ChannelSelection import ChannelSelection, BouquetSelector
 
-from Components.Pixmap import Pixmap, PixmapConditional
+from Components.ActionMap import ActionMap, HelpableActionMap
+from Components.ActionMap import NumberActionMap
 from Components.BlinkingPixmap import BlinkingPixmapConditional
-from Components.ServiceName import ServiceName
-from Components.EventInfo import EventInfo, EventInfoProgress
 from Components.Clock import Clock
+from Components.EventInfo import EventInfo, EventInfoProgress
+from Components.Harddisk import harddiskmanager
 from Components.Input import Input
+from Components.Label import *
+from Components.Pixmap import Pixmap, PixmapConditional
+from Components.PluginComponent import plugins
+from Components.ProgressBar import *
+from Components.ServiceEventTracker import ServiceEventTracker
+from Components.ServiceName import ServiceName
+from Components.config import config, configElement, ConfigSubsection, configSequence, configElementBoolean
+from Components.config import configfile, configsequencearg
 
-from ServiceReference import ServiceReference
 from EpgSelection import EPGSelection
+from Plugins.Plugin import PluginDescriptor
 
-from Screens.MessageBox import MessageBox
+from Screen import Screen
 from Screens.ChoiceBox import ChoiceBox
-from Screens.InputBox import InputBox
 from Screens.Dish import Dish
-from Screens.Standby import Standby
 from Screens.EventView import EventViewEPGSelect, EventViewSimple
+from Screens.InputBox import InputBox
+from Screens.MessageBox import MessageBox
 from Screens.MinuteInput import MinuteInput
-from Components.Harddisk import harddiskmanager
-
-from Components.ServiceEventTracker import ServiceEventTracker
+from ServiceReference import ServiceReference
 
 from Tools import Notifications
 from Tools.Directories import *
@@ -165,41 +165,6 @@ class NumberZap(Screen):
                self.Timer.timeout.get().append(self.keyOK)
                self.Timer.start(3000, True)
 
-class InfoBarPowerKey:
-       """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
-       
-       def __init__(self):
-               self.powerKeyTimer = eTimer()
-               self.powerKeyTimer.timeout.get().append(self.powertimer)
-               self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions",
-                       {
-                               "powerdown": self.powerdown,
-                               "powerup": self.powerup,
-                               "discreteStandby": (self.standby, "Go standby"),
-                               "discretePowerOff": (self.quit, "Go to deep standby"),
-                       })
-
-       def powertimer(self):   
-               print "PowerOff - Now!"
-               self.quit()
-       
-       def powerdown(self):
-               self.standbyblocked = 0
-               self.powerKeyTimer.start(3000, True)
-
-       def powerup(self):
-               self.powerKeyTimer.stop()
-               if self.standbyblocked == 0:
-                       self.standbyblocked = 1
-                       self.standby()
-
-       def standby(self):
-               self.session.open(Standby, self)
-
-       def quit(self):
-               # halt
-               quitMainloop(1)
-
 class InfoBarNumberZap:
        """ Handles an initial number for NumberZapping """
        def __init__(self):
@@ -269,12 +234,17 @@ class InfoBarNumberZap:
                        self.servicelist.setCurrentSelection(service) #select the service in servicelist
                        self.servicelist.zap()
 
+config.misc.initialchannelselection = configElementBoolean("config.misc.initialchannelselection", 1);
+
 class InfoBarChannelSelection:
        """ ChannelSelection - handles the channelSelection dialog and the initial 
        channelChange actions which open the channelSelection dialog """
        def __init__(self):
                #instantiate forever
                self.servicelist = self.session.instantiateDialog(ChannelSelection)
+               
+               if config.misc.initialchannelselection.value == 1:
+                       self.onShown.append(self.firstRun)
 
                self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
                        {
@@ -286,6 +256,12 @@ class InfoBarChannelSelection:
                                "historyNext": (self.historyNext, _("next channel in history"))
                        })
 
+       def firstRun(self):
+               self.onShown.remove(self.firstRun)
+               config.misc.initialchannelselection.value = 0
+               config.misc.initialchannelselection.save()
+               self.switchChannelDown()
+               
        def historyBack(self):
                self.servicelist.historyBack()
 
@@ -554,8 +530,9 @@ class InfoBarSeek:
                                if action[:5] == "seek:":
                                        time = int(action[5:])
                                        self.screen.seekRelative(time * 90000)
+                                       return 1
                                else:
-                                       HelpableActionMap.action(self, contexts, action)
+                                       return HelpableActionMap.action(self, contexts, action)
 
                self["SeekActions"] = InfoBarSeekActionMap(self, "InfobarSeekActions", 
                        {
@@ -655,7 +632,7 @@ class InfoBarSeek:
                self.checkSkipShowHideLock()
 
                return True
-               
+
        def pauseService(self):
                if self.seekstate == self.SEEK_STATE_PAUSE:
                        print "pause, but in fact unpause"
@@ -805,17 +782,17 @@ class InfoBarSeek:
                if seekable is not None:
                        seekable.seekRelative(1, diff)
 
-from Screens.PVRState import PVRState
+from Screens.PVRState import PVRState, TimeshiftState
 
 class InfoBarPVRState:
-       def __init__(self):
+       def __init__(self, screen=PVRState):
                self.onPlayStateChanged.append(self.__playStateChanged)
-               self.pvrStateDialog = self.session.instantiateDialog(PVRState)
+               self.pvrStateDialog = self.session.instantiateDialog(screen)
                self.onShow.append(self.__mayShow)
                self.onHide.append(self.pvrStateDialog.hide)
        
        def __mayShow(self):
-               if self.seekstate != self.SEEK_STATE_PLAY:
+               if self.seekstate != self.SEEK_STATE_PLAY and self.execing:
                        self.pvrStateDialog.show()
 
        def __playStateChanged(self, state):
@@ -823,6 +800,11 @@ class InfoBarPVRState:
                self.pvrStateDialog["state"].setText(playstateString)
                self.__mayShow()
 
+class InfoBarTimeshiftState(InfoBarPVRState):
+       def __init__(self):
+               InfoBarPVRState.__init__(self, screen=TimeshiftState)
+
+
 class InfoBarShowMovies:
 
        # i don't really like this class. 
@@ -884,6 +866,7 @@ class InfoBarTimeshift:
 
                self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
                        {
+                               iPlayableService.evStart: self.__serviceStarted,
                                iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged
                        })
        
@@ -903,7 +886,9 @@ class InfoBarTimeshift:
                        print "hu, timeshift already enabled?"
                else:
                        if not ts.startTimeshift():
+                               import time
                                self.timeshift_enabled = 1
+                               self.pvrStateDialog["timeshift"].setRelative(time.time())
                                
                                # PAUSE.
                                self.setSeekState(self.SEEK_STATE_PAUSE)
@@ -984,6 +969,10 @@ class InfoBarTimeshift:
                print "timeshift activate:", enabled
                self["TimeshiftActivateActions"].setEnabled(enabled)
 
+       def __serviceStarted(self):
+               self.timeshift_enabled = False
+               self.__seekableStatusChanged()
+
 from RecordTimer import parseEvent
 
 class InfoBarInstantRecord:
@@ -1375,8 +1364,8 @@ class InfoBarCueSheetSupport:
 class InfoBarSummary(Screen):
        skin = """
        <screen position="0,0" size="132,64">
-               <widget name="Clock" position="50,46" size="82,18" font="Regular;19" />
-               <widget name="CurrentService" position="0,4" size="132,42" font="Regular;19" />
+               <widget name="Clock" position="50,46" size="82,18" font="Regular;16" />
+               <widget name="CurrentService" position="0,4" size="132,42" font="Regular;18" />
        </screen>"""
 
        def __init__(self, session, parent):
@@ -1390,3 +1379,21 @@ class InfoBarSummarySupport:
        
        def createSummary(self):
                return InfoBarSummary
+
+class InfoBarTeletextPlugin:
+       def __init__(self):
+               self.teletext_plugin = None
+               
+               for p in plugins.getPlugins(PluginDescriptor.WHERE_TELETEXT):
+                       self.teletext_plugin = p
+               
+               if self.teletext_plugin is not None:
+                       self["TeletextActions"] = HelpableActionMap(self, "InfobarTeletextActions",
+                               {
+                                       "startTeletext": (self.startTeletext, "View teletext...")
+                               })
+               else:
+                       print "no teletext plugin found!"
+
+       def startTeletext(self):
+               self.teletext_plugin(session=self.session, service=self.session.nav.getCurrentService())