[libgda] GdaBrowser: allow to toggle between grid and form presentations for data sets



commit 1b1f076a4f71831e14ba2123aa4f797935154728
Author: Vivien Malerba <malerba gnome-db org>
Date:   Fri Jul 16 22:03:55 2010 +0200

    GdaBrowser: allow to toggle between grid and form presentations for data sets

 tools/browser/Makefile.am                |    4 +-
 tools/browser/common/Makefile.am         |    4 +-
 tools/browser/common/ui-formgrid.c       |  370 ++++++++++++++++++++++++++++++
 tools/browser/common/ui-formgrid.h       |   72 ++++++
 tools/browser/data-manager/data-source.c |   11 +-
 tools/browser/data-manager/data-source.h |    2 +-
 tools/browser/data-manager/data-widget.c |    9 +-
 tools/browser/gda-browser-form.png       |  Bin 0 -> 286 bytes
 tools/browser/gda-browser-grid.png       |  Bin 0 -> 258 bytes
 tools/browser/query-exec/query-result.c  |   11 +-
 tools/browser/support.c                  |    4 +-
 tools/browser/support.h                  |    3 +
 12 files changed, 472 insertions(+), 18 deletions(-)
---
diff --git a/tools/browser/Makefile.am b/tools/browser/Makefile.am
index d1f2ba0..7a3013b 100644
--- a/tools/browser/Makefile.am
+++ b/tools/browser/Makefile.am
@@ -147,7 +147,9 @@ icons_DATA= \
 	gda-browser-column-pk.png \
 	gda-browser-reference.png \
 	gda-browser-diagram.png \
-	gda-browser-query.png
+	gda-browser-query.png \
+	gda-browser-form.png \
+	gda-browser-grid.png
 
 # app icon
 appiconsdir=$(datadir)/pixmaps
diff --git a/tools/browser/common/Makefile.am b/tools/browser/common/Makefile.am
index d345d7d..6537dcc 100644
--- a/tools/browser/common/Makefile.am
+++ b/tools/browser/common/Makefile.am
@@ -24,7 +24,9 @@ libcommon_la_SOURCES = \
 	gdaui-data-import.c \
 	gdaui-data-import.h \
 	gdaui-entry-import.c \
-	gdaui-entry-import.h
+	gdaui-entry-import.h \
+	ui-formgrid.c \
+	ui-formgrid.h
 
 $(OBJECTS): marshal.c marshal.h
 
