libgnomedb r1757 - in trunk: . doc/C/tmpl libgnomedb libgnomedb/binreloc libgnomedb/data-entries libgnomedb/plugins testing



Author: vivien
Date: Sat Oct 18 13:07:41 2008
New Revision: 1757
URL: http://svn.gnome.org/viewvc/libgnomedb?rev=1757&view=rev

Log:
2008-10-18  Vivien Malerba <malerba gnome-db org>

	* libgnomedb/binreloc/Makefile.am
	* libgnomedb/binreloc/gnome-db-binreloc.c: ported code from Libgda
	correcting problems
	* libgnomedb/data-entries/gnome-db-entry-combo.c:
	* libgnomedb/gnome-db-basic-form.h: cosmetic cleanups
	* libgnomedb/gnome-db-basic-form.c:
	* libgnomedb/gnome-db-data-entry.c:
	* libgnomedb/gnome-db-raw-form.c:
	* libgnomedb/gnome-db-raw-grid.c:
	* libgnomedb/data-entries/gnome-db-entry-none.c:
	* libgnomedb/data-entries/gnome-db-format-entry.c:
	* libgnomedb/plugins/gnome-db-entry-text.c:
	* testing/test-handlers.c: minor corrections mainly due to Libgda's
	API changes


Modified:
   trunk/ChangeLog
   trunk/doc/C/tmpl/gnome-db-basic-form.sgml
   trunk/libgnomedb/binreloc/Makefile.am
   trunk/libgnomedb/binreloc/gnome-db-binreloc.c
   trunk/libgnomedb/data-entries/gnome-db-entry-combo.c
   trunk/libgnomedb/data-entries/gnome-db-entry-none.c
   trunk/libgnomedb/data-entries/gnome-db-format-entry.c
   trunk/libgnomedb/gnome-db-basic-form.c
   trunk/libgnomedb/gnome-db-basic-form.h
   trunk/libgnomedb/gnome-db-data-entry.c
   trunk/libgnomedb/gnome-db-raw-form.c
   trunk/libgnomedb/gnome-db-raw-grid.c
   trunk/libgnomedb/plugins/gnome-db-entry-text.c
   trunk/testing/test-handlers.c

Modified: trunk/doc/C/tmpl/gnome-db-basic-form.sgml
==============================================================================
--- trunk/doc/C/tmpl/gnome-db-basic-form.sgml	(original)
+++ trunk/doc/C/tmpl/gnome-db-basic-form.sgml	Sat Oct 18 13:07:41 2008
@@ -181,7 +181,7 @@
 
 @form: 
 @param: 
- sensitive: 
+ editable: 
 
 
 <!-- ##### FUNCTION gnome_db_basic_form_set_entries_auto_default ##### -->
@@ -228,6 +228,6 @@
 
 @form: 
 @param: 
- sensitive: 
+ editable: 
 
 

Modified: trunk/libgnomedb/binreloc/Makefile.am
==============================================================================
--- trunk/libgnomedb/binreloc/Makefile.am	(original)
+++ trunk/libgnomedb/binreloc/Makefile.am	Sat Oct 18 13:07:41 2008
@@ -5,7 +5,13 @@
 	-I$(top_builddir) \
 	$(LIBGNOMEDB_CFLAGS) \
 	$(BINRELOC_CFLAGS) \
-	-DLIBGNOMEDBPREFIX=\""$(prefix)"\"
+	-DLIBGNOMEDBPREFIX=\""$(prefix)"\" \
+	-DLIBGNOMEDBDATA=\""$(datadir)"\" \
+        -DLIBGNOMEDBLIB=\""$(libdir)"\" \
+        -DLIBGNOMEDBLIBEXEC=\""$(libexecdir)"\" \
+        -DLIBGNOMEDBBIN=\""$(bindir)"\" \
+        -DLIBGNOMEDBSBIN=\""$(sbindir)"\" \
+        -DLIBGNOMEDBSYSCONF=\""$(sysconfdir)"\"
 
 noinst_LTLIBRARIES = libgnomedb_binreloc-4.0.la
 

