GtkFormFieldInteger and GtkFormFieldFloat.
field_class->clear = gtk_form_field_datetime_clear;
field_class->is_empty = gtk_form_field_datetime_is_empty;
field_class->is_changed = gtk_form_field_datetime_is_changed;
- field_class->is_valid = gtk_form_field_datetime_is_valid;
field_class->set_as_origin = gtk_form_field_datetime_set_as_origin;
+ field_class->is_valid = gtk_form_field_datetime_is_valid;
field_class->set_from_datamodel = gtk_form_field_datetime_set_from_datamodel;
field_class->set_from_hashtable = gtk_form_field_datetime_set_from_hashtable;
field_class->set_value = gtk_form_field_datetime_set_value;
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2011 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
field_class->is_empty = gtk_form_field_float_is_empty;
field_class->is_changed = gtk_form_field_float_is_changed;
field_class->set_as_origin = gtk_form_field_float_set_as_origin;
+ field_class->is_valid = gtk_form_field_float_is_valid;
field_class->set_from_datamodel = gtk_form_field_float_set_from_datamodel;
field_class->set_from_hashtable = gtk_form_field_float_set_from_hashtable;
field_class->set_value = gtk_form_field_float_set_value;
priv->original_value = g_strtod (gtk_form_field_float_get_value_stringify (field), NULL);
}
+/**
+ * gtk_form_field_float_is_valid:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_float_is_valid (GtkFormField *field)
+{
+ gboolean ret;
+
+ GtkFormFieldFloatPrivate *priv;
+
+ gdouble value;
+
+ gchar *min_value;
+ gchar *max_value;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
+
+ ret = TRUE;
+
+ priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
+
+ value = g_strtod (gtk_form_field_float_get_value_stringify (field), NULL);
+
+ min_value = NULL;
+ max_value = NULL;
+
+ g_object_get (G_OBJECT (field),
+ "min-value", &min_value,
+ "max-value", &max_value,
+ NULL);
+
+ if (min_value != NULL
+ && g_strcmp0 (min_value, "") != 0)
+ {
+ ret = (g_strtod (min_value, NULL) <= value);
+ }
+
+ if (ret
+ && max_value != NULL
+ && g_strcmp0 (max_value, "") != 0)
+ {
+ ret = (g_strtod (max_value, NULL) >= value);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_float_set_from_datamodel:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2011 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
gboolean gtk_form_field_float_is_changed (GtkFormField *field);
void gtk_form_field_float_set_as_origin (GtkFormField *field);
+gboolean gtk_form_field_float_is_valid (GtkFormField *field);
+
gboolean gtk_form_field_float_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
gboolean gtk_form_field_float_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
gboolean gtk_form_field_float_set_value (GtkFormField *field, GValue *gvalue);
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2011 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
field_class->is_empty = gtk_form_field_integer_is_empty;
field_class->is_changed = gtk_form_field_integer_is_changed;
field_class->set_as_origin = gtk_form_field_integer_set_as_origin;
+ field_class->is_valid = gtk_form_field_integer_is_valid;
field_class->set_from_datamodel = gtk_form_field_integer_set_from_datamodel;
field_class->set_from_hashtable = gtk_form_field_integer_set_from_hashtable;
field_class->set_value = gtk_form_field_integer_set_value;
return ret;
}
+/**
+ * gtk_form_field_integer_is_valid:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_integer_is_valid (GtkFormField *field)
+{
+ gboolean ret;
+
+ GtkFormFieldIntegerPrivate *priv;
+
+ gint value;
+
+ gchar *min_value;
+ gchar *max_value;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), FALSE);
+
+ ret = TRUE;
+
+ priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
+
+ value = strtol (gtk_form_field_integer_get_value_stringify (field), NULL, 10);
+
+ min_value = NULL;
+ max_value = NULL;
+
+ g_object_get (G_OBJECT (field),
+ "min-value", &min_value,
+ "max-value", &max_value,
+ NULL);
+
+ if (min_value != NULL
+ && g_strcmp0 (min_value, "") != 0)
+ {
+ ret = (strtol (min_value, NULL, 10) <= value);
+ }
+
+ if (ret
+ && max_value != NULL
+ && g_strcmp0 (max_value, "") != 0)
+ {
+ ret = (strtol (max_value, NULL, 10) >= value);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_integer_set_as_origin:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2011 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
gboolean gtk_form_field_integer_is_changed (GtkFormField *field);
void gtk_form_field_integer_set_as_origin (GtkFormField *field);
+gboolean gtk_form_field_integer_is_valid (GtkFormField *field);
+
gboolean gtk_form_field_integer_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
gboolean gtk_form_field_integer_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
gboolean gtk_form_field_integer_set_value (GtkFormField *field, GValue *gvalue);
<widget type="spin" name="spn_age" label="label4">
<field type="integer" name="age">
+ <min-value>1</min-value>
+ <max-value>20</max-value>
</field>
</widget>