diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 4f1e18b4a..0769d0b2c 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -3127,9 +3127,9 @@ handle_toggle_on_all_workspaces (MetaDisplay *display, static void handle_move_to_workspace (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, + MetaScreen *screen, + MetaWindow *window, + XEvent *event, MetaKeyBinding *binding, gpointer dummy) { @@ -3314,9 +3314,9 @@ handle_workspace_switch (MetaDisplay *display, static void handle_set_spew_mark (MetaDisplay *display, - MetaScreen *screen, - MetaWindow *window, - XEvent *event, + MetaScreen *screen, + MetaWindow *window, + XEvent *event, MetaKeyBinding *binding, gpointer dummy) { @@ -3368,3 +3368,40 @@ handle_run_terminal (MetaDisplay *display, g_error_free (err); } } + +gboolean +meta_keybindings_set_custom_handler (const gchar *name, + MetaKeyHandlerFunc handler, + gpointer user_data, + MetaKeyHandlerDataFreeFunc free_data) +{ + MetaKeyHandler *key_handler = NULL; + guint i; + + /* + * FIXME -- the bindings should be in a hashtable or at least sorted somehow. + */ + for (i = 0; i < G_N_ELEMENTS (key_handlers); ++i) + { + if (!g_strcmp0 (key_handlers[i].name, name)) + { + key_handler = (MetaKeyHandler*)&key_handlers[i]; + break; + } + } + + if (!key_handler) + return FALSE; + + if (key_handler->user_data_free_func && key_handler->user_data) + { + key_handler->user_data_free_func (key_handler->user_data); + } + + key_handler->func = handler; + key_handler->user_data = user_data; + key_handler->user_data_free_func = free_data; + + return TRUE; +} + diff --git a/src/include/keybindings.h b/src/include/keybindings.h index 4009fb817..0ec87444c 100644 --- a/src/include/keybindings.h +++ b/src/include/keybindings.h @@ -52,9 +52,8 @@ struct _MetaKeyBinding }; -void -meta_keybindings_set_custom_hander (const gchar *name, - MetaKeyHandlerFunc handler, - gpointer user_data, - MetaKeyHandlerDataFreeFunc free_data); +gboolean meta_keybindings_set_custom_handler (const gchar *name, + MetaKeyHandlerFunc handler, + gpointer user_data, + MetaKeyHandlerDataFreeFunc free_data); #endif