[libgepub/wip/hadess-bug-fixes: 3/3] widget: Don't change LC_NUMERIC at runtime



commit 6afa69625742e9549cfe5a8379339aff09da9491
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jan 15 17:21:48 2018 +0100

    widget: Don't change LC_NUMERIC at runtime
    
    Don't change LC_NUMERIC to get a "." as the decimal point, as this could
    have an effect on the rest of the UI. Use g_ascii_formatd() to "print"
    the number with "." as the decimal point instead.

 libgepub/gepub-widget.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/libgepub/gepub-widget.c b/libgepub/gepub-widget.c
index 2a41ef8..733d4f0 100644
--- a/libgepub/gepub-widget.c
+++ b/libgepub/gepub-widget.c
@@ -194,9 +194,15 @@ reload_length_cb (GtkWidget *widget,
     }
 
     if (l) {
+        char line_height[G_ASCII_DTOSTR_BUF_SIZE];
+
+        g_ascii_formatd (line_height,
+                         G_ASCII_DTOSTR_BUF_SIZE,
+                         "%f",
+                         l);
         script = g_strdup_printf (
-            "document.querySelector('#gepubwrap').style.lineHeight = %f;"
-            , l);
+            "document.querySelector('#gepubwrap').style.lineHeight = %s;"
+            , line_height);
         webkit_web_view_run_javascript (web_view, script, NULL, NULL, NULL);
         g_free (script);
     }
@@ -337,9 +343,6 @@ gepub_widget_init (GepubWidget *widget)
     widget->margin = 20;
     widget->font_size = 0;
     widget->line_height = 0;
-
-    // locale to avoid '1,2' in line_height string composition
-    setlocale(LC_NUMERIC, "C");
 }
 
 static void


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