summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.c72
-rw-r--r--src/config.h16
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