summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-11-13 18:05:09 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-11-13 18:05:09 +0000
commit0c0b04ab5c847069ada54e1a1aa32880efc73125 (patch)
tree2c15f84814c37ec2697ee4a536777f3d015c2449 /gtk2_ardour
parentc0bb288ff148274bd258562b0c718aa5e009cca0 (diff)
determine whether or not to accept comma or period as a numeric character based on locale settings (once per instance of ardour), related to #5027
git-svn-id: svn://localhost/ardour2/branches/3.0@13481 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/utils.cc41
1 files changed, 38 insertions, 3 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 7771aea650..952a393f27 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -25,6 +25,8 @@
#include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
#include <cstdlib>
+#include <clocale>
+#include <cstring>
#include <cctype>
#include <fstream>
#include <list>
@@ -226,7 +228,7 @@ get_font_for_style (string widgetname)
Glib::RefPtr<const Pango::Layout> layout = foobar.get_layout();
- PangoFontDescription *pfd = (PangoFontDescription *)pango_layout_get_font_description(const_cast<PangoLayout *>(layout->gobj()));
+ PangoFontDescription *pfd = const_cast<PangoFontDescription *> (pango_layout_get_font_description(const_cast<PangoLayout *>(layout->gobj())));
if (!pfd) {
@@ -586,11 +588,44 @@ longest (vector<string>& strings)
bool
key_is_legal_for_numeric_entry (guint keyval)
{
+ /* we assume that this does not change over the life of the process
+ */
+
+ static int comma_decimal = -1;
+
switch (keyval) {
- case GDK_minus:
- case GDK_plus:
case GDK_period:
case GDK_comma:
+ if (comma_decimal < 0) {
+ std::lconv* lc = std::localeconv();
+ if (strchr (lc->decimal_point, ',') != 0) {
+ comma_decimal = 1;
+ } else {
+ comma_decimal = 0;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ switch (keyval) {
+ case GDK_period:
+ if (comma_decimal) {
+ return false;
+ } else {
+ return true;
+ }
+ break;
+ case GDK_comma:
+ if (comma_decimal) {
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case GDK_minus:
+ case GDK_plus:
case GDK_0:
case GDK_1:
case GDK_2: