aboutsummaryrefslogtreecommitdiff
path: root/src/notification.c
diff options
context:
space:
mode:
authorJason Conti <jason.conti@gmail.com>2011-05-17 16:15:41 -0400
committerJason Conti <jason.conti@gmail.com>2011-05-17 16:15:41 -0400
commit0b1363e5bcf1096ae2b665c1ba4ca842cd704b6a (patch)
tree453adb3ed0c348dba733b419ea8ec1131e1c6850 /src/notification.c
parentafb06274937260e27cfb4ca16b36bfe133946fdd (diff)
downloadayatana-indicator-notifications-0b1363e5bcf1096ae2b665c1ba4ca842cd704b6a.tar.gz
ayatana-indicator-notifications-0b1363e5bcf1096ae2b665c1ba4ca842cd704b6a.tar.bz2
ayatana-indicator-notifications-0b1363e5bcf1096ae2b665c1ba4ca842cd704b6a.zip
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).
Diffstat (limited to 'src/notification.c')
-rw-r--r--src/notification.c21
1 files changed, 21 insertions, 0 deletions
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)
{