Have separate settings for intype

Old: `/intype on|of`
Typing information is printed in console and titlebar.

New: `/intype titlebar|console on|off`
Typing information can be configured in more detail.

Regards https://github.com/profanity-im/profanity/issues/1516
This commit is contained in:
Michael Vetter
2021-05-08 19:33:58 +02:00
parent 1ef700f918
commit 1d8061e89b
7 changed files with 62 additions and 14 deletions

View File

@@ -127,6 +127,7 @@ static char* _software_autocomplete(ProfWin* window, const char* const input, gb
static char* _url_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _executable_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _intype_autocomplete(ProfWin* window, const char* const input, gboolean previous);
static char* _script_autocomplete_func(const char* const prefix, gboolean previous, void* context);
@@ -267,6 +268,7 @@ static Autocomplete correction_ac;
static Autocomplete avatar_ac;
static Autocomplete url_ac;
static Autocomplete executable_ac;
static Autocomplete intype_ac;
/*!
* \brief Initialization of auto completion for commands.
@@ -1053,6 +1055,10 @@ cmd_ac_init(void)
autocomplete_add(executable_ac, "urlopen");
autocomplete_add(executable_ac, "urlsave");
autocomplete_add(executable_ac, "editor");
intype_ac = autocomplete_new();
autocomplete_add(intype_ac, "console");
autocomplete_add(intype_ac, "titlebar");
}
void
@@ -1368,6 +1374,7 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(avatar_ac);
autocomplete_reset(url_ac);
autocomplete_reset(executable_ac);
autocomplete_reset(intype_ac);
autocomplete_reset(script_ac);
if (script_show_ac) {
@@ -1531,6 +1538,7 @@ cmd_ac_uninit(void)
autocomplete_free(avatar_ac);
autocomplete_free(url_ac);
autocomplete_free(executable_ac);
autocomplete_free(intype_ac);
}
static void
@@ -1660,7 +1668,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
jabber_conn_status_t conn_status = connection_get_status();
// autocomplete boolean settings
gchar* boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash",
gchar* boolean_choices[] = { "/beep", "/states", "/outtype", "/flash", "/splash",
"/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/os", "/slashguard", "/mam" };
for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
@@ -1794,6 +1802,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
g_hash_table_insert(ac_funcs, "/url", _url_autocomplete);
g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete);
g_hash_table_insert(ac_funcs, "/lastactivity", _lastactivity_autocomplete);
g_hash_table_insert(ac_funcs, "/intype", _intype_autocomplete);
int len = strlen(input);
char parsed[len + 1];
@@ -4121,3 +4130,21 @@ _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean pr
return result;
}
static char*
_intype_autocomplete(ProfWin* window, const char* const input, gboolean previous)
{
char* result = NULL;
result = autocomplete_param_with_func(input, "/intype console", prefs_autocomplete_boolean_choice, previous, NULL);
if (result) {
return result;
}
result = autocomplete_param_with_func(input, "/intype titlebar", prefs_autocomplete_boolean_choice, previous, NULL);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/intype", intype_ac, FALSE, previous);
return result;
}

View File

@@ -1514,18 +1514,19 @@ static struct cmd_t command_defs[] = {
},
{ "/intype",
parse_args, 1, 1, &cons_intype_setting,
parse_args, 2, 2, &cons_intype_setting,
CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_intype)
CMD_TAGS(
CMD_TAG_UI,
CMD_TAG_CHAT)
CMD_SYN(
"/intype on|off")
"/intype console|titlebar on|off")
CMD_DESC(
"Show when a contact is typing in the console, and in active message window.")
CMD_ARGS(
{ "on|off", "Enable or disable contact typing messages." })
{ "titlebar on|off", "Enable or disable contact typing messages notification in titlebar." },
{ "console on|off", "Enable or disable contact typing messages notification in console window." })
CMD_NOEXAMPLES
},

View File

@@ -6719,7 +6719,14 @@ cmd_tray(ProfWin* window, const char* const command, gchar** args)
gboolean
cmd_intype(ProfWin* window, const char* const command, gchar** args)
{
_cmd_set_boolean_preference(args[0], command, "Show contact typing", PREF_INTYPE);
if (g_strcmp0(args[0], "console") == 0) {
_cmd_set_boolean_preference(args[1], command, "Show contact typing in console", PREF_INTYPE_CONSOLE);
} else if (g_strcmp0(args[0], "titlebar") == 0) {
_cmd_set_boolean_preference(args[1], command, "Show contact typing in titlebar", PREF_INTYPE);
} else {
cons_bad_cmd_usage(command);
}
return TRUE;
}