[evolution-patches] Patch to fix #57576



This patch fixes #57576 by getting rid of the bit of code that was
modifying the start/end times. The check_start_before_end () function
is no longer needed, so I just removed it. The time no longer gets
changed.

-- dobey

Index: dialogs/event-page.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/event-page.c,v
retrieving revision 1.72
diff -u -r1.72 event-page.c
--- dialogs/event-page.c	12 Jul 2004 10:29:47 -0000	1.72
+++ dialogs/event-page.c	13 Jul 2004 17:35:33 -0000
@@ -1,3 +1,5 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
 /* Evolution calendar - Main page of the event editor dialog
  *
  * Copyright (C) 2001 Ximian, Inc.
@@ -93,6 +95,9 @@
 	CalUnits alarm_units;
 	int alarm_interval;
 	
+	struct icaltimetype *start_tt;
+	struct icaltimetype *end_tt;
+
 	/* This is TRUE if both the start & end timezone are the same. If the
 	   start timezone is then changed, we updated the end timezone to the
 	   same value, since 99% of events start and end in one timezone. */
@@ -186,6 +191,9 @@
 	
 	priv->updating = FALSE;
 	priv->sync_timezones = FALSE;
+
+	priv->start_tt = g_new0 (struct icaltimetype, 1);
+	priv->end_tt = g_new0 (struct icaltimetype, 1);
 }
 
 /* Destroy handler for the event page */
@@ -311,6 +319,14 @@
 
 	priv = epage->priv;
 
+	priv->start_tt->month = start_date->value->month;
+	priv->start_tt->day = start_date->value->day;
+	priv->start_tt->year = start_date->value->year;
+
+	priv->end_tt->month = end_date->value->month;
+	priv->end_tt->day = end_date->value->day;
+	priv->end_tt->year = end_date->value->year;
+
 	/* Note that if we are creating a new event, the timezones may not be
 	   on the server, so we try to get the builtin timezone with the TZID
 	   first. */
@@ -1222,44 +1238,6 @@
 }
 
 
-static gboolean
-check_start_before_end (struct icaltimetype *start_tt,
-			icaltimezone *start_zone,
-			struct icaltimetype *end_tt,
-			icaltimezone *end_zone,
-			gboolean adjust_end_time)
-{
-	struct icaltimetype end_tt_copy;
-	int cmp;
-
-	/* Convert the end time to the same timezone as the start time. */
-	end_tt_copy = *end_tt;
-	icaltimezone_convert_time (&end_tt_copy, end_zone, start_zone);
-
-	/* Now check if the start time is after the end time. If it is,
-	   we need to modify one of the times. */
-	cmp = icaltime_compare (*start_tt, end_tt_copy);
-	if (cmp > 0) {
-		if (adjust_end_time) {
-			/* Modify the end time, to be the start + 1 hour. */
-			*end_tt = *start_tt;
-			icaltime_adjust (end_tt, 0, 1, 0, 0);
-			icaltimezone_convert_time (end_tt, start_zone,
-						   end_zone);
-		} else {
-			/* Modify the start time, to be the end - 1 hour. */
-			*start_tt = *end_tt;
-			icaltime_adjust (start_tt, 0, -1, 0, 0);
-			icaltimezone_convert_time (start_tt, end_zone,
-						   start_zone);
-		}
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-
 /*
  * This is called whenever the start or end dates or timezones is changed.
  * It makes sure that the start date < end date. It also emits the notification
@@ -1328,18 +1306,22 @@
 		start_zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->start_timezone));
 		end_zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->end_timezone));
 
-		if (check_start_before_end (&start_tt, start_zone,
-					    &end_tt, end_zone,
-					    adjust_end_time)) {
-			if (adjust_end_time)
-				set_end_date = TRUE;
-			else
-				set_start_date = TRUE;
-		}
+		if (adjust_end_time)
+		  set_end_date = TRUE;
+		else
+		  set_start_date = TRUE;
 	}
 
 
 	if (set_start_date) {
+	        priv->start_tt->year = priv->start_tt->year - (priv->end_tt->year - end_tt.year);
+	        priv->start_tt->month = priv->start_tt->month - (priv->end_tt->month - end_tt.month);
+	        priv->start_tt->day = priv->start_tt->day - (priv->end_tt->day - end_tt.day);
+
+		priv->end_tt->year = end_tt.year;
+		priv->end_tt->month = end_tt.month;
+		priv->end_tt->day = end_tt.day;
+
 		g_signal_handlers_block_matched (priv->start_time, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage);
 		e_date_edit_set_date (E_DATE_EDIT (priv->start_time),
 				      start_tt.year, start_tt.month,
@@ -1350,9 +1332,16 @@
 	}
 
 	if (set_end_date) {
+	        priv->end_tt->year = priv->end_tt->year - (priv->start_tt->year - start_tt.year);
+	        priv->end_tt->month = priv->end_tt->month - (priv->start_tt->month - start_tt.month);
+	        priv->end_tt->day = priv->end_tt->day - (priv->start_tt->day - start_tt.day);
+		priv->start_tt->year = start_tt.year;
+		priv->start_tt->month = start_tt.month;
+		priv->start_tt->day = start_tt.day;
+
 		g_signal_handlers_block_matched (priv->end_time, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage);
 		e_date_edit_set_date (E_DATE_EDIT (priv->end_time),
-				      end_tt.year, end_tt.month, end_tt.day);
+				      priv->end_tt->year, priv->end_tt->month, priv->end_tt->day);
 		e_date_edit_set_time_of_day (E_DATE_EDIT (priv->end_time),
 					     end_tt.hour, end_tt.minute);
 		g_signal_handlers_unblock_matched (priv->end_time, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage);
@@ -1518,9 +1507,6 @@
 		/* Make sure that end > start using the timezones. */
 		start_zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->start_timezone));
 		end_zone = e_timezone_entry_get_timezone (E_TIMEZONE_ENTRY (priv->end_timezone));
-		check_start_before_end (&start_tt, start_zone,
-					&end_tt, end_zone,
-					TRUE);
 	}
 
 	gtk_signal_handler_block_by_data (GTK_OBJECT (priv->start_time),


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