From 273cab7ffc0c0b4ae17d5844bc1d9c0fc06fef19 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Fri, 23 Mar 2012 12:03:17 +0000 Subject: Update progress bar and stop/reload buttons when switching tabs Calling the _set_status and _set_progress methods in the web toolbar directly when a new tab is activated. Also the callback for load-status is disconnected now in the previous tab, like the other callbacks. Removed the update of the navigation buttons when the loading status changes. This is only needed when the adress changes or when the tabs are switched. Removed the title set to None when loading status chenges, this was giving the following Gtk error: Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed Signed-off-by: Manuel QuiƱones Acked-by: Simon Schampijer --- diff --git a/pdfviewer.py b/pdfviewer.py index c7e2452..ef6a6ea 100644 --- a/pdfviewer.py +++ b/pdfviewer.py @@ -366,7 +366,6 @@ class PDFTabPage(Gtk.HBox): def __download_progress_cb(self, download, data): progress = download.get_progress() - self._browser.props.load_status = WebKit.LoadStatus.PROVISIONAL self._browser.props.progress = progress def __download_status_cb(self, download, data): diff --git a/webtoolbar.py b/webtoolbar.py index 7525053..654f720 100644 --- a/webtoolbar.py +++ b/webtoolbar.py @@ -324,6 +324,7 @@ class PrimaryToolbar(ToolbarBase): self._browser.disconnect(self._title_changed_hid) self._browser.disconnect(self._uri_changed_hid) self._browser.disconnect(self._progress_changed_hid) + self._browser.disconnect(self._loading_changed_hid) self._browser = browser if self._browser.props.title: @@ -331,11 +332,11 @@ class PrimaryToolbar(ToolbarBase): else: self._set_title(_('Untitled')) self._set_address(self._browser.props.uri) + self._set_progress(self._browser.props.progress) + self._set_status(self._browser.props.load_status) - if isinstance(self._browser, Browser): - self.entry.props.editable = True - else: - self.entry.props.editable = False + is_webkit_browser = isinstance(self._browser, Browser) + self.entry.props.editable = is_webkit_browser self._title_changed_hid = self._browser.connect( 'notify::title', self._title_changed_cb) @@ -349,15 +350,14 @@ class PrimaryToolbar(ToolbarBase): self._update_navigation_buttons() def __loading_changed_cb(self, widget, param): - status = widget.get_load_status() - if status <= WebKit.LoadStatus.COMMITTED: - self._set_title(None) - self._set_loading(status < WebKit.LoadStatus.FINISHED) - self._update_navigation_buttons() + self._set_status(widget.get_load_status()) def __progress_changed_cb(self, widget, param): self._set_progress(widget.get_progress()) + def _set_status(self, status): + self._set_loading(status < WebKit.LoadStatus.FINISHED) + def _set_progress(self, progress): if progress == 1.0: self.entry.set_progress_fraction(0.0) -- cgit v0.9.1