summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-04 18:37:35 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-04 18:37:35 (EDT)
commitfe7427fa6ceeb8567e9ed53397226ae2f29f0ff7 (patch)
tree055a28ca74706428bfdb115c53a3a5a210f8c61d /src
parentbe5124c5764727f41b6583e5bc9b377a69fd5c7c (diff)
downloadmarquee-fe7427fa6ceeb8567e9ed53397226ae2f29f0ff7.zip
marquee-fe7427fa6ceeb8567e9ed53397226ae2f29f0ff7.tar.gz
marquee-fe7427fa6ceeb8567e9ed53397226ae2f29f0ff7.tar.bz2
mq_profiles_get_default(): New function
Diffstat (limited to 'src')
-rw-r--r--src/config/profiles.c23
-rw-r--r--src/config/profiles.h3
2 files changed, 26 insertions, 0 deletions
diff --git a/src/config/profiles.c b/src/config/profiles.c
index 36d3293..171b3aa 100644
--- a/src/config/profiles.c
+++ b/src/config/profiles.c
@@ -109,6 +109,29 @@ mq_profiles_is_default(MqProfiles *profiles, const gchar *profile)
NULL);
}
+gchar *
+mq_profiles_get_default(MqProfiles *profiles)
+{
+ gchar *def;
+ gchar **ids;
+ gsize length;
+ gsize i;
+
+ def = NULL;
+
+ ids = g_key_file_get_groups(profiles->key_file, &length);
+ for (i = 0; i < length; ++i) {
+ if (g_key_file_get_boolean(profiles->key_file, ids[i],
+ "default", NULL)) {
+ def = g_strdup(ids[i]);
+ break;
+ }
+ }
+ g_strfreev(ids);
+
+ return def;
+}
+
void
mq_profiles_set_name(MqProfiles *profiles, const gchar *profile,
const gchar *name)
diff --git a/src/config/profiles.h b/src/config/profiles.h
index 6783b10..9fa5ce1 100644
--- a/src/config/profiles.h
+++ b/src/config/profiles.h
@@ -43,6 +43,9 @@ mq_profiles_get_color(MqProfiles *profiles, const gchar *profile);
gboolean
mq_profiles_is_default(MqProfiles *profiles, const gchar *profile);
+gchar *
+mq_profiles_get_default(MqProfiles *profiles);
+
void
mq_profiles_set_name(MqProfiles *profiles, const gchar *profile,
const gchar *name);