primitivus: fixed progress panel
This commit is contained in:
parent
2494387bf5
commit
4ffbce51c3
4 changed files with 41 additions and 17 deletions
|
|
@ -55,8 +55,8 @@ class Const(constants.Const):
|
|||
('directory_focus', 'dark cyan, bold', 'dark green'),
|
||||
('separator', 'brown', 'default'),
|
||||
('warning', 'light red', 'default'),
|
||||
('progress_normal', 'default', 'black'),
|
||||
('progress_complete', 'default', 'light red'),
|
||||
('progress_normal', 'default', 'brown'),
|
||||
('progress_complete', 'default', 'dark green'),
|
||||
('show_disconnected', 'dark gray', 'default'),
|
||||
('show_normal', 'default', 'default'),
|
||||
('show_normal_focus', 'default, bold', 'default'),
|
||||
|
|
|
|||
|
|
@ -563,11 +563,13 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
self.center_part.focus_position = 0
|
||||
self.redraw()
|
||||
|
||||
def addProgress (self, id, message):
|
||||
"""Follow a SàT progress bar
|
||||
@param id: SàT id of the progression
|
||||
@param message: message to show to identify the progression"""
|
||||
self.progress_wid.addProgress(id, message)
|
||||
def addProgress(self, pid, message, profile):
|
||||
"""Follow a SàT progression
|
||||
|
||||
@param pid: progression id
|
||||
@param message: message to show to identify the progression
|
||||
"""
|
||||
self.progress_wid.add(pid, message, profile)
|
||||
|
||||
def setProgress(self, percentage):
|
||||
"""Set the progression shown in notification bar"""
|
||||
|
|
@ -631,6 +633,7 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
self.main_widget.hide('notif_bar')
|
||||
else:
|
||||
self.main_widget.show('notif_bar')
|
||||
self.redraw() # FIXME: invalidate cache in a more efficient way
|
||||
|
||||
def _actionManagerUnknownError(self):
|
||||
self.alert(_("Error"), _(u"Unmanaged action"))
|
||||
|
|
@ -707,11 +710,21 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
log.error (_("FIXME FIXME FIXME: type [%s] not implemented") % type_)
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, profile):
|
||||
super(PrimitivusApp, self).roomJoinedHandler(room_jid_s, room_nicks, user_nick, profile)
|
||||
self.contact_lists[profile].setFocus(jid.JID(room_jid_s), True)
|
||||
|
||||
def progressStartedHandler(self, pid, metadata, profile):
|
||||
super(PrimitivusApp, self).progressStartedHandler(pid, metadata, profile)
|
||||
self.addProgress(pid, metadata.get('name', _(u'unkown')), profile)
|
||||
|
||||
def progressFinishedHandler(self, pid, metadata, profile):
|
||||
log.info(u"Progress {} finished".format(pid))
|
||||
super(PrimitivusApp, self).progressFinishedHandler(pid, metadata, profile)
|
||||
|
||||
def progressErrorHandler(self, pid, err_msg, profile):
|
||||
log.warning(u"Progress {pid} error: {err_msg}".format(pid=pid, err_msg=err_msg))
|
||||
super(PrimitivusApp, self).progressErrorHandler(pid, err_msg, profile)
|
||||
|
||||
|
||||
##DIALOGS CALLBACKS##
|
||||
|
|
|
|||
|
|
@ -34,14 +34,13 @@ class Progress(urwid.WidgetWrap, quick_widgets.QuickWidget):
|
|||
self.progress_dict = {}
|
||||
listbox = urwid.ListBox(self.progress_list)
|
||||
buttons = []
|
||||
buttons.append(sat_widgets.CustomButton(_('Clear progress list'), self.__onClear))
|
||||
buttons.append(sat_widgets.CustomButton(_('Clear progress list'), self._onClear))
|
||||
max_len = max([button.getSize() for button in buttons])
|
||||
buttons_wid = urwid.GridFlow(buttons,max_len,1,0,'center')
|
||||
main_wid = sat_widgets.FocusFrame(listbox, footer=buttons_wid)
|
||||
urwid.WidgetWrap.__init__(self, main_wid)
|
||||
|
||||
def addProgress(self, progress_id, message):
|
||||
profile = self.host.profile # TODO: manage multiple profiles
|
||||
def add(self, progress_id, message, profile):
|
||||
mess_wid = urwid.Text(message)
|
||||
progr_wid = urwid.ProgressBar('progress_normal', 'progress_complete')
|
||||
column = urwid.Columns([mess_wid, progr_wid])
|
||||
|
|
@ -51,8 +50,8 @@ class Progress(urwid.WidgetWrap, quick_widgets.QuickWidget):
|
|||
|
||||
def progressCB(self, loop, data):
|
||||
progress_id, message, profile = data
|
||||
data = self.host.bridge.getProgress(progress_id, profile)
|
||||
pbar = self.progress_dict[(progress_id, profile)]['progress'] #FIXME: must manage profiles
|
||||
data = self.host.bridge.progressGet(progress_id, profile)
|
||||
pbar = self.progress_dict[(progress_id, profile)]['progress']
|
||||
if data:
|
||||
if self.progress_dict[(progress_id, profile)]['state'] == 'init':
|
||||
#first answer, we must construct the bar
|
||||
|
|
@ -68,20 +67,20 @@ class Progress(urwid.WidgetWrap, quick_widgets.QuickWidget):
|
|||
self.updateNotBar()
|
||||
return
|
||||
|
||||
loop.set_alarm_in(1,self.progressCB, (progress_id, message, profile))
|
||||
loop.set_alarm_in(0.2,self.progressCB, (progress_id, message, profile))
|
||||
|
||||
def __removeBar(self, progress_id, profile):
|
||||
def _removeBar(self, progress_id, profile):
|
||||
wid = self.progress_dict[(progress_id, profile)]['full']
|
||||
self.progress_list.remove(wid)
|
||||
del(self.progress_dict[(progress_id, profile)])
|
||||
|
||||
def __onClear(self, button):
|
||||
def _onClear(self, button):
|
||||
to_remove = []
|
||||
for progress_id, profile in self.progress_dict:
|
||||
if self.progress_dict[(progress_id, profile)]['state'] == 'done':
|
||||
to_remove.append((progress_id, profile))
|
||||
for progress_id, profile in to_remove:
|
||||
self.__removeBar(progress_id, profile)
|
||||
self._removeBar(progress_id, profile)
|
||||
self.updateNotBar()
|
||||
|
||||
def updateNotBar(self):
|
||||
|
|
|
|||
|
|
@ -249,6 +249,9 @@ class QuickApp(object):
|
|||
self.registerSignal("entityDataUpdated")
|
||||
self.registerSignal("askConfirmation")
|
||||
self.registerSignal("actionResult")
|
||||
self.registerSignal("progressStarted")
|
||||
self.registerSignal("progressFinished")
|
||||
self.registerSignal("progressError")
|
||||
self.registerSignal("actionResultExt", self.actionResultHandler)
|
||||
self.registerSignal("roomJoined", iface="plugin")
|
||||
self.registerSignal("roomLeft", iface="plugin")
|
||||
|
|
@ -646,6 +649,15 @@ class QuickApp(object):
|
|||
else:
|
||||
log.warning("Unmanaged PubSub event type {}".format(event_type))
|
||||
|
||||
def progressStartedHandler(self, pid, metadata, profile):
|
||||
log.info(u"Progress {} started".format(pid))
|
||||
|
||||
def progressFinishedHandler(self, pid, metadata, profile):
|
||||
log.info(u"Progress {} finished".format(pid))
|
||||
|
||||
def progressErrorHandler(self, pid, err_msg, profile):
|
||||
log.warning(u"Progress {pid} error: {err_msg}".format(pid=pid, err_msg=err_msg))
|
||||
|
||||
def _subscribe_cb(self, answer, data):
|
||||
entity, profile = data
|
||||
type_ = "subscribed" if answer else "unsubscribed"
|
||||
|
|
|
|||
Loading…
Reference in a new issue