[libgda] Implemented drawing of invalid data for all cell renderers



commit cb3bf554e766a6a303ea99c6f4f5e5357f15c952
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Jun 27 16:18:45 2010 +0200

    Implemented drawing of invalid data for all cell renderers

 libgda-ui/data-entries/Makefile.am                 |   11 +-
 .../data-entries/gdaui-data-cell-renderer-bin.c    |    4 +-
 .../gdaui-data-cell-renderer-boolean.c             |   63 +++++---
 .../data-entries/gdaui-data-cell-renderer-combo.c  |   16 ++-
 .../gdaui-data-cell-renderer-textual.c             |    4 +-
 .../{drawing.c => gdaui-data-cell-renderer-util.c} |    4 +-
 .../{drawing.h => gdaui-data-cell-renderer-util.h} |    6 +-
 .../plugins/gdaui-data-cell-renderer-cgrid.c       |  134 ++++++++-------
 .../plugins/gdaui-data-cell-renderer-password.c    |  156 ++++++++++--------
 .../plugins/gdaui-data-cell-renderer-pict.c        |  170 +++++++++++---------
 10 files changed, 313 insertions(+), 255 deletions(-)
---
diff --git a/libgda-ui/data-entries/Makefile.am b/libgda-ui/data-entries/Makefile.am
index 6cc9cce..4f7f7f8 100644
--- a/libgda-ui/data-entries/Makefile.am
+++ b/libgda-ui/data-entries/Makefile.am
@@ -13,6 +13,11 @@ AM_CPPFLAGS = \
         -DDATADIR=\""$(datadir)"\" \
         -DLIBDIR=\""$(libdir)"\"
 
+gdauiincludedir=$(includedir)/libgda-$(GDA_ABI_MAJOR_VERSION).$(GDA_ABI_MINOR_VERSION)/libgda-ui
+gdauiinclude_HEADERS= $(extra_headers)
+extra_headers = \
+	gdaui-data-cell-renderer-util.h
+
 libgda_ui_data_entries_headers = \
 	gdaui-data-cell-renderer-bin.h \
 	gdaui-data-cell-renderer-boolean.h \
@@ -39,6 +44,8 @@ libgda_ui_data_entries_la_SOURCES = \
 	$(libgda_ui_data_entries_headers) \
 	common-bin.c \
 	common-bin.h \
+	$(extra_headers) \
+	gdaui-data-cell-renderer-util.c \
 	gdaui-data-cell-renderer-bin.c \
 	gdaui-data-cell-renderer-boolean.c \
 	gdaui-data-cell-renderer-combo.c \
@@ -60,9 +67,7 @@ libgda_ui_data_entries_la_SOURCES = \
 	gdaui-entry-wrapper.c \
 	gdaui-entry.c \
 	gdaui-formatted-entry.c \
-	gdaui-numeric-entry.c \
-	drawing.h \
-	drawing.c
+	gdaui-numeric-entry.c
 
 xmldir   = $(datadir)/libgda-4.0/ui
 xml_in_files = \
diff --git a/libgda-ui/data-entries/gdaui-data-cell-renderer-bin.c b/libgda-ui/data-entries/gdaui-data-cell-renderer-bin.c
index b5e4f54..c0497a0 100644
--- a/libgda-ui/data-entries/gdaui-data-cell-renderer-bin.c
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-bin.c
@@ -26,7 +26,7 @@
 #include "gdaui-data-cell-renderer-bin.h"
 #include "marshallers/gdaui-custom-marshal.h"
 #include "common-bin.h"
-#include "drawing.h"
+#include "gdaui-data-cell-renderer-util.h"
 
 static void gdaui_data_cell_renderer_bin_get_property  (GObject *object,
 							guint param_id,
@@ -387,7 +387,7 @@ gdaui_data_cell_renderer_bin_render (GtkCellRenderer      *cell,
 		g_object_unref (style);
 	}
 	if (datacell->priv->invalid)
-		draw_invalid_area (window, cell_area);
+		gdaui_data_cell_renderer_draw_invalid_area (window, cell_area);
 }
 
 static void
diff --git a/libgda-ui/data-entries/gdaui-data-cell-renderer-boolean.c b/libgda-ui/data-entries/gdaui-data-cell-renderer-boolean.c
index fee2260..39a922c 100644
--- a/libgda-ui/data-entries/gdaui-data-cell-renderer-boolean.c
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-boolean.c
@@ -1,7 +1,7 @@
 /* gdaui-data-cell-renderer-boolean.c
  *
  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb redhat com>
- * Copyright (C) 2003 - 2009 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2003 - 2010 Vivien Malerba <malerba gnome-db org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -25,7 +25,7 @@
 #include <libgda/gda-enum-types.h>
 #include "gdaui-data-cell-renderer-boolean.h"
 #include "marshallers/gdaui-custom-marshal.h"
-
+#include "gdaui-data-cell-renderer-util.h"
 
 static void gdaui_data_cell_renderer_boolean_get_property  (GObject *object,
 							    guint param_id,
@@ -67,12 +67,13 @@ enum {
 };
 
 
-struct _GdauiDataCellRendererBooleanPrivate 
+struct _GdauiDataCellRendererBooleanPrivate
 {
 	GdaDataHandler       *dh;
         GType                 type;
         GValue               *value;
 	gboolean              to_be_deleted;
+	gboolean              invalid;
 
 	gboolean              editable;
 	gboolean              active;
@@ -110,7 +111,7 @@ gdaui_data_cell_renderer_boolean_get_type (void)
 			0,              /* n_preallocs */
 			(GInstanceInitFunc) gdaui_data_cell_renderer_boolean_init,
 		};
-		
+
 		cell_type =
 			g_type_register_static (GTK_TYPE_CELL_RENDERER_TOGGLE, "GdauiDataCellRendererBoolean",
 						&cell_info, 0);
