Re: [gnome-db] FORM_TYPE_LIST



Attached please find a patch against 1.0.2.

In addition to replacing GnomeDbList with GnomeDbGrid, it implements the get_current_row() method for FORM_TYPE_LIST by returning the first entry from the grid's get_selection() method.

At 1/14/2004, Rodrigo Moya wrote:
On Tue, 2004-01-13 at 16:49 -0500, Jon Willeke wrote:
> Whereas a FORM_TYPE_NAVIGATOR GnomeDbForm displays data for all columns, a
> FORM_TYPE_LIST only displays the first column with a GnomeDbList. It seems
> that displaying data for all columns with a GnomeDbGrid would be more
> useful.  Should this replace FORM_TYPE_LIST or be added as FORM_TYPE_GRID?
>
no, the intention was to use a grid, no need really to use a list, since
if you want a single column, you can do that with the grid also.

Would you like to provide a patch to change that to a grid please?
diff -Naur libgnomedb-1.0.2.orig/libgnomedb/gnome-db-form.c libgnomedb-1.0.2/libgnomedb/gnome-db-form.c
--- libgnomedb-1.0.2.orig/libgnomedb/gnome-db-form.c	2003-05-12 16:54:02.000000000 -0400
+++ libgnomedb-1.0.2/libgnomedb/gnome-db-form.c	2004-01-14 11:12:13.000000000 -0500
@@ -28,7 +28,7 @@
 #include <gtk/gtktable.h>
 #include <gtk/gtktogglebutton.h>
 #include <libgnomedb/gnome-db-form.h>
-#include <libgnomedb/gnome-db-list.h>
+#include <libgnomedb/gnome-db-grid.h>
 #include <libgnomedb/gnome-db-util.h>
 #include "gnome-db-i18n.h"
 
@@ -219,6 +219,15 @@
 	return navigator;
 }
 
+static GtkWidget *
+create_list (GnomeDbForm *form)
+{
+	g_return_val_if_fail (GNOME_DB_IS_FORM (form), NULL);
+	g_return_val_if_fail (GDA_IS_DATA_MODEL (form->priv->data_model), NULL);
+
+	return gnome_db_new_grid_widget (form->priv->data_model);
+}
+
 static void
 setup_widgets_for_model (GnomeDbForm *form)
 {
@@ -238,13 +247,16 @@
 		form->priv->form_container = create_navigator (form);
 		break;
 	case GNOME_DB_FORM_TYPE_LIST :
-		form->priv->form_container = gnome_db_list_new_with_model (form->priv->data_model, 0);
+		form->priv->form_container = create_list (form);
 		break;
 	default :
 		form->priv->form_container = NULL;
-		return;
+		break;
 	}
 
+	if (!form->priv->form_container)
+		return;
+
 	gtk_widget_show (form->priv->form_container);
 	gtk_box_pack_start (GTK_BOX (form), form->priv->form_container, TRUE, TRUE, 0);
 }
@@ -528,12 +540,24 @@
 gint
 gnome_db_form_get_current_row (GnomeDbForm *form)
 {
+	GList *selection;
+	gint ret;
+
 	g_return_val_if_fail (GNOME_DB_IS_FORM (form), -1);
 
 	switch (form->priv->type) {
 	case GNOME_DB_FORM_TYPE_NAVIGATOR :
 		return form->priv->navigator_current_row;
 	case GNOME_DB_FORM_TYPE_LIST :
+		g_return_val_if_fail (GNOME_DB_IS_GRID (form->priv->form_container), -1);
+
+		selection = gnome_db_grid_get_selection (GNOME_DB_GRID (form->priv->form_container));
+		if (selection) {
+			ret = GPOINTER_TO_INT (selection->data);
+			g_list_free (selection);
+			return ret;
+		}
+		break;
 	}
 
 	return -1;


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