[evolution] Bug #624021 - Honour weeks shown in a multi week view on print



commit 062a67cc1465d7a4d02b0308e4faaa5784d02af1
Author: Milan Crha <mcrha redhat com>
Date:   Tue Aug 31 20:36:20 2010 +0200

    Bug #624021 - Honour weeks shown in a multi week view on print

 calendar/gui/e-cal-model.c |    4 +++-
 calendar/gui/print.c       |   28 +++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index d0166b9..a48fc5d 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -2779,7 +2779,9 @@ e_cal_model_generate_instances (ECalModel *model, time_t start, time_t end,
 
 		mdata.comp_data = comp_data;
 		mdata.cb_data = cb_data;
-		e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp, start, end, cb, &mdata);
+
+		if (comp_data->instance_start < end && comp_data->instance_end > start)
+			e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp, start, end, cb, &mdata);
 	}
 }
 
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index 1371f2d..84ad29c 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -1955,19 +1955,39 @@ print_month_summary (GtkPrintContext *context, GnomeCalendar *gcal, time_t whenc
 	gchar buffer[100];
 	PangoFontDescription *font;
 	gboolean compress_weekend;
-	gint columns, col, weekday, month;
+	gint columns, col, weekday, month, weeks;
 	gdouble font_size, cell_width, x1, x2, y1, y2;
 
 	weekday = calendar_config_get_week_start_day ();
 	compress_weekend = calendar_config_get_compress_weekend ();
 
+	date = 0;
+	weeks = 6;
+	if (gnome_calendar_get_view (gcal) == GNOME_CAL_MONTH_VIEW) {
+		GnomeCalendarViewType view_type;
+		ECalendarView *calendar_view;
+		EWeekView *week_view;
+
+		view_type = gnome_calendar_get_view (gcal);
+		calendar_view = gnome_calendar_get_calendar_view (gcal, view_type);
+		week_view = E_WEEK_VIEW (calendar_view);
+
+		if (week_view && week_view->multi_week_view
+		    && !(week_view->weeks_shown >= 4 &&
+		    g_date_valid (&week_view->first_day_shown))) {
+			weeks = week_view->weeks_shown;
+			date = whence;
+		}
+	}
+
 	/* Remember which month we want. */
 	tt = icaltime_from_timet_with_zone (whence, FALSE, zone);
 	month = tt.month - 1;
 
 	/* Find the start of the month, and then the start of the week on
 	   or before that day. */
-	date = time_month_begin_with_zone (whence, zone);
+	if (!date)
+		date = time_month_begin_with_zone (whence, zone);
 	date = time_week_begin_with_zone (date, weekday, zone);
 
 	/* If weekends are compressed then we can't start on a Sunday. */
@@ -2015,7 +2035,7 @@ print_month_summary (GtkPrintContext *context, GnomeCalendar *gcal, time_t whenc
 	pango_font_description_free (font);
 
 	top = y2;
-	print_week_summary (context, gcal, date, TRUE, 6, month,
+	print_week_summary (context, gcal, date, TRUE, weeks, month,
 			    MONTH_NORMAL_FONT_SIZE,
 			    left, right, top, bottom);
 }
@@ -2517,6 +2537,8 @@ print_calendar (GnomeCalendar *gcal,
 			start_tt.day = g_date_get_day (&date);
 
 			start = icaltime_as_timet (start_tt);
+		} else if (week_view && week_view->multi_week_view) {
+			start = week_view->day_starts[0];
 		}
 	}
 



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