@@ 20,10 20,6 @@
#include <stdint.h>
-void libnotif_init(void);
-
-char** libnotif_get_info(void);
-
-void libnotif_register_cb(void (*cb)(uint32_t id, const char* app_name, const char* summary, const char* body));
+void libnotif_init(void (*cb)(uint32_t id, const char* app_name, const char* summary, const char* body));
#endif
@@ 2,9 2,6 @@ project('notif', 'c', default_options :
inc = include_directories('inc')
gio = dependency('gio-2.0')
-threads = dependency('threads')
-
-deps = [gio, threads]
subdir = 'libnotif-1'
@@ 15,6 12,6 @@ shared_library(
meson.project_name(),
'src/notify.c',
include_directories : inc,
- dependencies : deps,
+ dependencies : gio,
install : true
)
@@ 27,7 27,6 @@
#include <gio/gio.h>
-static bool running = false;
static uint32_t id = 0;
static void (*callback)(uint32_t id, const char* app_name, const char* summary, const char* body) = NULL;
@@ 344,22 343,11 @@ static void name_lost(GDBusConnection* c
fprintf(stderr, "Lost connection for %s\n", name);
}
-static void* run(void* data) {
- (void) data;
- g_bus_own_name(G_BUS_TYPE_SESSION, "org.freedesktop.Notifications", G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE, NULL, name_acquired, name_lost, NULL, NULL);
- GMainLoop* loop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(loop);
- return NULL;
-}
-
-void libnotif_init(void) {
- if(!running) {
- running = true;
- pthread_t thread;
- pthread_create(&thread, NULL, run, NULL);
+void libnotif_init(void (*cb)(uint32_t id, const char* app_name, const char* summary, const char* body)) {
+ if(callback == NULL) {
+ callback = cb;
+ g_bus_own_name(G_BUS_TYPE_SESSION, "org.freedesktop.Notifications", G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE, NULL, name_acquired, name_lost, NULL, NULL);
+ GMainLoop* loop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(loop);
}
}
-
-void libnotif_register_cb(void (*cb)(uint32_t id, const char* app_name, const char* summary, const char* body)) {
- callback = cb;
-}