[evolution-patches] patch for #22444



This adds 'Delete' commands for occurrences to the main menu, as there
is for the popup menu. It doesn't break the string freeze since all
strings used in the new code are already part of evolution.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1741
diff -u -p -r1.1741 ChangeLog
--- ChangeLog	19 Apr 2003 10:29:05 -0000	1.1741
+++ ChangeLog	21 Apr 2003 21:40:30 -0000
@@ -1,3 +1,29 @@
+2003-04-21  Rodrigo Moya <rodrigo ximian com>
+
+	Fixes #22444
+
+	* gui/calendar-commands.c: added new verbs for occurrence-related
+	menu items.
+	(delete_occurrence_cmd): added callback for "Delete this occurrence"
+	menu item. "Delete all occurrences" is just the same as "Delete".
+	(sensitize_calendar_commands): sensitive ocurrence-related menu items.
+
+	* gui/gnome-cal.[ch] (gnome_calendar_delete_selected_occurrence): new
+	function.
+	(gnome_calendar_get_current_view_widget): made this public.
+
+	* gui/e-week-view.[ch] (e_week_view_get_selected_event):
+	(e_week_view_delete_occurrence): new functions.
+	(e_week_view_delete_occurrence_internal): real implementation of the
+	'Delete Occurrence' logic.
+	(e_week_view_on_delete_occurrence): call delete_instance_internal.
+
+	* gui/e-day-view.[ch] (e_day_view_get_selected_event):
+	(e_day_view_delete_occurrence): new functions.
+	(e_week_view_delete_occurrence_internal): real implementation of the
+	'Delete Occurrence' logic.
+	(e_week_view_on_delete_occurrence): call delete_occurrence_internal.
+
 2003-04-18  Rodrigo Moya <rodrigo ximian com>
 
 	* gui/alarm-notify/alarm-notify.glade: removed 'heading' and
Index: gui/calendar-commands.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-commands.c,v
retrieving revision 1.117
diff -u -p -r1.117 calendar-commands.c
--- gui/calendar-commands.c	18 Apr 2003 17:44:19 -0000	1.117
+++ gui/calendar-commands.c	21 Apr 2003 21:40:31 -0000
@@ -49,6 +49,8 @@
 #include "shell/Evolution.h"
 #include "calendar-commands.h"
 #include "calendar-config.h"
+#include "e-day-view.h"
+#include "e-week-view.h"
 #include "gnome-cal.h"
 #include "goto.h"
 #include "print.h"
@@ -293,6 +295,18 @@ delete_cmd (BonoboUIComponent *uic, gpoi
 }
 
 static void
