Commit fc6a518c authored by Sebastian Ramacher's avatar Sebastian Ramacher

Use glib-compile-resource instead of sed magic

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent e8916021
......@@ -8,7 +8,7 @@ tests/girara_test-gtk*
.depend
*.pc
version.h
css-definitions.c
css-definitions.*
*.info
*.gcno
*.gcda
......
......@@ -88,17 +88,12 @@ ${PROJECTNV}/version.h: ${PROJECTNV}/version.h.in config.mk
${PROJECTNV}/version.h.in > ${PROJECTNV}/version.h.tmp
$(QUIET)mv ${PROJECTNV}/version.h.tmp ${PROJECTNV}/version.h
${PROJECTNV}/css-definitions.c: data/girara-pre-3.20.css_t data/girara-post-3.20.css_t
${PROJECTNV}/css-definitions.%: data/girara-css.gresource.xml config.mk
$(call colorecho,GEN,$@)
$(QUIET)echo '#include "css-definitions.h"' > $@.tmp
$(QUIET)echo 'const char* CSS_TEMPLATE_PRE_3_20 =' >> $@.tmp
$(QUIET)sed 's/^\(.*\)$$/"\1\\n"/' data/girara-pre-3.20.css_t >> $@.tmp
$(QUIET)echo ';' >> $@.tmp
$(QUIET)echo 'const char* CSS_TEMPLATE_POST_3_20 =' >> $@.tmp
$(QUIET)sed 's/^\(.*\)$$/"\1\\n"/' data/girara-post-3.20.css_t >> $@.tmp
$(QUIET)echo ';' >> $@.tmp
$(QUIET)mv $@.tmp $@
@mkdir -p ${DEPENDDIR}/$(dir $@)
$(QUIET)$(GLIB_COMPILE_RESOURCES) --generate --c-name=girara_css --internal \
--dependency-file=$(DEPENDDIR)/$@.dep \
--sourcedir=data --target=$@ data/girara-css.gresource.xml
${BUILDDIR}/${PROJECT}.pc: ${PROJECTNV}.pc.in config.mk
$(call colorecho,GEN,$(shell basename $@))
......@@ -116,6 +111,7 @@ ${BUILDDIR}/${PROJECT}.pc: ${PROJECTNV}.pc.in config.mk
${OBJECTS}: config.mk \
${PROJECTNV}/version.h \
${PROJECTNV}/css-definitions.h \
.version-checks/GTK \
.version-checks/GLIB
......@@ -147,6 +143,7 @@ release: ${PROJECT}
${OBJECT_DEBUG}: config.mk \
${PROJECTNV}/version.h \
${PROJECTNV}/css-definitions.h \
.version-checks/GTK \
.version-checks/GLIB
......@@ -176,6 +173,7 @@ debug: ${PROJECT}-debug
${OBJECTS_GCOV}: config.mk \
${PROJECTNV}/version.h \
${PROJECTNV}/css-definitions.h \
.version-checks/GLIB \
.version-checks/GTK
......@@ -222,7 +220,7 @@ clean:
${PROJECTNV}/version.h \
${PROJECTNV}/version.h.tmp \
${PROJECTNV}/css-definitions.c \
${PROJECTNV}/css-definitions.c.tmp
${PROJECTNV}/css-definitions.h \
$(QUIET)$(MAKE) -C tests clean
$(QUIET)$(MAKE) -C po clean
$(QUIET)$(MAKE) -C doc clean
......
......@@ -19,6 +19,9 @@ SOVERSION = ${SOMAJOR}.${SOMINOR}
# pkg-config binary
PKG_CONFIG ?= pkg-config
# glib-compile-resource binary
GLIB_COMPILE_RESOURCES ?= glib-compile-resources
# libnotify
WITH_LIBNOTIFY ?= $(shell (${PKG_CONFIG} libnotify --atleast-version=0.7.0 && echo 1) || echo 0)
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/pwmt/girara/CSS">
<file compressed="true">girara-post-3.20.css_t</file>
<file compressed="true">girara-pre-3.20.css_t</file>
</gresource>
</gresources>
/* See LICENSE file for license and copyright information */
#ifndef GIRARA_CSS_DEFINITIONS_H
#define GIRARA_CSS_DEFINITIONS_H
#include "macros.h"
extern const char* CSS_TEMPLATE_PRE_3_20 GIRARA_HIDDEN;
extern const char* CSS_TEMPLATE_POST_3_20 GIRARA_HIDDEN;
#endif
......@@ -345,11 +345,18 @@ girara_session_create()
(girara_free_function_t) girara_setting_free);
/* CSS style provider */
GResource* css_resource = girara_css_get_resource();
GBytes* css_data = NULL;
if (gtk_check_version(3, 20, 0) == NULL) {
session->private_data->csstemplate = girara_template_new(CSS_TEMPLATE_POST_3_20);
css_data = g_resource_lookup_data(css_resource, "/org/pwmt/girara/CSS/girara-post-3.20.css_t", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
} else {
session->private_data->csstemplate = girara_template_new(CSS_TEMPLATE_PRE_3_20);
css_data = g_resource_lookup_data(css_resource, "/org/pwmt/girara/CSS/girara-pre-3.20.css_t", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
}
if (css_data != NULL) {
session->private_data->csstemplate = girara_template_new(g_bytes_get_data(css_data, NULL));
g_bytes_unref(css_data);
}
session->private_data->gtk.cssprovider = NULL;
init_template_engine(session->private_data->csstemplate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment