[goffice] Don't add an extra separator at start of data labels. [#691704]



commit c221df5526349cce9e4cc1beeb34497364d1db61
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Jan 14 20:26:43 2013 +0100

    Don't add an extra separator at start of data labels. [#691704]

 ChangeLog                         |    5 +++
 NEWS                              |    3 ++
 goffice/graph/gog-series-labels.c |   55 +++++++++++++++++++++++++------------
 3 files changed, 45 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 699efb5..59cd3e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-01-14  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/graph/gog-series-labels.c (used_selection_changed_cb): don't add
+	an extra separator at start of the format string. [#691704]
+
 2013-01-13  Morten Welinder  <terra gnome org>
 
 	* goffice/math/go-regression.c (QRH): New QR decomposition code
diff --git a/NEWS b/NEWS
index 72db612..1b8b245 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 goffice 0.10.1:
 
+Jean:
+	* Don't add an extra separator at start of data labels. [#691704]
+
 Morten:
 	* Cleanup linear algebra.  [#691630]
 
diff --git a/goffice/graph/gog-series-labels.c b/goffice/graph/gog-series-labels.c
index fdaee52..ccf9b02 100644
--- a/goffice/graph/gog-series-labels.c
+++ b/goffice/graph/gog-series-labels.c
@@ -141,7 +141,7 @@ used_selection_changed_cb (struct SeriesLabelsState *state)
 			&GOG_DATA_LABEL (state->labels)->format:
 			&GOG_SERIES_LABELS (state->labels)->format;
 	g_free (*format);
-	*format = strdup ("");;
+	*format = NULL;
 	if (gtk_tree_model_get_iter_first (model, &iter)) {
 		/* if the first row is not selected and a second row exists, set the up button sensitive */
 		first = last = iter;
@@ -157,24 +157,43 @@ used_selection_changed_cb (struct SeriesLabelsState *state)
 			if (!gtk_tree_selection_iter_is_selected (state->used_sel, &last))
 				count++;
 			gtk_tree_model_get (model, &iter, 1, &dim, -1);
-			switch (dim) {
-			case -1:
-				new_format = g_strconcat (*format, "%s%c", NULL);
-				break;
-			case -2:
-				new_format = g_strconcat (*format, "%s%l", NULL);
-				break;
-			case -3:
-				new_format = g_strconcat (*format, "%s%n", NULL);
-				break;
-			case -4:
-				new_format = g_strconcat (*format, "%s%p", NULL);
-				break;
-			default:
-				new_format = g_strdup_printf ("%s%%s%%%d", *format, dim);
+			if (*format) /* we need to add a separator */ {
+				switch (dim) {
+				case -1:
+					new_format = g_strconcat (*format, "%s%c", NULL);
+					break;
+				case -2:
+					new_format = g_strconcat (*format, "%s%l", NULL);
+					break;
+				case -3:
+					new_format = g_strconcat (*format, "%s%n", NULL);
+					break;
+				case -4:
+					new_format = g_strconcat (*format, "%s%p", NULL);
+					break;
+				default:
+					new_format = g_strdup_printf ("%s%%s%%%d", *format, dim);
+				}
+				g_free (*format);
+				*format = new_format;
+			} else {
+				switch (dim) {
+				case -1:
+					*format = g_strdup ("%c");
+					break;
+				case -2:
+					*format = g_strdup ("%l");
+					break;
+				case -3:
+					*format = g_strdup ("%n");
+					break;
+				case -4:
+					*format = g_strdup ("%p");
+					break;
+				default:
+					*format = g_strdup_printf ("%%%d", dim);
+				}
 			}
-			g_free (*format);
-			*format = new_format;
 		} while (gtk_tree_model_iter_next (model, &iter));
 		f = gtk_tree_model_get_path (model, &first);
 		l = gtk_tree_model_get_path (model, &last);



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