return ret;
}
+/**
+ * gtk_form_field_set_as_origin:
+ * @field: a #GtkFormField object.
+ *
+ * Sets the original value of #GtkFormField to the current value.
+ */
+void
+gtk_form_field_set_as_origin (GtkFormField *field)
+{
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->set_as_origin != NULL)
+ {
+ GTK_FORM_FIELD_GET_CLASS (field)->set_as_origin (field);
+ }
+}
+
/**
* gtk_form_field_set_from_datamodel:
* @field: a #GtkFormField object.
gboolean (*clear) (GtkFormField *field);
gboolean (*is_empty) (GtkFormField *field);
gboolean (*is_changed) (GtkFormField *field);
+ void (*set_as_origin) (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);
+void gtk_form_field_set_as_origin (GtkFormField *field);
gboolean gtk_form_field_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
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_as_origin = gtk_form_field_boolean_set_as_origin;
field_class->set_from_datamodel = gtk_form_field_boolean_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_boolean_set_as_origin:
+ * @field: a #GtkFormField object.
+ *
+ */
+void
+gtk_form_field_boolean_set_as_origin (GtkFormField *field)
+{
+ GtkFormFieldBooleanPrivate *priv;
+ const gchar *value;
+
+ g_return_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field));
+
+ priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (GTK_FORM_FIELD_BOOLEAN (field));
+
+ value = gtk_form_field_boolean_get_value_stringify (field);
+
+ priv->original_value = gtk_form_field_boolean_str_to_boolean (value);
+}
+
/**
* gtk_form_field_boolean_set_from_datamodel:
* @field: a #GtkFormField object.
gboolean gtk_form_field_boolean_is_empty (GtkFormField *field);
gboolean gtk_form_filed_boolean_is_changed (GtkFormField *field);
+void gtk_form_field_boolean_set_as_origin (GtkFormField *field);
gboolean gtk_form_field_boolean_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
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_as_origin = gtk_form_field_datetime_set_as_origin;
field_class->set_from_datamodel = gtk_form_field_datetime_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
/**
* gtk_form_field_datetime_is_changed:
- * @field:
+ * @field: a #GtkFormField object.
*
*/
gboolean
return ret;
}
+/**
+ * gtk_form_field_datetime_set_as_origin:
+ * @field: a #GtkFormField object.
+ *
+ */
+void
+gtk_form_field_datetime_set_as_origin (GtkFormField *field)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldDateTimePrivate *priv;
+ struct tm *value;
+
+ g_return_if_fail (IS_GTK_FORM_FIELD_DATETIME (field));
+
+ 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));
+
+ priv->original_value = g_memdup (value, sizeof (struct tm));
+}
+
/**
* gtk_form_field_datetime_set_from_datamodel:
* @field: a #GtkFormField object.
gboolean gtk_form_field_datetime_is_empty (GtkFormField *field);
gboolean gtk_form_field_datetime_is_changed (GtkFormField *field);
+void gtk_form_field_datetime_set_as_origin (GtkFormField *field);
gboolean gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
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_as_origin = gtk_form_field_float_set_as_origin;
field_class->set_from_datamodel = gtk_form_field_float_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_float_set_as_origin:
+ * @field: a #GtkFormField object.
+ *
+ */
+void
+gtk_form_field_float_set_as_origin (GtkFormField *field)
+{
+ GtkFormFieldFloatPrivate *priv;
+
+ g_return_if_fail (IS_GTK_FORM_FIELD_FLOAT (field));
+
+ priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
+
+ priv->original_value = g_strtod (gtk_form_field_float_get_value_stringify (field), NULL);
+}
+
/**
* gtk_form_field_float_set_from_datamodel:
* @field: a #GtkFormField object.
gboolean gtk_form_field_float_is_empty (GtkFormField *field);
gboolean gtk_form_field_float_is_changed (GtkFormField *field);
+void gtk_form_field_float_set_as_origin (GtkFormField *field);
gboolean gtk_form_field_float_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
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_as_origin = gtk_form_field_integer_set_as_origin;
field_class->set_from_datamodel = gtk_form_field_integer_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_integer_set_as_origin:
+ * @field: a #GtkFormField object.
+ *
+ */
+void
+gtk_form_field_integer_set_as_origin (GtkFormField *field)
+{
+ GtkFormFieldIntegerPrivate *priv;
+
+ g_return_if_fail (IS_GTK_FORM_FIELD_INTEGER (field));
+
+ priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
+
+ priv->original_value = strtol (gtk_form_field_integer_get_value_stringify (field), NULL, 10);
+}
/**
* gtk_form_field_integer_set_from_datamodel:
* @field: a #GtkFormField object.
gboolean gtk_form_field_integer_is_empty (GtkFormField *field);
gboolean gtk_form_field_integer_is_changed (GtkFormField *field);
+void gtk_form_field_integer_set_as_origin (GtkFormField *field);
gboolean gtk_form_field_integer_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
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_as_origin = gtk_form_field_text_set_as_origin;
field_class->set_from_datamodel = gtk_form_field_text_set_from_datamodel;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_text_set_as_origin:
+ * @field: a #GtkFormField object.
+ *
+ */
+void
+gtk_form_field_text_set_as_origin (GtkFormField *field)
+{
+ GtkFormFieldTextPrivate *priv;
+
+ g_return_if_fail (IS_GTK_FORM_FIELD_TEXT (field));
+
+ priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (GTK_FORM_FIELD_TEXT (field));
+
+ priv->original_value = (gchar *)gtk_form_field_text_get_value_stringify (field);
+}
+
/**
* gtk_form_field_text_set_from_datamodel:
* @field: a #GtkFormField object.
gboolean gtk_form_field_text_is_empty (GtkFormField *field);
gboolean gtk_form_field_text_is_changed (GtkFormField *field);
+void gtk_form_field_text_set_as_origin (GtkFormField *field);
gboolean gtk_form_field_text_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
else
{
/* TO DO */
- g_warning ("The file is not a valid gtkform definition file");
+ g_warning ("The file is not a valid gtkform definition file.");
}
}
return ret;
}
+/**
+ * gtk_form_set_as_origin:
+ * @form: a #GtkForm object.
+ *
+ * Sets the original values of every #GtkForm #GtkFormField's to the currents
+ * values.
+ */
+void
+gtk_form_set_as_origin (GtkForm *form)
+{
+ GtkFormPrivate *priv;
+ GSList *fields;
+
+ g_return_if_fail (IS_GTK_FORM (form));
+
+ priv = GTK_FORM_GET_PRIVATE (form);
+
+ fields = priv->fields;
+ while (fields != NULL)
+ {
+ gtk_form_field_set_as_origin ((GtkFormField *)fields->data);
+
+ fields = g_slist_next (fields);
+ }
+}
+
/**
* gtk_form_set_sensitive:
* @form: a #GtkForm object.
void
gtk_form_set_sensitive (GtkForm *form, gboolean sensitive)
{
+ GtkFormPrivate *priv;
+ GSList *fields;
GtkFormWidget *fwidget;
- GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
GtkWidget *widget;
g_return_if_fail (IS_GTK_FORM (form));
- GSList *fields = priv->fields;
+ priv = GTK_FORM_GET_PRIVATE (form);
+
+ fields = priv->fields;
while (fields != NULL)
{
fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
gtk_form_set_editable (GtkForm *form, gboolean editable)
{
GtkFormWidget *fwidget;
- GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ GtkFormPrivate *priv;
+ GSList *fields;
g_return_if_fail (IS_GTK_FORM (form));
- GSList *fields = priv->fields;
+ priv = GTK_FORM_GET_PRIVATE (form);
+
+ fields = priv->fields;
while (fields != NULL)
{
fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
gchar
*gtk_form_get_sql (GtkForm *form, GtkFormSqlType type)
{
+ GtkFormPrivate *priv;
+ GSList *fields;
GtkFormField *field;
gchar *sql = "";
gchar *fields_names = "";
g_return_val_if_fail (IS_GTK_FORM (form), NULL);
- GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ priv = GTK_FORM_GET_PRIVATE (form);
- GSList *fields = priv->fields;
+ fields = priv->fields;
while (fields != NULL)
{
gboolean
gtk_form_fill_from_datamodel (GtkForm *form, GdaDataModel *dm, gint row)
{
+ GtkFormPrivate *priv;
+ GSList *fields;
gboolean ret = TRUE;
GtkFormField *field;
gchar *field_name;
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)
{
gboolean set_focus);
gboolean gtk_form_is_changed (GtkForm *form);
+void gtk_form_set_as_origin (GtkForm *form);
void gtk_form_set_sensitive (GtkForm *form, gboolean sensitive);
void gtk_form_set_sensitive_by_name (GtkForm *form, gboolean sensitive, ...);