diff frontends/src/primitivus/progress.py @ 1636:e00f450c25fc

primitivus: fixed progress panel
author Goffi <goffi@goffi.org>
date Fri, 20 Nov 2015 01:57:18 +0100
parents 069ad98b360d
children d17772b0fe22
line wrap: on
line diff
--- a/frontends/src/primitivus/progress.py	Fri Nov 20 01:57:18 2015 +0100
+++ b/frontends/src/primitivus/progress.py	Fri Nov 20 01:57:18 2015 +0100
@@ -34,14 +34,13 @@
         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 @@
 
     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 @@
                 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):