Modified: trunk/libgnomedb/binreloc/gnome-db-binreloc.c
==============================================================================
--- trunk/libgnomedb/binreloc/gnome-db-binreloc.c	(original)
+++ trunk/libgnomedb/binreloc/gnome-db-binreloc.c	Sat Oct 18 13:07:41 2008
@@ -24,6 +24,25 @@
 /* include source file as mentionned in gbr_init_lib()'s doc */
 #include "binreloc.c"
 
+#ifdef G_OS_WIN32
+#include <windows.h>
+/* Remember HMODULE to retrieve path to it lateron */
+static HMODULE hdllmodule = NULL;
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
+{
+	switch(fdwReason)
+	{
+	case DLL_PROCESS_ATTACH:
+		hdllmodule = (HMODULE)hinstDLL;
+		break;
+	}
+
+	return TRUE;
+}
+#elif HAVE_CARBON
+#include <Carbon/Carbon.h>
+#endif
+
 /**
  * gnome_db_gbr_init
  */
@@ -31,6 +50,9 @@
 gnome_db_gbr_init (void)
 {
 #ifdef G_OS_WIN32
+	/* nothing */
+#elif HAVE_CARBON
+	/* nothing */
 #else
 	_gnome_db_gbr_init_lib (NULL);
 #endif
@@ -42,50 +64,114 @@
 gchar *
 gnome_db_gbr_get_file_path (GnomeDbPrefixDir where, ...)
 {
-	gchar *prefix;
+	gchar *prefix = NULL;
 	gchar *tmp, *file_part;
 	va_list ap;
 	gchar **parts;
 	gint size, i;
-	const gchar *prefix_dir_name;
+	const gchar *prefix_dir_name = NULL;
+	gint prefix_len = strlen (LIBGNOMEDBPREFIX);
 
+#ifdef G_OS_WIN32
+	wchar_t path[MAX_PATH];
+	gchar* p;
+#endif
 	switch (where) {
 	default:
 	case GNOME_DB_NO_DIR:
-		prefix_dir_name = NULL;
 		break;
 	case GNOME_DB_BIN_DIR:
-		prefix_dir_name = "bin";
+		tmp = LIBGNOMEDBBIN;
+		if (! g_str_has_prefix (tmp, LIBGNOMEDBPREFIX) || (tmp [prefix_len] != G_DIR_SEPARATOR)) 
+			prefix = g_strdup (tmp);
+		else
+			prefix_dir_name = tmp + prefix_len + 1;
 		break;
 	case GNOME_DB_SBIN_DIR:
-		prefix_dir_name = "sbin";
+		tmp = LIBGNOMEDBSBIN;
+		if (! g_str_has_prefix (tmp, LIBGNOMEDBPREFIX) || (tmp [prefix_len] != G_DIR_SEPARATOR)) 
+			prefix = g_strdup (tmp);
+		else
+			prefix_dir_name = tmp + prefix_len + 1;
 		break;
 	case GNOME_DB_DATA_DIR:
-		prefix_dir_name = "share";
+		tmp = LIBGNOMEDBDATA;
+		if (! g_str_has_prefix (tmp, LIBGNOMEDBPREFIX) || (tmp [prefix_len] != G_DIR_SEPARATOR)) 
+			prefix = g_strdup (tmp);
+		else
+			prefix_dir_name = tmp + prefix_len + 1;
 		break;
 	case GNOME_DB_LOCALE_DIR:
-		prefix_dir_name = "share" G_DIR_SEPARATOR_S "locale";
+		tmp = LIBGNOMEDBDATA;
+		if (! g_str_has_prefix (tmp, LIBGNOMEDBPREFIX) || (tmp [prefix_len] != G_DIR_SEPARATOR)) {
+			prefix = g_strdup (tmp);
+			prefix_dir_name = "locale";
+		}
+		else
+			prefix_dir_name = "share" G_DIR_SEPARATOR_S "locale";
 		break;
 	case GNOME_DB_LIB_DIR:
-		prefix_dir_name = "lib";		
+		tmp = LIBGNOMEDBLIB;
+		if (! g_str_has_prefix (tmp, LIBGNOMEDBPREFIX) || (tmp [prefix_len] != G_DIR_SEPARATOR)) 
+			prefix = g_strdup (tmp);
+		else 
+			prefix_dir_name = tmp + prefix_len + 1;
 		break;
 	case GNOME_DB_LIBEXEC_DIR:
-		prefix_dir_name = "libexec";
+		tmp = LIBGNOMEDBLIBEXEC;
+		if (! g_str_has_prefix (tmp, LIBGNOMEDBPREFIX) || (tmp [prefix_len] != G_DIR_SEPARATOR)) 
+			prefix = g_strdup (tmp);
+		else
+			prefix_dir_name = tmp + prefix_len + 1;
 		break;
 	case GNOME_DB_ETC_DIR:
-		prefix_dir_name = "etc";
+		tmp = LIBGNOMEDBSYSCONF;
+		if (! g_str_has_prefix (tmp, LIBGNOMEDBPREFIX) || (tmp [prefix_len] != G_DIR_SEPARATOR)) 
+			prefix = g_strdup (tmp);
+		else
+			prefix_dir_name = tmp + prefix_len + 1;
 		break;
 	}
 
 #ifdef GNOME_DB_DEBUG_NO
 	g_print ("%s ()\n", __FUNCTION__);
 #endif
-	/* prefix part */
+
+
+	if (!prefix) {
+		/* prefix part for each OS */
 #ifdef G_OS_WIN32
-	prefix = g_win32_get_package_installation_directory (GETTEXT_PACKAGE, NULL);
+		/* Get from location of libgnomedb DLL */
+		GetModuleFileNameW (hdllmodule, path, MAX_PATH);
+		prefix = g_utf16_to_utf8 (path, -1, NULL, NULL, NULL);
+		if ((p = strrchr (prefix, G_DIR_SEPARATOR)) != NULL)
+			*p = '\0';
+		
+		p = strrchr (prefix, G_DIR_SEPARATOR);
+		if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0 ||
+			  g_ascii_strcasecmp (p + 1, "lib") == 0))
+			*p = '\0';	
+#elif HAVE_CARBON
+#define MAXLEN 500
+		ProcessSerialNumber myProcess;
+		FSRef bundleLocation;
+		unsigned char bundlePath[MAXLEN];
+		
+		if ((GetCurrentProcess (&myProcess) == noErr) &&
+		    (GetProcessBundleLocation (&myProcess, &bundleLocation) == noErr) &&
+		    (FSRefMakePath (&bundleLocation, bundlePath, MAXLEN) == noErr)) {
+			prefix = g_path_get_dirname ((const char*) bundlePath);
+			if (g_str_has_suffix (prefix, "bin"))
+				prefix [strlen (prefix) - 3] = 0;
+		}
+		else
+			g_warning ("Could not get PREFIX (using Mac OS X Carbon)");
 #else
-	prefix = _gnome_db_gbr_find_prefix (LIBGNOMEDBPREFIX);
+		if (!prefix)
+			prefix = _gnome_db_gbr_find_prefix (LIBGNOMEDBPREFIX);
 #endif
+	}
+
 	if (!prefix || !*prefix)
 		return NULL;
        

