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): |
190 | 190 | else: |
191 | 191 | self._append_tab(browser) |
192 | 192 | self.emit('focus-url-entry') |
193 | | browser.load_uri('about:blank') |
194 | 193 | return browser |
195 | 194 | |
196 | 195 | def _insert_tab_next(self, browser): |
… |
… |
class TabLabel(Gtk.HBox): |
354 | 353 | GObject.GObject.__init__(self) |
355 | 354 | |
356 | 355 | browser.connect('notify::title', self.__title_changed_cb) |
| 356 | browser.connect('notify::load-status', self.__load_status_changed_cb) |
357 | 357 | |
358 | 358 | self._label = Gtk.Label(label=_('Untitled')) |
359 | 359 | self._label.set_ellipsize(Pango.EllipsizeMode.END) |
… |
… |
class TabLabel(Gtk.HBox): |
392 | 392 | if widget.props.title: |
393 | 393 | self._label.set_text(widget.props.title) |
394 | 394 | |
| 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 | |
395 | 404 | |
396 | 405 | class Browser(WebKit.WebView): |
397 | 406 | __gtype_name__ = 'Browser' |
diff --git a/webtoolbar.py b/webtoolbar.py
index d0f2dc9..cc53f2d 100644
a
|
b
|
class PrimaryToolbar(ToolbarBase): |
350 | 350 | self._update_navigation_buttons() |
351 | 351 | |
352 | 352 | 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...')) |
353 | 360 | self._set_status(widget.get_load_status()) |
354 | 361 | |
355 | 362 | def __progress_changed_cb(self, widget, param): |