From 55e43e15f8f69b0d93adb52dc70b3b9af264a61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Thu, 3 Apr 2014 13:53:18 +0200 Subject: api: allow value "-1" for property "hotlist" in function buffer_set (to remove a buffer from hotlist) --- src/gui/gui-buffer.c | 11 ++++++++--- src/gui/gui-hotlist.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') 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; -- cgit v1.2.3