Modified: trunk/libgnomedb/data-entries/gnome-db-entry-combo.c
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-entry-combo.c	(original)
+++ trunk/libgnomedb/data-entries/gnome-db-entry-combo.c	Sat Oct 18 13:07:41 2008
@@ -231,12 +231,12 @@
 
 	obj = g_object_new (GNOME_DB_TYPE_ENTRY_COMBO, NULL);
   
-  _gnome_db_entry_combo_construct(GNOME_DB_ENTRY_COMBO (obj), paramlist, source);
+	_gnome_db_entry_combo_construct (GNOME_DB_ENTRY_COMBO (obj), paramlist, source);
 
 	return GTK_WIDGET (obj);
 }
 
-/**
+/*
  * _gnome_db_entry_combo_construct
  * @combo: a #GnomeDbEntryCombo object to be construced
  * @paramlist: a #GdaSet object
@@ -245,9 +245,8 @@
  * 
  * TODO: This is just a work-around for language bindings. Ideally we would use construction
  * properties instead.
-*/
-
-void _gnome_db_entry_combo_construct(GnomeDbEntryCombo* combo, GdaSet *paramlist, GdaSetSource *source)
+ */
+void _gnome_db_entry_combo_construct (GnomeDbEntryCombo* combo, GdaSet *paramlist, GdaSetSource *source)
 {
 	GSList *list;
 	GSList *values;

Modified: trunk/libgnomedb/data-entries/gnome-db-entry-none.c
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-entry-none.c	(original)
+++ trunk/libgnomedb/data-entries/gnome-db-entry-none.c	Sat Oct 18 13:07:41 2008
@@ -109,7 +109,7 @@
 	GObject *obj;
 	GnomeDbEntryNone *entry;
 
-	g_return_val_if_fail (type != G_TYPE_INVALID, NULL);
+	g_return_val_if_fail ((type == G_TYPE_INVALID) || (type != GDA_TYPE_NULL) , NULL);
 
 	obj = g_object_new (GNOME_DB_TYPE_ENTRY_NONE, NULL);
 	entry = GNOME_DB_ENTRY_NONE (obj);

Modified: trunk/libgnomedb/data-entries/gnome-db-format-entry.c
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-format-entry.c	(original)
+++ trunk/libgnomedb/data-entries/gnome-db-format-entry.c	Sat Oct 18 13:07:41 2008
@@ -1131,7 +1131,7 @@
 	g_free (new_text);
 
 	LEAVE_INTERNAL_CHANGES (entry);
-	g_signal_emit_by_name (entry, "changed");
+	//g_signal_emit_by_name (entry, "changed");
 
 	return FALSE; /* remove the timeout */
 }

Modified: trunk/libgnomedb/gnome-db-basic-form.c
==============================================================================
--- trunk/libgnomedb/gnome-db-basic-form.c	(original)
+++ trunk/libgnomedb/gnome-db-basic-form.c	Sat Oct 18 13:07:41 2008
@@ -133,6 +133,14 @@
 	parent_class = g_type_class_peek_parent (class);
 
 	/* signals */
+	/**
+	 * GnomeDbBasicForm::param-changed:
+	 * @form: GnomeDbBasicForm
+	 * @param: that changed
+	 * @is_user_modif: TRUE if the modification has been initiated by a user modification
+	 *
+	 * Emitted when a GdaHolder changes
+	 */
 	gnome_db_basic_form_signals[PARAM_CHANGED] =
 		g_signal_new ("param_changed",
 			      G_TYPE_FROM_CLASS (object_class),
@@ -352,7 +360,28 @@
 	}
 	else if (!strcmp (att_name, GNOME_DB_ATTRIBUTE_PLUGIN)) {
 		/* TODO: be more specific and change only the cell renderer corresponding to @param */
+
+		/* keep a list of hidden columns */
+		GSList *list, *hidden_params = NULL;
+		for (list = form->priv->hidden_entries; list; list = list->next) {
+			GdaHolder *param = g_object_get_data (G_OBJECT (list->data), "param");
+			if (param)
+				hidden_params = g_slist_prepend (hidden_params, param);
+			else {
+				/* multiple parameters, take the 1st param */
+				GdaSetGroup *group;				
+				group = g_object_get_data (G_OBJECT (list->data), "group");
+				hidden_params = g_slist_prepend (hidden_params, GDA_SET_NODE (group->nodes->data)->holder);
+			}
+		}
+
+		/* re-create entries */
 		paramlist_public_data_changed_cb (paramlist, form);
+
+		/* hide entries which were hidden */
+		for (list = hidden_params; list; list = list->next) 
+			gnome_db_basic_form_entry_show (form, GDA_HOLDER (list->data), FALSE);
+		g_slist_free (hidden_params);
 	}
 }
 
@@ -915,23 +944,6 @@
 	gnome_db_basic_form_show_entry_actions (form, form->priv->show_actions);
 	/* Set the Auto entries default in the entries */
 	gnome_db_basic_form_set_entries_auto_default (form, form->priv->entries_auto_default);
-
-	/* hide some entries if specified */
-	for (list = form->priv->entries; list; list = list->next) {
-		gboolean explicit_hide = FALSE;
-		GdaHolder *param;
-			
-		param = g_object_get_data (G_OBJECT (list->data), "param");
-		if (param) {
-			if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "_gnome_db_explicit_show")) == 1)
-				explicit_hide = TRUE;
-		}
-		else {
-			/* FIXME */
-		}
-		if (explicit_hide) 
-			gnome_db_basic_form_entry_show (form, param, FALSE);
-	}
 }
 
 static void
