Ticket #3550: 0001-Display-Loading.-message-in-the-tab-and-url-titles-w.patch

File 0001-Display-Loading.-message-in-the-tab-and-url-titles-w.patch, 3.1 KB (added by humitos, 12 years ago)
  • browser.py

    From 82cc05be9f345665a963ec24262ebc95c261bfa8 Mon Sep 17 00:00:00 2001
    Message-Id: <82cc05be9f345665a963ec24262ebc95c261bfa8.1336134441.git.humitos@gmail.com>
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Fri, 4 May 2012 09:27:07 -0300
    Subject: [PATCH Browse v2] Display 'Loading...' message in the tab and url
     titles while the page is loading #3550
    
    First of all, we don't need to open "about:blank" when we create a new
    tab, this was making the history to save that "page" and allowing to
    go back to it.
    
    That is related with this PATCH because we are checking the browser
    "load-status" property to know what title put in the tab and url
    label. Now, we check for the "load-status" property and set the title
    according to the load progress: if WebKit is loading the page we put
    "Loading..."  or the page's title otherwise with the exception of
    "about:blank" page that has no title, so we put "Untitled".
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     browser.py    |   11 ++++++++++-
     webtoolbar.py |    7 +++++++
     2 files changed, 17 insertions(+), 1 deletions(-)
    
    diff --git a/browser.py b/browser.py
    index c0bb7bc..6b744a3 100644
    a b class TabbedView(BrowserNotebook): 
    190190        else:
    191191            self._append_tab(browser)
    192192        self.emit('focus-url-entry')
    193         browser.load_uri('about:blank')
    194193        return browser
    195194
    196195    def _insert_tab_next(self, browser):
    class TabLabel(Gtk.HBox): 
    354353        GObject.GObject.__init__(self)
    355354
    356355        browser.connect('notify::title', self.__title_changed_cb)
     356        browser.connect('notify::load-status', self.__load_status_changed_cb)
    357357
    358358        self._label = Gtk.Label(label=_('Untitled'))
    359359        self._label.set_ellipsize(Pango.EllipsizeMode.END)
    class TabLabel(Gtk.HBox): 
    392392        if widget.props.title:
    393393            self._label.set_text(widget.props.title)
    394394
     395    def __load_status_changed_cb(self, widget, param):
     396        status = widget.get_load_status()
     397        if WebKit.LoadStatus.PROVISIONAL <= status \
     398                < WebKit.LoadStatus.FINISHED:
     399            self._label.set_text(_('Loading...'))
     400        elif status == WebKit.LoadStatus.FINISHED:
     401            if widget.props.title == None:
     402                self._label.set_text(_('Untitled'))
     403
    395404
    396405class Browser(WebKit.WebView):
    397406    __gtype_name__ = 'Browser'
  • webtoolbar.py

    diff --git a/webtoolbar.py b/webtoolbar.py
    index d0f2dc9..cc53f2d 100644
    a b class PrimaryToolbar(ToolbarBase): 
    350350        self._update_navigation_buttons()
    351351
    352352    def __loading_changed_cb(self, widget, param):
     353        status = widget.get_load_status()
     354        if WebKit.LoadStatus.PROVISIONAL <= status \
     355                < WebKit.LoadStatus.FINISHED:
     356            self.entry._set_title(_('Loading...'))
     357        elif status == WebKit.LoadStatus.FINISHED:
     358            if widget.props.title == None:
     359                self.entry._set_title(_('Loading...'))
    353360        self._set_status(widget.get_load_status())
    354361
    355362    def __progress_changed_cb(self, widget, param):