Add signals "nicklist_{group|nick}_{added|removed}", remove signal "nicklist_changed"

Data for new signals is a string with format: "buffer,name", where:
- buffer is a pointer, for example 0x123456
- name is group or nick name added/removed from nicklist on this buffer.
v2.8-utf8proc
Sebastien Helleu 2010-03-25 17:02:37 +01:00
parent ac27388543
commit 483b63f360
6 changed files with 81 additions and 16 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]);

View File

@ -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);
}
/*