1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Add preference for showing TLS indicator in titlebar

Issue #616
This commit is contained in:
James Booth 2015-10-14 00:46:16 +01:00
parent c9165ef9d2
commit ef832ce526
6 changed files with 19 additions and 3 deletions

View File

@ -200,7 +200,8 @@ static struct cmd_t command_defs[] =
"/tls revoke <fingerprint>",
"/tls certpath",
"/tls certpath set <path>",
"/tls certpath clear")
"/tls certpath clear",
"/tls show on|off")
CMD_DESC(
"Handle TLS certificates. ")
CMD_ARGS(
@ -211,7 +212,8 @@ static struct cmd_t command_defs[] =
{ "revoke <fingerprint>", "Remove a manually trusted certificate." },
{ "certpath", "Show the trusted certificate path." },
{ "certpath set <path>", "Specify filesystem path containing trusted certificates." },
{ "certpath clear", "Clear the trusted certificate path." })
{ "certpath clear", "Clear the trusted certificate path." },
{ "show on|off", "Show or hide the TLS indicator in the titlebar." })
CMD_NOEXAMPLES
},
@ -2158,6 +2160,7 @@ cmd_init(void)
autocomplete_add(tls_ac, "trusted");
autocomplete_add(tls_ac, "revoke");
autocomplete_add(tls_ac, "certpath");
autocomplete_add(tls_ac, "show");
tls_certpath_ac = autocomplete_new();
autocomplete_add(tls_certpath_ac, "set");
@ -3628,6 +3631,11 @@ _tls_autocomplete(ProfWin *window, const char * const input)
return result;
}
result = autocomplete_param_with_func(input, "/tls show", prefs_autocomplete_boolean_choice);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/tls", tls_ac, TRUE);
if (result) {
return result;

View File

@ -237,6 +237,8 @@ cmd_tls(ProfWin *window, const char * const command, gchar **args)
}
}
return TRUE;
} else if (g_strcmp0(args[0], "show") == 0) {
return _cmd_set_boolean_preference(args[1], command, "TLS titlebar indicator", PREF_TLS_SHOW);
} else {
cons_bad_cmd_usage(command);
return TRUE;

View File

@ -602,6 +602,7 @@ _get_group(preference_t pref)
case PREF_RESOURCE_MESSAGE:
case PREF_ENC_WARN:
case PREF_INPBLOCK_DYNAMIC:
case PREF_TLS_SHOW:
return PREF_GROUP_UI;
case PREF_STATES:
case PREF_OUTTYPE:
@ -781,6 +782,8 @@ _get_key(preference_t pref)
return "log";
case PREF_CERT_PATH:
return "certpath";
case PREF_TLS_SHOW:
return "tls.show";
default:
return NULL;
}
@ -817,6 +820,7 @@ _get_default_boolean(preference_t pref)
case PREF_ROSTER_OFFLINE:
case PREF_ROSTER_RESOURCE:
case PREF_ROSTER_EMPTY:
case PREF_TLS_SHOW:
return TRUE;
default:
return FALSE;

View File

@ -112,6 +112,7 @@ typedef enum {
PREF_ENC_WARN,
PREF_PGP_LOG,
PREF_CERT_PATH,
PREF_TLS_SHOW,
} preference_t;
typedef struct prof_alias_t {

View File

@ -471,6 +471,7 @@ _load_preferences(void)
_set_boolean_preference("intype", PREF_INTYPE);
_set_boolean_preference("enc.warn", PREF_ENC_WARN);
_set_boolean_preference("tls.show", PREF_TLS_SHOW);
if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL);

View File

@ -282,7 +282,7 @@ _show_self_presence(void)
mvwaddch(win, 0, cols - 2, ']');
wattroff(win, bracket_attrs);
if (is_connected) {
if (is_connected && prefs_get_boolean(PREF_TLS_SHOW)) {
wattron(win, bracket_attrs);
mvwaddch(win, 0, cols - tls_start, '[');
wattroff(win, bracket_attrs);