Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MUC title behaviour for roster, statusbar, and titlebar #1892

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 51 additions & 28 deletions src/command/cmd_ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ static Autocomplete roster_presence_ac;
static Autocomplete roster_char_ac;
static Autocomplete roster_remove_all_ac;
static Autocomplete roster_room_ac;
static Autocomplete roster_room_show_ac;
static Autocomplete roster_room_use_ac;
static Autocomplete roster_room_title_ac;
static Autocomplete roster_room_position_ac;
static Autocomplete roster_room_by_ac;
static Autocomplete roster_room_order_ac;
Expand Down Expand Up @@ -241,6 +240,8 @@ static Autocomplete ox_log_ac;
#endif
static Autocomplete tls_ac;
static Autocomplete titlebar_ac;
static Autocomplete titlebar_room_ac;
static Autocomplete titlebar_room_title_ac;
static Autocomplete titlebar_show_ac;
static Autocomplete tls_certpath_ac;
static Autocomplete script_ac;
Expand All @@ -262,6 +263,7 @@ static Autocomplete statusbar_ac;
static Autocomplete statusbar_self_ac;
static Autocomplete statusbar_chat_ac;
static Autocomplete statusbar_room_ac;
static Autocomplete statusbar_room_title_ac;
static Autocomplete statusbar_show_ac;
static Autocomplete statusbar_tabmode_ac;
static Autocomplete clear_ac;
Expand Down Expand Up @@ -601,20 +603,17 @@ cmd_ac_init(void)
autocomplete_add(roster_room_ac, "order");
autocomplete_add(roster_room_ac, "unread");
autocomplete_add(roster_room_ac, "private");
autocomplete_add(roster_room_ac, "show");
autocomplete_add(roster_room_ac, "hide");
autocomplete_add(roster_room_ac, "use");

roster_room_show_ac = autocomplete_new();
autocomplete_add(roster_room_show_ac, "server");
autocomplete_add(roster_room_ac, "title");

roster_room_by_ac = autocomplete_new();
autocomplete_add(roster_room_by_ac, "service");
autocomplete_add(roster_room_by_ac, "none");

roster_room_use_ac = autocomplete_new();
autocomplete_add(roster_room_use_ac, "jid");
autocomplete_add(roster_room_use_ac, "name");
roster_room_title_ac = autocomplete_new();
autocomplete_add(roster_room_title_ac, "bookmark");
autocomplete_add(roster_room_title_ac, "jid");
autocomplete_add(roster_room_title_ac, "localpart");
autocomplete_add(roster_room_title_ac, "name");

roster_room_order_ac = autocomplete_new();
autocomplete_add(roster_room_order_ac, "name");
Expand Down Expand Up @@ -941,14 +940,22 @@ cmd_ac_init(void)
autocomplete_add(titlebar_ac, "down");
autocomplete_add(titlebar_ac, "show");
autocomplete_add(titlebar_ac, "hide");
autocomplete_add(titlebar_ac, "room");

titlebar_room_ac = autocomplete_new();
autocomplete_add(titlebar_room_ac, "title");

titlebar_room_title_ac = autocomplete_new();
autocomplete_add(titlebar_room_title_ac, "bookmark");
autocomplete_add(titlebar_room_title_ac, "jid");
autocomplete_add(titlebar_room_title_ac, "localpart");
autocomplete_add(titlebar_room_title_ac, "name");

titlebar_show_ac = autocomplete_new();
autocomplete_add(titlebar_show_ac, "tls");
autocomplete_add(titlebar_show_ac, "encwarn");
autocomplete_add(titlebar_show_ac, "resource");
autocomplete_add(titlebar_show_ac, "presence");
autocomplete_add(titlebar_show_ac, "jid");
autocomplete_add(titlebar_show_ac, "name");

tls_certpath_ac = autocomplete_new();
autocomplete_add(tls_certpath_ac, "set");
Expand Down Expand Up @@ -1046,8 +1053,13 @@ cmd_ac_init(void)
autocomplete_add(statusbar_chat_ac, "jid");

statusbar_room_ac = autocomplete_new();
autocomplete_add(statusbar_room_ac, "room");
autocomplete_add(statusbar_room_ac, "jid");
autocomplete_add(statusbar_room_ac, "title");

