typedef struct _GtkFormPrivate GtkFormPrivate;
struct _GtkFormPrivate
{
- GList *fields;
-
gchar *table;
+ GList *fields;
GtkFormKey *key;
};
{
GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ priv->table = "";
priv->fields = NULL;
+ priv->key = NULL;
}
/**
* gtk_form_new:
*
- * Returns: the newly created #GtkForm.
+ * Returns: the newly created #GtkForm object.
*/
GtkForm
*gtk_form_new ()
return GTK_FORM (g_object_new (gtk_form_get_type (), NULL));
}
+/**
+ * gtk_form_new_from_xml:
+ * @xmldoc:
+ *
+ * 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)
+{
+ GtkForm *form;
+ xmlNode *cur;
+
+ form = NULL;
+
+ cur = xmlDocGetRootElement (xmldoc);
+ if (cur != NULL)
+ {
+ if (xmlStrcmp (cur->name, "gtkform") == 0)
+ {
+ }
+ else
+ {
+ /* TO DO */
+ g_warning ("The file is not a valid gtkform definition file");
+ }
+ }
+
+ return form;
+}
+
+/**
+ * gtk_form_new_from_file:
+ * @filename:
+ *
+ * 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)
+{
+ 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);
+ }
+
+ return form;
+}
+
+/**
+ * gtk_form_get_table:
+ * @form: a #GtkForm object.
+ *
+ * Returns: the table's name associated to the form.
+ */
+const gchar
+*gtk_form_get_table (GtkForm *form)
+{
+ GtkFormPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+ return (const gchar *)g_strdup (priv->table);
+}
+
+/**
+ * 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->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);
+
+ 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->key = key;
+}
+
/**
* gtk_form_add_field:
* @form: a #GtkForm object.
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;
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);
va_list vargs;
+ g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
va_start (vargs, form);
while ((field = va_arg (vargs, GtkFormField *)) != NULL)
{
GtkFormField *field = NULL;
const gchar *name;
- GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ GtkFormPrivate *priv;
+
+ g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+ priv = GTK_FORM_GET_PRIVATE (form);
GList *fields = g_list_first (priv->fields);
while (fields != NULL)
GtkFormWidget *widget = NULL;
GtkFormWidget *widget_ret = NULL;
gchar *name;
- GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ 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);
GList *fields = g_list_first (priv->fields);
while (fields != NULL)
{
GtkFormField *field;
gboolean ret = FALSE;
+ GtkFormPrivate *priv;
- GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
+ priv = GTK_FORM_GET_PRIVATE (form);
GList *fields = g_list_first (priv->fields);
gboolean ret = TRUE;
gboolean obl = FALSE;
+ g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
GList *fields = g_list_first (priv->fields);
GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
GtkWidget *widget;
+ g_return_if_fail (IS_GTK_FORM (form));
+
GList *fields = g_list_first (priv->fields);
while (fields != NULL)
{
GtkFormWidget *fwidget;
GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
+ g_return_if_fail (IS_GTK_FORM (form));
+
GList *fields = g_list_first (priv->fields);
while (fields != NULL)
{
gchar *where = "";
const gchar *field_name;
+ g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
GList *fields = g_list_first (priv->fields);
GtkFormField *field;
gchar *field_name;
+ g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+
GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
GList *fields = g_list_first (priv->fields);
switch (property_id)
{
case PROP_TABLE:
- priv->table = g_strstrip (g_strdup (g_value_get_string (value)));
+ gtk_form_set_table (form, g_value_get_string (value));
break;
case PROP_KEY:
- priv->key = g_value_get_object (value);
+ gtk_form_set_key (form, GTK_FORM_KEY (g_value_get_object (value)));
break;
default:
switch (property_id)
{
case PROP_TABLE:
- g_value_set_string (value, priv->table);
+ g_value_set_string (value, gtk_form_get_table (form));
break;
case PROP_KEY:
- g_value_set_object (value, priv->key);
+ g_value_set_object (value, gtk_form_get_key (form));
break;
default: