summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-05-16 07:58:52 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-05-16 07:58:52 +0200
commit5c79933faaf0dc6cbc36cf27edde62fd17d08fce (patch)
tree87ccf3f892b91033677e6ec84619740ba71a2f84 /src
parent47f40f961a6ae86130428adfd413ea93e2377717 (diff)
downloadweechat-5c79933faaf0dc6cbc36cf27edde62fd17d08fce.zip
core: add bar item "lag"
This bar item is overridden by the irc bar item with the same name, but it used on relay remote buffers, so that the lag is visible as well.
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui-bar-item.c43
-rw-r--r--src/gui/gui-bar-item.h1
2 files changed, 42 insertions, 2 deletions
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index e53fa4c7d..bfd20720d 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -66,8 +66,8 @@ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
"buffer_name", "buffer_short_name", "buffer_modes", "buffer_filter",
"buffer_zoom", "buffer_nicklist_count", "buffer_nicklist_count_groups",
"buffer_nicklist_count_all", "scroll", "hotlist", "completion",
- "buffer_title", "buffer_nicklist", "window_number", "mouse_status", "away",
- "spacer"
+ "buffer_title", "buffer_nicklist", "window_number", "mouse_status", "lag",
+ "away", "spacer"
};
struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL;
struct t_hook *gui_bar_item_timer = NULL;
@@ -2043,6 +2043,38 @@ gui_bar_item_mouse_status_cb (const void *pointer, void *data,
}
/*
+ * Bar item with buffer lag.
+ */
+
+char *
+gui_bar_item_lag_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
+{
+ const char *lag;
+ char str_lag[1024];
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) item;
+ (void) window;
+ (void) extra_info;
+
+ if (!buffer)
+ return NULL;
+
+ lag = (const char *)hashtable_get (buffer->local_variables, "lag");
+ if (!lag)
+ return NULL;
+
+ snprintf (str_lag, sizeof (str_lag), "%s: %s", _("Lag"), lag);
+ return strdup (str_lag);
+}
+
+/*
* Bar item with away message.
*/
@@ -2489,6 +2521,13 @@ gui_bar_item_init ()
gui_bar_item_hook_signal ("mouse_enabled;mouse_disabled",
gui_bar_item_names[GUI_BAR_ITEM_MOUSE_STATUS]);
+ /* lag */
+ gui_bar_item_new (NULL,
+ gui_bar_item_names[GUI_BAR_ITEM_LAG],
+ &gui_bar_item_lag_cb, NULL, NULL);
+ gui_bar_item_hook_signal ("window_switch;buffer_switch;buffer_localvar_*",
+ gui_bar_item_names[GUI_BAR_ITEM_LAG]);
+
/* away message */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_AWAY],
diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h
index 816a6cb58..ebfdb601a 100644
--- a/src/gui/gui-bar-item.h
+++ b/src/gui/gui-bar-item.h
@@ -46,6 +46,7 @@ enum t_gui_bar_item_weechat
GUI_BAR_ITEM_BUFFER_NICKLIST,
GUI_BAR_ITEM_WINDOW_NUMBER,
GUI_BAR_ITEM_MOUSE_STATUS,
+ GUI_BAR_ITEM_LAG,
GUI_BAR_ITEM_AWAY,
GUI_BAR_ITEM_SPACER,
/* number of bar items */