[gnome-calendar/ui-rewrite] views: implemented :manager property



commit 89a3bb99495c04b41346f77dac0f358692ecbce3
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Thu Oct 16 01:38:33 2014 -0400

    views: implemented :manager property
    
    As explained before, this is only intended to keep a reference to the
    GcalManager instance of the application.
    Misc: fixed some documentation and whitespace issues

 src/gcal-month-view.c |   22 ++++++++++++++--------
 src/gcal-month-view.h |    4 +++-
 src/gcal-week-view.c  |   26 +++++++++++++++-----------
 src/gcal-week-view.h  |    4 +++-
 src/gcal-year-view.c  |   22 ++++++++++++++--------
 src/gcal-year-view.h  |    6 +++---
 6 files changed, 52 insertions(+), 32 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index f80e785..4d39921 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -25,8 +25,6 @@
 
 #include <glib/gi18n.h>
 
-#include <libecal/libecal.h>
-
 #include <math.h>
 
 typedef struct
@@ -52,12 +50,14 @@ typedef struct
 
   /* property */
   icaltimetype   *date;
+  GcalManager    *manager; /* weak reference */
 } GcalMonthViewPrivate;
 
 enum
 {
   PROP_0,
-  PROP_DATE  /* active-date inherited property */
+  PROP_DATE,  /* active-date inherited property */
+  PROP_MANAGER  /* manager inherited property */
 };
 
 static void           gcal_view_interface_init              (GcalViewIface  *iface);
@@ -173,10 +173,9 @@ gcal_month_view_class_init (GcalMonthViewClass *klass)
   container_class->forall = gcal_month_view_forall;
 
   g_object_class_override_property (object_class, PROP_DATE, "active-date");
+  g_object_class_override_property (object_class, PROP_MANAGER, "manager");
 }
 
