about summary refs log tree commit diff stats
path: root/src/command/cmd_funcs.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-01-29 12:33:55 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-01-29 12:33:55 +0100
commitcd80b6cbf23bdf792dbbf6bedcba0bff2889a193 (patch)
treea35ac5f63ae340d16d0a31efdc0a584bded1e3de /src/command/cmd_funcs.c
parent5c41c5b380b8dddf68aa45e2e7265c60c52f36dc (diff)
downloadprofani-tty-cd80b6cbf23bdf792dbbf6bedcba0bff2889a193.tar.gz
Change theme handling
So far when loading a theme it also overwrote the preferences the user
set.

Lengthy discussion can be found at
https://github.com/profanity-im/profanity/issues/1077

Now we use `/theme load themename` to load the [colours] part of a
themem only.

`/theme full-load themename` will load the complete theme including
preferences set in there.

Regards https://github.com/profanity-im/profanity/issues/1077
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r--src/command/cmd_funcs.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index a0d40cdd..930004b3 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -804,7 +804,7 @@ _account_set_theme(char *account_name, char *theme)
         ProfAccount *account = accounts_get_account(session_get_account_name());
         if (account) {
             if (g_strcmp0(account->name, account_name) == 0) {
-                theme_load(theme);
+                theme_load(theme, false);
                 ui_load_colours();
                 if (prefs_get_boolean(PREF_ROSTER)) {
                     ui_show_roster();
@@ -1234,13 +1234,13 @@ cmd_disconnect(ProfWin *window, const char *const command, gchar **args)
 
     char *theme = prefs_get_string(PREF_THEME);
     if (theme) {
-        gboolean res = theme_load(theme);
+        gboolean res = theme_load(theme, false);
         prefs_free_string(theme);
         if (!res) {
-            theme_load("default");
+            theme_load("default", false);
         }
     } else {
-        theme_load("default");
+        theme_load("default", false);
     }
     ui_load_colours();
     if (prefs_get_boolean(PREF_ROSTER)) {
@@ -1699,6 +1699,9 @@ cmd_prefs(ProfWin *window, const char *const command, gchar **args)
 gboolean
 cmd_theme(ProfWin *window, const char *const command, gchar **args)
 {
+    // 'full-load' means to load the theme including the settings (not just [colours])
+    gboolean fullload = (g_strcmp0(args[0], "full-load") == 0);
+
     // list themes
     if (g_strcmp0(args[0], "list") == 0) {
         GSList *themes = theme_list();
@@ -1706,10 +1709,10 @@ cmd_theme(ProfWin *window, const char *const command, gchar **args)
         g_slist_free_full(themes, g_free);
 
     // load a theme
-    } else if (g_strcmp0(args[0], "load") == 0) {
+    } else if (g_strcmp0(args[0], "load") == 0 || fullload) {
         if (args[1] == NULL) {
             cons_bad_cmd_usage(command);
-        } else if (theme_load(args[1])) {
+        } else if (theme_load(args[1], fullload)) {
             ui_load_colours();
             prefs_set_string(PREF_THEME, args[1]);
             if (prefs_get_boolean(PREF_ROSTER)) {
@@ -8619,12 +8622,12 @@ cmd_color(ProfWin *window, const char *const command, gchar **args)
 
     char *theme = prefs_get_string(PREF_THEME);
     if (theme) {
-        gboolean res = theme_load(theme);
+        gboolean res = theme_load(theme, false);
 
         if (res) {
             cons_show("Theme reloaded: %s", theme);
         } else {
-            theme_load("default");
+            theme_load("default", false);
         }
 
         prefs_free_string(theme);