]> saetta.ns0.it Git - libgtkform/commitdiff
Renamed directories to replicate includedir structure.
authorAndrea Zagli <azagli@libero.it>
Mon, 4 Jul 2011 14:16:45 +0000 (16:16 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 4 Jul 2011 14:16:45 +0000 (16:16 +0200)
113 files changed:
Makefile.am
autogen.sh
configure.ac
libgtkform/Makefile.am [new file with mode: 0644]
libgtkform/field.c [new file with mode: 0644]
libgtkform/field.h [new file with mode: 0644]
libgtkform/fieldboolean.c [new file with mode: 0644]
libgtkform/fieldboolean.h [new file with mode: 0644]
libgtkform/fielddatetime.c [new file with mode: 0644]
libgtkform/fielddatetime.h [new file with mode: 0644]
libgtkform/fieldfloat.c [new file with mode: 0644]
libgtkform/fieldfloat.h [new file with mode: 0644]
libgtkform/fieldinteger.c [new file with mode: 0644]
libgtkform/fieldinteger.h [new file with mode: 0644]
libgtkform/fieldtext.c [new file with mode: 0644]
libgtkform/fieldtext.h [new file with mode: 0644]
libgtkform/form.c [new file with mode: 0644]
libgtkform/form.h [new file with mode: 0644]
libgtkform/group.c [new file with mode: 0644]
libgtkform/group.h [new file with mode: 0644]
libgtkform/key.c [new file with mode: 0644]
libgtkform/key.h [new file with mode: 0644]
libgtkform/widget.c [new file with mode: 0644]
libgtkform/widget.h [new file with mode: 0644]
libgtkform/widgetcheck.c [new file with mode: 0644]
libgtkform/widgetcheck.h [new file with mode: 0644]
libgtkform/widgetcombobox.c [new file with mode: 0644]
libgtkform/widgetcombobox.h [new file with mode: 0644]
libgtkform/widgetentry.c [new file with mode: 0644]
libgtkform/widgetentry.h [new file with mode: 0644]
libgtkform/widgetlabel.c [new file with mode: 0644]
libgtkform/widgetlabel.h [new file with mode: 0644]
libgtkform/widgetradio.c [new file with mode: 0644]
libgtkform/widgetradio.h [new file with mode: 0644]
libgtkform/widgetspin.c [new file with mode: 0644]
libgtkform/widgetspin.h [new file with mode: 0644]
libgtkform/widgettextview.c [new file with mode: 0644]
libgtkform/widgettextview.h [new file with mode: 0644]
libgtkformui/Makefile.am [new file with mode: 0644]
libgtkformui/glade/Makefile.am [new file with mode: 0644]
libgtkformui/glade/gtkformui.xml [new file with mode: 0644]
libgtkformui/glade/icons/Makefile.am [new file with mode: 0644]
libgtkformui/glade/icons/hicolor/16x16/Makefile.am [new file with mode: 0644]
libgtkformui/glade/icons/hicolor/16x16/actions/Makefile.am [new file with mode: 0644]
libgtkformui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png [new file with mode: 0644]
libgtkformui/glade/icons/hicolor/22x22/Makefile.am [new file with mode: 0644]
libgtkformui/glade/icons/hicolor/22x22/actions/Makefile.am [new file with mode: 0644]
libgtkformui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png [new file with mode: 0644]
libgtkformui/glade/icons/hicolor/Makefile.am [new file with mode: 0644]
libgtkformui/gtkformdecoder.c [new file with mode: 0644]
libgtkformui/gtkformdecoder.h [new file with mode: 0644]
libgtkformui/gtkformwidgetdecoder.c [new file with mode: 0644]
libgtkformui/gtkformwidgetdecoder.h [new file with mode: 0644]
libgtkformui/test/Makefile.am [new file with mode: 0644]
libgtkformui/test/database.db [new file with mode: 0644]
libgtkformui/test/decoder.c [new file with mode: 0644]
src/Makefile.am [deleted file]
src/field.c [deleted file]
src/field.h [deleted file]
src/fieldboolean.c [deleted file]
src/fieldboolean.h [deleted file]
src/fielddatetime.c [deleted file]
src/fielddatetime.h [deleted file]
src/fieldfloat.c [deleted file]
src/fieldfloat.h [deleted file]
src/fieldinteger.c [deleted file]
src/fieldinteger.h [deleted file]
src/fieldtext.c [deleted file]
src/fieldtext.h [deleted file]
src/form.c [deleted file]
src/form.h [deleted file]
src/group.c [deleted file]
src/group.h [deleted file]
src/key.c [deleted file]
src/key.h [deleted file]
src/widget.c [deleted file]
src/widget.h [deleted file]
src/widgetcheck.c [deleted file]
src/widgetcheck.h [deleted file]
src/widgetcombobox.c [deleted file]
src/widgetcombobox.h [deleted file]
src/widgetentry.c [deleted file]
src/widgetentry.h [deleted file]
src/widgetlabel.c [deleted file]
src/widgetlabel.h [deleted file]
src/widgetradio.c [deleted file]
src/widgetradio.h [deleted file]
src/widgetspin.c [deleted file]
src/widgetspin.h [deleted file]
src/widgettextview.c [deleted file]
src/widgettextview.h [deleted file]
test/Makefile.am
test/from_xml.c
test/from_xml_with_db.c
test/main.c
ui/Makefile.am [deleted file]
ui/glade/Makefile.am [deleted file]
ui/glade/gtkformui.xml [deleted file]
ui/glade/icons/Makefile.am [deleted file]
ui/glade/icons/hicolor/16x16/Makefile.am [deleted file]
ui/glade/icons/hicolor/16x16/actions/Makefile.am [deleted file]
ui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png [deleted file]
ui/glade/icons/hicolor/22x22/Makefile.am [deleted file]
ui/glade/icons/hicolor/22x22/actions/Makefile.am [deleted file]
ui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png [deleted file]
ui/glade/icons/hicolor/Makefile.am [deleted file]
ui/gtkformdecoder.c [deleted file]
ui/gtkformdecoder.h [deleted file]
ui/gtkformwidgetdecoder.c [deleted file]
ui/gtkformwidgetdecoder.h [deleted file]
ui/test/Makefile.am [deleted file]
ui/test/database.db [deleted file]
ui/test/decoder.c [deleted file]

index 24f47f770a2b6709bc75dcd8cab11c5c57ebb133..011cb4d1e2a1f4d2a3d73fc5e01b724148806542 100644 (file)
@@ -1,6 +1,6 @@
 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
 
-SUBDIRS = po src ui test docs data
+SUBDIRS = po libgtkform libgtkformui test docs data
 
 ACLOCAL_AMFLAGS = -I m4
 
index aa4860499cd1a75d5ce87441014f8fbbf0a731a7..723b7b31de2b04202c3b1665801e61504a26a883 100755 (executable)
@@ -7,8 +7,8 @@ test -z "$srcdir" && srcdir=.
 PKG_NAME="libgtkform"
 
 (test -f $srcdir/configure.ac \
-  && test -d $srcdir/src \
-  && test -f $srcdir/src/form.h) || {
+  && test -d $srcdir/libgtkform \
+  && test -f $srcdir/libgtkform/form.h) || {
     echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
     echo " top-level libgtkform directory"
     exit 1
index d74cfe1543c82db1654c4b03a54cd5b9b3125635..c895c604e55cf7a5ce0dedd304d3f72fad429f9a 100644 (file)
@@ -3,7 +3,7 @@
 
 AC_PREREQ(2.59)
 AC_INIT([libgtkform], [0.3.1], [azagli@libero.it])
-AC_CONFIG_SRCDIR([src/form.c])
+AC_CONFIG_SRCDIR([libgtkform/form.c])
 AC_CONFIG_HEADER([config.h])
 
 AM_INIT_AUTOMAKE(-Wall)
@@ -85,9 +85,9 @@ AC_CONFIG_FILES([
   libgtkform.pc
   libgtkformui.pc
   Makefile
-  src/Makefile
-  ui/Makefile
-  ui/test/Makefile
+  libgtkform/Makefile
+  libgtkformui/Makefile
+  libgtkformui/test/Makefile
   test/Makefile
   docs/Makefile
   docs/reference/Makefile
@@ -98,13 +98,13 @@ AC_CONFIG_FILES([
 
 if test $GLADEUI_FOUND = yes; then
 AC_CONFIG_FILES([
-  ui/glade/Makefile
-  ui/glade/icons/Makefile
-  ui/glade/icons/hicolor/Makefile
-  ui/glade/icons/hicolor/16x16/Makefile
-  ui/glade/icons/hicolor/16x16/actions/Makefile
-  ui/glade/icons/hicolor/22x22/Makefile
-  ui/glade/icons/hicolor/22x22/actions/Makefile
+  libgtkformui/glade/Makefile
+  libgtkformui/glade/icons/Makefile
+  libgtkformui/glade/icons/hicolor/Makefile
+  libgtkformui/glade/icons/hicolor/16x16/Makefile
+  libgtkformui/glade/icons/hicolor/16x16/actions/Makefile
+  libgtkformui/glade/icons/hicolor/22x22/Makefile
+  libgtkformui/glade/icons/hicolor/22x22/actions/Makefile
 ])
 fi
 
diff --git a/libgtkform/Makefile.am b/libgtkform/Makefile.am
new file mode 100644 (file)
index 0000000..ea9eb53
--- /dev/null
@@ -0,0 +1,54 @@
+LIBS = $(GTKFORM_LIBS)
+
+AM_CPPFLAGS = $(GTKFORM_CFLAGS) \
+              -DLOCALEDIR=\"$(localedir)\" \
+              -DMODULESDIR=\""$(libdir)/$(PACKAGE)/modules"\" \
+              -DG_LOG_DOMAIN=\"GtkForm\"
+
+lib_LTLIBRARIES = libgtkform.la
+
+libgtkform_la_SOURCES = form.c \
+                     key.c \
+                     field.c \
+                     fieldboolean.c \
+                     fielddatetime.c \
+                     fieldfloat.c \
+                     fieldinteger.c \
+                     fieldtext.c \
+                     widget.c \
+                     widgetcheck.c \
+                     widgetcombobox.c \
+                     widgetentry.c \
+                     widgetlabel.c \
+                     widgetradio.c \
+                     widgetspin.c \
+                     widgettextview.c \
+                     group.c
+
+libgtkform_la_LDFLAGS = -no-undefined
+
+libgtkform_include_HEADERS = form.h \
+                  key.h \
+                  field.h \
+                  fieldboolean.h \
+                  fielddatetime.h \
+                  fieldfloat.h \
+                  fieldinteger.h \
+                  fieldtext.h \
+                  widget.h \
+                  widgetcheck.h \
+                  widgetcombobox.h \
+                  widgetentry.h \
+                  widgetlabel.h \
+                  widgetradio.h \
+                  widgetspin.h \
+                  widgettextview.h \
+                  group.h
+
+libgtkform_includedir = $(includedir)/libgtkform
+
+install-exec-hook:
+       mkdir -p "$(libdir)/$(PACKAGE)/modules"
+
+uninstall-hook:
+       rm -rf "$(libdir)/$(PACKAGE)"
diff --git a/libgtkform/field.c b/libgtkform/field.c
new file mode 100644 (file)
index 0000000..1b72ca8
--- /dev/null
@@ -0,0 +1,666 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "widget.h"
+#include "field.h"
+
+enum
+{
+       PROP_0,
+       PROP_FIELD,
+       PROP_LONG_NAME,
+       PROP_TO_LOAD,
+       PROP_TO_SAVE,
+       PROP_OBLIGATORY,
+       PROP_AUTO_INCREMENT,
+       PROP_DATAMODEL,
+       PROP_TRIM,
+       PROP_WIDGET,
+       PROP_MIN_VALUE,
+       PROP_MAX_VALUE
+};
+
+static void gtk_form_field_class_init (GtkFormFieldClass *klass);
+static void gtk_form_field_init (GtkFormField *gtk_form_field);
+
+static void gtk_form_field_set_property (GObject *object,
+                                     guint property_id,
+                                     const GValue *value,
+                                     GParamSpec *pspec);
+static void gtk_form_field_get_property (GObject *object,
+                                     guint property_id,
+                                     GValue *value,
+                                     GParamSpec *pspec);
+
+#define GTK_FORM_FIELD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD, GtkFormFieldPrivate))
+
+typedef struct _GtkFormFieldPrivate GtkFormFieldPrivate;
+struct _GtkFormFieldPrivate
+       {
+               gchar *field;
+               gchar *long_name;
+               gboolean is_key;
+               gboolean to_load;
+               gboolean to_save;
+               gboolean obligatory;
+               gboolean auto_increment;
+               gboolean trim;
+               gchar *min_value;
+               gchar *max_value;
+
+               GdaDataModel *dm;
+
+               GtkFormWidget *widget;
+       };
+
+
+G_DEFINE_TYPE (GtkFormField, gtk_form_field, G_TYPE_OBJECT)
+
+static void
+gtk_form_field_class_init (GtkFormFieldClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       object_class->set_property = gtk_form_field_set_property;
+       object_class->get_property = gtk_form_field_get_property;
+
+       klass->get_value_stringify = NULL;
+       klass->get_value = NULL;
+       klass->get_value_sql = NULL;
+
+       g_object_class_install_property (object_class, PROP_FIELD,
+                                        g_param_spec_string ("field",
+                                                             "Field's name",
+                                                             "Field's name",
+                                                             "",
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_LONG_NAME,
+                                        g_param_spec_string ("long-name",
+                                                             "Field's long name",
+                                                             "Field's long name",
+                                                             "",
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_TO_LOAD,
+                                        g_param_spec_boolean ("to-load",
+                                                              "Whether load the field or not",
+                                                              "Whether the field should be included or not on sql SELECT",
+                                                              TRUE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_TO_SAVE,
+                                        g_param_spec_boolean ("to-save",
+                                                              "Whether save the field or not",
+                                                              "Whether the field should be included or not on sql INSERT INTO and UPDATE",
+                                                              TRUE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_OBLIGATORY,
+                                        g_param_spec_boolean ("obligatory",
+                                                              "Obligatory",
+                                                              "Whether the field could be empty",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_AUTO_INCREMENT,
+                                        g_param_spec_boolean ("auto-increment",
+                                                              "Auto increment",
+                                                              "Whether the field auto increments (works only on  numeric fields)",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_TRIM,
+                                        g_param_spec_boolean ("trim",
+                                                              "Trim stringify value",
+                                                              "Whether to trim the field's stringify value",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_WIDGET,
+                                        g_param_spec_object ("form-widget",
+                                                             "GtkFormWidget",
+                                                             "The GtkFormWidget",
+                                                             TYPE_GTK_FORM_WIDGET,
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_MIN_VALUE,
+                                        g_param_spec_string ("min-value",
+                                                             "Minimun value",
+                                                             "The minimun value allowed for this field.",
+                                                             "",
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_MAX_VALUE,
+                                        g_param_spec_string ("max-value",
+                                                             "Maximun value",
+                                                             "The macimun value allowed for this field.",
+                                                             "",
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormFieldPrivate));
+}
+
+static void
+gtk_form_field_init (GtkFormField *gtk_form_field)
+{
+}
+
+/**
+ * gtk_form_field_new:
+ *
+ * Returns: the newly created #GtkFormField.
+ */
+GtkFormField
+*gtk_form_field_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_FIELD, NULL);
+}
+
+/**
+ * gtk_form_field_new_from_gtk_form_widget:
+ * @fwidget: a #GtkFormWidget object.
+ *
+ * Returns: the newly created #GtkFormField.
+ */
+GtkFormField
+*gtk_form_field_new_from_gtk_form_widget (GtkFormWidget *fwidget)
+{
+       GtkFormField *f = gtk_form_field_new ();
+
+       g_object_set (G_OBJECT (f),
+                     "form-widget", fwidget,
+                     NULL);
+
+       return f;
+}
+
+/**
+ * gtk_form_field_get_field_name:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: the field's name.
+ */
+gchar
+*gtk_form_field_get_field_name (GtkFormField *field)
+{
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       return g_strdup (priv->field);
+}
+
+/**
+ * gtk_form_field_get_field_long_name:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: the field's long name.
+ */
+gchar
+*gtk_form_field_get_field_long_name (GtkFormField *field)
+{
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       return g_strdup (priv->long_name);
+}
+
+/**
+ * gtk_form_field_get_form_widget:
+ * @field: a #GtkFormField object.
+ *
+ * Return: the associated #GtkFormWidget.
+ */
+GtkFormWidget
+*gtk_form_field_get_form_widget (GtkFormField *field)
+{
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       return (GtkFormWidget *)priv->widget;
+}
+
+/**
+ * gtk_form_field_get_value_stringify:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_get_value_stringify (GtkFormField *field)
+{
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       gchar *ret;
+
+       ret = g_strdup ("");
+
+       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);
+                       if (priv->trim)
+                               {
+                                       ret = g_strstrip (ret);
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_get_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_get_value (GtkFormField *field)
+{
+       GValue *ret;
+
+       ret = NULL;
+
+       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);
+                       if (G_VALUE_HOLDS_STRING (ret))
+                               {
+                                       g_value_set_string (ret, g_strstrip (g_strdup (g_value_get_string (ret))));
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_get_value_sql:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_get_value_sql (GtkFormField *field)
+{
+       gchar *ret;
+
+       ret = g_strdup ("");
+
+       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_get_origin_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_get_original_value (GtkFormField *field)
+{
+       GValue *ret;
+
+       ret = NULL;
+
+       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->get_original_value != NULL)
+               {
+                       ret = GTK_FORM_FIELD_GET_CLASS (field)->get_original_value (field);
+                       if (G_VALUE_HOLDS_STRING (ret))
+                               {
+                                       g_value_set_string (ret, g_strstrip (g_strdup (g_value_get_string (ret))));
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_clear:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_clear (GtkFormField *field)
+{
+       gboolean ret;
+
+       ret = FALSE;
+
+       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_to_load:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_is_to_load (GtkFormField *field)
+{
+       GtkFormFieldPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       return priv->to_load;
+}
+
+/**
+ * gtk_form_field_is_to_save:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_is_to_save (GtkFormField *field)
+{
+       GtkFormFieldPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       return priv->to_save;
+}
+
+/**
+ * gtk_form_field_is_auto_increment:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_is_auto_increment (GtkFormField *field)
+{
+       GtkFormFieldPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       return priv->auto_increment;
+}
+
+/**
+ * gtk_form_field_is_empty:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: TRUE if the field is empty.
+ */
+gboolean
+gtk_form_field_is_empty (GtkFormField *field)
+{
+       gboolean ret = TRUE;
+
+       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_valid:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: TRUE if the field is valid.
+ */
+gboolean
+gtk_form_field_is_valid (GtkFormField *field)
+{
+       gboolean ret = TRUE;
+
+       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->is_valid != NULL)
+               {
+                       ret = GTK_FORM_FIELD_GET_CLASS (field)->is_valid (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(), gtk_form_field_set_from_datamodel() or
+ * gtk_form_field_set_as_origin().
+ */
+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_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.
+ * @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);
+
+       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)
+               {
+                       ret = GTK_FORM_FIELD_GET_CLASS (field)->set_from_datamodel (field, dm, row);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_set_from_hashtable:
+ * @field: a #GtkFormField object.
+ * @hashtable: a #GHashTable object.
+ *
+ */
+gboolean
+gtk_form_field_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
+{
+       gboolean ret = FALSE;
+
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->set_from_hashtable != NULL)
+               {
+                       ret = GTK_FORM_FIELD_GET_CLASS (field)->set_from_hashtable (field, hashtable);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_set_value:
+ * @field: a #GtkFormField object.
+ * @gvalue: a #GValue.
+ *
+ */
+gboolean
+gtk_form_field_set_value (GtkFormField *field, GValue *gvalue)
+{
+       gboolean ret = FALSE;
+
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->set_value != NULL)
+               {
+                       ret = GTK_FORM_FIELD_GET_CLASS (field)->set_value (field, gvalue);
+               }
+
+       return ret;
+}
+
+/* PRIVATE */
+static void
+gtk_form_field_set_property (GObject *object,
+                         guint property_id,
+                         const GValue *value,
+                         GParamSpec *pspec)
+{
+       GtkFormField *field = (GtkFormField *)object;
+
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_FIELD:
+                               priv->field = g_strstrip (g_value_dup_string (value));
+                               break;
+
+                       case PROP_LONG_NAME:
+                               priv->long_name = g_strstrip (g_value_dup_string (value));
+                               break;
+
+                       case PROP_TO_LOAD:
+                               priv->to_load = g_value_get_boolean (value);
+                               break;
+
+                       case PROP_TO_SAVE:
+                               priv->to_save = g_value_get_boolean (value);
+                               break;
+
+                       case PROP_OBLIGATORY:
+                               priv->obligatory = g_value_get_boolean (value);
+                               break;
+
+                       case PROP_AUTO_INCREMENT:
+                               priv->auto_increment = g_value_get_boolean (value);
+                               break;
+
+                       case PROP_DATAMODEL:
+                               priv->dm = g_value_get_pointer (value);
+                               break;
+
+                       case PROP_TRIM:
+                               priv->trim = g_value_get_boolean (value);
+                               break;
+
+                       case PROP_WIDGET:
+                               priv->widget = g_value_get_object (value);
+                               g_object_set (G_OBJECT (priv->widget), "field", field, NULL);
+                               break;
+
+                       case PROP_MIN_VALUE:
+                               priv->min_value = g_strstrip (g_value_dup_string (value));
+                               break;
+
+                       case PROP_MAX_VALUE:
+                               priv->max_value = g_strstrip (g_value_dup_string (value));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gtk_form_field_get_property (GObject *object,
+                         guint property_id,
+                         GValue *value,
+                         GParamSpec *pspec)
+{
+       GtkFormField *field = (GtkFormField *)object;
+
+       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_FIELD:
+                               g_value_set_string (value, gtk_form_field_get_field_name (field));
+                               break;
+
+                       case PROP_LONG_NAME:
+                               g_value_set_string (value, gtk_form_field_get_field_long_name (field));
+                               break;
+
+                       case PROP_TO_LOAD:
+                               g_value_set_boolean (value, priv->to_load);
+                               break;
+
+                       case PROP_TO_SAVE:
+                               g_value_set_boolean (value, priv->to_save);
+                               break;
+
+                       case PROP_OBLIGATORY:
+                               g_value_set_boolean (value, priv->obligatory);
+                               break;
+
+                       case PROP_AUTO_INCREMENT:
+                               g_value_set_boolean (value, priv->auto_increment);
+                               break;
+
+                       case PROP_DATAMODEL:
+                               g_value_set_pointer (value, priv->dm);
+                               break;
+
+                       case PROP_TRIM:
+                               g_value_set_boolean (value, priv->trim);
+                               break;
+
+                       case PROP_WIDGET:
+                               g_value_set_object (value, priv->widget);
+                               break;
+
+                       case PROP_MIN_VALUE:
+                               g_value_set_string (value, g_strdup (priv->min_value));
+                               break;
+
+                       case PROP_MAX_VALUE:
+                               g_value_set_string (value, g_strdup (priv->max_value));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
diff --git a/libgtkform/field.h b/libgtkform/field.h
new file mode 100644 (file)
index 0000000..1e6f68d
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_FIELD_H__
+#define __LIBGTK_FORM_FIELD_H__
+
+#include <glib.h>
+
+#include <libgdaex/libgdaex.h>
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_FIELD                 (gtk_form_field_get_type ())
+#define GTK_FORM_FIELD(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD, GtkFormField))
+#define GTK_FORM_FIELD_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD, GtkFormFieldClass))
+#define IS_GTK_FORM_FIELD(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD))
+#define IS_GTK_FORM_FIELD_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD))
+#define GTK_FORM_FIELD_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD, GtkFormFieldClass))
+
+
+typedef struct _GtkFormField GtkFormField;
+typedef struct _GtkFormFieldClass GtkFormFieldClass;
+
+struct _GtkFormField
+       {
+               GObject parent;
+       };
+
+struct _GtkFormFieldClass
+       {
+               GObjectClass parent_class;
+
+               gchar *(*get_value_stringify) (GtkFormField *field);
+               GValue *(*get_value) (GtkFormField *field);
+               gchar *(*get_value_sql) (GtkFormField *field);
+               GValue *(*get_original_value) (GtkFormField *field);
+
+               gboolean (*clear) (GtkFormField *field);
+               gboolean (*is_empty) (GtkFormField *field);
+               gboolean (*is_changed) (GtkFormField *field);
+               gboolean (*is_valid) (GtkFormField *field);
+               void (*set_as_origin) (GtkFormField *field);
+               gboolean (*set_from_datamodel) (GtkFormField *field, GdaDataModel *dm, gint row);
+               gboolean (*set_from_hashtable) (GtkFormField *field, GHashTable *hashtable);
+               gboolean (*set_value) (GtkFormField *field, GValue *gvalue);
+       };
+
+GType gtk_form_field_get_type (void) G_GNUC_CONST;
+
+GtkFormField *gtk_form_field_new (void);
+GtkFormField *gtk_form_field_new_from_gtk_form_widget (GtkFormWidget *fwidget);
+
+gchar *gtk_form_field_get_field_name (GtkFormField *field);
+gchar *gtk_form_field_get_field_long_name (GtkFormField *field);
+
+GtkFormWidget *gtk_form_field_get_form_widget (GtkFormField *field);
+
+gchar *gtk_form_field_get_value_stringify (GtkFormField *field);
+GValue *gtk_form_field_get_value (GtkFormField *field);
+gchar *gtk_form_field_get_value_sql (GtkFormField *field);
+GValue *gtk_form_field_get_original_value (GtkFormField *field);
+
+gboolean gtk_form_field_clear (GtkFormField *field);
+
+gboolean gtk_form_field_is_to_load (GtkFormField *field);
+gboolean gtk_form_field_is_to_save (GtkFormField *field);
+
+gboolean gtk_form_field_is_auto_increment (GtkFormField *field);
+
+gboolean gtk_form_field_is_empty (GtkFormField *field);
+
+gboolean gtk_form_field_is_valid (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);
+gboolean gtk_form_field_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
+gboolean gtk_form_field_set_value (GtkFormField *field, GValue *gvalue);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_FIELD_H__ */
diff --git a/libgtkform/fieldboolean.c b/libgtkform/fieldboolean.c
new file mode 100644 (file)
index 0000000..d38d706
--- /dev/null
@@ -0,0 +1,538 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <string.h>
+
+#include <glib/gi18n-lib.h>
+
+#include "widget.h"
+#include "fieldboolean.h"
+
+enum
+{
+       PROP_0,
+       PROP_DEFAULT
+};
+
+static void gtk_form_field_boolean_class_init (GtkFormFieldBooleanClass *klass);
+static void gtk_form_field_boolean_init (GtkFormFieldBoolean *gtk_form_field);
+
+static void gtk_form_field_boolean_set_property (GObject *object,
+                                             guint property_id,
+                                             const GValue *value,
+                                             GParamSpec *pspec);
+static void gtk_form_field_boolean_get_property (GObject *object,
+                                             guint property_id,
+                                             GValue *value,
+                                             GParamSpec *pspec);
+
+static gboolean gtk_form_field_boolean_set_value_stringify (GtkFormField *field, const gchar *value);
+
+#define GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBooleanPrivate))
+
+typedef struct _GtkFormFieldBooleanPrivate GtkFormFieldBooleanPrivate;
+struct _GtkFormFieldBooleanPrivate
+       {
+               gboolean default_value;
+               gboolean original_value;
+       };
+
+
+G_DEFINE_TYPE (GtkFormFieldBoolean, gtk_form_field_boolean, TYPE_GTK_FORM_FIELD)
+
+static void
+gtk_form_field_boolean_class_init (GtkFormFieldBooleanClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
+
+       object_class->set_property = gtk_form_field_boolean_set_property;
+       object_class->get_property = gtk_form_field_boolean_get_property;
+
+       field_class->get_value_stringify = gtk_form_field_boolean_get_value_stringify;
+       field_class->get_value = gtk_form_field_boolean_get_value;
+       field_class->get_value_sql = gtk_form_field_boolean_get_value_sql;
+       field_class->get_original_value = gtk_form_field_boolean_get_original_value;
+       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;
+       field_class->set_from_hashtable = gtk_form_field_boolean_set_from_hashtable;
+       field_class->set_value = gtk_form_field_boolean_set_value;
+
+       g_object_class_install_property (object_class, PROP_DEFAULT,
+                                        g_param_spec_boolean ("default",
+                                                              "Default",
+                                                              "Default value",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormFieldBooleanPrivate));
+}
+
+static void
+gtk_form_field_boolean_init (GtkFormFieldBoolean *gtk_form_field)
+{
+}
+
+/**
+ * gtk_form_field_boolean_new:
+ *
+ * Returns: the newly created #GtkFormFieldBoolean.
+ */
+GtkFormField
+*gtk_form_field_boolean_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_FIELD_BOOLEAN, NULL);
+}
+
+/**
+ * gtk_form_field_boolean_get_value_stringify:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_boolean_get_value_stringify (GtkFormField *field)
+{
+       gchar *ret;
+       GtkFormWidget *fw;
+
+       ret = g_strdup ("");
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), ret);
+               
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       if (IS_GTK_FORM_WIDGET (fw))
+               {
+                       ret = gtk_form_widget_get_value_stringify (fw);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_get_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_boolean_get_value (GtkFormField *field)
+{
+       GValue *ret;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), NULL);
+
+       ret = NULL;
+
+       value = gtk_form_field_boolean_get_value_stringify (field);
+
+       if (value != NULL)
+               {
+                       ret = g_malloc0 (sizeof (GValue));
+                       g_value_init (ret, G_TYPE_BOOLEAN);
+                       g_value_set_boolean (ret, gtk_form_field_boolean_str_to_boolean (value));
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_get_value_sql:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_boolean_get_value_sql (GtkFormField *field)
+{
+       gchar *ret;
+       gchar *value;
+
+       ret = g_strdup ("");
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), ret);
+
+       value = gtk_form_field_boolean_get_value_stringify (field);
+
+       if (value != NULL)
+               {
+                       gboolean bool_value;
+
+                       bool_value = gtk_form_field_boolean_str_to_boolean (value);
+
+                       ret = g_strconcat ("'", (bool_value ? "1" : "0"), "'", NULL);
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_get_original_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_boolean_get_original_value (GtkFormField *field)
+{
+       GValue *ret;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), NULL);
+
+       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
+
+       ret = NULL;
+
+       ret = g_malloc0 (sizeof (GValue));
+       g_value_init (ret, G_TYPE_BOOLEAN);
+       g_value_set_boolean (ret, priv->original_value
+       );
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_clear:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_boolean_clear (GtkFormField *field)
+{
+       gboolean ret = FALSE;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
+
+       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
+
+       ret = gtk_form_field_boolean_set_value_stringify (field, g_strdup_printf ("%d", priv->default_value));
+
+       priv->original_value = priv->default_value;
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_is_empty:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_boolean_is_empty (GtkFormField *field)
+{
+       gboolean ret;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), TRUE);
+
+       ret = FALSE;
+
+       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;
+       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));
+
+       g_free (value);
+
+       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;
+       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);
+
+       g_free (value);
+}
+
+/**
+ * gtk_form_field_boolean_set_from_datamodel:
+ * @field: a #GtkFormField object.
+ * @dm: a #GdaDataModel object.
+ * @row:
+ *
+ */
+gboolean
+gtk_form_field_boolean_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldBooleanPrivate *priv;
+       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 (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+               {
+                       priv->original_value = gdaex_data_model_get_field_value_boolean_at (dm, row, field_name);
+                       if (priv->original_value)
+                               {
+                                       value = g_strdup_printf ("TRUE");
+                               }
+                       else
+                               {
+                                       value = g_strdup_printf ("FALSE");
+                               }
+                       ret = gtk_form_field_boolean_set_value_stringify (field, value);
+               }
+       else
+               {
+                       g_warning (_("GtkFormField hasn't a field name."));
+               }
+
+       g_free (field_name);
+       g_free (value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_set_from_hashtable:
+ * @field: a #GtkFormField object.
+ * @hashtable: a #GHashTable object.
+ *
+ */
+gboolean
+gtk_form_field_boolean_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldBooleanPrivate *priv;
+       gchar *field_name;
+       GValue *gval;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (GTK_FORM_FIELD_BOOLEAN (field));
+
+       field_name = gtk_form_field_get_field_name (field);
+       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+               {
+                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
+                       if (gval == NULL)
+                               {
+                                       priv->original_value = FALSE;
+                                       ret = gtk_form_field_boolean_set_value_stringify (field, "FALSE");
+                               }
+                       else
+                               {
+                                       priv->original_value = g_value_get_boolean (gval);
+                                       if (priv->original_value)
+                                               {
+                                                       value = g_strdup_printf ("TRUE");
+                                               }
+                                       else
+                                               {
+                                                       value = g_strdup_printf ("FALSE");
+                                               }
+                                       ret = gtk_form_field_boolean_set_value_stringify (field, value);
+                               }
+               }
+       else
+               {
+                       g_warning (_("GtkFormField hasn't a field name."));
+               }
+
+       g_free (field_name);
+       g_free (value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_set_value:
+ * @field: a #GtkFormField object.
+ * @gvalue: a #GValue.
+ *
+ */
+gboolean
+gtk_form_field_boolean_set_value (GtkFormField *field, GValue *gvalue)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldBooleanPrivate *priv;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
+       g_return_val_if_fail (G_VALUE_HOLDS_BOOLEAN (gvalue), FALSE);
+
+       priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (GTK_FORM_FIELD_BOOLEAN (field));
+
+       priv->original_value = g_value_get_boolean (gvalue);
+       if (priv->original_value)
+               {
+                       value = g_strdup_printf ("TRUE");
+               }
+       else
+               {
+                       value = g_strdup_printf ("FALSE");
+               }
+       ret = gtk_form_field_boolean_set_value_stringify (field, value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_boolean_str_to_boolean:
+ * @value:
+ *
+ * Utility function to convert a string to its #gboolean equivalent.
+ *
+ * Returns: the #gboolean equivalent from @value.
+ */
+gboolean
+gtk_form_field_boolean_str_to_boolean (const gchar *value)
+{
+       gchar *str_value;
+       gboolean bool_value = FALSE;
+
+       if (value == NULL)
+               {
+                       return bool_value;
+               }
+
+       str_value = g_strstrip (g_strdup (value));
+
+       if (strcmp (str_value, "0") == 0
+                       || strcasecmp (str_value, "f") == 0
+                       || strcasecmp (str_value, "false") == 0
+                       || strcasecmp (str_value, "n") == 0
+                       || strcasecmp (str_value, "no") == 0)
+               {
+                       bool_value = FALSE;
+               }
+       else if (strcmp (str_value, "1") == 0
+                       || strcasecmp (str_value, "t") == 0
+                       || strcasecmp (str_value, "true") == 0
+                       || strcasecmp (str_value, "y") == 0
+                       || strcasecmp (str_value, "yes") == 0)
+               {
+                       bool_value = TRUE;
+               }
+
+       g_free (str_value);
+
+       return bool_value;
+}
+
+/* PRIVATE */
+static void
+gtk_form_field_boolean_set_property (GObject *object,
+                                 guint property_id,
+                                 const GValue *value,
+                                 GParamSpec *pspec)
+{
+       GtkFormFieldBoolean *field = (GtkFormFieldBoolean *)object;
+
+       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               priv->default_value = g_value_get_boolean (value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_field_boolean_get_property (GObject *object,
+                                 guint property_id,
+                                 GValue *value,
+                                 GParamSpec *pspec)
+{
+       GtkFormFieldBoolean *field = (GtkFormFieldBoolean *)object;
+
+       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               g_value_set_boolean (value, priv->default_value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static gboolean
+gtk_form_field_boolean_set_value_stringify (GtkFormField *field, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkFormWidget *fw;
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       ret = gtk_form_widget_set_value_stringify (fw, value);
+
+       return ret;
+}
diff --git a/libgtkform/fieldboolean.h b/libgtkform/fieldboolean.h
new file mode 100644 (file)
index 0000000..84ca860
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_FIELD_BOOLEAN_H__
+#define __LIBGTK_FORM_FIELD_BOOLEAN_H__
+
+#include "field.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_FIELD_BOOLEAN                 (gtk_form_field_boolean_get_type ())
+#define GTK_FORM_FIELD_BOOLEAN(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBoolean))
+#define GTK_FORM_FIELD_BOOLEAN_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBooleanClass))
+#define IS_GTK_FORM_FIELD_BOOLEAN(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN))
+#define IS_GTK_FORM_FIELD_BOOLEAN_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_BOOLEAN))
+#define GTK_FORM_FIELD_BOOLEAN_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBooleanClass))
+
+
+typedef struct _GtkFormFieldBoolean GtkFormFieldBoolean;
+typedef struct _GtkFormFieldBooleanClass GtkFormFieldBooleanClass;
+
+struct _GtkFormFieldBoolean
+       {
+               GtkFormField parent;
+       };
+
+struct _GtkFormFieldBooleanClass
+       {
+               GtkFormFieldClass parent_class;
+       };
+
+GType gtk_form_field_boolean_get_type (void) G_GNUC_CONST;
+
+GtkFormField *gtk_form_field_boolean_new (void);
+
+gchar *gtk_form_field_boolean_get_value_stringify (GtkFormField *field);
+GValue *gtk_form_field_boolean_get_value (GtkFormField *field);
+gchar *gtk_form_field_boolean_get_value_sql (GtkFormField *field);
+GValue *gtk_form_field_boolean_get_original_value (GtkFormField *field);
+
+gboolean gtk_form_field_boolean_clear (GtkFormField *field);
+
+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);
+gboolean gtk_form_field_boolean_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
+gboolean gtk_form_field_boolean_set_value (GtkFormField *field, GValue *gvalue);
+
+gboolean gtk_form_field_boolean_str_to_boolean (const gchar *value);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_FIELD_BOOLEAN_H__ */
diff --git a/libgtkform/fielddatetime.c b/libgtkform/fielddatetime.c
new file mode 100644 (file)
index 0000000..9c75802
--- /dev/null
@@ -0,0 +1,1050 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib/gi18n-lib.h>
+
+#include "widget.h"
+#include "fielddatetime.h"
+
+enum
+{
+       PROP_0,
+       PROP_DEFAULT,
+       PROP_TYPE,
+       PROP_DISPLAY_FORMAT
+};
+
+static void gtk_form_field_datetime_class_init (GtkFormFieldDateTimeClass *klass);
+static void gtk_form_field_datetime_init (GtkFormFieldDateTime *gtk_form_field);
+
+static void gtk_form_field_datetime_set_property (GObject *object,
+                                              guint property_id,
+                                              const GValue *value,
+                                              GParamSpec *pspec);
+static void gtk_form_field_datetime_get_property (GObject *object,
+                                              guint property_id,
+                                              GValue *value,
+                                              GParamSpec *pspec);
+
+static gboolean gtk_form_field_datetime_set_value_stringify (GtkFormField *field, const gchar *value);
+
+static gchar *gtk_form_field_datetime_get_str_format (GtkFormFieldDateTime *field);
+
+static gchar *gtk_form_field_datetime_str_replace (const gchar *string,
+                                      const gchar *origin,
+                                      const gchar *replace);
+
+static gboolean gtk_form_field_datetime_is_valid_datetime (GtkFormFieldDateTime *field);
+
+#define GTK_FORM_FIELD_DATETIME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTimePrivate))
+
+typedef struct _GtkFormFieldDateTimePrivate GtkFormFieldDateTimePrivate;
+struct _GtkFormFieldDateTimePrivate
+       {
+               struct tm *default_value;
+               struct tm *original_value;
+
+               gint type;
+
+               gchar *display_format;
+       };
+
+
+G_DEFINE_TYPE (GtkFormFieldDateTime, gtk_form_field_datetime, TYPE_GTK_FORM_FIELD)
+
+static void
+gtk_form_field_datetime_class_init (GtkFormFieldDateTimeClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
+
+       object_class->set_property = gtk_form_field_datetime_set_property;
+       object_class->get_property = gtk_form_field_datetime_get_property;
+
+       field_class->get_value_stringify = gtk_form_field_datetime_get_value_stringify;
+       field_class->get_value = gtk_form_field_datetime_get_value;
+       field_class->get_value_sql = gtk_form_field_datetime_get_value_sql;
+       field_class->get_original_value = gtk_form_field_datetime_get_original_value;
+       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->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;
+
+       g_object_class_install_property (object_class, PROP_DEFAULT,
+                                        g_param_spec_pointer ("default",
+                                                              "Default",
+                                                              "Default value",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_TYPE,
+                                        g_param_spec_int ("type",
+                                                          "Type",
+                                                          "Type",
+                                                          G_MININT,
+                                                          G_MAXINT,
+                                                          GTK_FORM_FIELD_DATETIME_TYPE_DATETIME,
+                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_DISPLAY_FORMAT,
+                                        g_param_spec_string ("display-format",
+                                                             "Display format",
+                                                             "Display format",
+                                                             "%Y-%m-%d %H:%M:%S",
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormFieldDateTimePrivate));
+}
+
+static void
+gtk_form_field_datetime_init (GtkFormFieldDateTime *gtk_form_field)
+{
+       GtkFormFieldDateTimePrivate *priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (gtk_form_field);
+
+       priv->default_value = NULL;
+       priv->original_value = NULL;
+}
+
+/**
+ * gtk_form_field_datetime_new:
+ *
+ * Returns: the newly created #GtkFormFieldDateTime.
+ */
+GtkFormField
+*gtk_form_field_datetime_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_FIELD_DATETIME, NULL);
+}
+
+/**
+ * gtk_form_field_datetime_get_value_stringify:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_datetime_get_value_stringify (GtkFormField *field)
+{
+       gchar *ret;
+       GtkFormWidget *fw;
+
+       ret = g_strdup ("");
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), ret);
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       if (IS_GTK_FORM_WIDGET (fw))
+               {
+                       ret = gtk_form_widget_get_value_stringify (fw);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_value:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: a #GValue of type G_TYPE_POINTER that point to a struct tm.
+ */
+GValue
+*gtk_form_field_datetime_get_value (GtkFormField *field)
+{
+       struct tm *datetime;
+       GValue *ret;
+       gchar *value;
+       GtkFormFieldDateTimePrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), NULL);
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+       ret = NULL;
+
+       value = gtk_form_field_datetime_get_value_stringify (field);
+
+       datetime = gtk_form_field_datetime_get_tm_from_str (value, priv->display_format);
+       if (value != NULL && datetime != NULL)
+               {
+                       ret = g_malloc0 (sizeof (GValue));
+                       g_value_init (ret, G_TYPE_POINTER);
+                       g_value_set_pointer (ret, datetime);
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_value_sql:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_datetime_get_value_sql (GtkFormField *field)
+{
+       gchar *ret;
+       gchar *value;
+       gchar *format;
+       GtkFormFieldDateTimePrivate *priv;
+
+       ret = g_strdup ("NULL");
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), ret);
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+       value = gtk_form_field_datetime_get_value_stringify (field);
+       format = gtk_form_field_datetime_get_str_format (GTK_FORM_FIELD_DATETIME (field));
+
+       if (value != NULL && format != NULL)
+               {
+                       struct tm *datetime;
+
+                       datetime = gtk_form_field_datetime_get_tm_from_str (value, priv->display_format);
+                       if (datetime != NULL)
+                               {
+                                       gchar *dvalue;
+
+                                       dvalue = gtk_form_field_datetime_get_str_from_tm (datetime, format);
+                                       if (dvalue != NULL)
+                                               {
+                                                       ret = g_strconcat ("'", dvalue, "'", NULL);
+
+                                                       g_free (dvalue);
+                                               }
+                               }
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_original_value:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: a #GValue of type G_TYPE_POINTER that point to a struct tm.
+ */
+GValue
+*gtk_form_field_datetime_get_original_value (GtkFormField *field)
+{
+       GValue *ret;
+       GtkFormFieldDateTimePrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), NULL);
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+       ret = NULL;
+
+       ret = g_malloc0 (sizeof (GValue));
+       g_value_init (ret, G_TYPE_POINTER);
+       g_value_set_pointer (ret, g_memdup (priv->original_value, sizeof (struct tm)));
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_clear:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_datetime_clear (GtkFormField *field)
+{
+       gboolean ret;
+       GtkFormFieldDateTimePrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
+       ret = FALSE;
+
+       if (priv->default_value != NULL)
+               {
+                       gchar *value;
+
+                       value = gtk_form_field_datetime_get_str_from_tm (priv->default_value, priv->display_format);
+                       if (value != NULL)
+                               {
+                                       ret = gtk_form_field_datetime_set_value_stringify (field, value);
+
+                                       g_free (value);
+                               }
+               }
+       else
+               {
+                       ret = gtk_form_field_datetime_set_value_stringify (field, "");
+               }
+
+       priv->original_value = g_memdup (priv->default_value, sizeof (struct tm));
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_is_empty:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_datetime_is_empty (GtkFormField *field)
+{
+       gboolean ret;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), TRUE);
+
+       return !gtk_form_field_datetime_is_valid_datetime (GTK_FORM_FIELD_DATETIME (field));
+}
+
+/**
+ * gtk_form_field_datetime_is_changed:
+ * @field: a #GtkFormField object.
+ *
+ */
+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),
+                                                        priv->display_format);
+
+       if (value != NULL && priv->original_value != NULL)
+               {
+                       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);
+                       if (!ret && priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATETIME)
+                               {
+                                       ret = (value->tm_hour != priv->original_value->tm_hour
+                                              || value->tm_min != priv->original_value->tm_min
+                                              || value->tm_sec != priv->original_value->tm_sec);
+                               }
+               }
+       else if ((value == NULL || priv->original_value == NULL)
+                && !(value == NULL && priv->original_value == NULL))
+               {
+                       ret = TRUE;
+               }
+
+       g_free (value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_is_valid:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_datetime_is_valid (GtkFormField *field)
+{
+       gboolean ret;
+
+       GtkFormFieldDateTimePrivate *priv;
+
+       struct tm *tm_value;
+
+       gchar *min_value;
+       struct tm *tm_min_value;
+       gchar *max_value;
+       struct tm *tm_max_value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
+
+       ret = TRUE;
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+       tm_value = gtk_form_field_datetime_get_tm_from_str (gtk_form_field_datetime_get_value_stringify (field), priv->display_format);
+
+       if (tm_value != 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)
+                               {
+                                       if (g_strcasecmp (min_value, "now") == 0)
+                                               {
+                                                       time_t tt;
+                                                       tt = time (NULL);
+
+                                                       tm_min_value = g_memdup (localtime (&tt), sizeof (struct tm));
+
+                                                       if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
+                                                               {
+                                                                       tm_min_value->tm_hour = 0;
+                                                                       tm_min_value->tm_min = 0;
+                                                                       tm_min_value->tm_sec = 0;
+                                                               }
+                                                       else if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_TIME)
+                                                               {
+                                                                       tm_min_value->tm_year = 0;
+                                                                       tm_min_value->tm_mon = 0;
+                                                                       tm_min_value->tm_mday = 0;
+                                                               }
+                                               }
+                                       else
+                                               {
+                                                       tm_min_value = gtk_form_field_datetime_get_tm_from_str (min_value,
+                                                              gtk_form_field_datetime_get_str_format (GTK_FORM_FIELD_DATETIME (field)));
+                                               }
+
+                                       if (tm_min_value != NULL)
+                                               {
+                                                       time_t tt_min_value;
+                                                       time_t tt_value;
+
+                                                       tt_min_value = mktime (tm_min_value);
+                                                       tt_value = mktime (tm_value);
+
+                                                       ret = (difftime (tt_min_value, tt_value) <= 0);
+
+                                                       g_free (tm_min_value);
+                                               }
+                               }
+
+                       if (ret
+                           && max_value != NULL
+                           && g_strcmp0 (max_value, "") != 0)
+                               {
+                                       if (g_strcasecmp (max_value, "now") == 0)
+                                               {
+                                                       time_t tt;
+                                                       tt = time (NULL);
+
+                                                       tm_max_value = g_memdup (localtime (&tt), sizeof (struct tm));
+
+                                                       if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
+                                                               {
+                                                                       tm_max_value->tm_hour = 0;
+                                                                       tm_max_value->tm_min = 0;
+                                                                       tm_max_value->tm_sec = 0;
+                                                               }
+                                                       else if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_TIME)
+                                                               {
+                                                                       tm_max_value->tm_year = 0;
+                                                                       tm_max_value->tm_mon = 0;
+                                                                       tm_max_value->tm_mday = 0;
+                                                               }
+                                               }
+                                       else
+                                               {
+                                                       tm_max_value = gtk_form_field_datetime_get_tm_from_str (max_value,
+                                                              gtk_form_field_datetime_get_str_format (GTK_FORM_FIELD_DATETIME (field)));
+                                               }
+
+                                       if (tm_max_value != NULL)
+                                               {
+                                                       time_t tt_max_value;
+                                                       time_t tt_value;
+
+                                                       tt_max_value = mktime (tm_max_value);
+                                                       tt_value = mktime (tm_value);
+
+                                                       ret = (difftime (tt_max_value, tt_value) >= 0);
+
+                                                       g_free (tm_max_value);
+                                               }
+                               }
+
+                       g_free (tm_value);
+               }
+
+       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->display_format);
+
+       priv->original_value = g_memdup (value, sizeof (struct tm));
+
+       if (priv->original_value != NULL && priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
+               {
+                       priv->original_value->tm_hour = 0;
+                       priv->original_value->tm_min = 0;
+                       priv->original_value->tm_sec = 0;
+               }
+
+       g_free (value);
+}
+
+/**
+ * gtk_form_field_datetime_set_from_datamodel:
+ * @field: a #GtkFormField object.
+ * @dm: a #GdaDataModel object.
+ * @row:
+ *
+ */
+gboolean
+gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
+{
+       gboolean ret;
+       GtkFormFieldDateTimePrivate *priv;
+       gchar *field_name;
+       struct tm *datetime;
+       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);
+
+       ret = FALSE;
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+       field_name = (gchar *)gtk_form_field_get_field_name (field);
+
+       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+               {
+                       datetime = gdaex_data_model_get_field_value_tm_at (dm, row, field_name);
+
+                       value = gtk_form_field_datetime_get_str_from_tm (datetime, priv->display_format);
+
+                       ret = gtk_form_field_datetime_set_value_stringify (field, value);
+
+                       priv->original_value = g_memdup (datetime, sizeof (struct tm));
+
+                       g_free (datetime);
+                       g_free (value);
+               }
+       else
+               {
+                       g_warning (_("GtkFormField hasn't a field name."));
+               }
+
+       g_free (field_name);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_set_from_hashtable:
+ * @field: a #GtkFormField object.
+ * @hashtable: a #GHashTable object.
+ *
+ */
+gboolean
+gtk_form_field_datetime_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
+{
+       gboolean ret;
+       GtkFormFieldDateTimePrivate *priv;
+       gchar *field_name;
+       GValue *gval;
+       struct tm *datetime;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       ret = FALSE;
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+       field_name = (gchar *)gtk_form_field_get_field_name (field);
+       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+               {
+                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
+                       if (gval == NULL)
+                               {
+                                       priv->original_value = NULL;
+                                       ret = gtk_form_field_datetime_set_value_stringify (field, "");
+                               }
+                       else
+                               {
+                                       datetime = (struct tm *)g_value_get_pointer (gval);
+
+                                       value = gtk_form_field_datetime_get_str_from_tm (datetime, priv->display_format);
+
+                                       ret = gtk_form_field_datetime_set_value_stringify (field, value);
+
+                                       priv->original_value = g_memdup (datetime, sizeof (struct tm));
+
+                                       g_free (datetime);
+                                       g_free (value);
+                               }
+               }
+       else
+               {
+                       g_warning (_("GtkFormField hasn't a field name."));
+               }
+
+       g_free (field_name);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_set_value:
+ * @field: a #GtkFormField object.
+ * @value: a #GValue.
+ *
+ */
+gboolean
+gtk_form_field_datetime_set_value (GtkFormField *field, GValue *gvalue)
+{
+       gboolean ret;
+       GtkFormFieldDateTimePrivate *priv;
+       struct tm *datetime;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
+       g_return_val_if_fail (G_VALUE_HOLDS_POINTER (gvalue), FALSE);
+
+       ret = FALSE;
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+       datetime = (struct tm *)g_value_get_pointer (gvalue);
+       value = gtk_form_field_datetime_get_str_from_tm (datetime, priv->display_format);
+       ret = gtk_form_field_datetime_set_value_stringify (field, value);
+       priv->original_value = g_memdup (datetime, sizeof (struct tm));
+
+       g_free (datetime);
+       g_free (value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_tm_from_str:
+ * @str: the #gchar to be parsed.
+ * @format:
+ *
+ */
+struct tm
+*gtk_form_field_datetime_get_tm_from_str (const gchar *str, const gchar *format)
+{
+       struct tm *ret;
+       gchar *new_str;
+       gchar *new_format;
+       gchar **str_tokens;
+       gchar **format_tokens;
+       gchar *delimiters;
+       guint len_strv;
+       guint len_formatv;
+       guint i;
+       guint i_to;
+       GDate *date;
+
+       g_return_val_if_fail (str != NULL, NULL);
+
+       new_str = g_strstrip (g_strdup (str));
+       if (g_strcmp0 (new_str, "") == 0)
+               {
+                       g_free (new_str);
+                       return NULL;
+               }
+
+       new_format = g_strstrip (g_strdup (format));
+       if (g_strcmp0 (new_format, "") == 0)
+               {
+                       new_format = g_strdup ("%Y-%m-%d %H:%M:%S");
+               }
+
+       /* removes format identifiers to find delimiters */
+       delimiters = gtk_form_field_datetime_str_replace (new_format, "%Y", "");
+       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%m", "");
+       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%d", "");
+       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%H", "");
+       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%M", "");
+       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%S", "");
+
+       if (delimiters == NULL || g_strcmp0 (delimiters, "") == 0)
+               {
+                       g_free (delimiters);
+                       g_free (new_format);
+                       g_free (new_str);
+                       return NULL;
+               }
+
+       str_tokens = g_strsplit_set (str, delimiters, -1);
+       if (str_tokens == NULL)
+               {
+                       g_free (delimiters);
+                       g_free (new_format);
+                       g_free (new_str);
+                       return NULL;
+               }
+
+       format_tokens = g_strsplit_set (format, delimiters, -1);
+       if (format_tokens == NULL)
+               {
+                       g_free (delimiters);
+                       g_free (new_format);
+                       g_free (new_str);
+                       return NULL;
+               }
+
+       len_strv = g_strv_length (str_tokens);
+       len_formatv = g_strv_length (format_tokens);
+
+       ret = g_malloc0 (sizeof (struct tm));
+       ret->tm_mday = 1;
+       ret->tm_isdst = -1;
+
+       i_to = MIN (len_strv, len_formatv);
+       for (i = 0; i < i_to; i++)
+               {
+                       if (g_strcmp0 (format_tokens[i], "%Y") == 0)
+                               {
+                                       ret->tm_year = strtol (str_tokens[i], NULL, 10) - 1900;
+                               }
+                       else if (g_strcmp0 (format_tokens[i], "%m") == 0)
+                               {
+                                       ret->tm_mon = strtol (str_tokens[i], NULL, 10) - 1;
+                               }
+                       else if (g_strcmp0 (format_tokens[i], "%d") == 0)
+                               {
+                                       ret->tm_mday = strtol (str_tokens[i], NULL, 10);
+                               }
+                       else if (g_strcmp0 (format_tokens[i], "%H") == 0)
+                               {
+                                       ret->tm_hour = strtol (str_tokens[i], NULL, 10);
+                               }
+                       else if (g_strcmp0 (format_tokens[i], "%M") == 0)
+                               {
+                                       ret->tm_min = strtol (str_tokens[i], NULL, 10);
+                               }
+                       else if (g_strcmp0 (format_tokens[i], "%S") == 0)
+                               {
+                                       ret->tm_sec = strtol (str_tokens[i], NULL, 10);
+                               }
+               }
+
+       g_free (delimiters);
+       g_free (new_format);
+       g_free (new_str);
+
+       /* check if it is valid */
+       date = g_date_new_dmy (ret->tm_mday,
+                              ret->tm_mon + 1,
+                              ret->tm_year + 1900);
+       if (date == NULL || !g_date_valid (date))
+               {
+                       return NULL;
+               }
+
+       if (ret != NULL)
+               {
+                       mktime (ret);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_str_from_tm:
+ * @datetime: a tm struct.
+ * @format:
+ *
+ * Returns: a string representation of @datetime based on the format in @format.
+ * It interprets a very little subset of format identifiers from strftime.
+ * %Y: the year with 4 digits.
+ * %m: the month with 2 digits.
+ * %d: the day with 2 digits.
+ * %H: the hours with 2 digits 00-24.
+ * %M: the minutes with 2 digits 00-59.
+ * %S: the seconds with 2 digits 00-59.
+ */
+gchar
+*gtk_form_field_datetime_get_str_from_tm (struct tm *datetime,
+                                          const gchar *format)
+{
+       gchar *ret;
+
+       ret = g_strdup ("");
+
+       g_return_val_if_fail (datetime != NULL, ret);
+
+       ret = gtk_form_field_datetime_str_replace (format, "%Y",
+                                                  g_strdup_printf ("%04u", datetime->tm_year + 1900));
+       ret = gtk_form_field_datetime_str_replace (ret, "%m",
+                                                  g_strdup_printf ("%02u", datetime->tm_mon + 1));
+       ret = gtk_form_field_datetime_str_replace (ret, "%d",
+                                                  g_strdup_printf ("%02u", datetime->tm_mday));
+       ret = gtk_form_field_datetime_str_replace (ret, "%H",
+                                                  g_strdup_printf ("%02u", datetime->tm_hour));
+       ret = gtk_form_field_datetime_str_replace (ret, "%M",
+                                                  g_strdup_printf ("%02u", datetime->tm_min));
+       ret = gtk_form_field_datetime_str_replace (ret, "%S",
+                                                  g_strdup_printf ("%02u", datetime->tm_sec));
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_gdate_from_tm:
+ * @datetime: a struct tm.
+ *
+ * Returns: a #GDate that represent the struct tm without time information.
+ */
+GDate
+*gtk_form_field_datetime_get_gdate_from_tm (struct tm *datetime)
+{
+       GDate *ret;
+
+       ret = NULL;
+
+       if (datetime != NULL)
+               {
+                       ret = g_date_new_dmy (datetime->tm_mday,
+                                             datetime->tm_mon + 1,
+                                             datetime->tm_year + 1900);
+
+                       if (ret == NULL || !g_date_valid (ret))
+                               {
+                                       ret = NULL;
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_now:
+ * 
+ * Returns: a struct tm that represent the actual date and time.
+ */
+struct tm
+*gtk_form_field_datetime_get_now (void)
+{
+       struct tm *ret;
+       time_t tt;
+
+       tt = time (NULL);
+       ret = localtime (&tt);
+
+       return ret;
+}
+
+/* PRIVATE */
+static void
+gtk_form_field_datetime_set_property (GObject *object,
+                                  guint property_id,
+                                  const GValue *value,
+                                  GParamSpec *pspec)
+{
+       GtkFormFieldDateTime *field = (GtkFormFieldDateTime *)object;
+
+       GtkFormFieldDateTimePrivate *priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               priv->default_value = g_value_get_pointer (value);
+                               break;
+
+                       case PROP_TYPE:
+                               priv->type = g_value_get_int (value);
+                               break;
+
+                       case PROP_DISPLAY_FORMAT:
+                               priv->display_format = g_strstrip (g_value_dup_string (value));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gtk_form_field_datetime_get_property (GObject *object,
+                                  guint property_id,
+                                  GValue *value,
+                                  GParamSpec *pspec)
+{
+       GtkFormFieldDateTime *field = (GtkFormFieldDateTime *)object;
+
+       GtkFormFieldDateTimePrivate *priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               g_value_set_pointer (value, priv->default_value);
+                               break;
+
+                       case PROP_TYPE:
+                               g_value_set_int (value, priv->type);
+                               break;
+
+                       case PROP_DISPLAY_FORMAT:
+                               g_value_set_string (value, priv->display_format);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static gboolean
+gtk_form_field_datetime_set_value_stringify (GtkFormField *field, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkFormWidget *fw;
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       ret = gtk_form_widget_set_value_stringify (fw, value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_datetime_get_str_format:
+ * @field: a #GtkFormFieldDateTime object.
+ *
+ * Returns: the strftime format string for the current type.
+ */
+static gchar
+*gtk_form_field_datetime_get_str_format (GtkFormFieldDateTime *field)
+{
+       gchar *format;
+       GtkFormFieldDateTimePrivate *priv;
+
+       format = NULL;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), format);
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
+
+       switch (priv->type)
+               {
+                       case GTK_FORM_FIELD_DATETIME_TYPE_DATETIME:
+                               format = g_strdup ("%Y-%m-%d %H:%M:%S");
+                               break;
+
+                       case GTK_FORM_FIELD_DATETIME_TYPE_DATE:
+                               format = g_strdup ("%Y-%m-%d");
+                               break;
+
+                       case GTK_FORM_FIELD_DATETIME_TYPE_TIME:
+                               format = g_strdup ("%H:%M:%S");
+                               break;
+
+                       default:
+                               g_warning (_("GtkFormFieldDateTimeType not supported: %d."), priv->type);
+                               format = NULL;
+                               break;
+               }
+
+       return format;
+}
+
+/**
+ * gtk_form_field_datetime_replace_str:
+ * @string: the string where make the replace.
+ * @origin: the string to replace.
+ * @replace: the string to insert.
+ *
+ * Returns: a string with replaced string. Must be freed.
+ */
+static gchar
+*gtk_form_field_datetime_str_replace (const gchar *string,
+                                      const gchar *origin,
+                                      const gchar *replace)
+{
+       gchar *ret;
+       gchar *p;
+
+       p = g_strstr_len (string, -1, origin);
+
+       if (p == NULL)
+               {
+                       return g_strdup (string);
+               }
+
+       ret = g_strndup (string, p - string);
+
+       ret = g_strdup_printf ("%s%s%s", ret, replace, p + strlen (origin));
+
+       return ret;
+}
+
+static gboolean
+gtk_form_field_datetime_is_valid_datetime (GtkFormFieldDateTime *field)
+{
+       gboolean ret;
+
+       GtkFormFieldDateTimePrivate *priv;
+
+       gchar *str_date;
+       struct tm *tm_date;
+
+       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
+
+       str_date = gtk_form_field_datetime_get_value_stringify (GTK_FORM_FIELD (field));
+       tm_date = gtk_form_field_datetime_get_tm_from_str (str_date, priv->display_format);
+
+       ret = (tm_date != NULL);
+
+       g_free (str_date);
+       g_free (tm_date);
+
+       return ret;
+}
diff --git a/libgtkform/fielddatetime.h b/libgtkform/fielddatetime.h
new file mode 100644 (file)
index 0000000..d645ea5
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_FIELD_DATETIME_H__
+#define __LIBGTK_FORM_FIELD_DATETIME_H__
+
+#include "field.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_FIELD_DATETIME                 (gtk_form_field_datetime_get_type ())
+#define GTK_FORM_FIELD_DATETIME(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTime))
+#define GTK_FORM_FIELD_DATETIME_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTimeClass))
+#define IS_GTK_FORM_FIELD_DATETIME(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_DATETIME))
+#define IS_GTK_FORM_FIELD_DATETIME_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_DATETIME))
+#define GTK_FORM_FIELD_DATETIME_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTimeClass))
+
+
+typedef struct _GtkFormFieldDateTime GtkFormFieldDateTime;
+typedef struct _GtkFormFieldDateTimeClass GtkFormFieldDateTimeClass;
+
+struct _GtkFormFieldDateTime
+       {
+               GtkFormField parent;
+       };
+
+struct _GtkFormFieldDateTimeClass
+       {
+               GtkFormFieldClass parent_class;
+       };
+
+GType gtk_form_field_datetime_get_type (void) G_GNUC_CONST;
+
+enum
+{
+       GTK_FORM_FIELD_DATETIME_TYPE_DATETIME,
+       GTK_FORM_FIELD_DATETIME_TYPE_DATE,
+       GTK_FORM_FIELD_DATETIME_TYPE_TIME
+};
+
+GtkFormField *gtk_form_field_datetime_new (void);
+
+gchar *gtk_form_field_datetime_get_value_stringify (GtkFormField *field);
+GValue *gtk_form_field_datetime_get_value (GtkFormField *field);
+gchar *gtk_form_field_datetime_get_value_sql (GtkFormField *field);
+GValue *gtk_form_field_datetime_get_original_value (GtkFormField *field);
+
+gboolean gtk_form_field_datetime_clear (GtkFormField *field);
+
+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_is_valid (GtkFormField *field);
+
+gboolean gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
+gboolean gtk_form_field_datetime_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
+gboolean gtk_form_field_datetime_set_value (GtkFormField *field, GValue *gvalue);
+
+struct tm *gtk_form_field_datetime_get_tm_from_str (const gchar *str, const gchar *format);
+gchar *gtk_form_field_datetime_get_str_from_tm (struct tm *datetime, const gchar *format);
+
+GDate *gtk_form_field_datetime_get_gdate_from_tm (struct tm *datetime);
+
+struct tm *gtk_form_field_datetime_get_now (void);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_FIELD_DATETIME_H__ */
diff --git a/libgtkform/fieldfloat.c b/libgtkform/fieldfloat.c
new file mode 100644 (file)
index 0000000..19379ef
--- /dev/null
@@ -0,0 +1,567 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <locale.h>
+
+#include <glib/gi18n-lib.h>
+
+#include "widget.h"
+#include "fieldfloat.h"
+
+enum
+{
+       PROP_0,
+       PROP_DEFAULT,
+       PROP_DECIMALS
+};
+
+static void gtk_form_field_float_class_init (GtkFormFieldFloatClass *klass);
+static void gtk_form_field_float_init (GtkFormFieldFloat *gtk_form_field);
+
+static void gtk_form_field_float_set_property (GObject *object,
+                                           guint property_id,
+                                           const GValue *value,
+                                           GParamSpec *pspec);
+static void gtk_form_field_float_get_property (GObject *object,
+                                           guint property_id,
+                                           GValue *value,
+                                           GParamSpec *pspec);
+
+static gboolean gtk_form_field_float_set_value_stringify (GtkFormField *field, const gchar *value);
+static const gchar *gtk_form_field_float_get_str_format (GtkFormFieldFloat *field);
+
+#define GTK_FORM_FIELD_FLOAT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloatPrivate))
+
+typedef struct _GtkFormFieldFloatPrivate GtkFormFieldFloatPrivate;
+struct _GtkFormFieldFloatPrivate
+       {
+               gfloat default_value;
+               gfloat original_value;
+
+               guint decimals;
+       };
+
+
+G_DEFINE_TYPE (GtkFormFieldFloat, gtk_form_field_float, TYPE_GTK_FORM_FIELD)
+
+static void
+gtk_form_field_float_class_init (GtkFormFieldFloatClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
+
+       object_class->set_property = gtk_form_field_float_set_property;
+       object_class->get_property = gtk_form_field_float_get_property;
+
+       field_class->get_value_stringify = gtk_form_field_float_get_value_stringify;
+       field_class->get_value = gtk_form_field_float_get_value;
+       field_class->get_value_sql = gtk_form_field_float_get_value_sql;
+       field_class->get_original_value = gtk_form_field_float_get_original_value;
+       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->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;
+
+       g_object_class_install_property (object_class, PROP_DEFAULT,
+                                        g_param_spec_float ("default",
+                                                            "Default",
+                                                            "Default value",
+                                                            -G_MAXFLOAT, G_MAXFLOAT, 0.0f,
+                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_DECIMALS,
+                                        g_param_spec_uint ("decimals",
+                                                           "Decimals",
+                                                           "Number of decimals to show",
+                                                           0, G_MAXUINT, 0,
+                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormFieldFloatPrivate));
+}
+
+static void
+gtk_form_field_float_init (GtkFormFieldFloat *gtk_form_field)
+{
+}
+
+/**
+ * gtk_form_field_float_new:
+ *
+ * Returns: the newly created #GtkFormFieldFloat.
+ */
+GtkFormField
+*gtk_form_field_float_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_FIELD_FLOAT, NULL);
+}
+
+/**
+ * gtk_form_field_float_get_value_stringify:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_float_get_value_stringify (GtkFormField *field)
+{
+       gchar *ret;
+
+       GtkFormWidget *fw;
+       GtkFormFieldFloatPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), "");
+
+       priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
+
+       ret = g_strdup ("");
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       if (IS_GTK_FORM_WIDGET (fw))
+               {
+                       gchar *value;
+
+                       value = gtk_form_widget_get_value_stringify (fw);
+
+                       if (value != NULL)
+                               {
+                                       ret = g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), g_strtod (value, NULL));
+
+                                       g_free (value);
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_float_get_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_float_get_value (GtkFormField *field)
+{
+       GValue *ret;
+       gchar *value;
+
+       ret = NULL;
+
+       value = gtk_form_field_float_get_value_stringify (field);
+
+       if (value != NULL)
+               {
+                       ret = g_malloc0 (sizeof (GValue));
+                       g_value_init (ret, G_TYPE_FLOAT);
+                       g_value_set_float (ret, g_strtod (value, NULL));
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_float_get_value_sql:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_float_get_value_sql (GtkFormField *field)
+{
+       gchar *ret;
+       gchar *value;
+
+       ret = g_strdup ("");
+
+       value = gtk_form_field_float_get_value_stringify (field);
+       if (value != NULL)
+               {
+                       char *cur = g_strdup (setlocale (LC_NUMERIC, NULL));
+                       gda_locale_changed ();
+
+                       gfloat fval = g_strtod (value, NULL);
+
+                       setlocale (LC_NUMERIC, "C");
+                       gda_locale_changed ();
+
+                       ret = g_strdup_printf ("%f", fval);
+
+                       setlocale (LC_NUMERIC, cur);
+                       gda_locale_changed ();
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_float_get_original_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_float_get_original_value (GtkFormField *field)
+{
+       GValue *ret;
+
+       ret = NULL;
+
+       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
+
+       ret = g_malloc0 (sizeof (GValue));
+       g_value_init (ret, G_TYPE_FLOAT);
+       g_value_set_float (ret, priv->original_value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_float_clear:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_float_clear (GtkFormField *field)
+{
+       gboolean ret = FALSE;
+
+       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
+
+       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), priv->default_value));
+
+       priv->original_value = priv->default_value;
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_float_is_empty:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_float_is_empty (GtkFormField *field)
+{
+       gboolean ret;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), TRUE);
+
+       value = gtk_form_field_float_get_value_stringify (field);
+
+       if (value != NULL && g_strtod (value, NULL) == 0.0f)
+               {
+                       ret = TRUE;
+               }
+       else
+               {
+                       ret = FALSE;
+               }
+
+       g_free (value);
+
+       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_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_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.
+ * @dm: a #GdaDataModel object.
+ * @row:
+ *
+ */
+gboolean
+gtk_form_field_float_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldFloatPrivate *priv;
+       gfloat value;
+       gchar *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_float_at (dm, row, field_name);
+
+       setlocale (LC_NUMERIC, "");
+       gda_locale_changed ();
+       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), value));
+
+       priv->original_value = value;
+
+       g_free (field_name);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_float_set_from_hashtable:
+ * @field: a #GtkFormField object.
+ * @hashtable: a #GHashTable object.
+ *
+ */
+gboolean
+gtk_form_field_float_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldFloatPrivate *priv;
+       GValue *gval;
+       gchar *field_name;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
+
+       field_name = gtk_form_field_get_field_name (field);
+       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+               {
+                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
+                       if (gval == NULL)
+                               {
+                                       priv->original_value = 0.0;
+
+                                       setlocale (LC_NUMERIC, "");
+                                       gda_locale_changed ();
+                                       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), 0.0));
+                               }
+                       else
+                               {
+                                       priv->original_value = g_value_get_float (gval);
+
+                                       setlocale (LC_NUMERIC, "");
+                                       gda_locale_changed ();
+                                       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), priv->original_value));
+                               }
+               }
+       else
+               {
+                       g_warning (_("GtkFormField hasn't a field name."));
+               }
+
+       g_free (field_name);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_float_set_value:
+ * @field: a #GtkFormField object.
+ * @value: a #GValue.
+ *
+ */
+gboolean
+gtk_form_field_float_set_value (GtkFormField *field, GValue *gvalue)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldFloatPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
+       g_return_val_if_fail (G_VALUE_HOLDS_FLOAT (gvalue), FALSE);
+
+       priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
+
+       priv->original_value = g_value_get_float (gvalue);
+       setlocale (LC_NUMERIC, "");
+       gda_locale_changed ();
+       ret = gtk_form_field_float_set_value_stringify (field,
+                                                       g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)),
+                                                                        priv->original_value));
+
+       return ret;
+}
+
+/* PRIVATE */
+static void
+gtk_form_field_float_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec)
+{
+       GtkFormFieldFloat *field = (GtkFormFieldFloat *)object;
+
+       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               priv->default_value = g_value_get_float (value);
+                               break;
+
+                       case PROP_DECIMALS:
+                               priv->decimals = g_value_get_uint (value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gtk_form_field_float_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec)
+{
+       GtkFormFieldFloat *field = (GtkFormFieldFloat *)object;
+
+       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               g_value_set_float (value, priv->default_value);
+                               break;
+
+                       case PROP_DECIMALS:
+                               g_value_set_uint (value, priv->decimals);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static gboolean
+gtk_form_field_float_set_value_stringify (GtkFormField *field, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkFormWidget *fw;
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       ret = gtk_form_widget_set_value_stringify (fw, value);
+
+       return ret;
+}
+
+static const gchar
+*gtk_form_field_float_get_str_format (GtkFormFieldFloat *field)
+{
+       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
+
+       return g_strdup_printf ("%%0%sf", priv->decimals < 0 ? ".2" : g_strdup_printf (".%d", priv->decimals));
+}
diff --git a/libgtkform/fieldfloat.h b/libgtkform/fieldfloat.h
new file mode 100644 (file)
index 0000000..62fcc3b
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_FIELD_FLOAT_H__
+#define __LIBGTK_FORM_FIELD_FLOAT_H__
+
+#include "field.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_FIELD_FLOAT                 (gtk_form_field_float_get_type ())
+#define GTK_FORM_FIELD_FLOAT(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloat))
+#define GTK_FORM_FIELD_FLOAT_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloatClass))
+#define IS_GTK_FORM_FIELD_FLOAT(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_FLOAT))
+#define IS_GTK_FORM_FIELD_FLOAT_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_FLOAT))
+#define GTK_FORM_FIELD_FLOAT_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloatClass))
+
+
+typedef struct _GtkFormFieldFloat GtkFormFieldFloat;
+typedef struct _GtkFormFieldFloatClass GtkFormFieldFloatClass;
+
+struct _GtkFormFieldFloat
+       {
+               GtkFormField parent;
+       };
+
+struct _GtkFormFieldFloatClass
+       {
+               GtkFormFieldClass parent_class;
+       };
+
+GType gtk_form_field_float_get_type (void) G_GNUC_CONST;
+
+GtkFormField *gtk_form_field_float_new (void);
+
+gchar *gtk_form_field_float_get_value_stringify (GtkFormField *field);
+GValue *gtk_form_field_float_get_value (GtkFormField *field);
+gchar *gtk_form_field_float_get_value_sql (GtkFormField *field);
+GValue *gtk_form_field_float_get_original_value (GtkFormField *field);
+
+gboolean gtk_form_field_float_clear (GtkFormField *field);
+
+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_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);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_FIELD_FLOAT_H__ */
diff --git a/libgtkform/fieldinteger.c b/libgtkform/fieldinteger.c
new file mode 100644 (file)
index 0000000..00c1260
--- /dev/null
@@ -0,0 +1,498 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include "widget.h"
+#include "fieldinteger.h"
+
+enum
+{
+       PROP_0,
+       PROP_DEFAULT
+};
+
+static void gtk_form_field_integer_class_init (GtkFormFieldIntegerClass *klass);
+static void gtk_form_field_integer_init (GtkFormFieldInteger *gtk_form_field);
+
+static void gtk_form_field_integer_set_property (GObject *object,
+                                             guint property_id,
+                                             const GValue *value,
+                                             GParamSpec *pspec);
+static void gtk_form_field_integer_get_property (GObject *object,
+                                             guint property_id,
+                                             GValue *value,
+                                             GParamSpec *pspec);
+
+static gboolean gtk_form_field_integer_set_value_stringify (GtkFormField *field, const gchar *value);
+
+#define GTK_FORM_FIELD_INTEGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldIntegerPrivate))
+
+typedef struct _GtkFormFieldIntegerPrivate GtkFormFieldIntegerPrivate;
+struct _GtkFormFieldIntegerPrivate
+       {
+               gint default_value;
+               gint original_value;
+       };
+
+
+G_DEFINE_TYPE (GtkFormFieldInteger, gtk_form_field_integer, TYPE_GTK_FORM_FIELD)
+
+static void
+gtk_form_field_integer_class_init (GtkFormFieldIntegerClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
+
+       object_class->set_property = gtk_form_field_integer_set_property;
+       object_class->get_property = gtk_form_field_integer_get_property;
+
+       field_class->get_value_stringify = gtk_form_field_integer_get_value_stringify;
+       field_class->get_value = gtk_form_field_integer_get_value;
+       field_class->get_value_sql = gtk_form_field_integer_get_value_sql;
+       field_class->get_original_value = gtk_form_field_integer_get_original_value;
+       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->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;
+
+       g_object_class_install_property (object_class, PROP_DEFAULT,
+                                        g_param_spec_int ("default",
+                                                          "Default",
+                                                          "Default value",
+                                                          G_MININT, G_MAXINT, 0,
+                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormFieldIntegerPrivate));
+}
+
+static void
+gtk_form_field_integer_init (GtkFormFieldInteger *gtk_form_field)
+{
+}
+
+/**
+ * gtk_form_field_integer_new:
+ *
+ * Returns: the newly created #GtkFormFieldInteger.
+ */
+GtkFormField
+*gtk_form_field_integer_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_FIELD_INTEGER, NULL);
+}
+
+/**
+ * gtk_form_field_integer_get_value_stringify:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_integer_get_value_stringify (GtkFormField *field)
+{
+       gchar *ret;
+
+       GtkFormWidget *fw;
+
+       ret = g_strdup ("");
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       if (IS_GTK_FORM_WIDGET (fw))
+               {
+                       gchar *value;
+
+                       value = gtk_form_widget_get_value_stringify (fw);
+
+                       if (value != NULL)
+                               {
+                                       ret = g_strdup_printf ("%d", strtol (value, NULL, 10));
+
+                                       g_free (value);
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_integer_get_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_integer_get_value (GtkFormField *field)
+{
+       GValue *ret;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), NULL);
+
+       ret = NULL;
+
+       value = gtk_form_field_integer_get_value_stringify (field);
+
+       if (value != NULL)
+               {
+                       ret = g_malloc0 (sizeof (GValue));
+                       g_value_init (ret, G_TYPE_INT);
+                       g_value_set_int (ret, strtol (value, NULL, 10));
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_integer_get_value_sql:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_integer_get_value_sql (GtkFormField *field)
+{
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), "0");
+
+       return gtk_form_field_integer_get_value_stringify (field);
+}
+
+/**
+ * gtk_form_field_integer_get_original_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_integer_get_original_value (GtkFormField *field)
+{
+       GValue *ret;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), NULL);
+
+       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
+
+       ret = NULL;
+
+       ret = g_malloc0 (sizeof (GValue));
+       g_value_init (ret, G_TYPE_INT);
+       g_value_set_int (ret, priv->original_value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_integer_clear:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_integer_clear (GtkFormField *field)
+{
+       gboolean ret = FALSE;
+
+       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
+
+       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: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_integer_is_empty (GtkFormField *field)
+{
+       gboolean ret;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), TRUE);
+
+       value = gtk_form_field_integer_get_value_stringify (field);
+
+       if (value != NULL && strtol (value, NULL, 10) == 0)
+               {
+                       ret = TRUE;
+               }
+       else
+               {
+                       ret = FALSE;
+               }
+
+       g_free (value);
+
+       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_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.
+ *
+ */
+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.
+ * @dm: a #GdaDataModel object.
+ * @row:
+ *
+ */
+gboolean
+gtk_form_field_integer_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldIntegerPrivate *priv;
+       gchar *value;
+       gchar *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);
+
+       g_free (field_name);
+       g_free (value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_integer_set_from_hashtable:
+ * @field: a #GtkFormField object.
+ * @hashtable: a #GHashTable object.
+ *
+ */
+gboolean
+gtk_form_field_integer_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldIntegerPrivate *priv;
+       GValue *gval;
+       gchar *field_name;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), FALSE);
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
+
+       field_name = gtk_form_field_get_field_name (field);
+       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+               {
+                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
+                       if (gval == NULL)
+                               {
+                                       priv->original_value = 0;
+                                       ret = gtk_form_field_integer_set_value_stringify (field, "0");
+                               }
+                       else
+                               {
+                                       priv->original_value = g_value_get_int (gval);
+                                       ret = gtk_form_field_integer_set_value_stringify (field, g_strdup_printf ("%d", priv->original_value));
+                               }
+
+                       g_free (field_name);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_integer_set_value:
+ * @field: a #GtkFormField object.
+ * @gvalue: a #Gvalue.
+ *
+ */
+gboolean
+gtk_form_field_integer_set_value (GtkFormField *field, GValue *gvalue)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldIntegerPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), FALSE);
+       g_return_val_if_fail (G_VALUE_HOLDS_INT (gvalue), FALSE);
+
+       priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
+
+       priv->original_value = g_value_get_int (gvalue);
+       ret = gtk_form_field_integer_set_value_stringify (field, g_strdup_printf ("%d", priv->original_value));
+
+       return ret;
+}
+
+/* PRIVATE */
+static void
+gtk_form_field_integer_set_property (GObject *object,
+                                 guint property_id,
+                                 const GValue *value,
+                                 GParamSpec *pspec)
+{
+       GtkFormFieldInteger *field = (GtkFormFieldInteger *)object;
+
+       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               priv->default_value = g_value_get_int (value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_field_integer_get_property (GObject *object,
+                                 guint property_id,
+                                 GValue *value,
+                                 GParamSpec *pspec)
+{
+       GtkFormFieldInteger *field = (GtkFormFieldInteger *)object;
+
+       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               g_value_set_int (value, priv->default_value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static gboolean
+gtk_form_field_integer_set_value_stringify (GtkFormField *field, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkFormWidget *fw;
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       ret = gtk_form_widget_set_value_stringify (fw, value);
+
+       return ret;
+}
diff --git a/libgtkform/fieldinteger.h b/libgtkform/fieldinteger.h
new file mode 100644 (file)
index 0000000..4ca3ca7
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_FIELD_INTEGER_H__
+#define __LIBGTK_FORM_FIELD_INTEGER_H__
+
+#include "field.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_FIELD_INTEGER                 (gtk_form_field_integer_get_type ())
+#define GTK_FORM_FIELD_INTEGER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldInteger))
+#define GTK_FORM_FIELD_INTEGER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldIntegerClass))
+#define IS_GTK_FORM_FIELD_INTEGER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_INTEGER))
+#define IS_GTK_FORM_FIELD_INTEGER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_INTEGER))
+#define GTK_FORM_FIELD_INTEGER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldIntegerClass))
+
+
+typedef struct _GtkFormFieldInteger GtkFormFieldInteger;
+typedef struct _GtkFormFieldIntegerClass GtkFormFieldIntegerClass;
+
+struct _GtkFormFieldInteger
+       {
+               GtkFormField parent;
+       };
+
+struct _GtkFormFieldIntegerClass
+       {
+               GtkFormFieldClass parent_class;
+       };
+
+GType gtk_form_field_integer_get_type (void) G_GNUC_CONST;
+
+GtkFormField *gtk_form_field_integer_new (void);
+
+gchar *gtk_form_field_integer_get_value_stringify (GtkFormField *field);
+GValue *gtk_form_field_integer_get_value (GtkFormField *field);
+gchar *gtk_form_field_integer_get_value_sql (GtkFormField *field);
+GValue *gtk_form_field_integer_get_original_value (GtkFormField *field);
+
+gboolean gtk_form_field_integer_clear (GtkFormField *field);
+
+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_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);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_FIELD_INTEGER_H__ */
diff --git a/libgtkform/fieldtext.c b/libgtkform/fieldtext.c
new file mode 100644 (file)
index 0000000..ae168da
--- /dev/null
@@ -0,0 +1,480 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include "widget.h"
+#include "fieldtext.h"
+
+enum
+{
+       PROP_0,
+       PROP_DEFAULT
+};
+
+static void gtk_form_field_text_class_init (GtkFormFieldTextClass *klass);
+static void gtk_form_field_text_init (GtkFormFieldText *gtk_form_field);
+
+static void gtk_form_field_text_set_property (GObject *object,
+                                          guint property_id,
+                                          const GValue *value,
+                                          GParamSpec *pspec);
+static void gtk_form_field_text_get_property (GObject *object,
+                                          guint property_id,
+                                          GValue *value,
+                                          GParamSpec *pspec);
+
+static gboolean gtk_form_field_text_set_value_stringify (GtkFormField *field, const gchar *value);
+
+#define GTK_FORM_FIELD_TEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldTextPrivate))
+
+typedef struct _GtkFormFieldTextPrivate GtkFormFieldTextPrivate;
+struct _GtkFormFieldTextPrivate
+       {
+               gchar *default_value;
+               gchar *original_value;
+       };
+
+
+G_DEFINE_TYPE (GtkFormFieldText, gtk_form_field_text, TYPE_GTK_FORM_FIELD)
+
+static void
+gtk_form_field_text_class_init (GtkFormFieldTextClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
+
+       object_class->set_property = gtk_form_field_text_set_property;
+       object_class->get_property = gtk_form_field_text_get_property;
+
+       field_class->get_value_stringify = gtk_form_field_text_get_value_stringify;
+       field_class->get_value = gtk_form_field_text_get_value;
+       field_class->get_value_sql = gtk_form_field_text_get_value_sql;
+       field_class->get_original_value = gtk_form_field_text_get_original_value;
+       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;
+       field_class->set_from_hashtable = gtk_form_field_text_set_from_hashtable;
+       field_class->set_value = gtk_form_field_text_set_value;
+
+       g_object_class_install_property (object_class, PROP_DEFAULT,
+                                        g_param_spec_string ("default",
+                                                             "Default",
+                                                             "Default value",
+                                                             "",
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormFieldTextPrivate));
+}
+
+static void
+gtk_form_field_text_init (GtkFormFieldText *gtk_form_field)
+{
+       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (gtk_form_field);
+
+       priv->original_value = g_strdup ("");
+}
+
+/**
+ * gtk_form_field_text_new:
+ *
+ * Returns: the newly created #GtkFormFieldText.
+ */
+GtkFormField
+*gtk_form_field_text_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_FIELD_TEXT, NULL);
+}
+
+/**
+ * gtk_form_field_text_get_value_stringify:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_text_get_value_stringify (GtkFormField *field)
+{
+       gchar *ret;
+
+       GtkFormWidget *fw;
+               
+       g_object_get (field,
+                     "form-widget", &fw,
+                     NULL);
+
+       ret = g_strdup ("");
+
+       if (IS_GTK_FORM_WIDGET (fw))
+               {
+                       ret = gtk_form_widget_get_value_stringify (fw);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_text_get_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_text_get_value (GtkFormField *field)
+{
+       GValue *ret;
+       gchar *value;
+
+       ret = NULL;
+
+       value = gtk_form_field_text_get_value_stringify (field);
+
+       if (value != NULL)
+               {
+                       ret = g_malloc0 (sizeof (GValue));
+                       g_value_init (ret, G_TYPE_STRING);
+                       g_value_set_string (ret, value);
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_text_get_value_sql:
+ * @field: a #GtkFormField object.
+ *
+ */
+gchar
+*gtk_form_field_text_get_value_sql (GtkFormField *field)
+{
+       gchar *ret;
+       gchar *value;
+
+       ret = g_strup ("");
+
+       value = gtk_form_field_text_get_value_stringify (field);
+
+       if (value != NULL)
+               {
+                       gboolean trim;
+
+                       g_object_get (G_OBJECT (field), "trim", &trim, NULL);
+                       if (trim)
+                               {
+                                       value = g_strstrip (value);
+                               }
+
+                       ret = g_strconcat ("'", gdaex_strescape (value, NULL), "'", NULL);
+
+                       g_free (value);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_text_get_original_value:
+ * @field: a #GtkFormField object.
+ *
+ */
+GValue
+*gtk_form_field_text_get_original_value (GtkFormField *field)
+{
+       GValue *ret;
+
+       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
+
+       ret = NULL;
+
+       ret = g_malloc0 (sizeof (GValue));
+       g_value_init (ret, G_TYPE_STRING);
+       g_value_set_string (ret, priv->original_value);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_text_clear:
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_text_clear (GtkFormField *field)
+{
+       gboolean ret = FALSE;
+
+       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
+
+       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: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_field_text_is_empty (GtkFormField *field)
+{
+       gboolean ret;
+       gchar *value;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), TRUE);
+
+       value = gtk_form_field_text_get_value_stringify (field);
+
+       if (value != NULL && g_strcmp0 (value, "") == 0)
+               {
+                       ret = TRUE;
+               }
+       else
+               {
+                       ret = FALSE;
+               }
+
+       g_free (value);
+
+       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;
+       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);
+
+       g_free (value);
+
+       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));
+
+       g_free (priv->original_value);
+       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
+}
+
+/**
+ * gtk_form_field_text_set_from_datamodel:
+ * @field: a #GtkFormField object.
+ * @dm: a #GdaDataModel object.
+ * @row:
+ *
+ */
+gboolean
+gtk_form_field_text_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldTextPrivate *priv;
+       gchar *strret;
+       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));
+
+       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)
+               {
+                       strret = g_strdup ("");
+               }
+       ret = gtk_form_field_text_set_value_stringify (field, strret);
+
+       g_free (priv->original_value);
+       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
+
+       g_free (field_name);
+       g_free (strret);
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_text_set_from_hashtable:
+ * @field: a #GtkFormField object.
+ * @hashtable: a #GHashTable object.
+ *
+ */
+gboolean
+gtk_form_field_text_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldTextPrivate *priv;
+       GValue *gval;
+       gchar *field_name;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), FALSE);
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (GTK_FORM_FIELD_TEXT (field));
+
+       field_name = gtk_form_field_get_field_name (field);
+       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+               {
+                       g_free (priv->original_value);
+                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
+                       if (gval == NULL)
+                               {
+                                       priv->original_value = g_strdup ("");
+                                       ret = gtk_form_field_text_set_value_stringify (field, "");
+                               }
+                       else
+                               {
+                                       ret = gtk_form_field_text_set_value_stringify (field, g_value_get_string (gval));
+                                       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
+                               }
+                       g_free (field_name);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_field_text_set_value:
+ * @field: a #GtkFormField object.
+ * @gvalue: a #GValue.
+ *
+ */
+gboolean
+gtk_form_field_text_set_value (GtkFormField *field, GValue *gvalue)
+{
+       gboolean ret = FALSE;
+       GtkFormFieldTextPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), FALSE);
+       g_return_val_if_fail (G_VALUE_HOLDS_STRING (gvalue), FALSE);
+
+       priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (GTK_FORM_FIELD_TEXT (field));
+
+       ret = gtk_form_field_text_set_value_stringify (field, g_value_get_string (gvalue));
+
+       g_free (priv->original_value);
+       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
+
+       return ret;
+}
+
+/* PRIVATE */
+static void
+gtk_form_field_text_set_property (GObject *object,
+                              guint property_id,
+                              const GValue *value,
+                              GParamSpec *pspec)
+{
+       GtkFormFieldText *field = (GtkFormFieldText *)object;
+
+       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               priv->default_value = g_strstrip (g_strdup (g_value_get_string (value)));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_field_text_get_property (GObject *object,
+                              guint property_id,
+                              GValue *value,
+                              GParamSpec *pspec)
+{
+       GtkFormFieldText *field = (GtkFormFieldText *)object;
+
+       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
+
+       switch (property_id)
+               {
+                       case PROP_DEFAULT:
+                               g_value_set_string (value, priv->default_value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static gboolean
+gtk_form_field_text_set_value_stringify (GtkFormField *field, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkFormWidget *fw;
+       gboolean trim;
+       gchar *newval;
+
+       g_object_get (field,
+                     "form-widget", &fw,
+                     "trim", &trim,
+                     NULL);
+
+       newval = g_strdup (value);
+
+       if (trim)
+               {
+                       newval = g_strstrip (newval);
+               }
+
+       ret = gtk_form_widget_set_value_stringify (fw, newval);
+       g_free (newval);
+
+       return ret;
+}
diff --git a/libgtkform/fieldtext.h b/libgtkform/fieldtext.h
new file mode 100644 (file)
index 0000000..f005ca5
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_FIELD_TEXT_H__
+#define __LIBGTK_FORM_FIELD_TEXT_H__
+
+#include "field.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_FIELD_TEXT                 (gtk_form_field_text_get_type ())
+#define GTK_FORM_FIELD_TEXT(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldText))
+#define GTK_FORM_FIELD_TEXT_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldTextClass))
+#define IS_GTK_FORM_FIELD_TEXT(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_TEXT))
+#define IS_GTK_FORM_FIELD_TEXT_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_TEXT))
+#define GTK_FORM_FIELD_TEXT_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldTextClass))
+
+
+typedef struct _GtkFormFieldText GtkFormFieldText;
+typedef struct _GtkFormFieldTextClass GtkFormFieldTextClass;
+
+struct _GtkFormFieldText
+       {
+               GtkFormField parent;
+       };
+
+struct _GtkFormFieldTextClass
+       {
+               GtkFormFieldClass parent_class;
+       };
+
+GType gtk_form_field_text_get_type (void) G_GNUC_CONST;
+
+GtkFormField *gtk_form_field_text_new (void);
+
+gchar *gtk_form_field_text_get_value_stringify (GtkFormField *field);
+GValue *gtk_form_field_text_get_value (GtkFormField *field);
+gchar *gtk_form_field_text_get_value_sql (GtkFormField *field);
+GValue *gtk_form_field_text_get_original_value (GtkFormField *field);
+
+gboolean gtk_form_field_text_clear (GtkFormField *field);
+
+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);
+gboolean gtk_form_field_text_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
+gboolean gtk_form_field_text_set_value (GtkFormField *field, GValue *gvalue);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_FIELD_TEXT_H__ */
diff --git a/libgtkform/form.c b/libgtkform/form.c
new file mode 100644 (file)
index 0000000..13a6acd
--- /dev/null
@@ -0,0 +1,2796 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <string.h>
+#include <time.h>
+
+#include <libxml/xpath.h>
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+#include <gtk/gtk.h>
+
+#include "form.h"
+
+#include "fieldboolean.h"
+#include "fielddatetime.h"
+#include "fieldinteger.h"
+#include "fieldfloat.h"
+#include "fieldtext.h"
+#include "widget.h"
+#include "widgetcheck.h"
+#include "widgetcombobox.h"
+#include "widgetentry.h"
+#include "widgetlabel.h"
+#include "widgetradio.h"
+#include "widgetspin.h"
+#include "widgettextview.h"
+
+
+static guint debug;
+static gchar *log_file;
+
+static GOptionEntry entries[] = 
+{
+       { "gtkform-debug-level", 0, 0, G_OPTION_ARG_INT, &debug, "Sets the debug level", NULL },
+       { "gtkform-log-file", 0, 0, G_OPTION_ARG_FILENAME, &log_file, "Path to file where to write debug info (or stdout or stderr)", NULL },
+       { NULL }
+};
+
+enum
+{
+       PROP_0,
+       PROP_TABLE,
+       PROP_KEY,
+       PROP_QUOTE,
+       PROP_GDAEX
+};
+
+typedef GtkFormWidget *(* FormWidgetConstructorFunc) (void);
+typedef gboolean (* FormWidgetXmlParsingFunc) (GtkFormWidget *, xmlNodePtr);
+
+typedef struct
+{
+       gchar *name;
+       gchar *cnc_string;
+       GdaEx *gdaex;
+} GtkFormDbConnection;
+
+static void gtk_form_class_init (GtkFormClass *class);
+static void gtk_form_init (GtkForm *form);
+
+static void parse_widget_on_change (GtkForm *form, xmlNodePtr xnode, GtkFormWidget *fwidget);
+static void parse_group (GtkForm *form, xmlNodePtr xnode);
+static void parse_db_connection (GtkForm *form, xmlNodePtr xnode);
+
+static void gtk_form_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec);
+static void gtk_form_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec);
+
+static void gtk_form_show_check_error_dialog (GtkFormWidget *fwidget,
+                                              GtkWidget *parent_window,
+                                              const gchar *message);
+
+static void gtk_form_load_modules (GtkForm *form);
+
+#define GTK_FORM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM, GtkFormPrivate))
+
+typedef struct _GtkFormPrivate GtkFormPrivate;
+struct _GtkFormPrivate
+       {
+               GtkBuilder *gtkbuilder;
+
+               gchar *table;
+               GSList *fields;
+               GtkFormKey *key;
+               gchar quote;
+
+               GList *modules;
+               GdaEx *gdaex;
+
+               GSList *groups; /*GtkFormGroup */
+
+               GSList *db_connections; /* GtkFormDbConnection */
+
+               guint debug;
+               GFileOutputStream *log_file;
+       };
+
+G_DEFINE_TYPE (GtkForm, gtk_form, G_TYPE_OBJECT)
+
+static void
+gtk_form_class_init (GtkFormClass *class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+       object_class->set_property = gtk_form_set_property;
+       object_class->get_property = gtk_form_get_property;
+
+       g_object_class_install_property (object_class, PROP_TABLE,
+                                        g_param_spec_string ("table",
+                                                             "Table name",
+                                                             "GtkForm's table name",
+                                                             "",
+                                                             G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_KEY,
+                                        g_param_spec_object ("key",
+                                                             "Key",
+                                                             "Key",
+                                                             TYPE_GTK_FORM_KEY,
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_QUOTE,
+                                        g_param_spec_char ("quote",
+                                                           "Quoting character",
+                                                           "Character to use to quote fields name",
+                                                           G_MININT8, G_MAXINT8, '"',
+                                                           G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_GDAEX,
+                                        g_param_spec_pointer ("gdaex",
+                                                              "GdaEx object",
+                                                              "GdaEx object",
+                                                              G_PARAM_READWRITE));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormPrivate));
+}
+
+static void
+gtk_form_init (GtkForm *form)
+{
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+
+       priv->fields = NULL;
+       priv->key = NULL;
+       priv->gdaex = NULL;
+       priv->groups = NULL;
+       priv->db_connections = NULL;
+}
+
+/**
+ * gtk_form_new:
+ *
+ * Returns: the newly created #GtkForm object.
+ */
+GtkForm
+*gtk_form_new ()
+{
+       GtkForm *form;
+
+       form = GTK_FORM (g_object_new (gtk_form_get_type (), NULL));
+       if (form == NULL)
+               {
+                       return NULL;
+               }
+
+       setlocale (LC_ALL, "");
+       gda_locale_changed ();
+       bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+       textdomain (GETTEXT_PACKAGE);
+       bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+       if (g_module_supported ())
+               {
+                       gtk_form_load_modules (form);
+               }
+       else
+               {
+                       g_warning (_("Modules not supported by this operating system."));
+               }
+
+       return form;
+}
+
+/**
+ * gtk_form_new_from_xml:
+ * @xmldoc:
+ * @gtkbuilder:
+ *
+ * Returns: the newly created #GtkForm object from an #xmlDoc that contains the
+ * xml definition of the form.
+ */
+GtkForm
+*gtk_form_new_from_xml (xmlDoc *xmldoc, GtkBuilder *gtkbuilder)
+{
+       GtkForm *form;
+
+       form = gtk_form_new ();
+
+       if (!gtk_form_load_from_xml (form, xmldoc, gtkbuilder))
+               {
+                       form = NULL;
+               }
+
+       return form;
+}
+
+/**
+ * gtk_form_new_from_file:
+ * @filename:
+ * @gtkbuilder:
+ *
+ * Returns: the newly created #GtkForm object from a file that contains the
+ * xml denifition of the form.
+ */
+GtkForm
+*gtk_form_new_from_file (const gchar *filename, GtkBuilder *gtkbuilder)
+{
+       GtkForm *form;
+       xmlDoc *xdoc;
+
+       g_return_val_if_fail (filename != NULL, NULL);
+
+       form = NULL;
+
+       xdoc = xmlParseFile (filename);
+       if (xdoc != NULL)
+               {
+                       form = gtk_form_new_from_xml (xdoc, gtkbuilder);
+               }
+
+       return form;
+}
+
+static void
+gtkform_log_handler (const gchar *log_domain,
+                   GLogLevelFlags log_level,
+                   const gchar *message,
+                   gpointer user_data)
+{
+       GError *error;
+
+       gchar *msg;
+
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE ((GtkForm *)user_data);
+
+       msg = g_strdup_printf ("%s **: %s\n\n", log_domain, message);
+
+       if (g_output_stream_write (G_OUTPUT_STREAM (priv->log_file),
+           msg, strlen (msg), NULL, &error) < 0)
+               {
+                       g_warning (_("Error on writing on log file: %s"),
+                                  error != NULL && error->message != NULL ? error->message : "no details.");
+               }
+}
+
+static gboolean
+gtkform_post_parse_options (GOptionContext *context,
+                          GOptionGroup *group,
+                          gpointer user_data,
+                          GError **error)
+{
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE ((GtkForm *)user_data);
+
+       GError *my_error;
+
+       priv->debug = debug;
+       if (log_file == NULL)
+               {
+                       priv->log_file = 0;
+               }
+       else if (priv->debug > 0)
+               {
+                       gchar *filename = g_strstrip (g_strdup (log_file));
+                       if (g_ascii_strncasecmp (filename, "stdout", 6) == 0
+                           || g_ascii_strncasecmp (filename, "stderr", 6) == 0)
+                               {
+                               }
+                       else
+                               {
+                                       my_error = NULL;
+                                       priv->log_file = g_file_replace (g_file_new_for_path (filename),
+                                                                        NULL, FALSE, G_FILE_CREATE_NONE, NULL, &my_error);
+                                       if (priv->log_file == NULL)
+                                               {
+                                                       g_warning (_("Error on opening log file: %s."),
+                                                                  my_error != NULL && my_error->message != NULL ? my_error->message : "no details.");
+                                               }
+                                       else
+                                               {
+                                                       /* set handler */
+                                                       g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+                                                                          | G_LOG_FLAG_RECURSION, gtkform_log_handler, user_data);
+                                               }
+                               }       
+               }
+
+       return TRUE;
+}
+
+/**
+ * gtk_form_get_option_group:
+ * #gtkform: a #GtkForm object.
+ *
+ * Returns: the #GOptionGroup.
+ */
+GOptionGroup
+*gtk_form_get_option_group (GtkForm *gtkform)
+{
+       GOptionGroup *ret;
+
+       ret = g_option_group_new ("gtkform", "GtkForm", "GtkForm", (gpointer)gtkform, g_free);
+       if (ret != NULL)
+               {
+                       g_option_group_add_entries (ret, entries);
+                       g_option_group_set_parse_hooks (ret, NULL, gtkform_post_parse_options);
+               }
+
+       return ret;
+}
+
+static void
+parse_widget_on_change (GtkForm *form, xmlNodePtr xnode, GtkFormWidget *fwidget)
+{
+       gchar *what;
+       gchar *connection_name;
+       gchar *widget_name;
+       gchar *sql;
+
+       xmlNodePtr child;
+
+       what = (gchar *)xmlGetProp (xnode, (const xmlChar *)"what");
+
+       g_return_if_fail (what != NULL);
+
+       if (g_strcmp0 (what, "update") == 0)
+               {
+                       child = xnode->children;
+                       while (child != NULL)
+                               {
+                                       if (xmlStrcmp (child->name, (const xmlChar *)"widget-name") == 0)
+                                               {
+                                                       widget_name = (gchar *)xmlNodeGetContent (child);
+                                               }
+                                       else if (xmlStrcmp (child->name, (const xmlChar *)"connection-name") == 0)
+                                               {
+                                                       connection_name = (gchar *)xmlNodeGetContent (child);
+                                               }
+                                       else if (xmlStrcmp (child->name, (const xmlChar *)"sql") == 0)
+                                               {
+                                                       sql = (gchar *)xmlNodeGetContent (child);
+                                               }
+                                       
+                                       child = child->next;
+                               }
+
+                       if (sql != NULL && g_strcmp0 (g_strstrip (sql), "") != 0)
+                               {
+                                       GtkFormWidgetOnChangeOpUpdate *op = (GtkFormWidgetOnChangeOpUpdate *)g_malloc0 (sizeof (GtkFormWidgetOnChangeOpUpdate));
+                                       op->op.type = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE;
+                                       if (connection_name != NULL && g_strcmp0 (g_strstrip (connection_name), "") != 0)
+                                               {
+                                                       op->connection_name = g_strdup (connection_name);
+                                               }
+                                       if (widget_name != NULL && g_strcmp0 (g_strstrip (widget_name), "") != 0)
+                                               {
+                                                       op->form_widget_name = g_strdup (widget_name);
+                                               }
+                                       op->sql = g_strdup (sql);
+
+                                       gchar *when = (gchar *)xmlGetProp (xnode, (const xmlChar *)"when");
+                                       if (when == NULL)
+                                               {
+                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH;
+                                               }
+                                       else if (g_strcmp0 (when, "before") == 0)
+                                               {
+                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BEFORE;
+                                               }
+                                       else if (g_strcmp0 (when, "after") == 0)
+                                               {
+                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_AFTER;
+                                               }
+                                       else
+                                               {
+                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH;
+                                               }
+
+                                       gtk_form_widget_add_on_change_op (fwidget, (GtkFormWidgetOnChangeOp *)op);
+                               }
+               }
+}
+
+static void
+parse_group (GtkForm *form, xmlNodePtr xnode)
+{
+       xmlNodePtr child;
+       gchar *name;
+       GtkFormGroup *group;
+
+       gchar *ele_name;
+       GtkFormWidget *fwidget;
+       GtkFormField *field;
+
+       name = (gchar *)xmlGetProp (xnode, "name");
+
+       group = gtk_form_group_new (name);
+       gtk_form_add_group (form, group);
+
+       child = xnode->children;
+       while (child != NULL)
+               {
+                       if (xmlStrcmp (child->name, (const xmlChar *)"widget") == 0)
+                               {
+                                       ele_name = (gchar *)xmlNodeGetContent (child);
+                                       if (ele_name != NULL)
+                                               {
+                                                       fwidget = gtk_form_get_form_widget_from_name (form, g_strstrip (ele_name));
+                                                       if (fwidget != NULL)
+                                                               {
+                                                                       gtk_form_group_add_widget (group, fwidget);
+                                                               }
+                                               }
+                               }
+                       else if (xmlStrcmp (child->name, (const xmlChar *)"field") == 0)
+                               {
+                                       ele_name = (gchar *)xmlNodeGetContent (child);
+                                       if (ele_name != NULL)
+                                               {
+                                                       field = gtk_form_get_form_field_from_name (form, g_strstrip (ele_name));
+                                                       if (field != NULL)
+                                                               {
+                                                                       gtk_form_group_add_field (group, field);
+                                                               }
+                                               }
+                               }
+
+                       child = child->next;
+               }
+}
+
+static void
+parse_db_connection (GtkForm *form, xmlNodePtr xnode)
+{
+       xmlNodePtr child;
+       gchar *name;
+       gchar *cnc_string;
+
+       name = (gchar *)xmlGetProp (xnode, "name");
+
+       child = xnode->children;
+       while (child != NULL)
+               {
+                       if (xmlStrcmp (child->name, (const xmlChar *)"connection-string") == 0)
+                               {
+                                       cnc_string = (gchar *)xmlNodeGetContent (child);
+                                       break;
+                               }
+
+                       child = child->next;
+               }
+
+       if (g_strcmp0 (g_strstrip (name), "") != 0
+           && g_strcmp0 (g_strstrip (cnc_string), "") != 0)
+               {
+                       gtk_form_add_db_connection (form, name, cnc_string);
+               }
+}
+
+/**
+ * gtk_form_load_from_xml:
+ * @form:
+ * @xmldoc:
+ * @gtkbuilder:
+ *
+ */
+gboolean
+gtk_form_load_from_xml (GtkForm *form, xmlDoc *xmldoc, GtkBuilder *gtkbuilder)
+{
+       GtkFormPrivate *priv;
+       xmlNode *cur;
+
+       gboolean ret;
+
+       GList *modules;
+       FormWidgetConstructorFunc widget_constructor;
+       FormWidgetXmlParsingFunc widget_xml_parsing;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (xmldoc != NULL, FALSE);
+
+       ret = FALSE;
+
+       cur = xmlDocGetRootElement (xmldoc);
+       if (cur != NULL)
+               {
+                       if (xmlStrcmp (cur->name, (const xmlChar *)"gtkform") == 0)
+                               {
+                                       gchar *type;
+                                       gchar *name;
+                                       gchar *label;
+
+                                       GtkFormWidget *widget;
+                                       xmlNode *node_widget;
+
+                                       GtkFormField *field;
+                                       xmlNode *node_field;
+
+                                       ret = TRUE;
+
+                                       priv = GTK_FORM_GET_PRIVATE (form);
+
+                                       if (GTK_IS_BUILDER (gtkbuilder))
+                                               {
+                                                       priv->gtkbuilder = gtkbuilder;
+                                               }
+                                       else
+                                               {
+                                                       priv->gtkbuilder = NULL;
+                                               }
+
+                                       /* search gtkguilder-file node */
+                                       if (!GTK_IS_BUILDER (priv->gtkbuilder))
+                                               {
+                                                       xmlXPathContextPtr xpcontext;
+                                                       xmlXPathObjectPtr xpresult;
+                                                       xmlNodeSetPtr xnodeset;
+
+                                                       xpcontext = xmlXPathNewContext (xmldoc);
+
+                                                       xpcontext->node = cur;
+                                                       xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::gtkbuilder-file", xpcontext);
+                                                       if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
+                                                               {
+                                                                       xnodeset = xpresult->nodesetval;
+                                                                       if (xnodeset->nodeNr == 1)
+                                                                               {
+                                                                                       GError *error;
+                                                                                       gchar *filename;
+
+                                                                                       filename = (gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]);
+
+                                                                                       priv->gtkbuilder = gtk_builder_new ();
+
+                                                                                       error = NULL;
+                                                                                       if (gtk_builder_add_from_file (priv->gtkbuilder, filename, &error) <= 0)
+                                                                                               {
+                                                                                                       priv->gtkbuilder = NULL;
+                                                                                                       g_warning (_("Error on loading GtkBuilder file: %s\n"),
+                                                                                                                  error->message);
+                                                                                               }
+                                                                               }
+                                                               }
+                                               }
+
+                                       cur = cur->children;
+                                       while (cur)
+                                               {
+                                                       if (xmlStrcmp (cur->name, (const xmlChar *)"table") == 0)
+                                                               {
+                                                                       gtk_form_set_table (form, (gchar *)xmlNodeGetContent (cur));
+                                                               }
+                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"widget") == 0)
+                                                               {
+                                                                       widget = NULL;
+                                                                       modules = NULL;
+
+                                                                       type = xmlGetProp (cur, (const xmlChar *)"type");
+                                                                       if (g_strcmp0 (type, "checkbox") == 0)
+                                                                               {
+                                                                                       widget = gtk_form_widget_check_new ();
+                                                                               }
+                                                                       else if (g_strcmp0 (type, "combobox") == 0)
+                                                                               {
+                                                                                       widget = gtk_form_widget_combo_box_new ();
+                                                                               }
+                                                                       else if (g_strcmp0 (type, "entry") == 0)
+                                                                               {
+                                                                                       widget = gtk_form_widget_entry_new ();
+                                                                               }
+                                                                       else if (g_strcmp0 (type, "label") == 0)
+                                                                               {
+                                                                                       widget = gtk_form_widget_label_new ();
+                                                                               }
+                                                                       else if (g_strcmp0 (type, "radio") == 0)
+                                                                               {
+                                                                                       widget = gtk_form_widget_radio_new ();
+                                                                               }
+                                                                       else if (g_strcmp0 (type, "spin") == 0)
+                                                                               {
+                                                                                       widget = gtk_form_widget_spin_new ();
+                                                                               }
+                                                                       else if (g_strcmp0 (type, "textview") == 0)
+                                                                               {
+                                                                                       widget = gtk_form_widget_textview_new ();
+                                                                               }
+                                                                       else
+                                                                               {
+                                                                                       /* trying in modules */
+                                                                                       modules = g_list_first (priv->modules);
+                                                                                       while (modules != NULL)
+                                                                                               {
+                                                                                                       if (g_module_symbol ((GModule *)modules->data,
+                                                                                                                                g_strconcat ("gtk_form_widget_", type, "_new", NULL),
+                                                                                                                                (gpointer *)&widget_constructor))
+                                                                                                               {
+                                                                                                                       if (widget_constructor != NULL)
+                                                                                                                               {
+                                                                                                                                       widget = widget_constructor ();
+                                                                                                                                       break;
+                                                                                                                               }
+                                                                                                               }
+
+                                                                                                       modules = g_list_next (modules);
+                                                                                               }
+
+                                                                                       if (widget == NULL)
+                                                                                               {
+                                                                                                       g_warning (_("Unknown type Â«%s»."), type);
+                                                                                                       modules = NULL;
+                                                                                               }
+                                                                               }
+
+                                                                       if (widget != NULL)
+                                                                               {
+                                                                                       g_object_set (G_OBJECT (widget), "form", form, NULL);
+
+                                                                                       name = xmlGetProp (cur, (const xmlChar *)"name");
+
+                                                                                       if (GTK_IS_BUILDER (priv->gtkbuilder))
+                                                                                               {
+                                                                                                       gtk_form_widget_set_from_gtkbuilder (widget, priv->gtkbuilder, name);
+
+                                                                                                       label = xmlGetProp (cur, (const xmlChar *)"label");
+                                                                                                       if (label != NULL && g_strcmp0 (g_strstrip (label), "") != 0)
+                                                                                                               {
+                                                                                                                       GtkWidget *wlabel;
+                                                                                                                       wlabel = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, label));
+                                                                                                                       if (GTK_IS_LABEL (wlabel))
+                                                                                                                               {
+                                                                                                                                       gtk_form_widget_set_label (widget, wlabel);
+                                                                                                                               }
+                                                                                                                       else if ((g_strcmp0 (type, "checkbox") == 0
+                                                                                                                                 || g_strcmp0 (type, "radio") == 0)
+                                                                                                                                && g_strcmp0 (label, name) == 0)
+                                                                                                                               {
+                                                                                                                                       gtk_form_widget_set_label (widget, wlabel);
+                                                                                                                               }
+                                                                                                                       else
+                                                                                                                               {
+                                                                                                                                       g_warning (_("Label Â«%s» not found."), label);
+                                                                                                                               }
+                                                                                                               }
+                                                                                               }
+
+                                                                                       node_widget = cur->children;
+                                                                                       while (node_widget != NULL)
+                                                                                               {
+                                                                                                       if (xmlStrcmp (node_widget->name, (const xmlChar *)"column-field") == 0
+                                                                                                                        && IS_GTK_FORM_WIDGET_COMBO_BOX (widget))
+                                                                                                               {
+                                                                                                                       g_object_set (G_OBJECT (widget), "column-field",
+                                                                                                                                     strtol ((gchar *)xmlNodeGetContent (node_widget), NULL, 10), NULL);
+                                                                                                               }
+                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"sql") == 0
+                                                                                                                        && IS_GTK_FORM_WIDGET_COMBO_BOX (widget) && IS_GDAEX (priv->gdaex))
+                                                                                                               {
+                                                                                                                       gtk_form_widget_combo_box_fill_from_sql (widget,
+                                                                                                                                     priv->gdaex,
+                                                                                                                                     (gchar *)xmlNodeGetContent (node_widget),
+                                                                                                                                     gtk_form_field_boolean_str_to_boolean (xmlGetProp (node_widget, "with-empty-entry")));
+                                                                                                               }
+                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"return-value") == 0
+                                                                                                                        && IS_GTK_FORM_WIDGET_RADIO (widget))
+                                                                                                               {
+                                                                                                                       g_object_set (G_OBJECT (widget), "return-value",
+                                                                                                                                     xmlNodeGetContent (node_widget), NULL);
+                                                                                                               }
+                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"on-change") == 0)
+                                                                                                               {
+                                                                                                                       parse_widget_on_change (form, node_widget, widget);
+                                                                                                               }
+                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"field") == 0)
+                                                                                                               {
+                                                                                                                       field = NULL;
+
+                                                                                                                       type = xmlGetProp (node_widget, (const xmlChar *)"type");
+                                                                                                                       if (g_strcmp0 (type, "boolean") == 0)
+                                                                                                                               {
+                                                                                                                                       field = gtk_form_field_boolean_new ();
+                                                                                                                               }
+                                                                                                                       else if (g_strcmp0 (type, "datetime") == 0)
+                                                                                                                               {
+                                                                                                                                       field = gtk_form_field_datetime_new ();
+                                                                                                                               }
+                                                                                                                       else if (g_strcmp0 (type, "float") == 0)
+                                                                                                                               {
+                                                                                                                                       field = gtk_form_field_float_new ();
+                                                                                                                               }
+                                                                                                                       else if (g_strcmp0 (type, "integer") == 0)
+                                                                                                                               {
+                                                                                                                                       field = gtk_form_field_integer_new ();
+                                                                                                                               }
+                                                                                                                       else if (g_strcmp0 (type, "text") == 0)
+                                                                                                                               {
+                                                                                                                                       field = gtk_form_field_text_new ();
+                                                                                                                               }
+
+                                                                                                                       if (field != NULL)
+                                                                                                                               {
+                                                                                                                                       gchar *prop;
+
+                                                                                                                                       gtk_form_add_field (form, field);
+
+                                                                                                                                       name = xmlGetProp (node_widget, (const xmlChar *)"name");
+                                                                                                                                       g_object_set (G_OBJECT (field),
+                                                                                                                                                    "field", name,
+                                                                                                                                                    "form-widget", widget,
+                                                                                                                                                    NULL);
+
+                                                                                                                                       node_field = node_widget->children;
+                                                                                                                                       while (node_field != NULL)
+                                                                                                                                               {
+                                                                                                                                                       prop = (gchar *)xmlNodeGetContent (node_field);
+                                                                                                                                                       if (xmlStrcmp (node_field->name, (const xmlChar *)"long-name") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field),
+                                                                                                                                                                                     "long-name", prop,
+                                                                                                                                                                                     NULL);
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"to-load") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field),
+                                                                                                                                                                                     "to-load", gtk_form_field_boolean_str_to_boolean (prop),
+                                                                                                                                                                                     NULL);
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"to-save") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field),
+                                                                                                                                                                                     "to-save", gtk_form_field_boolean_str_to_boolean (prop),
+                                                                                                                                                                                     NULL);
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"obligatory") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field),
+                                                                                                                                                                                     "obligatory", gtk_form_field_boolean_str_to_boolean (prop),
+                                                                                                                                                                                     NULL);
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"default") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       if (g_strcmp0 (type, "boolean") == 0)
+                                                                                                                                                                               {
+                                                                                                                                                                                       gboolean value = gtk_form_field_boolean_str_to_boolean (prop);
+                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", value, NULL);
+                                                                                                                                                                               }
+                                                                                                                                                                       else if (g_strcmp0 (type, "datetime") == 0)
+                                                                                                                                                                               {
+                                                                                                                                                                                       struct tm *datetime;
+
+                                                                                                                                                                                       if (g_strcmp0 (prop, "now") == 0)
+                                                                                                                                                                                               {
+                                                                                                                                                                                                       time_t time_now;
+
+                                                                                                                                                                                                       time (&time_now);
+                                                                                                                                                                                                       datetime = localtime (&time_now);
+                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", datetime, NULL);
+                                                                                                                                                                                               }
+                                                                                                                                                                                       else
+                                                                                                                                                                                               {
+                                                                                                                                                                                                       datetime = gtk_form_field_datetime_get_tm_from_str (prop, "%Y-%m-%d %H:%M:%S");
+                                                                                                                                                                                                       if (datetime != NULL)
+                                                                                                                                                                                                               {
+                                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", datetime, NULL);
+                                                                                                                                                                                                               }
+                                                                                                                                                                                               }
+                                                                                                                                                                               }
+                                                                                                                                                                       else if (g_strcmp0 (type, "float") == 0)
+                                                                                                                                                                               {
+                                                                                                                                                                                       gfloat value = g_strtod (prop, NULL);
+                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", value, NULL);
+                                                                                                                                                                               }
+                                                                                                                                                                       else if (g_strcmp0 (type, "integer") == 0)
+                                                                                                                                                                               {
+                                                                                                                                                                                       gint value = strtol (prop, NULL, 10);
+                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", value, NULL);
+                                                                                                                                                                               }
+                                                                                                                                                                       else if (g_strcmp0 (type, "text") == 0)
+                                                                                                                                                                               {
+                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", prop, NULL);
+                                                                                                                                                                               }
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"is-key") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       if (gtk_form_field_boolean_str_to_boolean (prop))
+                                                                                                                                                                               {
+                                                                                                                                                                                       if (!IS_GTK_FORM_KEY (priv->key))
+                                                                                                                                                                                               {
+                                                                                                                                                                                                       priv->key = gtk_form_key_new ();
+                                                                                                                                                                                               }
+
+                                                                                                                                                                                       gtk_form_key_add_field (priv->key, field);
+                                                                                                                                                                               }
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"auto-increment") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       if (gtk_form_field_boolean_str_to_boolean (prop))
+                                                                                                                                                                               {
+                                                                                                                                                                                       g_object_set (G_OBJECT (field), "auto-increment", TRUE, NULL);
+                                                                                                                                                                               }
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"datetime-type") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       if (g_strcmp0 (type, "datetime") == 0)
+                                                                                                                                                                               {
+                                                                                                                                                                                       if (g_strcmp0 (prop, "date") == 0)
+                                                                                                                                                                                               {
+                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "type", GTK_FORM_FIELD_DATETIME_TYPE_DATE, NULL);
+                                                                                                                                                                                               
+                                                                                                                                                                                               }
+                                                                                                                                                                                       else if (g_strcmp0 (prop, "time") == 0)
+                                                                                                                                                                                               {
+                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "type", GTK_FORM_FIELD_DATETIME_TYPE_TIME, NULL);
+                                                                                                                                                                                               
+                                                                                                                                                                                               }
+                                                                                                                                                                               }
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"display-format") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       if (g_strcmp0 (type, "datetime") == 0)
+                                                                                                                                                                               {
+                                                                                                                                                                                       g_object_set (G_OBJECT (field), "display-format", prop, NULL);
+                                                                                                                                                                               }
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"trim") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field),
+                                                                                                                                                                                     "trim", gtk_form_field_boolean_str_to_boolean (prop),
+                                                                                                                                                                                     NULL);
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"min-value") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field), "min-value", prop, NULL);
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"max-value") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field), "max-value", prop, NULL);
+                                                                                                                                                               }
+                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"decimals") == 0
+                                                                                                                                                                && g_strcmp0 (type, "float") == 0)
+                                                                                                                                                               {
+                                                                                                                                                                       g_object_set (G_OBJECT (field), "decimals", strtol (prop, NULL, 10), NULL);
+                                                                                                                                                               }
+
+                                                                                                                                                       node_field = node_field->next;
+                                                                                                                                               }
+                                                                                                                               }
+                                                                                                                       else
+                                                                                                                               {
+                                                                                                                                       g_warning (_("Field of type Â«%s» not found."), type);
+                                                                                                                               }
+                                                                                                               }
+                                                                                                       else
+                                                                                                               {
+                                                                                                                       /* if the widget is a plugin,
+                                                                                                                          try to make xml parsing by the plugin */
+                                                                                                                       if (modules != NULL)
+                                                                                                                               {
+                                                                                                                                       if (g_module_symbol ((GModule *)modules->data,
+                                                                                                                                                                g_strconcat ("gtk_form_widget_", type, "_xml_parsing", NULL),
+                                                                                                                                                                                (gpointer *)&widget_xml_parsing))
+                                                                                                                                               {
+                                                                                                                                                       if (widget_xml_parsing != NULL)
+                                                                                                                                                               {
+                                                                                                                                                                       widget_xml_parsing (widget, node_widget);
+                                                                                                                                                               }
+                                                                                                                                               }
+                                                                                                                               }
+                                                                                                               }
+
+                                                                                                       node_widget = node_widget->next;
+                                                                                               }
+                                                                               }
+                                                                       else
+                                                                               {
+                                                                                       g_warning (_("Widget of type Â«%s» not found."), type);
+                                                                               }
+                                                               }
+                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"group") == 0)
+                                                               {
+                                                                       parse_group (form, cur);
+                                                               }
+                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"db-connection") == 0)
+                                                               {
+                                                                       parse_db_connection (form, cur);
+                                                               }
+
+                                                       cur = cur->next;
+                                               }
+                               }
+                       else
+                               {
+                                       /* TO DO */
+                                       g_warning (_("The file is not a valid gtkform definition file."));
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_load_from_file:
+ * @form:
+ * @filename:
+ * @gtkbuilder:
+ *
+ */
+gboolean
+gtk_form_load_from_file (GtkForm *form, const gchar *filename, GtkBuilder *gtkbuilder)
+{
+       xmlDoc *xdoc;
+
+       gboolean ret;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (filename != NULL, FALSE);
+
+       ret = FALSE;
+
+       xdoc = xmlParseFile (filename);
+       if (xdoc != NULL)
+               {
+                       ret = gtk_form_load_from_xml (form, xdoc, gtkbuilder);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_gtkbuilder:
+ * @form: a #GtkForm object.
+ *
+ */
+GtkBuilder
+*gtk_form_get_gtkbuilder (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       return priv->gtkbuilder;
+}
+
+/**
+ * gtk_form_get_table:
+ * @form: a #GtkForm object.
+ *
+ * Returns: the table's name associated to the form. Must be freed.
+ */
+gchar
+*gtk_form_get_table (GtkForm *form)
+{
+       gchar *ret;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), "");
+
+       ret = g_strdup ("");
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       ret = g_strdup (priv->table);
+
+       return ret;
+}
+
+/**
+ * gtk_form_set_table:
+ * @form: a #GtkForm object.
+ * @table:
+ *
+ */
+void
+gtk_form_set_table (GtkForm *form, const gchar *table)
+{
+       GtkFormPrivate *priv;
+
+       g_return_if_fail (IS_GTK_FORM (form));
+       g_return_if_fail (table != NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       priv->table = g_strstrip (g_strdup (table));
+}
+
+/**
+ * gtk_form_get_key:
+ * @form: a #GtkForm object.
+ *
+ * Returns: the #GtkFormKey associated to the form.
+ */
+GtkFormKey
+*gtk_form_get_key (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       return priv->key;
+}
+
+/**
+ * gtk_form_set_key:
+ * @form: a #GtkForm object.
+ * @key:
+ *
+ */
+void
+gtk_form_set_key (GtkForm *form, GtkFormKey *key)
+{
+       GtkFormPrivate *priv;
+
+       g_return_if_fail (IS_GTK_FORM (form));
+       g_return_if_fail (IS_GTK_FORM_KEY (key));
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       priv->key = key;
+}
+
+/**
+ * gtk_form_add_field:
+ * @form: a #GtkForm object.
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_add_field (GtkForm *form, GtkFormField *field)
+{
+       gboolean ret;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       ret = FALSE;
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       priv->fields = g_slist_append (priv->fields, field);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_remove_field:
+ * @form: a #GtkForm object.
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_remove_field (GtkForm *form, GtkFormField *field)
+{
+       gboolean ret = FALSE;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       priv->fields = g_slist_remove (priv->fields, field);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_add_fields:
+ * @form: a #GtkForm object.
+ * @...: a NULL terminated list of #GtkFormFields to add.
+ *
+ */
+gboolean
+gtk_form_add_fields (GtkForm *form, ...)
+{
+       GtkFormField *field;
+
+       va_list vargs;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+       va_start (vargs, form);
+
+       while ((field = va_arg (vargs, GtkFormField *)) != NULL)
+               {
+                       gtk_form_add_field (form, field);
+               }
+
+       va_end (vargs);
+}
+
+/**
+ * gtk_form_get_form_field_from_name:
+ * @form: a #GtkForm object.
+ * @field_name:
+ *
+ */
+GtkFormField
+*gtk_form_get_form_field_from_name (GtkForm *form, const gchar *field_name)
+{
+       GtkFormField *field = NULL;
+       const gchar *name;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+       g_return_val_if_fail (field_name != NULL, NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       GSList *fields = priv->fields;
+       while (fields != NULL)
+               {
+                       name = gtk_form_field_get_field_name ((GtkFormField *)fields->data);
+                       if (g_strcmp0 (name, field_name) == 0)
+                               {
+                                       field = (GtkFormField *)fields->data;
+                                       break;
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return field;
+}
+
+/**
+ * gtk_form_get_form_widget_from_name:
+ * @form: a #GtkForm object.
+ * @widget_name: the #GtkFormWidget's name to return.
+ *
+ * Returns: a #GtkFormWidget.
+ */
+GtkFormWidget
+*gtk_form_get_form_widget_from_name (GtkForm *form, const gchar *widget_name)
+{
+       GtkFormWidget *widget = NULL;
+       GtkFormWidget *widget_ret = NULL;
+       gchar *name;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+       g_return_val_if_fail (widget_name != NULL, NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       GSList *fields = priv->fields;
+       while (fields != NULL)
+               {
+                       widget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
+
+                       if (g_strcmp0 (gtk_form_widget_get_widget_name (widget), widget_name) == 0)
+                               {
+                                       widget_ret = widget;
+                                       break;
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return widget_ret;
+}
+
+/**
+ * gtk_form_get_widget_from_form_field_name:
+ * @form: a #GtkForm object.
+ * @field_name: the #GtkFormField's name to return.
+ *
+ * Returns: a #GtkWidget.
+ */
+GtkWidget
+*gtk_form_get_widget_from_form_field_name (GtkForm *form, const gchar *field_name)
+{
+       GtkFormField *field = NULL;
+       GtkFormWidget *widget = NULL;
+       GtkWidget *widget_ret = NULL;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+       g_return_val_if_fail (field_name != NULL, NULL);
+
+       field = gtk_form_get_form_field_from_name (form, field_name);
+       if (field != NULL)
+               {
+                       widget = gtk_form_field_get_form_widget (field);
+                       if (widget != NULL)
+                               {
+                                       widget_ret = gtk_form_widget_get_widget (widget);
+                               }
+               }
+
+       return widget_ret;
+}
+
+/**
+ * gtk_form_get_widget_from_form_widget_name:
+ * @form: a #GtkForm object.
+ * @widget_name: the #GtkFormWidget's name to return.
+ *
+ * Returns: a #GtkWidget.
+ */
+GtkWidget
+*gtk_form_get_widget_from_form_widget_name (GtkForm *form, const gchar *widget_name)
+{
+       GtkFormWidget *widget = NULL;
+       GtkWidget *widget_ret = NULL;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+       g_return_val_if_fail (widget_name != NULL, NULL);
+
+       widget = gtk_form_get_form_widget_from_name (form, widget_name);
+       if (widget != NULL)
+               {
+                       widget_ret = gtk_form_widget_get_widget (widget);
+               }
+
+       return widget_ret;
+}
+
+/**
+ * gtk_form_get_form_field_from_widget:
+ * @form: a #GtkForm object.
+ * @widget: a #GtkWidget object.
+ *
+ */
+GtkFormField
+*gtk_form_get_form_field_from_widget (GtkForm *form, GtkWidget *widget)
+{
+       GtkFormWidget *fwidget = NULL;
+       GtkFormField *field = NULL;
+       GtkFormWidget *widget_ret = NULL;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+       g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       GSList *fields = priv->fields;
+       while (fields != NULL)
+               {
+                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
+
+                       if (gtk_form_widget_get_widget (fwidget) == widget)
+                               {
+                                       field = (GtkFormField *)fields->data;
+                                       break;
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return field;
+}
+
+/**
+ * gtk_form_get_form_widget_from_widget:
+ * @form: a #GtkForm object.
+ * @widget: a #GtkWidget object.
+ *
+ */
+GtkFormWidget
+*gtk_form_get_form_widget_from_widget (GtkForm *form, GtkWidget *widget)
+{
+       GtkFormWidget *fwidget = NULL;
+       GtkFormWidget *widget_ret = NULL;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+       g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       GSList *fields = priv->fields;
+       while (fields != NULL)
+               {
+                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
+
+                       if (gtk_form_widget_get_widget (fwidget) == widget)
+                               {
+                                       widget_ret = fwidget;
+                                       break;
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return widget_ret;
+}
+
+/**
+ * gtk_form_get_widgets:
+ * @form: a #GtkForm object.
+ *
+ * Returns: an array of all the #GtkWidget into the form. Must be free.
+ */ 
+GtkWidget
+**gtk_form_get_widgets (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+
+       GtkWidget **ret;
+
+       GSList *fields;
+       guint l;
+
+       GtkFormWidget *form_widget;
+       GtkWidget *widget;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       ret = NULL;
+       l = 0;
+
+       fields = priv->fields;
+       while (fields != NULL)
+               {
+                       l++;
+                       if (l == 1)
+                               {
+                                       ret = g_malloc (sizeof (GtkWidget *));
+                               }
+                       else
+                               {
+                                       ret = g_realloc (ret, l * sizeof (GtkWidget *));
+                               }
+
+                       form_widget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
+                       widget = gtk_form_widget_get_widget (form_widget);
+                       ret[l] = widget;
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_objects_by_name:
+ * @form: a #GtkForm object.
+ * @...: a NULL terminated list of objects name (gchar *) to return.
+ *
+ * Returns: an array of #GObject present in the #GtkBuilder object assigned to
+ * the form. Must be free.
+ */
+GObject
+**gtk_form_get_objects_by_name (GtkForm *form, ...)
+{
+       GObject **ret;
+
+       GtkFormPrivate *priv;
+
+       va_list vargs;
+       gchar *object_name;
+       guint l;
+
+       GObject *object;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       g_return_val_if_fail (GTK_IS_BUILDER (priv->gtkbuilder), NULL);
+
+       ret = NULL;
+       l = 0;
+
+       va_start (vargs, form);
+
+       while ((object_name = va_arg (vargs, gchar *)) != NULL)
+               {
+                       l++;
+                       if (l == 1)
+                               {
+                                       ret = g_malloc (sizeof (GObject *));
+                               }
+                       else
+                               {
+                                       ret = g_realloc (ret, l * sizeof (GObject *));
+                               }
+
+                       object = gtk_builder_get_object (priv->gtkbuilder, object_name);
+                       if (G_IS_OBJECT (object))
+                               {
+                                       ret[l - 1] = object;
+                               }
+                       else
+                               {
+                                       ret[l - 1] = NULL;
+                                       g_warning (_("Object Â«%s» not found."), object_name);
+                               }
+               }
+
+       va_end (vargs);
+
+       return ret;
+}
+
+/**
+ * gtk_form_clear:
+ * @form: a #GtkForm object.
+ *
+ */
+gboolean
+gtk_form_clear (GtkForm *form)
+{
+       GtkFormField *field;
+       gboolean ret = FALSE;
+       GtkFormPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       GSList *fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       gtk_form_field_clear (field);
+
+                       fields = g_slist_next (fields);
+               }
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_check:
+ * @form: a #GtkForm object.
+ * @with_key: whether check also the key or not.
+ * @form_widget: a #GtkFormWidget.
+ * @show_error_dialog:
+ * @parent_window:
+ * @set_focus:
+ *
+ * Returns: TRUE if all obligatory fields are full and @widget is NULL. Otherwise
+ * if @widget isn't NULL, it is the first #GtkFormWidget empty.
+ */
+gboolean
+gtk_form_check (GtkForm *form, gboolean with_key, GtkFormWidget **form_widget,
+                gboolean show_error_dialog, GtkWidget *parent_window,
+                gboolean set_focus)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       GtkFormField *field;
+       GtkFormWidget *fwidget;
+       GtkWidget *widget;
+
+       gboolean ret;
+       gboolean to_save;
+       gboolean obl;
+       gboolean is_empty;
+       gboolean is_valid;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+       if (show_error_dialog)
+               {
+                       g_return_val_if_fail (GTK_IS_WINDOW (parent_window), FALSE);
+               }
+
+       ret = TRUE;
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       g_object_get (G_OBJECT (field),
+                                     "to-save", &to_save,
+                                     "obligatory", &obl,
+                                     NULL);
+
+                       is_empty = gtk_form_field_is_empty (field);
+                       is_valid = gtk_form_field_is_valid (field);
+                       if (to_save
+                           && ((obl && is_empty) || !is_valid))
+                               {
+                                       ret = FALSE;
+
+                                       fwidget = gtk_form_field_get_form_widget (field);
+                                       widget = gtk_form_widget_get_widget (fwidget);
+
+                                       if (form_widget != NULL && *form_widget == NULL)
+                                               {
+                                                       *form_widget = fwidget;
+                                               }
+
+                                       if (show_error_dialog)
+                                               {
+                                                       gtk_form_show_check_error_dialog (fwidget, parent_window,
+                                                                                         obl && is_empty ? _(" is obligatory") : _(" isn't valid"));
+                                               }
+
+                                       if (set_focus)
+                                               {
+                                                       gtk_widget_grab_focus (widget);
+                                               }
+                                       break;
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       if (with_key && ret && IS_GTK_FORM_KEY (priv->key))
+               {
+                       GtkFormWidget *key_form_widget = NULL;
+
+                       ret = gtk_form_key_check (priv->key, &key_form_widget);
+
+                       if (!ret && form_widget != NULL && *form_widget == NULL && key_form_widget != NULL)
+                               {
+                                       *form_widget = key_form_widget;
+                               }
+
+                       if (!ret && key_form_widget != NULL && show_error_dialog)
+                               {
+                                       gtk_form_show_check_error_dialog (key_form_widget, parent_window, _(" is obligatory"));
+                               }
+
+                       if (!ret && key_form_widget != NULL && set_focus)
+                               {
+                                       gtk_widget_grab_focus (gtk_form_widget_get_widget (key_form_widget));
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_is_changed:
+ * @form: a #GtkForm object.
+ *
+ * Returns: TRUE if the values in the form are changed since last calling to
+ * gtk_form_clear(), gtk_form_fill_from_datamodel() or gtk_form_set_as_origin().
+ */
+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;
+
+                       if (gtk_form_field_is_to_save (field))
+                               {
+                                       ret = gtk_form_field_is_changed (field);
+                                       if (ret)
+                                               {
+                                                       if (priv->debug > 0)
+                                                               {
+                                                                       g_debug (_("Field Â«%s» is changed."), gtk_form_field_get_field_name (field));
+                                                               }
+                                                       break;
+                                               }
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       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.
+ * @sensitive: whether to set every #GtkFormWidget's sensitive or not.
+ *
+ */
+void
+gtk_form_set_sensitive (GtkForm *form, gboolean sensitive)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       GtkFormWidget *fwidget;
+       GtkWidget *widget;
+
+       g_return_if_fail (IS_GTK_FORM (form));
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+       while (fields != NULL)
+               {
+                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
+
+                       widget = gtk_form_widget_get_widget (fwidget);
+                       gtk_widget_set_sensitive (widget, sensitive);
+
+                       fields = g_slist_next (fields);
+               }
+}
+
+/**
+ * gtk_form_set_sensitive_by_name:
+ * @form: a #GtkForm object.
+ * @sensitive: whether to set #GtkWidget's sensitive or not.
+ * @...:
+ *
+ */
+void
+gtk_form_set_sensitive_by_name (GtkForm *form, gboolean sensitive, ...)
+{
+       GtkFormPrivate *priv;
+
+       va_list vargs;
+       gchar *object_name;
+
+       GObject *object;
+
+       g_return_if_fail (IS_GTK_FORM (form));
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       g_return_if_fail (GTK_IS_BUILDER (priv->gtkbuilder));
+
+       va_start (vargs, sensitive);
+
+       while ((object_name = va_arg (vargs, gchar *)) != NULL)
+               {
+                       object = gtk_builder_get_object (priv->gtkbuilder, object_name);
+                       if (GTK_IS_WIDGET (object))
+                               {
+                                       gtk_widget_set_sensitive (GTK_WIDGET (object), sensitive);
+                               }
+                       else
+                               {
+                                       g_warning (_("Object Â«%s» not found."), object_name);
+                               }
+               }
+
+       va_end (vargs);
+}
+
+/**
+ * gtk_form_set_editable:
+ * @form: a #GtkForm object.
+ * @editable: whether to set every #GtkFormWidget editable or not.
+ *
+ */
+void
+gtk_form_set_editable (GtkForm *form, gboolean editable)
+{
+       GtkFormWidget *fwidget;
+       GtkFormPrivate *priv;
+       GSList *fields;
+
+       g_return_if_fail (IS_GTK_FORM (form));
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+       while (fields != NULL)
+               {
+                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
+
+                       gtk_form_widget_set_editable (fwidget, editable);
+
+                       fields = g_slist_next (fields);
+               }
+}
+
+/**
+ * gtk_form_set_visible_by_name:
+ * @form: a #GtkForm object.
+ * @visible: whether to set #GtkWidget's sensitive or not.
+ * @...: a #NULL terminated list of #GtkWidgets's names (on #GtkBuilder).
+ *
+ */
+void
+gtk_form_set_visible_by_name (GtkForm *form, gboolean visible, ...)
+{
+       GtkFormPrivate *priv;
+
+       va_list vargs;
+       gchar *widget_name;
+
+       GObject *widget;
+
+       g_return_if_fail (IS_GTK_FORM (form));
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       g_return_if_fail (GTK_IS_BUILDER (priv->gtkbuilder));
+
+       va_start (vargs, visible);
+
+       while ((widget_name = va_arg (vargs, gchar *)) != NULL)
+               {
+                       widget = gtk_builder_get_object (priv->gtkbuilder, widget_name);
+                       if (GTK_IS_WIDGET (widget))
+                               {
+                                       if (visible)
+                                               {
+                                                       gtk_widget_show (GTK_WIDGET (widget));
+                                               }
+                                       else
+                                               {
+                                                       gtk_widget_hide (GTK_WIDGET (widget));
+                                               }
+                               }
+                       else
+                               {
+                                       g_warning (_("Object Â«%s» not found."), widget_name);
+                               }
+               }
+
+       va_end (vargs);
+}
+
+/**
+ * gtk_form_set_form_widgets_visible_by_name:
+ * @form: a #GtkForm object.
+ * @visible: whether to set every #GtkFormWidget visible or not.
+ * @...: a #NULL terminated list of #GtkFormWidgets's names.
+ *
+ */
+void
+gtk_form_set_form_widgets_visible_by_name (GtkForm *form, gboolean visible, ...)
+{
+       GtkFormPrivate *priv;
+
+       va_list vargs;
+       gchar *fwidget_name;
+
+       GtkFormWidget *fwidget;
+
+       g_return_if_fail (IS_GTK_FORM (form));
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       g_return_if_fail (GTK_IS_BUILDER (priv->gtkbuilder));
+
+       va_start (vargs, visible);
+
+       while ((fwidget_name = va_arg (vargs, gchar *)) != NULL)
+               {
+                       fwidget = gtk_form_get_form_widget_from_name (form, fwidget_name);
+                       if (IS_GTK_FORM_WIDGET (fwidget))
+                               {
+                                       gtk_form_widget_set_visible (fwidget, visible);
+                               }
+                       else
+                               {
+                                       g_warning (_("Object Â«%s» not found."), fwidget_name);
+                               }
+               }
+
+       va_end (vargs);
+}
+
+/**
+ * gtk_form_get_form_field_value_by_name:
+ * @form: a #GtkForm object.
+ * @field_name:
+ *
+ */
+GValue
+*gtk_form_get_form_field_value_by_name (GtkForm *form, const gchar *field_name)
+{
+       GValue *ret;
+       GtkFormField *field;
+
+       ret = NULL;
+
+       field = gtk_form_get_form_field_from_name (form, field_name);
+       ret = gtk_form_field_get_value (field);
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_form_widget_value_by_name:
+ * @form: a #GtkForm object.
+ * @widget_name:
+ *
+ */
+GValue
+*gtk_form_get_form_widget_value_by_name (GtkForm *form, const gchar *widget_name)
+{
+       GValue *ret;
+       GtkFormWidget *fwidget;
+       GtkFormField *field;
+
+       ret = NULL;
+
+       fwidget = gtk_form_get_form_widget_from_name (form, widget_name);
+       if (IS_GTK_FORM_WIDGET (fwidget))
+               {
+                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
+                       ret = gtk_form_field_get_value (field);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_form_field_value_stringify_by_name:
+ * @form: a #GtkForm object.
+ * @field_name:
+ *
+ */
+const gchar
+*gtk_form_get_form_field_value_stringify_by_name (GtkForm *form, const gchar *field_name)
+{
+       gchar *ret;
+       GtkFormField *field;
+
+       ret = NULL;
+
+       field = gtk_form_get_form_field_from_name (form, field_name);
+       ret = gtk_form_field_get_value_stringify (field);
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_form_widget_value_stringify_by_name:
+ * @form: a #GtkForm object.
+ * @widget_name:
+ *
+ */
+const gchar
+*gtk_form_get_form_widget_value_stringify_by_name (GtkForm *form, const gchar *widget_name)
+{
+       gchar *ret;
+       GtkFormWidget *fwidget;
+       GtkFormField *field;
+
+       ret = NULL;
+
+       fwidget = gtk_form_get_form_widget_from_name (form, widget_name);
+       if (IS_GTK_FORM_WIDGET (fwidget))
+               {
+                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
+                       ret = gtk_form_field_get_value_stringify (field);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_form_field_value_sql_by_name:
+ * @form: a #GtkForm object.
+ * @field_name:
+ *
+ */
+const gchar
+*gtk_form_get_form_field_value_sql_by_name (GtkForm *form, const gchar *field_name)
+{
+       gchar *ret;
+       GtkFormField *field;
+
+       ret = NULL;
+
+       field = gtk_form_get_form_field_from_name (form, field_name);
+       ret = gtk_form_field_get_value_sql (field);
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_form_widget_value_sql_by_name:
+ * @form: a #GtkForm object.
+ * @widget_name:
+ *
+ */
+const gchar
+*gtk_form_get_form_widget_value_sql_by_name (GtkForm *form, const gchar *widget_name)
+{
+       gchar *ret;
+       GtkFormWidget *fwidget;
+       GtkFormField *field;
+
+       ret = NULL;
+
+       fwidget = gtk_form_get_form_widget_from_name (form, widget_name);
+       if (IS_GTK_FORM_WIDGET (fwidget))
+               {
+                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
+                       ret = gtk_form_field_get_value_sql (field);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_sql:
+ * @form: a #GtkForm object.
+ * @type: SQL's type that returns.
+ *
+ * Returns: the SQL string.
+ */
+gchar
+*gtk_form_get_sql (GtkForm *form, GtkFormSqlType type)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       GtkFormField *field;
+       gchar *sql = "";
+       gchar *fields_names = "";
+       gchar *values = "";
+       const gchar *value;
+       gchar *where = "";
+       const gchar *field_name;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), sql);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       field_name = gtk_form_field_get_field_name (field);
+
+                       if (field_name != NULL && g_strcmp0 (field_name, "") != 0)
+                               {
+                                       field_name = g_strconcat (&priv->quote, field_name, &priv->quote, NULL);
+                                       if (g_strstr_len (fields_names, -1, field_name) == NULL)
+                                               {
+                                                       switch (type)
+                                                               {
+                                                                       case GTK_FORM_SQL_SELECT:
+                                                                               if (gtk_form_field_is_to_load (field))
+                                                                                       {
+                                                                                               fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
+                                                                                       }
+                                                                               break;
+
+                                                                       case GTK_FORM_SQL_INSERT:
+                                                                               if (gtk_form_field_is_to_save (field))
+                                                                                       {
+                                                                                               if (gtk_form_field_is_auto_increment (field))
+                                                                                                       {
+                                                                                                               GdaDataModel *dm;
+                                                                                                               gchar *field_name;
+                                                                                                               guint new_val;
+
+                                                                                                               g_return_val_if_fail (IS_GDAEX (priv->gdaex), NULL);
+
+                                                                                                               g_object_get (field, "field", &field_name, NULL);
+
+                                                                                                               new_val = 0;
+                                                                                                               dm = gdaex_query (priv->gdaex,
+                                                                                                                                                 g_strdup_printf ("SELECT COALESCE (MAX (%s), 0) FROM %s",
+                                                                                                                                                 field_name,
+                                                                                                                                                 priv->table));
+                                                                                                               if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
+                                                                                                                       {
+                                                                                                                               new_val = gdaex_data_model_get_value_integer_at (dm, 0, 0);
+                                                                                                                       }
+                                                                                                               new_val++;
+
+                                                                                                               gtk_form_widget_set_value_stringify (gtk_form_field_get_form_widget (field), g_strdup_printf ("%d", new_val));
+                                                                                                       }
+                                                                                       
+                                                                                               value = gtk_form_field_get_value_sql (field);
+                                                                                               if (value != NULL)
+                                                                                                       {
+                                                                                                               fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
+                                                                                                               values = g_strconcat (values, value, ", ", NULL);
+                                                                                                       }
+                                                                                       }
+                                                                               break;
+
+                                                                       case GTK_FORM_SQL_UPDATE:
+                                                                               if (gtk_form_field_is_to_save (field)
+                                                                                       && (!IS_GTK_FORM_KEY (priv->key) ||
+                                                                                       !gtk_form_key_field_is_key (priv->key, field)))
+                                                                                       {
+                                                                                               value = gtk_form_field_get_value_sql (field);
+                                                                                               if (value != NULL)
+                                                                                                       {
+                                                                                                               fields_names = g_strconcat (fields_names, field_name, " = ", value, ", ", NULL);
+                                                                                                       }
+                                                                                       }
+                                                                               break;
+                                                               }
+                                               }
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       if (g_str_has_suffix (fields_names, ", "))
+               {
+                       fields_names[strlen (fields_names) - 2] = '\0';
+               }
+       if (g_str_has_suffix (values, ", "))
+               {
+                       values[strlen (values) - 2] = '\0';
+               }
+
+       switch (type)
+               {
+                       case GTK_FORM_SQL_SELECT:
+                               sql = g_strconcat ("SELECT ", fields_names, " FROM ", priv->table, NULL);
+                               break;
+
+                       case GTK_FORM_SQL_INSERT:
+                               sql = g_strconcat ("INSERT INTO ", priv->table, " (", fields_names, ") VALUES (", values, ")", NULL);
+                               break;
+
+                       case GTK_FORM_SQL_UPDATE:
+                               sql = g_strconcat ("UPDATE ", priv->table, " SET ", fields_names, NULL);
+                               break;
+
+                       case GTK_FORM_SQL_DELETE:
+                               sql = g_strconcat ("DELETE FROM ", priv->table, NULL);
+                               break;
+               }
+
+       if (IS_GTK_FORM_KEY (priv->key)
+           && (type == GTK_FORM_SQL_SELECT || type == GTK_FORM_SQL_UPDATE || type == GTK_FORM_SQL_DELETE))
+               {
+                       where = gtk_form_key_get_sql (priv->key);
+                       if (where != NULL && g_strcmp0 (where, "") != 0)
+                               {
+                                       sql = g_strconcat (sql, where, NULL);
+                               }
+               }
+
+       return sql;
+}
+
+/**
+ * gtk_form_fill_from_datamodel:
+ * @form: a #GtkForm object.
+ * @dm: the #GdaDataModel from which fill the #GtkForm.
+ * @row: the #GdaDataModel's row from which read data.
+ *
+ */
+gboolean
+gtk_form_fill_from_datamodel (GtkForm *form, GdaDataModel *dm, gint row)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       gboolean ret = TRUE;
+       GtkFormField *field;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       if (gtk_form_field_is_to_load (field))
+                               {
+                                       gtk_form_field_set_from_datamodel (field, dm, row);
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_fill_from_table:
+ * @form: a #GtkForm object.
+ *
+ */
+gboolean
+gtk_form_fill_from_table (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+       gchar *sql;
+       GdaDataModel *dm;
+
+       gboolean ret = TRUE;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       g_return_val_if_fail (IS_GDAEX (priv->gdaex), FALSE);
+
+       sql = gtk_form_get_sql (form, GTK_FORM_SQL_SELECT);
+
+       dm = gdaex_query (priv->gdaex, sql);
+       if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
+               {
+                       ret = gtk_form_fill_from_datamodel (form, dm, 0);
+
+                       g_object_unref (dm);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_reset:
+ * @form:
+ *
+ */
+gboolean
+gtk_form_reset (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       gboolean ret = TRUE;
+       GtkFormField *field;
+       GtkFormWidget *widget;
+       GValue *gval;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       gval = gtk_form_field_get_original_value (field);
+                       gtk_form_field_set_value (field, gval);
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_values_as_hashtable:
+ * @form: a #GtkForm object.
+ *
+ */
+GHashTable
+*gtk_form_get_values_as_hashtable (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       GtkFormField *field;
+       gchar *field_name;
+       GValue *gval;
+       GHashTable *ht;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+
+       if (fields != NULL)
+               {
+                       ht = g_hash_table_new (g_str_hash, g_str_equal);
+               }
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       field_name = gtk_form_field_get_field_name (field);
+
+                       gval = gtk_form_field_get_value (field);
+                       if (gval != NULL)
+                               {
+                                       /* TODO check if the field already exists */
+                                       g_hash_table_insert (ht, field_name, gval);
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ht;
+}
+
+/**
+ * gtk_form_get_original_values_as_hashtable:
+ * @form:
+ *
+ */
+GHashTable
+*gtk_form_get_original_values_as_hashtable (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       GtkFormField *field;
+       gchar *field_name;
+       GValue *gval;
+       GHashTable *ht;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+
+       if (fields != NULL)
+               {
+                       ht = g_hash_table_new (g_str_hash, g_str_equal);
+               }
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       field_name = gtk_form_field_get_field_name (field);
+
+                       gval = gtk_form_field_get_original_value (field);
+                       if (gval != NULL)
+                               {
+                                       /* TODO check if the field already exists */
+                                       g_hash_table_insert (ht, field_name, gval);
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ht;
+}
+
+/**
+ * gtk_form_fill_from_hashtable:
+ * @form: a #GtkForm object.
+ * @hashtable: a @GHashTable object.
+ *
+ */
+gboolean
+gtk_form_fill_from_hashtable (GtkForm *form, GHashTable *hashtable)
+{
+       GtkFormPrivate *priv;
+       GSList *fields;
+       GtkFormField *field;
+
+       gboolean ret;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       if (gtk_form_field_is_to_load (field))
+                               {
+                                       gtk_form_field_set_from_hashtable (field, hashtable);
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_add_group:
+ * @form:
+ * @group:
+ *
+  */
+gboolean
+gtk_form_add_group (GtkForm *form, GtkFormGroup *group)
+{
+       gboolean ret;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
+
+       GtkFormPrivate *priv;
+
+       ret = FALSE;
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       priv->groups = g_slist_append (priv->groups, group);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_group_by_name:
+ * @form:
+ * @group_name:
+ *
+ */
+GtkFormGroup
+*gtk_form_get_group_by_name (GtkForm *form, const gchar *group_name)
+{
+       GtkFormGroup *g;
+
+       gchar *new_g_name;
+       GSList *gs;
+       gchar *g_name;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+       g_return_val_if_fail (group_name != NULL, NULL);
+
+       new_g_name = g_strstrip (g_strdup (group_name));
+
+       g_return_val_if_fail (g_strcmp0 (new_g_name, "") != 0, NULL);
+
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+
+       g = NULL;
+
+       gs = priv->groups;
+       while (gs != NULL)
+               {
+                       g_name = gtk_form_group_get_name ((GtkFormGroup *)gs->data);
+                       if (g_strcmp0 (g_name, new_g_name) == 0)
+                               {
+                                       g = (GtkFormGroup *)gs->data;
+                                       break;
+                               }
+
+                       gs = gs->next;
+               }
+
+       return g;
+}
+
+/**
+ * gtk_form_add_db_connection:
+ * @form:
+ * @name:
+ * @connection_string:
+ *
+ */
+gboolean
+gtk_form_add_db_connection (GtkForm *form, const gchar *name, const gchar *connection_string)
+{
+       gboolean ret;
+
+       gchar *_name;
+       gchar *_cnc_string;
+
+       GSList *dbs;
+       GtkFormDbConnection *dbc;
+       GtkFormDbConnection *dbc_new;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (name != NULL, FALSE);
+       g_return_val_if_fail (connection_string != NULL, FALSE);
+
+       GtkFormPrivate *priv;
+
+       ret = FALSE;
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       _name = g_strstrip (g_strdup (name));
+       if (g_strcmp0 (_name, "") == 0)
+               {
+                       return FALSE;
+               }
+       _cnc_string = g_strstrip (g_strdup (connection_string));
+       if (g_strcmp0 (_cnc_string, "") == 0)
+               {
+                       return FALSE;
+               }
+
+       dbc = NULL;
+       dbs = priv->db_connections;
+       while (dbs != NULL)
+               {
+                       dbc = (GtkFormDbConnection *)dbs->data;
+                       if (g_strcmp0 (dbc->cnc_string, _cnc_string) == 0)
+                               {
+                                       break;
+                               }
+                       dbc = NULL;
+
+                       dbs = dbs->next;
+               }
+
+       if (dbc != NULL)
+               {
+                       if (g_strcmp0 (dbc->name, _name) != 0)
+                               {
+                                       dbc_new = g_new0 (GtkFormDbConnection, 1);
+                                       dbc_new->name = g_strdup (_name);
+                                       dbc_new->cnc_string = g_strdup (_cnc_string);
+                                       dbc_new->gdaex = g_object_ref (dbc->gdaex);
+                                       priv->db_connections = g_slist_append (priv->db_connections, dbc_new);
+                               }
+               }
+       else
+               {
+                       dbc_new = g_new0 (GtkFormDbConnection, 1);
+                       dbc_new->gdaex = gdaex_new_from_string (_cnc_string);
+                       if (dbc_new->gdaex != NULL)
+                               {
+                                       dbc_new->name = g_strdup (_name);
+                                       dbc_new->cnc_string = g_strdup (_cnc_string);
+
+                                       priv->db_connections = g_slist_append (priv->db_connections, dbc_new);
+                               }
+                       else
+                               {
+                                       g_free (dbc_new);
+                                       return FALSE;
+                               }
+               }
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_add_db_connection:
+ * @form:
+ * @name:
+ * @gdaex:
+ *
+ */
+gboolean
+gtk_form_add_db_connection_gdaex (GtkForm *form, const gchar *name, GdaEx *gdaex)
+{
+       gboolean ret;
+       gchar *_name;
+       GSList *dbs;
+       GtkFormDbConnection *dbc;
+       GtkFormDbConnection *dbc_new;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+       g_return_val_if_fail (name != NULL, FALSE);
+       g_return_val_if_fail (IS_GDAEX (gdaex), FALSE);
+
+       _name = g_strstrip (g_strdup (name));
+
+       g_return_val_if_fail (g_strcmp0 (_name, "") != 0, FALSE);
+
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+
+       ret = FALSE;
+
+       dbs = priv->db_connections;
+       while (dbs != NULL)
+               {
+                       dbc = (GtkFormDbConnection *)dbs->data;
+                       if (g_strcmp0 (dbc->name, _name) == 0)
+                               {
+                                       dbc->gdaex = gdaex;
+                                       return TRUE;
+                               }
+
+                       dbs = dbs->next;
+               }
+
+       dbc_new = g_new0 (GtkFormDbConnection, 1);
+       dbc_new->name = g_strdup (_name);
+       dbc_new->cnc_string = g_strdup (gda_connection_get_cnc_string ((GdaConnection *)gdaex_get_gdaconnection (gdaex)));
+       dbc_new->gdaex = gdaex;
+
+       priv->db_connections = g_slist_append (priv->db_connections, dbc_new);
+
+       return TRUE;
+}
+
+/**
+ * gtk_form_get_db_connection_by_name:
+ * @form:
+ * @name:
+ *
+ * Returns: if @name is #NULL, the default #GdaEx connection; otherwise
+ * the connection associated with the name requested.
+ */
+GdaEx
+*gtk_form_get_db_connection_by_name (GtkForm *form, const gchar *name)
+{
+       GdaEx *gdaex;
+
+       gchar *_name;
+       GSList *dbs;
+       GtkFormDbConnection *dbc;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+
+       if (name == NULL)
+               {
+                       return priv->gdaex;
+               }
+
+       _name = g_strstrip (g_strdup (name));
+
+       g_return_val_if_fail (g_strcmp0 (_name, "") != 0, NULL);
+
+       gdaex = NULL;
+
+       dbs = priv->db_connections;
+       while (dbs != NULL)
+               {
+                       dbc = (GtkFormDbConnection *)dbs->data;
+                       if (g_strcmp0 (dbc->name, _name) == 0)
+                               {
+                                       gdaex = dbc->gdaex;
+                                       break;
+                               }
+
+                       dbs = dbs->next;
+               }
+
+       return gdaex;
+}
+
+/* PRIVATE */
+static void
+gtk_form_set_property (GObject *object,
+                   guint property_id,
+                   const GValue *value,
+                   GParamSpec *pspec)
+{
+       GtkForm *form = (GtkForm *)object;
+
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+
+       switch (property_id)
+               {
+                       case PROP_TABLE:
+                               gtk_form_set_table (form, g_value_get_string (value));
+                               break;
+
+                       case PROP_KEY:
+                               gtk_form_set_key (form, GTK_FORM_KEY (g_value_get_object (value)));
+                               break;
+
+                       case PROP_QUOTE:
+                               priv->quote = g_value_get_char (value);
+                               break;
+
+                       case PROP_GDAEX:
+                               priv->gdaex = g_value_get_pointer (value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_get_property (GObject *object,
+                   guint property_id,
+                   GValue *value,
+                   GParamSpec *pspec)
+{
+       GtkForm *form = (GtkForm *)object;
+
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+
+       switch (property_id)
+               {
+                       case PROP_TABLE:
+                               g_value_set_string (value, gtk_form_get_table (form));
+                               break;
+
+                       case PROP_KEY:
+                               g_value_set_object (value, gtk_form_get_key (form));
+                               break;
+
+                       case PROP_QUOTE:
+                               g_value_set_char (value, priv->quote);
+                               break;
+
+                       case PROP_GDAEX:
+                               g_value_set_pointer (value, priv->gdaex);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_show_check_error_dialog (GtkFormWidget *fwidget,
+                                  GtkWidget *parent_window,
+                                  const gchar *message)
+{
+       GtkWidget *dialog;
+       GtkWidget *label;
+       GtkFormField *field;
+
+       gchar *label_text;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
+       g_return_if_fail (GTK_IS_WINDOW (parent_window));
+
+       label_text = NULL;
+
+       label = gtk_form_widget_get_label (fwidget);
+       if (GTK_IS_LABEL (label))
+               {
+                       label_text = (gchar *)gtk_label_get_text (GTK_LABEL (label));
+               }
+       else
+               {
+                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
+                       if (IS_GTK_FORM_FIELD (field))
+                               {
+                                       label_text = gtk_form_field_get_field_long_name (field);
+                                       if (label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
+                                               {
+                                                       label_text = gtk_form_field_get_field_name (field);
+                                               }
+                               }
+
+                       if ((label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
+                           && GTK_IS_CHECK_BUTTON (label))
+                               {
+                                       label_text = (gchar *)gtk_button_get_label (GTK_BUTTON (label));
+                               }
+               }
+
+       if (label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
+               {
+                       label_text = gtk_form_widget_get_widget_name (fwidget);
+               }
+
+       dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window),
+                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                        GTK_MESSAGE_WARNING,
+                                        GTK_BUTTONS_OK,
+                                        g_strdup_printf (_("The field Â«%s»%s."), label_text, message));
+       gtk_dialog_run (GTK_DIALOG (dialog));
+       gtk_widget_destroy (dialog);
+}
+
+static void
+gtk_form_load_modules (GtkForm *form)
+{
+       gchar *modulesdir;
+       GDir *dir;
+       GError *error;
+
+       GModule *module;
+       const gchar *filename;
+
+       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+
+       modulesdir = (gchar *)g_getenv ("LIBGTKFORM_MODULESDIR");
+       if (modulesdir == NULL)
+               {
+#ifdef G_OS_WIN32
+
+                       gchar *moddir;
+                       gchar *p;
+
+                       moddir = g_win32_get_package_installation_directory_of_module (NULL);
+
+                       p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR));
+                       if (p != NULL
+                               && (g_ascii_strcasecmp (p + 1, "src") == 0
+                                       || g_ascii_strcasecmp (p + 1, ".libs") == 0))
+                               {
+                                       modulesdir = g_strdup (MODULESDIR);
+                               }
+                       else
+                               {
+                                       modulesdir = g_build_filename (moddir, "lib", PACKAGE, "modules", NULL);
+                               }
+
+#else
+
+                       modulesdir = g_strdup (MODULESDIR);
+
+#endif
+               }
+
+       /* for each file in MODULESDIR */
+       error = NULL;
+       dir = g_dir_open (modulesdir, 0, &error);
+       if (dir != NULL)
+               {
+                       while ((filename = g_dir_read_name (dir)) != NULL)
+                               {
+                                       /* trying to open the module */
+                                       module = g_module_open (filename, G_MODULE_BIND_LAZY);
+                                       if (module != NULL)
+                                               {
+                                                       priv->modules = g_list_append (priv->modules, (gpointer)module);
+                                                       if (priv->debug > 0)
+                                                               {
+                                                                       g_message (_("Loaded %s."), filename);
+                                                               }
+                                               }
+                                       else
+                                               {
+                                                       g_warning (_("Unable to load %s: %s."), filename, g_module_error ());
+                                               }
+                               }
+
+                       g_dir_close (dir);
+               }
+       else
+               {
+                       g_warning (_("Unable to open modules dir: %s."), error->message != NULL ? error->message : _("no details"));
+               }
+}
diff --git a/libgtkform/form.h b/libgtkform/form.h
new file mode 100644 (file)
index 0000000..2dca1c6
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_H__
+#define __LIBGTK_FORM_H__
+
+#include <glib.h>
+#include <libxml/tree.h>
+
+#include "field.h"
+#include "widget.h"
+#include "key.h"
+#include "group.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM                 (gtk_form_get_type ())
+#define GTK_FORM(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM, GtkForm))
+#define GTK_FORM_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM, GtkFormClass))
+#define IS_GTK_FORM(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM))
+#define IS_GTK_FORM_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM))
+#define GTK_FORM_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM, GtkFormClass))
+
+
+typedef struct _GtkForm GtkForm;
+typedef struct _GtkFormClass GtkFormClass;
+
+struct _GtkForm
+       {
+               GObject parent;
+       };
+
+struct _GtkFormClass
+       {
+               GObjectClass parent_class;
+       };
+
+GType gtk_form_get_type (void) G_GNUC_CONST;
+
+
+GtkForm *gtk_form_new (void);
+GtkForm *gtk_form_new_from_xml (xmlDoc *xmldoc, GtkBuilder *gtkbuilder);
+GtkForm *gtk_form_new_from_file (const gchar *filename, GtkBuilder *gtkbuilder);
+
+GOptionGroup *gtk_form_get_option_group (GtkForm *gtkform);
+
+gboolean gtk_form_load_from_xml (GtkForm *form, xmlDoc *xmldoc, GtkBuilder *gtkbuilder);
+gboolean gtk_form_load_from_file (GtkForm *form, const gchar *filename, GtkBuilder *gtkbuilder);
+
+GtkBuilder *gtk_form_get_gtkbuilder (GtkForm *form);
+
+gchar *gtk_form_get_table (GtkForm *form);
+void gtk_form_set_table (GtkForm *form, const gchar *table);
+
+GtkFormKey *gtk_form_get_key (GtkForm *form);
+void gtk_form_set_key (GtkForm *form, GtkFormKey *key);
+
+gboolean gtk_form_add_field (GtkForm *form, GtkFormField *field);
+gboolean gtk_form_remove_field (GtkForm *form, GtkFormField *field);
+
+gboolean gtk_form_add_fields (GtkForm *form, ...);
+
+GtkFormField *gtk_form_get_form_field_from_name (GtkForm *form, const gchar *field_name);
+GtkFormWidget *gtk_form_get_form_widget_from_name (GtkForm *form, const gchar *widget_name);
+GtkWidget *gtk_form_get_widget_from_form_field_name (GtkForm *form, const gchar *field_name);
+GtkWidget *gtk_form_get_widget_from_form_widget_name (GtkForm *form, const gchar *widget_name);
+
+GtkFormField *gtk_form_get_form_field_from_widget (GtkForm *form, GtkWidget *widget);
+GtkFormWidget *gtk_form_get_form_widget_from_widget (GtkForm *form, GtkWidget *widget);
+
+GtkWidget **gtk_form_get_widgets (GtkForm *form);
+GObject **gtk_form_get_objects_by_name (GtkForm *form, ...);
+
+gboolean gtk_form_clear (GtkForm *form);
+
+gboolean gtk_form_check (GtkForm *form, gboolean with_key,
+                         GtkFormWidget **form_widget,
+                         gboolean show_error_dialog, GtkWidget *parent_window,
+                         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, ...);
+
+void gtk_form_set_editable (GtkForm *form, gboolean editable);
+
+void gtk_form_set_visible_by_name (GtkForm *form, gboolean visible, ...);
+void gtk_form_set_form_widget_visible_by_name (GtkForm *form, gboolean visible, ...);
+
+GValue *gtk_form_get_form_field_value_by_name (GtkForm *form, const gchar *field_name);
+GValue *gtk_form_get_form_widget_value_by_name (GtkForm *form, const gchar *widget_name);
+const gchar *gtk_form_get_form_field_value_stringify_by_name (GtkForm *form, const gchar *field_name);
+const gchar *gtk_form_get_form_widget_value_stringify_by_name (GtkForm *form, const gchar *widget_name);
+const gchar *gtk_form_get_form_field_value_sql_by_name (GtkForm *form, const gchar *field_name);
+const gchar *gtk_form_get_form_widget_value_sql_by_name (GtkForm *form, const gchar *widget_name);
+
+typedef enum
+{
+       GTK_FORM_SQL_SELECT,
+       GTK_FORM_SQL_INSERT,
+       GTK_FORM_SQL_UPDATE,
+       GTK_FORM_SQL_DELETE
+} GtkFormSqlType;
+
+gchar *gtk_form_get_sql (GtkForm *form, GtkFormSqlType type);
+
+gboolean gtk_form_fill_from_datamodel (GtkForm *form, GdaDataModel *dm, gint row);
+gboolean gtk_form_fill_from_table (GtkForm *form);
+
+gboolean gtk_form_reset (GtkForm *form);
+
+GHashTable *gtk_form_get_values_as_hashtable (GtkForm *form);
+GHashTable *gtk_form_get_original_values_as_hashtable (GtkForm *form);
+gboolean gtk_form_fill_from_hashtable (GtkForm *form, GHashTable *hashtable);
+
+gboolean gtk_form_add_group (GtkForm *form, GtkFormGroup *group);
+GtkFormGroup *gtk_form_get_group_by_name (GtkForm *form, const gchar *group_name);
+
+gboolean gtk_form_add_db_connection (GtkForm *form, const gchar *name, const gchar *connection_string);
+gboolean gtk_form_add_db_connection_gdaex (GtkForm *form, const gchar *name, GdaEx *gdaex);
+GdaEx *gtk_form_get_db_connection_by_name (GtkForm *form, const gchar *name);
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_H__ */
diff --git a/libgtkform/group.c b/libgtkform/group.c
new file mode 100644 (file)
index 0000000..a2278f0
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "group.h"
+
+enum
+{
+       PROP_0,
+       PROP_NAME
+};
+
+static void gtk_form_group_class_init (GtkFormGroupClass *klass);
+static void gtk_form_group_init (GtkFormGroup *gtk_form_group);
+
+static void gtk_form_group_set_property (GObject *object,
+                                     guint property_id,
+                                     const GValue *value,
+                                     GParamSpec *pspec);
+static void gtk_form_group_get_property (GObject *object,
+                                     guint property_id,
+                                     GValue *value,
+                                     GParamSpec *pspec);
+
+#define GTK_FORM_GROUP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroupPrivate))
+
+typedef struct _GtkFormGroupPrivate GtkFormGroupPrivate;
+struct _GtkFormGroupPrivate
+       {
+               gchar *name;
+
+               GSList *elements; /* GtkFormWidgets and GtkFormFields */
+       };
+
+
+G_DEFINE_TYPE (GtkFormGroup, gtk_form_group, G_TYPE_OBJECT)
+
+static void
+gtk_form_group_class_init (GtkFormGroupClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       object_class->set_property = gtk_form_group_set_property;
+       object_class->get_property = gtk_form_group_get_property;
+
+       g_object_class_install_property (object_class, PROP_NAME,
+                                        g_param_spec_string ("name",
+                                                             "Group's name'",
+                                                             "Group's name",
+                                                             "",
+                                                             G_PARAM_READWRITE));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormGroupPrivate));
+}
+
+static void
+gtk_form_group_init (GtkFormGroup *gtk_form_group)
+{
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (gtk_form_group);
+
+       priv->name = NULL;
+}
+
+/**
+ * gtk_form_group_new:
+ * @name:
+ *
+ * Returns: the newly created #GtkFormGroup.
+ */
+GtkFormGroup
+*gtk_form_group_new (const gchar *name)
+{
+       GtkFormGroup *g;
+
+       g = g_object_new (TYPE_GTK_FORM_GROUP, NULL);
+
+       g_object_set (G_OBJECT (g), "name", name, NULL);
+
+       return g;
+}
+
+/**
+ * gtk_form_group_get_name:
+ * @group: a #GtkFormGroup object.
+ *
+ * Returns: the group's name.
+ */
+gchar
+*gtk_form_group_get_name (GtkFormGroup *group)
+{
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       return g_strdup (priv->name);
+}
+
+/**
+ * gtk_form_group_add_widget:
+ * @group:
+ * @fwidget:
+ *
+ */
+gboolean
+gtk_form_group_add_widget (GtkFormGroup *group, GtkFormWidget *fwidget)
+{
+       gboolean ret;
+
+       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), FALSE);
+
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       ret = FALSE;
+
+       priv->elements = g_slist_append (priv->elements, (gpointer)fwidget);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_group_add_field:
+ * @group:
+ * @field:
+ *
+ */
+gboolean
+gtk_form_group_add_field (GtkFormGroup *group, GtkFormField *field)
+{
+       gboolean ret;
+
+       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       ret = FALSE;
+
+       priv->elements = g_slist_append (priv->elements, (gpointer)field);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_group_clear:
+ * @group: a #GtkFormGroup object.
+ *
+ */
+gboolean
+gtk_form_group_clear (GtkFormGroup *group)
+{
+       gboolean ret;
+
+       GSList *els;
+
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
+
+       els = priv->elements;
+       while (els != NULL)
+               {
+                       if (IS_GTK_FORM_WIDGET ((GtkFormWidget *)els->data))
+                               {
+                                       gtk_form_widget_set_value_stringify ((GtkFormWidget *)els->data, "");
+                               }
+                       else if (IS_GTK_FORM_FIELD ((GtkFormField *)els->data))
+                               {
+                                       gtk_form_field_clear ((GtkFormField *)els->data);
+                               }
+
+                       els = g_slist_next (els);
+               }
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_group_set_from_datamodel:
+ * @group: a #GtkFormGroup object.
+ * @dm: a #GdaDataModel object.
+ * @row: the row number to return.
+ *
+ */
+gboolean
+gtk_form_group_set_from_datamodel (GtkFormGroup *group, GdaDataModel *dm, gint row)
+{
+       gboolean ret = FALSE;
+
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
+
+       /*if (IS_GTK_FORM_GROUP (group) && GTK_FORM_GROUP_GET_CLASS (group)->set_from_datamodel != NULL)
+               {
+                       ret = GTK_FORM_GROUP_GET_CLASS (group)->set_from_datamodel (group, dm, row);
+               }*/
+
+       return ret;
+}
+
+/**
+ * gtk_form_group_set_from_hashtable:
+ * @group: a #GtkFormGroup object.
+ * @hashtable: a #GHashTable object.
+ *
+ */
+gboolean
+gtk_form_group_set_from_hashtable (GtkFormGroup *group, GHashTable *hashtable)
+{
+       gboolean ret = FALSE;
+
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       g_return_val_if_fail (hashtable != NULL, FALSE);
+
+       /*if (IS_GTK_FORM_GROUP (group) && GTK_FORM_GROUP_GET_CLASS (group)->set_from_hashtable != NULL)
+               {
+                       ret = GTK_FORM_GROUP_GET_CLASS (group)->set_from_hashtable (group, hashtable);
+               }*/
+
+       return ret;
+}
+
+/* PRIVATE */
+static void
+gtk_form_group_set_property (GObject *object,
+                         guint property_id,
+                         const GValue *value,
+                         GParamSpec *pspec)
+{
+       GtkFormGroup *group = (GtkFormGroup *)object;
+
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       switch (property_id)
+               {
+                       case PROP_NAME:
+                               priv->name = g_strstrip (g_value_dup_string (value));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_group_get_property (GObject *object,
+                         guint property_id,
+                         GValue *value,
+                         GParamSpec *pspec)
+{
+       GtkFormGroup *group = (GtkFormGroup *)object;
+
+       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
+
+       switch (property_id)
+               {
+                       case PROP_NAME:
+                               g_value_set_string (value, gtk_form_group_get_name (group));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/group.h b/libgtkform/group.h
new file mode 100644 (file)
index 0000000..6d1f658
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_GROUP_H__
+#define __LIBGTK_FORM_GROUP_H__
+
+#include <glib.h>
+
+#include "widget.h"
+#include "field.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_GROUP                 (gtk_form_group_get_type ())
+#define GTK_FORM_GROUP(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroup))
+#define GTK_FORM_GROUP_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_GROUP, GtkFormGroupClass))
+#define IS_GTK_FORM_GROUP(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_GROUP))
+#define IS_GTK_FORM_GROUP_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_GROUP))
+#define GTK_FORM_GROUP_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroupClass))
+
+
+typedef struct _GtkFormGroup GtkFormGroup;
+typedef struct _GtkFormGroupClass GtkFormGroupClass;
+
+struct _GtkFormGroup
+       {
+               GObject parent;
+       };
+
+struct _GtkFormGroupClass
+       {
+               GObjectClass parent_class;
+       };
+
+GType gtk_form_group_get_type (void) G_GNUC_CONST;
+
+GtkFormGroup *gtk_form_group_new (const gchar *name);
+
+gchar *gtk_form_group_get_name (GtkFormGroup *group);
+
+gboolean gtk_form_group_add_widget (GtkFormGroup *group, GtkFormWidget *fwidget);
+gboolean gtk_form_group_add_field (GtkFormGroup *group, GtkFormField *field);
+
+gboolean gtk_form_group_clear (GtkFormGroup *group);
+
+gboolean gtk_form_group_set_from_datamodel (GtkFormGroup *group, GdaDataModel *dm, gint row);
+gboolean gtk_form_group_set_from_hashtable (GtkFormGroup *group, GHashTable *hashtable);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_GROUP_H__ */
diff --git a/libgtkform/key.c b/libgtkform/key.c
new file mode 100644 (file)
index 0000000..4d24a44
--- /dev/null
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#include "key.h"
+
+static void gtk_form_key_class_init (GtkFormKeyClass *class);
+static void gtk_form_key_init (GtkFormKey *gtk_form_key);
+
+
+#define GTK_FORM_KEY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_KEY, GtkFormKeyPrivate))
+
+typedef struct _GtkFormKeyPrivate GtkFormKeyPrivate;
+struct _GtkFormKeyPrivate
+       {
+               GSList *fields;
+       };
+
+
+G_DEFINE_TYPE (GtkFormKey, gtk_form_key, G_TYPE_OBJECT)
+
+static void
+gtk_form_key_class_init (GtkFormKeyClass *class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+       g_type_class_add_private (object_class, sizeof (GtkFormKeyPrivate));
+}
+
+static void
+gtk_form_key_init (GtkFormKey *gtk_form_key)
+{
+       GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+
+       priv->fields = NULL;
+}
+
+/**
+ * gtk_form_key_new:
+ *
+ * Returns: the newly created #GtkFormKey.
+ */
+GtkFormKey
+*gtk_form_key_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_KEY, NULL);
+}
+
+/**
+ * gtk_form_key_add_field:
+ * @gtk_form_key: a #GtkFormKey object.
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_key_add_field (GtkFormKey *gtk_form_key, GtkFormField *field)
+{
+       gboolean ret = FALSE;
+
+       GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       priv->fields = g_slist_append (priv->fields, field);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_key_remove_field:
+ * @gtk_form_key: a #GtkFormKey object.
+ * @field: a #GtkFormField object.
+ *
+ */
+gboolean
+gtk_form_key_remove_field (GtkFormKey *gtk_form_key, GtkFormField *field)
+{
+       gboolean ret = FALSE;
+
+       GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       priv->fields = g_slist_remove (priv->fields, field);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_key_add_fields:
+ * @gtk_form_key: a #GtkFormKey object.
+ *
+ */
+gboolean
+gtk_form_key_add_fields (GtkFormKey *gtk_form_key, ...)
+{
+       GtkFormField *field;
+
+       va_list vargs;
+
+       va_start (vargs, gtk_form_key);
+
+       while ((field = va_arg (vargs, GtkFormField *)) != NULL)
+               {
+                       gtk_form_key_add_field (gtk_form_key, field);
+               }
+
+       va_end (vargs);
+}
+
+/**
+ * gtk_form_key_check:
+ * @gtk_form_key: a #GtkFormKey object.
+ * @form_widget:
+ *
+ * Returns: TRUE if all obligatory fields are full.
+ */
+gboolean
+gtk_form_key_check (GtkFormKey *gtk_form_key, GtkFormWidget **form_widget)
+{
+       GtkFormField *field;
+       gboolean ret;
+
+       GtkFormKeyPrivate *priv;
+       GSList *fields;
+
+       g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), FALSE);
+
+       priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+
+       ret = TRUE;
+
+       fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       if (gtk_form_field_is_empty (field))
+                               {
+                                       GtkFormWidget *fwidget;
+
+                                       fwidget = gtk_form_field_get_form_widget (field);
+                                       if (form_widget != NULL && *form_widget == NULL)
+                                               {
+                                                       *form_widget = fwidget;
+                                               }
+
+                                       ret = FALSE;
+                                       break;
+                               }
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_key_get_sql:
+ * @gtk_form_key: a #GtkFormKey object.
+ *
+ */
+gchar
+*gtk_form_key_get_sql (GtkFormKey *gtk_form_key)
+{
+       GtkFormField *field;
+       gchar *sql = "";
+       gchar *field_name;
+
+       GtkFormKeyPrivate *priv;
+       GSList *fields;
+
+       g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), sql);
+
+       priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+
+       fields = priv->fields;
+
+       while (fields != NULL)
+               {
+                       field = (GtkFormField *)fields->data;
+
+                       g_object_get (G_OBJECT (field),
+                                     "field", &field_name,
+                                     NULL);
+
+                       sql = g_strconcat (sql, " AND ", field_name, " = ",
+                                          gtk_form_field_get_value_sql (field), NULL);
+
+                       fields = g_slist_next (fields);
+               }
+
+       if (strcmp (sql, "") != 0)
+               {
+                       sql = g_strconcat (" WHERE ", g_strdup (sql + 5), NULL);
+               }
+
+       g_free (field_name);
+
+       return sql;
+}
+
+/**
+ * gtk_form_key_field_is_key:
+ * @gtk_form_key: a #GtkFormKey object.
+ * @field: a #GtkFormField object.
+ *
+ * Returns: TRUE if @field is part of @gtk_form_key.
+ */
+gboolean
+gtk_form_key_field_is_key (GtkFormKey *gtk_form_key, GtkFormField *field)
+{
+       GtkFormKeyPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), FALSE);
+       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
+
+       priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
+
+       return (g_slist_index (priv->fields, field) >= 0 ? TRUE : FALSE);
+}
diff --git a/libgtkform/key.h b/libgtkform/key.h
new file mode 100644 (file)
index 0000000..144c2ec
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_KEY_H__
+#define __LIBGTK_FORM_KEY_H__
+
+#include <glib.h>
+
+#include "field.h"
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_KEY                 (gtk_form_key_get_type ())
+#define GTK_FORM_KEY(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_KEY, GtkFormKey))
+#define GTK_FORM_KEY_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_KEY, GtkFormKeyClass))
+#define IS_GTK_FORM_KEY(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_KEY))
+#define IS_GTK_FORM_KEY_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_KEY))
+#define GTK_FORM_KEY_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_KEY, GtkFormKeyClass))
+
+
+typedef struct _GtkFormKey GtkFormKey;
+typedef struct _GtkFormKeyClass GtkFormKeyClass;
+
+struct _GtkFormKey
+       {
+               GObject parent;
+       };
+
+struct _GtkFormKeyClass
+       {
+               GObjectClass parent_class;
+       };
+
+GType gtk_form_key_get_type (void) G_GNUC_CONST;
+
+
+GtkFormKey *gtk_form_key_new (void);
+
+gboolean gtk_form_key_add_field (GtkFormKey *gtk_form_key, GtkFormField *field);
+gboolean gtk_form_key_remove_field (GtkFormKey *gtk_form_key, GtkFormField *field);
+
+gboolean gtk_form_key_add_fields (GtkFormKey *gtk_form_key, ...);
+
+gboolean gtk_form_key_check (GtkFormKey *gtk_form_key, GtkFormWidget **form_widget);
+
+gchar *gtk_form_key_get_sql (GtkFormKey *gtk_form_key);
+
+gboolean gtk_form_key_field_is_key (GtkFormKey *gtk_form_key, GtkFormField *field);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_KEY_H__ */
diff --git a/libgtkform/widget.c b/libgtkform/widget.c
new file mode 100644 (file)
index 0000000..2fe9ba3
--- /dev/null
@@ -0,0 +1,608 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+
+#include <sql-parser/gda-sql-parser.h>
+
+#include "form.h"
+#include "widget.h"
+#include "field.h"
+
+enum
+{
+       PROP_0,
+       PROP_FORM,
+       PROP_FIELD,
+       PROP_WIDGET,
+       PROP_NAME,
+       PROP_LABEL
+};
+
+static void gtk_form_widget_class_init (GtkFormWidgetClass *klass);
+static void gtk_form_widget_init (GtkFormWidget *gtk_form_widget);
+
+static void gtk_form_widget_set_property (GObject *object,
+                                      guint property_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec);
+static void gtk_form_widget_get_property (GObject *object,
+                                      guint property_id,
+                                      GValue *value,
+                                      GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET, GtkFormWidgetPrivate))
+
+typedef struct _GtkFormWidgetPrivate GtkFormWidgetPrivate;
+struct _GtkFormWidgetPrivate
+       {
+               GtkForm *form;
+               GtkWidget *widget;
+               gchar *widget_name;
+
+               GtkWidget *label;
+
+               GtkFormField *field;
+
+               GSList *on_change_ops; /* GtkFormOnChangeOp */
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidget, gtk_form_widget, G_TYPE_OBJECT)
+
+static void
+gtk_form_widget_class_init (GtkFormWidgetClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       klass->get_value_stringify = NULL;
+       klass->set_value_stringify = NULL;
+       klass->set_editable = NULL;
+
+       object_class->set_property = gtk_form_widget_set_property;
+       object_class->get_property = gtk_form_widget_get_property;
+
+       g_object_class_install_property (object_class, PROP_FORM,
+                                        g_param_spec_object ("form",
+                                                             "GtkForm",
+                                                             "The GtkForm",
+                                                             TYPE_GTK_FORM,
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_FIELD,
+                                        g_param_spec_object ("field",
+                                                             "GtkFormField",
+                                                             "The GtkFormField",
+                                                             TYPE_GTK_FORM_FIELD,
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_WIDGET,
+                                        g_param_spec_object ("widget",
+                                                             "GtkWidget",
+                                                             "The GtkWidget",
+                                                             GTK_TYPE_WIDGET,
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_NAME,
+                                        g_param_spec_string ("widget-name",
+                                                             "Widget's name",
+                                                             "Widget's name",
+                                                             "",
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_LABEL,
+                                        g_param_spec_object ("label",
+                                                             "GtkLabel",
+                                                             "The GtkLabel",
+                                                             GTK_TYPE_WIDGET,
+                                                             G_PARAM_READWRITE));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormWidgetPrivate));
+}
+
+static void
+gtk_form_widget_init (GtkFormWidget *gtk_form_widget)
+{
+       GtkFormWidgetPrivate *priv = GTK_FORM_WIDGET_GET_PRIVATE (gtk_form_widget);
+
+       priv->form = NULL;
+       priv->field = NULL;
+       priv->widget = NULL;
+       priv->widget_name = NULL;
+       priv->label = NULL;
+       priv->on_change_ops = NULL;
+}
+
+/**
+ * gtk_form_widget_new:
+ *
+ * Returns: the newly created #GtkFormWidget.
+ */
+GtkFormWidget
+*gtk_form_widget_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET, NULL);
+}
+
+/**
+ * gtk_form_widget_set_from_gtkbuilder:
+ * @fwidget: a #GtkFormWidget object.
+ * @gtkbuilder:
+ * @widget_name:
+ *
+ */
+gboolean
+gtk_form_widget_set_from_gtkbuilder (GtkFormWidget *fwidget,
+                                     GtkBuilder *gtkbuilder,
+                                     const gchar *widget_name)
+{
+       gboolean ret;
+
+       GtkWidget *w;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), FALSE);
+       g_return_val_if_fail (GTK_IS_BUILDER (gtkbuilder), FALSE);
+
+       ret = FALSE;
+
+       w = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, widget_name));
+       if (w != NULL)
+               {
+                       g_object_set (fwidget,
+                                     "widget", w,
+                                     "widget-name", widget_name,
+                                     NULL);
+
+                       ret = TRUE;
+               }
+       else
+               {
+                       g_warning (_("Widget Â«%s» not found."), widget_name);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_get_widget:
+ * @fwidget: a #GtkFormWidget object.
+ *
+ */
+GtkWidget
+*gtk_form_widget_get_widget (GtkFormWidget *fwidget)
+{
+       GtkFormWidgetPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), NULL);
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       return priv->widget;
+}
+
+/**
+ * gtk_form_widget_get_widget_name:
+ * @fwidget: a #GtkFormWidget object.
+ *
+ * Returns: the #GtkFormWidget's name. Must be freed.
+ */
+gchar
+*gtk_form_widget_get_widget_name (GtkFormWidget *fwidget)
+{
+       gchar *ret;
+       GtkFormWidgetPrivate *priv;
+
+       ret = g_strdup ("");
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), ret);
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       ret = g_strdup (priv->widget_name);
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_get_label:
+ * @fwidget: a #GtkFormWidget object.
+ *
+ */
+GtkWidget
+*gtk_form_widget_get_label (GtkFormWidget *fwidget)
+{
+       GtkFormWidgetPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), NULL);
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       return priv->label;
+}
+
+/**
+ * gtk_form_widget_set_label:
+ * @fwidget: a #GtkFormWidget object.
+ * @label: a @GtkWidget object.
+ *
+ */
+void
+gtk_form_widget_set_label (GtkFormWidget *fwidget, GtkWidget *label)
+{
+       GtkFormWidgetPrivate *priv;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
+       g_return_if_fail (GTK_IS_LABEL (label));
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       priv->label = GTK_WIDGET (label);
+}
+
+/**
+ * gtk_form_widget_get_value_stringify:
+ * @fwidget: a #GtkFormWidget object.
+ *
+ * Returns: The widget's value as a string. Must be freed.
+ */
+gchar
+*gtk_form_widget_get_value_stringify (GtkFormWidget *fwidget)
+{
+       gchar *ret;
+
+       ret = NULL;
+
+       if (IS_GTK_FORM_WIDGET (fwidget) && GTK_FORM_WIDGET_GET_CLASS (fwidget)->get_value_stringify != NULL)
+               {
+                       ret = GTK_FORM_WIDGET_GET_CLASS (fwidget)->get_value_stringify (fwidget);
+               }
+
+       return ret;
+}
+
+static void
+execute_on_change_op (GtkFormWidget *fwidget, GtkFormWidgetOnChangeOpUpdate *op)
+{
+       GtkFormWidgetPrivate *priv;
+       GdaEx *gdaex;
+
+       GObject *res;
+       GdaConnection *gdacon;
+       GdaSqlParser *parser;
+       GdaStatement *stmt;
+       GdaSet *params;
+       GSList *hs;
+       GdaHolder *h;
+       GValue *gval;
+       GError *error;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       gdaex = NULL;
+
+       if (op->connection_name != NULL
+           && g_strcmp0 (op->connection_name, "") != 0)
+               {
+                       gdaex = gtk_form_get_db_connection_by_name (priv->form, op->connection_name);
+               }
+
+       if (!IS_GDAEX (gdaex))
+               {
+                       g_object_get (G_OBJECT (priv->form), "gdaex", &gdaex, NULL);
+               }
+
+       if (IS_GDAEX (gdaex))
+               {
+                       gdacon = (GdaConnection *)gdaex_get_gdaconnection (gdaex);
+                       parser = gda_connection_create_parser (gdacon);
+                       if (parser == NULL)
+                               {
+                                       parser = gda_sql_parser_new ();
+                               }
+
+                       error = NULL;
+                       stmt = gda_sql_parser_parse_string (parser, op->sql, NULL, &error);
+                       if (stmt == NULL)
+                               {
+                                       g_warning (_("Error on parsing sql string: %s\n%s."), op->sql,
+                                                  (error != NULL && error->message != NULL ? error->message : "no details"));
+                               }
+                       else
+                               {
+                                       gda_statement_get_parameters (stmt, &params, NULL);
+                                       if (params != NULL)
+                                               {
+                                                       hs = params->holders;
+                                                       while (hs != NULL)
+                                                               {
+                                                                       h = (GdaHolder *)hs->data;
+
+                                                                       if (GDA_IS_HOLDER (h))
+                                                                               {
+                                                                                       gval = gda_value_new_from_string (gtk_form_widget_get_value_stringify (gtk_form_get_form_widget_from_name (priv->form, gda_holder_get_id (h))), gda_holder_get_g_type (h));
+
+                                                                                       error = NULL;
+                                                                                       if (!gda_holder_set_value (h, gval, &error))
+                                                                                               {
+                                                                                                       g_warning (_("Error on setting holder's value: %s."),
+                                                                                                                  (error != NULL && error->message != NULL ? error->message : "no details"));
+                                                                                               }
+                                                                               }
+                                                                       hs = g_slist_next (hs);
+                                                               }
+                                               }
+
+                                       error = NULL;
+                                       res = gda_connection_statement_execute (gdacon, stmt, params,
+                                                                               GDA_STATEMENT_MODEL_RANDOM_ACCESS,
+                                                                               NULL, &error);
+
+                                       if (res == NULL)
+                                               {
+                                                       g_warning (_("Error on executing GtkFormWidgetOnChangeOp: %s."),
+                                                                  (error != NULL && error->message != NULL ? error->message : "no details"));
+                                               }
+                                       else if (GDA_IS_DATA_MODEL (res) && gda_data_model_get_n_rows ((GdaDataModel *)res) > 0)
+                                               {
+                                                       gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, op->form_widget_name),
+                                                                                            gdaex_data_model_get_value_stringify_at ((GdaDataModel *)res, 0, 0));
+                                                       g_object_unref (res);
+                                               }
+                                       else
+                                               {
+                                                       gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, op->form_widget_name), "");
+                                               }
+                                       g_object_unref (stmt);
+                               }
+               }
+       else
+               {
+                       g_warning (_("No GdaEx object inside GtkFormWidget."));
+               }
+}
+
+/**
+ * gtk_form_widget_set_value_stringify:
+ * @fwidget: a #GtkFormWidget object.
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret;
+       GSList *ops;
+       GtkFormWidgetOnChangeOp *op;
+
+       GtkFormWidgetPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), FALSE);
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       ops = priv->on_change_ops;
+       while (ops != NULL)
+               {
+                       op = (GtkFormWidgetOnChangeOp *)ops->data;
+                       switch (op->type)
+                               {
+                                       case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
+                                               {
+                                                       GtkFormWidgetOnChangeOpUpdate *op_update = (GtkFormWidgetOnChangeOpUpdate *)op;
+                                                       if (IS_GTK_FORM (priv->form)
+                                                           && (op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BEFORE
+                                                               || op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH))
+                                                               {
+                                                                       execute_on_change_op (fwidget, op_update);
+                                                               }
+                                               }
+                                               break;
+                               }
+
+                       ops = g_slist_next (ops);
+               }
+
+       if (GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_value_stringify != NULL)
+               {
+                       ret = GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_value_stringify (fwidget, value);
+               }
+
+       if (ret)
+               {
+                       ops = priv->on_change_ops;
+                       while (ops != NULL)
+                               {
+                                       op = (GtkFormWidgetOnChangeOp *)ops->data;
+                                       switch (op->type)
+                                               {
+                                                       case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
+                                                               {
+                                                                       GtkFormWidgetOnChangeOpUpdate *op_update = (GtkFormWidgetOnChangeOpUpdate *)op;
+                                                                       if (IS_GTK_FORM (priv->form)
+                                                                           && (op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_AFTER
+                                                                               || op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH))
+                                                                               {
+                                                                                       execute_on_change_op (fwidget, op_update);
+                                                                               }
+                                                               }
+                                                               break;
+                                               }
+
+                                       ops = g_slist_next (ops);
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_set_editable:
+ * @fwidget: a #GtkFormWidget object.
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       if (IS_GTK_FORM_WIDGET (fwidget) && GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_editable != NULL)
+               {
+                       GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_editable (fwidget, editable);
+               }
+}
+
+/**
+ * gtk_form_widget_set_visible:
+ * @fwidget: a #GtkFormWidget object.
+ * @visible:
+ *
+ */
+void
+gtk_form_widget_set_visible (GtkFormWidget *fwidget, gboolean visible)
+{
+       GtkFormWidgetPrivate *priv;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       if (visible)
+               {
+                       if (GTK_IS_WIDGET (priv->label))
+                               {
+                                       gtk_widget_show (priv->label);
+                               }
+                       gtk_widget_show (priv->widget);
+               }
+       else
+               {
+                       if (GTK_IS_WIDGET (priv->label))
+                               {
+                                       gtk_widget_hide (priv->label);
+                               }
+                       gtk_widget_hide (priv->widget);
+               }
+}
+
+/**
+ * gtk_form_widget_add_on_change_op:
+ * @fwidget:
+ * @op:
+ *
+ */
+void
+gtk_form_widget_add_on_change_op (GtkFormWidget *fwidget, GtkFormWidgetOnChangeOp *op)
+{
+       GtkFormWidgetPrivate *priv;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
+       g_return_if_fail (op != NULL);
+
+       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       switch (op->type)
+               {
+                       case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
+                               priv->on_change_ops = g_slist_append (priv->on_change_ops, g_memdup (op, sizeof (GtkFormWidgetOnChangeOpUpdate)));
+                               break;
+               }
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_set_property (GObject *object,
+                          guint property_id,
+                          const GValue *value,
+                          GParamSpec *pspec)
+{
+       GtkFormWidget *fwidget = (GtkFormWidget *)object;
+
+       GtkFormWidgetPrivate *priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       switch (property_id)
+               {
+                       case PROP_FORM:
+                               priv->form = g_value_get_object (value);
+                               break;
+
+                       case PROP_FIELD:
+                               priv->field = g_value_get_object (value);
+                               break;
+
+                       case PROP_WIDGET:
+                               priv->widget = g_value_get_object (value);
+                               break;
+
+                       case PROP_NAME:
+                               priv->widget_name = g_strstrip (g_strdup (g_value_get_string (value)));
+                               break;
+
+                       case PROP_LABEL:
+                               gtk_form_widget_set_label (fwidget, GTK_WIDGET (g_value_get_object (value)));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_get_property (GObject *object,
+                          guint property_id,
+                          GValue *value,
+                          GParamSpec *pspec)
+{
+       GtkFormWidget *fwidget = (GtkFormWidget *)object;
+
+       GtkFormWidgetPrivate *priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
+
+       switch (property_id)
+               {
+                       case PROP_FORM:
+                               g_value_set_object (value, priv->form);
+                               break;
+
+                       case PROP_FIELD:
+                               g_value_set_object (value, priv->field);
+                               break;
+
+                       case PROP_WIDGET:
+                               g_value_set_object (value, priv->widget);
+                               break;
+
+                       case PROP_NAME:
+                               g_value_set_string (value, priv->widget_name);
+                               break;
+
+                       case PROP_LABEL:
+                               g_value_set_object (value, gtk_form_widget_get_label (fwidget));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/widget.h b/libgtkform/widget.h
new file mode 100644 (file)
index 0000000..391e1d3
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_H__
+#define __LIBGTK_FORM_WIDGET_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include <libgdaex/libgdaex.h>
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET                 (gtk_form_widget_get_type ())
+#define GTK_FORM_WIDGET(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET, GtkFormWidget))
+#define GTK_FORM_WIDGET_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET, GtkFormWidgetClass))
+#define IS_GTK_FORM_WIDGET(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET))
+#define IS_GTK_FORM_WIDGET_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET))
+#define GTK_FORM_WIDGET_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET, GtkFormWidgetClass))
+
+
+typedef struct _GtkFormWidget GtkFormWidget;
+typedef struct _GtkFormWidgetClass GtkFormWidgetClass;
+
+struct _GtkFormWidget
+       {
+               GObject parent;
+       };
+
+struct _GtkFormWidgetClass
+       {
+               GObjectClass parent_class;
+
+               gchar *(*get_value_stringify) (GtkFormWidget *fwidget);
+
+               gboolean (*set_value_stringify) (GtkFormWidget *fwidget, const gchar *value);
+
+               void (*set_editable) (GtkFormWidget *fwidget, gboolean editable);
+       };
+
+GType gtk_form_widget_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_new (void);
+
+gboolean gtk_form_widget_set_from_gtkbuilder (GtkFormWidget *fwidget,
+                                              GtkBuilder *gtkbuilder,
+                                              const gchar *widget_name);
+
+GtkWidget *gtk_form_widget_get_widget (GtkFormWidget *fwidget);
+
+gchar *gtk_form_widget_get_widget_name (GtkFormWidget *fwidget);
+
+GtkWidget *gtk_form_widget_get_label (GtkFormWidget *fwidget);
+void gtk_form_widget_set_label (GtkFormWidget *fwidget, GtkWidget *label);
+
+gchar *gtk_form_widget_get_value_stringify (GtkFormWidget *fwidget);
+
+gboolean gtk_form_widget_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+void gtk_form_widget_set_visible (GtkFormWidget *fwidget, gboolean visible);
+
+typedef enum
+{
+       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE
+} GtkFormWidgetOnChangeOpType;
+
+typedef struct
+{
+       GtkFormWidgetOnChangeOpType type;
+} GtkFormWidgetOnChangeOp;
+
+typedef enum
+{
+       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BEFORE,
+       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_AFTER,
+       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH
+} GtkFormWidgetOnChangeOpUpdateWhen;
+
+typedef struct
+{
+       GtkFormWidgetOnChangeOp op;
+       gchar *form_widget_name;
+       gchar *connection_name;
+       gchar *sql;
+       GtkFormWidgetOnChangeOpUpdateWhen when;
+} GtkFormWidgetOnChangeOpUpdate;
+
+void gtk_form_widget_add_on_change_op (GtkFormWidget *fwidget, GtkFormWidgetOnChangeOp *op);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_H__ */
diff --git a/libgtkform/widgetcheck.c b/libgtkform/widgetcheck.c
new file mode 100644 (file)
index 0000000..f9e1b01
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "widgetcheck.h"
+
+enum
+{
+       PROP_0
+};
+
+static void gtk_form_widget_check_class_init (GtkFormWidgetCheckClass *klass);
+static void gtk_form_widget_check_init (GtkFormWidgetCheck *gtk_form_widget_check);
+
+static void gtk_form_widget_check_set_property (GObject *object,
+                                            guint property_id,
+                                            const GValue *value,
+                                            GParamSpec *pspec);
+static void gtk_form_widget_check_get_property (GObject *object,
+                                            guint property_id,
+                                            GValue *value,
+                                            GParamSpec *pspec);
+
+static gboolean check_value (const gchar *value);
+
+#define GTK_FORM_WIDGET_CHECK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheckPrivate))
+
+typedef struct _GtkFormWidgetCheckPrivate GtkFormWidgetCheckPrivate;
+struct _GtkFormWidgetCheckPrivate
+       {
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetCheck, gtk_form_widget_check, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_check_class_init (GtkFormWidgetCheckClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_check_set_property;
+       object_class->get_property = gtk_form_widget_check_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_check_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_check_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_check_set_editable;
+
+       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetCheckPrivate));*/
+}
+
+static void
+gtk_form_widget_check_init (GtkFormWidgetCheck *gtk_form_widget_check)
+{
+}
+
+/**
+ * gtk_form_widget_check_new:
+ *
+ * Returns: the newly created #GtkFormWidgetCheck.
+ */
+GtkFormWidget
+*gtk_form_widget_check_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET_CHECK, NULL);
+}
+
+/**
+ * gtk_form_widget_check_get_value_stringify:
+ * @widget:
+ *
+ */
+gchar
+*gtk_form_widget_check_get_value_stringify (GtkFormWidget *fwidget)
+{
+       GtkWidget *w;
+       gchar *ret;
+
+       ret = g_strdup ("FALSE");
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_CHECK (fwidget), ret);
+
+       w = gtk_form_widget_get_widget (fwidget);
+
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
+               {
+                       ret = g_strdup ("TRUE");
+               }
+       else if (gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (w)))
+               {
+                       ret = g_strdup ("");
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_check_set_value_stringify:
+ * @fwidget:
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_check_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+       gboolean active = FALSE;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_CHECK (fwidget), FALSE);
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       active = check_value (value);
+
+       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), active);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_check_set_editable:
+ * @fwidget: a #GtkFormWidget object.
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_check_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET_CHECK (fwidget));
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_widget_set_sensitive (w, editable);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_check_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetCheck *widget_check = (GtkFormWidgetCheck *)object;
+
+       GtkFormWidgetCheckPrivate *priv = GTK_FORM_WIDGET_CHECK_GET_PRIVATE (widget_check);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_check_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetCheck *widget_check = (GtkFormWidgetCheck *)object;
+
+       GtkFormWidgetCheckPrivate *priv = GTK_FORM_WIDGET_CHECK_GET_PRIVATE (widget_check);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static gboolean
+check_value (const gchar *value)
+{
+       gchar *str_value;
+       gboolean active;
+
+       active = FALSE;
+
+       str_value = g_strstrip (g_strdup (value));
+
+       if (strcmp (str_value, "0") == 0
+           || strcasecmp (str_value, "f") == 0
+           || strcasecmp (str_value, "false") == 0
+           || strcasecmp (str_value, "n") == 0
+           || strcasecmp (str_value, "no") == 0)
+               {
+                       active = FALSE;
+               }
+       else if (strcmp (str_value, "1") == 0
+           || strcasecmp (str_value, "t") == 0
+           || strcasecmp (str_value, "true") == 0
+           || strcasecmp (str_value, "y") == 0
+           || strcasecmp (str_value, "yes") == 0)
+               {
+                       active = TRUE;
+               }
+
+       return active;
+}
diff --git a/libgtkform/widgetcheck.h b/libgtkform/widgetcheck.h
new file mode 100644 (file)
index 0000000..f257fb3
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_CHECK_H__
+#define __LIBGTK_FORM_WIDGET_CHECK_H__
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET_CHECK                 (gtk_form_widget_check_get_type ())
+#define GTK_FORM_WIDGET_CHECK(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheck))
+#define GTK_FORM_WIDGET_CHECK_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheckClass))
+#define IS_GTK_FORM_WIDGET_CHECK(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_CHECK))
+#define IS_GTK_FORM_WIDGET_CHECK_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_CHECK))
+#define GTK_FORM_WIDGET_CHECK_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheckClass))
+
+
+typedef struct _GtkFormWidgetCheck GtkFormWidgetCheck;
+typedef struct _GtkFormWidgetCheckClass GtkFormWidgetCheckClass;
+
+struct _GtkFormWidgetCheck
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetCheckClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_check_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_check_new (void);
+
+gchar *gtk_form_widget_check_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_check_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_check_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_CHECK_H__ */
diff --git a/libgtkform/widgetcombobox.c b/libgtkform/widgetcombobox.c
new file mode 100644 (file)
index 0000000..0e52d58
--- /dev/null
@@ -0,0 +1,335 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+#include "widgetcombobox.h"
+
+enum
+{
+       PROP_0,
+       PROP_COLUMN_FIELD
+};
+
+static void gtk_form_widget_combo_box_class_init (GtkFormWidgetComboBoxClass *klass);
+static void gtk_form_widget_combo_box_init (GtkFormWidgetComboBox *gtk_form_widget_combo_box);
+
+static void gtk_form_widget_combo_box_set_property (GObject *object,
+                                                guint property_id,
+                                                const GValue *value,
+                                                GParamSpec *pspec);
+static void gtk_form_widget_combo_box_get_property (GObject *object,
+                                                guint property_id,
+                                                GValue *value,
+                                                GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBoxPrivate))
+
+typedef struct _GtkFormWidgetComboBoxPrivate GtkFormWidgetComboBoxPrivate;
+struct _GtkFormWidgetComboBoxPrivate
+       {
+               gint column_field;
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetComboBox, gtk_form_widget_combo_box, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_combo_box_class_init (GtkFormWidgetComboBoxClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_combo_box_set_property;
+       object_class->get_property = gtk_form_widget_combo_box_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_combo_box_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_combo_box_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_combo_box_set_editable;
+
+       g_object_class_install_property (object_class, PROP_COLUMN_FIELD,
+                                        g_param_spec_int ("column-field",
+                                                          "Column Field",
+                                                          "Column's Field",
+                                                          G_MININT,
+                                                          G_MAXINT,
+                                                          0,
+                                                          G_PARAM_READWRITE));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormWidgetComboBoxPrivate));
+}
+
+static void
+gtk_form_widget_combo_box_init (GtkFormWidgetComboBox *gtk_form_widget_combo_box)
+{
+}
+
+/**
+ * gtk_form_widget_combo_box_new:
+ *
+ * Returns: the newly created #GtkFormWidgetComboBox.
+ */
+GtkFormWidget
+*gtk_form_widget_combo_box_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET_COMBO_BOX, NULL);
+}
+
+/**
+ * gtk_form_widget_combo_box_get_value_stringify:
+ * @fwidget: a #GtkFormWidget object.
+ *
+ */
+gchar
+*gtk_form_widget_combo_box_get_value_stringify (GtkFormWidget *fwidget)
+{
+       gchar *ret;
+       GtkWidget *w;
+       GtkFormWidgetComboBoxPrivate *priv;
+       GtkTreeModel *tmodel;
+
+       ret = g_strdup ("");
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_COMBO_BOX (fwidget), ret);
+
+       w = gtk_form_widget_get_widget (fwidget);
+
+       priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (fwidget);
+
+       tmodel = gtk_combo_box_get_model (GTK_COMBO_BOX (w));
+       if (tmodel != NULL)
+               {
+                       GtkTreeIter iter;
+
+                       if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &iter))
+                               {
+                                       GValue *gvalue = g_malloc0 (sizeof (GValue));
+                                       GValue *gvstr = g_malloc0 (sizeof (GValue));
+
+                                       gtk_tree_model_get_value (tmodel, &iter, priv->column_field, gvalue);
+
+                                       g_value_init (gvstr, G_TYPE_STRING);
+                                       g_value_transform (gvalue, gvstr);
+                               
+                                       ret = g_strdup (g_value_get_string (gvstr));
+
+                                       g_value_unset (gvstr);
+                                       g_value_unset (gvalue);
+                               }
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_combo_box_set_value_stringify:
+ * @fwidget: a #GtkFormWidget object.
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_combo_box_set_value_stringify (GtkFormWidget *fwidget,
+                                               const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+       GtkTreeModel *tmodel;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_COMBO_BOX (fwidget), FALSE);
+
+       GtkFormWidgetComboBoxPrivate *priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (fwidget);
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_combo_box_set_active (GTK_COMBO_BOX (w), -1);
+
+       tmodel = gtk_combo_box_get_model (GTK_COMBO_BOX (w));
+       if (tmodel != NULL)
+               {
+                       GtkTreeIter iter;
+               
+                       if (gtk_tree_model_get_iter_first (tmodel, &iter))
+                               {
+                                       do
+                                               {
+                                                       GValue *gvalue = g_malloc0 (sizeof (GValue));
+                                                       GValue *gvstr = g_malloc0 (sizeof (GValue));
+
+                                                       gtk_tree_model_get_value (tmodel, &iter, priv->column_field, gvalue);
+
+                                                       g_value_init (gvstr, G_TYPE_STRING);
+                                                       g_value_transform (gvalue, gvstr);
+                                                       if (strcmp (g_value_get_string (gvstr), value) == 0)
+                                                               {
+                                                                       gtk_combo_box_set_active_iter (GTK_COMBO_BOX (w), &iter);
+                                                                       break;
+                                                               }
+
+                                               } while (gtk_tree_model_iter_next (tmodel, &iter));
+                               }
+               }
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_combo_box_set_editable:
+ * @fwidget: a #GtkFormWidget object.
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_combo_box_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_widget_set_sensitive (w, editable);
+}
+
+/**
+ * gtk_form_widget_combo_box_fill_from_datamodel:
+ * @fwidget: a #GtkFormWidget object.
+ * @dm:
+ * @with_empty_entry:
+ *
+ */
+void
+gtk_form_widget_combo_box_fill_from_datamodel (GtkFormWidget *fwidget, GdaDataModel *dm, gboolean with_empty_entry)
+{
+       GtkWidget *w;
+
+       GtkTreeModel *model;
+       GtkTreeIter iter;
+       guint rows;
+       guint row;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET_COMBO_BOX (fwidget));
+       g_return_if_fail (GDA_IS_DATA_MODEL (dm));
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       model = gtk_combo_box_get_model (GTK_COMBO_BOX (w));
+       g_return_if_fail (GTK_IS_TREE_MODEL (model));
+
+       if (with_empty_entry)
+               {
+                       gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+                       gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+                                                           0, "",
+                                                           1, "",
+                                                           -1);
+               }
+
+       rows = gda_data_model_get_n_rows (dm);
+       for (row = 0; row < rows; row++)
+               {
+                       gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+                       gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+                                           0, gdaex_data_model_get_value_stringify_at (dm, row, 0),
+                                           1, gdaex_data_model_get_value_stringify_at (dm, row, 1),
+                                           -1);
+               }
+}
+
+/**
+ * gtk_form_widget_combo_box_fill_from_sql:
+ * @fwidget: a #GtkFormWidget object.
+ * @gdaex:
+ * @sql:
+ * @with_empty_entry:
+ *
+ */
+void
+gtk_form_widget_combo_box_fill_from_sql (GtkFormWidget *fwidget, GdaEx *gdaex, const gchar *sql, gboolean with_empty_entry)
+{
+       GdaEx *real_gdaex;
+       GdaDataModel *dm;
+
+       real_gdaex = NULL;
+
+       if (IS_GDAEX (gdaex))
+               {
+                       real_gdaex = gdaex;
+               }
+       else
+               {
+                       g_object_get (G_OBJECT (fwidget),
+                                             "gdaex", &real_gdaex,
+                                             NULL);
+               }
+
+       g_return_if_fail (real_gdaex != NULL);
+
+       dm = gdaex_query (real_gdaex, sql);
+       gtk_form_widget_combo_box_fill_from_datamodel (fwidget, dm, with_empty_entry);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_combo_box_set_property (GObject *object,
+                                    guint property_id,
+                                    const GValue *value,
+                                    GParamSpec *pspec)
+{
+       GtkFormWidgetComboBox *widget_combo_box = (GtkFormWidgetComboBox *)object;
+
+       GtkFormWidgetComboBoxPrivate *priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (widget_combo_box);
+
+       switch (property_id)
+               {
+                       case PROP_COLUMN_FIELD:
+                               priv->column_field = g_value_get_int (value);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_combo_box_get_property (GObject *object,
+                                    guint property_id,
+                                    GValue *value,
+                                    GParamSpec *pspec)
+{
+       GtkFormWidgetComboBox *widget_combo_box = (GtkFormWidgetComboBox *)object;
+
+       GtkFormWidgetComboBoxPrivate *priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (widget_combo_box);
+
+       switch (property_id)
+               {
+                       case PROP_COLUMN_FIELD:
+                               g_value_set_int (value, priv->column_field);
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/widgetcombobox.h b/libgtkform/widgetcombobox.h
new file mode 100644 (file)
index 0000000..4d28236
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_COMBO_BOX_H__
+#define __LIBGTK_FORM_WIDGET_COMBO_BOX_H__
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET_COMBO_BOX                 (gtk_form_widget_combo_box_get_type ())
+#define GTK_FORM_WIDGET_COMBO_BOX(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBox))
+#define GTK_FORM_WIDGET_COMBO_BOX_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBoxClass))
+#define IS_GTK_FORM_WIDGET_COMBO_BOX(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX))
+#define IS_GTK_FORM_WIDGET_COMBO_BOX_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_COMBO_BOX))
+#define GTK_FORM_WIDGET_COMBO_BOX_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBoxClass))
+
+
+typedef struct _GtkFormWidgetComboBox GtkFormWidgetComboBox;
+typedef struct _GtkFormWidgetComboBoxClass GtkFormWidgetComboBoxClass;
+
+struct _GtkFormWidgetComboBox
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetComboBoxClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_combo_box_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_combo_box_new (void);
+
+gchar *gtk_form_widget_combo_box_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_combo_box_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_combo_box_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+void gtk_form_widget_combo_box_fill_from_datamodel (GtkFormWidget *fwidget, GdaDataModel *dm, gboolean with_empty_entry);
+void gtk_form_widget_combo_box_fill_from_sql (GtkFormWidget *fwidget, GdaEx *gdaex, const gchar *sql, gboolean with_empty_entry);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_COMBO_BOX_H__ */
diff --git a/libgtkform/widgetentry.c b/libgtkform/widgetentry.c
new file mode 100644 (file)
index 0000000..687d92b
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+#include "widgetentry.h"
+
+enum
+{
+       PROP_0
+};
+
+static void gtk_form_widget_entry_class_init (GtkFormWidgetEntryClass *klass);
+static void gtk_form_widget_entry_init (GtkFormWidgetEntry *gtk_form_widget_entry);
+
+static void gtk_form_widget_entry_set_property (GObject *object,
+                                      guint property_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec);
+static void gtk_form_widget_entry_get_property (GObject *object,
+                                      guint property_id,
+                                      GValue *value,
+                                      GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntryPrivate))
+
+typedef struct _GtkFormWidgetEntryPrivate GtkFormWidgetEntryPrivate;
+struct _GtkFormWidgetEntryPrivate
+       {
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetEntry, gtk_form_widget_entry, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_entry_class_init (GtkFormWidgetEntryClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_entry_set_property;
+       object_class->get_property = gtk_form_widget_entry_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_entry_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_entry_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_entry_set_editable;
+
+       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetEntryPrivate));*/
+}
+
+static void
+gtk_form_widget_entry_init (GtkFormWidgetEntry *gtk_form_widget_entry)
+{
+}
+
+/**
+ * gtk_form_widget_entry_new:
+ *
+ * Returns: the newly created #GtkFormWidgetEntry.
+ */
+GtkFormWidget
+*gtk_form_widget_entry_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET_ENTRY, NULL);
+}
+
+/**
+ * gtk_form_widget_entry_get_value_stringify:
+ * @widget:
+ *
+ */
+gchar
+*gtk_form_widget_entry_get_value_stringify (GtkFormWidget *fwidget)
+{
+       GtkWidget *w = gtk_form_widget_get_widget (fwidget);
+
+       return g_strdup (gtk_entry_get_text (GTK_ENTRY (w)));
+}
+
+/**
+ * gtk_form_widget_entry_set_value_stringify:
+ * @fwidget:
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_entry_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_entry_set_text (GTK_ENTRY (w), value);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_set_editable:
+ * @fwidget:
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_entry_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_editable_set_editable (GTK_EDITABLE (w), editable);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_entry_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetEntry *widget_entry = (GtkFormWidgetEntry *)object;
+
+       GtkFormWidgetEntryPrivate *priv = GTK_FORM_WIDGET_ENTRY_GET_PRIVATE (widget_entry);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_entry_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetEntry *widget_entry = (GtkFormWidgetEntry *)object;
+
+       GtkFormWidgetEntryPrivate *priv = GTK_FORM_WIDGET_ENTRY_GET_PRIVATE (widget_entry);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/widgetentry.h b/libgtkform/widgetentry.h
new file mode 100644 (file)
index 0000000..62f38b9
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_ENTRY_H__
+#define __LIBGTK_FORM_WIDGET_ENTRY_H__
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET_ENTRY                 (gtk_form_widget_entry_get_type ())
+#define GTK_FORM_WIDGET_ENTRY(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntry))
+#define GTK_FORM_WIDGET_ENTRY_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntryClass))
+#define IS_GTK_FORM_WIDGET_ENTRY(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_ENTRY))
+#define IS_GTK_FORM_WIDGET_ENTRY_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_ENTRY))
+#define GTK_FORM_WIDGET_ENTRY_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntryClass))
+
+
+typedef struct _GtkFormWidgetEntry GtkFormWidgetEntry;
+typedef struct _GtkFormWidgetEntryClass GtkFormWidgetEntryClass;
+
+struct _GtkFormWidgetEntry
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetEntryClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_entry_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_entry_new (void);
+
+gchar *gtk_form_widget_entry_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_entry_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_entry_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_ENTRY_H__ */
diff --git a/libgtkform/widgetlabel.c b/libgtkform/widgetlabel.c
new file mode 100644 (file)
index 0000000..6f984fb
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+#include "widgetlabel.h"
+
+enum
+{
+       PROP_0
+};
+
+static void gtk_form_widget_label_class_init (GtkFormWidgetLabelClass *klass);
+static void gtk_form_widget_label_init (GtkFormWidgetLabel *gtk_form_widget_label);
+
+static void gtk_form_widget_label_set_property (GObject *object,
+                                      guint property_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec);
+static void gtk_form_widget_label_get_property (GObject *object,
+                                      guint property_id,
+                                      GValue *value,
+                                      GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabelPrivate))
+
+typedef struct _GtkFormWidgetLabelPrivate GtkFormWidgetLabelPrivate;
+struct _GtkFormWidgetLabelPrivate
+       {
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetLabel, gtk_form_widget_label, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_label_class_init (GtkFormWidgetLabelClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_label_set_property;
+       object_class->get_property = gtk_form_widget_label_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_label_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_label_set_value_stringify;
+
+       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetLabelPrivate));*/
+}
+
+static void
+gtk_form_widget_label_init (GtkFormWidgetLabel *gtk_form_widget_label)
+{
+}
+
+/**
+ * gtk_form_widget_label_new:
+ *
+ * Returns: the newly created #GtkFormWidgetLabel.
+ */
+GtkFormWidget
+*gtk_form_widget_label_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET_LABEL, NULL);
+}
+
+/**
+ * gtk_form_widget_label_get_value_stringify:
+ * @widget:
+ *
+ */
+gchar
+*gtk_form_widget_label_get_value_stringify (GtkFormWidget *fwidget)
+{
+       GtkWidget *w = gtk_form_widget_get_widget (fwidget);;
+
+       return g_strdup (gtk_label_get_text (GTK_LABEL (w)));
+}
+
+/**
+ * gtk_form_widget_label_set_value_stringify:
+ * @fwidget:
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_label_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_label_set_text (GTK_LABEL (w), value);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_label_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetLabel *widget_label = (GtkFormWidgetLabel *)object;
+
+       GtkFormWidgetLabelPrivate *priv = GTK_FORM_WIDGET_LABEL_GET_PRIVATE (widget_label);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_label_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetLabel *widget_label = (GtkFormWidgetLabel *)object;
+
+       GtkFormWidgetLabelPrivate *priv = GTK_FORM_WIDGET_LABEL_GET_PRIVATE (widget_label);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/widgetlabel.h b/libgtkform/widgetlabel.h
new file mode 100644 (file)
index 0000000..42024a3
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_LABEL_H__
+#define __LIBGTK_FORM_WIDGET_LABEL_H__
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET_LABEL                 (gtk_form_widget_label_get_type ())
+#define GTK_FORM_WIDGET_LABEL(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabel))
+#define GTK_FORM_WIDGET_LABEL_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabelClass))
+#define IS_GTK_FORM_WIDGET_LABEL(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_LABEL))
+#define IS_GTK_FORM_WIDGET_LABEL_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_LABEL))
+#define GTK_FORM_WIDGET_LABEL_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabelClass))
+
+
+typedef struct _GtkFormWidgetLabel GtkFormWidgetLabel;
+typedef struct _GtkFormWidgetLabelClass GtkFormWidgetLabelClass;
+
+struct _GtkFormWidgetLabel
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetLabelClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_label_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_label_new (void);
+
+gchar *gtk_form_widget_label_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_label_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_LABEL_H__ */
diff --git a/libgtkform/widgetradio.c b/libgtkform/widgetradio.c
new file mode 100644 (file)
index 0000000..552ac6f
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "widgetradio.h"
+
+enum
+{
+       PROP_0,
+       PROP_RETURN_VALUE
+};
+
+static void gtk_form_widget_radio_class_init (GtkFormWidgetRadioClass *klass);
+static void gtk_form_widget_radio_init (GtkFormWidgetRadio *gtk_form_widget_radio);
+
+static void gtk_form_widget_radio_set_property (GObject *object,
+                                            guint property_id,
+                                            const GValue *value,
+                                            GParamSpec *pspec);
+static void gtk_form_widget_radio_get_property (GObject *object,
+                                            guint property_id,
+                                            GValue *value,
+                                            GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_RADIO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadioPrivate))
+
+typedef struct _GtkFormWidgetRadioPrivate GtkFormWidgetRadioPrivate;
+struct _GtkFormWidgetRadioPrivate
+       {
+               gchar *value;
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetRadio, gtk_form_widget_radio, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_radio_class_init (GtkFormWidgetRadioClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_radio_set_property;
+       object_class->get_property = gtk_form_widget_radio_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_radio_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_radio_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_radio_set_editable;
+
+       g_object_class_install_property (object_class, PROP_RETURN_VALUE,
+                                        g_param_spec_string ("return-value",
+                                                          "Return value",
+                                                          "Return value",
+                                                          "",
+                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_type_class_add_private (object_class, sizeof (GtkFormWidgetRadioPrivate));
+}
+
+static void
+gtk_form_widget_radio_init (GtkFormWidgetRadio *gtk_form_widget_radio)
+{
+}
+
+/**
+ * gtk_form_widget_radio_new:
+ *
+ * Returns: the newly created #GtkFormWidgetRadio.
+ */
+GtkFormWidget
+*gtk_form_widget_radio_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET_RADIO, NULL);
+}
+
+/**
+ * gtk_form_widget_radio_get_value_stringify:
+ * @widget:
+ *
+ */
+gchar
+*gtk_form_widget_radio_get_value_stringify (GtkFormWidget *fwidget)
+{
+       GSList *group;
+       GtkWidget *w;
+       gchar *ret;
+       GtkFormWidgetRadioPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget), "");
+
+       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (fwidget);
+
+       w = gtk_form_widget_get_widget (fwidget);
+
+       ret = g_strdup ("");
+
+       /* always returns the value of the group's active radio button */
+       group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+       while (group != NULL)
+               {
+                       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (group->data)))
+                               {
+                                       ret = (gchar *)g_object_get_data (G_OBJECT (group->data), "return-value");
+                                       if (ret == NULL)
+                                               {
+                                                       ret = g_strdup ("");
+                                               }
+                                       break;
+                               }
+
+                       group = g_slist_next (group);
+               }
+
+       return g_strdup (ret);
+}
+
+/**
+ * gtk_form_widget_radio_set_value_stringify:
+ * @fwidget:
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_radio_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret;
+       GtkWidget *w;
+
+       GSList *group;
+
+       GtkFormWidgetRadioPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget), FALSE);
+
+       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (GTK_FORM_WIDGET_RADIO (fwidget));
+
+       ret = FALSE;
+
+       w = gtk_form_widget_get_widget (fwidget);
+
+       /* always set only the right group's radio button */
+       group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
+       while (group != NULL)
+               {
+                       if (g_strcmp0 ((gchar *)g_object_get_data (G_OBJECT (group->data), "return-value"), value) == 0)
+                               {
+                                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->data), TRUE);
+                                       break;
+                               }
+
+                       group = g_slist_next (group);
+               }
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_radio_set_editable:
+ * @fwidget: a #GtkFormWidget object.
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_radio_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget));
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_widget_set_sensitive (w, editable);
+}
+
+/**
+ * gtk_form_widget_radio_set_return_value:
+ * @fwidget: a #GtkFormWidgetRadio object.
+ * @value:
+ *
+ */
+void
+gtk_form_widget_radio_set_return_value (GtkFormWidgetRadio *fwidget, const gchar *value)
+{
+       GtkFormWidgetRadioPrivate *priv;
+       GtkWidget *widget;
+
+       g_return_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget));
+
+       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (fwidget);
+
+       if (value == NULL)
+               {
+                       priv->value = g_strdup ("");
+               }
+       else
+               {
+                       priv->value = g_strdup (value);
+               }
+
+       widget = gtk_form_widget_get_widget (GTK_FORM_WIDGET (fwidget));
+       if (GTK_IS_WIDGET (widget))
+               {
+                       g_object_set_data (G_OBJECT (widget), "return-value", (gpointer)priv->value);
+               }
+}
+
+/**
+ * gtk_form_widget_radio_get_return_value:
+ * @fwidget: a #GtkFormWidgetRadio object.
+ *
+ */
+gchar
+*gtk_form_widget_radio_get_return_value (GtkFormWidgetRadio *fwidget)
+{
+       GtkFormWidgetRadioPrivate *priv;
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget), NULL);
+
+       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (fwidget);
+
+       return g_strdup (priv->value);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_radio_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetRadio *widget_radio = (GtkFormWidgetRadio *)object;
+
+       GtkFormWidgetRadioPrivate *priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (widget_radio);
+
+       switch (property_id)
+               {
+                       case PROP_RETURN_VALUE:
+                               gtk_form_widget_radio_set_return_value (widget_radio, g_value_get_string (value));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_radio_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetRadio *widget_radio = (GtkFormWidgetRadio *)object;
+
+       GtkFormWidgetRadioPrivate *priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (widget_radio);
+
+       switch (property_id)
+               {
+                       case PROP_RETURN_VALUE:
+                               g_value_set_string (value, gtk_form_widget_radio_get_return_value (widget_radio));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/widgetradio.h b/libgtkform/widgetradio.h
new file mode 100644 (file)
index 0000000..19d0fba
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2005-2010 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_RADIO_H__
+#define __LIBGTK_FORM_WIDGET_RADIO_H__
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET_RADIO                 (gtk_form_widget_radio_get_type ())
+#define GTK_FORM_WIDGET_RADIO(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadio))
+#define GTK_FORM_WIDGET_RADIO_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadioClass))
+#define IS_GTK_FORM_WIDGET_RADIO(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_RADIO))
+#define IS_GTK_FORM_WIDGET_RADIO_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_RADIO))
+#define GTK_FORM_WIDGET_RADIO_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadioClass))
+
+
+typedef struct _GtkFormWidgetRadio GtkFormWidgetRadio;
+typedef struct _GtkFormWidgetRadioClass GtkFormWidgetRadioClass;
+
+struct _GtkFormWidgetRadio
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetRadioClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_radio_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_radio_new (void);
+
+gchar *gtk_form_widget_radio_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_radio_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_radio_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+void gtk_form_widget_radio_set_return_value (GtkFormWidgetRadio *fwidget, const gchar *value);
+gchar *gtk_form_widget_radio_get_return_value (GtkFormWidgetRadio *fwidget);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_RADIO_H__ */
diff --git a/libgtkform/widgetspin.c b/libgtkform/widgetspin.c
new file mode 100644 (file)
index 0000000..6487165
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+
+#include "widgetspin.h"
+
+enum
+{
+       PROP_0
+};
+
+static void gtk_form_widget_spin_class_init (GtkFormWidgetSpinClass *klass);
+static void gtk_form_widget_spin_init (GtkFormWidgetSpin *gtk_form_widget_spin);
+
+static void gtk_form_widget_spin_set_property (GObject *object,
+                                           guint property_id,
+                                           const GValue *value,
+                                           GParamSpec *pspec);
+static void gtk_form_widget_spin_get_property (GObject *object,
+                                           guint property_id,
+                                           GValue *value,
+                                           GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_SPIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpinPrivate))
+
+typedef struct _GtkFormWidgetSpinPrivate GtkFormWidgetSpinPrivate;
+struct _GtkFormWidgetSpinPrivate
+       {
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetSpin, gtk_form_widget_spin, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_spin_class_init (GtkFormWidgetSpinClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_spin_set_property;
+       object_class->get_property = gtk_form_widget_spin_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_spin_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_spin_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_spin_set_editable;
+
+       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetSpinPrivate));*/
+}
+
+static void
+gtk_form_widget_spin_init (GtkFormWidgetSpin *gtk_form_widget_spin)
+{
+}
+
+/**
+ * gtk_form_widget_spin_new:
+ *
+ * Returns: the newly created #GtkFormWidgetSpin.
+ */
+GtkFormWidget
+*gtk_form_widget_spin_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET_SPIN, NULL);
+}
+
+/**
+ * gtk_form_widget_spin_get_value_stringify:
+ * @widget: a #GtkFormWidget object.
+ *
+ */
+gchar
+*gtk_form_widget_spin_get_value_stringify (GtkFormWidget *fwidget)
+{
+       GtkWidget *w;
+       gchar *ret;
+
+       ret = g_strdup ("");
+
+       g_return_val_if_fail (IS_GTK_FORM_WIDGET_SPIN (fwidget), ret);
+
+       w = gtk_form_widget_get_widget (fwidget);
+
+       if (w != NULL)
+               {
+                       ret = g_strdup_printf ("%f", gtk_spin_button_get_value (GTK_SPIN_BUTTON (w)));
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_spin_set_value_stringify:
+ * @fwidget: a #GtkFormWidget object.
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_spin_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), g_strtod (value, NULL));
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_spin_set_editable:
+ * @fwidget: a #GtkFormWidget object.
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_spin_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_editable_set_editable (GTK_EDITABLE (w), editable);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_spin_set_property (GObject *object,
+                               guint property_id,
+                               const GValue *value,
+                               GParamSpec *pspec)
+{
+       GtkFormWidgetSpin *widget_spin = (GtkFormWidgetSpin *)object;
+
+       GtkFormWidgetSpinPrivate *priv = GTK_FORM_WIDGET_SPIN_GET_PRIVATE (widget_spin);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_spin_get_property (GObject *object,
+                               guint property_id,
+                               GValue *value,
+                               GParamSpec *pspec)
+{
+       GtkFormWidgetSpin *widget_spin = (GtkFormWidgetSpin *)object;
+
+       GtkFormWidgetSpinPrivate *priv = GTK_FORM_WIDGET_SPIN_GET_PRIVATE (widget_spin);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/widgetspin.h b/libgtkform/widgetspin.h
new file mode 100644 (file)
index 0000000..886350f
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_SPIN_H__
+#define __LIBGTK_FORM_WIDGET_SPIN_H__
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET_SPIN                 (gtk_form_widget_spin_get_type ())
+#define GTK_FORM_WIDGET_SPIN(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpin))
+#define GTK_FORM_WIDGET_SPIN_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpinClass))
+#define IS_GTK_FORM_WIDGET_SPIN(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_SPIN))
+#define IS_GTK_FORM_WIDGET_SPIN_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_SPIN))
+#define GTK_FORM_WIDGET_SPIN_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpinClass))
+
+
+typedef struct _GtkFormWidgetSpin GtkFormWidgetSpin;
+typedef struct _GtkFormWidgetSpinClass GtkFormWidgetSpinClass;
+
+struct _GtkFormWidgetSpin
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetSpinClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_spin_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_spin_new (void);
+
+gchar *gtk_form_widget_spin_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_spin_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_spin_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_SPIN_H__ */
diff --git a/libgtkform/widgettextview.c b/libgtkform/widgettextview.c
new file mode 100644 (file)
index 0000000..18928d3
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+#include "widgettextview.h"
+
+enum
+{
+       PROP_0
+};
+
+static void gtk_form_widget_textview_class_init (GtkFormWidgetTextviewClass *klass);
+static void gtk_form_widget_textview_init (GtkFormWidgetTextview *gtk_form_widget_textview);
+
+static void gtk_form_widget_textview_set_property (GObject *object,
+                                      guint property_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec);
+static void gtk_form_widget_textview_get_property (GObject *object,
+                                      guint property_id,
+                                      GValue *value,
+                                      GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_TEXTVIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextviewPrivate))
+
+typedef struct _GtkFormWidgetTextviewPrivate GtkFormWidgetTextviewPrivate;
+struct _GtkFormWidgetTextviewPrivate
+       {
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetTextview, gtk_form_widget_textview, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_textview_class_init (GtkFormWidgetTextviewClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_textview_set_property;
+       object_class->get_property = gtk_form_widget_textview_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_textview_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_textview_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_textview_set_editable;
+
+       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetTextviewPrivate));*/
+}
+
+static void
+gtk_form_widget_textview_init (GtkFormWidgetTextview *gtk_form_widget_textview)
+{
+}
+
+/**
+ * gtk_form_widget_textview_new:
+ *
+ * Returns: the newly created #GtkFormWidgetTextview.
+ */
+GtkFormWidget
+*gtk_form_widget_textview_new ()
+{
+       return g_object_new (TYPE_GTK_FORM_WIDGET_TEXTVIEW, NULL);
+}
+
+/**
+ * gtk_form_widget_textview_get_value_stringify:
+ * @widget: a #GtkFormWidget object.
+ *
+ */
+gchar
+*gtk_form_widget_textview_get_value_stringify (GtkFormWidget *fwidget)
+{
+       gchar *ret = NULL;
+       GtkWidget *w;
+       GtkTextBuffer *buf;
+       GtkTextIter start;
+       GtkTextIter end;
+
+       w = gtk_form_widget_get_widget (fwidget);
+
+       buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
+       gtk_text_buffer_get_bounds (buf, &start, &end);
+       ret = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_textview_set_value_stringify:
+ * @fwidget: a #GtkFormWidget object.
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_textview_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+       GtkTextBuffer *buf;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
+       gtk_text_buffer_set_text (buf, value, -1);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_textview_set_editable:
+ * @fwidget: a #GtkFormWidget object.
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_textview_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_text_view_set_editable (GTK_TEXT_VIEW (w), editable);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_textview_set_property (GObject *object,
+                                   guint property_id,
+                                   const GValue *value,
+                                   GParamSpec *pspec)
+{
+       GtkFormWidgetTextview *widget_textview = (GtkFormWidgetTextview *)object;
+
+       GtkFormWidgetTextviewPrivate *priv = GTK_FORM_WIDGET_TEXTVIEW_GET_PRIVATE (widget_textview);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
+
+static void
+gtk_form_widget_textview_get_property (GObject *object,
+                                   guint property_id,
+                                   GValue *value,
+                                   GParamSpec *pspec)
+{
+       GtkFormWidgetTextview *widget_textview = (GtkFormWidgetTextview *)object;
+
+       GtkFormWidgetTextviewPrivate *priv = GTK_FORM_WIDGET_TEXTVIEW_GET_PRIVATE (widget_textview);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+         }
+}
diff --git a/libgtkform/widgettextview.h b/libgtkform/widgettextview.h
new file mode 100644 (file)
index 0000000..dcadf36
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2005-2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_TEXTVIEW_H__
+#define __LIBGTK_FORM_WIDGET_TEXTVIEW_H__
+
+#include "widget.h"
+
+
+G_BEGIN_DECLS
+
+
+#define TYPE_GTK_FORM_WIDGET_TEXTVIEW                 (gtk_form_widget_textview_get_type ())
+#define GTK_FORM_WIDGET_TEXTVIEW(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextview))
+#define GTK_FORM_WIDGET_TEXTVIEW_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextviewClass))
+#define IS_GTK_FORM_WIDGET_TEXTVIEW(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW))
+#define IS_GTK_FORM_WIDGET_TEXTVIEW_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_TEXTVIEW))
+#define GTK_FORM_WIDGET_TEXTVIEW_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextviewClass))
+
+
+typedef struct _GtkFormWidgetTextview GtkFormWidgetTextview;
+typedef struct _GtkFormWidgetTextviewClass GtkFormWidgetTextviewClass;
+
+struct _GtkFormWidgetTextview
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetTextviewClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_textview_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_textview_new (void);
+
+gchar *gtk_form_widget_textview_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_textview_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_textview_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_TEXTVIEW_H__ */
diff --git a/libgtkformui/Makefile.am b/libgtkformui/Makefile.am
new file mode 100644 (file)
index 0000000..1e3b1b5
--- /dev/null
@@ -0,0 +1,48 @@
+if GLADEUI
+GLADEDIR = glade
+else
+GLADEDIR =
+endif
+
+if PLATFORM_WIN32
+libmodulesext = -0.dll
+libmodulesdir = $(bindir)
+else
+libmodulesext = .so
+libmodulesdir = $(libdir)
+endif
+
+SUBDIRS = . \
+          test \
+          $(GLADEDIR)
+
+AM_CPPFLAGS = $(WARN_CFLAGS) \
+              $(DISABLE_DEPRECATED_CFLAGS) \
+              $(GTKFORM_CFLAGS) \
+              -I$(top_srcdir) \
+              -DLOCALEDIR=\"$(localedir)\" \
+              -DMODULESDIR=\""$(libdir)/$(PACKAGE)/modules"\" \
+              -DG_LOG_DOMAIN=\"GtkFormUI\"
+
+LIBS = $(GTKFORM_LIBS)
+
+lib_LTLIBRARIES = libgtkformui.la
+
+libgtkformui_la_SOURCES = gtkformdecoder.c \
+                          gtkformwidgetdecoder.c
+
+libgtkformui_la_LIBADD = $(top_builddir)/libgtkform/libgtkform.la
+
+libgtkformui_la_LDFLAGS = -no-undefined
+
+libgtkformui_include_HEADERS = gtkformdecoder.h \
+                               gtkformwidgetdecoder.h
+
+libgtkformui_includedir = $(includedir)/libgtkformui
+
+install-exec-hook:
+       cd $(libdir)/$(PACKAGE)/modules && \
+       ln -s -f $(libmodulesdir)/libgtkformui$(libmodulesext) .
+
+uninstall-hook:
+       rm -f $(libdir)/$(PACKAGE)/modules/libgtkformui$(libmodulesext)
diff --git a/libgtkformui/glade/Makefile.am b/libgtkformui/glade/Makefile.am
new file mode 100644 (file)
index 0000000..be8b722
--- /dev/null
@@ -0,0 +1,26 @@
+SUBDIRS = icons
+
+glademodulesdir = `pkg-config --variable=moduledir gladeui-1.0`
+
+gladecatalogsdir = `pkg-config --variable=catalogdir gladeui-1.0`
+
+gladecatalogs_DATA = gtkformui.xml
+
+EXTRA_DIST = $(gladecatalogs_DATA)
+
+if PLATFORM_WIN32
+libmodulesext = -0.dll
+libmodulesextglade = .dll
+libmodulesdir = $(bindir)
+else
+libmodulesext = .so
+libmodulesextglade = $(libmodulesext)
+libmodulesdir = $(libdir)
+endif
+
+install-exec-hook:
+       cd $(glademodulesdir) && \
+       ln -s -f $(libmodulesdir)/libgtkformui$(libmodulesext) libgtkformui$(libmodulesextglade)
+
+uninstall-hook:
+       rm -f $(glademodulesdir)/libgtkformui$(libmodulesextglade)
diff --git a/libgtkformui/glade/gtkformui.xml b/libgtkformui/glade/gtkformui.xml
new file mode 100644 (file)
index 0000000..7dc1f93
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<glade-catalog name="gtkformui" library="gtkformui" depends="gtk+" domain="gtkformui" book="gtkformui">
+
+       <glade-widget-classes>
+               <glade-widget-class name="GtkFormDecoder" generic-name="gtkformdecoder" title="Decoder">
+                       <properties>
+                               <property name="GdaEx object" id="gdaex" visible="False" />
+                               <property name="Sql statement" id="sql" />
+                               <property name="Show clean icon" id="show-btn-clean" />
+                               <property name="Show open button" id="show-btn-open" />
+                               <property name="Show browse button" id="show-btn-browse" />
+                       </properties>
+               </glade-widget-class>
+       </glade-widget-classes>
+
+       <glade-widget-group name="gtk-control-display" title="Control and Display">
+               <glade-widget-class-ref name="GtkFormDecoder" />
+       </glade-widget-group>
+
+</glade-catalog>
diff --git a/libgtkformui/glade/icons/Makefile.am b/libgtkformui/glade/icons/Makefile.am
new file mode 100644 (file)
index 0000000..658356b
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = hicolor
diff --git a/libgtkformui/glade/icons/hicolor/16x16/Makefile.am b/libgtkformui/glade/icons/hicolor/16x16/Makefile.am
new file mode 100644 (file)
index 0000000..0224d45
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = actions
diff --git a/libgtkformui/glade/icons/hicolor/16x16/actions/Makefile.am b/libgtkformui/glade/icons/hicolor/16x16/actions/Makefile.am
new file mode 100644 (file)
index 0000000..ccf8100
--- /dev/null
@@ -0,0 +1,5 @@
+iconsdir = `pkg-config --variable=pixmapdir gladeui-1.0`/hicolor/16x16/actions
+
+icons_DATA = widget-gtkformui-gtkformdecoder.png
+
+EXTRA_DIST = $(icons_DATA)
diff --git a/libgtkformui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png b/libgtkformui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png
new file mode 100644 (file)
index 0000000..9796233
Binary files /dev/null and b/libgtkformui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png differ
diff --git a/libgtkformui/glade/icons/hicolor/22x22/Makefile.am b/libgtkformui/glade/icons/hicolor/22x22/Makefile.am
new file mode 100644 (file)
index 0000000..0224d45
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = actions
diff --git a/libgtkformui/glade/icons/hicolor/22x22/actions/Makefile.am b/libgtkformui/glade/icons/hicolor/22x22/actions/Makefile.am
new file mode 100644 (file)
index 0000000..35aa85a
--- /dev/null
@@ -0,0 +1,5 @@
+iconsdir = `pkg-config --variable=pixmapdir gladeui-1.0`/hicolor/22x22/actions
+
+icons_DATA = widget-gtkformui-gtkformdecoder.png
+
+EXTRA_DIST = $(icons_DATA)
diff --git a/libgtkformui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png b/libgtkformui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png
new file mode 100644 (file)
index 0000000..d26591a
Binary files /dev/null and b/libgtkformui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png differ
diff --git a/libgtkformui/glade/icons/hicolor/Makefile.am b/libgtkformui/glade/icons/hicolor/Makefile.am
new file mode 100644 (file)
index 0000000..fc1d169
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = 16x16 22x22
diff --git a/libgtkformui/gtkformdecoder.c b/libgtkformui/gtkformdecoder.c
new file mode 100644 (file)
index 0000000..2023cf1
--- /dev/null
@@ -0,0 +1,610 @@
+/*
+ * GtkFormDecoder widget for GTK+
+ *
+ * Copyright (C) 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include <sql-parser/gda-sql-parser.h>
+
+#include <libgdaex/libgdaex.h>
+
+#include "gtkformdecoder.h"
+
+enum
+{
+       PROP_0,
+       PROP_GDAEX,
+       PROP_SQL,
+       PROP_SHOW_CLEAN,
+       PROP_SHOW_OPEN,
+       PROP_SHOW_BROWSE
+};
+
+static void gtk_form_decoder_class_init (GtkFormDecoderClass *klass);
+static void gtk_form_decoder_init (GtkFormDecoder *decoder);
+
+static void gtk_form_decoder_decode (GtkFormDecoder *decoder);
+
+static void gtk_form_decoder_size_request (GtkWidget *widget,
+                                    GtkRequisition *requisition);
+static void gtk_form_decoder_size_allocate (GtkWidget *widget,
+                                     GtkAllocation *allocation);
+
+static void gtk_form_decoder_set_property (GObject *object,
+                                           guint property_id,
+                                           const GValue *value,
+                                           GParamSpec *pspec);
+static void gtk_form_decoder_get_property (GObject *object,
+                                           guint property_id,
+                                           GValue *value,
+                                           GParamSpec *pspec);
+
+static void gtk_form_decoder_on_btn_clean_clicked (GtkEntry *entry,
+                                         GtkEntryIconPosition icon_pos,
+                                         GdkEvent *event,
+                                         gpointer user_data);
+
+static void gtk_form_decoder_on_btn_open_clicked (GtkButton *button,
+                                        gpointer user_data);
+
+static void gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
+                                        gpointer user_data);
+
+static GtkWidgetClass *parent_class = NULL;
+
+
+#define GTK_FORM_DECODER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_FORM_DECODER, GtkFormDecoderPrivate))
+
+typedef struct _GtkFormDecoderPrivate GtkFormDecoderPrivate;
+struct _GtkFormDecoderPrivate
+       {
+               GtkWidget *hbox;
+               GtkWidget *txt_decoded;
+               GtkWidget *btn_open;
+               GtkWidget *btn_browse;
+               GtkWidget *lbl_key;
+
+               GdaEx *gdaex;
+               gchar *sql;
+       };
+
+G_DEFINE_TYPE (GtkFormDecoder, gtk_form_decoder, GTK_TYPE_BIN)
+
+static void
+gtk_form_decoder_class_init (GtkFormDecoderClass *klass)
+{
+       GtkWidgetClass *widget_class;
+
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (GtkFormDecoderPrivate));
+
+       widget_class = (GtkWidgetClass*) klass;
+       parent_class = g_type_class_peek_parent (klass);
+
+       object_class->set_property = gtk_form_decoder_set_property;
+       object_class->get_property = gtk_form_decoder_get_property;
+
+       widget_class->size_request = gtk_form_decoder_size_request;
+       widget_class->size_allocate = gtk_form_decoder_size_allocate;
+
+       g_object_class_install_property (object_class, PROP_GDAEX,
+                                        g_param_spec_object ("gdaex",
+                                                             "GdaEx object",
+                                                             "GdaEx object",
+                                                             TYPE_GDAEX,
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_SQL,
+                                        g_param_spec_string ("sql",
+                                                             "Sql string",
+                                                             "Sql string",
+                                                             NULL,
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       g_object_class_install_property (object_class, PROP_SHOW_CLEAN,
+                                        g_param_spec_boolean ("show-btn-clean",
+                                                              "Show clean icon",
+                                                              "Whether to show the clean icon",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_SHOW_OPEN,
+                                        g_param_spec_boolean ("show-btn-open",
+                                                              "Show open button",
+                                                              "Whether to show the open button",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_SHOW_BROWSE,
+                                        g_param_spec_boolean ("show-btn-browse",
+                                                              "Show browse button",
+                                                              "Whether to show the browse button",
+                                                              TRUE,
+                                                              G_PARAM_READWRITE));
+
+       /**
+        * GtkFormDecoder::btn_clean_clicked:
+        * @gtk_form_decoder:
+        *
+        */
+       klass->btn_clean_clicked_signal_id = g_signal_new ("btn-clean-clicked",
+                                                      G_TYPE_FROM_CLASS (object_class),
+                                                      G_SIGNAL_RUN_LAST,
+                                                      0,
+                                                      NULL,
+                                                      NULL,
+                                                      g_cclosure_marshal_BOOLEAN__FLAGS,
+                                                      G_TYPE_BOOLEAN,
+                                                      1, G_TYPE_INT);
+
+       /**
+        * GtkFormDecoder::btn_open_clicked:
+        * @gtk_form_decoder:
+        *
+        */
+       klass->btn_open_clicked_signal_id = g_signal_new ("btn-open-clicked",
+                                                      G_TYPE_FROM_CLASS (object_class),
+                                                      G_SIGNAL_RUN_LAST,
+                                                      0,
+                                                      NULL,
+                                                      NULL,
+                                                      g_cclosure_marshal_VOID__VOID,
+                                                      G_TYPE_NONE,
+                                                      0);
+
+       /**
+        * GtkFormDecoder::btn_browse_clicked:
+        * @gtk_form_decoder:
+        *
+        */
+       klass->btn_browse_clicked_signal_id = g_signal_new ("btn-browse-clicked",
+                                                      G_TYPE_FROM_CLASS (object_class),
+                                                      G_SIGNAL_RUN_LAST,
+                                                      0,
+                                                      NULL,
+                                                      NULL,
+                                                      g_cclosure_marshal_VOID__VOID,
+                                                      G_TYPE_NONE,
+                                                      0);
+}
+
+static void
+gtk_form_decoder_init (GtkFormDecoder *decoder)
+{
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       GtkWidget *icon;
+
+       priv->hbox = gtk_hbox_new (FALSE, 3);
+       gtk_container_add (GTK_CONTAINER (decoder), priv->hbox);
+       gtk_widget_show (priv->hbox);
+
+       priv->txt_decoded = gtk_entry_new ();
+       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->txt_decoded, TRUE, TRUE, 0);
+       gtk_editable_set_editable (GTK_EDITABLE (priv->txt_decoded), FALSE);
+       gtk_widget_show (priv->txt_decoded);
+
+       g_signal_connect (G_OBJECT (priv->txt_decoded), "icon-press",
+                         G_CALLBACK (gtk_form_decoder_on_btn_clean_clicked), (gpointer)decoder);
+
+       priv->btn_open = gtk_button_new ();
+       gtk_widget_set_tooltip_text (priv->btn_open, _("Open"));
+       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->btn_open, FALSE, FALSE, 0);
+       gtk_widget_set_no_show_all (priv->btn_open, TRUE);
+       icon = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
+       gtk_container_add (GTK_CONTAINER (priv->btn_open), icon);
+       gtk_widget_show (icon);
+
+       g_signal_connect (G_OBJECT (priv->btn_open), "clicked",
+                         G_CALLBACK (gtk_form_decoder_on_btn_open_clicked), (gpointer)decoder);
+
+       priv->btn_browse = gtk_button_new_with_label ("...");
+       gtk_widget_set_tooltip_text (priv->btn_browse, _("Find"));
+       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->btn_browse, FALSE, FALSE, 0);
+       gtk_widget_set_no_show_all (priv->btn_browse, TRUE);
+       gtk_widget_show (priv->btn_browse);
+
+       g_signal_connect (G_OBJECT (priv->btn_browse), "clicked",
+                         G_CALLBACK (gtk_form_decoder_on_btn_browse_clicked), (gpointer)decoder);
+
+       priv->lbl_key = gtk_label_new ("");
+       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->lbl_key, FALSE, FALSE, 0);
+       gtk_widget_set_no_show_all (priv->lbl_key, TRUE);
+}
+
+/**
+ * gtk_form_decoder_new:
+ *
+ * Creates a new #GtkFormDecoder.
+ *
+ * Returns: The newly created #GtkFormDecoder widget.
+ */
+GtkWidget
+*gtk_form_decoder_new ()
+{
+       GtkWidget *w = GTK_WIDGET (g_object_new (gtk_form_decoder_get_type (), NULL));
+
+       return w;
+}
+
+void
+gtk_form_decoder_set_key (GtkFormDecoder *decoder, const gchar *key)
+{
+       GtkFormDecoderPrivate *priv;
+
+       g_return_if_fail (GTK_IS_FORM_DECODER (decoder));
+
+       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       gtk_label_set_text (GTK_LABEL (priv->lbl_key), key);
+       gtk_form_decoder_decode (decoder);
+}
+
+gchar
+*gtk_form_decoder_get_key (GtkFormDecoder *decoder)
+{
+       GtkFormDecoderPrivate *priv;
+
+       g_return_val_if_fail (GTK_IS_FORM_DECODER (decoder), NULL);
+
+       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       return g_strdup (gtk_label_get_text (GTK_LABEL (priv->lbl_key)));
+}
+
+gchar
+*gtk_form_decoder_get_decoded (GtkFormDecoder *decoder)
+{
+       GtkFormDecoderPrivate *priv;
+
+       g_return_val_if_fail (GTK_IS_FORM_DECODER (decoder), NULL);
+
+       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       return g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->txt_decoded)));
+}
+
+/* PRIVATE */
+static void
+gtk_form_decoder_decode (GtkFormDecoder *decoder)
+{
+       GtkFormDecoderPrivate *priv;
+
+       GObject *res;
+       GdaConnection *gdacon;
+       GdaSqlParser *parser;
+       GdaStatement *stmt;
+       GdaSet *params;
+       GSList *hs;
+       GdaHolder *h;
+       GValue *gval;
+       GError *error;
+
+       g_return_if_fail (GTK_IS_FORM_DECODER (decoder));
+
+       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       if (IS_GDAEX (priv->gdaex))
+               {
+                       gdacon = (GdaConnection *)gdaex_get_gdaconnection (priv->gdaex);
+                       parser = gda_connection_create_parser (gdacon);
+                       if (parser == NULL)
+                               {
+                                       parser = gda_sql_parser_new ();
+                               }
+
+                       error == NULL;
+                       stmt = gda_sql_parser_parse_string (parser, priv->sql, NULL, &error);
+                       if (stmt == NULL)
+                               {
+                                       g_warning (_("Error on parsing sql string: %s\n%s"), priv->sql,
+                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                               }
+                       else
+                               {
+                                       gda_statement_get_parameters (stmt, &params, NULL);
+                                       if (params != NULL)
+                                               {
+                                                       hs = params->holders;
+                                                       while (hs != NULL)
+                                                               {
+                                                                       h = (GdaHolder *)hs->data;
+
+                                                                       if (GDA_IS_HOLDER (h))
+                                                                               {
+                                                                                       gval = gda_value_new_from_string (gtk_label_get_text (GTK_LABEL (priv->lbl_key)), gda_holder_get_g_type (h));
+
+                                                                                       error = NULL;
+                                                                                       if (!gda_holder_set_value (h, gval, &error))
+                                                                                               {
+                                                                                                       g_warning (_("Error on setting holder's value: %s"),
+                                                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                                                               }
+                                                                               }
+                                                                       hs = g_slist_next (hs);
+                                                               }
+                                               }
+
+                                       error = NULL;
+                                       res = gda_connection_statement_execute (gdacon, stmt, params,
+                                                                               GDA_STATEMENT_MODEL_RANDOM_ACCESS,
+                                                                               NULL, &error);
+                                       if (res == NULL)
+                                               {
+                                                       g_warning (_("Error on executing decoding: %s"),
+                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                               }
+                                       else if (GDA_IS_DATA_MODEL (res) && gda_data_model_get_n_rows ((GdaDataModel *)res) == 1)
+                                               {
+                                                       gtk_entry_set_text (GTK_ENTRY (priv->txt_decoded),
+                                                                           gdaex_data_model_get_value_stringify_at ((GdaDataModel *)res, 0, 0));
+                                               }
+                                       else
+                                               {
+                                                       gtk_entry_set_text (GTK_ENTRY (priv->txt_decoded), "");
+                                               }
+                               }
+               }
+       else
+               {
+                       g_warning (_("No GdaEx object inside GtkFormDecoder."));
+               }
+}
+
+void
+gtk_form_decoder_show_btn_clean (GtkFormDecoder *decoder, gboolean visible)
+{
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, visible ? "gtk-clear" : NULL);
+       gtk_entry_set_icon_activatable (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, visible);
+       gtk_entry_set_icon_sensitive (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, visible);
+}
+
+void
+gtk_form_decoder_show_btn_open (GtkFormDecoder *decoder, gboolean visible)
+{
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       gtk_widget_set_visible (priv->btn_open, visible);
+}
+
+void
+gtk_form_decoder_show_btn_browse (GtkFormDecoder *decoder, gboolean visible)
+{
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       gtk_widget_set_visible (priv->btn_browse, visible);
+}
+
+gboolean
+gtk_form_decoder_btn_clean_is_visible (GtkFormDecoder *decoder)
+{
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       return gtk_entry_get_icon_stock (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY) != NULL;
+}
+
+gboolean
+gtk_form_decoder_btn_open_is_visible (GtkFormDecoder *decoder)
+{
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       return gtk_widget_get_visible (priv->btn_open);
+}
+
+gboolean
+gtk_form_decoder_btn_browse_is_visible (GtkFormDecoder *decoder)
+{
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       return gtk_widget_get_visible (priv->btn_browse);
+}
+
+/* CALLBACKS */
+static void
+gtk_form_decoder_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+       GtkFormDecoder *decoder = GTK_FORM_DECODER (object);
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       switch (property_id)
+               {
+                       case PROP_GDAEX:
+                               priv->gdaex = g_value_get_object (value);
+                               break;
+
+                       case PROP_SQL:
+                               if (G_VALUE_HOLDS_STRING (value))
+                                       {
+                                               priv->sql = g_value_dup_string (value);
+                                               if (priv->sql != NULL)
+                                                       {
+                                                               g_strstrip (priv->sql);
+                                                       }
+                                       }
+                               else
+                                       {
+                                               g_free (priv->sql);
+                                               priv->sql = NULL;
+                                       }
+                               break;
+
+                       case PROP_SHOW_CLEAN:
+                               gtk_form_decoder_show_btn_clean (decoder, g_value_get_boolean (value));
+                               break;
+
+                       case PROP_SHOW_OPEN:
+                               gtk_form_decoder_show_btn_open (decoder, g_value_get_boolean (value));
+                               break;
+
+                       case PROP_SHOW_BROWSE:
+                               gtk_form_decoder_show_btn_browse (decoder, g_value_get_boolean (value));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gtk_form_decoder_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       GtkFormDecoder *decoder = GTK_FORM_DECODER (object);
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+
+       switch (property_id)
+               {
+                       case PROP_GDAEX:
+                               g_value_set_object (value, priv->gdaex);
+                               break;
+
+                       case PROP_SQL:
+                               g_value_set_string (value, priv->sql);
+                               break;
+
+                       case PROP_SHOW_CLEAN:
+                               g_value_set_boolean (value, gtk_form_decoder_btn_clean_is_visible (decoder));
+                               break;
+
+                       case PROP_SHOW_OPEN:
+                               g_value_set_boolean (value, gtk_form_decoder_btn_open_is_visible (decoder));
+                               break;
+
+                       case PROP_SHOW_BROWSE:
+                               g_value_set_boolean (value, gtk_form_decoder_btn_browse_is_visible (decoder));
+                               break;
+
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gtk_form_decoder_size_request (GtkWidget *widget,
+                        GtkRequisition *requisition)
+{
+       GtkFormDecoder *decoder;
+       GtkBin *bin;
+       GtkRequisition child_requisition;
+
+       guint border_width;
+
+       g_return_if_fail (GTK_IS_FORM_DECODER (widget));
+       g_return_if_fail (requisition != NULL);
+
+       decoder = GTK_FORM_DECODER (widget);
+       bin = GTK_BIN (decoder);
+
+       requisition->width = 0;
+       requisition->height = 0;
+
+       if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+               {
+                       gtk_widget_size_request (bin->child, &child_requisition);
+                       requisition->width += child_requisition.width;
+                       requisition->height += child_requisition.height;
+               }
+
+       border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+       requisition->width += (border_width * 2);
+       requisition->height += (border_width * 2);
+}
+
+static void
+gtk_form_decoder_size_allocate (GtkWidget *widget,
+                         GtkAllocation *allocation)
+{
+       GtkFormDecoder *decoder;
+       GtkBin *bin;
+       GtkAllocation relative_allocation;
+       GtkAllocation child_allocation;
+
+       guint border_width;
+
+       g_return_if_fail (GTK_IS_FORM_DECODER (widget));
+       g_return_if_fail (allocation != NULL);
+
+       decoder = GTK_FORM_DECODER (widget);
+       bin = GTK_BIN (decoder);
+
+       gtk_widget_set_allocation (widget, allocation);
+
+       border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+       relative_allocation.x = border_width;
+       relative_allocation.y = border_width;
+       relative_allocation.width = MAX (1, (gint)widget->allocation.width - relative_allocation.x * 2);
+       relative_allocation.height = MAX (1, (gint)widget->allocation.height - relative_allocation.y * 2);
+
+       if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+               {
+                       child_allocation.x = relative_allocation.x + allocation->x;
+                       child_allocation.y = relative_allocation.y + allocation->y;
+                       child_allocation.width = relative_allocation.width;
+                       child_allocation.height = relative_allocation.height;
+                       gtk_widget_size_allocate (bin->child, &child_allocation);
+               }
+}
+
+static void
+gtk_form_decoder_on_btn_clean_clicked (GtkEntry *entry,
+                                       GtkEntryIconPosition icon_pos,
+                                       GdkEvent *event,
+                                       gpointer user_data)
+{
+       gboolean ret;
+
+       GtkFormDecoder *decoder = (GtkFormDecoder *)user_data;
+       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
+       GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS (decoder);
+
+       ret = FALSE;
+       g_signal_emit (G_OBJECT (user_data), klass->btn_clean_clicked_signal_id, 0, 0, &ret);
+
+       if (!ret)
+               {
+                       gtk_form_decoder_set_key (decoder, "0");
+               }
+}
+
+static void
+gtk_form_decoder_on_btn_open_clicked (GtkButton *button,
+                                        gpointer user_data)
+{
+       GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS ((GtkFormDecoder *)user_data);
+
+       g_signal_emit (G_OBJECT (user_data), klass->btn_open_clicked_signal_id, 0);
+}
+
+static void
+gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
+                                        gpointer user_data)
+{
+       GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS ((GtkFormDecoder *)user_data);
+
+       g_signal_emit (G_OBJECT (user_data), klass->btn_browse_clicked_signal_id, 0);
+}
diff --git a/libgtkformui/gtkformdecoder.h b/libgtkformui/gtkformdecoder.h
new file mode 100644 (file)
index 0000000..07a02af
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * GtkFormDecoder widget for GTK+
+ *
+ * Copyright (C) 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_FORM_DECODER_H__
+#define __GTK_FORM_DECODER_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+
+#define GTK_TYPE_FORM_DECODER           (gtk_form_decoder_get_type ())
+#define GTK_FORM_DECODER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FORM_DECODER, GtkFormDecoder))
+#define GTK_FORM_DECODER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FORM_DECODER, GtkFormDecoderClass))
+#define GTK_IS_FORM_DECODER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FORM_DECODER))
+#define GTK_IS_FORM_DECODER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FORM_DECODER))
+#define GTK_FORM_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FORM_DECODER, GtkFormDecoderClass))
+
+
+typedef struct _GtkFormDecoder GtkFormDecoder;
+typedef struct _GtkFormDecoderClass GtkFormDecoderClass;
+
+
+struct _GtkFormDecoder
+{
+       GtkBin parent;
+};
+
+struct _GtkFormDecoderClass
+{
+       GtkBinClass parent_class;
+
+       guint btn_clean_clicked_signal_id;
+       guint btn_open_clicked_signal_id;
+       guint btn_browse_clicked_signal_id;
+};
+
+
+GType gtk_form_decoder_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gtk_form_decoder_new (void);
+
+void gtk_form_decoder_set_key (GtkFormDecoder *decoder, const gchar *key);
+
+gchar *gtk_form_decoder_get_key (GtkFormDecoder *decoder);
+gchar *gtk_form_decoder_get_decoded (GtkFormDecoder *decoder);
+
+void gtk_form_decoder_show_btn_clean (GtkFormDecoder *decoder, gboolean visible);
+void gtk_form_decoder_show_btn_open (GtkFormDecoder *decoder, gboolean visible);
+void gtk_form_decoder_show_btn_browse (GtkFormDecoder *decoder, gboolean visible);
+
+gboolean gtk_form_decoder_btn_clean_is_visible (GtkFormDecoder *decoder);
+gboolean gtk_form_decoder_btn_open_is_visible (GtkFormDecoder *decoder);
+gboolean gtk_form_decoder_btn_browse_is_visible (GtkFormDecoder *decoder);
+
+
+G_END_DECLS
+
+#endif /* __GTK_FORM_DECODER_H__ */
diff --git a/libgtkformui/gtkformwidgetdecoder.c b/libgtkformui/gtkformwidgetdecoder.c
new file mode 100644 (file)
index 0000000..50cf9b3
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+#include <libgtkform/form.h>
+#include <libgtkform/fieldboolean.h>
+
+#include "gtkformdecoder.h"
+#include "gtkformwidgetdecoder.h"
+
+enum
+{
+       PROP_0
+};
+
+static void gtk_form_widget_decoder_class_init (GtkFormWidgetDecoderClass *klass);
+static void gtk_form_widget_decoder_init (GtkFormWidgetDecoder *gtk_form_widget_decoder);
+
+static void gtk_form_widget_decoder_set_property (GObject *object,
+                                      guint property_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec);
+static void gtk_form_widget_decoder_get_property (GObject *object,
+                                      guint property_id,
+                                      GValue *value,
+                                      GParamSpec *pspec);
+
+#define GTK_FORM_WIDGET_DECODER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoderPrivate))
+
+typedef struct _GtkFormWidgetDecoderPrivate GtkFormWidgetDecoderPrivate;
+struct _GtkFormWidgetDecoderPrivate
+       {
+               gpointer foo;
+       };
+
+
+G_DEFINE_TYPE (GtkFormWidgetDecoder, gtk_form_widget_decoder, TYPE_GTK_FORM_WIDGET)
+
+static void
+gtk_form_widget_decoder_class_init (GtkFormWidgetDecoderClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
+
+       object_class->set_property = gtk_form_widget_decoder_set_property;
+       object_class->get_property = gtk_form_widget_decoder_get_property;
+
+       widget_class->get_value_stringify = gtk_form_widget_decoder_get_value_stringify;
+       widget_class->set_value_stringify = gtk_form_widget_decoder_set_value_stringify;
+       widget_class->set_editable = gtk_form_widget_decoder_set_editable;
+
+       g_type_class_add_private (object_class, sizeof (GtkFormWidgetDecoderPrivate));
+}
+
+static void
+gtk_form_widget_decoder_init (GtkFormWidgetDecoder *gtk_form_widget_decoder)
+{
+}
+
+/**
+ * gtk_form_widget_decoder_new:
+ *
+ * Returns: the newly created #GtkFormWidgetDecoder.
+ */
+GtkFormWidget
+*gtk_form_widget_decoder_new ()
+{
+       return g_object_new (gtk_form_widget_decoder_get_type (), NULL);
+}
+
+/**
+ * gtk_form_widget_decoder_xml_parsing:
+ * @widget:
+ * @xml_node:
+ *
+ */
+gboolean
+gtk_form_widget_decoder_xml_parsing (GtkFormWidget *fwidget, xmlNodePtr xml_node)
+{
+       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (fwidget);
+
+       GtkForm *form;
+       GtkWidget *w;
+
+       gchar *connection_name;
+
+       xmlNodePtr child;
+
+       if (xmlStrcmp (xml_node->name, "decoder") != 0)
+               {
+                       return FALSE;
+               }
+
+       w = gtk_form_widget_get_widget (fwidget);
+
+       connection_name = NULL;
+
+       child = xml_node->children;
+       while (child != NULL)
+               {
+                       if (xmlStrcmp (child->name, (const xmlChar *)"sql") == 0)
+                               {
+                                       g_object_set (G_OBJECT (w), "sql", (gchar *)xmlNodeGetContent (child), NULL);
+                               }
+                       else if (xmlStrcmp (child->name, (const xmlChar *)"connection-name") == 0)
+                               {
+                                       connection_name = g_strdup ((gchar *)xmlNodeGetContent (child));
+                               }
+
+                       child = child->next;
+               }
+
+       g_object_get (G_OBJECT (fwidget), "form", &form, NULL);
+       g_object_set (G_OBJECT (w), "gdaex", gtk_form_get_db_connection_by_name (form, connection_name), NULL);
+
+       return TRUE;
+}
+
+/**
+ * gtk_form_widget_decoder_get_value_stringify:
+ * @widget:
+ *
+ */
+gchar
+*gtk_form_widget_decoder_get_value_stringify (GtkFormWidget *fwidget)
+{
+       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (fwidget);
+
+       GtkWidget *w = gtk_form_widget_get_widget (fwidget);
+
+       return g_strdup (gtk_form_decoder_get_key (GTK_FORM_DECODER (w)));
+}
+
+/**
+ * gtk_form_widget_decoder_set_value_stringify:
+ * @fwidget:
+ * @value:
+ *
+ */
+gboolean
+gtk_form_widget_decoder_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
+{
+       gboolean ret = FALSE;
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_form_decoder_set_key (GTK_FORM_DECODER (w), value);
+
+       ret = TRUE;
+
+       return ret;
+}
+
+/**
+ * gtk_form_widget_set_editable:
+ * @fwidget:
+ * @editable:
+ *
+ */
+void
+gtk_form_widget_decoder_set_editable (GtkFormWidget *fwidget, gboolean editable)
+{
+       GtkWidget *w;
+
+       g_object_get (G_OBJECT (fwidget),
+                     "widget", &w,
+                     NULL);
+
+       gtk_widget_set_sensitive (GTK_WIDGET (w), editable);
+}
+
+/* PRIVATE */
+static void
+gtk_form_widget_decoder_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetDecoder *widget_entry = (GtkFormWidgetDecoder *)object;
+       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (widget_entry);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+gtk_form_widget_decoder_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+       GtkFormWidgetDecoder *widget_entry = (GtkFormWidgetDecoder *)object;
+       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (widget_entry);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
diff --git a/libgtkformui/gtkformwidgetdecoder.h b/libgtkformui/gtkformwidgetdecoder.h
new file mode 100644 (file)
index 0000000..20da97f
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __LIBGTK_FORM_WIDGET_DECODER_H__
+#define __LIBGTK_FORM_WIDGET_DECODER_H__
+
+#include <libgtkform/widget.h>
+
+
+G_BEGIN_DECLS
+
+
+#define GTK_FORM_TYPE_WIDGET_DECODER                 (gtk_form_widget_decoder_get_type ())
+#define GTK_FORM_WIDGET_DECODER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoder))
+#define GTK_FORM_WIDGET_DECODER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoderClass))
+#define GTK_FORM_IS_WIDGET_DECODER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_FORM_TYPE_WIDGET_DECODER))
+#define GTK_FORM_IS_WIDGET_DECODER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_FORM_TYPE_WIDGET_DECODER))
+#define GTK_FORM_WIDGET_DECODER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoderClass))
+
+
+typedef struct _GtkFormWidgetDecoder GtkFormWidgetDecoder;
+typedef struct _GtkFormWidgetDecoderClass GtkFormWidgetDecoderClass;
+
+struct _GtkFormWidgetDecoder
+       {
+               GtkFormWidget parent;
+       };
+
+struct _GtkFormWidgetDecoderClass
+       {
+               GtkFormWidgetClass parent_class;
+       };
+
+GType gtk_form_widget_decoder_get_type (void) G_GNUC_CONST;
+
+GtkFormWidget *gtk_form_widget_decoder_new (void);
+
+gboolean gtk_form_widget_decoder_xml_parsing (GtkFormWidget *fwidget, xmlNodePtr xml_node);
+
+gchar *gtk_form_widget_decoder_get_value_stringify (GtkFormWidget *widget);
+
+gboolean gtk_form_widget_decoder_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
+
+void gtk_form_widget_decoder_set_editable (GtkFormWidget *fwidget, gboolean editable);
+
+
+G_END_DECLS
+
+
+#endif /* __LIBGTK_FORM_WIDGET_DECODER_H__ */
diff --git a/libgtkformui/test/Makefile.am b/libgtkformui/test/Makefile.am
new file mode 100644 (file)
index 0000000..40afd35
--- /dev/null
@@ -0,0 +1,17 @@
+LIBS = $(GTKFORM_LIBS) \
+       $(GTKFORMUI_LIBS) \
+       -export-dynamic
+
+AM_CPPFLAGS = $(GTKFORM_CFLAGS) \
+              $(GTKFORMUI_CFLAGS) \
+              -I$(top_srcdir) \
+              -DGUIDIR="\"@abs_builddir@\""
+
+noinst_PROGRAMS = decoder
+
+decoder_SOURCES = decoder.c
+
+LDADD = $(top_builddir)/libgtkform/libgtkform.la \
+        $(top_builddir)/libgtkformui/libgtkformui.la
+
+EXTRA_DIST = database.db
diff --git a/libgtkformui/test/database.db b/libgtkformui/test/database.db
new file mode 100644 (file)
index 0000000..c0668b9
Binary files /dev/null and b/libgtkformui/test/database.db differ
diff --git a/libgtkformui/test/decoder.c b/libgtkformui/test/decoder.c
new file mode 100644 (file)
index 0000000..3d40b4b
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+#include <libgdaex/libgdaex.h>
+
+#include <libgtkformui/gtkformdecoder.h>
+
+GtkWidget *w;
+GtkWidget *decoder;
+
+GdaEx *gdaex;
+
+static gboolean
+on_btn_clean_clicked (gpointer instance, gint arg1, gpointer user_data)
+{
+       return FALSE;
+}
+
+static void
+on_btn_open_clicked (gpointer instance, gpointer user_data)
+{
+       g_debug ("Open clicked.");
+}
+
+static void
+on_btn_browse_clicked (gpointer instance, gpointer user_data)
+{
+       gtk_form_decoder_set_key (GTK_FORM_DECODER (decoder), "1");
+}
+
+gboolean
+on_w_delete_event (GtkWidget *widget,
+                   GdkEvent *event,
+                   gpointer user_data)
+{
+       return FALSE;
+}
+
+int
+main (int argc, char **argv)
+{
+       gtk_init (&argc, &argv);
+
+       gdaex = gdaex_new_from_string ("SQLite://DB_DIR=" GUIDIR ";DB_NAME=database.db");
+       if (gdaex == NULL)
+               {
+                       return 0;
+               }
+
+       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), NULL);
+       g_signal_connect (w, "destroy", gtk_main_quit, NULL);
+
+       decoder = gtk_form_decoder_new ();
+       gtk_container_add (GTK_CONTAINER (w), decoder);
+
+       g_object_set (G_OBJECT (decoder),
+                     "gdaex", gdaex,
+                     "sql", "SELECT name"
+                            " FROM customers"
+                            " WHERE id = ##key0::gint",
+                     "show-btn-clean", TRUE,
+                     "show-btn-open", TRUE,
+                     NULL);
+
+       g_signal_connect (G_OBJECT (decoder), "btn_clean_clicked",
+                         G_CALLBACK (on_btn_clean_clicked), NULL);
+       g_signal_connect (G_OBJECT (decoder), "btn_open_clicked",
+                         G_CALLBACK (on_btn_open_clicked), NULL);
+       g_signal_connect (G_OBJECT (decoder), "btn_browse_clicked",
+                         G_CALLBACK (on_btn_browse_clicked), NULL);
+
+       gtk_widget_show_all (w);
+
+       gtk_main ();
+
+       return 0;
+}
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644 (file)
index ea9eb53..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-LIBS = $(GTKFORM_LIBS)
-
-AM_CPPFLAGS = $(GTKFORM_CFLAGS) \
-              -DLOCALEDIR=\"$(localedir)\" \
-              -DMODULESDIR=\""$(libdir)/$(PACKAGE)/modules"\" \
-              -DG_LOG_DOMAIN=\"GtkForm\"
-
-lib_LTLIBRARIES = libgtkform.la
-
-libgtkform_la_SOURCES = form.c \
-                     key.c \
-                     field.c \
-                     fieldboolean.c \
-                     fielddatetime.c \
-                     fieldfloat.c \
-                     fieldinteger.c \
-                     fieldtext.c \
-                     widget.c \
-                     widgetcheck.c \
-                     widgetcombobox.c \
-                     widgetentry.c \
-                     widgetlabel.c \
-                     widgetradio.c \
-                     widgetspin.c \
-                     widgettextview.c \
-                     group.c
-
-libgtkform_la_LDFLAGS = -no-undefined
-
-libgtkform_include_HEADERS = form.h \
-                  key.h \
-                  field.h \
-                  fieldboolean.h \
-                  fielddatetime.h \
-                  fieldfloat.h \
-                  fieldinteger.h \
-                  fieldtext.h \
-                  widget.h \
-                  widgetcheck.h \
-                  widgetcombobox.h \
-                  widgetentry.h \
-                  widgetlabel.h \
-                  widgetradio.h \
-                  widgetspin.h \
-                  widgettextview.h \
-                  group.h
-
-libgtkform_includedir = $(includedir)/libgtkform
-
-install-exec-hook:
-       mkdir -p "$(libdir)/$(PACKAGE)/modules"
-
-uninstall-hook:
-       rm -rf "$(libdir)/$(PACKAGE)"
diff --git a/src/field.c b/src/field.c
deleted file mode 100644 (file)
index 1b72ca8..0000000
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "widget.h"
-#include "field.h"
-
-enum
-{
-       PROP_0,
-       PROP_FIELD,
-       PROP_LONG_NAME,
-       PROP_TO_LOAD,
-       PROP_TO_SAVE,
-       PROP_OBLIGATORY,
-       PROP_AUTO_INCREMENT,
-       PROP_DATAMODEL,
-       PROP_TRIM,
-       PROP_WIDGET,
-       PROP_MIN_VALUE,
-       PROP_MAX_VALUE
-};
-
-static void gtk_form_field_class_init (GtkFormFieldClass *klass);
-static void gtk_form_field_init (GtkFormField *gtk_form_field);
-
-static void gtk_form_field_set_property (GObject *object,
-                                     guint property_id,
-                                     const GValue *value,
-                                     GParamSpec *pspec);
-static void gtk_form_field_get_property (GObject *object,
-                                     guint property_id,
-                                     GValue *value,
-                                     GParamSpec *pspec);
-
-#define GTK_FORM_FIELD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD, GtkFormFieldPrivate))
-
-typedef struct _GtkFormFieldPrivate GtkFormFieldPrivate;
-struct _GtkFormFieldPrivate
-       {
-               gchar *field;
-               gchar *long_name;
-               gboolean is_key;
-               gboolean to_load;
-               gboolean to_save;
-               gboolean obligatory;
-               gboolean auto_increment;
-               gboolean trim;
-               gchar *min_value;
-               gchar *max_value;
-
-               GdaDataModel *dm;
-
-               GtkFormWidget *widget;
-       };
-
-
-G_DEFINE_TYPE (GtkFormField, gtk_form_field, G_TYPE_OBJECT)
-
-static void
-gtk_form_field_class_init (GtkFormFieldClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-       object_class->set_property = gtk_form_field_set_property;
-       object_class->get_property = gtk_form_field_get_property;
-
-       klass->get_value_stringify = NULL;
-       klass->get_value = NULL;
-       klass->get_value_sql = NULL;
-
-       g_object_class_install_property (object_class, PROP_FIELD,
-                                        g_param_spec_string ("field",
-                                                             "Field's name",
-                                                             "Field's name",
-                                                             "",
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_LONG_NAME,
-                                        g_param_spec_string ("long-name",
-                                                             "Field's long name",
-                                                             "Field's long name",
-                                                             "",
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_TO_LOAD,
-                                        g_param_spec_boolean ("to-load",
-                                                              "Whether load the field or not",
-                                                              "Whether the field should be included or not on sql SELECT",
-                                                              TRUE,
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_TO_SAVE,
-                                        g_param_spec_boolean ("to-save",
-                                                              "Whether save the field or not",
-                                                              "Whether the field should be included or not on sql INSERT INTO and UPDATE",
-                                                              TRUE,
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_OBLIGATORY,
-                                        g_param_spec_boolean ("obligatory",
-                                                              "Obligatory",
-                                                              "Whether the field could be empty",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_AUTO_INCREMENT,
-                                        g_param_spec_boolean ("auto-increment",
-                                                              "Auto increment",
-                                                              "Whether the field auto increments (works only on  numeric fields)",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_TRIM,
-                                        g_param_spec_boolean ("trim",
-                                                              "Trim stringify value",
-                                                              "Whether to trim the field's stringify value",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_WIDGET,
-                                        g_param_spec_object ("form-widget",
-                                                             "GtkFormWidget",
-                                                             "The GtkFormWidget",
-                                                             TYPE_GTK_FORM_WIDGET,
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_MIN_VALUE,
-                                        g_param_spec_string ("min-value",
-                                                             "Minimun value",
-                                                             "The minimun value allowed for this field.",
-                                                             "",
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_MAX_VALUE,
-                                        g_param_spec_string ("max-value",
-                                                             "Maximun value",
-                                                             "The macimun value allowed for this field.",
-                                                             "",
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormFieldPrivate));
-}
-
-static void
-gtk_form_field_init (GtkFormField *gtk_form_field)
-{
-}
-
-/**
- * gtk_form_field_new:
- *
- * Returns: the newly created #GtkFormField.
- */
-GtkFormField
-*gtk_form_field_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_FIELD, NULL);
-}
-
-/**
- * gtk_form_field_new_from_gtk_form_widget:
- * @fwidget: a #GtkFormWidget object.
- *
- * Returns: the newly created #GtkFormField.
- */
-GtkFormField
-*gtk_form_field_new_from_gtk_form_widget (GtkFormWidget *fwidget)
-{
-       GtkFormField *f = gtk_form_field_new ();
-
-       g_object_set (G_OBJECT (f),
-                     "form-widget", fwidget,
-                     NULL);
-
-       return f;
-}
-
-/**
- * gtk_form_field_get_field_name:
- * @field: a #GtkFormField object.
- *
- * Returns: the field's name.
- */
-gchar
-*gtk_form_field_get_field_name (GtkFormField *field)
-{
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       return g_strdup (priv->field);
-}
-
-/**
- * gtk_form_field_get_field_long_name:
- * @field: a #GtkFormField object.
- *
- * Returns: the field's long name.
- */
-gchar
-*gtk_form_field_get_field_long_name (GtkFormField *field)
-{
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       return g_strdup (priv->long_name);
-}
-
-/**
- * gtk_form_field_get_form_widget:
- * @field: a #GtkFormField object.
- *
- * Return: the associated #GtkFormWidget.
- */
-GtkFormWidget
-*gtk_form_field_get_form_widget (GtkFormField *field)
-{
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       return (GtkFormWidget *)priv->widget;
-}
-
-/**
- * gtk_form_field_get_value_stringify:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_get_value_stringify (GtkFormField *field)
-{
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       gchar *ret;
-
-       ret = g_strdup ("");
-
-       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);
-                       if (priv->trim)
-                               {
-                                       ret = g_strstrip (ret);
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_get_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_get_value (GtkFormField *field)
-{
-       GValue *ret;
-
-       ret = NULL;
-
-       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);
-                       if (G_VALUE_HOLDS_STRING (ret))
-                               {
-                                       g_value_set_string (ret, g_strstrip (g_strdup (g_value_get_string (ret))));
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_get_value_sql:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_get_value_sql (GtkFormField *field)
-{
-       gchar *ret;
-
-       ret = g_strdup ("");
-
-       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_get_origin_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_get_original_value (GtkFormField *field)
-{
-       GValue *ret;
-
-       ret = NULL;
-
-       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->get_original_value != NULL)
-               {
-                       ret = GTK_FORM_FIELD_GET_CLASS (field)->get_original_value (field);
-                       if (G_VALUE_HOLDS_STRING (ret))
-                               {
-                                       g_value_set_string (ret, g_strstrip (g_strdup (g_value_get_string (ret))));
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_clear:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_clear (GtkFormField *field)
-{
-       gboolean ret;
-
-       ret = FALSE;
-
-       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_to_load:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_is_to_load (GtkFormField *field)
-{
-       GtkFormFieldPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       return priv->to_load;
-}
-
-/**
- * gtk_form_field_is_to_save:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_is_to_save (GtkFormField *field)
-{
-       GtkFormFieldPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       return priv->to_save;
-}
-
-/**
- * gtk_form_field_is_auto_increment:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_is_auto_increment (GtkFormField *field)
-{
-       GtkFormFieldPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       return priv->auto_increment;
-}
-
-/**
- * gtk_form_field_is_empty:
- * @field: a #GtkFormField object.
- *
- * Returns: TRUE if the field is empty.
- */
-gboolean
-gtk_form_field_is_empty (GtkFormField *field)
-{
-       gboolean ret = TRUE;
-
-       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_valid:
- * @field: a #GtkFormField object.
- *
- * Returns: TRUE if the field is valid.
- */
-gboolean
-gtk_form_field_is_valid (GtkFormField *field)
-{
-       gboolean ret = TRUE;
-
-       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->is_valid != NULL)
-               {
-                       ret = GTK_FORM_FIELD_GET_CLASS (field)->is_valid (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(), gtk_form_field_set_from_datamodel() or
- * gtk_form_field_set_as_origin().
- */
-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_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.
- * @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);
-
-       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)
-               {
-                       ret = GTK_FORM_FIELD_GET_CLASS (field)->set_from_datamodel (field, dm, row);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_set_from_hashtable:
- * @field: a #GtkFormField object.
- * @hashtable: a #GHashTable object.
- *
- */
-gboolean
-gtk_form_field_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
-{
-       gboolean ret = FALSE;
-
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->set_from_hashtable != NULL)
-               {
-                       ret = GTK_FORM_FIELD_GET_CLASS (field)->set_from_hashtable (field, hashtable);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_set_value:
- * @field: a #GtkFormField object.
- * @gvalue: a #GValue.
- *
- */
-gboolean
-gtk_form_field_set_value (GtkFormField *field, GValue *gvalue)
-{
-       gboolean ret = FALSE;
-
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->set_value != NULL)
-               {
-                       ret = GTK_FORM_FIELD_GET_CLASS (field)->set_value (field, gvalue);
-               }
-
-       return ret;
-}
-
-/* PRIVATE */
-static void
-gtk_form_field_set_property (GObject *object,
-                         guint property_id,
-                         const GValue *value,
-                         GParamSpec *pspec)
-{
-       GtkFormField *field = (GtkFormField *)object;
-
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_FIELD:
-                               priv->field = g_strstrip (g_value_dup_string (value));
-                               break;
-
-                       case PROP_LONG_NAME:
-                               priv->long_name = g_strstrip (g_value_dup_string (value));
-                               break;
-
-                       case PROP_TO_LOAD:
-                               priv->to_load = g_value_get_boolean (value);
-                               break;
-
-                       case PROP_TO_SAVE:
-                               priv->to_save = g_value_get_boolean (value);
-                               break;
-
-                       case PROP_OBLIGATORY:
-                               priv->obligatory = g_value_get_boolean (value);
-                               break;
-
-                       case PROP_AUTO_INCREMENT:
-                               priv->auto_increment = g_value_get_boolean (value);
-                               break;
-
-                       case PROP_DATAMODEL:
-                               priv->dm = g_value_get_pointer (value);
-                               break;
-
-                       case PROP_TRIM:
-                               priv->trim = g_value_get_boolean (value);
-                               break;
-
-                       case PROP_WIDGET:
-                               priv->widget = g_value_get_object (value);
-                               g_object_set (G_OBJECT (priv->widget), "field", field, NULL);
-                               break;
-
-                       case PROP_MIN_VALUE:
-                               priv->min_value = g_strstrip (g_value_dup_string (value));
-                               break;
-
-                       case PROP_MAX_VALUE:
-                               priv->max_value = g_strstrip (g_value_dup_string (value));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-gtk_form_field_get_property (GObject *object,
-                         guint property_id,
-                         GValue *value,
-                         GParamSpec *pspec)
-{
-       GtkFormField *field = (GtkFormField *)object;
-
-       GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_FIELD:
-                               g_value_set_string (value, gtk_form_field_get_field_name (field));
-                               break;
-
-                       case PROP_LONG_NAME:
-                               g_value_set_string (value, gtk_form_field_get_field_long_name (field));
-                               break;
-
-                       case PROP_TO_LOAD:
-                               g_value_set_boolean (value, priv->to_load);
-                               break;
-
-                       case PROP_TO_SAVE:
-                               g_value_set_boolean (value, priv->to_save);
-                               break;
-
-                       case PROP_OBLIGATORY:
-                               g_value_set_boolean (value, priv->obligatory);
-                               break;
-
-                       case PROP_AUTO_INCREMENT:
-                               g_value_set_boolean (value, priv->auto_increment);
-                               break;
-
-                       case PROP_DATAMODEL:
-                               g_value_set_pointer (value, priv->dm);
-                               break;
-
-                       case PROP_TRIM:
-                               g_value_set_boolean (value, priv->trim);
-                               break;
-
-                       case PROP_WIDGET:
-                               g_value_set_object (value, priv->widget);
-                               break;
-
-                       case PROP_MIN_VALUE:
-                               g_value_set_string (value, g_strdup (priv->min_value));
-                               break;
-
-                       case PROP_MAX_VALUE:
-                               g_value_set_string (value, g_strdup (priv->max_value));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
diff --git a/src/field.h b/src/field.h
deleted file mode 100644 (file)
index 1e6f68d..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_FIELD_H__
-#define __LIBGTK_FORM_FIELD_H__
-
-#include <glib.h>
-
-#include <libgdaex/libgdaex.h>
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_FIELD                 (gtk_form_field_get_type ())
-#define GTK_FORM_FIELD(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD, GtkFormField))
-#define GTK_FORM_FIELD_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD, GtkFormFieldClass))
-#define IS_GTK_FORM_FIELD(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD))
-#define IS_GTK_FORM_FIELD_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD))
-#define GTK_FORM_FIELD_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD, GtkFormFieldClass))
-
-
-typedef struct _GtkFormField GtkFormField;
-typedef struct _GtkFormFieldClass GtkFormFieldClass;
-
-struct _GtkFormField
-       {
-               GObject parent;
-       };
-
-struct _GtkFormFieldClass
-       {
-               GObjectClass parent_class;
-
-               gchar *(*get_value_stringify) (GtkFormField *field);
-               GValue *(*get_value) (GtkFormField *field);
-               gchar *(*get_value_sql) (GtkFormField *field);
-               GValue *(*get_original_value) (GtkFormField *field);
-
-               gboolean (*clear) (GtkFormField *field);
-               gboolean (*is_empty) (GtkFormField *field);
-               gboolean (*is_changed) (GtkFormField *field);
-               gboolean (*is_valid) (GtkFormField *field);
-               void (*set_as_origin) (GtkFormField *field);
-               gboolean (*set_from_datamodel) (GtkFormField *field, GdaDataModel *dm, gint row);
-               gboolean (*set_from_hashtable) (GtkFormField *field, GHashTable *hashtable);
-               gboolean (*set_value) (GtkFormField *field, GValue *gvalue);
-       };
-
-GType gtk_form_field_get_type (void) G_GNUC_CONST;
-
-GtkFormField *gtk_form_field_new (void);
-GtkFormField *gtk_form_field_new_from_gtk_form_widget (GtkFormWidget *fwidget);
-
-gchar *gtk_form_field_get_field_name (GtkFormField *field);
-gchar *gtk_form_field_get_field_long_name (GtkFormField *field);
-
-GtkFormWidget *gtk_form_field_get_form_widget (GtkFormField *field);
-
-gchar *gtk_form_field_get_value_stringify (GtkFormField *field);
-GValue *gtk_form_field_get_value (GtkFormField *field);
-gchar *gtk_form_field_get_value_sql (GtkFormField *field);
-GValue *gtk_form_field_get_original_value (GtkFormField *field);
-
-gboolean gtk_form_field_clear (GtkFormField *field);
-
-gboolean gtk_form_field_is_to_load (GtkFormField *field);
-gboolean gtk_form_field_is_to_save (GtkFormField *field);
-
-gboolean gtk_form_field_is_auto_increment (GtkFormField *field);
-
-gboolean gtk_form_field_is_empty (GtkFormField *field);
-
-gboolean gtk_form_field_is_valid (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);
-gboolean gtk_form_field_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
-gboolean gtk_form_field_set_value (GtkFormField *field, GValue *gvalue);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_FIELD_H__ */
diff --git a/src/fieldboolean.c b/src/fieldboolean.c
deleted file mode 100644 (file)
index d38d706..0000000
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-
-#include "widget.h"
-#include "fieldboolean.h"
-
-enum
-{
-       PROP_0,
-       PROP_DEFAULT
-};
-
-static void gtk_form_field_boolean_class_init (GtkFormFieldBooleanClass *klass);
-static void gtk_form_field_boolean_init (GtkFormFieldBoolean *gtk_form_field);
-
-static void gtk_form_field_boolean_set_property (GObject *object,
-                                             guint property_id,
-                                             const GValue *value,
-                                             GParamSpec *pspec);
-static void gtk_form_field_boolean_get_property (GObject *object,
-                                             guint property_id,
-                                             GValue *value,
-                                             GParamSpec *pspec);
-
-static gboolean gtk_form_field_boolean_set_value_stringify (GtkFormField *field, const gchar *value);
-
-#define GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBooleanPrivate))
-
-typedef struct _GtkFormFieldBooleanPrivate GtkFormFieldBooleanPrivate;
-struct _GtkFormFieldBooleanPrivate
-       {
-               gboolean default_value;
-               gboolean original_value;
-       };
-
-
-G_DEFINE_TYPE (GtkFormFieldBoolean, gtk_form_field_boolean, TYPE_GTK_FORM_FIELD)
-
-static void
-gtk_form_field_boolean_class_init (GtkFormFieldBooleanClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
-
-       object_class->set_property = gtk_form_field_boolean_set_property;
-       object_class->get_property = gtk_form_field_boolean_get_property;
-
-       field_class->get_value_stringify = gtk_form_field_boolean_get_value_stringify;
-       field_class->get_value = gtk_form_field_boolean_get_value;
-       field_class->get_value_sql = gtk_form_field_boolean_get_value_sql;
-       field_class->get_original_value = gtk_form_field_boolean_get_original_value;
-       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;
-       field_class->set_from_hashtable = gtk_form_field_boolean_set_from_hashtable;
-       field_class->set_value = gtk_form_field_boolean_set_value;
-
-       g_object_class_install_property (object_class, PROP_DEFAULT,
-                                        g_param_spec_boolean ("default",
-                                                              "Default",
-                                                              "Default value",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormFieldBooleanPrivate));
-}
-
-static void
-gtk_form_field_boolean_init (GtkFormFieldBoolean *gtk_form_field)
-{
-}
-
-/**
- * gtk_form_field_boolean_new:
- *
- * Returns: the newly created #GtkFormFieldBoolean.
- */
-GtkFormField
-*gtk_form_field_boolean_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_FIELD_BOOLEAN, NULL);
-}
-
-/**
- * gtk_form_field_boolean_get_value_stringify:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_boolean_get_value_stringify (GtkFormField *field)
-{
-       gchar *ret;
-       GtkFormWidget *fw;
-
-       ret = g_strdup ("");
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), ret);
-               
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       if (IS_GTK_FORM_WIDGET (fw))
-               {
-                       ret = gtk_form_widget_get_value_stringify (fw);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_get_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_boolean_get_value (GtkFormField *field)
-{
-       GValue *ret;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), NULL);
-
-       ret = NULL;
-
-       value = gtk_form_field_boolean_get_value_stringify (field);
-
-       if (value != NULL)
-               {
-                       ret = g_malloc0 (sizeof (GValue));
-                       g_value_init (ret, G_TYPE_BOOLEAN);
-                       g_value_set_boolean (ret, gtk_form_field_boolean_str_to_boolean (value));
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_get_value_sql:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_boolean_get_value_sql (GtkFormField *field)
-{
-       gchar *ret;
-       gchar *value;
-
-       ret = g_strdup ("");
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), ret);
-
-       value = gtk_form_field_boolean_get_value_stringify (field);
-
-       if (value != NULL)
-               {
-                       gboolean bool_value;
-
-                       bool_value = gtk_form_field_boolean_str_to_boolean (value);
-
-                       ret = g_strconcat ("'", (bool_value ? "1" : "0"), "'", NULL);
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_get_original_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_boolean_get_original_value (GtkFormField *field)
-{
-       GValue *ret;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), NULL);
-
-       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
-
-       ret = NULL;
-
-       ret = g_malloc0 (sizeof (GValue));
-       g_value_init (ret, G_TYPE_BOOLEAN);
-       g_value_set_boolean (ret, priv->original_value
-       );
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_clear:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_boolean_clear (GtkFormField *field)
-{
-       gboolean ret = FALSE;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
-
-       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
-
-       ret = gtk_form_field_boolean_set_value_stringify (field, g_strdup_printf ("%d", priv->default_value));
-
-       priv->original_value = priv->default_value;
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_is_empty:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_boolean_is_empty (GtkFormField *field)
-{
-       gboolean ret;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), TRUE);
-
-       ret = FALSE;
-
-       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;
-       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));
-
-       g_free (value);
-
-       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;
-       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);
-
-       g_free (value);
-}
-
-/**
- * gtk_form_field_boolean_set_from_datamodel:
- * @field: a #GtkFormField object.
- * @dm: a #GdaDataModel object.
- * @row:
- *
- */
-gboolean
-gtk_form_field_boolean_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldBooleanPrivate *priv;
-       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 (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
-               {
-                       priv->original_value = gdaex_data_model_get_field_value_boolean_at (dm, row, field_name);
-                       if (priv->original_value)
-                               {
-                                       value = g_strdup_printf ("TRUE");
-                               }
-                       else
-                               {
-                                       value = g_strdup_printf ("FALSE");
-                               }
-                       ret = gtk_form_field_boolean_set_value_stringify (field, value);
-               }
-       else
-               {
-                       g_warning (_("GtkFormField hasn't a field name."));
-               }
-
-       g_free (field_name);
-       g_free (value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_set_from_hashtable:
- * @field: a #GtkFormField object.
- * @hashtable: a #GHashTable object.
- *
- */
-gboolean
-gtk_form_field_boolean_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldBooleanPrivate *priv;
-       gchar *field_name;
-       GValue *gval;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (GTK_FORM_FIELD_BOOLEAN (field));
-
-       field_name = gtk_form_field_get_field_name (field);
-       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
-               {
-                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
-                       if (gval == NULL)
-                               {
-                                       priv->original_value = FALSE;
-                                       ret = gtk_form_field_boolean_set_value_stringify (field, "FALSE");
-                               }
-                       else
-                               {
-                                       priv->original_value = g_value_get_boolean (gval);
-                                       if (priv->original_value)
-                                               {
-                                                       value = g_strdup_printf ("TRUE");
-                                               }
-                                       else
-                                               {
-                                                       value = g_strdup_printf ("FALSE");
-                                               }
-                                       ret = gtk_form_field_boolean_set_value_stringify (field, value);
-                               }
-               }
-       else
-               {
-                       g_warning (_("GtkFormField hasn't a field name."));
-               }
-
-       g_free (field_name);
-       g_free (value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_set_value:
- * @field: a #GtkFormField object.
- * @gvalue: a #GValue.
- *
- */
-gboolean
-gtk_form_field_boolean_set_value (GtkFormField *field, GValue *gvalue)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldBooleanPrivate *priv;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
-       g_return_val_if_fail (G_VALUE_HOLDS_BOOLEAN (gvalue), FALSE);
-
-       priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (GTK_FORM_FIELD_BOOLEAN (field));
-
-       priv->original_value = g_value_get_boolean (gvalue);
-       if (priv->original_value)
-               {
-                       value = g_strdup_printf ("TRUE");
-               }
-       else
-               {
-                       value = g_strdup_printf ("FALSE");
-               }
-       ret = gtk_form_field_boolean_set_value_stringify (field, value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_boolean_str_to_boolean:
- * @value:
- *
- * Utility function to convert a string to its #gboolean equivalent.
- *
- * Returns: the #gboolean equivalent from @value.
- */
-gboolean
-gtk_form_field_boolean_str_to_boolean (const gchar *value)
-{
-       gchar *str_value;
-       gboolean bool_value = FALSE;
-
-       if (value == NULL)
-               {
-                       return bool_value;
-               }
-
-       str_value = g_strstrip (g_strdup (value));
-
-       if (strcmp (str_value, "0") == 0
-                       || strcasecmp (str_value, "f") == 0
-                       || strcasecmp (str_value, "false") == 0
-                       || strcasecmp (str_value, "n") == 0
-                       || strcasecmp (str_value, "no") == 0)
-               {
-                       bool_value = FALSE;
-               }
-       else if (strcmp (str_value, "1") == 0
-                       || strcasecmp (str_value, "t") == 0
-                       || strcasecmp (str_value, "true") == 0
-                       || strcasecmp (str_value, "y") == 0
-                       || strcasecmp (str_value, "yes") == 0)
-               {
-                       bool_value = TRUE;
-               }
-
-       g_free (str_value);
-
-       return bool_value;
-}
-
-/* PRIVATE */
-static void
-gtk_form_field_boolean_set_property (GObject *object,
-                                 guint property_id,
-                                 const GValue *value,
-                                 GParamSpec *pspec)
-{
-       GtkFormFieldBoolean *field = (GtkFormFieldBoolean *)object;
-
-       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               priv->default_value = g_value_get_boolean (value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_field_boolean_get_property (GObject *object,
-                                 guint property_id,
-                                 GValue *value,
-                                 GParamSpec *pspec)
-{
-       GtkFormFieldBoolean *field = (GtkFormFieldBoolean *)object;
-
-       GtkFormFieldBooleanPrivate *priv = GTK_FORM_FIELD_BOOLEAN_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               g_value_set_boolean (value, priv->default_value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static gboolean
-gtk_form_field_boolean_set_value_stringify (GtkFormField *field, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkFormWidget *fw;
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       ret = gtk_form_widget_set_value_stringify (fw, value);
-
-       return ret;
-}
diff --git a/src/fieldboolean.h b/src/fieldboolean.h
deleted file mode 100644 (file)
index 84ca860..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_FIELD_BOOLEAN_H__
-#define __LIBGTK_FORM_FIELD_BOOLEAN_H__
-
-#include "field.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_FIELD_BOOLEAN                 (gtk_form_field_boolean_get_type ())
-#define GTK_FORM_FIELD_BOOLEAN(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBoolean))
-#define GTK_FORM_FIELD_BOOLEAN_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBooleanClass))
-#define IS_GTK_FORM_FIELD_BOOLEAN(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN))
-#define IS_GTK_FORM_FIELD_BOOLEAN_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_BOOLEAN))
-#define GTK_FORM_FIELD_BOOLEAN_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_BOOLEAN, GtkFormFieldBooleanClass))
-
-
-typedef struct _GtkFormFieldBoolean GtkFormFieldBoolean;
-typedef struct _GtkFormFieldBooleanClass GtkFormFieldBooleanClass;
-
-struct _GtkFormFieldBoolean
-       {
-               GtkFormField parent;
-       };
-
-struct _GtkFormFieldBooleanClass
-       {
-               GtkFormFieldClass parent_class;
-       };
-
-GType gtk_form_field_boolean_get_type (void) G_GNUC_CONST;
-
-GtkFormField *gtk_form_field_boolean_new (void);
-
-gchar *gtk_form_field_boolean_get_value_stringify (GtkFormField *field);
-GValue *gtk_form_field_boolean_get_value (GtkFormField *field);
-gchar *gtk_form_field_boolean_get_value_sql (GtkFormField *field);
-GValue *gtk_form_field_boolean_get_original_value (GtkFormField *field);
-
-gboolean gtk_form_field_boolean_clear (GtkFormField *field);
-
-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);
-gboolean gtk_form_field_boolean_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
-gboolean gtk_form_field_boolean_set_value (GtkFormField *field, GValue *gvalue);
-
-gboolean gtk_form_field_boolean_str_to_boolean (const gchar *value);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_FIELD_BOOLEAN_H__ */
diff --git a/src/fielddatetime.c b/src/fielddatetime.c
deleted file mode 100644 (file)
index 9c75802..0000000
+++ /dev/null
@@ -1,1050 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include <glib/gi18n-lib.h>
-
-#include "widget.h"
-#include "fielddatetime.h"
-
-enum
-{
-       PROP_0,
-       PROP_DEFAULT,
-       PROP_TYPE,
-       PROP_DISPLAY_FORMAT
-};
-
-static void gtk_form_field_datetime_class_init (GtkFormFieldDateTimeClass *klass);
-static void gtk_form_field_datetime_init (GtkFormFieldDateTime *gtk_form_field);
-
-static void gtk_form_field_datetime_set_property (GObject *object,
-                                              guint property_id,
-                                              const GValue *value,
-                                              GParamSpec *pspec);
-static void gtk_form_field_datetime_get_property (GObject *object,
-                                              guint property_id,
-                                              GValue *value,
-                                              GParamSpec *pspec);
-
-static gboolean gtk_form_field_datetime_set_value_stringify (GtkFormField *field, const gchar *value);
-
-static gchar *gtk_form_field_datetime_get_str_format (GtkFormFieldDateTime *field);
-
-static gchar *gtk_form_field_datetime_str_replace (const gchar *string,
-                                      const gchar *origin,
-                                      const gchar *replace);
-
-static gboolean gtk_form_field_datetime_is_valid_datetime (GtkFormFieldDateTime *field);
-
-#define GTK_FORM_FIELD_DATETIME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTimePrivate))
-
-typedef struct _GtkFormFieldDateTimePrivate GtkFormFieldDateTimePrivate;
-struct _GtkFormFieldDateTimePrivate
-       {
-               struct tm *default_value;
-               struct tm *original_value;
-
-               gint type;
-
-               gchar *display_format;
-       };
-
-
-G_DEFINE_TYPE (GtkFormFieldDateTime, gtk_form_field_datetime, TYPE_GTK_FORM_FIELD)
-
-static void
-gtk_form_field_datetime_class_init (GtkFormFieldDateTimeClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
-
-       object_class->set_property = gtk_form_field_datetime_set_property;
-       object_class->get_property = gtk_form_field_datetime_get_property;
-
-       field_class->get_value_stringify = gtk_form_field_datetime_get_value_stringify;
-       field_class->get_value = gtk_form_field_datetime_get_value;
-       field_class->get_value_sql = gtk_form_field_datetime_get_value_sql;
-       field_class->get_original_value = gtk_form_field_datetime_get_original_value;
-       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->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;
-
-       g_object_class_install_property (object_class, PROP_DEFAULT,
-                                        g_param_spec_pointer ("default",
-                                                              "Default",
-                                                              "Default value",
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_TYPE,
-                                        g_param_spec_int ("type",
-                                                          "Type",
-                                                          "Type",
-                                                          G_MININT,
-                                                          G_MAXINT,
-                                                          GTK_FORM_FIELD_DATETIME_TYPE_DATETIME,
-                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_DISPLAY_FORMAT,
-                                        g_param_spec_string ("display-format",
-                                                             "Display format",
-                                                             "Display format",
-                                                             "%Y-%m-%d %H:%M:%S",
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormFieldDateTimePrivate));
-}
-
-static void
-gtk_form_field_datetime_init (GtkFormFieldDateTime *gtk_form_field)
-{
-       GtkFormFieldDateTimePrivate *priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (gtk_form_field);
-
-       priv->default_value = NULL;
-       priv->original_value = NULL;
-}
-
-/**
- * gtk_form_field_datetime_new:
- *
- * Returns: the newly created #GtkFormFieldDateTime.
- */
-GtkFormField
-*gtk_form_field_datetime_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_FIELD_DATETIME, NULL);
-}
-
-/**
- * gtk_form_field_datetime_get_value_stringify:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_datetime_get_value_stringify (GtkFormField *field)
-{
-       gchar *ret;
-       GtkFormWidget *fw;
-
-       ret = g_strdup ("");
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), ret);
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       if (IS_GTK_FORM_WIDGET (fw))
-               {
-                       ret = gtk_form_widget_get_value_stringify (fw);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_value:
- * @field: a #GtkFormField object.
- *
- * Returns: a #GValue of type G_TYPE_POINTER that point to a struct tm.
- */
-GValue
-*gtk_form_field_datetime_get_value (GtkFormField *field)
-{
-       struct tm *datetime;
-       GValue *ret;
-       gchar *value;
-       GtkFormFieldDateTimePrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), NULL);
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
-
-       ret = NULL;
-
-       value = gtk_form_field_datetime_get_value_stringify (field);
-
-       datetime = gtk_form_field_datetime_get_tm_from_str (value, priv->display_format);
-       if (value != NULL && datetime != NULL)
-               {
-                       ret = g_malloc0 (sizeof (GValue));
-                       g_value_init (ret, G_TYPE_POINTER);
-                       g_value_set_pointer (ret, datetime);
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_value_sql:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_datetime_get_value_sql (GtkFormField *field)
-{
-       gchar *ret;
-       gchar *value;
-       gchar *format;
-       GtkFormFieldDateTimePrivate *priv;
-
-       ret = g_strdup ("NULL");
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), ret);
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
-
-       value = gtk_form_field_datetime_get_value_stringify (field);
-       format = gtk_form_field_datetime_get_str_format (GTK_FORM_FIELD_DATETIME (field));
-
-       if (value != NULL && format != NULL)
-               {
-                       struct tm *datetime;
-
-                       datetime = gtk_form_field_datetime_get_tm_from_str (value, priv->display_format);
-                       if (datetime != NULL)
-                               {
-                                       gchar *dvalue;
-
-                                       dvalue = gtk_form_field_datetime_get_str_from_tm (datetime, format);
-                                       if (dvalue != NULL)
-                                               {
-                                                       ret = g_strconcat ("'", dvalue, "'", NULL);
-
-                                                       g_free (dvalue);
-                                               }
-                               }
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_original_value:
- * @field: a #GtkFormField object.
- *
- * Returns: a #GValue of type G_TYPE_POINTER that point to a struct tm.
- */
-GValue
-*gtk_form_field_datetime_get_original_value (GtkFormField *field)
-{
-       GValue *ret;
-       GtkFormFieldDateTimePrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), NULL);
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
-
-       ret = NULL;
-
-       ret = g_malloc0 (sizeof (GValue));
-       g_value_init (ret, G_TYPE_POINTER);
-       g_value_set_pointer (ret, g_memdup (priv->original_value, sizeof (struct tm)));
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_clear:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_datetime_clear (GtkFormField *field)
-{
-       gboolean ret;
-       GtkFormFieldDateTimePrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
-       ret = FALSE;
-
-       if (priv->default_value != NULL)
-               {
-                       gchar *value;
-
-                       value = gtk_form_field_datetime_get_str_from_tm (priv->default_value, priv->display_format);
-                       if (value != NULL)
-                               {
-                                       ret = gtk_form_field_datetime_set_value_stringify (field, value);
-
-                                       g_free (value);
-                               }
-               }
-       else
-               {
-                       ret = gtk_form_field_datetime_set_value_stringify (field, "");
-               }
-
-       priv->original_value = g_memdup (priv->default_value, sizeof (struct tm));
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_is_empty:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_datetime_is_empty (GtkFormField *field)
-{
-       gboolean ret;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), TRUE);
-
-       return !gtk_form_field_datetime_is_valid_datetime (GTK_FORM_FIELD_DATETIME (field));
-}
-
-/**
- * gtk_form_field_datetime_is_changed:
- * @field: a #GtkFormField object.
- *
- */
-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),
-                                                        priv->display_format);
-
-       if (value != NULL && priv->original_value != NULL)
-               {
-                       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);
-                       if (!ret && priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATETIME)
-                               {
-                                       ret = (value->tm_hour != priv->original_value->tm_hour
-                                              || value->tm_min != priv->original_value->tm_min
-                                              || value->tm_sec != priv->original_value->tm_sec);
-                               }
-               }
-       else if ((value == NULL || priv->original_value == NULL)
-                && !(value == NULL && priv->original_value == NULL))
-               {
-                       ret = TRUE;
-               }
-
-       g_free (value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_is_valid:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_datetime_is_valid (GtkFormField *field)
-{
-       gboolean ret;
-
-       GtkFormFieldDateTimePrivate *priv;
-
-       struct tm *tm_value;
-
-       gchar *min_value;
-       struct tm *tm_min_value;
-       gchar *max_value;
-       struct tm *tm_max_value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
-
-       ret = TRUE;
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
-
-       tm_value = gtk_form_field_datetime_get_tm_from_str (gtk_form_field_datetime_get_value_stringify (field), priv->display_format);
-
-       if (tm_value != 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)
-                               {
-                                       if (g_strcasecmp (min_value, "now") == 0)
-                                               {
-                                                       time_t tt;
-                                                       tt = time (NULL);
-
-                                                       tm_min_value = g_memdup (localtime (&tt), sizeof (struct tm));
-
-                                                       if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
-                                                               {
-                                                                       tm_min_value->tm_hour = 0;
-                                                                       tm_min_value->tm_min = 0;
-                                                                       tm_min_value->tm_sec = 0;
-                                                               }
-                                                       else if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_TIME)
-                                                               {
-                                                                       tm_min_value->tm_year = 0;
-                                                                       tm_min_value->tm_mon = 0;
-                                                                       tm_min_value->tm_mday = 0;
-                                                               }
-                                               }
-                                       else
-                                               {
-                                                       tm_min_value = gtk_form_field_datetime_get_tm_from_str (min_value,
-                                                              gtk_form_field_datetime_get_str_format (GTK_FORM_FIELD_DATETIME (field)));
-                                               }
-
-                                       if (tm_min_value != NULL)
-                                               {
-                                                       time_t tt_min_value;
-                                                       time_t tt_value;
-
-                                                       tt_min_value = mktime (tm_min_value);
-                                                       tt_value = mktime (tm_value);
-
-                                                       ret = (difftime (tt_min_value, tt_value) <= 0);
-
-                                                       g_free (tm_min_value);
-                                               }
-                               }
-
-                       if (ret
-                           && max_value != NULL
-                           && g_strcmp0 (max_value, "") != 0)
-                               {
-                                       if (g_strcasecmp (max_value, "now") == 0)
-                                               {
-                                                       time_t tt;
-                                                       tt = time (NULL);
-
-                                                       tm_max_value = g_memdup (localtime (&tt), sizeof (struct tm));
-
-                                                       if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
-                                                               {
-                                                                       tm_max_value->tm_hour = 0;
-                                                                       tm_max_value->tm_min = 0;
-                                                                       tm_max_value->tm_sec = 0;
-                                                               }
-                                                       else if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_TIME)
-                                                               {
-                                                                       tm_max_value->tm_year = 0;
-                                                                       tm_max_value->tm_mon = 0;
-                                                                       tm_max_value->tm_mday = 0;
-                                                               }
-                                               }
-                                       else
-                                               {
-                                                       tm_max_value = gtk_form_field_datetime_get_tm_from_str (max_value,
-                                                              gtk_form_field_datetime_get_str_format (GTK_FORM_FIELD_DATETIME (field)));
-                                               }
-
-                                       if (tm_max_value != NULL)
-                                               {
-                                                       time_t tt_max_value;
-                                                       time_t tt_value;
-
-                                                       tt_max_value = mktime (tm_max_value);
-                                                       tt_value = mktime (tm_value);
-
-                                                       ret = (difftime (tt_max_value, tt_value) >= 0);
-
-                                                       g_free (tm_max_value);
-                                               }
-                               }
-
-                       g_free (tm_value);
-               }
-
-       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->display_format);
-
-       priv->original_value = g_memdup (value, sizeof (struct tm));
-
-       if (priv->original_value != NULL && priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
-               {
-                       priv->original_value->tm_hour = 0;
-                       priv->original_value->tm_min = 0;
-                       priv->original_value->tm_sec = 0;
-               }
-
-       g_free (value);
-}
-
-/**
- * gtk_form_field_datetime_set_from_datamodel:
- * @field: a #GtkFormField object.
- * @dm: a #GdaDataModel object.
- * @row:
- *
- */
-gboolean
-gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
-{
-       gboolean ret;
-       GtkFormFieldDateTimePrivate *priv;
-       gchar *field_name;
-       struct tm *datetime;
-       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);
-
-       ret = FALSE;
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
-
-       field_name = (gchar *)gtk_form_field_get_field_name (field);
-
-       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
-               {
-                       datetime = gdaex_data_model_get_field_value_tm_at (dm, row, field_name);
-
-                       value = gtk_form_field_datetime_get_str_from_tm (datetime, priv->display_format);
-
-                       ret = gtk_form_field_datetime_set_value_stringify (field, value);
-
-                       priv->original_value = g_memdup (datetime, sizeof (struct tm));
-
-                       g_free (datetime);
-                       g_free (value);
-               }
-       else
-               {
-                       g_warning (_("GtkFormField hasn't a field name."));
-               }
-
-       g_free (field_name);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_set_from_hashtable:
- * @field: a #GtkFormField object.
- * @hashtable: a #GHashTable object.
- *
- */
-gboolean
-gtk_form_field_datetime_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
-{
-       gboolean ret;
-       GtkFormFieldDateTimePrivate *priv;
-       gchar *field_name;
-       GValue *gval;
-       struct tm *datetime;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       ret = FALSE;
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
-
-       field_name = (gchar *)gtk_form_field_get_field_name (field);
-       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
-               {
-                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
-                       if (gval == NULL)
-                               {
-                                       priv->original_value = NULL;
-                                       ret = gtk_form_field_datetime_set_value_stringify (field, "");
-                               }
-                       else
-                               {
-                                       datetime = (struct tm *)g_value_get_pointer (gval);
-
-                                       value = gtk_form_field_datetime_get_str_from_tm (datetime, priv->display_format);
-
-                                       ret = gtk_form_field_datetime_set_value_stringify (field, value);
-
-                                       priv->original_value = g_memdup (datetime, sizeof (struct tm));
-
-                                       g_free (datetime);
-                                       g_free (value);
-                               }
-               }
-       else
-               {
-                       g_warning (_("GtkFormField hasn't a field name."));
-               }
-
-       g_free (field_name);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_set_value:
- * @field: a #GtkFormField object.
- * @value: a #GValue.
- *
- */
-gboolean
-gtk_form_field_datetime_set_value (GtkFormField *field, GValue *gvalue)
-{
-       gboolean ret;
-       GtkFormFieldDateTimePrivate *priv;
-       struct tm *datetime;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
-       g_return_val_if_fail (G_VALUE_HOLDS_POINTER (gvalue), FALSE);
-
-       ret = FALSE;
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
-
-       datetime = (struct tm *)g_value_get_pointer (gvalue);
-       value = gtk_form_field_datetime_get_str_from_tm (datetime, priv->display_format);
-       ret = gtk_form_field_datetime_set_value_stringify (field, value);
-       priv->original_value = g_memdup (datetime, sizeof (struct tm));
-
-       g_free (datetime);
-       g_free (value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_tm_from_str:
- * @str: the #gchar to be parsed.
- * @format:
- *
- */
-struct tm
-*gtk_form_field_datetime_get_tm_from_str (const gchar *str, const gchar *format)
-{
-       struct tm *ret;
-       gchar *new_str;
-       gchar *new_format;
-       gchar **str_tokens;
-       gchar **format_tokens;
-       gchar *delimiters;
-       guint len_strv;
-       guint len_formatv;
-       guint i;
-       guint i_to;
-       GDate *date;
-
-       g_return_val_if_fail (str != NULL, NULL);
-
-       new_str = g_strstrip (g_strdup (str));
-       if (g_strcmp0 (new_str, "") == 0)
-               {
-                       g_free (new_str);
-                       return NULL;
-               }
-
-       new_format = g_strstrip (g_strdup (format));
-       if (g_strcmp0 (new_format, "") == 0)
-               {
-                       new_format = g_strdup ("%Y-%m-%d %H:%M:%S");
-               }
-
-       /* removes format identifiers to find delimiters */
-       delimiters = gtk_form_field_datetime_str_replace (new_format, "%Y", "");
-       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%m", "");
-       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%d", "");
-       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%H", "");
-       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%M", "");
-       delimiters = gtk_form_field_datetime_str_replace (delimiters, "%S", "");
-
-       if (delimiters == NULL || g_strcmp0 (delimiters, "") == 0)
-               {
-                       g_free (delimiters);
-                       g_free (new_format);
-                       g_free (new_str);
-                       return NULL;
-               }
-
-       str_tokens = g_strsplit_set (str, delimiters, -1);
-       if (str_tokens == NULL)
-               {
-                       g_free (delimiters);
-                       g_free (new_format);
-                       g_free (new_str);
-                       return NULL;
-               }
-
-       format_tokens = g_strsplit_set (format, delimiters, -1);
-       if (format_tokens == NULL)
-               {
-                       g_free (delimiters);
-                       g_free (new_format);
-                       g_free (new_str);
-                       return NULL;
-               }
-
-       len_strv = g_strv_length (str_tokens);
-       len_formatv = g_strv_length (format_tokens);
-
-       ret = g_malloc0 (sizeof (struct tm));
-       ret->tm_mday = 1;
-       ret->tm_isdst = -1;
-
-       i_to = MIN (len_strv, len_formatv);
-       for (i = 0; i < i_to; i++)
-               {
-                       if (g_strcmp0 (format_tokens[i], "%Y") == 0)
-                               {
-                                       ret->tm_year = strtol (str_tokens[i], NULL, 10) - 1900;
-                               }
-                       else if (g_strcmp0 (format_tokens[i], "%m") == 0)
-                               {
-                                       ret->tm_mon = strtol (str_tokens[i], NULL, 10) - 1;
-                               }
-                       else if (g_strcmp0 (format_tokens[i], "%d") == 0)
-                               {
-                                       ret->tm_mday = strtol (str_tokens[i], NULL, 10);
-                               }
-                       else if (g_strcmp0 (format_tokens[i], "%H") == 0)
-                               {
-                                       ret->tm_hour = strtol (str_tokens[i], NULL, 10);
-                               }
-                       else if (g_strcmp0 (format_tokens[i], "%M") == 0)
-                               {
-                                       ret->tm_min = strtol (str_tokens[i], NULL, 10);
-                               }
-                       else if (g_strcmp0 (format_tokens[i], "%S") == 0)
-                               {
-                                       ret->tm_sec = strtol (str_tokens[i], NULL, 10);
-                               }
-               }
-
-       g_free (delimiters);
-       g_free (new_format);
-       g_free (new_str);
-
-       /* check if it is valid */
-       date = g_date_new_dmy (ret->tm_mday,
-                              ret->tm_mon + 1,
-                              ret->tm_year + 1900);
-       if (date == NULL || !g_date_valid (date))
-               {
-                       return NULL;
-               }
-
-       if (ret != NULL)
-               {
-                       mktime (ret);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_str_from_tm:
- * @datetime: a tm struct.
- * @format:
- *
- * Returns: a string representation of @datetime based on the format in @format.
- * It interprets a very little subset of format identifiers from strftime.
- * %Y: the year with 4 digits.
- * %m: the month with 2 digits.
- * %d: the day with 2 digits.
- * %H: the hours with 2 digits 00-24.
- * %M: the minutes with 2 digits 00-59.
- * %S: the seconds with 2 digits 00-59.
- */
-gchar
-*gtk_form_field_datetime_get_str_from_tm (struct tm *datetime,
-                                          const gchar *format)
-{
-       gchar *ret;
-
-       ret = g_strdup ("");
-
-       g_return_val_if_fail (datetime != NULL, ret);
-
-       ret = gtk_form_field_datetime_str_replace (format, "%Y",
-                                                  g_strdup_printf ("%04u", datetime->tm_year + 1900));
-       ret = gtk_form_field_datetime_str_replace (ret, "%m",
-                                                  g_strdup_printf ("%02u", datetime->tm_mon + 1));
-       ret = gtk_form_field_datetime_str_replace (ret, "%d",
-                                                  g_strdup_printf ("%02u", datetime->tm_mday));
-       ret = gtk_form_field_datetime_str_replace (ret, "%H",
-                                                  g_strdup_printf ("%02u", datetime->tm_hour));
-       ret = gtk_form_field_datetime_str_replace (ret, "%M",
-                                                  g_strdup_printf ("%02u", datetime->tm_min));
-       ret = gtk_form_field_datetime_str_replace (ret, "%S",
-                                                  g_strdup_printf ("%02u", datetime->tm_sec));
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_gdate_from_tm:
- * @datetime: a struct tm.
- *
- * Returns: a #GDate that represent the struct tm without time information.
- */
-GDate
-*gtk_form_field_datetime_get_gdate_from_tm (struct tm *datetime)
-{
-       GDate *ret;
-
-       ret = NULL;
-
-       if (datetime != NULL)
-               {
-                       ret = g_date_new_dmy (datetime->tm_mday,
-                                             datetime->tm_mon + 1,
-                                             datetime->tm_year + 1900);
-
-                       if (ret == NULL || !g_date_valid (ret))
-                               {
-                                       ret = NULL;
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_now:
- * 
- * Returns: a struct tm that represent the actual date and time.
- */
-struct tm
-*gtk_form_field_datetime_get_now (void)
-{
-       struct tm *ret;
-       time_t tt;
-
-       tt = time (NULL);
-       ret = localtime (&tt);
-
-       return ret;
-}
-
-/* PRIVATE */
-static void
-gtk_form_field_datetime_set_property (GObject *object,
-                                  guint property_id,
-                                  const GValue *value,
-                                  GParamSpec *pspec)
-{
-       GtkFormFieldDateTime *field = (GtkFormFieldDateTime *)object;
-
-       GtkFormFieldDateTimePrivate *priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               priv->default_value = g_value_get_pointer (value);
-                               break;
-
-                       case PROP_TYPE:
-                               priv->type = g_value_get_int (value);
-                               break;
-
-                       case PROP_DISPLAY_FORMAT:
-                               priv->display_format = g_strstrip (g_value_dup_string (value));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-gtk_form_field_datetime_get_property (GObject *object,
-                                  guint property_id,
-                                  GValue *value,
-                                  GParamSpec *pspec)
-{
-       GtkFormFieldDateTime *field = (GtkFormFieldDateTime *)object;
-
-       GtkFormFieldDateTimePrivate *priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               g_value_set_pointer (value, priv->default_value);
-                               break;
-
-                       case PROP_TYPE:
-                               g_value_set_int (value, priv->type);
-                               break;
-
-                       case PROP_DISPLAY_FORMAT:
-                               g_value_set_string (value, priv->display_format);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static gboolean
-gtk_form_field_datetime_set_value_stringify (GtkFormField *field, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkFormWidget *fw;
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       ret = gtk_form_widget_set_value_stringify (fw, value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_datetime_get_str_format:
- * @field: a #GtkFormFieldDateTime object.
- *
- * Returns: the strftime format string for the current type.
- */
-static gchar
-*gtk_form_field_datetime_get_str_format (GtkFormFieldDateTime *field)
-{
-       gchar *format;
-       GtkFormFieldDateTimePrivate *priv;
-
-       format = NULL;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), format);
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
-
-       switch (priv->type)
-               {
-                       case GTK_FORM_FIELD_DATETIME_TYPE_DATETIME:
-                               format = g_strdup ("%Y-%m-%d %H:%M:%S");
-                               break;
-
-                       case GTK_FORM_FIELD_DATETIME_TYPE_DATE:
-                               format = g_strdup ("%Y-%m-%d");
-                               break;
-
-                       case GTK_FORM_FIELD_DATETIME_TYPE_TIME:
-                               format = g_strdup ("%H:%M:%S");
-                               break;
-
-                       default:
-                               g_warning (_("GtkFormFieldDateTimeType not supported: %d."), priv->type);
-                               format = NULL;
-                               break;
-               }
-
-       return format;
-}
-
-/**
- * gtk_form_field_datetime_replace_str:
- * @string: the string where make the replace.
- * @origin: the string to replace.
- * @replace: the string to insert.
- *
- * Returns: a string with replaced string. Must be freed.
- */
-static gchar
-*gtk_form_field_datetime_str_replace (const gchar *string,
-                                      const gchar *origin,
-                                      const gchar *replace)
-{
-       gchar *ret;
-       gchar *p;
-
-       p = g_strstr_len (string, -1, origin);
-
-       if (p == NULL)
-               {
-                       return g_strdup (string);
-               }
-
-       ret = g_strndup (string, p - string);
-
-       ret = g_strdup_printf ("%s%s%s", ret, replace, p + strlen (origin));
-
-       return ret;
-}
-
-static gboolean
-gtk_form_field_datetime_is_valid_datetime (GtkFormFieldDateTime *field)
-{
-       gboolean ret;
-
-       GtkFormFieldDateTimePrivate *priv;
-
-       gchar *str_date;
-       struct tm *tm_date;
-
-       priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (field);
-
-       str_date = gtk_form_field_datetime_get_value_stringify (GTK_FORM_FIELD (field));
-       tm_date = gtk_form_field_datetime_get_tm_from_str (str_date, priv->display_format);
-
-       ret = (tm_date != NULL);
-
-       g_free (str_date);
-       g_free (tm_date);
-
-       return ret;
-}
diff --git a/src/fielddatetime.h b/src/fielddatetime.h
deleted file mode 100644 (file)
index d645ea5..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_FIELD_DATETIME_H__
-#define __LIBGTK_FORM_FIELD_DATETIME_H__
-
-#include "field.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_FIELD_DATETIME                 (gtk_form_field_datetime_get_type ())
-#define GTK_FORM_FIELD_DATETIME(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTime))
-#define GTK_FORM_FIELD_DATETIME_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTimeClass))
-#define IS_GTK_FORM_FIELD_DATETIME(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_DATETIME))
-#define IS_GTK_FORM_FIELD_DATETIME_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_DATETIME))
-#define GTK_FORM_FIELD_DATETIME_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_DATETIME, GtkFormFieldDateTimeClass))
-
-
-typedef struct _GtkFormFieldDateTime GtkFormFieldDateTime;
-typedef struct _GtkFormFieldDateTimeClass GtkFormFieldDateTimeClass;
-
-struct _GtkFormFieldDateTime
-       {
-               GtkFormField parent;
-       };
-
-struct _GtkFormFieldDateTimeClass
-       {
-               GtkFormFieldClass parent_class;
-       };
-
-GType gtk_form_field_datetime_get_type (void) G_GNUC_CONST;
-
-enum
-{
-       GTK_FORM_FIELD_DATETIME_TYPE_DATETIME,
-       GTK_FORM_FIELD_DATETIME_TYPE_DATE,
-       GTK_FORM_FIELD_DATETIME_TYPE_TIME
-};
-
-GtkFormField *gtk_form_field_datetime_new (void);
-
-gchar *gtk_form_field_datetime_get_value_stringify (GtkFormField *field);
-GValue *gtk_form_field_datetime_get_value (GtkFormField *field);
-gchar *gtk_form_field_datetime_get_value_sql (GtkFormField *field);
-GValue *gtk_form_field_datetime_get_original_value (GtkFormField *field);
-
-gboolean gtk_form_field_datetime_clear (GtkFormField *field);
-
-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_is_valid (GtkFormField *field);
-
-gboolean gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row);
-gboolean gtk_form_field_datetime_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
-gboolean gtk_form_field_datetime_set_value (GtkFormField *field, GValue *gvalue);
-
-struct tm *gtk_form_field_datetime_get_tm_from_str (const gchar *str, const gchar *format);
-gchar *gtk_form_field_datetime_get_str_from_tm (struct tm *datetime, const gchar *format);
-
-GDate *gtk_form_field_datetime_get_gdate_from_tm (struct tm *datetime);
-
-struct tm *gtk_form_field_datetime_get_now (void);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_FIELD_DATETIME_H__ */
diff --git a/src/fieldfloat.c b/src/fieldfloat.c
deleted file mode 100644 (file)
index 19379ef..0000000
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <locale.h>
-
-#include <glib/gi18n-lib.h>
-
-#include "widget.h"
-#include "fieldfloat.h"
-
-enum
-{
-       PROP_0,
-       PROP_DEFAULT,
-       PROP_DECIMALS
-};
-
-static void gtk_form_field_float_class_init (GtkFormFieldFloatClass *klass);
-static void gtk_form_field_float_init (GtkFormFieldFloat *gtk_form_field);
-
-static void gtk_form_field_float_set_property (GObject *object,
-                                           guint property_id,
-                                           const GValue *value,
-                                           GParamSpec *pspec);
-static void gtk_form_field_float_get_property (GObject *object,
-                                           guint property_id,
-                                           GValue *value,
-                                           GParamSpec *pspec);
-
-static gboolean gtk_form_field_float_set_value_stringify (GtkFormField *field, const gchar *value);
-static const gchar *gtk_form_field_float_get_str_format (GtkFormFieldFloat *field);
-
-#define GTK_FORM_FIELD_FLOAT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloatPrivate))
-
-typedef struct _GtkFormFieldFloatPrivate GtkFormFieldFloatPrivate;
-struct _GtkFormFieldFloatPrivate
-       {
-               gfloat default_value;
-               gfloat original_value;
-
-               guint decimals;
-       };
-
-
-G_DEFINE_TYPE (GtkFormFieldFloat, gtk_form_field_float, TYPE_GTK_FORM_FIELD)
-
-static void
-gtk_form_field_float_class_init (GtkFormFieldFloatClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
-
-       object_class->set_property = gtk_form_field_float_set_property;
-       object_class->get_property = gtk_form_field_float_get_property;
-
-       field_class->get_value_stringify = gtk_form_field_float_get_value_stringify;
-       field_class->get_value = gtk_form_field_float_get_value;
-       field_class->get_value_sql = gtk_form_field_float_get_value_sql;
-       field_class->get_original_value = gtk_form_field_float_get_original_value;
-       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->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;
-
-       g_object_class_install_property (object_class, PROP_DEFAULT,
-                                        g_param_spec_float ("default",
-                                                            "Default",
-                                                            "Default value",
-                                                            -G_MAXFLOAT, G_MAXFLOAT, 0.0f,
-                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_DECIMALS,
-                                        g_param_spec_uint ("decimals",
-                                                           "Decimals",
-                                                           "Number of decimals to show",
-                                                           0, G_MAXUINT, 0,
-                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormFieldFloatPrivate));
-}
-
-static void
-gtk_form_field_float_init (GtkFormFieldFloat *gtk_form_field)
-{
-}
-
-/**
- * gtk_form_field_float_new:
- *
- * Returns: the newly created #GtkFormFieldFloat.
- */
-GtkFormField
-*gtk_form_field_float_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_FIELD_FLOAT, NULL);
-}
-
-/**
- * gtk_form_field_float_get_value_stringify:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_float_get_value_stringify (GtkFormField *field)
-{
-       gchar *ret;
-
-       GtkFormWidget *fw;
-       GtkFormFieldFloatPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), "");
-
-       priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
-
-       ret = g_strdup ("");
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       if (IS_GTK_FORM_WIDGET (fw))
-               {
-                       gchar *value;
-
-                       value = gtk_form_widget_get_value_stringify (fw);
-
-                       if (value != NULL)
-                               {
-                                       ret = g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), g_strtod (value, NULL));
-
-                                       g_free (value);
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_float_get_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_float_get_value (GtkFormField *field)
-{
-       GValue *ret;
-       gchar *value;
-
-       ret = NULL;
-
-       value = gtk_form_field_float_get_value_stringify (field);
-
-       if (value != NULL)
-               {
-                       ret = g_malloc0 (sizeof (GValue));
-                       g_value_init (ret, G_TYPE_FLOAT);
-                       g_value_set_float (ret, g_strtod (value, NULL));
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_float_get_value_sql:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_float_get_value_sql (GtkFormField *field)
-{
-       gchar *ret;
-       gchar *value;
-
-       ret = g_strdup ("");
-
-       value = gtk_form_field_float_get_value_stringify (field);
-       if (value != NULL)
-               {
-                       char *cur = g_strdup (setlocale (LC_NUMERIC, NULL));
-                       gda_locale_changed ();
-
-                       gfloat fval = g_strtod (value, NULL);
-
-                       setlocale (LC_NUMERIC, "C");
-                       gda_locale_changed ();
-
-                       ret = g_strdup_printf ("%f", fval);
-
-                       setlocale (LC_NUMERIC, cur);
-                       gda_locale_changed ();
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_float_get_original_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_float_get_original_value (GtkFormField *field)
-{
-       GValue *ret;
-
-       ret = NULL;
-
-       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
-
-       ret = g_malloc0 (sizeof (GValue));
-       g_value_init (ret, G_TYPE_FLOAT);
-       g_value_set_float (ret, priv->original_value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_float_clear:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_float_clear (GtkFormField *field)
-{
-       gboolean ret = FALSE;
-
-       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
-
-       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), priv->default_value));
-
-       priv->original_value = priv->default_value;
-
-       return ret;
-}
-
-/**
- * gtk_form_field_float_is_empty:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_float_is_empty (GtkFormField *field)
-{
-       gboolean ret;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), TRUE);
-
-       value = gtk_form_field_float_get_value_stringify (field);
-
-       if (value != NULL && g_strtod (value, NULL) == 0.0f)
-               {
-                       ret = TRUE;
-               }
-       else
-               {
-                       ret = FALSE;
-               }
-
-       g_free (value);
-
-       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_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_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.
- * @dm: a #GdaDataModel object.
- * @row:
- *
- */
-gboolean
-gtk_form_field_float_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldFloatPrivate *priv;
-       gfloat value;
-       gchar *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_float_at (dm, row, field_name);
-
-       setlocale (LC_NUMERIC, "");
-       gda_locale_changed ();
-       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), value));
-
-       priv->original_value = value;
-
-       g_free (field_name);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_float_set_from_hashtable:
- * @field: a #GtkFormField object.
- * @hashtable: a #GHashTable object.
- *
- */
-gboolean
-gtk_form_field_float_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldFloatPrivate *priv;
-       GValue *gval;
-       gchar *field_name;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
-
-       field_name = gtk_form_field_get_field_name (field);
-       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
-               {
-                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
-                       if (gval == NULL)
-                               {
-                                       priv->original_value = 0.0;
-
-                                       setlocale (LC_NUMERIC, "");
-                                       gda_locale_changed ();
-                                       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), 0.0));
-                               }
-                       else
-                               {
-                                       priv->original_value = g_value_get_float (gval);
-
-                                       setlocale (LC_NUMERIC, "");
-                                       gda_locale_changed ();
-                                       ret = gtk_form_field_float_set_value_stringify (field, g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)), priv->original_value));
-                               }
-               }
-       else
-               {
-                       g_warning (_("GtkFormField hasn't a field name."));
-               }
-
-       g_free (field_name);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_float_set_value:
- * @field: a #GtkFormField object.
- * @value: a #GValue.
- *
- */
-gboolean
-gtk_form_field_float_set_value (GtkFormField *field, GValue *gvalue)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldFloatPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
-       g_return_val_if_fail (G_VALUE_HOLDS_FLOAT (gvalue), FALSE);
-
-       priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (GTK_FORM_FIELD_FLOAT (field));
-
-       priv->original_value = g_value_get_float (gvalue);
-       setlocale (LC_NUMERIC, "");
-       gda_locale_changed ();
-       ret = gtk_form_field_float_set_value_stringify (field,
-                                                       g_strdup_printf (gtk_form_field_float_get_str_format (GTK_FORM_FIELD_FLOAT (field)),
-                                                                        priv->original_value));
-
-       return ret;
-}
-
-/* PRIVATE */
-static void
-gtk_form_field_float_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec)
-{
-       GtkFormFieldFloat *field = (GtkFormFieldFloat *)object;
-
-       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               priv->default_value = g_value_get_float (value);
-                               break;
-
-                       case PROP_DECIMALS:
-                               priv->decimals = g_value_get_uint (value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-gtk_form_field_float_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec)
-{
-       GtkFormFieldFloat *field = (GtkFormFieldFloat *)object;
-
-       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               g_value_set_float (value, priv->default_value);
-                               break;
-
-                       case PROP_DECIMALS:
-                               g_value_set_uint (value, priv->decimals);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static gboolean
-gtk_form_field_float_set_value_stringify (GtkFormField *field, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkFormWidget *fw;
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       ret = gtk_form_widget_set_value_stringify (fw, value);
-
-       return ret;
-}
-
-static const gchar
-*gtk_form_field_float_get_str_format (GtkFormFieldFloat *field)
-{
-       GtkFormFieldFloatPrivate *priv = GTK_FORM_FIELD_FLOAT_GET_PRIVATE (field);
-
-       return g_strdup_printf ("%%0%sf", priv->decimals < 0 ? ".2" : g_strdup_printf (".%d", priv->decimals));
-}
diff --git a/src/fieldfloat.h b/src/fieldfloat.h
deleted file mode 100644 (file)
index 62fcc3b..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_FIELD_FLOAT_H__
-#define __LIBGTK_FORM_FIELD_FLOAT_H__
-
-#include "field.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_FIELD_FLOAT                 (gtk_form_field_float_get_type ())
-#define GTK_FORM_FIELD_FLOAT(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloat))
-#define GTK_FORM_FIELD_FLOAT_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloatClass))
-#define IS_GTK_FORM_FIELD_FLOAT(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_FLOAT))
-#define IS_GTK_FORM_FIELD_FLOAT_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_FLOAT))
-#define GTK_FORM_FIELD_FLOAT_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_FLOAT, GtkFormFieldFloatClass))
-
-
-typedef struct _GtkFormFieldFloat GtkFormFieldFloat;
-typedef struct _GtkFormFieldFloatClass GtkFormFieldFloatClass;
-
-struct _GtkFormFieldFloat
-       {
-               GtkFormField parent;
-       };
-
-struct _GtkFormFieldFloatClass
-       {
-               GtkFormFieldClass parent_class;
-       };
-
-GType gtk_form_field_float_get_type (void) G_GNUC_CONST;
-
-GtkFormField *gtk_form_field_float_new (void);
-
-gchar *gtk_form_field_float_get_value_stringify (GtkFormField *field);
-GValue *gtk_form_field_float_get_value (GtkFormField *field);
-gchar *gtk_form_field_float_get_value_sql (GtkFormField *field);
-GValue *gtk_form_field_float_get_original_value (GtkFormField *field);
-
-gboolean gtk_form_field_float_clear (GtkFormField *field);
-
-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_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);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_FIELD_FLOAT_H__ */
diff --git a/src/fieldinteger.c b/src/fieldinteger.c
deleted file mode 100644 (file)
index 00c1260..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <glib/gi18n-lib.h>
-
-#include "widget.h"
-#include "fieldinteger.h"
-
-enum
-{
-       PROP_0,
-       PROP_DEFAULT
-};
-
-static void gtk_form_field_integer_class_init (GtkFormFieldIntegerClass *klass);
-static void gtk_form_field_integer_init (GtkFormFieldInteger *gtk_form_field);
-
-static void gtk_form_field_integer_set_property (GObject *object,
-                                             guint property_id,
-                                             const GValue *value,
-                                             GParamSpec *pspec);
-static void gtk_form_field_integer_get_property (GObject *object,
-                                             guint property_id,
-                                             GValue *value,
-                                             GParamSpec *pspec);
-
-static gboolean gtk_form_field_integer_set_value_stringify (GtkFormField *field, const gchar *value);
-
-#define GTK_FORM_FIELD_INTEGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldIntegerPrivate))
-
-typedef struct _GtkFormFieldIntegerPrivate GtkFormFieldIntegerPrivate;
-struct _GtkFormFieldIntegerPrivate
-       {
-               gint default_value;
-               gint original_value;
-       };
-
-
-G_DEFINE_TYPE (GtkFormFieldInteger, gtk_form_field_integer, TYPE_GTK_FORM_FIELD)
-
-static void
-gtk_form_field_integer_class_init (GtkFormFieldIntegerClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
-
-       object_class->set_property = gtk_form_field_integer_set_property;
-       object_class->get_property = gtk_form_field_integer_get_property;
-
-       field_class->get_value_stringify = gtk_form_field_integer_get_value_stringify;
-       field_class->get_value = gtk_form_field_integer_get_value;
-       field_class->get_value_sql = gtk_form_field_integer_get_value_sql;
-       field_class->get_original_value = gtk_form_field_integer_get_original_value;
-       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->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;
-
-       g_object_class_install_property (object_class, PROP_DEFAULT,
-                                        g_param_spec_int ("default",
-                                                          "Default",
-                                                          "Default value",
-                                                          G_MININT, G_MAXINT, 0,
-                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormFieldIntegerPrivate));
-}
-
-static void
-gtk_form_field_integer_init (GtkFormFieldInteger *gtk_form_field)
-{
-}
-
-/**
- * gtk_form_field_integer_new:
- *
- * Returns: the newly created #GtkFormFieldInteger.
- */
-GtkFormField
-*gtk_form_field_integer_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_FIELD_INTEGER, NULL);
-}
-
-/**
- * gtk_form_field_integer_get_value_stringify:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_integer_get_value_stringify (GtkFormField *field)
-{
-       gchar *ret;
-
-       GtkFormWidget *fw;
-
-       ret = g_strdup ("");
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       if (IS_GTK_FORM_WIDGET (fw))
-               {
-                       gchar *value;
-
-                       value = gtk_form_widget_get_value_stringify (fw);
-
-                       if (value != NULL)
-                               {
-                                       ret = g_strdup_printf ("%d", strtol (value, NULL, 10));
-
-                                       g_free (value);
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_integer_get_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_integer_get_value (GtkFormField *field)
-{
-       GValue *ret;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), NULL);
-
-       ret = NULL;
-
-       value = gtk_form_field_integer_get_value_stringify (field);
-
-       if (value != NULL)
-               {
-                       ret = g_malloc0 (sizeof (GValue));
-                       g_value_init (ret, G_TYPE_INT);
-                       g_value_set_int (ret, strtol (value, NULL, 10));
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_integer_get_value_sql:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_integer_get_value_sql (GtkFormField *field)
-{
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), "0");
-
-       return gtk_form_field_integer_get_value_stringify (field);
-}
-
-/**
- * gtk_form_field_integer_get_original_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_integer_get_original_value (GtkFormField *field)
-{
-       GValue *ret;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), NULL);
-
-       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
-
-       ret = NULL;
-
-       ret = g_malloc0 (sizeof (GValue));
-       g_value_init (ret, G_TYPE_INT);
-       g_value_set_int (ret, priv->original_value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_integer_clear:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_integer_clear (GtkFormField *field)
-{
-       gboolean ret = FALSE;
-
-       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
-
-       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: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_integer_is_empty (GtkFormField *field)
-{
-       gboolean ret;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), TRUE);
-
-       value = gtk_form_field_integer_get_value_stringify (field);
-
-       if (value != NULL && strtol (value, NULL, 10) == 0)
-               {
-                       ret = TRUE;
-               }
-       else
-               {
-                       ret = FALSE;
-               }
-
-       g_free (value);
-
-       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_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.
- *
- */
-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.
- * @dm: a #GdaDataModel object.
- * @row:
- *
- */
-gboolean
-gtk_form_field_integer_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldIntegerPrivate *priv;
-       gchar *value;
-       gchar *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);
-
-       g_free (field_name);
-       g_free (value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_integer_set_from_hashtable:
- * @field: a #GtkFormField object.
- * @hashtable: a #GHashTable object.
- *
- */
-gboolean
-gtk_form_field_integer_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldIntegerPrivate *priv;
-       GValue *gval;
-       gchar *field_name;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), FALSE);
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
-
-       field_name = gtk_form_field_get_field_name (field);
-       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
-               {
-                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
-                       if (gval == NULL)
-                               {
-                                       priv->original_value = 0;
-                                       ret = gtk_form_field_integer_set_value_stringify (field, "0");
-                               }
-                       else
-                               {
-                                       priv->original_value = g_value_get_int (gval);
-                                       ret = gtk_form_field_integer_set_value_stringify (field, g_strdup_printf ("%d", priv->original_value));
-                               }
-
-                       g_free (field_name);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_integer_set_value:
- * @field: a #GtkFormField object.
- * @gvalue: a #Gvalue.
- *
- */
-gboolean
-gtk_form_field_integer_set_value (GtkFormField *field, GValue *gvalue)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldIntegerPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), FALSE);
-       g_return_val_if_fail (G_VALUE_HOLDS_INT (gvalue), FALSE);
-
-       priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (GTK_FORM_FIELD_INTEGER (field));
-
-       priv->original_value = g_value_get_int (gvalue);
-       ret = gtk_form_field_integer_set_value_stringify (field, g_strdup_printf ("%d", priv->original_value));
-
-       return ret;
-}
-
-/* PRIVATE */
-static void
-gtk_form_field_integer_set_property (GObject *object,
-                                 guint property_id,
-                                 const GValue *value,
-                                 GParamSpec *pspec)
-{
-       GtkFormFieldInteger *field = (GtkFormFieldInteger *)object;
-
-       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               priv->default_value = g_value_get_int (value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_field_integer_get_property (GObject *object,
-                                 guint property_id,
-                                 GValue *value,
-                                 GParamSpec *pspec)
-{
-       GtkFormFieldInteger *field = (GtkFormFieldInteger *)object;
-
-       GtkFormFieldIntegerPrivate *priv = GTK_FORM_FIELD_INTEGER_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               g_value_set_int (value, priv->default_value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static gboolean
-gtk_form_field_integer_set_value_stringify (GtkFormField *field, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkFormWidget *fw;
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       ret = gtk_form_widget_set_value_stringify (fw, value);
-
-       return ret;
-}
diff --git a/src/fieldinteger.h b/src/fieldinteger.h
deleted file mode 100644 (file)
index 4ca3ca7..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_FIELD_INTEGER_H__
-#define __LIBGTK_FORM_FIELD_INTEGER_H__
-
-#include "field.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_FIELD_INTEGER                 (gtk_form_field_integer_get_type ())
-#define GTK_FORM_FIELD_INTEGER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldInteger))
-#define GTK_FORM_FIELD_INTEGER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldIntegerClass))
-#define IS_GTK_FORM_FIELD_INTEGER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_INTEGER))
-#define IS_GTK_FORM_FIELD_INTEGER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_INTEGER))
-#define GTK_FORM_FIELD_INTEGER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_INTEGER, GtkFormFieldIntegerClass))
-
-
-typedef struct _GtkFormFieldInteger GtkFormFieldInteger;
-typedef struct _GtkFormFieldIntegerClass GtkFormFieldIntegerClass;
-
-struct _GtkFormFieldInteger
-       {
-               GtkFormField parent;
-       };
-
-struct _GtkFormFieldIntegerClass
-       {
-               GtkFormFieldClass parent_class;
-       };
-
-GType gtk_form_field_integer_get_type (void) G_GNUC_CONST;
-
-GtkFormField *gtk_form_field_integer_new (void);
-
-gchar *gtk_form_field_integer_get_value_stringify (GtkFormField *field);
-GValue *gtk_form_field_integer_get_value (GtkFormField *field);
-gchar *gtk_form_field_integer_get_value_sql (GtkFormField *field);
-GValue *gtk_form_field_integer_get_original_value (GtkFormField *field);
-
-gboolean gtk_form_field_integer_clear (GtkFormField *field);
-
-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_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);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_FIELD_INTEGER_H__ */
diff --git a/src/fieldtext.c b/src/fieldtext.c
deleted file mode 100644 (file)
index ae168da..0000000
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <glib/gi18n-lib.h>
-
-#include "widget.h"
-#include "fieldtext.h"
-
-enum
-{
-       PROP_0,
-       PROP_DEFAULT
-};
-
-static void gtk_form_field_text_class_init (GtkFormFieldTextClass *klass);
-static void gtk_form_field_text_init (GtkFormFieldText *gtk_form_field);
-
-static void gtk_form_field_text_set_property (GObject *object,
-                                          guint property_id,
-                                          const GValue *value,
-                                          GParamSpec *pspec);
-static void gtk_form_field_text_get_property (GObject *object,
-                                          guint property_id,
-                                          GValue *value,
-                                          GParamSpec *pspec);
-
-static gboolean gtk_form_field_text_set_value_stringify (GtkFormField *field, const gchar *value);
-
-#define GTK_FORM_FIELD_TEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldTextPrivate))
-
-typedef struct _GtkFormFieldTextPrivate GtkFormFieldTextPrivate;
-struct _GtkFormFieldTextPrivate
-       {
-               gchar *default_value;
-               gchar *original_value;
-       };
-
-
-G_DEFINE_TYPE (GtkFormFieldText, gtk_form_field_text, TYPE_GTK_FORM_FIELD)
-
-static void
-gtk_form_field_text_class_init (GtkFormFieldTextClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormFieldClass *field_class = GTK_FORM_FIELD_CLASS (klass);
-
-       object_class->set_property = gtk_form_field_text_set_property;
-       object_class->get_property = gtk_form_field_text_get_property;
-
-       field_class->get_value_stringify = gtk_form_field_text_get_value_stringify;
-       field_class->get_value = gtk_form_field_text_get_value;
-       field_class->get_value_sql = gtk_form_field_text_get_value_sql;
-       field_class->get_original_value = gtk_form_field_text_get_original_value;
-       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;
-       field_class->set_from_hashtable = gtk_form_field_text_set_from_hashtable;
-       field_class->set_value = gtk_form_field_text_set_value;
-
-       g_object_class_install_property (object_class, PROP_DEFAULT,
-                                        g_param_spec_string ("default",
-                                                             "Default",
-                                                             "Default value",
-                                                             "",
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormFieldTextPrivate));
-}
-
-static void
-gtk_form_field_text_init (GtkFormFieldText *gtk_form_field)
-{
-       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (gtk_form_field);
-
-       priv->original_value = g_strdup ("");
-}
-
-/**
- * gtk_form_field_text_new:
- *
- * Returns: the newly created #GtkFormFieldText.
- */
-GtkFormField
-*gtk_form_field_text_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_FIELD_TEXT, NULL);
-}
-
-/**
- * gtk_form_field_text_get_value_stringify:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_text_get_value_stringify (GtkFormField *field)
-{
-       gchar *ret;
-
-       GtkFormWidget *fw;
-               
-       g_object_get (field,
-                     "form-widget", &fw,
-                     NULL);
-
-       ret = g_strdup ("");
-
-       if (IS_GTK_FORM_WIDGET (fw))
-               {
-                       ret = gtk_form_widget_get_value_stringify (fw);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_text_get_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_text_get_value (GtkFormField *field)
-{
-       GValue *ret;
-       gchar *value;
-
-       ret = NULL;
-
-       value = gtk_form_field_text_get_value_stringify (field);
-
-       if (value != NULL)
-               {
-                       ret = g_malloc0 (sizeof (GValue));
-                       g_value_init (ret, G_TYPE_STRING);
-                       g_value_set_string (ret, value);
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_text_get_value_sql:
- * @field: a #GtkFormField object.
- *
- */
-gchar
-*gtk_form_field_text_get_value_sql (GtkFormField *field)
-{
-       gchar *ret;
-       gchar *value;
-
-       ret = g_strup ("");
-
-       value = gtk_form_field_text_get_value_stringify (field);
-
-       if (value != NULL)
-               {
-                       gboolean trim;
-
-                       g_object_get (G_OBJECT (field), "trim", &trim, NULL);
-                       if (trim)
-                               {
-                                       value = g_strstrip (value);
-                               }
-
-                       ret = g_strconcat ("'", gdaex_strescape (value, NULL), "'", NULL);
-
-                       g_free (value);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_text_get_original_value:
- * @field: a #GtkFormField object.
- *
- */
-GValue
-*gtk_form_field_text_get_original_value (GtkFormField *field)
-{
-       GValue *ret;
-
-       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
-
-       ret = NULL;
-
-       ret = g_malloc0 (sizeof (GValue));
-       g_value_init (ret, G_TYPE_STRING);
-       g_value_set_string (ret, priv->original_value);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_text_clear:
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_text_clear (GtkFormField *field)
-{
-       gboolean ret = FALSE;
-
-       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
-
-       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: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_field_text_is_empty (GtkFormField *field)
-{
-       gboolean ret;
-       gchar *value;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), TRUE);
-
-       value = gtk_form_field_text_get_value_stringify (field);
-
-       if (value != NULL && g_strcmp0 (value, "") == 0)
-               {
-                       ret = TRUE;
-               }
-       else
-               {
-                       ret = FALSE;
-               }
-
-       g_free (value);
-
-       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;
-       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);
-
-       g_free (value);
-
-       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));
-
-       g_free (priv->original_value);
-       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
-}
-
-/**
- * gtk_form_field_text_set_from_datamodel:
- * @field: a #GtkFormField object.
- * @dm: a #GdaDataModel object.
- * @row:
- *
- */
-gboolean
-gtk_form_field_text_set_from_datamodel (GtkFormField *field, GdaDataModel *dm, gint row)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldTextPrivate *priv;
-       gchar *strret;
-       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));
-
-       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)
-               {
-                       strret = g_strdup ("");
-               }
-       ret = gtk_form_field_text_set_value_stringify (field, strret);
-
-       g_free (priv->original_value);
-       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
-
-       g_free (field_name);
-       g_free (strret);
-
-       return ret;
-}
-
-/**
- * gtk_form_field_text_set_from_hashtable:
- * @field: a #GtkFormField object.
- * @hashtable: a #GHashTable object.
- *
- */
-gboolean
-gtk_form_field_text_set_from_hashtable (GtkFormField *field, GHashTable *hashtable)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldTextPrivate *priv;
-       GValue *gval;
-       gchar *field_name;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), FALSE);
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (GTK_FORM_FIELD_TEXT (field));
-
-       field_name = gtk_form_field_get_field_name (field);
-       if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
-               {
-                       g_free (priv->original_value);
-                       gval = (GValue *)g_hash_table_lookup (hashtable, field_name);
-                       if (gval == NULL)
-                               {
-                                       priv->original_value = g_strdup ("");
-                                       ret = gtk_form_field_text_set_value_stringify (field, "");
-                               }
-                       else
-                               {
-                                       ret = gtk_form_field_text_set_value_stringify (field, g_value_get_string (gval));
-                                       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
-                               }
-                       g_free (field_name);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_field_text_set_value:
- * @field: a #GtkFormField object.
- * @gvalue: a #GValue.
- *
- */
-gboolean
-gtk_form_field_text_set_value (GtkFormField *field, GValue *gvalue)
-{
-       gboolean ret = FALSE;
-       GtkFormFieldTextPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), FALSE);
-       g_return_val_if_fail (G_VALUE_HOLDS_STRING (gvalue), FALSE);
-
-       priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (GTK_FORM_FIELD_TEXT (field));
-
-       ret = gtk_form_field_text_set_value_stringify (field, g_value_get_string (gvalue));
-
-       g_free (priv->original_value);
-       priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
-
-       return ret;
-}
-
-/* PRIVATE */
-static void
-gtk_form_field_text_set_property (GObject *object,
-                              guint property_id,
-                              const GValue *value,
-                              GParamSpec *pspec)
-{
-       GtkFormFieldText *field = (GtkFormFieldText *)object;
-
-       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               priv->default_value = g_strstrip (g_strdup (g_value_get_string (value)));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_field_text_get_property (GObject *object,
-                              guint property_id,
-                              GValue *value,
-                              GParamSpec *pspec)
-{
-       GtkFormFieldText *field = (GtkFormFieldText *)object;
-
-       GtkFormFieldTextPrivate *priv = GTK_FORM_FIELD_TEXT_GET_PRIVATE (field);
-
-       switch (property_id)
-               {
-                       case PROP_DEFAULT:
-                               g_value_set_string (value, priv->default_value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static gboolean
-gtk_form_field_text_set_value_stringify (GtkFormField *field, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkFormWidget *fw;
-       gboolean trim;
-       gchar *newval;
-
-       g_object_get (field,
-                     "form-widget", &fw,
-                     "trim", &trim,
-                     NULL);
-
-       newval = g_strdup (value);
-
-       if (trim)
-               {
-                       newval = g_strstrip (newval);
-               }
-
-       ret = gtk_form_widget_set_value_stringify (fw, newval);
-       g_free (newval);
-
-       return ret;
-}
diff --git a/src/fieldtext.h b/src/fieldtext.h
deleted file mode 100644 (file)
index f005ca5..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_FIELD_TEXT_H__
-#define __LIBGTK_FORM_FIELD_TEXT_H__
-
-#include "field.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_FIELD_TEXT                 (gtk_form_field_text_get_type ())
-#define GTK_FORM_FIELD_TEXT(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldText))
-#define GTK_FORM_FIELD_TEXT_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldTextClass))
-#define IS_GTK_FORM_FIELD_TEXT(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_FIELD_TEXT))
-#define IS_GTK_FORM_FIELD_TEXT_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_FIELD_TEXT))
-#define GTK_FORM_FIELD_TEXT_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_FIELD_TEXT, GtkFormFieldTextClass))
-
-
-typedef struct _GtkFormFieldText GtkFormFieldText;
-typedef struct _GtkFormFieldTextClass GtkFormFieldTextClass;
-
-struct _GtkFormFieldText
-       {
-               GtkFormField parent;
-       };
-
-struct _GtkFormFieldTextClass
-       {
-               GtkFormFieldClass parent_class;
-       };
-
-GType gtk_form_field_text_get_type (void) G_GNUC_CONST;
-
-GtkFormField *gtk_form_field_text_new (void);
-
-gchar *gtk_form_field_text_get_value_stringify (GtkFormField *field);
-GValue *gtk_form_field_text_get_value (GtkFormField *field);
-gchar *gtk_form_field_text_get_value_sql (GtkFormField *field);
-GValue *gtk_form_field_text_get_original_value (GtkFormField *field);
-
-gboolean gtk_form_field_text_clear (GtkFormField *field);
-
-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);
-gboolean gtk_form_field_text_set_from_hashtable (GtkFormField *field, GHashTable *hashtable);
-gboolean gtk_form_field_text_set_value (GtkFormField *field, GValue *gvalue);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_FIELD_TEXT_H__ */
diff --git a/src/form.c b/src/form.c
deleted file mode 100644 (file)
index 13a6acd..0000000
+++ /dev/null
@@ -1,2796 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <string.h>
-#include <time.h>
-
-#include <libxml/xpath.h>
-
-#include <glib/gi18n-lib.h>
-#include <gmodule.h>
-#include <gtk/gtk.h>
-
-#include "form.h"
-
-#include "fieldboolean.h"
-#include "fielddatetime.h"
-#include "fieldinteger.h"
-#include "fieldfloat.h"
-#include "fieldtext.h"
-#include "widget.h"
-#include "widgetcheck.h"
-#include "widgetcombobox.h"
-#include "widgetentry.h"
-#include "widgetlabel.h"
-#include "widgetradio.h"
-#include "widgetspin.h"
-#include "widgettextview.h"
-
-
-static guint debug;
-static gchar *log_file;
-
-static GOptionEntry entries[] = 
-{
-       { "gtkform-debug-level", 0, 0, G_OPTION_ARG_INT, &debug, "Sets the debug level", NULL },
-       { "gtkform-log-file", 0, 0, G_OPTION_ARG_FILENAME, &log_file, "Path to file where to write debug info (or stdout or stderr)", NULL },
-       { NULL }
-};
-
-enum
-{
-       PROP_0,
-       PROP_TABLE,
-       PROP_KEY,
-       PROP_QUOTE,
-       PROP_GDAEX
-};
-
-typedef GtkFormWidget *(* FormWidgetConstructorFunc) (void);
-typedef gboolean (* FormWidgetXmlParsingFunc) (GtkFormWidget *, xmlNodePtr);
-
-typedef struct
-{
-       gchar *name;
-       gchar *cnc_string;
-       GdaEx *gdaex;
-} GtkFormDbConnection;
-
-static void gtk_form_class_init (GtkFormClass *class);
-static void gtk_form_init (GtkForm *form);
-
-static void parse_widget_on_change (GtkForm *form, xmlNodePtr xnode, GtkFormWidget *fwidget);
-static void parse_group (GtkForm *form, xmlNodePtr xnode);
-static void parse_db_connection (GtkForm *form, xmlNodePtr xnode);
-
-static void gtk_form_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
-static void gtk_form_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
-
-static void gtk_form_show_check_error_dialog (GtkFormWidget *fwidget,
-                                              GtkWidget *parent_window,
-                                              const gchar *message);
-
-static void gtk_form_load_modules (GtkForm *form);
-
-#define GTK_FORM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM, GtkFormPrivate))
-
-typedef struct _GtkFormPrivate GtkFormPrivate;
-struct _GtkFormPrivate
-       {
-               GtkBuilder *gtkbuilder;
-
-               gchar *table;
-               GSList *fields;
-               GtkFormKey *key;
-               gchar quote;
-
-               GList *modules;
-               GdaEx *gdaex;
-
-               GSList *groups; /*GtkFormGroup */
-
-               GSList *db_connections; /* GtkFormDbConnection */
-
-               guint debug;
-               GFileOutputStream *log_file;
-       };
-
-G_DEFINE_TYPE (GtkForm, gtk_form, G_TYPE_OBJECT)
-
-static void
-gtk_form_class_init (GtkFormClass *class)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-       object_class->set_property = gtk_form_set_property;
-       object_class->get_property = gtk_form_get_property;
-
-       g_object_class_install_property (object_class, PROP_TABLE,
-                                        g_param_spec_string ("table",
-                                                             "Table name",
-                                                             "GtkForm's table name",
-                                                             "",
-                                                             G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_KEY,
-                                        g_param_spec_object ("key",
-                                                             "Key",
-                                                             "Key",
-                                                             TYPE_GTK_FORM_KEY,
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_QUOTE,
-                                        g_param_spec_char ("quote",
-                                                           "Quoting character",
-                                                           "Character to use to quote fields name",
-                                                           G_MININT8, G_MAXINT8, '"',
-                                                           G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_GDAEX,
-                                        g_param_spec_pointer ("gdaex",
-                                                              "GdaEx object",
-                                                              "GdaEx object",
-                                                              G_PARAM_READWRITE));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormPrivate));
-}
-
-static void
-gtk_form_init (GtkForm *form)
-{
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
-
-       priv->fields = NULL;
-       priv->key = NULL;
-       priv->gdaex = NULL;
-       priv->groups = NULL;
-       priv->db_connections = NULL;
-}
-
-/**
- * gtk_form_new:
- *
- * Returns: the newly created #GtkForm object.
- */
-GtkForm
-*gtk_form_new ()
-{
-       GtkForm *form;
-
-       form = GTK_FORM (g_object_new (gtk_form_get_type (), NULL));
-       if (form == NULL)
-               {
-                       return NULL;
-               }
-
-       setlocale (LC_ALL, "");
-       gda_locale_changed ();
-       bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-       textdomain (GETTEXT_PACKAGE);
-       bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-
-       if (g_module_supported ())
-               {
-                       gtk_form_load_modules (form);
-               }
-       else
-               {
-                       g_warning (_("Modules not supported by this operating system."));
-               }
-
-       return form;
-}
-
-/**
- * gtk_form_new_from_xml:
- * @xmldoc:
- * @gtkbuilder:
- *
- * Returns: the newly created #GtkForm object from an #xmlDoc that contains the
- * xml definition of the form.
- */
-GtkForm
-*gtk_form_new_from_xml (xmlDoc *xmldoc, GtkBuilder *gtkbuilder)
-{
-       GtkForm *form;
-
-       form = gtk_form_new ();
-
-       if (!gtk_form_load_from_xml (form, xmldoc, gtkbuilder))
-               {
-                       form = NULL;
-               }
-
-       return form;
-}
-
-/**
- * gtk_form_new_from_file:
- * @filename:
- * @gtkbuilder:
- *
- * Returns: the newly created #GtkForm object from a file that contains the
- * xml denifition of the form.
- */
-GtkForm
-*gtk_form_new_from_file (const gchar *filename, GtkBuilder *gtkbuilder)
-{
-       GtkForm *form;
-       xmlDoc *xdoc;
-
-       g_return_val_if_fail (filename != NULL, NULL);
-
-       form = NULL;
-
-       xdoc = xmlParseFile (filename);
-       if (xdoc != NULL)
-               {
-                       form = gtk_form_new_from_xml (xdoc, gtkbuilder);
-               }
-
-       return form;
-}
-
-static void
-gtkform_log_handler (const gchar *log_domain,
-                   GLogLevelFlags log_level,
-                   const gchar *message,
-                   gpointer user_data)
-{
-       GError *error;
-
-       gchar *msg;
-
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE ((GtkForm *)user_data);
-
-       msg = g_strdup_printf ("%s **: %s\n\n", log_domain, message);
-
-       if (g_output_stream_write (G_OUTPUT_STREAM (priv->log_file),
-           msg, strlen (msg), NULL, &error) < 0)
-               {
-                       g_warning (_("Error on writing on log file: %s"),
-                                  error != NULL && error->message != NULL ? error->message : "no details.");
-               }
-}
-
-static gboolean
-gtkform_post_parse_options (GOptionContext *context,
-                          GOptionGroup *group,
-                          gpointer user_data,
-                          GError **error)
-{
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE ((GtkForm *)user_data);
-
-       GError *my_error;
-
-       priv->debug = debug;
-       if (log_file == NULL)
-               {
-                       priv->log_file = 0;
-               }
-       else if (priv->debug > 0)
-               {
-                       gchar *filename = g_strstrip (g_strdup (log_file));
-                       if (g_ascii_strncasecmp (filename, "stdout", 6) == 0
-                           || g_ascii_strncasecmp (filename, "stderr", 6) == 0)
-                               {
-                               }
-                       else
-                               {
-                                       my_error = NULL;
-                                       priv->log_file = g_file_replace (g_file_new_for_path (filename),
-                                                                        NULL, FALSE, G_FILE_CREATE_NONE, NULL, &my_error);
-                                       if (priv->log_file == NULL)
-                                               {
-                                                       g_warning (_("Error on opening log file: %s."),
-                                                                  my_error != NULL && my_error->message != NULL ? my_error->message : "no details.");
-                                               }
-                                       else
-                                               {
-                                                       /* set handler */
-                                                       g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
-                                                                          | G_LOG_FLAG_RECURSION, gtkform_log_handler, user_data);
-                                               }
-                               }       
-               }
-
-       return TRUE;
-}
-
-/**
- * gtk_form_get_option_group:
- * #gtkform: a #GtkForm object.
- *
- * Returns: the #GOptionGroup.
- */
-GOptionGroup
-*gtk_form_get_option_group (GtkForm *gtkform)
-{
-       GOptionGroup *ret;
-
-       ret = g_option_group_new ("gtkform", "GtkForm", "GtkForm", (gpointer)gtkform, g_free);
-       if (ret != NULL)
-               {
-                       g_option_group_add_entries (ret, entries);
-                       g_option_group_set_parse_hooks (ret, NULL, gtkform_post_parse_options);
-               }
-
-       return ret;
-}
-
-static void
-parse_widget_on_change (GtkForm *form, xmlNodePtr xnode, GtkFormWidget *fwidget)
-{
-       gchar *what;
-       gchar *connection_name;
-       gchar *widget_name;
-       gchar *sql;
-
-       xmlNodePtr child;
-
-       what = (gchar *)xmlGetProp (xnode, (const xmlChar *)"what");
-
-       g_return_if_fail (what != NULL);
-
-       if (g_strcmp0 (what, "update") == 0)
-               {
-                       child = xnode->children;
-                       while (child != NULL)
-                               {
-                                       if (xmlStrcmp (child->name, (const xmlChar *)"widget-name") == 0)
-                                               {
-                                                       widget_name = (gchar *)xmlNodeGetContent (child);
-                                               }
-                                       else if (xmlStrcmp (child->name, (const xmlChar *)"connection-name") == 0)
-                                               {
-                                                       connection_name = (gchar *)xmlNodeGetContent (child);
-                                               }
-                                       else if (xmlStrcmp (child->name, (const xmlChar *)"sql") == 0)
-                                               {
-                                                       sql = (gchar *)xmlNodeGetContent (child);
-                                               }
-                                       
-                                       child = child->next;
-                               }
-
-                       if (sql != NULL && g_strcmp0 (g_strstrip (sql), "") != 0)
-                               {
-                                       GtkFormWidgetOnChangeOpUpdate *op = (GtkFormWidgetOnChangeOpUpdate *)g_malloc0 (sizeof (GtkFormWidgetOnChangeOpUpdate));
-                                       op->op.type = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE;
-                                       if (connection_name != NULL && g_strcmp0 (g_strstrip (connection_name), "") != 0)
-                                               {
-                                                       op->connection_name = g_strdup (connection_name);
-                                               }
-                                       if (widget_name != NULL && g_strcmp0 (g_strstrip (widget_name), "") != 0)
-                                               {
-                                                       op->form_widget_name = g_strdup (widget_name);
-                                               }
-                                       op->sql = g_strdup (sql);
-
-                                       gchar *when = (gchar *)xmlGetProp (xnode, (const xmlChar *)"when");
-                                       if (when == NULL)
-                                               {
-                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH;
-                                               }
-                                       else if (g_strcmp0 (when, "before") == 0)
-                                               {
-                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BEFORE;
-                                               }
-                                       else if (g_strcmp0 (when, "after") == 0)
-                                               {
-                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_AFTER;
-                                               }
-                                       else
-                                               {
-                                                       op->when = GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH;
-                                               }
-
-                                       gtk_form_widget_add_on_change_op (fwidget, (GtkFormWidgetOnChangeOp *)op);
-                               }
-               }
-}
-
-static void
-parse_group (GtkForm *form, xmlNodePtr xnode)
-{
-       xmlNodePtr child;
-       gchar *name;
-       GtkFormGroup *group;
-
-       gchar *ele_name;
-       GtkFormWidget *fwidget;
-       GtkFormField *field;
-
-       name = (gchar *)xmlGetProp (xnode, "name");
-
-       group = gtk_form_group_new (name);
-       gtk_form_add_group (form, group);
-
-       child = xnode->children;
-       while (child != NULL)
-               {
-                       if (xmlStrcmp (child->name, (const xmlChar *)"widget") == 0)
-                               {
-                                       ele_name = (gchar *)xmlNodeGetContent (child);
-                                       if (ele_name != NULL)
-                                               {
-                                                       fwidget = gtk_form_get_form_widget_from_name (form, g_strstrip (ele_name));
-                                                       if (fwidget != NULL)
-                                                               {
-                                                                       gtk_form_group_add_widget (group, fwidget);
-                                                               }
-                                               }
-                               }
-                       else if (xmlStrcmp (child->name, (const xmlChar *)"field") == 0)
-                               {
-                                       ele_name = (gchar *)xmlNodeGetContent (child);
-                                       if (ele_name != NULL)
-                                               {
-                                                       field = gtk_form_get_form_field_from_name (form, g_strstrip (ele_name));
-                                                       if (field != NULL)
-                                                               {
-                                                                       gtk_form_group_add_field (group, field);
-                                                               }
-                                               }
-                               }
-
-                       child = child->next;
-               }
-}
-
-static void
-parse_db_connection (GtkForm *form, xmlNodePtr xnode)
-{
-       xmlNodePtr child;
-       gchar *name;
-       gchar *cnc_string;
-
-       name = (gchar *)xmlGetProp (xnode, "name");
-
-       child = xnode->children;
-       while (child != NULL)
-               {
-                       if (xmlStrcmp (child->name, (const xmlChar *)"connection-string") == 0)
-                               {
-                                       cnc_string = (gchar *)xmlNodeGetContent (child);
-                                       break;
-                               }
-
-                       child = child->next;
-               }
-
-       if (g_strcmp0 (g_strstrip (name), "") != 0
-           && g_strcmp0 (g_strstrip (cnc_string), "") != 0)
-               {
-                       gtk_form_add_db_connection (form, name, cnc_string);
-               }
-}
-
-/**
- * gtk_form_load_from_xml:
- * @form:
- * @xmldoc:
- * @gtkbuilder:
- *
- */
-gboolean
-gtk_form_load_from_xml (GtkForm *form, xmlDoc *xmldoc, GtkBuilder *gtkbuilder)
-{
-       GtkFormPrivate *priv;
-       xmlNode *cur;
-
-       gboolean ret;
-
-       GList *modules;
-       FormWidgetConstructorFunc widget_constructor;
-       FormWidgetXmlParsingFunc widget_xml_parsing;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (xmldoc != NULL, FALSE);
-
-       ret = FALSE;
-
-       cur = xmlDocGetRootElement (xmldoc);
-       if (cur != NULL)
-               {
-                       if (xmlStrcmp (cur->name, (const xmlChar *)"gtkform") == 0)
-                               {
-                                       gchar *type;
-                                       gchar *name;
-                                       gchar *label;
-
-                                       GtkFormWidget *widget;
-                                       xmlNode *node_widget;
-
-                                       GtkFormField *field;
-                                       xmlNode *node_field;
-
-                                       ret = TRUE;
-
-                                       priv = GTK_FORM_GET_PRIVATE (form);
-
-                                       if (GTK_IS_BUILDER (gtkbuilder))
-                                               {
-                                                       priv->gtkbuilder = gtkbuilder;
-                                               }
-                                       else
-                                               {
-                                                       priv->gtkbuilder = NULL;
-                                               }
-
-                                       /* search gtkguilder-file node */
-                                       if (!GTK_IS_BUILDER (priv->gtkbuilder))
-                                               {
-                                                       xmlXPathContextPtr xpcontext;
-                                                       xmlXPathObjectPtr xpresult;
-                                                       xmlNodeSetPtr xnodeset;
-
-                                                       xpcontext = xmlXPathNewContext (xmldoc);
-
-                                                       xpcontext->node = cur;
-                                                       xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::gtkbuilder-file", xpcontext);
-                                                       if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
-                                                               {
-                                                                       xnodeset = xpresult->nodesetval;
-                                                                       if (xnodeset->nodeNr == 1)
-                                                                               {
-                                                                                       GError *error;
-                                                                                       gchar *filename;
-
-                                                                                       filename = (gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]);
-
-                                                                                       priv->gtkbuilder = gtk_builder_new ();
-
-                                                                                       error = NULL;
-                                                                                       if (gtk_builder_add_from_file (priv->gtkbuilder, filename, &error) <= 0)
-                                                                                               {
-                                                                                                       priv->gtkbuilder = NULL;
-                                                                                                       g_warning (_("Error on loading GtkBuilder file: %s\n"),
-                                                                                                                  error->message);
-                                                                                               }
-                                                                               }
-                                                               }
-                                               }
-
-                                       cur = cur->children;
-                                       while (cur)
-                                               {
-                                                       if (xmlStrcmp (cur->name, (const xmlChar *)"table") == 0)
-                                                               {
-                                                                       gtk_form_set_table (form, (gchar *)xmlNodeGetContent (cur));
-                                                               }
-                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"widget") == 0)
-                                                               {
-                                                                       widget = NULL;
-                                                                       modules = NULL;
-
-                                                                       type = xmlGetProp (cur, (const xmlChar *)"type");
-                                                                       if (g_strcmp0 (type, "checkbox") == 0)
-                                                                               {
-                                                                                       widget = gtk_form_widget_check_new ();
-                                                                               }
-                                                                       else if (g_strcmp0 (type, "combobox") == 0)
-                                                                               {
-                                                                                       widget = gtk_form_widget_combo_box_new ();
-                                                                               }
-                                                                       else if (g_strcmp0 (type, "entry") == 0)
-                                                                               {
-                                                                                       widget = gtk_form_widget_entry_new ();
-                                                                               }
-                                                                       else if (g_strcmp0 (type, "label") == 0)
-                                                                               {
-                                                                                       widget = gtk_form_widget_label_new ();
-                                                                               }
-                                                                       else if (g_strcmp0 (type, "radio") == 0)
-                                                                               {
-                                                                                       widget = gtk_form_widget_radio_new ();
-                                                                               }
-                                                                       else if (g_strcmp0 (type, "spin") == 0)
-                                                                               {
-                                                                                       widget = gtk_form_widget_spin_new ();
-                                                                               }
-                                                                       else if (g_strcmp0 (type, "textview") == 0)
-                                                                               {
-                                                                                       widget = gtk_form_widget_textview_new ();
-                                                                               }
-                                                                       else
-                                                                               {
-                                                                                       /* trying in modules */
-                                                                                       modules = g_list_first (priv->modules);
-                                                                                       while (modules != NULL)
-                                                                                               {
-                                                                                                       if (g_module_symbol ((GModule *)modules->data,
-                                                                                                                                g_strconcat ("gtk_form_widget_", type, "_new", NULL),
-                                                                                                                                (gpointer *)&widget_constructor))
-                                                                                                               {
-                                                                                                                       if (widget_constructor != NULL)
-                                                                                                                               {
-                                                                                                                                       widget = widget_constructor ();
-                                                                                                                                       break;
-                                                                                                                               }
-                                                                                                               }
-
-                                                                                                       modules = g_list_next (modules);
-                                                                                               }
-
-                                                                                       if (widget == NULL)
-                                                                                               {
-                                                                                                       g_warning (_("Unknown type Â«%s»."), type);
-                                                                                                       modules = NULL;
-                                                                                               }
-                                                                               }
-
-                                                                       if (widget != NULL)
-                                                                               {
-                                                                                       g_object_set (G_OBJECT (widget), "form", form, NULL);
-
-                                                                                       name = xmlGetProp (cur, (const xmlChar *)"name");
-
-                                                                                       if (GTK_IS_BUILDER (priv->gtkbuilder))
-                                                                                               {
-                                                                                                       gtk_form_widget_set_from_gtkbuilder (widget, priv->gtkbuilder, name);
-
-                                                                                                       label = xmlGetProp (cur, (const xmlChar *)"label");
-                                                                                                       if (label != NULL && g_strcmp0 (g_strstrip (label), "") != 0)
-                                                                                                               {
-                                                                                                                       GtkWidget *wlabel;
-                                                                                                                       wlabel = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, label));
-                                                                                                                       if (GTK_IS_LABEL (wlabel))
-                                                                                                                               {
-                                                                                                                                       gtk_form_widget_set_label (widget, wlabel);
-                                                                                                                               }
-                                                                                                                       else if ((g_strcmp0 (type, "checkbox") == 0
-                                                                                                                                 || g_strcmp0 (type, "radio") == 0)
-                                                                                                                                && g_strcmp0 (label, name) == 0)
-                                                                                                                               {
-                                                                                                                                       gtk_form_widget_set_label (widget, wlabel);
-                                                                                                                               }
-                                                                                                                       else
-                                                                                                                               {
-                                                                                                                                       g_warning (_("Label Â«%s» not found."), label);
-                                                                                                                               }
-                                                                                                               }
-                                                                                               }
-
-                                                                                       node_widget = cur->children;
-                                                                                       while (node_widget != NULL)
-                                                                                               {
-                                                                                                       if (xmlStrcmp (node_widget->name, (const xmlChar *)"column-field") == 0
-                                                                                                                        && IS_GTK_FORM_WIDGET_COMBO_BOX (widget))
-                                                                                                               {
-                                                                                                                       g_object_set (G_OBJECT (widget), "column-field",
-                                                                                                                                     strtol ((gchar *)xmlNodeGetContent (node_widget), NULL, 10), NULL);
-                                                                                                               }
-                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"sql") == 0
-                                                                                                                        && IS_GTK_FORM_WIDGET_COMBO_BOX (widget) && IS_GDAEX (priv->gdaex))
-                                                                                                               {
-                                                                                                                       gtk_form_widget_combo_box_fill_from_sql (widget,
-                                                                                                                                     priv->gdaex,
-                                                                                                                                     (gchar *)xmlNodeGetContent (node_widget),
-                                                                                                                                     gtk_form_field_boolean_str_to_boolean (xmlGetProp (node_widget, "with-empty-entry")));
-                                                                                                               }
-                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"return-value") == 0
-                                                                                                                        && IS_GTK_FORM_WIDGET_RADIO (widget))
-                                                                                                               {
-                                                                                                                       g_object_set (G_OBJECT (widget), "return-value",
-                                                                                                                                     xmlNodeGetContent (node_widget), NULL);
-                                                                                                               }
-                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"on-change") == 0)
-                                                                                                               {
-                                                                                                                       parse_widget_on_change (form, node_widget, widget);
-                                                                                                               }
-                                                                                                       else if (xmlStrcmp (node_widget->name, (const xmlChar *)"field") == 0)
-                                                                                                               {
-                                                                                                                       field = NULL;
-
-                                                                                                                       type = xmlGetProp (node_widget, (const xmlChar *)"type");
-                                                                                                                       if (g_strcmp0 (type, "boolean") == 0)
-                                                                                                                               {
-                                                                                                                                       field = gtk_form_field_boolean_new ();
-                                                                                                                               }
-                                                                                                                       else if (g_strcmp0 (type, "datetime") == 0)
-                                                                                                                               {
-                                                                                                                                       field = gtk_form_field_datetime_new ();
-                                                                                                                               }
-                                                                                                                       else if (g_strcmp0 (type, "float") == 0)
-                                                                                                                               {
-                                                                                                                                       field = gtk_form_field_float_new ();
-                                                                                                                               }
-                                                                                                                       else if (g_strcmp0 (type, "integer") == 0)
-                                                                                                                               {
-                                                                                                                                       field = gtk_form_field_integer_new ();
-                                                                                                                               }
-                                                                                                                       else if (g_strcmp0 (type, "text") == 0)
-                                                                                                                               {
-                                                                                                                                       field = gtk_form_field_text_new ();
-                                                                                                                               }
-
-                                                                                                                       if (field != NULL)
-                                                                                                                               {
-                                                                                                                                       gchar *prop;
-
-                                                                                                                                       gtk_form_add_field (form, field);
-
-                                                                                                                                       name = xmlGetProp (node_widget, (const xmlChar *)"name");
-                                                                                                                                       g_object_set (G_OBJECT (field),
-                                                                                                                                                    "field", name,
-                                                                                                                                                    "form-widget", widget,
-                                                                                                                                                    NULL);
-
-                                                                                                                                       node_field = node_widget->children;
-                                                                                                                                       while (node_field != NULL)
-                                                                                                                                               {
-                                                                                                                                                       prop = (gchar *)xmlNodeGetContent (node_field);
-                                                                                                                                                       if (xmlStrcmp (node_field->name, (const xmlChar *)"long-name") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field),
-                                                                                                                                                                                     "long-name", prop,
-                                                                                                                                                                                     NULL);
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"to-load") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field),
-                                                                                                                                                                                     "to-load", gtk_form_field_boolean_str_to_boolean (prop),
-                                                                                                                                                                                     NULL);
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"to-save") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field),
-                                                                                                                                                                                     "to-save", gtk_form_field_boolean_str_to_boolean (prop),
-                                                                                                                                                                                     NULL);
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"obligatory") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field),
-                                                                                                                                                                                     "obligatory", gtk_form_field_boolean_str_to_boolean (prop),
-                                                                                                                                                                                     NULL);
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"default") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       if (g_strcmp0 (type, "boolean") == 0)
-                                                                                                                                                                               {
-                                                                                                                                                                                       gboolean value = gtk_form_field_boolean_str_to_boolean (prop);
-                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", value, NULL);
-                                                                                                                                                                               }
-                                                                                                                                                                       else if (g_strcmp0 (type, "datetime") == 0)
-                                                                                                                                                                               {
-                                                                                                                                                                                       struct tm *datetime;
-
-                                                                                                                                                                                       if (g_strcmp0 (prop, "now") == 0)
-                                                                                                                                                                                               {
-                                                                                                                                                                                                       time_t time_now;
-
-                                                                                                                                                                                                       time (&time_now);
-                                                                                                                                                                                                       datetime = localtime (&time_now);
-                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", datetime, NULL);
-                                                                                                                                                                                               }
-                                                                                                                                                                                       else
-                                                                                                                                                                                               {
-                                                                                                                                                                                                       datetime = gtk_form_field_datetime_get_tm_from_str (prop, "%Y-%m-%d %H:%M:%S");
-                                                                                                                                                                                                       if (datetime != NULL)
-                                                                                                                                                                                                               {
-                                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", datetime, NULL);
-                                                                                                                                                                                                               }
-                                                                                                                                                                                               }
-                                                                                                                                                                               }
-                                                                                                                                                                       else if (g_strcmp0 (type, "float") == 0)
-                                                                                                                                                                               {
-                                                                                                                                                                                       gfloat value = g_strtod (prop, NULL);
-                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", value, NULL);
-                                                                                                                                                                               }
-                                                                                                                                                                       else if (g_strcmp0 (type, "integer") == 0)
-                                                                                                                                                                               {
-                                                                                                                                                                                       gint value = strtol (prop, NULL, 10);
-                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", value, NULL);
-                                                                                                                                                                               }
-                                                                                                                                                                       else if (g_strcmp0 (type, "text") == 0)
-                                                                                                                                                                               {
-                                                                                                                                                                                       g_object_set (G_OBJECT (field), "default", prop, NULL);
-                                                                                                                                                                               }
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"is-key") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       if (gtk_form_field_boolean_str_to_boolean (prop))
-                                                                                                                                                                               {
-                                                                                                                                                                                       if (!IS_GTK_FORM_KEY (priv->key))
-                                                                                                                                                                                               {
-                                                                                                                                                                                                       priv->key = gtk_form_key_new ();
-                                                                                                                                                                                               }
-
-                                                                                                                                                                                       gtk_form_key_add_field (priv->key, field);
-                                                                                                                                                                               }
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"auto-increment") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       if (gtk_form_field_boolean_str_to_boolean (prop))
-                                                                                                                                                                               {
-                                                                                                                                                                                       g_object_set (G_OBJECT (field), "auto-increment", TRUE, NULL);
-                                                                                                                                                                               }
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"datetime-type") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       if (g_strcmp0 (type, "datetime") == 0)
-                                                                                                                                                                               {
-                                                                                                                                                                                       if (g_strcmp0 (prop, "date") == 0)
-                                                                                                                                                                                               {
-                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "type", GTK_FORM_FIELD_DATETIME_TYPE_DATE, NULL);
-                                                                                                                                                                                               
-                                                                                                                                                                                               }
-                                                                                                                                                                                       else if (g_strcmp0 (prop, "time") == 0)
-                                                                                                                                                                                               {
-                                                                                                                                                                                                       g_object_set (G_OBJECT (field), "type", GTK_FORM_FIELD_DATETIME_TYPE_TIME, NULL);
-                                                                                                                                                                                               
-                                                                                                                                                                                               }
-                                                                                                                                                                               }
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"display-format") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       if (g_strcmp0 (type, "datetime") == 0)
-                                                                                                                                                                               {
-                                                                                                                                                                                       g_object_set (G_OBJECT (field), "display-format", prop, NULL);
-                                                                                                                                                                               }
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"trim") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field),
-                                                                                                                                                                                     "trim", gtk_form_field_boolean_str_to_boolean (prop),
-                                                                                                                                                                                     NULL);
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"min-value") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field), "min-value", prop, NULL);
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"max-value") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field), "max-value", prop, NULL);
-                                                                                                                                                               }
-                                                                                                                                                       else if (xmlStrcmp (node_field->name, (const xmlChar *)"decimals") == 0
-                                                                                                                                                                && g_strcmp0 (type, "float") == 0)
-                                                                                                                                                               {
-                                                                                                                                                                       g_object_set (G_OBJECT (field), "decimals", strtol (prop, NULL, 10), NULL);
-                                                                                                                                                               }
-
-                                                                                                                                                       node_field = node_field->next;
-                                                                                                                                               }
-                                                                                                                               }
-                                                                                                                       else
-                                                                                                                               {
-                                                                                                                                       g_warning (_("Field of type Â«%s» not found."), type);
-                                                                                                                               }
-                                                                                                               }
-                                                                                                       else
-                                                                                                               {
-                                                                                                                       /* if the widget is a plugin,
-                                                                                                                          try to make xml parsing by the plugin */
-                                                                                                                       if (modules != NULL)
-                                                                                                                               {
-                                                                                                                                       if (g_module_symbol ((GModule *)modules->data,
-                                                                                                                                                                g_strconcat ("gtk_form_widget_", type, "_xml_parsing", NULL),
-                                                                                                                                                                                (gpointer *)&widget_xml_parsing))
-                                                                                                                                               {
-                                                                                                                                                       if (widget_xml_parsing != NULL)
-                                                                                                                                                               {
-                                                                                                                                                                       widget_xml_parsing (widget, node_widget);
-                                                                                                                                                               }
-                                                                                                                                               }
-                                                                                                                               }
-                                                                                                               }
-
-                                                                                                       node_widget = node_widget->next;
-                                                                                               }
-                                                                               }
-                                                                       else
-                                                                               {
-                                                                                       g_warning (_("Widget of type Â«%s» not found."), type);
-                                                                               }
-                                                               }
-                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"group") == 0)
-                                                               {
-                                                                       parse_group (form, cur);
-                                                               }
-                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"db-connection") == 0)
-                                                               {
-                                                                       parse_db_connection (form, cur);
-                                                               }
-
-                                                       cur = cur->next;
-                                               }
-                               }
-                       else
-                               {
-                                       /* TO DO */
-                                       g_warning (_("The file is not a valid gtkform definition file."));
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_load_from_file:
- * @form:
- * @filename:
- * @gtkbuilder:
- *
- */
-gboolean
-gtk_form_load_from_file (GtkForm *form, const gchar *filename, GtkBuilder *gtkbuilder)
-{
-       xmlDoc *xdoc;
-
-       gboolean ret;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (filename != NULL, FALSE);
-
-       ret = FALSE;
-
-       xdoc = xmlParseFile (filename);
-       if (xdoc != NULL)
-               {
-                       ret = gtk_form_load_from_xml (form, xdoc, gtkbuilder);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_get_gtkbuilder:
- * @form: a #GtkForm object.
- *
- */
-GtkBuilder
-*gtk_form_get_gtkbuilder (GtkForm *form)
-{
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       return priv->gtkbuilder;
-}
-
-/**
- * gtk_form_get_table:
- * @form: a #GtkForm object.
- *
- * Returns: the table's name associated to the form. Must be freed.
- */
-gchar
-*gtk_form_get_table (GtkForm *form)
-{
-       gchar *ret;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), "");
-
-       ret = g_strdup ("");
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       ret = g_strdup (priv->table);
-
-       return ret;
-}
-
-/**
- * gtk_form_set_table:
- * @form: a #GtkForm object.
- * @table:
- *
- */
-void
-gtk_form_set_table (GtkForm *form, const gchar *table)
-{
-       GtkFormPrivate *priv;
-
-       g_return_if_fail (IS_GTK_FORM (form));
-       g_return_if_fail (table != NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       priv->table = g_strstrip (g_strdup (table));
-}
-
-/**
- * gtk_form_get_key:
- * @form: a #GtkForm object.
- *
- * Returns: the #GtkFormKey associated to the form.
- */
-GtkFormKey
-*gtk_form_get_key (GtkForm *form)
-{
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       return priv->key;
-}
-
-/**
- * gtk_form_set_key:
- * @form: a #GtkForm object.
- * @key:
- *
- */
-void
-gtk_form_set_key (GtkForm *form, GtkFormKey *key)
-{
-       GtkFormPrivate *priv;
-
-       g_return_if_fail (IS_GTK_FORM (form));
-       g_return_if_fail (IS_GTK_FORM_KEY (key));
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       priv->key = key;
-}
-
-/**
- * gtk_form_add_field:
- * @form: a #GtkForm object.
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_add_field (GtkForm *form, GtkFormField *field)
-{
-       gboolean ret;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       ret = FALSE;
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       priv->fields = g_slist_append (priv->fields, field);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_remove_field:
- * @form: a #GtkForm object.
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_remove_field (GtkForm *form, GtkFormField *field)
-{
-       gboolean ret = FALSE;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       priv->fields = g_slist_remove (priv->fields, field);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_add_fields:
- * @form: a #GtkForm object.
- * @...: a NULL terminated list of #GtkFormFields to add.
- *
- */
-gboolean
-gtk_form_add_fields (GtkForm *form, ...)
-{
-       GtkFormField *field;
-
-       va_list vargs;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-
-       va_start (vargs, form);
-
-       while ((field = va_arg (vargs, GtkFormField *)) != NULL)
-               {
-                       gtk_form_add_field (form, field);
-               }
-
-       va_end (vargs);
-}
-
-/**
- * gtk_form_get_form_field_from_name:
- * @form: a #GtkForm object.
- * @field_name:
- *
- */
-GtkFormField
-*gtk_form_get_form_field_from_name (GtkForm *form, const gchar *field_name)
-{
-       GtkFormField *field = NULL;
-       const gchar *name;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-       g_return_val_if_fail (field_name != NULL, NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       GSList *fields = priv->fields;
-       while (fields != NULL)
-               {
-                       name = gtk_form_field_get_field_name ((GtkFormField *)fields->data);
-                       if (g_strcmp0 (name, field_name) == 0)
-                               {
-                                       field = (GtkFormField *)fields->data;
-                                       break;
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return field;
-}
-
-/**
- * gtk_form_get_form_widget_from_name:
- * @form: a #GtkForm object.
- * @widget_name: the #GtkFormWidget's name to return.
- *
- * Returns: a #GtkFormWidget.
- */
-GtkFormWidget
-*gtk_form_get_form_widget_from_name (GtkForm *form, const gchar *widget_name)
-{
-       GtkFormWidget *widget = NULL;
-       GtkFormWidget *widget_ret = NULL;
-       gchar *name;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-       g_return_val_if_fail (widget_name != NULL, NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       GSList *fields = priv->fields;
-       while (fields != NULL)
-               {
-                       widget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
-
-                       if (g_strcmp0 (gtk_form_widget_get_widget_name (widget), widget_name) == 0)
-                               {
-                                       widget_ret = widget;
-                                       break;
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return widget_ret;
-}
-
-/**
- * gtk_form_get_widget_from_form_field_name:
- * @form: a #GtkForm object.
- * @field_name: the #GtkFormField's name to return.
- *
- * Returns: a #GtkWidget.
- */
-GtkWidget
-*gtk_form_get_widget_from_form_field_name (GtkForm *form, const gchar *field_name)
-{
-       GtkFormField *field = NULL;
-       GtkFormWidget *widget = NULL;
-       GtkWidget *widget_ret = NULL;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-       g_return_val_if_fail (field_name != NULL, NULL);
-
-       field = gtk_form_get_form_field_from_name (form, field_name);
-       if (field != NULL)
-               {
-                       widget = gtk_form_field_get_form_widget (field);
-                       if (widget != NULL)
-                               {
-                                       widget_ret = gtk_form_widget_get_widget (widget);
-                               }
-               }
-
-       return widget_ret;
-}
-
-/**
- * gtk_form_get_widget_from_form_widget_name:
- * @form: a #GtkForm object.
- * @widget_name: the #GtkFormWidget's name to return.
- *
- * Returns: a #GtkWidget.
- */
-GtkWidget
-*gtk_form_get_widget_from_form_widget_name (GtkForm *form, const gchar *widget_name)
-{
-       GtkFormWidget *widget = NULL;
-       GtkWidget *widget_ret = NULL;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-       g_return_val_if_fail (widget_name != NULL, NULL);
-
-       widget = gtk_form_get_form_widget_from_name (form, widget_name);
-       if (widget != NULL)
-               {
-                       widget_ret = gtk_form_widget_get_widget (widget);
-               }
-
-       return widget_ret;
-}
-
-/**
- * gtk_form_get_form_field_from_widget:
- * @form: a #GtkForm object.
- * @widget: a #GtkWidget object.
- *
- */
-GtkFormField
-*gtk_form_get_form_field_from_widget (GtkForm *form, GtkWidget *widget)
-{
-       GtkFormWidget *fwidget = NULL;
-       GtkFormField *field = NULL;
-       GtkFormWidget *widget_ret = NULL;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-       g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       GSList *fields = priv->fields;
-       while (fields != NULL)
-               {
-                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
-
-                       if (gtk_form_widget_get_widget (fwidget) == widget)
-                               {
-                                       field = (GtkFormField *)fields->data;
-                                       break;
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return field;
-}
-
-/**
- * gtk_form_get_form_widget_from_widget:
- * @form: a #GtkForm object.
- * @widget: a #GtkWidget object.
- *
- */
-GtkFormWidget
-*gtk_form_get_form_widget_from_widget (GtkForm *form, GtkWidget *widget)
-{
-       GtkFormWidget *fwidget = NULL;
-       GtkFormWidget *widget_ret = NULL;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-       g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       GSList *fields = priv->fields;
-       while (fields != NULL)
-               {
-                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
-
-                       if (gtk_form_widget_get_widget (fwidget) == widget)
-                               {
-                                       widget_ret = fwidget;
-                                       break;
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return widget_ret;
-}
-
-/**
- * gtk_form_get_widgets:
- * @form: a #GtkForm object.
- *
- * Returns: an array of all the #GtkWidget into the form. Must be free.
- */ 
-GtkWidget
-**gtk_form_get_widgets (GtkForm *form)
-{
-       GtkFormPrivate *priv;
-
-       GtkWidget **ret;
-
-       GSList *fields;
-       guint l;
-
-       GtkFormWidget *form_widget;
-       GtkWidget *widget;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       ret = NULL;
-       l = 0;
-
-       fields = priv->fields;
-       while (fields != NULL)
-               {
-                       l++;
-                       if (l == 1)
-                               {
-                                       ret = g_malloc (sizeof (GtkWidget *));
-                               }
-                       else
-                               {
-                                       ret = g_realloc (ret, l * sizeof (GtkWidget *));
-                               }
-
-                       form_widget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
-                       widget = gtk_form_widget_get_widget (form_widget);
-                       ret[l] = widget;
-
-                       fields = g_slist_next (fields);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_get_objects_by_name:
- * @form: a #GtkForm object.
- * @...: a NULL terminated list of objects name (gchar *) to return.
- *
- * Returns: an array of #GObject present in the #GtkBuilder object assigned to
- * the form. Must be free.
- */
-GObject
-**gtk_form_get_objects_by_name (GtkForm *form, ...)
-{
-       GObject **ret;
-
-       GtkFormPrivate *priv;
-
-       va_list vargs;
-       gchar *object_name;
-       guint l;
-
-       GObject *object;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       g_return_val_if_fail (GTK_IS_BUILDER (priv->gtkbuilder), NULL);
-
-       ret = NULL;
-       l = 0;
-
-       va_start (vargs, form);
-
-       while ((object_name = va_arg (vargs, gchar *)) != NULL)
-               {
-                       l++;
-                       if (l == 1)
-                               {
-                                       ret = g_malloc (sizeof (GObject *));
-                               }
-                       else
-                               {
-                                       ret = g_realloc (ret, l * sizeof (GObject *));
-                               }
-
-                       object = gtk_builder_get_object (priv->gtkbuilder, object_name);
-                       if (G_IS_OBJECT (object))
-                               {
-                                       ret[l - 1] = object;
-                               }
-                       else
-                               {
-                                       ret[l - 1] = NULL;
-                                       g_warning (_("Object Â«%s» not found."), object_name);
-                               }
-               }
-
-       va_end (vargs);
-
-       return ret;
-}
-
-/**
- * gtk_form_clear:
- * @form: a #GtkForm object.
- *
- */
-gboolean
-gtk_form_clear (GtkForm *form)
-{
-       GtkFormField *field;
-       gboolean ret = FALSE;
-       GtkFormPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       GSList *fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       gtk_form_field_clear (field);
-
-                       fields = g_slist_next (fields);
-               }
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_check:
- * @form: a #GtkForm object.
- * @with_key: whether check also the key or not.
- * @form_widget: a #GtkFormWidget.
- * @show_error_dialog:
- * @parent_window:
- * @set_focus:
- *
- * Returns: TRUE if all obligatory fields are full and @widget is NULL. Otherwise
- * if @widget isn't NULL, it is the first #GtkFormWidget empty.
- */
-gboolean
-gtk_form_check (GtkForm *form, gboolean with_key, GtkFormWidget **form_widget,
-                gboolean show_error_dialog, GtkWidget *parent_window,
-                gboolean set_focus)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       GtkFormField *field;
-       GtkFormWidget *fwidget;
-       GtkWidget *widget;
-
-       gboolean ret;
-       gboolean to_save;
-       gboolean obl;
-       gboolean is_empty;
-       gboolean is_valid;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-
-       if (show_error_dialog)
-               {
-                       g_return_val_if_fail (GTK_IS_WINDOW (parent_window), FALSE);
-               }
-
-       ret = TRUE;
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       g_object_get (G_OBJECT (field),
-                                     "to-save", &to_save,
-                                     "obligatory", &obl,
-                                     NULL);
-
-                       is_empty = gtk_form_field_is_empty (field);
-                       is_valid = gtk_form_field_is_valid (field);
-                       if (to_save
-                           && ((obl && is_empty) || !is_valid))
-                               {
-                                       ret = FALSE;
-
-                                       fwidget = gtk_form_field_get_form_widget (field);
-                                       widget = gtk_form_widget_get_widget (fwidget);
-
-                                       if (form_widget != NULL && *form_widget == NULL)
-                                               {
-                                                       *form_widget = fwidget;
-                                               }
-
-                                       if (show_error_dialog)
-                                               {
-                                                       gtk_form_show_check_error_dialog (fwidget, parent_window,
-                                                                                         obl && is_empty ? _(" is obligatory") : _(" isn't valid"));
-                                               }
-
-                                       if (set_focus)
-                                               {
-                                                       gtk_widget_grab_focus (widget);
-                                               }
-                                       break;
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       if (with_key && ret && IS_GTK_FORM_KEY (priv->key))
-               {
-                       GtkFormWidget *key_form_widget = NULL;
-
-                       ret = gtk_form_key_check (priv->key, &key_form_widget);
-
-                       if (!ret && form_widget != NULL && *form_widget == NULL && key_form_widget != NULL)
-                               {
-                                       *form_widget = key_form_widget;
-                               }
-
-                       if (!ret && key_form_widget != NULL && show_error_dialog)
-                               {
-                                       gtk_form_show_check_error_dialog (key_form_widget, parent_window, _(" is obligatory"));
-                               }
-
-                       if (!ret && key_form_widget != NULL && set_focus)
-                               {
-                                       gtk_widget_grab_focus (gtk_form_widget_get_widget (key_form_widget));
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_is_changed:
- * @form: a #GtkForm object.
- *
- * Returns: TRUE if the values in the form are changed since last calling to
- * gtk_form_clear(), gtk_form_fill_from_datamodel() or gtk_form_set_as_origin().
- */
-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;
-
-                       if (gtk_form_field_is_to_save (field))
-                               {
-                                       ret = gtk_form_field_is_changed (field);
-                                       if (ret)
-                                               {
-                                                       if (priv->debug > 0)
-                                                               {
-                                                                       g_debug (_("Field Â«%s» is changed."), gtk_form_field_get_field_name (field));
-                                                               }
-                                                       break;
-                                               }
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       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.
- * @sensitive: whether to set every #GtkFormWidget's sensitive or not.
- *
- */
-void
-gtk_form_set_sensitive (GtkForm *form, gboolean sensitive)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       GtkFormWidget *fwidget;
-       GtkWidget *widget;
-
-       g_return_if_fail (IS_GTK_FORM (form));
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-       while (fields != NULL)
-               {
-                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
-
-                       widget = gtk_form_widget_get_widget (fwidget);
-                       gtk_widget_set_sensitive (widget, sensitive);
-
-                       fields = g_slist_next (fields);
-               }
-}
-
-/**
- * gtk_form_set_sensitive_by_name:
- * @form: a #GtkForm object.
- * @sensitive: whether to set #GtkWidget's sensitive or not.
- * @...:
- *
- */
-void
-gtk_form_set_sensitive_by_name (GtkForm *form, gboolean sensitive, ...)
-{
-       GtkFormPrivate *priv;
-
-       va_list vargs;
-       gchar *object_name;
-
-       GObject *object;
-
-       g_return_if_fail (IS_GTK_FORM (form));
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       g_return_if_fail (GTK_IS_BUILDER (priv->gtkbuilder));
-
-       va_start (vargs, sensitive);
-
-       while ((object_name = va_arg (vargs, gchar *)) != NULL)
-               {
-                       object = gtk_builder_get_object (priv->gtkbuilder, object_name);
-                       if (GTK_IS_WIDGET (object))
-                               {
-                                       gtk_widget_set_sensitive (GTK_WIDGET (object), sensitive);
-                               }
-                       else
-                               {
-                                       g_warning (_("Object Â«%s» not found."), object_name);
-                               }
-               }
-
-       va_end (vargs);
-}
-
-/**
- * gtk_form_set_editable:
- * @form: a #GtkForm object.
- * @editable: whether to set every #GtkFormWidget editable or not.
- *
- */
-void
-gtk_form_set_editable (GtkForm *form, gboolean editable)
-{
-       GtkFormWidget *fwidget;
-       GtkFormPrivate *priv;
-       GSList *fields;
-
-       g_return_if_fail (IS_GTK_FORM (form));
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-       while (fields != NULL)
-               {
-                       fwidget = gtk_form_field_get_form_widget ((GtkFormField *)fields->data);
-
-                       gtk_form_widget_set_editable (fwidget, editable);
-
-                       fields = g_slist_next (fields);
-               }
-}
-
-/**
- * gtk_form_set_visible_by_name:
- * @form: a #GtkForm object.
- * @visible: whether to set #GtkWidget's sensitive or not.
- * @...: a #NULL terminated list of #GtkWidgets's names (on #GtkBuilder).
- *
- */
-void
-gtk_form_set_visible_by_name (GtkForm *form, gboolean visible, ...)
-{
-       GtkFormPrivate *priv;
-
-       va_list vargs;
-       gchar *widget_name;
-
-       GObject *widget;
-
-       g_return_if_fail (IS_GTK_FORM (form));
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       g_return_if_fail (GTK_IS_BUILDER (priv->gtkbuilder));
-
-       va_start (vargs, visible);
-
-       while ((widget_name = va_arg (vargs, gchar *)) != NULL)
-               {
-                       widget = gtk_builder_get_object (priv->gtkbuilder, widget_name);
-                       if (GTK_IS_WIDGET (widget))
-                               {
-                                       if (visible)
-                                               {
-                                                       gtk_widget_show (GTK_WIDGET (widget));
-                                               }
-                                       else
-                                               {
-                                                       gtk_widget_hide (GTK_WIDGET (widget));
-                                               }
-                               }
-                       else
-                               {
-                                       g_warning (_("Object Â«%s» not found."), widget_name);
-                               }
-               }
-
-       va_end (vargs);
-}
-
-/**
- * gtk_form_set_form_widgets_visible_by_name:
- * @form: a #GtkForm object.
- * @visible: whether to set every #GtkFormWidget visible or not.
- * @...: a #NULL terminated list of #GtkFormWidgets's names.
- *
- */
-void
-gtk_form_set_form_widgets_visible_by_name (GtkForm *form, gboolean visible, ...)
-{
-       GtkFormPrivate *priv;
-
-       va_list vargs;
-       gchar *fwidget_name;
-
-       GtkFormWidget *fwidget;
-
-       g_return_if_fail (IS_GTK_FORM (form));
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       g_return_if_fail (GTK_IS_BUILDER (priv->gtkbuilder));
-
-       va_start (vargs, visible);
-
-       while ((fwidget_name = va_arg (vargs, gchar *)) != NULL)
-               {
-                       fwidget = gtk_form_get_form_widget_from_name (form, fwidget_name);
-                       if (IS_GTK_FORM_WIDGET (fwidget))
-                               {
-                                       gtk_form_widget_set_visible (fwidget, visible);
-                               }
-                       else
-                               {
-                                       g_warning (_("Object Â«%s» not found."), fwidget_name);
-                               }
-               }
-
-       va_end (vargs);
-}
-
-/**
- * gtk_form_get_form_field_value_by_name:
- * @form: a #GtkForm object.
- * @field_name:
- *
- */
-GValue
-*gtk_form_get_form_field_value_by_name (GtkForm *form, const gchar *field_name)
-{
-       GValue *ret;
-       GtkFormField *field;
-
-       ret = NULL;
-
-       field = gtk_form_get_form_field_from_name (form, field_name);
-       ret = gtk_form_field_get_value (field);
-
-       return ret;
-}
-
-/**
- * gtk_form_get_form_widget_value_by_name:
- * @form: a #GtkForm object.
- * @widget_name:
- *
- */
-GValue
-*gtk_form_get_form_widget_value_by_name (GtkForm *form, const gchar *widget_name)
-{
-       GValue *ret;
-       GtkFormWidget *fwidget;
-       GtkFormField *field;
-
-       ret = NULL;
-
-       fwidget = gtk_form_get_form_widget_from_name (form, widget_name);
-       if (IS_GTK_FORM_WIDGET (fwidget))
-               {
-                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
-                       ret = gtk_form_field_get_value (field);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_get_form_field_value_stringify_by_name:
- * @form: a #GtkForm object.
- * @field_name:
- *
- */
-const gchar
-*gtk_form_get_form_field_value_stringify_by_name (GtkForm *form, const gchar *field_name)
-{
-       gchar *ret;
-       GtkFormField *field;
-
-       ret = NULL;
-
-       field = gtk_form_get_form_field_from_name (form, field_name);
-       ret = gtk_form_field_get_value_stringify (field);
-
-       return ret;
-}
-
-/**
- * gtk_form_get_form_widget_value_stringify_by_name:
- * @form: a #GtkForm object.
- * @widget_name:
- *
- */
-const gchar
-*gtk_form_get_form_widget_value_stringify_by_name (GtkForm *form, const gchar *widget_name)
-{
-       gchar *ret;
-       GtkFormWidget *fwidget;
-       GtkFormField *field;
-
-       ret = NULL;
-
-       fwidget = gtk_form_get_form_widget_from_name (form, widget_name);
-       if (IS_GTK_FORM_WIDGET (fwidget))
-               {
-                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
-                       ret = gtk_form_field_get_value_stringify (field);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_get_form_field_value_sql_by_name:
- * @form: a #GtkForm object.
- * @field_name:
- *
- */
-const gchar
-*gtk_form_get_form_field_value_sql_by_name (GtkForm *form, const gchar *field_name)
-{
-       gchar *ret;
-       GtkFormField *field;
-
-       ret = NULL;
-
-       field = gtk_form_get_form_field_from_name (form, field_name);
-       ret = gtk_form_field_get_value_sql (field);
-
-       return ret;
-}
-
-/**
- * gtk_form_get_form_widget_value_sql_by_name:
- * @form: a #GtkForm object.
- * @widget_name:
- *
- */
-const gchar
-*gtk_form_get_form_widget_value_sql_by_name (GtkForm *form, const gchar *widget_name)
-{
-       gchar *ret;
-       GtkFormWidget *fwidget;
-       GtkFormField *field;
-
-       ret = NULL;
-
-       fwidget = gtk_form_get_form_widget_from_name (form, widget_name);
-       if (IS_GTK_FORM_WIDGET (fwidget))
-               {
-                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
-                       ret = gtk_form_field_get_value_sql (field);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_get_sql:
- * @form: a #GtkForm object.
- * @type: SQL's type that returns.
- *
- * Returns: the SQL string.
- */
-gchar
-*gtk_form_get_sql (GtkForm *form, GtkFormSqlType type)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       GtkFormField *field;
-       gchar *sql = "";
-       gchar *fields_names = "";
-       gchar *values = "";
-       const gchar *value;
-       gchar *where = "";
-       const gchar *field_name;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), sql);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       field_name = gtk_form_field_get_field_name (field);
-
-                       if (field_name != NULL && g_strcmp0 (field_name, "") != 0)
-                               {
-                                       field_name = g_strconcat (&priv->quote, field_name, &priv->quote, NULL);
-                                       if (g_strstr_len (fields_names, -1, field_name) == NULL)
-                                               {
-                                                       switch (type)
-                                                               {
-                                                                       case GTK_FORM_SQL_SELECT:
-                                                                               if (gtk_form_field_is_to_load (field))
-                                                                                       {
-                                                                                               fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
-                                                                                       }
-                                                                               break;
-
-                                                                       case GTK_FORM_SQL_INSERT:
-                                                                               if (gtk_form_field_is_to_save (field))
-                                                                                       {
-                                                                                               if (gtk_form_field_is_auto_increment (field))
-                                                                                                       {
-                                                                                                               GdaDataModel *dm;
-                                                                                                               gchar *field_name;
-                                                                                                               guint new_val;
-
-                                                                                                               g_return_val_if_fail (IS_GDAEX (priv->gdaex), NULL);
-
-                                                                                                               g_object_get (field, "field", &field_name, NULL);
-
-                                                                                                               new_val = 0;
-                                                                                                               dm = gdaex_query (priv->gdaex,
-                                                                                                                                                 g_strdup_printf ("SELECT COALESCE (MAX (%s), 0) FROM %s",
-                                                                                                                                                 field_name,
-                                                                                                                                                 priv->table));
-                                                                                                               if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
-                                                                                                                       {
-                                                                                                                               new_val = gdaex_data_model_get_value_integer_at (dm, 0, 0);
-                                                                                                                       }
-                                                                                                               new_val++;
-
-                                                                                                               gtk_form_widget_set_value_stringify (gtk_form_field_get_form_widget (field), g_strdup_printf ("%d", new_val));
-                                                                                                       }
-                                                                                       
-                                                                                               value = gtk_form_field_get_value_sql (field);
-                                                                                               if (value != NULL)
-                                                                                                       {
-                                                                                                               fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
-                                                                                                               values = g_strconcat (values, value, ", ", NULL);
-                                                                                                       }
-                                                                                       }
-                                                                               break;
-
-                                                                       case GTK_FORM_SQL_UPDATE:
-                                                                               if (gtk_form_field_is_to_save (field)
-                                                                                       && (!IS_GTK_FORM_KEY (priv->key) ||
-                                                                                       !gtk_form_key_field_is_key (priv->key, field)))
-                                                                                       {
-                                                                                               value = gtk_form_field_get_value_sql (field);
-                                                                                               if (value != NULL)
-                                                                                                       {
-                                                                                                               fields_names = g_strconcat (fields_names, field_name, " = ", value, ", ", NULL);
-                                                                                                       }
-                                                                                       }
-                                                                               break;
-                                                               }
-                                               }
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       if (g_str_has_suffix (fields_names, ", "))
-               {
-                       fields_names[strlen (fields_names) - 2] = '\0';
-               }
-       if (g_str_has_suffix (values, ", "))
-               {
-                       values[strlen (values) - 2] = '\0';
-               }
-
-       switch (type)
-               {
-                       case GTK_FORM_SQL_SELECT:
-                               sql = g_strconcat ("SELECT ", fields_names, " FROM ", priv->table, NULL);
-                               break;
-
-                       case GTK_FORM_SQL_INSERT:
-                               sql = g_strconcat ("INSERT INTO ", priv->table, " (", fields_names, ") VALUES (", values, ")", NULL);
-                               break;
-
-                       case GTK_FORM_SQL_UPDATE:
-                               sql = g_strconcat ("UPDATE ", priv->table, " SET ", fields_names, NULL);
-                               break;
-
-                       case GTK_FORM_SQL_DELETE:
-                               sql = g_strconcat ("DELETE FROM ", priv->table, NULL);
-                               break;
-               }
-
-       if (IS_GTK_FORM_KEY (priv->key)
-           && (type == GTK_FORM_SQL_SELECT || type == GTK_FORM_SQL_UPDATE || type == GTK_FORM_SQL_DELETE))
-               {
-                       where = gtk_form_key_get_sql (priv->key);
-                       if (where != NULL && g_strcmp0 (where, "") != 0)
-                               {
-                                       sql = g_strconcat (sql, where, NULL);
-                               }
-               }
-
-       return sql;
-}
-
-/**
- * gtk_form_fill_from_datamodel:
- * @form: a #GtkForm object.
- * @dm: the #GdaDataModel from which fill the #GtkForm.
- * @row: the #GdaDataModel's row from which read data.
- *
- */
-gboolean
-gtk_form_fill_from_datamodel (GtkForm *form, GdaDataModel *dm, gint row)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       gboolean ret = TRUE;
-       GtkFormField *field;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       if (gtk_form_field_is_to_load (field))
-                               {
-                                       gtk_form_field_set_from_datamodel (field, dm, row);
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_fill_from_table:
- * @form: a #GtkForm object.
- *
- */
-gboolean
-gtk_form_fill_from_table (GtkForm *form)
-{
-       GtkFormPrivate *priv;
-       gchar *sql;
-       GdaDataModel *dm;
-
-       gboolean ret = TRUE;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       g_return_val_if_fail (IS_GDAEX (priv->gdaex), FALSE);
-
-       sql = gtk_form_get_sql (form, GTK_FORM_SQL_SELECT);
-
-       dm = gdaex_query (priv->gdaex, sql);
-       if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
-               {
-                       ret = gtk_form_fill_from_datamodel (form, dm, 0);
-
-                       g_object_unref (dm);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_reset:
- * @form:
- *
- */
-gboolean
-gtk_form_reset (GtkForm *form)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       gboolean ret = TRUE;
-       GtkFormField *field;
-       GtkFormWidget *widget;
-       GValue *gval;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       gval = gtk_form_field_get_original_value (field);
-                       gtk_form_field_set_value (field, gval);
-
-                       fields = g_slist_next (fields);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_get_values_as_hashtable:
- * @form: a #GtkForm object.
- *
- */
-GHashTable
-*gtk_form_get_values_as_hashtable (GtkForm *form)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       GtkFormField *field;
-       gchar *field_name;
-       GValue *gval;
-       GHashTable *ht;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-
-       if (fields != NULL)
-               {
-                       ht = g_hash_table_new (g_str_hash, g_str_equal);
-               }
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       field_name = gtk_form_field_get_field_name (field);
-
-                       gval = gtk_form_field_get_value (field);
-                       if (gval != NULL)
-                               {
-                                       /* TODO check if the field already exists */
-                                       g_hash_table_insert (ht, field_name, gval);
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return ht;
-}
-
-/**
- * gtk_form_get_original_values_as_hashtable:
- * @form:
- *
- */
-GHashTable
-*gtk_form_get_original_values_as_hashtable (GtkForm *form)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       GtkFormField *field;
-       gchar *field_name;
-       GValue *gval;
-       GHashTable *ht;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-
-       if (fields != NULL)
-               {
-                       ht = g_hash_table_new (g_str_hash, g_str_equal);
-               }
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       field_name = gtk_form_field_get_field_name (field);
-
-                       gval = gtk_form_field_get_original_value (field);
-                       if (gval != NULL)
-                               {
-                                       /* TODO check if the field already exists */
-                                       g_hash_table_insert (ht, field_name, gval);
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return ht;
-}
-
-/**
- * gtk_form_fill_from_hashtable:
- * @form: a #GtkForm object.
- * @hashtable: a @GHashTable object.
- *
- */
-gboolean
-gtk_form_fill_from_hashtable (GtkForm *form, GHashTable *hashtable)
-{
-       GtkFormPrivate *priv;
-       GSList *fields;
-       GtkFormField *field;
-
-       gboolean ret;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       if (gtk_form_field_is_to_load (field))
-                               {
-                                       gtk_form_field_set_from_hashtable (field, hashtable);
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_add_group:
- * @form:
- * @group:
- *
-  */
-gboolean
-gtk_form_add_group (GtkForm *form, GtkFormGroup *group)
-{
-       gboolean ret;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
-
-       GtkFormPrivate *priv;
-
-       ret = FALSE;
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       priv->groups = g_slist_append (priv->groups, group);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_get_group_by_name:
- * @form:
- * @group_name:
- *
- */
-GtkFormGroup
-*gtk_form_get_group_by_name (GtkForm *form, const gchar *group_name)
-{
-       GtkFormGroup *g;
-
-       gchar *new_g_name;
-       GSList *gs;
-       gchar *g_name;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-       g_return_val_if_fail (group_name != NULL, NULL);
-
-       new_g_name = g_strstrip (g_strdup (group_name));
-
-       g_return_val_if_fail (g_strcmp0 (new_g_name, "") != 0, NULL);
-
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
-
-       g = NULL;
-
-       gs = priv->groups;
-       while (gs != NULL)
-               {
-                       g_name = gtk_form_group_get_name ((GtkFormGroup *)gs->data);
-                       if (g_strcmp0 (g_name, new_g_name) == 0)
-                               {
-                                       g = (GtkFormGroup *)gs->data;
-                                       break;
-                               }
-
-                       gs = gs->next;
-               }
-
-       return g;
-}
-
-/**
- * gtk_form_add_db_connection:
- * @form:
- * @name:
- * @connection_string:
- *
- */
-gboolean
-gtk_form_add_db_connection (GtkForm *form, const gchar *name, const gchar *connection_string)
-{
-       gboolean ret;
-
-       gchar *_name;
-       gchar *_cnc_string;
-
-       GSList *dbs;
-       GtkFormDbConnection *dbc;
-       GtkFormDbConnection *dbc_new;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (name != NULL, FALSE);
-       g_return_val_if_fail (connection_string != NULL, FALSE);
-
-       GtkFormPrivate *priv;
-
-       ret = FALSE;
-
-       priv = GTK_FORM_GET_PRIVATE (form);
-
-       _name = g_strstrip (g_strdup (name));
-       if (g_strcmp0 (_name, "") == 0)
-               {
-                       return FALSE;
-               }
-       _cnc_string = g_strstrip (g_strdup (connection_string));
-       if (g_strcmp0 (_cnc_string, "") == 0)
-               {
-                       return FALSE;
-               }
-
-       dbc = NULL;
-       dbs = priv->db_connections;
-       while (dbs != NULL)
-               {
-                       dbc = (GtkFormDbConnection *)dbs->data;
-                       if (g_strcmp0 (dbc->cnc_string, _cnc_string) == 0)
-                               {
-                                       break;
-                               }
-                       dbc = NULL;
-
-                       dbs = dbs->next;
-               }
-
-       if (dbc != NULL)
-               {
-                       if (g_strcmp0 (dbc->name, _name) != 0)
-                               {
-                                       dbc_new = g_new0 (GtkFormDbConnection, 1);
-                                       dbc_new->name = g_strdup (_name);
-                                       dbc_new->cnc_string = g_strdup (_cnc_string);
-                                       dbc_new->gdaex = g_object_ref (dbc->gdaex);
-                                       priv->db_connections = g_slist_append (priv->db_connections, dbc_new);
-                               }
-               }
-       else
-               {
-                       dbc_new = g_new0 (GtkFormDbConnection, 1);
-                       dbc_new->gdaex = gdaex_new_from_string (_cnc_string);
-                       if (dbc_new->gdaex != NULL)
-                               {
-                                       dbc_new->name = g_strdup (_name);
-                                       dbc_new->cnc_string = g_strdup (_cnc_string);
-
-                                       priv->db_connections = g_slist_append (priv->db_connections, dbc_new);
-                               }
-                       else
-                               {
-                                       g_free (dbc_new);
-                                       return FALSE;
-                               }
-               }
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_add_db_connection:
- * @form:
- * @name:
- * @gdaex:
- *
- */
-gboolean
-gtk_form_add_db_connection_gdaex (GtkForm *form, const gchar *name, GdaEx *gdaex)
-{
-       gboolean ret;
-       gchar *_name;
-       GSList *dbs;
-       GtkFormDbConnection *dbc;
-       GtkFormDbConnection *dbc_new;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
-       g_return_val_if_fail (name != NULL, FALSE);
-       g_return_val_if_fail (IS_GDAEX (gdaex), FALSE);
-
-       _name = g_strstrip (g_strdup (name));
-
-       g_return_val_if_fail (g_strcmp0 (_name, "") != 0, FALSE);
-
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
-
-       ret = FALSE;
-
-       dbs = priv->db_connections;
-       while (dbs != NULL)
-               {
-                       dbc = (GtkFormDbConnection *)dbs->data;
-                       if (g_strcmp0 (dbc->name, _name) == 0)
-                               {
-                                       dbc->gdaex = gdaex;
-                                       return TRUE;
-                               }
-
-                       dbs = dbs->next;
-               }
-
-       dbc_new = g_new0 (GtkFormDbConnection, 1);
-       dbc_new->name = g_strdup (_name);
-       dbc_new->cnc_string = g_strdup (gda_connection_get_cnc_string ((GdaConnection *)gdaex_get_gdaconnection (gdaex)));
-       dbc_new->gdaex = gdaex;
-
-       priv->db_connections = g_slist_append (priv->db_connections, dbc_new);
-
-       return TRUE;
-}
-
-/**
- * gtk_form_get_db_connection_by_name:
- * @form:
- * @name:
- *
- * Returns: if @name is #NULL, the default #GdaEx connection; otherwise
- * the connection associated with the name requested.
- */
-GdaEx
-*gtk_form_get_db_connection_by_name (GtkForm *form, const gchar *name)
-{
-       GdaEx *gdaex;
-
-       gchar *_name;
-       GSList *dbs;
-       GtkFormDbConnection *dbc;
-
-       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
-
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
-
-       if (name == NULL)
-               {
-                       return priv->gdaex;
-               }
-
-       _name = g_strstrip (g_strdup (name));
-
-       g_return_val_if_fail (g_strcmp0 (_name, "") != 0, NULL);
-
-       gdaex = NULL;
-
-       dbs = priv->db_connections;
-       while (dbs != NULL)
-               {
-                       dbc = (GtkFormDbConnection *)dbs->data;
-                       if (g_strcmp0 (dbc->name, _name) == 0)
-                               {
-                                       gdaex = dbc->gdaex;
-                                       break;
-                               }
-
-                       dbs = dbs->next;
-               }
-
-       return gdaex;
-}
-
-/* PRIVATE */
-static void
-gtk_form_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
-{
-       GtkForm *form = (GtkForm *)object;
-
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
-
-       switch (property_id)
-               {
-                       case PROP_TABLE:
-                               gtk_form_set_table (form, g_value_get_string (value));
-                               break;
-
-                       case PROP_KEY:
-                               gtk_form_set_key (form, GTK_FORM_KEY (g_value_get_object (value)));
-                               break;
-
-                       case PROP_QUOTE:
-                               priv->quote = g_value_get_char (value);
-                               break;
-
-                       case PROP_GDAEX:
-                               priv->gdaex = g_value_get_pointer (value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
-{
-       GtkForm *form = (GtkForm *)object;
-
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
-
-       switch (property_id)
-               {
-                       case PROP_TABLE:
-                               g_value_set_string (value, gtk_form_get_table (form));
-                               break;
-
-                       case PROP_KEY:
-                               g_value_set_object (value, gtk_form_get_key (form));
-                               break;
-
-                       case PROP_QUOTE:
-                               g_value_set_char (value, priv->quote);
-                               break;
-
-                       case PROP_GDAEX:
-                               g_value_set_pointer (value, priv->gdaex);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_show_check_error_dialog (GtkFormWidget *fwidget,
-                                  GtkWidget *parent_window,
-                                  const gchar *message)
-{
-       GtkWidget *dialog;
-       GtkWidget *label;
-       GtkFormField *field;
-
-       gchar *label_text;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
-       g_return_if_fail (GTK_IS_WINDOW (parent_window));
-
-       label_text = NULL;
-
-       label = gtk_form_widget_get_label (fwidget);
-       if (GTK_IS_LABEL (label))
-               {
-                       label_text = (gchar *)gtk_label_get_text (GTK_LABEL (label));
-               }
-       else
-               {
-                       g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
-                       if (IS_GTK_FORM_FIELD (field))
-                               {
-                                       label_text = gtk_form_field_get_field_long_name (field);
-                                       if (label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
-                                               {
-                                                       label_text = gtk_form_field_get_field_name (field);
-                                               }
-                               }
-
-                       if ((label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
-                           && GTK_IS_CHECK_BUTTON (label))
-                               {
-                                       label_text = (gchar *)gtk_button_get_label (GTK_BUTTON (label));
-                               }
-               }
-
-       if (label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
-               {
-                       label_text = gtk_form_widget_get_widget_name (fwidget);
-               }
-
-       dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window),
-                                        GTK_DIALOG_DESTROY_WITH_PARENT,
-                                        GTK_MESSAGE_WARNING,
-                                        GTK_BUTTONS_OK,
-                                        g_strdup_printf (_("The field Â«%s»%s."), label_text, message));
-       gtk_dialog_run (GTK_DIALOG (dialog));
-       gtk_widget_destroy (dialog);
-}
-
-static void
-gtk_form_load_modules (GtkForm *form)
-{
-       gchar *modulesdir;
-       GDir *dir;
-       GError *error;
-
-       GModule *module;
-       const gchar *filename;
-
-       GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
-
-       modulesdir = (gchar *)g_getenv ("LIBGTKFORM_MODULESDIR");
-       if (modulesdir == NULL)
-               {
-#ifdef G_OS_WIN32
-
-                       gchar *moddir;
-                       gchar *p;
-
-                       moddir = g_win32_get_package_installation_directory_of_module (NULL);
-
-                       p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR));
-                       if (p != NULL
-                               && (g_ascii_strcasecmp (p + 1, "src") == 0
-                                       || g_ascii_strcasecmp (p + 1, ".libs") == 0))
-                               {
-                                       modulesdir = g_strdup (MODULESDIR);
-                               }
-                       else
-                               {
-                                       modulesdir = g_build_filename (moddir, "lib", PACKAGE, "modules", NULL);
-                               }
-
-#else
-
-                       modulesdir = g_strdup (MODULESDIR);
-
-#endif
-               }
-
-       /* for each file in MODULESDIR */
-       error = NULL;
-       dir = g_dir_open (modulesdir, 0, &error);
-       if (dir != NULL)
-               {
-                       while ((filename = g_dir_read_name (dir)) != NULL)
-                               {
-                                       /* trying to open the module */
-                                       module = g_module_open (filename, G_MODULE_BIND_LAZY);
-                                       if (module != NULL)
-                                               {
-                                                       priv->modules = g_list_append (priv->modules, (gpointer)module);
-                                                       if (priv->debug > 0)
-                                                               {
-                                                                       g_message (_("Loaded %s."), filename);
-                                                               }
-                                               }
-                                       else
-                                               {
-                                                       g_warning (_("Unable to load %s: %s."), filename, g_module_error ());
-                                               }
-                               }
-
-                       g_dir_close (dir);
-               }
-       else
-               {
-                       g_warning (_("Unable to open modules dir: %s."), error->message != NULL ? error->message : _("no details"));
-               }
-}
diff --git a/src/form.h b/src/form.h
deleted file mode 100644 (file)
index 2dca1c6..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_H__
-#define __LIBGTK_FORM_H__
-
-#include <glib.h>
-#include <libxml/tree.h>
-
-#include "field.h"
-#include "widget.h"
-#include "key.h"
-#include "group.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM                 (gtk_form_get_type ())
-#define GTK_FORM(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM, GtkForm))
-#define GTK_FORM_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM, GtkFormClass))
-#define IS_GTK_FORM(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM))
-#define IS_GTK_FORM_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM))
-#define GTK_FORM_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM, GtkFormClass))
-
-
-typedef struct _GtkForm GtkForm;
-typedef struct _GtkFormClass GtkFormClass;
-
-struct _GtkForm
-       {
-               GObject parent;
-       };
-
-struct _GtkFormClass
-       {
-               GObjectClass parent_class;
-       };
-
-GType gtk_form_get_type (void) G_GNUC_CONST;
-
-
-GtkForm *gtk_form_new (void);
-GtkForm *gtk_form_new_from_xml (xmlDoc *xmldoc, GtkBuilder *gtkbuilder);
-GtkForm *gtk_form_new_from_file (const gchar *filename, GtkBuilder *gtkbuilder);
-
-GOptionGroup *gtk_form_get_option_group (GtkForm *gtkform);
-
-gboolean gtk_form_load_from_xml (GtkForm *form, xmlDoc *xmldoc, GtkBuilder *gtkbuilder);
-gboolean gtk_form_load_from_file (GtkForm *form, const gchar *filename, GtkBuilder *gtkbuilder);
-
-GtkBuilder *gtk_form_get_gtkbuilder (GtkForm *form);
-
-gchar *gtk_form_get_table (GtkForm *form);
-void gtk_form_set_table (GtkForm *form, const gchar *table);
-
-GtkFormKey *gtk_form_get_key (GtkForm *form);
-void gtk_form_set_key (GtkForm *form, GtkFormKey *key);
-
-gboolean gtk_form_add_field (GtkForm *form, GtkFormField *field);
-gboolean gtk_form_remove_field (GtkForm *form, GtkFormField *field);
-
-gboolean gtk_form_add_fields (GtkForm *form, ...);
-
-GtkFormField *gtk_form_get_form_field_from_name (GtkForm *form, const gchar *field_name);
-GtkFormWidget *gtk_form_get_form_widget_from_name (GtkForm *form, const gchar *widget_name);
-GtkWidget *gtk_form_get_widget_from_form_field_name (GtkForm *form, const gchar *field_name);
-GtkWidget *gtk_form_get_widget_from_form_widget_name (GtkForm *form, const gchar *widget_name);
-
-GtkFormField *gtk_form_get_form_field_from_widget (GtkForm *form, GtkWidget *widget);
-GtkFormWidget *gtk_form_get_form_widget_from_widget (GtkForm *form, GtkWidget *widget);
-
-GtkWidget **gtk_form_get_widgets (GtkForm *form);
-GObject **gtk_form_get_objects_by_name (GtkForm *form, ...);
-
-gboolean gtk_form_clear (GtkForm *form);
-
-gboolean gtk_form_check (GtkForm *form, gboolean with_key,
-                         GtkFormWidget **form_widget,
-                         gboolean show_error_dialog, GtkWidget *parent_window,
-                         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, ...);
-
-void gtk_form_set_editable (GtkForm *form, gboolean editable);
-
-void gtk_form_set_visible_by_name (GtkForm *form, gboolean visible, ...);
-void gtk_form_set_form_widget_visible_by_name (GtkForm *form, gboolean visible, ...);
-
-GValue *gtk_form_get_form_field_value_by_name (GtkForm *form, const gchar *field_name);
-GValue *gtk_form_get_form_widget_value_by_name (GtkForm *form, const gchar *widget_name);
-const gchar *gtk_form_get_form_field_value_stringify_by_name (GtkForm *form, const gchar *field_name);
-const gchar *gtk_form_get_form_widget_value_stringify_by_name (GtkForm *form, const gchar *widget_name);
-const gchar *gtk_form_get_form_field_value_sql_by_name (GtkForm *form, const gchar *field_name);
-const gchar *gtk_form_get_form_widget_value_sql_by_name (GtkForm *form, const gchar *widget_name);
-
-typedef enum
-{
-       GTK_FORM_SQL_SELECT,
-       GTK_FORM_SQL_INSERT,
-       GTK_FORM_SQL_UPDATE,
-       GTK_FORM_SQL_DELETE
-} GtkFormSqlType;
-
-gchar *gtk_form_get_sql (GtkForm *form, GtkFormSqlType type);
-
-gboolean gtk_form_fill_from_datamodel (GtkForm *form, GdaDataModel *dm, gint row);
-gboolean gtk_form_fill_from_table (GtkForm *form);
-
-gboolean gtk_form_reset (GtkForm *form);
-
-GHashTable *gtk_form_get_values_as_hashtable (GtkForm *form);
-GHashTable *gtk_form_get_original_values_as_hashtable (GtkForm *form);
-gboolean gtk_form_fill_from_hashtable (GtkForm *form, GHashTable *hashtable);
-
-gboolean gtk_form_add_group (GtkForm *form, GtkFormGroup *group);
-GtkFormGroup *gtk_form_get_group_by_name (GtkForm *form, const gchar *group_name);
-
-gboolean gtk_form_add_db_connection (GtkForm *form, const gchar *name, const gchar *connection_string);
-gboolean gtk_form_add_db_connection_gdaex (GtkForm *form, const gchar *name, GdaEx *gdaex);
-GdaEx *gtk_form_get_db_connection_by_name (GtkForm *form, const gchar *name);
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_H__ */
diff --git a/src/group.c b/src/group.c
deleted file mode 100644 (file)
index a2278f0..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "group.h"
-
-enum
-{
-       PROP_0,
-       PROP_NAME
-};
-
-static void gtk_form_group_class_init (GtkFormGroupClass *klass);
-static void gtk_form_group_init (GtkFormGroup *gtk_form_group);
-
-static void gtk_form_group_set_property (GObject *object,
-                                     guint property_id,
-                                     const GValue *value,
-                                     GParamSpec *pspec);
-static void gtk_form_group_get_property (GObject *object,
-                                     guint property_id,
-                                     GValue *value,
-                                     GParamSpec *pspec);
-
-#define GTK_FORM_GROUP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroupPrivate))
-
-typedef struct _GtkFormGroupPrivate GtkFormGroupPrivate;
-struct _GtkFormGroupPrivate
-       {
-               gchar *name;
-
-               GSList *elements; /* GtkFormWidgets and GtkFormFields */
-       };
-
-
-G_DEFINE_TYPE (GtkFormGroup, gtk_form_group, G_TYPE_OBJECT)
-
-static void
-gtk_form_group_class_init (GtkFormGroupClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-       object_class->set_property = gtk_form_group_set_property;
-       object_class->get_property = gtk_form_group_get_property;
-
-       g_object_class_install_property (object_class, PROP_NAME,
-                                        g_param_spec_string ("name",
-                                                             "Group's name'",
-                                                             "Group's name",
-                                                             "",
-                                                             G_PARAM_READWRITE));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormGroupPrivate));
-}
-
-static void
-gtk_form_group_init (GtkFormGroup *gtk_form_group)
-{
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (gtk_form_group);
-
-       priv->name = NULL;
-}
-
-/**
- * gtk_form_group_new:
- * @name:
- *
- * Returns: the newly created #GtkFormGroup.
- */
-GtkFormGroup
-*gtk_form_group_new (const gchar *name)
-{
-       GtkFormGroup *g;
-
-       g = g_object_new (TYPE_GTK_FORM_GROUP, NULL);
-
-       g_object_set (G_OBJECT (g), "name", name, NULL);
-
-       return g;
-}
-
-/**
- * gtk_form_group_get_name:
- * @group: a #GtkFormGroup object.
- *
- * Returns: the group's name.
- */
-gchar
-*gtk_form_group_get_name (GtkFormGroup *group)
-{
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       return g_strdup (priv->name);
-}
-
-/**
- * gtk_form_group_add_widget:
- * @group:
- * @fwidget:
- *
- */
-gboolean
-gtk_form_group_add_widget (GtkFormGroup *group, GtkFormWidget *fwidget)
-{
-       gboolean ret;
-
-       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), FALSE);
-
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       ret = FALSE;
-
-       priv->elements = g_slist_append (priv->elements, (gpointer)fwidget);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_group_add_field:
- * @group:
- * @field:
- *
- */
-gboolean
-gtk_form_group_add_field (GtkFormGroup *group, GtkFormField *field)
-{
-       gboolean ret;
-
-       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       ret = FALSE;
-
-       priv->elements = g_slist_append (priv->elements, (gpointer)field);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_group_clear:
- * @group: a #GtkFormGroup object.
- *
- */
-gboolean
-gtk_form_group_clear (GtkFormGroup *group)
-{
-       gboolean ret;
-
-       GSList *els;
-
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       g_return_val_if_fail (IS_GTK_FORM_GROUP (group), FALSE);
-
-       els = priv->elements;
-       while (els != NULL)
-               {
-                       if (IS_GTK_FORM_WIDGET ((GtkFormWidget *)els->data))
-                               {
-                                       gtk_form_widget_set_value_stringify ((GtkFormWidget *)els->data, "");
-                               }
-                       else if (IS_GTK_FORM_FIELD ((GtkFormField *)els->data))
-                               {
-                                       gtk_form_field_clear ((GtkFormField *)els->data);
-                               }
-
-                       els = g_slist_next (els);
-               }
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_group_set_from_datamodel:
- * @group: a #GtkFormGroup object.
- * @dm: a #GdaDataModel object.
- * @row: the row number to return.
- *
- */
-gboolean
-gtk_form_group_set_from_datamodel (GtkFormGroup *group, GdaDataModel *dm, gint row)
-{
-       gboolean ret = FALSE;
-
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       g_return_val_if_fail (GDA_IS_DATA_MODEL (dm), FALSE);
-
-       /*if (IS_GTK_FORM_GROUP (group) && GTK_FORM_GROUP_GET_CLASS (group)->set_from_datamodel != NULL)
-               {
-                       ret = GTK_FORM_GROUP_GET_CLASS (group)->set_from_datamodel (group, dm, row);
-               }*/
-
-       return ret;
-}
-
-/**
- * gtk_form_group_set_from_hashtable:
- * @group: a #GtkFormGroup object.
- * @hashtable: a #GHashTable object.
- *
- */
-gboolean
-gtk_form_group_set_from_hashtable (GtkFormGroup *group, GHashTable *hashtable)
-{
-       gboolean ret = FALSE;
-
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       g_return_val_if_fail (hashtable != NULL, FALSE);
-
-       /*if (IS_GTK_FORM_GROUP (group) && GTK_FORM_GROUP_GET_CLASS (group)->set_from_hashtable != NULL)
-               {
-                       ret = GTK_FORM_GROUP_GET_CLASS (group)->set_from_hashtable (group, hashtable);
-               }*/
-
-       return ret;
-}
-
-/* PRIVATE */
-static void
-gtk_form_group_set_property (GObject *object,
-                         guint property_id,
-                         const GValue *value,
-                         GParamSpec *pspec)
-{
-       GtkFormGroup *group = (GtkFormGroup *)object;
-
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       switch (property_id)
-               {
-                       case PROP_NAME:
-                               priv->name = g_strstrip (g_value_dup_string (value));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_group_get_property (GObject *object,
-                         guint property_id,
-                         GValue *value,
-                         GParamSpec *pspec)
-{
-       GtkFormGroup *group = (GtkFormGroup *)object;
-
-       GtkFormGroupPrivate *priv = GTK_FORM_GROUP_GET_PRIVATE (group);
-
-       switch (property_id)
-               {
-                       case PROP_NAME:
-                               g_value_set_string (value, gtk_form_group_get_name (group));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/group.h b/src/group.h
deleted file mode 100644 (file)
index 6d1f658..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_GROUP_H__
-#define __LIBGTK_FORM_GROUP_H__
-
-#include <glib.h>
-
-#include "widget.h"
-#include "field.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_GROUP                 (gtk_form_group_get_type ())
-#define GTK_FORM_GROUP(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroup))
-#define GTK_FORM_GROUP_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_GROUP, GtkFormGroupClass))
-#define IS_GTK_FORM_GROUP(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_GROUP))
-#define IS_GTK_FORM_GROUP_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_GROUP))
-#define GTK_FORM_GROUP_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroupClass))
-
-
-typedef struct _GtkFormGroup GtkFormGroup;
-typedef struct _GtkFormGroupClass GtkFormGroupClass;
-
-struct _GtkFormGroup
-       {
-               GObject parent;
-       };
-
-struct _GtkFormGroupClass
-       {
-               GObjectClass parent_class;
-       };
-
-GType gtk_form_group_get_type (void) G_GNUC_CONST;
-
-GtkFormGroup *gtk_form_group_new (const gchar *name);
-
-gchar *gtk_form_group_get_name (GtkFormGroup *group);
-
-gboolean gtk_form_group_add_widget (GtkFormGroup *group, GtkFormWidget *fwidget);
-gboolean gtk_form_group_add_field (GtkFormGroup *group, GtkFormField *field);
-
-gboolean gtk_form_group_clear (GtkFormGroup *group);
-
-gboolean gtk_form_group_set_from_datamodel (GtkFormGroup *group, GdaDataModel *dm, gint row);
-gboolean gtk_form_group_set_from_hashtable (GtkFormGroup *group, GHashTable *hashtable);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_GROUP_H__ */
diff --git a/src/key.c b/src/key.c
deleted file mode 100644 (file)
index 4d24a44..0000000
--- a/src/key.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <stdarg.h>
-#include <string.h>
-
-#include "key.h"
-
-static void gtk_form_key_class_init (GtkFormKeyClass *class);
-static void gtk_form_key_init (GtkFormKey *gtk_form_key);
-
-
-#define GTK_FORM_KEY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_KEY, GtkFormKeyPrivate))
-
-typedef struct _GtkFormKeyPrivate GtkFormKeyPrivate;
-struct _GtkFormKeyPrivate
-       {
-               GSList *fields;
-       };
-
-
-G_DEFINE_TYPE (GtkFormKey, gtk_form_key, G_TYPE_OBJECT)
-
-static void
-gtk_form_key_class_init (GtkFormKeyClass *class)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-       g_type_class_add_private (object_class, sizeof (GtkFormKeyPrivate));
-}
-
-static void
-gtk_form_key_init (GtkFormKey *gtk_form_key)
-{
-       GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
-
-       priv->fields = NULL;
-}
-
-/**
- * gtk_form_key_new:
- *
- * Returns: the newly created #GtkFormKey.
- */
-GtkFormKey
-*gtk_form_key_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_KEY, NULL);
-}
-
-/**
- * gtk_form_key_add_field:
- * @gtk_form_key: a #GtkFormKey object.
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_key_add_field (GtkFormKey *gtk_form_key, GtkFormField *field)
-{
-       gboolean ret = FALSE;
-
-       GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       priv->fields = g_slist_append (priv->fields, field);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_key_remove_field:
- * @gtk_form_key: a #GtkFormKey object.
- * @field: a #GtkFormField object.
- *
- */
-gboolean
-gtk_form_key_remove_field (GtkFormKey *gtk_form_key, GtkFormField *field)
-{
-       gboolean ret = FALSE;
-
-       GtkFormKeyPrivate *priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
-
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       priv->fields = g_slist_remove (priv->fields, field);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_key_add_fields:
- * @gtk_form_key: a #GtkFormKey object.
- *
- */
-gboolean
-gtk_form_key_add_fields (GtkFormKey *gtk_form_key, ...)
-{
-       GtkFormField *field;
-
-       va_list vargs;
-
-       va_start (vargs, gtk_form_key);
-
-       while ((field = va_arg (vargs, GtkFormField *)) != NULL)
-               {
-                       gtk_form_key_add_field (gtk_form_key, field);
-               }
-
-       va_end (vargs);
-}
-
-/**
- * gtk_form_key_check:
- * @gtk_form_key: a #GtkFormKey object.
- * @form_widget:
- *
- * Returns: TRUE if all obligatory fields are full.
- */
-gboolean
-gtk_form_key_check (GtkFormKey *gtk_form_key, GtkFormWidget **form_widget)
-{
-       GtkFormField *field;
-       gboolean ret;
-
-       GtkFormKeyPrivate *priv;
-       GSList *fields;
-
-       g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), FALSE);
-
-       priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
-
-       ret = TRUE;
-
-       fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       if (gtk_form_field_is_empty (field))
-                               {
-                                       GtkFormWidget *fwidget;
-
-                                       fwidget = gtk_form_field_get_form_widget (field);
-                                       if (form_widget != NULL && *form_widget == NULL)
-                                               {
-                                                       *form_widget = fwidget;
-                                               }
-
-                                       ret = FALSE;
-                                       break;
-                               }
-
-                       fields = g_slist_next (fields);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_key_get_sql:
- * @gtk_form_key: a #GtkFormKey object.
- *
- */
-gchar
-*gtk_form_key_get_sql (GtkFormKey *gtk_form_key)
-{
-       GtkFormField *field;
-       gchar *sql = "";
-       gchar *field_name;
-
-       GtkFormKeyPrivate *priv;
-       GSList *fields;
-
-       g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), sql);
-
-       priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
-
-       fields = priv->fields;
-
-       while (fields != NULL)
-               {
-                       field = (GtkFormField *)fields->data;
-
-                       g_object_get (G_OBJECT (field),
-                                     "field", &field_name,
-                                     NULL);
-
-                       sql = g_strconcat (sql, " AND ", field_name, " = ",
-                                          gtk_form_field_get_value_sql (field), NULL);
-
-                       fields = g_slist_next (fields);
-               }
-
-       if (strcmp (sql, "") != 0)
-               {
-                       sql = g_strconcat (" WHERE ", g_strdup (sql + 5), NULL);
-               }
-
-       g_free (field_name);
-
-       return sql;
-}
-
-/**
- * gtk_form_key_field_is_key:
- * @gtk_form_key: a #GtkFormKey object.
- * @field: a #GtkFormField object.
- *
- * Returns: TRUE if @field is part of @gtk_form_key.
- */
-gboolean
-gtk_form_key_field_is_key (GtkFormKey *gtk_form_key, GtkFormField *field)
-{
-       GtkFormKeyPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_KEY (gtk_form_key), FALSE);
-       g_return_val_if_fail (IS_GTK_FORM_FIELD (field), FALSE);
-
-       priv = GTK_FORM_KEY_GET_PRIVATE (gtk_form_key);
-
-       return (g_slist_index (priv->fields, field) >= 0 ? TRUE : FALSE);
-}
diff --git a/src/key.h b/src/key.h
deleted file mode 100644 (file)
index 144c2ec..0000000
--- a/src/key.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_KEY_H__
-#define __LIBGTK_FORM_KEY_H__
-
-#include <glib.h>
-
-#include "field.h"
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_KEY                 (gtk_form_key_get_type ())
-#define GTK_FORM_KEY(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_KEY, GtkFormKey))
-#define GTK_FORM_KEY_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_KEY, GtkFormKeyClass))
-#define IS_GTK_FORM_KEY(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_KEY))
-#define IS_GTK_FORM_KEY_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_KEY))
-#define GTK_FORM_KEY_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_KEY, GtkFormKeyClass))
-
-
-typedef struct _GtkFormKey GtkFormKey;
-typedef struct _GtkFormKeyClass GtkFormKeyClass;
-
-struct _GtkFormKey
-       {
-               GObject parent;
-       };
-
-struct _GtkFormKeyClass
-       {
-               GObjectClass parent_class;
-       };
-
-GType gtk_form_key_get_type (void) G_GNUC_CONST;
-
-
-GtkFormKey *gtk_form_key_new (void);
-
-gboolean gtk_form_key_add_field (GtkFormKey *gtk_form_key, GtkFormField *field);
-gboolean gtk_form_key_remove_field (GtkFormKey *gtk_form_key, GtkFormField *field);
-
-gboolean gtk_form_key_add_fields (GtkFormKey *gtk_form_key, ...);
-
-gboolean gtk_form_key_check (GtkFormKey *gtk_form_key, GtkFormWidget **form_widget);
-
-gchar *gtk_form_key_get_sql (GtkFormKey *gtk_form_key);
-
-gboolean gtk_form_key_field_is_key (GtkFormKey *gtk_form_key, GtkFormField *field);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_KEY_H__ */
diff --git a/src/widget.c b/src/widget.c
deleted file mode 100644 (file)
index 2fe9ba3..0000000
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <glib/gi18n-lib.h>
-
-#include <gtk/gtk.h>
-
-#include <sql-parser/gda-sql-parser.h>
-
-#include "form.h"
-#include "widget.h"
-#include "field.h"
-
-enum
-{
-       PROP_0,
-       PROP_FORM,
-       PROP_FIELD,
-       PROP_WIDGET,
-       PROP_NAME,
-       PROP_LABEL
-};
-
-static void gtk_form_widget_class_init (GtkFormWidgetClass *klass);
-static void gtk_form_widget_init (GtkFormWidget *gtk_form_widget);
-
-static void gtk_form_widget_set_property (GObject *object,
-                                      guint property_id,
-                                      const GValue *value,
-                                      GParamSpec *pspec);
-static void gtk_form_widget_get_property (GObject *object,
-                                      guint property_id,
-                                      GValue *value,
-                                      GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET, GtkFormWidgetPrivate))
-
-typedef struct _GtkFormWidgetPrivate GtkFormWidgetPrivate;
-struct _GtkFormWidgetPrivate
-       {
-               GtkForm *form;
-               GtkWidget *widget;
-               gchar *widget_name;
-
-               GtkWidget *label;
-
-               GtkFormField *field;
-
-               GSList *on_change_ops; /* GtkFormOnChangeOp */
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidget, gtk_form_widget, G_TYPE_OBJECT)
-
-static void
-gtk_form_widget_class_init (GtkFormWidgetClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-       klass->get_value_stringify = NULL;
-       klass->set_value_stringify = NULL;
-       klass->set_editable = NULL;
-
-       object_class->set_property = gtk_form_widget_set_property;
-       object_class->get_property = gtk_form_widget_get_property;
-
-       g_object_class_install_property (object_class, PROP_FORM,
-                                        g_param_spec_object ("form",
-                                                             "GtkForm",
-                                                             "The GtkForm",
-                                                             TYPE_GTK_FORM,
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_FIELD,
-                                        g_param_spec_object ("field",
-                                                             "GtkFormField",
-                                                             "The GtkFormField",
-                                                             TYPE_GTK_FORM_FIELD,
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_WIDGET,
-                                        g_param_spec_object ("widget",
-                                                             "GtkWidget",
-                                                             "The GtkWidget",
-                                                             GTK_TYPE_WIDGET,
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_NAME,
-                                        g_param_spec_string ("widget-name",
-                                                             "Widget's name",
-                                                             "Widget's name",
-                                                             "",
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_LABEL,
-                                        g_param_spec_object ("label",
-                                                             "GtkLabel",
-                                                             "The GtkLabel",
-                                                             GTK_TYPE_WIDGET,
-                                                             G_PARAM_READWRITE));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormWidgetPrivate));
-}
-
-static void
-gtk_form_widget_init (GtkFormWidget *gtk_form_widget)
-{
-       GtkFormWidgetPrivate *priv = GTK_FORM_WIDGET_GET_PRIVATE (gtk_form_widget);
-
-       priv->form = NULL;
-       priv->field = NULL;
-       priv->widget = NULL;
-       priv->widget_name = NULL;
-       priv->label = NULL;
-       priv->on_change_ops = NULL;
-}
-
-/**
- * gtk_form_widget_new:
- *
- * Returns: the newly created #GtkFormWidget.
- */
-GtkFormWidget
-*gtk_form_widget_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET, NULL);
-}
-
-/**
- * gtk_form_widget_set_from_gtkbuilder:
- * @fwidget: a #GtkFormWidget object.
- * @gtkbuilder:
- * @widget_name:
- *
- */
-gboolean
-gtk_form_widget_set_from_gtkbuilder (GtkFormWidget *fwidget,
-                                     GtkBuilder *gtkbuilder,
-                                     const gchar *widget_name)
-{
-       gboolean ret;
-
-       GtkWidget *w;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), FALSE);
-       g_return_val_if_fail (GTK_IS_BUILDER (gtkbuilder), FALSE);
-
-       ret = FALSE;
-
-       w = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, widget_name));
-       if (w != NULL)
-               {
-                       g_object_set (fwidget,
-                                     "widget", w,
-                                     "widget-name", widget_name,
-                                     NULL);
-
-                       ret = TRUE;
-               }
-       else
-               {
-                       g_warning (_("Widget Â«%s» not found."), widget_name);
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_get_widget:
- * @fwidget: a #GtkFormWidget object.
- *
- */
-GtkWidget
-*gtk_form_widget_get_widget (GtkFormWidget *fwidget)
-{
-       GtkFormWidgetPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), NULL);
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       return priv->widget;
-}
-
-/**
- * gtk_form_widget_get_widget_name:
- * @fwidget: a #GtkFormWidget object.
- *
- * Returns: the #GtkFormWidget's name. Must be freed.
- */
-gchar
-*gtk_form_widget_get_widget_name (GtkFormWidget *fwidget)
-{
-       gchar *ret;
-       GtkFormWidgetPrivate *priv;
-
-       ret = g_strdup ("");
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), ret);
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       ret = g_strdup (priv->widget_name);
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_get_label:
- * @fwidget: a #GtkFormWidget object.
- *
- */
-GtkWidget
-*gtk_form_widget_get_label (GtkFormWidget *fwidget)
-{
-       GtkFormWidgetPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), NULL);
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       return priv->label;
-}
-
-/**
- * gtk_form_widget_set_label:
- * @fwidget: a #GtkFormWidget object.
- * @label: a @GtkWidget object.
- *
- */
-void
-gtk_form_widget_set_label (GtkFormWidget *fwidget, GtkWidget *label)
-{
-       GtkFormWidgetPrivate *priv;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
-       g_return_if_fail (GTK_IS_LABEL (label));
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       priv->label = GTK_WIDGET (label);
-}
-
-/**
- * gtk_form_widget_get_value_stringify:
- * @fwidget: a #GtkFormWidget object.
- *
- * Returns: The widget's value as a string. Must be freed.
- */
-gchar
-*gtk_form_widget_get_value_stringify (GtkFormWidget *fwidget)
-{
-       gchar *ret;
-
-       ret = NULL;
-
-       if (IS_GTK_FORM_WIDGET (fwidget) && GTK_FORM_WIDGET_GET_CLASS (fwidget)->get_value_stringify != NULL)
-               {
-                       ret = GTK_FORM_WIDGET_GET_CLASS (fwidget)->get_value_stringify (fwidget);
-               }
-
-       return ret;
-}
-
-static void
-execute_on_change_op (GtkFormWidget *fwidget, GtkFormWidgetOnChangeOpUpdate *op)
-{
-       GtkFormWidgetPrivate *priv;
-       GdaEx *gdaex;
-
-       GObject *res;
-       GdaConnection *gdacon;
-       GdaSqlParser *parser;
-       GdaStatement *stmt;
-       GdaSet *params;
-       GSList *hs;
-       GdaHolder *h;
-       GValue *gval;
-       GError *error;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       gdaex = NULL;
-
-       if (op->connection_name != NULL
-           && g_strcmp0 (op->connection_name, "") != 0)
-               {
-                       gdaex = gtk_form_get_db_connection_by_name (priv->form, op->connection_name);
-               }
-
-       if (!IS_GDAEX (gdaex))
-               {
-                       g_object_get (G_OBJECT (priv->form), "gdaex", &gdaex, NULL);
-               }
-
-       if (IS_GDAEX (gdaex))
-               {
-                       gdacon = (GdaConnection *)gdaex_get_gdaconnection (gdaex);
-                       parser = gda_connection_create_parser (gdacon);
-                       if (parser == NULL)
-                               {
-                                       parser = gda_sql_parser_new ();
-                               }
-
-                       error = NULL;
-                       stmt = gda_sql_parser_parse_string (parser, op->sql, NULL, &error);
-                       if (stmt == NULL)
-                               {
-                                       g_warning (_("Error on parsing sql string: %s\n%s."), op->sql,
-                                                  (error != NULL && error->message != NULL ? error->message : "no details"));
-                               }
-                       else
-                               {
-                                       gda_statement_get_parameters (stmt, &params, NULL);
-                                       if (params != NULL)
-                                               {
-                                                       hs = params->holders;
-                                                       while (hs != NULL)
-                                                               {
-                                                                       h = (GdaHolder *)hs->data;
-
-                                                                       if (GDA_IS_HOLDER (h))
-                                                                               {
-                                                                                       gval = gda_value_new_from_string (gtk_form_widget_get_value_stringify (gtk_form_get_form_widget_from_name (priv->form, gda_holder_get_id (h))), gda_holder_get_g_type (h));
-
-                                                                                       error = NULL;
-                                                                                       if (!gda_holder_set_value (h, gval, &error))
-                                                                                               {
-                                                                                                       g_warning (_("Error on setting holder's value: %s."),
-                                                                                                                  (error != NULL && error->message != NULL ? error->message : "no details"));
-                                                                                               }
-                                                                               }
-                                                                       hs = g_slist_next (hs);
-                                                               }
-                                               }
-
-                                       error = NULL;
-                                       res = gda_connection_statement_execute (gdacon, stmt, params,
-                                                                               GDA_STATEMENT_MODEL_RANDOM_ACCESS,
-                                                                               NULL, &error);
-
-                                       if (res == NULL)
-                                               {
-                                                       g_warning (_("Error on executing GtkFormWidgetOnChangeOp: %s."),
-                                                                  (error != NULL && error->message != NULL ? error->message : "no details"));
-                                               }
-                                       else if (GDA_IS_DATA_MODEL (res) && gda_data_model_get_n_rows ((GdaDataModel *)res) > 0)
-                                               {
-                                                       gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, op->form_widget_name),
-                                                                                            gdaex_data_model_get_value_stringify_at ((GdaDataModel *)res, 0, 0));
-                                                       g_object_unref (res);
-                                               }
-                                       else
-                                               {
-                                                       gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, op->form_widget_name), "");
-                                               }
-                                       g_object_unref (stmt);
-                               }
-               }
-       else
-               {
-                       g_warning (_("No GdaEx object inside GtkFormWidget."));
-               }
-}
-
-/**
- * gtk_form_widget_set_value_stringify:
- * @fwidget: a #GtkFormWidget object.
- * @value:
- *
- */
-gboolean
-gtk_form_widget_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret;
-       GSList *ops;
-       GtkFormWidgetOnChangeOp *op;
-
-       GtkFormWidgetPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET (fwidget), FALSE);
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       ops = priv->on_change_ops;
-       while (ops != NULL)
-               {
-                       op = (GtkFormWidgetOnChangeOp *)ops->data;
-                       switch (op->type)
-                               {
-                                       case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
-                                               {
-                                                       GtkFormWidgetOnChangeOpUpdate *op_update = (GtkFormWidgetOnChangeOpUpdate *)op;
-                                                       if (IS_GTK_FORM (priv->form)
-                                                           && (op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BEFORE
-                                                               || op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH))
-                                                               {
-                                                                       execute_on_change_op (fwidget, op_update);
-                                                               }
-                                               }
-                                               break;
-                               }
-
-                       ops = g_slist_next (ops);
-               }
-
-       if (GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_value_stringify != NULL)
-               {
-                       ret = GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_value_stringify (fwidget, value);
-               }
-
-       if (ret)
-               {
-                       ops = priv->on_change_ops;
-                       while (ops != NULL)
-                               {
-                                       op = (GtkFormWidgetOnChangeOp *)ops->data;
-                                       switch (op->type)
-                                               {
-                                                       case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
-                                                               {
-                                                                       GtkFormWidgetOnChangeOpUpdate *op_update = (GtkFormWidgetOnChangeOpUpdate *)op;
-                                                                       if (IS_GTK_FORM (priv->form)
-                                                                           && (op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_AFTER
-                                                                               || op_update->when == GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH))
-                                                                               {
-                                                                                       execute_on_change_op (fwidget, op_update);
-                                                                               }
-                                                               }
-                                                               break;
-                                               }
-
-                                       ops = g_slist_next (ops);
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_set_editable:
- * @fwidget: a #GtkFormWidget object.
- * @editable:
- *
- */
-void
-gtk_form_widget_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       if (IS_GTK_FORM_WIDGET (fwidget) && GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_editable != NULL)
-               {
-                       GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_editable (fwidget, editable);
-               }
-}
-
-/**
- * gtk_form_widget_set_visible:
- * @fwidget: a #GtkFormWidget object.
- * @visible:
- *
- */
-void
-gtk_form_widget_set_visible (GtkFormWidget *fwidget, gboolean visible)
-{
-       GtkFormWidgetPrivate *priv;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       if (visible)
-               {
-                       if (GTK_IS_WIDGET (priv->label))
-                               {
-                                       gtk_widget_show (priv->label);
-                               }
-                       gtk_widget_show (priv->widget);
-               }
-       else
-               {
-                       if (GTK_IS_WIDGET (priv->label))
-                               {
-                                       gtk_widget_hide (priv->label);
-                               }
-                       gtk_widget_hide (priv->widget);
-               }
-}
-
-/**
- * gtk_form_widget_add_on_change_op:
- * @fwidget:
- * @op:
- *
- */
-void
-gtk_form_widget_add_on_change_op (GtkFormWidget *fwidget, GtkFormWidgetOnChangeOp *op)
-{
-       GtkFormWidgetPrivate *priv;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
-       g_return_if_fail (op != NULL);
-
-       priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       switch (op->type)
-               {
-                       case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
-                               priv->on_change_ops = g_slist_append (priv->on_change_ops, g_memdup (op, sizeof (GtkFormWidgetOnChangeOpUpdate)));
-                               break;
-               }
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_set_property (GObject *object,
-                          guint property_id,
-                          const GValue *value,
-                          GParamSpec *pspec)
-{
-       GtkFormWidget *fwidget = (GtkFormWidget *)object;
-
-       GtkFormWidgetPrivate *priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       switch (property_id)
-               {
-                       case PROP_FORM:
-                               priv->form = g_value_get_object (value);
-                               break;
-
-                       case PROP_FIELD:
-                               priv->field = g_value_get_object (value);
-                               break;
-
-                       case PROP_WIDGET:
-                               priv->widget = g_value_get_object (value);
-                               break;
-
-                       case PROP_NAME:
-                               priv->widget_name = g_strstrip (g_strdup (g_value_get_string (value)));
-                               break;
-
-                       case PROP_LABEL:
-                               gtk_form_widget_set_label (fwidget, GTK_WIDGET (g_value_get_object (value)));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_get_property (GObject *object,
-                          guint property_id,
-                          GValue *value,
-                          GParamSpec *pspec)
-{
-       GtkFormWidget *fwidget = (GtkFormWidget *)object;
-
-       GtkFormWidgetPrivate *priv = GTK_FORM_WIDGET_GET_PRIVATE (fwidget);
-
-       switch (property_id)
-               {
-                       case PROP_FORM:
-                               g_value_set_object (value, priv->form);
-                               break;
-
-                       case PROP_FIELD:
-                               g_value_set_object (value, priv->field);
-                               break;
-
-                       case PROP_WIDGET:
-                               g_value_set_object (value, priv->widget);
-                               break;
-
-                       case PROP_NAME:
-                               g_value_set_string (value, priv->widget_name);
-                               break;
-
-                       case PROP_LABEL:
-                               g_value_set_object (value, gtk_form_widget_get_label (fwidget));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/widget.h b/src/widget.h
deleted file mode 100644 (file)
index 391e1d3..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_H__
-#define __LIBGTK_FORM_WIDGET_H__
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include <libgdaex/libgdaex.h>
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET                 (gtk_form_widget_get_type ())
-#define GTK_FORM_WIDGET(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET, GtkFormWidget))
-#define GTK_FORM_WIDGET_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET, GtkFormWidgetClass))
-#define IS_GTK_FORM_WIDGET(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET))
-#define IS_GTK_FORM_WIDGET_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET))
-#define GTK_FORM_WIDGET_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET, GtkFormWidgetClass))
-
-
-typedef struct _GtkFormWidget GtkFormWidget;
-typedef struct _GtkFormWidgetClass GtkFormWidgetClass;
-
-struct _GtkFormWidget
-       {
-               GObject parent;
-       };
-
-struct _GtkFormWidgetClass
-       {
-               GObjectClass parent_class;
-
-               gchar *(*get_value_stringify) (GtkFormWidget *fwidget);
-
-               gboolean (*set_value_stringify) (GtkFormWidget *fwidget, const gchar *value);
-
-               void (*set_editable) (GtkFormWidget *fwidget, gboolean editable);
-       };
-
-GType gtk_form_widget_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_new (void);
-
-gboolean gtk_form_widget_set_from_gtkbuilder (GtkFormWidget *fwidget,
-                                              GtkBuilder *gtkbuilder,
-                                              const gchar *widget_name);
-
-GtkWidget *gtk_form_widget_get_widget (GtkFormWidget *fwidget);
-
-gchar *gtk_form_widget_get_widget_name (GtkFormWidget *fwidget);
-
-GtkWidget *gtk_form_widget_get_label (GtkFormWidget *fwidget);
-void gtk_form_widget_set_label (GtkFormWidget *fwidget, GtkWidget *label);
-
-gchar *gtk_form_widget_get_value_stringify (GtkFormWidget *fwidget);
-
-gboolean gtk_form_widget_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-void gtk_form_widget_set_visible (GtkFormWidget *fwidget, gboolean visible);
-
-typedef enum
-{
-       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE
-} GtkFormWidgetOnChangeOpType;
-
-typedef struct
-{
-       GtkFormWidgetOnChangeOpType type;
-} GtkFormWidgetOnChangeOp;
-
-typedef enum
-{
-       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BEFORE,
-       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_AFTER,
-       GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE_BOTH
-} GtkFormWidgetOnChangeOpUpdateWhen;
-
-typedef struct
-{
-       GtkFormWidgetOnChangeOp op;
-       gchar *form_widget_name;
-       gchar *connection_name;
-       gchar *sql;
-       GtkFormWidgetOnChangeOpUpdateWhen when;
-} GtkFormWidgetOnChangeOpUpdate;
-
-void gtk_form_widget_add_on_change_op (GtkFormWidget *fwidget, GtkFormWidgetOnChangeOp *op);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_H__ */
diff --git a/src/widgetcheck.c b/src/widgetcheck.c
deleted file mode 100644 (file)
index f9e1b01..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include "widgetcheck.h"
-
-enum
-{
-       PROP_0
-};
-
-static void gtk_form_widget_check_class_init (GtkFormWidgetCheckClass *klass);
-static void gtk_form_widget_check_init (GtkFormWidgetCheck *gtk_form_widget_check);
-
-static void gtk_form_widget_check_set_property (GObject *object,
-                                            guint property_id,
-                                            const GValue *value,
-                                            GParamSpec *pspec);
-static void gtk_form_widget_check_get_property (GObject *object,
-                                            guint property_id,
-                                            GValue *value,
-                                            GParamSpec *pspec);
-
-static gboolean check_value (const gchar *value);
-
-#define GTK_FORM_WIDGET_CHECK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheckPrivate))
-
-typedef struct _GtkFormWidgetCheckPrivate GtkFormWidgetCheckPrivate;
-struct _GtkFormWidgetCheckPrivate
-       {
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetCheck, gtk_form_widget_check, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_check_class_init (GtkFormWidgetCheckClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_check_set_property;
-       object_class->get_property = gtk_form_widget_check_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_check_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_check_set_value_stringify;
-       widget_class->set_editable = gtk_form_widget_check_set_editable;
-
-       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetCheckPrivate));*/
-}
-
-static void
-gtk_form_widget_check_init (GtkFormWidgetCheck *gtk_form_widget_check)
-{
-}
-
-/**
- * gtk_form_widget_check_new:
- *
- * Returns: the newly created #GtkFormWidgetCheck.
- */
-GtkFormWidget
-*gtk_form_widget_check_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET_CHECK, NULL);
-}
-
-/**
- * gtk_form_widget_check_get_value_stringify:
- * @widget:
- *
- */
-gchar
-*gtk_form_widget_check_get_value_stringify (GtkFormWidget *fwidget)
-{
-       GtkWidget *w;
-       gchar *ret;
-
-       ret = g_strdup ("FALSE");
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_CHECK (fwidget), ret);
-
-       w = gtk_form_widget_get_widget (fwidget);
-
-       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
-               {
-                       ret = g_strdup ("TRUE");
-               }
-       else if (gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (w)))
-               {
-                       ret = g_strdup ("");
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_check_set_value_stringify:
- * @fwidget:
- * @value:
- *
- */
-gboolean
-gtk_form_widget_check_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkWidget *w;
-       gboolean active = FALSE;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_CHECK (fwidget), FALSE);
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       active = check_value (value);
-
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), active);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_check_set_editable:
- * @fwidget: a #GtkFormWidget object.
- * @editable:
- *
- */
-void
-gtk_form_widget_check_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       GtkWidget *w;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET_CHECK (fwidget));
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_widget_set_sensitive (w, editable);
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_check_set_property (GObject *object,
-                                guint property_id,
-                                const GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetCheck *widget_check = (GtkFormWidgetCheck *)object;
-
-       GtkFormWidgetCheckPrivate *priv = GTK_FORM_WIDGET_CHECK_GET_PRIVATE (widget_check);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_check_get_property (GObject *object,
-                                guint property_id,
-                                GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetCheck *widget_check = (GtkFormWidgetCheck *)object;
-
-       GtkFormWidgetCheckPrivate *priv = GTK_FORM_WIDGET_CHECK_GET_PRIVATE (widget_check);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static gboolean
-check_value (const gchar *value)
-{
-       gchar *str_value;
-       gboolean active;
-
-       active = FALSE;
-
-       str_value = g_strstrip (g_strdup (value));
-
-       if (strcmp (str_value, "0") == 0
-           || strcasecmp (str_value, "f") == 0
-           || strcasecmp (str_value, "false") == 0
-           || strcasecmp (str_value, "n") == 0
-           || strcasecmp (str_value, "no") == 0)
-               {
-                       active = FALSE;
-               }
-       else if (strcmp (str_value, "1") == 0
-           || strcasecmp (str_value, "t") == 0
-           || strcasecmp (str_value, "true") == 0
-           || strcasecmp (str_value, "y") == 0
-           || strcasecmp (str_value, "yes") == 0)
-               {
-                       active = TRUE;
-               }
-
-       return active;
-}
diff --git a/src/widgetcheck.h b/src/widgetcheck.h
deleted file mode 100644 (file)
index f257fb3..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_CHECK_H__
-#define __LIBGTK_FORM_WIDGET_CHECK_H__
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET_CHECK                 (gtk_form_widget_check_get_type ())
-#define GTK_FORM_WIDGET_CHECK(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheck))
-#define GTK_FORM_WIDGET_CHECK_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheckClass))
-#define IS_GTK_FORM_WIDGET_CHECK(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_CHECK))
-#define IS_GTK_FORM_WIDGET_CHECK_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_CHECK))
-#define GTK_FORM_WIDGET_CHECK_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_CHECK, GtkFormWidgetCheckClass))
-
-
-typedef struct _GtkFormWidgetCheck GtkFormWidgetCheck;
-typedef struct _GtkFormWidgetCheckClass GtkFormWidgetCheckClass;
-
-struct _GtkFormWidgetCheck
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetCheckClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_check_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_check_new (void);
-
-gchar *gtk_form_widget_check_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_check_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_check_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_CHECK_H__ */
diff --git a/src/widgetcombobox.c b/src/widgetcombobox.c
deleted file mode 100644 (file)
index 0e52d58..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <gtk/gtk.h>
-
-#include "widgetcombobox.h"
-
-enum
-{
-       PROP_0,
-       PROP_COLUMN_FIELD
-};
-
-static void gtk_form_widget_combo_box_class_init (GtkFormWidgetComboBoxClass *klass);
-static void gtk_form_widget_combo_box_init (GtkFormWidgetComboBox *gtk_form_widget_combo_box);
-
-static void gtk_form_widget_combo_box_set_property (GObject *object,
-                                                guint property_id,
-                                                const GValue *value,
-                                                GParamSpec *pspec);
-static void gtk_form_widget_combo_box_get_property (GObject *object,
-                                                guint property_id,
-                                                GValue *value,
-                                                GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBoxPrivate))
-
-typedef struct _GtkFormWidgetComboBoxPrivate GtkFormWidgetComboBoxPrivate;
-struct _GtkFormWidgetComboBoxPrivate
-       {
-               gint column_field;
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetComboBox, gtk_form_widget_combo_box, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_combo_box_class_init (GtkFormWidgetComboBoxClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_combo_box_set_property;
-       object_class->get_property = gtk_form_widget_combo_box_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_combo_box_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_combo_box_set_value_stringify;
-       widget_class->set_editable = gtk_form_widget_combo_box_set_editable;
-
-       g_object_class_install_property (object_class, PROP_COLUMN_FIELD,
-                                        g_param_spec_int ("column-field",
-                                                          "Column Field",
-                                                          "Column's Field",
-                                                          G_MININT,
-                                                          G_MAXINT,
-                                                          0,
-                                                          G_PARAM_READWRITE));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormWidgetComboBoxPrivate));
-}
-
-static void
-gtk_form_widget_combo_box_init (GtkFormWidgetComboBox *gtk_form_widget_combo_box)
-{
-}
-
-/**
- * gtk_form_widget_combo_box_new:
- *
- * Returns: the newly created #GtkFormWidgetComboBox.
- */
-GtkFormWidget
-*gtk_form_widget_combo_box_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET_COMBO_BOX, NULL);
-}
-
-/**
- * gtk_form_widget_combo_box_get_value_stringify:
- * @fwidget: a #GtkFormWidget object.
- *
- */
-gchar
-*gtk_form_widget_combo_box_get_value_stringify (GtkFormWidget *fwidget)
-{
-       gchar *ret;
-       GtkWidget *w;
-       GtkFormWidgetComboBoxPrivate *priv;
-       GtkTreeModel *tmodel;
-
-       ret = g_strdup ("");
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_COMBO_BOX (fwidget), ret);
-
-       w = gtk_form_widget_get_widget (fwidget);
-
-       priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (fwidget);
-
-       tmodel = gtk_combo_box_get_model (GTK_COMBO_BOX (w));
-       if (tmodel != NULL)
-               {
-                       GtkTreeIter iter;
-
-                       if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &iter))
-                               {
-                                       GValue *gvalue = g_malloc0 (sizeof (GValue));
-                                       GValue *gvstr = g_malloc0 (sizeof (GValue));
-
-                                       gtk_tree_model_get_value (tmodel, &iter, priv->column_field, gvalue);
-
-                                       g_value_init (gvstr, G_TYPE_STRING);
-                                       g_value_transform (gvalue, gvstr);
-                               
-                                       ret = g_strdup (g_value_get_string (gvstr));
-
-                                       g_value_unset (gvstr);
-                                       g_value_unset (gvalue);
-                               }
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_combo_box_set_value_stringify:
- * @fwidget: a #GtkFormWidget object.
- * @value:
- *
- */
-gboolean
-gtk_form_widget_combo_box_set_value_stringify (GtkFormWidget *fwidget,
-                                               const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkWidget *w;
-       GtkTreeModel *tmodel;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_COMBO_BOX (fwidget), FALSE);
-
-       GtkFormWidgetComboBoxPrivate *priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (fwidget);
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_combo_box_set_active (GTK_COMBO_BOX (w), -1);
-
-       tmodel = gtk_combo_box_get_model (GTK_COMBO_BOX (w));
-       if (tmodel != NULL)
-               {
-                       GtkTreeIter iter;
-               
-                       if (gtk_tree_model_get_iter_first (tmodel, &iter))
-                               {
-                                       do
-                                               {
-                                                       GValue *gvalue = g_malloc0 (sizeof (GValue));
-                                                       GValue *gvstr = g_malloc0 (sizeof (GValue));
-
-                                                       gtk_tree_model_get_value (tmodel, &iter, priv->column_field, gvalue);
-
-                                                       g_value_init (gvstr, G_TYPE_STRING);
-                                                       g_value_transform (gvalue, gvstr);
-                                                       if (strcmp (g_value_get_string (gvstr), value) == 0)
-                                                               {
-                                                                       gtk_combo_box_set_active_iter (GTK_COMBO_BOX (w), &iter);
-                                                                       break;
-                                                               }
-
-                                               } while (gtk_tree_model_iter_next (tmodel, &iter));
-                               }
-               }
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_combo_box_set_editable:
- * @fwidget: a #GtkFormWidget object.
- * @editable:
- *
- */
-void
-gtk_form_widget_combo_box_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_widget_set_sensitive (w, editable);
-}
-
-/**
- * gtk_form_widget_combo_box_fill_from_datamodel:
- * @fwidget: a #GtkFormWidget object.
- * @dm:
- * @with_empty_entry:
- *
- */
-void
-gtk_form_widget_combo_box_fill_from_datamodel (GtkFormWidget *fwidget, GdaDataModel *dm, gboolean with_empty_entry)
-{
-       GtkWidget *w;
-
-       GtkTreeModel *model;
-       GtkTreeIter iter;
-       guint rows;
-       guint row;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET_COMBO_BOX (fwidget));
-       g_return_if_fail (GDA_IS_DATA_MODEL (dm));
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       model = gtk_combo_box_get_model (GTK_COMBO_BOX (w));
-       g_return_if_fail (GTK_IS_TREE_MODEL (model));
-
-       if (with_empty_entry)
-               {
-                       gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-                       gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-                                                           0, "",
-                                                           1, "",
-                                                           -1);
-               }
-
-       rows = gda_data_model_get_n_rows (dm);
-       for (row = 0; row < rows; row++)
-               {
-                       gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-                       gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-                                           0, gdaex_data_model_get_value_stringify_at (dm, row, 0),
-                                           1, gdaex_data_model_get_value_stringify_at (dm, row, 1),
-                                           -1);
-               }
-}
-
-/**
- * gtk_form_widget_combo_box_fill_from_sql:
- * @fwidget: a #GtkFormWidget object.
- * @gdaex:
- * @sql:
- * @with_empty_entry:
- *
- */
-void
-gtk_form_widget_combo_box_fill_from_sql (GtkFormWidget *fwidget, GdaEx *gdaex, const gchar *sql, gboolean with_empty_entry)
-{
-       GdaEx *real_gdaex;
-       GdaDataModel *dm;
-
-       real_gdaex = NULL;
-
-       if (IS_GDAEX (gdaex))
-               {
-                       real_gdaex = gdaex;
-               }
-       else
-               {
-                       g_object_get (G_OBJECT (fwidget),
-                                             "gdaex", &real_gdaex,
-                                             NULL);
-               }
-
-       g_return_if_fail (real_gdaex != NULL);
-
-       dm = gdaex_query (real_gdaex, sql);
-       gtk_form_widget_combo_box_fill_from_datamodel (fwidget, dm, with_empty_entry);
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_combo_box_set_property (GObject *object,
-                                    guint property_id,
-                                    const GValue *value,
-                                    GParamSpec *pspec)
-{
-       GtkFormWidgetComboBox *widget_combo_box = (GtkFormWidgetComboBox *)object;
-
-       GtkFormWidgetComboBoxPrivate *priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (widget_combo_box);
-
-       switch (property_id)
-               {
-                       case PROP_COLUMN_FIELD:
-                               priv->column_field = g_value_get_int (value);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_combo_box_get_property (GObject *object,
-                                    guint property_id,
-                                    GValue *value,
-                                    GParamSpec *pspec)
-{
-       GtkFormWidgetComboBox *widget_combo_box = (GtkFormWidgetComboBox *)object;
-
-       GtkFormWidgetComboBoxPrivate *priv = GTK_FORM_WIDGET_COMBO_BOX_GET_PRIVATE (widget_combo_box);
-
-       switch (property_id)
-               {
-                       case PROP_COLUMN_FIELD:
-                               g_value_set_int (value, priv->column_field);
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/widgetcombobox.h b/src/widgetcombobox.h
deleted file mode 100644 (file)
index 4d28236..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_COMBO_BOX_H__
-#define __LIBGTK_FORM_WIDGET_COMBO_BOX_H__
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET_COMBO_BOX                 (gtk_form_widget_combo_box_get_type ())
-#define GTK_FORM_WIDGET_COMBO_BOX(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBox))
-#define GTK_FORM_WIDGET_COMBO_BOX_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBoxClass))
-#define IS_GTK_FORM_WIDGET_COMBO_BOX(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX))
-#define IS_GTK_FORM_WIDGET_COMBO_BOX_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_COMBO_BOX))
-#define GTK_FORM_WIDGET_COMBO_BOX_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_COMBO_BOX, GtkFormWidgetComboBoxClass))
-
-
-typedef struct _GtkFormWidgetComboBox GtkFormWidgetComboBox;
-typedef struct _GtkFormWidgetComboBoxClass GtkFormWidgetComboBoxClass;
-
-struct _GtkFormWidgetComboBox
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetComboBoxClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_combo_box_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_combo_box_new (void);
-
-gchar *gtk_form_widget_combo_box_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_combo_box_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_combo_box_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-void gtk_form_widget_combo_box_fill_from_datamodel (GtkFormWidget *fwidget, GdaDataModel *dm, gboolean with_empty_entry);
-void gtk_form_widget_combo_box_fill_from_sql (GtkFormWidget *fwidget, GdaEx *gdaex, const gchar *sql, gboolean with_empty_entry);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_COMBO_BOX_H__ */
diff --git a/src/widgetentry.c b/src/widgetentry.c
deleted file mode 100644 (file)
index 687d92b..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <gtk/gtk.h>
-
-#include "widgetentry.h"
-
-enum
-{
-       PROP_0
-};
-
-static void gtk_form_widget_entry_class_init (GtkFormWidgetEntryClass *klass);
-static void gtk_form_widget_entry_init (GtkFormWidgetEntry *gtk_form_widget_entry);
-
-static void gtk_form_widget_entry_set_property (GObject *object,
-                                      guint property_id,
-                                      const GValue *value,
-                                      GParamSpec *pspec);
-static void gtk_form_widget_entry_get_property (GObject *object,
-                                      guint property_id,
-                                      GValue *value,
-                                      GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntryPrivate))
-
-typedef struct _GtkFormWidgetEntryPrivate GtkFormWidgetEntryPrivate;
-struct _GtkFormWidgetEntryPrivate
-       {
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetEntry, gtk_form_widget_entry, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_entry_class_init (GtkFormWidgetEntryClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_entry_set_property;
-       object_class->get_property = gtk_form_widget_entry_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_entry_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_entry_set_value_stringify;
-       widget_class->set_editable = gtk_form_widget_entry_set_editable;
-
-       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetEntryPrivate));*/
-}
-
-static void
-gtk_form_widget_entry_init (GtkFormWidgetEntry *gtk_form_widget_entry)
-{
-}
-
-/**
- * gtk_form_widget_entry_new:
- *
- * Returns: the newly created #GtkFormWidgetEntry.
- */
-GtkFormWidget
-*gtk_form_widget_entry_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET_ENTRY, NULL);
-}
-
-/**
- * gtk_form_widget_entry_get_value_stringify:
- * @widget:
- *
- */
-gchar
-*gtk_form_widget_entry_get_value_stringify (GtkFormWidget *fwidget)
-{
-       GtkWidget *w = gtk_form_widget_get_widget (fwidget);
-
-       return g_strdup (gtk_entry_get_text (GTK_ENTRY (w)));
-}
-
-/**
- * gtk_form_widget_entry_set_value_stringify:
- * @fwidget:
- * @value:
- *
- */
-gboolean
-gtk_form_widget_entry_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_entry_set_text (GTK_ENTRY (w), value);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_set_editable:
- * @fwidget:
- * @editable:
- *
- */
-void
-gtk_form_widget_entry_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_editable_set_editable (GTK_EDITABLE (w), editable);
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_entry_set_property (GObject *object,
-                                guint property_id,
-                                const GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetEntry *widget_entry = (GtkFormWidgetEntry *)object;
-
-       GtkFormWidgetEntryPrivate *priv = GTK_FORM_WIDGET_ENTRY_GET_PRIVATE (widget_entry);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_entry_get_property (GObject *object,
-                                guint property_id,
-                                GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetEntry *widget_entry = (GtkFormWidgetEntry *)object;
-
-       GtkFormWidgetEntryPrivate *priv = GTK_FORM_WIDGET_ENTRY_GET_PRIVATE (widget_entry);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/widgetentry.h b/src/widgetentry.h
deleted file mode 100644 (file)
index 62f38b9..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_ENTRY_H__
-#define __LIBGTK_FORM_WIDGET_ENTRY_H__
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET_ENTRY                 (gtk_form_widget_entry_get_type ())
-#define GTK_FORM_WIDGET_ENTRY(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntry))
-#define GTK_FORM_WIDGET_ENTRY_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntryClass))
-#define IS_GTK_FORM_WIDGET_ENTRY(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_ENTRY))
-#define IS_GTK_FORM_WIDGET_ENTRY_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_ENTRY))
-#define GTK_FORM_WIDGET_ENTRY_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_ENTRY, GtkFormWidgetEntryClass))
-
-
-typedef struct _GtkFormWidgetEntry GtkFormWidgetEntry;
-typedef struct _GtkFormWidgetEntryClass GtkFormWidgetEntryClass;
-
-struct _GtkFormWidgetEntry
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetEntryClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_entry_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_entry_new (void);
-
-gchar *gtk_form_widget_entry_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_entry_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_entry_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_ENTRY_H__ */
diff --git a/src/widgetlabel.c b/src/widgetlabel.c
deleted file mode 100644 (file)
index 6f984fb..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <gtk/gtk.h>
-
-#include "widgetlabel.h"
-
-enum
-{
-       PROP_0
-};
-
-static void gtk_form_widget_label_class_init (GtkFormWidgetLabelClass *klass);
-static void gtk_form_widget_label_init (GtkFormWidgetLabel *gtk_form_widget_label);
-
-static void gtk_form_widget_label_set_property (GObject *object,
-                                      guint property_id,
-                                      const GValue *value,
-                                      GParamSpec *pspec);
-static void gtk_form_widget_label_get_property (GObject *object,
-                                      guint property_id,
-                                      GValue *value,
-                                      GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabelPrivate))
-
-typedef struct _GtkFormWidgetLabelPrivate GtkFormWidgetLabelPrivate;
-struct _GtkFormWidgetLabelPrivate
-       {
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetLabel, gtk_form_widget_label, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_label_class_init (GtkFormWidgetLabelClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_label_set_property;
-       object_class->get_property = gtk_form_widget_label_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_label_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_label_set_value_stringify;
-
-       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetLabelPrivate));*/
-}
-
-static void
-gtk_form_widget_label_init (GtkFormWidgetLabel *gtk_form_widget_label)
-{
-}
-
-/**
- * gtk_form_widget_label_new:
- *
- * Returns: the newly created #GtkFormWidgetLabel.
- */
-GtkFormWidget
-*gtk_form_widget_label_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET_LABEL, NULL);
-}
-
-/**
- * gtk_form_widget_label_get_value_stringify:
- * @widget:
- *
- */
-gchar
-*gtk_form_widget_label_get_value_stringify (GtkFormWidget *fwidget)
-{
-       GtkWidget *w = gtk_form_widget_get_widget (fwidget);;
-
-       return g_strdup (gtk_label_get_text (GTK_LABEL (w)));
-}
-
-/**
- * gtk_form_widget_label_set_value_stringify:
- * @fwidget:
- * @value:
- *
- */
-gboolean
-gtk_form_widget_label_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_label_set_text (GTK_LABEL (w), value);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_label_set_property (GObject *object,
-                                guint property_id,
-                                const GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetLabel *widget_label = (GtkFormWidgetLabel *)object;
-
-       GtkFormWidgetLabelPrivate *priv = GTK_FORM_WIDGET_LABEL_GET_PRIVATE (widget_label);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_label_get_property (GObject *object,
-                                guint property_id,
-                                GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetLabel *widget_label = (GtkFormWidgetLabel *)object;
-
-       GtkFormWidgetLabelPrivate *priv = GTK_FORM_WIDGET_LABEL_GET_PRIVATE (widget_label);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/widgetlabel.h b/src/widgetlabel.h
deleted file mode 100644 (file)
index 42024a3..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_LABEL_H__
-#define __LIBGTK_FORM_WIDGET_LABEL_H__
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET_LABEL                 (gtk_form_widget_label_get_type ())
-#define GTK_FORM_WIDGET_LABEL(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabel))
-#define GTK_FORM_WIDGET_LABEL_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabelClass))
-#define IS_GTK_FORM_WIDGET_LABEL(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_LABEL))
-#define IS_GTK_FORM_WIDGET_LABEL_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_LABEL))
-#define GTK_FORM_WIDGET_LABEL_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_LABEL, GtkFormWidgetLabelClass))
-
-
-typedef struct _GtkFormWidgetLabel GtkFormWidgetLabel;
-typedef struct _GtkFormWidgetLabelClass GtkFormWidgetLabelClass;
-
-struct _GtkFormWidgetLabel
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetLabelClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_label_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_label_new (void);
-
-gchar *gtk_form_widget_label_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_label_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_LABEL_H__ */
diff --git a/src/widgetradio.c b/src/widgetradio.c
deleted file mode 100644 (file)
index 552ac6f..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include "widgetradio.h"
-
-enum
-{
-       PROP_0,
-       PROP_RETURN_VALUE
-};
-
-static void gtk_form_widget_radio_class_init (GtkFormWidgetRadioClass *klass);
-static void gtk_form_widget_radio_init (GtkFormWidgetRadio *gtk_form_widget_radio);
-
-static void gtk_form_widget_radio_set_property (GObject *object,
-                                            guint property_id,
-                                            const GValue *value,
-                                            GParamSpec *pspec);
-static void gtk_form_widget_radio_get_property (GObject *object,
-                                            guint property_id,
-                                            GValue *value,
-                                            GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_RADIO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadioPrivate))
-
-typedef struct _GtkFormWidgetRadioPrivate GtkFormWidgetRadioPrivate;
-struct _GtkFormWidgetRadioPrivate
-       {
-               gchar *value;
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetRadio, gtk_form_widget_radio, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_radio_class_init (GtkFormWidgetRadioClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_radio_set_property;
-       object_class->get_property = gtk_form_widget_radio_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_radio_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_radio_set_value_stringify;
-       widget_class->set_editable = gtk_form_widget_radio_set_editable;
-
-       g_object_class_install_property (object_class, PROP_RETURN_VALUE,
-                                        g_param_spec_string ("return-value",
-                                                          "Return value",
-                                                          "Return value",
-                                                          "",
-                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_type_class_add_private (object_class, sizeof (GtkFormWidgetRadioPrivate));
-}
-
-static void
-gtk_form_widget_radio_init (GtkFormWidgetRadio *gtk_form_widget_radio)
-{
-}
-
-/**
- * gtk_form_widget_radio_new:
- *
- * Returns: the newly created #GtkFormWidgetRadio.
- */
-GtkFormWidget
-*gtk_form_widget_radio_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET_RADIO, NULL);
-}
-
-/**
- * gtk_form_widget_radio_get_value_stringify:
- * @widget:
- *
- */
-gchar
-*gtk_form_widget_radio_get_value_stringify (GtkFormWidget *fwidget)
-{
-       GSList *group;
-       GtkWidget *w;
-       gchar *ret;
-       GtkFormWidgetRadioPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget), "");
-
-       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (fwidget);
-
-       w = gtk_form_widget_get_widget (fwidget);
-
-       ret = g_strdup ("");
-
-       /* always returns the value of the group's active radio button */
-       group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
-       while (group != NULL)
-               {
-                       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (group->data)))
-                               {
-                                       ret = (gchar *)g_object_get_data (G_OBJECT (group->data), "return-value");
-                                       if (ret == NULL)
-                                               {
-                                                       ret = g_strdup ("");
-                                               }
-                                       break;
-                               }
-
-                       group = g_slist_next (group);
-               }
-
-       return g_strdup (ret);
-}
-
-/**
- * gtk_form_widget_radio_set_value_stringify:
- * @fwidget:
- * @value:
- *
- */
-gboolean
-gtk_form_widget_radio_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret;
-       GtkWidget *w;
-
-       GSList *group;
-
-       GtkFormWidgetRadioPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget), FALSE);
-
-       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (GTK_FORM_WIDGET_RADIO (fwidget));
-
-       ret = FALSE;
-
-       w = gtk_form_widget_get_widget (fwidget);
-
-       /* always set only the right group's radio button */
-       group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
-       while (group != NULL)
-               {
-                       if (g_strcmp0 ((gchar *)g_object_get_data (G_OBJECT (group->data), "return-value"), value) == 0)
-                               {
-                                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->data), TRUE);
-                                       break;
-                               }
-
-                       group = g_slist_next (group);
-               }
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_radio_set_editable:
- * @fwidget: a #GtkFormWidget object.
- * @editable:
- *
- */
-void
-gtk_form_widget_radio_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       GtkWidget *w;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget));
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_widget_set_sensitive (w, editable);
-}
-
-/**
- * gtk_form_widget_radio_set_return_value:
- * @fwidget: a #GtkFormWidgetRadio object.
- * @value:
- *
- */
-void
-gtk_form_widget_radio_set_return_value (GtkFormWidgetRadio *fwidget, const gchar *value)
-{
-       GtkFormWidgetRadioPrivate *priv;
-       GtkWidget *widget;
-
-       g_return_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget));
-
-       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (fwidget);
-
-       if (value == NULL)
-               {
-                       priv->value = g_strdup ("");
-               }
-       else
-               {
-                       priv->value = g_strdup (value);
-               }
-
-       widget = gtk_form_widget_get_widget (GTK_FORM_WIDGET (fwidget));
-       if (GTK_IS_WIDGET (widget))
-               {
-                       g_object_set_data (G_OBJECT (widget), "return-value", (gpointer)priv->value);
-               }
-}
-
-/**
- * gtk_form_widget_radio_get_return_value:
- * @fwidget: a #GtkFormWidgetRadio object.
- *
- */
-gchar
-*gtk_form_widget_radio_get_return_value (GtkFormWidgetRadio *fwidget)
-{
-       GtkFormWidgetRadioPrivate *priv;
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_RADIO (fwidget), NULL);
-
-       priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (fwidget);
-
-       return g_strdup (priv->value);
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_radio_set_property (GObject *object,
-                                guint property_id,
-                                const GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetRadio *widget_radio = (GtkFormWidgetRadio *)object;
-
-       GtkFormWidgetRadioPrivate *priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (widget_radio);
-
-       switch (property_id)
-               {
-                       case PROP_RETURN_VALUE:
-                               gtk_form_widget_radio_set_return_value (widget_radio, g_value_get_string (value));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_radio_get_property (GObject *object,
-                                guint property_id,
-                                GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetRadio *widget_radio = (GtkFormWidgetRadio *)object;
-
-       GtkFormWidgetRadioPrivate *priv = GTK_FORM_WIDGET_RADIO_GET_PRIVATE (widget_radio);
-
-       switch (property_id)
-               {
-                       case PROP_RETURN_VALUE:
-                               g_value_set_string (value, gtk_form_widget_radio_get_return_value (widget_radio));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/widgetradio.h b/src/widgetradio.h
deleted file mode 100644 (file)
index 19d0fba..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2005-2010 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_RADIO_H__
-#define __LIBGTK_FORM_WIDGET_RADIO_H__
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET_RADIO                 (gtk_form_widget_radio_get_type ())
-#define GTK_FORM_WIDGET_RADIO(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadio))
-#define GTK_FORM_WIDGET_RADIO_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadioClass))
-#define IS_GTK_FORM_WIDGET_RADIO(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_RADIO))
-#define IS_GTK_FORM_WIDGET_RADIO_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_RADIO))
-#define GTK_FORM_WIDGET_RADIO_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_RADIO, GtkFormWidgetRadioClass))
-
-
-typedef struct _GtkFormWidgetRadio GtkFormWidgetRadio;
-typedef struct _GtkFormWidgetRadioClass GtkFormWidgetRadioClass;
-
-struct _GtkFormWidgetRadio
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetRadioClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_radio_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_radio_new (void);
-
-gchar *gtk_form_widget_radio_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_radio_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_radio_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-void gtk_form_widget_radio_set_return_value (GtkFormWidgetRadio *fwidget, const gchar *value);
-gchar *gtk_form_widget_radio_get_return_value (GtkFormWidgetRadio *fwidget);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_RADIO_H__ */
diff --git a/src/widgetspin.c b/src/widgetspin.c
deleted file mode 100644 (file)
index 6487165..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <stdlib.h>
-
-#include <gtk/gtk.h>
-
-#include "widgetspin.h"
-
-enum
-{
-       PROP_0
-};
-
-static void gtk_form_widget_spin_class_init (GtkFormWidgetSpinClass *klass);
-static void gtk_form_widget_spin_init (GtkFormWidgetSpin *gtk_form_widget_spin);
-
-static void gtk_form_widget_spin_set_property (GObject *object,
-                                           guint property_id,
-                                           const GValue *value,
-                                           GParamSpec *pspec);
-static void gtk_form_widget_spin_get_property (GObject *object,
-                                           guint property_id,
-                                           GValue *value,
-                                           GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_SPIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpinPrivate))
-
-typedef struct _GtkFormWidgetSpinPrivate GtkFormWidgetSpinPrivate;
-struct _GtkFormWidgetSpinPrivate
-       {
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetSpin, gtk_form_widget_spin, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_spin_class_init (GtkFormWidgetSpinClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_spin_set_property;
-       object_class->get_property = gtk_form_widget_spin_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_spin_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_spin_set_value_stringify;
-       widget_class->set_editable = gtk_form_widget_spin_set_editable;
-
-       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetSpinPrivate));*/
-}
-
-static void
-gtk_form_widget_spin_init (GtkFormWidgetSpin *gtk_form_widget_spin)
-{
-}
-
-/**
- * gtk_form_widget_spin_new:
- *
- * Returns: the newly created #GtkFormWidgetSpin.
- */
-GtkFormWidget
-*gtk_form_widget_spin_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET_SPIN, NULL);
-}
-
-/**
- * gtk_form_widget_spin_get_value_stringify:
- * @widget: a #GtkFormWidget object.
- *
- */
-gchar
-*gtk_form_widget_spin_get_value_stringify (GtkFormWidget *fwidget)
-{
-       GtkWidget *w;
-       gchar *ret;
-
-       ret = g_strdup ("");
-
-       g_return_val_if_fail (IS_GTK_FORM_WIDGET_SPIN (fwidget), ret);
-
-       w = gtk_form_widget_get_widget (fwidget);
-
-       if (w != NULL)
-               {
-                       ret = g_strdup_printf ("%f", gtk_spin_button_get_value (GTK_SPIN_BUTTON (w)));
-               }
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_spin_set_value_stringify:
- * @fwidget: a #GtkFormWidget object.
- * @value:
- *
- */
-gboolean
-gtk_form_widget_spin_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), g_strtod (value, NULL));
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_spin_set_editable:
- * @fwidget: a #GtkFormWidget object.
- * @editable:
- *
- */
-void
-gtk_form_widget_spin_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_editable_set_editable (GTK_EDITABLE (w), editable);
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_spin_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec)
-{
-       GtkFormWidgetSpin *widget_spin = (GtkFormWidgetSpin *)object;
-
-       GtkFormWidgetSpinPrivate *priv = GTK_FORM_WIDGET_SPIN_GET_PRIVATE (widget_spin);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_spin_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec)
-{
-       GtkFormWidgetSpin *widget_spin = (GtkFormWidgetSpin *)object;
-
-       GtkFormWidgetSpinPrivate *priv = GTK_FORM_WIDGET_SPIN_GET_PRIVATE (widget_spin);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/widgetspin.h b/src/widgetspin.h
deleted file mode 100644 (file)
index 886350f..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_SPIN_H__
-#define __LIBGTK_FORM_WIDGET_SPIN_H__
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET_SPIN                 (gtk_form_widget_spin_get_type ())
-#define GTK_FORM_WIDGET_SPIN(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpin))
-#define GTK_FORM_WIDGET_SPIN_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpinClass))
-#define IS_GTK_FORM_WIDGET_SPIN(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_SPIN))
-#define IS_GTK_FORM_WIDGET_SPIN_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_SPIN))
-#define GTK_FORM_WIDGET_SPIN_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_SPIN, GtkFormWidgetSpinClass))
-
-
-typedef struct _GtkFormWidgetSpin GtkFormWidgetSpin;
-typedef struct _GtkFormWidgetSpinClass GtkFormWidgetSpinClass;
-
-struct _GtkFormWidgetSpin
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetSpinClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_spin_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_spin_new (void);
-
-gchar *gtk_form_widget_spin_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_spin_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_spin_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_SPIN_H__ */
diff --git a/src/widgettextview.c b/src/widgettextview.c
deleted file mode 100644 (file)
index 18928d3..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <gtk/gtk.h>
-
-#include "widgettextview.h"
-
-enum
-{
-       PROP_0
-};
-
-static void gtk_form_widget_textview_class_init (GtkFormWidgetTextviewClass *klass);
-static void gtk_form_widget_textview_init (GtkFormWidgetTextview *gtk_form_widget_textview);
-
-static void gtk_form_widget_textview_set_property (GObject *object,
-                                      guint property_id,
-                                      const GValue *value,
-                                      GParamSpec *pspec);
-static void gtk_form_widget_textview_get_property (GObject *object,
-                                      guint property_id,
-                                      GValue *value,
-                                      GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_TEXTVIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextviewPrivate))
-
-typedef struct _GtkFormWidgetTextviewPrivate GtkFormWidgetTextviewPrivate;
-struct _GtkFormWidgetTextviewPrivate
-       {
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetTextview, gtk_form_widget_textview, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_textview_class_init (GtkFormWidgetTextviewClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_textview_set_property;
-       object_class->get_property = gtk_form_widget_textview_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_textview_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_textview_set_value_stringify;
-       widget_class->set_editable = gtk_form_widget_textview_set_editable;
-
-       /*g_type_class_add_private (object_class, sizeof (GtkFormWidgetTextviewPrivate));*/
-}
-
-static void
-gtk_form_widget_textview_init (GtkFormWidgetTextview *gtk_form_widget_textview)
-{
-}
-
-/**
- * gtk_form_widget_textview_new:
- *
- * Returns: the newly created #GtkFormWidgetTextview.
- */
-GtkFormWidget
-*gtk_form_widget_textview_new ()
-{
-       return g_object_new (TYPE_GTK_FORM_WIDGET_TEXTVIEW, NULL);
-}
-
-/**
- * gtk_form_widget_textview_get_value_stringify:
- * @widget: a #GtkFormWidget object.
- *
- */
-gchar
-*gtk_form_widget_textview_get_value_stringify (GtkFormWidget *fwidget)
-{
-       gchar *ret = NULL;
-       GtkWidget *w;
-       GtkTextBuffer *buf;
-       GtkTextIter start;
-       GtkTextIter end;
-
-       w = gtk_form_widget_get_widget (fwidget);
-
-       buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
-       gtk_text_buffer_get_bounds (buf, &start, &end);
-       ret = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_textview_set_value_stringify:
- * @fwidget: a #GtkFormWidget object.
- * @value:
- *
- */
-gboolean
-gtk_form_widget_textview_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkWidget *w;
-       GtkTextBuffer *buf;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
-       gtk_text_buffer_set_text (buf, value, -1);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_textview_set_editable:
- * @fwidget: a #GtkFormWidget object.
- * @editable:
- *
- */
-void
-gtk_form_widget_textview_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_text_view_set_editable (GTK_TEXT_VIEW (w), editable);
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_textview_set_property (GObject *object,
-                                   guint property_id,
-                                   const GValue *value,
-                                   GParamSpec *pspec)
-{
-       GtkFormWidgetTextview *widget_textview = (GtkFormWidgetTextview *)object;
-
-       GtkFormWidgetTextviewPrivate *priv = GTK_FORM_WIDGET_TEXTVIEW_GET_PRIVATE (widget_textview);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
-
-static void
-gtk_form_widget_textview_get_property (GObject *object,
-                                   guint property_id,
-                                   GValue *value,
-                                   GParamSpec *pspec)
-{
-       GtkFormWidgetTextview *widget_textview = (GtkFormWidgetTextview *)object;
-
-       GtkFormWidgetTextviewPrivate *priv = GTK_FORM_WIDGET_TEXTVIEW_GET_PRIVATE (widget_textview);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-         }
-}
diff --git a/src/widgettextview.h b/src/widgettextview.h
deleted file mode 100644 (file)
index dcadf36..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2005-2009 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_TEXTVIEW_H__
-#define __LIBGTK_FORM_WIDGET_TEXTVIEW_H__
-
-#include "widget.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_GTK_FORM_WIDGET_TEXTVIEW                 (gtk_form_widget_textview_get_type ())
-#define GTK_FORM_WIDGET_TEXTVIEW(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextview))
-#define GTK_FORM_WIDGET_TEXTVIEW_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextviewClass))
-#define IS_GTK_FORM_WIDGET_TEXTVIEW(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW))
-#define IS_GTK_FORM_WIDGET_TEXTVIEW_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_WIDGET_TEXTVIEW))
-#define GTK_FORM_WIDGET_TEXTVIEW_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_WIDGET_TEXTVIEW, GtkFormWidgetTextviewClass))
-
-
-typedef struct _GtkFormWidgetTextview GtkFormWidgetTextview;
-typedef struct _GtkFormWidgetTextviewClass GtkFormWidgetTextviewClass;
-
-struct _GtkFormWidgetTextview
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetTextviewClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_textview_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_textview_new (void);
-
-gchar *gtk_form_widget_textview_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_textview_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_textview_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_TEXTVIEW_H__ */
index 944cfbe03d56afe69b8c5601c6a51cdc5f1e089e..c3ee566ebf8d0c3605b813ef4ada689ae97702ba 100644 (file)
@@ -2,7 +2,7 @@ LIBS = $(GTKFORM_LIBS) \
        -export-dynamic
 
 AM_CPPFLAGS = $(GTKFORM_CFLAGS) \
-              -I$(top_srcdir)/src \
+              -I$(top_srcdir) \
               -DGUIDIR="\"@abs_builddir@\""
 
 noinst_PROGRAMS = test \
@@ -11,7 +11,7 @@ noinst_PROGRAMS = test \
 
 test_SOURCES = main.c
 
-LDADD = $(top_builddir)/src/libgtkform.la
+LDADD = $(top_builddir)/libgtkform/libgtkform.la
 
 EXTRA_DIST = database.db \
              test.gui \
index 6e8efcb6aa28dcd8976c54c5b91d7195b181381a..edb72a6723fbc8de12802118a21919e5d00fd11b 100644 (file)
 
 #include <gtk/gtk.h>
 
-#include "form.h"
-#include "field.h"
-#include "fieldboolean.h"
-#include "fielddatetime.h"
-#include "fieldinteger.h"
-#include "fieldfloat.h"
-#include "fieldtext.h"
-#include "widget.h"
-#include "widgetcheck.h"
-#include "widgetcombobox.h"
-#include "widgetentry.h"
-#include "widgetlabel.h"
-#include "widgetspin.h"
-#include "widgettextview.h"
+#include <libgtkform/form.h>
+#include <libgtkform/field.h>
+#include <libgtkform/fieldboolean.h>
+#include <libgtkform/fielddatetime.h>
+#include <libgtkform/fieldinteger.h>
+#include <libgtkform/fieldfloat.h>
+#include <libgtkform/fieldtext.h>
+#include <libgtkform/widget.h>
+#include <libgtkform/widgetcheck.h>
+#include <libgtkform/widgetcombobox.h>
+#include <libgtkform/widgetentry.h>
+#include <libgtkform/widgetlabel.h>
+#include <libgtkform/widgetspin.h>
+#include <libgtkform/widgettextview.h>
 
 GtkForm *form;
 
index 1b1729fe61b172e5b1c1ed9305475d8baf6d8494..6715599f613c75dd4c4454bf66fc78b16508265c 100644 (file)
 
 #include <libgdaex/libgdaex.h>
 
-#include "form.h"
-#include "field.h"
-#include "fieldboolean.h"
-#include "fielddatetime.h"
-#include "fieldinteger.h"
-#include "fieldfloat.h"
-#include "fieldtext.h"
-#include "widget.h"
-#include "widgetcheck.h"
-#include "widgetcombobox.h"
-#include "widgetentry.h"
-#include "widgetlabel.h"
-#include "widgetspin.h"
-#include "widgettextview.h"
+#include <libgtkform/form.h>
+#include <libgtkform/field.h>
+#include <libgtkform/fieldboolean.h>
+#include <libgtkform/fielddatetime.h>
+#include <libgtkform/fieldinteger.h>
+#include <libgtkform/fieldfloat.h>
+#include <libgtkform/fieldtext.h>
+#include <libgtkform/widget.h>
+#include <libgtkform/widgetcheck.h>
+#include <libgtkform/widgetcombobox.h>
+#include <libgtkform/widgetentry.h>
+#include <libgtkform/widgetlabel.h>
+#include <libgtkform/widgetspin.h>
+#include <libgtkform/widgettextview.h>
 
 GdaEx *gdaex;
 
index 03e7597176c17dc84f39ac73e6ba798ccbb75cd8..d614182086787f3836b87ed4820f06d3f5e30a29 100644 (file)
 
 #include <gtk/gtk.h>
 
-#include "form.h"
-#include "field.h"
-#include "fieldboolean.h"
-#include "fielddatetime.h"
-#include "fieldinteger.h"
-#include "fieldfloat.h"
-#include "fieldtext.h"
-#include "widget.h"
-#include "widgetcheck.h"
-#include "widgetcombobox.h"
-#include "widgetentry.h"
-#include "widgetlabel.h"
-#include "widgetspin.h"
-#include "widgettextview.h"
+#include <libgtkform/form.h>
+#include <libgtkform/field.h>
+#include <libgtkform/fieldboolean.h>
+#include <libgtkform/fielddatetime.h>
+#include <libgtkform/fieldinteger.h>
+#include <libgtkform/fieldfloat.h>
+#include <libgtkform/fieldtext.h>
+#include <libgtkform/widget.h>
+#include <libgtkform/widgetcheck.h>
+#include <libgtkform/widgetcombobox.h>
+#include <libgtkform/widgetentry.h>
+#include <libgtkform/widgetlabel.h>
+#include <libgtkform/widgetspin.h>
+#include <libgtkform/widgettextview.h>
 
 GtkForm *form;
 
diff --git a/ui/Makefile.am b/ui/Makefile.am
deleted file mode 100644 (file)
index 5f127a8..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-if GLADEUI
-GLADEDIR = glade
-else
-GLADEDIR =
-endif
-
-if PLATFORM_WIN32
-libmodulesext = -0.dll
-libmodulesdir = $(bindir)
-else
-libmodulesext = .so
-libmodulesdir = $(libdir)
-endif
-
-SUBDIRS = . \
-          test \
-          $(GLADEDIR)
-
-AM_CPPFLAGS = $(WARN_CFLAGS) \
-              $(DISABLE_DEPRECATED_CFLAGS) \
-              $(GTKFORM_CFLAGS) \
-              -DLOCALEDIR=\"$(localedir)\" \
-              -DMODULESDIR=\""$(libdir)/$(PACKAGE)/modules"\" \
-              -DG_LOG_DOMAIN=\"GtkFormUI\"
-
-LIBS = $(GTKFORM_LIBS)
-
-lib_LTLIBRARIES = libgtkformui.la
-
-libgtkformui_la_SOURCES = gtkformdecoder.c \
-                          gtkformwidgetdecoder.c
-
-libgtkformui_la_LIBADD = $(top_builddir)/src/libgtkform.la
-
-libgtkformui_la_LDFLAGS = -no-undefined
-
-libgtkformui_include_HEADERS = gtkformdecoder.h \
-                               gtkformwidgetdecoder.h
-
-libgtkformui_includedir = $(includedir)/libgtkformui
-
-install-exec-hook:
-       cd $(libdir)/$(PACKAGE)/modules && \
-       ln -s -f $(libmodulesdir)/libgtkformui$(libmodulesext) .
-
-uninstall-hook:
-       rm -f $(libdir)/$(PACKAGE)/modules/libgtkformui$(libmodulesext)
diff --git a/ui/glade/Makefile.am b/ui/glade/Makefile.am
deleted file mode 100644 (file)
index be8b722..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-SUBDIRS = icons
-
-glademodulesdir = `pkg-config --variable=moduledir gladeui-1.0`
-
-gladecatalogsdir = `pkg-config --variable=catalogdir gladeui-1.0`
-
-gladecatalogs_DATA = gtkformui.xml
-
-EXTRA_DIST = $(gladecatalogs_DATA)
-
-if PLATFORM_WIN32
-libmodulesext = -0.dll
-libmodulesextglade = .dll
-libmodulesdir = $(bindir)
-else
-libmodulesext = .so
-libmodulesextglade = $(libmodulesext)
-libmodulesdir = $(libdir)
-endif
-
-install-exec-hook:
-       cd $(glademodulesdir) && \
-       ln -s -f $(libmodulesdir)/libgtkformui$(libmodulesext) libgtkformui$(libmodulesextglade)
-
-uninstall-hook:
-       rm -f $(glademodulesdir)/libgtkformui$(libmodulesextglade)
diff --git a/ui/glade/gtkformui.xml b/ui/glade/gtkformui.xml
deleted file mode 100644 (file)
index 7dc1f93..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<glade-catalog name="gtkformui" library="gtkformui" depends="gtk+" domain="gtkformui" book="gtkformui">
-
-       <glade-widget-classes>
-               <glade-widget-class name="GtkFormDecoder" generic-name="gtkformdecoder" title="Decoder">
-                       <properties>
-                               <property name="GdaEx object" id="gdaex" visible="False" />
-                               <property name="Sql statement" id="sql" />
-                               <property name="Show clean icon" id="show-btn-clean" />
-                               <property name="Show open button" id="show-btn-open" />
-                               <property name="Show browse button" id="show-btn-browse" />
-                       </properties>
-               </glade-widget-class>
-       </glade-widget-classes>
-
-       <glade-widget-group name="gtk-control-display" title="Control and Display">
-               <glade-widget-class-ref name="GtkFormDecoder" />
-       </glade-widget-group>
-
-</glade-catalog>
diff --git a/ui/glade/icons/Makefile.am b/ui/glade/icons/Makefile.am
deleted file mode 100644 (file)
index 658356b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = hicolor
diff --git a/ui/glade/icons/hicolor/16x16/Makefile.am b/ui/glade/icons/hicolor/16x16/Makefile.am
deleted file mode 100644 (file)
index 0224d45..0000000
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = actions
diff --git a/ui/glade/icons/hicolor/16x16/actions/Makefile.am b/ui/glade/icons/hicolor/16x16/actions/Makefile.am
deleted file mode 100644 (file)
index ccf8100..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-iconsdir = `pkg-config --variable=pixmapdir gladeui-1.0`/hicolor/16x16/actions
-
-icons_DATA = widget-gtkformui-gtkformdecoder.png
-
-EXTRA_DIST = $(icons_DATA)
diff --git a/ui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png b/ui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png
deleted file mode 100644 (file)
index 9796233..0000000
Binary files a/ui/glade/icons/hicolor/16x16/actions/widget-gtkformui-gtkformdecoder.png and /dev/null differ
diff --git a/ui/glade/icons/hicolor/22x22/Makefile.am b/ui/glade/icons/hicolor/22x22/Makefile.am
deleted file mode 100644 (file)
index 0224d45..0000000
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = actions
diff --git a/ui/glade/icons/hicolor/22x22/actions/Makefile.am b/ui/glade/icons/hicolor/22x22/actions/Makefile.am
deleted file mode 100644 (file)
index 35aa85a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-iconsdir = `pkg-config --variable=pixmapdir gladeui-1.0`/hicolor/22x22/actions
-
-icons_DATA = widget-gtkformui-gtkformdecoder.png
-
-EXTRA_DIST = $(icons_DATA)
diff --git a/ui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png b/ui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png
deleted file mode 100644 (file)
index d26591a..0000000
Binary files a/ui/glade/icons/hicolor/22x22/actions/widget-gtkformui-gtkformdecoder.png and /dev/null differ
diff --git a/ui/glade/icons/hicolor/Makefile.am b/ui/glade/icons/hicolor/Makefile.am
deleted file mode 100644 (file)
index fc1d169..0000000
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = 16x16 22x22
diff --git a/ui/gtkformdecoder.c b/ui/gtkformdecoder.c
deleted file mode 100644 (file)
index 2023cf1..0000000
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * GtkFormDecoder widget for GTK+
- *
- * Copyright (C) 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
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <glib/gi18n-lib.h>
-
-#include <sql-parser/gda-sql-parser.h>
-
-#include <libgdaex/libgdaex.h>
-
-#include "gtkformdecoder.h"
-
-enum
-{
-       PROP_0,
-       PROP_GDAEX,
-       PROP_SQL,
-       PROP_SHOW_CLEAN,
-       PROP_SHOW_OPEN,
-       PROP_SHOW_BROWSE
-};
-
-static void gtk_form_decoder_class_init (GtkFormDecoderClass *klass);
-static void gtk_form_decoder_init (GtkFormDecoder *decoder);
-
-static void gtk_form_decoder_decode (GtkFormDecoder *decoder);
-
-static void gtk_form_decoder_size_request (GtkWidget *widget,
-                                    GtkRequisition *requisition);
-static void gtk_form_decoder_size_allocate (GtkWidget *widget,
-                                     GtkAllocation *allocation);
-
-static void gtk_form_decoder_set_property (GObject *object,
-                                           guint property_id,
-                                           const GValue *value,
-                                           GParamSpec *pspec);
-static void gtk_form_decoder_get_property (GObject *object,
-                                           guint property_id,
-                                           GValue *value,
-                                           GParamSpec *pspec);
-
-static void gtk_form_decoder_on_btn_clean_clicked (GtkEntry *entry,
-                                         GtkEntryIconPosition icon_pos,
-                                         GdkEvent *event,
-                                         gpointer user_data);
-
-static void gtk_form_decoder_on_btn_open_clicked (GtkButton *button,
-                                        gpointer user_data);
-
-static void gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
-                                        gpointer user_data);
-
-static GtkWidgetClass *parent_class = NULL;
-
-
-#define GTK_FORM_DECODER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_FORM_DECODER, GtkFormDecoderPrivate))
-
-typedef struct _GtkFormDecoderPrivate GtkFormDecoderPrivate;
-struct _GtkFormDecoderPrivate
-       {
-               GtkWidget *hbox;
-               GtkWidget *txt_decoded;
-               GtkWidget *btn_open;
-               GtkWidget *btn_browse;
-               GtkWidget *lbl_key;
-
-               GdaEx *gdaex;
-               gchar *sql;
-       };
-
-G_DEFINE_TYPE (GtkFormDecoder, gtk_form_decoder, GTK_TYPE_BIN)
-
-static void
-gtk_form_decoder_class_init (GtkFormDecoderClass *klass)
-{
-       GtkWidgetClass *widget_class;
-
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-       g_type_class_add_private (object_class, sizeof (GtkFormDecoderPrivate));
-
-       widget_class = (GtkWidgetClass*) klass;
-       parent_class = g_type_class_peek_parent (klass);
-
-       object_class->set_property = gtk_form_decoder_set_property;
-       object_class->get_property = gtk_form_decoder_get_property;
-
-       widget_class->size_request = gtk_form_decoder_size_request;
-       widget_class->size_allocate = gtk_form_decoder_size_allocate;
-
-       g_object_class_install_property (object_class, PROP_GDAEX,
-                                        g_param_spec_object ("gdaex",
-                                                             "GdaEx object",
-                                                             "GdaEx object",
-                                                             TYPE_GDAEX,
-                                                             G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_SQL,
-                                        g_param_spec_string ("sql",
-                                                             "Sql string",
-                                                             "Sql string",
-                                                             NULL,
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class, PROP_SHOW_CLEAN,
-                                        g_param_spec_boolean ("show-btn-clean",
-                                                              "Show clean icon",
-                                                              "Whether to show the clean icon",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_SHOW_OPEN,
-                                        g_param_spec_boolean ("show-btn-open",
-                                                              "Show open button",
-                                                              "Whether to show the open button",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE));
-
-       g_object_class_install_property (object_class, PROP_SHOW_BROWSE,
-                                        g_param_spec_boolean ("show-btn-browse",
-                                                              "Show browse button",
-                                                              "Whether to show the browse button",
-                                                              TRUE,
-                                                              G_PARAM_READWRITE));
-
-       /**
-        * GtkFormDecoder::btn_clean_clicked:
-        * @gtk_form_decoder:
-        *
-        */
-       klass->btn_clean_clicked_signal_id = g_signal_new ("btn-clean-clicked",
-                                                      G_TYPE_FROM_CLASS (object_class),
-                                                      G_SIGNAL_RUN_LAST,
-                                                      0,
-                                                      NULL,
-                                                      NULL,
-                                                      g_cclosure_marshal_BOOLEAN__FLAGS,
-                                                      G_TYPE_BOOLEAN,
-                                                      1, G_TYPE_INT);
-
-       /**
-        * GtkFormDecoder::btn_open_clicked:
-        * @gtk_form_decoder:
-        *
-        */
-       klass->btn_open_clicked_signal_id = g_signal_new ("btn-open-clicked",
-                                                      G_TYPE_FROM_CLASS (object_class),
-                                                      G_SIGNAL_RUN_LAST,
-                                                      0,
-                                                      NULL,
-                                                      NULL,
-                                                      g_cclosure_marshal_VOID__VOID,
-                                                      G_TYPE_NONE,
-                                                      0);
-
-       /**
-        * GtkFormDecoder::btn_browse_clicked:
-        * @gtk_form_decoder:
-        *
-        */
-       klass->btn_browse_clicked_signal_id = g_signal_new ("btn-browse-clicked",
-                                                      G_TYPE_FROM_CLASS (object_class),
-                                                      G_SIGNAL_RUN_LAST,
-                                                      0,
-                                                      NULL,
-                                                      NULL,
-                                                      g_cclosure_marshal_VOID__VOID,
-                                                      G_TYPE_NONE,
-                                                      0);
-}
-
-static void
-gtk_form_decoder_init (GtkFormDecoder *decoder)
-{
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       GtkWidget *icon;
-
-       priv->hbox = gtk_hbox_new (FALSE, 3);
-       gtk_container_add (GTK_CONTAINER (decoder), priv->hbox);
-       gtk_widget_show (priv->hbox);
-
-       priv->txt_decoded = gtk_entry_new ();
-       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->txt_decoded, TRUE, TRUE, 0);
-       gtk_editable_set_editable (GTK_EDITABLE (priv->txt_decoded), FALSE);
-       gtk_widget_show (priv->txt_decoded);
-
-       g_signal_connect (G_OBJECT (priv->txt_decoded), "icon-press",
-                         G_CALLBACK (gtk_form_decoder_on_btn_clean_clicked), (gpointer)decoder);
-
-       priv->btn_open = gtk_button_new ();
-       gtk_widget_set_tooltip_text (priv->btn_open, _("Open"));
-       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->btn_open, FALSE, FALSE, 0);
-       gtk_widget_set_no_show_all (priv->btn_open, TRUE);
-       icon = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
-       gtk_container_add (GTK_CONTAINER (priv->btn_open), icon);
-       gtk_widget_show (icon);
-
-       g_signal_connect (G_OBJECT (priv->btn_open), "clicked",
-                         G_CALLBACK (gtk_form_decoder_on_btn_open_clicked), (gpointer)decoder);
-
-       priv->btn_browse = gtk_button_new_with_label ("...");
-       gtk_widget_set_tooltip_text (priv->btn_browse, _("Find"));
-       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->btn_browse, FALSE, FALSE, 0);
-       gtk_widget_set_no_show_all (priv->btn_browse, TRUE);
-       gtk_widget_show (priv->btn_browse);
-
-       g_signal_connect (G_OBJECT (priv->btn_browse), "clicked",
-                         G_CALLBACK (gtk_form_decoder_on_btn_browse_clicked), (gpointer)decoder);
-
-       priv->lbl_key = gtk_label_new ("");
-       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->lbl_key, FALSE, FALSE, 0);
-       gtk_widget_set_no_show_all (priv->lbl_key, TRUE);
-}
-
-/**
- * gtk_form_decoder_new:
- *
- * Creates a new #GtkFormDecoder.
- *
- * Returns: The newly created #GtkFormDecoder widget.
- */
-GtkWidget
-*gtk_form_decoder_new ()
-{
-       GtkWidget *w = GTK_WIDGET (g_object_new (gtk_form_decoder_get_type (), NULL));
-
-       return w;
-}
-
-void
-gtk_form_decoder_set_key (GtkFormDecoder *decoder, const gchar *key)
-{
-       GtkFormDecoderPrivate *priv;
-
-       g_return_if_fail (GTK_IS_FORM_DECODER (decoder));
-
-       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       gtk_label_set_text (GTK_LABEL (priv->lbl_key), key);
-       gtk_form_decoder_decode (decoder);
-}
-
-gchar
-*gtk_form_decoder_get_key (GtkFormDecoder *decoder)
-{
-       GtkFormDecoderPrivate *priv;
-
-       g_return_val_if_fail (GTK_IS_FORM_DECODER (decoder), NULL);
-
-       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       return g_strdup (gtk_label_get_text (GTK_LABEL (priv->lbl_key)));
-}
-
-gchar
-*gtk_form_decoder_get_decoded (GtkFormDecoder *decoder)
-{
-       GtkFormDecoderPrivate *priv;
-
-       g_return_val_if_fail (GTK_IS_FORM_DECODER (decoder), NULL);
-
-       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       return g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->txt_decoded)));
-}
-
-/* PRIVATE */
-static void
-gtk_form_decoder_decode (GtkFormDecoder *decoder)
-{
-       GtkFormDecoderPrivate *priv;
-
-       GObject *res;
-       GdaConnection *gdacon;
-       GdaSqlParser *parser;
-       GdaStatement *stmt;
-       GdaSet *params;
-       GSList *hs;
-       GdaHolder *h;
-       GValue *gval;
-       GError *error;
-
-       g_return_if_fail (GTK_IS_FORM_DECODER (decoder));
-
-       priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       if (IS_GDAEX (priv->gdaex))
-               {
-                       gdacon = (GdaConnection *)gdaex_get_gdaconnection (priv->gdaex);
-                       parser = gda_connection_create_parser (gdacon);
-                       if (parser == NULL)
-                               {
-                                       parser = gda_sql_parser_new ();
-                               }
-
-                       error == NULL;
-                       stmt = gda_sql_parser_parse_string (parser, priv->sql, NULL, &error);
-                       if (stmt == NULL)
-                               {
-                                       g_warning (_("Error on parsing sql string: %s\n%s"), priv->sql,
-                                                  error != NULL && error->message != NULL ? error->message : "no details");
-                               }
-                       else
-                               {
-                                       gda_statement_get_parameters (stmt, &params, NULL);
-                                       if (params != NULL)
-                                               {
-                                                       hs = params->holders;
-                                                       while (hs != NULL)
-                                                               {
-                                                                       h = (GdaHolder *)hs->data;
-
-                                                                       if (GDA_IS_HOLDER (h))
-                                                                               {
-                                                                                       gval = gda_value_new_from_string (gtk_label_get_text (GTK_LABEL (priv->lbl_key)), gda_holder_get_g_type (h));
-
-                                                                                       error = NULL;
-                                                                                       if (!gda_holder_set_value (h, gval, &error))
-                                                                                               {
-                                                                                                       g_warning (_("Error on setting holder's value: %s"),
-                                                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
-                                                                                               }
-                                                                               }
-                                                                       hs = g_slist_next (hs);
-                                                               }
-                                               }
-
-                                       error = NULL;
-                                       res = gda_connection_statement_execute (gdacon, stmt, params,
-                                                                               GDA_STATEMENT_MODEL_RANDOM_ACCESS,
-                                                                               NULL, &error);
-                                       if (res == NULL)
-                                               {
-                                                       g_warning (_("Error on executing decoding: %s"),
-                                                                  error != NULL && error->message != NULL ? error->message : "no details");
-                                               }
-                                       else if (GDA_IS_DATA_MODEL (res) && gda_data_model_get_n_rows ((GdaDataModel *)res) == 1)
-                                               {
-                                                       gtk_entry_set_text (GTK_ENTRY (priv->txt_decoded),
-                                                                           gdaex_data_model_get_value_stringify_at ((GdaDataModel *)res, 0, 0));
-                                               }
-                                       else
-                                               {
-                                                       gtk_entry_set_text (GTK_ENTRY (priv->txt_decoded), "");
-                                               }
-                               }
-               }
-       else
-               {
-                       g_warning (_("No GdaEx object inside GtkFormDecoder."));
-               }
-}
-
-void
-gtk_form_decoder_show_btn_clean (GtkFormDecoder *decoder, gboolean visible)
-{
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, visible ? "gtk-clear" : NULL);
-       gtk_entry_set_icon_activatable (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, visible);
-       gtk_entry_set_icon_sensitive (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY, visible);
-}
-
-void
-gtk_form_decoder_show_btn_open (GtkFormDecoder *decoder, gboolean visible)
-{
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       gtk_widget_set_visible (priv->btn_open, visible);
-}
-
-void
-gtk_form_decoder_show_btn_browse (GtkFormDecoder *decoder, gboolean visible)
-{
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       gtk_widget_set_visible (priv->btn_browse, visible);
-}
-
-gboolean
-gtk_form_decoder_btn_clean_is_visible (GtkFormDecoder *decoder)
-{
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       return gtk_entry_get_icon_stock (GTK_ENTRY (priv->txt_decoded), GTK_ENTRY_ICON_SECONDARY) != NULL;
-}
-
-gboolean
-gtk_form_decoder_btn_open_is_visible (GtkFormDecoder *decoder)
-{
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       return gtk_widget_get_visible (priv->btn_open);
-}
-
-gboolean
-gtk_form_decoder_btn_browse_is_visible (GtkFormDecoder *decoder)
-{
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       return gtk_widget_get_visible (priv->btn_browse);
-}
-
-/* CALLBACKS */
-static void
-gtk_form_decoder_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
-       GtkFormDecoder *decoder = GTK_FORM_DECODER (object);
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       switch (property_id)
-               {
-                       case PROP_GDAEX:
-                               priv->gdaex = g_value_get_object (value);
-                               break;
-
-                       case PROP_SQL:
-                               if (G_VALUE_HOLDS_STRING (value))
-                                       {
-                                               priv->sql = g_value_dup_string (value);
-                                               if (priv->sql != NULL)
-                                                       {
-                                                               g_strstrip (priv->sql);
-                                                       }
-                                       }
-                               else
-                                       {
-                                               g_free (priv->sql);
-                                               priv->sql = NULL;
-                                       }
-                               break;
-
-                       case PROP_SHOW_CLEAN:
-                               gtk_form_decoder_show_btn_clean (decoder, g_value_get_boolean (value));
-                               break;
-
-                       case PROP_SHOW_OPEN:
-                               gtk_form_decoder_show_btn_open (decoder, g_value_get_boolean (value));
-                               break;
-
-                       case PROP_SHOW_BROWSE:
-                               gtk_form_decoder_show_btn_browse (decoder, g_value_get_boolean (value));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-gtk_form_decoder_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
-       GtkFormDecoder *decoder = GTK_FORM_DECODER (object);
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-
-       switch (property_id)
-               {
-                       case PROP_GDAEX:
-                               g_value_set_object (value, priv->gdaex);
-                               break;
-
-                       case PROP_SQL:
-                               g_value_set_string (value, priv->sql);
-                               break;
-
-                       case PROP_SHOW_CLEAN:
-                               g_value_set_boolean (value, gtk_form_decoder_btn_clean_is_visible (decoder));
-                               break;
-
-                       case PROP_SHOW_OPEN:
-                               g_value_set_boolean (value, gtk_form_decoder_btn_open_is_visible (decoder));
-                               break;
-
-                       case PROP_SHOW_BROWSE:
-                               g_value_set_boolean (value, gtk_form_decoder_btn_browse_is_visible (decoder));
-                               break;
-
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-gtk_form_decoder_size_request (GtkWidget *widget,
-                        GtkRequisition *requisition)
-{
-       GtkFormDecoder *decoder;
-       GtkBin *bin;
-       GtkRequisition child_requisition;
-
-       guint border_width;
-
-       g_return_if_fail (GTK_IS_FORM_DECODER (widget));
-       g_return_if_fail (requisition != NULL);
-
-       decoder = GTK_FORM_DECODER (widget);
-       bin = GTK_BIN (decoder);
-
-       requisition->width = 0;
-       requisition->height = 0;
-
-       if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
-               {
-                       gtk_widget_size_request (bin->child, &child_requisition);
-                       requisition->width += child_requisition.width;
-                       requisition->height += child_requisition.height;
-               }
-
-       border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-       requisition->width += (border_width * 2);
-       requisition->height += (border_width * 2);
-}
-
-static void
-gtk_form_decoder_size_allocate (GtkWidget *widget,
-                         GtkAllocation *allocation)
-{
-       GtkFormDecoder *decoder;
-       GtkBin *bin;
-       GtkAllocation relative_allocation;
-       GtkAllocation child_allocation;
-
-       guint border_width;
-
-       g_return_if_fail (GTK_IS_FORM_DECODER (widget));
-       g_return_if_fail (allocation != NULL);
-
-       decoder = GTK_FORM_DECODER (widget);
-       bin = GTK_BIN (decoder);
-
-       gtk_widget_set_allocation (widget, allocation);
-
-       border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-       relative_allocation.x = border_width;
-       relative_allocation.y = border_width;
-       relative_allocation.width = MAX (1, (gint)widget->allocation.width - relative_allocation.x * 2);
-       relative_allocation.height = MAX (1, (gint)widget->allocation.height - relative_allocation.y * 2);
-
-       if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
-               {
-                       child_allocation.x = relative_allocation.x + allocation->x;
-                       child_allocation.y = relative_allocation.y + allocation->y;
-                       child_allocation.width = relative_allocation.width;
-                       child_allocation.height = relative_allocation.height;
-                       gtk_widget_size_allocate (bin->child, &child_allocation);
-               }
-}
-
-static void
-gtk_form_decoder_on_btn_clean_clicked (GtkEntry *entry,
-                                       GtkEntryIconPosition icon_pos,
-                                       GdkEvent *event,
-                                       gpointer user_data)
-{
-       gboolean ret;
-
-       GtkFormDecoder *decoder = (GtkFormDecoder *)user_data;
-       GtkFormDecoderPrivate *priv = GTK_FORM_DECODER_GET_PRIVATE (decoder);
-       GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS (decoder);
-
-       ret = FALSE;
-       g_signal_emit (G_OBJECT (user_data), klass->btn_clean_clicked_signal_id, 0, 0, &ret);
-
-       if (!ret)
-               {
-                       gtk_form_decoder_set_key (decoder, "0");
-               }
-}
-
-static void
-gtk_form_decoder_on_btn_open_clicked (GtkButton *button,
-                                        gpointer user_data)
-{
-       GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS ((GtkFormDecoder *)user_data);
-
-       g_signal_emit (G_OBJECT (user_data), klass->btn_open_clicked_signal_id, 0);
-}
-
-static void
-gtk_form_decoder_on_btn_browse_clicked (GtkButton *button,
-                                        gpointer user_data)
-{
-       GtkFormDecoderClass *klass = GTK_FORM_DECODER_GET_CLASS ((GtkFormDecoder *)user_data);
-
-       g_signal_emit (G_OBJECT (user_data), klass->btn_browse_clicked_signal_id, 0);
-}
diff --git a/ui/gtkformdecoder.h b/ui/gtkformdecoder.h
deleted file mode 100644 (file)
index 07a02af..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * GtkFormDecoder widget for GTK+
- *
- * Copyright (C) 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
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GTK_FORM_DECODER_H__
-#define __GTK_FORM_DECODER_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-
-#define GTK_TYPE_FORM_DECODER           (gtk_form_decoder_get_type ())
-#define GTK_FORM_DECODER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FORM_DECODER, GtkFormDecoder))
-#define GTK_FORM_DECODER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FORM_DECODER, GtkFormDecoderClass))
-#define GTK_IS_FORM_DECODER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FORM_DECODER))
-#define GTK_IS_FORM_DECODER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FORM_DECODER))
-#define GTK_FORM_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FORM_DECODER, GtkFormDecoderClass))
-
-
-typedef struct _GtkFormDecoder GtkFormDecoder;
-typedef struct _GtkFormDecoderClass GtkFormDecoderClass;
-
-
-struct _GtkFormDecoder
-{
-       GtkBin parent;
-};
-
-struct _GtkFormDecoderClass
-{
-       GtkBinClass parent_class;
-
-       guint btn_clean_clicked_signal_id;
-       guint btn_open_clicked_signal_id;
-       guint btn_browse_clicked_signal_id;
-};
-
-
-GType gtk_form_decoder_get_type (void) G_GNUC_CONST;
-
-GtkWidget *gtk_form_decoder_new (void);
-
-void gtk_form_decoder_set_key (GtkFormDecoder *decoder, const gchar *key);
-
-gchar *gtk_form_decoder_get_key (GtkFormDecoder *decoder);
-gchar *gtk_form_decoder_get_decoded (GtkFormDecoder *decoder);
-
-void gtk_form_decoder_show_btn_clean (GtkFormDecoder *decoder, gboolean visible);
-void gtk_form_decoder_show_btn_open (GtkFormDecoder *decoder, gboolean visible);
-void gtk_form_decoder_show_btn_browse (GtkFormDecoder *decoder, gboolean visible);
-
-gboolean gtk_form_decoder_btn_clean_is_visible (GtkFormDecoder *decoder);
-gboolean gtk_form_decoder_btn_open_is_visible (GtkFormDecoder *decoder);
-gboolean gtk_form_decoder_btn_browse_is_visible (GtkFormDecoder *decoder);
-
-
-G_END_DECLS
-
-#endif /* __GTK_FORM_DECODER_H__ */
diff --git a/ui/gtkformwidgetdecoder.c b/ui/gtkformwidgetdecoder.c
deleted file mode 100644 (file)
index 50cf9b3..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <gtk/gtk.h>
-
-#include <libgtkform/form.h>
-#include <libgtkform/fieldboolean.h>
-
-#include "gtkformdecoder.h"
-#include "gtkformwidgetdecoder.h"
-
-enum
-{
-       PROP_0
-};
-
-static void gtk_form_widget_decoder_class_init (GtkFormWidgetDecoderClass *klass);
-static void gtk_form_widget_decoder_init (GtkFormWidgetDecoder *gtk_form_widget_decoder);
-
-static void gtk_form_widget_decoder_set_property (GObject *object,
-                                      guint property_id,
-                                      const GValue *value,
-                                      GParamSpec *pspec);
-static void gtk_form_widget_decoder_get_property (GObject *object,
-                                      guint property_id,
-                                      GValue *value,
-                                      GParamSpec *pspec);
-
-#define GTK_FORM_WIDGET_DECODER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoderPrivate))
-
-typedef struct _GtkFormWidgetDecoderPrivate GtkFormWidgetDecoderPrivate;
-struct _GtkFormWidgetDecoderPrivate
-       {
-               gpointer foo;
-       };
-
-
-G_DEFINE_TYPE (GtkFormWidgetDecoder, gtk_form_widget_decoder, TYPE_GTK_FORM_WIDGET)
-
-static void
-gtk_form_widget_decoder_class_init (GtkFormWidgetDecoderClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkFormWidgetClass *widget_class = GTK_FORM_WIDGET_CLASS (klass);
-
-       object_class->set_property = gtk_form_widget_decoder_set_property;
-       object_class->get_property = gtk_form_widget_decoder_get_property;
-
-       widget_class->get_value_stringify = gtk_form_widget_decoder_get_value_stringify;
-       widget_class->set_value_stringify = gtk_form_widget_decoder_set_value_stringify;
-       widget_class->set_editable = gtk_form_widget_decoder_set_editable;
-
-       g_type_class_add_private (object_class, sizeof (GtkFormWidgetDecoderPrivate));
-}
-
-static void
-gtk_form_widget_decoder_init (GtkFormWidgetDecoder *gtk_form_widget_decoder)
-{
-}
-
-/**
- * gtk_form_widget_decoder_new:
- *
- * Returns: the newly created #GtkFormWidgetDecoder.
- */
-GtkFormWidget
-*gtk_form_widget_decoder_new ()
-{
-       return g_object_new (gtk_form_widget_decoder_get_type (), NULL);
-}
-
-/**
- * gtk_form_widget_decoder_xml_parsing:
- * @widget:
- * @xml_node:
- *
- */
-gboolean
-gtk_form_widget_decoder_xml_parsing (GtkFormWidget *fwidget, xmlNodePtr xml_node)
-{
-       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (fwidget);
-
-       GtkForm *form;
-       GtkWidget *w;
-
-       gchar *connection_name;
-
-       xmlNodePtr child;
-
-       if (xmlStrcmp (xml_node->name, "decoder") != 0)
-               {
-                       return FALSE;
-               }
-
-       w = gtk_form_widget_get_widget (fwidget);
-
-       connection_name = NULL;
-
-       child = xml_node->children;
-       while (child != NULL)
-               {
-                       if (xmlStrcmp (child->name, (const xmlChar *)"sql") == 0)
-                               {
-                                       g_object_set (G_OBJECT (w), "sql", (gchar *)xmlNodeGetContent (child), NULL);
-                               }
-                       else if (xmlStrcmp (child->name, (const xmlChar *)"connection-name") == 0)
-                               {
-                                       connection_name = g_strdup ((gchar *)xmlNodeGetContent (child));
-                               }
-
-                       child = child->next;
-               }
-
-       g_object_get (G_OBJECT (fwidget), "form", &form, NULL);
-       g_object_set (G_OBJECT (w), "gdaex", gtk_form_get_db_connection_by_name (form, connection_name), NULL);
-
-       return TRUE;
-}
-
-/**
- * gtk_form_widget_decoder_get_value_stringify:
- * @widget:
- *
- */
-gchar
-*gtk_form_widget_decoder_get_value_stringify (GtkFormWidget *fwidget)
-{
-       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (fwidget);
-
-       GtkWidget *w = gtk_form_widget_get_widget (fwidget);
-
-       return g_strdup (gtk_form_decoder_get_key (GTK_FORM_DECODER (w)));
-}
-
-/**
- * gtk_form_widget_decoder_set_value_stringify:
- * @fwidget:
- * @value:
- *
- */
-gboolean
-gtk_form_widget_decoder_set_value_stringify (GtkFormWidget *fwidget, const gchar *value)
-{
-       gboolean ret = FALSE;
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_form_decoder_set_key (GTK_FORM_DECODER (w), value);
-
-       ret = TRUE;
-
-       return ret;
-}
-
-/**
- * gtk_form_widget_set_editable:
- * @fwidget:
- * @editable:
- *
- */
-void
-gtk_form_widget_decoder_set_editable (GtkFormWidget *fwidget, gboolean editable)
-{
-       GtkWidget *w;
-
-       g_object_get (G_OBJECT (fwidget),
-                     "widget", &w,
-                     NULL);
-
-       gtk_widget_set_sensitive (GTK_WIDGET (w), editable);
-}
-
-/* PRIVATE */
-static void
-gtk_form_widget_decoder_set_property (GObject *object,
-                                guint property_id,
-                                const GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetDecoder *widget_entry = (GtkFormWidgetDecoder *)object;
-       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (widget_entry);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-gtk_form_widget_decoder_get_property (GObject *object,
-                                guint property_id,
-                                GValue *value,
-                                GParamSpec *pspec)
-{
-       GtkFormWidgetDecoder *widget_entry = (GtkFormWidgetDecoder *)object;
-       GtkFormWidgetDecoderPrivate *priv = GTK_FORM_WIDGET_DECODER_GET_PRIVATE (widget_entry);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
diff --git a/ui/gtkformwidgetdecoder.h b/ui/gtkformwidgetdecoder.h
deleted file mode 100644 (file)
index 20da97f..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __LIBGTK_FORM_WIDGET_DECODER_H__
-#define __LIBGTK_FORM_WIDGET_DECODER_H__
-
-#include <libgtkform/widget.h>
-
-
-G_BEGIN_DECLS
-
-
-#define GTK_FORM_TYPE_WIDGET_DECODER                 (gtk_form_widget_decoder_get_type ())
-#define GTK_FORM_WIDGET_DECODER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoder))
-#define GTK_FORM_WIDGET_DECODER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoderClass))
-#define GTK_FORM_IS_WIDGET_DECODER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_FORM_TYPE_WIDGET_DECODER))
-#define GTK_FORM_IS_WIDGET_DECODER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_FORM_TYPE_WIDGET_DECODER))
-#define GTK_FORM_WIDGET_DECODER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_FORM_TYPE_WIDGET_DECODER, GtkFormWidgetDecoderClass))
-
-
-typedef struct _GtkFormWidgetDecoder GtkFormWidgetDecoder;
-typedef struct _GtkFormWidgetDecoderClass GtkFormWidgetDecoderClass;
-
-struct _GtkFormWidgetDecoder
-       {
-               GtkFormWidget parent;
-       };
-
-struct _GtkFormWidgetDecoderClass
-       {
-               GtkFormWidgetClass parent_class;
-       };
-
-GType gtk_form_widget_decoder_get_type (void) G_GNUC_CONST;
-
-GtkFormWidget *gtk_form_widget_decoder_new (void);
-
-gboolean gtk_form_widget_decoder_xml_parsing (GtkFormWidget *fwidget, xmlNodePtr xml_node);
-
-gchar *gtk_form_widget_decoder_get_value_stringify (GtkFormWidget *widget);
-
-gboolean gtk_form_widget_decoder_set_value_stringify (GtkFormWidget *fwidget, const gchar *value);
-
-void gtk_form_widget_decoder_set_editable (GtkFormWidget *fwidget, gboolean editable);
-
-
-G_END_DECLS
-
-
-#endif /* __LIBGTK_FORM_WIDGET_DECODER_H__ */
diff --git a/ui/test/Makefile.am b/ui/test/Makefile.am
deleted file mode 100644 (file)
index 7a0133c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-LIBS = $(GTKFORM_LIBS) \
-       $(GTKFORMUI_LIBS) \
-       -export-dynamic
-
-AM_CPPFLAGS = $(GTKFORM_CFLAGS) \
-              $(GTKFORMUI_CFLAGS) \
-              -I$(top_srcdir)/src \
-              -I$(top_srcdir)/ui \
-              -DGUIDIR="\"@abs_builddir@\""
-
-noinst_PROGRAMS = decoder
-
-test_SOURCES = decoder.c
-
-LDADD = $(top_builddir)/src/libgtkform.la \
-        $(top_builddir)/ui/libgtkformui.la
-
-EXTRA_DIST = database.db
diff --git a/ui/test/database.db b/ui/test/database.db
deleted file mode 100644 (file)
index c0668b9..0000000
Binary files a/ui/test/database.db and /dev/null differ
diff --git a/ui/test/decoder.c b/ui/test/decoder.c
deleted file mode 100644 (file)
index f93f629..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <gtk/gtk.h>
-
-#include <libgdaex/libgdaex.h>
-
-#include "gtkformdecoder.h"
-
-GtkWidget *w;
-GtkWidget *decoder;
-
-GdaEx *gdaex;
-
-static gboolean
-on_btn_clean_clicked (gpointer instance, gint arg1, gpointer user_data)
-{
-       return FALSE;
-}
-
-static void
-on_btn_open_clicked (gpointer instance, gpointer user_data)
-{
-       g_debug ("Open clicked.");
-}
-
-static void
-on_btn_browse_clicked (gpointer instance, gpointer user_data)
-{
-       gtk_form_decoder_set_key (GTK_FORM_DECODER (decoder), "1");
-}
-
-gboolean
-on_w_delete_event (GtkWidget *widget,
-                   GdkEvent *event,
-                   gpointer user_data)
-{
-       return FALSE;
-}
-
-int
-main (int argc, char **argv)
-{
-       gtk_init (&argc, &argv);
-
-       gdaex = gdaex_new_from_string ("SQLite://DB_DIR=" GUIDIR ";DB_NAME=database.db");
-       if (gdaex == NULL)
-               {
-                       return 0;
-               }
-
-       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-       g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), NULL);
-       g_signal_connect (w, "destroy", gtk_main_quit, NULL);
-
-       decoder = gtk_form_decoder_new ();
-       gtk_container_add (GTK_CONTAINER (w), decoder);
-
-       g_object_set (G_OBJECT (decoder),
-                     "gdaex", gdaex,
-                     "sql", "SELECT name"
-                            " FROM customers"
-                            " WHERE id = ##key0::gint",
-                     "show-btn-clean", TRUE,
-                     "show-btn-open", TRUE,
-                     NULL);
-
-       g_signal_connect (G_OBJECT (decoder), "btn_clean_clicked",
-                         G_CALLBACK (on_btn_clean_clicked), NULL);
-       g_signal_connect (G_OBJECT (decoder), "btn_open_clicked",
-                         G_CALLBACK (on_btn_open_clicked), NULL);
-       g_signal_connect (G_OBJECT (decoder), "btn_browse_clicked",
-                         G_CALLBACK (on_btn_browse_clicked), NULL);
-
-       gtk_widget_show_all (w);
-
-       gtk_main ();
-
-       return 0;
-}