summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2016-10-17 14:10:36 -0500
committerMichael Catanzaro <mcatanzaro@gnome.org>2016-10-17 14:15:24 -0500
commit28314cdca80d8823fab025daf446132e5d10a3d8 (patch)
treec85b5ff2ca8e3666a1b923f4065da628cc8c39a6
parentee29f6dd3b588d3b16dfacd850b5a4dbee4a6168 (diff)
downloadepiphany-28314cdca80d8823fab025daf446132e5d10a3d8.tar.gz
Move error.css to the GResource
I can't figure out how to reference it directly from error.html using an ephy-resource:// URI, which is frustrating because we shouldn't need get_style_sheet() at all, but this is at least an improvement.
-rw-r--r--configure.ac1
-rw-r--r--data/Makefile.am2
-rw-r--r--data/pages/Makefile.am5
-rw-r--r--embed/ephy-web-view.c20
-rw-r--r--src/epiphany.gresource.xml1
-rw-r--r--src/resources/error.css (renamed from data/pages/error.css)0
-rw-r--r--src/resources/error.html3
7 files changed, 15 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index 53736d075..fd3acfe13 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,7 +190,6 @@ AC_CONFIG_FILES([
Makefile
data/Makefile
data/icons/Makefile
-data/pages/Makefile
gvdb/Makefile
help/Makefile
libgd/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index ffe757628..cf99150ea 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = icons pages
+SUBDIRS = icons
desktop_in_files = org.gnome.Epiphany.desktop.in
desktopdir = $(datadir)/applications
diff --git a/data/pages/Makefile.am b/data/pages/Makefile.am
deleted file mode 100644
index 7cb72f8f9..000000000
--- a/data/pages/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-stylepagesdir = $(pkgdatadir)/pages
-dist_stylepages_DATA = \
- error.css
-
--include $(top_srcdir)/git.mk
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index d552e0498..93279faa5 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -65,6 +65,7 @@
#define MAX_HIDDEN_POPUPS 5
#define EPHY_PAGE_TEMPLATE_ERROR "/org/gnome/epiphany/page-templates/error.html"
+#define EPHY_PAGE_TEMPLATE_ERROR_CSS "/org/gnome/epiphany/page-templates/error.css"
struct _EphyWebView {
WebKitWebView parent_instance;
@@ -1670,15 +1671,12 @@ ephy_web_view_set_placeholder (EphyWebView *view,
static char *
get_style_sheet (void)
{
- const gchar *file;
- GError *error = NULL;
- char *sheet = NULL;
+ GBytes *bytes;
+ const char *sheet;
- file = ephy_file ("error.css");
- if (file && !g_file_get_contents (file, &sheet, NULL, &error)) {
- g_debug ("Unable to load error style sheet: %s", error->message);
- g_error_free (error);
- }
+ bytes = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_ERROR_CSS, 0, NULL);
+ sheet = g_strdup (g_bytes_get_data (bytes, NULL));
+ g_bytes_unref (bytes);
return sheet;
}
@@ -1990,6 +1988,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
char *hidden_button_label = NULL;
char *button_action = NULL;
char *hidden_button_action = NULL;
+ char *style_sheet = NULL;
const char *button_accesskey = NULL;
const char *hidden_button_accesskey = NULL;
const char *icon_name = NULL;
@@ -2071,6 +2070,8 @@ ephy_web_view_load_error_page (EphyWebView *view,
_ephy_web_view_update_icon (view);
+ style_sheet = get_style_sheet ();
+
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
/* The HTML file is trusted input. */
@@ -2079,7 +2080,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
lang, lang,
((gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "rtl" : "ltr"),
page_title,
- get_style_sheet (),
+ style_sheet,
button_action, hidden_button_action,
icon_name,
page == EPHY_WEB_VIEW_ERROR_INVALID_TLS_CERTIFICATE ? "danger" : "default",
@@ -2103,6 +2104,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
g_free (button_action);
g_free (hidden_button_label);
g_free (hidden_button_action);
+ g_free (style_sheet);
/* Make our history backend ignore the next page load, since it will be an error page. */
ephy_web_view_freeze_history (view);
diff --git a/src/epiphany.gresource.xml b/src/epiphany.gresource.xml
index 5ce4f1ac8..c5861d6b5 100644
--- a/src/epiphany.gresource.xml
+++ b/src/epiphany.gresource.xml
@@ -10,6 +10,7 @@
<file compressed="true">prism.css</file>
<file compressed="true">prism.js</file>
<file alias="page-templates/about.css" compressed="true">about.css</file>
+ <file alias="page-templates/error.css" compressed="true">error.css</file>
<file alias="page-templates/error.html" compressed="true">error.html</file>
<file preprocess="xml-stripblanks" compressed="true">clear-data-dialog.ui</file>
<file preprocess="xml-stripblanks" compressed="true">cookies-dialog.ui</file>
diff --git a/data/pages/error.css b/src/resources/error.css
index ffc508f87..ffc508f87 100644
--- a/data/pages/error.css
+++ b/src/resources/error.css
diff --git a/src/resources/error.html b/src/resources/error.html
index 7dfc0a88d..f0ed9fb7f 100644
--- a/src/resources/error.html
+++ b/src/resources/error.html
@@ -18,11 +18,12 @@
You should have received a copy of the GNU General Public License
along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
-->
+<!-- Keep in mind that this file is a format template. Each raw % has to be %%. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="%s" lang="%s" dir="%s">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>%s</title>
- <style type="text/css">%s</style>
+ <style>%s</style>
<script type="text/javascript">
function buttonAction() {
%s