@@ -147,7 +148,7 @@ gdaui_data_cell_renderer_boolean_class_init (GdauiDataCellRendererBooleanClass *
 	cell_class->get_size = gdaui_data_cell_renderer_boolean_get_size;
 	cell_class->render = gdaui_data_cell_renderer_boolean_render;
 	cell_class->activate = gdaui_data_cell_renderer_boolean_activate;
-  
+
 	g_object_class_install_property (object_class,
 					 PROP_VALUE,
 					 g_param_spec_boxed ("value",
@@ -155,7 +156,7 @@ gdaui_data_cell_renderer_boolean_class_init (GdauiDataCellRendererBooleanClass *
 							     _("GValue to render"),
 							     G_TYPE_VALUE,
 							     G_PARAM_READWRITE));
-  
+
 	g_object_class_install_property (object_class,
 					 PROP_VALUE_ATTRIBUTES,
 					 g_param_spec_flags ("value-attributes", NULL, NULL, GDA_TYPE_VALUE_ATTRIBUTE,
@@ -182,7 +183,7 @@ gdaui_data_cell_renderer_boolean_class_init (GdauiDataCellRendererBooleanClass *
 					PROP_TYPE,
 					g_param_spec_gtype("type", NULL, NULL, G_TYPE_NONE,
 							   G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
-  
+
 
 	toggle_cell_signals[CHANGED] =
 		g_signal_new ("changed",
@@ -231,7 +232,7 @@ gdaui_data_cell_renderer_boolean_get_property (GObject *object,
 					       GParamSpec *pspec)
 {
 	GdauiDataCellRendererBoolean *cell = GDAUI_DATA_CELL_RENDERER_BOOLEAN (object);
-  
+
 	switch (param_id) {
 	case PROP_VALUE:
 		g_value_set_boxed (value, cell->priv->value);
@@ -255,33 +256,42 @@ gdaui_data_cell_renderer_boolean_set_property (GObject *object,
 					       GParamSpec *pspec)
 {
 	GdauiDataCellRendererBoolean *cell = GDAUI_DATA_CELL_RENDERER_BOOLEAN (object);
-  
+
 	switch (param_id) {
 	case PROP_VALUE:
 		/* Because we don't have a copy of the value, we MUST NOT free it! */
                 cell->priv->value = NULL;
-		if (value) {			
+		cell->priv->invalid = FALSE;
+		if (value) {
                         GValue *gval = g_value_get_boxed (value);
 			if (gval && !gda_value_is_null (gval)) {
 				g_return_if_fail (G_VALUE_TYPE (gval) == cell->priv->type);
 				if (! gda_value_isa (gval, G_TYPE_BOOLEAN))
 					g_warning ("GdauiDataCellRendererBoolean can only handle boolean values");
-				else 
+				else
 					g_object_set (G_OBJECT (object),
 						      "inconsistent", FALSE,
 						      "active", g_value_get_boolean (gval), NULL);
 			}
-			else
-				g_object_set (G_OBJECT (object), 
+			else if (gval)
+				g_object_set (G_OBJECT (object),
+					      "inconsistent", TRUE,
+					      "active", FALSE, NULL);
+			else {
+				cell->priv->invalid = TRUE;
+				g_object_set (G_OBJECT (object),
 					      "inconsistent", TRUE,
 					      "active", FALSE, NULL);
+			}
 
                         cell->priv->value = gval;
                 }
-		else
-			g_object_set (G_OBJECT (object), 
+		else {
+			cell->priv->invalid = TRUE;
+			g_object_set (G_OBJECT (object),
 				      "inconsistent", TRUE,
 				      "active", FALSE, NULL);
+		}
 
                 g_object_notify (object, "value");
 		break;
@@ -316,7 +326,7 @@ gdaui_data_cell_renderer_boolean_set_property (GObject *object,
  * gdaui_data_cell_renderer_boolean_new:
  * @dh: a #GdaDataHandler object
  * @type:
- * 
+ *
  * Creates a new #GdauiDataCellRendererBoolean. Adjust rendering
  * parameters using object properties. Object properties can be set
  * globally (with g_object_set()). Also, with #GtkTreeViewColumn, you
@@ -324,7 +334,7 @@ gdaui_data_cell_renderer_boolean_set_property (GObject *object,
  * can bind the "active" property on the cell renderer to a boolean value
  * in the model, thus causing the check button to reflect the state of
  * the model.
- * 
+ *
  * Return value: the new cell renderer
  */
 GtkCellRenderer *
@@ -333,9 +343,9 @@ gdaui_data_cell_renderer_boolean_new (GdaDataHandler *dh, GType type)
 	GObject *obj;
 
         g_return_val_if_fail (dh && GDA_IS_DATA_HANDLER (dh), NULL);
-        obj = g_object_new (GDAUI_TYPE_DATA_CELL_RENDERER_BOOLEAN, "type", type, 
+        obj = g_object_new (GDAUI_TYPE_DATA_CELL_RENDERER_BOOLEAN, "type", type,
                             "data-handler", dh, NULL);
-        	
+
         return GTK_CELL_RENDERER (obj);
 }
 
@@ -362,26 +372,29 @@ gdaui_data_cell_renderer_boolean_render (GtkCellRenderer      *cell,
 					 GdkRectangle         *expose_area,
 					 GtkCellRendererState  flags)
 {
+	GdauiDataCellRendererBoolean *datacell = GDAUI_DATA_CELL_RENDERER_BOOLEAN (cell);
 	GtkCellRendererClass *toggle_class = g_type_class_peek (GTK_TYPE_CELL_RENDERER_TOGGLE);
 
 	(toggle_class->render) (cell, window, widget, background_area, cell_area, expose_area, flags);
 
-	if (GDAUI_DATA_CELL_RENDERER_BOOLEAN (cell)->priv->to_be_deleted) {
+	if (datacell->priv->to_be_deleted) {
 		GtkStyle *style;
 		guint xpad;
 
 		g_object_get (G_OBJECT(widget), "style", &style, "xpad", &xpad, NULL);
 		gtk_paint_hline (style,
 				 window, GTK_STATE_SELECTED,
-				 cell_area, 
+				 cell_area,
 				 widget,
 				 "hline",
 				 cell_area->x + xpad, cell_area->x + cell_area->width - xpad,
 				 cell_area->y + cell_area->height / 2.);
 
 	}
+	if (datacell->priv->invalid)
+		gdaui_data_cell_renderer_draw_invalid_area (window, cell_area);
 }
-	
+
 static gboolean
 gdaui_data_cell_renderer_boolean_activate  (GtkCellRenderer            *cell,
 					    GdkEvent                   *event,
@@ -396,17 +409,17 @@ gdaui_data_cell_renderer_boolean_activate  (GtkCellRenderer            *cell,
 	if (editable) {
 		gboolean retval, active;
 		GValue *value;
-		
+
 		retval = gtk_cell_renderer_activate (cell, event, widget, path, background_area, cell_area, flags);
 		active = gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (cell));
-		
+
 		value = gda_value_new (G_TYPE_BOOLEAN);
 		g_value_set_boolean (value, ! active);
 		g_signal_emit (G_OBJECT (cell), toggle_cell_signals[CHANGED], 0, path, value);
 		gda_value_free (value);
 		return retval;
 	}
-	
+
 	return FALSE;
 }
 
diff --git a/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c b/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c
index 3698e7d..937e2e0 100644
--- a/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-combo.c
@@ -1,7 +1,7 @@
 /* gdaui-data-cell-renderer-combo.c
  *
  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb redhat com>
- * Copyright (C) 2003 - 2009 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2003 - 2010 Vivien Malerba <malerba gnome-db org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -28,6 +28,7 @@
 #include <libgda-ui/gdaui-combo.h>
 #include <libgda-ui/gdaui-data-entry.h>
 #include <libgda/gda-enum-types.h>
+#include "gdaui-data-cell-renderer-util.h"
 
 #define GDAUI_DATA_CELL_RENDERER_COMBO_PATH "gdaui-data-cell-renderer-combo-path"
 
@@ -93,6 +94,7 @@ struct _GdauiDataCellRendererComboPrivate
 	gboolean      to_be_deleted;
 	gboolean      set_default_if_invalid;
 	gboolean      show_expander;
+	gboolean      invalid;
 };
 
 
@@ -270,6 +272,7 @@ gdaui_data_cell_renderer_combo_set_property (GObject *object,
 
 	switch (param_id) {
 	case PROP_VALUES:
+		datacell->priv->invalid = FALSE;
 		if (value) {	
 			GList *gvalues = g_value_get_pointer (value);
 			if (gvalues) {
@@ -329,11 +332,15 @@ gdaui_data_cell_renderer_combo_set_property (GObject *object,
 
 				g_slist_free (values);
 			}
-			else
+			else {
+				datacell->priv->invalid = TRUE;
 				g_object_set (G_OBJECT (object), "text", "", NULL);
+			}
 		}
-		else
+		else {
+			datacell->priv->invalid = TRUE;
 			g_object_set (G_OBJECT (object), "text", "", NULL);
+		}
 		
 		g_object_notify (object, "values");
 		break;
@@ -551,6 +558,9 @@ gdaui_data_cell_renderer_combo_render (GtkCellRenderer      *cell,
 				 cell_area->y + cell_area->height / 2.);
 		g_object_unref (style);
 	}
+
+	if (combocell->priv->invalid)
+		gdaui_data_cell_renderer_draw_invalid_area (window, cell_area);
 }
 
 static void gdaui_data_cell_renderer_combo_editing_done (GtkCellEditable *combo, GdauiDataCellRendererCombo *datacell);
diff --git a/libgda-ui/data-entries/gdaui-data-cell-renderer-textual.c b/libgda-ui/data-entries/gdaui-data-cell-renderer-textual.c
index 5030c67..ddcf74a 100644
--- a/libgda-ui/data-entries/gdaui-data-cell-renderer-textual.c
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-textual.c
@@ -35,7 +35,7 @@
 #include "gdaui-entry-timestamp.h"
 #include <libgda/gda-enum-types.h>
 #include "marshallers/gdaui-custom-marshal.h"
-#include "drawing.h"
+#include "gdaui-data-cell-renderer-util.h"
 
 #define MAX_ACCEPTED_STRING_LENGTH 500
 
@@ -631,7 +631,7 @@ gdaui_data_cell_renderer_textual_render (GtkCellRenderer      *cell,
 		g_object_unref (style);
 	}
 	if (datacell->priv->invalid)
-		draw_invalid_area (window, cell_area);
+		gdaui_data_cell_renderer_draw_invalid_area (window, cell_area);
 }
 
 static void
diff --git a/libgda-ui/data-entries/drawing.c b/libgda-ui/data-entries/gdaui-data-cell-renderer-util.c
similarity index 91%
rename from libgda-ui/data-entries/drawing.c
rename to libgda-ui/data-entries/gdaui-data-cell-renderer-util.c
index bea41a1..192e135 100644
--- a/libgda-ui/data-entries/drawing.c
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-util.c
@@ -17,10 +17,10 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "drawing.h"
+#include "gdaui-data-cell-renderer-util.h"
 
 void
-draw_invalid_area (GdkWindow *window, GdkRectangle *cell_area)
+gdaui_data_cell_renderer_draw_invalid_area (GdkWindow *window, GdkRectangle *cell_area)
 {
 	cairo_t *cr;
 	cr = gdk_cairo_create (window);
diff --git a/libgda-ui/data-entries/drawing.h b/libgda-ui/data-entries/gdaui-data-cell-renderer-util.h
similarity index 82%
rename from libgda-ui/data-entries/drawing.h
rename to libgda-ui/data-entries/gdaui-data-cell-renderer-util.h
index ad9cf10..5723e25 100644
--- a/libgda-ui/data-entries/drawing.h
+++ b/libgda-ui/data-entries/gdaui-data-cell-renderer-util.h
@@ -17,11 +17,11 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef __DRAWING_H__
-#define __DRAWING_H__
+#ifndef __GDAUI_DATA_CELL_RENDERER_UTIL_H__
+#define __GDAUI_DATA_CELL_RENDERER_UTIL_H__
 
 #include <gtk/gtk.h>
 
-void draw_invalid_area (GdkWindow *window, GdkRectangle *cell_area);
+void gdaui_data_cell_renderer_draw_invalid_area (GdkWindow *window, GdkRectangle *cell_area);
 
 #endif
diff --git a/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-cgrid.c b/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-cgrid.c
index e371bb3..74f2b72 100644
--- a/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-cgrid.c
+++ b/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-cgrid.c
@@ -1,6 +1,7 @@
 /* gdaui-data-cell-renderer-cgrid.c
  *
- * Copyright (C) 2007 - 2009 Carlos Savoretti
+ * Copyright (C) 2007 - 2010 Carlos Savoretti
+ * Copyright (C) 2010 Vivien Malerba <malerba gnome-db org>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -24,6 +25,7 @@
 
 #include "gdaui-entry-cgrid.h"
 #include "gdaui-data-cell-renderer-cgrid.h"
+#include "gdaui-data-cell-renderer-util.h"
 
 struct _GdauiDataCellRendererCGridPrivate {
 	GdaDataHandler        *data_handler;    /* Data handler. */
@@ -34,6 +36,7 @@ struct _GdauiDataCellRendererCGridPrivate {
 
 	GValue                *value;
 	GdaValueAttribute      value_attributes;
+	gboolean               invalid;
 };
 
 enum {
@@ -67,21 +70,21 @@ static GObjectClass *parent_class;
  */
 GdauiDataCellRendererCGrid *
 gdaui_data_cell_renderer_cgrid_new (GdaDataHandler  *data_handler,
-				       GType            gtype,
-				       const gchar     *options)
+				    GType            gtype,
+				    const gchar     *options)
 {
 	return (GdauiDataCellRendererCGrid *) g_object_new (GDAUI_TYPE_DATA_CELL_RENDERER_CGRID,
-							      "data-handler", data_handler,
-							      "gtype", gtype,
-							      "options", g_strdup (options),
-							      NULL);
+							    "data-handler", data_handler,
+							    "gtype", gtype,
+							    "options", g_strdup (options),
+							    NULL);
 }
 
 static void
 gdaui_data_cell_renderer_cgrid_init (GdauiDataCellRendererCGrid  *cgrid)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
-	
+
 	cgrid->priv = g_new0 (GdauiDataCellRendererCGridPrivate, 1);
 	cgrid->priv->data_handler = NULL;
 	cgrid->priv->gtype = G_TYPE_INVALID;
@@ -94,10 +97,10 @@ gdaui_data_cell_renderer_cgrid_finalize (GdauiDataCellRendererCGrid  *cgrid)
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 
 	if (cgrid->priv) {
-		if (cgrid->priv->data_handler) { 
-			g_object_unref (G_OBJECT(cgrid->priv->data_handler)); 
-			cgrid->priv->data_handler = NULL; 
-		} 
+		if (cgrid->priv->data_handler) {
+			g_object_unref (G_OBJECT(cgrid->priv->data_handler));
+			cgrid->priv->data_handler = NULL;
+		}
 		if (cgrid->priv->options) {
 			g_free (G_OBJECT(cgrid->priv->options));
 			cgrid->priv->options = NULL;
@@ -133,7 +136,7 @@ gdaui_data_cell_renderer_cgrid_get_data_handler (GdauiDataCellRendererCGrid  *cg
  */
 void
 gdaui_data_cell_renderer_cgrid_set_data_handler (GdauiDataCellRendererCGrid  *cgrid,
-						    GdaDataHandler          *data_handler)
+						 GdaDataHandler          *data_handler)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 
@@ -169,7 +172,7 @@ gdaui_data_cell_renderer_cgrid_get_gtype (GdauiDataCellRendererCGrid  *cgrid)
  */
 void
 gdaui_data_cell_renderer_cgrid_set_gtype (GdauiDataCellRendererCGrid  *cgrid,
-					     GType                    gtype)
+					  GType                    gtype)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 
@@ -201,7 +204,7 @@ gdaui_data_cell_renderer_cgrid_get_options (GdauiDataCellRendererCGrid  *cgrid)
  */
 void
 gdaui_data_cell_renderer_cgrid_set_options (GdauiDataCellRendererCGrid  *cgrid,
-					       const gchar                   *options)
+					    const gchar                   *options)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 
@@ -235,7 +238,7 @@ gdaui_data_cell_renderer_cgrid_get_editable (GdauiDataCellRendererCGrid  *cgrid)
  */
 void
 gdaui_data_cell_renderer_cgrid_set_editable (GdauiDataCellRendererCGrid  *cgrid,
-						gboolean                 editable)
+					     gboolean                 editable)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 	cgrid->priv->editable = editable;
@@ -264,7 +267,7 @@ gdaui_data_cell_renderer_cgrid_get_to_be_deleted (GdauiDataCellRendererCGrid  *c
  */
 void
 gdaui_data_cell_renderer_cgrid_set_to_be_deleted (GdauiDataCellRendererCGrid  *cgrid,
-						     gboolean                 to_be_deleted)
+						  gboolean                 to_be_deleted)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 	cgrid->priv->to_be_deleted = to_be_deleted;
@@ -293,7 +296,7 @@ gdaui_data_cell_renderer_cgrid_get_value (GdauiDataCellRendererCGrid  *cgrid)
  */
 void
 gdaui_data_cell_renderer_cgrid_set_value (GdauiDataCellRendererCGrid  *cgrid,
-					     const GValue                  *value)
+					  const GValue                *value)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 
@@ -302,8 +305,10 @@ gdaui_data_cell_renderer_cgrid_set_value (GdauiDataCellRendererCGrid  *cgrid,
 		cgrid->priv->value = NULL;
 	}
 
-	if (!value)
+	if (!value) {
+		cgrid->priv->invalid = TRUE;
 		return;
+	}
 
 	cgrid->priv->value = gda_value_copy (value);
 	g_object_notify (G_OBJECT(cgrid), "value");
@@ -331,7 +336,7 @@ gdaui_data_cell_renderer_cgrid_get_value_attributes (GdauiDataCellRendererCGrid
  */
 void
 gdaui_data_cell_renderer_cgrid_set_value_attributes (GdauiDataCellRendererCGrid  *cgrid,
-							GdaValueAttribute        value_attributes)
+						     GdaValueAttribute        value_attributes)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID (cgrid));
 	cgrid->priv->value_attributes = value_attributes;
@@ -340,9 +345,9 @@ gdaui_data_cell_renderer_cgrid_set_value_attributes (GdauiDataCellRendererCGrid
 
 static void
 gdaui_data_cell_renderer_cgrid_set_property (GObject       *object,
-						guint          param_id,
-						const GValue  *value,
-						GParamSpec    *pspec)
+					     guint          param_id,
+					     const GValue  *value,
+					     GParamSpec    *pspec)
 {
 	GdauiDataCellRendererCGrid *cgrid;
 
@@ -382,9 +387,9 @@ gdaui_data_cell_renderer_cgrid_set_property (GObject       *object,
 
 static void
 gdaui_data_cell_renderer_cgrid_get_property (GObject     *object,
-						guint        param_id,
-						GValue      *value,
-						GParamSpec  *pspec)
+					     guint        param_id,
+					     GValue      *value,
+					     GParamSpec  *pspec)
 {
 	GdauiDataCellRendererCGrid *cgrid;
 
@@ -424,12 +429,12 @@ gdaui_data_cell_renderer_cgrid_get_property (GObject     *object,
 
 static void
 gdaui_data_cell_renderer_cgrid_get_size (GtkCellRenderer  *renderer,
-					    GtkWidget        *widget,
-					    GdkRectangle     *rectangle,
-					    gint             *x_offset,
-					    gint             *y_offset,
-					    gint             *width,
-					    gint             *height)
+					 GtkWidget        *widget,
+					 GdkRectangle     *rectangle,
+					 gint             *x_offset,
+					 gint             *y_offset,
+					 gint             *width,
+					 gint             *height)
 {
 	GtkCellRendererClass *renderer_class = g_type_class_peek (GTK_TYPE_CELL_RENDERER_TEXT);
 
@@ -438,18 +443,19 @@ gdaui_data_cell_renderer_cgrid_get_size (GtkCellRenderer  *renderer,
 
 static void
 gdaui_data_cell_renderer_cgrid_render (GtkCellRenderer       *renderer,
-					  GdkWindow             *window,
-					  GtkWidget             *widget,
-					  GdkRectangle          *background_rectangle,
-					  GdkRectangle          *cell_rectangle,
-					  GdkRectangle          *expose_rectangle,
-					  GtkCellRendererState   flags)
+				       GdkWindow             *window,
+				       GtkWidget             *widget,
+				       GdkRectangle          *background_rectangle,
+				       GdkRectangle          *cell_rectangle,
+				       GdkRectangle          *expose_rectangle,
+				       GtkCellRendererState   flags)
 {
+	GdauiDataCellRendererCGrid *datacell = GDAUI_DATA_CELL_RENDERER_CGRID (renderer);
 	GtkCellRendererClass *renderer_class = g_type_class_peek (GTK_TYPE_CELL_RENDERER_TEXT);
 
 	(renderer_class->render) (renderer, window, widget, background_rectangle, cell_rectangle, expose_rectangle, flags);
 
-	if (GDAUI_DATA_CELL_RENDERER_CGRID(renderer)->priv->to_be_deleted) {
+	if (datacell->priv->to_be_deleted) {
 		GtkStyle *style;
 		guint xpad;
 
@@ -461,16 +467,18 @@ gdaui_data_cell_renderer_cgrid_render (GtkCellRenderer       *renderer,
                                  cell_rectangle,
                                  widget,
                                  "hline",
-                                 cell_rectangle->x + xpad, 
+                                 cell_rectangle->x + xpad,
 				 cell_rectangle->x + cell_rectangle->width - xpad,
                                  cell_rectangle->y + cell_rectangle->height / 2.);
 		g_object_unref (style);
 	}
+	if (datacell->priv->invalid)
+		gdaui_data_cell_renderer_draw_invalid_area (window, cell_rectangle);
 }
 
 static void
 gdaui_data_cell_renderer_cgrid_editing_done (GtkCellEditable  *editable,
-						gpointer          data)
+					     gpointer          data)
 {
 	g_return_if_fail (GDAUI_IS_DATA_CELL_RENDERER_CGRID(data));
 
@@ -483,29 +491,29 @@ gdaui_data_cell_renderer_cgrid_editing_done (GtkCellEditable  *editable,
 
 static GtkCellEditable *
 gdaui_data_cell_renderer_cgrid_start_editing (GtkCellRenderer       *renderer,
-						 GdkEvent              *event,
-						 GtkWidget             *widget,
-						 const gchar           *path,
-						 GdkRectangle          *background_rectangle,
-						 GdkRectangle          *cell_rectangle,
-						 GtkCellRendererState   flags)
+					      GdkEvent              *event,
+					      GtkWidget             *widget,
+					      const gchar           *path,
+					      GdkRectangle          *background_rectangle,
+					      GdkRectangle          *cell_rectangle,
+					      GtkCellRendererState   flags)
 {
 	GdauiDataCellRendererCGrid *cgrid = GDAUI_DATA_CELL_RENDERER_CGRID(renderer);
 
 	gboolean editable;
-	g_object_get (G_OBJECT(renderer), "editable", &editable, NULL); 
+	g_object_get (G_OBJECT(renderer), "editable", &editable, NULL);
 
 	GtkWidget *entry = (GtkWidget *) gdaui_entry_cgrid_new (cgrid->priv->data_handler,
-								   cgrid->priv->gtype,
-								   cgrid->priv->options);
+								cgrid->priv->gtype,
+								cgrid->priv->options);
 
 	g_object_set (G_OBJECT(entry),
 		      "is-cell-renderer", TRUE,
 		      "actions", FALSE,
-		      NULL); 
+		      NULL);
 
 	gdaui_data_entry_set_reference_value (GDAUI_DATA_ENTRY(entry),
-					     cgrid->priv->value);
+					      cgrid->priv->value);
 
 	g_signal_connect (G_OBJECT(entry), "editing-done",
 			  G_CALLBACK(gdaui_data_cell_renderer_cgrid_editing_done),
@@ -547,9 +555,9 @@ gdaui_data_cell_renderer_cgrid_class_init (GdauiDataCellRendererCGridClass  *kla
 		(gobject_class,
 		 PROP_GTYPE,
 		 g_param_spec_gtype ("gtype", _("Cgrid gtype"),
-				      _("The cgrid gtype"),
-				      G_TYPE_NONE,
-				      (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
+				     _("The cgrid gtype"),
+				     G_TYPE_NONE,
+				     (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
 
 	g_object_class_install_property
 		(gobject_class,
@@ -563,24 +571,24 @@ gdaui_data_cell_renderer_cgrid_class_init (GdauiDataCellRendererCGridClass  *kla
 		(gobject_class,
 		 PROP_EDITABLE,
 		 g_param_spec_boolean ("editable", _("Cgrid is editable"),
-				      _("Cgrid editable"),
-				      TRUE,
-				      (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
+				       _("Cgrid editable"),
+				       TRUE,
+				       (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
 
 	g_object_class_install_property
 		(gobject_class,
 		 PROP_TO_BE_DELETED,
 		 g_param_spec_boolean ("to-be-deleted", _("Cgrid is to be deleted"),
-				      _("Cgrid to be deleted"),
-				      TRUE,
-				      (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
+				       _("Cgrid to be deleted"),
+				       TRUE,
+				       (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
 
 	g_object_class_install_property
 		(gobject_class,
 		 PROP_VALUE,
 		 g_param_spec_pointer ("value", _("Cgrid value"),
-				      _("Cgrid value"),
-				      (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
+				       _("Cgrid value"),
+				       (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
 
 	g_object_class_install_property
 		(gobject_class,
diff --git a/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-password.c b/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-password.c
index eac46eb..bc3808b 100644
--- a/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-password.c
+++ b/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-password.c
@@ -1,6 +1,6 @@
 /* gdaui-data-cell-renderer-password.c
  *
- * Copyright (C) 2003 - 2009 Vivien Malerba <malerba gdaui org>
+ * Copyright (C) 2003 - 2010 Vivien Malerba <malerba gdaui org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -26,6 +26,7 @@
 #include "custom-marshal.h"
 #include "gdaui-entry-password.h"
 #include <libgda/gda-enum-types.h>
+#include "gdaui-data-cell-renderer-util.h"
 
 static void gdaui_data_cell_renderer_password_init       (GdauiDataCellRendererPassword      *celltext);
 static void gdaui_data_cell_renderer_password_class_init (GdauiDataCellRendererPasswordClass *class);
@@ -33,35 +34,35 @@ static void gdaui_data_cell_renderer_password_dispose    (GObject *object);
 static void gdaui_data_cell_renderer_password_finalize   (GObject *object);
 
 static void gdaui_data_cell_renderer_password_get_property  (GObject *object,
-								guint param_id,
-								GValue *value,
-								GParamSpec *pspec);
+							     guint param_id,
+							     GValue *value,
+							     GParamSpec *pspec);
 static void gdaui_data_cell_renderer_password_set_property  (GObject *object,
-								guint param_id,
-								const GValue *value,
-								GParamSpec *pspec);
+							     guint param_id,
+							     const GValue *value,
+							     GParamSpec *pspec);
 static void gdaui_data_cell_renderer_password_get_size   (GtkCellRenderer          *cell,
-							     GtkWidget                *widget,
-							     GdkRectangle             *cell_area,
-							     gint                     *x_offset,
-							     gint                     *y_offset,
-							     gint                     *width,
-							     gint                     *height);
+							  GtkWidget                *widget,
+							  GdkRectangle             *cell_area,
+							  gint                     *x_offset,
+							  gint                     *y_offset,
+							  gint                     *width,
+							  gint                     *height);
 static void gdaui_data_cell_renderer_password_render     (GtkCellRenderer          *cell,
-							     GdkWindow                *window,
-							     GtkWidget                *widget,
-							     GdkRectangle             *background_area,
-							     GdkRectangle             *cell_area,
-							     GdkRectangle             *expose_area,
-							     GtkCellRendererState      flags);
+							  GdkWindow                *window,
+							  GtkWidget                *widget,
+							  GdkRectangle             *background_area,
+							  GdkRectangle             *cell_area,
+							  GdkRectangle             *expose_area,
+							  GtkCellRendererState      flags);
 
 static GtkCellEditable *gdaui_data_cell_renderer_password_start_editing (GtkCellRenderer      *cell,
-									    GdkEvent             *event,
-									    GtkWidget            *widget,
-									    const gchar          *path,
-									    GdkRectangle         *background_area,
-									    GdkRectangle         *cell_area,
-									    GtkCellRendererState  flags);
+									 GdkEvent             *event,
+									 GtkWidget            *widget,
+									 const gchar          *path,
+									 GdkRectangle         *background_area,
+									 GdkRectangle         *cell_area,
+									 GtkCellRendererState  flags);
 
 enum {
 	CHANGED,
@@ -85,9 +86,10 @@ struct _GdauiDataCellRendererPasswordPrivate
 	GValue         *value;
 	gboolean        to_be_deleted;
 	gchar          *options;
+	gboolean        invalid;
 };
 
-typedef struct 
+typedef struct
 {
 	/* text renderer */
 	gulong focus_out_id;
@@ -118,7 +120,7 @@ gdaui_data_cell_renderer_password_get_type (void)
 			0,              /* n_preallocs */
 			(GInstanceInitFunc) gdaui_data_cell_renderer_password_init,
 		};
-		
+
 		cell_text_type =
 			g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "GdauiDataCellRendererPassword",
 						&cell_text_info, 0);
@@ -158,14 +160,14 @@ gdaui_data_cell_renderer_password_class_init (GdauiDataCellRendererPasswordClass
 	cell_class->get_size = gdaui_data_cell_renderer_password_get_size;
 	cell_class->render = gdaui_data_cell_renderer_password_render;
 	cell_class->start_editing = gdaui_data_cell_renderer_password_start_editing;
-  
+
 	g_object_class_install_property (object_class,
 					 PROP_VALUE,
 					 g_param_spec_pointer ("value",
 							       _("Value"),
 							       _("GValue to render"),
 							       G_PARAM_WRITABLE));
-  
+
 	g_object_class_install_property (object_class,
 					 PROP_VALUE_ATTRIBUTES,
 					 g_param_spec_flags ("value-attributes", NULL, NULL, GDA_TYPE_VALUE_ATTRIBUTE,
@@ -183,7 +185,7 @@ gdaui_data_cell_renderer_password_class_init (GdauiDataCellRendererPasswordClass
 					PROP_TYPE,
 					g_param_spec_gtype("type", NULL, NULL, G_TYPE_NONE,
 							   G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
-  
+
 	text_cell_renderer_password_signals [CHANGED] =
 		g_signal_new ("changed",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -229,9 +231,9 @@ gdaui_data_cell_renderer_password_finalize (GObject *object)
 
 static void
 gdaui_data_cell_renderer_password_get_property (GObject *object,
-						   guint param_id,
-						   GValue *value,
-						   GParamSpec *pspec)
+						guint param_id,
+						GValue *value,
+						GParamSpec *pspec)
 {
 	switch (param_id) {
 	case PROP_VALUE_ATTRIBUTES:
@@ -245,9 +247,9 @@ gdaui_data_cell_renderer_password_get_property (GObject *object,
 
 static void
 gdaui_data_cell_renderer_password_set_property (GObject *object,
-						   guint         param_id,
-						   const GValue *value,
-						   GParamSpec *pspec)
+						guint         param_id,
+						const GValue *value,
+						GParamSpec *pspec)
 {
 	GdauiDataCellRendererPassword *datacell = GDAUI_DATA_CELL_RENDERER_PASSWORD (object);
 
@@ -260,16 +262,17 @@ gdaui_data_cell_renderer_password_set_property (GObject *object,
 			datacell->priv->value = NULL;
 		}
 
-		if (value) {			
+		datacell->priv->invalid = FALSE;
+		if (value) {
 			GValue *gval = g_value_get_pointer (value);
 			if (gval && !gda_value_is_null (gval)) {
 				gchar *str;
-				
+
 				if (G_VALUE_TYPE (gval) != datacell->priv->type) {
 					if (!datacell->priv->type_forced) {
 						datacell->priv->type_forced = TRUE;
 						g_warning (_("Data cell renderer's specified type (%s) differs from actual "
-							     "value to display type (%s)"), 
+							     "value to display type (%s)"),
 							   g_type_name (datacell->priv->type),
 							   g_type_name (G_VALUE_TYPE (gval)));
 					}
@@ -295,12 +298,18 @@ gdaui_data_cell_renderer_password_set_property (GObject *object,
 				else
 					g_object_set (G_OBJECT (object), "text", _("<non-printable>"), NULL);
 			}
-			else
+			else if (gval)
+				g_object_set (G_OBJECT (object), "text", "", NULL);
+			else {
+				datacell->priv->invalid = TRUE;
 				g_object_set (G_OBJECT (object), "text", "", NULL);
+			}
 		}
-		else
+		else {
+			datacell->priv->invalid = TRUE;
 			g_object_set (G_OBJECT (object), "text", "", NULL);
-			      
+		}
+
 		g_object_notify (object, "value");
 		break;
 	case PROP_VALUE_ATTRIBUTES:
@@ -331,9 +340,9 @@ gdaui_data_cell_renderer_password_set_property (GObject *object,
  * gdaui_data_cell_renderer_password_new
  * @dh: a #GdaDataHandler object, or %NULL
  * @type: the #GType being edited
- * 
+ *
  * Creates a new #GdauiDataCellRendererPassword.
- * 
+ *
  * Return value: the new cell renderer
  **/
 GtkCellRenderer *
@@ -354,12 +363,12 @@ gdaui_data_cell_renderer_password_new (GdaDataHandler *dh, GType type, const gch
 
 static void
 gdaui_data_cell_renderer_password_get_size (GtkCellRenderer *cell,
-					       GtkWidget       *widget,
-					       GdkRectangle    *cell_area,
-					       gint            *x_offset,
-					       gint            *y_offset,
-					       gint            *width,
-					       gint            *height)
+					    GtkWidget       *widget,
+					    GdkRectangle    *cell_area,
+					    gint            *x_offset,
+					    gint            *y_offset,
+					    gint            *width,
+					    gint            *height)
 {
 	GtkCellRendererClass *text_class = g_type_class_peek (GTK_TYPE_CELL_RENDERER_TEXT);
 	(text_class->get_size) (cell, widget, cell_area, x_offset, y_offset, width, height);
@@ -367,18 +376,19 @@ gdaui_data_cell_renderer_password_get_size (GtkCellRenderer *cell,
 
 static void
 gdaui_data_cell_renderer_password_render (GtkCellRenderer      *cell,
-					     GdkWindow            *window,
-					     GtkWidget            *widget,
-					     GdkRectangle         *background_area,
-					     GdkRectangle         *cell_area,
-					     GdkRectangle         *expose_area,
-					     GtkCellRendererState  flags)
-	
+					  GdkWindow            *window,
+					  GtkWidget            *widget,
+					  GdkRectangle         *background_area,
+					  GdkRectangle         *cell_area,
+					  GdkRectangle         *expose_area,
+					  GtkCellRendererState  flags)
+
 {
+	GdauiDataCellRendererPassword *datacell = GDAUI_DATA_CELL_RENDERER_PASSWORD (cell);
 	GtkCellRendererClass *text_class = g_type_class_peek (GTK_TYPE_CELL_RENDERER_TEXT);
 	(text_class->render) (cell, window, widget, background_area, cell_area, expose_area, flags);
 
-	if (GDAUI_DATA_CELL_RENDERER_PASSWORD (cell)->priv->to_be_deleted) {
+	if (datacell->priv->to_be_deleted) {
 		GtkStyle *style;
 		guint xpad;
 
@@ -387,13 +397,15 @@ gdaui_data_cell_renderer_password_render (GtkCellRenderer      *cell,
 
 		gtk_paint_hline (style,
 				 window, GTK_STATE_SELECTED,
-				 cell_area, 
+				 cell_area,
 				 widget,
 				 "hline",
 				 cell_area->x + xpad, cell_area->x + cell_area->width - xpad,
 				 cell_area->y + cell_area->height / 2.);
 		g_object_unref (style);
 	}
+	if (datacell->priv->invalid)
+		gdaui_data_cell_renderer_draw_invalid_area (window, cell_area);
 }
 
 static void
@@ -421,7 +433,7 @@ gdaui_data_cell_renderer_password_editing_done (GtkCellEditable *entry,
 	}
 
 	path = g_object_get_data (G_OBJECT (entry), GDAUI_DATA_CELL_RENDERER_PASSWORD_PATH);
-	
+
 	value = gdaui_data_entry_get_value (GDAUI_DATA_ENTRY (entry));
 	g_signal_emit (data, text_cell_renderer_password_signals[CHANGED], 0, path, value);
 	gda_value_free (value);
@@ -429,8 +441,8 @@ gdaui_data_cell_renderer_password_editing_done (GtkCellEditable *entry,
 
 static gboolean
 gdaui_data_cell_renderer_password_focus_out_event (GtkWidget *entry,
-						      GdkEvent  *event,
-						      gpointer   data)
+						   GdkEvent  *event,
+						   gpointer   data)
 {
 	gdaui_data_cell_renderer_password_editing_done (GTK_CELL_EDITABLE (entry), data);
 
@@ -440,18 +452,18 @@ gdaui_data_cell_renderer_password_focus_out_event (GtkWidget *entry,
 
 static GtkCellEditable *
 gdaui_data_cell_renderer_password_start_editing (GtkCellRenderer      *cell,
-						    GdkEvent             *event,
-						    GtkWidget            *widget,
-						    const gchar          *path,
-						    GdkRectangle         *background_area,
-						    GdkRectangle         *cell_area,
-						    GtkCellRendererState  flags)
+						 GdkEvent             *event,
+						 GtkWidget            *widget,
+						 const gchar          *path,
+						 GdkRectangle         *background_area,
+						 GdkRectangle         *cell_area,
+						 GtkCellRendererState  flags)
 {
 	GdauiDataCellRendererPassword *datacell;
 	GtkWidget *entry;
 	GdauiDataCellRendererPasswordInfo *info;
 	gboolean editable;
-	
+
 	datacell = GDAUI_DATA_CELL_RENDERER_PASSWORD (cell);
 
 	/* If the cell isn't editable we return NULL. */
@@ -467,11 +479,11 @@ gdaui_data_cell_renderer_password_start_editing (GtkCellRenderer      *cell,
 	g_object_set (G_OBJECT (entry), "is-cell-renderer", TRUE, "actions", FALSE, NULL);
 
 	gdaui_data_entry_set_reference_value (GDAUI_DATA_ENTRY (entry), datacell->priv->value);
-	
+
 	info = g_new0 (GdauiDataCellRendererPasswordInfo, 1);
- 	g_object_set_data_full (G_OBJECT (entry), GDAUI_DATA_CELL_RENDERER_PASSWORD_PATH, g_strdup (path), g_free); 
+ 	g_object_set_data_full (G_OBJECT (entry), GDAUI_DATA_CELL_RENDERER_PASSWORD_PATH, g_strdup (path), g_free);
 	g_object_set_data_full (G_OBJECT (cell), GDAUI_DATA_CELL_RENDERER_PASSWORD_INFO_KEY, info, g_free);
-  
+
 	g_signal_connect (entry, "editing-done",
 			  G_CALLBACK (gdaui_data_cell_renderer_password_editing_done), datacell);
 	info->focus_out_id = g_signal_connect (entry, "focus-out-event",
diff --git a/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-pict.c b/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-pict.c
index deda2c8..eb1c5fa 100644
--- a/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-pict.c
+++ b/libgda-ui/data-entries/plugins/gdaui-data-cell-renderer-pict.c
@@ -1,6 +1,6 @@
 /* gdaui-data-cell-renderer-pict.c
  *
- * Copyright (C) 2006 - 2009 Vivien Malerba <malerba gdaui org>
+ * Copyright (C) 2006 - 2010 Vivien Malerba <malerba gdaui org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -26,41 +26,41 @@
 #include "custom-marshal.h"
 #include "common-pict.h"
 #include <libgda/gda-enum-types.h>
-
+#include "gdaui-data-cell-renderer-util.h"
 
 static void gdaui_data_cell_renderer_pict_get_property  (GObject *object,
-							    guint param_id,
-							    GValue *value,
-							    GParamSpec *pspec);
+							 guint param_id,
+							 GValue *value,
+							 GParamSpec *pspec);
 static void gdaui_data_cell_renderer_pict_set_property  (GObject *object,
-							    guint param_id,
-							    const GValue *value,
-							    GParamSpec *pspec);
+							 guint param_id,
+							 const GValue *value,
+							 GParamSpec *pspec);
 static void gdaui_data_cell_renderer_pict_dispose       (GObject *object);
 
 static void gdaui_data_cell_renderer_pict_init       (GdauiDataCellRendererPict      *celltext);
 static void gdaui_data_cell_renderer_pict_class_init (GdauiDataCellRendererPictClass *class);
 static void gdaui_data_cell_renderer_pict_render     (GtkCellRenderer            *cell,
-							 GdkWindow                  *window,
+						      GdkWindow                  *window,
+						      GtkWidget                  *widget,
+						      GdkRectangle               *background_area,
+						      GdkRectangle               *cell_area,
+						      GdkRectangle               *expose_area,
+						      GtkCellRendererState        flags);
+static void gdaui_data_cell_renderer_pict_get_size   (GtkCellRenderer            *cell,
+						      GtkWidget                  *widget,
+						      GdkRectangle               *cell_area,
+						      gint                       *x_offset,
+						      gint                       *y_offset,
+						      gint                       *width,
+						      gint                       *height);
+static gboolean gdaui_data_cell_renderer_pict_activate  (GtkCellRenderer            *cell,
+							 GdkEvent                   *event,
 							 GtkWidget                  *widget,
+							 const gchar                *path,
 							 GdkRectangle               *background_area,
 							 GdkRectangle               *cell_area,
-							 GdkRectangle               *expose_area,
 							 GtkCellRendererState        flags);
-static void gdaui_data_cell_renderer_pict_get_size   (GtkCellRenderer            *cell,
-							 GtkWidget                  *widget,
-							 GdkRectangle               *cell_area,
-							 gint                       *x_offset,
-							 gint                       *y_offset,
-							 gint                       *width,
-							 gint                       *height);
-static gboolean gdaui_data_cell_renderer_pict_activate  (GtkCellRenderer            *cell,
-							    GdkEvent                   *event,
-							    GtkWidget                  *widget,
-							    const gchar                *path,
-							    GdkRectangle               *background_area,
-							    GdkRectangle               *cell_area,
-							    GtkCellRendererState        flags);
 
 /* get a pointer to the parents to be able to call their destructor */
 static GObjectClass  *parent_class = NULL;
@@ -71,7 +71,7 @@ enum {
 };
 
 
-struct _GdauiDataCellRendererPictPrivate 
+struct _GdauiDataCellRendererPictPrivate
 {
 	GdaDataHandler       *dh;
         GType                 type;
@@ -81,6 +81,7 @@ struct _GdauiDataCellRendererPictPrivate
 	PictAllocation        size;
 	PictMenu              popup_menu;
 	gboolean              to_be_deleted;
+	gboolean              invalid;
 
 	gboolean              editable;
 	gboolean              active;
@@ -115,7 +116,7 @@ gdaui_data_cell_renderer_pict_get_type (void)
 			0,              /* n_preallocs */
 			(GInstanceInitFunc) gdaui_data_cell_renderer_pict_init,
 		};
-		
+
 		cell_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_PIXBUF, "GdauiDataCellRendererPict",
 						    &cell_info, 0);
 	}
@@ -150,7 +151,7 @@ gdaui_data_cell_renderer_pict_init (GdauiDataCellRendererPict *cell)
 	cell->priv->options.encoding = ENCODING_NONE;
 	cell->priv->options.serialize = FALSE;
 	common_pict_init_cache (&(cell->priv->options));
-	
+
 	gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &(cell->priv->size.width), &(cell->priv->size.height));
 
 	g_object_set ((GObject*) cell, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
@@ -174,19 +175,19 @@ gdaui_data_cell_renderer_pict_class_init (GdauiDataCellRendererPictClass *class)
 	cell_class->get_size = gdaui_data_cell_renderer_pict_get_size;
 	cell_class->render = gdaui_data_cell_renderer_pict_render;
 	cell_class->activate = gdaui_data_cell_renderer_pict_activate;
-  
+
 	g_object_class_install_property (object_class,
 					 PROP_VALUE,
 					 g_param_spec_boxed ("value",
-                                                               _("Value"),
-                                                               _("GValue to render"),
-                                                              G_TYPE_VALUE,
-                                                               G_PARAM_READWRITE));
-  
+							     _("Value"),
+							     _("GValue to render"),
+							     G_TYPE_VALUE,
+							     G_PARAM_READWRITE));
+
 	g_object_class_install_property (object_class,
 					 PROP_VALUE_ATTRIBUTES,
 					 g_param_spec_flags ("value-attributes", NULL, NULL, GDA_TYPE_VALUE_ATTRIBUTE,
-                                                            GDA_VALUE_ATTR_NONE, G_PARAM_READWRITE));
+							     GDA_VALUE_ATTR_NONE, G_PARAM_READWRITE));
 
 	g_object_class_install_property (object_class,
 					 PROP_EDITABLE,
@@ -236,12 +237,12 @@ gdaui_data_cell_renderer_pict_dispose (GObject *object)
 
 static void
 gdaui_data_cell_renderer_pict_get_property (GObject *object,
-					       guint param_id,
-					       GValue *value,
-					       GParamSpec *pspec)
+					    guint param_id,
+					    GValue *value,
+					    GParamSpec *pspec)
 {
 	GdauiDataCellRendererPict *cell = GDAUI_DATA_CELL_RENDERER_PICT (object);
-  
+
 	switch (param_id) {
 	case PROP_VALUE:
 		g_value_set_boxed (value, cell->priv->value);
@@ -260,29 +261,33 @@ gdaui_data_cell_renderer_pict_get_property (GObject *object,
 
 static void
 gdaui_data_cell_renderer_pict_set_property (GObject *object,
-					       guint param_id,
-					       const GValue *value,
-					       GParamSpec *pspec)
+					    guint param_id,
+					    const GValue *value,
+					    GParamSpec *pspec)
 {
 	GdauiDataCellRendererPict *cell = GDAUI_DATA_CELL_RENDERER_PICT (object);
-  
+
 	switch (param_id) {
 	case PROP_VALUE:
 		/* Because we don't have a copy of the value, we MUST NOT free it! */
                 cell->priv->value = NULL;
 		g_object_set (G_OBJECT (cell), "pixbuf", NULL, "stock-id", NULL, NULL);
+		cell->priv->invalid = FALSE;
 		if (value) {
                         GValue *gval = g_value_get_boxed (value);
 			GdkPixbuf *pixbuf = NULL;
 			const gchar *stock = NULL;
 			GError *error = NULL;
-			
+
+			if (!gval)
+				cell->priv->invalid = TRUE;
+
 			if (cell->priv->bindata.data) {
 				g_free (cell->priv->bindata.data);
 				cell->priv->bindata.data = NULL;
 				cell->priv->bindata.data_length = 0;
 			}
-			
+
 			/* fill in cell->priv->data */
 			if (common_pict_load_data (&(cell->priv->options), gval, &(cell->priv->bindata), &stock, &error)) {
 				/* try to make a pixbuf */
@@ -290,13 +295,13 @@ gdaui_data_cell_renderer_pict_set_property (GObject *object,
 				if (pixbuf)
 					g_object_ref (pixbuf);
 				else {
-					pixbuf = common_pict_make_pixbuf (&(cell->priv->options), 
+					pixbuf = common_pict_make_pixbuf (&(cell->priv->options),
 									  &(cell->priv->bindata), &(cell->priv->size),
 									  &stock, &error);
-					if (pixbuf) 
+					if (pixbuf)
 						common_pict_add_cached_pixbuf (&(cell->priv->options), gval, pixbuf);
 				}
-				
+
 				if (!pixbuf && !stock)
 					stock = GTK_STOCK_MISSING_IMAGE;
 			}
@@ -306,14 +311,16 @@ gdaui_data_cell_renderer_pict_set_property (GObject *object,
 				g_object_set (G_OBJECT (cell), "pixbuf", pixbuf, NULL);
 				g_object_unref (pixbuf);
 			}
-			
-			if (stock) 
+
+			if (stock)
 				g_object_set (G_OBJECT (cell), "stock-id", stock, NULL);
 			if (error)
 				g_error_free (error);
-			
+
                         cell->priv->value = gval;
                 }
+		else
+			cell->priv->invalid = TRUE;
 
                 g_object_notify (object, "value");
 		break;
@@ -338,7 +345,7 @@ gdaui_data_cell_renderer_pict_set_property (GObject *object,
  * @dh: a #GdaDataHandler object
  * @type:
  * @options: options string
- * 
+ *
  * Creates a new #GdauiDataCellRendererPict. Adjust rendering
  * parameters using object properties. Object properties can be set
  * globally (with g_object_set()). Also, with #GtkTreeViewColumn, you
@@ -346,7 +353,7 @@ gdaui_data_cell_renderer_pict_set_property (GObject *object,
  * can bind the "active" property on the cell renderer to a pict value
  * in the model, thus causing the check button to reflect the state of
  * the model.
- * 
+ *
  * Return value: the new cell renderer
  */
 GtkCellRenderer *
@@ -357,25 +364,25 @@ gdaui_data_cell_renderer_pict_new (GdaDataHandler *dh, GType type, const gchar *
 
         g_return_val_if_fail (dh && GDA_IS_DATA_HANDLER (dh), NULL);
         obj = g_object_new (GDAUI_TYPE_DATA_CELL_RENDERER_PICT, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
-	
+
         cell = GDAUI_DATA_CELL_RENDERER_PICT (obj);
         cell->priv->dh = dh;
         g_object_ref (G_OBJECT (dh));
         cell->priv->type = type;
 
 	common_pict_parse_options (&(cell->priv->options), options);
-	
+
         return GTK_CELL_RENDERER (obj);
 }
 
 static void
 gdaui_data_cell_renderer_pict_get_size (GtkCellRenderer *cell,
-					   GtkWidget       *widget,
-					   GdkRectangle    *cell_area,
-					   gint            *x_offset,
-					   gint            *y_offset,
-					   gint            *width,
-					   gint            *height)
+					GtkWidget       *widget,
+					GdkRectangle    *cell_area,
+					gint            *x_offset,
+					gint            *y_offset,
+					gint            *width,
+					gint            *height)
 {
 	/* FIXME */
 	/* GtkIconSize */
@@ -386,18 +393,19 @@ gdaui_data_cell_renderer_pict_get_size (GtkCellRenderer *cell,
 
 static void
 gdaui_data_cell_renderer_pict_render (GtkCellRenderer      *cell,
-					 GdkWindow            *window,
-					 GtkWidget            *widget,
-					 GdkRectangle         *background_area,
-					 GdkRectangle         *cell_area,
-					 GdkRectangle         *expose_area,
-					 GtkCellRendererState  flags)
+				      GdkWindow            *window,
+				      GtkWidget            *widget,
+				      GdkRectangle         *background_area,
+				      GdkRectangle         *cell_area,
+				      GdkRectangle         *expose_area,
+				      GtkCellRendererState  flags)
 {
+	GdauiDataCellRendererPict *datacell = GDAUI_DATA_CELL_RENDERER_PICT (cell);
 	GtkCellRendererClass *pixbuf_class = g_type_class_peek (GTK_TYPE_CELL_RENDERER_PIXBUF);
 
 	(pixbuf_class->render) (cell, window, widget, background_area, cell_area, expose_area, flags);
 
-	if (GDAUI_DATA_CELL_RENDERER_PICT (cell)->priv->to_be_deleted) {
+	if (datacell->priv->to_be_deleted) {
 		GtkStyle *style;
 		guint xpad;
 
@@ -406,13 +414,15 @@ gdaui_data_cell_renderer_pict_render (GtkCellRenderer      *cell,
 
 		gtk_paint_hline (style,
 				 window, GTK_STATE_SELECTED,
-				 cell_area, 
+				 cell_area,
 				 widget,
 				 "hline",
 				 cell_area->x + xpad, cell_area->x + cell_area->width - xpad,
 				 cell_area->y + cell_area->height / 2.);
 		g_object_unref (style);
 	}
+	if (datacell->priv->invalid)
+		gdaui_data_cell_renderer_draw_invalid_area (window, cell_area);
 }
 
 static void
@@ -420,21 +430,21 @@ pict_data_changed_cb (GdauiDataCellRendererPict *pictcell)
 {
 	GValue *value;
 
-	value = common_pict_get_value (&(pictcell->priv->bindata), &(pictcell->priv->options), 
+	value = common_pict_get_value (&(pictcell->priv->bindata), &(pictcell->priv->options),
 				       pictcell->priv->type);
-	g_signal_emit (G_OBJECT (pictcell), pixbuf_cell_signals[CHANGED], 0, 
+	g_signal_emit (G_OBJECT (pictcell), pixbuf_cell_signals[CHANGED], 0,
 		       g_object_get_data (G_OBJECT (pictcell), "last-path"), value);
 	gda_value_free (value);
 }
 
 static gboolean
 gdaui_data_cell_renderer_pict_activate  (GtkCellRenderer            *cell,
-					    GdkEvent                   *event,
-					    GtkWidget                  *widget,
-					    const gchar                *path,
-					    GdkRectangle               *background_area,
-					    GdkRectangle               *cell_area,
-					    GtkCellRendererState        flags)
+					 GdkEvent                   *event,
+					 GtkWidget                  *widget,
+					 const gchar                *path,
+					 GdkRectangle               *background_area,
+					 GdkRectangle               *cell_area,
+					 GtkCellRendererState        flags)
 {
 	GdauiDataCellRendererPict *pictcell;
 
@@ -443,15 +453,15 @@ gdaui_data_cell_renderer_pict_activate  (GtkCellRenderer            *cell,
 		int event_time;
 
 		g_object_set_data_full (G_OBJECT (pictcell), "last-path", g_strdup (path), g_free);
-		if (!pictcell->priv->popup_menu.menu) 
-			common_pict_create_menu (&(pictcell->priv->popup_menu), widget, &(pictcell->priv->bindata), 
+		if (!pictcell->priv->popup_menu.menu)
+			common_pict_create_menu (&(pictcell->priv->popup_menu), widget, &(pictcell->priv->bindata),
 						 &(pictcell->priv->options),
 						 (PictCallback) pict_data_changed_cb, pictcell);
 
-		common_pict_adjust_menu_sensitiveness (&(pictcell->priv->popup_menu), pictcell->priv->editable, 
+		common_pict_adjust_menu_sensitiveness (&(pictcell->priv->popup_menu), pictcell->priv->editable,
 						       &(pictcell->priv->bindata));
 		event_time = gtk_get_current_event_time ();
-		gtk_menu_popup (GTK_MENU (pictcell->priv->popup_menu.menu), NULL, NULL, NULL, NULL, 
+		gtk_menu_popup (GTK_MENU (pictcell->priv->popup_menu.menu), NULL, NULL, NULL, NULL,
 				0, event_time);
 	}
 



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