[almanah] Include the event time as new design suggest (#680845)



commit f93cab82dc8a0c905331038e9959a3004b7671da
Author: Ãlvaro PeÃa <alvaropg gmail com>
Date:   Wed Aug 1 18:16:37 2012 +0200

    Include the event time as new design suggest (#680845)

 src/event-factories/calendar.c    |    2 +-
 src/event.c                       |    8 ++++++++
 src/event.h                       |    2 ++
 src/events/calendar-appointment.c |   15 +++++++++++++++
 src/events/calendar-task.c        |   18 +++++++++++++++++-
 src/events/calendar-task.h        |    2 +-
 src/main-window.c                 |    2 +-
 7 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/src/event-factories/calendar.c b/src/event-factories/calendar.c
index 7997350..bbfe159 100644
--- a/src/event-factories/calendar.c
+++ b/src/event-factories/calendar.c
@@ -128,7 +128,7 @@ get_events (AlmanahEventFactory *event_factory, GDate *date)
 			/* Have to filter out tasks by date */
 			if (calendar_event->event.task.start_time <= today_time &&
 			    (calendar_event->event.task.completed_time == 0 || calendar_event->event.task.completed_time >= yesterday_time)) {
-				event = ALMANAH_EVENT (almanah_calendar_task_event_new (calendar_event->event.task.uid, calendar_event->event.task.summary));
+				event = ALMANAH_EVENT (almanah_calendar_task_event_new (calendar_event->event.task.uid, calendar_event->event.task.summary, calendar_event->event.task.start_time));
 			} else {
 				event = NULL;
 			}
diff --git a/src/event.c b/src/event.c
index 9bc1665..42bd22b 100644
--- a/src/event.c
+++ b/src/event.c
@@ -94,6 +94,14 @@ almanah_event_format_value (AlmanahEvent *self)
 	return klass->format_value (self);
 }
 
+const gchar *
+almanah_event_format_time (AlmanahEvent *self)
+{
+	AlmanahEventClass *klass = ALMANAH_EVENT_GET_CLASS (self);
+	g_assert (klass->format_time != NULL);
+	return klass->format_time (self);
+}
+
 gboolean
 almanah_event_view (AlmanahEvent *self, GtkWindow *parent_window)
 {
diff --git a/src/event.h b/src/event.h
index 53a1c2c..2d2f539 100644
--- a/src/event.h
+++ b/src/event.h
@@ -47,12 +47,14 @@ typedef struct {
 	const gchar *icon_name;
 
 	const gchar *(*format_value) (AlmanahEvent *event);
+	const gchar *(*format_time) (AlmanahEvent *event);
 	gboolean (*view) (AlmanahEvent *event, GtkWindow *parent_window);
 } AlmanahEventClass;
 
 GType almanah_event_get_type (void);
 
 const gchar *almanah_event_format_value (AlmanahEvent *self);
+const gchar *almanah_event_format_time (AlmanahEvent *self);
 gboolean almanah_event_view (AlmanahEvent *self, GtkWindow *parent_window);
 const gchar *almanah_event_get_name (AlmanahEvent *self);
 const gchar *almanah_event_get_description (AlmanahEvent *self);
diff --git a/src/events/calendar-appointment.c b/src/events/calendar-appointment.c
index f8dd521..6016f39 100644
--- a/src/events/calendar-appointment.c
+++ b/src/events/calendar-appointment.c
@@ -26,10 +26,12 @@
 
 static void almanah_calendar_appointment_event_finalize (GObject *object);
 static const gchar *almanah_calendar_appointment_event_format_value (AlmanahEvent *event);
+static const gchar *almanah_calendar_appointment_event_format_time (AlmanahEvent *event);
 static gboolean almanah_calendar_appointment_event_view (AlmanahEvent *event, GtkWindow *parent_window);
 
 struct _AlmanahCalendarAppointmentEventPrivate {
 	gchar *summary;
+	gchar *time;
 	GTime start_time;
 };
 
@@ -51,6 +53,7 @@ almanah_calendar_appointment_event_class_init (AlmanahCalendarAppointmentEventCl
 	event_class->icon_name = "appointment-new";
 
 	event_class->format_value = almanah_calendar_appointment_event_format_value;
+	event_class->format_time = almanah_calendar_appointment_event_format_time;
 	event_class->view = almanah_calendar_appointment_event_view;
 }
 
@@ -66,6 +69,7 @@ almanah_calendar_appointment_event_finalize (GObject *object)
 	AlmanahCalendarAppointmentEventPrivate *priv = ALMANAH_CALENDAR_APPOINTMENT_EVENT_GET_PRIVATE (object);
 
 	g_free (priv->summary);
+	g_free (priv->time);
 
 	/* Chain up to the parent class */
 	G_OBJECT_CLASS (almanah_calendar_appointment_event_parent_class)->finalize (object);
@@ -75,9 +79,14 @@ AlmanahCalendarAppointmentEvent *
 almanah_calendar_appointment_event_new (const gchar *summary, GTime start_time)
 {
 	AlmanahCalendarAppointmentEvent *event = g_object_new (ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, NULL);
+	struct tm utc_date_tm;
+
 	event->priv->summary = g_strdup (summary);
 	event->priv->start_time = start_time;
 
+	gmtime_r ((const time_t*) &(ALMANAH_CALENDAR_APPOINTMENT_EVENT (event)->priv->start_time), &utc_date_tm);
+	event->priv->time = g_strdup_printf ("%.2d:%.2d", utc_date_tm.tm_hour, utc_date_tm.tm_min);
+
 	return event;
 }
 
@@ -87,6 +96,12 @@ almanah_calendar_appointment_event_format_value (AlmanahEvent *event)
 	return ALMANAH_CALENDAR_APPOINTMENT_EVENT (event)->priv->summary;
 }
 
+static const gchar *
+almanah_calendar_appointment_event_format_time (AlmanahEvent *event)
+{
+	return ALMANAH_CALENDAR_APPOINTMENT_EVENT (event)->priv->time;
+}
+
 static gboolean
 almanah_calendar_appointment_event_view (AlmanahEvent *event, GtkWindow *parent_window)
 {
diff --git a/src/events/calendar-task.c b/src/events/calendar-task.c
index d07703b..351e2f7 100644
--- a/src/events/calendar-task.c
+++ b/src/events/calendar-task.c
@@ -26,11 +26,13 @@
 
 static void almanah_calendar_task_event_finalize (GObject *object);
 static const gchar *almanah_calendar_task_event_format_value (AlmanahEvent *event);
+static const gchar *almanah_calendar_task_event_format_time (AlmanahEvent *event);
 static gboolean almanah_calendar_task_event_view (AlmanahEvent *event, GtkWindow *parent_window);
 
 struct _AlmanahCalendarTaskEventPrivate {
 	gchar *uid;
 	gchar *summary;
+	gchar *time;
 };
 
 G_DEFINE_TYPE (AlmanahCalendarTaskEvent, almanah_calendar_task_event, ALMANAH_TYPE_EVENT)
@@ -51,6 +53,7 @@ almanah_calendar_task_event_class_init (AlmanahCalendarTaskEventClass *klass)
 	event_class->icon_name = "stock_task";
 
 	event_class->format_value = almanah_calendar_task_event_format_value;
+	event_class->format_time = almanah_calendar_task_event_format_time;
 	event_class->view = almanah_calendar_task_event_view;
 }
 
@@ -67,17 +70,24 @@ almanah_calendar_task_event_finalize (GObject *object)
 
 	g_free (priv->uid);
 	g_free (priv->summary);
+	g_free (priv->time);
 
 	/* Chain up to the parent class */
 	G_OBJECT_CLASS (almanah_calendar_task_event_parent_class)->finalize (object);
 }
 
 AlmanahCalendarTaskEvent *
