From 136ec52c4a9081d6cc82325285c26938b7ece9ef Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 4 Dec 2010 10:58:06 +0100 Subject: [PATCH] Implemented GtkCalEx::add_calendar, GtkCalEx::remove_calendar and GtkCalEx::get_calendars. Implemented GtkCalEx::add_category, GtkCalEx::remove_category and GtkCalEx::get_categories. Added some GtkDoc. --- src/gtkcalex.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++-- src/gtkcalex.h | 9 ++-- 2 files changed, 141 insertions(+), 6 deletions(-) diff --git a/src/gtkcalex.c b/src/gtkcalex.c index d2f419c..57d540c 100644 --- a/src/gtkcalex.c +++ b/src/gtkcalex.c @@ -61,9 +61,9 @@ struct _GtkCalExPrivate GtkWidget *view; - GList *calendars; - GList *categories; - GList *events; + GSList *calendars; + GSList *categories; + GSList *events; }; G_DEFINE_TYPE (GtkCalEx, gtk_calex, GTK_TYPE_BIN) @@ -164,6 +164,12 @@ gtk_calex_get_view_type (GtkCalEx *calex) return priv->view_type; } +/** + * gtk_calex_set_view_type: + * @calex: + * @type: + * + */ void gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type) { @@ -235,6 +241,11 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type) } } +/** + * gtk_calex_get_date: + * @calex: + * + */ GDate *gtk_calex_get_date (GtkCalEx *calex) { @@ -245,6 +256,12 @@ GDate return g_memdup (priv->date, sizeof (GDate)); } +/** + * gtk_calex_set_date: + * @calex: + * @date: + * + */ void gtk_calex_set_date (GtkCalEx *calex, GDate *date) { @@ -261,6 +278,120 @@ gtk_calex_set_date (GtkCalEx *calex, GDate *date) gtk_calex_view_set_date (GTK_CALEX_VIEW (priv->view), priv->date); } +/** + * gtk_calex_add_calendar: + * @calex: + * @calendar: + * + */ +void +gtk_calex_add_calendar (GtkCalEx *calex, GtkCalExCalendar *calendar) +{ + GtkCalExPrivate *priv; + + g_return_if_fail (IS_GTK_CALEX (calex)); + g_return_if_fail (IS_GTK_CALEX_CALENDAR (calendar)); + + priv = GTK_CALEX_GET_PRIVATE (calex); + + priv->calendars = g_slist_append (priv->calendars, calendar); +} + +/** + * gtk_calex_remove_calendar: + * @calex: + * @calendar: + * + */ +void +gtk_calex_remove_calendar (GtkCalEx *calex, GtkCalExCalendar *calendar) +{ + GtkCalExPrivate *priv; + + g_return_if_fail (IS_GTK_CALEX (calex)); + g_return_if_fail (IS_GTK_CALEX_CALENDAR (calendar)); + + priv = GTK_CALEX_GET_PRIVATE (calex); + + /* TODO remove before events of this calendar */ + + priv->calendars = g_slist_remove (priv->calendars, calendar); +} + +/** + * gtk_calex_get_calendars: + * @calex: + * + */ +GSList +*gtk_calex_get_calendars (GtkCalEx *calex) +{ + GtkCalExPrivate *priv; + + g_return_val_if_fail (IS_GTK_CALEX (calex), NULL); + + priv = GTK_CALEX_GET_PRIVATE (calex); + + return priv->calendars; +} + +/** + * gtk_calex_add_category: + * @calex: + * @category: + * + */ +void +gtk_calex_add_category (GtkCalEx *calex, GtkCalExCategory *category) +{ + GtkCalExPrivate *priv; + + g_return_if_fail (IS_GTK_CALEX (calex)); + g_return_if_fail (IS_GTK_CALEX_CATEGORY (category)); + + priv = GTK_CALEX_GET_PRIVATE (calex); + + priv->categories = g_slist_append (priv->categories, category); +} + +/** + * gtk_calex_remove_category: + * @calex: + * @category: + * + */ +void +gtk_calex_remove_category (GtkCalEx *calex, GtkCalExCategory *category) +{ + GtkCalExPrivate *priv; + + g_return_if_fail (IS_GTK_CALEX (calex)); + g_return_if_fail (IS_GTK_CALEX_CATEGORY (category)); + + priv = GTK_CALEX_GET_PRIVATE (calex); + + /* TODO remove before events of this category */ + + priv->categories = g_slist_remove (priv->categories, category); +} + +/** + * gtk_calex_get_categories: + * @calex: + * + */ +GSList +*gtk_calex_get_categories (GtkCalEx *calex) +{ + GtkCalExPrivate *priv; + + g_return_val_if_fail (IS_GTK_CALEX (calex), NULL); + + priv = GTK_CALEX_GET_PRIVATE (calex); + + return priv->categories; +} + static void gtk_calex_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -290,6 +421,7 @@ gtk_calex_size_request (GtkWidget *widget, border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); requisition->width += (border_width * 2); requisition->height += (border_width * 2); + /*g_message("gtkcalex requisition %d %d",requisition->width,requisition->height);*/ } diff --git a/src/gtkcalex.h b/src/gtkcalex.h index e9b351d..0105691 100644 --- a/src/gtkcalex.h +++ b/src/gtkcalex.h @@ -73,17 +73,20 @@ void gtk_calex_set_date (GtkCalEx *calex, GDate *date); void gtk_calex_add_calendar (GtkCalEx *calex, GtkCalExCalendar *calendar); void gtk_calex_remove_calendar (GtkCalEx *calex, GtkCalExCalendar *calendar); -GList *gtk_calex_get_calendars (GtkCalEx *calex); +GSList *gtk_calex_get_calendars (GtkCalEx *calex); void gtk_calex_add_category (GtkCalEx *calex, GtkCalExCategory *category); void gtk_calex_remove_category (GtkCalEx *calex, GtkCalExCategory *category); -GList *gtk_calex_get_categories (GtkCalEx *calex); +GSList *gtk_calex_get_categories (GtkCalEx *calex); void gtk_calex_add_event (GtkCalEx *calex, GtkCalExEvent *event); void gtk_calex_remove_event (GtkCalEx *calex, GtkCalExEvent *event); -GList *gtk_calex_get_events (GtkCalEx *calex); +GSList *gtk_calex_get_events (GtkCalEx *calex); + +GSList *gtk_calex_get_events_by_calendar (GtkCalEx *calex, GtkCalExCalendar *calendar); +GSList *gtk_calex_get_events_by_category (GtkCalEx *calex, GtkCalExCategory *category); G_END_DECLS -- 2.49.0