/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
return ret;
}
+/**
+ * gtk_form_field_set_from_xml:
+ * @field: a #GtkFormField object.
+ * @xnode: an #xmlNode object.
+ *
+ */
+gboolean
+gtk_form_field_set_from_xml (GtkFormField *field, xmlNode *xnode)
+{
+ gboolean ret = FALSE;
+
+ GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+ g_return_val_if_fail (xnode != NULL, FALSE);
+
+ if (IS_GTK_FORM_FIELD (field) && GTK_FORM_FIELD_GET_CLASS (field)->set_from_xml != NULL)
+ {
+ ret = GTK_FORM_FIELD_GET_CLASS (field)->set_from_xml (field, xnode);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_set_value:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
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_from_xml) (GtkFormField *field, xmlNode *xnode);
gboolean (*set_value) (GtkFormField *field, GValue *gvalue);
};
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_from_xml (GtkFormField *field, xmlNode *xnode);
gboolean gtk_form_field_set_value (GtkFormField *field, GValue *gvalue);
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
#include <string.h>
#include <glib/gi18n-lib.h>
+#include <libxml/xpath.h>
#include "widget.h"
#include "fieldboolean.h"
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_from_xml = gtk_form_field_boolean_set_from_xml;
field_class->set_value = gtk_form_field_boolean_set_value;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_boolean_set_from_xml:
+ * @field: a #GtkFormField object.
+ * @xnode: an #xmlNode object.
+ *
+ */
+gboolean
+gtk_form_field_boolean_set_from_xml (GtkFormField *field, xmlNode *xnode)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldBooleanPrivate *priv;
+ gchar *str;
+ gchar *field_name;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_BOOLEAN (field), FALSE);
+ g_return_val_if_fail (xnode != 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)
+ {
+ xmlDoc *xdoc;
+ xmlXPathContextPtr xpcontext;
+ xmlXPathObjectPtr xpresult;
+ xmlNodeSetPtr xnodeset;
+
+ xdoc = xmlNewDoc ("1.0");
+ xmlDocSetRootElement (xdoc, xnode);
+ xpcontext = xmlXPathNewContext (xdoc);
+
+ priv->original_value = FALSE;
+ ret = gtk_form_field_boolean_set_value_stringify (field, "FALSE");
+
+ xpcontext->node = xnode;
+ xpresult = xmlXPathEvalExpression ((const xmlChar *)g_strdup_printf ("child::%s", field_name), xpcontext);
+ if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
+ {
+ xnodeset = xpresult->nodesetval;
+ if (xnodeset->nodeNr >= 1)
+ {
+ str = (gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]);
+ ret = gtk_form_field_boolean_set_value_stringify (field, str);
+ priv->original_value = gtk_form_field_boolean_str_to_boolean (gtk_form_field_boolean_get_value_stringify (field));
+ xmlFree (str);
+ }
+ }
+
+ xmlXPathFreeObject (xpresult);
+ xmlXPathFreeContext (xpcontext);
+ xmlUnlinkNode (xnode);
+ xmlFreeDoc (xdoc);
+
+ g_free (field_name);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_boolean_set_value:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
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_from_xml (GtkFormField *field, xmlNode *xnode);
gboolean gtk_form_field_boolean_set_value (GtkFormField *field, GValue *gvalue);
gboolean gtk_form_field_boolean_str_to_boolean (const gchar *value);
/*
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
#include <time.h>
#include <glib/gi18n-lib.h>
+#include <libxml/xpath.h>
#include "widget.h"
#include "fielddatetime.h"
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_from_xml = gtk_form_field_datetime_set_from_xml;
field_class->set_value = gtk_form_field_datetime_set_value;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_boolean_set_from_xml:
+ * @field: a #GtkFormField object.
+ * @xnode: an #xmlNode object.
+ *
+ */
+gboolean
+gtk_form_field_datetime_set_from_xml (GtkFormField *field, xmlNode *xnode)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldDateTimePrivate *priv;
+ gchar *str;
+ gchar *field_name;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_DATETIME (field), FALSE);
+ g_return_val_if_fail (xnode != NULL, FALSE);
+
+ priv = GTK_FORM_FIELD_DATETIME_GET_PRIVATE (GTK_FORM_FIELD_DATETIME (field));
+
+ field_name = gtk_form_field_get_field_name (field);
+ if (field_name != NULL && g_strcmp0 (g_strstrip (field_name), "") != 0)
+ {
+ xmlDoc *xdoc;
+ xmlXPathContextPtr xpcontext;
+ xmlXPathObjectPtr xpresult;
+ xmlNodeSetPtr xnodeset;
+
+ xdoc = xmlNewDoc ("1.0");
+ xmlDocSetRootElement (xdoc, xnode);
+ xpcontext = xmlXPathNewContext (xdoc);
+
+ if (priv->original_value != NULL)
+ {
+ g_date_time_unref (priv->original_value);
+ }
+ priv->original_value = NULL;
+ ret = gtk_form_field_datetime_set_value_stringify (field, "");
+
+ xpcontext->node = xnode;
+ xpresult = xmlXPathEvalExpression ((const xmlChar *)g_strdup_printf ("child::%s", field_name), xpcontext);
+ if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
+ {
+ xnodeset = xpresult->nodesetval;
+ if (xnodeset->nodeNr >= 1)
+ {
+ str = (gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]);
+ ret = gtk_form_field_datetime_set_value_stringify (field, str);
+ priv->original_value = gtk_form_field_datetime_get_gdatetime_from_str (gtk_form_field_datetime_get_value_stringify (field), "%Y-%m-%d %H:%M:%S");
+ xmlFree (str);
+ }
+ }
+
+ xmlXPathFreeObject (xpresult);
+ xmlXPathFreeContext (xpcontext);
+ xmlUnlinkNode (xnode);
+ xmlFreeDoc (xdoc);
+
+ g_free (field_name);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_datetime_set_value:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
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_from_xml (GtkFormField *field, xmlNode *xnode);
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);
/*
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
#include <locale.h>
#include <glib/gi18n-lib.h>
+#include <libxml/xpath.h>
#include "widget.h"
#include "fieldfloat.h"
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_from_xml = gtk_form_field_float_set_from_xml;
field_class->set_value = gtk_form_field_float_set_value;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_float_set_from_xml:
+ * @field: a #GtkFormField object.
+ * @xnode: an #xmlNode object.
+ *
+ */
+gboolean
+gtk_form_field_float_set_from_xml (GtkFormField *field, xmlNode *xnode)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldFloatPrivate *priv;
+ gchar *str;
+ gchar *field_name;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_FLOAT (field), FALSE);
+ g_return_val_if_fail (xnode != 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)
+ {
+ xmlDoc *xdoc;
+ xmlXPathContextPtr xpcontext;
+ xmlXPathObjectPtr xpresult;
+ xmlNodeSetPtr xnodeset;
+
+ xdoc = xmlNewDoc ("1.0");
+ xmlDocSetRootElement (xdoc, xnode);
+ xpcontext = xmlXPathNewContext (xdoc);
+
+ priv->original_value = 0.0f;
+ ret = gtk_form_field_float_set_value_stringify (field, "");
+
+ xpcontext->node = xnode;
+ xpresult = xmlXPathEvalExpression ((const xmlChar *)g_strdup_printf ("child::%s", field_name), xpcontext);
+ if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
+ {
+ xnodeset = xpresult->nodesetval;
+ if (xnodeset->nodeNr >= 1)
+ {
+ setlocale (LC_NUMERIC, "");
+ gda_locale_changed ();
+
+ str = (gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]);
+ ret = gtk_form_field_float_set_value_stringify (field, str);
+ priv->original_value = g_strtod (gtk_form_field_float_get_value_stringify (field), NULL);
+ xmlFree (str);
+ }
+ }
+
+ xmlXPathFreeObject (xpresult);
+ xmlXPathFreeContext (xpcontext);
+ xmlUnlinkNode (xnode);
+ xmlFreeDoc (xdoc);
+
+ g_free (field_name);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_float_set_value:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
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_from_xml (GtkFormField *field, xmlNode *xnode);
gboolean gtk_form_field_float_set_value (GtkFormField *field, GValue *gvalue);
/*
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
#endif
#include <glib/gi18n-lib.h>
+#include <libxml/xpath.h>
#include "widget.h"
#include "widgetspin.h"
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_from_xml = gtk_form_field_integer_set_from_xml;
field_class->set_value = gtk_form_field_integer_set_value;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_integer_set_from_xml:
+ * @field: a #GtkFormField object.
+ * @xnode: an #xmlNode object.
+ *
+ */
+gboolean
+gtk_form_field_integer_set_from_xml (GtkFormField *field, xmlNode *xnode)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldIntegerPrivate *priv;
+ gchar *str;
+ gchar *field_name;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_INTEGER (field), FALSE);
+ g_return_val_if_fail (xnode != 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)
+ {
+ xmlDoc *xdoc;
+ xmlXPathContextPtr xpcontext;
+ xmlXPathObjectPtr xpresult;
+ xmlNodeSetPtr xnodeset;
+
+ xdoc = xmlNewDoc ("1.0");
+ xmlDocSetRootElement (xdoc, xnode);
+ xpcontext = xmlXPathNewContext (xdoc);
+
+ priv->original_value = 0;
+ ret = gtk_form_field_integer_set_value_stringify (field, "");
+
+ xpcontext->node = xnode;
+ xpresult = xmlXPathEvalExpression ((const xmlChar *)g_strdup_printf ("child::%s", field_name), xpcontext);
+ if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
+ {
+ xnodeset = xpresult->nodesetval;
+ if (xnodeset->nodeNr >= 1)
+ {
+ str = (gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]);
+ ret = gtk_form_field_integer_set_value_stringify (field, str);
+ priv->original_value = strtol (gtk_form_field_integer_get_value_stringify (field), NULL, 10);
+ xmlFree (str);
+ }
+ }
+
+ xmlXPathFreeObject (xpresult);
+ xmlXPathFreeContext (xpcontext);
+ xmlUnlinkNode (xnode);
+ xmlFreeDoc (xdoc);
+
+ g_free (field_name);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_integer_set_value:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
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_from_xml (GtkFormField *field, xmlNode *xml);
gboolean gtk_form_field_integer_set_value (GtkFormField *field, GValue *gvalue);
/*
- * Copyright (C) 2005-2011 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
#endif
#include <glib/gi18n-lib.h>
+#include <libxml/xpath.h>
#include "widget.h"
#include "fieldtext.h"
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_from_xml = gtk_form_field_text_set_from_xml;
field_class->set_value = gtk_form_field_text_set_value;
g_object_class_install_property (object_class, PROP_DEFAULT,
return ret;
}
+/**
+ * gtk_form_field_text_set_from_xml:
+ * @field: a #GtkFormField object.
+ * @xnode: an #xmlNode object.
+ *
+ */
+gboolean
+gtk_form_field_text_set_from_xml (GtkFormField *field, xmlNode *xnode)
+{
+ gboolean ret = FALSE;
+ GtkFormFieldTextPrivate *priv;
+ gchar *str;
+ gchar *field_name;
+
+ g_return_val_if_fail (IS_GTK_FORM_FIELD_TEXT (field), FALSE);
+ g_return_val_if_fail (xnode != 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)
+ {
+ xmlDoc *xdoc;
+ xmlXPathContextPtr xpcontext;
+ xmlXPathObjectPtr xpresult;
+ xmlNodeSetPtr xnodeset;
+
+ xdoc = xmlNewDoc ("1.0");
+ xmlDocSetRootElement (xdoc, xnode);
+ xpcontext = xmlXPathNewContext (xdoc);
+
+ g_free (priv->original_value);
+ priv->original_value = g_strdup ("");
+ ret = gtk_form_field_text_set_value_stringify (field, "");
+
+ xpcontext->node = xnode;
+ xpresult = xmlXPathEvalExpression ((const xmlChar *)g_strdup_printf ("child::%s", field_name), xpcontext);
+ if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
+ {
+ xnodeset = xpresult->nodesetval;
+ if (xnodeset->nodeNr >= 1)
+ {
+ str = (gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]);
+ ret = gtk_form_field_text_set_value_stringify (field, str);
+ priv->original_value = g_strdup (gtk_form_field_text_get_value_stringify (field));
+ xmlFree (str);
+ }
+ }
+
+ xmlXPathFreeObject (xpresult);
+ xmlXPathFreeContext (xpcontext);
+ xmlUnlinkNode (xnode);
+ xmlFreeDoc (xdoc);
+
+ g_free (field_name);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_field_text_set_value:
* @field: a #GtkFormField object.
/*
- * Copyright (C) 2005-2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2012 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
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_from_xml (GtkFormField *field, xmlNode *xnode);
gboolean gtk_form_field_text_set_value (GtkFormField *field, GValue *gvalue);
}
/**
- * gtk_form_get_original_values_as_xml:
+ * gtk_form_get_values_as_xml:
* @form:
*
*/
return xnode;
}
+/**
+ * gtk_form_fill_from_xml:
+ * @form: a #GtkForm object.
+ * @xnode: an @xmlNode object.
+ *
+ */
+gboolean
+gtk_form_fill_from_xml (GtkForm *form, xmlNode *xnode)
+{
+ GtkFormPrivate *priv;
+ GSList *fields;
+ GtkFormField *field;
+
+ gboolean ret;
+
+ g_return_val_if_fail (IS_GTK_FORM (form), FALSE);
+ g_return_val_if_fail (xnode != 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_xml (field, xnode);
+ }
+
+ fields = g_slist_next (fields);
+ }
+
+ return ret;
+}
+
/**
* gtk_form_add_group:
* @form:
gboolean gtk_form_fill_from_hashtable (GtkForm *form, GHashTable *hashtable);
xmlNode *gtk_form_get_values_as_xml (GtkForm *form);
+gboolean gtk_form_fill_from_xml (GtkForm *form, xmlNode *xnode);
gboolean gtk_form_add_group (GtkForm *form, GtkFormGroup *group);
GtkFormGroup *gtk_form_get_group_by_name (GtkForm *form, const gchar *group_name);
gtk_text_buffer_set_text (buf, str, strlen (str));
}
+G_MODULE_EXPORT void
+on_btnLoadXml_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *dlg;
+
+ dlg = gtk_file_chooser_dialog_new ("Open XML",
+ GTK_WINDOW (w),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_ACCEPT)
+ {
+ gchar *filename;
+ xmlDoc *xdoc;
+ xmlNode *xnode;
+
+ gint size;
+ xmlChar *str;
+
+ gtk_form_clear (form);
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
+ xdoc = xmlParseFile (filename);
+ if (xdoc == NULL)
+ {
+ return;
+ }
+
+ xnode = xmlDocGetRootElement (xdoc);
+ gtk_form_fill_from_xml (form, xnode);
+ xmlDocSetRootElement (xdoc, xnode);
+
+ GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (txtvSql));
+ xmlDocDumpMemory (xdoc, &str, &size);
+ gtk_text_buffer_set_text (buf, str, strlen (str));
+
+ xmlFreeDoc (xdoc);
+ g_free (filename);
+ }
+ gtk_widget_destroy (dlg);
+}
+
void
create_cb_nation (GtkWidget *w)
{
gtk_text_buffer_set_text (buf, str, strlen (str));
}
+G_MODULE_EXPORT void
+on_btnLoadXml_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *dlg;
+
+ dlg = gtk_file_chooser_dialog_new ("Open XML",
+ GTK_WINDOW (w),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_ACCEPT)
+ {
+ gchar *filename;
+ xmlDoc *xdoc;
+ xmlNode *xnode;
+
+ gint size;
+ xmlChar *str;
+
+ gtk_form_clear (form);
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
+ xdoc = xmlParseFile (filename);
+ if (xdoc == NULL)
+ {
+ return;
+ }
+
+ xnode = xmlDocGetRootElement (xdoc);
+ gtk_form_fill_from_xml (form, xnode);
+ xmlDocSetRootElement (xdoc, xnode);
+
+ GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (txtvSql));
+ xmlDocDumpMemory (xdoc, &str, &size);
+ gtk_text_buffer_set_text (buf, str, strlen (str));
+
+ xmlFreeDoc (xdoc);
+ g_free (filename);
+ }
+ gtk_widget_destroy (dlg);
+}
+
void
create_cb_nation (GtkWidget *w)
{
<property name="position">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="label" translatable="yes">_Load XML</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_btnLoadXml_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
--- /dev/null
+<?xml version="1.0"?>
+<values><id>55</id><name>entry value from XML</name><age>88</age><amount>32,65</amount><id_nation>2</id_nation><married>TRUE</married><description>the default value
+for this text view
+with also line feed
+and t a b
+EDIT FORM XML LOADING TEST</description><now>2012-11-15 12:34:44</now><sex>M</sex><sex>M</sex><sex>M</sex></values>
--- /dev/null
+<?xml version="1.0"?>
+<values><id>33</id></values>