zakformmarshal.c \
form.c \
formelement.c \
+ formelementextension.c \
formelementfilter.c \
formelementfilterluc.c \
formelementfiltertrim.c \
zakformmarshal.h \
form.h \
formelement.h \
+ formelementextension.h \
formelementfilter.h \
formelementfilterluc.h \
formelementfiltertrim.h \
#include <windows.h>
#endif
-typedef ZakFormElement *(* FormElementConstructorFunc) (void);
-typedef GObject *(* FormElementExtensionConstructorFunc) (void);
-typedef gboolean (* FormElementExtensionXmlParsingFunc) (GObject *, xmlNodePtr);
typedef ZakFormValidator *(* FormValidatorConstructorFunc) (void);
static void zak_form_form_class_init (ZakFormFormClass *class);
gchar *type;
guint i;
- GObject *extension;
+ ZakFormElementExtension *extension;
ZakFormElementFilter *filter;
ZakFormElementValidator *validator;
- FormElementExtensionConstructorFunc extension_constructor;
- FormElementExtensionXmlParsingFunc extension_xml_parsing;
+ ZakFormElementExtensionConstructorFunc extension_constructor;
ZakFormElementFilterConstructorFunc filter_constructor;
ZakFormElementValidatorConstructorFunc validator_constructor;
{
type = (gchar *)xmlGetProp (xnode, (const xmlChar *)"type");
- /* for each module */
- for (i = 0; i < priv->ar_modules->len; i++)
+ extension_constructor = zak_form_form_get_form_element_extension (zakform, type);
+ if (extension_constructor != NULL)
{
- if (g_module_symbol ((GModule *)g_ptr_array_index (priv->ar_modules, i),
- g_strconcat (type, "_new", NULL),
- (gpointer *)&extension_constructor))
- {
- if (extension_constructor != NULL)
- {
- extension = extension_constructor ();
- zak_form_element_add_extension (element, extension);
-
- if (g_module_symbol ((GModule *)g_ptr_array_index (priv->ar_modules, i),
- g_strconcat (type, "_xml_parsing", NULL),
- (gpointer *)&extension_xml_parsing))
- {
- if (extension_xml_parsing != NULL)
- {
- extension_xml_parsing (extension, xnode);
- }
- }
+ extension = extension_constructor ();
+ zak_form_element_add_extension (element, extension);
- break;
- }
- }
+ zak_form_element_extension_xml_parsing (extension, xnode);
}
- if (i >= priv->ar_modules->len)
+ else
{
- g_warning ("Filter «%s» not found.", type);
+ g_warning ("Extension «%s» not found.", type);
}
to_unlink = TRUE;
return validator_constructor;
}
+/**
+ * zak_form_form_get_form_element_extension:
+ * @zakform:
+ * @namespace:
+ *
+ * Returns:
+ */
+ZakFormElementExtensionConstructorFunc
+zak_form_form_get_form_element_extension (ZakFormForm *zakform, const gchar *namespace)
+{
+ ZakFormElementExtensionConstructorFunc extension_constructor;
+
+ g_return_val_if_fail (ZAK_FORM_IS_FORM (zakform), NULL);
+
+ extension_constructor = (ZakFormElementExtensionConstructorFunc)_zak_form_form_get_module_new (zakform, namespace);
+
+ return extension_constructor;
+}
+
/**
* zak_form_form_load_from_xml:
* @zakform:
#include <libxml/tree.h>
#include "formelement.h"
+#include "formelementextension.h"
#include "formiprovider.h"
#include "formvalidator.h"
typedef ZakFormElementValidator *(* ZakFormElementValidatorConstructorFunc) (void);
ZakFormElementValidatorConstructorFunc zak_form_form_get_form_element_validator (ZakFormForm *zakform, const gchar *namespace);
+typedef ZakFormElementExtension *(* ZakFormElementExtensionConstructorFunc) (void);
+ZakFormElementExtensionConstructorFunc zak_form_form_get_form_element_extension (ZakFormForm *zakform, const gchar *namespace);
+
gboolean zak_form_form_load_from_xml (ZakFormForm *zakform, xmlDoc *xmldoc);
gboolean zak_form_form_load_from_file (ZakFormForm *zakform, const gchar *filename);
*
*/
void
-zak_form_element_add_extension (ZakFormElement *element, GObject *extension)
+zak_form_element_add_extension (ZakFormElement *element, ZakFormElementExtension *extension)
{
ZakFormElementPrivate *priv;
#include "formelementfilter.h"
#include "formelementvalidator.h"
+#include "formelementextension.h"
G_BEGIN_DECLS
void zak_form_element_clear (ZakFormElement *element);
-void zak_form_element_add_extension (ZakFormElement *element, GObject *extension);
+void zak_form_element_add_extension (ZakFormElement *element, ZakFormElementExtension *extension);
GPtrArray *zak_form_element_get_extensions (ZakFormElement *element);
GPtrArray *zak_form_element_get_extensions_by_type (ZakFormElement *element, GType type);
--- /dev/null
+/*
+ * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <locale.h>
+
+#include <libzakutils/libzakutils.h>
+
+#include "formelementextension.h"
+
+enum
+{
+ PROP_0
+};
+
+static void zak_form_element_extension_class_init (ZakFormElementExtensionClass *class);
+static void zak_form_element_extension_init (ZakFormElementExtension *zak_form_element);
+
+static void zak_form_element_extension_construct (ZakFormElementExtension *element,
+ const gchar *id,
+ GHashTable *ht_attrs);
+
+static void zak_form_element_extension_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void zak_form_element_extension_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void zak_form_element_extension_dispose (GObject *gobject);
+static void zak_form_element_extension_finalize (GObject *gobject);
+
+typedef struct
+ {
+ gpointer useless;
+ } ZakFormElementExtensionPrivate;
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ZakFormElementExtension, zak_form_element_extension, G_TYPE_OBJECT)
+
+static void
+zak_form_element_extension_class_init (ZakFormElementExtensionClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->set_property = zak_form_element_extension_set_property;
+ object_class->get_property = zak_form_element_extension_get_property;
+ object_class->dispose = zak_form_element_extension_dispose;
+ object_class->finalize = zak_form_element_extension_finalize;
+}
+
+static void
+zak_form_element_extension_init (ZakFormElementExtension *zak_form_element)
+{
+ ZakFormElementExtensionPrivate *priv = zak_form_element_extension_get_instance_private (zak_form_element);
+
+}
+
+/**
+ * zak_form_element_extension_xml_parsing:
+ * @element:
+ * @xmlnode:
+ *
+ */
+void
+zak_form_element_extension_xml_parsing (ZakFormElementExtension *element, xmlNode *xmlnode)
+{
+ if (ZAK_FORM_ELEMENT_EXTENSION_GET_CLASS (element)->xml_parsing != NULL)
+ {
+ ZAK_FORM_ELEMENT_EXTENSION_GET_CLASS (element)->xml_parsing (element, xmlnode);
+ }
+}
+
+/* PRIVATE */
+static void
+zak_form_element_extension_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ZakFormElementExtension *zak_form_element_extension = (ZakFormElementExtension *)object;
+ ZakFormElementExtensionPrivate *priv = zak_form_element_extension_get_instance_private (zak_form_element_extension);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_form_element_extension_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ZakFormElementExtension *zak_form_element_extension = (ZakFormElementExtension *)object;
+ ZakFormElementExtensionPrivate *priv = zak_form_element_extension_get_instance_private (zak_form_element_extension);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_form_element_extension_dispose (GObject *gobject)
+{
+ ZakFormElementExtension *zak_form_element_extension = (ZakFormElementExtension *)gobject;
+ ZakFormElementExtensionPrivate *priv = zak_form_element_extension_get_instance_private (zak_form_element_extension);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->dispose (gobject);
+}
+
+static void
+zak_form_element_extension_finalize (GObject *gobject)
+{
+ ZakFormElementExtension *zak_form_element_extension = (ZakFormElementExtension *)gobject;
+ ZakFormElementExtensionPrivate *priv = zak_form_element_extension_get_instance_private (zak_form_element_extension);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->finalize (gobject);
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __ZAK_FORM_ELEMENT_EXTENSION_H__
+#define __ZAK_FORM_ELEMENT_EXTENSION_H__
+
+
+#include <glib-object.h>
+
+#include <libxml/tree.h>
+
+
+G_BEGIN_DECLS
+
+
+#define ZAK_FORM_TYPE_ELEMENT_EXTENSION zak_form_element_extension_get_type ()
+G_DECLARE_DERIVABLE_TYPE (ZakFormElementExtension, zak_form_element_extension, ZAK_FORM, ELEMENT_EXTENSION, GObject)
+
+struct _ZakFormElementExtensionClass
+ {
+ GObjectClass parent_class;
+
+ void (*xml_parsing) (ZakFormElementExtension *element, xmlNode *xmlnode);
+ };
+
+void zak_form_element_extension_xml_parsing (ZakFormElementExtension *element, xmlNode *xmlnode);
+
+
+G_END_DECLS
+
+
+#endif /* __ZAK_FORM_ELEMENT_EXTENSION_H__ */
#include <libzakform/formelement.h>
+#include <libzakform/formelementextension.h>
+
#include <libzakform/formelementfilter.h>
#include <libzakform/formelementfilterluc.h>
#include <libzakform/formelementfiltertrim.h>