mirror of
https://github.com/weechat/weechat.git
synced 2026-06-24 20:06:38 +02:00
Add "buffer_title" bar item, and create title bar when using /bar default
This commit is contained in:
+30
-1
@@ -50,7 +50,7 @@ struct t_gui_bar_item *last_gui_bar_item = NULL; /* last bar item */
|
||||
char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
|
||||
{ "input_prompt", "input_text", "time", "buffer_count", "buffer_plugin",
|
||||
"buffer_name", "buffer_filter", "nicklist_count", "scroll", "hotlist",
|
||||
"completion"
|
||||
"completion", "buffer_title"
|
||||
};
|
||||
struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL;
|
||||
struct t_hook *gui_bar_item_timer = NULL;
|
||||
@@ -993,6 +993,28 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_default_buffer_title: default item for buffer title
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_buffer_title (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width, int max_height)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) max_width;
|
||||
(void) max_height;
|
||||
|
||||
if (!window)
|
||||
window = gui_current_window;
|
||||
|
||||
return (window->buffer->title) ?
|
||||
strdup (window->buffer->title) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_timer_cb: timer callback
|
||||
*/
|
||||
@@ -1159,6 +1181,13 @@ gui_bar_item_init ()
|
||||
&gui_bar_item_default_completion, NULL);
|
||||
gui_bar_item_hook ("partial_completion",
|
||||
gui_bar_item_names[GUI_BAR_ITEM_COMPLETION]);
|
||||
|
||||
/* buffer title */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE],
|
||||
&gui_bar_item_default_buffer_title, NULL);
|
||||
gui_bar_item_hook ("buffer_title_changed",
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -33,6 +33,7 @@ enum t_gui_bar_item_weechat
|
||||
GUI_BAR_ITEM_SCROLL,
|
||||
GUI_BAR_ITEM_HOTLIST,
|
||||
GUI_BAR_ITEM_COMPLETION,
|
||||
GUI_BAR_ITEM_BUFFER_TITLE,
|
||||
/* number of bar items */
|
||||
GUI_BAR_NUM_ITEMS,
|
||||
};
|
||||
|
||||
+18
-1
@@ -1656,11 +1656,28 @@ gui_bar_create_default ()
|
||||
"0", buf))
|
||||
{
|
||||
gui_chat_printf (NULL, _("Bar \"%s\" created"),
|
||||
"input");
|
||||
"status");
|
||||
}
|
||||
free (buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* search title bar */
|
||||
ptr_bar = gui_bar_search ("title");
|
||||
if (!ptr_bar)
|
||||
{
|
||||
/* create title bar */
|
||||
if (gui_bar_new (NULL, "title", "0", "0", "window", "",
|
||||
"top", "horizontal", "1", "0",
|
||||
gui_color_get_name (CONFIG_COLOR(config_color_title)),
|
||||
gui_color_get_name (CONFIG_COLOR(config_color_title)),
|
||||
gui_color_get_name (CONFIG_COLOR(config_color_title_bg)),
|
||||
"0", gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE]))
|
||||
{
|
||||
gui_chat_printf (NULL, _("Bar \"%s\" created"),
|
||||
"title");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -392,6 +392,7 @@ gui_buffer_set_title (struct t_gui_buffer *buffer, const char *new_title)
|
||||
free (buffer->title);
|
||||
buffer->title = (new_title && new_title[0]) ? strdup (new_title) : NULL;
|
||||
gui_buffer_ask_title_refresh (buffer, 1);
|
||||
hook_signal_send ("buffer_title_changed", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user