[goffice] Fix scientific format with SI prefix selection. [#665301]



commit 3ac6740423df484948d0afd6c95d0d9e16d53222
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Thu Dec 1 10:02:01 2011 -0700

    Fix scientific format with SI prefix selection. [#665301]
    
    2011-12-01  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* goffice/gtk/go-format-sel.c (cb_si_unit_toggle): set the scale
    	correctly

 ChangeLog                   |    5 +++++
 NEWS                        |    3 +++
 goffice/gtk/go-format-sel.c |   13 +++++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 035a621..0ab8780 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-12-01  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* goffice/gtk/go-format-sel.c (cb_si_unit_toggle): set the scale 
+	correctly
+
 2011-11-30  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* goffice/gtk/go-format-sel.c (fmt_dialog_enable_widgets): set
diff --git a/NEWS b/NEWS
index ed17486..1502a7f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 goffice 0.9.2:
 
+Andreas:
+	* Fix scientific format with SI prefix selection. [#665301]
+
 --------------------------------------------------------------------------
 goffice 0.9.1:
 
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index ebfe7a9..e359e70 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -301,7 +301,7 @@ fillin_negative_samples (GOFormatSel *gfs)
 
 static struct {
 	char const *name;
-	char const * unit;
+	char const *unit;
 	int scale;
 } si_units[] = {
 	{N_("A (ampere)"), "A", 0},
@@ -484,8 +484,17 @@ cb_si_unit_toggle (GtkWidget *w, GOFormatSel *gfs)
 			}
 		} else
 			gfs->format.details.appended_SI_unit = NULL;
-	} else
+	} else {
+		guint i;
 		gfs->format.details.appended_SI_unit = g_strdup (gfs->format.default_si_unit);
+		gfs->format.details.scale = 1;
+		if (gfs->format.details.appended_SI_unit != NULL)
+			for (i=0; i < G_N_ELEMENTS (si_units); i++)
+				if (0 == strcmp (si_units[i].unit, gfs->format.details.appended_SI_unit)) {
+					gfs->format.details.scale = si_units[i].scale;
+					break;
+				}
+	}
 
 	draw_format_preview (gfs, TRUE);
 }



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