From e9915e3da8f09ca11b4c1eb9c9e4b96a36206f93 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 18 Sep 2012 15:53:58 +0000 Subject: 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 Acked-by: Manuel QuiƱones --- (limited to 'browser.py') diff --git a/browser.py b/browser.py index 0d94649..b315bf6 100644 --- a/browser.py +++ b/browser.py @@ -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): -- cgit v0.9.1