typedef ZakFormElement *(* FormElementConstructorFunc) (void);
typedef gboolean (* FormElementXmlParsingFunc) (ZakFormElement *, xmlNodePtr);
+typedef GObject *(* FormElementExtensionConstructorFunc) (void);
+typedef gboolean (* FormElementExtensionXmlParsingFunc) (GObject *, xmlNodePtr);
typedef ZakFormElementFilter *(* FormElementFilterConstructorFunc) (void);
typedef gboolean (* FormElementFilterXmlParsingFunc) (ZakFormElementFilter *, xmlNodePtr);
typedef ZakFormElementValidator *(* FormElementValidatorConstructorFunc) (void);
gchar *type;
guint i;
+ GObject *extension;
ZakFormElementFilter *filter;
ZakFormElementValidator *validator;
+ FormElementExtensionConstructorFunc extension_constructor;
+ FormElementExtensionXmlParsingFunc extension_xml_parsing;
FormElementFilterConstructorFunc filter_constructor;
FormElementFilterXmlParsingFunc filter_xml_parsing;
FormElementValidatorConstructorFunc validator_constructor;
{
to_unlink = FALSE;
- if (xmlStrcmp (xnode->name, (const xmlChar *)"filter") == 0)
+ if (xmlStrcmp (xnode->name, (const xmlChar *)"extension") == 0)
{
type = xmlGetProp (xnode, (const xmlChar *)"type");
for (i = 0; i < priv->ar_modules->len; i++)
{
if (g_module_symbol ((GModule *)g_ptr_array_index (priv->ar_modules, i),
- g_strconcat (type, "_new", NULL),
- (gpointer *)&filter_constructor))
+ 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);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+ if (i >= priv->ar_modules->len)
+ {
+ g_warning ("Filter «%s» not found.", type);
+ }
+
+ to_unlink = TRUE;
+ }
+ else if (xmlStrcmp (xnode->name, (const xmlChar *)"filter") == 0)
+ {
+ type = xmlGetProp (xnode, (const xmlChar *)"type");
+
+ /* for each module */
+ for (i = 0; i < priv->ar_modules->len; i++)
+ {
+ if (g_module_symbol ((GModule *)g_ptr_array_index (priv->ar_modules, i),
+ g_strconcat (type, "_new", NULL),
+ (gpointer *)&filter_constructor))
{
if (filter_constructor != NULL)
{
zak_form_element_add_filter (element, filter);
if (g_module_symbol ((GModule *)g_ptr_array_index (priv->ar_modules, i),
- g_strconcat (type, "_xml_parsing", NULL),
- (gpointer *)&filter_xml_parsing))
+ g_strconcat (type, "_xml_parsing", NULL),
+ (gpointer *)&filter_xml_parsing))
{
if (filter_xml_parsing != NULL)
{
for (i = 0; i < priv->ar_modules->len; i++)
{
if (g_module_symbol ((GModule *)g_ptr_array_index (priv->ar_modules, i),
- g_strconcat (type, "_new", NULL),
- (gpointer *)&validator_constructor))
+ g_strconcat (type, "_new", NULL),
+ (gpointer *)&validator_constructor))
{
if (validator_constructor != NULL)
{
zak_form_element_add_validator (element, validator);
if (g_module_symbol ((GModule *)g_ptr_array_index (priv->ar_modules, i),
- g_strconcat (type, "_xml_parsing", NULL),
- (gpointer *)&validator_xml_parsing))
+ g_strconcat (type, "_xml_parsing", NULL),
+ (gpointer *)&validator_xml_parsing))
{
if (validator_xml_parsing != NULL)
{
gboolean to_load;
gboolean to_save;
+ GPtrArray *pa_extensions;
GPtrArray *pa_filters;
GPtrArray *pa_validators;
GPtrArray *pa_messages;
priv->to_load = TRUE;
priv->to_save = TRUE;
+ priv->pa_extensions = g_ptr_array_new ();
priv->pa_filters = g_ptr_array_new ();
priv->pa_validators = g_ptr_array_new ();
priv->pa_messages = NULL;
}
+/**
+ * zak_form_element_add_extension:
+ * @element:
+ * @extension:
+ *
+ */
+void
+zak_form_element_add_extension (ZakFormElement *element, GObject *extension)
+{
+ ZakFormElementPrivate *priv;
+
+ priv = zak_form_element_get_instance_private (element);
+
+ g_ptr_array_add (priv->pa_extensions, extension);
+}
+
+/**
+ * zak_form_element_get_extensions:
+ * @zakform:
+ *
+ * Returns: a #GPtrArray with the list of extensions in the form element.
+ */
+GPtrArray
+*zak_form_element_get_extensions (ZakFormElement *element)
+{
+ ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element);
+
+ return priv->pa_extensions;
+}
+
+/**
+ * zak_form_element_get_extensions_by_type:
+ * @element:
+ * @type:
+ *
+ * Returns: a #GPtrArray with the list of extensions in the form element filtered by @type.
+ */
+GPtrArray
+*zak_form_element_get_extensions_by_type (ZakFormElement *element, GType type)
+{
+ GPtrArray *ar;
+ GObject *extension;
+
+ guint i;
+
+ ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element);
+
+ ar = g_ptr_array_new ();
+ for (i = 0; i < priv->pa_extensions->len; i++)
+ {
+ extension = (GObject *)g_ptr_array_index (priv->pa_extensions, i);
+ if (G_OBJECT_TYPE (extension) == type)
+ {
+ g_ptr_array_add (ar, extension);
+ }
+ }
+
+ return ar;
+}
+
/**
* zak_form_element_add_filter:
* @element: