From cb1da8552b56959f8f1c59a17fd4341f2aee611f Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Mon, 29 Aug 2011 11:11:43 -0400 Subject: * Simplified the indicator by removing the dbus service. Still needs: - Clear button - Message limit * GTK3 is having issues with the multi-line menu items. Adding a bit of a hack to calculate the size of the menu and resize it when an item is added. Still has some problems, but better than before. Will probably cause other issues that will need to be addressed later. --- src/dbus-spy.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/dbus-spy.c') diff --git a/src/dbus-spy.c b/src/dbus-spy.c index 4fe5141..e63a5ee 100644 --- a/src/dbus-spy.c +++ b/src/dbus-spy.c @@ -9,6 +9,13 @@ enum { LAST_SIGNAL }; +typedef struct _IdleMessage IdleMessage; +struct _IdleMessage +{ + DBusSpy *spy; + Notification *note; +}; + static guint signals[LAST_SIGNAL]; static void dbus_spy_class_init(DBusSpyClass *klass); @@ -22,6 +29,8 @@ static void bus_get_cb(GObject *source_object, GAsyncResult *res, gpointer user_ static GDBusMessage *message_filter(GDBusConnection *connection, GDBusMessage *message, gboolean incoming, gpointer user_data); +static gboolean idle_message_emit(gpointer user_data); + #define MATCH_STRING "type='method_call',interface='org.freedesktop.Notifications',member='Notify'" G_DEFINE_TYPE (DBusSpy, dbus_spy, G_TYPE_OBJECT); @@ -115,8 +124,10 @@ message_filter(GDBusConnection *connection, GDBusMessage *message, gboolean inco { DBusSpy *spy = DBUS_SPY(user_data); Notification *note = notification_new_from_dbus_message(message); - g_signal_emit(spy, signals[MESSAGE_RECEIVED], 0, note); - g_object_unref(note); + IdleMessage *im = g_new0(IdleMessage, 1); + im->spy = spy; + im->note = note; + g_idle_add(idle_message_emit, im); g_object_unref(message); message = NULL; } @@ -124,6 +135,18 @@ message_filter(GDBusConnection *connection, GDBusMessage *message, gboolean inco return message; } +static gboolean +idle_message_emit(gpointer user_data) +{ + IdleMessage *message = (IdleMessage *)user_data; + + g_signal_emit(message->spy, signals[MESSAGE_RECEIVED], 0, message->note); + + g_free(message); + + return FALSE; +} + static void dbus_spy_init(DBusSpy *self) { -- cgit v1.2.3