From 800ecf938ca27c577a7e9c80078c67ecea108dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Sun, 9 Jun 2013 23:00:29 -0400 Subject: [PATCH] gcal-view: add some API implementation Added GcalView:get_left_header and GcalView:get_right_header implementations to GcalMonthView and GcalYearView --- src/gcal-month-view.c | 35 +++++++++++++++++++++++++++++++++++ src/gcal-year-view.c | 24 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c index bdee2110..7f2e367f 100644 --- a/src/gcal-month-view.c +++ b/src/gcal-month-view.c @@ -133,6 +133,10 @@ static void gcal_month_view_clear_selection (GcalView *vie static void gcal_month_view_create_event_on_current_unit (GcalView *view); +static gchar* gcal_month_view_get_left_header (GcalView *view); + +static gchar* gcal_month_view_get_right_header (GcalView *view); + G_DEFINE_TYPE_WITH_CODE (GcalMonthView, gcal_month_view, GTK_TYPE_CONTAINER, @@ -217,6 +221,10 @@ gcal_view_interface_init (GcalViewIface *iface) iface->clear_selection = gcal_month_view_clear_selection; iface->create_event_on_current_unit = gcal_month_view_create_event_on_current_unit; + + /* New API */ + iface->get_left_header = gcal_month_view_get_left_header; + iface->get_right_header = gcal_month_view_get_right_header; } static void @@ -1400,6 +1408,33 @@ gcal_month_view_create_event_on_current_unit (GcalView *view) g_free (start_span); } +static gchar* +gcal_month_view_get_left_header (GcalView *view) +{ + GcalMonthViewPrivate *priv; + + gchar str_date[64]; + + struct tm tm_date; + + priv = GCAL_MONTH_VIEW (view)->priv; + + tm_date = icaltimetype_to_tm (priv->date); + e_utf8_strftime_fix_am_pm (str_date, 64, "%B", &tm_date); + + return g_strdup_printf ("%s", str_date); +} + +static gchar* +gcal_month_view_get_right_header (GcalView *view) +{ + GcalMonthViewPrivate *priv; + + priv = GCAL_MONTH_VIEW (view)->priv; + + return g_strdup_printf ("%d", priv->date->year); +} + /* Public API */ /** * gcal_month_view_new: diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c index 93af5453..0eb6e0fa 100644 --- a/src/gcal-year-view.c +++ b/src/gcal-year-view.c @@ -131,6 +131,10 @@ static void gcal_year_view_clear_selection (GcalView static void gcal_year_view_create_event_on_current_unit (GcalView *view); +static gchar* gcal_year_view_get_left_header (GcalView *view); + +static gchar* gcal_year_view_get_right_header (GcalView *view); + G_DEFINE_TYPE_WITH_CODE (GcalYearView, gcal_year_view, GTK_TYPE_CONTAINER, @@ -215,6 +219,10 @@ gcal_view_interface_init (GcalViewIface *iface) iface->clear_selection = gcal_year_view_clear_selection; iface->create_event_on_current_unit = gcal_year_view_create_event_on_current_unit; + + /* New API */ + iface->get_left_header = gcal_year_view_get_left_header; + iface->get_right_header = gcal_year_view_get_right_header; } static void @@ -1203,6 +1211,22 @@ gcal_year_view_create_event_on_current_unit (GcalView *view) g_free (end_span); } +static gchar* +gcal_year_view_get_left_header (GcalView *view) +{ + GcalYearViewPrivate *priv; + + priv = GCAL_YEAR_VIEW (view)->priv; + + return g_strdup_printf ("%d", priv->date->year); +} + +static gchar* +gcal_year_view_get_right_header (GcalView *view) +{ + return g_strdup (""); +} + /* Public API */ /** * gcal_year_view_new: