aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Tools/Notifications.py
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2006-12-07 23:50:31 +0000
committerFelix Domke <tmbinc@elitedvb.net>2006-12-07 23:50:31 +0000
commitebf9e4748af73d94cf3de121b6e8c4e8a70d1d13 (patch)
tree54cd573298c314ad6e2c7ff56eb125bbb690cf61 /lib/python/Tools/Notifications.py
parent69600a7a1779402fd2d1a2eee4b313590d5824fe (diff)
downloadenigma2-ebf9e4748af73d94cf3de121b6e8c4e8a70d1d13.tar.gz
enigma2-ebf9e4748af73d94cf3de121b6e8c4e8a70d1d13.zip
add popups with id so they can be updated /removed
Diffstat (limited to 'lib/python/Tools/Notifications.py')
-rw-r--r--lib/python/Tools/Notifications.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/lib/python/Tools/Notifications.py b/lib/python/Tools/Notifications.py
index 3cb107cc..85452e11 100644
--- a/lib/python/Tools/Notifications.py
+++ b/lib/python/Tools/Notifications.py
@@ -3,10 +3,43 @@ notifications = [ ]
notificationAdded = [ ]
+
+# notifications which are currently on screen (and might be closed by similiar notifications)
+current_notifications = [ ]
+
+def __AddNotification(fnc, screen, id, *args, **kwargs):
+ notifications.append((fnc, screen, args, kwargs, id))
+ for x in notificationAdded:
+ x()
+
def AddNotification(screen, *args, **kwargs):
AddNotificationWithCallback(None, screen, *args, **kwargs)
def AddNotificationWithCallback(fnc, screen, *args, **kwargs):
- notifications.append((fnc, screen, args, kwargs))
- for x in notificationAdded:
- x()
+ __AddNotification(fnc, screen, None, *args, **kwargs)
+
+def AddNotificationWithID(id, screen, *args, **kwargs):
+ __AddNotification(None, screen, id, *args, **kwargs)
+
+# we don't support notifications with callback and ID as this
+# would require manually calling the callback on cancelled popups.
+
+def RemovePopup(id):
+ # remove similiar notifications
+ print "RemovePopup, id =", id
+ for x in notifications:
+ if x[4] and x[4] == id:
+ print "(found in notifications)"
+ notifications.remove(x)
+
+ for x in current_notifications:
+ if x[0] == id:
+ print "(found in current notifications)"
+ x[1].close()
+
+def AddPopup(text, type, timeout, id = None):
+ if id is not None:
+ RemovePopup(id)
+ from Screens.MessageBox import MessageBox
+ print "AddPopup, id =", id
+ AddNotificationWithID(id, MessageBox, text = text, type = type, timeout = timeout)