aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Conti <jason.conti@gmail.com>2011-05-15 15:56:57 -0400
committerJason Conti <jason.conti@gmail.com>2011-05-15 15:56:57 -0400
commitf055a17dbc1fcd39fc279ce60d65e62268ff30aa (patch)
tree74debd5c6f9c6e3504dd7879d95155b946cc2863 /src
parent239dec68b0e37d20d07af51e4bc21200447b0aaa (diff)
downloadayatana-indicator-notifications-f055a17dbc1fcd39fc279ce60d65e62268ff30aa.tar.gz
ayatana-indicator-notifications-f055a17dbc1fcd39fc279ce60d65e62268ff30aa.tar.bz2
ayatana-indicator-notifications-f055a17dbc1fcd39fc279ce60d65e62268ff30aa.zip
Update indicator icon to unread when a message is received, and to read when the menu is hidden.
Diffstat (limited to 'src')
-rw-r--r--src/indicator-notifications.c22
-rw-r--r--src/notifications-interface.c6
-rw-r--r--src/notifications-interface.h5
-rw-r--r--src/notifications-service.c8
4 files changed, 30 insertions, 11 deletions
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 <http://www.gnu.org/licenses/>.
#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));