changeset 22899:24dfef623410

Check if a key is already bound before assigning a menu trigger
author Richard Nelson <wabz@pidgin.im>
date Sun, 11 May 2008 07:20:42 +0000
parents 3d7e9eff04d0
children c9aebd4762a8
files ChangeLog ChangeLog.API finch/libgnt/gntbindable.c finch/libgnt/gntbindable.h finch/libgnt/gntmenu.c
diffstat 5 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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:
--- 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)
 {
--- 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.
--- 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;