about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-08-02 10:23:13 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-08-02 10:23:13 +0200
commit658e36a06618dd48798133983c4a234e747834ad (patch)
tree6355ffa39185e5b17c9f5dee1f720636d2016cef /src/command
parentd4150eb7d15c3a8674eaf78a212209381ed95ee9 (diff)
downloadprofani-tty-658e36a06618dd48798133983c4a234e747834ad.tar.gz
Add 'save' command to save preferences
Most applications have an 'apply changes' button. This makes testing
easier too.

Implement https://github.com/profanity-im/profanity/issues/1164
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_defs.c13
-rw-r--r--src/command/cmd_defs.h1
-rw-r--r--src/command/cmd_funcs.c10
-rw-r--r--src/command/cmd_funcs.h2
4 files changed, 26 insertions, 0 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index efe2bad0..358b3472 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2393,6 +2393,19 @@ static struct cmd_t command_defs[] =
             "/omemo untrust buddy@buddychat.org c4f9c875-144d7a3b-0c4a05b6-ca3be51a-a037f329-0bd3ae62-07f99719-55559d2a",
             "/omemo char *")
     },
+
+    { "/save",
+        parse_args, 0, 0, NULL,
+        CMD_NOSUBFUNCS
+        CMD_MAINFUNC(cmd_save)
+        CMD_NOTAGS
+        CMD_SYN(
+            "/save")
+        CMD_DESC(
+            "Save preferences to configuration file.")
+        CMD_NOARGS
+        CMD_NOEXAMPLES
+    },
 };
 
 static GHashTable *search_index;
diff --git a/src/command/cmd_defs.h b/src/command/cmd_defs.h
index e6ce1053..fb3a12c4 100644
--- a/src/command/cmd_defs.h
+++ b/src/command/cmd_defs.h
@@ -2,6 +2,7 @@
  * cmd_defs.h
  *
  * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
  *
  * This file is part of Profanity.
  *
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index b2893633..a64e70b2 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -2,6 +2,7 @@
  * cmd_funcs.c
  *
  * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
  *
  * This file is part of Profanity.
  *
@@ -8535,3 +8536,12 @@ cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args)
     return TRUE;
 #endif
 }
+
+gboolean
+cmd_save(ProfWin *window, const char *const command, gchar **args)
+{
+    log_info("Saving preferences to configuration file");
+    cons_show("Saving preferences.");
+    prefs_save();
+    return TRUE;
+}
diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h
index 8f8d60a9..c623ca83 100644
--- a/src/command/cmd_funcs.h
+++ b/src/command/cmd_funcs.h
@@ -2,6 +2,7 @@
  * cmd_funcs.h
  *
  * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
+ * Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
  *
  * This file is part of Profanity.
  *
@@ -225,4 +226,5 @@ gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **a
 gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args);
 gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args);
 
+gboolean cmd_save(ProfWin *window, const char *const command, gchar **args);
 #endif