[gnome-db] gda_config_get_provider_model()
- From: Laurent Sansonetti <laurent datarescue be>
- To: gnome-db-list gnome org
- Subject: [gnome-db] gda_config_get_provider_model()
- Date: Mon, 27 Oct 2003 21:28:52 +0000
Hi,
A Ruby/Libgda user noticed me that gda_config_get_provider_model()
wasn't implemented, to the contrary of
gda_config_get_data_source_model().
The following patch introduces the missing function.
Cheers,
--
{ "Laurent" => "http://lrz.samika.net" }
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.582
diff -u -r1.582 ChangeLog
--- ChangeLog 26 Oct 2003 20:39:35 -0000 1.582
+++ ChangeLog 27 Oct 2003 18:25:34 -0000
@@ -1,3 +1,8 @@
+2003-10-27 Laurent Sansonetti <laurent datarescue be>
+
+ * libgda/gda-config.[c.h] (gda_config_get_provider_model):
+ New function.
+
2003-10-26 Laurent Sansonetti <laurent datarescue be>
* libgda/gda-data-model.c (gda_data_model_to_xml):
Index: libgda/gda-config.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-config.c,v
retrieving revision 1.52
diff -u -r1.52 gda-config.c
--- libgda/gda-config.c 18 Oct 2003 23:03:52 -0000 1.52
+++ libgda/gda-config.c 27 Oct 2003 18:25:37 -0000
@@ -1165,6 +1165,50 @@
}
/**
+ * gda_config_get_provider_model
+ *
+ * Fills and returns a new #GdaDataModel object using information from all
+ * providers which are currently installed in the system.
+ *
+ * Rows are separated in 3 columns:
+ * 'Id', 'Location' and 'Description'.
+ *
+ * Returns: a new #GdaDataModel object.
+ */
+GdaDataModel *
+gda_config_get_provider_model (void)
+{
+ GList *prov_list;
+ GList *l;
+ GdaDataModel *model;
+
+ model = gda_data_model_array_new (3);
+ gda_data_model_set_column_title (model, 0, _("Id"));
+ gda_data_model_set_column_title (model, 1, _("Location"));
+ gda_data_model_set_column_title (model, 2, _("Description"));
+
+ /* convert the returned GList into a GdaDataModelArray */
+ prov_list = gda_config_get_provider_list ();
+ for (l = prov_list; l != NULL; l = l->next) {
+ GList *value_list = NULL;
+ GdaProviderInfo *prov_info = (GdaProviderInfo *) l->data;
+
+ g_assert (prov_info != NULL);
+
+ value_list = g_list_append (value_list, gda_value_new_string (prov_info->id));
+ value_list = g_list_append (value_list, gda_value_new_string (prov_info->location));
+ value_list = g_list_append (value_list, gda_value_new_string (prov_info->description));
+
+ gda_data_model_append_row (GDA_DATA_MODEL (model), value_list);
+ }
+
+ /* free memory */
+ gda_config_free_provider_list (prov_list);
+
+ return model;
+}
+
+/**
* gda_provider_info_copy
* @src: provider information to get a copy from.
*
Index: libgda/gda-config.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-config.h,v
retrieving revision 1.18
diff -u -r1.18 gda-config.h
--- libgda/gda-config.h 18 Oct 2003 23:03:52 -0000 1.18
+++ libgda/gda-config.h 27 Oct 2003 18:25:37 -0000
@@ -79,7 +79,7 @@
GList *gda_config_get_provider_list (void);
void gda_config_free_provider_list (GList *list);
GdaProviderInfo *gda_config_get_provider_by_name (const gchar *name);
-
+GdaDataModel *gda_config_get_provider_model (void);
/*
* Data sources configuration
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]