[lasem] svg_filter: boilerplate.



commit 789d0119bd0dd59fbefe65314191cdb9cf98db24
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Sat Aug 14 12:17:30 2010 +0200

    svg_filter: boilerplate.

 src/Makefile.am           |    6 +-
 src/lsmsvg.h              |    1 +
 src/lsmsvgdocument.c      |    3 +
 src/lsmsvgfilterelement.c |  140 +++++++++++++++++++++++++++++++++++++++++++++
 src/lsmsvgfilterelement.h |   61 +++++++++++++++++++
 5 files changed, 209 insertions(+), 2 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index b0b198c..3fa8aef 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -104,7 +104,8 @@ liblasem_ LASEM_API_VERSION@_la_SOURCES =				\
 	lsmsvgradialgradientelement.c		\
 	lsmsvgstopelement.c			\
 	lsmsvgpatternelement.c			\
-	lsmsvgmaskelement.c
+	lsmsvgmaskelement.c			\
+	lsmsvgfilterelement.c
 
 LASEM_HDRS = \
 	lsm.h					\
@@ -192,7 +193,8 @@ LASEM_HDRS = \
 	lsmsvgradialgradientelement.h		\
 	lsmsvgstopelement.h			\
 	lsmsvgpatternelement.h			\
-	lsmsvgmaskelement.h
+	lsmsvgmaskelement.h			\
+	lsmsvgfilterelement.h
 
 liblasem_ LASEM_API_VERSION@_ladir = $(includedir)/lasem- LASEM_API_VERSION@
 liblasem_ LASEM_API_VERSION@_la_HEADERS = $(LASEM_HDRS)
diff --git a/src/lsmsvg.h b/src/lsmsvg.h
index a6b61d5..e30d5fb 100644
--- a/src/lsmsvg.h
+++ b/src/lsmsvg.h
@@ -53,6 +53,7 @@ typedef struct _LsmSvgRadialGradientElement LsmSvgRadialGradientElement;
 typedef struct _LsmSvgStopElement LsmSvgStopElement;
 typedef struct _LsmSvgPatternElement LsmSvgPatternElement;
 typedef struct _LsmSvgMaskElement LsmSvgMaskElement;
+typedef struct _LsmSvgFilterElement LsmSvgFilterElement;
 
 typedef struct _LsmSvgView LsmSvgView;
 typedef struct _LsmSvgStyle LsmSvgStyle;
diff --git a/src/lsmsvgdocument.c b/src/lsmsvgdocument.c
index 8684cc2..36d673e 100644
--- a/src/lsmsvgdocument.c
+++ b/src/lsmsvgdocument.c
@@ -44,6 +44,7 @@
 #include <lsmsvgstopelement.h>
 #include <lsmsvgpatternelement.h>
 #include <lsmsvgmaskelement.h>
+#include <lsmsvgfilterelement.h>
 #include <lsmsvgview.h>
 #include <string.h>
 
@@ -129,6 +130,8 @@ lsm_svg_document_create_element (LsmDomDocument *document, const char *tag_name)
 		node = lsm_svg_marker_element_new ();
 	else if (strcmp (tag_name, "clipPath") == 0)
 		node = lsm_svg_clip_path_element_new ();
+	else if (strcmp (tag_name, "filter") == 0)
+		node = lsm_svg_filter_element_new ();
 
 	if (node != NULL)
 		lsm_debug ("dom", "[LsmSvgDocument::create_element] Create a %s element", tag_name);
