[goffice] icons: embed icons into plugin.xml
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] icons: embed icons into plugin.xml
- Date: Tue, 6 Dec 2011 19:59:00 +0000 (UTC)
commit 4925c5adb3393dc2b6bb45d0c9309f158c647092
Author: Morten Welinder <terra gnome org>
Date: Tue Dec 6 14:58:39 2011 -0500
icons: embed icons into plugin.xml
plugins/plot_barcol/Makefile.am | 12 ++++-
plugins/plot_xy/Makefile.am | 14 ++++--
tools/Makefile.am | 2 +-
tools/embedder | 16 +++++++
tools/resource-embedder | 92 +++++++++++++++++++++++++++++++++++++++
5 files changed, 128 insertions(+), 8 deletions(-)
---
diff --git a/plugins/plot_barcol/Makefile.am b/plugins/plot_barcol/Makefile.am
index 63e6524..5b98c84 100644
--- a/plugins/plot_barcol/Makefile.am
+++ b/plugins/plot_barcol/Makefile.am
@@ -1,8 +1,5 @@
goffice_graph_barcoldir = $(goffice_plugindir)/plot_barcol
xmldir = $(goffice_graph_barcoldir)
-icondir = $(goffice_graph_barcoldir)
-
-icon_DATA = linegraph.xpm area.xpm bar.xpm column.xpm dropbar.xpm minmax.xpm
goffice_graph_barcol_LTLIBRARIES = barcol.la
barcol_la_LDFLAGS = -module $(GOFFICE_PLUGIN_FLAGS)
@@ -28,6 +25,15 @@ if WITH_GTK
barcol_la_SOURCES += gog-barcol-prefs.c
endif
+plugin_resources = linegraph.xpm area.xpm bar.xpm column.xpm dropbar.xpm minmax.xpm
+pofiles = $(wildcard $(top_srcdir)/po/*.po)
+
+plugin.xml: plugin.xml.in $(plugin_resources) $(pofiles) $(top_srcdir)/tools/embedder
+ LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $ tmp
+ cd $(srcdir) && @PERL@ $(abs_top_srcdir)/tools/resource-embedder \
+ $ tmp $@
+ rm -f $ tmp
+
# Do not use the intl-tool stuff to merge the text back;
# it's simpler to just use gettext directly
plot-types.xml : plot-types.xml.in
diff --git a/plugins/plot_xy/Makefile.am b/plugins/plot_xy/Makefile.am
index e427edc..eae1f46 100644
--- a/plugins/plot_xy/Makefile.am
+++ b/plugins/plot_xy/Makefile.am
@@ -1,8 +1,5 @@
goffice_graph_xydir = $(goffice_plugindir)/plot_xy
xmldir = $(goffice_graph_xydir)
-icondir = $(goffice_graph_xydir)
-
-icon_DATA = bubble.xpm color.xpm dropbar.xpm scatter.xpm
goffice_graph_xy_LTLIBRARIES = xy.la
xy_la_LDFLAGS = -module $(GOFFICE_PLUGIN_FLAGS)
@@ -23,6 +20,15 @@ if WITH_GTK
xy_la_SOURCES += gog-bubble-prefs.c
endif
+plugin_resources = bubble.xpm color.xpm dropbar.xpm scatter.xpm
+pofiles = $(wildcard $(top_srcdir)/po/*.po)
+
+plugin.xml: plugin.xml.in $(plugin_resources) $(pofiles) $(top_srcdir)/tools/embedder
+ LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $ tmp
+ cd $(srcdir) && @PERL@ $(abs_top_srcdir)/tools/resource-embedder \
+ $ tmp $@
+ rm -f $ tmp
+
# Do not use the intl-tool stuff to merge the text back;
# it's simpler to just use gettext directly
plot-types.xml : plot-types.xml.in
@@ -67,7 +73,7 @@ embedded-stuff.c: $(top_srcdir)/tools/embedder $(embedded_stuff)
BUILT_SOURCES = embedded-stuff.c
CLEANFILES = $(BUILT_SOURCES)
-EXTRA_DIST = $(xml_in_files) $(embedded_stuff)
+EXTRA_DIST = $(xml_in_files) $(embedded_stuff) $(plugin_resources)
DISTCLEANFILES = $(xml_in_files:.xml.in=.xml)
include $(top_srcdir)/goffice-plugins.mk
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 83c6877..d139a16 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST = dumpdef.pl embedder
+EXTRA_DIST = dumpdef.pl embedder resource-embedder
diff --git a/tools/embedder b/tools/embedder
old mode 100644
new mode 100755
index 905ff2d..d8339b4
--- a/tools/embedder
+++ b/tools/embedder
@@ -1,5 +1,21 @@
#!/usr/bin/perl
+# Copyright (C) 2011 Morten Welinder <terra gnome org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+
use strict;
use Getopt::Long;
use IO::Compress::Gzip qw(gzip $GzipError);
diff --git a/tools/resource-embedder b/tools/resource-embedder
new file mode 100755
index 0000000..1415655
--- /dev/null
+++ b/tools/resource-embedder
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2011 Morten Welinder <terra gnome org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+
+# This program is fairly dumb: we do search-and-replace on the text of
+# an xml file. Don't expect anything fancy to work.
+
+use strict;
+use Getopt::Long;
+use English;
+
+my $myself = $0;
+$myself =~ s|^.*/||;
+
+my $srcfile = shift @ARGV;
+my $dstfile = shift @ARGV;
+
+my $data = &read_file ($srcfile);
+
+while ($data =~ m{(<service\s+type="resource"\s+id=".*")(\s+)file="(.*)"(\s*/>)}) {
+ my $filename = $3;
+ print STDERR "Embedding $filename\n";
+ my $file_data = &read_file ($filename);
+ my $encoded_data = &xml_encode ($file_data);
+ $data = $PREMATCH . $1 . $2 . "data=\"$encoded_data\"" . $4 . $POSTMATCH;
+}
+
+&write_file ($dstfile, $data);
+
+
+sub read_file
+{
+ my ($filename) = @_;
+
+ local (*FIL);
+ local $/ = undef;
+ open (*FIL, "<$filename") or die "$myself: cannot read $filename: $!\n";
+ my $data = <FIL>;
+ close (*FIL);
+ return $data;
+}
+
+sub write_file
+{
+ my ($filename,$data) = @_;
+
+ local (*FIL);
+ open (*FIL, ">$filename") or die "$myself: cannot write $filename: $!\n";
+ print FIL $data;
+ close (*FIL);
+}
+
+sub xml_encode {
+ my ($s) = @_;
+
+ my $res = "";
+
+ foreach my $c (split (//, $s)) {
+ my $ci = ord ($c);
+ if ($c eq "&") {
+ $res .= '&';
+ } elsif ($c eq "<") {
+ $res .= '<';
+ } elsif ($c eq ">") {
+ $res .= '>';
+ } elsif ($c eq '"') {
+ $res .= '"';
+ } elsif ($ci >= 32 && $ci < 127) {
+ $res .= $c;
+ } elsif ($ci == 7) {
+ die "$myself: cannot embed character 7\n";
+ } else {
+ $res .= '&#' . $ci . ";";
+ }
+ }
+
+ return $res;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]