titlebar: allow displaying MUC name and MUC jid
`/titlebar use name|jid` -> `/titlebar show|hide name|jid` Fix https://github.com/profanity-im/profanity/issues/1284
This commit is contained in:
@@ -210,7 +210,6 @@ static Autocomplete pgp_sendfile_ac;
|
||||
static Autocomplete tls_ac;
|
||||
static Autocomplete titlebar_ac;
|
||||
static Autocomplete titlebar_show_ac;
|
||||
static Autocomplete titlebar_use_ac;
|
||||
static Autocomplete tls_certpath_ac;
|
||||
static Autocomplete script_ac;
|
||||
static Autocomplete script_show_ac;
|
||||
@@ -825,10 +824,8 @@ cmd_ac_init(void)
|
||||
autocomplete_add(titlebar_show_ac, "encwarn");
|
||||
autocomplete_add(titlebar_show_ac, "resource");
|
||||
autocomplete_add(titlebar_show_ac, "presence");
|
||||
|
||||
titlebar_use_ac = autocomplete_new();
|
||||
autocomplete_add(titlebar_use_ac, "name");
|
||||
autocomplete_add(titlebar_use_ac, "jid");
|
||||
autocomplete_add(titlebar_show_ac, "jid");
|
||||
autocomplete_add(titlebar_show_ac, "name");
|
||||
|
||||
tls_certpath_ac = autocomplete_new();
|
||||
autocomplete_add(tls_certpath_ac, "set");
|
||||
@@ -1256,7 +1253,6 @@ cmd_ac_reset(ProfWin *window)
|
||||
autocomplete_reset(tls_ac);
|
||||
autocomplete_reset(titlebar_ac);
|
||||
autocomplete_reset(titlebar_show_ac);
|
||||
autocomplete_reset(titlebar_use_ac);
|
||||
autocomplete_reset(tls_certpath_ac);
|
||||
autocomplete_reset(console_ac);
|
||||
autocomplete_reset(console_msg_ac);
|
||||
@@ -1405,7 +1401,6 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(tls_ac);
|
||||
autocomplete_free(titlebar_ac);
|
||||
autocomplete_free(titlebar_show_ac);
|
||||
autocomplete_free(titlebar_use_ac);
|
||||
autocomplete_free(tls_certpath_ac);
|
||||
autocomplete_free(script_ac);
|
||||
autocomplete_free(script_show_ac);
|
||||
@@ -3085,11 +3080,6 @@ _titlebar_autocomplete(ProfWin *window, const char *const input, gboolean previo
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/titlebar use", titlebar_use_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/titlebar", titlebar_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
|
||||
@@ -1292,8 +1292,7 @@ static struct cmd_t command_defs[] =
|
||||
parse_args, 1, 2, &cons_titlebar_setting,
|
||||
CMD_SUBFUNCS(
|
||||
{ "show", cmd_titlebar_show_hide },
|
||||
{ "hide", cmd_titlebar_show_hide },
|
||||
{ "use", cmd_titlebar_use }
|
||||
{ "hide", cmd_titlebar_show_hide }
|
||||
)
|
||||
CMD_MAINFUNC(cmd_titlebar)
|
||||
CMD_TAGS(
|
||||
@@ -1301,8 +1300,7 @@ static struct cmd_t command_defs[] =
|
||||
CMD_SYN(
|
||||
"/titlebar up",
|
||||
"/titlebar down",
|
||||
"/titlebar show|hide [encwarn|resource|tls]",
|
||||
"/titlebar use name|jid"
|
||||
"/titlebar show|hide [encwarn|resource|tls]"
|
||||
)
|
||||
CMD_DESC(
|
||||
"Titlebar settings.")
|
||||
@@ -1312,14 +1310,13 @@ static 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." },
|
||||
{ "use name", "In case of a MUC. Use the MUC name as title." },
|
||||
{ "use jid", "In case of a MUC. Use the JID as title." }
|
||||
{ "show name", "In case of a MUC. Show the MUC name in the titlebar." },
|
||||
{ "show jid", "In case of a MUC. Show the JID in the titlebar." }
|
||||
)
|
||||
CMD_EXAMPLES(
|
||||
"/titlebar up",
|
||||
"/titlebar show tls",
|
||||
"/titlebar hide encwarn",
|
||||
"/titlebar use name")
|
||||
"/titlebar hide encwarn")
|
||||
},
|
||||
|
||||
{ "/mainwin",
|
||||
|
||||
@@ -5958,6 +5958,12 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
|
||||
} else if (g_strcmp0(args[1], "presence") == 0) {
|
||||
cons_show("Showing contact presence in titlebar enabled.");
|
||||
prefs_set_boolean(PREF_PRESENCE , TRUE);
|
||||
} else if (g_strcmp0(args[1], "jid") == 0) {
|
||||
cons_show("Showing MUC JID in titlebar as title enabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, TRUE);
|
||||
} else if (g_strcmp0(args[1], "name") == 0) {
|
||||
cons_show("Showing MUC name in titlebar as title enabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_NAME, TRUE);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
@@ -5975,6 +5981,12 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
|
||||
} else if (g_strcmp0(args[1], "presence") == 0) {
|
||||
cons_show("Showing contact presence in titlebar enabled.");
|
||||
prefs_set_boolean(PREF_PRESENCE , FALSE);
|
||||
} else if (g_strcmp0(args[1], "jid") == 0) {
|
||||
cons_show("Showing MUC JID in titlebar as title disabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_JID, FALSE);
|
||||
} else if (g_strcmp0(args[1], "name") == 0) {
|
||||
cons_show("Showing MUC name in titlebar as title disabled.");
|
||||
prefs_set_boolean(PREF_TITLEBAR_MUC_TITLE_NAME, FALSE);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
@@ -5986,31 +5998,6 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_titlebar_use(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
if (args[1] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "use") == 0) {
|
||||
if (g_strcmp0(args[1], "jid") == 0) {
|
||||
cons_show("Using MUC JID in titlebar as title.");
|
||||
prefs_set_string(PREF_TITLEBAR_MUC_TITLE, "jid");
|
||||
} else if (g_strcmp0(args[1], "name") == 0) {
|
||||
cons_show("Using MUC name in titlebar as title.");
|
||||
prefs_set_string(PREF_TITLEBAR_MUC_TITLE, "name");
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_mainwin(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
|
||||
@@ -146,7 +146,6 @@ gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_titlebar_use(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_mainwin(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
Reference in New Issue
Block a user