enigma2: 4.3.1r16
[opendreambox.git] / meta-opendreambox / recipes-dreambox / enigma2 / enigma2 / 0002-InfoBarServiceErrorPopupSupport-InfoBarStateInfo.patch
1 From 6d763911db5e7dc9fc63e8d5a080676d136a999e Mon Sep 17 00:00:00 2001
2 From: reichi <reichi@opendreambox.org>
3 Date: Tue, 5 Sep 2017 10:03:43 +0200
4 Subject: [PATCH 2/2] InfoBarServiceErrorPopupSupport: rework InfoBarStateInfo
5  handling a bit. - Make InfoBarStateInfo static/shared between all
6  InfoBarServiceErrorPopupSupport instances - Hide InfoBarStateInfo when
7  InfoBarServiceErrorPopupSupport is not execing, and restore it in onShown -
8  Fixes issues with "external" players that i was aware of and tested Screen:
9  Add onExecEnd callback
10
11 ---
12  lib/python/Screens/InfoBarGenerics.py | 42 ++++++++++++++++++++++++++---------
13  lib/python/Screens/Screen.py          |  3 +++
14  2 files changed, 34 insertions(+), 11 deletions(-)
15
16 diff --git a/usr/lib/enigma2/python/Screens/InfoBarGenerics.py b/usr/lib/enigma2/python/Screens/InfoBarGenerics.py
17 index 2667a68..3f8c28d 100644
18 --- a/usr/lib/enigma2/python/Screens/InfoBarGenerics.py
19 +++ b/usr/lib/enigma2/python/Screens/InfoBarGenerics.py
20 @@ -2523,12 +2523,17 @@ class InfoBarStateInfo(Screen):
21                 self._stateOnly = False if message else True
22                 #self._resizeBoxes()
23  
24 +       def current(self):
25 +               return (self["state"].text, self["message"].text)
26 +
27  class InfoBarServiceErrorPopupSupport:
28         STATE_TUNING = _("tuning...")
29         STATE_CONNECTING = _("connecting...")
30         MESSAGE_WAIT = _("Please wait!")
31         STATE_RECONNECTING = _("reconnecting...")
32  
33 +       _stateInfo = None
34 +
35         def __init__(self):
36                 Notifications.notificationQueue.registerDomain("ZapError", _("ZapError"), Notifications.ICON_DEFAULT)
37                 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
38 @@ -2545,25 +2550,40 @@ class InfoBarServiceErrorPopupSupport:
39                 self._isReconnect = False
40                 self._currentRef = None
41                 self.last_error = None
42 -               self._stateInfo = self.session.instantiateDialog(InfoBarStateInfo,zPosition=-5)
43 -               self._stateInfo.neverAnimate()
44 +               if not InfoBarServiceErrorPopupSupport._stateInfo:
45 +                       InfoBarServiceErrorPopupSupport._stateInfo = self.session.instantiateDialog(InfoBarStateInfo,zPosition=-5)
46 +                       InfoBarServiceErrorPopupSupport._stateInfo.neverAnimate()
47                 self._reconnTimer = eTimer()
48                 self._reconnTimer_conn = self._reconnTimer.timeout.connect(self._doReconnect)
49 +               self._restoreInfo = None
50 +
51 +               self.onShown.append(self.__restoreState)
52 +               self.onExecEnd.append(self.__hideState)
53 +               self.onClose.append(self.__hideState)
54 +
55                 self.__servicePlaying()
56 -               self.onClose.append(self.__onClose)
57  
58 -       def __onClose(self):
59 -               self._stateInfo.close()
60 +       def __restoreState(self):
61 +               Log.i()
62 +               if self.execing and self._restoreInfo:
63 +                       self.setPlaybackState(*self._restoreInfo)
64 +
65 +       def __hideState(self):
66 +               if InfoBarServiceErrorPopupSupport._stateInfo.shown:
67 +                       self._restoreInfo = InfoBarServiceErrorPopupSupport._stateInfo.current()
68 +               InfoBarServiceErrorPopupSupport._stateInfo.hide()
69  
70         def setPlaybackState(self, state=None, message=None):
71 -               Log.w("%s %s %s" %(state, message, time()))
72 +               Log.i("%s %s %s" %(state, message, time()))
73                 if state or message:
74 -                       Log.w("show")
75 -                       self._stateInfo.setPlaybackState(state, message)
76 -                       self._stateInfo.show()
77 +                       if self.execing:
78 +                               InfoBarServiceErrorPopupSupport._stateInfo.setPlaybackState(state, message)
79 +                               InfoBarServiceErrorPopupSupport._stateInfo.show()
80 +                               self._restoreInfo = None
81 +                       else:
82 +                               self._restoreInfo = (state, message)
83                 else:
84 -                       self._stateInfo.hide()
85 -                       Log.w("hide")
86 +                       InfoBarServiceErrorPopupSupport._stateInfo.hide()
87  
88         def __serviceStarted(self):
89                 if not self._isStream:
90 diff --git a/usr/lib/enigma2/python/Screens/Screen.py b/usr/lib/enigma2/python/Screens/Screen.py
91 index 1bbf916..30aa0fe 100644
92 --- a/usr/lib/enigma2/python/Screens/Screen.py
93 +++ b/usr/lib/enigma2/python/Screens/Screen.py
94 @@ -30,6 +30,7 @@ class Screen(dict, GUISkin):
95  
96                 self.onShow = [ ]
97                 self.onHide = [ ]
98 +               self.onExecEnd = [ ]
99                 self.onHideFinished = [ ]
100  
101                 self.execing = False
102 @@ -106,6 +107,8 @@ class Screen(dict, GUISkin):
103  #              assert self.session != None, "execEnd on non-execing screen!"
104  #              self.session = None
105                 self.execing = False
106 +               for x in self.onExecEnd:
107 +                       x()
108  
109         def doClose(self, immediate=True):
110                 print "WARNING: NEVER call Screen.doClose directly!!! You have to use Session.deleteDialog(screen)\nThis function is deprecated and will be removed in the future\nPlease report!"
111 -- 
112 2.7.4
113