From 136cd966aaf501ad56ae62f8ea043ca084bd391b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Wed, 3 Sep 2014 23:38:30 +0200 Subject: [PATCH] Added a bar item next to nickname when busy/away. --- src/tox-weechat-commands.c | 1 + src/tox-weechat-gui.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/tox-weechat-commands.c b/src/tox-weechat-commands.c index 7e4fdf5..3d4f756 100644 --- a/src/tox-weechat-commands.c +++ b/src/tox-weechat-commands.c @@ -364,6 +364,7 @@ tox_weechat_cmd_status(void *data, struct t_gui_buffer *buffer, return WEECHAT_RC_ERROR; tox_set_user_status(tox, status); + weechat_bar_item_update("away"); return WEECHAT_RC_OK; } diff --git a/src/tox-weechat-gui.c b/src/tox-weechat-gui.c index 8158d1a..1dc3970 100644 --- a/src/tox-weechat-gui.c +++ b/src/tox-weechat-gui.c @@ -8,6 +8,29 @@ #include "tox-weechat.h" #include "tox-weechat-utils.h" +#include "tox-weechat-gui.h" + +char * +bar_item_away(void *data, + struct t_gui_bar_item *item, + struct t_gui_window *window, + struct t_gui_buffer *buffer, + struct t_hashtable *extra_info) +{ + char *status = NULL;; + switch (tox_get_self_user_status(tox)) + { + case TOX_USERSTATUS_BUSY: + status = strdup("busy"); + break; + case TOX_USERSTATUS_AWAY: + status = strdup("away"); + break; + } + + return status; +} + char * bar_item_input_prompt(void *data, struct t_gui_bar_item *item, @@ -39,6 +62,7 @@ bar_item_buffer_plugin(void *data, struct t_gui_bar_item *item, void tox_weechat_gui_init() { + weechat_bar_item_new("away", bar_item_away, NULL); weechat_bar_item_new("input_prompt", bar_item_input_prompt, NULL); weechat_bar_item_new("buffer_plugin", bar_item_buffer_plugin, NULL); }