[gnumeric] fix #641198



commit d3b3fe743560c295e33c9e430b060566267622fb
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Nov 30 11:38:55 2011 -0700

    fix #641198
    
    2011-11-30  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/wbc-gtk.c (wbc_gtk_create_status_area): allocate space for spaces
    	surrounding "="
    	* src/workbook-view.c (wb_view_darken_foreground_attributes_cb): new
    	(wb_view_darken_foreground_attributes): new
    	(wb_view_auto_expr_recalc): call wb_view_darken_foreground_attributes
    	and add spaces around "="

 ChangeLog           |    9 +++++++++
 src/wbc-gtk.c       |    2 +-
 src/workbook-view.c |   38 ++++++++++++++++++++++++++++++++++----
 3 files changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8964fc5..1e2df5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-11-30  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/wbc-gtk.c (wbc_gtk_create_status_area): allocate space for spaces
+	surrounding "="
+	* src/workbook-view.c (wb_view_darken_foreground_attributes_cb): new
+	(wb_view_darken_foreground_attributes): new
+	(wb_view_auto_expr_recalc): call wb_view_darken_foreground_attributes
+	and add spaces around "="
+
+2011-11-30  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/cmd-edit.c: adjust calls to sv_selection_add_full and
 	sv_selection_add_pos throughout
 	(sv_select_cur_inputs): fix leak
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index f3734f9..a6571cc 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -4804,7 +4804,7 @@ wbc_gtk_create_status_area (WBCGtk *wbcg)
 	gtk_widget_set_size_request (tmp, go_pango_measure_string (
 		gtk_widget_get_pango_context (GTK_WIDGET (wbcg->toplevel)),
 		gtk_style_context_get_font (gtk_widget_get_style_context (tmp), GTK_STATE_NORMAL),
-		"Sumerage=-012345678901234"), -1);
+		"Sumerage = -012345678901234"), -1);
 	tmp = gtk_event_box_new ();
 	gtk_container_add (GTK_CONTAINER (tmp), wbcg->auto_expr_label);
 	g_signal_connect (G_OBJECT (tmp),
diff --git a/src/workbook-view.c b/src/workbook-view.c
index 984adb9..ab13da9 100644
--- a/src/workbook-view.c
+++ b/src/workbook-view.c
@@ -495,6 +495,33 @@ accumulate_regions (SheetView *sv,  GnmRange const *r, gpointer closure)
 		gnm_expr_new_constant (value_new_cellrange_unsafe (&a, &b)));
 }
 
+static gboolean
+wb_view_darken_foreground_attributes_cb (PangoAttribute *attribute,
+					 G_GNUC_UNUSED gpointer data)
+{
+	if (attribute->klass->type == PANGO_ATTR_FOREGROUND) {
+		PangoAttrColor *cat = (PangoAttrColor *) attribute;
+		guint total = (guint)cat->color.red + (guint)cat->color.green + (guint)cat->color.blue;
+		if (total > 98302) {
+			float adj = 98302.5/total;
+			cat->color.red = cat->color.red * adj;
+			cat->color.green = cat->color.green * adj;
+			cat->color.blue = cat->color.blue * adj;
+		}
+	}
+	return FALSE;
+}
+
+static void
+wb_view_darken_foreground_attributes (PangoAttrList *attrs)
+{
+	pango_attr_list_unref 
+		(pango_attr_list_filter 
+		 (attrs,
+		  wb_view_darken_foreground_attributes_cb,
+		  NULL));
+}
+
 void
 wb_view_auto_expr_recalc (WorkbookView *wbv)
 {
@@ -551,7 +578,7 @@ wb_view_auto_expr_recalc (WorkbookView *wbv)
 		GOFormat const *tmp_format = NULL;
 		PangoAttrList *attrs = NULL;
 
-		g_string_append_c (str, '=');
+		g_string_append (str, " = ");
 		if (!wbv->auto_expr_use_max_precision) {
 			format = VALUE_FMT (v);
 			if (!format)
@@ -566,8 +593,8 @@ wb_view_auto_expr_recalc (WorkbookView *wbv)
 			GOFormatNumberError err =
 				format_value_layout (layout, format, v,
 						     /* Note that we created a label large enough for */
-						     /* "Sumerage=-012345678901234" */
-						     25 - g_utf8_strlen (str->str, -1),
+						     /* "Sumerage = -012345678901234" */
+						     27 - g_utf8_strlen (str->str, -1),
 						     workbook_date_conv (wb_view_get_workbook (wbv)));
 			go_format_unref (tmp_format);
 			switch (err) {
@@ -585,6 +612,9 @@ wb_view_auto_expr_recalc (WorkbookView *wbv)
 						(attrs, atl, old_len,
 						 str->len - old_len);
 					pango_attr_list_unref (atl);
+					/* The field background is white so we need to ensure that no */
+					/* foreground colour is set to white (or close to white)      */
+					wb_view_darken_foreground_attributes (attrs);
 				}
 				break;
 			}
@@ -617,7 +647,7 @@ wb_view_auto_expr_recalc (WorkbookView *wbv)
 /* perform whatever initialization of a control that is necessary when it
  * finally gets assigned to a view with a workbook */
 static void
-wb_view_init_control (WorkbookControl *wbc)
+wb_view_init_control (G_GNUC_UNUSED WorkbookControl *wbc)
 {
 }
 



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