From 719276fd17d2270ba2e50b41920a68b2b09df040 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Mon, 1 Nov 2010 14:58:21 +0100 Subject: [PATCH] Sterted managing view type week. --- src/gtkcalex.c | 18 +++++++++--------- src/gtkcalex.h | 2 +- src/gtkcalexviewday.c | 7 ++++++- src/gtkcalexviewday.h | 2 +- src/gtkcalexviewweek.c | 24 ++++++++++++++++++++++-- src/gtkcalexviewweek.h | 2 +- tests/test.c | 2 +- 7 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/gtkcalex.c b/src/gtkcalex.c index b9933fc..cd7d95c 100644 --- a/src/gtkcalex.c +++ b/src/gtkcalex.c @@ -223,17 +223,17 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type) g_object_unref (priv->view); priv->view = NULL; } - GtkCalExViewDay *vd = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date); + GtkCalExViewDay *vd = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, FALSE); priv->view = G_OBJECT (vd); break; - case GTK_CALEX_VIEW_TYPE_WORK_WEEK: + case GTK_CALEX_VIEW_TYPE_WORKING_WEEK: if (priv->view != NULL) { g_object_unref (priv->view); priv->view = NULL; } - GtkCalExViewDay *vww = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date); + GtkCalExViewDay *vww = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, TRUE); priv->view = G_OBJECT (vww); break; @@ -243,7 +243,7 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type) g_object_unref (priv->view); priv->view = NULL; } - GtkCalExViewDay *vw = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date); + GtkCalExViewWeek *vw = gtk_calex_view_week_new (priv->goo_canvas_root, priv->date); priv->view = G_OBJECT (vw); break; @@ -253,7 +253,7 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type) g_object_unref (priv->view); priv->view = NULL; } - GtkCalExViewDay *vm = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date); + GtkCalExViewDay *vm = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, FALSE); priv->view = G_OBJECT (vm); break; @@ -263,7 +263,7 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type) g_object_unref (priv->view); priv->view = NULL; } - GtkCalExViewDay *vl = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date); + GtkCalExViewDay *vl = gtk_calex_view_day_new (priv->goo_canvas_root, priv->date, FALSE); priv->view = G_OBJECT (vl); break; @@ -475,15 +475,15 @@ gtk_calex_size_allocate (GtkWidget *widget, static void gtk_calex_clean_canvas (GtkCalEx *gtk_calex) { - guint children; - guint i; + gint children; + gint i; g_return_if_fail (IS_GTK_CALEX (gtk_calex)); GtkCalExPrivate *priv = GTK_CALEX_GET_PRIVATE (gtk_calex); children = goo_canvas_item_get_n_children (priv->goo_canvas_root); - for (i = 0; i < children; i++) + for (i = children - 1; i >= 0; i--) { goo_canvas_item_remove (goo_canvas_item_get_child (priv->goo_canvas_root, i)); } diff --git a/src/gtkcalex.h b/src/gtkcalex.h index 5003996..14d3a0c 100644 --- a/src/gtkcalex.h +++ b/src/gtkcalex.h @@ -54,7 +54,7 @@ GtkWidget *gtk_calex_new (void); typedef enum { GTK_CALEX_VIEW_TYPE_DAY, - GTK_CALEX_VIEW_TYPE_WORK_WEEK, + GTK_CALEX_VIEW_TYPE_WORKING_WEEK, GTK_CALEX_VIEW_TYPE_WEEK, GTK_CALEX_VIEW_TYPE_MONTH, GTK_CALEX_VIEW_TYPE_LIST diff --git a/src/gtkcalexviewday.c b/src/gtkcalexviewday.c index 1b9b956..dc97185 100644 --- a/src/gtkcalexviewday.c +++ b/src/gtkcalexviewday.c @@ -49,6 +49,7 @@ struct _GtkCalExViewDayPrivate { GooCanvasItem *goo_canvas_root; GDate *date; + gboolean working_week; }; G_DEFINE_TYPE (GtkCalExViewDay, gtk_calex_view_day, G_TYPE_OBJECT) @@ -102,11 +103,14 @@ gtk_calex_view_day_get_property (GObject *object, guint property_id, GValue *val /** * gtk_calex_view_day_new: + * @root: + * @date: + * @working_week: * * Returns: the newly created #GtkCalExViewDay object. */ GtkCalExViewDay -*gtk_calex_view_day_new (GooCanvasItem *root, GDate *date) +*gtk_calex_view_day_new (GooCanvasItem *root, GDate *date, gboolean working_week) { GtkCalExViewDay *gtk_calex_view_day = GTK_CALEX_VIEW_DAY (g_object_new (gtk_calex_view_day_get_type (), NULL)); @@ -114,6 +118,7 @@ GtkCalExViewDay priv->goo_canvas_root = root; priv->date = date; + priv->working_week = working_week; gtk_calex_view_day_draw (gtk_calex_view_day); diff --git a/src/gtkcalexviewday.h b/src/gtkcalexviewday.h index 579aeb3..b8d92f7 100644 --- a/src/gtkcalexviewday.h +++ b/src/gtkcalexviewday.h @@ -52,7 +52,7 @@ struct _GtkCalExViewDayClass GType gtk_calex_view_day_get_type (void) G_GNUC_CONST; -GtkCalExViewDay *gtk_calex_view_day_new (GooCanvasItem *root, GDate *date); +GtkCalExViewDay *gtk_calex_view_day_new (GooCanvasItem *root, GDate *date, gboolean working_week); G_END_DECLS diff --git a/src/gtkcalexviewweek.c b/src/gtkcalexviewweek.c index bf3c4e6..59de39b 100644 --- a/src/gtkcalexviewweek.c +++ b/src/gtkcalexviewweek.c @@ -41,13 +41,16 @@ static void gtk_calex_view_week_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static void gtk_calex_view_week_draw (GtkCalExViewWeek *gtk_calex_view_week); + #define GTK_CALEX_VIEW_WEEK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_CALEX_VIEW_WEEK, GtkCalExViewWeekPrivate)) typedef struct _GtkCalExViewWeekPrivate GtkCalExViewWeekPrivate; struct _GtkCalExViewWeekPrivate { - gpointer foo; + GooCanvasItem *goo_canvas_root; + GDate *date; }; G_DEFINE_TYPE (GtkCalExViewWeek, gtk_calex_view_week, G_TYPE_OBJECT) @@ -101,13 +104,30 @@ gtk_calex_view_week_get_property (GObject *object, guint property_id, GValue *va /** * gtk_calex_view_week_new: + * @root: + * @date: * * Returns: the newly created #GtkCalExViewWeek object. */ GtkCalExViewWeek -*gtk_calex_view_week_new () +*gtk_calex_view_week_new (GooCanvasItem *root, GDate *date) { GtkCalExViewWeek *gtk_calex_view_week = GTK_CALEX_VIEW_WEEK (g_object_new (gtk_calex_view_week_get_type (), NULL)); + GtkCalExViewWeekPrivate *priv = GTK_CALEX_VIEW_WEEK_GET_PRIVATE (gtk_calex_view_week); + + priv->goo_canvas_root = root; + priv->date = date; + + gtk_calex_view_week_draw (gtk_calex_view_week); + return gtk_calex_view_week; } + +static void +gtk_calex_view_week_draw (GtkCalExViewWeek *gtk_calex_view_week) +{ + g_return_if_fail (IS_GTK_CALEX_VIEW_WEEK (gtk_calex_view_week)); + + GtkCalExViewWeekPrivate *priv = GTK_CALEX_VIEW_WEEK_GET_PRIVATE (gtk_calex_view_week); +} diff --git a/src/gtkcalexviewweek.h b/src/gtkcalexviewweek.h index e6352d7..31e86b3 100644 --- a/src/gtkcalexviewweek.h +++ b/src/gtkcalexviewweek.h @@ -50,7 +50,7 @@ struct _GtkCalExViewWeekClass GType gtk_calex_view_week_get_type (void) G_GNUC_CONST; -GtkCalExViewWeek *gtk_calex_view_week_new (void); +GtkCalExViewWeek *gtk_calex_view_week_new (GooCanvasItem *root, GDate *date); G_END_DECLS diff --git a/tests/test.c b/tests/test.c index 8d7986b..f04cf61 100644 --- a/tests/test.c +++ b/tests/test.c @@ -33,7 +33,7 @@ G_MODULE_EXPORT void on_tbtn_view_type_wweek_toggled (GtkToggleToolButton *toggle_tool_button, gpointer user_data) { - gtk_calex_set_view_type (GTK_CALEX (calex), GTK_CALEX_VIEW_TYPE_WORK_WEEK); + gtk_calex_set_view_type (GTK_CALEX (calex), GTK_CALEX_VIEW_TYPE_WORKING_WEEK); } G_MODULE_EXPORT void -- 2.49.0