diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-11-05 20:39:33 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-11-05 20:39:33 +0100 |
commit | fc6f2755c1cb65436df1a1e2a12e6f2de99183a9 (patch) | |
tree | 55ba4a99d3f7fa99b7119abe959466fbcbf64478 /src/command | |
parent | 5490d148b957d3d614c914a09d77c43d2a6aa6d9 (diff) | |
download | profani-tty-fc6f2755c1cb65436df1a1e2a12e6f2de99183a9.tar.gz |
Move /encwarn command into /titlebar
Instead of `/encwarn on|off` we now have `/titlebar show|hide encwarn`. Regards https://github.com/profanity-im/profanity/issues/1116
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 4 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 32 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 38 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 3 |
4 files changed, 36 insertions, 41 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 12c17ab7..94e6f221 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -775,6 +775,7 @@ cmd_ac_init(void) titlebar_show_ac = autocomplete_new(); autocomplete_add(titlebar_show_ac, "tls"); + autocomplete_add(titlebar_show_ac, "encwarn"); tls_certpath_ac = autocomplete_new(); autocomplete_add(tls_certpath_ac, "set"); @@ -1440,8 +1441,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ // autocomplete boolean settings gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog", - "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/encwarn", - "/lastactivity" }; + "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/lastactivity" }; for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index e8d89c5d..d1b1d4c1 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1197,22 +1197,6 @@ static struct cmd_t command_defs[] = CMD_NOEXAMPLES }, - { "/encwarn", - parse_args, 1, 1, &cons_encwarn_setting, - CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_encwarn) - CMD_TAGS( - CMD_TAG_CHAT, - CMD_TAG_UI) - CMD_SYN( - "/encwarn on|off") - CMD_DESC( - "Titlebar encryption warning.") - CMD_ARGS( - { "on|off", "Enable or disable the unencrypted warning message in the titlebar." }) - CMD_NOEXAMPLES - }, - { "/presence", parse_args, 2, 2, &cons_presence_setting, CMD_NOSUBFUNCS @@ -1324,10 +1308,10 @@ static struct cmd_t command_defs[] = }, { "/titlebar", - parse_args, 1, 2, &cons_winpos_setting, + parse_args, 1, 2, &cons_titlebar_setting, CMD_SUBFUNCS( - { "show", cmd_titlebar_tls_show }, - { "hide", cmd_titlebar_tls_show } + { "show", cmd_titlebar_show_hide }, + { "hide", cmd_titlebar_show_hide } ) CMD_MAINFUNC(cmd_titlebar) CMD_TAGS( @@ -1335,15 +1319,19 @@ static struct cmd_t command_defs[] = CMD_SYN( "/titlebar up", "/titlebar down", - "/titlebar show|hide tls") + "/titlebar show|hide [tls|encwarn]") CMD_DESC( "Titlebar settings.") CMD_ARGS( { "up", "Move the title bar up the screen." }, { "down", "Move the title bar down the screen." }, - { "show", "Show or hide the TLS indicator in the titlebar." } + { "show tls", "Show or hide TLS indicator in the titlebar." }, + { "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." } ) - CMD_NOEXAMPLES + CMD_EXAMPLES( + "/titlebar up", + "/titlebar show tls", + "/titlebar hide encwarn") }, { "/mainwin", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 5794d85b..5eec7016 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5947,21 +5947,36 @@ cmd_titlebar(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_titlebar_tls_show(ProfWin *window, const char *const command, gchar **args) +cmd_titlebar_show_hide(ProfWin *window, const char *const command, gchar **args) { - if (args[1] == NULL || g_strcmp0(args[1], "tls") != 0) { - cons_bad_cmd_usage(command); - } else { + if (args[1] != NULL) { if (g_strcmp0(args[0], "show") == 0) { - cons_show("TLS titlebar indicator enabled."); - prefs_set_boolean(PREF_TLS_SHOW, TRUE); + + if (g_strcmp0(args[1], "tls") == 0) { + cons_show("TLS titlebar indicator enabled."); + prefs_set_boolean(PREF_TLS_SHOW, TRUE); + } else if (g_strcmp0(args[1], "encwarn") == 0) { + cons_show("Encryption warning titlebar indicator enabled."); + prefs_set_boolean(PREF_ENC_WARN, TRUE); + } else { + cons_bad_cmd_usage(command); + } } else if (g_strcmp0(args[0], "hide") == 0) { - cons_show("TLS titlebar indicator disabled."); - prefs_set_boolean(PREF_TLS_SHOW, FALSE); + + if (g_strcmp0(args[1], "tls") == 0) { + cons_show("TLS titlebar indicator disabled."); + prefs_set_boolean(PREF_TLS_SHOW, FALSE); + } else if (g_strcmp0(args[1], "encwarn") == 0) { + cons_show("Encryption warning titlebar indicator disabled."); + prefs_set_boolean(PREF_ENC_WARN, FALSE); + } else { + cons_bad_cmd_usage(command); + } } else { cons_bad_cmd_usage(command); } } + return TRUE; } @@ -7800,13 +7815,6 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_encwarn(ProfWin *window, const char *const command, gchar **args) -{ - _cmd_set_boolean_preference(args[0], command, "Encryption warning message", PREF_ENC_WARN); - return TRUE; -} - -gboolean cmd_command_list(ProfWin *window, const char *const command, gchar **args) { jabber_conn_status_t conn_status = connection_get_status(); diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 7bc723a7..9e845657 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -151,11 +151,10 @@ gboolean cmd_time(ProfWin *window, const char *const command, gchar **args); 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_tls_show(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_titlebar_show_hide(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); -gboolean cmd_encwarn(ProfWin *window, const char *const command, gchar **args); gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); gboolean cmd_export(ProfWin *window, const char *const command, gchar **args); gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args); |