[epiphany] Refactor redundant code of the different error pages
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Refactor redundant code of the different error pages
- Date: Thu, 6 Feb 2014 17:34:23 +0000 (UTC)
commit 936840d5d00885d3741275321fdb461f7f76f103
Author: Lorenzo Tilve <ltilve igalia com>
Date: Tue Feb 4 18:35:22 2014 +0100
Refactor redundant code of the different error pages
Merges the almost identical process-crash.html, recovery.html and
error.html pages into a single one, allowing any specific style
change to the error pages through passing a custom class to the
resultant generic error template.
https://bugzilla.gnome.org/show_bug.cgi?id=705180
embed/ephy-web-view.c | 20 ++++++----------
src/Makefile.am | 2 -
src/epiphany.gresource.xml | 2 -
src/resources/error.html | 2 +-
src/resources/process-crash.html | 44 -------------------------------------
src/resources/recovery.html | 45 --------------------------------------
6 files changed, 9 insertions(+), 106 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 26ac211..9c58bcb 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -65,8 +65,6 @@
#define EMPTY_PAGE _("Blank page") /* Title for the empty page */
#define EPHY_PAGE_TEMPLATE_ERROR "/org/gnome/epiphany/page-templates/error.html"
-#define EPHY_PAGE_TEMPLATE_RECOVERY "/org/gnome/epiphany/page-templates/recovery.html"
-#define EPHY_PAGE_TEMPLATE_PROCESS_CRASH "/org/gnome/epiphany/page-templates/process-crash.html"
struct _EphyWebViewPrivate {
EphyWebViewSecurityLevel security_level;
@@ -1758,6 +1756,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
char *msg;
char *button_label;
char *stylesheet;
+ const char *custom_class;
GBytes *html_file;
if (error)
@@ -1772,6 +1771,8 @@ ephy_web_view_load_error_page (EphyWebView *view,
lang = g_strdup (pango_language_to_string (gtk_get_default_language ()));
g_strdelimit (lang, "_-@", '\0');
+ html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_ERROR, 0, NULL);
+
switch (page) {
case EPHY_WEB_VIEW_ERROR_PAGE_NETWORK_ERROR:
page_title = g_strdup_printf (_("Problem loading “%s”"), hostname);
@@ -1785,10 +1786,8 @@ ephy_web_view_load_error_page (EphyWebView *view,
"address. You may wish to verify that your "
"internet connection is working correctly.</p>"),
uri, reason);
-
- button_label = g_strdup (_("Try Again"));
-
- html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_ERROR, 0, NULL);
+ button_label = g_strdup (_("Try again"));
+ custom_class = "network-error";
break;
case EPHY_WEB_VIEW_ERROR_PAGE_CRASH:
page_title = g_strdup_printf (_("Problem loading “%s”"), hostname);
@@ -1799,19 +1798,15 @@ ephy_web_view_load_error_page (EphyWebView *view,
"please report the problem to the "
"<strong>%s</strong> developers.</p>"),
LSB_DISTRIBUTOR);
-
button_label = g_strdup (_("Reload Anyway"));
-
- html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_RECOVERY, 0, NULL);
+ custom_class = "page-crash";
break;
case EPHY_WEB_VIEW_ERROR_PROCESS_CRASH:
page_title = g_strdup_printf (_("Problem displaying “%s”"), hostname);
msg_title = g_strdup (_("Oops!"));
msg = g_strdup (_("Something went wrong while displaying this page. Please reload or visit a different
page to continue."));
button_label = g_strdup (_("Reload Anyway"));
-
- html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_PROCESS_CRASH, 0, NULL);
-
+ custom_class = "process-crash";
break;
default:
return;
@@ -1831,6 +1826,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
page_title,
stylesheet,
uri,
+ custom_class,
msg_title, msg, button_label);
g_bytes_unref (html_file);
diff --git a/src/Makefile.am b/src/Makefile.am
index 5145d31..fa1d583 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,8 +114,6 @@ RESOURCE_FILES = \
resources/incognito.png \
resources/incognito-tinted.png \
resources/error.html \
- resources/process-crash.html \
- resources/recovery.html \
$(NULL)
epiphany-resources.c: epiphany.gresource.xml $(RESOURCE_FILES)
diff --git a/src/epiphany.gresource.xml b/src/epiphany.gresource.xml
index 29c0d03..263e43d 100644
--- a/src/epiphany.gresource.xml
+++ b/src/epiphany.gresource.xml
@@ -15,7 +15,5 @@
<file preprocess="xml-stripblanks">epiphany-history-window-ui.xml</file>
<file>epiphany.css</file>
<file alias="page-templates/error.html" compressed="true">error.html</file>
- <file alias="page-templates/process-crash.html" compressed="true">process-crash.html</file>
- <file alias="page-templates/recovery.html" compressed="true">recovery.html</file>
</gresource>
</gresources>
diff --git a/src/resources/error.html b/src/resources/error.html
index 62831a8..56411b6 100644
--- a/src/resources/error.html
+++ b/src/resources/error.html
@@ -29,7 +29,7 @@
}
</script>
</head>
-<body>
+<body class="%s">
<div id="container">
<div id="content">
<h1>%s</h1>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]