From ec545c70b1b2f2c29301e2ab0c8a5377ddb9efa4 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 13 Dec 2008 19:43:11 +0100 Subject: Add infolists for bars/bar items/bar windows, code cleanup for bars --- doc/de/autogen/weechat_infos.xml | 15 ++ doc/en/autogen/weechat_infos.xml | 15 ++ doc/fr/autogen/weechat_infos.xml | 15 ++ po/cs.po | 36 +++-- po/de.po | 36 +++-- po/es.po | 36 +++-- po/fr.po | 33 +++-- po/hu.po | 36 +++-- po/ru.po | 36 +++-- po/weechat.pot | 23 +++- src/core/wee-command.c | 8 +- src/gui/curses/gui-curses-main.c | 40 +++--- src/gui/curses/gui-curses-window.c | 6 +- src/gui/curses/gui-curses.h | 7 - src/gui/gtk/gui-gtk-main.c | 50 +++++-- src/gui/gtk/gui-gtk-window.c | 6 +- src/gui/gui-bar-item.c | 119 ++++++++++++---- src/gui/gui-bar-item.h | 5 + src/gui/gui-bar-window.c | 208 +++++++++++++++++++++++++++- src/gui/gui-bar-window.h | 14 +- src/gui/gui-bar.c | 169 ++++++++++++++++++----- src/gui/gui-bar.h | 11 +- src/gui/gui-buffer.c | 21 ++- src/gui/gui-window.c | 11 +- src/gui/gui-window.h | 3 +- src/plugins/plugin-api.c | 274 +++++++++++++++++++++++++++---------- src/plugins/scripts/script.c | 4 +- src/plugins/weechat-plugin.h | 15 +- 28 files changed, 949 insertions(+), 303 deletions(-) diff --git a/doc/de/autogen/weechat_infos.xml b/doc/de/autogen/weechat_infos.xml index 8c83f94aa..a0e9108e8 100644 --- a/doc/de/autogen/weechat_infos.xml +++ b/doc/de/autogen/weechat_infos.xml @@ -61,6 +61,21 @@ weechat_sharedir WeeChat "share" directory + + infolist + bar + list of bars + + + infolist + bar_item + list of bar items + + + infolist + bar_window + list of bar windows + infolist buffer diff --git a/doc/en/autogen/weechat_infos.xml b/doc/en/autogen/weechat_infos.xml index 8c83f94aa..a0e9108e8 100644 --- a/doc/en/autogen/weechat_infos.xml +++ b/doc/en/autogen/weechat_infos.xml @@ -61,6 +61,21 @@ weechat_sharedir WeeChat "share" directory + + infolist + bar + list of bars + + + infolist + bar_item + list of bar items + + + infolist + bar_window + list of bar windows + infolist buffer diff --git a/doc/fr/autogen/weechat_infos.xml b/doc/fr/autogen/weechat_infos.xml index 3066da142..5dd237430 100644 --- a/doc/fr/autogen/weechat_infos.xml +++ b/doc/fr/autogen/weechat_infos.xml @@ -61,6 +61,21 @@ weechat_sharedir répertoire "share" de WeeChat + + infolist + bar + liste des barres + + + infolist + bar_item + liste des objets de barres + + + infolist + bar_window + liste des fenêtres de barre + infolist buffer diff --git a/po/cs.po b/po/cs.po index ff2d454be..ef5d70900 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-12-10 17:02+0100\n" +"POT-Creation-Date: 2008-12-12 16:40+0100\n" "PO-Revision-Date: 2008-09-17 16:19+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -111,8 +111,8 @@ msgstr "šířka" msgid "auto" msgstr "auto" -#, c-format -msgid " priority: %d, fg: %s, bg: %s, items: %s%s (plugin: %s)" +#, fuzzy, c-format +msgid " priority: %d, fg: %s, bg: %s, items: %s%s" msgstr " priorita: %d, popředí: %s, pozadí: %s, položky: %s%s (plugin: %s)" msgid ", with separator" @@ -4299,6 +4299,18 @@ msgstr "" msgid "1 if filters are enabled" msgstr "uživatel byl zablokován" +#, fuzzy +msgid "list of bars" +msgstr "Seznam polí:" + +#, fuzzy +msgid "list of bar items" +msgstr "Seznam položek polí:" + +#, fuzzy +msgid "list of bar windows" +msgstr "Seznam položek polí:" + #, fuzzy msgid "list of buffers" msgstr "Seznam pro aliasy:\n" @@ -4312,28 +4324,28 @@ msgid "list of filters" msgstr "Seznam pro aliasy:\n" #, fuzzy -msgid "nicks in nicklist for a buffer" -msgstr "nevalidní délka pro buffer" - -msgid "list of windows" -msgstr "" +msgid "list of hooks" +msgstr "Seznam pro aliasy:\n" #, fuzzy msgid "list of buffers in hotlist" msgstr "zobrazit historii příkazů bufferu" #, fuzzy -msgid "list of options" -msgstr "nastaví konfigurační možnosti" +msgid "nicks in nicklist for a buffer" +msgstr "nevalidní délka pro buffer" #, fuzzy -msgid "list of hooks" -msgstr "Seznam pro aliasy:\n" +msgid "list of options" +msgstr "nastaví konfigurační možnosti" #, fuzzy msgid "list of plugins" msgstr "nastaví konfigurační možnosti" +msgid "list of windows" +msgstr "" + #, fuzzy, c-format msgid "%sError: unable to load plugin \"%s\": %s" msgstr "%s nemůžu načist plugin \"%s\": %s\n" diff --git a/po/de.po b/po/de.po index ca9c8b912..08055367b 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-12-10 17:02+0100\n" +"POT-Creation-Date: 2008-12-12 16:40+0100\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -118,7 +118,7 @@ msgid "auto" msgstr "" #, fuzzy, c-format -msgid " priority: %d, fg: %s, bg: %s, items: %s%s (plugin: %s)" +msgid " priority: %d, fg: %s, bg: %s, items: %s%s" msgstr "%sin %s%s%s/%s%s%s:%s ignoriere %s%s%s von %s%s\n" #, fuzzy @@ -4272,6 +4272,18 @@ msgstr "" msgid "1 if filters are enabled" msgstr "/users wurde deaktiviert" +#, fuzzy +msgid "list of bars" +msgstr "Liste der Aliases:\n" + +#, fuzzy +msgid "list of bar items" +msgstr "Liste der Aliases:\n" + +#, fuzzy +msgid "list of bar windows" +msgstr "Liste der /ignore-Regeln:\n" + #, fuzzy msgid "list of buffers" msgstr "Liste der Aliases:\n" @@ -4285,29 +4297,29 @@ msgid "list of filters" msgstr "Liste der Aliases:\n" #, fuzzy -msgid "nicks in nicklist for a buffer" -msgstr "Fehlerhafte Pufferlänge" - -#, fuzzy -msgid "list of windows" -msgstr "Liste der /ignore-Regeln:\n" +msgid "list of hooks" +msgstr "Liste der Aliases:\n" #, fuzzy msgid "list of buffers in hotlist" msgstr "Maximale Länge der Namen in der Hotlist" #, fuzzy -msgid "list of options" -msgstr "Konfigurationsparameter setzen" +msgid "nicks in nicklist for a buffer" +msgstr "Fehlerhafte Pufferlänge" #, fuzzy -msgid "list of hooks" -msgstr "Liste der Aliases:\n" +msgid "list of options" +msgstr "Konfigurationsparameter setzen" #, fuzzy msgid "list of plugins" msgstr "Konfigurationsparameter setzen" +#, fuzzy +msgid "list of windows" +msgstr "Liste der /ignore-Regeln:\n" + #, fuzzy, c-format msgid "%sError: unable to load plugin \"%s\": %s" msgstr "%s kann Plugin \"%s\" nicht laden: %s\n" diff --git a/po/es.po b/po/es.po index a4e3bfcab..9360ab89f 100644 --- a/po/es.po +++ b/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-12-10 17:02+0100\n" +"POT-Creation-Date: 2008-12-12 16:40+0100\n" "PO-Revision-Date: 2007-09-19 12:09+0200\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -114,7 +114,7 @@ msgid "auto" msgstr "" #, fuzzy, c-format -msgid " priority: %d, fg: %s, bg: %s, items: %s%s (plugin: %s)" +msgid " priority: %d, fg: %s, bg: %s, items: %s%s" msgstr "%sen %s%s%s/%s%s%s:%s ignorando %s%s%s de %s%s\n" #, fuzzy @@ -4272,6 +4272,18 @@ msgstr "" msgid "1 if filters are enabled" msgstr "los usuarios han sido desactivados" +#, fuzzy +msgid "list of bars" +msgstr "Lista de alias:\n" + +#, fuzzy +msgid "list of bar items" +msgstr "Lista de alias:\n" + +#, fuzzy +msgid "list of bar windows" +msgstr "Lista de ignores:\n" + #, fuzzy msgid "list of buffers" msgstr "Lista de alias:\n" @@ -4285,29 +4297,29 @@ msgid "list of filters" msgstr "Lista de alias:\n" #, fuzzy -msgid "nicks in nicklist for a buffer" -msgstr "longitud inválida para un búfer" - -#, fuzzy -msgid "list of windows" -msgstr "Lista de ignores:\n" +msgid "list of hooks" +msgstr "Lista de alias:\n" #, fuzzy msgid "list of buffers in hotlist" msgstr "longitud máxima de nombres en la hotlist" #, fuzzy -msgid "list of options" -msgstr "poner opciones de configuración" +msgid "nicks in nicklist for a buffer" +msgstr "longitud inválida para un búfer" #, fuzzy -msgid "list of hooks" -msgstr "Lista de alias:\n" +msgid "list of options" +msgstr "poner opciones de configuración" #, fuzzy msgid "list of plugins" msgstr "poner opciones de configuración" +#, fuzzy +msgid "list of windows" +msgstr "Lista de ignores:\n" + #, fuzzy, c-format msgid "%sError: unable to load plugin \"%s\": %s" msgstr "%s no ha sido posible cargar el plugin \"%s\": %s\n" diff --git a/po/fr.po b/po/fr.po index c7699115e..73e285d18 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-12-10 17:02+0100\n" -"PO-Revision-Date: 2008-12-10 17:02+0100\n" +"POT-Creation-Date: 2008-12-12 16:40+0100\n" +"PO-Revision-Date: 2008-12-12 16:41+0100\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -114,8 +114,8 @@ msgid "auto" msgstr "auto" #, c-format -msgid " priority: %d, fg: %s, bg: %s, items: %s%s (plugin: %s)" -msgstr " priorité: %d, fg: %s, bg: %s, objets: %s%s (extension: %s)" +msgid " priority: %d, fg: %s, bg: %s, items: %s%s" +msgstr " priorité: %d, fg: %s, bg: %s, objets: %s%s" msgid ", with separator" msgstr ", avec séparateur" @@ -4442,6 +4442,15 @@ msgstr "inactivité du clavier (secondes)" msgid "1 if filters are enabled" msgstr "1 si les filtres sont activés" +msgid "list of bars" +msgstr "liste des barres" + +msgid "list of bar items" +msgstr "liste des objets de barres" + +msgid "list of bar windows" +msgstr "liste des fenêtres de barre" + msgid "list of buffers" msgstr "liste des tampons" @@ -4451,24 +4460,24 @@ msgstr "lignes d'un tampon" msgid "list of filters" msgstr "liste des filtres" -msgid "nicks in nicklist for a buffer" -msgstr "pseudos dans la liste des pseudos pour un tampon" - -msgid "list of windows" -msgstr "liste des fenêtres" +msgid "list of hooks" +msgstr "liste des hooks" msgid "list of buffers in hotlist" msgstr "liste des tampons dans la hotlist" +msgid "nicks in nicklist for a buffer" +msgstr "pseudos dans la liste des pseudos pour un tampon" + msgid "list of options" msgstr "liste des options" -msgid "list of hooks" -msgstr "liste des hooks" - msgid "list of plugins" msgstr "liste des extensions" +msgid "list of windows" +msgstr "liste des fenêtres" + #, c-format msgid "%sError: unable to load plugin \"%s\": %s" msgstr "%sErreur: impossible de charger l'extension \"%s\": %s" diff --git a/po/hu.po b/po/hu.po index cfaf56785..14c11ebd8 100644 --- a/po/hu.po +++ b/po/hu.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-12-10 17:02+0100\n" +"POT-Creation-Date: 2008-12-12 16:40+0100\n" "PO-Revision-Date: 2007-10-10 18:07+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -119,7 +119,7 @@ msgid "auto" msgstr "" #, fuzzy, c-format -msgid " priority: %d, fg: %s, bg: %s, items: %s%s (plugin: %s)" +msgid " priority: %d, fg: %s, bg: %s, items: %s%s" msgstr "%s %s%s%s/%s%s%s:%s %s%s%s mellőzése a következő(k)től: %s%s\n" #, fuzzy @@ -4300,6 +4300,18 @@ msgstr "" msgid "1 if filters are enabled" msgstr "a felhasználók le lettek tiltva" +#, fuzzy +msgid "list of bars" +msgstr "Aliaszok listája:\n" + +#, fuzzy +msgid "list of bar items" +msgstr "Aliaszok listája:\n" + +#, fuzzy +msgid "list of bar windows" +msgstr "Mellőzések listája:\n" + #, fuzzy msgid "list of buffers" msgstr "Aliaszok listája:\n" @@ -4313,29 +4325,29 @@ msgid "list of filters" msgstr "Aliaszok listája:\n" #, fuzzy -msgid "nicks in nicklist for a buffer" -msgstr "érvénytelen pufferhossz" - -#, fuzzy -msgid "list of windows" -msgstr "Mellőzések listája:\n" +msgid "list of hooks" +msgstr "Aliaszok listája:\n" #, fuzzy msgid "list of buffers in hotlist" msgstr "kiemelendő szavak listája" #, fuzzy -msgid "list of options" -msgstr "konfigurációs paraméterek beállítása" +msgid "nicks in nicklist for a buffer" +msgstr "érvénytelen pufferhossz" #, fuzzy -msgid "list of hooks" -msgstr "Aliaszok listája:\n" +msgid "list of options" +msgstr "konfigurációs paraméterek beállítása" #, fuzzy msgid "list of plugins" msgstr "konfigurációs paraméterek beállítása" +#, fuzzy +msgid "list of windows" +msgstr "Mellőzések listája:\n" + #, fuzzy, c-format msgid "%sError: unable to load plugin \"%s\": %s" msgstr "%s nem sikerült a modult betölteni \"%s\": %s\n" diff --git a/po/ru.po b/po/ru.po index 8a4e1049d..267b05f80 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-12-10 17:02+0100\n" +"POT-Creation-Date: 2008-12-12 16:40+0100\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -115,7 +115,7 @@ msgid "auto" msgstr "" #, fuzzy, c-format -msgid " priority: %d, fg: %s, bg: %s, items: %s%s (plugin: %s)" +msgid " priority: %d, fg: %s, bg: %s, items: %s%s" msgstr "%sна %s%s%s/%s%s%s:%s игнорирует %s%s%s с %s%s\n" #, fuzzy @@ -4287,6 +4287,18 @@ msgstr "" msgid "1 if filters are enabled" msgstr "команда users отключена" +#, fuzzy +msgid "list of bars" +msgstr "Список сокращений:\n" + +#, fuzzy +msgid "list of bar items" +msgstr "Список сокращений:\n" + +#, fuzzy +msgid "list of bar windows" +msgstr "Список игнорирования:\n" + #, fuzzy msgid "list of buffers" msgstr "Список сокращений:\n" @@ -4300,29 +4312,29 @@ msgid "list of filters" msgstr "Список сокращений:\n" #, fuzzy -msgid "nicks in nicklist for a buffer" -msgstr "некорректная длина буфера" - -#, fuzzy -msgid "list of windows" -msgstr "Список игнорирования:\n" +msgid "list of hooks" +msgstr "Список сокращений:\n" #, fuzzy msgid "list of buffers in hotlist" msgstr "максимальная длина имён в хотлисте" #, fuzzy -msgid "list of options" -msgstr "настроить параметры конфигурации" +msgid "nicks in nicklist for a buffer" +msgstr "некорректная длина буфера" #, fuzzy -msgid "list of hooks" -msgstr "Список сокращений:\n" +msgid "list of options" +msgstr "настроить параметры конфигурации" #, fuzzy msgid "list of plugins" msgstr "настроить параметры конфигурации" +#, fuzzy +msgid "list of windows" +msgstr "Список игнорирования:\n" + #, fuzzy, c-format msgid "%sError: unable to load plugin \"%s\": %s" msgstr "%s не могу загрузить plugin \"%s\": %s\n" diff --git a/po/weechat.pot b/po/weechat.pot index d6fcb3409..a3cd70138 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-12-10 17:02+0100\n" +"POT-Creation-Date: 2008-12-12 16:40+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -95,7 +95,7 @@ msgid "auto" msgstr "" #, c-format -msgid " priority: %d, fg: %s, bg: %s, items: %s%s (plugin: %s)" +msgid " priority: %d, fg: %s, bg: %s, items: %s%s" msgstr "" msgid ", with separator" @@ -3726,6 +3726,15 @@ msgstr "" msgid "1 if filters are enabled" msgstr "" +msgid "list of bars" +msgstr "" + +msgid "list of bar items" +msgstr "" + +msgid "list of bar windows" +msgstr "" + msgid "list of buffers" msgstr "" @@ -3735,22 +3744,22 @@ msgstr "" msgid "list of filters" msgstr "" -msgid "nicks in nicklist for a buffer" +msgid "list of hooks" msgstr "" -msgid "list of windows" +msgid "list of buffers in hotlist" msgstr "" -msgid "list of buffers in hotlist" +msgid "nicks in nicklist for a buffer" msgstr "" msgid "list of options" msgstr "" -msgid "list of hooks" +msgid "list of plugins" msgstr "" -msgid "list of plugins" +msgid "list of windows" msgstr "" #, c-format diff --git a/src/core/wee-command.c b/src/core/wee-command.c index a8b7a7523..9d5ba39de 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -101,16 +101,14 @@ command_bar_list (int full) _("height") : _("width"), (CONFIG_INTEGER(ptr_bar->size) == 0) ? _("auto") : str_size); gui_chat_printf (NULL, - _(" priority: %d, fg: %s, bg: %s, items: %s%s (plugin: " - "%s)"), + _(" priority: %d, fg: %s, bg: %s, items: %s%s"), CONFIG_INTEGER(ptr_bar->priority), gui_color_get_name (CONFIG_COLOR(ptr_bar->color_fg)), gui_color_get_name (CONFIG_COLOR(ptr_bar->color_bg)), (CONFIG_STRING(ptr_bar->items) && CONFIG_STRING(ptr_bar->items)[0]) ? CONFIG_STRING(ptr_bar->items) : "-", (CONFIG_INTEGER(ptr_bar->separator)) ? - _(", with separator") : "", - (ptr_bar->plugin) ? ptr_bar->plugin->name : "-"); + _(", with separator") : ""); } else { @@ -246,7 +244,7 @@ command_bar (void *data, struct t_gui_buffer *buffer, if (error && !error[0]) { /* create bar */ - if (gui_bar_new (NULL, argv[2], "0", "0", str_type, + if (gui_bar_new (argv[2], "0", "0", str_type, (pos_condition) ? pos_condition : "", argv[4], "horizontal", "vertical", diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 897511722..ba13a4ba8 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -112,33 +112,37 @@ gui_main_init () /* init bar items */ gui_bar_item_init (); - /* create new window/buffer */ - if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100)) + gui_init_ok = 0; + + /* create core buffer */ + ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL); + if (ptr_buffer) { - gui_current_window = gui_windows; - ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL); - if (ptr_buffer) + gui_init_ok = 1; + + /* set title for core buffer */ + gui_buffer_set_title (ptr_buffer, + "WeeChat " WEECHAT_COPYRIGHT_DATE + " - " WEECHAT_WEBSITE); + + /* create main window (using full space) */ + if (gui_window_new (NULL, ptr_buffer, 0, 0, COLS, LINES, 100, 100)) { - gui_init_ok = 1; - gui_buffer_set_title (ptr_buffer, - "WeeChat " WEECHAT_COPYRIGHT_DATE - " - " WEECHAT_WEBSITE); + gui_current_window = gui_windows; + + if (CONFIG_BOOLEAN(config_look_set_title)) + gui_window_title_set (); } - else - gui_init_ok = 0; - if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_title_set (); - } - - if (gui_init_ok) - { /* create bar windows for root bars (they were read from config, but no window was created (GUI was not initialized) */ for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) { - if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT) && (!ptr_bar->bar_window)) + if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT) + && (!ptr_bar->bar_window)) + { gui_bar_window_new (ptr_bar, NULL); + } } for (ptr_bar_win = gui_windows->bar_windows; ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window) diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index ff26a9173..6c19c206b 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -980,7 +980,7 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage) if ((height1 >= GUI_WINDOW_MIN_HEIGHT) && (height2 >= GUI_WINDOW_MIN_HEIGHT) && (percentage > 0) && (percentage <= 100)) { - new_window = gui_window_new (window, + new_window = gui_window_new (window, window->buffer, window->win_x, window->win_y, window->win_width, height1, 100, percentage); @@ -992,7 +992,6 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage) window->win_height_pct = 100 - percentage; /* assign same buffer for new window (top window) */ - new_window->buffer = window->buffer; new_window->buffer->num_displayed++; gui_window_switch_to_buffer (window, window->buffer, 1); @@ -1025,7 +1024,7 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage) if ((width1 >= GUI_WINDOW_MIN_WIDTH) && (width2 >= GUI_WINDOW_MIN_WIDTH) && (percentage > 0) && (percentage <= 100)) { - new_window = gui_window_new (window, + new_window = gui_window_new (window, window->buffer, window->win_x + width1 + 1, window->win_y, width2, window->win_height, percentage, 100); @@ -1036,7 +1035,6 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage) window->win_width_pct = 100 - percentage; /* assign same buffer for new window (right window) */ - new_window->buffer = window->buffer; new_window->buffer->num_displayed++; gui_window_switch_to_buffer (window, window->buffer, 1); diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index dfb76466c..91923f1b5 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -59,13 +59,6 @@ extern void gui_color_pre_init (); extern void gui_color_init (); extern void gui_color_end (); -/* bar functions */ -extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window, - struct t_gui_window *window); -extern void gui_bar_window_create_win (struct t_gui_bar_window *bar_window); -extern int gui_bar_window_remove_unused_bars (struct t_gui_window *window); -extern int gui_bar_window_add_missing_bars (struct t_gui_window *window); - /* chat functions */ extern void gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **line, diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c index 8b12876aa..9633c49f2 100644 --- a/src/gui/gtk/gui-gtk-main.c +++ b/src/gui/gtk/gui-gtk-main.c @@ -35,6 +35,7 @@ #include "../../plugins/plugin.h" #include "../gui-bar.h" #include "../gui-bar-item.h" +#include "../gui-bar-window.h" #include "../gui-chat.h" #include "../gui-main.h" #include "../gui-buffer.h" @@ -84,6 +85,8 @@ void gui_main_init () { struct t_gui_buffer *ptr_buffer; + struct t_gui_bar *ptr_bar; + struct t_gui_bar_window *ptr_bar_win; GdkColor color_fg, color_bg; gui_color_init (); @@ -170,23 +173,44 @@ gui_main_init () gtk_widget_show_all (gui_gtk_main_window); - /* create new window/buffer */ - if (gui_window_new (NULL, 0, 0, 0, 0, 100, 100)) + gui_init_ok = 0; + + /* create core buffer */ + ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL); + if (ptr_buffer) { - gui_current_window = gui_windows; - ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL); - if (ptr_buffer) + gui_init_ok = 1; + + /* set title for core buffer */ + gui_buffer_set_title (ptr_buffer, + "WeeChat " WEECHAT_COPYRIGHT_DATE + " - " WEECHAT_WEBSITE); + + /* create main window (using full space) */ + if (gui_window_new (NULL, ptr_buffer, 0, 0, 0, 0, 100, 100)) { - gui_init_ok = 1; - gui_buffer_set_title (ptr_buffer, - PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE - " - " WEECHAT_WEBSITE); + gui_current_window = gui_windows; + + if (CONFIG_BOOLEAN(config_look_set_title)) + gui_window_title_set (); } - else - gui_init_ok = 0; - if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_title_set (); + /* create bar windows for root bars (they were read from config, + but no window was created (GUI was not initialized) */ + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if ((CONFIG_INTEGER(ptr_bar->type) == GUI_BAR_TYPE_ROOT) + && (!ptr_bar->bar_window)) + { + gui_bar_window_new (ptr_bar, NULL); + } + } + for (ptr_bar_win = gui_windows->bar_windows; + ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window) + { + gui_bar_window_calculate_pos_size (ptr_bar_win, gui_windows); + gui_bar_window_create_win (ptr_bar_win); + } } } diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c index 81515d560..11c06479b 100644 --- a/src/gui/gtk/gui-gtk-window.c +++ b/src/gui/gtk/gui-gtk-window.c @@ -480,7 +480,7 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage) if ((percentage > 0) && (percentage <= 100)) { - new_window = gui_window_new (window, + new_window = gui_window_new (window, window->buffer, window->win_x, window->win_y, window->win_width, height1, 100, percentage); @@ -492,7 +492,6 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage) window->win_height_pct = 100 - percentage; /* assign same buffer for new window (top window) */ - new_window->buffer = window->buffer; new_window->buffer->num_displayed++; gui_window_switch_to_buffer (window, window->buffer, 1); @@ -526,7 +525,7 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage) if ((percentage > 0) && (percentage <= 100)) { - new_window = gui_window_new (window, + new_window = gui_window_new (window, window->buffer, window->win_x + width1 + 1, window->win_y, width2, window->win_height, percentage, 100); @@ -537,7 +536,6 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage) window->win_width_pct = 100 - percentage; /* assign same buffer for new window (right window) */ - new_window->buffer = window->buffer; new_window->buffer->num_displayed++; gui_window_switch_to_buffer (window, window->buffer, 1); diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 72c9f7f68..9d75c523b 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -30,12 +30,14 @@ #include "../core/weechat.h" #include "../core/wee-config.h" #include "../core/wee-hook.h" +#include "../core/wee-infolist.h" #include "../core/wee-log.h" #include "../core/wee-string.h" #include "../core/wee-utf8.h" #include "../plugins/plugin.h" #include "gui-bar-item.h" #include "gui-bar.h" +#include "gui-bar-window.h" #include "gui-buffer.h" #include "gui-chat.h" #include "gui-color.h" @@ -59,6 +61,31 @@ struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL; struct t_hook *gui_bar_item_timer = NULL; +/* + * gui_bar_item_valid: check if a bar item pointer exists + * return 1 if bar item exists + * 0 if bar item is not found + */ + +int +gui_bar_item_valid (struct t_gui_bar_item *bar_item) +{ + struct t_gui_bar_item *ptr_bar_item; + + if (!bar_item) + return 0; + + for (ptr_bar_item = gui_bar_items; ptr_bar_item; + ptr_bar_item = ptr_bar_item->next_item) + { + if (ptr_bar_item == bar_item) + return 1; + } + + /* bar item not found */ + return 0; +} + /* * gui_bar_item_search: search a bar item */ @@ -189,29 +216,6 @@ gui_bar_item_search_with_plugin (struct t_weechat_plugin *plugin, return item_found_plugin; } -/* - * gui_bar_contains_item: return 1 if a bar contains item, O otherwise - */ - -int -gui_bar_contains_item (struct t_gui_bar *bar, const char *item_name) -{ - int i; - - if (!bar || !item_name || !item_name[0]) - return 0; - - for (i = 0; i < bar->items_count; i++) - { - /* skip non letters chars at beginning (prefix) */ - if (gui_bar_item_string_is_item (bar->items_array[i], item_name)) - return 1; - } - - /* item is not in bar */ - return 0; -} - /* * gui_bar_item_used_in_a_bar: return 1 if an item is used in at least one bar * if partial_name == 1, then search a bar that @@ -396,7 +400,8 @@ gui_bar_item_get_value (const char *name, struct t_gui_bar *bar, item_value = NULL; if (item_name) { - ptr_item = gui_bar_item_search_with_plugin ((window) ? window->buffer->plugin : NULL, + ptr_item = gui_bar_item_search_with_plugin ((window && window->buffer) ? + window->buffer->plugin : NULL, 0, item_name); if (ptr_item) @@ -550,13 +555,43 @@ void gui_bar_item_update (const char *item_name) { struct t_gui_bar *ptr_bar; + struct t_gui_window *ptr_window; + struct t_gui_bar_window *ptr_bar_window; + int item_index; for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) { - if (!CONFIG_BOOLEAN(ptr_bar->hidden) - && gui_bar_contains_item (ptr_bar, item_name)) + if (!CONFIG_BOOLEAN(ptr_bar->hidden)) { - gui_bar_ask_refresh (ptr_bar); + item_index = gui_bar_get_item_index (ptr_bar, item_name); + if (item_index >= 0) + { + if (ptr_bar->bar_window) + { + gui_bar_window_content_build_item (ptr_bar->bar_window, + NULL, + item_index); + } + else + { + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) + { + for (ptr_bar_window = ptr_window->bar_windows; + ptr_bar_window; + ptr_bar_window = ptr_bar_window->next_bar_window) + { + if (ptr_bar_window->bar == ptr_bar) + { + gui_bar_window_content_build_item (ptr_bar_window, + ptr_window, + item_index); + } + } + } + } + gui_bar_ask_refresh (ptr_bar); + } } } } @@ -1467,6 +1502,36 @@ gui_bar_item_end () gui_bar_item_free_all (); } +/* + * gui_bar_item_add_to_infolist: add a bar item in an infolist + * return 1 if ok, 0 if error + */ + +int +gui_bar_item_add_to_infolist (struct t_infolist *infolist, + struct t_gui_bar_item *bar_item) +{ + struct t_infolist_item *ptr_item; + + if (!infolist || !bar_item) + return 0; + + ptr_item = infolist_new_item (infolist); + if (!ptr_item) + return 0; + + if (!infolist_new_var_pointer (ptr_item, "plugin", bar_item->plugin)) + return 0; + if (!infolist_new_var_string (ptr_item, "name", bar_item->name)) + return 0; + if (!infolist_new_var_pointer (ptr_item, "build_callback", bar_item->build_callback)) + return 0; + if (!infolist_new_var_pointer (ptr_item, "build_callback_data", bar_item->build_callback_data)) + return 0; + + return 1; +} + /* * gui_bar_item_print_log: print bar items infos in log (usually for crash dump) */ diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index bd522c4a2..007257779 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -71,7 +71,10 @@ extern char *gui_bar_item_names[]; /* functions */ +extern int gui_bar_item_valid (struct t_gui_bar_item *bar_item); extern struct t_gui_bar_item *gui_bar_item_search (const char *name); +extern int gui_bar_item_string_is_item (const char *string, + const char *item_name); extern int gui_bar_item_used_in_a_bar (const char *item_name, int partial_name); extern char *gui_bar_item_get_value (const char *name, @@ -93,6 +96,8 @@ extern void gui_bar_item_free_all (); extern void gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin); extern void gui_bar_item_init (); extern void gui_bar_item_end (); +extern int gui_bar_item_add_to_infolist (struct t_infolist *infolist, + struct t_gui_bar_item *bar_item); extern void gui_bar_item_print_log (); #endif /* gui-bar-item.h */ diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c index a2bfbb268..96b878fa6 100644 --- a/src/gui/gui-bar-window.c +++ b/src/gui/gui-bar-window.c @@ -29,13 +29,55 @@ #include "../core/weechat.h" #include "../core/wee-config.h" +#include "../core/wee-infolist.h" #include "../core/wee-log.h" #include "../core/wee-string.h" #include "gui-bar-window.h" #include "gui-bar.h" +#include "gui-bar-item.h" +#include "gui-color.h" #include "gui-window.h" +/* + * gui_bar_window_valid: check if a bar window pointer exists + * return 1 if bar window exists + * 0 if bar window is not found + */ + +int +gui_bar_window_valid (struct t_gui_bar_window *bar_window) +{ + struct t_gui_bar *ptr_bar; + struct t_gui_window *ptr_window; + struct t_gui_bar_window *ptr_bar_window; + + if (!bar_window) + return 0; + + /* check root bars */ + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if (ptr_bar->bar_window && (ptr_bar->bar_window == bar_window)) + return 1; + } + + /* check window bars */ + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) + { + for (ptr_bar_window = ptr_window->bar_windows; ptr_bar_window; + ptr_bar_window = ptr_bar_window->next_bar_window) + { + if (ptr_bar_window == bar_window) + return 1; + } + } + + /* bar window not found */ + return 0; +} + /* * gui_bar_window_search_bar: search a reference to a bar in a window */ @@ -189,6 +231,97 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window) return NULL; } +/* + * gui_bar_window_content_alloc: allocate content for a bar window + */ + +void +gui_bar_window_content_alloc (struct t_gui_bar_window *bar_window) +{ + int i; + + bar_window->items_count = bar_window->bar->items_count; + bar_window->items_content = malloc((bar_window->items_count) * + sizeof (bar_window->items_content[0])); + if (bar_window->items_content) + { + for (i = 0; i < bar_window->items_count; i++) + { + bar_window->items_content[i] = NULL; + } + } + else + bar_window->items_count = 0; +} + +/* + * gui_bar_window_content_free: free content of a bar window + */ + +void +gui_bar_window_content_free (struct t_gui_bar_window *bar_window) +{ + int i; + + if (bar_window->items_content) + { + for (i = 0; i < bar_window->items_count; i++) + { + if (bar_window->items_content[i]) + free (bar_window->items_content[i]); + } + free (bar_window->items_content); + bar_window->items_content = NULL; + } +} + +/* + * gui_bar_window_content_build_item: build content of an item for a bar window, + * by calling callback for each item, then + * concat values (according to bar position + * and filling) + */ + +void +gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window, + struct t_gui_window *window, + int item_index) +{ + log_printf ("bar_window: build item '%s'", bar_window->bar->items_array[item_index]); + if (bar_window->items_content[item_index]) + free (bar_window->items_content[item_index]); + + bar_window->items_content[item_index] = + gui_bar_item_get_value (bar_window->bar->items_array[item_index], + bar_window->bar, window, + 0, 0, 0); +} + +/* + * gui_bar_window_content_build: build content of a bar window, by calling + * callback for each item, then concat values + * (according to bar position and filling) + */ + +void +gui_bar_window_content_build (struct t_gui_bar_window *bar_window, + struct t_gui_window *window) +{ + int i; + + if (bar_window->items_count != bar_window->bar->items_count) + { + gui_bar_window_content_free (bar_window); + gui_bar_window_content_alloc (bar_window); + } + + for (i = 0; i < bar_window->items_count; i++) + { + gui_bar_window_content_build_item (bar_window, window, i); + + } +} + /* * gui_bar_window_new: create a new "window bar" for a bar, in screen or a window * if window is not NULL, bar window will be in this window @@ -262,8 +395,10 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window) new_bar_window->cursor_y = -1; new_bar_window->current_size = (CONFIG_INTEGER(bar->size) == 0) ? 1 : CONFIG_INTEGER(bar->size); - new_bar_window->content = NULL; + new_bar_window->items_content = NULL; + new_bar_window->items_count = 0; gui_bar_window_objects_init (new_bar_window); + gui_bar_window_content_build (new_bar_window, window); if (gui_init_ok) { @@ -404,8 +539,7 @@ gui_bar_window_free (struct t_gui_bar_window *bar_window, } /* free data */ - if (bar_window->content) - free (bar_window->content); + gui_bar_window_content_free (bar_window); gui_bar_window_objects_free (bar_window); free (bar_window->gui_objects); @@ -547,6 +681,61 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window, } } +/* + * gui_bar_window_add_to_infolist: add a bar window in an infolist + * return 1 if ok, 0 if error + */ + +int +gui_bar_window_add_to_infolist (struct t_infolist *infolist, + struct t_gui_bar_window *bar_window) +{ + struct t_infolist_item *ptr_item; + int i; + char option_name[64]; + + if (!infolist || !bar_window) + return 0; + + ptr_item = infolist_new_item (infolist); + if (!ptr_item) + return 0; + + if (!infolist_new_var_pointer (ptr_item, "bar", bar_window->bar)) + return 0; + if (!infolist_new_var_integer (ptr_item, "x", bar_window->x)) + return 0; + if (!infolist_new_var_integer (ptr_item, "y", bar_window->y)) + return 0; + if (!infolist_new_var_integer (ptr_item, "width", bar_window->width)) + return 0; + if (!infolist_new_var_integer (ptr_item, "height", bar_window->height)) + return 0; + if (!infolist_new_var_integer (ptr_item, "scroll_x", bar_window->scroll_x)) + return 0; + if (!infolist_new_var_integer (ptr_item, "scroll_y", bar_window->scroll_y)) + return 0; + if (!infolist_new_var_integer (ptr_item, "cursor_x", bar_window->cursor_x)) + return 0; + if (!infolist_new_var_integer (ptr_item, "cursor_y", bar_window->cursor_y)) + return 0; + if (!infolist_new_var_integer (ptr_item, "current_size", bar_window->current_size)) + return 0; + if (!infolist_new_var_integer (ptr_item, "items_count", bar_window->current_size)) + return 0; + for (i = 0; i < bar_window->items_count; i++) + { + snprintf (option_name, sizeof (option_name), "items_content_%05d", i + 1); + if (!infolist_new_var_string (ptr_item, option_name, + bar_window->items_content[i])) + return 0; + } + if (!infolist_new_var_pointer (ptr_item, "gui_objects", bar_window->gui_objects)) + return 0; + + return 1; +} + /* * gui_bar_window_print_log: print bar window infos in log (usually for crash dump) */ @@ -554,8 +743,10 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window, void gui_bar_window_print_log (struct t_gui_bar_window *bar_window) { + int i; + log_printf (""); - log_printf (" [window bar (addr:0x%lx)]", bar_window); + log_printf (" [window bar (addr:0x%lx)]", bar_window); log_printf (" bar . . . . . . . : 0x%lx ('%s')", bar_window->bar, (bar_window->bar) ? bar_window->bar->name : ""); @@ -568,6 +759,15 @@ gui_bar_window_print_log (struct t_gui_bar_window *bar_window) log_printf (" cursor_x. . . . . . : %d", bar_window->cursor_x); log_printf (" cursor_y. . . . . . : %d", bar_window->cursor_y); log_printf (" current_size. . . . : %d", bar_window->current_size); + log_printf (" items_count . . . . : %d", bar_window->items_count); + for (i = 0; i < bar_window->items_count; i++) + { + log_printf (" items_content[%03d]. : '%s' (item: '%s')", + i, + bar_window->items_content[i], + (bar_window->bar->items_count >= i + 1) ? + bar_window->bar->items_array[i] : "?"); + } log_printf (" gui_objects . . . . : 0x%lx", bar_window->gui_objects); gui_bar_window_objects_print_log (bar_window); log_printf (" prev_bar_window . . : 0x%lx", bar_window->prev_bar_window); diff --git a/src/gui/gui-bar-window.h b/src/gui/gui-bar-window.h index d8d7c89d1..2b716dfc4 100644 --- a/src/gui/gui-bar-window.h +++ b/src/gui/gui-bar-window.h @@ -32,7 +32,8 @@ struct t_gui_bar_window int cursor_x, cursor_y; /* use to move cursor on screen (for */ /* input_text item) */ int current_size; /* current size (width or height) */ - char *content; /* bar window content (data displayed) */ + int items_count; /* number of items */ + char **items_content; /* content for each item of bar */ void *gui_objects; /* pointer to a GUI specific struct */ struct t_gui_bar_window *prev_bar_window; /* link to previous bar win */ /* (only for non-root bars) */ @@ -42,6 +43,12 @@ struct t_gui_bar_window /* functions */ +extern int gui_bar_window_valid (struct t_gui_bar_window *bar_window); +extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window, + struct t_gui_window *window); +extern void gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window, + struct t_gui_window *window, + int item_index); extern struct t_gui_bar_window *gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar); extern int gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window); @@ -53,11 +60,16 @@ extern int gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window); extern void gui_bar_window_free (struct t_gui_bar_window *bar_window, struct t_gui_window *window); +extern int gui_bar_window_remove_unused_bars (struct t_gui_window *window); +extern int gui_bar_window_add_missing_bars (struct t_gui_window *window); extern void gui_bar_window_scroll (struct t_gui_bar_window *bar_window, struct t_gui_window *window, int add_x, int scroll_beginning, int scroll_end, int add, int percent, int value); +extern int gui_bar_window_add_to_infolist (struct t_infolist *infolist, + struct t_gui_bar_window *bar_window); +extern void gui_bar_window_print_log (struct t_gui_bar_window *bar_window); /* functions (GUI dependent) */ diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 1030ec59d..129fabe35 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -29,6 +29,7 @@ #include "../core/weechat.h" #include "../core/wee-config.h" +#include "../core/wee-infolist.h" #include "../core/wee-log.h" #include "../core/wee-string.h" #include "../plugins/plugin.h" @@ -59,6 +60,30 @@ struct t_gui_bar *gui_temp_bars = NULL; /* bars used when reading config */ struct t_gui_bar *last_gui_temp_bar = NULL; +/* + * gui_bar_valid: check if a bar pointer exists + * return 1 if bar exists + * 0 if bar is not found + */ + +int +gui_bar_valid (struct t_gui_bar *bar) +{ + struct t_gui_bar *ptr_bar; + + if (!bar) + return 0; + + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if (ptr_bar == bar) + return 1; + } + + /* bar not found */ + return 0; +} + /* * gui_bar_search_option search a bar option name * return index of option in array @@ -265,6 +290,31 @@ gui_bar_get_option_filling (struct t_gui_bar *bar) return bar->filling_left_right; } +/* + * gui_bar_get_item_index: return index of item in bar (position of item in + * items list) + * return -1 if item is not in bar + */ + +int +gui_bar_get_item_index (struct t_gui_bar *bar, const char *item_name) +{ + int i; + + if (!bar || !item_name || !item_name[0]) + return -1; + + for (i = 0; i < bar->items_count; i++) + { + /* skip non letters chars at beginning (prefix) */ + if (gui_bar_item_string_is_item (bar->items_array[i], item_name)) + return i; + } + + /* item is not in bar */ + return -1; +} + /* * gui_bar_find_pos: find position for a bar in list (keeping list sorted * by priority) @@ -1367,7 +1417,6 @@ gui_bar_alloc (const char *name) new_bar = malloc (sizeof (*new_bar)); if (new_bar) { - new_bar->plugin = NULL; new_bar->name = strdup (name); new_bar->hidden = NULL; new_bar->priority = NULL; @@ -1401,7 +1450,7 @@ gui_bar_alloc (const char *name) */ struct t_gui_bar * -gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name, +gui_bar_new_with_options (const char *name, struct t_config_option *hidden, struct t_config_option *priority, struct t_config_option *type, @@ -1424,7 +1473,6 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name, new_bar = gui_bar_alloc (name); if (new_bar) { - new_bar->plugin = plugin; new_bar->hidden = hidden; new_bar->priority = priority; new_bar->type = type; @@ -1493,9 +1541,8 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name, */ struct t_gui_bar * -gui_bar_new (struct t_weechat_plugin *plugin, const char *name, - const char *hidden, const char *priority, const char *type, - const char *conditions, const char *position, +gui_bar_new (const char *name, const char *hidden, const char *priority, + const char *type, const char *conditions, const char *position, const char *filling_top_bottom, const char *filling_left_right, const char *size, const char *size_max, const char *color_fg, const char *color_delim, @@ -1554,7 +1601,7 @@ gui_bar_new (struct t_weechat_plugin *plugin, const char *name, "on" : "off"); option_items = gui_bar_create_option (name, GUI_BAR_OPTION_ITEMS, items); - new_bar = gui_bar_new_with_options (plugin, name, option_hidden, + new_bar = gui_bar_new_with_options (name, option_hidden, option_priority, option_type, option_conditions, option_position, option_filling_top_bottom, @@ -1686,8 +1733,7 @@ gui_bar_use_temp_bars () && ptr_temp_bar->color_bg && ptr_temp_bar->separator && ptr_temp_bar->items) { - gui_bar_new_with_options (NULL, - ptr_temp_bar->name, + gui_bar_new_with_options (ptr_temp_bar->name, ptr_temp_bar->hidden, ptr_temp_bar->priority, ptr_temp_bar->type, @@ -1849,7 +1895,7 @@ gui_bar_create_default_input () gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT], gui_bar_item_names[GUI_BAR_ITEM_INPUT_SEARCH], gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]); - if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_INPUT, + if (gui_bar_new (GUI_BAR_DEFAULT_NAME_INPUT, "0", /* hidden */ "1000", /* priority */ "window", /* type */ @@ -1888,7 +1934,7 @@ gui_bar_create_default_title () if (!ptr_bar) { /* create title bar */ - if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_TITLE, + if (gui_bar_new (GUI_BAR_DEFAULT_NAME_TITLE, "0", /* hidden */ "500", /* priority */ "window", /* type */ @@ -1949,7 +1995,7 @@ gui_bar_create_default_status () gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER], gui_bar_item_names[GUI_BAR_ITEM_COMPLETION], gui_bar_item_names[GUI_BAR_ITEM_SCROLL]); - if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_STATUS, + if (gui_bar_new (GUI_BAR_DEFAULT_NAME_STATUS, "0", /* hidden */ "500", /* priority */ "window", /* type */ @@ -1987,7 +2033,7 @@ gui_bar_create_default_nicklist () if (!ptr_bar) { /* create nicklist bar */ - if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_NICKLIST, + if (gui_bar_new (GUI_BAR_DEFAULT_NAME_NICKLIST, "0", /* hidden */ "200", /* priority */ "window", /* type */ @@ -2229,27 +2275,6 @@ gui_bar_free_all () } } -/* - * gui_bar_free_all_plugin: delete all bars for a plugin - */ - -void -gui_bar_free_all_plugin (struct t_weechat_plugin *plugin) -{ - struct t_gui_bar *ptr_bar, *next_bar; - - ptr_bar = gui_bars; - while (ptr_bar) - { - next_bar = ptr_bar->next_bar; - - if (ptr_bar->plugin == plugin) - gui_bar_free (ptr_bar); - - ptr_bar = next_bar; - } -} - /* * gui_bar_free_bar_windows: free bar windows for a bar */ @@ -2275,6 +2300,80 @@ gui_bar_free_bar_windows (struct t_gui_bar *bar) } } +/* + * gui_bar_add_to_infolist: add a bar in an infolist + * return 1 if ok, 0 if error + */ + +int +gui_bar_add_to_infolist (struct t_infolist *infolist, + struct t_gui_bar *bar) +{ + struct t_infolist_item *ptr_item; + int i; + char option_name[64]; + + if (!infolist || !bar) + return 0; + + ptr_item = infolist_new_item (infolist); + if (!ptr_item) + return 0; + + if (!infolist_new_var_integer (ptr_item, "hidden", CONFIG_INTEGER(bar->hidden))) + return 0; + if (!infolist_new_var_integer (ptr_item, "priority", CONFIG_INTEGER(bar->priority))) + return 0; + if (!infolist_new_var_integer (ptr_item, "type", CONFIG_INTEGER(bar->type))) + return 0; + if (!infolist_new_var_string (ptr_item, "conditions", CONFIG_STRING(bar->conditions))) + return 0; + if (!infolist_new_var_integer (ptr_item, "conditions_count", bar->conditions_count)) + return 0; + for (i = 0; i < bar->conditions_count; i++) + { + snprintf (option_name, sizeof (option_name), + "conditions_array_%05d", i + 1); + if (!infolist_new_var_string (ptr_item, option_name, + bar->conditions_array[i])) + return 0; + } + if (!infolist_new_var_integer (ptr_item, "position", CONFIG_INTEGER(bar->position))) + return 0; + if (!infolist_new_var_integer (ptr_item, "filling_top_bottom", CONFIG_INTEGER(bar->filling_top_bottom))) + return 0; + if (!infolist_new_var_integer (ptr_item, "filling_left_right", CONFIG_INTEGER(bar->filling_left_right))) + return 0; + if (!infolist_new_var_integer (ptr_item, "size", CONFIG_INTEGER(bar->size))) + return 0; + if (!infolist_new_var_integer (ptr_item, "size_max", CONFIG_INTEGER(bar->size_max))) + return 0; + if (!infolist_new_var_string (ptr_item, "color_fg", gui_color_get_name (CONFIG_COLOR(bar->color_fg)))) + return 0; + if (!infolist_new_var_string (ptr_item, "color_delim", gui_color_get_name (CONFIG_COLOR(bar->color_delim)))) + return 0; + if (!infolist_new_var_string (ptr_item, "color_bg", gui_color_get_name (CONFIG_COLOR(bar->color_bg)))) + return 0; + if (!infolist_new_var_integer (ptr_item, "separator", CONFIG_INTEGER(bar->separator))) + return 0; + if (!infolist_new_var_string (ptr_item, "items", CONFIG_STRING(bar->items))) + return 0; + if (!infolist_new_var_integer (ptr_item, "items_count", bar->items_count)) + return 0; + for (i = 0; i < bar->items_count; i++) + { + snprintf (option_name, sizeof (option_name), + "items_array_%05d", i + 1); + if (!infolist_new_var_string (ptr_item, option_name, + bar->items_array[i])) + return 0; + } + if (!infolist_new_var_pointer (ptr_item, "bar_window", bar->bar_window)) + return 0; + + return 1; +} + /* * gui_bar_print_log: print bar infos in log (usually for crash dump) */ @@ -2288,8 +2387,6 @@ gui_bar_print_log () { log_printf (""); log_printf ("[bar (addr:0x%lx)]", ptr_bar); - log_printf (" plugin . . . . . . . . : 0x%lx ('%s')", - ptr_bar->plugin, plugin_get_name (ptr_bar->plugin)); log_printf (" name . . . . . . . . . : '%s'", ptr_bar->name); log_printf (" hidden . . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->hidden)); log_printf (" priority . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->priority)); diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h index a197b8778..38fe5865f 100644 --- a/src/gui/gui-bar.h +++ b/src/gui/gui-bar.h @@ -78,7 +78,6 @@ enum t_gui_bar_filling struct t_gui_bar { /* user choices */ - struct t_weechat_plugin *plugin; /* plugin */ char *name; /* bar name */ struct t_config_option *hidden; /* true if bar is hidden */ struct t_config_option *priority; /* bar priority */ @@ -121,10 +120,13 @@ extern struct t_gui_bar *last_gui_temp_bar; /* functions */ +extern int gui_bar_valid (struct t_gui_bar *bar); extern int gui_bar_search_option (const char *option_name); extern int gui_bar_search_type (const char *type); extern int gui_bar_search_position (const char *position); extern struct t_config_option *gui_bar_get_option_filling (struct t_gui_bar *bar); +extern int gui_bar_get_item_index (struct t_gui_bar *bar, + const char *item_name); extern int gui_bar_check_conditions_for_window (struct t_gui_bar *bar, struct t_gui_window *window); extern int gui_bar_root_get_size (struct t_gui_bar *bar, @@ -136,8 +138,7 @@ extern int gui_bar_set (struct t_gui_bar *bar, const char *property, const char extern void gui_bar_create_option_temp (struct t_gui_bar *temp_bar, int index_option, const char *value); extern struct t_gui_bar *gui_bar_alloc (const char *name); -extern struct t_gui_bar *gui_bar_new (struct t_weechat_plugin *plugin, - const char *name, +extern struct t_gui_bar *gui_bar_new (const char *name, const char *hidden, const char *priority, const char *type, @@ -163,9 +164,9 @@ extern int gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_buffer *buffer, const char *scroll); extern void gui_bar_free (struct t_gui_bar *bar); extern void gui_bar_free_all (); -extern void gui_bar_free_all_plugin (struct t_weechat_plugin *plugin); extern void gui_bar_free_bar_windows (struct t_gui_bar *bar); -extern void gui_bar_window_print_log (struct t_gui_bar_window *bar_window); +extern int gui_bar_add_to_infolist (struct t_infolist *infolist, + struct t_gui_bar *bar); extern void gui_bar_print_log (); #endif /* gui-bar.h */ diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 70079814c..a3ce05be3 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -257,6 +257,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin, { struct t_gui_buffer *new_buffer; struct t_gui_completion *new_completion; + int first_buffer_creation; if (!name) return NULL; @@ -363,24 +364,18 @@ gui_buffer_new (struct t_weechat_plugin *plugin, gui_buffer_local_var_add (new_buffer, "name", name); /* add buffer to buffers list */ + first_buffer_creation = (gui_buffers == NULL); gui_buffer_insert (new_buffer); - /* first buffer creation ? */ - if (!gui_current_window->buffer) - { - gui_current_window->buffer = new_buffer; - gui_current_window->first_line_displayed = 1; - gui_current_window->start_line = NULL; - gui_current_window->start_line_pos = 0; - gui_window_switch_to_buffer (gui_current_window, new_buffer, 0); - } - /* check if this buffer should be assigned to a window, according to windows layout saved */ gui_layout_window_check_buffer (new_buffer); - - hook_signal_send ("buffer_open", - WEECHAT_HOOK_SIGNAL_POINTER, new_buffer); + + if (!first_buffer_creation) + { + hook_signal_send ("buffer_open", + WEECHAT_HOOK_SIGNAL_POINTER, new_buffer); + } } else return NULL; diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index 0c707903b..21d220775 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -129,7 +129,8 @@ gui_window_tree_free (struct t_gui_window_tree **tree) */ struct t_gui_window * -gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height, +gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer, + int x, int y, int width, int height, int width_pct, int height_pct) { struct t_gui_window *new_window; @@ -141,7 +142,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height x, y, width, height); #endif - if (parent) + if (parent_window) { child1 = malloc (sizeof (*child1)); if (!child1) @@ -152,7 +153,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height free (child1); return NULL; } - ptr_tree = parent->ptr_tree; + ptr_tree = parent_window->ptr_tree; if (width_pct == 100) { @@ -168,7 +169,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height /* parent window leaf becomes node and we add 2 leafs below (#1 is parent win, #2 is new win) */ - parent->ptr_tree = child1; + parent_window->ptr_tree = child1; child1->parent_node = ptr_tree; child1->child1 = NULL; child1->child2 = NULL; @@ -225,7 +226,7 @@ gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height new_window->refresh_needed = 0; /* buffer and layout infos */ - new_window->buffer = NULL; + new_window->buffer = buffer; new_window->layout_plugin_name = NULL; new_window->layout_buffer_name = NULL; diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h index 37ad3da65..cee9340db 100644 --- a/src/gui/gui-window.h +++ b/src/gui/gui-window.h @@ -107,7 +107,8 @@ extern int gui_window_tree_init (struct t_gui_window *window); extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *node, struct t_gui_window *window); extern void gui_window_tree_free (struct t_gui_window_tree **tree); -extern struct t_gui_window *gui_window_new (struct t_gui_window *parent, +extern struct t_gui_window *gui_window_new (struct t_gui_window *parent_window, + struct t_gui_buffer *buffer, int x, int y, int width, int height, int width_pct, int height_pct); extern int gui_window_valid (struct t_gui_window *window); diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 0aea6d584..c0a390b7c 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -38,6 +38,9 @@ #include "../core/wee-infolist.h" #include "../core/wee-input.h" #include "../core/wee-string.h" +#include "../gui/gui-bar.h" +#include "../gui/gui-bar-item.h" +#include "../gui/gui-bar-window.h" #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-color.h" @@ -288,6 +291,9 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_infolist *ptr_infolist; + struct t_gui_bar *ptr_bar; + struct t_gui_bar_item *ptr_bar_item; + struct t_gui_bar_window *ptr_bar_window; struct t_gui_buffer *ptr_buffer; struct t_gui_line *ptr_line; struct t_gui_filter *ptr_filter; @@ -300,8 +306,128 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, if (!infolist_name || !infolist_name[0]) return NULL; - - if (string_strcasecmp (infolist_name, "buffer") == 0) + + if (string_strcasecmp (infolist_name, "bar") == 0) + { + /* invalid bar pointer ? */ + if (pointer && (!gui_bar_valid (pointer))) + return NULL; + + ptr_infolist = infolist_new (); + if (ptr_infolist) + { + if (pointer) + { + /* build list with only one bar */ + if (!gui_bar_add_to_infolist (ptr_infolist, pointer)) + { + infolist_free (ptr_infolist); + return NULL; + } + return ptr_infolist; + } + else + { + /* build list with all bars */ + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if (!gui_bar_add_to_infolist (ptr_infolist, ptr_bar)) + { + infolist_free (ptr_infolist); + return NULL; + } + } + return ptr_infolist; + } + } + } + else if (string_strcasecmp (infolist_name, "bar_item") == 0) + { + /* invalid bar item pointer ? */ + if (pointer && (!gui_bar_item_valid (pointer))) + return NULL; + + ptr_infolist = infolist_new (); + if (ptr_infolist) + { + if (pointer) + { + /* build list with only one bar item */ + if (!gui_bar_item_add_to_infolist (ptr_infolist, pointer)) + { + infolist_free (ptr_infolist); + return NULL; + } + return ptr_infolist; + } + else + { + /* build list with all bar items */ + for (ptr_bar_item = gui_bar_items; ptr_bar_item; + ptr_bar_item = ptr_bar_item->next_item) + { + if (!gui_bar_item_add_to_infolist (ptr_infolist, ptr_bar_item)) + { + infolist_free (ptr_infolist); + return NULL; + } + } + return ptr_infolist; + } + } + } + else if (string_strcasecmp (infolist_name, "bar_window") == 0) + { + /* invalid bar window pointer ? */ + if (pointer && (!gui_bar_window_valid (pointer))) + return NULL; + + ptr_infolist = infolist_new (); + if (ptr_infolist) + { + if (pointer) + { + /* build list with only one bar window */ + if (!gui_bar_window_add_to_infolist (ptr_infolist, pointer)) + { + infolist_free (ptr_infolist); + return NULL; + } + return ptr_infolist; + } + else + { + /* build list with all bar windows (from root and window bars) */ + for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) + { + if (ptr_bar->bar_window) + { + if (!gui_bar_window_add_to_infolist (ptr_infolist, ptr_bar->bar_window)) + { + infolist_free (ptr_infolist); + return NULL; + } + } + } + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) + { + for (ptr_bar_window = ptr_window->bar_windows; + ptr_bar_window; + ptr_bar_window = ptr_bar_window->next_bar_window) + { + if (!gui_bar_window_add_to_infolist (ptr_infolist, ptr_bar_window)) + { + infolist_free (ptr_infolist); + return NULL; + } + } + } + return ptr_infolist; + } + } + } + else if (string_strcasecmp (infolist_name, "buffer") == 0) { /* invalid buffer pointer ? */ if (pointer && (!gui_buffer_valid (pointer))) @@ -380,16 +506,12 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, return ptr_infolist; } } - else if (string_strcasecmp (infolist_name, "nicklist") == 0) + else if (string_strcasecmp (infolist_name, "hook") == 0) { - /* invalid buffer pointer ? */ - if (!pointer || (!gui_buffer_valid (pointer))) - return NULL; - ptr_infolist = infolist_new (); if (ptr_infolist) { - if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer)) + if (!hook_add_to_infolist (ptr_infolist, arguments)) { infolist_free (ptr_infolist); return NULL; @@ -397,60 +519,6 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, return ptr_infolist; } } - else if (string_strcasecmp (infolist_name, "window") == 0) - { - /* invalid window pointer ? */ - if (pointer && (!gui_window_valid (pointer))) - return NULL; - - ptr_infolist = infolist_new (); - if (ptr_infolist) - { - if (pointer) - { - /* build list with only one window */ - if (!gui_window_add_to_infolist (ptr_infolist, pointer)) - { - infolist_free (ptr_infolist); - return NULL; - } - return ptr_infolist; - } - else - { - if (arguments && arguments[0]) - { - if ((string_strcasecmp (arguments, "current") == 0) - && gui_current_window) - { - if (!gui_window_add_to_infolist (ptr_infolist, - gui_current_window)) - { - infolist_free (ptr_infolist); - return NULL; - } - return ptr_infolist; - } - return NULL; - } - else - { - /* build list with all windows */ - for (ptr_window = gui_windows; ptr_window; - ptr_window = ptr_window->next_window) - { - if (!gui_window_add_to_infolist (ptr_infolist, - ptr_window)) - { - infolist_free (ptr_infolist); - return NULL; - } - } - return ptr_infolist; - } - } - } - } else if (string_strcasecmp (infolist_name, "hotlist") == 0) { ptr_infolist = infolist_new (); @@ -468,12 +536,16 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, return ptr_infolist; } } - else if (string_strcasecmp (infolist_name, "option") == 0) + else if (string_strcasecmp (infolist_name, "nicklist") == 0) { + /* invalid buffer pointer ? */ + if (!pointer || (!gui_buffer_valid (pointer))) + return NULL; + ptr_infolist = infolist_new (); if (ptr_infolist) { - if (!config_file_add_to_infolist (ptr_infolist, arguments)) + if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer)) { infolist_free (ptr_infolist); return NULL; @@ -481,12 +553,12 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, return ptr_infolist; } } - else if (string_strcasecmp (infolist_name, "hook") == 0) + else if (string_strcasecmp (infolist_name, "option") == 0) { ptr_infolist = infolist_new (); if (ptr_infolist) { - if (!hook_add_to_infolist (ptr_infolist, arguments)) + if (!config_file_add_to_infolist (ptr_infolist, arguments)) { infolist_free (ptr_infolist); return NULL; @@ -529,6 +601,60 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, } } } + else if (string_strcasecmp (infolist_name, "window") == 0) + { + /* invalid window pointer ? */ + if (pointer && (!gui_window_valid (pointer))) + return NULL; + + ptr_infolist = infolist_new (); + if (ptr_infolist) + { + if (pointer) + { + /* build list with only one window */ + if (!gui_window_add_to_infolist (ptr_infolist, pointer)) + { + infolist_free (ptr_infolist); + return NULL; + } + return ptr_infolist; + } + else + { + if (arguments && arguments[0]) + { + if ((string_strcasecmp (arguments, "current") == 0) + && gui_current_window) + { + if (!gui_window_add_to_infolist (ptr_infolist, + gui_current_window)) + { + infolist_free (ptr_infolist); + return NULL; + } + return ptr_infolist; + } + return NULL; + } + else + { + /* build list with all windows */ + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) + { + if (!gui_window_add_to_infolist (ptr_infolist, + ptr_window)) + { + infolist_free (ptr_infolist); + return NULL; + } + } + return ptr_infolist; + } + } + } + } /* infolist not found */ return NULL; @@ -699,22 +825,28 @@ plugin_api_init () &plugin_api_info_get_internal, NULL); /* WeeChat core infolist hooks */ + hook_infolist (NULL, "bar", N_("list of bars"), + &plugin_api_infolist_get_internal, NULL); + hook_infolist (NULL, "bar_item", N_("list of bar items"), + &plugin_api_infolist_get_internal, NULL); + hook_infolist (NULL, "bar_window", N_("list of bar windows"), + &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "buffer", N_("list of buffers"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "buffer_lines", N_("lines of a buffer"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "filter", N_("list of filters"), &plugin_api_infolist_get_internal, NULL); - hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"), - &plugin_api_infolist_get_internal, NULL); - hook_infolist (NULL, "window", N_("list of windows"), + hook_infolist (NULL, "hook", N_("list of hooks"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "hotlist", N_("list of buffers in hotlist"), &plugin_api_infolist_get_internal, NULL); - hook_infolist (NULL, "option", N_("list of options"), + hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"), &plugin_api_infolist_get_internal, NULL); - hook_infolist (NULL, "hook", N_("list of hooks"), + hook_infolist (NULL, "option", N_("list of options"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "plugin", N_("list of plugins"), &plugin_api_infolist_get_internal, NULL); + hook_infolist (NULL, "window", N_("list of windows"), + &plugin_api_infolist_get_internal, NULL); } diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index 9095bca28..7b44e5e2c 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -175,9 +175,9 @@ char * script_ptr2str (void *pointer) { char pointer_str[128]; - + if (!pointer) - return strdup (""); + return strdup ("0x0"); snprintf (pointer_str, sizeof (pointer_str), "0x%lx", (long unsigned int)pointer); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 6a1ad8970..3a07ae3e4 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -496,8 +496,7 @@ struct t_weechat_plugin void (*bar_item_update) (const char *name); void (*bar_item_remove) (struct t_gui_bar_item *item); struct t_gui_bar *(*bar_search) (const char *name); - struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin, - const char *name, + struct t_gui_bar *(*bar_new) (const char *name, const char *hidden, const char *priority, const char *type, @@ -1004,12 +1003,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); __filling_left_right, __size, __size_max, \ __color_fg, __color_delim, __color_bg, \ __separator, __items) \ - weechat_plugin->bar_new(weechat_plugin, __name, __hidden, \ - __priority, __type, __condition, \ - __position, __filling_top_bottom, \ - __filling_left_right, __size, __size_max, \ - __color_fg, __color_delim, __color_bg, \ - __separator, __items) + weechat_plugin->bar_new(__name, __hidden, __priority, __type, \ + __condition, __position, \ + __filling_top_bottom, __filling_left_right, \ + __size, __size_max, __color_fg, \ + __color_delim, __color_bg, __separator, \ + __items) #define weechat_bar_set(__bar, __property, __value) \ weechat_plugin->bar_set(__bar, __property, __value) #define weechat_bar_update(__name) \ -- cgit v1.2.3