mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 05:16:38 +02:00
Add new property "short_name" for buffers
This commit is contained in:
@@ -324,6 +324,10 @@ upgrade_weechat_read_cb (int object_id,
|
||||
{
|
||||
if (infolist_integer (infolist, "current_buffer"))
|
||||
upgrade_set_current_buffer = upgrade_current_buffer;
|
||||
upgrade_current_buffer->short_name =
|
||||
(infolist_string (infolist, "short_name")) ?
|
||||
strdup (infolist_string (infolist, "short_name")) :
|
||||
strdup (infolist_string (infolist, "name"));
|
||||
upgrade_current_buffer->plugin_name_for_upgrade =
|
||||
strdup (infolist_string (infolist, "plugin_name"));
|
||||
upgrade_current_buffer->nicklist_case_sensitive =
|
||||
|
||||
@@ -965,7 +965,7 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width, int max_height)
|
||||
{
|
||||
char buf[1024], format[32], *pos_point;
|
||||
char buf[1024], format[32];
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
int names_count, display_name;
|
||||
|
||||
@@ -1027,11 +1027,9 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
|
||||
snprintf (format, sizeof (format) - 1,
|
||||
"%%.%ds",
|
||||
CONFIG_INTEGER(config_look_hotlist_names_length));
|
||||
pos_point = NULL;
|
||||
if (CONFIG_BOOLEAN(config_look_hotlist_short_names))
|
||||
pos_point = strchr (ptr_hotlist->buffer->name, '.');
|
||||
sprintf (buf + strlen (buf), format,
|
||||
(pos_point) ? pos_point + 1 : ptr_hotlist->buffer->name);
|
||||
(CONFIG_BOOLEAN(config_look_hotlist_short_names)) ?
|
||||
ptr_hotlist->buffer->short_name : ptr_hotlist->buffer->name);
|
||||
}
|
||||
|
||||
if (ptr_hotlist->next_hotlist)
|
||||
|
||||
+30
-4
@@ -169,6 +169,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
||||
new_buffer->layout_number = gui_layout_buffer_get_number (plugin_get_name (plugin),
|
||||
name);
|
||||
new_buffer->name = strdup (name);
|
||||
new_buffer->short_name = strdup (name);
|
||||
new_buffer->type = GUI_BUFFER_TYPE_FORMATED;
|
||||
new_buffer->notify = CONFIG_INTEGER(config_look_buffer_notify_default);
|
||||
new_buffer->num_displayed = 0;
|
||||
@@ -351,6 +352,8 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property)
|
||||
return plugin_get_name (buffer->plugin);
|
||||
else if (string_strcasecmp (property, "name") == 0)
|
||||
return buffer->name;
|
||||
else if (string_strcasecmp (property, "short_name") == 0)
|
||||
return buffer->short_name;
|
||||
else if (string_strcasecmp (property, "title") == 0)
|
||||
return buffer->title;
|
||||
}
|
||||
@@ -414,6 +417,24 @@ gui_buffer_set_name (struct t_gui_buffer *buffer, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_set_short_name: set short name for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_set_short_name (struct t_gui_buffer *buffer, const char *short_name)
|
||||
{
|
||||
if (short_name && short_name[0])
|
||||
{
|
||||
if (buffer->short_name)
|
||||
free (buffer->short_name);
|
||||
buffer->short_name = strdup (short_name);
|
||||
|
||||
hook_signal_send ("buffer_renamed",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_set_type: set buffer type
|
||||
*/
|
||||
@@ -609,6 +630,10 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
{
|
||||
gui_buffer_set_name (buffer, value_str);
|
||||
}
|
||||
else if (string_strcasecmp (property, "short_name") == 0)
|
||||
{
|
||||
gui_buffer_set_short_name (buffer, value_str);
|
||||
}
|
||||
else if (string_strcasecmp (property, "type") == 0)
|
||||
{
|
||||
if (string_strcasecmp (value_str, "formated") == 0)
|
||||
@@ -970,6 +995,8 @@ gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another)
|
||||
free (buffer->title);
|
||||
if (buffer->name)
|
||||
free (buffer->name);
|
||||
if (buffer->short_name)
|
||||
free (buffer->short_name);
|
||||
if (buffer->input_buffer)
|
||||
free (buffer->input_buffer);
|
||||
if (buffer->completion)
|
||||
@@ -1183,7 +1210,7 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
struct t_gui_key *ptr_key;
|
||||
char *pos_point, option_name[32];
|
||||
char option_name[32];
|
||||
int i;
|
||||
|
||||
if (!infolist || !buffer)
|
||||
@@ -1207,9 +1234,7 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "name", buffer->name))
|
||||
return 0;
|
||||
pos_point = strchr (buffer->name, '.');
|
||||
if (!infolist_new_var_string (ptr_item, "short_name",
|
||||
(pos_point) ? pos_point + 1 : buffer->name))
|
||||
if (!infolist_new_var_string (ptr_item, "short_name", buffer->short_name))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "type", buffer->type))
|
||||
return 0;
|
||||
@@ -1399,6 +1424,7 @@ gui_buffer_print_log ()
|
||||
log_printf (" number . . . . . . . . : %d", ptr_buffer->number);
|
||||
log_printf (" layout_number. . . . . : %d", ptr_buffer->layout_number);
|
||||
log_printf (" name . . . . . . . . . : '%s'", ptr_buffer->name);
|
||||
log_printf (" short_name . . . . . . : '%s'", ptr_buffer->short_name);
|
||||
log_printf (" type . . . . . . . . . : %d", ptr_buffer->type);
|
||||
log_printf (" notify . . . . . . . . : %d", ptr_buffer->notify);
|
||||
log_printf (" num_displayed. . . . . : %d", ptr_buffer->num_displayed);
|
||||
|
||||
@@ -79,6 +79,7 @@ struct t_gui_buffer
|
||||
int layout_number; /* the number of buffer saved in */
|
||||
/* layout */
|
||||
char *name; /* buffer name */
|
||||
char *short_name; /* short buffer name */
|
||||
enum t_gui_buffer_type type; /* buffer type (formated, free, ..) */
|
||||
int notify; /* 0 = never */
|
||||
/* 1 = highlight only */
|
||||
|
||||
@@ -96,6 +96,8 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
weechat_buffer_set (new_buffer, "short_name", (char *)channel_name);
|
||||
|
||||
weechat_hook_signal_send ("logger_backlog",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
||||
}
|
||||
|
||||
@@ -3136,6 +3136,8 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
}
|
||||
}
|
||||
weechat_buffer_set (irc_current_server->buffer, "short_name",
|
||||
irc_current_server->name);
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -2179,6 +2179,8 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
|
||||
irc_buffer_servers = server->buffer;
|
||||
}
|
||||
|
||||
weechat_buffer_set (server->buffer, "short_name", server->name);
|
||||
|
||||
weechat_buffer_set (server->buffer, "display", "1");
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
|
||||
Reference in New Issue
Block a user