[Pkg-sugar-commit] [sugar-browse-activity] 11/16: Download progress bar SL #4385

Jonas Smedegaard dr at jones.dk
Mon Apr 20 09:47:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag v149.2
in repository sugar-browse-activity.

commit 9d886575e4410752be01eacbb72708befcdc8df3
Author: Manuel Kaufmann <humitos at gmail.com>
Date:   Tue Feb 26 15:25:46 2013 -0300

    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 at gmail.com>
    Acked-by: Manuel Quiñones <manuq at laptop.org>
---
 downloadmanager.py | 15 +++++++++++++--
 pdfviewer.py       | 12 +++++++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/downloadmanager.py b/downloadmanager.py
index 1e4f92b..d3f5874 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -95,6 +95,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:
@@ -128,8 +135,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
 
diff --git a/pdfviewer.py b/pdfviewer.py
index b98fab4..25188b1 100644
--- a/pdfviewer.py
+++ b/pdfviewer.py
@@ -384,12 +384,22 @@ class PDFTabPage(Gtk.HBox):
         self._download = WebKit.Download.new(network_request)
         self._download.set_destination_uri('file://' + dest_path)
 
-        self._download.connect('notify::progress', self.__download_progress_cb)
+        # FIXME: workaround for SL #4385
+        # self._download.connect('notify::progress', self.__download_progress_cb)
+        self._download.connect('notify::current-size',
+                               self.__current_size_changed_cb)
         self._download.connect('notify::status', self.__download_status_cb)
         self._download.connect('error', self.__download_error_cb)
 
         self._download.start()
 
+    def __current_size_changed_cb(self, download, something):
+        current_size = download.get_current_size()
+        total_size = download.get_total_size()
+        progress = current_size / float(total_size)
+        self._browser.props.progress = progress
+        self._message_box.progress_icon.update(progress)
+
     def __download_progress_cb(self, download, data):
         progress = download.get_progress()
         self._browser.props.progress = progress

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-browse-activity.git



More information about the pkg-sugar-commit mailing list