From 425bde705a072effe6232cb3fa4fecdcb8849639 Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Tue, 17 May 2011 16:15:41 -0400 Subject: Adding a timestamp to the messages. Currently sends a timestamp string across dbus, but ideally it will send an integer, and the indicator can decide how to display it (time ago in words, custom time format, etc). --- src/notification.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/notification.c') diff --git a/src/notification.c b/src/notification.c index 10f83e8..d99a1f8 100644 --- a/src/notification.c +++ b/src/notification.c @@ -42,6 +42,7 @@ notification_init(Notification *self) self->priv->summary = NULL; self->priv->body = NULL; self->priv->expire_timeout = 0; + self->priv->timestamp = NULL; } static void @@ -69,6 +70,11 @@ notification_dispose(GObject *object) self->priv->body = NULL; } + if(self->priv->timestamp != NULL) { + g_date_time_unref(self->priv->timestamp); + self->priv->timestamp = NULL; + } + G_OBJECT_CLASS(notification_parent_class)->dispose(object); } @@ -83,6 +89,9 @@ notification_new_from_dbus_message(GDBusMessage *message) { Notification *self = notification_new(); + /* timestamp */ + self->priv->timestamp = g_date_time_new_now_local(); + GVariant *body = g_dbus_message_get_body(message); GVariant *child = NULL; g_assert(g_variant_is_of_type(body, G_VARIANT_TYPE_TUPLE)); @@ -146,6 +155,18 @@ notification_get_body(Notification *self) return self->priv->body; } +gint64 +notification_get_timestamp(Notification *self) +{ + return g_date_time_to_unix(self->priv->timestamp); +} + +gchar* +notification_timestamp_for_locale(Notification *self) +{ + return g_date_time_format(self->priv->timestamp, "%X %x"); +} + void notification_print(Notification *self) { -- cgit v1.2.3