gtk_form_field_boolean_get_value_sql
gtk_form_field_boolean_clear
gtk_form_field_boolean_is_empty
+gtk_form_filed_boolean_is_changed
gtk_form_field_boolean_set_from_datamodel
gtk_form_field_boolean_str_to_boolean
</SECTION>
gtk_form_field_text_get_value_sql
gtk_form_field_text_clear
gtk_form_field_text_is_empty
+gtk_form_field_text_is_changed
gtk_form_field_text_set_from_datamodel
</SECTION>
gtk_form_field_datetime_get_value_sql
gtk_form_field_datetime_clear
gtk_form_field_datetime_is_empty
+gtk_form_field_datetime_is_changed
gtk_form_field_datetime_set_from_datamodel
gtk_form_field_datetime_get_tm_from_str
</SECTION>
gtk_form_field_float_get_value_sql
gtk_form_field_float_clear
gtk_form_field_float_is_empty
+gtk_form_field_float_is_changed
gtk_form_field_float_set_from_datamodel
</SECTION>
gtk_form_field_get_value_sql
gtk_form_field_clear
gtk_form_field_is_empty
+gtk_form_field_is_changed
gtk_form_field_set_from_datamodel
</SECTION>
gtk_form_get_widget_from_name
gtk_form_clear
gtk_form_check
+gtk_form_is_changed
gtk_form_set_sensitive
gtk_form_set_editable
GtkFormSqlType
gtk_form_field_integer_get_value_sql
gtk_form_field_integer_clear
gtk_form_field_integer_is_empty
+gtk_form_field_integer_is_changed
gtk_form_field_integer_set_from_datamodel
</SECTION>
GtkFormField *field
</FUNCTION>
<FUNCTION>
+<NAME>gtk_form_filed_boolean_is_changed</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormField *field
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_form_field_boolean_set_from_datamodel</NAME>
<RETURNS>gboolean </RETURNS>
GtkFormField *field, GdaDataModel *dm, gint row
GtkFormField *field
</FUNCTION>
<FUNCTION>
+<NAME>gtk_form_field_text_is_changed</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormField *field
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_form_field_text_set_from_datamodel</NAME>
<RETURNS>gboolean </RETURNS>
GtkFormField *field, GdaDataModel *dm, gint row
GtkFormField *field
</FUNCTION>
<FUNCTION>
+<NAME>gtk_form_field_datetime_is_changed</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormField *field
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_form_field_datetime_set_from_datamodel</NAME>
<RETURNS>gboolean </RETURNS>
GtkFormField *field, GdaDataModel *dm, gint row
GtkFormField *field
</FUNCTION>
<FUNCTION>
+<NAME>gtk_form_field_float_is_changed</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormField *field
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_form_field_float_set_from_datamodel</NAME>
<RETURNS>gboolean </RETURNS>
GtkFormField *field, GdaDataModel *dm, gint row
gboolean (*clear) (GtkFormField *field);
gboolean (*is_empty) (GtkFormField *field);
+ gboolean (*is_changed) (GtkFormField *field);
gboolean (*set_from_datamodel) (GtkFormField *field, GdaDataModel *dm, gint row);
};
</STRUCT>
GtkFormField *field
</FUNCTION>
<FUNCTION>
+<NAME>gtk_form_field_is_changed</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormField *field
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_form_field_set_from_datamodel</NAME>
<RETURNS>gboolean </RETURNS>
GtkFormField *field, GdaDataModel *dm, gint row
GtkForm *form
</FUNCTION>
<FUNCTION>
+<NAME>gtk_form_is_changed</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkForm *form
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_form_set_sensitive</NAME>
<RETURNS>void </RETURNS>
GtkForm *form, gboolean sensitive
GtkFormField *field
</FUNCTION>
<FUNCTION>
+<NAME>gtk_form_field_integer_is_changed</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormField *field
+</FUNCTION>
+<FUNCTION>
<NAME>gtk_form_field_integer_set_from_datamodel</NAME>
<RETURNS>gboolean </RETURNS>
GtkFormField *field, GdaDataModel *dm, gint row
6% symbol docs coverage.
17 symbols documented.
2 symbols incomplete.
-252 not documented.
+259 not documented.
GTK_FORM
gtk_form_field_datetime_get_value
gtk_form_field_datetime_get_value_sql
gtk_form_field_datetime_get_value_stringify
+gtk_form_field_datetime_is_changed
gtk_form_field_datetime_is_empty
gtk_form_field_datetime_new
gtk_form_field_datetime_set_from_datamodel
gtk_form_field_float_get_value
gtk_form_field_float_get_value_sql
gtk_form_field_float_get_value_stringify
+gtk_form_field_float_is_changed
gtk_form_field_float_is_empty
gtk_form_field_float_new
gtk_form_field_float_set_from_datamodel
gtk_form_field_get_field_name
-gtk_form_field_get_gtk_form_widget (field, field, Returns)
+gtk_form_field_get_gtk_form_widget (Returns)
gtk_form_field_get_str_format
gtk_form_field_get_type
gtk_form_field_get_value
gtk_form_field_integer_get_value
gtk_form_field_integer_get_value_sql
gtk_form_field_integer_get_value_stringify
+gtk_form_field_integer_is_changed
gtk_form_field_integer_is_empty
gtk_form_field_integer_new
gtk_form_field_integer_set_from_datamodel
+gtk_form_field_is_changed
gtk_form_field_is_empty
gtk_form_field_new
gtk_form_field_new_from_gtk_form_widget
gtk_form_field_text_get_value
gtk_form_field_text_get_value_sql
gtk_form_field_text_get_value_stringify
+gtk_form_field_text_is_changed
gtk_form_field_text_is_empty
gtk_form_field_text_new
gtk_form_field_text_set_from_datamodel
+gtk_form_filed_boolean_is_changed
gtk_form_fill_from_datamodel
gtk_form_get_field_from_name
gtk_form_get_gtkbuilder
gtk_form_get_table
gtk_form_get_type
gtk_form_get_widget_from_name
+gtk_form_is_changed
gtk_form_key_add_field
gtk_form_key_add_fields
gtk_form_key_check
GtkFormWidgetTextviewClass
gtk_form_field_boolean_str_to_boolean
gtk_form_field_datetime_get_tm_from_str
+gtk_form_field_datetime_is_changed
+gtk_form_field_float_is_changed
+gtk_form_field_integer_is_changed
+gtk_form_field_is_changed
+gtk_form_field_text_is_changed
+gtk_form_filed_boolean_is_changed
gtk_form_get_gtkbuilder
gtk_form_get_key
gtk_form_get_table
+gtk_form_is_changed
gtk_form_new_from_file
gtk_form_new_from_xml
gtk_form_set_key
includedir=@includedir@
Name: @PACKAGE_NAME@
-Description: Class for easly manage Gtk+ forms binded to db (or not).
+Description: Class to more easly manage Gtk+ forms binded to db (or not).
Version: @PACKAGE_VERSION@
Requires: gtk+-2.0, libxml-2.0, libgdaex
Libs: -L${libdir} -lgtkform
-Cflags: -I${includedir}/libgtkform
+Cflags: -I${includedir}
g_param_spec_object ("form-widget",
"GtkFormWidget",
"The GtkFormWidget",
- TYPE_GTK_FORM_WIDGET,
+ TYPE_GTK_FORM_WIDGET,
G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (GtkFormFieldPrivate));
/**
* gtk_form_field_new_from_gtk_form_widget:
- * @fwidget:
+ * @fwidget: a #GtkFormWidget object.
*
* Returns: the newly created #GtkFormField.
*/
/**
* gtk_form_field_get_field_name:
- * @field:
+ * @field: a #GtkFormField object.
*
* Returns: the field's name.
*/
/**
* gtk_form_field_get_gtk_form_widget:
- * @field:
+ * @field: a #GtkFormField object.
*
* Return: the associated #GtkFormWidget.
*/
/**
* gtk_form_field_get_value_stringify:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
*gtk_form_field_get_value_stringify (GtkFormField *field)
{
- GTK_FORM_FIELD_GET_CLASS (field)->get_value_stringify (field);
+ const gchar *ret;
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->get_value_stringify != NULL)
+ {
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->get_value_stringify (field);
+ }
+
+ return ret;
}
/**
* gtk_form_field_get_value:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const GValue
*gtk_form_field_get_value (GtkFormField *field)
{
- GTK_FORM_FIELD_GET_CLASS (field)->get_value (field);
+ const GValue *ret;
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->get_value != NULL)
+ {
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->get_value (field);
+ }
+
+ return ret;
}
/**
* gtk_form_field_get_value_sql:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
*gtk_form_field_get_value_sql (GtkFormField *field)
{
- GTK_FORM_FIELD_GET_CLASS (field)->get_value_sql (field);
+ const gchar *ret;
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->get_value_sql != NULL)
+ {
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->get_value_sql (field);
+ }
+
+ return ret;
}
/**
* gtk_form_field_clear:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
gtk_form_field_clear (GtkFormField *field)
{
- GTK_FORM_FIELD_GET_CLASS (field)->clear (field);
+ gboolean ret;
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->clear != NULL)
+ {
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->clear (field);
+ }
+
+ return ret;
}
/**
* gtk_form_field_is_empty:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
gtk_form_field_is_empty (GtkFormField *field)
{
- GTK_FORM_FIELD_GET_CLASS (field)->is_empty (field);
+ gboolean ret = FALSE;
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->is_empty != NULL)
+ {
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->is_empty (field);
+ }
+
+ return ret;
+}
+
+/**
+ * gtk_form_field_is_changed:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: TRUE if the values in the form are changed since last calling to
+ * gtk_form_field_clear() or gtk_form_field_set_from_datamodel().
+ */
+gboolean
+gtk_form_field_is_changed (GtkFormField *field)
+{
+ gboolean ret = FALSE;
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->is_changed != NULL)
+ {
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->is_changed (field);
+ }
+
+ return ret;
}
/**
* gtk_form_field_set_from_datamodel:
- * @field:
- * @dm:
- * @row:
+ * @field: a #GtkFormField object.
+ * @dm: a #GdaDataModel object.
+ * @row: the row number to return.
*
*/
gboolean
gtk_form_field_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
{
+ gboolean ret = FALSE;
+
GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
- if (priv->field != NULL && strcmp (priv->field, "") != 0)
+ g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->set_from_datamodel != NULL)
{
- GTK_FORM_FIELD_GET_CLASS (field)->set_from_datamodel (field, dm, row);
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->set_from_datamodel (field, dm, row);
}
+
+ return ret;
}
/* PRIVATE */
gboolean (*clear) (GtkFormField *field);
gboolean (*is_empty) (GtkFormField *field);
+ gboolean (*is_changed) (GtkFormField *field);
gboolean (*set_from_datamodel) (GtkFormField *field, GdaDataModel *dm, gint row);
};
gboolean gtk_form_field_is_empty (GtkFormField *field);
+gboolean gtk_form_field_is_changed (GtkFormField *field);
+
gboolean gtk_form_field_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
struct _GtkFormFieldBooleanPrivate
{
gboolean default_value;
+ gboolean original_value;
};
field_class->get_value_sql = gtk_form_field_boolean_get_value_sql;
field_class->clear = gtk_form_field_boolean_clear;
field_class->is_empty = gtk_form_field_boolean_is_empty;
+ field_class->is_changed = gtk_form_filed_boolean_is_changed;
field_class->set_from_datamodel = gtk_form_field_boolean_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
*gtk_form_field_boolean_get_value (GtkFormField *field)
{
GValue *ret = NULL;
+ const gchar *value;
g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), NULL);
- const gchar *value = gtk_form_field_boolean_get_value_stringify (field);
+ value = gtk_form_field_boolean_get_value_stringify (field);
if (value != NULL)
{
ret = gtk_form_field_boolean_set_value_stringify (field, g_strdup_printf ("%d", priv->default_value));
+ priv->original_value = priv->default_value;
+
return ret;
}
return ret;
}
+/**
+ * gtk_form_filed_boolean_is_changed:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_filed_boolean_is_changed (GtkFormField *field)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldBooleanPrivate *priv;
+ const gchar *value;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
+
+ priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (GTK_FORM_FIELD_BOOLEAN (field));
+
+ value = gtk_form_field_boolean_get_value_stringify (field);
+
+ ret = (priv->original_value != gtk_form_field_boolean_str_to_boolean (value));
+
+ return ret;
+}
+
/**
* gtk_form_field_boolean_set_from_datamodel:
* @field: a #GtkFormField object.
gtk_form_field_boolean_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
{
gboolean ret = FALSE;
+ GtkFormFieldBooleanPrivate *priv;
const gchar *field_name;
gchar *value;
g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
+ priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (GTK_FORM_FIELD_BOOLEAN (field));
+
field_name = gtk_form_field_get_field_name (field);
if (gdaex_data_model_get_field_value_boolean_at (dm, row, field_name))
}
ret = gtk_form_field_boolean_set_value_stringify (field, value);
+ priv->original_value = gtk_form_field_boolean_str_to_boolean (value);
+
return ret;
}
gboolean gtk_form_field_boolean_is_empty (GtkFormField *field);
+gboolean gtk_form_filed_boolean_is_changed (GtkFormField *field);
+
gboolean gtk_form_field_boolean_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
gboolean gtk_form_field_boolean_str_to_boolean (const gchar *value);
struct _GtkFormFieldDateTimePrivate
{
struct tm *default_value;
+ struct tm *original_value;
gint type;
};
field_class->get_value_sql = gtk_form_field_datetime_get_value_sql;
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->set_from_datamodel = gtk_form_field_datetime_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
ret = gtk_form_field_datetime_set_value_stringify (field, "");
}
+ priv->original_value = g_memdup (priv->default_value, sizeof (struct tm));
+
return ret;
}
return ret;
}
+/**
+ * gtk_form_field_datetime_is_changed:
+ * @field:
+ *
+ */
+gboolean
+gtk_form_field_datetime_is_changed (GtkFormField *field)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldDateTimePrivate *priv;
+ struct tm *value;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
+
+ priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+ value = gtk_form_field_datetime_get_tm_from_str (gtk_form_field_datetime_get_value_stringify (field));
+
+ ret = (value->tm_year != priv->original_value->tm_year
+ || value->tm_mon != priv->original_value->tm_mon
+ || value->tm_mday != priv->original_value->tm_mday
+ || value->tm_hour != priv->original_value->tm_hour
+ || value->tm_min != priv->original_value->tm_min
+ || value->tm_sec != priv->original_value->tm_sec);
+
+ return ret;
+}
+
/**
* gtk_form_field_datetime_set_from_datamodel:
* @field: a #GtkFormField object.
- * @dm:
+ * @dm: a #GdaDataModel object.
* @row:
*
*/
gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
{
gboolean ret = FALSE;
+ GtkFormFieldDateTimePrivate *priv;
+ const gchar *field_name;
+ const gchar *value;
g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
+ g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
- const gchar *field_name = gtk_form_field_get_field_name (field);
+ priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
- if (dm != NULL)
- {
- ret = gtk_form_field_datetime_set_value_stringify (field,
- gdaex_data_model_get_field_value_stringify_at (dm, row, field_name));
- }
+ field_name = gtk_form_field_get_field_name (field);
+
+ value = gdaex_data_model_get_field_value_stringify_at (dm, row, field_name);
+
+ ret = gtk_form_field_datetime_set_value_stringify (field, value);
+
+ priv->original_value = gtk_form_field_datetime_get_tm_from_str (value);
return ret;
}
gboolean gtk_form_field_datetime_is_empty (GtkFormField *field);
+gboolean gtk_form_field_datetime_is_changed (GtkFormField *field);
+
gboolean gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
struct tm *gtk_form_field_datetime_get_tm_from_str (const gchar *str);
struct _GtkFormFieldFloatPrivate
{
gfloat default_value;
+ gfloat original_value;
};
field_class->get_value_sql = gtk_form_field_float_get_value_sql;
field_class->clear = gtk_form_field_float_clear;
field_class->is_empty = gtk_form_field_float_is_empty;
+ field_class->is_changed = gtk_form_field_float_is_changed;
field_class->set_from_datamodel = gtk_form_field_float_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
/**
* gtk_form_field_float_get_value_stringify:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
/**
* gtk_form_field_float_get_value:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const GValue
/**
* gtk_form_field_float_get_value_sql:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
/**
* gtk_form_field_float_clear:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf ("%f", priv->default_value));
+ priv->original_value = priv->default_value;
+
return ret;
}
/**
* gtk_form_field_float_is_empty:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
return ret;
}
+/**
+ * gtk_form_field_float_is_changed:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_float_is_changed (GtkFormField *field)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldFloatPrivate *priv;
+ gfloat value;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
+
+ priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
+
+ value = g_strtod (gtk_form_field_float_get_value_stringify (field), NULL);
+
+ ret = (priv->original_value != value);
+
+ return ret;
+}
+
/**
* gtk_form_field_float_set_from_datamodel:
- * @field:
- * @dm:
+ * @field: a #GtkFormField object.
+ * @dm: a #GdaDataModel object.
* @row:
*
*/
gtk_form_field_float_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
{
gboolean ret = FALSE;
- const gchar *field_name = gtk_form_field_get_field_name (field);
+ GtkFormFieldFloatPrivate *priv;
+ const gchar *value;
+ const gchar *field_name;
- if (dm != NULL)
- {
- ret = gtk_form_field_float_set_value_stringify (field,
- gdaex_data_model_get_field_value_stringify_at (dm, row, field_name));
- }
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
+ g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
+
+ priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
+
+ field_name = gtk_form_field_get_field_name (field);
+
+ value = gdaex_data_model_get_field_value_stringify_at (dm, row, field_name);
+
+ ret = gtk_form_field_float_set_value_stringify (field, value);
+
+ priv->original_value = g_strtod (value, NULL);
return ret;
}
gboolean gtk_form_field_float_is_empty (GtkFormField *field);
+gboolean gtk_form_field_float_is_changed (GtkFormField *field);
+
gboolean gtk_form_field_float_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
struct _GtkFormFieldIntegerPrivate
{
gint default_value;
+ gint original_value;
};
field_class->get_value_sql = gtk_form_field_integer_get_value_sql;
field_class->clear = gtk_form_field_integer_clear;
field_class->is_empty = gtk_form_field_integer_is_empty;
+ field_class->is_changed = gtk_form_field_integer_is_changed;
field_class->set_from_datamodel = gtk_form_field_integer_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
/**
* gtk_form_field_integer_get_value_stringify:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
/**
* gtk_form_field_integer_get_value:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const GValue
/**
* gtk_form_field_integer_get_value_sql:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
/**
* gtk_form_field_integer_clear:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
ret = gtk_form_field_integer_set_value_stringify (field, g_strdup_printf ("%d", priv->default_value));
+ priv->original_value = priv->default_value;
+
return ret;
}
/**
* gtk_form_field_integer_is_empty:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
return ret;
}
+/**
+ * gtk_form_field_integer_is_changed:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_integer_is_changed (GtkFormField *field)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldIntegerPrivate *priv;
+ gint value;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), FALSE);
+
+ priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
+
+ value = strtol (gtk_form_field_integer_get_value_stringify (field), NULL, 10);
+
+ ret = (priv->original_value != value);
+
+ return ret;
+}
+
/**
* gtk_form_field_integer_set_from_datamodel:
- * @field:
- * @dm:
+ * @field: a #GtkFormField object.
+ * @dm: a #GdaDataModel object.
* @row:
*
*/
gtk_form_field_integer_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
{
gboolean ret = FALSE;
- const gchar *field_name = gtk_form_field_get_field_name (field);
+ GtkFormFieldIntegerPrivate *priv;
+ const gchar *value;
+ const gchar *field_name;
- if (dm != NULL)
- {
- ret = gtk_form_field_integer_set_value_stringify (field,
- gdaex_data_model_get_field_value_stringify_at (dm, row, field_name));
- }
+ g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
+
+ priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
+
+ field_name = gtk_form_field_get_field_name (field);
+
+ value = gdaex_data_model_get_field_value_stringify_at (dm, row, field_name);
+
+ ret = gtk_form_field_integer_set_value_stringify (field, value);
+
+ priv->original_value = strtol (value, NULL, 10);
return ret;
}
gboolean gtk_form_field_integer_is_empty (GtkFormField *field);
+gboolean gtk_form_field_integer_is_changed (GtkFormField *field);
+
gboolean gtk_form_field_integer_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
struct _GtkFormFieldTextPrivate
{
gchar *default_value;
+ gchar *original_value;
};
field_class->get_value_sql = gtk_form_field_text_get_value_sql;
field_class->clear = gtk_form_field_text_clear;
field_class->is_empty = gtk_form_field_text_is_empty;
+ field_class->is_changed = gtk_form_field_text_is_changed;
field_class->set_from_datamodel = gtk_form_field_text_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
/**
* gtk_form_field_text_get_value_stringify:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
/**
* gtk_form_field_text_get_value:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const GValue
/**
* gtk_form_field_text_get_value_sql:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
const gchar
/**
* gtk_form_field_text_clear:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
ret = gtk_form_field_text_set_value_stringify (field, priv->default_value);
+ priv->original_value = g_strdup (priv->default_value);
+
return ret;
}
/**
* gtk_form_field_text_is_empty:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
return ret;
}
+/**
+ * gtk_form_field_text_is_changed:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_text_is_changed (GtkFormField *field)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldTextPrivate *priv;
+ const gchar *value;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), FALSE);
+
+ priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (GTK_FORM_FIELD_TEXT (field));
+
+ value = gtk_form_field_text_get_value_stringify (field);
+
+ ret = (g_strcmp0 (priv->original_value, value) != 0);
+
+ return ret;
+}
+
/**
* gtk_form_field_text_set_from_datamodel:
- * @field:
- * @dm:
+ * @field: a #GtkFormField object.
+ * @dm: a #GdaDataModel object.
* @row:
*
*/
gtk_form_field_text_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
{
gboolean ret = FALSE;
- const gchar *field_name = gtk_form_field_get_field_name (field);
+ GtkFormFieldTextPrivate *priv;
+ gchar *strret;
+ const gchar *field_name;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), FALSE);
+ g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
+
+ priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (GTK_FORM_FIELD_TEXT (field));
- if (dm != NULL)
+ field_name = gtk_form_field_get_field_name (field);
+
+ strret = gdaex_data_model_get_field_value_stringify_at (dm, row, field_name);
+ if (strret == NULL)
{
- gchar *strret;
-
- strret = gdaex_data_model_get_field_value_stringify_at (dm, row, field_name);
- if (strret == NULL)
- {
- strret = g_strdup ("");
- }
- ret = gtk_form_field_text_set_value_stringify (field, strret);
+ strret = g_strdup ("");
}
+ ret = gtk_form_field_text_set_value_stringify (field, strret);
+
+ priv->original_value = g_strdup (strret);
return ret;
}
gboolean gtk_form_field_text_is_empty (GtkFormField *field);
+gboolean gtk_form_field_text_is_changed (GtkFormField *field);
+
gboolean gtk_form_field_text_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
gboolean
gtk_form_check (GtkForm *form)
{
+ GtkFormPrivate *priv;
+ GSList *fields;
GtkFormField *field;
+
gboolean ret = TRUE;
gboolean obl = FALSE;
g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
- GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ priv = GTK_FORM_GET_PRIVATE (form);
- GSList *fields = priv->fields;
+ fields = priv->fields;
while (fields != NULL)
{
return ret;
}
+/**
+ * gtk_form_is_changed:
+ * @form:
+ *
+ * Returns: TRUE if the values in the form are changed since last calling to
+ * gtk_form_clear() or gtk_form_fill_from_datamodel().
+ */
+gboolean
+gtk_form_is_changed (GtkForm *form)
+{
+ GtkFormPrivate *priv;
+ GSList *fields;
+ GtkFormField *field;
+
+ gboolean ret;
+
+ g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+ ret = FALSE;
+
+ priv = GTK_FORM_GET_PRIVATE (form);
+
+ fields = priv->fields;
+
+ while (fields != NULL)
+ {
+ field = (GtkFormField *)fields->data;
+
+ ret = gtk_form_field_is_changed (field);
+ if (ret) break;
+
+ fields = g_slist_next (fields);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_set_sensitive:
* @form: a #GtkForm object.
#include <glib.h>
#include <libxml/tree.h>
-
#include "field.h"
#include "widget.h"
#include "key.h"
gboolean gtk_form_check (GtkForm *form);
+gboolean gtk_form_is_changed (GtkForm *form);
+
void gtk_form_set_sensitive (GtkForm *form, gboolean sensitive);
void gtk_form_set_editable (GtkForm *form, gboolean editable);