diff --git a/data/snippets/js.snippets b/data/snippets/js.snippets index ffe9ac2ef89042cb9111c280e2ca07f2c8456a8f..f9a0885fed273e7157783eb865aa1ed5dc056770 100644 --- a/data/snippets/js.snippets +++ b/data/snippets/js.snippets @@ -2,19 +2,22 @@ snippet import import "${1:./module.js}"; $0 snippet from - import ${1:Module} from "${2:./}${3:$1|lower}"; +- desc import … from + import ${1:{ Module }} from "${2:./module.js}"; $0 -snippet require - const ${1:Module} = require("${2:./}${3:$1|lower}"); +snippet imports + const ${1:Module} = imports.${2:path}.${$1|decapitalize}; $0 snippet gi - const ${1:Gtk} = imports.gi.$1; +- desc imports.gi + const ${1:{ GObject, Gtk }} = imports.gi; $0 snippet lang +- desc imports.lang const ${1:Lang} = imports.${$1|decapitalize}; $0 -snippet imports - const ${1:Module} = imports.${2:path}.${$1|decapitalize}; +snippet require + const ${1:Module} = require("${2:./}${3:$1|lower}"); $0 snippet class class ${1:ClassName} { diff --git a/src/gstyle/gstyle-color.c b/src/gstyle/gstyle-color.c index 41710dfdc1beb34e0359329fd3cdcd2493839a8d..ffc63b565aa187b7ec47b2483603f4c0b1fc29ff 100644 --- a/src/gstyle/gstyle-color.c +++ b/src/gstyle/gstyle-color.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "gstyle-private.h" #include "gstyle-colorlexer.h" @@ -116,10 +117,27 @@ gstyle_color_to_hsla (GstyleColor *self, static gchar * truncate_trailing_zeros (gdouble number) { - gint c = g_snprintf(TRUNCATE_BUF, 6, "%.2f", number); + /* Switch to "C" locale to avoid problems with decimal separators */ + locale_t bk_locale = uselocale (NULL); + locale_t base_locale = duplocale (bk_locale); + locale_t new_locale = newlocale (LC_ALL, "C", base_locale); /* Just LC_NUMERIC doesn't work */ + if (new_locale != NULL) + uselocale (new_locale); + + gint c = g_snprintf (TRUNCATE_BUF, 6, "%.2f", number); + + /* Restore locale */ + uselocale (bk_locale); + + if (new_locale != NULL) + freelocale (new_locale); + else + freelocale (base_locale); + + /* Format the number string, e.g. "0.50" => "0.5"; "1.0" => "1" */ --c; - while(TRUNCATE_BUF[c] == '0') + while (TRUNCATE_BUF[c] == '0') c--; if (TRUNCATE_BUF[c] == '.')