[gnome-calendar/ui-rewrite] gcal-view: add some API implementation



commit a64d2d736c1c9bf9e2657dbb0d3b7951113a4977
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Sun Jun 9 23:00:29 2013 -0400

    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(+), 0 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index bdee211..7f2e367 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 93af545..0eb6e0f 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:


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