evolution r37518 - in trunk/calendar: . gui gui/dialogs



Author: pchen
Date: Mon Apr 13 09:03:38 2009
New Revision: 37518
URL: http://svn.gnome.org/viewvc/evolution?rev=37518&view=rev

Log:
2009-04-13  Chenthill Palanisamy  <pchenthill novell com>

	Fixes #561312
	* calendar/gui/comp-util.c:
	* calendar/gui/comp-util.h: Added a new function to
	sanitize master recurrence event before modifying
	all instances.
	* calendar/gui/dialogs/comp-editor.c:
	* calendar/gui/e-day-view.c:
	* calendar/gui/e-week-view.c: Used the new util api.
	Do not invoke recurrence dialog while modifying detached
	instances.

Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/gui/comp-util.c
   trunk/calendar/gui/comp-util.h
   trunk/calendar/gui/dialogs/comp-editor.c
   trunk/calendar/gui/e-day-view.c
   trunk/calendar/gui/e-week-view.c

Modified: trunk/calendar/gui/comp-util.c
==============================================================================
--- trunk/calendar/gui/comp-util.c	(original)
+++ trunk/calendar/gui/comp-util.c	Mon Apr 13 09:03:38 2009
@@ -796,3 +796,62 @@
 
 	return success;
 }
+
+void
+comp_util_sanitize_recurrence_master (ECalComponent *comp, ECal *client)
+{
+	ECalComponent *master = NULL;
+	icalcomponent *icalcomp = NULL;
+	ECalComponentRange rid;
+       	ECalComponentDateTime sdt;	
+	const char *uid;
+
+	/* Get the master component */
+	e_cal_component_get_uid (comp, &uid);
+	if (!e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) {
+		g_warning ("Unable to get the master component \n");
+		return;
+	}
+
+	master = e_cal_component_new ();
+	e_cal_component_set_icalcomponent (master, icalcomp);
+
+	/* Compare recur id and start date */
+	e_cal_component_get_recurid (comp, &rid);
+	e_cal_component_get_dtstart (comp, &sdt);
+
+	if (icaltime_compare_date_only (*rid.datetime.value, *sdt.value) == 0)
+	{
+		ECalComponentDateTime msdt, medt, edt;
+		int *sequence;
+
+		e_cal_component_get_dtstart (master, &msdt);
+		e_cal_component_get_dtend (master, &medt);
+
+		e_cal_component_get_dtend (comp, &edt);
+
+		sdt.value->year = msdt.value->year;
+		sdt.value->month = msdt.value->month;
+		sdt.value->day = msdt.value->day;
+
+		edt.value->year = medt.value->year;
+		edt.value->month = medt.value->month;
+		edt.value->day = medt.value->day;
+
+		e_cal_component_set_dtstart (comp, &sdt);
+		e_cal_component_set_dtend (comp, &edt);
+		
+		e_cal_component_get_sequence (master, &sequence);
+		e_cal_component_set_sequence (comp, sequence);
+
+		e_cal_component_free_datetime (&msdt);
+		e_cal_component_free_datetime (&medt);
+		e_cal_component_free_datetime (&edt);
+	}
+
+	e_cal_component_free_datetime (&sdt);
+	e_cal_component_free_range (&rid);
+	e_cal_component_set_recurid (comp, NULL);
+
+	g_object_unref (master);
+}

Modified: trunk/calendar/gui/comp-util.h
==============================================================================
--- trunk/calendar/gui/comp-util.h	(original)
+++ trunk/calendar/gui/comp-util.h	Mon Apr 13 09:03:38 2009
@@ -58,5 +58,6 @@
 void cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate);
 
 gboolean cal_comp_process_source_list_drop (ECal *destination, icalcomponent *comp, GdkDragAction action, const char *source_uid, ESourceList *source_list);
+void comp_util_sanitize_recurrence_master (ECalComponent *comp, ECal *client);
 
 #endif

