diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-nicklist.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index d03fe3175..e0e21eb77 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -35,6 +35,7 @@ #include "../core/weechat.h" #include "../core/wee-config.h" +#include "../core/wee-hashtable.h" #include "../core/wee-hdata.h" #include "../core/wee-hook.h" #include "../core/wee-infolist.h" @@ -47,6 +48,9 @@ #include "gui-color.h" +struct t_hashtable *gui_nicklist_hsignal = NULL; + + /* * Sends a signal when something has changed in nicklist. */ @@ -80,6 +84,40 @@ gui_nicklist_send_signal (const char *signal, struct t_gui_buffer *buffer, } /* + * Sends a hsignal when something will change or has changed in nicklist. + */ + +void +gui_nicklist_send_hsignal (const char *signal, struct t_gui_buffer *buffer, + struct t_gui_nick_group *group, + struct t_gui_nick *nick) +{ + if (!gui_nicklist_hsignal) + { + gui_nicklist_hsignal = hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_POINTER, + NULL, + NULL); + } + + if (!gui_nicklist_hsignal) + return; + + hashtable_remove_all (gui_nicklist_hsignal); + + hashtable_set (gui_nicklist_hsignal, "buffer", buffer); + hashtable_set (gui_nicklist_hsignal, "parent_group", + (group) ? group->parent : nick->group); + if (group) + hashtable_set (gui_nicklist_hsignal, "group", group); + if (nick) + hashtable_set (gui_nicklist_hsignal, "nick", nick); + + hook_hsignal_send (signal, gui_nicklist_hsignal); +} + +/* * Searches for position of a group (to keep nicklist sorted). */ @@ -259,6 +297,7 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer, buffer->nicklist_visible_count++; gui_nicklist_send_signal ("nicklist_group_added", buffer, name); + gui_nicklist_send_hsignal ("nicklist_group_added", buffer, new_group, NULL); return new_group; } @@ -421,6 +460,7 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer, gui_buffer_ask_chat_refresh (buffer, 1); gui_nicklist_send_signal ("nicklist_nick_added", buffer, name); + gui_nicklist_send_hsignal ("nicklist_nick_added", buffer, NULL, new_nick); return new_nick; } @@ -440,6 +480,9 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer, nick_removed = (nick->name) ? strdup (nick->name) : NULL; + gui_nicklist_send_signal ("nicklist_nick_removing", buffer, nick_removed); + gui_nicklist_send_hsignal ("nicklist_nick_removing", buffer, NULL, nick); + /* remove nick from list */ if (nick->prev_nick) (nick->prev_nick)->next_nick = nick->next_nick; @@ -507,6 +550,9 @@ gui_nicklist_remove_group (struct t_gui_buffer *buffer, gui_nicklist_remove_nick (buffer, group->nicks); } + gui_nicklist_send_signal ("nicklist_group_removing", buffer, group_removed); + gui_nicklist_send_hsignal ("nicklist_group_removing", buffer, group, NULL); + if (group->parent) { /* remove group from list */ @@ -855,6 +901,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer, { gui_nicklist_send_signal ("nicklist_group_changed", buffer, group->name); + gui_nicklist_send_hsignal ("nicklist_group_changed", buffer, group, NULL); } } @@ -979,6 +1026,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer, { gui_nicklist_send_signal ("nicklist_nick_changed", buffer, nick->name); + gui_nicklist_send_hsignal ("nicklist_nick_changed", buffer, NULL, nick); } } |