+delete_occurrence_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
+{
+	GnomeCalendar *gcal;
+
+	gcal = GNOME_CALENDAR (data);
+
+	set_clock_cursor (gcal);
+	gnome_calendar_delete_selected_occurrence (gcal);
+	set_normal_cursor (gcal);
+}
+
+static void
 publish_freebusy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
 {
 	GnomeCalendar *gcal;
@@ -505,7 +519,7 @@ sensitize_calendar_commands (GnomeCalend
 {
 	BonoboUIComponent *uic;
 	int n_selected;
-	gboolean read_only;
+	gboolean read_only, has_recurrences;
 	
 	uic = bonobo_control_get_ui_component (control);
 	g_assert (uic != NULL);
@@ -525,6 +539,33 @@ sensitize_calendar_commands (GnomeCalend
 	bonobo_ui_component_set_prop (uic, "/commands/Delete", "sensitive",
 				      n_selected == 0 || read_only ? "0" : "1",
 				      NULL);
+
+	/* occurrence-related menu items */
+	has_recurrences = FALSE;
+	if (n_selected > 0 && !read_only) {
+		CalComponent *comp;
+		GtkWidget *view;
+
+		view = gnome_calendar_get_current_view_widget (gcal);
+		if (E_IS_DAY_VIEW (view))
+			comp = e_day_view_get_selected_event (E_DAY_VIEW (view));
+		else if (E_IS_WEEK_VIEW (view))
+			comp = e_week_view_get_selected_event (E_WEEK_VIEW (view));
+		else
+			comp = NULL;
+
+		if (comp) {
+			if (cal_component_has_recurrences (comp))
+				has_recurrences = TRUE;
+		}
+	}
+
+	bonobo_ui_component_set_prop (uic, "/commands/DeleteOccurrence", "sensitive",
+				      has_recurrences ? "1" : "0",
+				      NULL);
+	bonobo_ui_component_set_prop (uic, "/commands/DeleteAllOccurrences", "sensitive",
+				      has_recurrences ? "1" : "0",
+				      NULL);
 }
 
 /* Sensitizes the UI Component menu/toolbar tasks commands based on the number
@@ -659,6 +700,8 @@ static BonoboUIVerb verbs [] = {
 	BONOBO_UI_VERB ("Copy", copy_cmd),
 	BONOBO_UI_VERB ("Paste", paste_cmd),
 	BONOBO_UI_VERB ("Delete", delete_cmd),
+	BONOBO_UI_VERB ("DeleteOccurrence", delete_occurrence_cmd),
+	BONOBO_UI_VERB ("DeleteAllOccurrences", delete_cmd),
 
 	BONOBO_UI_VERB ("CalendarPrev", previous_clicked),
 	BONOBO_UI_VERB ("CalendarToday", today_clicked),
@@ -681,6 +724,8 @@ static EPixmap pixmaps [] =
 	E_PIXMAP ("/menu/EditPlaceholder/Edit/Copy",			      "16_copy.png"),
 	E_PIXMAP ("/menu/EditPlaceholder/Edit/Paste",			      "16_paste.png"),
 	E_PIXMAP ("/menu/EditPlaceholder/Edit/Delete",			      "evolution-trash-mini.png"),
+	E_PIXMAP ("/menu/EditPlaceholder/Edit/DeleteOccurrence",	      "evolution-trash-mini.png"),
+	E_PIXMAP ("/menu/EditPlaceholder/Edit/DeleteAllOccurrences",	      "evolution-trash-mini.png"),
 	E_PIXMAP ("/menu/File/Print/Print",				      "print.xpm"),
 	E_PIXMAP ("/menu/File/Print/PrintPreview",			      "print-preview.xpm"),
 	E_PIXMAP ("/menu/View/ViewBegin/Goto",				      "goto-16.png"),
Index: gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.237
diff -u -p -r1.237 gnome-cal.c
--- gui/gnome-cal.c	16 Apr 2003 16:23:58 -0000	1.237
+++ gui/gnome-cal.c	21 Apr 2003 21:40:32 -0000
@@ -347,7 +347,7 @@ dn_query_eval_error_cb (CalQuery *query,
 }
 
 /* Returns the current view widget, a EDayView or EWeekView. */
-static GtkWidget*
+GtkWidget*
 gnome_calendar_get_current_view_widget (GnomeCalendar *gcal)
 {
 	GnomeCalendarPrivate *priv;
@@ -2853,6 +2853,29 @@ gnome_calendar_delete_selection		(GnomeC
 		g_assert_not_reached ();
 }
 
+void
+gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal)
+{
+	GnomeCalendarPrivate *priv;
+	FocusLocation location;
+	GtkWidget *view;
+
+	g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
+	priv = gcal->priv;
+
+	location = get_focus_location (gcal);
+
+	if (location == FOCUS_CALENDAR) {
+
+		view = gnome_calendar_get_current_view_widget (gcal);
+
+		if (E_IS_DAY_VIEW (view))
+			e_day_view_delete_occurrence (E_DAY_VIEW (view));
+		else
+			e_week_view_delete_occurrence (E_WEEK_VIEW (view));
+	}
+}
 
 ECalendarTable*
 gnome_calendar_get_task_pad	(GnomeCalendar *gcal)
Index: gui/gnome-cal.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.h,v
retrieving revision 1.80
diff -u -p -r1.80 gnome-cal.h
--- gui/gnome-cal.h	7 Nov 2002 02:00:55 -0000	1.80
+++ gui/gnome-cal.h	21 Apr 2003 21:40:32 -0000
@@ -108,6 +108,7 @@ GnomeCalendarViewType gnome_calendar_get
 void gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type,
 			      gboolean range_selected, gboolean grab_focus);
 
+GtkWidget *gnome_calendar_get_current_view_widget (GnomeCalendar *gcal);
 void gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic);
 void gnome_calendar_discard_view_menus (GnomeCalendar *gcal);
 
@@ -167,6 +168,7 @@ void       gnome_calendar_copy_clipboard
 void       gnome_calendar_paste_clipboard       (GnomeCalendar  *gcal);
 
 void       gnome_calendar_delete_selection	(GnomeCalendar  *gcal);
+void       gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal);
 
 
 
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.156
diff -u -p -r1.156 e-week-view.c
--- gui/e-week-view.c	15 Apr 2003 22:26:10 -0000	1.156
+++ gui/e-week-view.c	21 Apr 2003 21:40:34 -0000
@@ -3898,44 +3898,6 @@ e_week_view_on_settings (GtkWidget *widg
 }
 
 static void
