diff options
author | Richard Nelson <wabz@pidgin.im> | 2008-05-11 07:20:42 +0000 |
---|---|---|
committer | Richard Nelson <wabz@pidgin.im> | 2008-05-11 07:20:42 +0000 |
commit | 82cd4b9c63ee19842ce115e0a83fec459321e309 (patch) | |
tree | ae2c2b814e38c98bdb4cfb3fbdccce857311dd69 | |
parent | f0c82387b32ce55cb49afd52942edf911f23f485 (diff) | |
download | pidgin-82cd4b9c63ee19842ce115e0a83fec459321e309.tar.gz |
Check if a key is already bound before assigning a menu trigger
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | ChangeLog.API | 3 | ||||
-rw-r--r-- | finch/libgnt/gntbindable.c | 7 | ||||
-rw-r--r-- | finch/libgnt/gntbindable.h | 10 | ||||
-rw-r--r-- | finch/libgnt/gntmenu.c | 3 |
5 files changed, 23 insertions, 1 deletions
@@ -53,6 +53,7 @@ version 2.x.x: Finch: * New default binding ctrl+x to open context menus. + * Menu triggers and other bindings will no longer conflict. version 2.4.1 (03/31/2008): http://developer.pidgin.im/query?status=closed&milestone=2.4.1 diff --git a/ChangeLog.API b/ChangeLog.API index 0e41d4d258..48d41e5682 100644 --- a/ChangeLog.API +++ b/ChangeLog.API @@ -11,6 +11,9 @@ version 2.x.x: * Callbacks to Purple::Util::fetch_url and the Purple::Request::* functions can now be specified as both strings (the name of the callback function) and as coderefs. + Finch: + libgnt: + * Added gnt_bindable_check_key to check if a keystroke is bound. version 2.4.0 (02/29/2008): libpurple: diff --git a/finch/libgnt/gntbindable.c b/finch/libgnt/gntbindable.c index 5a5c6cfffc..c2be911a6b 100644 --- a/finch/libgnt/gntbindable.c +++ b/finch/libgnt/gntbindable.c @@ -339,6 +339,13 @@ gnt_bindable_perform_action_key(GntBindable *bindable, const char *keys) return FALSE; } +gboolean +gnt_bindable_check_key(GntBindable *bindable, const char *keys) { + GntBindableClass *klass = GNT_BINDABLE_CLASS(GNT_BINDABLE_GET_CLASS(bindable)); + GntBindableActionParam *param = g_hash_table_lookup(klass->bindings, keys); + return (param && param->action); +} + static void register_binding(GntBindableClass *klass, const char *name, const char *trigger, GList *list) { diff --git a/finch/libgnt/gntbindable.h b/finch/libgnt/gntbindable.h index 3b386df7bd..418ea41d25 100644 --- a/finch/libgnt/gntbindable.h +++ b/finch/libgnt/gntbindable.h @@ -149,6 +149,16 @@ void gnt_bindable_register_binding(GntBindableClass *klass, const char *name, co gboolean gnt_bindable_perform_action_key(GntBindable *bindable, const char *keys); /** + * Discover if a key is bound. + * + * @param bindable The bindable object. + * @param keys The key to check for. + * + * @return @c TRUE if the the key has an action associated with it. + */ +gboolean gnt_bindable_check_key(GntBindable *bindable, const char *keys); + +/** * Perform an action on a bindable object. * * @param bindable The bindable object. diff --git a/finch/libgnt/gntmenu.c b/finch/libgnt/gntmenu.c index e81226dc9f..621083a402 100644 --- a/finch/libgnt/gntmenu.c +++ b/finch/libgnt/gntmenu.c @@ -168,7 +168,8 @@ assign_triggers(GntMenu *menu) continue; while (*text) { char ch = tolower(*text++); - if (ch == ' ' || bools[(int)GET_VAL(ch)]) + char t[2] = {ch, '\0'}; + if (ch == ' ' || bools[(int)GET_VAL(ch)] || gnt_bindable_check_key(GNT_BINDABLE(menu), t)) continue; trigger = ch; break; |