[Calendar] potential patch for Bug321807

"jerry.pu" <[email protected]>
Newsgroups gmane.comp.gnome.evolution.patches
Message-ID <1144916926.21398.13.camel@autoracing>
hi,

here is a potential resovle method to fix
http://bugzilla.gnome.org/show_bug.cgi?id=321807

Now, it print preview appointments in the month view, instead of
printing preview them month after month.

pls help me to review it.

regards,

jerry

_______________________________________________
Evolution-patches mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-patches
321807.diff (text/x-patch, 3.9 KB)
Index: calendar/gui/print.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/print.c,v
retrieving revision 1.81
diff -u -p -r1.81 print.c
--- calendar/gui/print.c	8 Feb 2006 13:06:02 -0000	1.81
+++ calendar/gui/print.c	13 Apr 2006 08:04:15 -0000
@@ -1723,7 +1723,7 @@ print_year_summary (GnomePrintContext *p
 	}
 }
 
-static void
+static time_t
 print_month_summary (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence,
 		     double left, double right, double top, double bottom)
 {
@@ -1736,22 +1736,26 @@ print_month_summary (GnomePrintContext *
 	gboolean compress_weekend;
 	int columns, col, weekday, len, month;
 	double font_size, cell_width, x1, x2, y1, y2;
+	ECalModel *model = gnome_calendar_get_calendar_model (gcal);
+	time_t view_start = 0;
 
 	weekday = calendar_config_get_week_start_day ();
 	compress_weekend = calendar_config_get_compress_weekend ();
 
+	e_cal_model_get_time_range (model, &view_start, NULL);
+	if (view_start == 0)
+		return 0;
+
 	/* Remember which month we want. */
-	tt = icaltime_from_timet_with_zone (whence, FALSE, zone);
+	tt = icaltime_from_timet_with_zone (view_start, 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);
-	date = time_week_begin_with_zone (date, weekday, zone);
-
-	/* If weekends are compressed then we can't start on a Sunday. */
-	if (compress_weekend && weekday == 0)
-		date = time_add_day_with_zone (date, -1, zone);
+	if (tt.day <= 15) 
+		date = time_month_begin_with_zone (view_start, zone);
+	else{
+		date = time_month_begin_with_zone (view_start, zone);
+		date = time_add_month_with_zone (view_start, 1, zone);
+	}
 
 	/* do day names ... */
 
@@ -1759,7 +1763,7 @@ print_month_summary (GnomePrintContext *
 	   to be able to step through the week without worrying about
 	   overflows making strftime choke, so we move near to the start of
 	   the month. */
-	tm = *convert_timet_to_struct_tm (date, zone);
+	tm = *convert_timet_to_struct_tm (view_start, zone);
 	tm.tm_mday = (tm.tm_mday % 7) + 7;
 
 	font = get_font_for_size (MONTH_NORMAL_FONT_SIZE, GNOME_FONT_BOLD, FALSE);
@@ -1795,9 +1799,11 @@ print_month_summary (GnomePrintContext *
 	g_object_unref (font);
 
 	top = y2;
-	print_week_summary (pc, gcal, date, TRUE, 6, month,
+	print_week_summary (pc, gcal, view_start, TRUE, 6, month,
 			    MONTH_NORMAL_FONT_SIZE,
 			    left, right, top, bottom);
+
+	return date;
 }
 
 
@@ -2121,31 +2127,34 @@ print_month_view (GnomePrintContext *pc,
 	icaltimezone *zone = calendar_config_get_icaltimezone ();
 	double header;
 	char buf[100];
+	time_t main_month_begin = 0;
 
 	header = top - HEADER_HEIGHT;
 
 	gnome_print_beginpage (pc, NULL);
 
 	/* Print the main month view. */
-	print_month_summary (pc, gcal, date, left, right, header, bottom);
+	main_month_begin = print_month_summary (pc, gcal, date, left, right, header, bottom);
+	if (main_month_begin == 0)
+		return;
 
 	/* Print the border around the header. */
 	print_border (pc, left, right, top, header, 1.0, 0.9);
 
 	/* Print the 2 mini calendar-months. */
 	print_month_small (pc, gcal,
-			   time_add_month_with_zone (date, 1, zone),
+			   time_add_month_with_zone (main_month_begin, 1, zone),
 			   right - (right - left) / 7 + 2, right - 8,
 			   top - 4, header,
 			   DATE_MONTH | DATE_YEAR, 0, 0, FALSE);
 	print_month_small (pc, gcal,
-			   time_add_month_with_zone (date, -1, zone),
+			   time_add_month_with_zone (main_month_begin, -1, zone),
 			   left + 8, left + (right - left) / 7 - 2,
 			   top - 4, header,
 			   DATE_MONTH | DATE_YEAR, 0, 0, FALSE);
 
 	/* Print the month, e.g. 'May 2001'. */
-	format_date (date, DATE_MONTH | DATE_YEAR, buf, 100);
+	format_date (main_month_begin, DATE_MONTH | DATE_YEAR, buf, 100);
 	print_text_size_bold (pc, buf, ALIGN_CENTER,
 			      left + 3, right - 3, top - 3, top - 3 - 24);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.