about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-19 23:58:55 +0000
committerJames Booth <boothj5@gmail.com>2014-11-19 23:58:55 +0000
commit20fa96325d9b0618646d5fb94f98d2ffde66a0d8 (patch)
tree450dd9d28297fc64977eb6fa94500aebd24a4132 /src/config
parent1a896d7b530874e808d46794e2cf56ea30204082 (diff)
downloadprofani-tty-20fa96325d9b0618646d5fb94f98d2ffde66a0d8.tar.gz
Added [ui] preferences to themes
Diffstat (limited to 'src/config')
-rw-r--r--src/config/theme.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/config/theme.c b/src/config/theme.c
index 756ab7d1..714560dd 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -47,6 +47,7 @@
 #include "common.h"
 #include "log.h"
 #include "theme.h"
+#include "preferences.h"
 
 static GString *theme_loc;
 static GKeyFile *theme;
@@ -125,6 +126,7 @@ static struct colours_t {
 static NCURSES_COLOR_T _lookup_colour(const char * const colour);
 static void _set_colour(gchar *val, NCURSES_COLOR_T *pref, NCURSES_COLOR_T def, theme_item_t theme_item);
 static void _load_colours(void);
+static void _load_preferences(void);
 static gchar * _get_themes_dir(void);
 void _theme_list_dir(const gchar * const dir, GSList **result);
 static GString * _theme_find(const char * const theme_name);
@@ -169,6 +171,7 @@ theme_load(const char * const theme_name)
     }
 
     _load_colours();
+    _load_preferences();
     return TRUE;
 }
 
@@ -381,6 +384,59 @@ _load_colours(void)
     _set_colour("occupants.header",         &colour_prefs.occupantsheader,      COLOR_YELLOW,   THEME_OCCUPANTS_HEADER);
 }
 
+static void
+_set_string_preference(char *prefstr, preference_t pref)
+{
+    if (g_key_file_has_key(theme, "ui", prefstr, NULL)) {
+        gchar *val = g_key_file_get_string(theme, "ui", prefstr, NULL);
+        prefs_set_string(pref, val);
+    }
+}
+
+static void
+_set_boolean_preference(char *prefstr, preference_t pref)
+{
+    if (g_key_file_has_key(theme, "ui", prefstr, NULL)) {
+        gboolean val = g_key_file_get_boolean(theme, "ui", prefstr, NULL);
+        prefs_set_boolean(pref, val);
+    }
+}
+
+static void
+_load_preferences(void)
+{
+    _set_boolean_preference("intype", PREF_INTYPE);
+    _set_boolean_preference("beep", PREF_BEEP);
+    _set_boolean_preference("flash", PREF_FLASH);
+    _set_boolean_preference("privileges", PREF_MUC_PRIVILEGES);
+    _set_boolean_preference("presence", PREF_PRESENCE);
+    _set_boolean_preference("wrap", PREF_WRAP);
+
+    _set_string_preference("time", PREF_TIME);
+    _set_string_preference("statuses.muc", PREF_STATUSES_MUC);
+    _set_string_preference("statuses.console", PREF_STATUSES_CONSOLE);
+    _set_string_preference("statuses.chat", PREF_STATUSES_CHAT);
+
+    _set_boolean_preference("occupants", PREF_OCCUPANTS);
+
+    if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) {
+        gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL);
+        prefs_set_occupants_size(occupants_size);
+    }
+
+    _set_boolean_preference("roster", PREF_ROSTER);
+    _set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE);
+    _set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE);
+    _set_string_preference("roster.by", PREF_ROSTER_BY);
+
+    if (g_key_file_has_key(theme, "ui", "roster.size", NULL)) {
+        gint roster_size = g_key_file_get_integer(theme, "ui", "roster.size", NULL);
+        prefs_set_roster_size(roster_size);
+    }
+
+    _set_boolean_preference("otr.warn", PREF_OTR_WARN);
+}
+
 static gchar *
 _get_themes_dir(void)
 {