core: add variable "gui_buffers_count", use it in bar item "buffer_count"
Now the bar item "buffer_count" displays the number of opened buffers (each merged buffer counts 1).
This commit is contained in:
parent
a496db78aa
commit
4c59f2bf5e
@ -949,8 +949,7 @@ gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item,
|
|||||||
(void) buffer;
|
(void) buffer;
|
||||||
(void) extra_info;
|
(void) extra_info;
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf), "%d",
|
snprintf (buf, sizeof (buf), "%d", gui_buffers_count);
|
||||||
(last_gui_buffer) ? last_gui_buffer->number : 0);
|
|
||||||
|
|
||||||
return strdup (buf);
|
return strdup (buf);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
|
|
||||||
struct t_gui_buffer *gui_buffers = NULL; /* first buffer */
|
struct t_gui_buffer *gui_buffers = NULL; /* first buffer */
|
||||||
struct t_gui_buffer *last_gui_buffer = NULL; /* last buffer */
|
struct t_gui_buffer *last_gui_buffer = NULL; /* last buffer */
|
||||||
|
int gui_buffers_count = 0; /* number of buffers */
|
||||||
|
|
||||||
/* history of last visited buffers */
|
/* history of last visited buffers */
|
||||||
struct t_gui_buffer_visited *gui_buffers_visited = NULL;
|
struct t_gui_buffer_visited *gui_buffers_visited = NULL;
|
||||||
@ -493,8 +494,9 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
|||||||
|
|
||||||
/* create new buffer */
|
/* create new buffer */
|
||||||
new_buffer = malloc (sizeof (*new_buffer));
|
new_buffer = malloc (sizeof (*new_buffer));
|
||||||
if (new_buffer)
|
if (!new_buffer)
|
||||||
{
|
return NULL;
|
||||||
|
|
||||||
/* init buffer */
|
/* init buffer */
|
||||||
new_buffer->plugin = plugin;
|
new_buffer->plugin = plugin;
|
||||||
new_buffer->plugin_name_for_upgrade = NULL;
|
new_buffer->plugin_name_for_upgrade = NULL;
|
||||||
@ -618,6 +620,8 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
|||||||
first_buffer_creation = (gui_buffers == NULL);
|
first_buffer_creation = (gui_buffers == NULL);
|
||||||
gui_buffer_insert (new_buffer);
|
gui_buffer_insert (new_buffer);
|
||||||
|
|
||||||
|
gui_buffers_count++;
|
||||||
|
|
||||||
/* set notify level */
|
/* set notify level */
|
||||||
new_buffer->notify = gui_buffer_notify_get (new_buffer);
|
new_buffer->notify = gui_buffer_notify_get (new_buffer);
|
||||||
|
|
||||||
@ -633,9 +637,6 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
|||||||
hook_signal_send ("buffer_opened",
|
hook_signal_send ("buffer_opened",
|
||||||
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return new_buffer;
|
return new_buffer;
|
||||||
}
|
}
|
||||||
@ -2417,6 +2418,9 @@ gui_buffer_close (struct t_gui_buffer *buffer)
|
|||||||
if (gui_buffer_last_displayed == buffer)
|
if (gui_buffer_last_displayed == buffer)
|
||||||
gui_buffer_last_displayed = NULL;
|
gui_buffer_last_displayed = NULL;
|
||||||
|
|
||||||
|
if (gui_buffers_count > 0)
|
||||||
|
gui_buffers_count--;
|
||||||
|
|
||||||
hook_signal_send ("buffer_closed",
|
hook_signal_send ("buffer_closed",
|
||||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||||
|
|
||||||
@ -3876,6 +3880,7 @@ gui_buffer_print_log ()
|
|||||||
log_printf ("");
|
log_printf ("");
|
||||||
log_printf ("gui_buffers . . . . . . . . . : 0x%lx", gui_buffers);
|
log_printf ("gui_buffers . . . . . . . . . : 0x%lx", gui_buffers);
|
||||||
log_printf ("last_gui_buffer . . . . . . . : 0x%lx", last_gui_buffer);
|
log_printf ("last_gui_buffer . . . . . . . : 0x%lx", last_gui_buffer);
|
||||||
|
log_printf ("gui_buffers_count . . . . . . : %d", gui_buffers_count);
|
||||||
log_printf ("gui_buffers_visited . . . . . : 0x%lx", gui_buffers_visited);
|
log_printf ("gui_buffers_visited . . . . . : 0x%lx", gui_buffers_visited);
|
||||||
log_printf ("last_gui_buffer_visited . . . : 0x%lx", last_gui_buffer_visited);
|
log_printf ("last_gui_buffer_visited . . . : 0x%lx", last_gui_buffer_visited);
|
||||||
log_printf ("gui_buffers_visited_index . . : %d", gui_buffers_visited_index);
|
log_printf ("gui_buffers_visited_index . . : %d", gui_buffers_visited_index);
|
||||||
|
@ -204,6 +204,7 @@ struct t_gui_buffer_visited
|
|||||||
|
|
||||||
extern struct t_gui_buffer *gui_buffers;
|
extern struct t_gui_buffer *gui_buffers;
|
||||||
extern struct t_gui_buffer *last_gui_buffer;
|
extern struct t_gui_buffer *last_gui_buffer;
|
||||||
|
extern int gui_buffers_count;
|
||||||
extern struct t_gui_buffer_visited *gui_buffers_visited;
|
extern struct t_gui_buffer_visited *gui_buffers_visited;
|
||||||
extern struct t_gui_buffer_visited *last_gui_buffer_visited;
|
extern struct t_gui_buffer_visited *last_gui_buffer_visited;
|
||||||
extern int gui_buffers_visited_index;
|
extern int gui_buffers_visited_index;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user