diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2013-02-26 18:25:46 (GMT) |
---|---|---|
committer | Manuel QuiƱones <manuq@laptop.org> | 2013-04-10 13:00:16 (GMT) |
commit | 5234aee5bae44f0ca81084f0d33a26f24d6ac63a (patch) | |
tree | d7a57e05f01e82d75d78837a7f3577e5ab5f8358 /downloadmanager.py | |
parent | 673332382799ea8e9c3f18914b9757583e4833a0 (diff) |
Download progress bar SL #4385
This patch is a workaround for a WebKit's bug[1] regarding the
'notify::progress' signal that is not emitted when it should be. So,
we use 'notify::current-size' signal instead and compare the
'current-size' with the 'total-size' to get the proper progress.
[1] https://bugs.webkit.org/show_bug.cgi?id=107308
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Acked-by: Manuel QuiƱones <manuq@laptop.org>
Diffstat (limited to 'downloadmanager.py')
-rw-r--r-- | downloadmanager.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/downloadmanager.py b/downloadmanager.py index 2fdbaa5..9e630ff 100644 --- a/downloadmanager.py +++ b/downloadmanager.py @@ -97,6 +97,13 @@ class Download(object): self.dl_jobject.metadata['progress'] = str(int(progress * 100)) datastore.write(self.dl_jobject) + def __current_size_changed_cb(self, download, something): + current_size = self._download.get_current_size() + total_size = self._download.get_total_size() + progress = current_size * 100 / total_size + self.dl_jobject.metadata['progress'] = str(progress) + datastore.write(self.dl_jobject) + def __state_change_cb(self, download, gparamspec): state = self._download.get_status() if state == WebKit.DownloadStatus.STARTED: @@ -133,8 +140,12 @@ class Download(object): self.__stop_response_cb) self._activity.add_alert(self._canceled_alert) else: - self._download.connect('notify::progress', - self.__progress_change_cb) + # FIXME: workaround for SL #4385 + # self._download.connect('notify::progress', + # self.__progress_change_cb) + self._download.connect('notify::current-size', + self.__current_size_changed_cb) + self._create_journal_object() self._object_id = self.dl_jobject.object_id |