mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
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:
parent
1ef700f918
commit
1d8061e89b
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
},
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1803,6 +1803,7 @@ _get_group(preference_t pref)
|
||||
case PREF_WINTITLE_GOODBYE:
|
||||
case PREF_FLASH:
|
||||
case PREF_INTYPE:
|
||||
case PREF_INTYPE_CONSOLE:
|
||||
case PREF_HISTORY:
|
||||
case PREF_OCCUPANTS:
|
||||
case PREF_OCCUPANTS_JID:
|
||||
@ -1967,6 +1968,8 @@ _get_key(preference_t pref)
|
||||
return "adv.notify.discoversion";
|
||||
case PREF_INTYPE:
|
||||
return "intype";
|
||||
case PREF_INTYPE_CONSOLE:
|
||||
return "intype.console";
|
||||
case PREF_HISTORY:
|
||||
return "history";
|
||||
case PREF_CARBONS:
|
||||
|
@ -59,6 +59,7 @@ typedef enum {
|
||||
PREF_TRAY_READ,
|
||||
PREF_ADV_NOTIFY_DISCO_OR_VERSION,
|
||||
PREF_INTYPE,
|
||||
PREF_INTYPE_CONSOLE,
|
||||
PREF_HISTORY,
|
||||
PREF_CARBONS,
|
||||
PREF_RECEIPTS_SEND,
|
||||
|
@ -1716,9 +1716,14 @@ void
|
||||
cons_intype_setting(void)
|
||||
{
|
||||
if (prefs_get_boolean(PREF_INTYPE))
|
||||
cons_show("Show typing (/intype) : ON");
|
||||
cons_show("Show typing in titlebar (/intype titlebar) : ON");
|
||||
else
|
||||
cons_show("Show typing (/intype) : OFF");
|
||||
cons_show("Show typing in titlebar (/intype titlebar) : OFF");
|
||||
|
||||
if (prefs_get_boolean(PREF_INTYPE_CONSOLE))
|
||||
cons_show("Show typing in console (/intype console) : ON");
|
||||
else
|
||||
cons_show("Show typing in console (/intype console) : OFF");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -276,17 +276,21 @@ ui_contact_typing(const char* const barejid, const char* const resource)
|
||||
ProfWin* window = (ProfWin*)chatwin;
|
||||
ChatSession* session = chat_session_get(barejid);
|
||||
|
||||
if (prefs_get_boolean(PREF_INTYPE)) {
|
||||
// no chat window for user
|
||||
if (chatwin == NULL) {
|
||||
// no chat window for user
|
||||
if (chatwin == NULL) {
|
||||
if (prefs_get_boolean(PREF_INTYPE_CONSOLE)) {
|
||||
cons_show_typing(barejid);
|
||||
}
|
||||
|
||||
// have chat window but not currently in it
|
||||
} else if (!wins_is_current(window)) {
|
||||
// have chat window but not currently in it
|
||||
} else if (!wins_is_current(window)) {
|
||||
if (prefs_get_boolean(PREF_INTYPE_CONSOLE)) {
|
||||
cons_show_typing(barejid);
|
||||
}
|
||||
|
||||
// in chat window with user, no session or session with resource
|
||||
} else if (!session || (session && g_strcmp0(session->resource, resource) == 0)) {
|
||||
// in chat window with user, no session or session with resource
|
||||
} else if (!session || (session && g_strcmp0(session->resource, resource) == 0)) {
|
||||
if (prefs_get_boolean(PREF_INTYPE)) {
|
||||
title_bar_set_typing(TRUE);
|
||||
|
||||
int num = wins_get_num(window);
|
||||
|
Loading…
Reference in New Issue
Block a user