libzakform_la_SOURCES = \
form.c \
formelement.c \
- formelementifilter.c \
+ formelementfilter.c \
formelementfiltertrim.c \
formelementvalidator.c \
formelementvalidatornotempty.c \
libzakform.h \
form.h \
formelement.h \
- formelementifilter.h \
+ formelementfilter.h \
formelementfiltertrim.h \
formelementvalidator.h \
formelementvalidatornotempty.h \
*
*/
void
-zak_form_element_add_filter (ZakFormElement *element, ZakFormElementIFilter *filter)
+zak_form_element_add_filter (ZakFormElement *element, ZakFormElementFilter *filter)
{
ZakFormElementPrivate *priv;
value = zak_form_element_get_value (element);
- val = zak_form_element_ifilter_filter ((ZakFormElementIFilter *)g_ptr_array_index (priv->pa_filters, i),
- value);
+ val = zak_form_element_filter_filter ((ZakFormElementFilter *)g_ptr_array_index (priv->pa_filters, i),
+ value);
zak_form_element_set_value (element, val);
}
}
#include <glib-object.h>
-#include "formelementifilter.h"
+#include "formelementfilter.h"
#include "formelementvalidator.h"
void zak_form_element_clear (ZakFormElement *element);
-void zak_form_element_add_filter (ZakFormElement *element, ZakFormElementIFilter *filter);
+void zak_form_element_add_filter (ZakFormElement *element, ZakFormElementFilter *filter);
void zak_form_element_filter (ZakFormElement *element);
void zak_form_element_add_validator (ZakFormElement *element, ZakFormElementValidator *validator);
--- /dev/null
+/*
+ * Copyright (C) 2015 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 "formelementfilter.h"
+
+static void zak_form_element_filter_class_init (ZakFormElementFilterClass *class);
+static void zak_form_element_filter_init (ZakFormElementFilter *zak_form_element_filter);
+
+static void zak_form_element_filter_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void zak_form_element_filter_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void zak_form_element_filter_dispose (GObject *gobject);
+static void zak_form_element_filter_finalize (GObject *gobject);
+
+typedef struct
+ {
+ gpointer nothing;
+ } ZakFormElementFilterPrivate;
+
+G_DEFINE_ABSTRACT_TYPE (ZakFormElementFilter, zak_form_element_filter, G_TYPE_OBJECT)
+
+static void
+zak_form_element_filter_class_init (ZakFormElementFilterClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->set_property = zak_form_element_filter_set_property;
+ object_class->get_property = zak_form_element_filter_get_property;
+ object_class->dispose = zak_form_element_filter_dispose;
+ object_class->finalize = zak_form_element_filter_finalize;
+}
+
+static void
+zak_form_element_filter_init (ZakFormElementFilter *zak_form_element_filter)
+{
+ ZakFormElementFilterPrivate *priv = zak_form_element_filter_get_instance_private (zak_form_element_filter);
+}
+
+gchar
+*zak_form_element_filter_filter (ZakFormElementFilter *self, const gchar *value)
+{
+ gchar *ret;
+
+ g_return_val_if_fail (ZAK_FORM_IS_ELEMENT_FILTER (self), g_strdup (""));
+
+ if (ZAK_FORM_ELEMENT_FILTER_GET_CLASS (self)->filter != NULL)
+ {
+ ret = ZAK_FORM_ELEMENT_FILTER_GET_CLASS (self)->filter (self, value);
+ }
+ else
+ {
+ ret = g_strdup ("");
+ }
+ return ret;
+}
+
+/* PRIVATE */
+static void
+zak_form_element_filter_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ZakFormElementFilter *zak_form_element_filter = (ZakFormElementFilter *)object;
+ ZakFormElementFilterPrivate *priv = zak_form_element_filter_get_instance_private (zak_form_element_filter);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_form_element_filter_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ZakFormElementFilter *zak_form_element_filter = (ZakFormElementFilter *)object;
+ ZakFormElementFilterPrivate *priv = zak_form_element_filter_get_instance_private (zak_form_element_filter);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_form_element_filter_dispose (GObject *gobject)
+{
+ ZakFormElementFilter *zak_form_element_filter = (ZakFormElementFilter *)gobject;
+ ZakFormElementFilterPrivate *priv = zak_form_element_filter_get_instance_private (zak_form_element_filter);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->dispose (gobject);
+}
+
+static void
+zak_form_element_filter_finalize (GObject *gobject)
+{
+ ZakFormElementFilter *zak_form_element_filter = (ZakFormElementFilter *)gobject;
+ ZakFormElementFilterPrivate *priv = zak_form_element_filter_get_instance_private (zak_form_element_filter);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->finalize (gobject);
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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_FILTER_H__
+#define __ZAK_FORM_ELEMENT_FILTER_H__
+
+#include <glib-object.h>
+
+
+G_BEGIN_DECLS
+
+
+#define ZAK_FORM_TYPE_ELEMENT_FILTER zak_form_element_filter_get_type ()
+G_DECLARE_DERIVABLE_TYPE (ZakFormElementFilter, zak_form_element_filter, ZAK_FORM, ELEMENT_FILTER, GObject)
+
+struct _ZakFormElementFilterClass
+{
+ GObjectClass parent_cleass;
+
+ gchar *(*filter) (ZakFormElementFilter *self, const gchar *value);
+};
+
+gchar *zak_form_element_filter_filter (ZakFormElementFilter *self, const gchar *value);
+
+
+G_END_DECLS
+
+
+#endif /* __ZAK_FORM_ELEMENT_FILTER_H__ */
#include <config.h>
#endif
-#include "formelementifilter.h"
+#include "formelementfilter.h"
#include "formelementfiltertrim.h"
static void zak_form_element_filter_trim_class_init (ZakFormElementFilterTrimClass *class);
-static void zak_form_element_filter_trim_interface_init (ZakFormElementIFilterInterface *iface);
static void zak_form_element_filter_trim_init (ZakFormElementFilterTrim *zak_form_element);
static void zak_form_element_filter_trim_set_property (GObject *object,
static void zak_form_element_filter_trim_dispose (GObject *gobject);
static void zak_form_element_filter_trim_finalize (GObject *gobject);
-static gchar *zak_form_element_filter_trim_filter (ZakFormElementIFilter *filter_trim, const gchar *value);
+static gchar *zak_form_element_filter_trim_filter (ZakFormElementFilter *filter_trim, const gchar *value);
struct _ZakFormElementFilterTrim
{
- GObject parent_instance;
+ ZakFormElementFilter parent_instance;
/* Other members, including private data. */
};
-#define ZAK_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_TYPE_FORM_ELEMENT_FILTER_TRIM, ZakFormElementFilterTrimPrivate))
+#define ZAK_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_FORM_TYPE_ELEMENT_FILTER_TRIM, ZakFormElementFilterTrimPrivate))
typedef struct _ZakFormElementFilterTrimPrivate ZakFormElementFilterTrimPrivate;
struct _ZakFormElementFilterTrimPrivate
gpointer nothing;
};
-G_DEFINE_TYPE_WITH_CODE (ZakFormElementFilterTrim, zak_form_element_filter_trim, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (ZAK_TYPE_FORM_ELEMENT_IFILTER,
- zak_form_element_filter_trim_interface_init))
+G_DEFINE_TYPE (ZakFormElementFilterTrim, zak_form_element_filter_trim, ZAK_FORM_TYPE_ELEMENT_FILTER)
static void
zak_form_element_filter_trim_class_init (ZakFormElementFilterTrimClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ ZakFormElementFilterClass *parent_class = ZAK_FORM_ELEMENT_FILTER_CLASS (class);
object_class->set_property = zak_form_element_filter_trim_set_property;
object_class->get_property = zak_form_element_filter_trim_get_property;
object_class->dispose = zak_form_element_filter_trim_dispose;
object_class->finalize = zak_form_element_filter_trim_finalize;
- g_type_class_add_private (object_class, sizeof (ZakFormElementFilterTrimPrivate));
-}
+ parent_class->filter = zak_form_element_filter_trim_filter;
-static void
-zak_form_element_filter_trim_interface_init (ZakFormElementIFilterInterface *iface)
-{
- iface->filter = zak_form_element_filter_trim_filter;
+ g_type_class_add_private (object_class, sizeof (ZakFormElementFilterTrimPrivate));
}
static void
}
static gchar
-*zak_form_element_filter_trim_filter (ZakFormElementIFilter *filter_trim,
+*zak_form_element_filter_trim_filter (ZakFormElementFilter *filter_trim,
const gchar *value)
{
gchar *ret;
#include <glib-object.h>
+#include "formelementfilter.h"
+
G_BEGIN_DECLS
-#define ZAK_TYPE_FORM_ELEMENT_FILTER_TRIM zak_form_element_filter_trim_get_type ()
-G_DECLARE_FINAL_TYPE (ZakFormElementFilterTrim, zak_form_element_filter_trim, ZAK_FORM, ELEMENT_FILTER_TRIM, GObject)
+#define ZAK_FORM_TYPE_ELEMENT_FILTER_TRIM zak_form_element_filter_trim_get_type ()
+G_DECLARE_FINAL_TYPE (ZakFormElementFilterTrim, zak_form_element_filter_trim, ZAK_FORM, ELEMENT_FILTER_TRIM, ZakFormElementFilter)
ZakFormElementFilterTrim *zak_form_element_filter_trim_new (void);
+++ /dev/null
-/*
- * Copyright (C) 2015 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
- */
-
-#include "formelementifilter.h"
-
-G_DEFINE_INTERFACE (ZakFormElementIFilter, zak_form_element_ifilter, G_TYPE_OBJECT);
-
-static void
-zak_form_element_ifilter_default_init (ZakFormElementIFilterInterface *iface)
-{
- /* add properties and signals to the interface here */
-}
-
-gchar
-*zak_form_element_ifilter_filter (ZakFormElementIFilter *self, const gchar *value)
-{
- g_return_val_if_fail (ZAK_FORM_IS_ELEMENT_IFILTER (self), NULL);
-
- return ZAK_FORM_ELEMENT_IFILTER_GET_IFACE (self)->filter (self, value);
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 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_IFILTER_H__
-#define __ZAK_FORM_ELEMENT_IFILTER_H__
-
-#include <glib-object.h>
-
-
-G_BEGIN_DECLS
-
-
-#define ZAK_TYPE_FORM_ELEMENT_IFILTER zak_form_element_ifilter_get_type ()
-G_DECLARE_INTERFACE (ZakFormElementIFilter, zak_form_element_ifilter, ZAK_FORM, ELEMENT_IFILTER, GObject)
-
-struct _ZakFormElementIFilterInterface
-{
- GTypeInterface parent_iface;
-
- gchar *(*filter) (ZakFormElementIFilter *self, const gchar *value);
-};
-
-gchar *zak_form_element_ifilter_filter (ZakFormElementIFilter *self, const gchar *value);
-
-
-G_END_DECLS
-
-
-#endif /* __ZAK_FORM_ELEMENT_IFILTER_H__ */
struct _ZakFormElementValidatorNotempty
{
- GObject parent_instance;
+ ZakFormElementValidator parent_instance;
/* Other members, including private data. */
};
struct _ZakFormElementValidatorRegex
{
- GObject parent_instance;
+ ZakFormElementValidator parent_instance;
/* Other members, including private data. */
};
#include <libzakform/formelement.h>
-#include <libzakform/formelementifilter.h>
+#include <libzakform/formelementfilter.h>
#include <libzakform/formelementfiltertrim.h>
#include <libzakform/formelementvalidator.h>