@@ -1215,8 +1227,7 @@
 	g_return_if_fail (form && GNOME_DB_IS_BASIC_FORM (form));
 	g_return_if_fail (form->priv);
 
-	list = form->priv->entries;
-	while (list) {
+	for (list = form->priv->entries; list; list = list->next) {
 		GdaSetGroup *group;
 
 		group = g_object_get_data (G_OBJECT (list->data), "group");
@@ -1248,9 +1259,12 @@
 		else {
 			/* non combo entry */
 			param = g_object_get_data (G_OBJECT (list->data), "param");
+			g_signal_handlers_block_by_func (G_OBJECT (list->data),
+							 G_CALLBACK (entry_contents_modified), form);
 			gnome_db_data_entry_set_value_orig (GNOME_DB_DATA_ENTRY (list->data), gda_holder_get_value (param));
+			g_signal_handlers_unblock_by_func (G_OBJECT (list->data),
+							   G_CALLBACK (entry_contents_modified), form);
 		}
-		list = g_slist_next (list);
 	}
 }
 
@@ -1479,7 +1493,7 @@
  * gnome_db_basic_form_entry_set_editable
  * @form: a #GnomeDbBasicForm widget
  * @param: a #GdaHolder object
- * @editable:
+ * @editable: %TRUE if corresponding data entry must be editable
  *
  * Sets the #GnomeDbDataEntry in @form which corresponds to the
  * @param parameter editable or not
@@ -1577,8 +1591,7 @@
 	g_return_val_if_fail (GNOME_DB_IS_BASIC_FORM (form), NULL);
 	g_return_val_if_fail (form->priv, NULL);
 
-	entries = form->priv->entries;
-	while (entries && !entry) {
+	for (entries = form->priv->entries; entries && !entry; entries = entries->next) {
 		GdaHolder *thisparam = g_object_get_data (G_OBJECT (entries->data), "param");
 
 		if (thisparam) {
@@ -1591,15 +1604,13 @@
 			GdaSetGroup *group;
 
 			group = g_object_get_data (G_OBJECT (entries->data), "group");
-			params = group->nodes;
-			while (params && !entry) {
-				if (GDA_SET_NODE (params->data)->holder == (gpointer) param)
+			for (params = group->nodes; params; params = params->next) {
+				if (GDA_SET_NODE (params->data)->holder == (gpointer) param) {
 					entry = GTK_WIDGET (entries->data);
-				params = g_slist_next (params);
+					break;
+				}
 			}
 		}
-
-		entries = g_slist_next (entries);
 	}
 
 	return entry;

Modified: trunk/libgnomedb/gnome-db-basic-form.h
==============================================================================
--- trunk/libgnomedb/gnome-db-basic-form.h	(original)
+++ trunk/libgnomedb/gnome-db-basic-form.h	Sat Oct 18 13:07:41 2008
@@ -86,14 +86,14 @@
 								GdaHolder *param, gboolean show);
 void              gnome_db_basic_form_entry_grab_focus         (GnomeDbBasicForm *form, GdaHolder *param);
 void              gnome_db_basic_form_entry_set_editable       (GnomeDbBasicForm *form, GdaHolder *param, 
-								gboolean sensitive);
+								gboolean editable);
 void              gnome_db_basic_form_set_entries_auto_default (GnomeDbBasicForm *form, gboolean auto_default);
 void              gnome_db_basic_form_set_entries_default      (GnomeDbBasicForm *form);
 
 GtkWidget        *gnome_db_basic_form_get_entry_widget         (GnomeDbBasicForm *form, GdaHolder *param);
 GtkWidget        *gnome_db_basic_form_get_label_widget         (GnomeDbBasicForm *form, GdaHolder *param);
 
-void              gnome_db_basic_form_entry_set_editable       (GnomeDbBasicForm *form, GdaHolder *param, gboolean editable);
+
 
 G_END_DECLS
 

