diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-17 20:10:32 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-17 20:10:32 +0200 |
commit | 6d0e15e0d78d76ed37a59db1833b91cd76c24de8 (patch) | |
tree | 78997dee65f9104a4fefbb00a65fbbb8a33aa165 /src/gui | |
parent | e2497ff8bcdaa0a78975e98996958c76a418b9e0 (diff) | |
download | weechat-6d0e15e0d78d76ed37a59db1833b91cd76c24de8.zip |
Add signals "key_bind" and "key_unbind"
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-buffer.c | 2 | ||||
-rw-r--r-- | src/gui/gui-keyboard.c | 22 | ||||
-rw-r--r-- | src/gui/gui-keyboard.h | 3 |
3 files changed, 20 insertions, 7 deletions
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, |