1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 08:43:13 +02:00

Fix hotlist bug: buffer were added to hotlist even if line is filtered (hidden)

This commit is contained in:
Sebastien Helleu
2008-06-19 12:23:09 +02:00
parent 72f587df06
commit 6bb860456c
4 changed files with 74 additions and 55 deletions
+21 -15
View File
@@ -492,9 +492,29 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
long number;
char *error;
if (!buffer || !property || !value)
if (!property || !value)
return;
/* properties that does NOT need a buffer */
if (string_strcasecmp (property, "hotlist") == 0)
{
if (strcmp (value, "-") == 0)
gui_add_hotlist = 0;
else if (strcmp (value, "+") == 0)
gui_add_hotlist = 1;
else
{
error = NULL;
number = strtol (value, &error, 10);
if (error && !error[0])
gui_hotlist_add (buffer, number, NULL, 1);
}
}
if (!buffer)
return;
/* properties that need a buffer */
if (string_strcasecmp (property, "display") == 0)
{
gui_window_switch_to_buffer (gui_current_window, buffer);
@@ -557,20 +577,6 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
{
gui_buffer_set_nick (buffer, value);
}
else if (string_strcasecmp (property, "hotlist") == 0)
{
if (strcmp (value, "-") == 0)
gui_add_hotlist = 0;
else if (strcmp (value, "+") == 0)
gui_add_hotlist = 1;
else
{
error = NULL;
number = strtol (value, &error, 10);
if (error && !error[0])
gui_hotlist_add (buffer, number, NULL, 1);
}
}
else if (string_strcasecmp (property, "highlight_words") == 0)
{
gui_buffer_set_highlight_words (buffer, value);
+29 -11
View File
@@ -666,6 +666,27 @@ gui_chat_line_free_all (struct t_gui_buffer *buffer)
}
}
/*
* gui_chat_line_get_notify_level: get notify level for a line
*/
int
gui_chat_line_get_notify_level (struct t_gui_line *line)
{
int i;
for (i = 0; i < line->tags_count; i++)
{
if (string_strcasecmp (line->tags_array[i], "notify_highlight") == 0)
return GUI_HOTLIST_HIGHLIGHT;
if (string_strcasecmp (line->tags_array[i], "notify_private") == 0)
return GUI_HOTLIST_PRIVATE;
if (string_strcasecmp (line->tags_array[i], "notify_message") == 0)
return GUI_HOTLIST_MESSAGE;
}
return GUI_HOTLIST_LOW;
}
/*
* gui_chat_line_add: add a new line for a buffer
*/
@@ -707,8 +728,6 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
gui_chat_strlen_screen (prefix) : 0;
new_line->message = (message) ? strdup (message) : strdup ("");
new_line->highlight = gui_chat_line_has_highlight (buffer, new_line);
if (new_line->highlight)
gui_hotlist_add (buffer, GUI_HOTLIST_HIGHLIGHT, NULL, 0);
/* add line to lines list */
if (!buffer->lines)
@@ -726,6 +745,14 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
{
if (new_line->prefix_length > buffer->prefix_max_length)
buffer->prefix_max_length = new_line->prefix_length;
if (new_line->highlight)
gui_hotlist_add (buffer, GUI_HOTLIST_HIGHLIGHT, NULL, 0);
else
{
gui_hotlist_add (buffer,
gui_chat_line_get_notify_level (new_line),
NULL, 0);
}
}
else
{
@@ -942,16 +969,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
}
if (gui_init_ok)
{
gui_buffer_ask_chat_refresh (buffer, 1);
if (gui_add_hotlist
&& ((buffer->num_displayed == 0)
|| (gui_buffer_is_scrolled (buffer))))
{
gui_hotlist_add (buffer, 0, NULL, 1);
gui_status_refresh_needed = 1;
}
}
free (buf);
}