aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-09-29 16:27:46 +0800
committerMilan Crha <mcrha@redhat.com>2010-09-29 16:27:46 +0800
commit42ab34061a48ccfc0763df1314cf5f60adb7acd3 (patch)
tree8364d364a40ddf365f49ef247a86df39c2b792bc /calendar/gui
parent29fcf7f35fb41d5fbf0c5faff42e3e5634329a1f (diff)
downloadgsoc2013-evolution-42ab34061a48ccfc0763df1314cf5f60adb7acd3.tar
gsoc2013-evolution-42ab34061a48ccfc0763df1314cf5f60adb7acd3.tar.gz
gsoc2013-evolution-42ab34061a48ccfc0763df1314cf5f60adb7acd3.tar.bz2
gsoc2013-evolution-42ab34061a48ccfc0763df1314cf5f60adb7acd3.tar.lz
gsoc2013-evolution-42ab34061a48ccfc0763df1314cf5f60adb7acd3.tar.xz
gsoc2013-evolution-42ab34061a48ccfc0763df1314cf5f60adb7acd3.tar.zst
gsoc2013-evolution-42ab34061a48ccfc0763df1314cf5f60adb7acd3.zip
Bug #629150 - Empty calendar view
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/e-day-view.c53
-rw-r--r--calendar/gui/e-day-view.h2
-rw-r--r--calendar/gui/e-week-view.c55
-rw-r--r--calendar/gui/e-week-view.h2
-rw-r--r--calendar/gui/gnome-cal.c17
5 files changed, 106 insertions, 23 deletions
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 25527765e1..ee27455d3f 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -772,6 +772,7 @@ time_range_changed_cb (ECalModel *model, time_t start_time, time_t end_time, gpo
if (!E_CALENDAR_VIEW (day_view)->in_focus) {
e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
return;
}
@@ -866,6 +867,8 @@ model_row_changed_cb (ETableModel *etm, gint row, gpointer user_data)
EDayView *day_view = E_DAY_VIEW (user_data);
if (!E_CALENDAR_VIEW (day_view)->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
return;
}
@@ -878,6 +881,8 @@ model_cell_changed_cb (ETableModel *etm, gint col, gint row, gpointer user_data)
EDayView *day_view = E_DAY_VIEW (user_data);
if (!E_CALENDAR_VIEW (day_view)->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
return;
}
@@ -892,6 +897,8 @@ model_rows_inserted_cb (ETableModel *etm, gint row, gint count, gpointer user_da
gint i;
if (!E_CALENDAR_VIEW (day_view)->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
return;
}
@@ -922,6 +929,8 @@ model_comps_deleted_cb (ETableModel *etm, gpointer data, gpointer user_data)
GSList *l, *list = data;
if (!E_CALENDAR_VIEW (day_view)->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
return;
}
@@ -964,8 +973,11 @@ timezone_changed_cb (ECalModel *cal_model, icaltimezone *old_zone,
g_return_if_fail (E_IS_DAY_VIEW (day_view));
- if (!cal_view->in_focus)
+ if (!cal_view->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
return;
+ }
/* If our time hasn't been set yet, just return. */
if (day_view->lower == 0 && day_view->upper == 0)
@@ -1311,6 +1323,8 @@ e_day_view_init (EDayView *day_view)
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
e_drag_dest_add_calendar_targets (day_view->main_canvas);
+
+ day_view->requires_update = FALSE;
}
static void
@@ -1941,6 +1955,22 @@ e_day_view_focus_in (GtkWidget *widget, GdkEventFocus *event)
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
#endif
+ if (E_CALENDAR_VIEW (day_view)->in_focus && day_view->requires_update) {
+ time_t my_start = 0, my_end = 0, model_start = 0, model_end = 0;
+
+ day_view->requires_update = FALSE;
+
+ e_cal_model_get_time_range (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), &model_start, &model_end);
+
+ if (e_calendar_view_get_visible_time_range (E_CALENDAR_VIEW (day_view), &my_start, &my_end) &&
+ model_start == my_start && model_end == my_end) {
+ /* update only when the same time range is set in a view and in a model;
+ otherwise time range change invokes also query update */
+ e_day_view_recalc_day_starts (day_view, day_view->lower);
+ e_day_view_update_query (day_view);
+ }
+ }
+
gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas);
@@ -2741,8 +2771,11 @@ e_day_view_set_mins_per_row (EDayView *day_view,
g_object_notify (G_OBJECT (day_view), "mins-per-row");
/* If we aren't visible, we'll sort it out later. */
- if (!E_CALENDAR_VIEW (day_view)->in_focus)
- return;
+ if (!E_CALENDAR_VIEW (day_view)->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
+ return;
+ }
for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++)
day_view->need_layout[day] = TRUE;
@@ -3802,8 +3835,13 @@ e_day_view_update_query (EDayView *day_view)
{
gint rows, r;
- if (!E_CALENDAR_VIEW (day_view)->in_focus)
+ if (!E_CALENDAR_VIEW (day_view)->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
return;
+ }
+
+ day_view->requires_update = FALSE;
e_day_view_stop_editing_event (day_view);
@@ -4742,8 +4780,11 @@ e_day_view_check_layout (EDayView *day_view)
gint max_cols = -1;
/* Don't bother if we aren't visible. */
- if (!E_CALENDAR_VIEW (day_view)->in_focus)
- return;
+ if (!E_CALENDAR_VIEW (day_view)->in_focus) {
+ e_day_view_free_events (day_view);
+ day_view->requires_update = TRUE;
+ return;
+ }
/* Make sure the events are sorted (by start and size). */
e_day_view_ensure_events_sorted (day_view);
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index 4e70f46531..41982572a9 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -485,6 +485,8 @@ struct _EDayView {
guint32 bc_event_time;
time_t before_click_dtstart;
time_t before_click_dtend;
+
+ gboolean requires_update;
};
struct _EDayViewClass
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 9219548c92..8f549ee165 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -280,8 +280,11 @@ week_view_model_cell_changed_cb (EWeekView *week_view,
gint col,
gint row)
{
- if (!E_CALENDAR_VIEW (week_view)->in_focus)
+ if (!E_CALENDAR_VIEW (week_view)->in_focus) {
+ e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
return;
+ }
week_view_update_row (week_view, row);
}
@@ -293,8 +296,11 @@ week_view_model_comps_deleted_cb (EWeekView *week_view,
GSList *l, *list = data;
/* FIXME Stop editing? */
- if (!E_CALENDAR_VIEW (week_view)->in_focus)
+ if (!E_CALENDAR_VIEW (week_view)->in_focus) {
+ e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
return;
+ }
for (l = list; l != NULL; l = g_slist_next (l)) {
gint event_num;
@@ -324,8 +330,11 @@ static void
week_view_model_row_changed_cb (EWeekView *week_view,
gint row)
{
- if (!E_CALENDAR_VIEW (week_view)->in_focus)
+ if (!E_CALENDAR_VIEW (week_view)->in_focus) {
+ e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
return;
+ }
week_view_update_row (week_view, row);
}
@@ -338,8 +347,11 @@ week_view_model_rows_inserted_cb (EWeekView *week_view,
ECalModel *model;
gint i;
- if (!E_CALENDAR_VIEW (week_view)->in_focus)
+ if (!E_CALENDAR_VIEW (week_view)->in_focus) {
+ e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
return;
+ }
model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
@@ -419,6 +431,7 @@ week_view_time_range_changed_cb (EWeekView *week_view,
if (!E_CALENDAR_VIEW (week_view)->in_focus) {
e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
return;
}
@@ -443,8 +456,11 @@ timezone_changed_cb (ECalModel *cal_model,
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (!cal_view->in_focus)
+ if (!cal_view->in_focus) {
+ e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
return;
+ }
/* If we don't have a valid date set yet, just return. */
if (!g_date_valid (&week_view->first_day_shown))
@@ -832,6 +848,8 @@ e_week_view_init (EWeekView *week_view)
week_view->move_cursor = gdk_cursor_new (GDK_FLEUR);
week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
week_view->last_cursor_set = NULL;
+
+ week_view->requires_update = FALSE;
}
/**
@@ -1372,6 +1390,21 @@ e_week_view_focus_in (GtkWidget *widget, GdkEventFocus *event)
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
#endif
+ if (E_CALENDAR_VIEW (week_view)->in_focus && week_view->requires_update) {
+ time_t my_start = 0, my_end = 0, model_start = 0, model_end = 0;
+
+ week_view->requires_update = FALSE;
+
+ e_cal_model_get_time_range (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), &model_start, &model_end);
+
+ if (e_calendar_view_get_visible_time_range (E_CALENDAR_VIEW (week_view), &my_start, &my_end) &&
+ model_start == my_start && model_end == my_end) {
+ /* update only when the same time range is set in a view and in a model;
+ otherwise time range change invokes also query update */
+ e_week_view_update_query (week_view);
+ }
+ }
+
gtk_widget_queue_draw (week_view->main_canvas);
return FALSE;
@@ -1597,8 +1630,11 @@ e_week_view_update_query (EWeekView *week_view)
{
gint rows, r;
- if (!E_CALENDAR_VIEW (week_view)->in_focus)
+ if (!E_CALENDAR_VIEW (week_view)->in_focus) {
+ e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
return;
+ }
gtk_widget_queue_draw (week_view->main_canvas);
e_week_view_free_events (week_view);
@@ -2825,8 +2861,11 @@ static void
e_week_view_check_layout (EWeekView *week_view)
{
/* Don't bother if we aren't visible. */
- if (!E_CALENDAR_VIEW (week_view)->in_focus)
- return;
+ if (!E_CALENDAR_VIEW (week_view)->in_focus) {
+ e_week_view_free_events (week_view);
+ week_view->requires_update = TRUE;
+ return;
+ }
/* Make sure the events are sorted (by start and size). */
e_week_view_ensure_events_sorted (week_view);
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 83d058e2d7..1e4a71a037 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -354,6 +354,8 @@ struct _EWeekView {
guint32 bc_event_time;
time_t before_click_dtstart;
time_t before_click_dtend;
+
+ gboolean requires_update;
};
struct _EWeekViewClass {
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 985c47857b..75eac32f0b 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1826,12 +1826,20 @@ gnome_calendar_set_view (GnomeCalendar *gcal,
GnomeCalendarViewType view_type)
{
ECalendarView *calendar_view;
+ gint ii;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
gcal->priv->current_view_type = view_type;
gnome_calendar_set_range_selected (gcal, FALSE);
+ E_CALENDAR_VIEW (gcal->priv->views[view_type])->in_focus = TRUE;
+ for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++) {
+ if (ii == view_type)
+ continue;
+ E_CALENDAR_VIEW (gcal->priv->views[ii])->in_focus = FALSE;
+ }
+
calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
gtk_widget_grab_focus (GTK_WIDGET (calendar_view));
@@ -1846,7 +1854,6 @@ gnome_calendar_display_view (GnomeCalendar *gcal,
gboolean preserve_day;
gboolean range_selected;
time_t start_time;
- gint ii;
view = gnome_calendar_get_calendar_view (gcal, view_type);
@@ -1898,14 +1905,6 @@ gnome_calendar_display_view (GnomeCalendar *gcal,
gnome_calendar_set_view (gcal, view_type);
gnome_calendar_set_range_selected (gcal, range_selected);
- /* XXX Move this to set_view()? */
- E_CALENDAR_VIEW (gcal->priv->views[view_type])->in_focus = TRUE;
- for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++) {
- if (ii == view_type)
- continue;
- E_CALENDAR_VIEW (gcal->priv->views[ii])->in_focus = FALSE;
- }
-
/* For the week & month views we want the selection in the date
navigator to be rounded to the nearest week when the arrow buttons
are pressed to move to the previous/next month. */