[libgxps] tools: Add xpstosvg tool
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgxps] tools: Add xpstosvg tool
- Date: Sun, 30 Oct 2011 14:03:18 +0000 (UTC)
commit 017759d4b9a20fbb920fde326167a76e4258541e
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sun Oct 30 12:55:22 2011 +0100
tools: Add xpstosvg tool
configure.ac | 8 +++++
tools/Makefile.am | 24 ++++++++++++++-
tools/gxps-svg-converter.c | 73 ++++++++++++++++++++++++++++++++++++++++++++
tools/gxps-svg-converter.h | 41 ++++++++++++++++++++++++
4 files changed, 145 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7dd5076..e48335a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -183,6 +183,14 @@ AM_CONDITIONAL(HAVE_CAIRO_PS, test x$have_cairo_ps = xyes)
AC_SUBST(CAIRO_PS_CFLAGS)
AC_SUBST(CAIRO_PS_LIBS)
+dnl Cairo SVG
+PKG_CHECK_MODULES(CAIRO_SVG, cairo-svg, [have_cairo_svg="yes"], [have_cairo_svg="no"])
+
+AM_CONDITIONAL(HAVE_CAIRO_SVG, test x$have_cairo_svg = xyes)
+
+AC_SUBST(CAIRO_SVG_CFLAGS)
+AC_SUBST(CAIRO_SVG_LIBS)
+
dnl gtk-doc
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 50a201a..777d69c 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -99,4 +99,26 @@ xpstops_CFLAGS = \
xpstops_LDADD = \
libgxpstools.la \
$(CAIRO_PS_LIBS)
-endif # HAVE_CAIRO_PS
\ No newline at end of file
+endif # HAVE_CAIRO_PS
+
+if HAVE_CAIRO_SVG
+bin_PROGRAMS += xpstosvg
+
+xpstosvg_SOURCES = \
+ gxps-converter-main.c \
+ gxps-svg-converter.c \
+ gxps-svg-converter.h
+
+xpstosvg_CPPFLAGS = \
+ $(tools_cppflags) \
+ -DCONVERTER_TYPE=GXPS_TYPE_SVG_CONVERTER \
+ -DCONVERTER_HEADER=gxps-svg-converter.h
+
+xpstosvg_CFLAGS = \
+ $(tools_cflags) \
+ $(CAIRO_SVG_CFLAGS)
+
+xpstosvg_LDADD = \
+ libgxpstools.la \
+ $(CAIRO_SVG_LIBS)
+endif # HAVE_CAIRO_SVG
\ No newline at end of file
diff --git a/tools/gxps-svg-converter.c b/tools/gxps-svg-converter.c
new file mode 100644
index 0000000..291f7aa
--- /dev/null
+++ b/tools/gxps-svg-converter.c
@@ -0,0 +1,73 @@
+/* GXPSSvgConverter
+ *
+ * Copyright (C) 2011 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#include "gxps-svg-converter.h"
+#include <libgxps/gxps.h>
+#include <cairo-svg.h>
+#include <string.h>
+
+struct _GXPSSvgConverter {
+ GXPSPrintConverter parent;
+};
+
+struct _GXPSSvgConverterClass {
+ GXPSPrintConverterClass parent_class;
+};
+
+G_DEFINE_TYPE (GXPSSvgConverter, gxps_svg_converter, GXPS_TYPE_PRINT_CONVERTER)
+
+static const gchar *
+gxps_svg_converter_get_extension (GXPSConverter *converter)
+{
+ return "svg";
+}
+
+static void
+gxps_svg_converter_begin_document (GXPSConverter *converter,
+ const gchar *output_filename,
+ GXPSPage *first_page)
+{
+ GXPSPrintConverter *print_converter = GXPS_PRINT_CONVERTER (converter);
+ gdouble width, height;
+
+ GXPS_CONVERTER_CLASS (gxps_svg_converter_parent_class)->begin_document (converter, output_filename, first_page);
+
+ _gxps_converter_print_get_output_size (print_converter, first_page, &width, &height);
+ converter->surface = cairo_svg_surface_create (print_converter->filename, width, height);
+ cairo_svg_surface_restrict_to_version (converter->surface, CAIRO_SVG_VERSION_1_2);
+}
+
+static void
+gxps_svg_converter_init (GXPSSvgConverter *converter)
+{
+ GXPSPrintConverter *print_converter = GXPS_PRINT_CONVERTER (converter);
+
+ print_converter->upside_down_coords = TRUE;
+}
+
+static void
+gxps_svg_converter_class_init (GXPSSvgConverterClass *klass)
+{
+ GXPSConverterClass *converter_class = GXPS_CONVERTER_CLASS (klass);
+
+ converter_class->get_extension = gxps_svg_converter_get_extension;
+ converter_class->begin_document = gxps_svg_converter_begin_document;
+}
diff --git a/tools/gxps-svg-converter.h b/tools/gxps-svg-converter.h
new file mode 100644
index 0000000..26e9caa
--- /dev/null
+++ b/tools/gxps-svg-converter.h
@@ -0,0 +1,41 @@
+/* GXPSSvgConverter
+ *
+ * Copyright (C) 2011 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GXPS_SVG_CONVERTER_H__
+#define __GXPS_SVG_CONVERTER_H__
+
+#include "gxps-print-converter.h"
+
+G_BEGIN_DECLS
+
+#define GXPS_TYPE_SVG_CONVERTER (gxps_svg_converter_get_type ())
+#define GXPS_SVG_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GXPS_TYPE_SVG_CONVERTER, GXPSSvgConverter))
+#define GXPS_SVG_CONVERTER_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GXPS_TYPE_SVG_CONVERTER, GXPSSvgConverterClass))
+#define GXPS_IS_SVG_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GXPS_TYPE_SVG_CONVERTER))
+#define GXPS_IS_SVG_CONVERTER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GXPS_TYPE_SVG_CONVERTER))
+#define GXPS_SVG_CONVERTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXPS_TYPE_SVG_CONVERTER, GXPSSvgConverterClass))
+
+typedef struct _GXPSSvgConverter GXPSSvgConverter;
+typedef struct _GXPSSvgConverterClass GXPSSvgConverterClass;
+
+GType gxps_svg_converter_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GXPS_SVG_CONVERTER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]