[gnome-calendar] gcal-view: modified API
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] gcal-view: modified API
- Date: Thu, 4 Dec 2014 22:24:13 +0000 (UTC)
commit 9f530a5b8accef747b9bff59587d523930357503
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Tue Jun 18 10:43:18 2013 -0400
gcal-view: modified API
Implemented in views.
Reworked GcalDayView implementation to allow bigger
than days events.
src/gcal-day-view.c | 25 +++++++++++++------------
src/gcal-month-view.c | 48 +++++++++++++++++++++++++-----------------------
src/gcal-view.c | 42 +++++++++++++++++++++++-------------------
src/gcal-view.h | 9 +++++----
src/gcal-week-view.c | 22 +++++++++++++---------
src/gcal-window.c | 18 +++++++++++-------
src/gcal-year-view.c | 28 +++++++++++++++-------------
7 files changed, 105 insertions(+), 87 deletions(-)
---
diff --git a/src/gcal-day-view.c b/src/gcal-day-view.c
index f8b4f3e..e06f252 100644
--- a/src/gcal-day-view.c
+++ b/src/gcal-day-view.c
@@ -77,11 +77,14 @@ static icaltimetype* gcal_day_view_get_final_date (GcalView *view)
static gboolean gcal_day_view_contains_date (GcalView *view,
icaltimetype *date);
-
static gchar* gcal_day_view_get_left_header (GcalView *view);
static gchar* gcal_day_view_get_right_header (GcalView *view);
+static gboolean gcal_day_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date);
+
static GtkWidget* gcal_day_view_get_by_uuid (GcalView *view,
const gchar *uuid);
@@ -154,11 +157,11 @@ gcal_view_interface_init (GcalViewIface *iface)
/* New API */
iface->get_initial_date = gcal_day_view_get_initial_date;
iface->get_final_date = gcal_day_view_get_final_date;
- iface->contains_date = gcal_day_view_contains_date;
iface->get_left_header = gcal_day_view_get_left_header;
iface->get_right_header = gcal_day_view_get_right_header;
+ iface->draw_event = gcal_day_view_draw_event;
iface->get_by_uuid = gcal_day_view_get_by_uuid;
}
@@ -368,8 +371,9 @@ gcal_day_view_get_final_date (GcalView *view)
}
static gboolean
-gcal_day_view_contains_date (GcalView *view,
- icaltimetype *date)
+gcal_day_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date)
{
GcalDayViewPrivate *priv;
@@ -386,16 +390,13 @@ gcal_day_view_contains_date (GcalView *view,
return FALSE;
/* XXX: Check for date_only comparison since might drop timezone info */
- left_boundary = icaltime_compare_date_only (*first_day, *date);
- right_boundary = icaltime_compare_date_only (*date, *last_day);
+ left_boundary = icaltime_compare_date_only (*end_date, *first_day);
+ right_boundary = icaltime_compare_date_only (*last_day, *end_date);
- if ((left_boundary == -1 || left_boundary == 0) &&
- (right_boundary == -1 || right_boundary == 0))
- {
- return TRUE;
- }
+ if (left_boundary == -1 || right_boundary == -1)
+ return FALSE;
- return FALSE;
+ return TRUE;
}
static gchar*
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index d067e37..12ecd3c 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -117,13 +117,14 @@ static icaltimetype* gcal_month_view_get_initial_date (GcalView *vie
static icaltimetype* gcal_month_view_get_final_date (GcalView *view);
-static gboolean gcal_month_view_contains_date (GcalView *view,
- icaltimetype *date);
-
static gchar* gcal_month_view_get_left_header (GcalView *view);
static gchar* gcal_month_view_get_right_header (GcalView *view);
+static gboolean gcal_month_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date);
+
static GtkWidget* gcal_month_view_get_by_uuid (GcalView *view,
const gchar *uuid);
@@ -218,11 +219,11 @@ gcal_view_interface_init (GcalViewIface *iface)
/* New API */
iface->get_initial_date = gcal_month_view_get_initial_date;
iface->get_final_date = gcal_month_view_get_final_date;
- iface->contains_date = gcal_month_view_contains_date;
iface->get_left_header = gcal_month_view_get_left_header;
iface->get_right_header = gcal_month_view_get_right_header;
+ iface->draw_event = gcal_month_view_draw_event;
iface->get_by_uuid = gcal_month_view_get_by_uuid;
}
@@ -1099,7 +1100,7 @@ gcal_month_view_set_date (GcalMonthView *view,
will_resize = FALSE;
/* if span_updated: queue_resize */
- will_resize = ! gcal_month_view_contains_date (GCAL_VIEW (view), date);
+ will_resize = ! gcal_month_view_draw_event (GCAL_VIEW (view), date, NULL);
if (priv->date != NULL)
g_free (priv->date);
@@ -1125,7 +1126,7 @@ gcal_month_view_set_date (GcalMonthView *view,
child = (GcalViewChild*) l->data;
child_date =
gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
- if (! gcal_month_view_contains_date (GCAL_VIEW (view), child_date))
+ if (! gcal_month_view_draw_event (GCAL_VIEW (view), child_date, NULL))
to_remove = g_list_append (to_remove, child->widget);
}
}
@@ -1212,22 +1213,6 @@ gcal_month_view_get_final_date (GcalView *view)
return new_date;
}
-static gboolean
-gcal_month_view_contains_date (GcalView *view,
- icaltimetype *date)
-{
- GcalMonthViewPrivate *priv;
-
- g_return_val_if_fail (GCAL_IS_MONTH_VIEW (view), FALSE);
- priv = GCAL_MONTH_VIEW (view)->priv;
-
- if (priv->date == NULL)
- return FALSE;
-
- return (priv->date->month == date->month &&
- priv->date->year == date->year);
-}
-
static gchar*
gcal_month_view_get_left_header (GcalView *view)
{
@@ -1255,6 +1240,23 @@ gcal_month_view_get_right_header (GcalView *view)
return g_strdup_printf ("%d", priv->date->year);
}
+static gboolean
+gcal_month_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date)
+{
+ GcalMonthViewPrivate *priv;
+
+ g_return_val_if_fail (GCAL_IS_MONTH_VIEW (view), FALSE);
+ priv = GCAL_MONTH_VIEW (view)->priv;
+
+ if (priv->date == NULL)
+ return FALSE;
+
+ return (priv->date->month == start_date->month &&
+ priv->date->year == start_date->year);
+}
+
static GtkWidget*
gcal_month_view_get_by_uuid (GcalView *view,
const gchar *uuid)
@@ -1309,7 +1311,7 @@ gcal_month_view_reposition_child (GcalView *view,
date =
gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
- if (gcal_month_view_contains_date (view, date))
+ if (gcal_month_view_draw_event (view, date, NULL))
{
if (date->day - 1 == i)
{
diff --git a/src/gcal-view.c b/src/gcal-view.c
index 9302083..664481e 100644
--- a/src/gcal-view.c
+++ b/src/gcal-view.c
@@ -179,25 +179,6 @@ gcal_view_get_final_date (GcalView *view)
}
/**
- * gcal_view_contains_date:
- * @view: a #GcalView
- * @date: an #icaltimetype object
- *
- * Whether @date is contained in the time-range represented by @view
- *
- * Returns: %TRUE if it is, %FALSE otherwise
- **/
-gboolean
-gcal_view_contains_date (GcalView *view,
- icaltimetype *date)
-{
- g_return_val_if_fail (GCAL_IS_VIEW (view), FALSE);
- g_return_if_fail (GCAL_VIEW_GET_INTERFACE (view)->contains_date);
-
- return GCAL_VIEW_GET_INTERFACE (view)->contains_date (view, date);
-}
-
-/**
* gcal_view_mark_current_unit:
* @view: a #GcalView
*
@@ -264,6 +245,29 @@ gcal_view_get_right_header (GcalView *view)
}
/**
+ * gcal_view_draw_event:
+ * @view: a #GcalView
+ * @start_date: an #icaltimetype object. The starting date of the event
+ * @end_date: an #icaltimetype object. The edn-date of the event
+ *
+ * Whether the event within these boundaries will be drawn by the #GcalView implementation
+ *
+ * Returns: %TRUE if it is, %FALSE otherwise
+ **/
+gboolean
+gcal_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date)
+{
+ g_return_val_if_fail (GCAL_IS_VIEW (view), FALSE);
+ g_return_if_fail (GCAL_VIEW_GET_INTERFACE (view)->draw_event);
+
+ return GCAL_VIEW_GET_INTERFACE (view)->draw_event (view,
+ start_date,
+ end_date);
+}
+
+/**
* gcal_view_get_by_uuid:
* @view: a #GcalView
* @uuid: the uuid of the event-widget
diff --git a/src/gcal-view.h b/src/gcal-view.h
index 2914a67..3dc72a0 100644
--- a/src/gcal-view.h
+++ b/src/gcal-view.h
@@ -63,7 +63,6 @@ struct _GcalViewIface
/* Time handling related API */
icaltimetype* (*get_initial_date) (GcalView *view);
icaltimetype* (*get_final_date) (GcalView *view);
- gboolean (*contains_date) (GcalView *view, icaltimetype *date);
/* Marks related API */
void (*mark_current_unit) (GcalView *view);
@@ -74,6 +73,7 @@ struct _GcalViewIface
gchar* (*get_right_header) (GcalView *view);
/* Container functions related API */
+ gboolean (*draw_event) (GcalView *view, icaltimetype *start_date,
icaltimetype *end_date);
GtkWidget* (*get_by_uuid) (GcalView *view, const gchar *uuid);
};
@@ -99,9 +99,6 @@ icaltimetype* gcal_view_get_initial_date (GcalView *view);
icaltimetype* gcal_view_get_final_date (GcalView *view);
-gboolean gcal_view_contains_date (GcalView *view,
- icaltimetype *date);
-
void gcal_view_mark_current_unit (GcalView *view);
void gcal_view_clear_mark (GcalView *view);
@@ -110,6 +107,10 @@ gchar* gcal_view_get_left_header (GcalView *view);
gchar* gcal_view_get_right_header (GcalView *view);
+gboolean gcal_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date);
+
GtkWidget* gcal_view_get_by_uuid (GcalView *view,
const gchar *uuid);
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index 09ae392..0f9a3ca 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -149,8 +149,9 @@ static icaltimetype* gcal_week_view_get_initial_date (GcalView *view
static icaltimetype* gcal_week_view_get_final_date (GcalView *view);
-static gboolean gcal_week_view_contains_date (GcalView *view,
- icaltimetype *date);
+static gboolean gcal_week_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date);
static GtkWidget* gcal_week_view_get_by_uuid (GcalView *view,
const gchar *uuid);
@@ -233,7 +234,8 @@ gcal_view_interface_init (GcalViewIface *iface)
{
iface->get_initial_date = gcal_week_view_get_initial_date;
iface->get_final_date = gcal_week_view_get_final_date;
- iface->contains_date = gcal_week_view_contains_date;
+
+ iface->draw_event = gcal_week_view_draw_event;
iface->get_by_uuid = gcal_week_view_get_by_uuid;
}
@@ -975,7 +977,7 @@ gcal_week_view_set_date (GcalWeekView *view,
will_resize = FALSE;
/* if span_updated: queue_resize */
- will_resize = ! gcal_week_view_contains_date (GCAL_VIEW (view), date);
+ will_resize = ! gcal_week_view_draw_event (GCAL_VIEW (view), date, NULL);
if (priv->date != NULL)
g_free (priv->date);
@@ -995,7 +997,7 @@ gcal_week_view_set_date (GcalWeekView *view,
child = (GcalWeekViewChild*) l->data;
child_date = gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
- if (! gcal_week_view_contains_date (GCAL_VIEW (view), child_date))
+ if (! gcal_week_view_draw_event (GCAL_VIEW (view), child_date, NULL))
to_remove = g_list_append (to_remove, child->widget);
}
}
@@ -1498,8 +1500,9 @@ gcal_week_view_get_final_date (GcalView *view)
}
static gboolean
-gcal_week_view_contains_date (GcalView *view,
- icaltimetype *date)
+gcal_week_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date)
{
GcalWeekViewPrivate *priv;
@@ -1508,8 +1511,9 @@ gcal_week_view_contains_date (GcalView *view,
if (priv->date == NULL)
return FALSE;
- if (icaltime_week_number (*(priv->date)) == icaltime_week_number (*date)
- && priv->date->year == date->year)
+
+ if (icaltime_week_number (*(priv->date)) == icaltime_week_number (*start_date)
+ && priv->date->year == start_date->year)
{
return TRUE;
}
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 081f297..aba230a 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -688,7 +688,8 @@ gcal_window_events_added (GcalManager *manager,
GcalView *view;
GtkWidget *event;
- icaltimetype *starting_date;
+ icaltimetype *start_date;
+ icaltimetype *end_date;
priv = GCAL_WINDOW (user_data)->priv;
view = GCAL_VIEW (priv->views[priv->active_view]);
@@ -698,16 +699,19 @@ gcal_window_events_added (GcalManager *manager,
tokens = g_strsplit ((gchar*) l->data, ":", -1);
source_uid = tokens[0];
event_uid = tokens[1];
- starting_date = gcal_manager_get_event_start_date (manager,
- source_uid,
- event_uid);
+ start_date = gcal_manager_get_event_start_date (manager,
+ source_uid,
+ event_uid);
+ end_date = gcal_manager_get_event_end_date (manager,
+ source_uid,
+ event_uid);
/* FIXME: erase me */
/* g_debug ("add: %s with date %s", */
/* (gchar*) l->data, */
- /* icaltime_as_ical_string (*starting_date)); */
+ /* icaltime_as_ical_string (*start_date)); */
- if (gcal_view_contains_date (view, starting_date) &&
+ if (gcal_view_draw_event (view, start_date, end_date) &&
gcal_view_get_by_uuid (view, (gchar*)l->data) == NULL)
{
event = gcal_event_widget_new ((gchar*) l->data);
@@ -726,7 +730,7 @@ gcal_window_events_added (GcalManager *manager,
user_data);
}
- g_free (starting_date);
+ g_free (start_date);
g_strfreev (tokens);
}
}
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index 635fe86..31e59b3 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -115,8 +115,13 @@ static icaltimetype* gcal_year_view_get_initial_date (GcalView
static icaltimetype* gcal_year_view_get_final_date (GcalView *view);
-static gboolean gcal_year_view_contains_date (GcalView *view,
- icaltimetype *date);
+static gchar* gcal_year_view_get_left_header (GcalView *view);
+
+static gchar* gcal_year_view_get_right_header (GcalView *view);
+
+static gboolean gcal_year_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date);
static GtkWidget* gcal_year_view_get_by_uuid (GcalView *view,
const gchar *uuid);
@@ -129,10 +134,6 @@ 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,
@@ -213,11 +214,11 @@ gcal_view_interface_init (GcalViewIface *iface)
/* New API */
iface->get_initial_date = gcal_year_view_get_initial_date;
iface->get_final_date = gcal_year_view_get_final_date;
- iface->contains_date = gcal_year_view_contains_date;
iface->get_left_header = gcal_year_view_get_left_header;
iface->get_right_header = gcal_year_view_get_right_header;
+ iface->draw_event = gcal_year_view_draw_event;
iface->get_by_uuid = gcal_year_view_get_by_uuid;
}
@@ -758,7 +759,7 @@ gcal_year_view_set_date (GcalYearView *view,
will_resize = FALSE;
/* if span_updated: queue_resize */
- will_resize = ! gcal_year_view_contains_date (GCAL_VIEW (view), date);
+ will_resize = ! gcal_year_view_draw_event (GCAL_VIEW (view), date, NULL);
if (priv->date != NULL)
g_free (priv->date);
@@ -779,7 +780,7 @@ gcal_year_view_set_date (GcalYearView *view,
child = (GcalViewChild*) l->data;
child_date =
gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
- if (! gcal_year_view_contains_date (GCAL_VIEW (view), child_date))
+ if (! gcal_year_view_draw_event (GCAL_VIEW (view), child_date, NULL))
to_remove = g_list_append (to_remove, child->widget);
}
}
@@ -1023,8 +1024,9 @@ gcal_year_view_get_final_date (GcalView *view)
}
static gboolean
-gcal_year_view_contains_date (GcalView *view,
- icaltimetype *date)
+gcal_year_view_draw_event (GcalView *view,
+ icaltimetype *start_date,
+ icaltimetype *end_date)
{
GcalYearViewPrivate *priv;
@@ -1034,7 +1036,7 @@ gcal_year_view_contains_date (GcalView *view,
if (priv->date == NULL)
return FALSE;
- return priv->date->year == date->year;
+ return priv->date->year == start_date->year;
}
static GtkWidget*
@@ -1091,7 +1093,7 @@ gcal_year_view_reposition_child (GcalView *view,
date =
gcal_event_widget_get_date (GCAL_EVENT_WIDGET (child->widget));
- if (gcal_year_view_contains_date (view, date))
+ if (gcal_year_view_draw_event (view, date, NULL))
{
if (date->month - 1 == i)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]