diff options
author | Benjamin Otte <otte@redhat.com> | 2013-04-16 15:24:02 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2013-04-16 15:30:14 +0200 |
commit | 065a8da87a30cc5195d7907f5dbf0c0c6fa3cfde (patch) | |
tree | f3cab3f1a6607bbf7c949a2ebe71847f5d1313ea | |
parent | 441359b0a8046457c6f6207ba9f8deaec0d2a395 (diff) | |
download | gtk+-065a8da87a30cc5195d7907f5dbf0c0c6fa3cfde.tar.gz |
gdk: Refactor default key vfuncs
Instead of copying them all over the place, keep a default
implementation around.
-rw-r--r-- | gdk/broadway/gdkdisplaymanager-broadway.c | 18 | ||||
-rw-r--r-- | gdk/gdkkeys.c | 25 | ||||
-rw-r--r-- | gdk/quartz/gdkdisplaymanager-quartz.c | 18 | ||||
-rw-r--r-- | gdk/win32/gdkdisplaymanager-win32.c | 18 |
4 files changed, 19 insertions, 60 deletions
diff --git a/gdk/broadway/gdkdisplaymanager-broadway.c b/gdk/broadway/gdkdisplaymanager-broadway.c index 9fcd3a5624..2ed5b96513 100644 --- a/gdk/broadway/gdkdisplaymanager-broadway.c +++ b/gdk/broadway/gdkdisplaymanager-broadway.c @@ -88,22 +88,6 @@ gdk_broadway_display_manager_open_display (GdkDisplayManager *manager, return _gdk_broadway_display_open (name); } -#include "../gdkkeynames.c" - -static gchar * -gdk_broadway_display_manager_get_keyval_name (GdkDisplayManager *manager, - guint keyval) -{ - return _gdk_keyval_name (keyval); -} - -static guint -gdk_broadway_display_manager_lookup_keyval (GdkDisplayManager *manager, - const gchar *name) -{ - return _gdk_keyval_from_name (name); -} - static void gdk_broadway_display_manager_init (GdkBroadwayDisplayManager *manager) { @@ -126,6 +110,4 @@ gdk_broadway_display_manager_class_init (GdkBroadwayDisplayManagerClass *class) object_class->finalize = gdk_broadway_display_manager_finalize; manager_class->open_display = gdk_broadway_display_manager_open_display; - manager_class->lookup_keyval = gdk_broadway_display_manager_lookup_keyval; - manager_class->get_keyval_name = gdk_broadway_display_manager_get_keyval_name; } diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c index 60277b6c29..3026cfc7ad 100644 --- a/gdk/gdkkeys.c +++ b/gdk/gdkkeys.c @@ -674,6 +674,7 @@ gdk_keymap_get_modifier_mask (GdkKeymap *keymap, return GDK_KEYMAP_GET_CLASS (keymap)->get_modifier_mask (keymap, intent); } +#include "gdkkeynames.c" /** * gdk_keyval_name: @@ -692,10 +693,16 @@ gdk_keymap_get_modifier_mask (GdkKeymap *keymap, gchar * gdk_keyval_name (guint keyval) { - GdkDisplayManager *manager = gdk_display_manager_get (); + GdkDisplayManagerClass *manager_class; + GdkDisplayManager *manager; + + manager = gdk_display_manager_get (); + manager_class = GDK_DISPLAY_MANAGER_GET_CLASS (manager); - return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->get_keyval_name (manager, - keyval); + if (manager_class->get_keyval_name) + return manager_class->get_keyval_name (manager, keyval); + else + return _gdk_keyval_name (keyval); } /** @@ -714,10 +721,16 @@ gdk_keyval_name (guint keyval) guint gdk_keyval_from_name (const gchar *keyval_name) { - GdkDisplayManager *manager = gdk_display_manager_get (); + GdkDisplayManagerClass *manager_class; + GdkDisplayManager *manager; + + manager = gdk_display_manager_get (); + manager_class = GDK_DISPLAY_MANAGER_GET_CLASS (manager); - return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->lookup_keyval (manager, - keyval_name); + if (manager_class->lookup_keyval) + return manager_class->lookup_keyval (manager, keyval_name); + else + return _gdk_keyval_from_name (keyval_name); } /** diff --git a/gdk/quartz/gdkdisplaymanager-quartz.c b/gdk/quartz/gdkdisplaymanager-quartz.c index bccaf247f6..4756cd0428 100644 --- a/gdk/quartz/gdkdisplaymanager-quartz.c +++ b/gdk/quartz/gdkdisplaymanager-quartz.c @@ -47,22 +47,6 @@ gdk_quartz_display_manager_open_display (GdkDisplayManager *manager, return _gdk_quartz_display_open (name); } -#include "../gdkkeynames.c" - -static gchar * -gdk_quartz_display_manager_get_keyval_name (GdkDisplayManager *manager, - guint keyval) -{ - return _gdk_keyval_name (keyval); -} - -static guint -gdk_quartz_display_manager_lookup_keyval (GdkDisplayManager *manager, - const gchar *name) -{ - return _gdk_keyval_from_name (name); -} - static void gdk_quartz_display_manager_init (GdkQuartzDisplayManager *manager) { @@ -98,6 +82,4 @@ gdk_quartz_display_manager_class_init (GdkQuartzDisplayManagerClass *class) manager_class->open_display = gdk_quartz_display_manager_open_display; manager_class->atom_intern = _gdk_quartz_display_manager_atom_intern; manager_class->get_atom_name = _gdk_quartz_display_manager_get_atom_name; - manager_class->lookup_keyval = gdk_quartz_display_manager_lookup_keyval; - manager_class->get_keyval_name = gdk_quartz_display_manager_get_keyval_name; } diff --git a/gdk/win32/gdkdisplaymanager-win32.c b/gdk/win32/gdkdisplaymanager-win32.c index 127386bba3..8907dec164 100644 --- a/gdk/win32/gdkdisplaymanager-win32.c +++ b/gdk/win32/gdkdisplaymanager-win32.c @@ -45,22 +45,6 @@ gdk_win32_display_manager_open_display (GdkDisplayManager *manager, return _gdk_win32_display_open (name); } -#include "../gdkkeynames.c" - -static gchar * -gdk_win32_display_manager_get_keyval_name (GdkDisplayManager *manager, - guint keyval) -{ - return _gdk_keyval_name (keyval); -} - -static guint -gdk_win32_display_manager_lookup_keyval (GdkDisplayManager *manager, - const gchar *name) -{ - return _gdk_keyval_from_name (name); -} - static void gdk_win32_display_manager_init (GdkWin32DisplayManager *manager) { @@ -94,6 +78,4 @@ gdk_win32_display_manager_class_init (GdkWin32DisplayManagerClass *class) manager_class->atom_intern = _gdk_win32_display_manager_atom_intern; manager_class->get_atom_name = _gdk_win32_display_manager_get_atom_name; #endif - manager_class->lookup_keyval = gdk_win32_display_manager_lookup_keyval; - manager_class->get_keyval_name = gdk_win32_display_manager_get_keyval_name; } |