From 667f78dbedf20c1ef55e6bca4928c4401a712869 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 7 Mar 2017 00:47:51 +0100 Subject: Sync code of "sp_dtw_zoom_input()" with code of "sp_dtw_rotation_input()" from previous commit. This allows to enter numbers with both dot (.) and comma (,) as decimal separator independently of the system locale. (bzr r15573) --- src/widgets/desktop-widget.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/widgets/desktop-widget.cpp') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 644c29b60..2317f9b7a 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1832,16 +1832,21 @@ sp_dtw_zoom_display_to_value (gdouble value) static gint sp_dtw_zoom_input (GtkSpinButton *spin, gdouble *new_val, gpointer /*data*/) { - gdouble new_scrolled = gtk_spin_button_get_value (spin); - const gchar *b = gtk_entry_get_text (GTK_ENTRY (spin)); - gdouble new_typed = atof (b); + gchar *b = g_strdup (gtk_entry_get_text (GTK_ENTRY (spin))); - if (sp_dtw_zoom_value_to_display (new_scrolled) == new_typed) { // the new value is set by scrolling - *new_val = new_scrolled; - } else { // the new value is typed in - *new_val = sp_dtw_zoom_display_to_value (new_typed); + gchar *comma = g_strstr_len (b, -1, ","); + if (comma) { + *comma = '.'; } + char *oldlocale = g_strdup (setlocale(LC_NUMERIC, NULL)); + setlocale (LC_NUMERIC, "C"); + gdouble new_typed = atof (b); + setlocale (LC_NUMERIC, oldlocale); + g_free (oldlocale); + g_free (b); + + *new_val = sp_dtw_zoom_display_to_value (new_typed); return TRUE; } -- cgit v1.2.3