From 581bb1805a5e94e42091344b4ca1e1b6cd64b460 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 17 Jul 2010 18:43:53 +0200 Subject: [PATCH] Added function GtkForm::fill_from_table. --- src/form.c | 33 +++++++++++++++++++++++++++++++++ src/form.h | 1 + 2 files changed, 34 insertions(+) diff --git a/src/form.c b/src/form.c index da86517..d80725b 100644 --- a/src/form.c +++ b/src/form.c @@ -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, diff --git a/src/form.h b/src/form.h index 6a3c305..9ef3f10 100644 --- a/src/form.h +++ b/src/form.h @@ -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 -- 2.49.0