[goffice] compilation: embed svg-patterns.xml too
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] compilation: embed svg-patterns.xml too
- Date: Fri, 2 Dec 2011 18:26:08 +0000 (UTC)
commit f0922a6ee58be05234ff9effc9a92761acad015d
Author: Morten Welinder <terra gnome org>
Date: Fri Dec 2 11:59:40 2011 -0500
compilation: embed svg-patterns.xml too
ChangeLog | 7 +++++++
NEWS | 1 +
goffice/Makefile.am | 7 +++++--
goffice/utils/Makefile.am | 14 ++++----------
goffice/utils/go-pattern.c | 22 +++++++++++-----------
5 files changed, 28 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4b60802..1883089 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-02 Morten Welinder <terra gnome org>
+
+ * goffice/Makefile.am: Embed svg-patterns.xml without compression.
+
+ * goffice/utils/go-pattern.c (go_pattern_get_svg_path): Use
+ embedded resource, not a file.
+
2011-12-02 Jean Brefort <jean brefort normalesup org>
* goffice/canvas/goc-path.c (goc_path_set_property): make it properly
diff --git a/NEWS b/NEWS
index 82ac457..680e2f5 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Andreas:
Morten:
* Embed ui files into library.
+ * Embed svg-patterns.xml too.
--------------------------------------------------------------------------
goffice 0.9.1:
diff --git a/goffice/Makefile.am b/goffice/Makefile.am
index 87e8871..1c3386c 100644
--- a/goffice/Makefile.am
+++ b/goffice/Makefile.am
@@ -107,11 +107,14 @@ embedded_uis = \
gtk/go-rotation-sel.ui \
utils/go-style-prefs.ui
+embedded_raw = utils/svg-patterns.xml
-embedded-ui.c: $(top_srcdir)/tools/embedder $(embedded_uis)
+embedded-ui.c: $(top_srcdir)/tools/embedder $(embedded_uis) $(embedded_raw)
cd $(srcdir) && @PERL@ $(abs_top_srcdir)/tools/embedder \
--id-prefix=go: \
--static \
--register-function=go_register_ui_files \
--register-file-function=go_rsm_register_file \
- COMPRESS $(embedded_uis) >$(abs_builddir)/$@
+ COMPRESS $(embedded_uis) \
+ NOCOMPRESS $(embedded_raw) \
+ >$(abs_builddir)/$@
diff --git a/goffice/utils/Makefile.am b/goffice/utils/Makefile.am
index 4b3f556..632fc48 100644
--- a/goffice/utils/Makefile.am
+++ b/goffice/utils/Makefile.am
@@ -1,6 +1,5 @@
-EXTRA_DIST =
-patternsdir = $(goffice_datadir)/patterns
-dist_patterns_DATA = svg-patterns.xml
+# listed here for distribution and one level up for embedding
+EXTRA_DIST = svg-patterns.xml go-style-prefs.ui
noinst_LTLIBRARIES = libgoffice-utils.la
libgoffice_utils_la_SOURCES = \
@@ -16,7 +15,7 @@ libgoffice_utils_la_SOURCES = \
go-pixbuf.c \
go-svg.c \
go-emf.c \
- go-spectre.c \
+ go-spectre.c \
go-line.c \
go-locale.c \
go-marker.c \
@@ -52,7 +51,7 @@ libgoffice_utils_la_HEADERS = \
go-pixbuf.h \
go-svg.h \
go-emf.h \
- go-spectre.h \
+ go-spectre.h \
go-line.h \
go-locale.h \
go-marker.h \
@@ -75,11 +74,6 @@ libgoffice_utils_la_HEADERS = \
go-style.h \
go-styled-object.h
-# ui files should be listed here for distribution and one level up for
-# embedding
-EXTRA_DIST += \
- go-style-prefs.ui
-
CLEANFILES = \
go-marshalers.h \
go-marshalers.c
diff --git a/goffice/utils/go-pattern.c b/goffice/utils/go-pattern.c
index 7bfc39a..df2eb7f 100644
--- a/goffice/utils/go-pattern.c
+++ b/goffice/utils/go-pattern.c
@@ -30,6 +30,7 @@
#include <string.h>
#define CC2XML(s) ((const xmlChar *)(s))
+#define CXML2C(s) ((const char *)(s))
typedef struct {
char const *name;
@@ -153,32 +154,31 @@ go_pattern_get_pattern (GOPattern const *pat)
xmlChar *
go_pattern_get_svg_path (GOPattern const *pattern, double *width, double *height)
{
- char *path;
- char *d = NULL;
- xmlChar *name, *svg_path = NULL;
+ xmlChar *svg_path = NULL;
xmlDocPtr doc;
xmlNodePtr ptr;
+ const char *data;
+ size_t length;
+ g_return_val_if_fail (pattern != NULL, NULL);
g_return_val_if_fail (pattern->pattern < GO_PATTERN_MAX, NULL);
- path = g_build_filename (go_sys_data_dir(), "patterns", "svg-patterns.xml", NULL);
- doc = go_xml_parse_file (path);
- g_free (path);
-
+ data = go_rsm_lookup ("go:utils/svg-patterns.xml", &length);
+ doc = data ? xmlParseMemory (data, length) : NULL;
g_return_val_if_fail (doc != NULL, NULL);
for (ptr = doc->xmlRootNode->xmlChildrenNode;
- ptr != NULL && d == NULL ;
+ ptr != NULL;
ptr = ptr->next)
{
if (!xmlIsBlankNode (ptr) &&
ptr->name &&
- !strcmp ((char *)ptr->name, "pattern"))
+ !strcmp (CXML2C(ptr->name), "pattern"))
{
double value;
- name = xmlGetProp (ptr, CC2XML ("name"));
+ xmlChar *name = xmlGetProp (ptr, CC2XML ("name"));
if (name != NULL) {
- if (strcmp ((char *)name, go_patterns [pattern->pattern].str) == 0) {
+ if (strcmp (CXML2C(name), go_patterns [pattern->pattern].str) == 0) {
if (width != NULL &&
go_xml_node_get_double (ptr, "width", &value))
*width = value;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]