From a8b12f25975568f3f4d6f8fc383d785bab9b24fa Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 21 Sep 2008 19:32:41 +0200 Subject: [PATCH] Add IRC bar items (buffer name, lag indicator), use bar items from plugins with callback to core items if not found --- po/POTFILES.in | 2 + po/cs.po | 5 +- po/de.po | 5 +- po/es.po | 5 +- po/fr.po | 15 ++- po/hu.po | 5 +- po/ru.po | 5 +- po/srcfiles.cmake | 2 + po/weechat.pot | 5 +- src/gui/gui-bar-item.c | 45 +++++++-- src/gui/gui-bar.c | 2 +- src/gui/gui-buffer.c | 39 +++++--- src/gui/gui-window.c | 51 ++++++++++ src/gui/gui-window.h | 6 ++ src/plugins/irc/CMakeLists.txt | 1 + src/plugins/irc/Makefile.am | 2 + src/plugins/irc/irc-bar-item.c | 164 +++++++++++++++++++++++++++++++ src/plugins/irc/irc-bar-item.h | 25 +++++ src/plugins/irc/irc-buffer.c | 2 +- src/plugins/irc/irc-channel.c | 2 +- src/plugins/irc/irc-color.c | 2 +- src/plugins/irc/irc-completion.c | 2 +- src/plugins/irc/irc-display.c | 2 +- src/plugins/irc/irc-mode.c | 2 + src/plugins/irc/irc-nick.c | 2 +- src/plugins/irc/irc-protocol.c | 12 +-- src/plugins/irc/irc.c | 3 + src/plugins/irc/irc.h | 5 + src/plugins/plugin.c | 7 +- src/plugins/weechat-plugin.h | 18 ++++ 30 files changed, 396 insertions(+), 47 deletions(-) create mode 100644 src/plugins/irc/irc-bar-item.c create mode 100644 src/plugins/irc/irc-bar-item.h diff --git a/po/POTFILES.in b/po/POTFILES.in index d085f4b8c..caf2e2f08 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -98,6 +98,8 @@ ./src/plugins/fifo/fifo.h ./src/plugins/fifo/fifo-info.c ./src/plugins/fifo/fifo-info.h +./src/plugins/irc/irc-bar-item.c +./src/plugins/irc/irc-bar-item.h ./src/plugins/irc/irc-buffer.c ./src/plugins/irc/irc-buffer.h ./src/plugins/irc/irc.c diff --git a/po/cs.po b/po/cs.po index b66fac525..87d7530ca 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-09-18 18:49+0200\n" +"POT-Creation-Date: 2008-09-21 19:29+0200\n" "PO-Revision-Date: 2008-09-17 16:19+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -2205,6 +2205,9 @@ msgstr "%s chyba při čtení FIFO roury, zavírám ji\n" msgid "name of FIFO pipe" msgstr "" +msgid "Lag" +msgstr "" + #, fuzzy, c-format msgid "%s%s: error with IRC server from URL (\"%s\"), ignored" msgstr "%s nevalidní syntaxe pro IRC server ('%s'), ignorován\n" diff --git a/po/de.po b/po/de.po index e0f9a4b9e..35dcc4a96 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-09-18 18:49+0200\n" +"POT-Creation-Date: 2008-09-21 19:29+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -2146,6 +2146,9 @@ msgstr "%s Fehler beim Lesen vom FIFO, FIFO wird geschlossen\n" msgid "name of FIFO pipe" msgstr "" +msgid "Lag" +msgstr "" + # ??? #, fuzzy, c-format msgid "%s%s: error with IRC server from URL (\"%s\"), ignored" diff --git a/po/es.po b/po/es.po index 9776030e0..6fd7ecd17 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-09-18 18:49+0200\n" +"POT-Creation-Date: 2008-09-21 19:29+0200\n" "PO-Revision-Date: 2007-09-19 12:09+0200\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -2124,6 +2124,9 @@ msgstr "%s error al leer la tubería FIFO, cerrándola\n" msgid "name of FIFO pipe" msgstr "" +msgid "Lag" +msgstr "" + #, fuzzy, c-format msgid "%s%s: error with IRC server from URL (\"%s\"), ignored" msgstr "%s sintaxis inválida para el servidor IRC ('%s'), ignorado\n" diff --git a/po/fr.po b/po/fr.po index 550f54ac0..48cc3a202 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-09-18 18:49+0200\n" -"PO-Revision-Date: 2008-09-18 18:50+0200\n" +"POT-Creation-Date: 2008-09-21 19:29+0200\n" +"PO-Revision-Date: 2008-09-21 19:29+0200\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -1023,10 +1023,14 @@ msgstr "" " right: saute à la fenêtre à droite\n" "splith: éclate la fenêtre en deux horizontalement\n" "splitv: éclate la fenêtre en deux verticalement\n" -"resize: redimensionne une fenêtre, la nouvelle taille est pourcentage de la fenêtre parent\n" +"resize: redimensionne une fenêtre, la nouvelle taille est pourcentage " +"de la fenêtre parent\n" " merge: fusionne la fenêtre avec une autre\n" "\n" -"Pour splith et splitv, pct est un pourcentage qui représente la taille de la nouvelle fenêtre, calculée par rapport à la taille de la fenêtre courante. Par exemple 25 signifie créer une fenêtre qui a pour taille: taille_courante / 4" +"Pour splith et splitv, pct est un pourcentage qui représente la taille de la " +"nouvelle fenêtre, calculée par rapport à la taille de la fenêtre courante. " +"Par exemple 25 signifie créer une fenêtre qui a pour taille: " +"taille_courante / 4" msgid "" "Warning: you should now issue /save to write \"save_on_exit\" option in " @@ -2127,6 +2131,9 @@ msgstr "%s%s: erreur d'ouverture du fichier, fermeture" msgid "name of FIFO pipe" msgstr "nom du tube FIFO" +msgid "Lag" +msgstr "Lag" + #, c-format msgid "%s%s: error with IRC server from URL (\"%s\"), ignored" msgstr "%s%s: erreur avec le serveur IRC de l'URL (\"%s\"), ignoré" diff --git a/po/hu.po b/po/hu.po index f7d18ed7b..31b57cf34 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-09-18 18:49+0200\n" +"POT-Creation-Date: 2008-09-21 19:29+0200\n" "PO-Revision-Date: 2007-10-10 18:07+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -2153,6 +2153,9 @@ msgstr "%s hiba a FIFO cső olvasása közben, bezárás\n" msgid "name of FIFO pipe" msgstr "" +msgid "Lag" +msgstr "" + #, fuzzy, c-format msgid "%s%s: error with IRC server from URL (\"%s\"), ignored" msgstr "%s érvénytelen szintaxis az IRC szervernek ('%s'), mellőzve\n" diff --git a/po/ru.po b/po/ru.po index 40cd1c05a..b09b9d93c 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-09-18 18:49+0200\n" +"POT-Creation-Date: 2008-09-21 19:29+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -2158,6 +2158,9 @@ msgstr "%s ошибка чтения FIFO pipe, закрываю его\n" msgid "name of FIFO pipe" msgstr "" +msgid "Lag" +msgstr "" + #, fuzzy, c-format msgid "%s%s: error with IRC server from URL (\"%s\"), ignored" msgstr "%s некорректный синтаксис IRC сервра ('%s'), игнорируется\n" diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake index fccd74776..027d1f01d 100644 --- a/po/srcfiles.cmake +++ b/po/srcfiles.cmake @@ -99,6 +99,8 @@ SET(WEECHAT_SOURCES ./src/plugins/fifo/fifo.h ./src/plugins/fifo/fifo-info.c ./src/plugins/fifo/fifo-info.h +./src/plugins/irc/irc-bar-item.c +./src/plugins/irc/irc-bar-item.h ./src/plugins/irc/irc-buffer.c ./src/plugins/irc/irc-buffer.h ./src/plugins/irc/irc.c diff --git a/po/weechat.pot b/po/weechat.pot index df1b75093..ac611af63 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-09-18 18:49+0200\n" +"POT-Creation-Date: 2008-09-21 19:29+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1814,6 +1814,9 @@ msgstr "" msgid "name of FIFO pipe" msgstr "" +msgid "Lag" +msgstr "" + #, c-format msgid "%s%s: error with IRC server from URL (\"%s\"), ignored" msgstr "" diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index afa74a9c2..c9eadcbbf 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -145,26 +145,49 @@ gui_bar_item_string_is_item (const char *string, const char *item_name) /* * gui_bar_item_search_with_plugin: search a bar item for a plugin + * if exact_plugin == 1, then search only for + * this plugin, otherwise, if plugin is not + * found, function may return item for core + * (plugin == NULL) */ struct t_gui_bar_item * gui_bar_item_search_with_plugin (struct t_weechat_plugin *plugin, + int exact_plugin, const char *item_name) { - struct t_gui_bar_item *ptr_item; + struct t_gui_bar_item *ptr_item, *item_found_plugin; + struct t_gui_bar_item *item_found_without_plugin; if (!item_name || !item_name[0]) return NULL; + item_found_plugin = NULL; + item_found_without_plugin = NULL; + for (ptr_item = gui_bar_items; ptr_item; ptr_item = ptr_item->next_item) { - if ((ptr_item->plugin == plugin) - && (strcmp (ptr_item->name, item_name) == 0)) - return ptr_item; + if (strcmp (ptr_item->name, item_name) == 0) + { + if (ptr_item->plugin == plugin) + { + log_printf("item found 1: %x", ptr_item); + return ptr_item; + } + if (!exact_plugin) + { + if (ptr_item->plugin) + item_found_plugin = ptr_item; + else + item_found_without_plugin = ptr_item; + } + } } - /* bar item not found */ - return NULL; + if (item_found_without_plugin) + return item_found_without_plugin; + + return item_found_plugin; } /* @@ -374,7 +397,9 @@ 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 (item_name); + ptr_item = gui_bar_item_search_with_plugin ((window) ? window->buffer->plugin : NULL, + 0, + item_name); if (ptr_item) { if (ptr_item->build_callback) @@ -490,7 +515,7 @@ gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name, return NULL; /* it's not possible to create 2 bar items with same name for same plugin */ - if (gui_bar_item_search_with_plugin (plugin, name)) + if (gui_bar_item_search_with_plugin (plugin, 1, name)) return NULL; /* create bar item */ @@ -1333,7 +1358,9 @@ gui_bar_item_print_log () { log_printf (""); log_printf ("[bar item (addr:0x%x)]", ptr_item); - log_printf (" plugin . . . . . . . . : 0x%x", ptr_item->plugin); + log_printf (" plugin . . . . . . . . : 0x%x ('%s')", + ptr_item->plugin, + (ptr_item->plugin) ? ptr_item->plugin->name : ""); log_printf (" name . . . . . . . . . : '%s'", ptr_item->name); log_printf (" build_callback . . . . : 0x%x", ptr_item->build_callback); log_printf (" build_callback_data. . : 0x%x", ptr_item->build_callback_data); diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index e07b57173..e31f84352 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -1721,7 +1721,7 @@ gui_bar_create_default () buf = malloc (length); if (buf) { - snprintf (buf, length, "[%s],[%s],[%s],%s,(%s),[%s],[%s],%s,%s", + snprintf (buf, length, "[%s],[%s],[%s],%s,(%s),[lag],[%s],[%s],%s,%s", gui_bar_item_names[GUI_BAR_ITEM_TIME], gui_bar_item_names[GUI_BAR_ITEM_BUFFER_COUNT], gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN], diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index c4241eb8f..cd943b844 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -265,10 +265,15 @@ gui_buffer_set_plugin_for_upgrade (char *name, struct t_weechat_plugin *plugin) int gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property) { - if (string_strcasecmp (property, "notify") == 0) - return buffer->notify; - else if (string_strcasecmp (property, "lines_hidden") == 0) - return buffer->lines_hidden; + if (buffer && property) + { + if (string_strcasecmp (property, "number") == 0) + return buffer->number; + else if (string_strcasecmp (property, "notify") == 0) + return buffer->notify; + else if (string_strcasecmp (property, "lines_hidden") == 0) + return buffer->lines_hidden; + } return 0; } @@ -280,14 +285,17 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property) char * gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property) { - if (string_strcasecmp (property, "plugin") == 0) - return (buffer->plugin) ? buffer->plugin->name : NULL; - else if (string_strcasecmp (property, "name") == 0) - return buffer->name; - else if (string_strcasecmp (property, "title") == 0) - return buffer->title; - else if (string_strcasecmp (property, "nick") == 0) - return buffer->input_nick; + if (buffer && property) + { + if (string_strcasecmp (property, "plugin") == 0) + return (buffer->plugin) ? buffer->plugin->name : NULL; + else if (string_strcasecmp (property, "name") == 0) + return buffer->name; + else if (string_strcasecmp (property, "title") == 0) + return buffer->title; + else if (string_strcasecmp (property, "nick") == 0) + return buffer->input_nick; + } return NULL; } @@ -299,8 +307,11 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property) void * gui_buffer_get_pointer (struct t_gui_buffer *buffer, const char *property) { - if (string_strcasecmp (property, "plugin") == 0) - return buffer->plugin; + if (buffer && property) + { + if (string_strcasecmp (property, "plugin") == 0) + return buffer->plugin; + } return NULL; } diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index d9da78738..6907d337f 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -37,6 +37,7 @@ #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-window.h" @@ -303,6 +304,56 @@ gui_window_valid (struct t_gui_window *window) return 0; } +/* + * gui_window_get_integer: get a window property as integer + */ + +int +gui_window_get_integer (struct t_gui_window *window, const char *property) +{ + if (window && property) + { + } + + return 0; +} + +/* + * gui_window_get_string: get a window property as string + */ + +char * +gui_window_get_string (struct t_gui_window *window, const char *property) +{ + if (window && property) + { + } + + return NULL; +} + +/* + * gui_windowr_get_pointer: get a window property as pointer + */ + +void * +gui_window_get_pointer (struct t_gui_window *window, const char *property) +{ + if (property) + { + if (string_strcasecmp (property, "current") == 0) + return gui_current_window; + + if (window) + { + if (string_strcasecmp (property, "buffer") == 0) + return window->buffer; + } + } + + return NULL; +} + /* * gui_window_free: delete a window */ diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h index 564528d34..441a54a1e 100644 --- a/src/gui/gui-window.h +++ b/src/gui/gui-window.h @@ -123,6 +123,12 @@ extern struct t_gui_window *gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height, int width_pct, int height_pct); extern int gui_window_valid (struct t_gui_window *window); +extern int gui_window_get_integer (struct t_gui_window *window, + const char *property); +extern char *gui_window_get_string (struct t_gui_window *window, + const char *property); +extern void *gui_window_get_pointer (struct t_gui_window *window, + const char *property); extern void gui_window_free (struct t_gui_window *window); extern struct t_gui_window *gui_window_search_by_buffer (struct t_gui_buffer *buffer); extern void gui_window_switch_server (struct t_gui_window *window); diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt index 7ed63016c..4a2b6e250 100644 --- a/src/plugins/irc/CMakeLists.txt +++ b/src/plugins/irc/CMakeLists.txt @@ -16,6 +16,7 @@ ADD_LIBRARY(irc MODULE irc.c irc.h +irc-bar-item.c irc-bar-item.h irc-buffer.c irc-buffer.h irc-channel.c irc-channel.h irc-color.c irc-color.h diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am index f6ff77f85..13648f691 100644 --- a/src/plugins/irc/Makefile.am +++ b/src/plugins/irc/Makefile.am @@ -22,6 +22,8 @@ lib_LTLIBRARIES = irc.la irc_la_SOURCES = irc.c \ irc.h \ + irc-bar-item.c \ + irc-bar-item.h \ irc-buffer.c \ irc-buffer.h \ irc-channel.c \ diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c new file mode 100644 index 000000000..9f8258736 --- /dev/null +++ b/src/plugins/irc/irc-bar-item.c @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2003-2008 by FlashCode + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* irc-bar-item.c: bar items for IRC plugin */ + + +#include +#include +#include + +#include "../weechat-plugin.h" +#include "irc.h" +#include "irc-buffer.h" +#include "irc-config.h" +#include "irc-server.h" +#include "irc-channel.h" + + +/* + * irc_bar_item_buffer_name: bar item with buffer name + */ + +char * +irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + int max_width, int max_height) +{ + char buf[256], buf_name[256], *name; + int number; + struct t_gui_buffer *buffer; + struct t_irc_server *server; + struct t_irc_channel *channel; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) max_width; + (void) max_height; + + if (!window) + window = weechat_current_window; + + buf_name[0] = '\0'; + + buffer = weechat_window_get_pointer (window, "buffer"); + + if (buffer) + { + number = weechat_buffer_get_integer (buffer, "number"); + + irc_buffer_get_server_channel (buffer, &server, &channel); + if (server || channel) + { + if (server && !channel) + { + snprintf (buf_name, sizeof (buf_name), "%s%s[%s%s%s]", + _("server"), + IRC_COLOR_BAR_DELIM, + IRC_COLOR_STATUS_NAME, + server->name, + IRC_COLOR_BAR_DELIM); + } + else + { + if (channel) + { + snprintf (buf_name, sizeof (buf_name), + "%s%s%s/%s%s%s(%s%s%s)", + IRC_COLOR_STATUS_NAME, + server->name, + IRC_COLOR_BAR_DELIM, + IRC_COLOR_STATUS_NAME, + channel->name, + IRC_COLOR_BAR_DELIM, + IRC_COLOR_STATUS_NAME, + channel->modes, + IRC_COLOR_BAR_DELIM); + } + } + } + else + { + name = weechat_buffer_get_string (buffer, "name"); + if (name) + snprintf (buf_name, sizeof (buf_name), "%s", name); + } + + snprintf (buf, sizeof (buf), "%s%d%s:%s%s", + IRC_COLOR_STATUS_NUMBER, + number, + IRC_COLOR_BAR_DELIM, + IRC_COLOR_STATUS_NAME, + buf_name); + return strdup (buf); + } + + return NULL; +} + +/* + * irc_bar_item_lag: bar item with lag value + */ + +char * +irc_bar_item_lag (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + int max_width, int max_height) +{ + char buf[32]; + struct t_gui_buffer *buffer; + struct t_irc_server *server; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) window; + (void) max_width; + (void) max_height; + + buffer = weechat_window_get_pointer (window, "buffer"); + + if (buffer) + { + irc_buffer_get_server_channel (buffer, &server, NULL); + + if (server + && (server->lag >= weechat_config_integer (irc_config_network_lag_min_show) * 1000)) + { + snprintf (buf, sizeof (buf), + "%s: %.1f", + _("Lag"), + ((float)(server->lag)) / 1000); + return strdup (buf); + } + } + + return NULL; +} + +/* + * irc_bar_item_init: initialize IRC bar items + */ + +void +irc_bar_item_init () +{ + weechat_bar_item_new ("buffer_name", &irc_bar_item_buffer_name, NULL); + weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL); +} diff --git a/src/plugins/irc/irc-bar-item.h b/src/plugins/irc/irc-bar-item.h new file mode 100644 index 000000000..749a27301 --- /dev/null +++ b/src/plugins/irc/irc-bar-item.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2003-2008 by FlashCode + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#ifndef __WEECHAT_IRC_BAR_ITEM_H +#define __WEECHAT_IRC_BAR_ITEM_H 1 + +extern void irc_bar_item_init (); + +#endif /* irc-bar_item.h */ diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c index 268f4c7d0..ab3862035 100644 --- a/src/plugins/irc/irc-buffer.c +++ b/src/plugins/irc/irc-buffer.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/* irc-buffer.c: manages buffers for IRC protocol */ +/* irc-buffer.c: manages buffers for IRC plugin */ #include diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index a4ccf0d41..dcc3350df 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/* irc-channel.c: manages a chat (channel or private chat) */ +/* irc-channel.c: manages a chat (channel or private chat) for IRC plugin */ #include diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c index dd2bf28c3..974e20f7e 100644 --- a/src/plugins/irc/irc-color.c +++ b/src/plugins/irc/irc-color.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/* irc-color.c: IRC color decoding/encidong in messages */ +/* irc-color.c: IRC color decoding/encoding in messages */ #include diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index cf28f50c3..6ca570412 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/* irc-command.c: IRC commands managment */ +/* irc-completion.c: completion for IRC commands */ #include diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c index e6c31889a..e1c8a4a61 100644 --- a/src/plugins/irc/irc-display.c +++ b/src/plugins/irc/irc-display.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/* irc-display.c: display functions for IRC */ +/* irc-display.c: display functions for IRC plugin */ #include diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c index 3afaacf5f..e7520253b 100644 --- a/src/plugins/irc/irc-mode.c +++ b/src/plugins/irc/irc-mode.c @@ -206,6 +206,8 @@ irc_mode_channel_set (struct t_irc_server *server, free (str_modes); if (argv) weechat_string_free_exploded (argv); + + weechat_bar_item_update ("buffer_name"); } /* diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index fb68993ec..96312fc58 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/* irc-nick.c: manages nick list for channels */ +/* irc-nick.c: manages nick list for channels for IRC plugin */ #include diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 2871ea445..57db6947c 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -/* irc-protocol.c: description of IRC commands, according to RFC 1459, 2810, - 2811 2812 */ +/* irc-protocol.c: implementation of IRC protocol, according to + RFC 1459, 2810, 2811 2812 */ #ifndef __USE_XOPEN @@ -989,10 +989,10 @@ irc_protocol_cmd_pong (struct t_irc_server *server, const char *command, /* calculate lag (time diff with lag check) */ old_lag = server->lag; gettimeofday (&tv, NULL); - server->lag = (int) weechat_timeval_diff (&(server->lag_check_time), &tv); - /* TODO: update lag indicator */ - //if (old_lag != server->lag) - // gui_status_draw (gui_current_window->buffer, 1); + server->lag = (int) weechat_timeval_diff (&(server->lag_check_time), + &tv); + if (old_lag != server->lag) + weechat_bar_item_update ("lag"); /* schedule next lag check */ server->lag_check_time.tv_sec = 0; diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index f2ada2b7d..d836f02ce 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -24,6 +24,7 @@ #include "../weechat-plugin.h" #include "irc.h" +#include "irc-bar-item.h" #include "irc-command.h" #include "irc-completion.h" #include "irc-config.h" @@ -128,6 +129,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) /* hook completions */ irc_completion_init (); + irc_bar_item_init (); + /* look at arguments */ auto_connect = 1; upgrading = 0; diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h index 4702f6e1f..14b75a6f9 100644 --- a/src/plugins/irc/irc.h +++ b/src/plugins/irc/irc.h @@ -58,6 +58,11 @@ #define IRC_COLOR_NICKLIST_PREFIX3 weechat_color("nicklist_prefix3") #define IRC_COLOR_NICKLIST_PREFIX4 weechat_color("nicklist_prefix4") #define IRC_COLOR_NICKLIST_PREFIX5 weechat_color("nicklist_prefix5") +#define IRC_COLOR_BAR_FG weechat_color("bar_fg") +#define IRC_COLOR_BAR_BG weechat_color("bar_bg") +#define IRC_COLOR_BAR_DELIM weechat_color("bar_delim") +#define IRC_COLOR_STATUS_NUMBER weechat_color("status_number") +#define IRC_COLOR_STATUS_NAME weechat_color("status_name") extern struct t_weechat_plugin *weechat_irc_plugin; extern struct t_hook *irc_hook_timer_check_away; diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 78bb8f732..c08de42ad 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -49,6 +49,7 @@ #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-nicklist.h" +#include "../gui/gui-window.h" #include "plugin.h" #include "plugin-api.h" #include "plugin-config.h" @@ -399,7 +400,11 @@ plugin_load (const char *filename) new_plugin->buffer_get_string = &gui_buffer_get_string; new_plugin->buffer_get_pointer = &gui_buffer_get_pointer; new_plugin->buffer_set = &gui_buffer_set; - + + new_plugin->window_get_integer = &gui_window_get_integer; + new_plugin->window_get_string = &gui_window_get_string; + new_plugin->window_get_pointer = &gui_window_get_pointer; + new_plugin->nicklist_add_group = &gui_nicklist_add_group; new_plugin->nicklist_search_group = &gui_nicklist_search_group; new_plugin->nicklist_add_nick = &gui_nicklist_add_nick; diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 43066d8cf..de2c7c567 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -415,6 +415,14 @@ struct t_weechat_plugin const char *property); void (*buffer_set) (struct t_gui_buffer *buffer, const char *property, void *value); + + /* windows */ + int (*window_get_integer) (struct t_gui_window *window, + const char *property); + char *(*window_get_string) (struct t_gui_window *window, + const char *property); + void *(*window_get_pointer) (struct t_gui_window *window, + const char *property); /* nicklist */ struct t_gui_nick_group *(*nicklist_add_group) (struct t_gui_buffer *buffer, @@ -890,6 +898,16 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); #define weechat_buffer_set(__buffer, __property, __value) \ weechat_plugin->buffer_set(__buffer, __property, __value) +/* windows */ +#define weechat_window_get_integer(__window, __property) \ + weechat_plugin->window_get_integer(__window, __property) +#define weechat_window_get_string(__window, __property) \ + weechat_plugin->window_get_string(__window, __property) +#define weechat_window_get_pointer(__window, __property) \ + weechat_plugin->window_get_pointer(__window, __property) +#define weechat_current_window \ + weechat_plugin->window_get_pointer(NULL, "current") + /* nicklist */ #define weechat_nicklist_add_group(__buffer, __parent_group, __name, \ __color, __visible) \