Modified: trunk/libgnomedb/gnome-db-data-entry.c
==============================================================================
--- trunk/libgnomedb/gnome-db-data-entry.c	(original)
+++ trunk/libgnomedb/gnome-db-data-entry.c	Sat Oct 18 13:07:41 2008
@@ -152,7 +152,6 @@
 gnome_db_data_entry_set_value_type (GnomeDbDataEntry *de, GType type)
 {
 	g_return_if_fail (GNOME_DB_IS_DATA_ENTRY (de));
-	g_return_if_fail (type != G_TYPE_INVALID);
 
 	if (GNOME_DB_DATA_ENTRY_GET_IFACE (de)->set_value_type)
 		(GNOME_DB_DATA_ENTRY_GET_IFACE (de)->set_value_type) (de, type);

Modified: trunk/libgnomedb/gnome-db-raw-form.c
==============================================================================
--- trunk/libgnomedb/gnome-db-raw-form.c	(original)
+++ trunk/libgnomedb/gnome-db-raw-form.c	Sat Oct 18 13:07:41 2008
@@ -473,16 +473,10 @@
 		gint i;
 
 		for (i = 0, params = ((GdaSet *) iter)->holders; params; i++, params = params->next) {
-			gboolean explicit_hide = FALSE;
 			param = (GdaHolder *) params->data;
 			attributes = gda_data_proxy_get_value_attributes (form->priv->proxy, row, i);
 			gnome_db_basic_form_entry_set_editable ((GnomeDbBasicForm *) form, 
 								param, !(attributes & GDA_VALUE_ATTR_NO_MODIF));
-			if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "_gnome_db_explicit_show")) == 1)
-				explicit_hide = TRUE;
-			if (!explicit_hide) 
-				gnome_db_basic_form_entry_show ((GnomeDbBasicForm *) form, 
-								param, !(attributes & GDA_VALUE_ATTR_UNUSED));
 		}
 	}
 }
@@ -517,8 +511,6 @@
 static void 
 gnome_db_raw_form_initialize (GnomeDbRawForm *form, GtkWidget *layout, GHashTable *box_widgets)
 {
-	GSList *list;
-
 	/*
 	 * handling of the layout
 	 */
@@ -552,18 +544,6 @@
 	if (!layout && gda_data_proxy_is_read_only (form->priv->proxy))
 		gnome_db_basic_form_show_entry_actions (GNOME_DB_BASIC_FORM (form), FALSE);
 
-	for (list = GDA_SET (form->priv->iter)->holders; list; list = list->next) {
-		GdaSetNode *node;
-
-		node = gda_set_get_node (GDA_SET (form->priv->iter), GDA_HOLDER (list->data));
-		g_assert (node);
-		if (node->hint &GDA_SET_HOLDER_HIDE) {
-			gnome_db_basic_form_entry_show (GNOME_DB_BASIC_FORM (form),
-							GDA_HOLDER (list->data), FALSE);
-			g_object_set_data (G_OBJECT (list->data), "_gnome_db_explicit_show", GINT_TO_POINTER (1));
-		}
-	}
-
 	/* data display update */
 	proxy_changed_cb (form->priv->proxy, form);
 }
@@ -936,7 +916,6 @@
 	param = gda_data_model_iter_get_holder_for_field (form->priv->iter, column);
 	g_return_if_fail (param);
 	gnome_db_basic_form_entry_show (GNOME_DB_BASIC_FORM (form), param, shown);
-	g_object_set_data (G_OBJECT (param), "_gnome_db_explicit_show", GINT_TO_POINTER (shown ? 2 : 1));
 }
 
 void

Modified: trunk/libgnomedb/gnome-db-raw-grid.c
==============================================================================
--- trunk/libgnomedb/gnome-db-raw-grid.c	(original)
+++ trunk/libgnomedb/gnome-db-raw-grid.c	Sat Oct 18 13:07:41 2008
@@ -71,11 +71,11 @@
 static GnomeDbDataWidgetWriteMode gnome_db_raw_grid_widget_get_write_mode (GnomeDbDataWidget *iface);
 
 typedef struct {
-	GdaSetGroup *group;
-	GtkCellRenderer       *data_cell;
-	GtkCellRenderer       *info_cell;
-	gboolean               info_shown;
-	gboolean               data_locked; /* TRUE if no modification allowed on that column */
+	GdaSetGroup     *group;
+	GtkCellRenderer *data_cell;
+	GtkCellRenderer *info_cell;
+	gboolean         info_shown;
+	gboolean         data_locked; /* TRUE if no modification allowed on that column */
 } ColumnData;
 
 #define COLUMN_DATA(x) ((ColumnData *)(x))
