From 19e860eb0c66030cf181bf49a1f93f2ea13d0215 Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Tue, 26 Feb 2013 15:25:46 -0300
Subject: [PATCH Browse] 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>
---
downloadmanager.py | 15 +++++++++++++--
pdfviewer.py | 12 +++++++++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/downloadmanager.py b/downloadmanager.py
index 2fdbaa5..9e630ff 100644
a
|
b
|
class Download(object): |
97 | 97 | self.dl_jobject.metadata['progress'] = str(int(progress * 100)) |
98 | 98 | datastore.write(self.dl_jobject) |
99 | 99 | |
| 100 | def __current_size_changed_cb(self, download, something): |
| 101 | current_size = self._download.get_current_size() |
| 102 | total_size = self._download.get_total_size() |
| 103 | progress = current_size * 100 / total_size |
| 104 | self.dl_jobject.metadata['progress'] = str(progress) |
| 105 | datastore.write(self.dl_jobject) |
| 106 | |
100 | 107 | def __state_change_cb(self, download, gparamspec): |
101 | 108 | state = self._download.get_status() |
102 | 109 | if state == WebKit.DownloadStatus.STARTED: |
… |
… |
class Download(object): |
133 | 140 | self.__stop_response_cb) |
134 | 141 | self._activity.add_alert(self._canceled_alert) |
135 | 142 | else: |
136 | | self._download.connect('notify::progress', |
137 | | self.__progress_change_cb) |
| 143 | # FIXME: workaround for SL #4385 |
| 144 | # self._download.connect('notify::progress', |
| 145 | # self.__progress_change_cb) |
| 146 | self._download.connect('notify::current-size', |
| 147 | self.__current_size_changed_cb) |
| 148 | |
138 | 149 | self._create_journal_object() |
139 | 150 | self._object_id = self.dl_jobject.object_id |
140 | 151 | |
diff --git a/pdfviewer.py b/pdfviewer.py
index 7557594..f30dbc0 100644
a
|
b
|
class PDFTabPage(Gtk.HBox): |
503 | 503 | self._download = WebKit.Download.new(network_request) |
504 | 504 | self._download.set_destination_uri('file://' + dest_path) |
505 | 505 | |
506 | | self._download.connect('notify::progress', self.__download_progress_cb) |
| 506 | # FIXME: workaround for SL #4385 |
| 507 | # self._download.connect('notify::progress', self.__download_progress_cb) |
| 508 | self._download.connect('notify::current-size', |
| 509 | self.__current_size_changed_cb) |
507 | 510 | self._download.connect('notify::status', self.__download_status_cb) |
508 | 511 | self._download.connect('error', self.__download_error_cb) |
509 | 512 | |
510 | 513 | self._download.start() |
511 | 514 | |
| 515 | def __current_size_changed_cb(self, download, something): |
| 516 | current_size = download.get_current_size() |
| 517 | total_size = download.get_total_size() |
| 518 | progress = current_size / float(total_size) |
| 519 | self._browser.props.progress = progress |
| 520 | self._message_box.progress_icon.update(progress) |
| 521 | |
512 | 522 | def __download_progress_cb(self, download, data): |
513 | 523 | progress = download.get_progress() |
514 | 524 | self._browser.props.progress = progress |