diff --git a/src/lsmsvgfilterelement.c b/src/lsmsvgfilterelement.c
new file mode 100644
index 0000000..7db46c8
--- /dev/null
+++ b/src/lsmsvgfilterelement.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright © 2010 Emmanuel Pacaud
+ *
+ * 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 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., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * 	Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <lsmsvgfilterelement.h>
+#include <lsmsvgview.h>
+
+static GObjectClass *parent_class;
+
+/* GdomNode implementation */
+
+static const char *
+lsm_svg_filter_element_get_node_name (LsmDomNode *node)
+{
+	return "filter";
+}
+
+static gboolean
+lsm_svg_filter_element_can_append_child (LsmDomNode *self, LsmDomNode *child)
+{
+	return (lsm_svg_element_get_category (LSM_SVG_ELEMENT (child)) == LSM_SVG_ELEMENT_CATEGORY_FILTER_PRIMITIVE);
+}
+
+/* LsmSvgElement implementation */
+
+/* LsmSvgGraphic implementation */
+
+/* LsmSvgFilterElement implementation */
+
+LsmDomNode *
+lsm_svg_filter_element_new (void)
+{
+	return g_object_new (LSM_TYPE_SVG_FILTER_ELEMENT, NULL);
+}
+
+static const LsmSvgLength x_y_default = 	 { .value_unit = -10.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
+static const LsmSvgLength width_height_default = { .value_unit = 120.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
+static const LsmSvgPatternUnits units_default =  	  LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX;
+static const LsmSvgPatternUnits primitive_units_default = LSM_SVG_PATTERN_UNITS_USER_SPACE_ON_USE;
+
+static void
+lsm_svg_filter_element_init (LsmSvgFilterElement *self)
+{
+	self->x.length = x_y_default;
+	self->y.length = x_y_default;
+	self->width.length = width_height_default;
+	self->height.length = width_height_default;
+	self->units.value = units_default;
+	self->primitive_units.value = primitive_units_default;
+}
+
+static void
+lsm_svg_filter_element_finalize (GObject *object)
+{
+	parent_class->finalize (object);
+}
+
+/* LsmSvgFilterElement class */
+
+static const LsmAttributeInfos lsm_svg_filter_element_attribute_infos[] = {
+	{
+		.name = "x",
+		.attribute_offset = offsetof (LsmSvgFilterElement, x),
+		.trait_class = &lsm_svg_length_trait_class,
+		.trait_default = &x_y_default
+	},
+	{
+		.name = "y",
+		.attribute_offset = offsetof (LsmSvgFilterElement, y),
+		.trait_class = &lsm_svg_length_trait_class,
+		.trait_default = &x_y_default
+	},
+	{
+		.name = "width",
+		.attribute_offset = offsetof (LsmSvgFilterElement, width),
+		.trait_class = &lsm_svg_length_trait_class,
+		.trait_default = &width_height_default
+	},
+	{
+		.name = "height",
+		.attribute_offset = offsetof (LsmSvgFilterElement, height),
+		.trait_class = &lsm_svg_length_trait_class,
+		.trait_default = &width_height_default
+	},
+	{
+		.name = "filterUnits",
+		.attribute_offset = offsetof (LsmSvgFilterElement, units),
+		.trait_class = &lsm_svg_pattern_units_trait_class,
+		.trait_default = &units_default
+	},
+	{
+		.name = "primitiveUnits",
+		.attribute_offset = offsetof (LsmSvgFilterElement, primitive_units),
+		.trait_class = &lsm_svg_pattern_units_trait_class,
+		.trait_default = &primitive_units_default
+	}
+};
+
+static void
+lsm_svg_filter_element_class_init (LsmSvgFilterElementClass *s_rect_class)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (s_rect_class);
+	LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
+	LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
+
+	parent_class = g_type_class_peek_parent (s_rect_class);
+
+	object_class->finalize = lsm_svg_filter_element_finalize;
+
+	d_node_class->get_node_name = lsm_svg_filter_element_get_node_name;
+	d_node_class->can_append_child = lsm_svg_filter_element_can_append_child;
+
+	s_element_class->category = LSM_SVG_ELEMENT_CATEGORY_NONE;
+
+	s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
+
+	lsm_attribute_manager_add_attributes (s_element_class->attribute_manager,
+					      G_N_ELEMENTS (lsm_svg_filter_element_attribute_infos),
+					      lsm_svg_filter_element_attribute_infos);
+}
+
+G_DEFINE_TYPE (LsmSvgFilterElement, lsm_svg_filter_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgfilterelement.h b/src/lsmsvgfilterelement.h
new file mode 100644
index 0000000..0d52ced
--- /dev/null
+++ b/src/lsmsvgfilterelement.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2010 Emmanuel Pacaud
+ *
+ * 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 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., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * 	Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef LSM_SVG_FILTER_ELEMENT_H
+#define LSM_SVG_FILTER_ELEMENT_H
+
+#include <lsmsvg.h>
+#include <lsmsvgelement.h>
+
+G_BEGIN_DECLS
+
+#define LSM_TYPE_SVG_FILTER_ELEMENT             (lsm_svg_filter_element_get_type ())
+#define LSM_SVG_FILTER_ELEMENT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_SVG_FILTER_ELEMENT, LsmSvgFilterElement))
+#define LSM_SVG_FILTER_ELEMENT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_SVG_FILTER_ELEMENT, LsmSvgFilterElementClass))
+#define LSM_IS_SVG_FILTER_ELEMENT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_SVG_FILTER_ELEMENT))
+#define LSM_IS_SVG_FILTER_ELEMENT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_SVG_FILTER_ELEMENT))
+#define LSM_SVG_FILTER_ELEMENT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_SVG_FILTER_ELEMENT, LsmSvgFilterElementClass))
+
+typedef struct _LsmSvgFilterElementClass LsmSvgFilterElementClass;
+
+struct _LsmSvgFilterElement {
+	LsmSvgElement element;
+
+	LsmSvgLengthAttribute		x;
+	LsmSvgLengthAttribute		y;
+	LsmSvgLengthAttribute		width;
+	LsmSvgLengthAttribute		height;
+	LsmSvgPatternUnitsAttribute	units;
+	LsmSvgPatternUnitsAttribute	primitive_units;
+};
+
+struct _LsmSvgFilterElementClass {
+	LsmSvgElementClass  element_class;
+};
+
+GType lsm_svg_filter_element_get_type (void);
+
+LsmDomNode *		lsm_svg_filter_element_new 		(void);
+
+G_END_DECLS
+
+#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]