[libgda] GdaBrowser: handle user preferences in all forms
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaBrowser: handle user preferences in all forms
- Date: Fri, 16 Jul 2010 20:57:55 +0000 (UTC)
commit 35c5e9fc75c72aa8c428b916ca1892d60cad66b1
Author: Vivien Malerba <malerba gnome-db org>
Date: Fri Jul 16 22:55:21 2010 +0200
GdaBrowser: handle user preferences in all forms
tools/browser/common/ui-formgrid.c | 67 ++++++++++++++++++++++++++++++
tools/browser/common/ui-formgrid.h | 4 ++
tools/browser/data-manager/data-source.c | 10 ++++
tools/browser/data-manager/data-source.h | 1 +
tools/browser/data-manager/data-widget.c | 6 +++
tools/browser/query-exec/query-result.c | 45 +-------------------
6 files changed, 89 insertions(+), 44 deletions(-)
---
diff --git a/tools/browser/common/ui-formgrid.c b/tools/browser/common/ui-formgrid.c
index cf5cf60..6584a66 100644
--- a/tools/browser/common/ui-formgrid.c
+++ b/tools/browser/common/ui-formgrid.c
@@ -250,6 +250,73 @@ ui_formgrid_new (GdaDataModel *model, GdauiDataProxyInfoFlag flags)
return (GtkWidget *) formgrid;
}
+/**
+ * ui_formgrid_handle_user_prefs
+ * @formgrid: a #UiFormGrid widget
+ * @bcnc: a #BrowserConnection
+ * @stmt: the #GdaStatement which has been executed to produce the #GdaDataModel displayed in @formgrid
+ *
+ * Takes into account the UI preferences of the user
+ */
+void
+ui_formgrid_handle_user_prefs (UiFormGrid *formgrid, BrowserConnection *bcnc, GdaStatement *stmt)
+{
+ g_return_if_fail (UI_IS_FORMGRID (formgrid));
+ if (bcnc)
+ g_return_if_fail (BROWSER_IS_CONNECTION (bcnc));
+ else
+ return;
+ if (stmt)
+ g_return_if_fail (GDA_IS_STATEMENT (stmt));
+ else
+ return;
+
+ GdaSqlStatement *sqlst;
+ g_object_get ((GObject*) stmt, "structure", &sqlst, NULL);
+ if (!sqlst)
+ return;
+
+ if ((sqlst->stmt_type != GDA_SQL_STATEMENT_SELECT) ||
+ !browser_connection_normalize_sql_statement (bcnc, sqlst, NULL))
+ goto out;
+
+ GdaSet *set;
+ set = (GdaSet*) ui_formgrid_get_form_data_set (UI_FORMGRID (formgrid));
+
+ GdaSqlStatementSelect *sel;
+ GSList *list;
+ gint pos;
+ sel = (GdaSqlStatementSelect*) sqlst->contents;
+ for (pos = 0, list = sel->expr_list; list; pos ++, list = list->next) {
+ GdaSqlSelectField *field = (GdaSqlSelectField*) list->data;
+ if (! field->validity_meta_object ||
+ (field->validity_meta_object->obj_type != GDA_META_DB_TABLE) ||
+ !field->validity_meta_table_column)
+ continue;
+
+ gchar *plugin;
+ plugin = browser_connection_get_table_column_attribute (bcnc,
+ GDA_META_TABLE (field->validity_meta_object),
+ field->validity_meta_table_column,
+ BROWSER_CONNECTION_COLUMN_PLUGIN, NULL);
+ if (!plugin)
+ continue;
+
+ GdaHolder *holder;
+ holder = gda_set_get_nth_holder (set, pos);
+ if (holder) {
+ GValue *value;
+ value = gda_value_new_from_string (plugin, G_TYPE_STRING);
+ gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
+ gda_value_free (value);
+ }
+ }
+
+ out:
+ gda_sql_statement_free (sqlst);
+}
+
+
static void
ui_formgrid_set_property (GObject *object,
diff --git a/tools/browser/common/ui-formgrid.h b/tools/browser/common/ui-formgrid.h
index 193deda..fe69ff4 100644
--- a/tools/browser/common/ui-formgrid.h
+++ b/tools/browser/common/ui-formgrid.h
@@ -25,6 +25,7 @@
#include <libgda/gda-data-model.h>
#include <libgda-ui/gdaui-data-proxy-info.h>
#include <libgda-ui/gdaui-raw-grid.h>
+#include "../browser-connection.h"
G_BEGIN_DECLS
@@ -58,6 +59,9 @@ struct _UiFormGridClass
GType ui_formgrid_get_type (void);
GtkWidget *ui_formgrid_new (GdaDataModel *model, GdauiDataProxyInfoFlag flags);
+void ui_formgrid_handle_user_prefs (UiFormGrid *formgrid, BrowserConnection *bcnc,
+ GdaStatement *stmt);
+
GArray *ui_formgrid_get_selection (UiFormGrid *formgrid);
GdaDataModelIter *ui_formgrid_get_form_data_set (UiFormGrid *formgrid);
GdaDataModelIter *ui_formgrid_get_grid_data_set (UiFormGrid *formgrid);
diff --git a/tools/browser/data-manager/data-source.c b/tools/browser/data-manager/data-source.c
index 6597357..652e097 100644
--- a/tools/browser/data-manager/data-source.c
+++ b/tools/browser/data-manager/data-source.c
@@ -638,6 +638,16 @@ exec_end_timeout_cb (DataSource *source)
}
/**
+ *data_source_get_statement
+ */
+GdaStatement *
+data_source_get_statement (DataSource *source)
+{
+ g_return_val_if_fail (IS_DATA_SOURCE (source), NULL);
+ return source->priv->stmt;
+}
+
+/**
* data_source_execution_going_on
*/
gboolean
diff --git a/tools/browser/data-manager/data-source.h b/tools/browser/data-manager/data-source.h
index a49d845..10088ca 100644
--- a/tools/browser/data-manager/data-source.h
+++ b/tools/browser/data-manager/data-source.h
@@ -58,6 +58,7 @@ GType data_source_get_type (void) G_GNUC_CONST;
DataSource *data_source_new_from_xml_node (BrowserConnection *bcnc, xmlNodePtr node, GError **error);
void data_source_set_params (DataSource *source, GdaSet *params);
xmlNodePtr data_source_to_xml_node (DataSource *source);
+GdaStatement *data_source_get_statement (DataSource *source);
GdaSet *data_source_get_import (DataSource *source);
GArray *data_source_get_export_names (DataSource *source);
diff --git a/tools/browser/data-manager/data-widget.c b/tools/browser/data-manager/data-widget.c
index 7a81c51..ca24fd7 100644
--- a/tools/browser/data-manager/data-widget.c
+++ b/tools/browser/data-manager/data-widget.c
@@ -26,6 +26,7 @@
#include "../browser-connection.h"
#include "../browser-spinner.h"
#include "../common/ui-formgrid.h"
+#include "../browser-window.h"
typedef struct {
DataWidget *dwid;
@@ -361,7 +362,12 @@ source_exec_finished_cb (DataSource *source, GError *error, DataPart *part)
if (! part->data_widget) {
GtkWidget *cwid;
+ BrowserConnection *bcnc;
+ bcnc = browser_window_get_connection ((BrowserWindow*) gtk_widget_get_toplevel ((GtkWidget*) part->dwid));
cwid = (GtkWidget*) data_source_create_grid (part->source);
+ ui_formgrid_handle_user_prefs (UI_FORMGRID (cwid), bcnc,
+ data_source_get_statement (part->source));
+
wid = (GtkWidget*) ui_formgrid_get_grid_widget (UI_FORMGRID (cwid));
part->data_widget = wid;
part->data_widget_page = gtk_notebook_append_page (part->nb, cwid, NULL);
diff --git a/tools/browser/query-exec/query-result.c b/tools/browser/query-exec/query-result.c
index 343c9f7..8f241e2 100644
--- a/tools/browser/query-exec/query-result.c
+++ b/tools/browser/query-exec/query-result.c
@@ -347,51 +347,8 @@ make_widget_for_data_model (GdaDataModel *model, QueryResult *qres, const gchar
g_object_unref (parser);
if (!stmt)
goto out;
-
- GdaSqlStatement *sqlst;
- g_object_get ((GObject*) stmt, "structure", &sqlst, NULL);
+ ui_formgrid_handle_user_prefs (UI_FORMGRID (grid), bcnc, stmt);
g_object_unref (stmt);
-
- if ((sqlst->stmt_type != GDA_SQL_STATEMENT_SELECT) ||
- !browser_connection_normalize_sql_statement (bcnc, sqlst, NULL)) {
- gda_sql_statement_free (sqlst);
- goto out;
- }
-
- GdaSet *set;
- set = (GdaSet*) ui_formgrid_get_form_data_set (UI_FORMGRID (grid));
-
- GdaSqlStatementSelect *sel;
- GSList *list;
- gint pos;
- sel = (GdaSqlStatementSelect*) sqlst->contents;
- for (pos = 0, list = sel->expr_list; list; pos ++, list = list->next) {
- GdaSqlSelectField *field = (GdaSqlSelectField*) list->data;
- if (! field->validity_meta_object ||
- (field->validity_meta_object->obj_type != GDA_META_DB_TABLE) ||
- !field->validity_meta_table_column)
- continue;
-
- gchar *plugin;
- plugin = browser_connection_get_table_column_attribute (bcnc,
- GDA_META_TABLE (field->validity_meta_object),
- field->validity_meta_table_column,
- BROWSER_CONNECTION_COLUMN_PLUGIN, NULL);
- if (!plugin)
- continue;
-
- GdaHolder *holder;
- holder = gda_set_get_nth_holder (set, pos);
- if (holder) {
- GValue *value;
- value = gda_value_new_from_string (plugin, G_TYPE_STRING);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
- }
-
- }
-
- gda_sql_statement_free (sqlst);
}
out:
return grid;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]