summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-04-03 13:53:18 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-04-03 13:53:18 +0200
commit55e43e15f8f69b0d93adb52dc70b3b9af264a61f (patch)
tree1ebd40ccf9992260a1fc0d27b90a5b4f92ee01a3 /src
parent220682c1bc12404f981f3ca74ce349342c3e4b9c (diff)
downloadweechat-55e43e15f8f69b0d93adb52dc70b3b9af264a61f.zip
api: allow value "-1" for property "hotlist" in function buffer_set (to remove a buffer from hotlist)
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui-buffer.c11
-rw-r--r--src/gui/gui-hotlist.c2
2 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 05bf6ce58..1766b2ecb 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -1709,19 +1709,24 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
if (!property || !value)
return;
- /* properties that does NOT need a buffer */
+ /* properties with optional 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
+ else if (buffer)
{
error = NULL;
number = strtol (value, &error, 10);
if (error && !error[0])
- (void) gui_hotlist_add (buffer, number, NULL);
+ {
+ if (number < 0)
+ gui_hotlist_remove_buffer (buffer);
+ else
+ (void) gui_hotlist_add (buffer, number, NULL);
+ }
}
}
else if (string_strcasecmp (property, "completion_freeze") == 0)
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index 8904e2c01..3f8dbd319 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -492,7 +492,7 @@ gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
int hotlist_changed;
struct t_gui_hotlist *ptr_hotlist, *next_hotlist;
- if (weechat_upgrading)
+ if (!buffer || weechat_upgrading)
return;
hotlist_changed = 0;