diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2012-09-18 15:53:58 (GMT) |
---|---|---|
committer | Manuel QuiƱones <manuq@laptop.org> | 2012-09-27 23:28:01 (GMT) |
commit | e9915e3da8f09ca11b4c1eb9c9e4b96a36206f93 (patch) | |
tree | f4fa25688f67b3763ad3c12b47aa3628f86a00b5 /browser.py | |
parent | a07d27a0356f312602c15bbb55cfad553a614118 (diff) |
Error page SL #3500
Added an "Error page" with Sugar style that informs the users about
the the page could not be loaded for any reason.
This patch contains a HTML template (error_page.tmpl) that is used to
generate the error page with the correct language.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Acked-by: Manuel QuiƱones <manuq@laptop.org>
Diffstat (limited to 'browser.py')
-rw-r--r-- | browser.py | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -58,6 +58,9 @@ _NON_SEARCH_REGEX = re.compile(''' ^file:.*$) ''', re.VERBOSE) +DEFAULT_ERROR_PAGE = os.path.join(activity.get_bundle_path(), + 'data/error_page.tmpl') + class CommandListener(object): def __init__(self, window): @@ -483,6 +486,7 @@ class Browser(WebKit.WebView): self.__mime_type_policy_cb) self.connect('new-window-policy-decision-requested', self.__new_window_policy_cb) + self.connect('load-error', self.__load_error_cb) try: self.connect('run-file-chooser', self.__run_file_chooser) @@ -624,6 +628,24 @@ class Browser(WebKit.WebView): downloadmanager.add_download(download, browser) return True + def __load_error_cb(self, web_view, web_frame, uri, web_error): + """Show Sugar's error page""" + + data = { + 'page_title': _('This web page could not be loaded'), + 'title': _('This web page could not be loaded'), + 'message': _('"%s" could not be loaded. Please check for ' + 'typing errors, and make sure you are connected ' + 'to the internet.') % uri, + 'btn_value': _('Try again'), + 'url': uri, + } + + html = open(DEFAULT_ERROR_PAGE, 'r').read() % data + web_frame.load_alternate_string(html, '', uri) + + return True + class PopupDialog(Gtk.Window): def __init__(self): |