diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 35 | ||||
-rw-r--r-- | calendar/gui/e-cal-view.c | 482 | ||||
-rw-r--r-- | calendar/gui/e-cal-view.h | 3 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 482 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.h | 3 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 592 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 1 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 569 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 1 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 24 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 1 |
11 files changed, 1037 insertions, 1156 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 06fdce3d40..231d41c508 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,38 @@ +2003-07-23 Rodrigo Moya <rodrigo@ximian.com> + + * gui/e-cal-view.[ch]: moved the duplicated popup menu code here. + (e_cal_view_create_popup_menu): new function to create the popup + menu for all views. + (on_new_appointment, on_new_event, on_new_meeting, on_new_task, + on_goto_today, on_goto_date, on_edit_appointment, on_print, + on_save_as, on_print_event, on_meeting, on_forward, on_publish, + on_settings, on_delete_appointment, on_cut, on_copy, on_paste, + on_unrecur_appointment): callbacks for the popup menu items. + + * gui/e-week-view.c (e_week_view_on_new_appointment, + e_week_view_new_appointment, e_week_view_on_new_event, + e_week_view_on_new_meeting, e_week_view_on_new_task, + e_week_view_on_goto_today, e_week_view_on_goto_date, + e_week_view_on_edit_appointment, e_week_view_on_print, + e_week_view_on_save_as, e_week_view_on_print_event, + e_week_view_on_meeting, e_week_view_on_forward, + e_week_view_on_publish, e_week_view_on_settings, + e_week_view_on_delete_appointment, + e_week_view_delete_event_internal, e_week_view_on_cut, + e_week_view_on_copy, e_week_view_on_paste): + * gui/e-day-view.c (e_day_view_on_new_appointment, + e_day_view_on_new_event, e_day_view_on_new_meeting, + e_day_view_on_new_task, e_day_view_on_goto_today, + e_day_view_on_goto_date, e_day_view_on_edit_appointment, + e_day_view_on_print, e_day_view_on_save_as, + e_day_view_on_print_event, e_day_view_on_meeting, + e_day_view_on_forward, e_day_view_on_publish, + e_day_view_on_settings, e_day_view_on_delete_appointment, + e_day_view_delete_event_internal, e_day_view_on_cut, + e_day_view_on_copy, e_day_view_on_paste): removed duplicated code. + + * gui/gnome-cal.[ch] (gnome_calendar_unrecur_selection): new function. + 2003-07-23 Dan Winship <danw@ximian.com> * gui/alarm-notify/alarm-queue.c (on_dialog_obj_updated_cb): Fix diff --git a/calendar/gui/e-cal-view.c b/calendar/gui/e-cal-view.c index f5c64c049b..c9bfebc294 100644 --- a/calendar/gui/e-cal-view.c +++ b/calendar/gui/e-cal-view.c @@ -26,13 +26,20 @@ #include <gtk/gtkinvisible.h> #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> +#include "e-util/e-dialog-utils.h" +#include "cal-util/timeutil.h" #include "evolution-activity-client.h" +#include "calendar-commands.h" #include "calendar-config.h" #include "e-cal-view.h" #include "itip-utils.h" -#include "dialogs/cancel-comp.h" +#include "dialogs/delete-comp.h" #include "dialogs/delete-error.h" #include "dialogs/send-comp.h" +#include "dialogs/cancel-comp.h" +#include "dialogs/recur-comp.h" +#include "print.h" +#include "goto.h" /* Used for the status bar messages */ #define EVOLUTION_CALENDAR_PROGRESS_IMAGE "evolution-calendar-mini.png" @@ -54,6 +61,9 @@ struct _ECalViewPrivate { /* the invisible widget to manage the clipboard selections */ GtkWidget *invisible; gchar *clipboard_selection; + + /* The popup menu */ + EPopupMenu *view_menu; }; static void e_cal_view_class_init (ECalViewClass *klass); @@ -75,6 +85,7 @@ static void e_cal_view_class_init (ECalViewClass *klass) { GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); parent_class = g_type_class_peek_parent (klass); @@ -461,12 +472,14 @@ e_cal_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_ gboolean e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), FALSE); if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( + return E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( cal_view, start_time, end_time); } + + return FALSE; } void @@ -560,3 +573,466 @@ e_cal_view_paste_clipboard (ECalView *cal_view) GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME); } + +static void +on_new_appointment (GtkWidget *widget, gpointer user_data) +{ + time_t dtstart, dtend; + ECalView *cal_view = (ECalView *) user_data; + + e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); + gnome_calendar_new_appointment_for (cal_view->priv->calendar, dtstart, dtend, FALSE, FALSE); +} + +static void +on_new_event (GtkWidget *widget, gpointer user_data) +{ + time_t dtstart, dtend; + ECalView *cal_view = (ECalView *) user_data; + + e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); + gnome_calendar_new_appointment_for (cal_view->priv->calendar, dtstart, dtend, TRUE, FALSE); +} + +static void +on_new_meeting (GtkWidget *widget, gpointer user_data) +{ + time_t dtstart, dtend; + ECalView *cal_view = (ECalView *) user_data; + + e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); + gnome_calendar_new_appointment_for (cal_view->priv->calendar, dtstart, dtend, FALSE, TRUE); +} + +static void +on_new_task (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = (ECalView *) user_data; + gnome_calendar_new_task (cal_view->priv->calendar); +} + +static void +on_goto_date (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + goto_dialog (cal_view->priv->calendar); +} + +static void +on_goto_today (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + calendar_goto_today (cal_view->priv->calendar); +} + +static void +on_edit_appointment (GtkWidget *widget, gpointer user_data) +{ + GList *selected; + ECalView *cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), FALSE); + + g_list_free (selected); + } +} + +static void +on_print (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + time_t start; + GnomeCalendarViewType view_type; + PrintView print_view; + + cal_view = E_CAL_VIEW (user_data); + + gnome_calendar_get_current_time_range (cal_view->priv->calendar, &start, NULL); + view_type = gnome_calendar_get_view (cal_view->priv->calendar); + + switch (view_type) { + case GNOME_CAL_WEEK_VIEW: + print_view = PRINT_VIEW_WEEK; + break; + + case GNOME_CAL_MONTH_VIEW: + print_view = PRINT_VIEW_MONTH; + break; + + default: + g_assert_not_reached (); + return; + } + + print_calendar (cal_view->priv->calendar, FALSE, start, print_view); +} + +static void +on_save_as (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + GList *selected; + char *filename; + char *ical_string; + FILE *file; + + cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (!selected) + return; + + filename = e_file_dialog_save (_("Save as...")); + if (filename == NULL) + return; + + ical_string = cal_client_get_component_as_string (cal_view->priv->client, + CAL_COMPONENT (selected->data)); + if (ical_string == NULL) { + g_warning ("Couldn't convert item to a string"); + return; + } + + file = fopen (filename, "w"); + if (file == NULL) { + g_warning ("Couldn't save item"); + return; + } + + fprintf (file, ical_string); + g_free (ical_string); + fclose (file); + + g_list_free (selected); +} + +static void +on_print_event (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + GList *selected; + + cal_view = E_CAL_VIEW (user_data); + selected = e_cal_view_get_selected_events (cal_view); + if (!selected) + return; + + print_comp (CAL_COMPONENT (selected->data), cal_view->priv->client, FALSE); +} + +static void +on_meeting (GtkWidget *widget, gpointer user_data) +{ + GList *selected; + ECalView *cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), TRUE); + + g_list_free (selected); + } +} + +static void +on_forward (GtkWidget *widget, gpointer user_data) +{ + GList *selected; + ECalView *cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, CAL_COMPONENT (selected->data), + cal_view->priv->client, NULL); + + g_list_free (selected); + } +} + +static void +on_publish (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + icaltimezone *utc; + time_t start = time (NULL), end; + GList *comp_list; + + cal_view = E_CAL_VIEW (user_data); + + utc = icaltimezone_get_utc_timezone (); + start = time_day_begin_with_zone (start, utc); + end = time_add_week_with_zone (start, 6, utc); + + comp_list = cal_client_get_free_busy (cal_view->priv->client, NULL, start, end); + if (comp_list) { + GList *l; + + for (l = comp_list; l; l = l->next) { + CalComponent *comp = CAL_COMPONENT (l->data); + itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, cal_view->priv->client, NULL); + + g_object_unref (comp); + } + + g_list_free (comp_list); + } +} + +static void +on_settings (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + + cal_view = E_CAL_VIEW (user_data); + control_util_show_settings (cal_view->priv->calendar); +} + +void +e_cal_view_delete_event_internal (ECalView *cal_view, CalComponent *comp) +{ + CalComponentVType vtype; + + vtype = cal_component_get_vtype (comp); + + if (delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view))) { + const char *uid; + + if (itip_organizer_is_user (comp, cal_view->priv->client) + && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view), + cal_view->priv->client, + comp, TRUE)) + itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, + cal_view->priv->client, NULL); + + cal_component_get_uid (comp, &uid); + + delete_error_dialog ( + cal_client_remove_object (cal_view->priv->client, uid), CAL_COMPONENT_EVENT); + } +} + + +static void +on_delete_appointment (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + GList *selected; + + cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + e_cal_view_delete_event_internal (cal_view, CAL_COMPONENT (selected->data)); + g_list_free (selected); + } +} + +static void +on_delete_occurrence (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + + cal_view = E_CAL_VIEW (user_data); + gnome_calendar_delete_selected_occurrence (cal_view->priv->calendar); +} + +static void +on_cut (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + e_cal_view_cut_clipboard (cal_view); +} + +static void +on_copy (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + e_cal_view_copy_clipboard (cal_view); +} + +static void +on_paste (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + e_cal_view_paste_clipboard (cal_view); +} + +static void +on_unrecur_appointment (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + gnome_calendar_unrecur_selection (cal_view->priv->calendar); +} + +enum { + /* + * This is used to "flag" events that can not be editted + */ + MASK_EDITABLE = 1, + + /* + * To disable recurring actions to be displayed + */ + MASK_RECURRING = 2, + + /* + * To disable actions for non-recurring items to be displayed + */ + MASK_SINGLE = 4, + + /* + * This is used to when an event is currently being edited + * in another window and we want to disable the event + * from being edited twice + */ + MASK_EDITING = 8, + + /* + * This is used to when an event is already a meeting and + * we want to disable the schedule meeting command + */ + MASK_MEETING = 16, + + /* + * To disable cut and copy for meetings the user is not the + * organizer of + */ + MASK_MEETING_ORGANIZER = 32, + + /* + * To disable things not valid for instances + */ + MASK_INSTANCE = 64 +}; + +static EPopupMenu main_items [] = { + E_POPUP_ITEM (N_("New _Appointment..."), GTK_SIGNAL_FUNC (on_new_appointment), MASK_EDITABLE), + E_POPUP_ITEM (N_("New All Day _Event"), GTK_SIGNAL_FUNC (on_new_event), MASK_EDITABLE), + E_POPUP_ITEM (N_("New Meeting"), GTK_SIGNAL_FUNC (on_new_meeting), MASK_EDITABLE), + E_POPUP_ITEM (N_("New Task"), GTK_SIGNAL_FUNC (on_new_task), MASK_EDITABLE), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print), 0), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE), + + E_POPUP_SEPARATOR, + + E_POPUP_SUBMENU (N_("Current View"), NULL, 0), + + E_POPUP_ITEM (N_("Go to _Today"), GTK_SIGNAL_FUNC (on_goto_today), 0), + E_POPUP_ITEM (N_("_Go to Date..."), GTK_SIGNAL_FUNC (on_goto_date), 0), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Publish Free/Busy Information"), GTK_SIGNAL_FUNC (on_publish), 0), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Settings..."), GTK_SIGNAL_FUNC (on_settings), 0), + + E_POPUP_TERMINATOR +}; + +static EPopupMenu child_items [] = { + E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (on_edit_appointment), MASK_EDITING), + E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (on_save_as), MASK_EDITING), + E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print_event), MASK_EDITING), + + /* Only show this separator if one of the above is shown. */ + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("C_ut"), GTK_SIGNAL_FUNC (on_cut), MASK_EDITING | MASK_EDITABLE | MASK_MEETING_ORGANIZER), + E_POPUP_ITEM (N_("_Copy"), GTK_SIGNAL_FUNC (on_copy), MASK_EDITING | MASK_MEETING_ORGANIZER), + E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Schedule Meeting..."), GTK_SIGNAL_FUNC (on_meeting), MASK_EDITABLE | MASK_EDITING | MASK_MEETING), + E_POPUP_ITEM (N_("_Forward as iCalendar..."), GTK_SIGNAL_FUNC (on_forward), MASK_EDITING), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), + E_POPUP_ITEM (N_("Make this Occurrence _Movable"), GTK_SIGNAL_FUNC (on_unrecur_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE | MASK_INSTANCE), + E_POPUP_ITEM (N_("Delete this _Occurrence"), GTK_SIGNAL_FUNC (on_delete_occurrence), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE), + E_POPUP_ITEM (N_("Delete _All Occurrences"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE), + + E_POPUP_TERMINATOR +}; + +static void +free_view_popup (GtkWidget *widget, gpointer data) +{ + ECalView *cal_view = E_CAL_VIEW (data); + + if (cal_view->priv->view_menu == NULL) + return; + + gnome_calendar_discard_view_popup (cal_view->priv->calendar, cal_view->priv->view_menu); + cal_view->priv->view_menu = NULL; +} + +GtkMenu * +e_cal_view_create_popup_menu (ECalView *cal_view) +{ + gboolean being_edited, have_selection; + GList *selected; + EPopupMenu *context_menu; + guint32 disable_mask = 0, hide_mask = 0; + GtkMenu *popup; + + g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + + /* get the selection */ + being_edited = FALSE; + selected = e_cal_view_get_selected_events (cal_view); + + have_selection = GTK_WIDGET_HAS_FOCUS (cal_view) && selected != NULL; + + if (selected == NULL) { + cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar); + main_items[9].submenu = cal_view->priv->view_menu; + context_menu = main_items; + } else { + context_menu = child_items; + + if (cal_component_has_recurrences (CAL_COMPONENT (selected->data))) + hide_mask |= MASK_SINGLE; + else + hide_mask |= MASK_RECURRING; + + if (cal_component_is_instance (CAL_COMPONENT (selected->data))) + hide_mask |= MASK_INSTANCE; + + if (cal_component_has_organizer (CAL_COMPONENT (selected->data))) { + disable_mask |= MASK_MEETING; + + if (!itip_organizer_is_user (CAL_COMPONENT (selected->data), + cal_view->priv->client)) + disable_mask |= MASK_MEETING_ORGANIZER; + } + } + + if (cal_client_is_read_only (cal_view->priv->client)) + disable_mask |= MASK_EDITABLE; + + if (being_edited) + disable_mask |= MASK_EDITING; + + popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, cal_view); + g_signal_connect (popup, "selection-done", G_CALLBACK (free_view_popup), cal_view); + + return popup; +} diff --git a/calendar/gui/e-cal-view.h b/calendar/gui/e-cal-view.h index eb22decb26..28079831d0 100644 --- a/calendar/gui/e-cal-view.h +++ b/calendar/gui/e-cal-view.h @@ -80,6 +80,9 @@ void e_cal_view_update_query (ECalView *cal_view); void e_cal_view_cut_clipboard (ECalView *cal_view); void e_cal_view_copy_clipboard (ECalView *cal_view); void e_cal_view_paste_clipboard (ECalView *cal_view); +void e_cal_view_delete_event_internal (ECalView *cal_view, CalComponent *comp); + +GtkMenu *e_cal_view_create_popup_menu (ECalView *cal_view); G_END_DECLS diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index f5c64c049b..c9bfebc294 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -26,13 +26,20 @@ #include <gtk/gtkinvisible.h> #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> +#include "e-util/e-dialog-utils.h" +#include "cal-util/timeutil.h" #include "evolution-activity-client.h" +#include "calendar-commands.h" #include "calendar-config.h" #include "e-cal-view.h" #include "itip-utils.h" -#include "dialogs/cancel-comp.h" +#include "dialogs/delete-comp.h" #include "dialogs/delete-error.h" #include "dialogs/send-comp.h" +#include "dialogs/cancel-comp.h" +#include "dialogs/recur-comp.h" +#include "print.h" +#include "goto.h" /* Used for the status bar messages */ #define EVOLUTION_CALENDAR_PROGRESS_IMAGE "evolution-calendar-mini.png" @@ -54,6 +61,9 @@ struct _ECalViewPrivate { /* the invisible widget to manage the clipboard selections */ GtkWidget *invisible; gchar *clipboard_selection; + + /* The popup menu */ + EPopupMenu *view_menu; }; static void e_cal_view_class_init (ECalViewClass *klass); @@ -75,6 +85,7 @@ static void e_cal_view_class_init (ECalViewClass *klass) { GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); parent_class = g_type_class_peek_parent (klass); @@ -461,12 +472,14 @@ e_cal_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_ gboolean e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), FALSE); if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( + return E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( cal_view, start_time, end_time); } + + return FALSE; } void @@ -560,3 +573,466 @@ e_cal_view_paste_clipboard (ECalView *cal_view) GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME); } + +static void +on_new_appointment (GtkWidget *widget, gpointer user_data) +{ + time_t dtstart, dtend; + ECalView *cal_view = (ECalView *) user_data; + + e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); + gnome_calendar_new_appointment_for (cal_view->priv->calendar, dtstart, dtend, FALSE, FALSE); +} + +static void +on_new_event (GtkWidget *widget, gpointer user_data) +{ + time_t dtstart, dtend; + ECalView *cal_view = (ECalView *) user_data; + + e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); + gnome_calendar_new_appointment_for (cal_view->priv->calendar, dtstart, dtend, TRUE, FALSE); +} + +static void +on_new_meeting (GtkWidget *widget, gpointer user_data) +{ + time_t dtstart, dtend; + ECalView *cal_view = (ECalView *) user_data; + + e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); + gnome_calendar_new_appointment_for (cal_view->priv->calendar, dtstart, dtend, FALSE, TRUE); +} + +static void +on_new_task (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = (ECalView *) user_data; + gnome_calendar_new_task (cal_view->priv->calendar); +} + +static void +on_goto_date (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + goto_dialog (cal_view->priv->calendar); +} + +static void +on_goto_today (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + calendar_goto_today (cal_view->priv->calendar); +} + +static void +on_edit_appointment (GtkWidget *widget, gpointer user_data) +{ + GList *selected; + ECalView *cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), FALSE); + + g_list_free (selected); + } +} + +static void +on_print (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + time_t start; + GnomeCalendarViewType view_type; + PrintView print_view; + + cal_view = E_CAL_VIEW (user_data); + + gnome_calendar_get_current_time_range (cal_view->priv->calendar, &start, NULL); + view_type = gnome_calendar_get_view (cal_view->priv->calendar); + + switch (view_type) { + case GNOME_CAL_WEEK_VIEW: + print_view = PRINT_VIEW_WEEK; + break; + + case GNOME_CAL_MONTH_VIEW: + print_view = PRINT_VIEW_MONTH; + break; + + default: + g_assert_not_reached (); + return; + } + + print_calendar (cal_view->priv->calendar, FALSE, start, print_view); +} + +static void +on_save_as (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + GList *selected; + char *filename; + char *ical_string; + FILE *file; + + cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (!selected) + return; + + filename = e_file_dialog_save (_("Save as...")); + if (filename == NULL) + return; + + ical_string = cal_client_get_component_as_string (cal_view->priv->client, + CAL_COMPONENT (selected->data)); + if (ical_string == NULL) { + g_warning ("Couldn't convert item to a string"); + return; + } + + file = fopen (filename, "w"); + if (file == NULL) { + g_warning ("Couldn't save item"); + return; + } + + fprintf (file, ical_string); + g_free (ical_string); + fclose (file); + + g_list_free (selected); +} + +static void +on_print_event (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + GList *selected; + + cal_view = E_CAL_VIEW (user_data); + selected = e_cal_view_get_selected_events (cal_view); + if (!selected) + return; + + print_comp (CAL_COMPONENT (selected->data), cal_view->priv->client, FALSE); +} + +static void +on_meeting (GtkWidget *widget, gpointer user_data) +{ + GList *selected; + ECalView *cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), TRUE); + + g_list_free (selected); + } +} + +static void +on_forward (GtkWidget *widget, gpointer user_data) +{ + GList *selected; + ECalView *cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, CAL_COMPONENT (selected->data), + cal_view->priv->client, NULL); + + g_list_free (selected); + } +} + +static void +on_publish (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + icaltimezone *utc; + time_t start = time (NULL), end; + GList *comp_list; + + cal_view = E_CAL_VIEW (user_data); + + utc = icaltimezone_get_utc_timezone (); + start = time_day_begin_with_zone (start, utc); + end = time_add_week_with_zone (start, 6, utc); + + comp_list = cal_client_get_free_busy (cal_view->priv->client, NULL, start, end); + if (comp_list) { + GList *l; + + for (l = comp_list; l; l = l->next) { + CalComponent *comp = CAL_COMPONENT (l->data); + itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, cal_view->priv->client, NULL); + + g_object_unref (comp); + } + + g_list_free (comp_list); + } +} + +static void +on_settings (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + + cal_view = E_CAL_VIEW (user_data); + control_util_show_settings (cal_view->priv->calendar); +} + +void +e_cal_view_delete_event_internal (ECalView *cal_view, CalComponent *comp) +{ + CalComponentVType vtype; + + vtype = cal_component_get_vtype (comp); + + if (delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view))) { + const char *uid; + + if (itip_organizer_is_user (comp, cal_view->priv->client) + && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view), + cal_view->priv->client, + comp, TRUE)) + itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, + cal_view->priv->client, NULL); + + cal_component_get_uid (comp, &uid); + + delete_error_dialog ( + cal_client_remove_object (cal_view->priv->client, uid), CAL_COMPONENT_EVENT); + } +} + + +static void +on_delete_appointment (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + GList *selected; + + cal_view = E_CAL_VIEW (user_data); + + selected = e_cal_view_get_selected_events (cal_view); + if (selected) { + e_cal_view_delete_event_internal (cal_view, CAL_COMPONENT (selected->data)); + g_list_free (selected); + } +} + +static void +on_delete_occurrence (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view; + + cal_view = E_CAL_VIEW (user_data); + gnome_calendar_delete_selected_occurrence (cal_view->priv->calendar); +} + +static void +on_cut (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + e_cal_view_cut_clipboard (cal_view); +} + +static void +on_copy (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + e_cal_view_copy_clipboard (cal_view); +} + +static void +on_paste (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + e_cal_view_paste_clipboard (cal_view); +} + +static void +on_unrecur_appointment (GtkWidget *widget, gpointer user_data) +{ + ECalView *cal_view = E_CAL_VIEW (user_data); + + gnome_calendar_unrecur_selection (cal_view->priv->calendar); +} + +enum { + /* + * This is used to "flag" events that can not be editted + */ + MASK_EDITABLE = 1, + + /* + * To disable recurring actions to be displayed + */ + MASK_RECURRING = 2, + + /* + * To disable actions for non-recurring items to be displayed + */ + MASK_SINGLE = 4, + + /* + * This is used to when an event is currently being edited + * in another window and we want to disable the event + * from being edited twice + */ + MASK_EDITING = 8, + + /* + * This is used to when an event is already a meeting and + * we want to disable the schedule meeting command + */ + MASK_MEETING = 16, + + /* + * To disable cut and copy for meetings the user is not the + * organizer of + */ + MASK_MEETING_ORGANIZER = 32, + + /* + * To disable things not valid for instances + */ + MASK_INSTANCE = 64 +}; + +static EPopupMenu main_items [] = { + E_POPUP_ITEM (N_("New _Appointment..."), GTK_SIGNAL_FUNC (on_new_appointment), MASK_EDITABLE), + E_POPUP_ITEM (N_("New All Day _Event"), GTK_SIGNAL_FUNC (on_new_event), MASK_EDITABLE), + E_POPUP_ITEM (N_("New Meeting"), GTK_SIGNAL_FUNC (on_new_meeting), MASK_EDITABLE), + E_POPUP_ITEM (N_("New Task"), GTK_SIGNAL_FUNC (on_new_task), MASK_EDITABLE), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print), 0), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE), + + E_POPUP_SEPARATOR, + + E_POPUP_SUBMENU (N_("Current View"), NULL, 0), + + E_POPUP_ITEM (N_("Go to _Today"), GTK_SIGNAL_FUNC (on_goto_today), 0), + E_POPUP_ITEM (N_("_Go to Date..."), GTK_SIGNAL_FUNC (on_goto_date), 0), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Publish Free/Busy Information"), GTK_SIGNAL_FUNC (on_publish), 0), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Settings..."), GTK_SIGNAL_FUNC (on_settings), 0), + + E_POPUP_TERMINATOR +}; + +static EPopupMenu child_items [] = { + E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (on_edit_appointment), MASK_EDITING), + E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (on_save_as), MASK_EDITING), + E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print_event), MASK_EDITING), + + /* Only show this separator if one of the above is shown. */ + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("C_ut"), GTK_SIGNAL_FUNC (on_cut), MASK_EDITING | MASK_EDITABLE | MASK_MEETING_ORGANIZER), + E_POPUP_ITEM (N_("_Copy"), GTK_SIGNAL_FUNC (on_copy), MASK_EDITING | MASK_MEETING_ORGANIZER), + E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Schedule Meeting..."), GTK_SIGNAL_FUNC (on_meeting), MASK_EDITABLE | MASK_EDITING | MASK_MEETING), + E_POPUP_ITEM (N_("_Forward as iCalendar..."), GTK_SIGNAL_FUNC (on_forward), MASK_EDITING), + + E_POPUP_SEPARATOR, + + E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), + E_POPUP_ITEM (N_("Make this Occurrence _Movable"), GTK_SIGNAL_FUNC (on_unrecur_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE | MASK_INSTANCE), + E_POPUP_ITEM (N_("Delete this _Occurrence"), GTK_SIGNAL_FUNC (on_delete_occurrence), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE), + E_POPUP_ITEM (N_("Delete _All Occurrences"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE), + + E_POPUP_TERMINATOR +}; + +static void +free_view_popup (GtkWidget *widget, gpointer data) +{ + ECalView *cal_view = E_CAL_VIEW (data); + + if (cal_view->priv->view_menu == NULL) + return; + + gnome_calendar_discard_view_popup (cal_view->priv->calendar, cal_view->priv->view_menu); + cal_view->priv->view_menu = NULL; +} + +GtkMenu * +e_cal_view_create_popup_menu (ECalView *cal_view) +{ + gboolean being_edited, have_selection; + GList *selected; + EPopupMenu *context_menu; + guint32 disable_mask = 0, hide_mask = 0; + GtkMenu *popup; + + g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + + /* get the selection */ + being_edited = FALSE; + selected = e_cal_view_get_selected_events (cal_view); + + have_selection = GTK_WIDGET_HAS_FOCUS (cal_view) && selected != NULL; + + if (selected == NULL) { + cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar); + main_items[9].submenu = cal_view->priv->view_menu; + context_menu = main_items; + } else { + context_menu = child_items; + + if (cal_component_has_recurrences (CAL_COMPONENT (selected->data))) + hide_mask |= MASK_SINGLE; + else + hide_mask |= MASK_RECURRING; + + if (cal_component_is_instance (CAL_COMPONENT (selected->data))) + hide_mask |= MASK_INSTANCE; + + if (cal_component_has_organizer (CAL_COMPONENT (selected->data))) { + disable_mask |= MASK_MEETING; + + if (!itip_organizer_is_user (CAL_COMPONENT (selected->data), + cal_view->priv->client)) + disable_mask |= MASK_MEETING_ORGANIZER; + } + } + + if (cal_client_is_read_only (cal_view->priv->client)) + disable_mask |= MASK_EDITABLE; + + if (being_edited) + disable_mask |= MASK_EDITING; + + popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, cal_view); + g_signal_connect (popup, "selection-done", G_CALLBACK (free_view_popup), cal_view); + + return popup; +} diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index eb22decb26..28079831d0 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -80,6 +80,9 @@ void e_cal_view_update_query (ECalView *cal_view); void e_cal_view_cut_clipboard (ECalView *cal_view); void e_cal_view_copy_clipboard (ECalView *cal_view); void e_cal_view_paste_clipboard (ECalView *cal_view); +void e_cal_view_delete_event_internal (ECalView *cal_view, CalComponent *comp); + +GtkMenu *e_cal_view_create_popup_menu (ECalView *cal_view); G_END_DECLS diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 52d9f53a2f..d1586dd902 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -357,43 +357,6 @@ static void e_day_view_start_auto_scroll (EDayView *day_view, gboolean scroll_up); static gboolean e_day_view_auto_scroll_handler (gpointer data); -static void e_day_view_on_new_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_new_event (GtkWidget *widget, - gpointer data); -static void e_day_view_on_new_meeting (GtkWidget *widget, - gpointer data); -static void e_day_view_on_new_task (GtkWidget *widget, - gpointer data); -static void e_day_view_on_goto_today (GtkWidget *widget, - gpointer data); -static void e_day_view_on_goto_date (GtkWidget *widget, - gpointer data); -static void e_day_view_on_edit_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_save_as (GtkWidget *widget, - gpointer data); -static void e_day_view_on_print (GtkWidget *widget, - gpointer data); -static void e_day_view_on_print_event (GtkWidget *widget, - gpointer data); -static void e_day_view_on_meeting (GtkWidget *widget, - gpointer data); -static void e_day_view_on_forward (GtkWidget *widget, - gpointer data); -static void e_day_view_on_publish (GtkWidget *widget, - gpointer data); -static void e_day_view_on_settings (GtkWidget *widget, - gpointer data); -static void e_day_view_on_delete_occurrence (GtkWidget *widget, - gpointer data); -static void e_day_view_on_delete_appointment (GtkWidget *widget, - gpointer data); -static void e_day_view_on_cut (GtkWidget *widget, gpointer data); -static void e_day_view_on_copy (GtkWidget *widget, gpointer data); -static void e_day_view_on_paste (GtkWidget *widget, gpointer data); -static void e_day_view_on_unrecur_appointment (GtkWidget *widget, - gpointer data); static EDayViewEvent* e_day_view_get_popup_menu_event (EDayView *day_view); static gboolean e_day_view_on_top_canvas_drag_motion (GtkWidget *widget, @@ -3378,130 +3341,6 @@ e_day_view_on_event_double_click (EDayView *day_view, } } -enum { - /* - * This is used to "flag" events that can not be edited - */ - MASK_EDITABLE = 1, - - /* - * To disable recurring actions to be displayed - */ - MASK_RECURRING = 2, - - /* - * To disable actions for non-recurring items to be displayed - */ - MASK_SINGLE = 4, - - /* - * This is used to when an event is currently being edited - * in another window and we want to disable the event - * from being edited twice - */ - MASK_EDITING = 8, - - /* - * This is used to when an event is already a meeting and - * we want to disable the schedule meeting command - */ - MASK_MEETING = 16, - - /* - * To disable cut and copy for meetings the user is not the - * organizer of - */ - MASK_MEETING_ORGANIZER = 32, - - /* - * To disable things not valid for instances - */ - MASK_INSTANCE = 64 -}; - -static EPopupMenu main_items [] = { - E_POPUP_ITEM (N_("New _Appointment"), - GTK_SIGNAL_FUNC (e_day_view_on_new_appointment), MASK_EDITABLE), - E_POPUP_ITEM (N_("New All Day _Event"), - GTK_SIGNAL_FUNC (e_day_view_on_new_event), MASK_EDITABLE), - E_POPUP_ITEM (N_("New Meeting"), - GTK_SIGNAL_FUNC (e_day_view_on_new_meeting), MASK_EDITABLE), - E_POPUP_ITEM (N_("New Task"), - GTK_SIGNAL_FUNC (e_day_view_on_new_task), MASK_EDITABLE), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("Print..."), - GTK_SIGNAL_FUNC (e_day_view_on_print), 0), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Paste"), - GTK_SIGNAL_FUNC (e_day_view_on_paste), MASK_EDITABLE), - - E_POPUP_SEPARATOR, - - E_POPUP_SUBMENU (N_("Current View"), NULL, 0), - - E_POPUP_ITEM (N_("Go to _Today"), - GTK_SIGNAL_FUNC (e_day_view_on_goto_today), 0), - E_POPUP_ITEM (N_("_Go to Date..."), - GTK_SIGNAL_FUNC (e_day_view_on_goto_date), 0), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Publish Free/Busy Information"), - GTK_SIGNAL_FUNC (e_day_view_on_publish), 0), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Settings..."), - GTK_SIGNAL_FUNC (e_day_view_on_settings), 0), - - E_POPUP_TERMINATOR -}; - -static EPopupMenu child_items [] = { - - E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (e_day_view_on_edit_appointment), MASK_EDITING), - E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (e_day_view_on_save_as), MASK_EDITING), - E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (e_day_view_on_print_event), MASK_EDITING), - - /* Only show this separator if one of the above is shown. */ - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("C_ut"), GTK_SIGNAL_FUNC (e_day_view_on_cut), MASK_EDITABLE | MASK_EDITING | MASK_MEETING_ORGANIZER), - E_POPUP_ITEM (N_("_Copy"), GTK_SIGNAL_FUNC (e_day_view_on_copy), MASK_EDITING | MASK_MEETING_ORGANIZER), - E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (e_day_view_on_paste), MASK_EDITABLE), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Schedule Meeting..."), GTK_SIGNAL_FUNC (e_day_view_on_meeting), MASK_EDITABLE | MASK_EDITING | MASK_MEETING), - E_POPUP_ITEM (N_("_Forward as iCalendar..."), GTK_SIGNAL_FUNC (e_day_view_on_forward), MASK_EDITING), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (e_day_view_on_delete_appointment), MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), - E_POPUP_ITEM (N_("Make this Occurrence _Movable"), GTK_SIGNAL_FUNC (e_day_view_on_unrecur_appointment), MASK_EDITABLE | MASK_RECURRING | MASK_EDITING | MASK_INSTANCE), - E_POPUP_ITEM (N_("Delete this _Occurrence"), GTK_SIGNAL_FUNC (e_day_view_on_delete_occurrence), MASK_EDITABLE | MASK_RECURRING | MASK_EDITING), - E_POPUP_ITEM (N_("Delete _All Occurrences"), GTK_SIGNAL_FUNC (e_day_view_on_delete_appointment), MASK_EDITABLE | MASK_RECURRING | MASK_EDITING), - - E_POPUP_TERMINATOR -}; - -static void -free_view_popup (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - - if (day_view->view_menu == NULL) - return; - - gnome_calendar_discard_view_popup (e_cal_view_get_calendar (E_CAL_VIEW (day_view)), - day_view->view_menu); - day_view->view_menu = NULL; -} - static void e_day_view_show_popup_menu (EDayView *day_view, GdkEvent *gdk_event, @@ -3509,68 +3348,12 @@ e_day_view_show_popup_menu (EDayView *day_view, gint event_num) { EDayViewEvent *event; - int have_selection; - gboolean being_edited; - EPopupMenu *context_menu; GtkMenu *popup; - int hide_mask = 0; - int disable_mask = 0; - - /* - * FIXME: - * This used to be set only if the event wasn't being edited - * in the event editor, but we can't check that at present. - * We could possibly set up another method of checking it. - */ - - being_edited = FALSE; - - have_selection = GTK_WIDGET_HAS_FOCUS (day_view) - && day_view->selection_start_day != -1; - - if (event_num == -1) { - day_view->view_menu = gnome_calendar_setup_view_popup ( - e_cal_view_get_calendar (E_CAL_VIEW (day_view))); - main_items[9].submenu = day_view->view_menu; - context_menu = main_items; - } else { - context_menu = child_items; - - if (day == E_DAY_VIEW_LONG_EVENT) - event = &g_array_index (day_view->long_events, - EDayViewEvent, event_num); - else - event = &g_array_index (day_view->events[day], - EDayViewEvent, event_num); - - if (cal_component_has_recurrences (event->comp)) - hide_mask |= MASK_SINGLE; - else - hide_mask |= MASK_RECURRING; - - if (cal_component_is_instance (event->comp)) - hide_mask |= MASK_INSTANCE; - - if (cal_component_has_organizer (event->comp)) { - disable_mask |= MASK_MEETING; - - if (!itip_organizer_is_user (event->comp, - e_cal_view_get_cal_client (E_CAL_VIEW (day_view)))) - disable_mask |= MASK_MEETING_ORGANIZER; - } - } - - if (cal_client_is_read_only (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)))) - disable_mask |= MASK_EDITABLE; - - if (being_edited) - disable_mask |= MASK_EDITING; day_view->popup_event_day = day; day_view->popup_event_num = event_num; - popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, day_view); - g_signal_connect (popup, "selection-done", G_CALLBACK (free_view_popup), day_view); + popup = e_cal_view_create_popup_menu (E_CAL_VIEW (day_view)); e_popup_menu (popup, gdk_event); } @@ -3676,331 +3459,6 @@ e_day_view_on_event_right_click (EDayView *day_view, day, event_num); } -static void -e_day_view_on_new_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - time_t dtstart, dtend; - struct icaltimetype itt; - - /* Edit a new event. If only one day is selected in the top canvas, - we set the time to the first 1/2-hour of the working day. */ - if (day_view->selection_in_top_canvas - && day_view->selection_start_day != -1 - && day_view->selection_start_day == day_view->selection_end_day) { - dtstart = day_view->day_starts[day_view->selection_start_day]; - itt = icaltime_from_timet_with_zone (dtstart, FALSE, - day_view->zone); - itt.hour = calendar_config_get_day_start_hour (); - itt.minute = calendar_config_get_day_start_minute (); - dtstart = icaltime_as_timet_with_zone (itt, day_view->zone); - - icaltime_adjust (&itt, 0, 0, 30, 0); - dtend = icaltime_as_timet_with_zone (itt, day_view->zone); - } else { - e_day_view_get_selected_time_range (day_view, &dtstart, - &dtend); - } - - gnome_calendar_new_appointment_for ( - e_cal_view_get_calendar (E_CAL_VIEW (day_view)), dtstart, dtend, FALSE, FALSE); -} - -static void -e_day_view_on_new_event (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - time_t dtstart, dtend; - - e_day_view_get_selected_time_range (day_view, &dtstart, &dtend); - gnome_calendar_new_appointment_for ( - e_cal_view_get_calendar (E_CAL_VIEW (day_view)), dtstart, dtend, TRUE, FALSE); -} - -static void -e_day_view_on_new_meeting (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - time_t dtstart, dtend; - struct icaltimetype itt; - - /* Edit a new event. If only one day is selected in the top canvas, - we set the time to the first 1/2-hour of the working day. */ - if (day_view->selection_in_top_canvas - && day_view->selection_start_day != -1 - && day_view->selection_start_day == day_view->selection_end_day) { - dtstart = day_view->day_starts[day_view->selection_start_day]; - itt = icaltime_from_timet_with_zone (dtstart, FALSE, - day_view->zone); - itt.hour = calendar_config_get_day_start_hour (); - itt.minute = calendar_config_get_day_start_minute (); - dtstart = icaltime_as_timet_with_zone (itt, day_view->zone); - - icaltime_adjust (&itt, 0, 0, 30, 0); - dtend = icaltime_as_timet_with_zone (itt, day_view->zone); - } else { - e_day_view_get_selected_time_range (day_view, &dtstart, - &dtend); - } - - gnome_calendar_new_appointment_for ( - e_cal_view_get_calendar (E_CAL_VIEW (day_view)), dtstart, dtend, FALSE, TRUE); -} - -static void -e_day_view_on_new_task (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - - gnome_calendar_new_task (e_cal_view_get_calendar (E_CAL_VIEW (day_view))); -} - -static void -e_day_view_on_goto_date (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - - goto_dialog (e_cal_view_get_calendar (E_CAL_VIEW (day_view))); -} - -static void -e_day_view_on_goto_today (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - - calendar_goto_today (e_cal_view_get_calendar (E_CAL_VIEW (day_view))); -} - -static void -e_day_view_on_edit_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - GnomeCalendar *calendar; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - calendar = e_cal_view_get_calendar (E_CAL_VIEW (day_view)); - if (calendar) - gnome_calendar_edit_object (calendar, event->comp, FALSE); - else - g_warning ("Calendar not set"); -} - -static void -e_day_view_on_save_as (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - char *filename; - char *ical_string; - FILE *file; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - filename = e_file_dialog_save (_("Save as...")); - if (filename == NULL) - return; - - ical_string = cal_client_get_component_as_string (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), - event->comp); - if (ical_string == NULL) { - g_warning ("Couldn't convert item to a string"); - return; - } - - file = fopen (filename, "w"); - if (file == NULL) { - g_warning ("Couldn't save item"); - return; - } - - fprintf (file, ical_string); - g_free (ical_string); - fclose (file); -} - -static void -e_day_view_on_print (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - time_t start; - GnomeCalendarViewType view_type; - PrintView print_view; - - day_view = E_DAY_VIEW (data); - - gnome_calendar_get_current_time_range (e_cal_view_get_calendar (E_CAL_VIEW (day_view)), &start, NULL); - view_type = gnome_calendar_get_view (e_cal_view_get_calendar (E_CAL_VIEW (day_view))); - - switch (view_type) { - case GNOME_CAL_DAY_VIEW: - print_view = PRINT_VIEW_DAY; - break; - - case GNOME_CAL_WORK_WEEK_VIEW: - print_view = PRINT_VIEW_WEEK; - break; - - default: - g_assert_not_reached (); - return; - } - - print_calendar (e_cal_view_get_calendar (E_CAL_VIEW (day_view)), FALSE, start, print_view); -} - -static void -e_day_view_on_print_event (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - print_comp (event->comp, e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), FALSE); -} - -static void -e_day_view_on_meeting (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - GnomeCalendar *calendar; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - calendar = e_cal_view_get_calendar (E_CAL_VIEW (day_view)); - if (calendar) - gnome_calendar_edit_object (calendar, event->comp, TRUE); - else - g_warning ("Calendar not set"); -} - -static void -e_day_view_on_forward (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, event->comp, - e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), NULL); -} - -static void -e_day_view_on_publish (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - icaltimezone *utc; - time_t start = time (NULL), end; - GList *comp_list; - - day_view = E_DAY_VIEW (data); - - utc = icaltimezone_get_utc_timezone (); - start = time_day_begin_with_zone (start, utc); - end = time_add_week_with_zone (start, 6, utc); - - comp_list = cal_client_get_free_busy (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), NULL, - start, end); - if (comp_list) { - GList *l; - - for (l = comp_list; l; l = l->next) { - CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, - e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), NULL); - - g_object_unref (comp); - } - - g_list_free (comp_list); - } -} - -static void -e_day_view_on_settings (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - - day_view = E_DAY_VIEW (data); - - control_util_show_settings (e_cal_view_get_calendar (E_CAL_VIEW (day_view))); -} - -static void -e_day_view_delete_event_internal (EDayView *day_view, EDayViewEvent *event) -{ - CalComponentVType vtype; - - vtype = cal_component_get_vtype (event->comp); - - if (delete_component_dialog (event->comp, FALSE, 1, vtype, - GTK_WIDGET (day_view))) { - const char *uid; - - if (itip_organizer_is_user (event->comp, e_cal_view_get_cal_client (E_CAL_VIEW (day_view))) - && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (day_view), - e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), - event->comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp, - e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), NULL); - - cal_component_get_uid (event->comp, &uid); - - delete_error_dialog (cal_client_remove_object (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), - uid), CAL_COMPONENT_EVENT); - } -} - -static void -e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - gboolean destroyed; - - day_view = E_DAY_VIEW (data); - - event = e_day_view_get_popup_menu_event (day_view); - if (event == NULL) - return; - - destroyed = FALSE; - g_object_weak_ref ((GObject *) event->comp, comp_destroy_cb, &destroyed); - - if (day_view->editing_event_day >= 0) - e_day_view_stop_editing_event (day_view); - - if (!destroyed) { - g_object_weak_unref ((GObject *) event->comp, comp_destroy_cb, &destroyed); - - e_day_view_delete_event_internal (day_view, event); - } -} - void e_day_view_delete_event (EDayView *day_view) { @@ -4020,7 +3478,7 @@ e_day_view_delete_event (EDayView *day_view) EDayViewEvent, day_view->editing_event_num); - e_day_view_delete_event_internal (day_view, event); + e_cal_view_delete_event_internal (day_view, event->comp); } static void @@ -4052,21 +3510,6 @@ e_day_view_delete_occurrence_internal (EDayView *day_view, EDayViewEvent *event) g_object_unref (comp); } -static void -e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) -{ - EDayView *day_view; - EDayViewEvent *event; - - 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) { @@ -4089,41 +3532,14 @@ e_day_view_delete_occurrence (EDayView *day_view) e_day_view_delete_occurrence_internal (day_view, event); } -static void -e_day_view_on_cut (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - - e_cal_view_cut_clipboard (E_CAL_VIEW (day_view)); -} - -static void -e_day_view_on_copy (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - - e_cal_view_copy_clipboard (E_CAL_VIEW (day_view)); -} - -static void -e_day_view_on_paste (GtkWidget *widget, gpointer data) -{ - EDayView *day_view = E_DAY_VIEW (data); - - e_cal_view_paste_clipboard (E_CAL_VIEW (day_view)); -} - -static void -e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) +void +e_day_view_unrecur_appointment (EDayView *day_view) { - EDayView *day_view; EDayViewEvent *event; CalComponent *comp, *new_comp; CalComponentDateTime date; struct icaltimetype itt; - day_view = E_DAY_VIEW (data); - event = e_day_view_get_popup_menu_event (day_view); if (event == NULL) return; diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 119a5f5fd0..c56d25a4ca 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -407,7 +407,6 @@ struct _EDayView /* The event for which a popup menu is being displayed, as above. */ gint popup_event_day; gint popup_event_num; - EPopupMenu *view_menu; /* The currently selected region. If selection_start_day is -1 there is no current selection. If start_row or end_row is -1 then the diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 3277eb9c60..81b6fe53ba 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -180,44 +180,6 @@ static gboolean e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event); static gboolean e_week_view_popup_menu (GtkWidget *widget); -static void e_week_view_on_new_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_new_event (GtkWidget *widget, - gpointer data); -static void e_week_view_on_new_meeting (GtkWidget *widget, - gpointer data); -static void e_week_view_on_new_task (GtkWidget *widget, - gpointer data); -static void e_week_view_on_goto_today (GtkWidget *widget, - gpointer data); -static void e_week_view_on_goto_date (GtkWidget *widget, - gpointer data); -static void e_week_view_on_edit_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_save_as (GtkWidget *widget, - gpointer data); -static void e_week_view_on_print (GtkWidget *widget, - gpointer data); -static void e_week_view_on_print_event (GtkWidget *widget, - gpointer data); -static void e_week_view_on_meeting (GtkWidget *widget, - gpointer data); -static void e_week_view_on_forward (GtkWidget *widget, - gpointer data); -static void e_week_view_on_publish (GtkWidget *widget, - gpointer data); -static void e_week_view_on_settings (GtkWidget *widget, - gpointer data); -static void e_week_view_on_delete_occurrence (GtkWidget *widget, - gpointer data); -static void e_week_view_on_delete_appointment (GtkWidget *widget, - gpointer data); -static void e_week_view_on_cut (GtkWidget *widget, gpointer data); -static void e_week_view_on_copy (GtkWidget *widget, gpointer data); -static void e_week_view_on_paste (GtkWidget *widget, gpointer data); -static void e_week_view_on_unrecur_appointment (GtkWidget *widget, - gpointer data); - static gboolean e_week_view_update_event_cb (EWeekView *week_view, gint event_num, gpointer data); @@ -1276,35 +1238,6 @@ e_week_view_draw_shadow (EWeekView *week_view) gdk_draw_line (window, light_gc, x1, y2, x2, y2); } -static void -e_week_view_new_appointment (EWeekView *week_view, gboolean meeting) -{ - time_t dtstart, dtend; - struct icaltimetype itt; - gboolean all_day = FALSE; - - /* Edit a new event. If only one day is selected we set the time to - the first 1/2-hour of the working day. */ - if (week_view->selection_start_day == week_view->selection_end_day) { - dtstart = week_view->day_starts[week_view->selection_start_day]; - itt = icaltime_from_timet_with_zone (dtstart, FALSE, - week_view->zone); - itt.hour = calendar_config_get_day_start_hour (); - itt.minute = calendar_config_get_day_start_minute (); - dtstart = icaltime_as_timet_with_zone (itt, week_view->zone); - - icaltime_adjust (&itt, 0, 0, 30, 0); - dtend = icaltime_as_timet_with_zone (itt, week_view->zone); - } else { - dtstart = week_view->day_starts[week_view->selection_start_day]; - dtend = week_view->day_starts[week_view->selection_end_day + 1]; - all_day = TRUE; - } - - gnome_calendar_new_appointment_for (e_cal_view_get_calendar (E_CAL_VIEW (week_view)), - dtstart, dtend, all_day, meeting); -} - /** * e_week_view_set_default_category: * @week_view: A week view. @@ -3453,176 +3386,17 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event) return handled; } -enum { - /* - * This is used to "flag" events that can not be editted - */ - MASK_EDITABLE = 1, - - /* - * To disable recurring actions to be displayed - */ - MASK_RECURRING = 2, - - /* - * To disable actions for non-recurring items to be displayed - */ - MASK_SINGLE = 4, - - /* - * This is used to when an event is currently being edited - * in another window and we want to disable the event - * from being edited twice - */ - MASK_EDITING = 8, - - /* - * This is used to when an event is already a meeting and - * we want to disable the schedule meeting command - */ - MASK_MEETING = 16, - - /* - * To disable cut and copy for meetings the user is not the - * organizer of - */ - MASK_MEETING_ORGANIZER = 32, - - /* - * To disable things not valid for instances - */ - MASK_INSTANCE = 64 -}; - -static EPopupMenu main_items [] = { - E_POPUP_ITEM (N_("New _Appointment..."), GTK_SIGNAL_FUNC (e_week_view_on_new_appointment), MASK_EDITABLE), - E_POPUP_ITEM (N_("New All Day _Event"), GTK_SIGNAL_FUNC (e_week_view_on_new_event), MASK_EDITABLE), - E_POPUP_ITEM (N_("New Meeting"), GTK_SIGNAL_FUNC (e_week_view_on_new_meeting), MASK_EDITABLE), - E_POPUP_ITEM (N_("New Task"), GTK_SIGNAL_FUNC (e_week_view_on_new_task), MASK_EDITABLE), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (e_week_view_on_print), 0), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (e_week_view_on_paste), MASK_EDITABLE), - - E_POPUP_SEPARATOR, - - E_POPUP_SUBMENU (N_("Current View"), NULL, 0), - - E_POPUP_ITEM (N_("Go to _Today"), GTK_SIGNAL_FUNC (e_week_view_on_goto_today), 0), - E_POPUP_ITEM (N_("_Go to Date..."), GTK_SIGNAL_FUNC (e_week_view_on_goto_date), 0), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Publish Free/Busy Information"), GTK_SIGNAL_FUNC (e_week_view_on_publish), 0), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Settings..."), GTK_SIGNAL_FUNC (e_week_view_on_settings), 0), - - E_POPUP_TERMINATOR -}; - -static EPopupMenu child_items [] = { - E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (e_week_view_on_edit_appointment), MASK_EDITING), - E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (e_week_view_on_save_as), MASK_EDITING), - E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (e_week_view_on_print_event), MASK_EDITING), - - /* Only show this separator if one of the above is shown. */ - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("C_ut"), GTK_SIGNAL_FUNC (e_week_view_on_cut), MASK_EDITING | MASK_EDITABLE | MASK_MEETING_ORGANIZER), - E_POPUP_ITEM (N_("_Copy"), GTK_SIGNAL_FUNC (e_week_view_on_copy), MASK_EDITING | MASK_MEETING_ORGANIZER), - E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (e_week_view_on_paste), MASK_EDITABLE), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Schedule Meeting..."), GTK_SIGNAL_FUNC (e_week_view_on_meeting), MASK_EDITABLE | MASK_EDITING | MASK_MEETING), - E_POPUP_ITEM (N_("_Forward as iCalendar..."), GTK_SIGNAL_FUNC (e_week_view_on_forward), MASK_EDITING), - - E_POPUP_SEPARATOR, - - E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (e_week_view_on_delete_appointment), MASK_EDITABLE | MASK_SINGLE | MASK_EDITING), - E_POPUP_ITEM (N_("Make this Occurrence _Movable"), GTK_SIGNAL_FUNC (e_week_view_on_unrecur_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE | MASK_INSTANCE), - E_POPUP_ITEM (N_("Delete this _Occurrence"), GTK_SIGNAL_FUNC (e_week_view_on_delete_occurrence), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE), - E_POPUP_ITEM (N_("Delete _All Occurrences"), GTK_SIGNAL_FUNC (e_week_view_on_delete_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE), - - E_POPUP_TERMINATOR -}; - -static void -free_view_popup (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - if (week_view->view_menu == NULL) - return; - - gnome_calendar_discard_view_popup (e_cal_view_get_calendar (E_CAL_VIEW (week_view)), - week_view->view_menu); - week_view->view_menu = NULL; -} - void e_week_view_show_popup_menu (EWeekView *week_view, GdkEventButton *bevent, gint event_num) { EWeekViewEvent *event; - int have_selection; - gboolean being_edited; - guint32 disable_mask = 0, hide_mask = 0; - EPopupMenu *context_menu; GtkMenu *popup; - have_selection = GTK_WIDGET_HAS_FOCUS (week_view) - && week_view->selection_start_day != -1; - - /* - * This used to be set only if the event wasn't being edited - * in the event editor, but we can't check that at present. - * We could possibly set up another method of checking it. - */ - being_edited = FALSE; - - if (event_num == -1) { - week_view->view_menu = gnome_calendar_setup_view_popup (e_cal_view_get_calendar (E_CAL_VIEW (week_view))); - main_items[9].submenu = week_view->view_menu; - context_menu = main_items; - } else { - context_menu = child_items; - event = &g_array_index (week_view->events, - EWeekViewEvent, event_num); - - if (cal_component_has_recurrences (event->comp)) - hide_mask |= MASK_SINGLE; - else - hide_mask |= MASK_RECURRING; - - if (cal_component_is_instance (event->comp)) - hide_mask |= MASK_INSTANCE; - - if (cal_component_has_organizer (event->comp)) { - disable_mask |= MASK_MEETING; - - if (!itip_organizer_is_user (event->comp, - e_cal_view_get_cal_client (E_CAL_VIEW (week_view)))) - disable_mask |= MASK_MEETING_ORGANIZER; - } - } - - if (cal_client_is_read_only (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)))) - disable_mask |= MASK_EDITABLE; - - if (being_edited) - disable_mask |= MASK_EDITING; week_view->popup_event_num = event_num; - popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, week_view); - g_signal_connect (popup, "selection-done", G_CALLBACK (free_view_popup), week_view); + popup = e_cal_view_create_popup_menu (E_CAL_VIEW (week_view)); e_popup_menu (popup, (GdkEvent *) bevent); } @@ -3635,305 +3409,20 @@ e_week_view_popup_menu (GtkWidget *widget) return TRUE; } -static void -e_week_view_on_new_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - e_week_view_new_appointment (week_view, FALSE); -} - - -static void -e_week_view_on_new_event (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - time_t dtstart, dtend; - - dtstart = week_view->day_starts[week_view->selection_start_day]; - dtend = week_view->day_starts[week_view->selection_end_day + 1]; - gnome_calendar_new_appointment_for ( - e_cal_view_get_calendar (E_CAL_VIEW (week_view)), dtstart, dtend, TRUE, FALSE); -} - -static void -e_week_view_on_new_meeting (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - e_week_view_new_appointment (week_view, TRUE); -} - -static void -e_week_view_on_new_task (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - gnome_calendar_new_task (e_cal_view_get_calendar (E_CAL_VIEW (week_view))); -} - -static void -e_week_view_on_goto_date (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - goto_dialog (e_cal_view_get_calendar (E_CAL_VIEW (week_view))); -} - -static void -e_week_view_on_goto_today (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - calendar_goto_today (e_cal_view_get_calendar (E_CAL_VIEW (week_view))); -} - -static void -e_week_view_on_edit_appointment (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - GnomeCalendar *calendar; - - 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); - - calendar = e_cal_view_get_calendar (E_CAL_VIEW (week_view)); - if (calendar) - gnome_calendar_edit_object (calendar, event->comp, FALSE); - else - g_warning ("Calendar not set"); -} - -static void -e_week_view_on_print (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - time_t start; - GnomeCalendarViewType view_type; - PrintView print_view; - - week_view = E_WEEK_VIEW (data); - - gnome_calendar_get_current_time_range (e_cal_view_get_calendar (E_CAL_VIEW (week_view)), &start, NULL); - view_type = gnome_calendar_get_view (e_cal_view_get_calendar (E_CAL_VIEW (week_view))); - - switch (view_type) { - case GNOME_CAL_WEEK_VIEW: - print_view = PRINT_VIEW_WEEK; - break; - - case GNOME_CAL_MONTH_VIEW: - print_view = PRINT_VIEW_MONTH; - break; - - default: - g_assert_not_reached (); - return; - } - - print_calendar (e_cal_view_get_calendar (E_CAL_VIEW (week_view)), FALSE, start, print_view); -} - -static void -e_week_view_on_save_as (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - char *filename; - char *ical_string; - FILE *file; - - 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); - - filename = e_file_dialog_save (_("Save as...")); - if (filename == NULL) - return; - - ical_string = cal_client_get_component_as_string (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), - event->comp); - if (ical_string == NULL) { - g_warning ("Couldn't convert item to a string"); - return; - } - - file = fopen (filename, "w"); - if (file == NULL) { - g_warning ("Couldn't save item"); - return; - } - - fprintf (file, ical_string); - g_free (ical_string); - fclose (file); -} - -static void -e_week_view_on_print_event (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - - 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); - - print_comp (event->comp, e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), FALSE); -} - -static void -e_week_view_on_meeting (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - GnomeCalendar *calendar; - - 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); - - calendar = e_cal_view_get_calendar (E_CAL_VIEW (week_view)); - if (calendar) - gnome_calendar_edit_object (calendar, event->comp, TRUE); - else - g_warning ("Calendar not set"); -} - -static void -e_week_view_on_forward (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - EWeekViewEvent *event; - - 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); - - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, event->comp, - e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), NULL); -} - -static void -e_week_view_on_publish (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - icaltimezone *utc; - time_t start = time (NULL), end; - GList *comp_list; - - week_view = E_WEEK_VIEW (data); - - utc = icaltimezone_get_utc_timezone (); - start = time_day_begin_with_zone (start, utc); - end = time_add_week_with_zone (start, 6, utc); - - comp_list = cal_client_get_free_busy (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), NULL, - start, end); - if (comp_list) { - GList *l; - - for (l = comp_list; l; l = l->next) { - CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, - e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), NULL); - - g_object_unref (comp); - } - - g_list_free (comp_list); - } -} - -static void -e_week_view_on_settings (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view; - - week_view = E_WEEK_VIEW (data); - - control_util_show_settings (e_cal_view_get_calendar (E_CAL_VIEW (week_view))); -} - -static void -e_week_view_delete_event_internal (EWeekView *week_view, gint event_num) -{ - CalComponentVType vtype; - EWeekViewEvent *event; - - event = &g_array_index (week_view->events, EWeekViewEvent, - event_num); - - vtype = cal_component_get_vtype (event->comp); - - if (delete_component_dialog (event->comp, FALSE, 1, vtype, - GTK_WIDGET (week_view))) { - const char *uid; - - if (itip_organizer_is_user (event->comp, - e_cal_view_get_cal_client (E_CAL_VIEW (week_view))) - && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (week_view), - e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), - event->comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp, - e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), NULL); - - cal_component_get_uid (event->comp, &uid); - - delete_error_dialog ( - cal_client_remove_object (e_cal_view_get_cal_client (E_CAL_VIEW (week_view)), - uid), CAL_COMPONENT_EVENT); - } -} - - -static void -e_week_view_on_delete_appointment (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_event_internal (week_view, - week_view->popup_event_num); -} - - void e_week_view_delete_event (EWeekView *week_view) { + EWeekViewEvent *event; + g_return_if_fail (E_IS_WEEK_VIEW (week_view)); if (week_view->editing_event_num == -1) return; - e_week_view_delete_event_internal (week_view, - week_view->editing_event_num); + event = &g_array_index (week_view->events, EWeekViewEvent, week_view->editing_event_num); + if (!event) + return; + e_cal_view_delete_event_internal (week_view, event->comp); } @@ -3970,19 +3459,6 @@ e_week_view_delete_occurrence_internal (EWeekView *week_view, gint event_num) 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) { @@ -3994,41 +3470,14 @@ e_week_view_delete_occurrence (EWeekView *week_view) 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 = E_WEEK_VIEW (data); - - e_cal_view_cut_clipboard (E_CAL_VIEW (week_view)); -} - -static void -e_week_view_on_copy (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - e_cal_view_copy_clipboard (E_CAL_VIEW (week_view)); -} - -static void -e_week_view_on_paste (GtkWidget *widget, gpointer data) -{ - EWeekView *week_view = E_WEEK_VIEW (data); - - e_cal_view_paste_clipboard (E_CAL_VIEW (week_view)); -} - -static void -e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) +void +e_week_view_unrecur_appointment (EWeekView *week_view) { - EWeekView *week_view; EWeekViewEvent *event; CalComponent *comp, *new_comp; CalComponentDateTime date; struct icaltimetype itt; - week_view = E_WEEK_VIEW (data); - if (week_view->popup_event_num == -1) return; diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 4b14dce298..ffe31ffea5 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -342,7 +342,6 @@ struct _EWeekView /* The event that the context menu is for. */ gint popup_event_num; - EPopupMenu *view_menu; /* The last mouse position when dragging, in the entire canvas. */ gint drag_event_x; diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 61b4980586..c16651f9cb 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -2953,6 +2953,30 @@ gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal) } } +void +gnome_calendar_unrecur_selection (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_unrecur_appointment (E_DAY_VIEW (view)); + else + e_week_view_unrecur_appointment (E_WEEK_VIEW (view)); + } +} + typedef struct { gboolean remove; GnomeCalendar *gcal; diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index e573a55fbb..02c77703d2 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -184,6 +184,7 @@ void gnome_calendar_paste_clipboard (GnomeCalendar *gcal); void gnome_calendar_delete_selection (GnomeCalendar *gcal); void gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal); +void gnome_calendar_unrecur_selection (GnomeCalendar *gcal); void gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than); |