diff --git a/tools/browser/common/ui-formgrid.c b/tools/browser/common/ui-formgrid.c
new file mode 100644
index 0000000..cf5cf60
--- /dev/null
+++ b/tools/browser/common/ui-formgrid.c
@@ -0,0 +1,370 @@
+/* ui-formgrid.c
+ *
+ * Copyright (C) 2010 Vivien Malerba
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include <libgda/libgda.h>
+#include "ui-formgrid.h"
+#include <libgda-ui/gdaui-data-proxy.h>
+#include <libgda-ui/gdaui-raw-form.h>
+#include <libgda-ui/gdaui-data-selector.h>
+#include "../support.h"
+
+static void ui_formgrid_class_init (UiFormGridClass * class);
+static void ui_formgrid_init (UiFormGrid *wid);
+
+static void ui_formgrid_set_property (GObject *object,
+					    guint param_id,
+					    const GValue *value,
+					    GParamSpec *pspec);
+static void ui_formgrid_get_property (GObject *object,
+					    guint param_id,
+					    GValue *value,
+					    GParamSpec *pspec);
+
+struct _UiFormGridPriv
+{
+	GtkWidget   *nb;
+	GtkWidget   *raw_form;
+	GtkWidget   *raw_grid;
+	GtkWidget   *info;
+	GdauiDataProxyInfoFlag flags;
+};
+
+/* get a pointer to the parents to be able to call their destructor */
+static GObjectClass *parent_class = NULL;
+
+/* properties */
+enum {
+	PROP_0,
+	PROP_RAW_GRID,
+	PROP_RAW_FORM,
+	PROP_INFO,
+};
+
+GType
+ui_formgrid_get_type (void)
+{
+	static GType type = 0;
+
+	if (!type) {
+		static const GTypeInfo info = {
+			sizeof (UiFormGridClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) ui_formgrid_class_init,
+			NULL,
+			NULL,
+			sizeof (UiFormGrid),
+			0,
+			(GInstanceInitFunc) ui_formgrid_init
+		};		
+
+		type = g_type_register_static (GTK_TYPE_VBOX, "UiFormGrid", &info, 0);
+	}
+
+	return type;
+}
+
+static void
+ui_formgrid_class_init (UiFormGridClass *class)
+{
+	GObjectClass   *object_class = G_OBJECT_CLASS (class);
+	
+	parent_class = g_type_class_peek_parent (class);
+
+	/* Properties */
+        object_class->set_property = ui_formgrid_set_property;
+        object_class->get_property = ui_formgrid_get_property;
+	g_object_class_install_property (object_class, PROP_RAW_GRID,
+                                         g_param_spec_object ("raw_grid", NULL, NULL, 
+							      GDAUI_TYPE_RAW_GRID,
+							      G_PARAM_READABLE));
+	g_object_class_install_property (object_class, PROP_RAW_FORM,
+                                         g_param_spec_object ("raw_form", NULL, NULL, 
+							      GDAUI_TYPE_RAW_GRID,
+							      G_PARAM_READABLE));
+	g_object_class_install_property (object_class, PROP_INFO,
+                                         g_param_spec_object ("widget_info", NULL, NULL, 
+							      GDAUI_TYPE_DATA_PROXY_INFO,
+							      G_PARAM_READABLE));
+}
+
+static void form_grid_toggled_cb (GtkToggleButton *button, UiFormGrid *formgrid);
+
+static void
+ui_formgrid_init (UiFormGrid *formgrid)
+{
+	GtkWidget *sw;
+	GtkWidget *hbox, *button;
+	
+	formgrid->priv = g_new0 (UiFormGridPriv, 1);
+	formgrid->priv->raw_grid = NULL;
+	formgrid->priv->info = NULL;
+	formgrid->priv->flags = GDAUI_DATA_PROXY_INFO_CURRENT_ROW;
+
+	/* notebook */
+	formgrid->priv->nb = gtk_notebook_new ();
+	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (formgrid->priv->nb), FALSE);
+	gtk_notebook_set_show_border (GTK_NOTEBOOK (formgrid->priv->nb), FALSE);
+	gtk_box_pack_start (GTK_BOX (formgrid), formgrid->priv->nb, TRUE, TRUE, 0);
+	gtk_widget_show (formgrid->priv->nb);
+
+	/* grid on 1st page of notebook */
+	sw = gtk_scrolled_window_new (NULL, NULL);
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+	gtk_notebook_append_page (GTK_NOTEBOOK (formgrid->priv->nb), sw, NULL);
+	gtk_widget_show (sw);
+
+	formgrid->priv->raw_grid = gdaui_raw_grid_new (NULL);
+	gdaui_data_proxy_column_show_actions (GDAUI_DATA_PROXY (formgrid->priv->raw_grid), -1, TRUE);
+	gtk_container_add (GTK_CONTAINER (sw), formgrid->priv->raw_grid);
+	gtk_widget_show (formgrid->priv->raw_grid);
+
+	/* form on the 2nd page of the notebook */
+	formgrid->priv->raw_form = gdaui_raw_form_new (NULL);
+	gdaui_data_proxy_column_show_actions (GDAUI_DATA_PROXY (formgrid->priv->raw_form), -1, TRUE);
+	gtk_notebook_append_page (GTK_NOTEBOOK (formgrid->priv->nb), formgrid->priv->raw_form, NULL);
+        gtk_widget_show (formgrid->priv->raw_form);
+
+	/* info widget and toggle button at last */
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (formgrid), hbox, FALSE, TRUE, 0);
+	gtk_widget_show (hbox);
+		
+	button = gtk_toggle_button_new ();
+	GdkPixbuf *pixbuf = browser_get_pixbuf_icon (BROWSER_ICON_GRID);
+	gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_pixbuf (pixbuf));
+
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+	gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
+	gtk_widget_show (button);
+	g_signal_connect (G_OBJECT (button), "toggled",
+			  G_CALLBACK (form_grid_toggled_cb), formgrid);
+	gtk_widget_set_tooltip_text (button, _("Toggle between grid and form presentations"));
+
+	formgrid->priv->info = gdaui_data_proxy_info_new (GDAUI_DATA_PROXY (formgrid->priv->raw_grid), 
+							  formgrid->priv->flags |
+							  GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
+							  GDAUI_DATA_PROXY_INFO_CHUNCK_CHANGE_BUTTONS);
+	gtk_box_pack_start (GTK_BOX (hbox), formgrid->priv->info, TRUE, TRUE, 0);
+	gtk_widget_show (formgrid->priv->info);
+}
+
+static void
+form_grid_toggled_cb (GtkToggleButton *button, UiFormGrid *formgrid)
+{
+	GdaDataModelIter *iter;
+	gint row;
+
+	if (!gtk_toggle_button_get_active (button)) {
+		/* switch to form  view */
+		gtk_notebook_set_current_page (GTK_NOTEBOOK (formgrid->priv->nb), 1);
+		g_object_set (G_OBJECT (formgrid->priv->info),
+			      "data-proxy", formgrid->priv->raw_form,
+			      "flags", formgrid->priv->flags | GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
+			      GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS
+			      /*GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
+			      GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS |
+			      GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS*/, NULL);
+
+		GdkPixbuf *pixbuf = browser_get_pixbuf_icon (BROWSER_ICON_FORM);
+		gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_pixbuf (pixbuf));
+
+		iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (formgrid->priv->raw_grid));
+		row = gda_data_model_iter_get_row (iter);
+		iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (formgrid->priv->raw_form));
+	}
+	else {
+		/* switch to grid view */
+		gtk_notebook_set_current_page (GTK_NOTEBOOK (formgrid->priv->nb), 0);
+		g_object_set (G_OBJECT (formgrid->priv->info),
+			      "data-proxy", formgrid->priv->raw_grid,
+			      "flags", formgrid->priv->flags | GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
+			      GDAUI_DATA_PROXY_INFO_CHUNCK_CHANGE_BUTTONS
+			      /*GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
+			      GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS |
+			      GDAUI_DATA_PROXY_INFO_CHUNCK_CHANGE_BUTTONS*/, NULL);
+
+		GdkPixbuf *pixbuf = browser_get_pixbuf_icon (BROWSER_ICON_GRID);
+		gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_pixbuf (pixbuf));
+
+		iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (formgrid->priv->raw_form));
+		row = gda_data_model_iter_get_row (iter);
+		iter = gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (formgrid->priv->raw_grid));
+	}
+
+	gda_data_model_iter_move_to_row (iter, row >= 0 ? row : 0);
+}
+
+/**
+ * ui_formgrid_new
+ * @model: a #GdaDataModel
+ *
+ * Creates a new #UiFormGrid widget suitable to display the data in @model
+ *
+ *  Returns: the new widget
+ */
+GtkWidget *
+ui_formgrid_new (GdaDataModel *model, GdauiDataProxyInfoFlag flags)
+{
+	UiFormGrid *formgrid;
+	GdaDataProxy *proxy;
+
+	g_return_val_if_fail (!model || GDA_IS_DATA_MODEL (model), NULL);
+
+	formgrid = (UiFormGrid *) g_object_new (UI_TYPE_FORMGRID, NULL);
+	formgrid->priv->flags = flags;
+
+	/* a raw form and a raw grid for the same proxy */
+	g_object_set (formgrid->priv->raw_grid, "model", model, NULL);
+	proxy = gdaui_data_proxy_get_proxy (GDAUI_DATA_PROXY (formgrid->priv->raw_grid));
+	g_object_set (formgrid->priv->raw_form, "model", proxy, NULL);
+	gdaui_data_proxy_set_write_mode (GDAUI_DATA_PROXY (formgrid->priv->raw_form),
+					 GDAUI_DATA_PROXY_WRITE_ON_ROW_CHANGE);
+	g_object_set (G_OBJECT (formgrid->priv->info),
+		      "flags", formgrid->priv->flags | GDAUI_DATA_PROXY_INFO_CURRENT_ROW |
+		      GDAUI_DATA_PROXY_INFO_CHUNCK_CHANGE_BUTTONS, NULL);
+
+	/* no more than 300 rows at a time */
+	gda_data_proxy_set_sample_size (proxy, 300);
+
+	return (GtkWidget *) formgrid;
+}
+
+
+static void
+ui_formgrid_set_property (GObject *object,
+				guint param_id,
+				const GValue *value,
+				GParamSpec *pspec)
+{
+	UiFormGrid *formgrid;
+	
+	formgrid = UI_FORMGRID (object);
+	
+	switch (param_id) {
+		
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}
+}
+
+static void
+ui_formgrid_get_property (GObject *object,
+				guint param_id,
+				GValue *value,
+				GParamSpec *pspec)
+{
+	UiFormGrid *formgrid;
+
+	formgrid = UI_FORMGRID (object);
+	
+	switch (param_id) {
+	case PROP_RAW_GRID:
+		g_value_set_object (value, formgrid->priv->raw_grid);
+		break;
+	case PROP_RAW_FORM:
+		g_value_set_object (value, formgrid->priv->raw_form);
+		break;
+	case PROP_INFO:
+		g_value_set_object (value, formgrid->priv->info);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}	
+}
+
+/**
+ * ui_formgrid_get_selection
+ * @formgrid: a #UiFormGrid widget
+ * 
+ * Returns the list of the currently selected rows in a #UiFormGrid widget. 
+ * The returned value is a list of integers, which represent each of the selected rows.
+ *
+ * If new rows have been inserted, then those new rows will have a row number equal to -1.
+ * This function is a wrapper around the gdaui_raw_grid_get_selection() function.
+ *
+ * Returns: a new array, should be freed (by calling g_array_free() and passing %TRUE as last argument) when no longer needed.
+ */
+GArray *
+ui_formgrid_get_selection (UiFormGrid *formgrid)
+{
+	g_return_val_if_fail (UI_IS_FORMGRID (formgrid), NULL);
+	g_return_val_if_fail (formgrid->priv, NULL);
+
+	return gdaui_data_selector_get_selected_rows (GDAUI_DATA_SELECTOR (formgrid->priv->raw_grid));
+}
+
+/**
+ * ui_formgrid_get_form_data_set
+ */
+GdaDataModelIter *
+ui_formgrid_get_form_data_set (UiFormGrid *formgrid)
+{
+	g_return_val_if_fail (UI_IS_FORMGRID (formgrid), NULL);
+	g_return_val_if_fail (formgrid->priv, NULL);
+
+	return gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (formgrid->priv->raw_form));
+}
+
+/**
+ * ui_formgrid_get_grid_data_set
+ */
+GdaDataModelIter *
+ui_formgrid_get_grid_data_set (UiFormGrid *formgrid)
+{
+	g_return_val_if_fail (UI_IS_FORMGRID (formgrid), NULL);
+	g_return_val_if_fail (formgrid->priv, NULL);
+
+	return gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (formgrid->priv->raw_grid));
+}
+
+
+/**
+ * ui_formgrid_set_sample_size
+ * @formgrid: a #UiFormGrid widget
+ * @sample_size:
+ *
+ *
+ */
+void
+ui_formgrid_set_sample_size (UiFormGrid *formgrid, gint sample_size)
+{
+	g_return_if_fail (UI_IS_FORMGRID (formgrid));
+	g_return_if_fail (formgrid->priv);
+
+	gdaui_raw_grid_set_sample_size (GDAUI_RAW_GRID (formgrid->priv->raw_grid), sample_size);
+}
+
+/**
+ * ui_formgrid_get_grid_widget
+ */
+GdauiRawGrid *
+ui_formgrid_get_grid_widget (UiFormGrid *formgrid)
+{
+	g_return_val_if_fail (UI_IS_FORMGRID (formgrid), NULL);
+	g_return_val_if_fail (formgrid->priv, NULL);
+
+	return GDAUI_RAW_GRID (formgrid->priv->raw_grid);
+}
diff --git a/tools/browser/common/ui-formgrid.h b/tools/browser/common/ui-formgrid.h
new file mode 100644
index 0000000..193deda
--- /dev/null
+++ b/tools/browser/common/ui-formgrid.h
@@ -0,0 +1,72 @@
+/* ui-formgrid.h
+ *
+ * Copyright (C) 2010 Vivien Malerba
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef __UI_FORMGRID__
+#define __UI_FORMGRID__
+
+#include <gtk/gtk.h>
+#include <libgda/gda-data-model.h>
+#include <libgda-ui/gdaui-data-proxy-info.h>
+#include <libgda-ui/gdaui-raw-grid.h>
+
+G_BEGIN_DECLS
+
+#define UI_TYPE_FORMGRID          (ui_formgrid_get_type())
+#define UI_FORMGRID(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, ui_formgrid_get_type(), UiFormGrid)
+#define UI_FORMGRID_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, ui_formgrid_get_type (), UiFormGridClass)
+#define UI_IS_FORMGRID(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, ui_formgrid_get_type ())
+
+
+typedef struct _UiFormGrid      UiFormGrid;
+typedef struct _UiFormGridClass UiFormGridClass;
+typedef struct _UiFormGridPriv  UiFormGridPriv;
+
+/* struct for the object's data */
+struct _UiFormGrid
+{
+	GtkVBox             object;
+
+	UiFormGridPriv     *priv;
+};
+
+/* struct for the object's class */
+struct _UiFormGridClass
+{
+	GtkVBoxClass       parent_class;
+};
+
+/* 
+ * Generic widget's methods 
+ */
+GType             ui_formgrid_get_type            (void);
+
+GtkWidget        *ui_formgrid_new                 (GdaDataModel *model, GdauiDataProxyInfoFlag flags);
+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);
+void              ui_formgrid_set_sample_size     (UiFormGrid *formgrid, gint sample_size);
+GdauiRawGrid     *ui_formgrid_get_grid_widget     (UiFormGrid *formgrid);
+
+G_END_DECLS
+
+#endif
+
+
+
diff --git a/tools/browser/data-manager/data-source.c b/tools/browser/data-manager/data-source.c
index c275076..6597357 100644
--- a/tools/browser/data-manager/data-source.c
+++ b/tools/browser/data-manager/data-source.c
@@ -26,6 +26,7 @@
 #include <sql-parser/gda-sql-parser.h>
 #include <libgda/gda-data-model-extra.h>
 #include <libgda/gda-sql-builder.h>
