+2006-12-23 Andrea Zagli <azagli@inwind.it>
+
+ * widget.c:
+ * fieldboolean.c:
+ * fielddatetime.c:
+ * fieldfloat.c:
+ * fieldinteger.c:
+ * fieldtext.c: checked if form_widget property isn't set
+
2006-12-21 Andrea Zagli <azagli@inwind.it>
* libform.h:
- * form.c: form_get_field_from_name, form_get_widget_from_name
+ * form.c: added form_get_field_from_name, form_get_widget_from_name
* libformfield.h:
* field.c: added form_field_get_form_widget
* libformwidget.h:
"form-widget", &fw,
NULL);
- ret = form_widget_get_value_stringify (fw);
+ if (IS_FORM_WIDGET (fw)
+ {
+ ret = form_widget_get_value_stringify (fw);
+ }
return ret;
}
const GValue
*form_field_boolean_get_value (FormField *field)
{
- GValue *ret = g_malloc0 (sizeof (GValue));
+ GValue *ret = NULL;
const gchar *value = form_field_boolean_get_value_stringify (field);
- g_value_init (ret, G_TYPE_BOOLEAN);
- g_value_set_boolean (ret, strtol (value, NULL, 10));
+ if (value != NULL)
+ {
+ ret = g_malloc0 (sizeof (GValue));
+ g_value_init (ret, G_TYPE_BOOLEAN);
+ g_value_set_boolean (ret, strtol (value, NULL, 10));
+ }
return (const GValue *)ret;
}
"form-widget", &fw,
NULL);
- ret = form_widget_get_value_stringify (fw);
+ if (IS_FORM_WIDGET (fw))
+ {
+ ret = form_widget_get_value_stringify (fw);
+ }
return ret;
}
*form_field_datetime_get_value (FormField *field)
{
struct tm datetime;
- GValue *ret = g_malloc0 (sizeof (GValue));
+ GValue *ret = NULL;
const gchar *format = form_field_get_str_format (field);
const gchar *value = form_field_datetime_get_value_stringify (field);
- if (strptime (value, format, &datetime) != '\0')
+ if (value != NULL && strptime (value, format, &datetime) != '\0')
{
+ ret = g_malloc0 (sizeof (GValue));
g_value_init (ret, G_TYPE_POINTER);
g_value_set_pointer (ret, &datetime);
}
"form-widget", &fw,
NULL);
- ret = g_strdup_printf ("%f", strtod (form_widget_get_value_stringify (fw), NULL));
+ if (IS_FORM_WIDGET (fw))
+ {
+ ret = g_strdup_printf ("%f", strtod (form_widget_get_value_stringify (fw), NULL));
+ }
return ret;
}
const GValue
*form_field_float_get_value (FormField *field)
{
- GValue *ret = g_malloc0 (sizeof (GValue));
+ GValue *ret = NULL;
const gchar *value = form_field_float_get_value_stringify (field);
- g_value_init (ret, G_TYPE_FLOAT);
- g_value_set_float (ret, strtod (value, NULL));
+ if (value != NULL)
+ {
+ ret = g_malloc0 (sizeof (GValue));
+ g_value_init (ret, G_TYPE_FLOAT);
+ g_value_set_float (ret, strtod (value, NULL));
+ }
return (const GValue *)ret;
}
"form-widget", &fw,
NULL);
- ret = g_strdup_printf ("%d", strtol (form_widget_get_value_stringify (fw), NULL, 10));
+ if (IS_FORM_WIDGET (fw))
+ {
+ ret = g_strdup_printf ("%d", strtol (form_widget_get_value_stringify (fw), NULL, 10));
+ }
return ret;
}
const GValue
*form_field_integer_get_value (FormField *field)
{
- GValue *ret = g_malloc0 (sizeof (GValue));
+ GValue *ret = NULL;
const gchar *value = form_field_integer_get_value_stringify (field);
- g_value_init (ret, G_TYPE_INT);
- g_value_set_int (ret, atol (value));
+ if (value != NULL)
+ {
+ ret = g_malloc0 (sizeof (GValue));
+ g_value_init (ret, G_TYPE_INT);
+ g_value_set_int (ret, atol (value));
+ }
return (const GValue *)ret;
}
"form-widget", &fw,
NULL);
- ret = form_widget_get_value_stringify (fw);
+ if (IS_FORM_WIDGET (fw))
+ {
+ ret = form_widget_get_value_stringify (fw);
+ }
return ret;
}
const GValue
*form_field_text_get_value (FormField *field)
{
- GValue *ret = g_malloc0 (sizeof (GValue));
+ GValue *ret = NULL;
const gchar *value = form_field_text_get_value_stringify (field);
- g_value_init (ret, G_TYPE_STRING);
- g_value_set_string (ret, value);
+ if (value != NULL)
+ {
+ ret = g_malloc0 (sizeof (GValue));
+ g_value_init (ret, G_TYPE_STRING);
+ g_value_set_string (ret, value);
+ }
return (const GValue *)ret;
}
const gchar
*form_widget_get_value_stringify (FormWidget *fwidget)
{
- FORM_WIDGET_GET_CLASS (fwidget)->get_value_stringify (fwidget);
+ if (IS_FORM_WIDGET (fwidget))
+ {
+ FORM_WIDGET_GET_CLASS (fwidget)->get_value_stringify (fwidget);
+ }
}
/**
gboolean
form_widget_set_value_stringify (FormWidget *fwidget, const gchar *value)
{
- FORM_WIDGET_GET_CLASS (fwidget)->set_value_stringify (fwidget, value);
+ if (IS_FORM_WIDGET (fwidget))
+ {
+ FORM_WIDGET_GET_CLASS (fwidget)->set_value_stringify (fwidget, value);
+ }
}
/* PRIVATE */