Ticket #3620: 0001-Unset-loading.-message-when-the-loading-fails-SL-362.patch

File 0001-Unset-loading.-message-when-the-loading-fails-SL-362.patch, 3.7 KB (added by manuq, 12 years ago)
  • browser.py

    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): 
    361361        browser.connect('notify::title', self.__title_changed_cb)
    362362        browser.connect('notify::load-status', self.__load_status_changed_cb)
    363363
    364         self._label = Gtk.Label(label=_('Untitled'))
     364        self._title = _('Untitled')
     365        self._label = Gtk.Label(label=self._title)
    365366        self._label.set_ellipsize(Pango.EllipsizeMode.END)
    366367        self._label.set_alignment(0, 0.5)
    367368        self.pack_start(self._label, True, True, 0)
    class TabLabel(Gtk.HBox): 
    397398    def __title_changed_cb(self, widget, param):
    398399        if widget.props.title:
    399400            self._label.set_text(widget.props.title)
     401            self._title = widget.props.title
    400402
    401403    def __load_status_changed_cb(self, widget, param):
    402404        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 \
    404408                < WebKit.LoadStatus.FINISHED:
    405409            self._label.set_text(_('Loading...'))
    406410        elif status == WebKit.LoadStatus.FINISHED:
    407411            if widget.props.title == None:
    408412                self._label.set_text(_('Untitled'))
     413                self._title = _('Untitled')
    409414
    410415
    411416class Browser(WebKit.WebView):
  • webtoolbar.py

    diff --git a/webtoolbar.py b/webtoolbar.py
    index 6241eb1..99c5fd6 100644
    a b class PrimaryToolbar(ToolbarBase): 
    241241        self._tabbed_view = tabbed_view
    242242
    243243        self._loading = False
     244        self._title = _('Untitled')
    244245
    245246        toolbar = self.toolbar
    246247        activity_button = ActivityToolbarButton(self._activity)
    class PrimaryToolbar(ToolbarBase): 
    353354
    354355    def __loading_changed_cb(self, widget, param):
    355356        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 \
    357360                < WebKit.LoadStatus.FINISHED:
    358361            self.entry._set_title(_('Loading...'))
    359362        elif status == WebKit.LoadStatus.FINISHED:
    360363            if widget.props.title == None:
    361364                self.entry._set_title(_('Untitled'))
     365                self._title = _('Untitled')
    362366        self._set_status(widget.get_load_status())
    363367
    364368    def __progress_changed_cb(self, widget, param):
    class PrimaryToolbar(ToolbarBase): 
    381385
    382386    def _set_title(self, title):
    383387        self.entry.props.title = title
     388        self._title = title
    384389
    385390    def _show_stop_icon(self):
    386391        self.entry.set_icon_from_name(iconentry.ICON_ENTRY_SECONDARY,