1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

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
This commit is contained in:
Michael Vetter 2019-11-05 20:39:33 +01:00
parent 5490d148b9
commit fc6f2755c1
6 changed files with 50 additions and 59 deletions

View File

@ -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);

View File

@ -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",

View File

@ -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;
}
@ -7799,13 +7814,6 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args)
#endif
}
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)
{

View File

@ -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);

View File

@ -1130,12 +1130,20 @@ cons_wrap_setting(void)
}
void
cons_encwarn_setting(void)
cons_titlebar_setting(void)
{
if (prefs_get_boolean(PREF_ENC_WARN)) {
cons_show("Warn unencrypted (/encwarn) : ON");
cons_winpos_setting();
if (prefs_get_boolean(PREF_TLS_SHOW)) {
cons_show("TLS show (/titlebar) : ON");
} else {
cons_show("Warn unencrypted (/encwarn) : OFF");
cons_show("TLS show (/titlebar) : OFF");
}
if (prefs_get_boolean(PREF_ENC_WARN)) {
cons_show("Warn unencrypted (/titlebar) : ON");
} else {
cons_show("Warn unencrypted (/titlebar) : OFF");
}
}
@ -1155,16 +1163,6 @@ cons_console_setting(void)
prefs_free_string(privsetting);
}
void
cons_tlsshow_setting(void)
{
if (prefs_get_boolean(PREF_TLS_SHOW)) {
cons_show("TLS show (/tls) : ON");
} else {
cons_show("TLS show (/tls) : OFF");
}
}
void
cons_presence_setting(void)
{
@ -1556,10 +1554,9 @@ cons_show_ui_prefs(void)
cons_roster_setting();
cons_privileges_setting();
cons_wintitle_setting();
cons_encwarn_setting();
cons_presence_setting();
cons_inpblock_setting();
cons_tlsshow_setting();
cons_titlebar_setting();
cons_statusbar_setting();
cons_alert();

View File

@ -289,8 +289,7 @@ void cons_console_setting(void);
void cons_flash_setting(void);
void cons_tray_setting(void);
void cons_splash_setting(void);
void cons_encwarn_setting(void);
void cons_tlsshow_setting(void);
void cons_titlebar_setting(void);
void cons_vercheck_setting(void);
void cons_occupants_setting(void);
void cons_roster_setting(void);