aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-day-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/e-day-view.c')
-rw-r--r--calendar/gui/e-day-view.c592
1 files changed, 4 insertions, 588 deletions
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;