diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-06 00:35:43 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-06 00:35:43 (EDT) |
commit | 0a2ccb6513e4db3adaa107f8a76d48eb1b711a8a (patch) | |
tree | 01ccc4b48abc29688445bc6ee8bebc29c9bd2f14 /src | |
parent | 56eb9f1b5347dc97bb2d37bfb3b80e6dd4981f3a (diff) | |
download | marquee-0a2ccb6513e4db3adaa107f8a76d48eb1b711a8a.zip marquee-0a2ccb6513e4db3adaa107f8a76d48eb1b711a8a.tar.gz marquee-0a2ccb6513e4db3adaa107f8a76d48eb1b711a8a.tar.bz2 |
mq_config_notify_*(): New functions
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 72 | ||||
-rw-r--r-- | src/config.h | 16 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index ff3b7ee..5bff673 100644 --- a/src/config.c +++ b/src/config.c @@ -424,3 +424,75 @@ mq_config_set(MqConfig *config, const gchar *name, const gchar *value) g_assert_not_reached(); return FALSE; } + +void +mq_config_notify_boolean(MqConfig *config, const gchar *name, + MqConfigBooleanCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_BOOLEAN); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.boolean_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} + +void +mq_config_notify_integer(MqConfig *config, const gchar *name, + MqConfigIntegerCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_INTEGER); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.integer_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} + +void +mq_config_notify_double(MqConfig *config, const gchar *name, + MqConfigDoubleCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_DOUBLE); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.double_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} + +void +mq_config_notify_string(MqConfig *config, const gchar *name, + MqConfigStringCallback callback, gpointer user_data) +{ + struct item *item; + struct callbacks *cbs; + + item = g_hash_table_lookup(config->types_and_cbs, name); + g_assert(item->type == TYPE_STRING); + + cbs = g_malloc(sizeof(*cbs)); + cbs->cb.string_cb = callback; + cbs->user_data = user_data; + cbs->next = item->callbacks; + + item->callbacks = cbs; +} diff --git a/src/config.h b/src/config.h index 1f1fb67..3a28d9e 100644 --- a/src/config.h +++ b/src/config.h @@ -76,4 +76,20 @@ mq_config_set_string(MqConfig *config, const gchar *name, const gchar *value); gboolean mq_config_set(MqConfig *config, const gchar *name, const gchar *value); +void +mq_config_notify_boolean(MqConfig *config, const gchar *name, + MqConfigBooleanCallback callback, gpointer user_data); + +void +mq_config_notify_integer(MqConfig *config, const gchar *name, + MqConfigIntegerCallback callback, gpointer user_data); + +void +mq_config_notify_double(MqConfig *config, const gchar *name, + MqConfigDoubleCallback callback, gpointer user_data); + +void +mq_config_notify_string(MqConfig *config, const gchar *name, + MqConfigStringCallback callback, gpointer user_data); + #endif |