[evolution] Bug #558030 - Convert meeting to appointment popup menu option



commit 00e1de6f7d333da5177548cc45be669b1e4e2195
Author: Milan Crha <mcrha redhat com>
Date:   Thu Nov 26 16:04:54 2009 +0100

    Bug #558030 - Convert meeting to appointment popup menu option

 modules/calendar/e-cal-shell-view-actions.c |   57 ++++++++++++++++++++++++--
 modules/calendar/e-cal-shell-view-actions.h |    2 +
 modules/calendar/e-cal-shell-view.c         |    4 ++
 ui/evolution-calendars.ui                   |    1 +
 4 files changed, 59 insertions(+), 5 deletions(-)
---
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index e88fae7..68da6b2 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -1105,8 +1105,7 @@ exit:
 }
 
 static void
-action_event_schedule_cb (GtkAction *action,
-                          ECalShellView *cal_shell_view)
+edit_event_as (ECalShellView *cal_shell_view, gboolean as_meeting)
 {
 	ECalShellContent *cal_shell_content;
 	GnomeCalendarViewType view_type;
@@ -1129,13 +1128,50 @@ action_event_schedule_cb (GtkAction *action,
 	client = event->comp_data->client;
 	icalcomp = event->comp_data->icalcomp;
 
+	if (!as_meeting && icalcomp) {
+		/* remove organizer and all attendees */
+		icalproperty *prop;
+
+		/* do it on a copy, as user can cancel changes */
+		icalcomp = icalcomponent_new_clone (icalcomp);
+
+		#define remove_all(_kind)									\
+			while (prop = icalcomponent_get_first_property (icalcomp, _kind), prop != NULL) {	\
+				icalcomponent_remove_property (icalcomp, prop);					\
+				icalproperty_free (prop);							\
+			}
+
+		remove_all (ICAL_ATTENDEE_PROPERTY);
+		remove_all (ICAL_ORGANIZER_PROPERTY);
+
+		#undef remove_all
+	}
+
 	e_calendar_view_edit_appointment (
-		calendar_view, client, icalcomp, TRUE);
+		calendar_view, client, icalcomp, as_meeting);
+
+	if (!as_meeting && icalcomp) {
+		icalcomponent_free (icalcomp);
+	}
 
 	g_list_free (selected);
 }
 
 static void
+action_event_schedule_cb (GtkAction *action,
+                          ECalShellView *cal_shell_view)
+{
+	edit_event_as (cal_shell_view, TRUE);
+}
+
+static void
+action_event_schedule_appointment_cb (GtkAction *action,
+                          ECalShellView *cal_shell_view)
+{
+	edit_event_as (cal_shell_view, FALSE);
+}
+
+static void
 action_gal_save_custom_view_cb (GtkAction *action,
                                 ECalShellView *cal_shell_view)
 {
@@ -1372,9 +1408,16 @@ static GtkActionEntry calendar_entries[] = {
 	  NULL,
 	  N_("_Schedule Meeting..."),
 	  NULL,
-	  NULL,  /* XXX Add a tooltip! */
+	  N_("Converts an appointment to a meeting"),
 	  G_CALLBACK (action_event_schedule_cb) },
 
+	{ "event-schedule-appointment",
+	  NULL,
+	  N_("Conv_ert to Appointment..."),
+	  NULL,
+	  N_("Converts a meeting to an appointment"),
+	  G_CALLBACK (action_event_schedule_appointment_cb) },
+
 	/*** Menus ***/
 
 	{ "calendar-actions-menu",
@@ -1481,7 +1524,11 @@ static EPopupActionEntry calendar_popup_entries[] = {
 
 	{ "event-popup-schedule",
 	  NULL,
-	  "event-schedule" }
+	  "event-schedule" },
+
+	{ "event-popup-schedule-appointment",
+	  NULL,
+	  "event-schedule-appointment" }
 };
 
 static GtkRadioActionEntry calendar_view_entries[] = {
diff --git a/modules/calendar/e-cal-shell-view-actions.h b/modules/calendar/e-cal-shell-view-actions.h
index 840985b..94ad66c 100644
--- a/modules/calendar/e-cal-shell-view-actions.h
+++ b/modules/calendar/e-cal-shell-view-actions.h
@@ -85,6 +85,8 @@
 	E_SHELL_WINDOW_ACTION ((window), "event-print")
 #define E_SHELL_WINDOW_ACTION_EVENT_SCHEDULE(window) \
 	E_SHELL_WINDOW_ACTION ((window), "event-schedule")
+#define E_SHELL_WINDOW_ACTION_EVENT_SCHEDULE_APPOINTMENT(window) \
+	E_SHELL_WINDOW_ACTION ((window), "event-schedule-appointment")
 #define E_SHELL_WINDOW_ACTION_EVENT_REPLY(window) \
 	E_SHELL_WINDOW_ACTION ((window), "event-reply")
 #define E_SHELL_WINDOW_ACTION_EVENT_REPLY_ALL(window) \
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index f767f92..396cdec 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -436,6 +436,10 @@ cal_shell_view_update_actions (EShellView *shell_view)
 	sensitive = (n_selected == 1) && editable && !is_meeting;
 	gtk_action_set_sensitive (action, sensitive);
 
+	action = ACTION (EVENT_SCHEDULE_APPOINTMENT);
+	sensitive = (n_selected == 1) && editable && is_meeting;
+	gtk_action_set_sensitive (action, sensitive);
+
 	action = ACTION (EVENT_REPLY);
 	sensitive = (n_selected == 1) && is_meeting;
 	gtk_action_set_sensitive (action, sensitive);
diff --git a/ui/evolution-calendars.ui b/ui/evolution-calendars.ui
index 69d4263..feb68db 100644
--- a/ui/evolution-calendars.ui
+++ b/ui/evolution-calendars.ui
@@ -92,6 +92,7 @@
     <menuitem action='event-popup-move'/>
     <menuitem action='event-popup-delegate'/>
     <menuitem action='event-popup-schedule'/>
+    <menuitem action='event-popup-schedule-appointment'/>
     <menuitem action='event-popup-forward'/>
     <menuitem action='event-popup-reply'/>
     <menuitem action='event-popup-reply-all'/>



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