# HG changeset patch # User Richard Nelson # Date 1210490442 0 # Node ID 24dfef6234105becd2bb778150ce76e73e0e10bb # Parent 3d7e9eff04d0d0fc5814f727632a6895c15677e8 Check if a key is already bound before assigning a menu trigger diff -r 3d7e9eff04d0 -r 24dfef623410 ChangeLog --- a/ChangeLog Sun May 11 05:08:08 2008 +0000 +++ b/ChangeLog Sun May 11 07:20:42 2008 +0000 @@ -53,6 +53,7 @@ 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 -r 3d7e9eff04d0 -r 24dfef623410 ChangeLog.API --- a/ChangeLog.API Sun May 11 05:08:08 2008 +0000 +++ b/ChangeLog.API Sun May 11 07:20:42 2008 +0000 @@ -11,6 +11,9 @@ * 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 -r 3d7e9eff04d0 -r 24dfef623410 finch/libgnt/gntbindable.c --- a/finch/libgnt/gntbindable.c Sun May 11 05:08:08 2008 +0000 +++ b/finch/libgnt/gntbindable.c Sun May 11 07:20:42 2008 +0000 @@ -339,6 +339,13 @@ 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 -r 3d7e9eff04d0 -r 24dfef623410 finch/libgnt/gntbindable.h --- a/finch/libgnt/gntbindable.h Sun May 11 05:08:08 2008 +0000 +++ b/finch/libgnt/gntbindable.h Sun May 11 07:20:42 2008 +0000 @@ -149,6 +149,16 @@ 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 -r 3d7e9eff04d0 -r 24dfef623410 finch/libgnt/gntmenu.c --- a/finch/libgnt/gntmenu.c Sun May 11 05:08:08 2008 +0000 +++ b/finch/libgnt/gntmenu.c Sun May 11 07:20:42 2008 +0000 @@ -168,7 +168,8 @@ 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;