+#include "../common/ui-formgrid.h"
 
 #include "data-source.h"
 
@@ -803,7 +804,7 @@ replace_double_underscores (const gchar *str)
  *
  * Returns: a new #GdauiRawGrid, or %NULL if an error occurred
  */
-GdauiRawGrid *
+GtkWidget *
 data_source_create_grid (DataSource *source)
 {
 	g_return_val_if_fail (IS_DATA_SOURCE (source), NULL);
@@ -811,9 +812,11 @@ data_source_create_grid (DataSource *source)
 	if (! source->priv->model)
 		return NULL;
 
+	GtkWidget *fg;
 	GdauiRawGrid *grid;
-	grid = (GdauiRawGrid*) gdaui_raw_grid_new (source->priv->model);
-	
+	fg = (GdauiRawGrid*) ui_formgrid_new (source->priv->model, 0);
+	grid = ui_formgrid_get_grid_widget (UI_FORMGRID (fg));
+
 	GList *columns, *list;
 	columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (grid));
 	for (list = columns; list; list = list->next) {
@@ -850,7 +853,7 @@ data_source_create_grid (DataSource *source)
 	/*if (!columns || !columns->next)*/
 		gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (grid), FALSE);
 	g_list_free (columns);
-	return grid;
+	return fg;
 }
 
 /**
diff --git a/tools/browser/data-manager/data-source.h b/tools/browser/data-manager/data-source.h
index 720c719..a49d845 100644
--- a/tools/browser/data-manager/data-source.h
+++ b/tools/browser/data-manager/data-source.h
@@ -65,7 +65,7 @@ GHashTable         *data_source_get_export_columns  (DataSource *source);
 
 void                data_source_execute             (DataSource *source, GError **error);
 gboolean            data_source_execution_going_on  (DataSource *source);
-GdauiRawGrid       *data_source_create_grid         (DataSource *source);
+GtkWidget          *data_source_create_grid         (DataSource *source);
 const gchar        *data_source_get_title           (DataSource *source);
 
 /*
diff --git a/tools/browser/data-manager/data-widget.c b/tools/browser/data-manager/data-widget.c
index 205a67d..7a81c51 100644
--- a/tools/browser/data-manager/data-widget.c
+++ b/tools/browser/data-manager/data-widget.c
@@ -25,6 +25,7 @@
 #include "data-widget.h"
 #include "../browser-connection.h"
 #include "../browser-spinner.h"
+#include "../common/ui-formgrid.h"
 
 typedef struct {
 	DataWidget *dwid;
@@ -359,10 +360,12 @@ source_exec_finished_cb (DataSource *source, GError *error, DataPart *part)
 	}
 	
 	if (! part->data_widget) {
-		wid = (GtkWidget*) data_source_create_grid (part->source);
+		GtkWidget *cwid;
+		cwid = (GtkWidget*) data_source_create_grid (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, wid, NULL);
-		gtk_widget_show (part->data_widget);
+		part->data_widget_page = gtk_notebook_append_page (part->nb, cwid, NULL);
+		gtk_widget_show (cwid);
 		g_print ("Creating data widget for source [%s]\n", data_source_get_title (part->source));
 
 		/* compute part->export_data */
