[gnome-calendar] year-view: implement GcalSubscriber extensions points



commit d9801d188b1417bb89105c25d5dee4bbfa1cc32b
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Mon Dec 29 16:32:17 2014 -0500

    year-view: implement GcalSubscriber extensions points
    
    In GcalSubscriber container implementation is needed to find out if an
    event will expand more than on cell on a view and on which cell it
    belongs. GcalSubscriber provides two vfuncs for its descendants to implement.

 src/gcal-year-view.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index 248851c..802b9f7 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -93,6 +93,13 @@ static gboolean       gcal_year_view_button_release               (GtkWidget
 
 static void           gcal_year_view_direction_changed            (GtkWidget        *widget,
                                                                    GtkTextDirection  previous_direction);
+
+static gboolean       gcal_year_view_is_child_multimonth          (GcalSubscriber  *subscriber,
+                                                                   GcalEventWidget *child);
+
+static guint          gcal_year_view_get_child_cell               (GcalSubscriber  *subscriber,
+                                                                   GcalEventWidget *child);
+
 static icaltimetype*  gcal_year_view_get_initial_date             (GcalView       *view);
 
 static icaltimetype*  gcal_year_view_get_final_date               (GcalView       *view);
@@ -126,9 +133,13 @@ event_opened (GcalEventWidget *event_widget,
 static void
 gcal_year_view_class_init (GcalYearViewClass *klass)
 {
+  GcalSubscriberClass *subscriber_class;
   GtkWidgetClass *widget_class;
   GObjectClass *object_class;
 
+  subscriber_class = GCAL_SUBSCRIBER_CLASS (klass);
+  subscriber_class->is_child_multicell = gcal_year_view_is_child_multimonth;
+  subscriber_class->get_child_cell = gcal_year_view_get_child_cell;
 
   widget_class = GTK_WIDGET_CLASS (klass);
   widget_class->realize = gcal_year_view_realize;
@@ -617,6 +628,28 @@ gcal_year_view_direction_changed (GtkWidget        *widget,
     priv->k = 1;
 }
 
+static gboolean
+gcal_year_view_is_child_multimonth (GcalSubscriber  *subscriber,
+                                    GcalEventWidget *child)
+{
+  const icaltimetype *dt_start, *dt_end;
+
+  dt_start = gcal_event_widget_peek_start_date (child);
+  dt_end = gcal_event_widget_peek_end_date (child);
+  if (dt_end == NULL)
+    return FALSE;
+
+  return dt_start->month != dt_end->month || dt_start->year != dt_end->year;
+}
+
+static guint
+gcal_year_view_get_child_cell (GcalSubscriber  *subscriber,
+                               GcalEventWidget *child)
+{
+  const icaltimetype *dt_start = gcal_event_widget_peek_start_date (child);
+  return dt_start->month;
+}
+
 /* GcalView Interface API */
 /**
  * gcal_year_view_get_initial_date:


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