]> saetta.ns0.it Git - libgtkform/commitdiff
Added function GtkForm::fill_from_table. 0.1.1
authorAndrea Zagli <azagli@libero.it>
Sat, 17 Jul 2010 16:43:53 +0000 (18:43 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 17 Jul 2010 16:43:53 +0000 (18:43 +0200)
src/form.c
src/form.h

index da86517bd36249ce8c801d28eeb3fea2a30d4159..d80725b91041c1e3b6a06a522d6598ff5106dcbe 100644 (file)
@@ -1399,6 +1399,39 @@ gtk_form_fill_from_datamodel (GtkForm *form, GdaDataModel *dm, gint row)
        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;
+}
+
 /* PRIVATE */
 static void
 gtk_form_set_property (GObject *object,
index 6a3c3055eb019ece33584c063b105e5c5676495e..9ef3f10d1705b786a14b94be27bb671cd47e3900 100644 (file)
@@ -106,6 +106,7 @@ typedef enum
 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);
 
 
 G_END_DECLS