Modified: trunk/calendar/gui/dialogs/comp-editor.c
==============================================================================
--- trunk/calendar/gui/dialogs/comp-editor.c	(original)
+++ trunk/calendar/gui/dialogs/comp-editor.c	Mon Apr 13 09:03:38 2009
@@ -799,6 +799,11 @@
 		if (result)
 			g_signal_emit_by_name (editor, "object_created");
 	} else {
+
+		if (e_cal_component_has_recurrences (priv->comp) && priv->mod == CALOBJ_MOD_ALL)
+			comp_util_sanitize_recurrence_master (priv->comp, priv->client);
+
+
 		if (priv->mod == CALOBJ_MOD_THIS) {
 			e_cal_component_set_rdate_list (priv->comp, NULL);
 			e_cal_component_set_rrule_list (priv->comp, NULL);
@@ -1159,11 +1164,15 @@
 	}
 
 	commit_all_fields (editor);
-	if (e_cal_component_is_instance (priv->comp))
+	if (e_cal_component_has_recurrences (priv->comp)) {
 		if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor), delegated))
 			return;
 
+	} else if (e_cal_component_is_instance (priv->comp))
+		priv->mod = CALOBJ_MOD_THIS;
+
 	comp = comp_editor_get_current_comp (editor, &correct);
+		
 	e_cal_component_get_summary (comp, &text);
 	g_object_unref (comp);
 

Modified: trunk/calendar/gui/e-day-view.c
==============================================================================
--- trunk/calendar/gui/e-day-view.c	(original)
+++ trunk/calendar/gui/e-day-view.c	Mon Apr 13 09:03:38 2009
@@ -4022,12 +4022,15 @@
 	}
 
 	e_cal_component_commit_sequence (comp);
- 	if (e_cal_component_is_instance (comp)) {
+ 	if (e_cal_component_has_recurrences (comp)) {
  		if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
  			gtk_widget_queue_draw (day_view->top_canvas);
 			goto out;
  		}
 
+		if (mod == CALOBJ_MOD_ALL)
+			comp_util_sanitize_recurrence_master (comp, client);
+
 		if (mod == CALOBJ_MOD_THIS) {
 			/* set the correct DTSTART/DTEND on the individual recurrence */
 			if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE) {
@@ -4049,7 +4052,8 @@
 
 			e_cal_component_commit_sequence (comp);
 		}
-	}
+	} else if (e_cal_component_is_instance (comp))
+		mod = CALOBJ_MOD_THIS;
 
 	toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 	e_calendar_view_modify_and_send (comp, client, mod, toplevel, TRUE);
@@ -4129,11 +4133,14 @@
 
 	day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
 
- 	if (e_cal_component_is_instance (comp)) {
+ 	if (e_cal_component_has_recurrences (comp)) {
  		if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
  			gtk_widget_queue_draw (day_view->top_canvas);
 			goto out;
  		}
+				
+		if (mod == CALOBJ_MOD_ALL)
+			comp_util_sanitize_recurrence_master (comp, client);
 
 		if (mod == CALOBJ_MOD_THIS) {
 			/* set the correct DTSTART/DTEND on the individual recurrence */
@@ -4154,7 +4161,8 @@
 			e_cal_component_set_exdate_list (comp, NULL);
 			e_cal_component_set_exrule_list (comp, NULL);
 		}
-	}
+	} else if (e_cal_component_is_instance (comp))
+		mod = CALOBJ_MOD_THIS;
 
 	toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 
@@ -6138,19 +6146,23 @@
 
 	day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
 
- 	if (e_cal_component_is_instance (comp)) {
+ 	if (e_cal_component_has_recurrences (comp)) {
  		if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
  			gtk_widget_queue_draw (day_view->top_canvas);
 			goto out;
  		}
 
+		if (mod == CALOBJ_MOD_ALL)
+			comp_util_sanitize_recurrence_master (comp, client);
+
 		if (mod == CALOBJ_MOD_THIS) {
 			e_cal_component_set_rdate_list (comp, NULL);
 			e_cal_component_set_rrule_list (comp, NULL);
 			e_cal_component_set_exdate_list (comp, NULL);
 			e_cal_component_set_exrule_list (comp, NULL);
 		}
-	}
+	} else if (e_cal_component_is_instance (comp))
+		mod = CALOBJ_MOD_THIS;
 
 	toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 
@@ -6371,11 +6383,14 @@
 		} else {
 			CalObjModType mod = CALOBJ_MOD_ALL;
 			GtkWindow *toplevel;
-			if (e_cal_component_is_instance (comp)) {
+			if (e_cal_component_has_recurrences (comp)) {
 				if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
 					goto out;
 				}
 
+				if (mod == CALOBJ_MOD_ALL)
+					comp_util_sanitize_recurrence_master (comp, client);
+
 				if (mod == CALOBJ_MOD_THIS) {
 					ECalComponentDateTime olddt, dt;
 					icaltimetype itt;
@@ -6423,7 +6438,8 @@
 
 					e_cal_component_commit_sequence (comp);
 				}
-			}
+			} else if (e_cal_component_is_instance (comp))
+				mod = CALOBJ_MOD_THIS;
 
 			/* FIXME When sending here, what exactly should we send? */
 			toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
