From d90af9aab2a740352b453862b94d8ed5225d6634 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Fri, 23 Mar 2012 09:03:17 -0300
Subject: [PATCH Browse 2/3] Update progress bar and stop/reload buttons when
switching tabs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
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 <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
---
pdfviewer.py | 1 -
webtoolbar.py | 18 +++++++++---------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/pdfviewer.py b/pdfviewer.py
index c7e2452..ef6a6ea 100644
a
|
b
|
class PDFTabPage(Gtk.HBox): |
366 | 366 | |
367 | 367 | def __download_progress_cb(self, download, data): |
368 | 368 | progress = download.get_progress() |
369 | | self._browser.props.load_status = WebKit.LoadStatus.PROVISIONAL |
370 | 369 | self._browser.props.progress = progress |
371 | 370 | |
372 | 371 | def __download_status_cb(self, download, data): |
diff --git a/webtoolbar.py b/webtoolbar.py
index 7525053..654f720 100644
a
|
b
|
class PrimaryToolbar(ToolbarBase): |
324 | 324 | self._browser.disconnect(self._title_changed_hid) |
325 | 325 | self._browser.disconnect(self._uri_changed_hid) |
326 | 326 | self._browser.disconnect(self._progress_changed_hid) |
| 327 | self._browser.disconnect(self._loading_changed_hid) |
327 | 328 | |
328 | 329 | self._browser = browser |
329 | 330 | if self._browser.props.title: |
… |
… |
class PrimaryToolbar(ToolbarBase): |
331 | 332 | else: |
332 | 333 | self._set_title(_('Untitled')) |
333 | 334 | self._set_address(self._browser.props.uri) |
| 335 | self._set_progress(self._browser.props.progress) |
| 336 | self._set_status(self._browser.props.load_status) |
334 | 337 | |
335 | | if isinstance(self._browser, Browser): |
336 | | self.entry.props.editable = True |
337 | | else: |
338 | | self.entry.props.editable = False |
| 338 | is_webkit_browser = isinstance(self._browser, Browser) |
| 339 | self.entry.props.editable = is_webkit_browser |
339 | 340 | |
340 | 341 | self._title_changed_hid = self._browser.connect( |
341 | 342 | 'notify::title', self._title_changed_cb) |
… |
… |
class PrimaryToolbar(ToolbarBase): |
349 | 350 | self._update_navigation_buttons() |
350 | 351 | |
351 | 352 | def __loading_changed_cb(self, widget, param): |
352 | | status = widget.get_load_status() |
353 | | if status <= WebKit.LoadStatus.COMMITTED: |
354 | | self._set_title(None) |
355 | | self._set_loading(status < WebKit.LoadStatus.FINISHED) |
356 | | self._update_navigation_buttons() |
| 353 | self._set_status(widget.get_load_status()) |
357 | 354 | |
358 | 355 | def __progress_changed_cb(self, widget, param): |
359 | 356 | self._set_progress(widget.get_progress()) |
360 | 357 | |
| 358 | def _set_status(self, status): |
| 359 | self._set_loading(status < WebKit.LoadStatus.FINISHED) |
| 360 | |
361 | 361 | def _set_progress(self, progress): |
362 | 362 | if progress == 1.0: |
363 | 363 | self.entry.set_progress_fraction(0.0) |