From a67f2bd32574dc82ae5a32f6dc9e786c29e3c821 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Tue, 22 May 2012 12:20:26 -0300
Subject: [PATCH Browse] Unset "loading..." message when the loading fails SL
#3620
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
Browse has to restore the previous title in the tab and in the URL
entry when the loading finishes with WEBKIT_LOAD_FAILED status.
This fixes bug #3620 in Sugarlabs trac. The WEBKIT_LOAD_FAILED
status is reached in the current webview when the loading is
manually handled in the mime-type-policy-decision-requested callback.
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
browser.py | 9 +++++++--
webtoolbar.py | 7 ++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/browser.py b/browser.py
index 764f913..6895667 100644
a
|
b
|
class TabLabel(Gtk.HBox): |
361 | 361 | browser.connect('notify::title', self.__title_changed_cb) |
362 | 362 | browser.connect('notify::load-status', self.__load_status_changed_cb) |
363 | 363 | |
364 | | self._label = Gtk.Label(label=_('Untitled')) |
| 364 | self._title = _('Untitled') |
| 365 | self._label = Gtk.Label(label=self._title) |
365 | 366 | self._label.set_ellipsize(Pango.EllipsizeMode.END) |
366 | 367 | self._label.set_alignment(0, 0.5) |
367 | 368 | self.pack_start(self._label, True, True, 0) |
… |
… |
class TabLabel(Gtk.HBox): |
397 | 398 | def __title_changed_cb(self, widget, param): |
398 | 399 | if widget.props.title: |
399 | 400 | self._label.set_text(widget.props.title) |
| 401 | self._title = widget.props.title |
400 | 402 | |
401 | 403 | def __load_status_changed_cb(self, widget, param): |
402 | 404 | status = widget.get_load_status() |
403 | | if WebKit.LoadStatus.PROVISIONAL <= status \ |
| 405 | if status == WebKit.LoadStatus.FAILED: |
| 406 | self._label.set_text(self._title) |
| 407 | elif WebKit.LoadStatus.PROVISIONAL <= status \ |
404 | 408 | < WebKit.LoadStatus.FINISHED: |
405 | 409 | self._label.set_text(_('Loading...')) |
406 | 410 | elif status == WebKit.LoadStatus.FINISHED: |
407 | 411 | if widget.props.title == None: |
408 | 412 | self._label.set_text(_('Untitled')) |
| 413 | self._title = _('Untitled') |
409 | 414 | |
410 | 415 | |
411 | 416 | class Browser(WebKit.WebView): |
diff --git a/webtoolbar.py b/webtoolbar.py
index 6241eb1..99c5fd6 100644
a
|
b
|
class PrimaryToolbar(ToolbarBase): |
241 | 241 | self._tabbed_view = tabbed_view |
242 | 242 | |
243 | 243 | self._loading = False |
| 244 | self._title = _('Untitled') |
244 | 245 | |
245 | 246 | toolbar = self.toolbar |
246 | 247 | activity_button = ActivityToolbarButton(self._activity) |
… |
… |
class PrimaryToolbar(ToolbarBase): |
353 | 354 | |
354 | 355 | def __loading_changed_cb(self, widget, param): |
355 | 356 | status = widget.get_load_status() |
356 | | if WebKit.LoadStatus.PROVISIONAL <= status \ |
| 357 | if status == WebKit.LoadStatus.FAILED: |
| 358 | self.entry._set_title(self._title) |
| 359 | elif WebKit.LoadStatus.PROVISIONAL <= status \ |
357 | 360 | < WebKit.LoadStatus.FINISHED: |
358 | 361 | self.entry._set_title(_('Loading...')) |
359 | 362 | elif status == WebKit.LoadStatus.FINISHED: |
360 | 363 | if widget.props.title == None: |
361 | 364 | self.entry._set_title(_('Untitled')) |
| 365 | self._title = _('Untitled') |
362 | 366 | self._set_status(widget.get_load_status()) |
363 | 367 | |
364 | 368 | def __progress_changed_cb(self, widget, param): |
… |
… |
class PrimaryToolbar(ToolbarBase): |
381 | 385 | |
382 | 386 | def _set_title(self, title): |
383 | 387 | self.entry.props.title = title |
| 388 | self._title = title |
384 | 389 | |
385 | 390 | def _show_stop_icon(self): |
386 | 391 | self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY, |