diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-03-06 23:47:51 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-03-06 23:47:51 +0000 |
| commit | 667f78dbedf20c1ef55e6bca4928c4401a712869 (patch) | |
| tree | ef0b80a43ce81e12c4b15d9c41a08d7fce571479 /src/widgets/desktop-widget.cpp | |
| parent | Fix Inkscape crashing on Windows (and possibly other OSs) if $LANG is set to ... (diff) | |
| download | inkscape-667f78dbedf20c1ef55e6bca4928c4401a712869.tar.gz inkscape-667f78dbedf20c1ef55e6bca4928c4401a712869.zip | |
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)
Diffstat (limited to 'src/widgets/desktop-widget.cpp')
| -rw-r--r-- | src/widgets/desktop-widget.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
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; } |
