Ticket #4385: 0001-Download-progress-bar-SL-4385.patch

File 0001-Download-progress-bar-SL-4385.patch, 3.4 KB (added by humitos, 8 years ago)

Workaround for this WebKit+ bug

  • downloadmanager.py

    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): 
    9797        self.dl_jobject.metadata['progress'] = str(int(progress * 100))
    9898        datastore.write(self.dl_jobject)
    9999
     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
    100107    def __state_change_cb(self, download, gparamspec):
    101108        state = self._download.get_status()
    102109        if state == WebKit.DownloadStatus.STARTED:
    class Download(object): 
    133140                                             self.__stop_response_cb)
    134141                self._activity.add_alert(self._canceled_alert)
    135142            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
    138149                self._create_journal_object()
    139150                self._object_id = self.dl_jobject.object_id
    140151
  • pdfviewer.py

    diff --git a/pdfviewer.py b/pdfviewer.py
    index 7557594..f30dbc0 100644
    a b class PDFTabPage(Gtk.HBox): 
    503503        self._download = WebKit.Download.new(network_request)
    504504        self._download.set_destination_uri('file://' + dest_path)
    505505
    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)
    507510        self._download.connect('notify::status', self.__download_status_cb)
    508511        self._download.connect('error', self.__download_error_cb)
    509512
    510513        self._download.start()
    511514
     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
    512522    def __download_progress_cb(self, download, data):
    513523        progress = download.get_progress()
    514524        self._browser.props.progress = progress