-
-
 static void
 gcal_month_view_init (GcalMonthView *self)
 {
@@ -249,6 +248,11 @@ gcal_month_view_set_property (GObject       *object,
 
         break;
       }
+    case PROP_MANAGER:
+      {
+        priv->manager = g_value_get_pointer (value);
+        break;
+      }
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -1332,13 +1336,15 @@ gcal_month_view_will_add_event (GcalView        *view,
 /* Public API */
 /**
  * gcal_month_view_new:
+ * @manager: App singleton #GcalManager instance
  *
  * Since: 0.1
- * Return value: the new month view widget
+ * Create a new month view widget
+ *
  * Returns: (transfer full):
  **/
 GtkWidget*
-gcal_month_view_new (void)
+gcal_month_view_new (GcalManager *manager)
 {
-  return g_object_new (GCAL_TYPE_MONTH_VIEW, NULL);
+  return g_object_new (GCAL_TYPE_MONTH_VIEW, "manager", manager, NULL);
 }
diff --git a/src/gcal-month-view.h b/src/gcal-month-view.h
index 38694a1..cf5b50c 100644
--- a/src/gcal-month-view.h
+++ b/src/gcal-month-view.h
@@ -20,6 +20,8 @@
 #ifndef __GCAL_MONTH_VIEW_H__
 #define __GCAL_MONTH_VIEW_H__
 
+#include "gcal-manager.h"
+
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
@@ -49,7 +51,7 @@ struct _GcalMonthViewClass
 
 GType          gcal_month_view_get_type         (void);
 
-GtkWidget*     gcal_month_view_new              (void);
+GtkWidget*     gcal_month_view_new              (GcalManager *manager);
 
 G_END_DECLS
 
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index 716b47c..b131b07 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -25,8 +25,6 @@
 
 #include <glib/gi18n.h>
 
-#include <libecal/libecal.h>
-
 #include <math.h>
 
 #define ALL_DAY_CELLS_HEIGHT 40
@@ -40,7 +38,8 @@ static const double dashed [] =
 enum
 {
   PROP_0,
-  PROP_DATE
+  PROP_DATE,
+  PROP_MANAGER
 };
 
 struct _GcalWeekViewChild
@@ -71,6 +70,7 @@ typedef struct
 
   /* property */
   icaltimetype   *date;
+  GcalManager    *manager; /* weak referenced */
 
   GdkWindow      *event_window;
 
@@ -195,10 +195,9 @@ gcal_week_view_class_init (GcalWeekViewClass *klass)
   object_class->get_property = gcal_week_view_get_property;
 
   g_object_class_override_property (object_class, PROP_DATE, "active-date");
+  g_object_class_override_property (object_class, PROP_MANAGER, "manager");
 }
 
-
-
 static void
 gcal_week_view_init (GcalWeekView *self)
 {
@@ -291,7 +290,9 @@ gcal_week_view_set_property (GObject       *object,
                              const GValue  *value,
                              GParamSpec    *pspec)
 {
-  g_return_if_fail (GCAL_IS_WEEK_VIEW (object));
+  GcalWeekViewPrivate *priv;
+
+  priv = gcal_week_view_get_instance_private (GCAL_WEEK_VIEW (object));
 
   switch (property_id)
     {
@@ -300,6 +301,9 @@ gcal_week_view_set_property (GObject       *object,
           GCAL_WEEK_VIEW (object),
           g_value_dup_boxed (value));
       break;
+    case PROP_MANAGER:
+      priv->manager = g_value_get_pointer (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -1425,14 +1429,14 @@ gcal_week_view_will_add_event (GcalView        *view,
 /* Public API */
 /**
  * gcal_week_view_new:
- * @date:
+ * @manager: App singleton #GcalManager instance
+ *
+ * Create a week-view widget
  *
- * Since: 0.1
- * Return value: the new month view widget
  * Returns: (transfer full):
  **/
 GtkWidget*
-gcal_week_view_new (void)
+gcal_week_view_new (GcalManager *manager)
 {
-  return g_object_new (GCAL_TYPE_WEEK_VIEW, NULL);
+  return g_object_new (GCAL_TYPE_WEEK_VIEW, "manager", manager, NULL);
 }
diff --git a/src/gcal-week-view.h b/src/gcal-week-view.h
index ee67f50..7972a87 100644
--- a/src/gcal-week-view.h
+++ b/src/gcal-week-view.h
@@ -20,6 +20,8 @@
 #ifndef __GCAL_WEEK_VIEW_H__
 #define __GCAL_WEEK_VIEW_H__
 
+#include "gcal-manager.h"
+
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
@@ -46,7 +48,7 @@ struct _GcalWeekViewClass
 
 GType          gcal_week_view_get_type         (void);
 
-GtkWidget*     gcal_week_view_new              (void);
+GtkWidget*     gcal_week_view_new              (GcalManager *manager);
 
 G_END_DECLS
 
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index 10ad04e..0522dc0 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -42,6 +42,7 @@ typedef struct
 
   /* property */
   icaltimetype   *date;
+  GcalManager    *manager; /* weak reference */
 
   gint            clicked_cell;
 
@@ -52,7 +53,8 @@ typedef struct
 enum
 {
   PROP_0,
-  PROP_DATE  //active-date inherited property
+  PROP_DATE,  //active-date inherited property
+  PROP_MANAGER  //manager inherited property
 };
 
 static void           gcal_view_interface_init                    (GcalViewIface  *iface);
@@ -171,10 +173,9 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
   object_class->finalize = gcal_year_view_finalize;
 
   g_object_class_override_property (object_class, PROP_DATE, "active-date");
+  g_object_class_override_property (object_class, PROP_MANAGER, "manager");
 }
 
-
-
 static void
 gcal_year_view_init (GcalYearView *self)
 {
@@ -238,6 +239,9 @@ gcal_year_view_set_property (GObject       *object,
 
       priv->date = g_value_dup_boxed (value);
       break;
+    case PROP_MANAGER:
+      priv->manager = g_value_get_pointer (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -1035,19 +1039,21 @@ static gboolean
 gcal_year_view_will_add_event (GcalView        *view,
                                GcalEventWidget *event)
 {
-  ;
+  /* FIXME: implement me !!! */
+  return FALSE;
 }
 
 /* Public API */
 /**
  * gcal_year_view_new:
+ * @manager: App singleton #GcalManager instance
+ *
+ * Create the year view
  *
- * Since: 0.1
- * Return value: the new month view widget
  * Returns: (transfer full):
  **/
 GtkWidget*
-gcal_year_view_new (void)
+gcal_year_view_new (GcalManager *manager)
 {
-  return g_object_new (GCAL_TYPE_YEAR_VIEW, NULL);
+  return g_object_new (GCAL_TYPE_YEAR_VIEW, "manager", manager, NULL);
 }
diff --git a/src/gcal-year-view.h b/src/gcal-year-view.h
index 3b9b7d4..ddc12a8 100644
--- a/src/gcal-year-view.h
+++ b/src/gcal-year-view.h
@@ -20,9 +20,9 @@
 #ifndef __GCAL_YEAR_VIEW_H__
 #define __GCAL_YEAR_VIEW_H__
 
-#include <gtk/gtk.h>
+#include "gcal-manager.h"
 
-#include <libical/icaltime.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
@@ -51,7 +51,7 @@ struct _GcalYearViewClass
 
 GType          gcal_year_view_get_type         (void);
 
-GtkWidget*     gcal_year_view_new              (void);
+GtkWidget*     gcal_year_view_new              (GcalManager *manager);
 
 G_END_DECLS
 


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