Added an online/offline indicator in status bar.
This commit is contained in:
parent
5a99af58d6
commit
f001ccb132
4 changed files with 17 additions and 21 deletions
|
@ -19,38 +19,27 @@ bar_item_input_prompt(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
irc_bar_item_buffer_plugin(void *data, struct t_gui_bar_item *item,
|
bar_item_buffer_plugin(void *data, struct t_gui_bar_item *item,
|
||||||
struct t_gui_window *window,
|
struct t_gui_window *window,
|
||||||
struct t_gui_buffer *buffer,
|
struct t_gui_buffer *buffer,
|
||||||
struct t_hashtable *extra_info)
|
struct t_hashtable *extra_info)
|
||||||
{
|
{
|
||||||
char string[512];
|
char string[256];
|
||||||
|
|
||||||
const char *name = weechat_plugin_get_name(weechat_plugin);
|
const char *name = weechat_plugin_get_name(weechat_plugin);
|
||||||
|
|
||||||
char *status = "online"
|
const char *status = tox_weechat_online_status ? "online" : "offline";
|
||||||
|
const char *color = weechat_color(tox_weechat_online_status ? "green" : "red");
|
||||||
|
|
||||||
|
snprintf(string, sizeof(string),
|
||||||
|
"%s %s%s", name, color, status);
|
||||||
|
|
||||||
|
return strdup(string);
|
||||||
snprintf(string, sizeof(string), "%s %s%s",
|
|
||||||
name,
|
|
||||||
weechat_color("
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buf, sizeof (buf), "%s", name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
snprintf (buf, sizeof (buf), "%s", name);
|
|
||||||
}
|
|
||||||
return strdup (buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tox_weechat_gui_init()
|
void tox_weechat_gui_init()
|
||||||
{
|
{
|
||||||
weechat_bar_item_new("input_prompt", bar_item_input_prompt, NULL);
|
weechat_bar_item_new("input_prompt", bar_item_input_prompt, NULL);
|
||||||
|
weechat_bar_item_new("buffer_plugin", bar_item_buffer_plugin, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,13 @@ tox_weechat_do_timer_cb(void *data,
|
||||||
tox_do(tox);
|
tox_do(tox);
|
||||||
weechat_hook_timer(tox_do_interval(tox), 0, 1, tox_weechat_do_timer_cb, data);
|
weechat_hook_timer(tox_do_interval(tox), 0, 1, tox_weechat_do_timer_cb, data);
|
||||||
|
|
||||||
|
int connected = tox_isconnected(tox);
|
||||||
|
if (connected ^ tox_weechat_online_status)
|
||||||
|
{
|
||||||
|
tox_weechat_online_status = connected;
|
||||||
|
weechat_bar_item_update("buffer_plugin");
|
||||||
|
}
|
||||||
|
|
||||||
return WEECHAT_RC_OK;
|
return WEECHAT_RC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ WEECHAT_PLUGIN_LICENSE("MIT");
|
||||||
|
|
||||||
struct t_weechat_plugin *weechat_plugin = NULL;
|
struct t_weechat_plugin *weechat_plugin = NULL;
|
||||||
struct t_gui_buffer *tox_main_buffer = NULL;
|
struct t_gui_buffer *tox_main_buffer = NULL;
|
||||||
int online_status = 0;
|
int tox_weechat_online_status = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[])
|
weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
extern struct t_weechat_plugin *weechat_plugin;
|
extern struct t_weechat_plugin *weechat_plugin;
|
||||||
extern Tox *tox;
|
extern Tox *tox;
|
||||||
extern int online_status;
|
extern int tox_weechat_online_status;
|
||||||
|
|
||||||
extern struct t_gui_buffer *tox_main_buffer;
|
extern struct t_gui_buffer *tox_main_buffer;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue