Added property "field" to GtkFormWidget.
Added functions GtkForm::add_group and GtkForm::get_group_by_name.
Bugfixes.
-<!ELEMENT gtkform (gtkbuilder-file?, table?, widget+)>
+<!ELEMENT gtkform (gtkbuilder-file?, table?, widget+, group*)>
<!ELEMENT gtkbuilder-file (#PCDATA)>
<!ELEMENT auto-increment (#PCDATA)>
<!ELEMENT datetime-type (date | time | datetime)>
<!ELEMENT display-format (#PCDATA)>
+
+<!ELEMENT group (widget*, field*)>
+
+<!ATTLIST group
+ name CDATA #REQUIRED
+>
gtk_form_widget_check_set_editable
</SECTION>
+<SECTION>
+<FILE>group</FILE>
+<TITLE>GtkFormGroup</TITLE>
+TYPE_GTK_FORM_GROUP
+GTK_FORM_GROUP
+GTK_FORM_GROUP_CLASS
+IS_GTK_FORM_GROUP
+IS_GTK_FORM_GROUP_CLASS
+GTK_FORM_GROUP_GET_CLASS
+GtkFormGroup
+GtkFormGroupClass
+gtk_form_group_get_type
+gtk_form_group_new
+gtk_form_group_get_name
+gtk_form_group_add_widget
+gtk_form_group_add_field
+gtk_form_group_clear
+gtk_form_group_set_from_datamodel
+gtk_form_group_set_from_hashtable
+</SECTION>
+
<SECTION>
<FILE>fieldboolean</FILE>
<TITLE>GtkFormFieldBoolean</TITLE>
gtk_form_fill_from_table
gtk_form_get_values_as_hashtable
gtk_form_fill_from_hashtable
+gtk_form_add_group
+gtk_form_get_group_by_name
</SECTION>
<SECTION>
GtkFormWidget *fwidget, gboolean editable
</FUNCTION>
<MACRO>
+<NAME>TYPE_GTK_FORM_GROUP</NAME>
+#define TYPE_GTK_FORM_GROUP (gtk_form_group_get_type ())
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_GROUP</NAME>
+#define GTK_FORM_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroup))
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_GROUP_CLASS</NAME>
+#define GTK_FORM_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_FORM_GROUP, GtkFormGroupClass))
+</MACRO>
+<MACRO>
+<NAME>IS_GTK_FORM_GROUP</NAME>
+#define IS_GTK_FORM_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_FORM_GROUP))
+</MACRO>
+<MACRO>
+<NAME>IS_GTK_FORM_GROUP_CLASS</NAME>
+#define IS_GTK_FORM_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_FORM_GROUP))
+</MACRO>
+<MACRO>
+<NAME>GTK_FORM_GROUP_GET_CLASS</NAME>
+#define GTK_FORM_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GTK_FORM_GROUP, GtkFormGroupClass))
+</MACRO>
+<STRUCT>
+<NAME>GtkFormGroup</NAME>
+</STRUCT>
+<STRUCT>
+<NAME>GtkFormGroupClass</NAME>
+</STRUCT>
+<STRUCT>
+<NAME>GtkFormGroup</NAME>
+struct _GtkFormGroup
+ {
+ GObject parent;
+ };
+</STRUCT>
+<STRUCT>
+<NAME>GtkFormGroupClass</NAME>
+struct _GtkFormGroupClass
+ {
+ GObjectClass parent_class;
+ };
+</STRUCT>
+<FUNCTION>
+<NAME>gtk_form_group_get_type</NAME>
+<RETURNS>GType </RETURNS>
+void
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_group_new</NAME>
+<RETURNS>GtkFormGroup *</RETURNS>
+const gchar *name
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_group_get_name</NAME>
+<RETURNS>gchar *</RETURNS>
+GtkFormGroup *group
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_group_add_widget</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormGroup *group, GtkFormWidget *fwidget
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_group_add_field</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormGroup *group, GtkFormField *field
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_group_clear</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormGroup *group
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_group_set_from_datamodel</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormGroup *group, GdaDataModel *dm, gint row
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_group_set_from_hashtable</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkFormGroup *group, GHashTable *hashtable
+</FUNCTION>
+<MACRO>
<NAME>TYPE_GTK_FORM_FIELD_BOOLEAN</NAME>
#define TYPE_GTK_FORM_FIELD_BOOLEAN (gtk_form_field_boolean_get_type ())
</MACRO>
<RETURNS>gboolean </RETURNS>
GtkForm *form, GHashTable *hashtable
</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_add_group</NAME>
+<RETURNS>gboolean </RETURNS>
+GtkForm *form, GtkFormGroup *group
+</FUNCTION>
+<FUNCTION>
+<NAME>gtk_form_get_group_by_name</NAME>
+<RETURNS>GtkFormGroup *</RETURNS>
+GtkForm *form, const gchar *group_name
+</FUNCTION>
<MACRO>
<NAME>TYPE_GTK_FORM_WIDGET_COMBO_BOX</NAME>
#define TYPE_GTK_FORM_WIDGET_COMBO_BOX (gtk_form_widget_combo_box_get_type ())
8% symbol docs coverage.
-27 symbols documented.
+28 symbols documented.
2 symbols incomplete.
-305 not documented.
+314 not documented.
GTK_FORM
TYPE_GTK_FORM_WIDGET_TEXTVIEW
gtk_form_add_field
gtk_form_add_fields
+gtk_form_add_group
gtk_form_check
gtk_form_clear
gtk_form_field_boolean_clear
gtk_form_get_form_field_from_widget
gtk_form_get_form_widget_from_name
gtk_form_get_form_widget_from_widget
+gtk_form_get_group_by_name
gtk_form_get_gtkbuilder
gtk_form_get_key
gtk_form_get_objects
gtk_form_get_values_as_hashtable
gtk_form_get_widget_from_form_widget_name
gtk_form_get_widget_from_name
+gtk_form_group_add_field
+gtk_form_group_add_widget
+gtk_form_group_clear
+gtk_form_group_get_name
+gtk_form_group_new
+gtk_form_group_set_from_datamodel
+gtk_form_group_set_from_hashtable
gtk_form_is_changed
gtk_form_key_add_field
gtk_form_key_add_fields
+GTK_FORM_GROUP
+GTK_FORM_GROUP_CLASS
+GTK_FORM_GROUP_GET_CLASS
GTK_FORM_WIDGET_RADIO
GTK_FORM_WIDGET_RADIO_CLASS
GTK_FORM_WIDGET_RADIO_GET_CLASS
+GtkFormGroup
+GtkFormGroupClass
GtkFormWidgetOnChangeOpType
GtkFormWidgetOnChangeOpUpdateWhen
GtkFormWidgetRadio
GtkFormWidgetRadioClass
+IS_GTK_FORM_GROUP
+IS_GTK_FORM_GROUP_CLASS
IS_GTK_FORM_WIDGET_RADIO
IS_GTK_FORM_WIDGET_RADIO_CLASS
+TYPE_GTK_FORM_GROUP
TYPE_GTK_FORM_WIDGET_RADIO
+gtk_form_add_group
gtk_form_field_boolean_set_as_origin
gtk_form_field_boolean_set_from_hashtable
gtk_form_field_boolean_str_to_boolean
gtk_form_get_form_field_from_widget
gtk_form_get_form_widget_from_name
gtk_form_get_form_widget_from_widget
+gtk_form_get_group_by_name
gtk_form_get_gtkbuilder
gtk_form_get_key
gtk_form_get_objects_by_name
gtk_form_get_values_as_hashtable
gtk_form_get_widget_from_form_widget_name
gtk_form_get_widgets
+gtk_form_group_add_field
+gtk_form_group_add_widget
+gtk_form_group_clear
+gtk_form_group_get_name
+gtk_form_group_get_type
+gtk_form_group_new
+gtk_form_group_set_from_datamodel
+gtk_form_group_set_from_hashtable
gtk_form_is_changed
gtk_form_load_from_file
gtk_form_load_from_xml
<DEFAULT>""</DEFAULT>
</ARG>
+<ARG>
+<NAME>GtkFormWidget::field</NAME>
+<TYPE>GtkFormField*</TYPE>
+<RANGE></RANGE>
+<FLAGS>rw</FLAGS>
+<NICK>GtkFormField</NICK>
+<BLURB>The GtkFormField.</BLURB>
+<DEFAULT></DEFAULT>
+</ARG>
+
<ARG>
<NAME>GtkFormWidget::form</NAME>
<TYPE>GtkForm*</TYPE>
</para>
+<!-- ##### ARG GtkFormWidget:field ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG GtkFormWidget:form ##### -->
<para>
widgetlabel.c \
widgetradio.c \
widgetspin.c \
- widgettextview.c
+ widgettextview.c \
+ group.c
libgtkform_la_LDFLAGS = -no-undefined
widgetlabel.h \
widgetradio.h \
widgetspin.h \
- widgettextview.h
+ widgettextview.h \
+ group.h
libgtkform_includedir = $(includedir)/libgtkform
case PROP_WIDGET:
priv->widget = g_value_get_object (value);
+ g_object_set (G_OBJECT (priv->widget), "field", field, NULL);
break;
default:
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 gtk_form_set_property (GObject *object,
guint property_id,
gchar quote;
GdaEx *gdaex;
+
+ GSList *groups;
};
G_DEFINE_TYPE (GtkForm, gtk_form, G_TYPE_OBJECT)
priv->fields = NULL;
priv->key = NULL;
priv->gdaex = NULL;
+ priv->groups = NULL;
}
/**
}
}
+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;
+ }
+}
+
/**
* gtk_form_load_from_xml:
* @form:
g_warning (_("Widget of type «%s» not found."), type);
}
}
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"group") == 0)
+ {
+ parse_group (form, cur);
+ }
cur = cur->next;
}
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;
+}
+
/* PRIVATE */
static void
gtk_form_set_property (GObject *object,
#include "field.h"
#include "widget.h"
#include "key.h"
+#include "group.h"
G_BEGIN_DECLS
GHashTable *gtk_form_get_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);
G_END_DECLS
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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 <libgdaex.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__ */
#include "form.h"
#include "widget.h"
+#include "field.h"
enum
{
PROP_0,
PROP_FORM,
+ PROP_FIELD,
PROP_WIDGET,
PROP_NAME,
PROP_LABEL
GtkWidget *label;
+ GtkFormField *field;
+
GSList *on_change_ops; /* GtkFormOnChangeOp */
};
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",
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;
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));
}
+ else
+ {
+ gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, op->form_widget_name), "");
+ }
}
}
else
ret = GTK_FORM_WIDGET_GET_CLASS (fwidget)->set_value_stringify (fwidget, value);
}
- ops = priv->on_change_ops;
- while (ops != NULL)
+ if (ret)
{
- op = (GtkFormWidgetOnChangeOp *)ops->data;
- switch (op->type)
+ ops = priv->on_change_ops;
+ while (ops != NULL)
{
- case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
+ op = (GtkFormWidgetOnChangeOp *)ops->data;
+ switch (op->type)
{
- 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))
+ case GTK_FORM_WIDGET_ON_CHANGE_OP_UPDATE:
{
- execute_on_change_op (fwidget, 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;
}
- break;
- }
- ops = g_slist_next (ops);
+ ops = g_slist_next (ops);
+ }
}
return ret;
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;
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;