about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-03-24 22:13:14 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-03-24 22:22:16 +0100
commitf13168005512fe4219741d9daf83681dd9ed3d63 (patch)
treea6a9697bc8f9580fb4689d3a423e9a29e5308ef9 /src/command
parentfd090d384da14a6fe65cfb4ecb23f02c29d10eba (diff)
downloadprofani-tty-f13168005512fe4219741d9daf83681dd9ed3d63.tar.gz
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
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c14
-rw-r--r--src/command/cmd_defs.c13
-rw-r--r--src/command/cmd_funcs.c37
-rw-r--r--src/command/cmd_funcs.h1
4 files changed, 19 insertions, 46 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 0266d8f5..652b9b16 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -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;
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 3845b901..21e8f6f5 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -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",
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index cee58c7a..83671bd3 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -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);
             }
@@ -5987,31 +5999,6 @@ 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 bcb633d2..4b7b6017 100644
--- a/src/command/cmd_funcs.h
+++ b/src/command/cmd_funcs.h
@@ -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);