Implemented meta_keybindings_set_custom_handler().

This commit is contained in:
Tomas Frydrych 2009-01-29 15:07:57 +00:00
parent e25282088b
commit 096e3dee8f
2 changed files with 47 additions and 11 deletions

View File

@ -3368,3 +3368,40 @@ handle_run_terminal (MetaDisplay *display,
g_error_free (err); 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;
}

View File

@ -52,8 +52,7 @@ struct _MetaKeyBinding
}; };
void gboolean meta_keybindings_set_custom_handler (const gchar *name,
meta_keybindings_set_custom_hander (const gchar *name,
MetaKeyHandlerFunc handler, MetaKeyHandlerFunc handler,
gpointer user_data, gpointer user_data,
MetaKeyHandlerDataFreeFunc free_data); MetaKeyHandlerDataFreeFunc free_data);