[evolution/wip/webkit2] Bug 760638 - Month view loses weeks when jumping through months



commit 17171cc8757df50af12519b5400a682c9f32823f
Author: Milan Crha <mcrha redhat com>
Date:   Tue Feb 2 11:04:47 2016 +0100

    Bug 760638 - Month view loses weeks when jumping through months

 calendar/gui/e-week-view.c             |   14 +++++++++++++-
 modules/calendar/e-cal-shell-content.c |   15 +++++++++------
 2 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 05ba0b0..4fa8985 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -416,8 +416,20 @@ e_week_view_precalc_visible_time_range (ECalendarView *cal_view,
        /* See if we need to update the first day shown. */
        if (!g_date_valid (&week_view->priv->first_day_shown)
            || g_date_compare (&week_view->priv->first_day_shown, &base_date)) {
+               GDate end_date, in_end_date;
                gint day;
 
+               end_date = date;
+               g_date_add_days (&end_date, num_days);
+               g_date_subtract_days (&end_date, day_offset);
+
+               time_to_gdate_with_zone (&in_end_date, in_end_time, e_calendar_view_get_timezone 
(E_CALENDAR_VIEW (week_view)));
+
+               while (g_date_days_between (&end_date, &in_end_date) >= 6) {
+                       g_date_add_days (&end_date, 7);
+                       num_days += 7;
+               }
+
                in_start_time = time_add_day_with_zone (in_start_time, -((gint) day_offset), zone);
                in_start_time = time_day_begin_with_zone (in_start_time, zone);
 
@@ -2258,7 +2270,7 @@ e_week_view_recalc_day_starts (EWeekView *week_view,
        gint num_days, day;
        time_t tmp_time;
 
-       num_days = e_week_view_get_weeks_shown (week_view) * 7;
+       num_days = E_WEEK_VIEW_MAX_WEEKS * 7;
 
        tmp_time = lower;
        week_view->day_starts[0] = tmp_time;
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index 2be7201..f00a672 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -173,7 +173,6 @@ cal_shell_content_update_model_and_current_view_times (ECalShellContent *cal_she
                        e_cal_shell_content_update_filters (cal_shell_content, cal_filter, 
visible_range_start, visible_range_end);
                        e_calendar_view_set_selected_time_range (current_view, cmp_range_start, 
cmp_range_start);
                        filters_updated = TRUE;
-
                        view_start_tt = cmp_range_start;
                        view_end_tt = cmp_range_end;
                }
@@ -2051,13 +2050,17 @@ cal_shell_content_move_view_range_relative (ECalShellContent *cal_shell_content,
                        break;
                case E_CAL_VIEW_KIND_MONTH:
                case E_CAL_VIEW_KIND_LIST:
-                       if (direction > 0) {
+                       if (g_date_get_day (&start) != 1) {
+                               g_date_add_months (&start, 1);
+                               g_date_set_day (&start, 1);
+                       }
+                       if (direction > 0)
                                g_date_add_months (&start, direction);
-                               g_date_add_months (&end, direction);
-                       } else {
+                       else
                                g_date_subtract_months (&start, direction * -1);
-                               g_date_subtract_months (&end, direction * -1);
-                       }
+                       end = start;
+                       g_date_set_day (&end, g_date_get_days_in_month (g_date_get_month (&start), 
g_date_get_year (&start)));
+                       g_date_add_days (&end, 6);
                        break;
                case E_CAL_VIEW_KIND_LAST:
                        return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]