[Sugar-devel] [PATCH][Browse] Update progress bar and stop/reload buttons when switching tabs
Manuel Quiñones
manuq at laptop.org
Fri Mar 23 01:02:46 EDT 2012
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.
The title is set to an empty string instead of None, this was giving
the following Gtk error:
Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed
Signed-off-by: Manuel Quiñones <manuq at laptop.org>
---
pdfviewer.py | 1 -
webtoolbar.py | 20 +++++++++++---------
2 files changed, 11 insertions(+), 10 deletions(-)
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..d74ec7c 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,16 @@ 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):
+ if status <= WebKit.LoadStatus.COMMITTED:
+ self._set_title("")
+ self._set_loading(status < WebKit.LoadStatus.FINISHED)
+
def _set_progress(self, progress):
if progress == 1.0:
self.entry.set_progress_fraction(0.0)
--
1.7.7.6
More information about the Sugar-devel
mailing list