Mercurial > pidgin.yaz
diff finch/libgnt/gntkeys.c @ 15979:2c81ebc7bf0b
Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 04 Apr 2007 03:47:13 +0000 |
parents | 0e3a8505ebbe |
children | ca463cecd432 |
line wrap: on
line diff
--- a/finch/libgnt/gntkeys.c Sun Apr 01 08:05:59 2007 +0000 +++ b/finch/libgnt/gntkeys.c Wed Apr 04 03:47:13 2007 +0000 @@ -134,6 +134,28 @@ return g_hash_table_lookup(specials, name); } +typedef struct { + const char *name; + const char *key; +} gntkey; + +static void +get_key_name(gpointer key, gpointer value, gpointer data) +{ + gntkey *k = data; + if (k->name) + return; + if (g_utf8_collate(value, k->key) == 0) + k->name = key; +} + +const char *gnt_key_lookup(const char *key) +{ + gntkey k = {NULL, key}; + g_hash_table_foreach(specials, get_key_name, &k); + return k.name; +} + /** * The key-bindings will be saved in a tree. When a keystroke happens, GNT will * find the sequence that matches a binding and return the length.