statusbar_room_title_ac = autocomplete_new();
autocomplete_add(statusbar_room_title_ac, "bookmark");
autocomplete_add(statusbar_room_title_ac, "jid");
autocomplete_add(statusbar_room_title_ac, "localpart");
autocomplete_add(statusbar_room_title_ac, "name");

statusbar_show_ac = autocomplete_new();
autocomplete_add(statusbar_show_ac, "name");
Expand Down Expand Up @@ -1611,8 +1623,7 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(roster_count_ac);
autocomplete_reset(roster_order_ac);
autocomplete_reset(roster_room_ac);
autocomplete_reset(roster_room_show_ac);
autocomplete_reset(roster_room_use_ac);
autocomplete_reset(roster_room_title_ac);
autocomplete_reset(roster_room_by_ac);
autocomplete_reset(roster_unread_ac);
autocomplete_reset(roster_room_position_ac);
Expand Down Expand Up @@ -1672,6 +1683,8 @@ cmd_ac_reset(ProfWin* window)
#endif
autocomplete_reset(tls_ac);
autocomplete_reset(titlebar_ac);
autocomplete_reset(titlebar_room_ac);
autocomplete_reset(titlebar_room_title_ac);
autocomplete_reset(titlebar_show_ac);
autocomplete_reset(tls_certpath_ac);
autocomplete_reset(console_ac);
Expand All @@ -1687,6 +1700,7 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(statusbar_self_ac);
autocomplete_reset(statusbar_chat_ac);
autocomplete_reset(statusbar_room_ac);
autocomplete_reset(statusbar_room_title_ac);
autocomplete_reset(statusbar_show_ac);
autocomplete_reset(statusbar_tabmode_ac);
autocomplete_reset(clear_ac);
Expand Down Expand Up @@ -1794,8 +1808,7 @@ cmd_ac_uninit(void)
autocomplete_free(roster_count_ac);
autocomplete_free(roster_order_ac);
autocomplete_free(roster_room_ac);
autocomplete_free(roster_room_show_ac);
autocomplete_free(roster_room_use_ac);
autocomplete_free(roster_room_title_ac);
autocomplete_free(roster_room_by_ac);
autocomplete_free(roster_unread_ac);
autocomplete_free(roster_room_position_ac);
Expand Down Expand Up @@ -1853,6 +1866,8 @@ cmd_ac_uninit(void)
#endif
autocomplete_free(tls_ac);
autocomplete_free(titlebar_ac);
autocomplete_free(titlebar_room_ac);
autocomplete_free(titlebar_room_title_ac);
autocomplete_free(titlebar_show_ac);
autocomplete_free(tls_certpath_ac);
autocomplete_free(script_ac);
Expand All @@ -1874,6 +1889,7 @@ cmd_ac_uninit(void)
autocomplete_free(statusbar_self_ac);
autocomplete_free(statusbar_chat_ac);
autocomplete_free(statusbar_room_ac);
autocomplete_free(statusbar_room_title_ac);
autocomplete_free(statusbar_show_ac);
autocomplete_free(statusbar_tabmode_ac);
autocomplete_free(clear_ac);
Expand Down Expand Up @@ -2265,15 +2281,7 @@ _roster_autocomplete(ProfWin* window, const char* const input, gboolean previous
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster room show", roster_room_show_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster room hide", roster_room_show_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster room use", roster_room_use_ac, TRUE, previous);
result = autocomplete_param_with_ac(input, "/roster room title", roster_room_title_ac, TRUE, previous);
if (result) {
return result;
}
Expand Down Expand Up @@ -3549,6 +3557,16 @@ _titlebar_autocomplete(ProfWin* window, const char* const input, gboolean previo
{
char* result = NULL;

result = autocomplete_param_with_ac(input, "/titlebar room title", titlebar_room_title_ac, TRUE, previous);
if (result) {
return result;
}

result = autocomplete_param_with_ac(input, "/titlebar room", titlebar_room_ac, TRUE, previous);
if (result) {
return result;
}

result = autocomplete_param_with_ac(input, "/titlebar show", titlebar_show_ac, TRUE, previous);
if (result) {
return result;
Expand Down Expand Up @@ -4130,6 +4148,11 @@ _statusbar_autocomplete(ProfWin* window, const char* const input, gboolean previ
}

found = autocomplete_param_with_ac(input, "/statusbar room", statusbar_room_ac, TRUE, previous);
if (found) {
return found;
}

found = autocomplete_param_with_ac(input, "/statusbar room title", statusbar_room_title_ac, TRUE, previous);

return found;
}
Expand Down
26 changes: 11 additions & 15 deletions src/command/cmd_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ static const struct cmd_t command_defs[] = {
"/roster room by service|none",
"/roster room order name|unread",
"/roster room unread before|after|off",
"/roster room show server",
"/roster room hide server",
"/roster room use name|jid",
"/roster room title bookmark|jid|localpart|name",
"/roster private room|group|off",
"/roster private char <char>|none",
"/roster header char <char>|none",
Expand Down Expand Up @@ -349,10 +347,7 @@ static const struct cmd_t command_defs[] = {
{ "room unread before", "Show unread message count before room." },
{ "room unread after", "Show unread message count after room." },
{ "room unread off", "Do not show unread message count for rooms." },
{ "room show server", "Show the conference server with room JIDs." },
{ "room hide server", "Do not show the conference server with room JIDs." },
{ "room use name", "Use the MUC name as room name." },
{ "room use jid", "Use the JID as room name." },
{ "room title bookmark|jid|localpart|name", "Display the bookmark name, JID, JID localpart, or room name as the roster title for MUCs." },
{ "private room", "Show room private chats with the room." },
{ "private group", "Show room private chats as a separate roster group." },
{ "private off", "Do not show room private chats." },
Expand Down Expand Up @@ -1241,7 +1236,7 @@ static const struct cmd_t command_defs[] = {


{ CMD_PREAMBLE("/titlebar",
parse_args, 1, 2, &cons_titlebar_setting)
parse_args, 1, 3, &cons_titlebar_setting)
CMD_SUBFUNCS(
{ "show", cmd_titlebar_show_hide },
{ "hide", cmd_titlebar_show_hide })
Expand All @@ -1251,7 +1246,8 @@ static const struct cmd_t command_defs[] = {
CMD_SYN(
"/titlebar up",
"/titlebar down",
"/titlebar show|hide [encwarn|resource|tls]")
"/titlebar show|hide encwarn|resource|tls",
"/titlebar room title bookmark|jid|localpart|name")
CMD_DESC(
"Titlebar settings.")
CMD_ARGS(
Expand All @@ -1260,12 +1256,12 @@ static const struct cmd_t command_defs[] = {
{ "show tls", "Show or hide TLS indicator in the titlebar." },
{ "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." },
{ "show resource", "Show or hide the current resource in the titlebar." },
{ "show name", "Show the nickname or MUC name in the titlebar." },
{ "show jid", "Show the JID in the titlebar." })
{ "room title bookmark|jid|localpart|name", "Display the bookmark name, JID, JID localpart, or room name as the MUC window title." })
CMD_EXAMPLES(
"/titlebar up",
"/titlebar show tls",
"/titlebar hide encwarn")
"/titlebar hide encwarn",
"/titlebar room title localpart")
},

{ CMD_PREAMBLE("/mainwin",
Expand All @@ -1284,7 +1280,7 @@ static const struct cmd_t command_defs[] = {
},

{ CMD_PREAMBLE("/statusbar",
parse_args, 1, 2, &cons_statusbar_setting)
parse_args, 1, 3, &cons_statusbar_setting)
CMD_MAINFUNC(cmd_statusbar)
CMD_TAGS(
CMD_TAG_UI)
Expand All @@ -1296,7 +1292,7 @@ static const struct cmd_t command_defs[] = {
"/statusbar tabmode default|actlist",
"/statusbar self user|barejid|fulljid|off",
"/statusbar chat user|jid",
"/statusbar room room|jid",
"/statusbar room title bookmark|jid|localpart|name",
"/statusbar up",
"/statusbar down")
CMD_DESC(
Expand All @@ -1311,7 +1307,7 @@ static const struct cmd_t command_defs[] = {
{ "self user|barejid|fulljid", "Show account user name, barejid, fulljid as status bar title." },
{ "self off", "Disable showing self as status bar title." },
{ "chat user|jid", "Show users name, or fulljid. Change needs a redraw/restart to take effect." },
{ "room room|jid", "Show room name, or the fulljid for room tabs." },
{ "room title bookmark|jid|localpart|name", "Display the bookmark name, JID, JID localpart, or room name as the title for MUC tabs." },
{ "up", "Move the status bar up the screen." },
{ "down", "Move the status bar down the screen." })
CMD_EXAMPLES(
Expand Down
Loading