diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | doc/en/weechat_plugin_api.en.txt | 13 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.txt | 13 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.txt | 13 | ||||
-rw-r--r-- | src/gui/gui-bar-item.c | 4 | ||||
-rw-r--r-- | src/gui/gui-nicklist.c | 51 |
6 files changed, 81 insertions, 16 deletions
@@ -9,7 +9,6 @@ Version 0.3.2 (under dev!) * core: add new options for command /key: listdefault, listdiff and reset * core: add new command /mute -* core: add signal "day_changed" * core: add command line option "-s" (or "--no-script") to start WeeChat without loading any script * core: remove unneeded space after time on each line if option @@ -40,6 +39,8 @@ Version 0.3.2 (under dev!) * api: add missing infos in functions buffer_get_integer / buffer_get_string and in buffer infolist * api: add description of arguments for functions hook_info and hook_infolist +* api: add signals "day_changed", "nicklist_group_added/removed", + "nicklist_nick_added/removed" * api: fix function "color" in Lua script API * api: fix "inactivity" value when no key has been pressed since WeeChat started (bug #28930) diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index f82292b0e..540d590b8 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -5732,8 +5732,17 @@ Arguments: | weechat | key_pressed | string: key pressed | key pressed -| weechat | nicklist_changed | - | - nicklist has changed +| weechat | nicklist_group_added | string: buffer pointer + "," + group name | + group added in nicklist + +| weechat | nicklist_group_removed | string: buffer pointer + "," + group name | + group removed from nicklist + +| weechat | nicklist_nick_added | string: buffer pointer + "," + nick name | + nick added in nicklist + +| weechat | nicklist_nick_removed | string: buffer pointer + "," + nick name | + nick removed from nicklist | weechat | partial_completion | - | partial completion happened diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 28ff9c5b0..e92fda835 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -5806,8 +5806,17 @@ Paramètres : | weechat | key_pressed | chaîne : touche appuyée | touche appuyée -| weechat | nicklist_changed | - | - la liste des pseudos a changé +| weechat | nicklist_group_added | chaîne: pointeur tampon + "," + nom du groupe | + groupe ajouté dans la liste des pseudos + +| weechat | nicklist_group_removed | chaîne: pointeur tampon + "," + nom du groupe | + groupe supprimé de la liste des pseudos + +| weechat | nicklist_nick_added | chaîne: pointeur tampon + "," + pseudo | + pseudo ajouté dans la liste des pseudos + +| weechat | nicklist_nick_removed | chaîne: pointeur tampon + "," + pseudo | + pseudo supprimé de la liste des pseudos | weechat | partial_completion | - | une complétion partielle a été faite diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index d311ee3d8..f39e24728 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -5553,8 +5553,17 @@ Argomenti: | weechat | key_pressed | string: key pressed | key pressed -| weechat | nicklist_changed | - | - nicklist has changed +| weechat | nicklist_group_added | string: buffer pointer + "," + group name | + group added in nicklist + +| weechat | nicklist_group_removed | string: buffer pointer + "," + group name | + group removed from nicklist + +| weechat | nicklist_nick_added | string: buffer pointer + "," + nick name | + nick added in nicklist + +| weechat | nicklist_nick_removed | string: buffer pointer + "," + nick name | + nick removed from nicklist | weechat | partial_completion | - | partial completion happened diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 64ee4ec9e..8db2ec907 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -1431,7 +1431,7 @@ gui_bar_item_init () &gui_bar_item_default_buffer_nicklist_count, NULL); gui_bar_item_hook_signal ("buffer_switch", gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT]); - gui_bar_item_hook_signal ("nicklist_changed", + gui_bar_item_hook_signal ("nicklist_*", gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT]); /* scroll indicator */ @@ -1470,7 +1470,7 @@ gui_bar_item_init () gui_bar_item_new (NULL, gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST], &gui_bar_item_default_buffer_nicklist, NULL); - gui_bar_item_hook_signal ("nicklist_changed", + gui_bar_item_hook_signal ("nicklist_*", gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST]); gui_bar_item_hook_signal ("buffer_switch", gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST]); diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index 8e1bce9ef..2ea5a8352 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -45,13 +45,36 @@ /* - * gui_nicklist_changed_signal: send "nicklist_changed" signal + * gui_nicklist_send_signal: send a signal when something has changed in + * nicklist */ void -gui_nicklist_changed_signal () +gui_nicklist_send_signal (const char *signal, struct t_gui_buffer *buffer, + const char *arguments) { - hook_signal_send ("nicklist_changed", WEECHAT_HOOK_SIGNAL_STRING, NULL); + char *str_args; + int length; + + if (buffer) + { + length = 128 + ((arguments) ? strlen (arguments) : 0) + 1 + 1; + str_args = malloc (length); + if (str_args) + { + snprintf (str_args, length, + "0x%lx,%s", + (long unsigned int)(buffer), + (arguments) ? arguments : ""); + hook_signal_send (signal, WEECHAT_HOOK_SIGNAL_STRING, str_args); + free (str_args); + } + } + else + { + hook_signal_send (signal, WEECHAT_HOOK_SIGNAL_STRING, + (char *)arguments); + } } /* @@ -201,7 +224,7 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer, if (buffer->nicklist_display_groups && visible) buffer->nicklist_visible_count++; - gui_nicklist_changed_signal (); + gui_nicklist_send_signal ("nicklist_group_added", buffer, name); return new_group; } @@ -342,7 +365,7 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer, if (visible) buffer->nicklist_visible_count++; - gui_nicklist_changed_signal (); + gui_nicklist_send_signal ("nicklist_nick_added", buffer, name); return new_nick; } @@ -355,9 +378,13 @@ void gui_nicklist_remove_nick (struct t_gui_buffer *buffer, struct t_gui_nick *nick) { + char *nick_removed; + if (!buffer || !nick) return; + nick_removed = (nick->name) ? strdup (nick->name) : NULL; + /* remove nick from list */ if (nick->prev_nick) (nick->prev_nick)->next_nick = nick->next_nick; @@ -386,7 +413,10 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer, free (nick); - gui_nicklist_changed_signal (); + gui_nicklist_send_signal ("nicklist_nick_removed", buffer, nick_removed); + + if (nick_removed) + free (nick_removed); } /* @@ -397,9 +427,13 @@ void gui_nicklist_remove_group (struct t_gui_buffer *buffer, struct t_gui_nick_group *group) { + char *group_removed; + if (!buffer || !group) return; + group_removed = (group->name) ? strdup (group->name) : NULL; + /* remove childs first */ while (group->childs) { @@ -444,7 +478,10 @@ gui_nicklist_remove_group (struct t_gui_buffer *buffer, free (group); - gui_nicklist_changed_signal (); + gui_nicklist_send_signal ("nicklist_group_removed", buffer, group_removed); + + if (group_removed) + free (group_removed); } /* |