[Sugar-devel] [PATCH Browse] Unset "loading..." message when the loading fails SL #3620

Manuel Quiñones manuq at laptop.org
Tue May 22 11:28:37 EDT 2012


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 at 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/browser.py
+++ b/browser.py
@@ -361,7 +361,8 @@ class TabLabel(Gtk.HBox):
         browser.connect('notify::title', self.__title_changed_cb)
         browser.connect('notify::load-status', self.__load_status_changed_cb)
 
-        self._label = Gtk.Label(label=_('Untitled'))
+        self._title = _('Untitled')
+        self._label = Gtk.Label(label=self._title)
         self._label.set_ellipsize(Pango.EllipsizeMode.END)
         self._label.set_alignment(0, 0.5)
         self.pack_start(self._label, True, True, 0)
@@ -397,15 +398,19 @@ class TabLabel(Gtk.HBox):
     def __title_changed_cb(self, widget, param):
         if widget.props.title:
             self._label.set_text(widget.props.title)
+            self._title = widget.props.title
 
     def __load_status_changed_cb(self, widget, param):
         status = widget.get_load_status()
-        if WebKit.LoadStatus.PROVISIONAL <= status \
+        if status == WebKit.LoadStatus.FAILED:
+            self._label.set_text(self._title)
+        elif WebKit.LoadStatus.PROVISIONAL <= status \
                 < WebKit.LoadStatus.FINISHED:
             self._label.set_text(_('Loading...'))
         elif status == WebKit.LoadStatus.FINISHED:
             if widget.props.title == None:
                 self._label.set_text(_('Untitled'))
+                self._title = _('Untitled')
 
 
 class Browser(WebKit.WebView):
diff --git a/webtoolbar.py b/webtoolbar.py
index 6241eb1..99c5fd6 100644
--- a/webtoolbar.py
+++ b/webtoolbar.py
@@ -241,6 +241,7 @@ class PrimaryToolbar(ToolbarBase):
         self._tabbed_view = tabbed_view
 
         self._loading = False
+        self._title = _('Untitled')
 
         toolbar = self.toolbar
         activity_button = ActivityToolbarButton(self._activity)
@@ -353,12 +354,15 @@ class PrimaryToolbar(ToolbarBase):
 
     def __loading_changed_cb(self, widget, param):
         status = widget.get_load_status()
-        if WebKit.LoadStatus.PROVISIONAL <= status \
+        if status == WebKit.LoadStatus.FAILED:
+            self.entry._set_title(self._title)
+        elif WebKit.LoadStatus.PROVISIONAL <= status \
                 < WebKit.LoadStatus.FINISHED:
             self.entry._set_title(_('Loading...'))
         elif status == WebKit.LoadStatus.FINISHED:
             if widget.props.title == None:
                 self.entry._set_title(_('Untitled'))
+                self._title = _('Untitled')
         self._set_status(widget.get_load_status())
 
     def __progress_changed_cb(self, widget, param):
@@ -381,6 +385,7 @@ class PrimaryToolbar(ToolbarBase):
 
     def _set_title(self, title):
         self.entry.props.title = title
+        self._title = title
 
     def _show_stop_icon(self):
         self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,
-- 
1.7.10.1



More information about the Sugar-devel mailing list