summaryrefslogtreecommitdiff
path: root/gdk/gdkkeys.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-12-16 19:00:01 -0500
committerMatthias Clasen <mclasen@redhat.com>2010-12-21 12:07:03 -0500
commit519f09f7f4b60305df1308d9cda2736c166ff5e9 (patch)
tree514abf64cc43ebead9bc5bc0314fbe2ee4d5ebe2 /gdk/gdkkeys.c
parentfdabc9585d4d8616926c4acf09f114f8e00c383b (diff)
downloadgtk+-519f09f7f4b60305df1308d9cda2736c166ff5e9.tar.gz
Add vfuncs for keyval and window property functions
The keyval functions should really be generic, and the window property api should be completely revisited, but for now this will allow us to proceed.
Diffstat (limited to 'gdk/gdkkeys.c')
-rw-r--r--gdk/gdkkeys.c163
1 files changed, 35 insertions, 128 deletions
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c
index 75ef078ced..5b7ea78e5f 100644
--- a/gdk/gdkkeys.c
+++ b/gdk/gdkkeys.c
@@ -28,6 +28,7 @@
#include "gdkkeysprivate.h"
#include "gdkdisplay.h"
+#include "gdkdisplaymanagerprivate.h"
/**
@@ -182,12 +183,6 @@ gdk_keymap_init (GdkKeymap *keymap)
/* Other key-handling stuff
*/
-#ifndef HAVE_XCONVERTCASE
-#include "gdkkeysyms.h"
-
-/* compatibility function from X11R6.3, since XConvertCase is not
- * supplied by X11R5.
- */
/**
* gdk_keyval_convert_case:
* @symbol: a keyval
@@ -196,133 +191,16 @@ gdk_keymap_init (GdkKeymap *keymap)
*
* Obtains the upper- and lower-case versions of the keyval @symbol.
* Examples of keyvals are #GDK_KEY_a, #GDK_KEY_Enter, #GDK_KEY_F1, etc.
- *
- **/
+ */
void
gdk_keyval_convert_case (guint symbol,
- guint *lower,
- guint *upper)
+ guint *lower,
+ guint *upper)
{
- guint xlower = symbol;
- guint xupper = symbol;
-
- /* Check for directly encoded 24-bit UCS characters: */
- if ((symbol & 0xff000000) == 0x01000000)
- {
- if (lower)
- *lower = gdk_unicode_to_keyval (g_unichar_tolower (symbol & 0x00ffffff));
- if (upper)
- *upper = gdk_unicode_to_keyval (g_unichar_toupper (symbol & 0x00ffffff));
- return;
- }
-
- switch (symbol >> 8)
- {
- case 0: /* Latin 1 */
- if ((symbol >= GDK_KEY_A) && (symbol <= GDK_KEY_Z))
- xlower += (GDK_KEY_a - GDK_KEY_A);
- else if ((symbol >= GDK_KEY_a) && (symbol <= GDK_KEY_z))
- xupper -= (GDK_KEY_a - GDK_KEY_A);
- else if ((symbol >= GDK_KEY_Agrave) && (symbol <= GDK_KEY_Odiaeresis))
- xlower += (GDK_KEY_agrave - GDK_KEY_Agrave);
- else if ((symbol >= GDK_KEY_agrave) && (symbol <= GDK_KEY_odiaeresis))
- xupper -= (GDK_KEY_agrave - GDK_KEY_Agrave);
- else if ((symbol >= GDK_KEY_Ooblique) && (symbol <= GDK_KEY_Thorn))
- xlower += (GDK_KEY_oslash - GDK_KEY_Ooblique);
- else if ((symbol >= GDK_KEY_oslash) && (symbol <= GDK_KEY_thorn))
- xupper -= (GDK_KEY_oslash - GDK_KEY_Ooblique);
- break;
-
- case 1: /* Latin 2 */
- /* Assume the KeySym is a legal value (ignore discontinuities) */
- if (symbol == GDK_KEY_Aogonek)
- xlower = GDK_KEY_aogonek;
- else if (symbol >= GDK_KEY_Lstroke && symbol <= GDK_KEY_Sacute)
- xlower += (GDK_KEY_lstroke - GDK_KEY_Lstroke);
- else if (symbol >= GDK_KEY_Scaron && symbol <= GDK_KEY_Zacute)
- xlower += (GDK_KEY_scaron - GDK_KEY_Scaron);
- else if (symbol >= GDK_KEY_Zcaron && symbol <= GDK_KEY_Zabovedot)
- xlower += (GDK_KEY_zcaron - GDK_KEY_Zcaron);
- else if (symbol == GDK_KEY_aogonek)
- xupper = GDK_KEY_Aogonek;
- else if (symbol >= GDK_KEY_lstroke && symbol <= GDK_KEY_sacute)
- xupper -= (GDK_KEY_lstroke - GDK_KEY_Lstroke);
- else if (symbol >= GDK_KEY_scaron && symbol <= GDK_KEY_zacute)
- xupper -= (GDK_KEY_scaron - GDK_KEY_Scaron);
- else if (symbol >= GDK_KEY_zcaron && symbol <= GDK_KEY_zabovedot)
- xupper -= (GDK_KEY_zcaron - GDK_KEY_Zcaron);
- else if (symbol >= GDK_KEY_Racute && symbol <= GDK_KEY_Tcedilla)
- xlower += (GDK_KEY_racute - GDK_KEY_Racute);
- else if (symbol >= GDK_KEY_racute && symbol <= GDK_KEY_tcedilla)
- xupper -= (GDK_KEY_racute - GDK_KEY_Racute);
- break;
-
- case 2: /* Latin 3 */
- /* Assume the KeySym is a legal value (ignore discontinuities) */
- if (symbol >= GDK_KEY_Hstroke && symbol <= GDK_KEY_Hcircumflex)
- xlower += (GDK_KEY_hstroke - GDK_KEY_Hstroke);
- else if (symbol >= GDK_KEY_Gbreve && symbol <= GDK_KEY_Jcircumflex)
- xlower += (GDK_KEY_gbreve - GDK_KEY_Gbreve);
- else if (symbol >= GDK_KEY_hstroke && symbol <= GDK_KEY_hcircumflex)
- xupper -= (GDK_KEY_hstroke - GDK_KEY_Hstroke);
- else if (symbol >= GDK_KEY_gbreve && symbol <= GDK_KEY_jcircumflex)
- xupper -= (GDK_KEY_gbreve - GDK_KEY_Gbreve);
- else if (symbol >= GDK_KEY_Cabovedot && symbol <= GDK_KEY_Scircumflex)
- xlower += (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
- else if (symbol >= GDK_KEY_cabovedot && symbol <= GDK_KEY_scircumflex)
- xupper -= (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
- break;
-
- case 3: /* Latin 4 */
- /* Assume the KeySym is a legal value (ignore discontinuities) */
- if (symbol >= GDK_KEY_Rcedilla && symbol <= GDK_KEY_Tslash)
- xlower += (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
- else if (symbol >= GDK_KEY_rcedilla && symbol <= GDK_KEY_tslash)
- xupper -= (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
- else if (symbol == GDK_KEY_ENG)
- xlower = GDK_KEY_eng;
- else if (symbol == GDK_KEY_eng)
- xupper = GDK_KEY_ENG;
- else if (symbol >= GDK_KEY_Amacron && symbol <= GDK_KEY_Umacron)
- xlower += (GDK_KEY_amacron - GDK_KEY_Amacron);
- else if (symbol >= GDK_KEY_amacron && symbol <= GDK_KEY_umacron)
- xupper -= (GDK_KEY_amacron - GDK_KEY_Amacron);
- break;
-
- case 6: /* Cyrillic */
- /* Assume the KeySym is a legal value (ignore discontinuities) */
- if (symbol >= GDK_KEY_Serbian_DJE && symbol <= GDK_KEY_Serbian_DZE)
- xlower -= (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
- else if (symbol >= GDK_KEY_Serbian_dje && symbol <= GDK_KEY_Serbian_dze)
- xupper += (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
- else if (symbol >= GDK_KEY_Cyrillic_YU && symbol <= GDK_KEY_Cyrillic_HARDSIGN)
- xlower -= (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
- else if (symbol >= GDK_KEY_Cyrillic_yu && symbol <= GDK_KEY_Cyrillic_hardsign)
- xupper += (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
- break;
-
- case 7: /* Greek */
- /* Assume the KeySym is a legal value (ignore discontinuities) */
- if (symbol >= GDK_KEY_Greek_ALPHAaccent && symbol <= GDK_KEY_Greek_OMEGAaccent)
- xlower += (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
- else if (symbol >= GDK_KEY_Greek_alphaaccent && symbol <= GDK_KEY_Greek_omegaaccent &&
- symbol != GDK_KEY_Greek_iotaaccentdieresis &&
- symbol != GDK_KEY_Greek_upsilonaccentdieresis)
- xupper -= (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
- else if (symbol >= GDK_KEY_Greek_ALPHA && symbol <= GDK_KEY_Greek_OMEGA)
- xlower += (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
- else if (symbol >= GDK_KEY_Greek_alpha && symbol <= GDK_KEY_Greek_omega &&
- symbol != GDK_KEY_Greek_finalsmallsigma)
- xupper -= (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
- break;
- }
+ GdkDisplayManager *manager = gdk_display_manager_get ();
- if (lower)
- *lower = xlower;
- if (upper)
- *upper = xupper;
+ GDK_DISPLAY_MANAGER_GET_CLASS (manager)->keyval_convert_case (manager, symbol, lower, upper);
}
-#endif
/**
* gdk_keyval_to_upper:
@@ -699,3 +577,32 @@ gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
{
return GDK_KEYMAP_GET_CLASS(keymap)->map_virtual_modifiers (keymap, state);
}
+
+/**
+ * gdk_keyval_name:
+ * @keyval: a key value.
+ *
+ * Converts a key value into a symbolic name.
+ * The names are the same as those in the
+ * <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> header file
+ * but without the leading "GDK_KEY_".
+ *
+ * Return value: (transfer none): a string containing the name of the key,
+ * or %NULL if @keyval is not a valid key. The string should not be
+ * modified.
+ */
+gchar*
+gdk_keyval_name (guint keyval)
+{
+ GdkDisplayManager *manager = gdk_display_manager_get ();
+
+ return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->get_keyval_name (manager, keyval);
+}
+
+guint
+gdk_keyval_from_name (const gchar *keyval_name)
+{
+ GdkDisplayManager *manager = gdk_display_manager_get ();
+
+ return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->lookup_keyval (manager, keyval_name);
+}