diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-04 13:50:53 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-04 13:50:53 (EDT) |
commit | f392135bc44e66558fe19c3418964b7e3c0820b2 (patch) | |
tree | f59ff0d24cbdb85edf81d70655ce071edb2ab1f3 | |
parent | 925f3333f6330aea8ebc3fb7a5091a5ba9147b84 (diff) | |
download | marquee-f392135bc44e66558fe19c3418964b7e3c0820b2.zip marquee-f392135bc44e66558fe19c3418964b7e3c0820b2.tar.gz marquee-f392135bc44e66558fe19c3418964b7e3c0820b2.tar.bz2 |
src/config.c: Move hash table setup into new function
-rw-r--r-- | src/config.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/config.c b/src/config.c index 18e6875..701dc35 100644 --- a/src/config.c +++ b/src/config.c @@ -45,26 +45,33 @@ split_name(const gchar *name, gchar **group, gchar **key) } static void -set_boolean(MqConfig *config, const gchar *name, gboolean value) +add_type_and_callbacks(MqConfig *config, const gchar *name, Type type) { - gchar *group; - gchar *key; ConfigItem *item; - split_name(name, &group, &key); - - g_key_file_set_boolean(config->key_file, group, name, value); - if (!config->types_and_cbs_set) { item = g_malloc(sizeof(*item)); - item->type = TYPE_BOOLEAN; - item-callbacks = NULL; + item->type = type; + item->callbacks = NULL; g_hash_table_insert(config->types_and_cbs, g_strdup(name), item); } } static void +set_boolean(MqConfig *config, const gchar *name, gboolean value) +{ + gchar *group; + gchar *key; + + split_name(name, &group, &key); + + g_key_file_set_boolean(config->key_file, group, name, value); + + add_type_and_callbacks(config, name, TYPE_BOOLEAN); +} + +static void set_defaults(MqConfig *config) { config->types_and_cbs_set = FALSE; |