Added function GtkForm::add_db_connection_gdaex.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 24 May 2011 07:06:05 +0000 (09:06 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 24 May 2011 07:06:05 +0000 (09:06 +0200)
Bugfixes.

data/gtkform.dtd
src/form.c
src/form.h

index c0db411a1240275d0d841ef0b1ec93cb9cf44c19..d2003081f45069240334bbec8d6a7f03657a51cb 100644 (file)
@@ -38,6 +38,7 @@
 >
 
 <!ELEMENT widget-name (#PCDATA)>
+<!ELEMENT connection-name (#PCDATA)>
 
 <!ELEMENT field (long-name?, to-load?, to-save?, obligatory?, default?, is-key?, auto-increment?, datetime-type?, display-format?, trim?, min-value?, max-value?, decimals?)>
 
index d3908b5d5f25e20b034922ef6298e565535e5451..8fd465edf4c459c7a957af7286a9512ed2cc97ee 100644 (file)
@@ -474,7 +474,7 @@ parse_db_connection (GtkForm *form, xmlNodePtr xnode)
        child = xnode->children;
        while (child != NULL)
                {
-                       if (xmlStrcmp (child->name, (const xmlChar *)"connection_string") == 0)
+                       if (xmlStrcmp (child->name, (const xmlChar *)"connection-string") == 0)
                                {
                                        cnc_string = (gchar *)xmlNodeGetContent (child);
                                        break;
@@ -892,7 +892,7 @@ gtk_form_load_from_xml (GtkForm *form, xmlDoc *xmldoc, GtkBuilder *gtkbuilder)
                                                                {
                                                                        parse_group (form, cur);
                                                                }
-                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"db_connection") == 0)
+                                                       else if (xmlStrcmp (cur->name, (const xmlChar *)"db-connection") == 0)
                                                                {
                                                                        parse_db_connection (form, cur);
                                                                }
@@ -2480,6 +2480,57 @@ gtk_form_add_db_connection (GtkForm *form, const gchar *name, const gchar *conne
        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:
index c046be6d41ad41737d71f57f5c0dd549b2637690..2dca1c6956aaf0478dd2c718ae1f52fef8ba56de 100644 (file)
@@ -136,6 +136,7 @@ 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