aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-01-23 19:42:22 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-01-23 19:42:22 +0100
commit56b7482b0817e33286d5a941c0811d05514377d4 (patch)
tree3b5932d109743ceb37cf031cc885d0eff909ef2e /src/command
parent0401412c64d1a871d472d8cd5f04c89968027a5b (diff)
downloadprofani-tty-56b7482b0817e33286d5a941c0811d05514377d4.tar.gz
Add option to display MUC name or JID in titlebar
Add `/titlebar use [name|jid]`.
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c13
-rw-r--r--src/command/cmd_defs.c14
-rw-r--r--src/command/cmd_funcs.c25
-rw-r--r--src/command/cmd_funcs.h1
4 files changed, 49 insertions, 4 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 6fa92792..db885ceb 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -205,6 +205,7 @@ static Autocomplete pgp_log_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;
@@ -791,6 +792,7 @@ cmd_ac_init(void)
autocomplete_add(titlebar_ac, "down");
autocomplete_add(titlebar_ac, "show");
autocomplete_add(titlebar_ac, "hide");
+ autocomplete_add(titlebar_ac, "use");
titlebar_show_ac = autocomplete_new();
autocomplete_add(titlebar_show_ac, "tls");
@@ -798,6 +800,10 @@ cmd_ac_init(void)
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");
+
tls_certpath_ac = autocomplete_new();
autocomplete_add(tls_certpath_ac, "set");
autocomplete_add(tls_certpath_ac, "clear");
@@ -1202,6 +1208,7 @@ 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);
@@ -1343,6 +1350,7 @@ 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);
@@ -2964,6 +2972,11 @@ _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;
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 5e3e556a..3ed8213e 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1293,7 +1293,8 @@ 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 }
+ { "hide", cmd_titlebar_show_hide },
+ { "use", cmd_titlebar_use }
)
CMD_MAINFUNC(cmd_titlebar)
CMD_TAGS(
@@ -1301,7 +1302,9 @@ static struct cmd_t command_defs[] =
CMD_SYN(
"/titlebar up",
"/titlebar down",
- "/titlebar show|hide [encwarn|resource|tls]")
+ "/titlebar show|hide [encwarn|resource|tls]",
+ "/titlebar use [name|jid]"
+ )
CMD_DESC(
"Titlebar settings.")
CMD_ARGS(
@@ -1309,12 +1312,15 @@ static struct cmd_t command_defs[] =
{ "down", "Move the title bar down the screen." },
{ "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 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." }
)
CMD_EXAMPLES(
"/titlebar up",
"/titlebar show tls",
- "/titlebar hide encwarn")
+ "/titlebar hide encwarn",
+ "/titlebar use name")
},
{ "/mainwin",
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 2c85251e..d9fc0ed6 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -5943,6 +5943,31 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
}
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)
{
if (g_strcmp0(args[0], "up") == 0) {
diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h
index 4ce1e284..74cab615 100644
--- a/src/command/cmd_funcs.h
+++ b/src/command/cmd_funcs.h
@@ -146,6 +146,7 @@ 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);