summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-12 16:33:50 (EST)
committer Patrick McDermott <pj@pehjota.net>2017-11-12 16:33:50 (EST)
commit465b5cf5731122fb174ee4012ce469cf43a5a785 (patch)
tree5e0a0ffd8b0f54a9b0e70e31c759d128cd79624b
parent4bd688d7a15be374d1b9085c1e5a3abe61abb673 (diff)
downloadmarquee-465b5cf5731122fb174ee4012ce469cf43a5a785.zip
marquee-465b5cf5731122fb174ee4012ce469cf43a5a785.tar.gz
marquee-465b5cf5731122fb174ee4012ce469cf43a5a785.tar.bz2
MqProfiles: Manage current profile's MqConfig
And save it on profile re-insertion.
-rw-r--r--src/config/profiles.c14
-rw-r--r--src/config/profiles.h5
2 files changed, 19 insertions, 0 deletions
diff --git a/src/config/profiles.c b/src/config/profiles.c
index 8d7100d..52d4131 100644
--- a/src/config/profiles.c
+++ b/src/config/profiles.c
@@ -36,6 +36,7 @@ struct _MqProfiles {
gchar *file_name;
GKeyFile *key_file;
gchar *current;
+ MqConfig *current_config;
};
static gboolean
@@ -146,6 +147,7 @@ changed(GFileMonitor G_GNUC_UNUSED *monitor, GFile G_GNUC_UNUSED *file,
if (insert(profiles, profiles->current,
cur_name, cur_color))
{
+ mq_config_save(profiles->current_config);
mq_profiles_save(profiles);
}
}
@@ -251,6 +253,12 @@ mq_profiles_get_current(MqProfiles *profiles)
return g_strdup(profiles->current);
}
+MqConfig *
+mq_profiles_get_current_config(MqProfiles *profiles)
+{
+ return profiles->current_config;
+}
+
void
mq_profiles_set_name(MqProfiles *profiles, const gchar *profile,
const gchar *name)
@@ -286,12 +294,18 @@ void
mq_profiles_set_current(MqProfiles *profiles, const gchar *profile)
{
g_free(profiles->current);
+ if (profiles->current_config) {
+ mq_config_free(profiles->current_config);
+ }
if (profile && profile[0]) {
profiles->current = g_strdup(profile);
} else {
profiles->current = mq_profiles_get_default(profiles);
}
+ profiles->current_config = mq_config_new(profiles->current,
+ MQ_CONFIG_PROFILE_DEFAULT);
+ mq_config_load(profiles->current_config);
}
gchar *
diff --git a/src/config/profiles.h b/src/config/profiles.h
index c75f3b3..50db8fe 100644
--- a/src/config/profiles.h
+++ b/src/config/profiles.h
@@ -26,6 +26,8 @@ typedef struct _MqProfiles MqProfiles;
#include <glib.h>
+#include "config.h"
+
G_BEGIN_DECLS
MqProfiles *
@@ -49,6 +51,9 @@ mq_profiles_get_default(MqProfiles *profiles);
gchar *
mq_profiles_get_current(MqProfiles *profiles) G_GNUC_PURE;
+MqConfig *
+mq_profiles_get_current_config(MqProfiles *profiles) G_GNUC_PURE;
+
void
mq_profiles_set_name(MqProfiles *profiles, const gchar *profile,
const gchar *name);