-almanah_calendar_task_event_new (const gchar *uid, const gchar *summary)
+almanah_calendar_task_event_new (const gchar *uid, const gchar *summary, GTime start_time)
 {
 	AlmanahCalendarTaskEvent *event = g_object_new (ALMANAH_TYPE_CALENDAR_TASK_EVENT, NULL);
+	struct tm utc_date_tm;
+
 	event->priv->uid = g_strdup (uid);
 	event->priv->summary = g_strdup (summary);
+
+	gmtime_r ((const time_t*) &(start_time), &utc_date_tm);
+	event->priv->time = g_strdup_printf ("%.2d:%.2d", utc_date_tm.tm_hour, utc_date_tm.tm_min);
+
 	return event;
 }
 
@@ -87,6 +97,12 @@ almanah_calendar_task_event_format_value (AlmanahEvent *event)
 	return ALMANAH_CALENDAR_TASK_EVENT (event)->priv->summary;
 }
 
+static const gchar *
+almanah_calendar_task_event_format_time (AlmanahEvent *event)
+{
+	return ALMANAH_CALENDAR_TASK_EVENT (event)->priv->time;
+}
+
 static gboolean
 almanah_calendar_task_event_view (AlmanahEvent *event, GtkWindow *parent_window)
 {
diff --git a/src/events/calendar-task.h b/src/events/calendar-task.h
index 2e5b788..fdea4b1 100644
--- a/src/events/calendar-task.h
+++ b/src/events/calendar-task.h
@@ -46,7 +46,7 @@ typedef struct {
 } AlmanahCalendarTaskEventClass;
 
 GType almanah_calendar_task_event_get_type (void);
-AlmanahCalendarTaskEvent *almanah_calendar_task_event_new (const gchar *uid, const gchar *summary);
+AlmanahCalendarTaskEvent *almanah_calendar_task_event_new (const gchar *uid, const gchar *summary, GTime start_time);
 
 G_END_DECLS
 
diff --git a/src/main-window.c b/src/main-window.c
index 7d9f83a..a940787 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -1385,7 +1385,7 @@ mw_events_updated_cb (AlmanahEventManager *event_manager, AlmanahEventFactoryTyp
 				    1, almanah_event_get_icon_name (event),
 				    2, type_id,
 				    3, almanah_event_format_value (event),
-				    4, g_strdup_printf ("<small>%s</small>", almanah_event_get_name (event)),
+				    4, g_strdup_printf ("<small>%s @ %s</small>", almanah_event_format_time (event), almanah_event_get_name (event)),
 				    -1);
 
 		events_count++;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]