@@ -7524,11 +7540,14 @@
 				gnome_canvas_item_show (event->canvas_item);
 
 			e_cal_component_commit_sequence (comp);
-			if (e_cal_component_is_instance (comp)) {
+			if (e_cal_component_has_recurrences (comp)) {
 				if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
 					g_object_unref (comp);
 					return;
 				}
+				
+				if (mod == CALOBJ_MOD_ALL)
+					comp_util_sanitize_recurrence_master (comp, client);
 
 				if (mod == CALOBJ_MOD_THIS) {
 					e_cal_component_set_rdate_list (comp, NULL);
@@ -7536,7 +7555,8 @@
 					e_cal_component_set_exdate_list (comp, NULL);
 					e_cal_component_set_exrule_list (comp, NULL);
 				}
-			}
+			} else if (e_cal_component_is_instance (comp))
+				mod = CALOBJ_MOD_THIS;
 
 			toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 			e_calendar_view_modify_and_send (comp, client, mod, toplevel, FALSE);
@@ -7726,19 +7746,23 @@
 				gnome_canvas_item_show (event->canvas_item);
 
 			e_cal_component_commit_sequence (comp);
-			if (e_cal_component_is_instance (comp)) {
+			if (e_cal_component_has_recurrences (comp)) {
 				if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
 					g_object_unref (comp);
 					return;
 				}
 
+				if (mod == CALOBJ_MOD_ALL)
+					comp_util_sanitize_recurrence_master (comp, client);
+
 				if (mod == CALOBJ_MOD_THIS) {
 					e_cal_component_set_rdate_list (comp, NULL);
 					e_cal_component_set_rrule_list (comp, NULL);
 					e_cal_component_set_exdate_list (comp, NULL);
 					e_cal_component_set_exrule_list (comp, NULL);
 				}
-			}
+			} else if (e_cal_component_is_instance (comp))
+				mod = CALOBJ_MOD_THIS;
 
 			toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 			e_calendar_view_modify_and_send (comp, client, mod, toplevel, FALSE);

Modified: trunk/calendar/gui/e-week-view.c
==============================================================================
--- trunk/calendar/gui/e-week-view.c	(original)
+++ trunk/calendar/gui/e-week-view.c	Mon Apr 13 09:03:38 2009
@@ -3445,19 +3445,23 @@
 	week_view->last_edited_comp_string = e_cal_component_get_as_string (comp);
 
 
- 	if (e_cal_component_is_instance (comp)) {
+ 	if (e_cal_component_has_recurrences (comp)) {
  		if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
  			gtk_widget_queue_draw (week_view->main_canvas);
 			goto out;
  		}
 
+		if (mod == CALOBJ_MOD_ALL)
+			comp_util_sanitize_recurrence_master (comp, client);
+
 		if (mod == CALOBJ_MOD_THIS) {
 			e_cal_component_set_rdate_list (comp, NULL);
 			e_cal_component_set_rrule_list (comp, NULL);
 			e_cal_component_set_exdate_list (comp, NULL);
 			e_cal_component_set_exrule_list (comp, NULL);
 		}
-	}
+	} else if (e_cal_component_is_instance (comp))
+		mod = CALOBJ_MOD_THIS;
 
 	toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (week_view)));
 
@@ -3578,10 +3582,13 @@
 			CalObjModType mod = CALOBJ_MOD_ALL;
 			GtkWindow *toplevel;
 
-			if (e_cal_component_is_instance (comp)) {
+			if (e_cal_component_has_recurrences (comp)) {
 				if (!recur_component_dialog (client, comp, &mod, NULL, FALSE)) {
 					goto out;
 				}
+		
+				if (mod == CALOBJ_MOD_ALL)
+					comp_util_sanitize_recurrence_master (comp, client);
 
 				if (mod == CALOBJ_MOD_THIS) {
 					ECalComponentDateTime dt;
@@ -3633,7 +3640,8 @@
 
 					e_cal_component_commit_sequence (comp);
 				}
-			}
+			} else if (e_cal_component_is_instance (comp))
+				mod = CALOBJ_MOD_THIS;
 
 			/* FIXME When sending here, what exactly should we send? */
 			toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (week_view)));



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