-e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
-{
-	EWeekView *week_view;
-	EWeekViewEvent *event;
-	CalComponent *comp;
-
-	week_view = E_WEEK_VIEW (data);
-
-	if (week_view->popup_event_num == -1)
-		return;
-
-	event = &g_array_index (week_view->events, EWeekViewEvent,
-				week_view->popup_event_num);
-
-	if (cal_component_is_instance (event->comp)) {
-		const char *uid;
-
-		cal_component_get_uid (event->comp, &uid);
-		if (cal_client_remove_object_with_mod (week_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS)
-			g_message ("e_week_view_on_delete_occurrence(): Could not update the object!");
-
-		return;
-	}
-
-	/* We must duplicate the CalComponent, or we won't know it has changed
-	   when we get the "update_event" callback. */
-
-	comp = cal_component_clone (event->comp);
-	cal_comp_util_add_exdate (comp, event->start, week_view->zone);
-
-	if (cal_client_update_object (week_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
-		g_message ("e_week_view_on_delete_occurrence(): Could not update the object!");
-
-	g_object_unref (comp);
-}
-
-
-static void
 e_week_view_delete_event_internal (EWeekView *week_view, gint event_num)
 {
 	CalComponentVType vtype;
@@ -3993,6 +3955,61 @@ e_week_view_delete_event		(EWeekView    
 
 
 static void
+e_week_view_delete_occurrence_internal (EWeekView *week_view, gint event_num)
+{
+	EWeekViewEvent *event;
+	CalComponent *comp;
+
+	event = &g_array_index (week_view->events, EWeekViewEvent,
+				event_num);
+
+	if (cal_component_is_instance (event->comp)) {
+		const char *uid;
+
+		cal_component_get_uid (event->comp, &uid);
+		if (cal_client_remove_object_with_mod (week_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS)
+			g_message ("e_week_view_on_delete_occurrence(): Could not update the object!");
+
+		return;
+	}
+
+	/* We must duplicate the CalComponent, or we won't know it has changed
+	   when we get the "update_event" callback. */
+
+	comp = cal_component_clone (event->comp);
+	cal_comp_util_add_exdate (comp, event->start, week_view->zone);
+
+	if (cal_client_update_object (week_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
+		g_message ("e_week_view_on_delete_occurrence(): Could not update the object!");
+
+	g_object_unref (comp);
+}
+
+static void
+e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
+{
+	EWeekView *week_view;
+
+	week_view = E_WEEK_VIEW (data);
+
+	if (week_view->popup_event_num == -1)
+		return;
+
+	e_week_view_delete_occurrence_internal (week_view, week_view->popup_event_num);
+}
+
+void
+e_week_view_delete_occurrence (EWeekView *week_view)
+{
+	g_return_if_fail (E_IS_WEEK_VIEW (week_view));
+
+	if (week_view->editing_event_num == -1)
+		return;
+
+	e_week_view_delete_occurrence_internal (week_view, week_view->editing_event_num);
+}
+
+static void
 e_week_view_on_cut (GtkWidget *widget, gpointer data)
 {
 	EWeekView *week_view;
@@ -4428,6 +4445,21 @@ e_week_view_get_num_events_selected (EWe
 	g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), 0);
 
 	return (week_view->editing_event_num != -1) ? 1 : 0;
+}
+
+/* Returns the currently-selected event, or NULL if none */
+CalComponent *
+e_week_view_get_selected_event (EWeekView *week_view)
+{
+	EWeekViewEvent *event;
+
+	g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), NULL);
+	g_return_val_if_fail (week_view->editing_event_num != -1, NULL);
+
+	event = &g_array_index (week_view->events, EWeekViewEvent,
+				week_view->editing_event_num);
+
+	return event ? event->comp : NULL;
 }
 
 /* Displays a message on the activity client. */
Index: gui/e-week-view.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.h,v
retrieving revision 1.33
diff -u -p -r1.33 e-week-view.h
--- gui/e-week-view.h	7 Apr 2003 00:14:52 -0000	1.33
+++ gui/e-week-view.h	21 Apr 2003 21:40:35 -0000
@@ -465,9 +465,12 @@ void       e_week_view_copy_clipboard   
 void       e_week_view_paste_clipboard          (EWeekView      *week_view);
 
 void       e_week_view_delete_event		(EWeekView      *week_view);
+void       e_week_view_delete_occurrence        (EWeekView      *week_view);
 
 /* Returns the number of selected events (0 or 1 at present). */
 gint	   e_week_view_get_num_events_selected	(EWeekView	*week_view);
+
+CalComponent *e_week_view_get_selected_event    (EWeekView      *week_view);
 
 /*
  * Internal functions called by the associated canvas items.
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.185
diff -u -p -r1.185 e-day-view.c
--- gui/e-day-view.c	15 Apr 2003 22:26:10 -0000	1.185
+++ gui/e-day-view.c	21 Apr 2003 21:40:38 -0000
@@ -4077,40 +4077,6 @@ e_day_view_on_settings (GtkWidget *widge
 }
 
 static void
-e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
-{
-	EDayView *day_view;
-	EDayViewEvent *event;
-	CalComponent *comp;
-
-	day_view = E_DAY_VIEW (data);
-
-	event = e_day_view_get_popup_menu_event (day_view);
-	if (event == NULL)
-		return;
-
-	if (cal_component_is_instance (event->comp)) {
-		const char *uid;
-
-		cal_component_get_uid (event->comp, &uid);
-		if (cal_client_remove_object_with_mod (day_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS)
-			g_message ("e_day_view_on_delete_occurrence(): Could not update the object!");
-
-		return;
-	}
-	
-	/* We must duplicate the CalComponent, or we won't know it has changed
-	   when we get the "update_event" callback. */
-	comp = cal_component_clone (event->comp);
-	cal_comp_util_add_exdate (comp, event->start, day_view->zone);
-
-	if (cal_client_update_object (day_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
-		g_message ("e_day_view_on_delete_occurrence(): Could not update the object!");
-
-	g_object_unref (comp);
-}
-
-static void
 e_day_view_delete_event_internal (EDayView *day_view, EDayViewEvent *event)
 {
 	CalComponentVType vtype;
@@ -4182,6 +4148,69 @@ e_day_view_delete_event		(EDayView      
 	e_day_view_delete_event_internal (day_view, event);
 }
 
+static void
+e_day_view_delete_occurrence_internal (EDayView *day_view, EDayViewEvent *event)
+{
+	CalComponent *comp;
+
+	if (cal_component_is_instance (event->comp)) {
+		const char *uid;
+
+		cal_component_get_uid (event->comp, &uid);
+		if (cal_client_remove_object_with_mod (day_view->client, uid, CALOBJ_MOD_THIS) != CAL_CLIENT_RESULT_SUCCESS)
+			g_message ("e_day_view_on_delete_occurrence(): Could not update the object!");
+
+		return;
+	}
+	
+	/* We must duplicate the CalComponent, or we won't know it has changed
+	   when we get the "update_event" callback. */
+	comp = cal_component_clone (event->comp);
+	cal_comp_util_add_exdate (comp, event->start, day_view->zone);
+
+	if (cal_client_update_object (day_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
+		g_message ("e_day_view_on_delete_occurrence(): Could not update the object!");
+
+	g_object_unref (comp);
+}
+
+static void
+e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
+{
+	EDayView *day_view;
+	EDayViewEvent *event;
+	CalComponent *comp;
+
+	day_view = E_DAY_VIEW (data);
+
+	event = e_day_view_get_popup_menu_event (day_view);
+	if (event == NULL)
+		return;
+
+	e_day_view_delete_occurrence_internal (day_view, event);
+}
+
+void
+e_day_view_delete_occurrence (EDayView *day_view)
+{
+	EDayViewEvent *event;
+
+	g_return_if_fail (E_IS_DAY_VIEW (day_view));
+
+	if (day_view->editing_event_day == -1)
+		return;
+
+	if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT)
+		event = &g_array_index (day_view->long_events,
+					EDayViewEvent,
+					day_view->editing_event_num);
+	else
+		event = &g_array_index (day_view->events[day_view->editing_event_day],
+					EDayViewEvent,
+					day_view->editing_event_num);
+
+	e_day_view_delete_occurrence_internal (day_view, event);
+}
 
 static void
 e_day_view_on_cut (GtkWidget *widget, gpointer data)
@@ -7754,6 +7783,27 @@ e_day_view_get_num_events_selected (EDay
 	g_return_val_if_fail (E_IS_DAY_VIEW (day_view), 0);
 
 	return (day_view->editing_event_day != -1) ? 1 : 0;
+}
+
+/* Returns the currently-selected event, or NULL if none */
+CalComponent *
+e_day_view_get_selected_event (EDayView *day_view)
+{
+	EDayViewEvent *event;
+
+	g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL);
+	g_return_val_if_fail (day_view->editing_event_day != -1, NULL);
+
+	if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT)
+		event = &g_array_index (day_view->long_events,
+				       EDayViewEvent,
+				       day_view->editing_event_num);
+	else
+		event = &g_array_index (day_view->events[day_view->editing_event_day],
+				       EDayViewEvent,
+				       day_view->editing_event_num);
+
+	return event ? event->comp : NULL;
 }
 
 /* Displays messages on the status bar. */
Index: gui/e-day-view.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.h,v
retrieving revision 1.38
diff -u -p -r1.38 e-day-view.h
--- gui/e-day-view.h	29 Mar 2003 20:04:52 -0000	1.38
+++ gui/e-day-view.h	21 Apr 2003 21:40:39 -0000
@@ -609,11 +609,13 @@ void       e_day_view_copy_clipboard    
 void       e_day_view_paste_clipboard           (EDayView       *day_view);
 
 void       e_day_view_delete_event		(EDayView       *day_view);
+void       e_day_view_delete_occurrence         (EDayView       *day_view);
 
 
 /* Returns the number of selected events (0 or 1 at present). */
 gint	   e_day_view_get_num_events_selected	(EDayView	*day_view);
 
+CalComponent *e_day_view_get_selected_event     (EDayView       *day_view);
 
 /*
  * Internal functions called by the associated canvas items.


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