about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-11-05 20:51:27 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-11-05 20:51:27 +0100
commit3d272f02bce39babe943a71bf6df4d9539fc787c (patch)
tree8d95e581f7c71723ac3a64bcf67ed76c793d0632
parentfc6f2755c1cb65436df1a1e2a12e6f2de99183a9 (diff)
downloadprofani-tty-3d272f02bce39babe943a71bf6df4d9539fc787c.tar.gz
Add `/titlebar show resource` command
Additionally to `/resource titlebar on` we now allow the setting via
/titlebar show|hide resource` since it's about the titlebar.

But makes sense to have it in `/resource` too because there is
`/resource message on|off` too. And this one doesnt have an setting of
it's own.

Regards https://github.com/profanity-im/profanity/issues/1116
-rw-r--r--src/command/cmd_ac.c1
-rw-r--r--src/command/cmd_defs.c5
-rw-r--r--src/command/cmd_funcs.c7
3 files changed, 10 insertions, 3 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 94e6f221..f8aa2e21 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -776,6 +776,7 @@ cmd_ac_init(void)
     titlebar_show_ac = autocomplete_new();
     autocomplete_add(titlebar_show_ac, "tls");
     autocomplete_add(titlebar_show_ac, "encwarn");
+    autocomplete_add(titlebar_show_ac, "resource");
 
     tls_certpath_ac = autocomplete_new();
     autocomplete_add(tls_certpath_ac, "set");
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index d1b1d4c1..f10b5b33 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1319,14 +1319,15 @@ static struct cmd_t command_defs[] =
         CMD_SYN(
             "/titlebar up",
             "/titlebar down",
-            "/titlebar show|hide [tls|encwarn]")
+            "/titlebar show|hide [encwarn|resource|tls]")
         CMD_DESC(
             "Titlebar settings.")
         CMD_ARGS(
             { "up", "Move the title bar up the screen." },
             { "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 encwarn", "Enable or disable the unencrypted warning message in the titlebar." },
+            { "show resource", "Show or hide the current resource in the titlebar." }
             )
         CMD_EXAMPLES(
             "/titlebar up",
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 5eec7016..32474650 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -3136,7 +3136,6 @@ cmd_blocked(ProfWin *window, const char *const command, gchar **args)
     return TRUE;
 }
 
-
 gboolean
 cmd_resource(ProfWin *window, const char *const command, gchar **args)
 {
@@ -5958,6 +5957,9 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
             } else if (g_strcmp0(args[1], "encwarn") == 0) {
                 cons_show("Encryption warning titlebar indicator enabled.");
                 prefs_set_boolean(PREF_ENC_WARN, TRUE);
+            } else if (g_strcmp0(args[1], "resource") == 0) {
+                cons_show("Showing resource in titlebar enabled.");
+                prefs_set_boolean(PREF_RESOURCE_TITLE , TRUE);
             } else {
                 cons_bad_cmd_usage(command);
             }
@@ -5969,6 +5971,9 @@ cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args)
             } else if (g_strcmp0(args[1], "encwarn") == 0) {
                 cons_show("Encryption warning titlebar indicator disabled.");
                 prefs_set_boolean(PREF_ENC_WARN, FALSE);
+            } else if (g_strcmp0(args[1], "resource") == 0) {
+                cons_show("Showing resource in titlebar disabled.");
+                prefs_set_boolean(PREF_RESOURCE_TITLE , FALSE);
             } else {
                 cons_bad_cmd_usage(command);
             }