[epiphany] Move error.css to the GResource
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Move error.css to the GResource
- Date: Mon, 17 Oct 2016 19:54:46 +0000 (UTC)
commit 28314cdca80d8823fab025daf446132e5d10a3d8
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Oct 17 14:10:36 2016 -0500
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.
configure.ac | 1 -
data/Makefile.am | 2 +-
data/pages/Makefile.am | 5 -----
embed/ephy-web-view.c | 20 +++++++++++---------
src/epiphany.gresource.xml | 1 +
{data/pages => src/resources}/error.css | 0
src/resources/error.html | 3 ++-
7 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 53736d0..fd3acfe 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 ffe7576..cf99150 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/embed/ephy-web-view.c b/embed/ephy-web-view.c
index d552e04..93279fa 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 5ce4f1a..c5861d6 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
similarity index 100%
rename from data/pages/error.css
rename to src/resources/error.css
diff --git a/src/resources/error.html b/src/resources/error.html
index 7dfc0a8..f0ed9fb 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]