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: [PATCH] api: allow value "-1" for property "hotlist" in function buffer_set (to remove a buffer from hotlist) --- ChangeLog.asciidoc | 2 ++ doc/en/weechat_plugin_api.en.txt | 3 ++- doc/fr/weechat_plugin_api.fr.txt | 3 ++- doc/it/weechat_plugin_api.it.txt | 4 +++- doc/ja/weechat_plugin_api.ja.txt | 4 +++- src/gui/gui-buffer.c | 11 ++++++++--- src/gui/gui-hotlist.c | 2 +- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index d08911de4..df1d5af42 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -70,6 +70,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * core: add signals "key_combo_{default|search|cursor}" * core: display a warning in case of inconsistency between the options weechat.look.save_{config|layout}_on_exit +* api: allow value "-1" for property "hotlist" in function buffer_set (to remove + a buffer from hotlist) * api: add option "buffer_flush" in function hook_process_hashtable * api: allow negative value for y in function printf_y * api: add support of case insensitive search and search by buffer full name diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index 02706bdb0..f4ac391ee 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -10454,7 +10454,8 @@ Properties: WEECHAT_HOTLIST_PRIVATE, WEECHAT_HOTLIST_HIGHLIGHT | "+": enable hotlist (global setting, buffer pointer is not used) + "-": disable hotlist (global setting, buffer pointer is not used) + - priority: add buffer to hotlist with this priority + priority: add buffer to hotlist with this priority + + "-1": remove buffer from hotlist _(WeeChat ≥ 0.4.4)_ | completion_freeze | "0", "1" | "0": no freeze of completion (default value) diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 4078f3d26..a5eb9680e 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -10657,7 +10657,8 @@ Propriétés : utilisé) + "-" : désactive la hotlist (option globale, le pointeur vers le tampon n'est pas utilisé) + - priorité : ajouter ce tampon dans la hotlist avec cette priorité + priorité : ajouter ce tampon dans la hotlist avec cette priorité + + "-1" : supprimer ce tampon de la hotlist _(WeeChat ≥ 0.4.4)_ | completion_freeze | "0", "1" | "0" : pas de gel de la complétion (valeur par défaut) diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index f794030d4..405989569 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -10723,13 +10723,15 @@ Properties: |=== | Nome | Valore | Descrizione +// TRANSLATION MISSING | hotlist | "+", "-", WEECHAT_HOTLIST_LOW, WEECHAT_HOTLIST_MESSAGE, WEECHAT_HOTLIST_PRIVATE, WEECHAT_HOTLIST_HIGHLIGHT | "+": abilita hotlist (impostazione globale , il puntatore al buffer pointer non è utilizzato) + "-": disabilita hotlist (impostazione globale, il puntatore al buffer non è utilizzato) + - priorità: aggiunge il buffer alla hotlist con questa proprietà + priorità: aggiunge il buffer alla hotlist con questa proprietà + + "-1": remove buffer from hotlist _(WeeChat ≥ 0.4.4)_ // TRANSLATION MISSING | completion_freeze | "0", "1" | diff --git a/doc/ja/weechat_plugin_api.ja.txt b/doc/ja/weechat_plugin_api.ja.txt index a14bf8a0c..525529d6c 100644 --- a/doc/ja/weechat_plugin_api.ja.txt +++ b/doc/ja/weechat_plugin_api.ja.txt @@ -10443,11 +10443,13 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property, |=== | 名前 | 値 | 説明 +// TRANSLATION MISSING | hotlist | "+", "-", WEECHAT_HOTLIST_LOW, WEECHAT_HOTLIST_MESSAGE, WEECHAT_HOTLIST_PRIVATE, WEECHAT_HOTLIST_HIGHLIGHT | "+": ホットリストを有効化 (グローバル設定、バッファへのポインタは使われない) + "-": ホットリストを無効化 (グローバル設定、バッファへのポインタは使われない) + - 優先度: この優先度でホットリストにバッファを追加 + 優先度: この優先度でホットリストにバッファを追加 + + "-1": remove buffer from hotlist _(WeeChat ≥ 0.4.4)_ | completion_freeze | "0", "1" | "0": 補完を止める (デフォルト) 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;