aboutsummaryrefslogtreecommitdiff
path: root/src/notification.c
diff options
context:
space:
mode:
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)
{