From 8775d99a5d5eb3751970bfecd45c36180cb114c5 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Thu, 02 Feb 2012 14:52:13 +0000 Subject: Show loading message in the overlay While Browse is loading, the overlay at the bottom-left of the screen -which is currently used to show the URL of a link when the mouse is over it- will show "Loading...", and later will append the requested URI to that message. This message replaces the one showing the link URL until the page load is done. Signed-off-by: Manuel QuiƱones Acked-by: Simon Schampijer --- diff --git a/browser.py b/browser.py index c5165db..8dd8a79 100644 --- a/browser.py +++ b/browser.py @@ -291,6 +291,8 @@ class TabPage(Gtk.Overlay): GObject.GObject.__init__(self) self._browser = browser + self._showing_load_status = False + self._requested_uri = None link_info = Gtk.Label() link_info.set_halign(Gtk.Align.START) @@ -307,6 +309,10 @@ class TabPage(Gtk.Overlay): browser.connect('hovering-over-link', self.__hovering_over_link_cb, link_info) + browser.connect('notify::load-status', self.__load_status_cb, + link_info) + browser.connect('resource-request-starting', + self.__resource_request_starting_cb) def _get_browser(self): return self._browser @@ -315,12 +321,34 @@ class TabPage(Gtk.Overlay): getter=_get_browser) def __hovering_over_link_cb(self, webview, title, uri, link_info): + if self._showing_load_status: + return + if uri is None: link_info.hide() else: link_info.set_text(uri) link_info.show() + def __load_status_cb(self, webview, param, link_info): + status = webview.get_load_status() + if status <= WebKit.LoadStatus.COMMITTED: + if self._requested_uri is None: + link_info.set_text(_("Loading...")) + else: + link_info.set_text(_("Loading %s...") % self._requested_uri) + self._showing_load_status = True + link_info.show() + else: + self._showing_load_status = False + self._requested_uri = None + link_info.hide() + + def __resource_request_starting_cb(self, webview, webframe, webresource, + request, response): + """Set the request uri to be shown in the label overlay.""" + self._requested_uri = request.get_uri() + class TabLabel(Gtk.HBox): __gtype_name__ = 'TabLabel' -- cgit v0.9.1