Simplify calendar views
We don't need a split subscription update step in GcalView anymore, since subscribers communicate range directly to the timeline now.
This commit is contained in:
+8
-17
@@ -788,28 +788,19 @@ gcal_manager_set_default_calendar (GcalManager *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_manager_set_subscriber:
|
||||
* gcal_manager_get_timeline:
|
||||
* @self: a #GcalManager
|
||||
* @subscriber: a #ECalDataModelSubscriber
|
||||
* @range_start: the start of the range
|
||||
* @range_end: the end of the range
|
||||
*
|
||||
* Sets the @subscriber to show events between @range_start
|
||||
* and @range_end.
|
||||
* Retrieves the default timeline of GNOME Calendar.
|
||||
*
|
||||
* Returns: (transfer none): a #GcalTimeline
|
||||
*/
|
||||
void
|
||||
gcal_manager_set_subscriber (GcalManager *self,
|
||||
ECalDataModelSubscriber *subscriber,
|
||||
time_t range_start,
|
||||
time_t range_end)
|
||||
GcalTimeline*
|
||||
gcal_manager_get_timeline (GcalManager *self)
|
||||
{
|
||||
GCAL_ENTRY;
|
||||
g_return_val_if_fail (GCAL_IS_MANAGER (self), NULL);
|
||||
|
||||
g_return_if_fail (GCAL_IS_MANAGER (self));
|
||||
|
||||
gcal_timeline_add_subscriber (self->timeline, GCAL_TIMELINE_SUBSCRIBER (subscriber));
|
||||
|
||||
GCAL_EXIT;
|
||||
return self->timeline;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,10 +43,7 @@ GcalCalendar* gcal_manager_get_default_calendar (GcalManager
|
||||
void gcal_manager_set_default_calendar (GcalManager *self,
|
||||
GcalCalendar *calendar);
|
||||
|
||||
void gcal_manager_set_subscriber (GcalManager *self,
|
||||
ECalDataModelSubscriber *subscriber,
|
||||
time_t range_start,
|
||||
time_t range_end);
|
||||
GcalTimeline* gcal_manager_get_timeline (GcalManager *self);
|
||||
|
||||
void gcal_manager_set_query (GcalManager *self,
|
||||
const gchar *query);
|
||||
|
||||
+23
-6
@@ -30,6 +30,8 @@
|
||||
#include "gcal-month-view.h"
|
||||
#include "gcal-quick-add-popover.h"
|
||||
#include "gcal-search-button.h"
|
||||
#include "gcal-timeline.h"
|
||||
#include "gcal-timeline-subscriber.h"
|
||||
#include "gcal-view.h"
|
||||
#include "gcal-weather-settings.h"
|
||||
#include "gcal-week-view.h"
|
||||
@@ -121,6 +123,7 @@ struct _GcalWindow
|
||||
/* day, week, month, year, list */
|
||||
GtkWidget *views [6];
|
||||
GtkWidget *edit_dialog;
|
||||
gboolean subscribed;
|
||||
|
||||
GcalContext *context;
|
||||
GcalWindowView active_view;
|
||||
@@ -233,6 +236,23 @@ update_today_button_sensitive (GcalWindow *window)
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_add_subscribers_to_timeline (GcalWindow *self)
|
||||
{
|
||||
GcalTimeline *timeline;
|
||||
|
||||
if (self->subscribed)
|
||||
return;
|
||||
|
||||
|
||||
timeline = gcal_manager_get_timeline (gcal_context_get_manager (self->context));
|
||||
gcal_timeline_add_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->week_view));
|
||||
gcal_timeline_add_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->month_view));
|
||||
gcal_timeline_add_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->year_view));
|
||||
|
||||
self->subscribed = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_active_date (GcalWindow *window,
|
||||
GDateTime *new_date)
|
||||
@@ -248,15 +268,12 @@ update_active_date (GcalWindow *window,
|
||||
gcal_set_date_time (&window->active_date, new_date);
|
||||
|
||||
for (i = GCAL_WINDOW_VIEW_WEEK; i <= GCAL_WINDOW_VIEW_YEAR; i++)
|
||||
{
|
||||
GcalView *view = GCAL_VIEW (window->views[i]);
|
||||
|
||||
gcal_view_set_date (view, new_date);
|
||||
gcal_view_update_subscription (view);
|
||||
}
|
||||
gcal_view_set_date (GCAL_VIEW (window->views[i]), new_date);
|
||||
|
||||
update_today_button_sensitive (window);
|
||||
|
||||
maybe_add_subscribers_to_timeline (window);
|
||||
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
|
||||
@@ -1202,32 +1202,6 @@ gcal_month_view_get_children_by_uuid (GcalView *view,
|
||||
return filter_event_list_by_uid_and_modtype (children, mod, uuid);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_month_view_update_subscription (GcalView *view)
|
||||
{
|
||||
g_autoptr (GDateTime) date_start = NULL;
|
||||
g_autoptr (GDateTime) date_end = NULL;
|
||||
GcalMonthView *self;
|
||||
time_t range_start;
|
||||
time_t range_end;
|
||||
|
||||
self = GCAL_MONTH_VIEW (view);
|
||||
|
||||
g_assert (self->date != NULL);
|
||||
date_start = g_date_time_new_local (g_date_time_get_year (self->date),
|
||||
g_date_time_get_month (self->date),
|
||||
1, 0, 0, 0);
|
||||
range_start = g_date_time_to_unix (date_start);
|
||||
|
||||
date_end = g_date_time_add_months (date_start, 1);
|
||||
range_end = g_date_time_to_unix (date_end);
|
||||
|
||||
gcal_manager_set_subscriber (gcal_context_get_manager (self->context),
|
||||
E_CAL_DATA_MODEL_SUBSCRIBER (self),
|
||||
range_start,
|
||||
range_end);
|
||||
}
|
||||
|
||||
static GDateTime*
|
||||
gcal_month_view_get_next_date (GcalView *view)
|
||||
{
|
||||
@@ -1254,7 +1228,6 @@ gcal_view_interface_init (GcalViewInterface *iface)
|
||||
iface->set_date = gcal_month_view_set_date;
|
||||
iface->clear_marks = gcal_month_view_clear_marks;
|
||||
iface->get_children_by_uuid = gcal_month_view_get_children_by_uuid;
|
||||
iface->update_subscription = gcal_month_view_update_subscription;
|
||||
iface->get_next_date = gcal_month_view_get_next_date;
|
||||
iface->get_previous_date = gcal_month_view_get_previous_date;
|
||||
}
|
||||
|
||||
@@ -192,25 +192,6 @@ gcal_view_get_children_by_uuid (GcalView *view,
|
||||
return GCAL_VIEW_GET_IFACE (view)->get_children_by_uuid (view, mod, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_view_update_subscription:
|
||||
* @self: a #GcalView
|
||||
*
|
||||
* Asks @self to update its #ECalDataModel subscription range. This
|
||||
* is called after gcal_view_set_date(), and it's safe to assume that
|
||||
* @self's active date is correct.
|
||||
*/
|
||||
void
|
||||
gcal_view_update_subscription (GcalView *self)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_VIEW (self));
|
||||
g_return_if_fail (GCAL_VIEW_GET_IFACE (self)->update_subscription);
|
||||
|
||||
g_debug ("Updating subscription of %s", G_OBJECT_TYPE_NAME (self));
|
||||
|
||||
GCAL_VIEW_GET_IFACE (self)->update_subscription (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_view_get_next_date:
|
||||
* @self: a #GcalView
|
||||
|
||||
@@ -48,8 +48,6 @@ struct _GcalViewInterface
|
||||
void (*set_date) (GcalView *view,
|
||||
GDateTime *date);
|
||||
|
||||
void (*update_subscription) (GcalView *self);
|
||||
|
||||
GDateTime* (*get_next_date) (GcalView *self);
|
||||
|
||||
GDateTime* (*get_previous_date) (GcalView *self);
|
||||
@@ -75,8 +73,6 @@ GList* gcal_view_get_children_by_uuid (GcalView
|
||||
GcalRecurrenceModType mod,
|
||||
const gchar *uuid);
|
||||
|
||||
void gcal_view_update_subscription (GcalView *self);
|
||||
|
||||
GDateTime* gcal_view_get_next_date (GcalView *self);
|
||||
|
||||
GDateTime* gcal_view_get_previous_date (GcalView *self);
|
||||
|
||||
@@ -230,28 +230,6 @@ gcal_week_view_clear_marks (GcalView *view)
|
||||
gcal_week_grid_clear_marks (GCAL_WEEK_GRID (self->week_grid));
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_week_view_update_subscription (GcalView *view)
|
||||
{
|
||||
g_autoptr (GDateTime) date_start = NULL;
|
||||
g_autoptr (GDateTime) date_end = NULL;
|
||||
GcalWeekView *self;
|
||||
time_t range_start;
|
||||
time_t range_end;
|
||||
|
||||
self = GCAL_WEEK_VIEW (view);
|
||||
date_start = gcal_date_time_get_start_of_week (self->date);
|
||||
range_start = g_date_time_to_unix (date_start);
|
||||
|
||||
date_end = gcal_date_time_get_end_of_week (self->date);
|
||||
range_end = g_date_time_to_unix (date_end);
|
||||
|
||||
gcal_manager_set_subscriber (gcal_context_get_manager (self->context),
|
||||
E_CAL_DATA_MODEL_SUBSCRIBER (self),
|
||||
range_start,
|
||||
range_end);
|
||||
}
|
||||
|
||||
static GDateTime*
|
||||
gcal_week_view_get_next_date (GcalView *view)
|
||||
{
|
||||
@@ -278,7 +256,6 @@ gcal_view_interface_init (GcalViewInterface *iface)
|
||||
iface->set_date = gcal_week_view_set_date;
|
||||
iface->get_children_by_uuid = gcal_week_view_get_children_by_uuid;
|
||||
iface->clear_marks = gcal_week_view_clear_marks;
|
||||
iface->update_subscription = gcal_week_view_update_subscription;
|
||||
iface->get_next_date = gcal_week_view_get_next_date;
|
||||
iface->get_previous_date = gcal_week_view_get_previous_date;
|
||||
}
|
||||
|
||||
@@ -1787,28 +1787,6 @@ gcal_year_view_get_children_by_uuid (GcalView *view,
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_year_view_update_subscription (GcalView *view)
|
||||
{
|
||||
g_autoptr (GDateTime) date_start = NULL;
|
||||
g_autoptr (GDateTime) date_end = NULL;
|
||||
GcalYearView *self;
|
||||
time_t range_start;
|
||||
time_t range_end;
|
||||
|
||||
self = GCAL_YEAR_VIEW (view);
|
||||
date_start = g_date_time_new_local (g_date_time_get_year (self->date), 1, 1, 0, 0, 0);
|
||||
range_start = g_date_time_to_unix (date_start);
|
||||
|
||||
date_end = g_date_time_add_years (date_start, 1);
|
||||
range_end = g_date_time_to_unix (date_end);
|
||||
|
||||
gcal_manager_set_subscriber (gcal_context_get_manager (self->context),
|
||||
E_CAL_DATA_MODEL_SUBSCRIBER (self),
|
||||
range_start,
|
||||
range_end);
|
||||
}
|
||||
|
||||
static GDateTime*
|
||||
gcal_year_view_get_next_date (GcalView *view)
|
||||
{
|
||||
@@ -1831,11 +1809,9 @@ gcal_year_view_get_previous_date (GcalView *view)
|
||||
static void
|
||||
gcal_view_interface_init (GcalViewInterface *iface)
|
||||
{
|
||||
/* FIXME: implement what's needed */
|
||||
iface->get_date = gcal_year_view_get_date;
|
||||
iface->set_date = gcal_year_view_set_date;
|
||||
iface->get_children_by_uuid = gcal_year_view_get_children_by_uuid;
|
||||
iface->update_subscription = gcal_year_view_update_subscription;
|
||||
iface->get_next_date = gcal_year_view_get_next_date;
|
||||
iface->get_previous_date = gcal_year_view_get_previous_date;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user