changeset 2103:b44558286bbb

quick frontend (quick app): added progressFinished and progressError listeners
author Goffi <goffi@goffi.org>
date Thu, 22 Dec 2016 18:10:36 +0100
parents 071423b3a413
children 4f189bd1d9ed
files frontends/src/quick_frontend/constants.py frontends/src/quick_frontend/quick_app.py
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/constants.py	Tue Dec 20 21:07:22 2016 +0100
+++ b/frontends/src/quick_frontend/constants.py	Thu Dec 22 18:10:36 2016 +0100
@@ -83,7 +83,7 @@
     UPDATE_SELECTION = 'SELECTION'
     UPDATE_STRUCTURE = 'STRUCTURE' # high level update (i.e. not item level but organisation of items)
 
-    LISTENERS = {'avatar', 'nick', 'presence', 'profilePlugged', 'disconnect', 'gotMenus', 'menu', 'notification', 'notificationsClear'}
+    LISTENERS = {'avatar', 'nick', 'presence', 'profilePlugged', 'disconnect', 'gotMenus', 'menu', 'notification', 'notificationsClear', 'progressFinished', 'progressError'}
 
     # Notifications
     NOTIFY_MESSAGE = 'MESSAGE'  # a message was received
--- a/frontends/src/quick_frontend/quick_app.py	Tue Dec 20 21:07:22 2016 +0100
+++ b/frontends/src/quick_frontend/quick_app.py	Thu Dec 22 18:10:36 2016 +0100
@@ -363,6 +363,10 @@
                     path_i18n: translated path (or None if the item is removed)
                     item: instance of quick_menus.MenuItemBase or None if the item is removed
             - gotMenus: called only once when menu are available (no arg)
+            - progressFinished: called when a progressing action has just finished
+                args:  (progress_id, metadata, profile)
+            - progressError: called when a progressing action failed
+                args: (progress_id, error_msg, profile):
         @param callback: method to call on event
         @param profiles_filter (set[unicode]): if set and not empty, the
             listener will be callable only by one of the given profiles.
@@ -747,9 +751,11 @@
 
     def progressFinishedHandler(self, pid, metadata, profile):
         log.info(u"Progress {} finished".format(pid))
+        self.callListeners('progressFinished', pid, metadata, profile=profile)
 
     def progressErrorHandler(self, pid, err_msg, profile):
         log.warning(u"Progress {pid} error: {err_msg}".format(pid=pid, err_msg=err_msg))
+        self.callListeners('progressError', pid, err_msg, profile=profile)
 
     def _subscribe_cb(self, answer, data):
         entity, profile = data