Ticket #3550: 0001-Display-Loading.-message-in-the-tab-title-while-the-.patch

File 0001-Display-Loading.-message-in-the-tab-title-while-the-.patch, 2.3 KB (added by humitos, 12 years ago)
  • browser.py

    From 94375b4567b3a28f12fe6c349e2d014b6a9199b4 Mon Sep 17 00:00:00 2001
    Message-Id: <94375b4567b3a28f12fe6c349e2d014b6a9199b4.1336058091.git.humitos@gmail.com>
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Thu, 3 May 2012 12:13:11 -0300
    Subject: [PATCH Browse] Display 'Loading...' message in the tab title 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 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 |   12 +++++++++++-
     1 files changed, 11 insertions(+), 1 deletions(-)
    
    diff --git a/browser.py b/browser.py
    index c0bb7bc..3cb8f38 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 widget.get_uri() == 'about:blank':
     398            self._label.set_text(_('Untitled'))
     399            return None
     400
     401        if WebKit.LoadStatus.PROVISIONAL <= status \
     402                < WebKit.LoadStatus.FINISHED:
     403            self._label.set_text(_('Loading...'))
     404
    395405
    396406class Browser(WebKit.WebView):
    397407    __gtype_name__ = 'Browser'