diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-05-08 19:33:58 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2021-05-08 19:38:40 +0200 |
commit | 1d8061e89b23f896035fdd62e777dd9343b35bb5 (patch) | |
tree | 0cf9969d157e282d0a2cc14048806e18a49bb248 /src | |
parent | 1ef700f918f706da2098460ead880b2538aaf262 (diff) | |
download | profani-tty-1d8061e89b23f896035fdd62e777dd9343b35bb5.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/command/cmd_ac.c | 29 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 7 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 9 | ||||
-rw-r--r-- | src/config/preferences.c | 3 | ||||
-rw-r--r-- | src/config/preferences.h | 1 | ||||
-rw-r--r-- | src/ui/console.c | 9 | ||||
-rw-r--r-- | src/ui/core.c | 18 |
7 files changed, 62 insertions, 14 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 14af0552..b84d4d2e 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -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; +} diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 5c03cad3..4ebc3432 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -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 }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 351f7b98..ab212975 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -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; } diff --git a/src/config/preferences.c b/src/config/preferences.c index f4c86b2d..84209f0c 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -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: diff --git a/src/config/preferences.h b/src/config/preferences.h index d58cf8b1..d8573349 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -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, diff --git a/src/ui/console.c b/src/ui/console.c index 9f4d6248..3eff47d5 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -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 diff --git a/src/ui/core.c b/src/ui/core.c index 931417c4..4e4e39a0 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -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); |