summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-10-20 11:06:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-10-25 13:59:48 -0400
commit7c7fde136e1fd1197df1881a3bbd975c4cb1c01a (patch)
treec77ef6815f4018ca52cf88e97be443ebb7d6361f
parent64c5b97be84dd05fb200201274ac9fd8ba2f424c (diff)
downloadgtk+-7c7fde136e1fd1197df1881a3bbd975c4cb1c01a.tar.gz
Translate GDK_KEY_KP_Decimal according to locale
It makes sense that you should be able to type numbers that are correctly formatted and parsable according to the current locale, using just the keypad. This patch makes it so by translating GDK_KEY_KP_Decimal to the decimal separator for the current locale, instead of hardcoding a '.'. https://bugzilla.gnome.org/show_bug.cgi?id=756751
-rw-r--r--gdk/gdkkeyuni.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdk/gdkkeyuni.c b/gdk/gdkkeyuni.c
index d770737ccc..ea28010f87 100644
--- a/gdk/gdkkeyuni.c
+++ b/gdk/gdkkeyuni.c
@@ -27,6 +27,7 @@
#include "gdkkeys.h"
#include "gdktypes.h"
+#include <locale.h>
/* Thanks to Markus G. Kuhn <mkuhn@acm.org> for the ksysym<->Unicode
* mapping functions, from the xterm sources.
@@ -872,6 +873,23 @@ static const struct {
#endif
};
+static gunichar
+get_decimal_point (void)
+{
+ struct lconv *locale_data;
+ const gchar *decimal_point;
+ gunichar ret;
+
+ locale_data = localeconv ();
+ decimal_point = locale_data->decimal_point;
+
+ ret = g_utf8_get_char_validated (decimal_point, -1);
+ if (ret != (gunichar)-2 && ret != (gunichar)-1)
+ return ret;
+
+ return (gunichar) '.';
+}
+
/**
* gdk_keyval_to_unicode:
* @keyval: a GDK key symbol
@@ -899,6 +917,9 @@ gdk_keyval_to_unicode (guint keyval)
if ((keyval & 0xff000000) == 0x01000000)
return keyval & 0x00ffffff;
+ if (keyval == 0xffae)
+ return (guint32) get_decimal_point ();
+
/* binary search in table */
while (max >= min) {
mid = (min + max) / 2;