diff options
-rw-r--r-- | doc/de/autogen/user/buflist_options.adoc | 2 | ||||
-rw-r--r-- | doc/en/autogen/user/buflist_options.adoc | 2 | ||||
-rw-r--r-- | doc/fr/autogen/user/buflist_options.adoc | 2 | ||||
-rw-r--r-- | doc/it/autogen/user/buflist_options.adoc | 2 | ||||
-rw-r--r-- | doc/ja/autogen/user/buflist_options.adoc | 2 | ||||
-rw-r--r-- | doc/pl/autogen/user/buflist_options.adoc | 2 | ||||
-rw-r--r-- | po/cs.po | 6 | ||||
-rw-r--r-- | po/de.po | 7 | ||||
-rw-r--r-- | po/es.po | 6 | ||||
-rw-r--r-- | po/fr.po | 14 | ||||
-rw-r--r-- | po/hu.po | 6 | ||||
-rw-r--r-- | po/it.po | 6 | ||||
-rw-r--r-- | po/ja.po | 7 | ||||
-rw-r--r-- | po/pl.po | 6 | ||||
-rw-r--r-- | po/pt.po | 6 | ||||
-rw-r--r-- | po/pt_BR.po | 6 | ||||
-rw-r--r-- | po/ru.po | 6 | ||||
-rw-r--r-- | po/tr.po | 6 | ||||
-rw-r--r-- | po/weechat.pot | 6 | ||||
-rw-r--r-- | src/plugins/buflist/buflist-bar-item.c | 55 | ||||
-rw-r--r-- | src/plugins/buflist/buflist-config.c | 6 | ||||
-rw-r--r-- | src/plugins/buflist/buflist.c | 107 | ||||
-rw-r--r-- | src/plugins/buflist/buflist.h | 6 |
23 files changed, 183 insertions, 91 deletions
diff --git a/doc/de/autogen/user/buflist_options.adoc b/doc/de/autogen/user/buflist_options.adoc index ec7d4d0a3..f9efb533b 100644 --- a/doc/de/autogen/user/buflist_options.adoc +++ b/doc/de/autogen/user/buflist_options.adoc @@ -123,7 +123,7 @@ ** Standardwert: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** Beschreibung: pass:none[durch Kommata getrennte Liste von Feldern um die Buffer zu sortieren; jedes Feld ist eine hdata Variable von Buffer; wird das "-" Zeichen vor einem Feld angewendet, wird die Ausgabe umgekehrt] +** Beschreibung: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order] ** Typ: Zeichenkette ** Werte: beliebige Zeichenkette ** Standardwert: `+"number,-active"+` diff --git a/doc/en/autogen/user/buflist_options.adoc b/doc/en/autogen/user/buflist_options.adoc index 019d946f0..5a85346e9 100644 --- a/doc/en/autogen/user/buflist_options.adoc +++ b/doc/en/autogen/user/buflist_options.adoc @@ -123,7 +123,7 @@ ** default value: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** description: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer; char "-" can be used before field to reverse order] +** description: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order] ** type: string ** values: any string ** default value: `+"number,-active"+` diff --git a/doc/fr/autogen/user/buflist_options.adoc b/doc/fr/autogen/user/buflist_options.adoc index 8dcd96dbc..82098be11 100644 --- a/doc/fr/autogen/user/buflist_options.adoc +++ b/doc/fr/autogen/user/buflist_options.adoc @@ -123,7 +123,7 @@ ** valeur par défaut: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** description: pass:none[liste de champs séparés par des virgules pour trier les tampons ; chaque champ est une variable hdata du tampon ; le caractère "-" peut être utilisé pour inverser l'ordre] +** description: pass:none[liste de champs séparés par des virgules pour trier les tampons ; chaque champ est une variable hdata du tampon ("var"), une variable hdata du serveur IRC ("irc_server.var") ou une variable hdata du canal IRC ("irc_channel.var") ; le caractère "-" peut être utilisé pour inverser l'ordre] ** type: chaîne ** valeurs: toute chaîne ** valeur par défaut: `+"number,-active"+` diff --git a/doc/it/autogen/user/buflist_options.adoc b/doc/it/autogen/user/buflist_options.adoc index 2fcce8b17..bddc29bec 100644 --- a/doc/it/autogen/user/buflist_options.adoc +++ b/doc/it/autogen/user/buflist_options.adoc @@ -123,7 +123,7 @@ ** valore predefinito: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** descrizione: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer; char "-" can be used before field to reverse order] +** descrizione: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order] ** tipo: stringa ** valori: qualsiasi stringa ** valore predefinito: `+"number,-active"+` diff --git a/doc/ja/autogen/user/buflist_options.adoc b/doc/ja/autogen/user/buflist_options.adoc index ba3c4202d..1c4305246 100644 --- a/doc/ja/autogen/user/buflist_options.adoc +++ b/doc/ja/autogen/user/buflist_options.adoc @@ -123,7 +123,7 @@ ** デフォルト値: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** 説明: pass:none[バッファをソートする際に考慮するフィールドのコンマ区切りリスト; 各フィールドはバッファの hdata 変数です; フィールドの先頭に "-" 文字を付けることでソート順を逆にすることも可能です] +** 説明: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order] ** タイプ: 文字列 ** 値: 未制約文字列 ** デフォルト値: `+"number,-active"+` diff --git a/doc/pl/autogen/user/buflist_options.adoc b/doc/pl/autogen/user/buflist_options.adoc index 11cdb5377..2f93781dd 100644 --- a/doc/pl/autogen/user/buflist_options.adoc +++ b/doc/pl/autogen/user/buflist_options.adoc @@ -123,7 +123,7 @@ ** domyślna wartość: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** opis: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer; char "-" can be used before field to reverse order] +** opis: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order] ** typ: ciąg ** wartości: dowolny ciąg ** domyślna wartość: `+"number,-active"+` @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-01-06 21:59+0100\n" "Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4995,7 +4995,9 @@ msgstr "čárkami oddělený seznam slovníků, které použít pro tento buffer msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-04-24 22:21+0200\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <kde-i18n-de@kde.org>\n" @@ -5938,9 +5938,12 @@ msgstr "" "benutzerdefinierte Variablen genutzt werden und dadurch eine Aktualisierung " "erforderlich wird" +#, fuzzy msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" "durch Kommata getrennte Liste von Feldern um die Buffer zu sortieren; jedes " "Feld ist eine hdata Variable von Buffer; wird das \"-\" Zeichen vor einem " @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-01-06 22:01+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5208,7 +5208,9 @@ msgstr "lista separada por comas de diccionarios para usar en este buffer" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" -"PO-Revision-Date: 2017-04-25 20:39+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" +"PO-Revision-Date: 2017-04-26 20:19+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -5817,11 +5817,15 @@ msgstr "" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" "liste de champs séparés par des virgules pour trier les tampons ; chaque " -"champ est une variable hdata du tampon ; le caractère \"-\" peut être " -"utilisé pour inverser l'ordre" +"champ est une variable hdata du tampon (\"var\"), une variable hdata du " +"serveur IRC (\"irc_server.var\") ou une variable hdata du canal IRC " +"(\"irc_channel.var\") ; le caractère \"-\" peut être utilisé pour inverser " +"l'ordre" msgid "" "format of each line with a buffer (note: content is evaluated, see /help " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-01-06 22:03+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4531,7 +4531,9 @@ msgstr "" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-01-06 22:04+0100\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5346,7 +5346,9 @@ msgstr "elenco separato da virgole di dizionari da usare su questo buffer" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-04-23 09:00+0900\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/master/" @@ -5540,9 +5540,12 @@ msgstr "" "れは一部のカスタム変数が書式内で使われており、明示的に再読込が必要な場合に便" "利です" +#, fuzzy msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" "バッファをソートする際に考慮するフィールドのコンマ区切りリスト; 各フィールド" "はバッファの hdata 変数です; フィールドの先頭に \"-\" 文字を付けることでソー" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-04-08 14:49+0200\n" "Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5600,7 +5600,9 @@ msgstr "oddzielona przecinkami lista słowników do użycia w tym buforze" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-04-08 14:50+0200\n" "Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n" "Language-Team: Portuguese <>\n" @@ -5602,7 +5602,9 @@ msgstr "lista de dicionários separados por vírgula para usar neste buffer" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy diff --git a/po/pt_BR.po b/po/pt_BR.po index 2878cbd50..02939e6e9 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2016-09-03 08:24+0200\n" "Last-Translator: Eduardo Elias <camponez@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5148,7 +5148,9 @@ msgstr "lista de dicionários (separados por vírgula) para uso neste buffer" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-01-06 22:06+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4569,7 +4569,9 @@ msgstr "" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" #, fuzzy @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2017-01-06 22:07+0100\n" "Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4134,7 +4134,9 @@ msgstr "" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" msgid "" diff --git a/po/weechat.pot b/po/weechat.pot index 403078b02..d3a7ab36f 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2017-04-25 20:37+0200\n" +"POT-Creation-Date: 2017-04-26 15:04+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4119,7 +4119,9 @@ msgstr "" msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " -"variable of buffer; char \"-\" can be used before field to reverse order" +"variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." +"var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " +"can be used before field to reverse order" msgstr "" msgid "" diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c index 036b42f0b..46a275aed 100644 --- a/src/plugins/buflist/buflist-bar-item.c +++ b/src/plugins/buflist/buflist-bar-item.c @@ -52,18 +52,15 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, struct t_gui_buffer *ptr_buffer, *ptr_current_buffer; struct t_gui_nick *ptr_gui_nick; struct t_gui_hotlist *ptr_hotlist; - struct t_hdata *hdata_irc_server, *hdata_irc_channel; struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; char **buflist, *str_buflist, *condition; - char str_condition[512]; char str_format_number[32], str_format_number_empty[32]; char str_nick_prefix[32], str_color_nick_prefix[32]; char str_number[32], *line, **hotlist, *str_hotlist; char str_hotlist_count[32]; const char *ptr_format, *ptr_format_current, *ptr_format_indent; - const char *ptr_name, *ptr_type, *ptr_server_name, *ptr_channel_name; - const char *ptr_nick, *ptr_nick_prefix; + const char *ptr_name, *ptr_type, *ptr_nick, *ptr_nick_prefix; const char *ptr_hotlist_format, *ptr_hotlist_priority; const char *hotlist_priority_none = "none"; const char *hotlist_priority[4] = { "low", "message", "private", @@ -84,9 +81,6 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, prev_number = -1; - hdata_irc_server = NULL; - hdata_irc_channel = NULL; - buflist = weechat_string_dyn_alloc (256); ptr_format = weechat_config_string (buflist_config_format_buffer); @@ -122,52 +116,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, "buffer", ptr_buffer); /* set IRC server/channel pointers */ - ptr_server = NULL; - ptr_channel = NULL; - if (strcmp (weechat_buffer_get_string (ptr_buffer, "plugin"), "irc") == 0) - { - ptr_server_name = weechat_buffer_get_string (ptr_buffer, "localvar_server"); - if (ptr_server_name && ptr_server_name[0]) - { - if (!hdata_irc_server) - hdata_irc_server = weechat_hdata_get ("irc_server"); - if (hdata_irc_server) - { - snprintf (str_condition, sizeof (str_condition), - "${irc_server.name} == %s", - ptr_server_name); - ptr_server = weechat_hdata_get_list (hdata_irc_server, - "irc_servers"); - ptr_server = weechat_hdata_search (hdata_irc_server, - ptr_server, - str_condition, - 1); - if (ptr_server) - { - ptr_channel_name = weechat_buffer_get_string (ptr_buffer, - "localvar_channel"); - if (ptr_channel_name && ptr_channel_name[0]) - { - if (!hdata_irc_channel) - hdata_irc_channel = weechat_hdata_get ("irc_channel"); - if (hdata_irc_channel) - { - snprintf (str_condition, sizeof (str_condition), - "${irc_channel.name} == %s", - ptr_channel_name); - ptr_channel = weechat_hdata_pointer (hdata_irc_server, - ptr_server, - "channels"); - ptr_channel = weechat_hdata_search (hdata_irc_channel, - ptr_channel, - str_condition, - 1); - } - } - } - } - } - } + buflist_buffer_get_irc_pointers (ptr_buffer, &ptr_server, &ptr_channel); weechat_hashtable_set (buflist_hashtable_pointers, "irc_server", ptr_server); weechat_hashtable_set (buflist_hashtable_pointers, diff --git a/src/plugins/buflist/buflist-config.c b/src/plugins/buflist/buflist-config.c index 9398b4d0e..87ca1f8c1 100644 --- a/src/plugins/buflist/buflist-config.c +++ b/src/plugins/buflist/buflist-config.c @@ -369,8 +369,10 @@ buflist_config_init () buflist_config_file, ptr_section, "sort", "string", N_("comma-separated list of fields to sort buffers; each field is " - "a hdata variable of buffer; char \"-\" can be used before field " - "to reverse order"), + "a hdata variable of buffer (\"var\"), a hdata variable of " + "IRC server (\"irc_server.var\") or a hdata variable of " + "IRC channel (\"irc_channel.var\"); " + "char \"-\" can be used before field to reverse order"), NULL, 0, 0, "number,-active", NULL, 0, NULL, NULL, NULL, &buflist_config_change_sort, NULL, NULL, diff --git a/src/plugins/buflist/buflist.c b/src/plugins/buflist/buflist.c index 08d2889ff..891d9b25d 100644 --- a/src/plugins/buflist/buflist.c +++ b/src/plugins/buflist/buflist.c @@ -20,6 +20,7 @@ */ #include <stdlib.h> +#include <stdio.h> #include <string.h> #include "../weechat-plugin.h" @@ -44,6 +45,78 @@ struct t_hdata *buflist_hdata_hotlist = NULL; /* + * Get IRC server and channel pointers for a buffer. + * + * According to buffer: + * - non IRC buffer: both are NULL + * - IRC server/private: server is set, channel is NULL + * - IRC channel: server and channel are set + */ + +void +buflist_buffer_get_irc_pointers(struct t_gui_buffer *buffer, + struct t_irc_server **server, + struct t_irc_channel **channel) +{ + const char *ptr_server_name, *ptr_channel_name; + char str_condition[512]; + struct t_hdata *hdata_irc_server, *hdata_irc_channel; + + *server = NULL; + *channel = NULL; + + /* check if the buffer belongs to IRC plugin */ + if (strcmp (weechat_buffer_get_string (buffer, "plugin"), "irc") != 0) + return; + + /* get server name from buffer local variable */ + ptr_server_name = weechat_buffer_get_string (buffer, "localvar_server"); + if (!ptr_server_name || !ptr_server_name[0]) + return; + + /* get hdata "irc_server" (can be NULL if irc plugin is not loaded) */ + hdata_irc_server = weechat_hdata_get ("irc_server"); + if (!hdata_irc_server) + return; + + /* search the server by name in list of servers */ + snprintf (str_condition, sizeof (str_condition), + "${irc_server.name} == %s", + ptr_server_name); + *server = weechat_hdata_get_list (hdata_irc_server, + "irc_servers"); + *server = weechat_hdata_search (hdata_irc_server, + *server, + str_condition, + 1); + if (!*server) + return; + + /* get channel name from buffer local variable */ + ptr_channel_name = weechat_buffer_get_string (buffer, + "localvar_channel"); + if (!ptr_channel_name || !ptr_channel_name[0]) + return; + + /* get hdata "irc_channel" (can be NULL if irc plugin is not loaded) */ + hdata_irc_channel = weechat_hdata_get ("irc_channel"); + if (!hdata_irc_channel) + return; + + /* search the channel by name in list of channels on the server */ + snprintf (str_condition, sizeof (str_condition), + "${irc_channel.name} == %s", + ptr_channel_name); + *channel = weechat_hdata_pointer (hdata_irc_server, + *server, + "channels"); + *channel = weechat_hdata_search (hdata_irc_channel, + *channel, + str_condition, + 1); +} + +/* * Compares a hdata variable of two objects. * * Returns: @@ -143,13 +216,20 @@ buflist_compare_buffers (void *data, struct t_arraylist *arraylist, int i, reverse, rc; const char *ptr_field; struct t_gui_hotlist *ptr_hotlist1, *ptr_hotlist2; + struct t_irc_server *ptr_server1, *ptr_server2; + struct t_irc_channel *ptr_channel1, *ptr_channel2; + struct t_hdata *hdata_irc_server, *hdata_irc_channel; /* make C compiler happy */ (void) data; (void) arraylist; + hdata_irc_server = weechat_hdata_get ("irc_server"); + hdata_irc_channel = weechat_hdata_get ("irc_channel"); + for (i = 0; i < buflist_config_sort_fields_count; i++) { + rc = 0; reverse = 1; if (buflist_config_sort_fields[i][0] == '-') { @@ -160,7 +240,6 @@ buflist_compare_buffers (void *data, struct t_arraylist *arraylist, { ptr_field = buflist_config_sort_fields[i]; } - rc = 0; if (strncmp (ptr_field, "hotlist.", 8) == 0) { ptr_hotlist1 = weechat_hdata_pointer (buflist_hdata_buffer, @@ -180,6 +259,32 @@ buflist_compare_buffers (void *data, struct t_arraylist *arraylist, ptr_field + 8); } } + else if (strncmp (ptr_field, "irc_server.", 11) == 0) + { + if (hdata_irc_server) + { + buflist_buffer_get_irc_pointers (pointer1, + &ptr_server1, &ptr_channel1); + buflist_buffer_get_irc_pointers (pointer2, + &ptr_server2, &ptr_channel2); + rc = buflist_compare_hdata_var (hdata_irc_server, + ptr_server1, ptr_server2, + ptr_field + 11); + } + } + else if (strncmp (ptr_field, "irc_channel.", 12) == 0) + { + if (hdata_irc_channel) + { + buflist_buffer_get_irc_pointers (pointer1, + &ptr_server1, &ptr_channel1); + buflist_buffer_get_irc_pointers (pointer2, + &ptr_server2, &ptr_channel2); + rc = buflist_compare_hdata_var (hdata_irc_channel, + ptr_channel1, ptr_channel2, + ptr_field + 12); + } + } else { rc = buflist_compare_hdata_var (buflist_hdata_buffer, diff --git a/src/plugins/buflist/buflist.h b/src/plugins/buflist/buflist.h index 51af55c15..56a16d450 100644 --- a/src/plugins/buflist/buflist.h +++ b/src/plugins/buflist/buflist.h @@ -26,11 +26,17 @@ #define BUFLIST_BAR_NAME "buflist" +struct t_irc_server; +struct t_irc_channel; + extern struct t_weechat_plugin *weechat_buflist_plugin; extern struct t_hdata *buflist_hdata_buffer; extern struct t_hdata *buflist_hdata_hotlist; +extern void buflist_buffer_get_irc_pointers(struct t_gui_buffer *buffer, + struct t_irc_server **server, + struct t_irc_channel **channel); extern struct t_gui_hotlist *buflist_search_hotlist_for_buffer (struct t_gui_buffer *buffer); extern struct t_arraylist *buflist_sort_buffers (); |