@@ -566,7 +566,6 @@
 		GtkTreeViewColumn *column;
 		GtkCellRenderer *renderer;
 		ColumnData *column_data;
-		gboolean explicit_hide = FALSE;
 
 		group = GDA_SET_GROUP (list->data);
 
@@ -622,7 +621,6 @@
 					  G_CALLBACK (data_cell_values_changed), grid);
 
 			g_object_set_data (G_OBJECT (column), "source", group->nodes_source);
-			/* FIXME: compute @explicit_hide */
 		}
 		else {
 			/* single direct parameter */
@@ -652,28 +650,16 @@
 			}
 			renderer = gnome_db_util_new_cell_renderer (g_type, plugin);
 			column_data->data_cell = renderer;
-			if (! column_data->data_locked)
-				column_data->data_locked = GDA_SET_NODE (group->nodes->data)->hint & 
-					GDA_SET_HOLDER_READ_ONLY;
 			gtk_tree_view_insert_column_with_data_func (tree_view, i, title, renderer,
 								    (GtkTreeCellDataFunc) cell_renderer_value_set_attributes, 
 								    grid, NULL);
 			column = gtk_tree_view_get_column (tree_view, i);
 			g_free (title);
 
-			if (GDA_SET_NODE (group->nodes->data)->hint & GDA_SET_HOLDER_HIDE)
-				g_object_set_data (G_OBJECT (param), "_gnome_db_explicit_show", GINT_TO_POINTER (1));
-
-			if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "_gnome_db_explicit_show")) == 1)
-				explicit_hide = TRUE;
-
 			g_signal_connect (G_OBJECT (renderer), "changed", 
 					  G_CALLBACK (data_cell_value_changed), grid);
 		}
 
-		if (explicit_hide)
-			gtk_tree_view_column_set_visible (column, FALSE);
-
 		g_object_set_data (G_OBJECT (column), "data_renderer", renderer);
 		g_object_set (G_OBJECT (renderer), "editable", !column_data->data_locked, NULL);
 
@@ -704,26 +690,6 @@
 		list = g_slist_next (list);
 		i++;
 	}
-
-	/*
-	 * Hiding some columns of the grid
-	 */
-	for (list = GDA_SET (grid->priv->iter)->nodes_list; list; list = list->next) {
-		guint hint = GDA_SET_NODE (list->data)->hint;
-
-		if (hint & GDA_SET_HOLDER_HIDE) {
-			GtkTreeViewColumn *viewcol;
-			GdaSetGroup *group;
-			gint pos;
-
-			group = gda_set_get_group ((GdaSet *) grid->priv->iter, GDA_SET_NODE (list->data)->holder);
-			pos = g_slist_index (((GdaSet *) grid->priv->iter)->groups_list, group);
-			g_assert (pos >= 0);
-
-			viewcol = gtk_tree_view_get_column (GTK_TREE_VIEW (grid), pos);
-			gtk_tree_view_column_set_visible (viewcol, FALSE);
-		}
-	}
 }
 
 /*
@@ -2079,7 +2045,6 @@
 
 	/* Sets the column's visibility */
 	gtk_tree_view_column_set_visible (viewcol, shown);
-	g_object_set_data (G_OBJECT (param), "_gnome_db_explicit_show", GINT_TO_POINTER (shown ? 2 : 1));
 }
 
 
@@ -2157,7 +2122,30 @@
 {
 	if (!strcmp (att_name, GNOME_DB_ATTRIBUTE_PLUGIN)) {
 		/* TODO: be more specific and change only the cell renderer corresponding to @param */
+
+		/* keep a list of hidden columns */
+		gint i;
+		gboolean *hidden_cols;
+		GList *cols, *list;
+		cols = gtk_tree_view_get_columns (GTK_TREE_VIEW (grid));
+		hidden_cols = g_new0 (gboolean, g_list_length (cols));
+		for (list = cols, i = 0; list; list = list->next, i++) {
+			if (!gtk_tree_view_column_get_visible (GTK_TREE_VIEW_COLUMN (list->data)))
+				hidden_cols [i] = TRUE;
+		}
+		g_list_free (cols);
+
+		/* re-create columns */
 		paramlist_public_data_changed_cb (paramlist, grid);
+
+		/* hide columns which were hidden */
+		cols = gtk_tree_view_get_columns (GTK_TREE_VIEW (grid));
+		for (list = cols, i = 0; list; list = list->next, i++) {
+			if (hidden_cols [i])
+				gtk_tree_view_column_set_visible (GTK_TREE_VIEW_COLUMN (list->data), FALSE);
+		}
+		g_list_free (cols);
+		g_free (hidden_cols);
 	}
 }
 

