summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-05-17 20:10:32 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-05-17 20:10:32 +0200
commit6d0e15e0d78d76ed37a59db1833b91cd76c24de8 (patch)
tree78997dee65f9104a4fefbb00a65fbbb8a33aa165
parente2497ff8bcdaa0a78975e98996958c76a418b9e0 (diff)
downloadweechat-6d0e15e0d78d76ed37a59db1833b91cd76c24de8.zip
Add signals "key_bind" and "key_unbind"
-rw-r--r--src/core/wee-command.c2
-rw-r--r--src/core/wee-config.c2
-rw-r--r--src/gui/gui-buffer.c2
-rw-r--r--src/gui/gui-keyboard.c22
-rw-r--r--src/gui/gui-keyboard.h3
5 files changed, 22 insertions, 9 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 827617cf6..737afb3c7 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1810,7 +1810,7 @@ command_key (void *data, struct t_gui_buffer *buffer,
{
if (argc >= 3)
{
- if (gui_keyboard_unbind (NULL, argv[2]))
+ if (gui_keyboard_unbind (NULL, argv[2], 1))
{
gui_chat_printf (NULL,
_("Key \"%s\" unbound"),
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index d779bfdd1..d90d89c6f 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -1100,7 +1100,7 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
else
{
/* unbind key if no value given */
- gui_keyboard_unbind (NULL, option_name);
+ gui_keyboard_unbind (NULL, option_name, 1);
}
}
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index eb97a6b5a..113a4f936 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -1048,7 +1048,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
if (strcmp (property + 11, "*") == 0)
gui_keyboard_free_all (&buffer->keys, &buffer->last_key);
else
- gui_keyboard_unbind (buffer, property + 11);
+ gui_keyboard_unbind (buffer, property + 11, 1);
}
else if (string_strcasecmp (property, "input") == 0)
{
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c
index 27d60105c..e3ee919ee 100644
--- a/src/gui/gui-keyboard.c
+++ b/src/gui/gui-keyboard.c
@@ -28,6 +28,7 @@
#include <ctype.h>
#include "../core/weechat.h"
+#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-input.h"
#include "../core/wee-log.h"
@@ -317,18 +318,22 @@ gui_keyboard_new (struct t_gui_buffer *buffer, const char *key,
else
gui_keyboard_insert_sorted (&gui_keys, &last_gui_key, new_key);
+ expanded_name = gui_keyboard_get_expanded_name (new_key->key);
+
+ hook_signal_send ("key_bind",
+ WEECHAT_HOOK_SIGNAL_STRING, expanded_name);
+
if (gui_keyboard_verbose)
{
- expanded_name = gui_keyboard_get_expanded_name (new_key->key);
gui_chat_printf (NULL,
_("New key binding: %s%s => %s%s"),
(expanded_name) ? expanded_name : new_key->key,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
new_key->command);
- if (expanded_name)
- free (expanded_name);
}
+ if (expanded_name)
+ free (expanded_name);
}
else
return NULL;
@@ -414,7 +419,7 @@ gui_keyboard_bind (struct t_gui_buffer *buffer, const char *key, const char *com
return NULL;
}
- gui_keyboard_unbind (buffer, key);
+ gui_keyboard_unbind (buffer, key, 0);
new_key = gui_keyboard_new (buffer, key, command);
if (!new_key)
@@ -431,7 +436,8 @@ gui_keyboard_bind (struct t_gui_buffer *buffer, const char *key, const char *com
*/
int
-gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key)
+gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key,
+ int send_signal)
{
struct t_gui_key *ptr_key;
char *internal_code;
@@ -450,6 +456,12 @@ gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key)
if (internal_code)
free (internal_code);
+ if (send_signal)
+ {
+ hook_signal_send ("key_unbind",
+ WEECHAT_HOOK_SIGNAL_STRING, (char *)key);
+ }
+
return (ptr_key != NULL);
}
diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h
index 73dda8d00..b58c56e8c 100644
--- a/src/gui/gui-keyboard.h
+++ b/src/gui/gui-keyboard.h
@@ -61,7 +61,8 @@ extern struct t_gui_key *gui_keyboard_search (struct t_gui_buffer *buffer,
extern struct t_gui_key *gui_keyboard_bind (struct t_gui_buffer *buffer,
const char *key,
const char *command);
-extern int gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key);
+extern int gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key,
+ int send_signal);
extern int gui_keyboard_pressed (const char *key_str);
extern void gui_keyboard_free (struct t_gui_key **keys,
struct t_gui_key **last_key,