Merge branch 'experimental' of git.opendreambox.org:/git/enigma2 into experimental
[enigma2.git] / lib / python / Screens / Scart.py
1 from Screen import Screen
2 from MessageBox import MessageBox
3 from Components.AVSwitch import AVSwitch
4 from Tools import Notifications
5
6 class Scart(Screen):
7         def __init__(self, session, start_visible=True):
8                 Screen.__init__(self, session)
9                 self.msgBox = None
10                 self.notificationVisible = None
11
12                 self.avswitch = AVSwitch()
13
14                 if start_visible:
15                         self.onExecBegin.append(self.showMessageBox)
16                         self.msgVisible = None
17                 else:
18                         self.msgVisible = False
19
20         def showMessageBox(self):
21                 if self.msgVisible is None:
22                         self.onExecBegin.remove(self.showMessageBox)
23                         self.msgVisible = False
24
25                 if not self.msgVisible:
26                         self.msgVisible = True
27                         self.avswitch.setInput("SCART")
28                         if not self.session.in_exec:
29                                 self.notificationVisible = True
30                                 Notifications.AddNotificationWithCallback(self.MsgBoxClosed, MessageBox, _("If you see this, something is wrong with\nyour scart connection. Press OK to return."), MessageBox.TYPE_ERROR, msgBoxID = "scart_msgbox")
31                         else:
32                                 self.msgBox = self.session.openWithCallback(self.MsgBoxClosed, MessageBox, _("If you see this, something is wrong with\nyour scart connection. Press OK to return."), MessageBox.TYPE_ERROR)
33
34         def MsgBoxClosed(self, *val):
35                 self.msgBox = None
36                 self.switchToTV()
37
38         def switchToTV(self, *val):
39                 if self.msgVisible:
40                         if self.msgBox:
41                                 self.msgBox.close() # ... MsgBoxClosed -> switchToTV again..
42                                 return
43                         self.avswitch.setInput("ENCODER")
44                         self.msgVisible = False
45                 if self.notificationVisible:
46                         self.avswitch.setInput("ENCODER")
47                         self.notificationVisible = False
48                         for notification in Notifications.current_notifications:
49                                 try:
50                                         if notification[1].msgBoxID == "scart_msgbox":
51                                                 notification[1].close()
52                                 except:
53                                         print "other notification is open. try another one."
54