fix non working timeshift
[enigma2.git] / lib / python / Tools / Notifications.py
1
2 notifications = [ ]
3
4 notificationAdded = [ ]
5
6 # notifications which are currently on screen (and might be closed by similiar notifications)
7 current_notifications = [ ]
8
9 def __AddNotification(fnc, screen, id, *args, **kwargs):
10         notifications.append((fnc, screen, args, kwargs, id))
11         for x in notificationAdded:
12                 x()
13
14 def AddNotification(screen, *args, **kwargs):
15         AddNotificationWithCallback(None, screen, *args, **kwargs)
16
17 def AddNotificationWithCallback(fnc, screen, *args, **kwargs):
18         __AddNotification(fnc, screen, None, *args, **kwargs)
19
20 def AddNotificationWithID(id, screen, *args, **kwargs):
21         __AddNotification(None, screen, id, *args, **kwargs)
22
23 # we don't support notifications with callback and ID as this
24 # would require manually calling the callback on cancelled popups.
25
26 def RemovePopup(id):
27         # remove similiar notifications
28         print "RemovePopup, id =", id
29         for x in notifications:
30                 if x[4] and x[4] == id:
31                         print "(found in notifications)"
32                         notifications.remove(x)
33
34         for x in current_notifications:
35                 if x[0] == id:
36                         print "(found in current notifications)"
37                         x[1].close()
38
39 from Screens.MessageBox import MessageBox
40
41 def AddPopup(text, type, timeout, id = None):
42         if id is not None:
43                 RemovePopup(id)
44         print "AddPopup, id =", id
45         AddNotificationWithID(id, MessageBox, text = text, type = type, timeout = timeout, close_on_any_key = True)