diff options
Diffstat (limited to 'calendar/gui/e-calendar-view.c')
-rw-r--r-- | calendar/gui/e-calendar-view.c | 280 |
1 files changed, 50 insertions, 230 deletions
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index e02838e35d..9897354e5a 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -37,15 +37,13 @@ #include <e-util/e-icon-factory.h> #include <libecal/e-cal-time-util.h> #include <libecal/e-cal-component.h> +#include <shell/e-shell.h> #include "common/authentication.h" -#include "calendar-commands.h" -#include "calendar-component.h" #include "calendar-config.h" #include "comp-util.h" #include "e-cal-model-calendar.h" #include "e-calendar-view.h" -#include "e-comp-editor-registry.h" #include "itip-utils.h" #include "dialogs/delete-comp.h" #include "dialogs/delete-error.h" @@ -56,7 +54,7 @@ #include "dialogs/select-source-dialog.h" #include "print.h" #include "goto.h" -#include "ea-calendar.h" +/*#include "a11y/ea-calendar.h"*/ /* KILL-BONOBO */ #include "e-cal-popup.h" #include "misc.h" @@ -67,10 +65,6 @@ struct _ECalendarViewPrivate { /* The calendar model we are monitoring */ ECalModel *model; - /* Current activity (for the EActivityHandler, i.e. the status bar). */ - EActivityHandler *activity_handler; - guint activity_id; - /* The default category */ gchar *default_category; }; @@ -79,8 +73,6 @@ static void e_calendar_view_get_property (GObject *object, guint property_id, GV static void e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static void e_calendar_view_destroy (GtkObject *object); -extern ECompEditorRegistry *comp_editor_registry; - /* Property IDs */ enum props { PROP_0, @@ -100,7 +92,7 @@ enum { LAST_SIGNAL }; -static guint e_calendar_view_signals[LAST_SIGNAL] = { 0 }; +static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (ECalendarView, e_calendar_view, GTK_TYPE_TABLE) @@ -181,7 +173,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) G_PARAM_READABLE | G_PARAM_WRITABLE)); /* Create class' signals */ - e_calendar_view_signals[SELECTION_CHANGED] = + signals[SELECTION_CHANGED] = g_signal_new ("selection_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, @@ -189,7 +181,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - e_calendar_view_signals[SELECTED_TIME_CHANGED] = + signals[SELECTED_TIME_CHANGED] = g_signal_new ("selected_time_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, @@ -197,7 +189,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - e_calendar_view_signals[TIMEZONE_CHANGED] = + signals[TIMEZONE_CHANGED] = g_signal_new ("timezone_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, @@ -206,7 +198,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) e_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); - e_calendar_view_signals[EVENT_CHANGED] = + signals[EVENT_CHANGED] = g_signal_new ("event_changed", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, @@ -216,7 +208,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) G_TYPE_NONE, 1, G_TYPE_POINTER); - e_calendar_view_signals[EVENT_ADDED] = + signals[EVENT_ADDED] = g_signal_new ("event_added", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, @@ -226,7 +218,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) G_TYPE_NONE, 1, G_TYPE_POINTER); - e_calendar_view_signals[USER_CREATED] = + signals[USER_CREATED] = g_signal_new ("user_created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, @@ -235,7 +227,7 @@ e_calendar_view_class_init (ECalendarViewClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - e_calendar_view_signals[OPEN_EVENT] = + signals[OPEN_EVENT] = g_signal_new ("open_event", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, @@ -254,14 +246,17 @@ e_calendar_view_class_init (ECalendarViewClass *klass) GDK_CONTROL_MASK, "open_event", 0); +#if 0 /* KILL-BONOBO */ /* init the accessibility support for e_day_view */ e_cal_view_a11y_init (); +#endif } void e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart, icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas) { +#if 0 /* KILL-BONOBO */ ECalComponent *comp; struct icaltimetype itime, old_dtstart, old_dtend; time_t tt_start, tt_end, new_dtstart = 0; @@ -379,6 +374,7 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart } g_object_unref (comp); +#endif } static void @@ -474,7 +470,7 @@ e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone) return; e_cal_model_set_timezone (cal_view->priv->model, zone); - g_signal_emit (G_OBJECT (cal_view), e_calendar_view_signals[TIMEZONE_CHANGED], 0, + g_signal_emit (G_OBJECT (cal_view), signals[TIMEZONE_CHANGED], 0, old_zone, zone); } @@ -535,55 +531,6 @@ e_calendar_view_set_use_24_hour_format (ECalendarView *cal_view, gboolean use_24 e_cal_model_set_use_24_hour_format (cal_view->priv->model, use_24_hour); } -void -e_calendar_view_set_activity_handler (ECalendarView *cal_view, EActivityHandler *activity_handler) -{ - ECalendarViewPrivate *priv; - - g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - - priv = cal_view->priv; - - priv->activity_handler = activity_handler; -} - -void -e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message, gint percent) -{ - ECalendarViewPrivate *priv; - - g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - - priv = cal_view->priv; - - if (!priv->activity_handler) - return; - - if (!message || !*message) { - if (priv->activity_id != 0) { - e_activity_handler_operation_finished (priv->activity_handler, priv->activity_id); - priv->activity_id = 0; - } - } else if (priv->activity_id == 0) { - gchar *client_id = g_strdup_printf ("%p", (gpointer) cal_view); - - priv->activity_id = e_activity_handler_operation_started ( - priv->activity_handler, client_id, message, TRUE); - - g_free (client_id); - } else { - double progress; - - if (percent < 0) - progress = -1.0; - else { - progress = ((double) percent / 100); - } - - e_activity_handler_operation_progressing (priv->activity_handler, priv->activity_id, message, progress); - } -} - GList * e_calendar_view_get_selected_events (ECalendarView *cal_view) { @@ -654,7 +601,9 @@ e_calendar_view_cut_clipboard (ECalendarView *cal_view) if (!selected) return; +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, _("Deleting selected objects"), -1); +#endif e_calendar_view_copy_clipboard (cal_view); for (l = selected; l != NULL; l = l->next) { @@ -699,7 +648,9 @@ e_calendar_view_cut_clipboard (ECalendarView *cal_view) g_object_unref (comp); } +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, NULL, -1); +#endif g_list_free (selected); } @@ -868,7 +819,9 @@ clipboard_get_calendar_data (ECalendarView *cal_view, const gchar *text) if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPONENT) return; +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, _("Updating objects"), -1); +#endif e_calendar_view_get_selected_time_range (cal_view, &selected_time_start, &selected_time_end); if ((selected_time_end - selected_time_start) == 60 * 60 * 24) @@ -916,7 +869,9 @@ clipboard_get_calendar_data (ECalendarView *cal_view, const gchar *text) e_calendar_view_add_event (cal_view, client, selected_time_start, default_zone, icalcomp, in_top_canvas); } +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, NULL, -1); +#endif } static void @@ -1239,53 +1194,15 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) } static void -on_new_appointment (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = data; - - e_calendar_view_new_appointment (cal_view); -} - -static void -on_new_event (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = data; - - e_calendar_view_new_appointment_full (cal_view, TRUE, FALSE, FALSE); -} - -static void -on_new_meeting (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = data; - - e_calendar_view_new_appointment_full (cal_view, FALSE, TRUE, FALSE); -} - -static void on_new_task (EPopup *ep, EPopupItem *pitem, gpointer data) { +#if 0 /* KILL-BONOBO */ ECalendarView *cal_view = data; time_t dtstart, dtend; e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); gnome_calendar_new_task (cal_view->priv->calendar, &dtstart, &dtend); -} - -static void -on_goto_date (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = data; - - goto_dialog (cal_view->priv->calendar); -} - -static void -on_goto_today (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = data; - - calendar_goto_today (cal_view->priv->calendar); +#endif } static void @@ -1310,9 +1227,11 @@ on_edit_appointment (EPopup *ep, EPopupItem *pitem, gpointer data) static void on_print (EPopup *ep, EPopupItem *pitem, gpointer data) { +#if 0 /* KILL-BONOBO */ ECalendarView *cal_view = data; calendar_command_print (cal_view->priv->calendar, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); +#endif } static void @@ -1346,28 +1265,6 @@ on_save_as (EPopup *ep, EPopupItem *pitem, gpointer data) } static void -on_print_event (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = data; - GList *selected; - ECalendarViewEvent *event; - ECalComponent *comp; - - selected = e_calendar_view_get_selected_events (cal_view); - if (!selected) - return; - - event = (ECalendarViewEvent *) selected->data; - - comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - print_comp (comp, event->comp_data->client, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); - - g_object_unref (comp); - g_list_free (selected); -} - -static void transfer_item_to (ECalendarViewEvent *event, ECal *dest_client, gboolean remove_item) { const gchar *uid; @@ -1471,16 +1368,20 @@ transfer_selected_items (ECalendarView *cal_view, gboolean remove_item) return; } +#if 0 /* KILL-BONOBO */ /* process all selected events */ if (remove_item) e_calendar_view_set_status_message (cal_view, _("Moving items"), -1); else e_calendar_view_set_status_message (cal_view, _("Copying items"), -1); +#endif for (l = selected; l != NULL; l = l->next) transfer_item_to ((ECalendarViewEvent *) l->data, dest_client, remove_item); +#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (cal_view, NULL, -1); +#endif /* free memory */ g_object_unref (destination_source); @@ -1781,9 +1682,6 @@ on_paste (EPopup *ep, EPopupItem *pitem, gpointer data) } static EPopupItem ecv_main_items [] = { - { E_POPUP_ITEM, (gchar *) "00.new", (gchar *) N_("New _Appointment..."), on_new_appointment, NULL, (gchar *) "appointment-new", 0, 0 }, - { E_POPUP_ITEM, (gchar *) "10.newallday", (gchar *) N_("New All Day _Event"), on_new_event, NULL, (gchar *) "stock_new-24h-appointment", 0, 0}, - { E_POPUP_ITEM, (gchar *) "20.meeting", (gchar *) N_("New _Meeting"), on_new_meeting, NULL, (gchar *) "stock_new-meeting", 0, 0}, { E_POPUP_ITEM, (gchar *) "30.task", (gchar *) N_("New _Task"), on_new_task, NULL, (gchar *) "stock_task", 0, 0}, { E_POPUP_BAR, (gchar *) "40."}, @@ -1795,15 +1693,11 @@ static EPopupItem ecv_main_items [] = { { E_POPUP_BAR, (gchar *) "60." }, /* FIXME: hook in this somehow */ { E_POPUP_SUBMENU, (gchar *) "60.view", (gchar *) N_("_Current View") }, - - { E_POPUP_ITEM, (gchar *) "61.today", (gchar *) N_("Select T_oday"), on_goto_today, NULL, (gchar *) "go-today" }, - { E_POPUP_ITEM, (gchar *) "62.todate", (gchar *) N_("_Select Date..."), on_goto_date, NULL, (gchar *) GTK_STOCK_JUMP_TO }, }; static EPopupItem ecv_child_items [] = { { E_POPUP_ITEM, (gchar *) "00.open", (gchar *) N_("_Open"), on_edit_appointment, NULL, (gchar *) GTK_STOCK_OPEN, 0, E_CAL_POPUP_SELECT_NOTEDITING }, { E_POPUP_ITEM, (gchar *) "10.saveas", (gchar *) N_("_Save As..."), on_save_as, NULL, (gchar *) GTK_STOCK_SAVE_AS, 0, E_CAL_POPUP_SELECT_NOTEDITING }, - { E_POPUP_ITEM, (gchar *) "20.print", (gchar *) N_("Pri_nt..."), on_print_event, NULL, (gchar *) GTK_STOCK_PRINT, 0, E_CAL_POPUP_SELECT_NOTEDITING }, { E_POPUP_BAR, (gchar *) "30." }, @@ -1829,69 +1723,6 @@ static EPopupItem ecv_child_items [] = { { E_POPUP_ITEM, (gchar *) "54.delete", (gchar *) N_("Delete _All Occurrences"), on_delete_appointment, NULL, (gchar *) GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_RECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE }, }; -static void -ecv_popup_free (EPopup *ep, GSList *list, gpointer data) -{ - g_slist_free(list); -} - -GtkMenu * -e_calendar_view_create_popup_menu (ECalendarView *cal_view) -{ - ECalPopup *ep; - GSList *menus = NULL; - GList *selected, *l; - gint i; - ECalPopupTargetSelect *t; - ECalModel *model; - GPtrArray *events; - - g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); - - /* We could do this using a factory on the ECalPopup class, - * that way we would get called implicitly whenever a popup - * menu was created rather than everyone having to call us. - * We could also have a different menu id for each view */ - - /** @HookPoint-ECalPopup: Calendar Main View Context Menu - * @Id: org.gnome.evolution.calendar.view.popup - * @Class: org.gnome.evolution.calendar.popup:1.0 - * @Target: ECalPopupTargetSelect - * - * The context menu on the main calendar view. This menu - * applies to all view types. - */ - ep = e_cal_popup_new("org.gnome.evolution.calendar.view.popup"); - - model = e_calendar_view_get_model(cal_view); - events = g_ptr_array_new(); - selected = e_calendar_view_get_selected_events(cal_view); - for (l=selected;l;l=g_list_next(l)) { - ECalendarViewEvent *event = l->data; - - if (event) - g_ptr_array_add(events, e_cal_model_copy_component_data(event->comp_data)); - } - g_list_free(selected); - - t = e_cal_popup_target_new_select(ep, model, events); - t->target.widget = (GtkWidget *)cal_view; - - if (t->events->len == 0) { - for (i=0;i<sizeof(ecv_main_items)/sizeof(ecv_main_items[0]);i++) - menus = g_slist_prepend(menus, &ecv_main_items[i]); - - gnome_calendar_view_popup_factory(cal_view->priv->calendar, (EPopup *)ep, "60.view"); - } else { - for (i=0;i<sizeof(ecv_child_items)/sizeof(ecv_child_items[0]);i++) - menus = g_slist_prepend(menus, &ecv_child_items[i]); - } - - e_popup_add_items((EPopup *)ep, menus, NULL, ecv_popup_free, cal_view); - - return e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0); -} - void e_calendar_view_open_event (ECalendarView *cal_view) { @@ -2090,7 +1921,7 @@ e_calendar_view_new_appointment (ECalendarView *cal_view) static void object_created_cb (CompEditor *ce, ECalendarView *cal_view) { - gnome_calendar_emit_user_created_signal (cal_view, e_calendar_view_get_calendar (cal_view), comp_editor_get_client (ce)); + e_calendar_view_emit_user_created (cal_view); } CompEditor * @@ -2099,12 +1930,16 @@ e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, ic CompEditor *ce; const gchar *uid; ECalComponent *comp; + EShell *shell; + + /* FIXME ECalendarView should own an EShell pointer. */ + shell = e_shell_get_default (); uid = icalcomponent_get_uid (icalcomp); - ce = e_comp_editor_registry_find (comp_editor_registry, uid); + ce = comp_editor_find_instance (uid); if (!ce) { - ce = event_editor_new (client, flags); + ce = event_editor_new (client, shell, flags); g_signal_connect (ce, "object_created", G_CALLBACK (object_created_cb), cal_view); @@ -2114,8 +1949,6 @@ e_calendar_view_open_event_with_flags (ECalendarView *cal_view, ECal *client, ic if (flags & COMP_EDITOR_MEETING) event_editor_show_meeting (EVENT_EDITOR (ce)); - e_comp_editor_registry_add (comp_editor_registry, ce, FALSE); - g_object_unref (comp); } @@ -2599,6 +2432,14 @@ e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp, } void +e_calendar_view_emit_user_created (ECalendarView *cal_view) +{ + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); + + g_signal_emit (cal_view, signals[USER_CREATED], 0); +} + +void draw_curved_rectangle (cairo_t *cr, double x0, double y0, double rect_width, double rect_height, double radius) @@ -2651,31 +2492,10 @@ draw_curved_rectangle (cairo_t *cr, double x0, double y0, static void error_response(GtkWidget *widget, gint response, gpointer data) { - gtk_widget_destroy (widget); -} - -void -e_calendar_utils_show_error_silent (GtkWidget *widget) -{ - EActivityHandler *handler = calendar_component_peek_activity_handler (calendar_component_peek ()); - - if (!g_object_get_data ((GObject *) widget, "response-handled")) { - g_signal_connect(widget, "response", G_CALLBACK(error_response), NULL); - } - - e_activity_handler_make_error (handler, "calendar", E_LOG_ERROR, widget); -} - -void -e_calendar_utils_show_info_silent (GtkWidget *widget) -{ - EActivityHandler *handler = calendar_component_peek_activity_handler (calendar_component_peek ()); - - if (!g_object_get_data ((GObject *) widget, "response-handled")) { - g_signal_connect(widget, "response", G_CALLBACK(error_response), NULL); - } - - e_activity_handler_make_error (handler, "calendar", E_LOG_WARNINGS, widget); + if (response == GTK_RESPONSE_DELETE_EVENT) + gtk_widget_destroy(widget); + else if (response == GTK_RESPONSE_OK) + gtk_widget_destroy(widget); } /* returns either light or dark yellow, based on the base_background, |