/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2016 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
typedef struct _ZakFormElementValidatorNotemptyPrivate ZakFormElementValidatorNotemptyPrivate;
struct _ZakFormElementValidatorNotemptyPrivate
{
- gpointer nothing;
+ gchar *as_empty_string;
};
G_DEFINE_TYPE (ZakFormElementValidatorNotempty, zak_form_element_validator_notempty, ZAK_FORM_TYPE_ELEMENT_VALIDATOR)
zak_form_element_validator_notempty_init (ZakFormElementValidatorNotempty *zak_form_element)
{
ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_form_element);
+
+ priv->as_empty_string = g_strdup ("");
}
/**
*
*/
gboolean
-zak_form_elemen_validator_notempty_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode)
+zak_form_element_validator_notempty_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode)
{
- /* nothing to do */
+ ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (validator);
+
+ if (priv->as_empty_string != NULL)
+ {
+ g_free (priv->as_empty_string);
+ }
+ priv->as_empty_string = g_strdup ((gchar *)xmlNodeGetContent (xnode));
+
return TRUE;
}
const GValue *value,
GParamSpec *pspec)
{
- ZakFormElementValidatorNotempty *zak_form_element = (ZakFormElementValidatorNotempty *)object;
- ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_form_element);
+ ZakFormElementValidatorNotempty *validator = (ZakFormElementValidatorNotempty *)object;
+ ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (validator);
switch (property_id)
{
GValue *value,
GParamSpec *pspec)
{
- ZakFormElementValidatorNotempty *zak_form_element = (ZakFormElementValidatorNotempty *)object;
- ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_form_element);
+ ZakFormElementValidatorNotempty *validator = (ZakFormElementValidatorNotempty *)object;
+ ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (validator);
switch (property_id)
{
static void
zak_form_element_validator_notempty_dispose (GObject *gobject)
{
- ZakFormElementValidatorNotempty *zak_form_element = (ZakFormElementValidatorNotempty *)gobject;
- ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_form_element);
+ ZakFormElementValidatorNotempty *validator = (ZakFormElementValidatorNotempty *)gobject;
+ ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (validator);
static void
zak_form_element_validator_notempty_finalize (GObject *gobject)
{
- ZakFormElementValidatorNotempty *zak_form_element = (ZakFormElementValidatorNotempty *)gobject;
- ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_form_element);
+ ZakFormElementValidatorNotempty *validator = (ZakFormElementValidatorNotempty *)gobject;
+ ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (validator);
}
static gboolean
-zak_form_element_validator_notempty_validate (ZakFormElementValidator *validator_notempty,
+zak_form_element_validator_notempty_validate (ZakFormElementValidator *validator,
const gchar *value)
{
gboolean ret;
+ ZakFormElementValidatorNotemptyPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (validator);
+
g_return_val_if_fail (value != NULL, FALSE);
- ret = (g_strcmp0 (value, "") != 0);
+ ret = (g_strcmp0 (value, priv->as_empty_string) != 0);
return ret;
}
/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2016 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
/**
* zak_form_element_validator_regex_new:
- * @regex:
*
* Returns: the newly created #ZakFormElementValidatorRegex object.
*/
ZakFormElementValidatorRegex
-*zak_form_element_validator_regex_new (const gchar *regex)
+*zak_form_element_validator_regex_new ()
{
ZakFormElementValidatorRegex *zak_form_element_validator_regex;
ZakFormElementValidatorRegexPrivate *priv = ZAK_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (zak_form_element_validator_regex);
- if (regex != NULL)
- {
- priv->regex = g_strdup (regex);
- }
-
return zak_form_element_validator_regex;
}
/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2016 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
#define ZAK_TYPE_FORM_ELEMENT_VALIDATOR_REGEX zak_form_element_validator_regex_get_type ()
G_DECLARE_FINAL_TYPE (ZakFormElementValidatorRegex, zak_form_element_validator_regex, ZAK_FORM, ELEMENT_VALIDATOR_REGEX, ZakFormElementValidator)
-ZakFormElementValidatorRegex *zak_form_element_validator_regex_new (const gchar *regex);
+ ZakFormElementValidatorRegex *zak_form_element_validator_regex_new (void);
gboolean zak_form_element_validator_regex_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);