From f055a17dbc1fcd39fc279ce60d65e62268ff30aa Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Sun, 15 May 2011 15:56:57 -0400 Subject: Update indicator icon to unread when a message is received, and to read when the menu is hidden. --- src/indicator-notifications.c | 22 +++++++++++++--------- src/notifications-interface.c | 6 ++++++ src/notifications-interface.h | 5 +++-- src/notifications-service.c | 8 ++++++++ 4 files changed, 30 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c index 2e75a97..01bddb7 100644 --- a/src/indicator-notifications.c +++ b/src/indicator-notifications.c @@ -129,17 +129,14 @@ indicator_notifications_class_init(IndicatorNotificationsClass *klass) static void menu_visible_notify_cb(GtkWidget *menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data) { - /* IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(user_data); */ - - g_debug("notify visible signal received"); + IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(user_data); gboolean visible; g_object_get(G_OBJECT(menu), "visible", &visible, NULL); - if(visible) { - g_debug("notify visible menu shown"); - } - else { - g_debug("notify visible menu hidden"); + if(!visible) { + if(self->priv->pixbuf_read != NULL) { + gtk_image_set_from_pixbuf(self->priv->image, self->priv->pixbuf_read); + } } } @@ -268,7 +265,14 @@ static void receive_signal(GDBusProxy *proxy, gchar *sender_name, gchar *signal_name, GVariant *parameters, gpointer user_data) { - /*IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(user_data);*/ + IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(user_data); + + g_debug("received signal '%s'", signal_name); + if(g_strcmp0(signal_name, "MessageAdded") == 0) { + if(self->priv->pixbuf_unread != NULL) { + gtk_image_set_from_pixbuf(self->priv->image, self->priv->pixbuf_unread); + } + } return; } diff --git a/src/notifications-interface.c b/src/notifications-interface.c index 6326bf2..d130049 100644 --- a/src/notifications-interface.c +++ b/src/notifications-interface.c @@ -178,6 +178,12 @@ notifications_interface_finalize(GObject *object) return; } +NotificationsInterface * +notifications_interface_new() +{ + return NOTIFICATIONS_INTERFACE(g_object_new(NOTIFICATIONS_INTERFACE_TYPE, NULL)); +} + void notifications_interface_message_added(NotificationsInterface *self) { diff --git a/src/notifications-interface.h b/src/notifications-interface.h index 7cce828..1af5824 100644 --- a/src/notifications-interface.h +++ b/src/notifications-interface.h @@ -47,8 +47,9 @@ struct _NotificationsInterface { NotificationsInterfacePrivate *priv; }; -GType notifications_interface_get_type(void); -void notifications_interface_message_added(NotificationsInterface *self); +GType notifications_interface_get_type(void); +NotificationsInterface *notifications_interface_new(); +void notifications_interface_message_added(NotificationsInterface *self); G_END_DECLS diff --git a/src/notifications-service.c b/src/notifications-service.c index 4e21de9..f0e82bf 100644 --- a/src/notifications-service.c +++ b/src/notifications-service.c @@ -33,6 +33,7 @@ with this program. If not, see . #include "dbus-shared.h" #include "dbus-spy.h" +#include "notifications-interface.h" #include "settings-shared.h" static IndicatorService *service = NULL; @@ -40,6 +41,7 @@ static GMainLoop *mainloop = NULL; static DbusmenuServer *server = NULL; static DbusmenuMenuitem *root = NULL; static DBusSpy *spy = NULL; +static NotificationsInterface *dbus = NULL; /* Global Items */ static DbusmenuMenuitem *clear_item = NULL; @@ -83,6 +85,8 @@ add_notification_item(gpointer user_data) item = NULL; } + notifications_interface_message_added(dbus); + g_object_unref(note); return FALSE; @@ -235,9 +239,13 @@ main(int argc, char **argv) spy = dbus_spy_new(); g_signal_connect(spy, DBUS_SPY_SIGNAL_MESSAGE_RECEIVED, G_CALLBACK(message_received_cb), NULL); + /* Setup the dbus interface */ + dbus = notifications_interface_new(); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_object_unref(G_OBJECT(dbus)); g_object_unref(G_OBJECT(spy)); g_object_unref(G_OBJECT(service)); g_object_unref(G_OBJECT(server)); -- cgit v1.2.3