diff --git a/tools/browser/gda-browser-form.png b/tools/browser/gda-browser-form.png
new file mode 100644
index 0000000..0f77db8
Binary files /dev/null and b/tools/browser/gda-browser-form.png differ
diff --git a/tools/browser/gda-browser-grid.png b/tools/browser/gda-browser-grid.png
new file mode 100644
index 0000000..4edc744
Binary files /dev/null and b/tools/browser/gda-browser-grid.png differ
diff --git a/tools/browser/query-exec/query-result.c b/tools/browser/query-exec/query-result.c
index 501f52f..343c9f7 100644
--- a/tools/browser/query-exec/query-result.c
+++ b/tools/browser/query-exec/query-result.c
@@ -26,6 +26,7 @@
 #include "../browser-window.h"
 #include <libgda-ui/libgda-ui.h>
 #include <libgda/sql-parser/gda-sql-parser.h>
+#include "../common/ui-formgrid.h"
 
 struct _QueryResultPrivate {
 	QueryEditor *history;
@@ -331,12 +332,8 @@ static GtkWidget *
 make_widget_for_data_model (GdaDataModel *model, QueryResult *qres, const gchar *sql)
 {
 	GtkWidget *grid;
-	grid = gdaui_grid_new (model);
-	gdaui_grid_set_sample_size (GDAUI_GRID (grid), 300);
-	g_object_set (G_OBJECT (grid), "info-flags",
-		      GDAUI_DATA_PROXY_INFO_CHUNCK_CHANGE_BUTTONS | 
-		      GDAUI_DATA_PROXY_INFO_CURRENT_ROW, NULL);
-
+	grid = ui_formgrid_new (model, 0);
+	ui_formgrid_set_sample_size (UI_FORMGRID (grid), 300);
 	if (sql) {
 		BrowserConnection *bcnc;
 		bcnc = browser_window_get_connection ((BrowserWindow*) gtk_widget_get_toplevel ((GtkWidget*) qres));
@@ -362,7 +359,7 @@ make_widget_for_data_model (GdaDataModel *model, QueryResult *qres, const gchar
 		}
 
 		GdaSet *set;
-		set = (GdaSet*) gdaui_data_selector_get_data_set (GDAUI_DATA_SELECTOR (grid));
+		set = (GdaSet*) ui_formgrid_get_form_data_set (UI_FORMGRID (grid));
 
 		GdaSqlStatementSelect *sel;
 		GSList *list;
diff --git a/tools/browser/support.c b/tools/browser/support.c
index 0fda728..065785a 100644
--- a/tools/browser/support.c
+++ b/tools/browser/support.c
@@ -410,7 +410,9 @@ browser_get_pixbuf_icon (BrowserIconType type)
 		"gda-browser-column-nn.png",
 		"gda-browser-reference.png",
 		"gda-browser-diagram.png",
-		"gda-browser-query.png"
+		"gda-browser-query.png",
+		"gda-browser-grid.png",
+		"gda-browser-form.png",
 	};
 
 	if (!array)
diff --git a/tools/browser/support.h b/tools/browser/support.h
index 4ddcd5f..29bcdd6 100644
--- a/tools/browser/support.h
+++ b/tools/browser/support.h
@@ -71,6 +71,9 @@ typedef enum {
 	BROWSER_ICON_REFERENCE,
 	BROWSER_ICON_DIAGRAM,
 	BROWSER_ICON_QUERY,
+	
+	BROWSER_ICON_GRID,
+	BROWSER_ICON_FORM,
 
 	BROWSER_ICON_LAST
 } BrowserIconType;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]