I have a problem using Glib. I want to subscribe to a dbus signal without launching the mainloop with g_main_loop_run.
I create the connection to the correct bus and call the function g_dbus_connection_signal_subscribe.
I replaced the call to g_main_loop_run in the main function by a while(1).
Unfortunately, it's not working. If I understand correctly the GLib, there is no need to launch the mainloop for a such treatment.
Please help.
Sample code :
session_bus = g_bus_get_sync(G_BUS_TYPE_SESSION,
NULL,
NULL );
g_dbus_connection_signal_subscribe(session_bus,
"org.freedesktop.Notifications",
"org.freedesktop.Notifications",
"NotificationClosed",
"/org/freedesktop/Notifications",
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
(GDBusSignalCallback) onNotifClosed,
NULL,
NULL );
loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);
g_main_loop_unref(loop);
g_object_unref(session_bus);