keyboard: Use GTK+ to parse keys

Instead of some custom code

https://bugzilla.gnome.org/show_bug.cgi?id=663341
This commit is contained in:
Bastien Nocera 2011-11-03 17:25:29 +00:00
parent a795220be7
commit df493ef93c
5 changed files with 10 additions and 7 deletions

View file

@ -60,7 +60,7 @@ dnl Check that we meet the dependencies
dnl ==============================================
GLIB_REQUIRED_VERSION=2.29.14
GTK_REQUIRED_VERSION=3.1.19
GTK_REQUIRED_VERSION=3.3.3
DESKTOP_SCHEMAS_REQUIRED_VERSION=3.0.2
PA_REQUIRED_VERSION=0.9.16
CANBERRA_REQUIRED_VERSION=0.13

View file

@ -18,7 +18,7 @@ libkeyboard_la_SOURCES = \
keyboard-shortcuts.h
libkeyboard_la_CFLAGS = $(PANEL_CFLAGS) $(KEYBOARD_PANEL_CFLAGS) -I$(top_srcdir)/panels/common/
libkeyboard_la_LIBADD = $(PANEL_LIBS) $(KEYBOARD_PANEL_LIBS) $(top_builddir)/panels/common/libshortcuts.la
libkeyboard_la_LIBADD = $(PANEL_LIBS) $(KEYBOARD_PANEL_LIBS)
libkeyboard_la_LDFLAGS = $(PANEL_LDFLAGS)
@INTLTOOL_DESKTOP_RULE@

View file

@ -30,7 +30,6 @@
#include <gconf/gconf-client.h>
#include "cc-keyboard-item.h"
#include "eggaccelerators.h"
#define CC_KEYBOARD_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_ITEM, CcKeyboardItemPrivate))
@ -64,6 +63,7 @@ binding_from_string (const char *str,
GdkModifierType *accelerator_mods)
{
g_return_val_if_fail (accelerator_key != NULL, FALSE);
guint *keycodes;
if (str == NULL || strcmp (str, "disabled") == 0)
{
@ -73,7 +73,11 @@ binding_from_string (const char *str,
return TRUE;
}
egg_accelerator_parse_virtual (str, accelerator_key, keycode, (EggVirtualModifierType *) accelerator_mods);
gtk_accelerator_parse_with_keycode (str, accelerator_key, &keycodes, accelerator_mods);
if (keycode != NULL)
*keycode = (keycodes ? keycodes[0] : 0);
g_free (keycodes);
if (*accelerator_key == 0)
return FALSE;

View file

@ -22,7 +22,6 @@
#define __CC_KEYBOARD_ITEM_H
#include <glib-object.h>
#include "eggaccelerators.h"
G_BEGIN_DECLS

View file

@ -1184,8 +1184,8 @@ binding_name (guint keyval,
{
if (keyval != 0 || keycode != 0)
return translate ?
egg_virtual_accelerator_label (keyval, keycode, mask) :
egg_virtual_accelerator_name (keyval, keycode, mask);
gtk_accelerator_get_label_with_keycode (NULL, keyval, keycode, mask) :
gtk_accelerator_name_with_keycode (NULL, keyval, keycode, mask);
else
return g_strdup (translate ? _("Disabled") : "");
}