From ae1e60a9f900708f5ea42746c84c0451d6f7473d Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 17 Jun 2019 14:23:33 +0200 Subject: [PATCH] Add option to set all window related time formats Implements feature requested at: https://github.com/profanity-im/profanity/issues/632 So instead of: /time console set /time chat set /time muc set /time mucconfig set /time private set /time xml set As a short cut the user can do: /time all set Excluding statusbar and lastactivity settings since they are not for main windows, but used slightly differently. --- src/command/cmd_ac.c | 6 ++++++ src/command/cmd_defs.c | 11 +++++++---- src/command/cmd_funcs.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index e65bbe65..1ce20862 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -717,6 +717,7 @@ cmd_ac_init(void) autocomplete_add(time_ac, "xml"); autocomplete_add(time_ac, "statusbar"); autocomplete_add(time_ac, "lastactivity"); + autocomplete_add(time_ac, "all"); time_format_ac = autocomplete_new(); autocomplete_add(time_format_ac, "set"); @@ -2665,6 +2666,11 @@ _time_autocomplete(ProfWin *window, const char *const input, gboolean previous) return found; } + found = autocomplete_param_with_ac(input, "/time all", time_format_ac, TRUE, previous); + if (found) { + return found; + } + found = autocomplete_param_with_ac(input, "/time", time_ac, TRUE, previous); if (found) { return found; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 904d176d..2dca64c0 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1277,8 +1277,8 @@ static struct cmd_t command_defs[] = CMD_TAGS( CMD_TAG_UI) CMD_SYN( - "/time console|chat|muc|config|private|xml set ", - "/time console|chat|muc|config|private|xml off", + "/time all|console|chat|muc|config|private|xml set ", + "/time all|console|chat|muc|config|private|xml off", "/time statusbar set ", "/time statusbar off", "/time lastactivity set ") @@ -1303,13 +1303,16 @@ static struct cmd_t command_defs[] = { "xml off", "Do not show time in XML console window." }, { "statusbar set ", "Change time format in statusbar." }, { "statusbar off", "Do not show time in status bar." }, - { "lastactivity set ", "Change time format for last activity." }) + { "lastactivity set ", "Change time format for last activity." }, + { "all set ", "Set time for: console, chat, muc, config, private and xml windows." }, + { "all off", "Do not show time for: console, chat, muc, config, private and xml windows." }) CMD_EXAMPLES( "/time console set %H:%M:%S", "/time chat set \"%d-%m-%y %H:%M:%S\"", "/time xml off", "/time statusbar set %H:%M", - "/time lastactivity set \"%d-%m-%y %H:%M:%S\"") + "/time lastactivity set \"%d-%m-%y %H:%M:%S\"", + "/time all set \"%d-%m-%y %H:%M:%S\"") }, { "/inpblock", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index b5e996e9..e9e266c1 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5359,6 +5359,44 @@ cmd_time(ProfWin *window, const char *const command, gchar **args) cons_bad_cmd_usage(command); return TRUE; } + } else if (g_strcmp0(args[0], "all") == 0) { + if (args[1] == NULL) { + cons_time_setting(); + return TRUE; + } else if (g_strcmp0(args[1], "set") == 0 && args[2] != NULL) { + prefs_set_string(PREF_TIME_CONSOLE, args[2]); + cons_show("Console time format set to '%s'.", args[2]); + prefs_set_string(PREF_TIME_CHAT, args[2]); + cons_show("Chat time format set to '%s'.", args[2]); + prefs_set_string(PREF_TIME_MUC, args[2]); + cons_show("MUC time format set to '%s'.", args[2]); + prefs_set_string(PREF_TIME_CONFIG, args[2]); + cons_show("config time format set to '%s'.", args[2]); + prefs_set_string(PREF_TIME_PRIVATE, args[2]); + cons_show("Private chat time format set to '%s'.", args[2]); + prefs_set_string(PREF_TIME_XMLCONSOLE, args[2]); + cons_show("XML Console time format set to '%s'.", args[2]); + wins_resize_all(); + return TRUE; + } else if (g_strcmp0(args[1], "off") == 0) { + prefs_set_string(PREF_TIME_CONSOLE, "off"); + cons_show("Console time display disabled."); + prefs_set_string(PREF_TIME_CHAT, "off"); + cons_show("Chat time display disabled."); + prefs_set_string(PREF_TIME_MUC, "off"); + cons_show("MUC time display disabled."); + prefs_set_string(PREF_TIME_CONFIG, "off"); + cons_show("config time display disabled."); + prefs_set_string(PREF_TIME_PRIVATE, "off"); + cons_show("config time display disabled."); + prefs_set_string(PREF_TIME_XMLCONSOLE, "off"); + cons_show("XML Console time display disabled."); + ui_redraw(); + return TRUE; + } else { + cons_bad_cmd_usage(command); + return TRUE; + } } else { cons_bad_cmd_usage(command); return TRUE;