about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-06-17 14:46:55 +0200
committerGitHub <noreply@github.com>2019-06-17 14:46:55 +0200
commit110a2c7bb857904956104794b563e70640e873f4 (patch)
treea442d3b414fbe5b7b39592cfe72294ff9c54f0c1
parentde787a858237a88e07f989273f361ca7c6bd4d1d (diff)
parentae1e60a9f900708f5ea42746c84c0451d6f7473d (diff)
downloadprofani-tty-110a2c7bb857904956104794b563e70640e873f4.tar.gz
Merge pull request #1129 from profanity-im/feature/632-set-all-time
Add option to set all window related time formats
-rw-r--r--src/command/cmd_ac.c6
-rw-r--r--src/command/cmd_defs.c11
-rw-r--r--src/command/cmd_funcs.c38
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 <format>",
-            "/time console|chat|muc|config|private|xml off",
+            "/time all|console|chat|muc|config|private|xml set <format>",
+            "/time all|console|chat|muc|config|private|xml off",
             "/time statusbar set <format>",
             "/time statusbar off",
             "/time lastactivity set <format>")
@@ -1303,13 +1303,16 @@ static struct cmd_t command_defs[] =
             { "xml off",                   "Do not show time in XML console window." },
             { "statusbar set <format>",    "Change time format in statusbar." },
             { "statusbar off",             "Do not show time in status bar." },
-            { "lastactivity set <format>", "Change time format for last activity." })
+            { "lastactivity set <format>", "Change time format for last activity." },
+            { "all set <format>",          "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;