Modified: trunk/libgnomedb/plugins/gnome-db-entry-text.c
==============================================================================
--- trunk/libgnomedb/plugins/gnome-db-entry-text.c	(original)
+++ trunk/libgnomedb/plugins/gnome-db-entry-text.c	Sat Oct 18 13:07:41 2008
@@ -190,10 +190,9 @@
 	mgtxt = GNOME_DB_ENTRY_TEXT (mgwrap);
 	g_return_if_fail (mgtxt->priv);
 
+	gtk_text_buffer_set_text (mgtxt->priv->buffer, "", -1);
 	if (value) {
-		if (gda_value_is_null ((GValue *) value))
-                        gtk_text_buffer_set_text (mgtxt->priv->buffer, "", -1);
-		else {
+		if (! gda_value_is_null ((GValue *) value)) {
 			GdaDataHandler *dh;		
 			gchar *str;
 
@@ -205,8 +204,6 @@
 			}
 		}
 	}
-	else 
-		gtk_text_buffer_set_text (mgtxt->priv->buffer, "", -1);
 }
 
 static GValue *
@@ -226,8 +223,8 @@
 	gtk_text_buffer_get_start_iter (mgtxt->priv->buffer, &start);
 	gtk_text_buffer_get_end_iter (mgtxt->priv->buffer, &end);
 	str = gtk_text_buffer_get_text (mgtxt->priv->buffer, &start, &end, FALSE);
-	value = gda_data_handler_get_value_from_sql (dh, str, 
-						    gnome_db_data_entry_get_value_type (GNOME_DB_DATA_ENTRY (mgwrap)));
+	value = gda_data_handler_get_value_from_str (dh, str, 
+						     gnome_db_data_entry_get_value_type (GNOME_DB_DATA_ENTRY (mgwrap)));
 	g_free (str);
 	if (!value) {
 		/* in case the gda_data_handler_get_value_from_sql() returned an error because

Modified: trunk/testing/test-handlers.c
==============================================================================
--- trunk/testing/test-handlers.c	(original)
+++ trunk/testing/test-handlers.c	Sat Oct 18 13:07:41 2008
@@ -930,13 +930,17 @@
 		GdaSet *plist;
 		GdaHolder *param;
 		GnomeDbDataWidget *datawid;
+		GValue *value;
 
 		wid = gnome_db_form_new (model);
 		g_object_get (G_OBJECT (wid), "raw-form", &datawid, NULL);
 		g_object_set (G_OBJECT (datawid), "show-actions", TRUE, NULL);
 		plist = GDA_SET (gnome_db_data_widget_get_current_data (GNOME_DB_DATA_WIDGET (datawid)));
 		param = plist->holders->data;
-		g_object_set (G_OBJECT (param), "entry-plugin", plugin_name, NULL);
+
+		value = gda_value_new_from_string (plugin_name, G_TYPE_STRING);
+		gda_holder_set_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN, value);
+		gda_value_free (value);
 		g_object_unref (datawid);
 	}
 	else {
@@ -962,13 +966,17 @@
 		GdaSet *plist;
 		GdaHolder *param;
 		GnomeDbDataWidget *datawid;
-
+		GValue *value;
+		
 		wid = gnome_db_grid_new (model);
 		g_object_get (G_OBJECT (wid), "raw-grid", &datawid, NULL);
 		g_object_set (G_OBJECT (datawid), "info-cell-visible", TRUE, NULL);
 		plist = GDA_SET (gnome_db_data_widget_get_current_data (GNOME_DB_DATA_WIDGET (datawid)));
 		param = plist->holders->data;
-		g_object_set (G_OBJECT (param), "entry-plugin", plugin_name, NULL);
+
+		value = gda_value_new_from_string (plugin_name, G_TYPE_STRING);
+		gda_holder_set_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN, value);
+		gda_value_free (value);
 		g_object_unref (datawid);
 	}
 	else {



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