From 79aa45cfed7e87150de85869795ef0dd3be06db0 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 13 Oct 2008 17:57:46 +0000 Subject: Progress update: - Calendar is kind of a mess at the moment. Doesn't compile. - Roughed in the Mail module, including all the actions. That _does_ compile. Runs, even. svn path=/branches/kill-bonobo/; revision=36611 --- addressbook/gui/component/e-book-shell-module.c | 7 +- .../gui/component/e-book-shell-view-actions.c | 14 +- calendar/gui/calendar-commands.c | 236 -- calendar/gui/calendar-component.c | 271 +- calendar/gui/control-factory.c | 80 - calendar/gui/control-factory.h | 31 - calendar/gui/e-cal-list-view.c | 2 + calendar/gui/e-calendar-view.c | 63 - calendar/gui/e-day-view.c | 2 + calendar/gui/e-week-view.c | 2 + calendar/gui/gnome-cal.c | 652 +---- calendar/gui/gnome-cal.h | 14 +- calendar/gui/memos-component.c | 2 - calendar/gui/tasks-component.c | 202 -- calendar/modules/e-cal-shell-content.c | 601 +++- calendar/modules/e-cal-shell-content.h | 18 + calendar/modules/e-cal-shell-module.c | 17 +- calendar/modules/e-cal-shell-sidebar.c | 131 +- calendar/modules/e-cal-shell-sidebar.h | 5 + calendar/modules/e-cal-shell-view-actions.c | 604 +++- calendar/modules/e-cal-shell-view-actions.h | 66 + calendar/modules/e-cal-shell-view-memopad.c | 472 +++ calendar/modules/e-cal-shell-view-private.c | 186 +- calendar/modules/e-cal-shell-view-private.h | 59 +- calendar/modules/e-cal-shell-view-taskpad.c | 600 ++++ calendar/modules/e-cal-shell-view.c | 86 +- calendar/modules/e-memo-shell-module.c | 7 +- calendar/modules/e-memo-shell-sidebar.c | 3 + calendar/modules/e-memo-shell-view-actions.c | 19 +- calendar/modules/e-memo-shell-view-private.c | 2 - calendar/modules/e-memo-shell-view.c | 4 +- calendar/modules/e-task-shell-module.c | 7 +- calendar/modules/e-task-shell-sidebar.c | 3 + calendar/modules/e-task-shell-view-actions.c | 59 +- calendar/modules/e-task-shell-view-private.c | 2 - calendar/modules/e-task-shell-view.c | 3 +- mail/Makefile.am | 349 ++- mail/e-mail-shell-content.c | 347 +++ mail/e-mail-shell-content.h | 77 + mail/e-mail-shell-module-migrate.c | 3088 ++++++++++++++++++++ mail/e-mail-shell-module-migrate.h | 38 + mail/e-mail-shell-module.c | 175 ++ mail/e-mail-shell-module.h | 41 + mail/e-mail-shell-sidebar.c | 139 + mail/e-mail-shell-sidebar.h | 67 + mail/e-mail-shell-view-actions.c | 1713 +++++++++++ mail/e-mail-shell-view-actions.h | 255 ++ mail/e-mail-shell-view-private.c | 126 + mail/e-mail-shell-view-private.h | 126 + mail/e-mail-shell-view.c | 135 + mail/e-mail-shell-view.h | 71 + mail/em-migrate.c | 3055 ------------------- mail/em-migrate.h | 39 - shell/e-shell-module.c | 24 +- shell/e-shell-module.h | 5 +- shell/e-shell-window-actions.c | 38 +- shell/e-shell-window-private.c | 18 +- shell/e-shell-window-private.h | 2 + shell/e-shell-window.c | 7 + shell/shell.error.xml | 5 +- shell/test/e-test-shell-module.c | 5 +- ui/Makefile.am | 1 + ui/evolution-calendars.ui | 70 + ui/evolution-mail.ui | 203 ++ ui/evolution-shell.ui | 3 + widgets/misc/e-calendar.h | 21 +- 66 files changed, 9944 insertions(+), 4831 deletions(-) delete mode 100644 calendar/gui/control-factory.c delete mode 100644 calendar/gui/control-factory.h create mode 100644 calendar/modules/e-cal-shell-view-memopad.c create mode 100644 calendar/modules/e-cal-shell-view-taskpad.c create mode 100644 mail/e-mail-shell-content.c create mode 100644 mail/e-mail-shell-content.h create mode 100644 mail/e-mail-shell-module-migrate.c create mode 100644 mail/e-mail-shell-module-migrate.h create mode 100644 mail/e-mail-shell-module.c create mode 100644 mail/e-mail-shell-module.h create mode 100644 mail/e-mail-shell-sidebar.c create mode 100644 mail/e-mail-shell-sidebar.h create mode 100644 mail/e-mail-shell-view-actions.c create mode 100644 mail/e-mail-shell-view-actions.h create mode 100644 mail/e-mail-shell-view-private.c create mode 100644 mail/e-mail-shell-view-private.h create mode 100644 mail/e-mail-shell-view.c create mode 100644 mail/e-mail-shell-view.h delete mode 100644 mail/em-migrate.c delete mode 100644 mail/em-migrate.h create mode 100644 ui/evolution-mail.ui diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c index 276e6f0a24..fbe660b7b6 100644 --- a/addressbook/gui/component/e-book-shell-module.c +++ b/addressbook/gui/component/e-book-shell-module.c @@ -424,10 +424,9 @@ e_shell_module_init (GTypeModule *type_module) shell_module = E_SHELL_MODULE (type_module); shell = e_shell_module_get_shell (shell_module); - /* Register the GType for EBookShellView. */ - e_book_shell_view_get_type (type_module); - - e_shell_module_set_info (shell_module, &module_info); + e_shell_module_set_info ( + shell_module, &module_info, + e_book_shell_view_get_type (type_module)); book_shell_module_init_importers (); book_shell_module_ensure_sources (shell_module); diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c index 8ade5e6805..6085bc5d82 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.c +++ b/addressbook/gui/component/e-book-shell-view-actions.c @@ -449,6 +449,9 @@ action_gal_save_custom_view_cb (GtkAction *action, EAddressbookView *address_view; GalViewInstance *view_instance; + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with saving the custom view. */ shell_view = E_SHELL_VIEW (book_shell_view); if (!e_shell_view_is_active (shell_view)) return; @@ -463,6 +466,15 @@ static void action_search_execute_cb (GtkAction *action, EBookShellView *book_shell_view) { + EShellView *shell_view; + + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with executing the search. */ + shell_view = E_SHELL_VIEW (book_shell_view); + if (!e_shell_view_is_active (shell_view)) + return; + e_book_shell_view_execute_search (book_shell_view); } @@ -471,7 +483,7 @@ action_search_filter_cb (GtkRadioAction *action, GtkRadioAction *current, EBookShellView *book_shell_view) { - action_search_execute_cb (GTK_ACTION (current), book_shell_view); + e_book_shell_view_execute_search (book_shell_view); } static GtkActionEntry contact_entries[] = { diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 3b619134be..c2a46fb4e5 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -68,53 +68,6 @@ typedef struct { guint taskpad_focused : 1; } FocusData; -static void -file_open_event_cb (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - e_calendar_view_open_event (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal))); -} - - -/* Prints the calendar at its current view and time range */ -void -calendar_command_print (GnomeCalendar *gcal, GtkPrintOperationAction action) -{ - if (gnome_calendar_get_view (gcal) == GNOME_CAL_LIST_VIEW) { - ECalListView *list_view; - ETable *table; - - list_view = E_CAL_LIST_VIEW (gnome_calendar_get_current_view_widget (gcal)); - table = e_table_scrolled_get_table (list_view->table_scrolled); - print_table (table, _("Print"), _("Calendar"), action); - } else { - time_t start; - - gnome_calendar_get_current_time_range (gcal, &start, NULL); - print_calendar (gcal, action, start); - } -} - -/* File/Print callback */ -static void -file_print_cb (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (data); - - calendar_command_print (gcal, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); -} - -static void -file_print_preview_cb (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal = GNOME_CALENDAR (data); - - calendar_command_print (gcal, GTK_PRINT_OPERATION_ACTION_PREVIEW); -} - /* Sets a clock cursor for the specified calendar window */ static void set_clock_cursor (GnomeCalendar *gcal) @@ -135,58 +88,6 @@ set_normal_cursor (GnomeCalendar *gcal) gdk_flush (); } -static void -previous_clicked (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - set_clock_cursor (gcal); - gnome_calendar_previous (gcal); - set_normal_cursor (gcal); -} - -static void -next_clicked (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - set_clock_cursor (gcal); - gnome_calendar_next (gcal); - set_normal_cursor (gcal); -} - -void -calendar_goto_today (GnomeCalendar *gcal) -{ - set_clock_cursor (gcal); - gnome_calendar_goto_today (gcal); - set_normal_cursor (gcal); -} - -static void -today_clicked (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - calendar_goto_today (gcal); -} - -static void -goto_clicked (BonoboUIComponent *uic, gpointer data, const char *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - goto_dialog (gcal); -} - static void show_day_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path) { @@ -239,65 +140,6 @@ show_list_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path) } -static void -cut_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - set_clock_cursor (gcal); - gnome_calendar_cut_clipboard (gcal); - set_normal_cursor (gcal); -} - -static void -copy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - set_clock_cursor (gcal); - gnome_calendar_copy_clipboard (gcal); - set_normal_cursor (gcal); -} - -static void -paste_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - set_clock_cursor (gcal); - gnome_calendar_paste_clipboard (gcal); - set_normal_cursor (gcal); -} - -static void -delete_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - set_clock_cursor (gcal); - gnome_calendar_delete_selection (gcal); - set_normal_cursor (gcal); -} - -static void -delete_occurrence_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - set_clock_cursor (gcal); - gnome_calendar_delete_selected_occurrence (gcal); - set_normal_cursor (gcal); -} - static void purge_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) { @@ -370,69 +212,6 @@ sensitize_items(BonoboUIComponent *uic, struct _sensitize_item *items, guint32 m } } -static struct _sensitize_item calendar_sensitize_table[] = { - { "EventOpen", E_CAL_MENU_SELECT_ONE }, - { "Cut", E_CAL_MENU_SELECT_EDITABLE }, - { "Copy", E_CAL_MENU_SELECT_ANY }, - { "Paste", E_CAL_MENU_SELECT_EDITABLE }, - { "Delete", E_CAL_MENU_SELECT_EDITABLE|E_CAL_MENU_SELECT_NONRECURRING }, - { "DeleteOccurrence", E_CAL_MENU_SELECT_EDITABLE|E_CAL_MENU_SELECT_RECURRING }, - { "DeleteAllOccurrences", E_CAL_MENU_SELECT_EDITABLE|E_CAL_MENU_SELECT_RECURRING }, - { NULL } -}; - -/* Sensitizes the UI Component menu/toolbar calendar commands based on the - * number of selected events. (This will always be 0 or 1 currently.) If enable - * is FALSE, all will be disabled. Otherwise, the currently-selected number of - * events will be used. - */ -void -calendar_control_sensitize_calendar_commands (BonoboControl *control, GnomeCalendar *gcal, gboolean enable) -{ - BonoboUIComponent *uic; - GtkWidget *view; - ECalMenu *menu; - ECalModel *model; - GPtrArray *events; - GList *selected, *l; - ECalMenuTargetSelect *t; - - uic = bonobo_control_get_ui_component (control); - g_return_if_fail (uic != NULL); - - if (bonobo_ui_component_get_container (uic) == CORBA_OBJECT_NIL) - return; - - view = gnome_calendar_get_current_view_widget (gcal); - - menu = gnome_calendar_get_calendar_menu (gcal); - model = e_calendar_view_get_model((ECalendarView *)view); - events = g_ptr_array_new(); - selected = e_calendar_view_get_selected_events((ECalendarView *)view); - for (l=selected;l;l=g_list_next(l)) { - ECalendarViewEvent *event = l->data; - if (event && event->comp_data) - g_ptr_array_add (events, e_cal_model_copy_component_data(event->comp_data)); - } - g_list_free(selected); - - t = e_cal_menu_target_new_select(menu, model, events); - if (!enable) - t->target.mask = ~0; - - sensitize_items(uic, calendar_sensitize_table, t->target.mask); -#if 0 - /* retrieve read-onlyness of the default client */ - e_cal = e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal)); - if (e_cal) - e_cal_is_read_only (e_cal, &default_read_only, NULL); - else - default_read_only = TRUE; -#endif - - e_menu_update_target((EMenu *)menu, (EMenuTarget *)t); -} - static struct _sensitize_item taskpad_sensitize_table[] = { { "Cut", E_CAL_MENU_SELECT_EDITABLE }, { "Copy", E_CAL_MENU_SELECT_ANY }, @@ -555,21 +334,6 @@ gcal_taskpad_focus_change_cb (GnomeCalendar *gcal, gboolean in, gpointer data) static BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("EventOpen", file_open_event_cb), - BONOBO_UI_VERB ("CalendarPrint", file_print_cb), - BONOBO_UI_VERB ("CalendarPrintPreview", file_print_preview_cb), - - BONOBO_UI_VERB ("Cut", cut_cmd), - BONOBO_UI_VERB ("Copy", copy_cmd), - BONOBO_UI_VERB ("Paste", paste_cmd), - BONOBO_UI_VERB ("Delete", delete_cmd), - BONOBO_UI_VERB ("DeleteOccurrence", delete_occurrence_cmd), - BONOBO_UI_VERB ("DeleteAllOccurrences", delete_cmd), - - BONOBO_UI_VERB ("CalendarPrev", previous_clicked), - BONOBO_UI_VERB ("CalendarToday", today_clicked), - BONOBO_UI_VERB ("CalendarNext", next_clicked), - BONOBO_UI_VERB ("CalendarGoto", goto_clicked), BONOBO_UI_VERB ("ShowDayView", show_day_view_clicked), BONOBO_UI_VERB ("ShowWorkWeekView", show_work_week_view_clicked), diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index f2896a5990..d22d43e5ff 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -78,12 +78,9 @@ typedef struct GnomeCalendar *calendar; - EInfoLabel *info_label; GtkWidget *source_selector; BonoboControl *view_control; - BonoboControl *sidebar_control; - BonoboControl *statusbar_control; GList *notifications; @@ -154,40 +151,6 @@ is_in_uids (GSList *uids, ESource *source) return FALSE; } -static void -update_selection (CalendarComponentView *component_view) -{ - GSList *selection, *uids_selected, *l; - - /* Get the selection in gconf */ - uids_selected = calendar_config_get_calendars_selected (); - - /* Remove any that aren't there any more */ - selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - - for (l = selection; l; l = l->next) { - ESource *source = l->data; - - if (!is_in_uids (uids_selected, source)) - e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - } - - e_source_selector_free_selection (selection); - - /* Make sure the whole selection is there */ - for (l = uids_selected; l; l = l->next) { - char *uid = l->data; - ESource *source; - - source = e_source_list_peek_source_by_uid (component_view->source_list, uid); - if (source) - e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - - g_free (uid); - } - g_slist_free (uids_selected); -} - static void update_task_memo_selection (CalendarComponentView *component_view, ECalSourceType type) { @@ -236,28 +199,6 @@ update_task_memo_selection (CalendarComponentView *component_view, ECalSourceTyp component_view->memo_source_selection = uids_selected; } -static void -update_primary_selection (CalendarComponentView *component_view) -{ - ESource *source = NULL; - char *uid; - - uid = calendar_config_get_primary_calendar (); - if (uid) { - source = e_source_list_peek_source_by_uid (component_view->source_list, uid); - g_free (uid); - } - - if (source) { - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source); - } else { - /* Try to create a default if there isn't one */ - source = e_source_list_peek_source_any (component_view->source_list); - if (source) - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source); - } -} - static void update_primary_task_memo_selection (CalendarComponentView *component_view, ECalSourceType type) { @@ -283,161 +224,6 @@ update_primary_task_memo_selection (CalendarComponentView *component_view, ECalS gnome_calendar_set_default_source (component_view->calendar, type, source); } -/* Callbacks. */ -static void -copy_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - CalendarComponentView *component_view = data; - ESource *selected_source; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - if (!selected_source) - return; - - copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (ep->target->widget)), selected_source, E_CAL_SOURCE_TYPE_EVENT); -} - -static void -delete_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - CalendarComponentView *component_view = data; - ESource *selected_source; - ECal *cal; - char *uri; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - if (!selected_source) - return; - - if (e_error_run((GtkWindow *)gtk_widget_get_toplevel(ep->target->widget), - "calendar:prompt-delete-calendar", e_source_peek_name(selected_source), NULL) != GTK_RESPONSE_YES) - return; - - /* first, ask the backend to remove the calendar */ - uri = e_source_get_uri (selected_source); - cal = e_cal_model_get_client_for_uri (gnome_calendar_get_calendar_model (component_view->calendar), uri); - if (!cal) - cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_EVENT); - g_free (uri); - if (cal) { - if (e_cal_remove (cal, NULL)) { - if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector), - selected_source)) { - gnome_calendar_remove_source (component_view->calendar, E_CAL_SOURCE_TYPE_EVENT, selected_source); - e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), - selected_source); - } - - e_source_group_remove_source (e_source_peek_group (selected_source), selected_source); - e_source_list_sync (component_view->source_list, NULL); - } - } -} - -static void -new_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - calendar_setup_edit_calendar (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), NULL, pitem->user_data); -} - -static void -edit_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - CalendarComponentView *component_view = data; - ESource *selected_source; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - if (!selected_source) - return; - - calendar_setup_edit_calendar (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source, NULL); -} - -static EPopupItem ecc_source_popups[] = { - { E_POPUP_ITEM, "10.new", N_("_New Calendar"), new_calendar_cb, NULL, "x-office-calendar", 0, 0 }, - { E_POPUP_ITEM, "15.copy", N_("_Copy..."), copy_calendar_cb, NULL, "edit-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY }, - - { E_POPUP_BAR, "20.bar" }, - { E_POPUP_ITEM, "20.delete", N_("_Delete"), delete_calendar_cb, NULL, "edit-delete", 0,E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY|E_CAL_POPUP_SOURCE_DELETE }, - - { E_POPUP_BAR, "99.bar" }, - { E_POPUP_ITEM, "99.properties", N_("_Properties"), edit_calendar_cb, NULL, "document-properties", 0, E_CAL_POPUP_SOURCE_PRIMARY }, -}; - -static void -ecc_source_popup_free(EPopup *ep, GSList *list, void *data) -{ - g_slist_free(list); -} - -static gboolean -popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *event, CalendarComponentView *component_view) -{ - ECalPopup *ep; - ECalPopupTargetSource *t; - GSList *menus = NULL; - int i; - GtkMenu *menu; - - /** @HookPoint-ECalPopup: Calendar Source Selector Context Menu - * @Id: org.gnome.evolution.calendar.source.popup - * @Class: org.gnome.evolution.calendar.popup:1.0 - * @Target: ECalPopupTargetSource - * - * The context menu on the source selector in the calendar window. - */ - ep = e_cal_popup_new("org.gnome.evolution.calendar.source.popup"); - t = e_cal_popup_target_new_source(ep, selector); - t->target.widget = (GtkWidget *)component_view->calendar; - - for (i=0;ibutton:0, event?event->time:gtk_get_current_event_time()); - - return TRUE; -} - -static void -source_changed_cb (ESource *source, GnomeCalendar *calendar) -{ - if (calendar) { - GtkWidget *widget = gnome_calendar_get_current_view_widget (calendar); - - if (widget) - gtk_widget_queue_draw (widget); - } -} - -static void -source_added_cb (GnomeCalendar *calendar, ECalSourceType source_type, ESource *source, CalendarComponentView *component_view) -{ - switch (source_type) { - case E_CAL_SOURCE_TYPE_EVENT: - e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), calendar); - break; - default: - break; - } -} - -static void -source_removed_cb (GnomeCalendar *calendar, ECalSourceType source_type, ESource *source, CalendarComponentView *component_view) -{ - switch (source_type) { - case E_CAL_SOURCE_TYPE_EVENT: - g_signal_handlers_disconnect_by_func (source, G_CALLBACK (source_changed_cb), calendar); - e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - break; - default: - break; - } -} - static void config_primary_selection_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { @@ -662,10 +448,8 @@ create_component_view (CalendarComponent *calendar_component) { CalendarComponentPrivate *priv; CalendarComponentView *component_view; - GtkWidget *selector_scrolled_window, *vbox, *vpane; - GtkWidget *statusbar_widget; + GtkWidget **vpane; guint not; - AtkObject *a11y; priv = calendar_component->priv; @@ -682,68 +466,15 @@ create_component_view (CalendarComponent *calendar_component) component_view->source_list = g_object_ref (priv->source_list); component_view->task_source_list = g_object_ref (priv->task_source_list); component_view->memo_source_list = g_object_ref (priv->memo_source_list); - component_view->vpane_pos = calendar_config_get_tag_vpane_pos (); - /* Create sidebar selector */ component_view->source_selector = e_source_selector_new (calendar_component->priv->source_list); - e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE); - a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector)); - atk_object_set_name (a11y, _("Calendar Source Selector")); gtk_widget_show (component_view->source_selector); - selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (selector_scrolled_window), component_view->source_selector); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window), - GTK_SHADOW_IN); - gtk_widget_show (selector_scrolled_window); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (component_view->info_label), FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX (vbox), selector_scrolled_window, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - gtk_paned_pack1 (GTK_PANED (vpane), vbox, FALSE, FALSE); - - component_view->sidebar_control = bonobo_control_new (vpane); - - /* Create main view */ - component_view->view_control = control_factory_new_control (); - if (!component_view->view_control) { - /* FIXME free memory */ - - return NULL; - } - - component_view->calendar = (GnomeCalendar *) bonobo_control_get_widget (component_view->view_control); - - gtk_paned_pack2 (GTK_PANED (vpane), gnome_calendar_get_tag (component_view->calendar), FALSE, FALSE); - - /* This signal is thrown if backends die - we update the selector */ - g_signal_connect (component_view->calendar, "source_added", - G_CALLBACK (source_added_cb), component_view); - g_signal_connect (component_view->calendar, "source_removed", - G_CALLBACK (source_removed_cb), component_view); - - /* Create status bar */ - statusbar_widget = e_task_bar_new (); - gtk_widget_show (statusbar_widget); - - component_view->statusbar_control = bonobo_control_new (statusbar_widget); - - /* connect after setting the initial selections, or we'll get unwanted calls - to calendar_control_sensitize_calendar_commands */ - g_signal_connect (component_view->source_selector, "popup_event", - G_CALLBACK (popup_event_cb), component_view); - /* Set up the "new" item handler */ g_signal_connect (component_view->view_control, "activate", G_CALLBACK (control_activate_cb), component_view); /* Load the selection from the last run */ - update_selection (component_view); - update_primary_selection (component_view); update_task_memo_selection (component_view, E_CAL_SOURCE_TYPE_TODO); update_primary_task_memo_selection (component_view, E_CAL_SOURCE_TYPE_TODO); update_task_memo_selection (component_view, E_CAL_SOURCE_TYPE_JOURNAL); diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c deleted file mode 100644 index 63014b2c4f..0000000000 --- a/calendar/gui/control-factory.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Ettore Perazzoli - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "control-factory.h" - -/* Are these supposed to be global or static? */ -CORBA_Environment ev; -CORBA_ORB orb; - -static void -control_activate_cb (BonoboControl *control, gboolean activate, gpointer data) -{ - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (data); - - if (activate) - calendar_control_activate (control, gcal); - else - calendar_control_deactivate (control, gcal); -} - -BonoboControl * -control_factory_new_control (void) -{ - BonoboControl *control; - GnomeCalendar *gcal; - - gcal = GNOME_CALENDAR (gnome_calendar_new ()); - if (!gcal) - return NULL; - - gtk_widget_show (GTK_WIDGET (gcal)); - - control = bonobo_control_new (GTK_WIDGET (gcal)); - if (!control) { - g_message ("control_factory_fn(): could not create the control!"); - return NULL; - } - g_object_set_data (G_OBJECT (gcal), "control", control); - - g_signal_connect (control, "activate", G_CALLBACK (control_activate_cb), gcal); - - return control; -} diff --git a/calendar/gui/control-factory.h b/calendar/gui/control-factory.h deleted file mode 100644 index 2103f458f1..0000000000 --- a/calendar/gui/control-factory.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Ettore Perazzoli - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _CONTROL_FACTORY_H_ -#define _CONTROL_FACTORY_H_ - -#include - -BonoboControl *control_factory_new_control (void); - -#endif /* _CONTROL_FACTORY_H_ */ diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 5556ff8618..25ad6fb852 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -361,8 +361,10 @@ e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row, GdkEvent { GtkMenu *menu; +#if 0 /* KILL-BONOBO */ menu = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (cal_list_view)); gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time()); +#endif } static gboolean diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index ee76bf4e66..c4cabe1f45 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -1653,69 +1653,6 @@ static EPopupItem ecv_child_items [] = { { E_POPUP_ITEM, "54.delete", N_("Delete _All Occurrences"), on_delete_appointment, NULL, 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, void *data) -{ - g_slist_free(list); -} - -GtkMenu * -e_calendar_view_create_popup_menu (ECalendarView *cal_view) -{ - ECalPopup *ep; - GSList *menus = NULL; - GList *selected, *l; - int 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;ipriv->calendar, (EPopup *)ep, "60.view"); - } else { - for (i=0;ipopup_event_day = day; day_view->popup_event_num = event_num; +#if 0 /* KILL-BONOBO */ popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (day_view)); g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, day_view); gtk_menu_popup (popup, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time()); +#endif } static gboolean diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index ffbb32a398..2b8f303acd 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -4163,9 +4163,11 @@ e_week_view_show_popup_menu (EWeekView *week_view, week_view->popup_event_num = event_num; +#if 0 /* KILL-BONOBO */ popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (week_view)); g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, week_view); gtk_menu_popup (popup, NULL, NULL, NULL, NULL, bevent?bevent->button:0, bevent?bevent->time:gtk_get_current_event_time()); +#endif } static gboolean diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 0bea1e472a..f479f5ba4b 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -44,11 +44,12 @@ #include #include +#include "shell/e-user-creatable-items-handler.h" #include #include #include -#include #include +#include "widgets/menus/gal-view-menus.h" #include "e-util/e-error.h" #include "e-util/e-util-private.h" #include "e-comp-editor-registry.h" @@ -56,6 +57,7 @@ #include "dialogs/event-editor.h" #include "dialogs/task-editor.h" #include "comp-util.h" +#include "e-calendar-marshal.h" #include "e-cal-model-calendar.h" #include "e-day-view.h" #include "e-day-view-config.h" @@ -67,8 +69,12 @@ #include "e-mini-calendar-config.h" #include "e-calendar-table-config.h" #include "e-memo-table-config.h" +#include "evolution-calendar.h" #include "gnome-cal.h" -/*#include "cal-search-bar.h"*/ +#include "calendar-component.h" +#include "memos-component.h" +#include "cal-search-bar.h" +#include "calendar-commands.h" #include "calendar-config.h" #include "calendar-view.h" #include "calendar-view-factory.h" @@ -80,12 +86,15 @@ #include "e-cal-menu.h" #include "e-cal-model-tasks.h" +/* FIXME glib 2.4 and above has this */ +#ifndef G_MAXINT32 +#define G_MAXINT32 ((gint32) 0x7fffffff) +#endif + #define d(x) x /* Private part of the GnomeCalendar structure */ struct _GnomeCalendarPrivate { - gpointer shell_view; /* weak pointer */ - /* The clients for display */ GHashTable *clients[E_CAL_SOURCE_TYPE_LAST]; @@ -110,10 +119,8 @@ struct _GnomeCalendarPrivate { ECalendar *date_navigator; EMiniCalendarConfig *date_navigator_config; GtkWidget *todo; - ECalendarTableConfig *todo_config; GtkWidget *memo; - EMemoTableConfig *memo_config; GtkWidget *day_view; GtkWidget *work_week_view; @@ -121,6 +128,9 @@ struct _GnomeCalendarPrivate { GtkWidget *month_view; GtkWidget *list_view; + /* Activity */ + EActivityHandler *activity_handler; + /* plugin menu managers */ ECalMenu *calendar_menu; ECalMenu *taskpad_menu; @@ -155,9 +165,6 @@ struct _GnomeCalendarPrivate { /* The signal handler id for our GtkCalendar "day_selected" handler. */ guint day_selected_id; - /* View instance and menus for the control */ - GalViewInstance *view_instance; - /* Our current week start */ int week_start; @@ -180,10 +187,7 @@ struct _GnomeCalendarPrivate { ECal *user_created_cal; }; -enum { - PROP_0, - PROP_SHELL_VIEW -}; +/* Signal IDs */ enum { DATES_SHOWN_CHANGED, @@ -200,14 +204,6 @@ enum { LAST_SIGNAL }; -/* Used to indicate who has the focus within the calendar view */ -typedef enum { - FOCUS_CALENDAR, - FOCUS_TASKPAD, - FOCUS_MEMOPAD, - FOCUS_OTHER -} FocusLocation; - static guint gnome_calendar_signals[LAST_SIGNAL]; @@ -277,77 +273,14 @@ message_push (Message *msg) G_DEFINE_TYPE (GnomeCalendar, gnome_calendar, GTK_TYPE_VBOX) -static void -calendar_set_shell_view (GnomeCalendar *calendar, - EShellView *shell_view) -{ - g_return_if_fail (calendar->priv->shell_view == NULL); - - calendar->priv->shell_view = shell_view; - - g_object_add_weak_pointer ( - G_OBJECT (shell_view), - &calendar->priv->shell_view); -} - -static void -calendar_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - calendar_set_shell_view ( - GNOME_CALENDAR (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -calendar_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_SHELL_VIEW: - g_value_set_object ( - value, gnome_calendar_get_shell_view ( - GNOME_CALENDAR (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - /* Class initialization function for the gnome calendar */ static void gnome_calendar_class_init (GnomeCalendarClass *class) { - GObjectClass *object_class; - GtkObjectClass *gtk_object_class; + GtkObjectClass *object_class; GtkBindingSet *binding_set; - object_class = G_OBJECT_CLASS (class); - object_class->set_property = calendar_set_property; - object_class->get_property = calendar_get_property; - - gtk_object_class = (GtkObjectClass *) class; - - g_object_class_install_property ( - object_class, - PROP_SHELL_VIEW, - g_param_spec_object ( - "shell-view", - _("Shell View"), - NULL, - E_TYPE_SHELL_VIEW, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); + object_class = (GtkObjectClass *) class; gnome_calendar_signals[DATES_SHOWN_CHANGED] = g_signal_new ("dates_shown_changed", @@ -422,7 +355,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GnomeCalendarClass, source_added), NULL, NULL, - e_marshal_VOID__INT_OBJECT, + e_calendar_marshal_VOID__INT_OBJECT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_OBJECT); @@ -433,7 +366,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GnomeCalendarClass, source_removed), NULL, NULL, - e_marshal_VOID__INT_OBJECT, + e_calendar_marshal_VOID__INT_OBJECT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_OBJECT); @@ -460,7 +393,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class) 1, G_TYPE_INT); - gtk_object_class->destroy = gnome_calendar_destroy; + object_class->destroy = gnome_calendar_destroy; class->dates_shown_changed = NULL; class->calendar_selection_changed = NULL; @@ -775,69 +708,6 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_ } } -/* Gets the focus location based on who is the focused widget within the - * calendar view. - */ -static FocusLocation -get_focus_location (GnomeCalendar *gcal) -{ - GnomeCalendarPrivate *priv; - ETable *etable, *m_etable; - - priv = gcal->priv; - - etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo)); - m_etable = e_memo_table_get_table (E_MEMO_TABLE (priv->memo)); - - if (GTK_WIDGET_HAS_FOCUS (etable->table_canvas)) - return FOCUS_TASKPAD; - else if (GTK_WIDGET_HAS_FOCUS (m_etable->table_canvas)) - return FOCUS_MEMOPAD; - else { - GtkWidget *widget; - EDayView *dv; - EWeekView *wv; - ECalListView *lv; - - widget = gnome_calendar_get_current_view_widget (gcal); - - switch (priv->current_view_type) { - case GNOME_CAL_DAY_VIEW: - case GNOME_CAL_WORK_WEEK_VIEW: - dv = E_DAY_VIEW (widget); - - if (GTK_WIDGET_HAS_FOCUS (dv->top_canvas) - || GNOME_CANVAS (dv->top_canvas)->focused_item != NULL - || GTK_WIDGET_HAS_FOCUS (dv->main_canvas) - || GNOME_CANVAS (dv->main_canvas)->focused_item != NULL) - return FOCUS_CALENDAR; - else - return FOCUS_OTHER; - - case GNOME_CAL_WEEK_VIEW: - case GNOME_CAL_MONTH_VIEW: - wv = E_WEEK_VIEW (widget); - - if (GTK_WIDGET_HAS_FOCUS (wv->main_canvas) - || GNOME_CANVAS (wv->main_canvas)->focused_item != NULL) - return FOCUS_CALENDAR; - else - return FOCUS_OTHER; - - case GNOME_CAL_LIST_VIEW: - lv = E_CAL_LIST_VIEW (widget); - - if (GTK_WIDGET_HAS_FOCUS (e_table_scrolled_get_table (lv->table_scrolled))) - return FOCUS_CALENDAR; - else - return FOCUS_OTHER; - - default: - g_return_val_if_reached (FOCUS_OTHER); - } - } -} - /* Computes the range of time that the date navigator is showing */ static void get_date_navigator_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_time) @@ -1006,7 +876,6 @@ update_query (GnomeCalendar *gcal) static void set_search_query (GnomeCalendar *gcal, const char *sexp) { -#if 0 /* KILL-BONOBO */ GnomeCalendarPrivate *priv; int i; time_t start, end; @@ -1049,7 +918,6 @@ set_search_query (GnomeCalendar *gcal, const char *sexp) /* Set the query on the task pad */ update_todo_view (gcal); -#endif } /* Returns the current time, for the ECalendarItem. */ @@ -1072,7 +940,6 @@ get_current_time (ECalendarItem *calitem, gpointer data) return tmp_tm; } -#if 0 /* KILL-BONOBO */ /* Callback used when the sexp changes in the calendar search bar */ static void search_bar_sexp_changed_cb (CalSearchBar *cal_search, const char *sexp, gpointer data) @@ -1115,7 +982,6 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category, model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)); e_cal_model_set_default_category (model, category); } -#endif static void view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal) @@ -1123,6 +989,7 @@ view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal) g_signal_emit (gcal, gnome_calendar_signals[CALENDAR_SELECTION_CHANGED], 0); } + /** * gnome_calendar_emit_user_created_signal * Emits "user_created" signal on a gcal and use calendar as a store where was event created. @@ -1318,6 +1185,37 @@ working_days_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpoin set_working_days (calendar); } +static void +set_timezone (GnomeCalendar *calendar) +{ + GnomeCalendarPrivate *priv; + int i; + + priv = calendar->priv; + + priv->zone = calendar_config_get_icaltimezone (); + + for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) { + GList *l; + + for (l = priv->clients_list[i]; l != NULL; l = l->next) { + ECal *client = l->data; + + if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) + /* FIXME Error checking */ + e_cal_set_default_timezone (client, priv->zone, NULL); + } + + if (priv->default_client[i] + && e_cal_get_load_state (priv->default_client[i]) == E_CAL_LOAD_LOADED) + /* FIXME Error checking */ + e_cal_set_default_timezone (priv->default_client[i], priv->zone, NULL); + } + + if (priv->views [priv->current_view_type]) + e_calendar_view_set_timezone (priv->views [priv->current_view_type], priv->zone); +} + static void timezone_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { @@ -1550,9 +1448,7 @@ categories_changed_cb (gpointer object, gpointer user_data) cat_list = g_list_remove (cat_list, cat_list->data); } -#if 0 /* KILL-BONOBO */ cal_search_bar_set_categories ((CalSearchBar *)priv->search_bar, cat_array); -#endif g_ptr_array_free (cat_array, TRUE); } @@ -1561,7 +1457,6 @@ categories_changed_cb (gpointer object, gpointer user_data) static void view_progress_cb (ECalModel *model, const char *message, int percent, ECalSourceType type, GnomeCalendar *gcal) { -#if 0 /* KILL-BONOBO */ if (type == E_CAL_SOURCE_TYPE_EVENT) { e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), message, percent); } else if (type == E_CAL_SOURCE_TYPE_TODO) { @@ -1569,13 +1464,11 @@ view_progress_cb (ECalModel *model, const char *message, int percent, ECalSource } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) { e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), message); } -#endif } static void view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, GnomeCalendar *gcal) { -#if 0 /* KILL-BONOBO */ if (type == E_CAL_SOURCE_TYPE_EVENT) { e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), NULL, -1); } else if (type == E_CAL_SOURCE_TYPE_TODO) { @@ -1583,7 +1476,7 @@ view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, Gno } else if (type == E_CAL_SOURCE_TYPE_JOURNAL) { e_memo_table_set_status_message (E_MEMO_TABLE (gcal->priv->memo), NULL); } -#endif + } GtkWidget * @@ -1609,14 +1502,12 @@ setup_widgets (GnomeCalendar *gcal) priv = gcal->priv; -#if 0 /* KILL-BONOBO */ priv->search_bar = cal_search_bar_new (CAL_SEARCH_CALENDAR_DEFAULT); g_signal_connect (priv->search_bar, "sexp_changed", G_CALLBACK (search_bar_sexp_changed_cb), gcal); g_signal_connect (priv->search_bar, "category_changed", G_CALLBACK (search_bar_category_changed_cb), gcal); categories_changed_cb (NULL, gcal); -#endif gtk_widget_show (priv->search_bar); gtk_box_pack_start (GTK_BOX (gcal), priv->search_bar, FALSE, FALSE, 6); @@ -1676,26 +1567,11 @@ setup_widgets (GnomeCalendar *gcal) g_free (tmp); gtk_box_pack_start ((GtkBox *)vbox, label, FALSE, TRUE, 0); -#if 0 /* KILL-BONOBO */ - priv->todo = e_calendar_table_new (); - priv->todo_config = e_calendar_table_config_new (E_CALENDAR_TABLE (priv->todo)); - gtk_paned_pack1 (GTK_PANED (priv->vpane), vbox, FALSE, TRUE); - gtk_box_pack_end ((GtkBox *)vbox, priv->todo, TRUE, TRUE, 0); -#endif - - gtk_widget_show (priv->todo); gtk_widget_show (label); gtk_widget_show (vbox); gtk_widget_show (sep); -#if 0 /* KILL-BONOBO */ - filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()), - "TaskPad", NULL); - e_calendar_table_load_state (E_CALENDAR_TABLE (priv->todo), filename); - update_todo_view (gcal); - g_free (filename); -#endif etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo)); g_signal_connect (etable->table_canvas, "focus_in_event", @@ -1804,7 +1680,6 @@ setup_widgets (GnomeCalendar *gcal) gtk_widget_show (GTK_WIDGET (priv->views[i])); } -#if 0 /* KILL-BONOBO */ /* Memo view */ vbox = gtk_vbox_new (FALSE, 0); label = gtk_label_new (NULL); @@ -1812,24 +1687,10 @@ setup_widgets (GnomeCalendar *gcal) gtk_label_set_markup ((GtkLabel *)label, tmp); g_free (tmp); gtk_box_pack_start ((GtkBox *)vbox, label, FALSE, TRUE, 0); - priv->memo = e_memo_table_new (); - priv->memo_config = e_memo_table_config_new (E_MEMO_TABLE (priv->memo)); - gtk_paned_pack2 (GTK_PANED (priv->vpane), vbox, TRUE, TRUE); - gtk_box_pack_end ((GtkBox *)vbox, priv->memo, TRUE, TRUE, 0); -#endif - - gtk_widget_show (priv->memo); gtk_widget_show (label); gtk_widget_show (vbox); -#if 0 /* KILL-BONOBO */ - filename = g_build_filename (memos_component_peek_config_directory (memos_component_peek ()), - "MemoPad", NULL); - e_memo_table_load_state (E_MEMO_TABLE (priv->memo), filename); -#endif - update_memo_view (gcal); - g_free (filename); etable = e_memo_table_get_table (E_MEMO_TABLE (priv->memo)); g_signal_connect (etable->table_canvas, "focus_in_event", @@ -1871,7 +1732,6 @@ gnome_calendar_init (GnomeCalendar *gcal) priv->calendar_menu = e_cal_menu_new("org.gnome.evolution.calendar.view"); priv->taskpad_menu = e_cal_menu_new("org.gnome.evolution.calendar.taskpad"); - priv->memopad_menu = e_cal_menu_new ("org.gnome.evolution.calendar.memopad"); priv->dn_queries = NULL; priv->sexp = g_strdup ("#t"); /* Match all */ @@ -1933,29 +1793,23 @@ gnome_calendar_destroy (GtkObject *object) priv->configs[i] = NULL; } g_object_unref (priv->date_navigator_config); - g_object_unref (priv->todo_config); - g_object_unref (priv->memo_config); for (l = priv->notifications; l; l = l->next) calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); g_list_free (priv->notifications); priv->notifications = NULL; -#if 0 /* KILL-BONOBO */ /* Save the TaskPad layout. */ filename = g_build_filename (calendar_component_peek_config_directory (calendar_component_peek ()), "TaskPad", NULL); e_calendar_table_save_state (E_CALENDAR_TABLE (priv->todo), filename); g_free (filename); -#endif -#if 0 /* KILL-BONOBO */ /* Save the MemoPad layout. */ filename = g_build_filename (memos_component_peek_config_directory (memos_component_peek ()), "MemoPad", NULL); e_memo_table_save_state (E_MEMO_TABLE (priv->memo), filename); g_free (filename); -#endif if (priv->dn_queries) { for (l = priv->dn_queries; l != NULL; l = l->next) { @@ -1978,21 +1832,11 @@ gnome_calendar_destroy (GtkObject *object) priv->todo_sexp = NULL; } - if (priv->memo_sexp) { - g_free (priv->memo_sexp); - priv->memo_sexp = NULL; - } - if (priv->update_timeout) { g_source_remove (priv->update_timeout); priv->update_timeout = 0; } - if (priv->view_instance) { - g_object_unref (priv->view_instance); - priv->view_instance = NULL; - } - if (priv->update_marcus_bains_line_timeout) { g_source_remove (priv->update_marcus_bains_line_timeout); priv->update_marcus_bains_line_timeout = 0; @@ -2452,233 +2296,6 @@ display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data) } -#if 0 /* KILL-BONOBO */ -/** - * gnome_calendar_setup_view_menus: - * @gcal: A calendar. - * @uic: UI controller to use for the menus. - * - * Sets up the #GalView menus for a calendar. This function should be called - * from the Bonobo control activation callback for this calendar. Also, the - * menus should be discarded using gnome_calendar_discard_view_menus(). - **/ -void -gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic) -{ - GnomeCalendarPrivate *priv; - char *path0, *path1, *etspecfile; - CalendarViewFactory *factory; - GalViewFactory *gal_factory; - static GalViewCollection *collection = NULL; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (uic != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic)); - - priv = gcal->priv; - - g_return_if_fail (priv->view_instance == NULL); - g_return_if_fail (priv->view_menus == NULL); - - /* Create the view instance */ - if (collection == NULL) { - ETableSpecification *spec; - - collection = gal_view_collection_new (); - - gal_view_collection_set_title (collection, _("Calendar")); - - path0 = g_build_filename (EVOLUTION_GALVIEWSDIR, - "calendar", - NULL); - path1 = g_build_filename (calendar_component_peek_base_directory (calendar_component_peek ()), - "views", NULL); - gal_view_collection_set_storage_directories (collection, - path0, - path1); - g_free (path1); - g_free (path0); - - /* Create the views */ - - factory = calendar_view_factory_new (GNOME_CAL_DAY_VIEW); - gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory)); - g_object_unref (factory); - - factory = calendar_view_factory_new (GNOME_CAL_WORK_WEEK_VIEW); - gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory)); - g_object_unref (factory); - - factory = calendar_view_factory_new (GNOME_CAL_WEEK_VIEW); - gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory)); - g_object_unref (factory); - - factory = calendar_view_factory_new (GNOME_CAL_MONTH_VIEW); - gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory)); - g_object_unref (factory); - - spec = e_table_specification_new (); - etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, - "e-cal-list-view.etspec", - NULL); - if (!e_table_specification_load_from_file (spec, etspecfile)) - g_error ("Unable to load ETable specification file " - "for calendar"); - g_free (etspecfile); - gal_factory = gal_view_factory_etable_new (spec); - g_object_unref (spec); - gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (gal_factory)); - g_object_unref (gal_factory); - - /* Load the collection and create the menus */ - - gal_view_collection_load (collection); - - } - - priv->view_instance = gal_view_instance_new (collection, NULL); - priv->view_menus = gal_view_menus_new (priv->view_instance); - gal_view_menus_apply (priv->view_menus, uic, NULL); - - g_signal_connect (priv->view_instance, "display_view", G_CALLBACK (display_view_cb), gcal); - display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), gcal); -} -#endif - -/* This is copied/moved from gal-view-instance, only the calendar uses this for a popup menu */ -static void -gc_set_view(EPopup *ep, EPopupItem *pitem, void *data) -{ - GnomeCalendar *gcal = data; - - if (pitem->type & E_POPUP_ACTIVE) - gal_view_instance_set_current_view_id(gcal->priv->view_instance, (char *)pitem->user_data); -} - -static void -gc_save_custom_view(EPopup *ep, EPopupItem *pitem, void *data) -{ - GnomeCalendar *gcal = data; - - gal_view_instance_save_as(gcal->priv->view_instance); -} - -static void -gc_define_views_response(GtkWidget *d, int id, GnomeCalendar *gcal) -{ - if (id == GTK_RESPONSE_OK) - gal_view_collection_save(gcal->priv->view_instance->collection); - - gtk_widget_destroy(d); -} - -static void -gc_define_views(EPopup *ep, EPopupItem *pitem, void *data) -{ - GnomeCalendar *gcal = data; - GtkWidget *dialog = gal_define_views_dialog_new(gcal->priv->view_instance->collection); - - g_signal_connect(dialog, "response", G_CALLBACK(gc_define_views_response), data); - gtk_widget_show(dialog); -} - -static EPopupItem gc_popups[] = { - /* Code generates the path to fit */ - { E_POPUP_BAR, NULL }, - { E_POPUP_RADIO|E_POPUP_ACTIVE, NULL, N_("_Custom View"), }, - { E_POPUP_ITEM, NULL, N_("_Save Custom View"), gc_save_custom_view }, - - /* index == 3, when we have non-custom view */ - - { E_POPUP_BAR, NULL }, - { E_POPUP_ITEM, NULL, N_("_Define Views..."), gc_define_views }, -}; - -static void -gc_popup_free (EPopup *ep, GSList *list, void *data) -{ - while (list) { - GSList *n = list->next; - EPopupItem *pitem = list->data; - - g_free(pitem->path); - g_free(pitem->label); - g_free(pitem->user_data); - g_free(pitem); - g_slist_free_1(list); - list = n; - } -} - -static void -gc_popup_free_static (EPopup *ep, GSList *list, void *data) -{ - while (list) { - GSList *n = list->next; - EPopupItem *pitem = list->data; - - g_free(pitem->path); - g_free(pitem); - g_slist_free_1(list); - list = n; - } -} - -void -gnome_calendar_view_popup_factory (GnomeCalendar *gcal, EPopup *ep, const char *prefix) -{ - GnomeCalendarPrivate *priv; - int length; - int i; - gboolean found = FALSE; - char *id; - GSList *menus = NULL; - EPopupItem *pitem; - - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (prefix != NULL); - - priv = gcal->priv; - - g_return_if_fail (priv->view_instance != NULL); - - length = gal_view_collection_get_count(priv->view_instance->collection); - id = gal_view_instance_get_current_view_id (priv->view_instance); - - for (i = 0; i < length; i++) { - GalViewCollectionItem *item = gal_view_collection_get_view_item(priv->view_instance->collection, i); - - pitem = g_malloc0(sizeof(*pitem)); - pitem->type = E_POPUP_RADIO; - pitem->path = g_strdup_printf("%s/%02d.item", prefix, i); - pitem->label = g_strdup(item->title); - pitem->activate = gc_set_view; - pitem->user_data = g_strdup(item->id); - - if (!found && id && !strcmp (id, item->id)) { - found = TRUE; - pitem->type |= E_POPUP_ACTIVE; - } - - menus = g_slist_prepend(menus, pitem); - } - - if (menus) - e_popup_add_items(ep, menus, NULL, gc_popup_free, gcal); - - menus = NULL; - for (i = found?3:0; ipath = g_strdup_printf("%s/%02d.item", prefix, i+length); - menus = g_slist_prepend(menus, pitem); - } - - e_popup_add_items(ep, menus, NULL, gc_popup_free_static, gcal); -} - static void gnome_calendar_set_pane_positions (GnomeCalendar *gcal) { @@ -2740,7 +2357,6 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) source = e_cal_get_source (ecal); state = e_cal_get_load_state (ecal); -#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT: e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); @@ -2753,7 +2369,6 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) default: break; } -#endif if (status == E_CALENDAR_STATUS_AUTHENTICATION_FAILED && source_type == E_CAL_SOURCE_TYPE_EVENT) auth_cal_forget_password (ecal); @@ -2801,7 +2416,6 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, client_cal_opened_cb, NULL); -#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT : msg = g_strdup_printf (_("Loading appointments at %s"), e_cal_get_uri (ecal)); @@ -2837,7 +2451,6 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal) default: g_return_if_reached (); } -#endif } static void @@ -2854,7 +2467,6 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar source = e_cal_get_source (ecal); state = e_cal_get_load_state (ecal); -#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT: e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); @@ -2868,7 +2480,6 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar default: break; } -#endif switch (status) { case E_CALENDAR_STATUS_OK: @@ -2936,7 +2547,6 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of zone = calendar_config_get_icaltimezone (); e_cal_set_default_timezone (cal, zone, NULL); -#if 0 /* KILL-BONOBO */ msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (cal)); switch (e_cal_get_source_type (cal)) { case E_CAL_SOURCE_TYPE_EVENT : @@ -2954,7 +2564,6 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of } g_free (msg); -#endif g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (of), gcal); e_cal_open_async (cal, only_if_exists); @@ -2962,6 +2571,31 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of return TRUE; } +/* Callback when we get an error message from the backend */ +static void +backend_error_cb (ECal *client, const char *message, gpointer data) +{ + GnomeCalendar *gcal; + GtkDialog *dialog; + char *uristr; + + gcal = GNOME_CALENDAR (data); + + uristr = get_uri_without_password (e_cal_get_uri (client)); + + dialog = GTK_DIALOG (gtk_message_dialog_new ( + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Error on %s:\n %s"), + uristr, message)); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); + + g_free (uristr); +} + /* Callback when the backend dies */ static void backend_died_cb (ECal *ecal, gpointer data) @@ -2984,7 +2618,6 @@ backend_died_cb (ECal *ecal, gpointer data) priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal); g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source)); -#if 0 /* KILL-BONOBO */ switch (source_type) { case E_CAL_SOURCE_TYPE_EVENT: id = "calendar:calendar-crashed"; @@ -3012,7 +2645,6 @@ backend_died_cb (ECal *ecal, gpointer data) default: g_return_if_reached (); } -#endif g_object_unref (source); @@ -3033,15 +2665,11 @@ gnome_calendar_construct (GnomeCalendar *gcal) } GtkWidget * -gnome_calendar_new (EShellView *shell_view) +gnome_calendar_new (void) { GnomeCalendar *gcal; - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - gcal = g_object_new ( - GNOME_TYPE_CALENDAR, - "shell-view", shell_view, NULL); + gcal = g_object_new (gnome_calendar_get_type (), NULL); if (!gnome_calendar_construct (gcal)) { g_message (G_STRLOC ": Could not construct the calendar GUI"); @@ -3052,14 +2680,6 @@ gnome_calendar_new (EShellView *shell_view) return GTK_WIDGET (gcal); } -EShellView * -gnome_calendar_get_shell_view (GnomeCalendar *calendar) -{ - g_return_val_if_fail (GNOME_IS_CALENDAR (calendar), NULL); - - return calendar->priv->shell_view; -} - /** * gnome_calendar_get_calendar_model: * @gcal: A calendar view. @@ -3362,10 +2982,8 @@ gnome_calendar_new_task (GnomeCalendar *gcal, time_t *dtstart, time_t *dtend) comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomp); -#if 0 /* KILL-BONOBO */ category = cal_search_bar_get_category (CAL_SEARCH_BAR (priv->search_bar)); e_cal_component_set_categories (comp, category); -#endif dt.value = &itt; dt.tzid = icaltimezone_get_tzid (e_cal_model_get_timezone (model)); @@ -3649,55 +3267,34 @@ gnome_calendar_vpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gc void gnome_calendar_cut_clipboard (GnomeCalendar *gcal) { - GnomeCalendarPrivate *priv; - FocusLocation location; + GtkWidget *widget; - priv = gcal->priv; - - location = get_focus_location (gcal); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - if (location == FOCUS_CALENDAR) { - e_calendar_view_cut_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal))); - } else if (location == FOCUS_TASKPAD) - e_calendar_table_cut_clipboard (E_CALENDAR_TABLE (priv->todo)); - else if (location == FOCUS_MEMOPAD) - e_memo_table_cut_clipboard (E_MEMO_TABLE (priv->memo)); + widget = gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_cut_clipboard (E_CALENDAR_VIEW (widget)); } void gnome_calendar_copy_clipboard (GnomeCalendar *gcal) { - GnomeCalendarPrivate *priv; - FocusLocation location; + GtkWidget *widget; - priv = gcal->priv; - - location = get_focus_location (gcal); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - if (location == FOCUS_CALENDAR) { - e_calendar_view_copy_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal))); - } else if (location == FOCUS_TASKPAD) - e_calendar_table_copy_clipboard (E_CALENDAR_TABLE (priv->todo)); - else if (location == FOCUS_MEMOPAD) - e_memo_table_copy_clipboard (E_MEMO_TABLE (priv->memo)); + widget = gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_copy_clipboard (E_CALENDAR_VIEW (widget)); } void gnome_calendar_paste_clipboard (GnomeCalendar *gcal) { - GnomeCalendarPrivate *priv; - FocusLocation location; + GtkWidget *widget; - priv = gcal->priv; - - location = get_focus_location (gcal); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - if (location == FOCUS_CALENDAR) { - e_calendar_view_paste_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal))); - } else if (location == FOCUS_TASKPAD) - e_calendar_table_paste_clipboard (E_CALENDAR_TABLE (priv->todo)); - else if (location == FOCUS_MEMOPAD) - e_memo_table_paste_clipboard (E_MEMO_TABLE (priv->memo)); + widget = gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_paste_clipboard (E_CALENDAR_VIEW (widget)); } @@ -3759,69 +3356,26 @@ gnome_calendar_get_num_events_selected (GnomeCalendar *gcal) return retval; } -/** - * gnome_calendar_get_num_tasks_selected: - * @gcal: A calendar view. - * - * Queries the number of tasks that are currently selected in the task pad of a - * calendar view. - * - * Return value: Number of selected tasks. - **/ -gint -gnome_calendar_get_num_tasks_selected (GnomeCalendar *gcal) -{ - GnomeCalendarPrivate *priv; - ETable *etable; - - g_return_val_if_fail (gcal != NULL, -1); - g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), -1); - - priv = gcal->priv; - - etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo)); - return e_table_selected_count (etable); -} - - void -gnome_calendar_delete_selection (GnomeCalendar *gcal) +gnome_calendar_delete_selection (GnomeCalendar *gcal) { - GnomeCalendarPrivate *priv; - FocusLocation location; - GtkWidget *view; + GtkWidget *widget; 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); - - e_calendar_view_delete_selected_events (E_CALENDAR_VIEW (view)); - } else if (location == FOCUS_TASKPAD) - e_calendar_table_delete_selected (E_CALENDAR_TABLE (priv->todo)); - else if (location == FOCUS_MEMOPAD) - e_memo_table_delete_selected (E_MEMO_TABLE (priv->memo)); + widget = gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_delete_selected_events (E_CALENDAR_VIEW (widget)); } void gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal) { - FocusLocation location; - GtkWidget *view; + GtkWidget *widget; g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - location = get_focus_location (gcal); - - if (location == FOCUS_CALENDAR) { - - view = gnome_calendar_get_current_view_widget (gcal); - e_calendar_view_delete_selected_occurrence (E_CALENDAR_VIEW (view)); - } + widget = gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_delete_selected_occurrence (E_CALENDAR_VIEW (widget)); } static gboolean @@ -3854,9 +3408,7 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) " (make-time \"%s\"))", start, end); -#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), _("Purging"), -1); -#endif /* FIXME Confirm expunge */ for (l = priv->clients_list[E_CAL_SOURCE_TYPE_EVENT]; l != NULL; l = l->next) { @@ -3914,9 +3466,7 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) g_list_free (objects); } -#if 0 /* KILL-BONOBO */ e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL, -1); -#endif g_free (sexp); g_free (start); diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 6d06f2666b..29865d98fa 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -106,10 +105,7 @@ struct _GnomeCalendarClass { GType gnome_calendar_get_type (void); GtkWidget *gnome_calendar_construct (GnomeCalendar *gcal); -GtkWidget *gnome_calendar_new (EShellView *shell_view); -EShellView * gnome_calendar_get_shell_view (GnomeCalendar *calendar); - -void gnome_calendar_set_ui_component (GnomeCalendar *cal, BonoboUIComponent *ui_component); +GtkWidget *gnome_calendar_new (void); ECalendarTable *gnome_calendar_get_task_pad (GnomeCalendar *gcal); @@ -145,11 +141,6 @@ struct _ECalMenu *gnome_calendar_get_taskpad_menu (GnomeCalendar *gcal); struct _ECalMenu *gnome_calendar_get_calendar_menu (GnomeCalendar *gcal); struct _ECalMenu *gnome_calendar_get_memopad_menu (GnomeCalendar *gcal); -void gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic); -void gnome_calendar_discard_view_menus (GnomeCalendar *gcal); - -void gnome_calendar_view_popup_factory (GnomeCalendar *gcal, struct _EPopup *ep, const char *prefix); - void gnome_calendar_set_selected_time_range (GnomeCalendar *gcal, time_t start_time, time_t end_time); @@ -175,9 +166,6 @@ gboolean gnome_calendar_get_visible_time_range (GnomeCalendar *gcal, /* Returns the number of selected events (0 or 1 at present). */ gint gnome_calendar_get_num_events_selected (GnomeCalendar *gcal); -/* Returns the number of selected tasks */ -gint gnome_calendar_get_num_tasks_selected (GnomeCalendar *gcal); - /* Get the current timezone. */ icaltimezone *gnome_calendar_get_timezone (GnomeCalendar *gcal); diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c index 51afab099f..45974af517 100644 --- a/calendar/gui/memos-component.c +++ b/calendar/gui/memos-component.c @@ -482,9 +482,7 @@ create_component_view (MemosComponent *memos_component) { MemosComponentPrivate *priv; MemosComponentView *component_view; - GtkWidget *selector_scrolled_window, *vbox; GtkWidget *statusbar_widget; - AtkObject *a11y; priv = memos_component->priv; diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 3800f01f0f..7c70192c90 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -74,18 +74,12 @@ typedef struct ETable *table; ETableModel *model; - EInfoLabel *info_label; GtkWidget *source_selector; BonoboControl *view_control; - BonoboControl *sidebar_control; - BonoboControl *statusbar_control; GList *notifications; - EUserCreatableItemsHandler *creatable_items_handler; - - EActivityHandler *activity_handler; } TasksComponentView; struct _TasksComponentPrivate { @@ -184,62 +178,6 @@ update_uri_for_primary_selection (TasksComponentView *component_view) calendar_config_set_primary_tasks (e_source_peek_uid (source)); } -static void -update_selection (TasksComponentView *component_view) -{ - GSList *selection, *uids_selected, *l; - - /* Get the selection in gconf */ - uids_selected = calendar_config_get_tasks_selected (); - - /* Remove any that aren't there any more */ - selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector)); - - for (l = selection; l; l = l->next) { - ESource *source = l->data; - - if (!is_in_uids (uids_selected, source)) - e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - } - - e_source_selector_free_selection (selection); - - /* Make sure the whole selection is there */ - for (l = uids_selected; l; l = l->next) { - char *uid = l->data; - ESource *source; - - source = e_source_list_peek_source_by_uid (component_view->source_list, uid); - if (source) - e_source_selector_select_source (E_SOURCE_SELECTOR (component_view->source_selector), source); - - g_free (uid); - } - g_slist_free (uids_selected); -} - -static void -update_primary_selection (TasksComponentView *component_view) -{ - ESource *source = NULL; - char *uid; - - uid = calendar_config_get_primary_tasks (); - if (uid) { - source = e_source_list_peek_source_by_uid (component_view->source_list, uid); - g_free (uid); - } - - if (source) { - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source); - } else { - /* Try to create a default if there isn't one */ - source = e_source_list_peek_source_any (component_view->source_list); - if (source) - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector), source); - } -} - /* Callbacks. */ static void copy_task_list_cb (EPopup *ep, EPopupItem *pitem, void *data) @@ -378,31 +316,6 @@ source_removed_cb (ETasks *tasks, ESource *source, TasksComponentView *component e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector), source); } -/* Evolution::Component CORBA methods */ - -static void -impl_upgradeFromVersion (PortableServer_Servant servant, - CORBA_short major, - CORBA_short minor, - CORBA_short revision, - CORBA_Environment *ev) -{ - GError *err = NULL; - TasksComponent *component = TASKS_COMPONENT (bonobo_object_from_servant (servant)); - - if (!migrate_tasks(component, major, minor, revision, &err)) { - GNOME_Evolution_Component_UpgradeFailed *failedex; - - failedex = GNOME_Evolution_Component_UpgradeFailed__alloc(); - failedex->what = CORBA_string_dup(_("Failed upgrading tasks.")); - failedex->why = CORBA_string_dup(err->message); - CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex); - } - - if (err) - g_error_free(err); -} - static gboolean update_single_object (ECal *client, icalcomponent *icalcomp) { @@ -721,42 +634,11 @@ create_new_todo (TasksComponent *task_component, gboolean is_assigned, TasksComp return TRUE; } -static void -create_local_item_cb (EUserCreatableItemsHandler *handler, const char *item_type_name, void *data) -{ - TasksComponent *tasks_component = data; - TasksComponentPrivate *priv; - TasksComponentView *component_view = NULL; - GList *l; - - priv = tasks_component->priv; - - for (l = priv->views; l; l = l->next) { - component_view = l->data; - - if (component_view->creatable_items_handler == handler) - break; - - component_view = NULL; - } - - if (strcmp (item_type_name, CREATE_TASK_ID) == 0) { - create_new_todo (tasks_component, FALSE, component_view); - } else if (strcmp (item_type_name, CREATE_TASK_ASSIGNED_ID) == 0) { - create_new_todo (tasks_component, TRUE, component_view); - } else if (strcmp (item_type_name, CREATE_TASK_LIST_ID) == 0) { - calendar_setup_new_task_list (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (component_view->tasks)))); - } -} - static TasksComponentView * create_component_view (TasksComponent *tasks_component) { TasksComponentPrivate *priv; TasksComponentView *component_view; - GtkWidget *selector_scrolled_window, *vbox; - GtkWidget *statusbar_widget; - AtkObject *a11y; priv = tasks_component->priv; @@ -768,38 +650,10 @@ create_component_view (TasksComponent *tasks_component) /* Create sidebar selector */ component_view->source_selector = e_source_selector_new (tasks_component->priv->source_list); - e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE); - a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector)); - atk_object_set_name (a11y, _("Task Source Selector")); g_signal_connect (component_view->source_selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), tasks_component); - gtk_widget_show (component_view->source_selector); - - selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (selector_scrolled_window), component_view->source_selector); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window), - GTK_SHADOW_IN); - gtk_widget_show (selector_scrolled_window); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (component_view->info_label), FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX (vbox), selector_scrolled_window, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - component_view->sidebar_control = bonobo_control_new (vbox); - - /* Create main view */ - component_view->view_control = tasks_control_new (); - if (!component_view->view_control) { - /* FIXME free memory */ - - return NULL; - } - component_view->tasks = (ETasks *) bonobo_control_get_widget (component_view->view_control); component_view->table = e_calendar_table_get_table (e_tasks_get_calendar_table (component_view->tasks)); component_view->model = E_TABLE_MODEL (e_calendar_table_get_model (e_tasks_get_calendar_table (component_view->tasks))); @@ -808,16 +662,6 @@ create_component_view (TasksComponent *tasks_component) g_signal_connect (component_view->tasks, "source_removed", G_CALLBACK (source_removed_cb), component_view); - /* Create status bar */ - statusbar_widget = e_task_bar_new (); - component_view->activity_handler = e_activity_handler_new (); - e_activity_handler_attach_task_bar (component_view->activity_handler, E_TASK_BAR (statusbar_widget)); - gtk_widget_show (statusbar_widget); - - component_view->statusbar_control = bonobo_control_new (statusbar_widget); - - e_calendar_table_set_activity_handler (e_tasks_get_calendar_table (component_view->tasks), component_view->activity_handler); - /* connect after setting the initial selections, or we'll get unwanted calls to calendar_control_sensitize_calendar_commands */ g_signal_connect (component_view->source_selector, "selection_changed", @@ -827,10 +671,6 @@ create_component_view (TasksComponent *tasks_component) g_signal_connect (component_view->source_selector, "popup_event", G_CALLBACK (popup_event_cb), component_view); - /* Load the selection from the last run */ - update_selection (component_view); - update_primary_selection (component_view); - return component_view; } @@ -852,12 +692,6 @@ destroy_component_view (TasksComponentView *component_view) calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); g_list_free (component_view->notifications); - if (component_view->creatable_items_handler) - g_object_unref (component_view->creatable_items_handler); - - if (component_view->activity_handler) - g_object_unref (component_view->activity_handler); - g_free (component_view); } @@ -882,38 +716,6 @@ view_destroyed_cb (gpointer data, GObject *where_the_object_was) } } -static GNOME_Evolution_ComponentView -impl_createView (PortableServer_Servant servant, - GNOME_Evolution_ShellView parent, - CORBA_boolean select_item, - CORBA_Environment *ev) -{ - TasksComponent *component = TASKS_COMPONENT (bonobo_object_from_servant (servant)); - TasksComponentPrivate *priv; - TasksComponentView *component_view; - EComponentView *ecv; - - priv = component->priv; - - /* Create the calendar component view */ - component_view = create_component_view (component); - if (!component_view) { - /* FIXME Should we describe the problem in a control? */ - bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed); - - return CORBA_OBJECT_NIL; - } - - g_object_weak_ref (G_OBJECT (component_view->view_control), view_destroyed_cb, component); - priv->views = g_list_append (priv->views, component_view); - - /* TODO: Make TasksComponentView just subclass EComponentView */ - ecv = e_component_view_new_controls (parent, "tasks", component_view->sidebar_control, - component_view->view_control, component_view->statusbar_control); - - return BONOBO_OBJREF(ecv); -} - static void impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environment *ev) { @@ -1073,8 +875,6 @@ tasks_component_class_init (TasksComponentClass *klass) parent_class = g_type_class_peek_parent (klass); - epv->upgradeFromVersion = impl_upgradeFromVersion; - epv->createView = impl_createView; epv->requestCreateItem = impl_requestCreateItem; epv->handleURI = impl_handleURI; @@ -1091,5 +891,3 @@ tasks_component_init (TasksComponent *component, TasksComponentClass *klass) component->priv = priv; } - -BONOBO_TYPE_FUNC_FULL (TasksComponent, GNOME_Evolution_Component, PARENT_TYPE, tasks_component) diff --git a/calendar/modules/e-cal-shell-content.c b/calendar/modules/e-cal-shell-content.c index 7529893026..8300c657ca 100644 --- a/calendar/modules/e-cal-shell-content.c +++ b/calendar/modules/e-cal-shell-content.c @@ -34,20 +34,128 @@ ((obj), E_TYPE_CAL_SHELL_CONTENT, ECalShellContentPrivate)) struct _ECalShellContentPrivate { - gint dummy; + GtkWidget *hpaned; + GtkWidget *notebook; + GtkWidget *vpaned; + + GtkWidget *day_view; + GtkWidget *work_week_view; + GtkWidget *week_view; + GtkWidget *month_view; + GtkWidget *list_view; + GtkWidget *task_table; + GtkWidget *memo_table; + + EDayViewConfig *day_view_config; + EDayViewConfig *work_week_view_config; + EWeekViewConfig *week_view_config; + EWeekViewConfig *month_view_config; + ECalListViewConfig *list_view_config; + ECalendarTableConfig *task_table_config; + EMemoTableConfig *memo_table_config; + + GalViewInstance *view_instance; }; enum { PROP_0 }; +/* Used to indicate who has the focus within the calendar view. */ +typedef enum { + FOCUS_CALENDAR, + FOCUS_MEMO_TABLE, + FOCUS_TASK_TABLE, + FOCUS_OTHER +} FocusLocation; + static gpointer parent_class; +static void +cal_shell_content_changed_cb (ECalShellContent *cal_shell_content, + GalViewInstance *view_instance) +{ + EShellView *shell_view; + EShellContent *shell_content; + gchar *view_id; + + shell_content = E_SHELL_CONTENT (cal_shell_content); + shell_view = e_shell_content_get_shell_view (shell_content); + view_id = gal_view_instance_get_current_view_id (view_instance); + e_shell_view_set_view_id (shell_view, view_id); + g_free (view_id); +} + +static void +cal_shell_content_display_view_cb (ECalShellContent *cal_shell_content, + GalView *gal_view) +{ +} + +static FocusLocation +cal_shell_content_get_focus_location (ECalShellContent *cal_shell_content) +{ + GtkWidget *widget; + GnomeCalendar *calendar; + ECalendarTable *task_table; + EMemoTable *memo_table; + ETable *table; + ECalendarView *calendar_view; + + calendar = GNOME_CALENDAR (cal_shell_content->priv->calendar); + widget = gnome_calendar_get_current_view_widget (calendar); + + memo_table = E_MEMO_TABLE (cal_shell_content->priv->memo_table); + task_table = E_CALENDAR_TABLE (cal_shell_content->priv->task_table); + + table = e_memo_table_get_table (memo_table); + if (GTK_WIDGET_HAS_FOCUS (table->table_canvas)) + return FOCUS_MEMO_TABLE; + + table = e_calendar_table_get_table (task_table); + if (GTK_WIDGET_HAS_FOCUS (table->table_canvas)) + return FOCUS_TASK_TABLE; + + if (E_IS_DAY_VIEW (widget)) { + EDayView *view = E_DAY_VIEW (widget); + + if (GTK_WIDGET_HAS_FOCUS (view->top_canvas)) + return FOCUS_CALENDAR; + + if (GNOME_CANVAS (view->top_canvas)->focused_item != NULL) + return FOCUS_CALENDAR; + + if (GTK_WIDGET_HAS_FOCUS (view->main_canvas)) + return FOCUS_CALENDAR; + + if (GNOME_CANVAS (view->main_canvas)->focused_item != NULL) + return FOCUS_CALENDAR; + + } else if (E_IS_WEEK_VIEW (widget)) { + EWeekView *view = E_WEEK_VIEW (widget); + + if (GTK_WIDGET_HAS_FOCUS (view->main_canvas)) + return FOCUS_CALENDAR; + + if (GNOME_CANVAS (view->main_canvas)->focused_item != NULL) + return FOCUS_CALENDAR; + + } else if (E_IS_CAL_LIST_VIEW (widget)) { + ECalListView *view = E_CAL_LIST_VIEW (widget); + + table = e_table_scrolled_get_table (view->table_scrolled); + if (GTK_WIDGET_HAS_FOCUS (table)) + return FOCUS_CALENDAR; + } + + return FOCUS_OTHER; +} + static void cal_shell_content_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { } @@ -57,9 +165,9 @@ cal_shell_content_set_property (GObject *object, static void cal_shell_content_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { switch (property_id) { } @@ -74,6 +182,96 @@ cal_shell_content_dispose (GObject *object) priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (object); + if (priv->hpaned != NULL) { + g_object_unref (priv->hpaned); + priv->hpaned = NULL; + } + + if (priv->notebook != NULL) { + g_object_unref (priv->notebook); + priv->notebook = NULL; + } + + if (priv->vpaned != NULL) { + g_object_unref (priv->vpaned); + priv->vpaned = NULL; + } + + if (priv->day_view != NULL) { + g_object_unref (priv->day_view); + priv->day_view = NULL; + } + + if (priv->work_week_view != NULL) { + g_object_unref (priv->work_week_view); + priv->work_week_view = NULL; + } + + if (priv->week_view != NULL) { + g_object_unref (priv->week_view); + priv->week_view = NULL; + } + + if (priv->month_view != NULL) { + g_object_unref (priv->month_view); + priv->month_view = NULL; + } + + if (priv->list_view != NULL) { + g_object_unref (priv->list_view); + priv->list_view = NULL; + } + + if (priv->task_table != NULL) { + g_object_unref (priv->task_table); + priv->task_table = NULL; + } + + if (priv->memo_table != NULL) { + g_object_unref (priv->memo_table); + priv->memo_table = NULL; + } + + if (priv->day_view_config != NULL) { + g_object_unref (priv->day_view_config); + priv->day_view_config = NULL; + } + + if (priv->work_week_view_config != NULL) { + g_object_unref (priv->work_week_view_config); + priv->work_week_view_config = NULL; + } + + if (priv->week_view_config != NULL) { + g_object_unref (priv->week_view_config); + priv->week_view_config = NULL; + } + + if (priv->month_view_config != NULL) { + g_object_unref (priv->month_view_config); + priv->month_view_config = NULL; + } + + if (priv->list_view_config != NULL) { + g_object_unref (priv->list_view_config); + priv->list_view_config = NULL; + } + + if (priv->task_table_config != NULL) { + g_object_unref (priv->task_table_config); + priv->task_table_config = NULL; + } + + if (priv->memo_table_config != NULL) { + g_object_unref (priv->memo_table_config); + priv->memo_table_config = NULL; + } + + if (priv->view_instance != NULL) { + g_object_unref (priv->view_instance); + priv->view_instance = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -93,12 +291,217 @@ static void cal_shell_content_constructed (GObject *object) { ECalShellContentPrivate *priv; + ECalModelCalendar *cal_model; + EShellContent *shell-content; + EShellModule *shell_module; + EShellView *shell_view; + EShellViewClass *shell_view_class; + GalViewCollection *view_collection; + GalViewInstnace *view_instance; + GtkWidget *container; + GtkWidget *widget; + const gchar *config_dir; + gchar *filename; + gchar *markup; + gint page_num; priv = E_CAL_SHELL_CONTENT_GET_PRIVATE (object); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (parent_class)->constructed (object); + shell_content = E_SHELL_CONTENT (object); + shell_view = e_shell_content_get_shell_view (shell_content); + shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view); + view_collection = shell_view_class->view_collection; + + shell_module = e_shell_view_get_shell_module (shell_view); + config_dir = e_shell_module_get_config_dir (shell_module); + + /* Calendar model for the views. */ + cal_model = e_cal_model_calendar_new (); + e_cal_model_set_flags ( + E_CAL_MODEL (cal_model), + E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES); + + /* Build content widgets. */ + + container = GTK_WIDGET (object); + + /* FIXME Need to deal with saving and restoring the position. + * Month view has its own position. */ + widget = gtk_hpaned_new (); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->hpaned = g_object_ref (widget); + gtk_widget_show (widget); + + container = priv->hpaned; + + widget = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); + gtk_paned_pack1 (GTK_PANED (container), widget, FALSE, TRUE); + priv->notebook = g_object_ref (widget); + gtk_widget_show (widget); + + /* FIXME Need to deal with saving and restoring the position. + * Month view has its own position. */ + widget = gtk_vpaned_new (); + gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, TRUE); + priv->vpaned = g_object_ref (); + gtk_widget_show (widget); + + container = priv->notebook; + + /* Add views in the order defined by GnomeCalendarViewType, such + * that the notebook page number corresponds to the view type. + * The assertions below ensure that stays true. */ + + /* FIXME Need to establish a calendar and timezone first. */ + widget = e_day_view_new (E_CAL_MODEL (cal_model)); + e_calendar_view_set_calendar ( + E_CALENDAR_VIEW (widget), GNOME_CALENDAR (priv->calendar)); + e_calendar_view_set_timezone ( + E_CALENDAR_VIEW (widget), priv->timezone); + page_num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (widget)); + gtk_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL); + g_return_if_fail (page_num == GNOME_CAL_DAY_VIEW); + priv->day_view = g_object_ref (widget); + gtk_widget_show (widget); + + /* FIXME Need to establish a calendar and timezone first. */ + widget = e_day_view_new (E_CAL_MODEL (cal_model)); + e_day_view_set_work_week_view (E_DAY_VIEW (widget), TRUE); + e_day_view_set_days_shown (E_DAY_VIEW (widget), 5); + e_calendar_view_set_calendar ( + E_CALENDAR_VIEW (widget), GNOME_CALENDAR (priv->calendar)); + e_calendar_view_set_timezone ( + E_CALENDAR_VIEW (widget), priv->timezone); + page_num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (widget)); + gtk_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL); + g_return_if_fail (page_num == GNOME_CAL_WORK_WEEK_VIEW); + priv->work_week_view = g_object_ref (widget); + gtk_widget_show (widget); + + /* FIXME Need to establish a calendar and timezone first. */ + widget = e_week_view_new (E_CAL_MODEL (cal_model)); + e_calendar_view_set_calendar ( + E_CALENDAR_VIEW (widget), GNOME_CALENDAR (priv->calendar)); + e_calendar_view_set_timezone ( + E_CALENDAR_VIEW (widget), priv->timezone); + page_num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (widget)); + gtk_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL); + g_return_if_fail (page_num == GNOME_CAL_WEEK_VIEW); + priv->week_view = g_object_ref (widget); + gtk_widget_show (widget); + + /* FIXME Need to establish a calendar and timezone first. */ + widget = e_week_view_new (E_CAL_MODEL (cal_model)); + e_week_view_set_multi_week_view (E_WEEK_VIEW (widget), TRUE); + e_week_view_set_weeks_shown (E_WEEK_VIEW (widget), 6); + e_calendar_view_set_calendar ( + E_CALENDAR_VIEW (widget), GNOME_CALENDAR (priv->calendar)); + e_calendar_view_set_timezone ( + E_CALENDAR_VIEW (widget), priv->timezone); + page_num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (widget)); + gtk_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL); + g_return_if_fail (page_num == GNOME_CAL_MONTH_VIEW); + priv->month_view = g_object_ref (widget); + gtk_widget_show (widget); + + /* FIXME Need to establish a calendar and timezone first. */ + widget = e_cal_list_view_new (E_CAL_MODEL (cal_model)); + e_calendar_view_set_calendar ( + E_CALENDAR_VIEW (widget), GNOME_CALENDAR (priv->calendar)); + e_calendar_view_set_timezone ( + E_CALENDAR_VIEW (widget), priv->timezone); + page_num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (widget)); + gtk_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL); + g_return_if_fail (page_num == GNOME_CAL_LIST_VIEW); + priv->list_view = g_object_ref (widget); + gtk_widget_show (widget); + + container = priv->vpaned; + + widget = gtk_vbox_new (FALSE, 0); + gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, TRUE); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_hseparator_new (); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0); + gtk_widget_show (widget); + + widget = gtk_label_new (NULL); + markup = g_strdup_printf ("%s", _("Tasks")); + gtk_label_set_markup (GTK_LABEL (widget), markup); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0); + gtk_widget_show (widget); + g_free (markup); + + widget = e_calendar_table_new (); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + priv->task_table = g_object_ref (); + gtk_widget_show (widget); + + filename = g_build_filename (config_dir, "TaskPad", NULL); + e_calendar_table_load_state (E_CALENDAR_TABLE (widget), filename); + g_free (filename); + + container = priv->vpaned; + + widget = gtk_vbox_new (FALSE, 0); + gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, TRUE); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_label_new (NULL); + markup = g_strdup_printf ("%s", _("Memos")); + gtk_label_set_markup (GTK_LABEL (widget), markup); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0); + gtk_widget_show (widget); + g_free (markup); + + widget = e_memo_table_new (); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + priv->memo_table = g_object_ref (); + gtk_widget_show (widget); + + filename = g_build_filename (config_dir, "MemoPad", NULL); + e_memo_table_load_state (E_MEMO_TABLE (widget), filename); + g_free (filename); + + /* Configuration managers for views and tables. */ + priv->day_view_config = e_day_view_config_new ( + E_DAY_VIEW (priv->day_view)); + priv->work_week_view_config = e_day_view_config_new ( + E_DAY_VIEW (priv->work_week_view)); + priv->week_view_config = e_week_view_config_new ( + E_WEEK_VIEW (priv->week_view)); + priv->month_view_config = e_week_view_config_new ( + E_WEEK_VIEW (priv->month_view)); + priv->list_view_config = e_cal_list_view_config_new ( + E_CAL_LIST_VIEW (priv->list_view)); + priv->task_table_config = e_calendar_table_config_new ( + E_CALENDAR_TABLE (priv->task_table)); + priv->memo_table_config = e_memo_table_config_new ( + E_MEMO_TABLE (priv->memo_table)); + + /* Load the view instance. */ + + view_instance = gal_view_instance_new (view_collection, NULL); + g_signal_connect_swapped ( + view_instance, "changed", + G_CALLBACK (cal_shell_content_changed_cb), + object); + g_signal_connect_swapped ( + view_instance, "display-view", + G_CALLBACK (cal_shell_content_display_view_cb), + object); + gal_view_instance_load (view_instance); + priv->view_instance = view_instance; } static void @@ -162,3 +565,187 @@ e_cal_shell_content_new (EShellView *shell_view) E_TYPE_CAL_SHELL_CONTENT, "shell-view", shell_view, NULL); } + +GnomeCalendar * +e_cal_shell_content_get_calendar (ECalShellContent *cal_shell_content) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_CONTENT (cal_shell_content), NULL); + + return GNOME_CALENDAR (cal_shell_content->priv->calendar); +} + +EMemoTable * +e_cal_shell_content_get_memo_table (ECalShellContent *cal_shell_content) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_CONTENT (cal_shell_content), NULL); + + return E_MEMO_TABLE (cal_shell_content->priv->memo_table); +} + +ECalendarTable * +e_cal_shell_content_get_task_table (ECalShellContent *cal_shell_content) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_CONTENT (cal_shell_content), NULL); + + return E_CALENDAR_TABLE (cal_shell_content->priv->task_table); +} + +icaltimezone * +e_cal_shell_content_get_timezone (ECalShellContent *cal_shell_content) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_CONTENT (cal_shell_content), NULL); + + return cal_shell_content->priv->timezone; +} + +GalViewInstance * +e_cal_shell_content_get_view_instance (ECalShellContent *cal_shell_content) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_CONTENT (cal_shell_content), NULL); + + return cal_shell_content->priv->view_instance; +} + +void +e_cal_shell_content_copy_clipboard (ECalShellContent *cal_shell_content) +{ + GnomeCalendar *calendar; + EMemoTable *memo_table; + ECalendarTable *task_table; + + g_return_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content)); + + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + switch (cal_shell_content_get_focus_location (cal_shell_content)) { + case FOCUS_CALENDAR: + gnome_calendar_copy_clipboard (calendar); + break; + + case FOCUS_MEMO_TABLE: + e_memo_table_copy_clipboard (memo_table); + break; + + case FOCUS_TASK_TABLE: + e_calendar_table_copy_clipboard (task_table); + break; + + default: + g_return_if_reached (); + } +} + +void +e_cal_shell_content_cut_clipboard (ECalShellContent *cal_shell_content) +{ + GnomeCalendar *calendar; + EMemoTable *memo_table; + ECalendarTable *task_table; + + g_return_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content)); + + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + switch (cal_shell_content_get_focus_location (cal_shell_content)) { + case FOCUS_CALENDAR: + gnome_calendar_cut_clipboard (calendar); + break; + + case FOCUS_MEMO_TABLE: + e_memo_table_copy_clipboard (memo_table); + break; + + case FOCUS_TASK_TABLE: + e_calendar_table_copy_clipboard (task_table); + break; + + default: + g_return_if_reached (); + } +} + +void +e_cal_shell_content_paste_clipboard (ECalShellContent *cal_shell_content) +{ + GnomeCalendar *calendar; + EMemoTable *memo_table; + ECalendarTable *task_table; + + g_return_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content)); + + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + switch (cal_shell_content_get_focus_location (cal_shell_content)) { + case FOCUS_CALENDAR: + gnome_calendar_paste_clipboard (calendar); + break; + + case FOCUS_MEMO_TABLE: + e_memo_table_copy_clipboard (memo_table); + break; + + case FOCUS_TASK_TABLE: + e_calendar_table_copy_clipboard (task_table); + break; + + default: + g_return_if_reached (); + } +} + +void +e_cal_shell_content_delete_selection (ECalShellContent *cal_shell_content) +{ + GnomeCalendar *calendar; + EMemoTable *memo_table; + ECalendarTable *task_table; + + g_return_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content)); + + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + switch (cal_shell_content_get_focus_location (cal_shell_content)) { + case FOCUS_CALENDAR: + gnome_calendar_delete_selection (calendar); + break; + + case FOCUS_MEMO_TABLE: + e_memo_table_delete_selected (memo_table); + break; + + case FOCUS_TASK_TABLE: + e_calendar_table_delete_selected (task_table); + break; + + default: + g_return_if_reached (); + } +} + +void +e_cal_shell_content_delete_selected_occurrence (ECalShellContent *cal_shell_content) +{ + GnomeCalendar *calendar; + FocusLocation focus; + + g_return_if_fail (E_IS_CAL_SHELL_CONTENT (cal_shell_content)); + + focus = cal_shell_content_get_focus_location (cal_shell_content); + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + + if (focus == FOCUS_CALENDAR) + gnome_calendar_delete_selected_occurrence (calendar); +} diff --git a/calendar/modules/e-cal-shell-content.h b/calendar/modules/e-cal-shell-content.h index c7b78c52a4..5d8a56a185 100644 --- a/calendar/modules/e-cal-shell-content.h +++ b/calendar/modules/e-cal-shell-content.h @@ -25,6 +25,8 @@ #include #include +#include +#include #include /* Standard GObject macros */ @@ -63,9 +65,25 @@ struct _ECalShellContentClass { GType e_cal_shell_content_get_type (void); GtkWidget * e_cal_shell_content_new (EShellView *shell_view); +GnomeCalendar * e_cal_shell_content_get_calendar(ECalShellContent *cal_shell_content); +EMemoTable * e_cal_shell_content_get_memo_table + (ECalShellContent *cal_shell_content); +ECalendarTable *e_cal_shell_content_get_task_table + (ECalShellContent *cal_shell_content); +icaltimezone * e_cal_shell_content_get_timezone(ECalShellContent *cal_shell_content); GalViewInstance * e_cal_shell_content_get_view_instance (ECalShellContent *cal_shell_content); +void e_cal_shell_content_copy_clipboard + (ECalShellContent *cal_shell_content); +void e_cal_shell_content_cut_clipboard + (ECalShellContent *cal_shell_content); +void e_cal_shell_content_paste_clipboard + (ECalShellContent *cal_shell_content); +void e_cal_shell_content_delete_selection + (ECalShellContent *cal_shell_content); +void e_cal_shell_content_delete_selected_occurrence + (ECalShellContent *cal_shell_content); G_END_DECLS diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c index 17c4b2152b..88f743f1ee 100644 --- a/calendar/modules/e-cal-shell-module.c +++ b/calendar/modules/e-cal-shell-module.c @@ -307,10 +307,10 @@ cal_module_cal_opened_cb (ECal *cal, flags |= COMP_EDITOR_NEW_ITEM; flags |= COMP_EDITOR_USER_ORG; - if (strcmp (action_name, "meeting-new") == 0) + if (strcmp (action_name, "event-meeting-new") == 0) flags |= COMP_EDITOR_MEETING; - all_day = (strcmp (action_name, "appointment-all-day-new") == 0); + all_day = (strcmp (action_name, "event-all-day-new") == 0); editor = event_editor_new (cal, flags); comp = cal_comp_event_new_with_current_time (cal, all_day); @@ -372,21 +372,21 @@ action_calendar_new_cb (GtkAction *action, static GtkActionEntry item_entries[] = { - { "appointment-new", + { "event-new", "appointment-new", N_("_Appointment"), /* XXX Need C_() here */ "a", N_("Create a new appointment"), G_CALLBACK (action_event_new_cb) }, - { "appointment-all-day-new", + { "event-all-day-new", "stock_new-24h-appointment", N_("All Day A_ppointment"), NULL, N_("Create a new all-day appointment"), G_CALLBACK (action_event_new_cb) }, - { "meeting-new", + { "event-meeting-new", "stock_new-meeting", N_("M_eeting"), "e", @@ -450,10 +450,9 @@ e_shell_module_init (GTypeModule *type_module) shell_module = E_SHELL_MODULE (type_module); shell = e_shell_module_get_shell (shell_module); - /* Register the GType for ECalShellView. */ - e_cal_shell_view_get_type (type_module); - - e_shell_module_set_info (shell_module, &module_info); + e_shell_module_set_info ( + shell_module, &module_info, + e_cal_shell_view_get_type (type_module)); cal_module_ensure_sources (shell_module); diff --git a/calendar/modules/e-cal-shell-sidebar.c b/calendar/modules/e-cal-shell-sidebar.c index bbe0c15caf..707770df81 100644 --- a/calendar/modules/e-cal-shell-sidebar.c +++ b/calendar/modules/e-cal-shell-sidebar.c @@ -28,6 +28,7 @@ #include "calendar/common/authentication.h" #include "calendar/gui/calendar-config.h" #include "calendar/gui/e-calendar-selector.h" +#include "calendar/gui/e-mini-calendar-config.h" #include "calendar/gui/misc.h" #include "e-cal-shell-view.h" @@ -37,14 +38,19 @@ ((obj), E_TYPE_CAL_SHELL_SIDEBAR, ECalShellSidebarPrivate)) struct _ECalShellSidebarPrivate { + GtkWidget *paned; GtkWidget *selector; + GtkWidget *mini_calendar; /* UID -> Client */ GHashTable *client_table; + + EMiniCalendarConfig *mini_calendar_config; }; enum { PROP_0, + PROP_MINI_CALENDAR, PROP_SELECTOR }; @@ -85,33 +91,6 @@ cal_shell_sidebar_emit_status_message (ECalShellSidebar *cal_shell_sidebar, g_signal_emit (cal_shell_sidebar, signal_id, 0, status_message); } -static void -cal_shell_sidebar_update_timezone (ECalShellSidebar *cal_shell_sidebar) -{ - GHashTable *client_table; - icaltimezone *zone; - GList *values; - - zone = calendar_config_get_icaltimezone (); - client_table = cal_shell_sidebar->priv->client_table; - values = g_hash_table_get_values (client_table); - - while (values != NULL) { - ECal *client = values->data; - - if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) - e_cal_set_default_timezone (client, zone, NULL); - - values = g_list_delete_link (values, values); - } - - /* XXX Need to call e_calendar_view_set_timezone() here but the - * sidebar is not really supposed to access content stuff. - * I guess we could emit an "update-timezone" signal here, - * but that feels wrong. Maybe this whole thing should be - * in ECalShellView instead. */ -} - static void cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar, ECal *client) @@ -305,6 +284,12 @@ cal_shell_sidebar_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MINI_CALENDAR: + g_value_set_object ( + value, e_cal_shell_sidebar_get_mini_calendar ( + E_CAL_SHELL_SIDEBAR (object))); + return; + case PROP_SELECTOR: g_value_set_object ( value, e_cal_shell_sidebar_get_selector ( @@ -322,13 +307,28 @@ cal_shell_sidebar_dispose (GObject *object) priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (object); + if (priv->paned != NULL) { + g_object_unref (priv->paned); + priv->paned = NULL; + } + if (priv->selector != NULL) { g_object_unref (priv->selector); priv->selector = NULL; } + if (priv->mini_calendar != NULL) { + g_object_unref (priv->mini_calendar); + priv->mini_calendar = NULL; + } + g_hash_table_remove_all (priv->client_table); + if (priv->mini_calendar_config != NULL) { + g_object_unref (priv->mini_calendar_config); + priv->mini_calendar = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -356,9 +356,11 @@ cal_shell_sidebar_constructed (GObject *object) ESourceSelector *selector; ESourceList *source_list; ESource *source; - GtkContainer *container; + ECalendarItem *calitem; GtkTreeModel *model; + GtkWidget *container; GtkWidget *widget; + AtkObject *a11y; GSList *list, *iter; gchar *uid; @@ -372,7 +374,14 @@ cal_shell_sidebar_constructed (GObject *object) cal_shell_view = E_CAL_SHELL_VIEW (shell_view); source_list = e_cal_shell_view_get_source_list (cal_shell_view); - container = GTK_CONTAINER (shell_sidebar); + container = GTK_WIDGET (shell_sidebar); + + widget = gtk_vpaned_new (); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->paned = g_object_ref (widget); + gtk_widget_show (widget); + + container = widget; widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy ( @@ -380,17 +389,33 @@ cal_shell_sidebar_constructed (GObject *object) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - gtk_container_add (container, widget); + gtk_paned_add1 (GTK_PANED (container), widget); gtk_widget_show (widget); - container = GTK_CONTAINER (widget); + container = widget; widget = e_calendar_selector_new (source_list); e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); - gtk_container_add (container, widget); + gtk_container_add (GTK_CONTAINER (container), widget); + a11y = gtk_widget_get_accessible (widget); + atk_object_set_name (a11y, _("Calendar Selector")); priv->selector = g_object_ref (widget); gtk_widget_show (widget); + container = priv->paned; + + widget = e_calendar_new (); + calitem = E_CALENDAR (widget)->calitem; + e_calendar_item_set_days_start_week_sel (calitem, 9); + e_calendar_item_set_max_days_sel (calitem, 42); + widget = gnome_calendar_new (shell_view); + gtk_paned_add2 (GTK_PANED (container), widget); + priv->mini_calendar = g_object_ref (widget); + gtk_widget_show (widget); + + priv->mini_calendar_config = + e_mini_calendar_config_new (E_CALENDAR (widget)); + /* Restore the selector state from the last session. */ selector = E_SOURCE_SELECTOR (priv->selector); @@ -486,6 +511,16 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class) class->client_added = cal_shell_sidebar_client_added; class->client_removed = cal_shell_sidebar_client_removed; + g_object_class_install_property ( + object_class, + PROP_MINI_CALENDAR, + g_param_spec_object ( + "mini-calendar", + _("Mini-Calendar Widget"), + _("This widget displays a miniature calendar"), + E_TYPE_CALENDAR, + G_PARAM_READABLE)); + g_object_class_install_property ( object_class, PROP_SELECTOR, @@ -582,6 +617,15 @@ e_cal_shell_sidebar_new (EShellView *shell_view) "shell-view", shell_view, NULL); } +ECalendar * +e_cal_shell_sidebar_get_mini_calendar (ECalShellSidebar *cal_shell_sidebar) +{ + g_return_val_if_fail ( + E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar), NULL); + + return E_CALENDAR (cal_shell_sidebar->priv->mini_calendar); +} + ESourceSelector * e_cal_shell_sidebar_get_selector (ECalShellSidebar *cal_shell_sidebar) { @@ -666,3 +710,26 @@ e_cal_shell_sidebar_remove_source (ECalShellSidebar *cal_shell_sidebar, cal_shell_sidebar_emit_client_removed (cal_shell_sidebar, client); } + +void +e_cal_shell_sidebar_update_timezone (ECalShellSidebar *cal_shell_sidebar) +{ + GHashTable *client_table; + icaltimezone *timezone; + GList *values; + + g_return_if_fail (E_CAL_SHELL_SIDEBAR (cal_shell_sidebar)); + + timezone = calendar_config_get_icaltimezone (); + client_table = cal_shell_sidebar->priv->client_table; + values = g_hash_table_get_values (client_table); + + while (values != NULL) { + ECal *client = values->data; + + if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) + e_cal_set_default_timezone (client, timezone, NULL); + + values = g_list_delete_link (values, values); + } +} diff --git a/calendar/modules/e-cal-shell-sidebar.h b/calendar/modules/e-cal-shell-sidebar.h index 49b89c556e..eecb6a0365 100644 --- a/calendar/modules/e-cal-shell-sidebar.h +++ b/calendar/modules/e-cal-shell-sidebar.h @@ -27,6 +27,7 @@ #include #include +#include /* Standard GObject macros */ #define E_TYPE_CAL_SHELL_SIDEBAR \ @@ -72,6 +73,8 @@ struct _ECalShellSidebarClass { GType e_cal_shell_sidebar_get_type (void); GtkWidget * e_cal_shell_sidebar_new (EShellView *shell_view); +ECalendar * e_cal_shell_sidebar_get_mini_calendar + (ECalShellSidebar *cal_shell_sidebar); ESourceSelector * e_cal_shell_sidebar_get_selector(ECalShellSidebar *cal_shell_sidebar); void e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, @@ -79,6 +82,8 @@ void e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar, void e_cal_shell_sidebar_remove_source (ECalShellSidebar *cal_shell_sidebar, ESource *source); +void e_cal_shell_sidebar_update_timezone + (ECalShellSidebar *cal_shell_sidebar); G_END_DECLS diff --git a/calendar/modules/e-cal-shell-view-actions.c b/calendar/modules/e-cal-shell-view-actions.c index 18c740d28b..4e077b273f 100644 --- a/calendar/modules/e-cal-shell-view-actions.c +++ b/calendar/modules/e-cal-shell-view-actions.c @@ -25,48 +25,187 @@ static void action_calendar_copy_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellSidebar *cal_shell_sidebar; + EShellWindow *shell_window; + EShellView *shell_view; + ESourceSelector *selector; + ESource *source; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar; + selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (E_IS_SOURCE (source)); + + copy_source_dialog ( + GTK_WINDOW (shell_window), + source, E_CAL_SOURCE_TYPE_EVENT); } static void action_calendar_delete_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + ECalShellSidebar *cal_shell_sidebar; + EShellWindow *shell_window; + EShellView *shell_view; + ECalendarView *calendar_view; + GnomeCalendarViewType view_type; + ECalModel *model; + ESourceSelector *selector; + ESourceGroup *source_group; + ESourceList *source_list; + ESource *source; + gint response; + gchar *uri; + GError *error = NULL; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + cal_shell_content = cal_shell_content->priv->cal_shell_content; + view_type = e_cal_shell_content_get_current_view (cal_shell_content); + calendar_view = e_cal_shell_content_get_calendar_view ( + cal_shell_content, view_type); + model = e_calendar_view_get_model (calendar_view); + + cal_shell_sidebar = cal_shell_sidebar->priv->cal_shell_sidebar; + selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (E_IS_SOURCE (source)); + + /* Ask for confirmation. */ + response = e_error_run ( + GTK_WINDOW (shell_window), + "calendar:prompt-delete-calendar", + e_source_peek_name (source)); + if (response != GTK_RESPONSE_YES) + return; + + uri = e_source_get_uri (source); + client = e_cal_model_get_client_for_uri (model, uri); + if (client == NULL) + client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_EVENT); + g_free (uri); + + g_return_if_fail (client != NULL); + + if (!e_cal_remove (client, &error)) { + g_warning ("%s", error->message); + g_error_free (error); + return; + } + + if (e_source_selector_source_is_selected (selector, source)) { + e_cal_shell_sidebar_remove_source ( + cal_shell_sidebar, source); + e_source_selector_unselect_source (selector, source); + } + + source_group = e_source_peek_group (source); + e_source_group_remove_source (source_group, source); + + source_list = cal_shell_view->priv->source_list; + if (!e_source_list_sync (source_list, &error)) { + g_warning ("%s", error->message); + g_error_free (error); + } } static void action_calendar_go_back_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + calendar = e_shell_content_get_calendar (cal_shell_content); + + gnome_claendar_previous (calendar); } static void action_calendar_go_forward_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + calendar = e_shell_content_get_calendar (cal_shell_content); + + gnome_calendar_next (calendar); } static void action_calendar_go_today_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + + gnome_calendar_goto_today (calendar); } static void action_calendar_jump_to_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + + goto_dialog (calendar); } static void action_calendar_new_cb (GtkAction *action, ECalShellView *cal_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + calendar_setup_new_calendar (GTK_WINDOW (shell_window)); } static void action_calendar_print_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + GtkPrintOperationAction print_action; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; + + if (gnome_calendar_get_view (calendar) == GNOME_CAL_LIST_VIEW) { + ECalListView *list_view; + GtkWidget *widget; + ETable *table; + + widget = gnome_calendar_get_current_view_widget (calendar); + list_view = E_CAL_LIST_VIEW (widget); + table = e_table_scrolled_get_table (list_view->table_scrolled); + print_table (table, _("Print"), _("Calendar"), action); + } else { + time_t start; + + gnome_calendar_get_current_time_range (calendar, &start, NULL); + print_calendar (calendar, action, start); + } } static void @@ -74,17 +213,56 @@ action_calendar_print_preview_cb (GtkAction *action, ECalShellView *cal_shell_view) { } + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + GtkPrintOperationAction print_action; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW; + + if (gnome_calendar_get_view (calendar) == GNOME_CAL_LIST_VIEW) { + ECalListView *list_view; + GtkWidget *widget; + ETable *table; + + widget = gnome_calendar_get_current_view_widget (calendar); + list_view = E_CAL_LIST_VIEW (widget); + table = e_table_scrolled_get_table (list_view->table_scrolled); + print_table (table, _("Print"), _("Calendar"), action); + } else { + time_t start; + + gnome_calendar_get_current_time_range (calendar, &start, NULL); + print_calendar (calendar, action, start); + } static void action_calendar_properties_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellSidebar *cal_shell_sidebar; + EShellView *shell_view; + EShellWindow *shell_window; + ESource *source; + ESourceSelector *selector; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar; + selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (E_IS_SOURCE (source)); + + calendar_setup_edit_calendar (GTK_WINDOW (shell_window), source); } static void action_calendar_purge_cb (GtkAction *action, ECalShellView *cal_shell_view) { + /* FIXME */ } static void @@ -92,48 +270,230 @@ action_calendar_view_cb (GtkRadioAction *action, GtkRadioAction *current, ECalShellView *cal_shell_view) { + EShellView *shell_view; + GnomeCalendarViewType view_type; + const gchar *view_id; + + shell_view = E_SHELL_VIEW (cal_shell_view); + view_type = gtk_radio_action_get_current_value (action); + + switch (view_type) { + case GNOME_CAL_DAY_VIEW: + view_id = "Day_View"; + break; + + case GNOME_CAL_WORK_WEEK_VIEW: + view_id = "Work_Week_View"; + break; + + case GNOME_CAL_WEEK_VIEW: + view_id = "Week_View"; + break; + + case GNOME_CAL_MONTH_VIEW: + view_id = "Month_View"; + break; + + case GNOME_CAL_LIST_VIEW: + view_id = "List_View"; + break; + + default: + g_return_if_reached (); + } + + e_shell_view_set_view_id (shell_view, view_id); } static void action_event_clipboard_copy_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + e_cal_shell_content_copy_clipboard (cal_shell_content); } static void action_event_clipboard_cut_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + e_cal_shell_content_cut_clipboard (cal_shell_content); } static void action_event_clipboard_paste_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + e_cal_shell_content_paste_clipboard (cal_shell_content); +} + +static void +action_event_copy_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_event_delegate_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ } static void action_event_delete_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + + cal_shell_content = cal_shell-view->priv->cal_shell_content; + e_cal_shell_content_delete_selection (cal_shell_content); } static void action_event_delete_occurrence_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + e_cal_shell_content_delete_selected_occurrence (cal_shell_content); } static void action_event_delete_occurrence_all_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + + /* XXX Same as "event-delete". */ + cal_shell_content = cal_shell_view->priv->cal_shell_content; + e_cal_shell_content_delete_selection (cal_shell_content); +} + +static void +action_event_forward_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_event_move_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_event_occurrence_movable_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ } static void action_event_open_cb (GtkAction *action, ECalShellView *cal_shell_view) { + ECalShellContent *cal_shell_content; + GnomeCalendar *calendar; + GtkWidget *widget; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + widget = gnome_calendar_get_current_view_widget (calendar); + + e_calendar_view_open_event (E_CALENDAR_VIEW (widget)); +} + +static void +action_event_print_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_event_reply_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_event_reply_all_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_event_save_as_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_event_schedule_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + /* FIXME */ +} + +static void +action_gal_save_custom_view_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EShellView *shell_view; + GalViewInstance *view_instance; + + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with saving the custom view. */ + shell_view = E_SHELL_VIEW (cal_shell_view); + if (!e_shell_view_is_active (shell_view)) + return; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + view_instance = e_cal_shell_content_get_view_instance (cal_shell_content); + gal_view_instance_save_as (view_instance); +} + +static void +action_search_execute_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + EShellView *shell_view; + + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with executing the search. */ + shell_view = E_SHELL_VIEW (cal_shell_view); + if (!e_shell_view_is_active (shell_view)) + return; + + e_cal_shell_view_execute_search (cal_shell_view); +} + +static void +action_search_filter_cb (GtkRadioAction *action, + GtkRadioAction *current, + ECalShellView *cal_shell_view) +{ + e_cal_shell_view_execute_search (cal_shell_view); } static GtkActionEntry calendar_entries[] = { @@ -236,6 +596,20 @@ static GtkActionEntry calendar_entries[] = { N_("Paste the clipboard"), G_CALLBACK (action_event_clipboard_paste_cb) }, + { "event-copy", + NULL, + N_("Cop_y to Calendar..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_copy_cb) }, + + { "event-delegate", + NULL, + N_("_Delegate Meeting..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_delegate_cb) }, + { "event-delete", GTK_STOCK_DELETE, NULL, @@ -257,12 +631,89 @@ static GtkActionEntry calendar_entries[] = { N_("Delete all occurrences"), G_CALLBACK (action_event_delete_occurrence_all_cb) }, + { "event-all-day-new", + NULL, + N_("New All Day _Event..."), + NULL, + N_("Create a new all day event"), + G_CALLBACK (action_event_all_day_new_cb) }, + + { "event-forward", + "mail-forward", + N_("_Forward as iCalendar..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_forward_new_cb) }, + + { "event-meeting-new", + NULL, + N_("New _Meeting..."), + NULL, + N_("Create a new meeting"), + G_CALLBACK (action_event_meeting_new_cb) }, + + { "event-move", + NULL, + N_("Mo_ve to Calendar..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_move_cb) }, + + { "event-new", + NULL, + N_("New _Appointment..."), + NULL, + N_("Create a new appointment"), + G_CALLBACK (action_event_new_cb) }, + + { "event-occurrence-movable", + NULL, + N_("Make this Occurrence _Movable"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_occurrence_movable_cb) }, + { "event-open", NULL, N_("_Open Appointment"), "o", N_("View the current appointment"), - G_CALLBACK (action_event_open_cb) } + G_CALLBACK (action_event_open_cb) }, + + { "event-print", + GTK_STOCK_PRINT, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_print_cb) }, + + { "event-reply", + "mail-reply-sender", + N_("_Reply"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_reply_cb) }, + + { "event-reply-all", + "mail-reply-all", + N_("Reply to _All"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_reply_all_cb) }, + + { "event-save-as", + GTK_STOCK_SAVE_AS, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_save_as_cb) }, + + { "event-schedule", + NULL, + N_("_Schedule Meeting..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_event_schedule_cb) } }; static GtkRadioActionEntry calendar_view_entries[] = { @@ -303,22 +754,76 @@ static GtkRadioActionEntry calendar_view_entries[] = { GNOME_CAL_WORK_WEEK_VIEW } }; +static GtkRadioActionEntry calendar_filter_entries[] = { + + { "calendar-filter-active-appointments", + NULL, + N_("Active Appointements"), + NULL, + NULL, /* XXX Add a tooltip! */ + CALENDAR_FILTER_ACTIVE_APPOINTMENTS }, + + { "calendar-filter-any-category", + NULL, + N_("Any Category"), + NULL, + NULL, /* XXX Add a tooltip! */ + CALENDAR_FILTER_ANY_CATEGORY }, + + { "calendar-filter-next-7-days-appointments", + NULL, + N_("Next 7 Days' Appointments"), + NULL, + NULL, /* XXX Add a tooltip! */ + CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS }, + + { "calendar-filter-unmatched", + NULL, + N_("Unmatched"), + NULL, + NULL, /* XXX Add a tooltip! */ + CALENDAR_FILTER_UNMATCHED } +}; + +static GtkRadioActionEntry calendar_search_entries[] = { + + { "calendar-search-any-field-contains", + NULL, + N_("Any field contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + CALENDAR_SEARCH_ANY_FIELD_CONTAINS }, + + { "calendar-search-description-contains", + NULL, + N_("Description contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + CALENDAR_SEARCH_DESCRIPTION_CONTAINS }, + + { "calendar-search-summary-contains", + NULL, + N_("Summary contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + CALENDAR_SEARCH_SUMMARY_CONTAINS } +}; + void e_cal_shell_view_actions_init (ECalShellView *cal_shell_view) { EShellView *shell_view; EShellWindow *shell_window; GtkActionGroup *action_group; - GtkUIManager *manager; + GtkUIManager *ui_manager; + GtkAction *action; const gchar *domain; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - manager = e_shell_window_get_ui_manager (shell_window); + ui_manager = e_shell_window_get_ui_manager (shell_window); domain = GETTEXT_PACKAGE; - e_load_ui_definition (manager, "evolution-calendars.ui"); - action_group = cal_shell_view->priv->calendar_actions; gtk_action_group_set_translation_domain (action_group, domain); gtk_action_group_add_actions ( @@ -328,5 +833,92 @@ e_cal_shell_view_actions_init (ECalShellView *cal_shell_view) action_group, calendar_view_entries, G_N_ELEMENTS (calendar_view_entries), GNOME_CAL_DAY_VIEW, G_CALLBACK (action_calendar_view_cb), cal_shell_view); - gtk_ui_manager_insert_action_group (manager, action_group, 0); + gtk_action_group_add_radio_actions ( + action_group, calendar_search_entries, + G_N_ELEMENTS (calendar_search_entries), + CALENDAR_SEARCH_SUMMARY_CONTAINS, + NULL, NULL); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + /* Fine tuning. */ + + action = ACTION (EVENT_DELETE); + g_object_set (action, "short-label", _("Delete"), NULL); + + g_signal_connect ( + ACTION (GAL_SAVE_CUSTOM_VIEW), "activate", + G_CALLBACK (action_gal_save_custom_view_cb), cal_shell_view); + + g_signal_connect ( + ACTION (SEARCH_EXECUTE), "activate", + G_CALLBACK (action_search_execute_cb), cal_shell_view); + + /* Initialize the memo and task pad actions. */ + e_cal_shell_view_memopad_actions_init (cal_shell_view); + e_cal_shell_view_taskpad_actions_init (cal_shell_view); +} + +void +e_cal_shell_view_update_search_filter (ECalShellView *cal_shell_view) +{ + EShellContent *shell_content; + EShellView *shell_view; + GtkActionGroup *action_group; + GtkRadioAction *radio_action; + GList *list, *iter; + GSList *group; + gint ii; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + action_group = cal_shell_view->priv->filter_actions; + + e_action_group_remove_all_actions (action_group); + + /* Add the standard filter actions. */ + gtk_action_group_add_radio_actions ( + action_group, calendar_filter_entries, + G_N_ELEMENTS (calendar_filter_entries), + CALENDAR_FILTER_ANY_CATEGORY, + G_CALLBACK (action_search_filter_cb), + cal_shell_view); + + /* Retrieve the radio group from an action we just added. */ + list = gtk_action_group_list_actions (action_group); + radio_action = GTK_RADIO_ACTION (list->data); + group = gtk_radio_action_get_group (radio_action); + g_list_free (list); + + /* Build the category actions. */ + + list = e_categories_get_list (); + for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) { + const gchar *category_name = iter->data; + GtkAction *action; + gchar *action_name; + + action_name = g_strdup_printf ( + "calendar-filter-category-%d", ii); + radio_action = gtk_radio_action_new ( + action_name, category_name, NULL, NULL, ii); + g_free (action_name); + + gtk_radio_action_set_group (radio_action, group); + group = gtk_radio_action_get_group (radio_action); + + /* The action group takes ownership of the action. */ + action = GTK_ACTION (radio_action); + gtk_action_group_add_action (action_group, action); + g_object_unref (radio_action); + } + g_list_free (list); + + /* Use any action in the group; doesn't matter which. */ + e_shell_content_set_filter_action (shell_content, radio_action); + + ii = CALENDAR_FILTER_UNMATCHED; + e_shell_content_add_filter_separator_after (shell_content, ii); + + ii = CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS; + e_shell_content_add_filter_separator_after (shell_content, ii); } diff --git a/calendar/modules/e-cal-shell-view-actions.h b/calendar/modules/e-cal-shell-view-actions.h index 6436a26b97..c682b22190 100644 --- a/calendar/modules/e-cal-shell-view-actions.h +++ b/calendar/modules/e-cal-shell-view-actions.h @@ -74,6 +74,72 @@ #define E_SHELL_WINDOW_ACTION_EVENT_OPEN(window) \ E_SHELL_WINDOW_ACTION ((window), "event-open") +/* Memo Pad Actions */ +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_CLIPBOARD_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-clipboard-copy") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_CLIPBOARD_CUT(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-clipboard-cut") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_CLIPBOARD_PASTE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-clipboard-paste") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-delete") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_FORWARD(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-forward") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-new") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_OPEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-open") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_OPEN_URL(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-open-url") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_PRINT(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-print") +#define E_SHELL_WINDOW_ACTION_CALENDAR_MEMOPAD_SAVE_AS(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-memopad-save-as") + +/* Task Pad Actions */ +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_ASSIGN(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-assign") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_CLIPBOARD_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-clipboard-copy") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_CLIPBOARD_CUT(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-clipboard-cut") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_CLIPBOARD_PASTE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-clipboard-paste") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-delete") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_FORWARD(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-forward") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_MARK_COMPLETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-mark-complete") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_MARK_INCOMPLETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-mark-incomplete") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-new") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_OPEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-open") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_OPEN_URL(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-open-url") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_PRINT(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-print") +#define E_SHELL_WINDOW_ACTION_CALENDAR_TASKPAD_SAVE_AS(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-taskpad-save-as") + +/* Calendar Query Actions */ +#define E_SHELL_WINDOW_ACTION_CALENDAR_FILTER_ACTIVE_APPOINTMENTS(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-filter-active-appointments") +#define E_SHELL_WINDOW_ACTION_CALENDAR_FILTER_ANY_CATEGORY(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-filter-any-category") +#define E_SHELL_WINDOW_ACTION_CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-filter-next-7-days-appointments") +#define E_SHELL_WINDOW_ACTION_CALENDAR_FILTER_UNMATCHED(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-filter-unmatched") +#define E_SHELL_WINDOW_ACTION_CALENDAR_SEARCH_ANY_FIELD_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-search-any-field-contains") +#define E_SHELL_WINDOW_ACTION_CALENDAR_SEARCH_DESCRIPTION_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-search-description-contains") +#define E_SHELL_WINDOW_ACTION_CALENDAR_SEARCH_SUMMARY_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-search-summary-contains") + /* Action Groups */ #define E_SHELL_WINDOW_ACTION_GROUP_CALS(window) \ E_SHELL_WINDOW_ACTION_GROUP ((window), "calendars") diff --git a/calendar/modules/e-cal-shell-view-memopad.c b/calendar/modules/e-cal-shell-view-memopad.c new file mode 100644 index 0000000000..ff9c235062 --- /dev/null +++ b/calendar/modules/e-cal-shell-view-memopad.c @@ -0,0 +1,472 @@ +/* + * e-cal-shell-view-memopad.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-cal-shell-view-private.h" + +/* Much of this file is based on e-memo-shell-view-actions.c. */ + +static void +action_calendar_memopad_clipboard_copy_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + e_memo_table_copy_clipboard (memo_table); +} + +static void +action_calendar_memopad_clipboard_cut_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + e_memo_table_cut_clipboard (memo_table); +} + +static void +action_calendar_memopad_clipboard_paste_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + e_memo_table_paste_clipboard (memo_table); +} + +static void +action_calendar_memopad_delete_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + const gchar *status_message; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + status_message = _("Deleting selected memos..."); + e_cal_shell_view_set_status_message (cal_shell_view, status_message); + e_memo_table_delete_selected (memo_table); + e_cal_shell_view_set_status_message (cal_shell_view, NULL); +} + +static void +action_calendar_memopad_forward_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + ECalComponentItipMethod method; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only forward the first selected memo. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + method = E_CAL_COMPONENT_METHOD_PUBLISH; + e_cal_component_set_icalcomponent (comp, clone); + itip_send_comp (method, comp, comp_data->client, NULL, NULL, NULL); + g_object_unref (comp); +} + +static void +action_calendar_memopad_new_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + ECal *client; + ECalComponent *comp; + CompEditor *editor; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + client = comp_data->client; + editor = memo_editor_new (client, COMP_EDITOR_NEW_ITEM); + comp = cal_comp_memo_new_with_defaults (client); + comp_editor_edit_comp (editor, comp); + + gtk_window_present (GTK_WINDOW (editor)); + + g_object_unref (comp); + g_object_unref (client); +} + +static void +action_calendar_memopad_open_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only open the first selected memo. */ + e_cal_shell_view_memopad_open_memo (cal_shell_view, comp_data); +} + +static void +action_calendar_memopad_open_url_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + icalproperty *prop; + GdkScreen *screen; + const gchar *uri; + GSList *list; + GError *error = NULL; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only open the URI of the first selected memo. */ + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_URL_PROPERTY); + g_return_if_fail (prop == NULL); + + screen = gtk_widget_get_screen (GTK_WIDGET (cal_shell_view)); + uri = icalproperty_get_url (prop); + gtk_show_uri (screen, uri, GDK_CURRENT_TIME, &error); + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } +} + +static void +action_calendar_memopad_print_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + GtkPrintOperationAction print_action; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only print the first selected memo. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; + e_cal_component_set_icalcomponent (comp, clone); + print_comp (comp, comp_data->client, print_action); + g_object_unref (comp); +} + +static void +action_calendar_memopad_save_as_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + GSList *list; + gchar *filename; + gchar *string; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + filename = e_file_dialog_save (_("Save as..."), NULL); + if (filename == NULL) + return; + + /* XXX We only save the first selected memo. */ + string = e_cal_get_component_as_string ( + comp_data->client, comp_data->icalcomp); + if (string == NULL) { + g_warning ("Could not convert memo to a string."); + return; + } + + e_write_file_uri (filename, string); + + g_free (filename); + g_free (string); +} + +static GtkActionEntry calendar_memopad_entries[] = { + + { "calendar-memopad-clipboard-copy", + GTK_STOCK_COPY, + NULL, + NULL, + N_("Copy selected memo"), + G_CALLBACK (action_calendar_memopad_clipboard_copy_cb) }, + + { "calendar-memopad-clipboard-cut", + GTK_STOCK_CUT, + NULL, + NULL, + N_("Cut selected memo"), + G_CALLBACK (action_calendar_memopad_clipboard_cut_cb) }, + + { "calendar-memopad-clipboard-paste", + GTK_STOCK_PASTE, + NULL, + NULL, + N_("Paste memo from the clipboard"), + G_CALLBACK (action_calendar_memopad_clipboard_paste_cb) }, + + { "calendar-memopad-delete", + GTK_STOCK_DELETE, + N_("_Delete Memo"), + NULL, + N_("Delete selected memos"), + G_CALLBACK (action_calendar_memopad_delete_cb) }, + + { "calendar-memopad-forward", + "mail-forward", + N_("_Forward as iCalendar..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_memopad_forward_cb) }, + + { "calendar-memopad-new", + "stock_insert-note", + N_("New _Memo"), + NULL, + N_("Create a new memo"), + G_CALLBACK (action_calendar_memopad_new_cb) }, + + { "calendar-memopad-open", + GTK_STOCK_OPEN, + N_("_Open Memo"), + NULL, + N_("View the selected memo"), + G_CALLBACK (action_calendar_memopad_open_cb) }, + + { "calendar-memopad-open-url", + "applications-internet", + N_("Open _Web Page"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_memopad_open_url_cb) }, + + { "calendar-memopad-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print the selected memo"), + G_CALLBACK (action_calendar_memopad_print_cb) }, + + { "calendar-memopad-save-as", + GTK_STOCK_SAVE_AS, + NULL, + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_memopad_save_as_cb) } +}; + +void +e_cal_shell_view_memopad_actions_init (ECalShellView *cal_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + ui_manager = e_shell_window_get_ui_manager (shell_window); + + action_group = cal_shell_view->priv->calendar_actions; + gtk_action_group_add_actions ( + action_group, calendar_memopad_entries, + G_N_ELEMENTS (calendar_memopad_entries), cal_shell_view); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); +} + +void +e_cal_shell_view_memopad_actions_update (ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EShellWindow *shell_window; + EShellView *shell_view; + EMemoTable *memo_table; + ETable *table; + GtkAction *action; + GSList *list, *iter; + const gchar *label; + gboolean editable = TRUE; + gboolean has_url = FALSE; + gboolean sensitive; + gint n_selected; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); + + table = e_memo_table_get_table (memo_table); + n_selected = e_table_selected_count (table); + + list = e_memo_table_get_selected (memo_table); + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + icalproperty *prop; + gboolean read_only; + + e_cal_is_read_only (comp_data->client, &read_only, NULL); + editable &= !read_only; + + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_URL_PROPERTY); + has_url |= (prop != NULL); + } + g_slist_free (list); + + action = ACTION (CALENDAR_MEMOPAD_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_MEMOPAD_CLIPBOARD_CUT); + sensitive = (n_selected > 0) && editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_MEMOPAD_CLIPBOARD_PASTE); + sensitive = editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_MEMOPAD_DELETE); + sensitive = (n_selected > 0) && editable; + gtk_action_set_sensitive (action, sensitive); + label = ngettext ("Delete Memo", "Delete Memos", n_selected); + g_object_set (action, "label", label, NULL); + + action = ACTION (CALENDAR_MEMOPAD_FORWARD); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_MEMOPAD_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_MEMOPAD_OPEN_URL); + sensitive = (n_selected == 1) && has_url; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_MEMOPAD_PRINT); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_MEMOPAD_SAVE_AS); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); +} + +void +e_cal_shell_view_memopad_open_memo (ECalShellView *cal_shell_view, + ECalModelComponent *comp_data) +{ + CompEditor *editor; + CompEditorFlags flags = 0; + ECalComponent *comp; + icalcomponent *clone; + const gchar *uid; + + g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view)); + g_return_if_fail (E_IS_CAL_MODEL_COMPONENT (comp_data)); + + uid = icalcomponent_get_uid (comp_data->icalcomp); + editor = comp_editor_find_instance (uid); + + if (editor != NULL) + goto exit; + + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + e_cal_component_set_icalcomponent (comp, clone); + + if (e_cal_component_has_organizer (comp)) + flags |= COMP_EDITOR_IS_SHARED; + + if (itip_organizer_is_user (comp, comp_data->client)) + flags |= COMP_EDITOR_USER_ORG; + + editor = memo_editor_new (comp_data->client, flags); + comp_editor_edit_comp (editor, comp); + + g_object_unref (comp); + +exit: + gtk_window_present (GTK_WINDOW (editor)); +} diff --git a/calendar/modules/e-cal-shell-view-private.c b/calendar/modules/e-cal-shell-view-private.c index 9107aee1fa..65be70ae93 100644 --- a/calendar/modules/e-cal-shell-view-private.c +++ b/calendar/modules/e-cal-shell-view-private.c @@ -24,6 +24,104 @@ #include "calendar/gui/calendar-view-factory.h" #include "widgets/menus/gal-view-factory-etable.h" +static void +cal_shell_view_update_timezone (ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalShellSidebar *cal_shell_sidebar; + GnomeCalendarViewType view_type; + ECalendarView *calendar_view; + icaltimezone *timezone; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar; + + e_cal_shell_sidebar_update_timezone (cal_shell_sidebar); + + view_type = e_cal_shell_content_get_current_view (cal_shell_content); + calendar_view = e_cal_shell_content_get_calendar_view ( + cal_shell_content, view_type); + + timezone = calendar_config_get_icaltimezone (); + e_calendar_view_get_icaltimezone (calendar_view, timezone); +} + +static void +cal_shell_view_timezone_changed_cb (GConfClient *client, + guint id, + GConfEntry *entry, + gpointer user_data) +{ + ECalShellView *cal_shell_view = user_data; + + cal_shell_view_update_timezone (cal_shell_view); +} + +static struct tm +cal_shell_view_get_current_time (ECalendarItem *calitem, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + struct icaltimetype tt; + icaltimezone *timezone; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + timezone = e_cal_shell_content_get_timezone (cal_shell_content); + + tt = icaltime_from_timet_with_zone (time (NULL), FALSE, timezone); + + return icaltimetype_to_tm (&tt); +} + +static void +cal_shell_view_mini_calendar_date_range_changed_cb (ECalShellView *cal_shell_view, + ECalendarItem *calitem) +{ + /* FIXME gnome-calendar.c calls update_query() here. */ +} + +static void +cal_shell_view_mini_calendar_selection_changed_cb (ECalShellView *cal_shell_view, + ECalendarItem *calitem) +{ + /* FIXME */ +} + +static void +cal_shell_view_mini_calendar_scroll_event_cb (ECalShellView *cal_shell_view, + GdkEventScroll *event, + ECalendar *mini_calendar) +{ + ECalendarItem *calitem; + GDate start_date, end_date; + + calitem = mini_calendar->calitem; + if (!e_calendar_item_get_selection (calitem, &start_date, &end_date)) + return; + + switch (event->direction) { + case GDK_SCROLL_UP: + g_date_subtract_months (&start_date, 1); + g_date_subtract_months (&end_date, 1); + break; + + case GDK_SCROLL_DOWN: + g_date_add_months (&start_date, 1); + g_date_add_months (&end_date, 1); + break; + + default: + g_return_if_reached (); + } + + /* XXX Does ECalendarItem emit a signal for this? If so, maybe + * we could move this handler into ECalShellSidebar. */ + e_calendar_item_set_selection (calitem, &start_date, &end_date); + + cal_shell_view_mini_calendar_date_range_changed_cb ( + cal_shell_view, calitem); +} + static void cal_shell_view_load_view_collection (EShellViewClass *shell_view_class) { @@ -104,6 +202,7 @@ e_cal_shell_view_private_init (ECalShellView *cal_shell_view, priv->source_list = g_object_ref (source_list); priv->calendar_actions = gtk_action_group_new ("calendars"); + priv->filter_actions = gtk_action_group_new ("calendars-filter"); if (!gal_view_collection_loaded (shell_view_class->view_collection)) cal_shell_view_load_view_collection (shell_view_class); @@ -117,10 +216,14 @@ void e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) { ECalShellViewPrivate *priv = cal_shell_view->priv; + ECalShellContent *cal_shell_content; + ECalShellSidebar *cal_shell_sidebar; EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellView *shell_view; GnomeCalendar *calendar; + ECalendar *mini_calendar; + guint notification; shell_view = E_SHELL_VIEW (cal_shell_view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -130,13 +233,44 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view) priv->cal_shell_content = g_object_ref (shell_content); priv->cal_shell_sidebar = g_object_ref (shell_sidebar); - calendar = e_cal_shell_view_get_calendar (cal_shell_view); + cal_shell_content = E_CAL_SHELL_CONTENT (shell_content); + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + + cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar); + mini_calendar = e_cal_shell_sidebar_get_mini_calendar (cal_shell_sidebar); + + e_calendar_item_set_get_time_callback ( + mini_calendar->calitem, (ECalendarItemGetTimeCallback) + cal_shell_view_get_current_time, cal_shell_view, NULL); g_signal_connect_swapped ( calendar, "dates-shown-changed", G_CALLBACK (e_cal_shell_view_update_sidebar), cal_shell_view); + g_signal_connect_swapped ( + mini_calendar, "scroll-event", + G_CALLBACK (cal_shell_view_mini_calendar_scroll_event_cb), + cal_shell_view); + + g_signal_connect_swapped ( + mini_calendar->calitem, "date-range-changed", + G_CALLBACK (cal_shell_view_mini_calendar_date_range_changed_cb), + cal_shell_view); + + g_signal_connect_swapped ( + mini_calendar->calitem, "selection-changed", + G_CALLBACK (cal_shell_view_mini_calendar_selection_changed_cb), + cal_shell_view); + + /* Listen for configuration changes. */ + + notification = calendar_config_add_notification_timezone ( + cal_shell_view_timezone_changed_cb, cal_shell_view); + priv->notifications = g_list_prepend ( + priv->notifications, GUINT_TO_POINTER (notification)); + cal_shell_view_update_timezone (cal_shell_view); + e_shell_view_update_actions (shell_view); e_cal_shell_view_update_sidebar (cal_shell_view); } @@ -149,6 +283,7 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view) DISPOSE (priv->source_list); DISPOSE (priv->calendar_actions); + DISPOSE (priv->filter_actions); DISPOSE (priv->cal_shell_content); DISPOSE (priv->cal_shell_sidebar); @@ -167,6 +302,53 @@ e_cal_shell_view_private_finalize (ECalShellView *cal_shell_view) /* XXX Nothing to do? */ } +void +e_cal_shell_view_open_event (ECalShellView *cal_shell_view, + ECalModelComponent *comp_data) +{ + CompEditor *editor; + CompEditorFlags flags = 0; + ECalComponent *comp; + icalcomponent *clone; + icalproperty *prop; + const gchar *uid; + + g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view)); + g_return_if_fail (E_IS_CAL_MODEL_COMPONENT (comp_data)); + + uid = icalcomponent_get_uid (comp_data->icalcomp); + editor = comp_editor_find_instance (uid); + + if (editor != NULL) + goto exit; + + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + e_cal_component_set_icalcomponent (comp, clone); + + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY); + if (prop != NULL) + flags |= COMP_EDITOR_MEETING; + + if (itip_organizer_is_user (comp, comp_data->client)) + flags |= COMP_EDITOR_USER_ORG; + + if (itip_sentby_is_user (comp)) + flags |= COMP_EDITOR_USER_ORG; + + if (!e_cal_component_has_attendees (comp)) + flags |= COMP_EDITOR_USER_ORG; + + editor = event_editor_new (comp_data->client, flags); + comp_editor_edit_comp (editor, comp); + + g_object_ref (comp); + +exit: + gtk_window_present (GTK_WINDOW (editor)); +} + void e_cal_shell_view_set_status_message (ECalShellView *cal_shell_view, const gchar *status_message) @@ -212,6 +394,8 @@ e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view) gchar buffer[512]; gchar end_buffer[512]; + g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view)); + shell_view = E_SHELL_VIEW (cal_shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); diff --git a/calendar/modules/e-cal-shell-view-private.h b/calendar/modules/e-cal-shell-view-private.h index 320e489cbc..bf246cd4ac 100644 --- a/calendar/modules/e-cal-shell-view-private.h +++ b/calendar/modules/e-cal-shell-view-private.h @@ -29,11 +29,19 @@ #include #include +#include "e-util/e-dialog-utils.h" #include "e-util/e-util.h" -#include "shell/e-shell-content.h" - +#include "calendar/gui/comp-util.h" +#include "calendar/gui/e-cal-model-tasks.h" +#include "calendar/gui/e-calendar-view.h" #include "calendar/gui/gnome-cal.h" +#include "calendar/gui/goto.h" +#include "calendar/gui/print.h" +#include "calendar/gui/dialogs/copy-source-dialog.h" +#include "calendar/gui/dialogs/event-editor.h" +#include "calendar/gui/dialogs/memo-editor.h" +#include "calendar/gui/dialogs/task-editor.h" #include "e-cal-shell-content.h" #include "e-cal-shell-sidebar.h" @@ -60,6 +68,22 @@ G_BEGIN_DECLS +/* Filter items are displayed in ascending order. + * Non-negative values are reserved for categories. */ +enum { + CALENDAR_FILTER_ANY_CATEGORY = -4, + CALENDAR_FILTER_UNMATCHED = -3, + CALENDAR_FILTER_ACTIVE_APPOINTMENTS = -2, + CALENDAR_FILTER_NEXT_7_DAYS_APPOINTMENTS = -1 +}; + +/* Search items are displayed in ascending order. */ +enum { + CALENDAR_SEARCH_SUMMARY_CONTAINS, + CALENDAR_SEARCH_DESCRIPTION_CONTAINS, + CALENDAR_SEARCH_ANY_FIELD_CONTAINS +}; + struct _ECalShellViewPrivate { /*** Module Data ***/ @@ -69,11 +93,15 @@ struct _ECalShellViewPrivate { /*** UI Management ***/ GtkActionGroup *calendar_actions; + GtkActionGroup *filter_actions; /* These are just for convenience. */ ECalShellContent *cal_shell_content; ECalShellSidebar *cal_shell_sidebar; + /* The last time explicitly selected by the user. */ + time_t base_view_time; + EActivity *activity; }; @@ -91,11 +119,38 @@ void e_cal_shell_view_private_finalize void e_cal_shell_view_actions_init (ECalShellView *cal_shell_view); +void e_cal_shell_view_execute_search + (ECalShellView *cal_shell_view); +void e_cal_shell_view_open_event + (ECalShellView *cal_shell_view, + ECalModelComponent *comp_data); void e_cal_shell_view_set_status_message (ECalShellView *cal_shell_view, const gchar *status_message); void e_cal_shell_view_update_sidebar (ECalShellView *cal_shell_view); +void e_cal_shell_view_update_search_filter + (ECalShellView *cal_shell_view); + +/* Memo Pad Utilities */ + +void e_cal_shell_view_memopad_actions_init + (ECalShellView *cal_shell_view); +void e_cal_shell_view_memopad_actions_update + (ECalShellView *cal_shell_view); +void e_cal_shell_view_memopad_open_memo + (ECalShellView *cal_shell_view, + ECalModelComponent *comp_data); + +/* Task Pad Utilities */ + +void e_cal_shell_view_taskpad_actions_init + (ECalShellView *cal_shell_view); +void e_cal_shell_view_taskpad_actions_update + (ECalShellView *cal_shell_view); +void e_cal_shell_view_taskpad_open_task + (ECalShellView *cal_shell_view, + ECalModelComponent *comp_data); G_END_DECLS diff --git a/calendar/modules/e-cal-shell-view-taskpad.c b/calendar/modules/e-cal-shell-view-taskpad.c new file mode 100644 index 0000000000..e2cc9d9a52 --- /dev/null +++ b/calendar/modules/e-cal-shell-view-taskpad.c @@ -0,0 +1,600 @@ +/* + * e-cal-shell-view-taskpad.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-cal-shell-view-private.h" + +/* Much of this file is based on e-task-shell-view-actions.c. */ + +static void +action_calendar_taskpad_assign_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModelComponent *comp_data; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + list = e_calendar_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only open the first selected task. */ + e_cal_shell_view_taskpad_open_task (cal_shell_view, comp_data); + + /* FIXME Need to actually assign the task. */ +} + +static void +action_calendar_taskpad_clipboard_copy_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + e_calendar_table_copy_clipboard (task_table); +} + +static void +action_calendar_taskpad_clipboard_cut_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + e_calendar_table_cut_clipboard (task_table); +} + +static void +action_calendar_taskpad_clipboard_paste_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + e_calendar_table_paste_clipboard (task_table); +} + +static void +action_calendar_taskpad_delete_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + const gchar *status_message; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + status_message = _("Deleting selected tasks..."); + e_cal_shell_view_set_status_message (cal_shell_view, status_message); + e_calendar_table_delete_selected (task_table); + e_cal_shell_view_set_status_message (cal_shell_view, NULL); +} + +static void +action_calendar_taskpad_forward_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + ECalComponentItipMethod method; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + list = e_calendar_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only forward the first selected task. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + method = E_CAL_COMPONENT_METHOD_PUBLISH; + e_cal_component_set_icalcomponent (comp, clone); + itip_send_comp (method, comp, comp_data->client, NULL, NULL, NULL); + g_object_unref (comp); +} + +static void +action_calendar_taskpad_mark_complete_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModel *model; + GSList *list, *iter; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + list = e_calendar_table_get_selected (task_table); + model = e_calendar_table_get_model (task_table); + + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + e_cal_model_tasks_mark_comp_complete ( + E_CAL_MODEL_TASKS (model), comp_data); + } + + g_slist_free (list); +} + +static void +action_calendar_taskpad_mark_incomplete_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModel *model; + GSList *list, *iter; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + list = e_calendar_table_get_selected (task_table); + model = e_calendar_table_get_model (task_table); + + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + e_cal_model_tasks_mark_comp_incomplete ( + E_CAL_MODEL_TASKS (model), comp_data); + } + + g_slist_free (list); +} + +static void +action_calendar_taskpad_new_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModelComponent *comp_data; + ECal *client; + ECalComponent *comp; + CompEditor *editor; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + list = e_calendar_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + client = comp_data->client; + editor = task_editor_new (client, COMP_EDITOR_NEW_ITEM); + comp = cal_comp_task_new_with_defaults (client); + comp_editor_edit_comp (editor, comp); + + gtk_window_present (GTK_WINDOW (editor)); + + g_object_unref (comp); + g_object_unref (client); +} + +static void +action_calendar_taskpad_open_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModelComponent *comp_data; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + list = e_calendar_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only open the first selected task. */ + e_cal_shell_view_taskpad_open_task (cal_shell_view, comp_data); +} + +static void +action_calendar_taskpad_open_url_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModelComponent *comp_data; + icalproperty *prop; + GdkScreen *screen; + const gchar *uri; + GSList *list; + GError *error = NULL; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + list = e_calendar_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + + /* XXX We only open the URI of the first selected task. */ + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_URL_PROPERTY); + g_return_if_fail (prop == NULL); + + screen = gtk_widget_get_screen (GTK_WIDGET (cal_shell_view)); + uri = icalproperty_get_url (prop); + gtk_show_uri (screen, uri, GDK_CURRENT_TIME, &error); + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } +} + +static void +action_calendar_taskpad_print_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + GtkPrintOperationAction print_action; + GSList *list; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + list = e_calendar_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only print the first selected task. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; + e_cal_component_set_icalcomponent (comp, clone); + print_comp (comp, comp_data->client, print_action); + g_object_unref (comp); +} + +static void +action_calendar_taskpad_save_as_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + ECalendarTable *task_table; + ECalModelComponent *comp_data; + GSList *list; + gchar *filename; + gchar *string; + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + list = e_calendar_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + filename = e_file_dialog_save (_("Save as..."), NULL); + if (filename == NULL) + return; + + string = e_cal_get_component_as_string ( + comp_data->client, comp_data->icalcomp); + if (string == NULL) { + g_warning ("Could not convert task to a string"); + return; + } + + e_write_file_uri (filename, string); + + g_free (filename); + g_free (string); +} + +static GtkActionEntry calendar_taskpad_entries[] = { + + { "calendar-taskpad-assign", + NULL, + N_("_Assign Task"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_taskpad_assign_cb) }, + + { "calendar-taskpad-clipboard-copy", + GTK_STOCK_COPY, + NULL, + NULL, + N_("Copy selected tasks"), + G_CALLBACK (action_calendar_taskpad_clipboard_copy_cb) }, + + { "calendar-taskpad-clipboard-cut", + GTK_STOCK_CUT, + NULL, + NULL, + N_("Cut selected tasks"), + G_CALLBACK (action_calendar_taskpad_clipboard_cut_cb) }, + + { "calendar-taskpad-clipboard-paste", + GTK_STOCK_PASTE, + NULL, + NULL, + N_("Paste tasks from the clipboard"), + G_CALLBACK (action_calendar_taskpad_clipboard_paste_cb) }, + + { "calendar-taskpad-delete", + GTK_STOCK_DELETE, + N_("_Delete Task"), + NULL, + N_("Delete selected tasks"), + G_CALLBACK (action_calendar_taskpad_delete_cb) }, + + { "calendar-taskpad-forward", + "mail-forward", + N_("_Forward as iCalendar..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_taskpad_forward_cb) }, + + { "calendar-taskpad-mark-complete", + NULL, + N_("_Mark as Complete"), + NULL, + N_("Mark selected tasks as complete"), + G_CALLBACK (action_calendar_taskpad_mark_complete_cb) }, + + { "calendar-taskpad-mark-incomplete", + NULL, + N_("_Mar_k as Incomplete"), + NULL, + N_("Mark selected tasks as incomplete"), + G_CALLBACK (action_calendar_taskpad_mark_incomplete_cb) }, + + { "calendar-taskpad-new", + "stock_task", + N_("New _Task"), + NULL, + N_("Create a new task"), + G_CALLBACK (action_calendar_taskpad_new_cb) }, + + { "calendar-taskpad-open", + GTK_STOCK_OPEN, + N_("_Open Task"), + NULL, + N_("View the selected task"), + G_CALLBACK (action_calendar_taskpad_open_cb) }, + + { "calendar-taskpad-open-url", + "applications-internet", + N_("Open _Web Page"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_taskpad_open_url_cb) }, + + { "calendar-taskpad-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print the selected task"), + G_CALLBACK (action_calendar_taskpad_print_cb) }, + + { "calendar-taskpad-save-as", + GTK_STOCK_SAVE_AS, + N_("_Save as iCalendar..."), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_calendar_taskpad_save_as_cb) } +}; + +void +e_cal_shell_view_taskpad_actions_init (ECalShellView *cal_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + ui_manager = e_shell_window_get_ui_manager (shell_window); + + action_group = cal_shell_view->priv->calendar_actions; + gtk_action_group_add_actions ( + action_group, calendar_taskpad_entries, + G_N_ELEMENTS (calendar_taskpad_entries), cal_shell_view); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); +} + +void +e_cal_shell_view_taskpad_actions_update (ECalShellView *cal_shell_view) +{ + ECalShellContent *cal_shell_content; + EShellWindow *shell_window; + EShellView *shell_view; + ECalendarTable *task_table; + ETable *table; + GtkAction *action; + GSList *list, *iter; + const gchar *label; + gboolean assignable = TRUE; + gboolean editable = TRUE; + gboolean has_url = FALSE; + gboolean sensitive; + gint n_selected; + gint n_complete = 0; + gint n_incomplete = 0; + + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + cal_shell_content = cal_shell_view->priv->cal_shell_content; + task_table = e_cal_shell_content_get_task_table (cal_shell_content); + + table = e_calendar_table_get_table (task_table); + n_selected = e_table_selected_count (table); + + list = e_calendar_table_get_selected (task_table); + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + icalproperty *prop; + const gchar *cap; + gboolean read_only; + + e_cal_is_read_only (comp_data->client, &read_only, NULL); + editable &= !read_only; + + cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT; + if (e_cal_get_static_capability (comp_data->client, cap)) + assignable = FALSE; + + cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK; + if (e_cal_get_static_capability (comp_data->client, cap)) + assignable = FALSE; + + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_URL_PROPERTY); + has_url |= (prop != NULL); + + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_COMPLETED_PROPERTY); + if (prop != NULL) + n_complete++; + else + n_incomplete++; + } + g_slist_free (list); + + action = ACTION (CALENDAR_TASKPAD_ASSIGN); + sensitive = (n_selected == 1) && editable && assignable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_CLIPBOARD_CUT); + sensitive = (n_selected > 0) && editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_CLIPBOARD_PASTE); + sensitive = editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_DELETE); + sensitive = (n_selected > 0) && editable; + gtk_action_set_sensitive (action, sensitive); + label = ngettext ("Delete Task", "Delete Tasks", n_selected); + g_object_set (action, "label", label, NULL); + + action = ACTION (CALENDAR_TASKPAD_FORWARD); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_MARK_COMPLETE); + sensitive = (n_selected > 0) && editable && (n_incomplete > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_MARK_INCOMPLETE); + sensitive = (n_selected > 0) && editable && (n_complete > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_OPEN_URL); + sensitive = (n_selected == 1) && has_url; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_PRINT); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_TASKPAD_SAVE_AS); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); +} + +void +e_cal_shell_view_taskpad_open_task (ECalShellView *cal_shell_view, + ECalModelComponent *comp_data) +{ + CompEditor *editor; + CompEditorFlags flags = 0; + ECalComponent *comp; + icalcomponent *clone; + icalproperty *prop; + const gchar *uid; + + g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view)); + g_return_if_fail (E_IS_CAL_MODEL_COMPONENT (comp_data)); + + uid = icalcomponent_get_uid (comp_data->icalcomp); + editor = comp_editor_find_instance (uid); + + if (editor != NULL) + goto exit; + + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + e_cal_component_set_icalcomponent (comp, clone); + + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY); + if (prop != NULL) + flags |= COMP_EDITOR_IS_ASSIGNED; + + if (itip_organizer_is_user (comp, comp_data->client)) + flags |= COMP_EDITOR_USER_ORG; + + if (!e_cal_component_has_attendees (comp)) + flags |= COMP_EDITOR_USER_ORG; + + editor = task_editor_new (comp_data->client, flags); + comp_editor_edit_comp (editor, comp); + + g_object_ref (comp); + + if (flags & COMP_EDITOR_IS_ASSIGNED) + task_editor_show_assignment (TASK_EDITOR (editor)); + +exit: + gtk_window_present (GTK_WINDOW (editor)); +} diff --git a/calendar/modules/e-cal-shell-view.c b/calendar/modules/e-cal-shell-view.c index 06e433be31..353658474b 100644 --- a/calendar/modules/e-cal-shell-view.c +++ b/calendar/modules/e-cal-shell-view.c @@ -77,17 +77,99 @@ static void cal_shell_view_update_actions (EShellView *shell_view) { ECalShellViewPrivate *priv; + ECalShellContent *cal_shell_content; + ECalShellSidebar *cal_shell_sidebar; EShellWindow *shell_window; + GnomeCalendar *calendar; + ECalModel *model; + ESourceSelector *selector; + ESource *source; + GtkAction *action; + GtkWidget *widget; + GList *list, *iter; + const gchar *uri = NULL; + gboolean user_created_source; + gboolean editable = TRUE; + gboolean recurring = FALSE; + gboolean sensitive; + gint n_selected; priv = E_CAL_SHELL_VIEW_GET_PRIVATE (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - /* FIXME */ + cal_shell_content = priv->cal_shell_content; + calendar = e_cal_shell_content_get_calendar (cal_shell_content); + widget = gnome_calendar_get_current_view_widget (calendar); + model = e_calendar_view_get_model (E_CALENDAR_VIEW (widget)); + + cal_shell_sidebar = priv->cal_shell_sidebar; + selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar); + + list = e_calendar_view_get_selected_events (E_CALENDAR_VIEW (widget)); + n_selected = g_list_length (list); + + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + gboolean read_only; + + e_cal_is_read_only (comp_data->client, &read_only, NULL); + editable &= !read_only; + + if (e_cal_util_component_has_recurrences (comp_data->icalcomp)) + recurring |= TRUE; + else if (e_cal_util_component_is_instance (comp_data->icalcomp)) + recurring |= TRUE; + } + + source = e_source_selector_peek_primary_selection (selector); + if (source != NULL) + uri = e_source_peek_relative_uri (source); + user_created_source = (uri != NULL && strcmp (uri, "system") != 0); + + action = ACTION (CALENDAR_COPY); + sensitive = (source != NULL); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_DELETE); + sensitive = user_created_source; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CALENDAR_PROPERTIES); + sensitive = (source != NULL); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (EVENT_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (EVENT_CLIPBOARD_CUT); + sensitive = (n_selected > 0) && editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (EVENT_CLIPBOARD_PASTE); + sensitive = editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (EVENT_DELETE); + sensitive = (n_selected > 0) && editable && !recurring; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (EVENT_DELETE_OCCURRENCE); + sensitive = (n_selected > 0) && editable && recurring; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (EVENT_DELETE_OCCURRENCE_ALL); + sensitive = (n_selected > 0) && editable && recurring; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (EVENT_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); } static void -cal_shell_view_class_init (ECalShellView *class, +cal_shell_view_class_init (ECalShellViewClass *class, GTypeModule *type_module) { GObjectClass *object_class; diff --git a/calendar/modules/e-memo-shell-module.c b/calendar/modules/e-memo-shell-module.c index 7f6df49691..9f6c45b695 100644 --- a/calendar/modules/e-memo-shell-module.c +++ b/calendar/modules/e-memo-shell-module.c @@ -480,10 +480,9 @@ e_shell_module_init (GTypeModule *type_module) shell_module = E_SHELL_MODULE (type_module); shell = e_shell_module_get_shell (shell_module); - /* Register the GType for EMemoShellView. */ - e_memo_shell_view_get_type (type_module); - - e_shell_module_set_info (shell_module, &module_info); + e_shell_module_set_info ( + shell_module, &module_info, + e_memo_shell_view_get_type (type_module)); memo_module_ensure_sources (shell_module); diff --git a/calendar/modules/e-memo-shell-sidebar.c b/calendar/modules/e-memo-shell-sidebar.c index 63629f2108..e46b84e8ea 100644 --- a/calendar/modules/e-memo-shell-sidebar.c +++ b/calendar/modules/e-memo-shell-sidebar.c @@ -360,6 +360,7 @@ memo_shell_sidebar_constructed (GObject *object) GtkContainer *container; GtkTreeModel *model; GtkWidget *widget; + AtkObject *a11y; GSList *list, *iter; gchar *uid; @@ -389,6 +390,8 @@ memo_shell_sidebar_constructed (GObject *object) widget = e_calendar_selector_new (source_list); e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); gtk_container_add (container, widget); + a11y = gtk_widget_get_accessible (widget); + atk_object_set_name (a11y, _("Memo List Selector")); priv->selector = g_object_ref (widget); gtk_widget_show (widget); diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c index cbbaceaf9c..d6e9387e31 100644 --- a/calendar/modules/e-memo-shell-view-actions.c +++ b/calendar/modules/e-memo-shell-view-actions.c @@ -29,6 +29,9 @@ action_gal_save_custom_view_cb (GtkAction *action, EShellView *shell_view; GalViewInstance *view_instance; + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with saving the custom view. */ shell_view = E_SHELL_VIEW (memo_shell_view); if (!e_shell_view_is_active (shell_view)) return; @@ -47,6 +50,7 @@ action_memo_clipboard_copy_cb (GtkAction *action, memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + e_memo_table_copy_clipboard (memo_table); } @@ -59,6 +63,7 @@ action_memo_clipboard_cut_cb (GtkAction *action, memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + e_memo_table_cut_clipboard (memo_table); } @@ -71,6 +76,7 @@ action_memo_clipboard_paste_cb (GtkAction *action, memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + e_memo_table_paste_clipboard (memo_table); } @@ -384,6 +390,7 @@ action_memo_open_url_cb (GtkAction *action, list = e_memo_table_get_selected (memo_table); g_return_if_fail (list != NULL); comp_data = list->data; + g_slist_free (list); /* XXX We only open the URI of the first selected memo. */ prop = icalcomponent_get_first_property ( @@ -464,6 +471,7 @@ action_memo_save_as_cb (GtkAction *action, if (filename == NULL) return; + /* XXX We only save the first selected memo. */ string = e_cal_get_component_as_string ( comp_data->client, comp_data->icalcomp); if (string == NULL) { @@ -483,6 +491,9 @@ action_search_execute_cb (GtkAction *action, { EShellView *shell_view; + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with executing the search. */ shell_view = E_SHELL_VIEW (memo_shell_view); if (!e_shell_view_is_active (shell_view)) return; @@ -523,7 +534,7 @@ static GtkActionEntry memo_entries[] = { { "memo-delete", GTK_STOCK_DELETE, - N_("Delete Memo"), + N_("_Delete Memo"), NULL, N_("Delete selected memos"), G_CALLBACK (action_memo_delete_cb) }, @@ -678,7 +689,7 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) EShellView *shell_view; EShellWindow *shell_window; GtkActionGroup *action_group; - GtkUIManager *manager; + GtkUIManager *ui_manager; GConfBridge *bridge; GtkAction *action; GObject *object; @@ -687,7 +698,7 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) shell_view = E_SHELL_VIEW (memo_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - manager = e_shell_window_get_ui_manager (shell_window); + ui_manager = e_shell_window_get_ui_manager (shell_window); domain = GETTEXT_PACKAGE; action_group = memo_shell_view->priv->memo_actions; @@ -703,7 +714,7 @@ e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view) G_N_ELEMENTS (memo_search_entries), MEMO_SEARCH_SUMMARY_CONTAINS, NULL, NULL); - gtk_ui_manager_insert_action_group (manager, action_group, 0); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* Bind GObject properties to GConf keys. */ diff --git a/calendar/modules/e-memo-shell-view-private.c b/calendar/modules/e-memo-shell-view-private.c index 4c2312a9d2..183d48a5b0 100644 --- a/calendar/modules/e-memo-shell-view-private.c +++ b/calendar/modules/e-memo-shell-view-private.c @@ -178,7 +178,6 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) EMemoShellContent *memo_shell_content; EMemoShellSidebar *memo_shell_sidebar; EShellView *shell_view; - EShellWindow *shell_window; EShellContent *shell_content; EShellSidebar *shell_sidebar; EMemoTable *memo_table; @@ -187,7 +186,6 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) ESourceSelector *selector; shell_view = E_SHELL_VIEW (memo_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); diff --git a/calendar/modules/e-memo-shell-view.c b/calendar/modules/e-memo-shell-view.c index 17a28fb0d8..72427107d3 100644 --- a/calendar/modules/e-memo-shell-view.c +++ b/calendar/modules/e-memo-shell-view.c @@ -81,8 +81,8 @@ memo_shell_view_update_actions (EShellView *shell_view) EMemoShellSidebar *memo_shell_sidebar; EShellWindow *shell_window; ESourceSelector *selector; - ETable *table; EMemoTable *memo_table; + ETable *table; ESource *source; GtkAction *action; GSList *list, *iter; @@ -179,7 +179,7 @@ memo_shell_view_update_actions (EShellView *shell_view) } static void -memo_shell_view_class_init (EMemoShellView *class, +memo_shell_view_class_init (EMemoShellViewClass *class, GTypeModule *type_module) { GObjectClass *object_class; diff --git a/calendar/modules/e-task-shell-module.c b/calendar/modules/e-task-shell-module.c index c5f268d131..9ed38b0cad 100644 --- a/calendar/modules/e-task-shell-module.c +++ b/calendar/modules/e-task-shell-module.c @@ -486,10 +486,9 @@ e_shell_module_init (GTypeModule *type_module) shell_module = E_SHELL_MODULE (type_module); shell = e_shell_module_get_shell (shell_module); - /* Register the GType for ETaskShellView. */ - e_task_shell_view_get_type (type_module); - - e_shell_module_set_info (shell_module, &module_info); + e_shell_module_set_info ( + shell_module, &module_info, + e_task_shell_view_get_type (type_module)); task_module_ensure_sources (shell_module); diff --git a/calendar/modules/e-task-shell-sidebar.c b/calendar/modules/e-task-shell-sidebar.c index e36c05b879..6a84ef3179 100644 --- a/calendar/modules/e-task-shell-sidebar.c +++ b/calendar/modules/e-task-shell-sidebar.c @@ -360,6 +360,7 @@ task_shell_sidebar_constructed (GObject *object) GtkContainer *container; GtkTreeModel *model; GtkWidget *widget; + AtkObject *a11y; GSList *list, *iter; gchar *uid; @@ -389,6 +390,8 @@ task_shell_sidebar_constructed (GObject *object) widget = e_calendar_selector_new (source_list); e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE); gtk_container_add (container, widget); + a11y = gtk_widget_get_accessible (widget); + atk_object_set_name (a11y, _("Task List Selector")); priv->selector = g_object_ref (widget); gtk_widget_show (widget); diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c index fe7331b4be..805089ea8b 100644 --- a/calendar/modules/e-task-shell-view-actions.c +++ b/calendar/modules/e-task-shell-view-actions.c @@ -29,6 +29,9 @@ action_gal_save_custom_view_cb (GtkAction *action, EShellView *shell_view; GalViewInstance *view_instance; + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with saving the custom view. */ shell_view = E_SHELL_VIEW (task_shell_view); if (!e_shell_view_is_active (shell_view)) return; @@ -44,6 +47,9 @@ action_search_execute_cb (GtkAction *action, { EShellView *shell_view; + /* All shell views respond to the activation of this action, + * which is defined by EShellWindow. But only the currently + * active shell view proceeds with executing the search. */ shell_view = E_SHELL_VIEW (task_shell_view); if (!e_shell_view_is_active (shell_view)) return; @@ -91,6 +97,7 @@ action_task_clipboard_copy_cb (GtkAction *action, task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); + e_calendar_table_copy_clipboard (task_table); } @@ -103,6 +110,7 @@ action_task_clipboard_cut_cb (GtkAction *action, task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); + e_calendar_table_cut_clipboard (task_table); } @@ -115,6 +123,7 @@ action_task_clipboard_paste_cb (GtkAction *action, task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); + e_calendar_table_paste_clipboard (task_table); } @@ -535,6 +544,50 @@ static void action_task_purge_cb (GtkAction *action, ETaskShellView *task_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; + GtkWidget *dialog; + GtkWidget *widget; + gboolean active; + gint response; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + if (!calendar_config_get_confirm_purge ()) + goto purge; + + /* XXX This needs reworked. The dialog looks like ass. */ + + dialog = gtk_message_dialog_new ( + GTK_WINDOW (shell_window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_YES_NO, + "%s", _("This operation will permanently erase all tasks " + "marked as completed. If you continue, you will not be able " + "to recover these tasks.\n\nReally erase these tasks?")); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO); + + widget = gtk_check_button_new_with_label (_("Do not ask me again")); + gtk_box_pack_start ( + GTK_BOX (GTK_DIALOG (dialog)->vbox), widget, TRUE, TRUE, 6); + gtk_widget_show (widget); + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + gtk_widget_destroy (dialog); + + if (response != GTK_RESPONSE_YES) + return; + + if (active) + calendar_config_set_confirm_purge (FALSE); + +purge: + + /* FIXME */ } static void @@ -825,7 +878,7 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) EShellView *shell_view; EShellWindow *shell_window; GtkActionGroup *action_group; - GtkUIManager *manager; + GtkUIManager *ui_manager; GConfBridge *bridge; GtkAction *action; GObject *object; @@ -834,7 +887,7 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) shell_view = E_SHELL_VIEW (task_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - manager = e_shell_window_get_ui_manager (shell_window); + ui_manager = e_shell_window_get_ui_manager (shell_window); domain = GETTEXT_PACKAGE; action_group = task_shell_view->priv->task_actions; @@ -850,7 +903,7 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) G_N_ELEMENTS (task_search_entries), TASK_SEARCH_SUMMARY_CONTAINS, NULL, NULL); - gtk_ui_manager_insert_action_group (manager, action_group, 0); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* Bind GObject properties to GConf keys. */ diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c index bd48cf3f23..754f6fe4c6 100644 --- a/calendar/modules/e-task-shell-view-private.c +++ b/calendar/modules/e-task-shell-view-private.c @@ -178,7 +178,6 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) ETaskShellContent *task_shell_content; ETaskShellSidebar *task_shell_sidebar; EShellView *shell_view; - EShellWindow *shell_window; EShellContent *shell_content; EShellSidebar *shell_sidebar; ECalendarTable *task_table; @@ -187,7 +186,6 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) ESourceSelector *selector; shell_view = E_SHELL_VIEW (task_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c index 8ff7e16c91..9fc0643a14 100644 --- a/calendar/modules/e-task-shell-view.c +++ b/calendar/modules/e-task-shell-view.c @@ -148,6 +148,7 @@ task_shell_view_update_actions (EShellView *shell_view) action = ACTION (TASK_ASSIGN); sensitive = (n_selected == 1) && editable && assignable; + gtk_action_set_sensitive (action, sensitive); action = ACTION (TASK_CLIPBOARD_COPY); sensitive = (n_selected > 0); @@ -213,7 +214,7 @@ task_shell_view_update_actions (EShellView *shell_view) } static void -task_shell_view_class_init (ETaskShellView *class, +task_shell_view_class_init (ETaskShellViewClass *class, GTypeModule *type_module) { GObjectClass *object_class; diff --git a/mail/Makefile.am b/mail/Makefile.am index 23778d569c..e029968a0f 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = default importers +#SUBDIRS = default importers mailincludedir = $(privincludedir)/mail @@ -31,159 +31,159 @@ INCLUDES = \ -DPREFIX=\""$(prefix)"\" \ -DG_LOG_DOMAIN=\"evolution-mail\" -component_LTLIBRARIES = libevolution-mail.la - -# Mail.idl -MAIL_IDL = Evolution-Mail.idl -MAIL_IDL_GENERATED_H = \ - Evolution-Mail.h -MAIL_IDL_GENERATED_C = \ - Evolution-Mail-common.c \ - Evolution-Mail-skels.c \ - Evolution-Mail-stubs.c -MAIL_IDL_GENERATED = $(MAIL_IDL_GENERATED_C) $(MAIL_IDL_GENERATED_H) - -$(MAIL_IDL_GENERATED_H): $(MAIL_IDL) - $(ORBIT_IDL) -I $(top_srcdir) -I $(datadir)/idl $(IDL_INCLUDES) $^ -$(MAIL_IDL_GENERATED_C): $(MAIL_IDL_GENERATED_H) - -# IDL install - -idl_DATA = $(MAIL_IDL) +module_LTLIBRARIES = \ + libevolution-module-mail.la + +libevolution_module_mail_la_SOURCES = \ + e-mail-shell-module.c \ + e-mail-shell-module.h \ + e-mail-shell-module-migrate.c \ + e-mail-shell-module-migrate.h \ + e-mail-shell-content.c \ + e-mail-shell-content.h \ + e-mail-shell-sidebar.c \ + e-mail-shell-sidebar.h \ + e-mail-shell-view.c \ + e-mail-shell-view.h \ + e-mail-shell-view-actions.c \ + e-mail-shell-view-actions.h \ + e-mail-shell-view-private.c \ + e-mail-shell-view-private.h + +libevolution_module_mail_la_LIBADD = \ + $(top_builddir)/shell/libeshell.la # plugin mail api -mailinclude_HEADERS = \ - $(MAIL_IDL_GENERATED_H) \ - em-composer-utils.h \ - em-config.h \ - em-event.h \ - em-folder-browser.h \ - em-folder-tree-model.h \ - em-folder-tree.h \ - em-folder-utils.h \ - em-folder-view.h \ - em-format-hook.h \ - em-format-html-display.h \ - em-format-html-print.h \ - em-format-html.h \ - em-format-quote.h \ - em-format.h \ - em-html-stream.h \ - em-icon-stream.h \ - em-inline-filter.h \ - em-junk-hook.h \ - em-menu.h \ - em-message-browser.h \ - em-popup.h \ - em-stripsig-filter.h \ - em-sync-stream.h \ - em-utils.h \ - mail-autofilter.h \ - mail-component.h \ - mail-config.h \ - mail-mt.h \ - mail-ops.h \ - mail-session.h \ - mail-tools.h \ - message-list.h \ - mail-vfolder.h +#mailinclude_HEADERS = \ +# em-composer-utils.h \ +# em-config.h \ +# em-event.h \ +# em-folder-browser.h \ +# em-folder-tree-model.h \ +# em-folder-tree.h \ +# em-folder-utils.h \ +# em-folder-view.h \ +# em-format-hook.h \ +# em-format-html-display.h \ +# em-format-html-print.h \ +# em-format-html.h \ +# em-format-quote.h \ +# em-format.h \ +# em-html-stream.h \ +# em-icon-stream.h \ +# em-inline-filter.h \ +# em-junk-hook.h \ +# em-menu.h \ +# em-message-browser.h \ +# em-popup.h \ +# em-stripsig-filter.h \ +# em-sync-stream.h \ +# em-utils.h \ +# mail-autofilter.h \ +# mail-component.h \ +# mail-config.h \ +# mail-mt.h \ +# mail-ops.h \ +# mail-session.h \ +# mail-tools.h \ +# message-list.h \ +# mail-vfolder.h # libevolution-mail -libevolution_mail_la_SOURCES = \ - $(MAIL_IDL_GENERATED) \ - $(mailinclude_HEADERS) \ - e-searching-tokenizer.c \ - e-searching-tokenizer.h \ - em-account-editor.c \ - em-account-editor.h \ - em-account-prefs.c \ - em-account-prefs.h \ - em-composer-prefs.c \ - em-composer-prefs.h \ - em-composer-utils.c \ - em-config.c \ - em-event.c \ - em-filter-context.c \ - em-filter-context.h \ - em-filter-editor.c \ - em-filter-editor.h \ - em-filter-folder-element.c \ - em-filter-folder-element.h \ - em-filter-rule.c \ - em-filter-rule.h \ - em-filter-source-element.c \ - em-filter-source-element.h \ - em-folder-browser.c \ - em-folder-properties.c \ - em-folder-properties.h \ - em-folder-selection-button.c \ - em-folder-selection-button.h \ - em-folder-selection.c \ - em-folder-selection.h \ - em-folder-selector.c \ - em-folder-selector.h \ - em-folder-tree-model.c \ - em-folder-tree.c \ - em-folder-utils.c \ - em-folder-view.c \ - em-format-hook.c \ - em-format-html-display.c \ - em-format-html-print.c \ - em-format-html.c \ - em-format-quote.c \ - em-format.c \ - em-html-stream.c \ - em-icon-stream.c \ - em-inline-filter.c \ - em-junk-hook.c \ - em-mailer-prefs.c \ - em-mailer-prefs.h \ - em-menu.c \ - em-message-browser.c \ - em-migrate.c \ - em-migrate.h \ - em-network-prefs.c \ - em-network-prefs.h \ - em-popup.c \ - em-search-context.c \ - em-search-context.h \ - em-stripsig-filter.c \ - em-subscribe-editor.c \ - em-subscribe-editor.h \ - em-sync-stream.c \ - em-utils.c \ - em-vfolder-context.c \ - em-vfolder-context.h \ - em-vfolder-editor.c \ - em-vfolder-editor.h \ - em-vfolder-rule.c \ - em-vfolder-rule.h \ - mail-autofilter.c \ - mail-component-factory.c \ - mail-component.c \ - mail-config-factory.c \ - mail-config-factory.h \ - mail-config.c \ - mail-crypto.c \ - mail-crypto.h \ - mail-folder-cache.c \ - mail-folder-cache.h \ - mail-mt.c \ - mail-ops.c \ - mail-send-recv.c \ - mail-send-recv.h \ - mail-session.c \ - mail-signature-editor.c \ - mail-signature-editor.h \ - mail-tools.c \ - mail-types.h \ - mail-vfolder.c \ - message-list.c \ - message-tag-editor.c \ - message-tag-editor.h \ - message-tag-followup.c \ - message-tag-followup.h +#libevolution_mail_la_SOURCES = \ +# $(mailinclude_HEADERS) \ +# e-searching-tokenizer.c \ +# e-searching-tokenizer.h \ +# em-account-editor.c \ +# em-account-editor.h \ +# em-account-prefs.c \ +# em-account-prefs.h \ +# em-composer-prefs.c \ +# em-composer-prefs.h \ +# em-composer-utils.c \ +# em-config.c \ +# em-event.c \ +# em-filter-context.c \ +# em-filter-context.h \ +# em-filter-editor.c \ +# em-filter-editor.h \ +# em-filter-folder-element.c \ +# em-filter-folder-element.h \ +# em-filter-rule.c \ +# em-filter-rule.h \ +# em-filter-source-element.c \ +# em-filter-source-element.h \ +# em-folder-browser.c \ +# em-folder-properties.c \ +# em-folder-properties.h \ +# em-folder-selection-button.c \ +# em-folder-selection-button.h \ +# em-folder-selection.c \ +# em-folder-selection.h \ +# em-folder-selector.c \ +# em-folder-selector.h \ +# em-folder-tree-model.c \ +# em-folder-tree.c \ +# em-folder-utils.c \ +# em-folder-view.c \ +# em-format-hook.c \ +# em-format-html-display.c \ +# em-format-html-print.c \ +# em-format-html.c \ +# em-format-quote.c \ +# em-format.c \ +# em-html-stream.c \ +# em-icon-stream.c \ +# em-inline-filter.c \ +# em-junk-hook.c \ +# em-mailer-prefs.c \ +# em-mailer-prefs.h \ +# em-menu.c \ +# em-message-browser.c \ +# em-migrate.c \ +# em-migrate.h \ +# em-network-prefs.c \ +# em-network-prefs.h \ +# em-popup.c \ +# em-search-context.c \ +# em-search-context.h \ +# em-stripsig-filter.c \ +# em-subscribe-editor.c \ +# em-subscribe-editor.h \ +# em-sync-stream.c \ +# em-utils.c \ +# em-vfolder-context.c \ +# em-vfolder-context.h \ +# em-vfolder-editor.c \ +# em-vfolder-editor.h \ +# em-vfolder-rule.c \ +# em-vfolder-rule.h \ +# mail-autofilter.c \ +# mail-component-factory.c \ +# mail-component.c \ +# mail-config-factory.c \ +# mail-config-factory.h \ +# mail-config.c \ +# mail-crypto.c \ +# mail-crypto.h \ +# mail-folder-cache.c \ +# mail-folder-cache.h \ +# mail-mt.c \ +# mail-ops.c \ +# mail-send-recv.c \ +# mail-send-recv.h \ +# mail-session.c \ +# mail-signature-editor.c \ +# mail-signature-editor.h \ +# mail-tools.c \ +# mail-types.h \ +# mail-vfolder.c \ +# message-list.c \ +# message-tag-editor.c \ +# message-tag-editor.h \ +# message-tag-followup.c \ +# message-tag-followup.h if ENABLE_SMIME SMIME_LIBS = \ @@ -191,30 +191,30 @@ SMIME_LIBS = \ $(top_builddir)/smime/gui/libevolution-smime.la endif -libevolution_mail_la_LIBADD = \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/shell/libeshell.la \ - $(top_builddir)/composer/libcomposer.la \ - $(top_builddir)/widgets/table/libetable.la \ - $(top_builddir)/widgets/text/libetext.la \ - $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/widgets/misc/libefilterbar.la \ - $(top_builddir)/filter/libfilter.la \ - $(top_builddir)/widgets/menus/libmenus.la \ - $(top_builddir)/addressbook/util/libeabutil.la \ - $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \ - $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ - $(top_builddir)/mail/importers/libevolution-mail-importers.la \ - $(SMIME_LIBS) \ - $(EVOLUTION_MAIL_LIBS) \ - $(GTKHTML_LIBS) \ - $(REGEX_LIBS) \ - $(THREADS_LIBS) - -libevolution_mail_la_LDFLAGS = \ - -avoid-version -module $(NO_UNDEFINED) - -libevolution_mail_la_DEPENDENCIES = em-filter-i18n.h +#libevolution_mail_la_LIBADD = \ +# $(top_builddir)/e-util/libeutil.la \ +# $(top_builddir)/shell/libeshell.la \ +# $(top_builddir)/composer/libcomposer.la \ +# $(top_builddir)/widgets/table/libetable.la \ +# $(top_builddir)/widgets/text/libetext.la \ +# $(top_builddir)/widgets/misc/libemiscwidgets.la \ +# $(top_builddir)/widgets/misc/libefilterbar.la \ +# $(top_builddir)/filter/libfilter.la \ +# $(top_builddir)/widgets/menus/libmenus.la \ +# $(top_builddir)/addressbook/util/libeabutil.la \ +# $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \ +# $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ +# $(top_builddir)/mail/importers/libevolution-mail-importers.la \ +# $(SMIME_LIBS) \ +# $(EVOLUTION_MAIL_LIBS) \ +# $(GTKHTML_LIBS) \ +# $(REGEX_LIBS) \ +# $(THREADS_LIBS) + +#libevolution_mail_la_LDFLAGS = \ +# -avoid-version -module $(NO_UNDEFINED) + +#libevolution_mail_la_DEPENDENCIES = em-filter-i18n.h # .server files @@ -246,7 +246,6 @@ etspec_DATA = message-list.etspec EXTRA_DIST = \ ChangeLog.pre-1-4 \ README.async \ - $(MAIL_IDL) \ mail.error.xml \ $(glade_DATA) \ $(schema_in_files) \ @@ -302,7 +301,7 @@ endif dist-hook: cd $(distdir); rm -f $(BUILT_SOURCES) -BUILT_SOURCES = $(MAIL_IDL_GENERATED) $(server_DATA) $(error_DATA) +BUILT_SOURCES = $(server_DATA) $(error_DATA) CLEANFILES = $(BUILT_SOURCES) diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c new file mode 100644 index 0000000000..d0c773d470 --- /dev/null +++ b/mail/e-mail-shell-content.c @@ -0,0 +1,347 @@ +/* + * e-mail-shell-content.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-shell-content.h" + +#include + +#include "e-util/gconf-bridge.h" + +#define E_MAIL_SHELL_CONTENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SHELL_CONTENT, EMailShellContentPrivate)) + +struct _EMailShellContentPrivate { + GtkWidget *paned; + + guint paned_binding_id; + + guint preview_visible : 1; + guint vertical_view : 1; +}; + +enum { + PROP_0, + PROP_PREVIEW_VISIBLE, + PROP_VERTICAL_VIEW +}; + +static gpointer parent_class; + +static void +mail_shell_content_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREVIEW_VISIBLE: + e_mail_shell_content_set_preview_visible ( + E_MAIL_SHELL_CONTENT (object), + g_value_get_boolean (value)); + return; + + case PROP_VERTICAL_VIEW: + e_mail_shell_content_set_vertical_view ( + E_MAIL_SHELL_CONTENT (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_shell_content_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_PREVIEW_VISIBLE: + g_value_set_boolean ( + value, + e_mail_shell_content_get_preview_visible ( + E_MAIL_SHELL_CONTENT (object))); + return; + + case PROP_VERTICAL_VIEW: + g_value_set_boolean ( + value, + e_mail_shell_content_get_vertical_view ( + E_MAIL_SHELL_CONTENT (object))); + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_shell_content_dispose (GObject *object) +{ + EMailShellContentPrivate *priv; + + priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (object); + + if (priv->paned != NULL) { + g_object_unref (priv->paned); + priv->paned = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +mail_shell_content_finalize (GObject *object) +{ + EMailShellContentPrivate *priv; + + priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +mail_shell_content_constructed (GObject *object) +{ + EMailShellContentPrivate *priv; + GConfBridge *bridge; + GtkWidget *container; + GtkWidget *widget; + const gchar *key; + + priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (object); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + /* Build content widgets. */ + + container = GTK_WIDGET (object); + + widget = gtk_vpaned_new (); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->paned = g_object_ref (widget); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_label_new ("Message List"); + gtk_paned_add1 (GTK_PANED (container), widget); + gtk_widget_show (widget); + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_paned_add2 (GTK_PANED (container), widget); + gtk_widget_show (widget); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (priv->paned); + key = "/apps/evolution/mail/display/paned_size"; + gconf_bridge_bind_property_delayed (bridge, key, object, "position"); +} + +static void +mail_shell_content_class_init (EMailShellContentClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMailShellContentPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = mail_shell_content_set_property; + object_class->get_property = mail_shell_content_get_property; + object_class->dispose = mail_shell_content_dispose; + object_class->finalize = mail_shell_content_finalize; + object_class->constructed = mail_shell_content_constructed; + + g_object_class_install_property ( + object_class, + PROP_PREVIEW_VISIBLE, + g_param_spec_boolean ( + "preview-visible", + _("Preview is Visible"), + _("Whether the preview pane is visible"), + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_VERTICAL_VIEW, + g_param_spec_boolean ( + "vertical-view", + _("Vertical View"), + _("Whether vertical view is enabled"), + FALSE, + G_PARAM_READWRITE)); +} + +static void +mail_shell_content_init (EMailShellContent *mail_shell_content) +{ + mail_shell_content->priv = + E_MAIL_SHELL_CONTENT_GET_PRIVATE (mail_shell_content); + + mail_shell_content->priv->preview_visible = TRUE; + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_mail_shell_content_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMailShellContentClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_shell_content_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailShellContent), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_shell_content_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_CONTENT, "EMailShellContent", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_mail_shell_content_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_MAIL_SHELL_CONTENT, + "shell-view", shell_view, NULL); +} + +gboolean +e_mail_shell_content_get_preview_visible (EMailShellContent *mail_shell_content) +{ + g_return_val_if_fail ( + E_IS_MAIL_SHELL_CONTENT (mail_shell_content), FALSE); + + return mail_shell_content->priv->preview_visible; +} + +void +e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content, + gboolean preview_visible) +{ + GtkPaned *paned; + GtkWidget *child; + + g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content)); + + if (preview_visible == mail_shell_content->priv->preview_visible) + return; + + paned = GTK_PANED (mail_shell_content->priv->paned); + child = gtk_paned_get_child2 (paned); + + if (preview_visible) + gtk_widget_show (child); + else + gtk_widget_hide (child); + + mail_shell_content->priv->preview_visible = preview_visible; + + g_object_notify (G_OBJECT (mail_shell_content), "preview-visible"); +} + +gboolean +e_mail_shell_content_get_vertical_view (EMailShellContent *mail_shell_content) +{ + g_return_val_if_fail ( + E_IS_MAIL_SHELL_CONTENT (mail_shell_content), FALSE); + + return mail_shell_content->priv->vertical_view; +} + +void +e_mail_shell_content_set_vertical_view (EMailShellContent *mail_shell_content, + gboolean vertical_view) +{ + GConfBridge *bridge; + GtkWidget *old_paned; + GtkWidget *new_paned; + GtkWidget *child1; + GtkWidget *child2; + guint binding_id; + const gchar *key; + + g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content)); + + if (vertical_view == mail_shell_content->priv->vertical_view) + return; + + bridge = gconf_bridge_get (); + old_paned = mail_shell_content->priv->paned; + binding_id = mail_shell_content->priv->paned_binding_id; + + child1 = gtk_paned_get_child1 (GTK_PANED (old_paned)); + child2 = gtk_paned_get_child2 (GTK_PANED (old_paned)); + + if (binding_id > 0) + gconf_bridge_unbind (bridge, binding_id); + + if (vertical_view) { + new_paned = gtk_hpaned_new (); + key = "/apps/evolution/mail/display/hpaned_size"; + } else { + new_paned = gtk_vpaned_new (); + key = "/apps/evolution/mail/display/paned_size"; + } + + gtk_widget_reparent (child1, new_paned); + gtk_widget_reparent (child2, new_paned); + gtk_widget_show (new_paned); + + gtk_widget_destroy (old_paned); + gtk_container_add (GTK_CONTAINER (mail_shell_content), new_paned); + + binding_id = gconf_bridge_bind_property_delayed ( + bridge, key, G_OBJECT (new_paned), "position"); + + mail_shell_content->priv->vertical_view = vertical_view; + mail_shell_content->priv->paned_binding_id = binding_id; + mail_shell_content->priv->paned = g_object_ref (new_paned); + + g_object_notify (G_OBJECT (mail_shell_content), "vertical-view"); +} diff --git a/mail/e-mail-shell-content.h b/mail/e-mail-shell-content.h new file mode 100644 index 0000000000..dddaf589d7 --- /dev/null +++ b/mail/e-mail-shell-content.h @@ -0,0 +1,77 @@ +/* + * e-mail-shell-content.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SHELL_CONTENT_H +#define E_MAIL_SHELL_CONTENT_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MAIL_SHELL_CONTENT \ + (e_mail_shell_content_get_type ()) +#define E_MAIL_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_SHELL_CONTENT, EMailShellContent)) +#define E_MAIL_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_SHELL_CONTENT, EMailShellContentClass)) +#define E_IS_MAIL_SHELL_CONTENT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_SHELL_CONTENT)) +#define E_IS_MAIL_SHELL_CONTENT_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_SHELL_CONTENT)) +#define E_MAIL_SHELL_CONTENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_SHELL_CONTENT, EMailShellContentClass)) + +G_BEGIN_DECLS + +typedef struct _EMailShellContent EMailShellContent; +typedef struct _EMailShellContentClass EMailShellContentClass; +typedef struct _EMailShellContentPrivate EMailShellContentPrivate; + +struct _EMailShellContent { + EShellContent parent; + EMailShellContentPrivate *priv; +}; + +struct _EMailShellContentClass { + EShellContentClass parent_class; +}; + +GType e_mail_shell_content_get_type (void); +GtkWidget * e_mail_shell_content_new (EShellView *shell_view); +gboolean e_mail_shell_content_get_preview_visible + (EMailShellContent *mail_shell_content); +void e_mail_shell_content_set_preview_visible + (EMailShellContent *mail_shell_content, + gboolean preview_visible); +gboolean e_mail_shell_content_get_vertical_view + (EMailShellContent *mail_shell_content); +void e_mail_shell_content_set_vertical_view + (EMailShellContent *mail_shell_content, + gboolean vertical_view); + +G_END_DECLS + +#endif /* E_MAIL_SHELL_CONTENT_H */ diff --git a/mail/e-mail-shell-module-migrate.c b/mail/e-mail-shell-module-migrate.c new file mode 100644 index 0000000000..c41ec65e2e --- /dev/null +++ b/mail/e-mail-shell-module-migrate.c @@ -0,0 +1,3088 @@ +/* + * e-mail-shell-module-migrate.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-shell-module-migrate.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "e-util/e-bconf-map.h" +#include "libedataserver/e-account-list.h" +#include "e-util/e-signature-list.h" +#include "e-util/e-error.h" +#include "e-util/e-util-private.h" +#include "e-util/e-plugin.h" + +#include "e-mail-shell-module.h" +#include "shell/e-shell-migrate.h" + +#include "mail-config.h" +#include "em-utils.h" + +#define d(x) x + +#ifndef G_OS_WIN32 +/* No versions previous to 2.8 or thereabouts have been available on + * Windows, so don't bother with upgrade support from earlier versions + * on Win32. Do try to support upgrades from 2.12 and later to the + * current version. + */ + +/* upgrade helper functions */ +static xmlDocPtr +emm_load_xml (const char *dirname, const char *filename) +{ + xmlDocPtr doc; + struct stat st; + char *path; + + path = g_strdup_printf ("%s/%s", dirname, filename); + if (stat (path, &st) == -1 || !(doc = xmlParseFile (path))) { + g_free (path); + return NULL; + } + + g_free (path); + + return doc; +} + +static int +emm_save_xml (xmlDocPtr doc, const char *dirname, const char *filename) +{ + char *path; + int retval; + + path = g_strdup_printf ("%s/%s", dirname, filename); + retval = e_xml_save_file (path, doc); + g_free (path); + + return retval; +} + +static xmlNodePtr +xml_find_node (xmlNodePtr parent, const char *name) +{ + xmlNodePtr node; + + node = parent->children; + while (node != NULL) { + if (node->name && !strcmp ((char *)node->name, name)) + return node; + + node = node->next; + } + + return NULL; +} + +static void +upgrade_xml_uris (xmlDocPtr doc, char * (* upgrade_uri) (const char *uri)) +{ + xmlNodePtr root, node; + char *uri, *new; + + if (!doc || !(root = xmlDocGetRootElement (doc))) + return; + + if (!root->name || strcmp ((char *)root->name, "filteroptions") != 0) { + /* root node is not , nothing to upgrade */ + return; + } + + if (!(node = xml_find_node (root, "ruleset"))) { + /* no ruleset node, nothing to upgrade */ + return; + } + + node = node->children; + while (node != NULL) { + if (node->name && !strcmp ((char *)node->name, "rule")) { + xmlNodePtr actionset, part, val, n; + + if ((actionset = xml_find_node (node, "actionset"))) { + /* filters.xml */ + part = actionset->children; + while (part != NULL) { + if (part->name && !strcmp ((char *)part->name, "part")) { + val = part->children; + while (val != NULL) { + if (val->name && !strcmp ((char *)val->name, "value")) { + char *type; + + type = (char *)xmlGetProp (val, (const unsigned char *)"type"); + if (type && !strcmp ((char *)type, "folder")) { + if ((n = xml_find_node (val, "folder"))) { + uri = (char *)xmlGetProp (n, (const unsigned char *)"uri"); + new = upgrade_uri (uri); + xmlFree (uri); + + xmlSetProp (n, (const unsigned char *)"uri", (unsigned char *)new); + g_free (new); + } + } + + xmlFree (type); + } + + val = val->next; + } + } + + part = part->next; + } + } else if ((actionset = xml_find_node (node, "sources"))) { + /* vfolders.xml */ + n = actionset->children; + while (n != NULL) { + if (n->name && !strcmp ((char *)n->name, "folder")) { + uri = (char *)xmlGetProp (n, (const unsigned char *)"uri"); + new = upgrade_uri (uri); + xmlFree (uri); + + xmlSetProp (n, (const unsigned char *)"uri", (unsigned char *)new); + g_free (new); + } + + n = n->next; + } + } + } + + node = node->next; + } +} + +/* 1.0 upgrade functions & data */ + +/* as much info as we have on a given account */ +struct _account_info_1_0 { + char *name; + char *uri; + char *base_uri; + union { + struct { + /* for imap */ + char *namespace; + char *namespace_full; + guint32 capabilities; + GHashTable *folders; + char dir_sep; + } imap; + } u; +}; + +struct _imap_folder_info_1_0 { + char *folder; + /* encoded? decoded? canonicalised? */ + char dir_sep; +}; + +static GHashTable *accounts_1_0 = NULL; +static GHashTable *accounts_name_1_0 = NULL; + +static void +imap_folder_info_1_0_free (struct _imap_folder_info_1_0 *fi) +{ + g_free(fi->folder); + g_free(fi); +} + +static void +account_info_1_0_free (struct _account_info_1_0 *ai) +{ + g_free(ai->name); + g_free(ai->uri); + g_free(ai->base_uri); + g_free(ai->u.imap.namespace); + g_free(ai->u.imap.namespace_full); + g_hash_table_destroy(ai->u.imap.folders); + g_free(ai); +} + +static char * +get_base_uri(const char *val) +{ + const char *tmp; + + tmp = strchr(val, ':'); + if (tmp) { + tmp++; + if (strncmp(tmp, "//", 2) == 0) + tmp += 2; + tmp = strchr(tmp, '/'); + } + + if (tmp) + return g_strndup(val, tmp-val); + else + return g_strdup(val); +} + +static char * +upgrade_xml_uris_1_0 (const char *uri) +{ + char *out = NULL; + + /* upgrades camel uri's */ + if (strncmp (uri, "imap:", 5) == 0) { + char *base_uri, dir_sep, *folder, *p; + struct _account_info_1_0 *ai; + + /* add namespace, canonicalise dir_sep to / */ + base_uri = get_base_uri (uri); + ai = g_hash_table_lookup (accounts_1_0, base_uri); + + if (ai == NULL) { + g_free (base_uri); + return NULL; + } + + dir_sep = ai->u.imap.dir_sep; + if (dir_sep == 0) { + /* no dir_sep listed, try get it from the namespace, if set */ + if (ai->u.imap.namespace != NULL) { + p = ai->u.imap.namespace; + while ((dir_sep = *p++)) { + if (dir_sep < '0' + || (dir_sep > '9' && dir_sep < 'A') + || (dir_sep > 'Z' && dir_sep < 'a') + || (dir_sep > 'z')) { + break; + } + p++; + } + } + + /* give up ... */ + if (dir_sep == 0) { + g_free (base_uri); + return NULL; + } + } + + folder = g_strdup (uri + strlen (base_uri) + 1); + + /* Add the namespace before the mailbox name, unless the mailbox is INBOX */ + if (ai->u.imap.namespace && strcmp ((char *)folder, "INBOX") != 0) + out = g_strdup_printf ("%s/%s/%s", base_uri, ai->u.imap.namespace, folder); + else + out = g_strdup_printf ("%s/%s", base_uri, folder); + + p = out; + while (*p) { + if (*p == dir_sep) + *p = '/'; + p++; + } + + g_free (folder); + g_free (base_uri); + } else if (strncmp (uri, "exchange:", 9) == 0) { + char *base_uri, *folder, *p; + + /* exchange://user@host/exchange/ * -> exchange://user@host/personal/ * */ + /* Any url encoding (%xx) in the folder name is also removed */ + base_uri = get_base_uri (uri); + uri += strlen (base_uri) + 1; + if (strncmp (uri, "exchange/", 9) == 0) { + folder = e_bconf_url_decode (uri + 9); + p = strchr (folder, '/'); + out = g_strdup_printf ("%s/personal%s", base_uri, p ? p : "/"); + g_free (folder); + } + } else if (strncmp (uri, "exchanget:", 10) == 0) { + /* these should be converted in the accounts table when it is loaded */ + g_warning ("exchanget: uri not converted: '%s'", uri); + } + + return out; +} + +static char * +parse_lsub (const char *lsub, char *dir_sep) +{ + static int comp; + static regex_t pat; + regmatch_t match[3]; + char *m = "^\\* LSUB \\([^)]*\\) \"?([^\" ]+)\"? \"?(.*)\"?$"; + + if (!comp) { + if (regcomp (&pat, m, REG_EXTENDED|REG_ICASE) == -1) { + g_warning ("reg comp '%s' failed: %s", m, g_strerror (errno)); + return NULL; + } + comp = 1; + } + + if (regexec (&pat, lsub, 3, match, 0) == 0) { + if (match[1].rm_so != -1 && match[2].rm_so != -1) { + if (dir_sep) + *dir_sep = (match[1].rm_eo - match[1].rm_so == 1) ? lsub[match[1].rm_so] : 0; + return g_strndup (lsub + match[2].rm_so, match[2].rm_eo - match[2].rm_so); + } + } + + return NULL; +} + +static gboolean +read_imap_storeinfo (struct _account_info_1_0 *si) +{ + FILE *storeinfo; + guint32 tmp; + char *buf, *folder, dir_sep, *path, *name, *p; + struct _imap_folder_info_1_0 *fi; + + si->u.imap.folders = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) imap_folder_info_1_0_free); + + /* get details from uri first */ + name = strstr (si->uri, ";override_namespace"); + if (name) { + name = strstr (si->uri, ";namespace="); + if (name) { + char *end; + + name += strlen (";namespace="); + if (*name == '\"') { + name++; + end = strchr (name, '\"'); + } else { + end = strchr (name, ';'); + } + + if (end) { + /* try get the dir_sep from the namespace */ + si->u.imap.namespace = g_strndup (name, end-name); + + p = si->u.imap.namespace; + while ((dir_sep = *p++)) { + if (dir_sep < '0' + || (dir_sep > '9' && dir_sep < 'A') + || (dir_sep > 'Z' && dir_sep < 'a') + || (dir_sep > 'z')) { + si->u.imap.dir_sep = dir_sep; + break; + } + p++; + } + } + } + } + + /* now load storeinfo if it exists */ + path = g_build_filename (g_get_home_dir (), "evolution", "mail", "imap", si->base_uri + 7, "storeinfo", NULL); + storeinfo = fopen (path, "r"); + g_free (path); + if (storeinfo == NULL) { + g_warning ("could not find imap store info '%s'", path); + return FALSE; + } + + /* ignore version */ + camel_file_util_decode_uint32 (storeinfo, &tmp); + camel_file_util_decode_uint32 (storeinfo, &si->u.imap.capabilities); + g_free (si->u.imap.namespace); + camel_file_util_decode_string (storeinfo, &si->u.imap.namespace); + camel_file_util_decode_uint32 (storeinfo, &tmp); + si->u.imap.dir_sep = tmp; + /* strip trailing dir_sep or / */ + if (si->u.imap.namespace + && (si->u.imap.namespace[strlen (si->u.imap.namespace) - 1] == si->u.imap.dir_sep + || si->u.imap.namespace[strlen (si->u.imap.namespace) - 1] == '/')) { + si->u.imap.namespace[strlen (si->u.imap.namespace) - 1] = 0; + } + + d(printf ("namespace '%s' dir_sep '%c'\n", si->u.imap.namespace, si->u.imap.dir_sep ? si->u.imap.dir_sep : '?')); + + while (camel_file_util_decode_string (storeinfo, &buf) == 0) { + folder = parse_lsub (buf, &dir_sep); + if (folder) { + fi = g_new0 (struct _imap_folder_info_1_0, 1); + fi->folder = folder; + fi->dir_sep = dir_sep; +#if d(!)0 + printf (" add folder '%s' ", folder); + if (dir_sep) + printf ("'%c'\n", dir_sep); + else + printf ("NIL\n"); +#endif + g_hash_table_insert (si->u.imap.folders, fi->folder, fi); + } else { + g_warning ("Could not parse LIST result '%s'\n", buf); + } + } + + fclose (storeinfo); + + return TRUE; +} + +static gboolean +load_accounts_1_0 (xmlDocPtr doc) +{ + xmlNodePtr source; + char *val, *tmp; + int count = 0, i; + char key[32]; + + if (!(source = e_bconf_get_path (doc, "/Mail/Accounts"))) + return TRUE; + + if ((val = e_bconf_get_value (source, "num"))) { + count = atoi (val); + xmlFree (val); + } + + /* load account upgrade info for each account */ + for (i = 0; i < count; i++) { + struct _account_info_1_0 *ai; + char *rawuri; + + sprintf (key, "source_url_%d", i); + if (!(rawuri = e_bconf_get_value (source, key))) + continue; + + ai = g_malloc0 (sizeof (struct _account_info_1_0)); + ai->uri = e_bconf_hex_decode (rawuri); + ai->base_uri = get_base_uri (ai->uri); + sprintf (key, "account_name_%d", i); + ai->name = e_bconf_get_string (source, key); + + d(printf("load account '%s'\n", ai->uri)); + + if (!strncmp (ai->uri, "imap:", 5)) { + read_imap_storeinfo (ai); + } else if (!strncmp (ai->uri, "exchange:", 9)) { + xmlNodePtr node; + + d(printf (" upgrade exchange account\n")); + /* small hack, poke the source_url into the transport_url for exchanget: transports + - this will be picked up later in the conversion */ + sprintf (key, "transport_url_%d", i); + node = e_bconf_get_entry (source, key); + if (node && (val = (char *)xmlGetProp (node, (const unsigned char *)"value"))) { + tmp = e_bconf_hex_decode (val); + xmlFree (val); + if (strncmp (tmp, "exchanget:", 10) == 0) + xmlSetProp (node, (const unsigned char *)"value", (unsigned char *)rawuri); + g_free (tmp); + } else { + d(printf (" couldn't find transport uri?\n")); + } + } + xmlFree (rawuri); + + g_hash_table_insert (accounts_1_0, ai->base_uri, ai); + if (ai->name) + g_hash_table_insert (accounts_name_1_0, ai->name, ai); + } + + return TRUE; +} + +static gboolean +em_migrate_1_0 (const char *data_dir, xmlDocPtr config_xmldb, xmlDocPtr filters, xmlDocPtr vfolders, GError **error) +{ + accounts_1_0 = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) account_info_1_0_free); + accounts_name_1_0 = g_hash_table_new (g_str_hash, g_str_equal); + load_accounts_1_0 (config_xmldb); + + upgrade_xml_uris(filters, upgrade_xml_uris_1_0); + upgrade_xml_uris(vfolders, upgrade_xml_uris_1_0); + + g_hash_table_destroy (accounts_1_0); + g_hash_table_destroy (accounts_name_1_0); + + return TRUE; +} + +/* 1.2 upgrade functions */ +static gboolean +is_xml1encoded (const char *txt) +{ + const unsigned char *p; + int isxml1 = FALSE; + int is8bit = FALSE; + + p = (const unsigned char *)txt; + while (*p) { + if (p[0] == '\\' && p[1] == 'U' && p[2] == '+' + && isxdigit (p[3]) && isxdigit (p[4]) && isxdigit (p[5]) && isxdigit (p[6]) + && p[7] == '\\') { + isxml1 = TRUE; + p+=7; + } else if (p[0] >= 0x80) + is8bit = TRUE; + p++; + } + + /* check for invalid utf8 that needs cleaning */ + if (is8bit && !isxml1) + isxml1 = !g_utf8_validate (txt, -1, NULL); + + return isxml1; +} + +static char * +decode_xml1 (const char *txt) +{ + GString *out = g_string_new (""); + const unsigned char *p; + char *res; + + /* convert: + \U+XXXX\ -> utf8 + 8 bit characters -> utf8 (iso-8859-1) */ + + p = (const unsigned char *) txt; + while (*p) { + if (p[0] > 0x80 + || (p[0] == '\\' && p[1] == 'U' && p[2] == '+' + && isxdigit (p[3]) && isxdigit (p[4]) && isxdigit (p[5]) && isxdigit (p[6]) + && p[7] == '\\')) { + char utf8[8]; + gunichar u; + + if (p[0] == '\\') { + memcpy (utf8, p + 3, 4); + utf8[4] = 0; + u = strtoul (utf8, NULL, 16); + p+=7; + } else + u = p[0]; + utf8[g_unichar_to_utf8 (u, utf8)] = 0; + g_string_append (out, utf8); + } else { + g_string_append_c (out, *p); + } + p++; + } + + res = out->str; + g_string_free (out, FALSE); + + return res; +} + +static char * +utf8_reencode (const char *txt) +{ + GString *out = g_string_new (""); + gchar *p; + char *res; + + /* convert: + libxml1 8 bit utf8 converted to xml entities byte-by-byte chars -> utf8 */ + + p = (gchar *)txt; + + while (*p) { + g_string_append_c (out, (gchar)g_utf8_get_char ((const gchar *)p)); + p = (gchar *)g_utf8_next_char (p); + } + + res = out->str; + if (g_utf8_validate (res, -1, NULL)) { + g_string_free (out, FALSE); + return res; + } else { + g_string_free (out, TRUE); + return g_strdup (txt); + } +} + +static gboolean +upgrade_xml_1_2_rec (xmlNodePtr node) +{ + const char *value_tags[] = { "string", "address", "regex", "file", "command", NULL }; + const char *rule_tags[] = { "title", NULL }; + const char *item_props[] = { "name", NULL }; + struct { + const char *name; + const char **tags; + const char **props; + } tags[] = { + { "value", value_tags, NULL }, + { "rule", rule_tags, NULL }, + { "item", NULL, item_props }, + { 0 }, + }; + xmlNodePtr work; + int i,j; + char *txt, *tmp; + + /* upgrades the content of a node, if the node has a specific parent/node name */ + + for (i = 0; tags[i].name; i++) { + if (!strcmp ((char *)node->name, tags[i].name)) { + if (tags[i].tags != NULL) { + work = node->children; + while (work) { + for (j = 0; tags[i].tags[j]; j++) { + if (!strcmp ((char *)work->name, tags[i].tags[j])) { + txt = (char *)xmlNodeGetContent (work); + if (is_xml1encoded (txt)) { + tmp = decode_xml1 (txt); + d(printf ("upgrading xml node %s/%s '%s' -> '%s'\n", + tags[i].name, tags[i].tags[j], txt, tmp)); + xmlNodeSetContent (work, (unsigned char *)tmp); + g_free (tmp); + } + xmlFree (txt); + } + } + work = work->next; + } + break; + } + + if (tags[i].props != NULL) { + for (j = 0; tags[i].props[j]; j++) { + txt = (char *)xmlGetProp (node, (unsigned char *)tags[i].props[j]); + tmp = utf8_reencode (txt); + d(printf ("upgrading xml property %s on node %s '%s' -> '%s'\n", + tags[i].props[j], tags[i].name, txt, tmp)); + xmlSetProp (node, (const unsigned char *)tags[i].props[j], (unsigned char *)tmp); + g_free (tmp); + xmlFree (txt); + } + } + } + } + + node = node->children; + while (node) { + upgrade_xml_1_2_rec (node); + node = node->next; + } + + return TRUE; +} + +static gboolean +em_upgrade_xml_1_2 (xmlDocPtr doc) +{ + xmlNodePtr root; + + if (!doc || !(root = xmlDocGetRootElement (doc))) + return TRUE; + + return upgrade_xml_1_2_rec (root); +} + +/* converts passwords from ~/evolution/private/config.xmldb to gnome_private() */ +static gboolean +upgrade_passwords_1_2(void) +{ + xmlNodePtr root, entry; + char *filename; + xmlDocPtr priv_doc = NULL; + struct stat st; + int work = 0; + gboolean success = FALSE; + + filename = g_build_filename(g_get_home_dir(), "evolution/private/config.xmldb", NULL); + if (lstat(filename, &st) == 0 && S_ISREG(st.st_mode)) + priv_doc = xmlParseFile(filename); + g_free(filename); + + if (priv_doc == NULL) + return TRUE; + + root = priv_doc->children; + if (strcmp((char *)root->name, "bonobo-config") != 0) { + xmlFreeDoc(priv_doc); + return TRUE; + } + + root = root->children; + while (root) { + if (!strcmp((char *)root->name, "section")) { + char *path = (char *)xmlGetProp(root, (const unsigned char *)"path"); + + /* All sections of form +
+ + Are converted to: + /Evolution/Passwords-COMPONENT/name = value + */ + + if (path && !strncmp(path, "/Passwords/", 11)) { + entry = root->children; + while (entry) { + if (!strcmp((char *)entry->name, "entry")) { + char *namep = (char *)xmlGetProp(entry, (const unsigned char *)"name"), + *valuep = (char *)xmlGetProp(entry, (const unsigned char *)"value"); + + if (namep && valuep) { + char *value = e_bconf_hex_decode(valuep); + guchar *decoded; + char *p, *new; + gsize len; + + decoded = g_base64_decode (namep, &len); + memcpy (namep, decoded, len); + g_free (decoded); + namep[len] = 0; + p = namep; + + d(printf("Found password entry '%s' = '%s'\n", namep, value)); + + while (*p) { + if (*p == '/' || *p == '=') + *p = '_'; + p++; + } + + p = g_strdup_printf("/Evolution/Passwords-%s/%s", path+11, namep); + new = gnome_config_private_get_string_with_default(p, NULL); + if (new == NULL) { + d(printf("password not there, setting '%s' = '%s'\n", p, value)); + gnome_config_private_set_string(p, value); + work = TRUE; + } else { + d(printf("password already there, leaving\n")); + } + g_free(p); + g_free(value); + } + xmlFree(namep); + xmlFree(valuep); + } + entry = entry->next; + } + } + xmlFree(path); + } + root = root->next; + } + + xmlFreeDoc(priv_doc); + + if (work) { + if (gnome_config_private_sync_file("/Evolution")) + success = TRUE; + } else { + success = TRUE; + } + + return success; +} + +/* ********************************************************************** */ +/* Tables for converting flat bonobo conf -> gconf xml blob */ +/* ********************************************************************** */ + +/* Mail/Accounts/ * */ +static e_bconf_map_t cc_map[] = { + { "account_always_cc_%i", "always", E_BCONF_MAP_BOOL }, + { "account_always_cc_addrs_%i", "recipients", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL }, +}; + +static e_bconf_map_t bcc_map[] = { + { "account_always_cc_%i", "always", E_BCONF_MAP_BOOL }, + { "account_always_bcc_addrs_%i", "recipients", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL }, +}; + +static e_bconf_map_t pgp_map[] = { + { "account_pgp_encrypt_to_self_%i", "encrypt-to-self", E_BCONF_MAP_BOOL }, + { "account_pgp_always_trust_%i", "always-trust", E_BCONF_MAP_BOOL }, + { "account_pgp_always_sign_%i", "always-sign", E_BCONF_MAP_BOOL }, + { "account_pgp_no_imip_sign_%i", "no-imip-sign", E_BCONF_MAP_BOOL }, + { "account_pgp_key_%i", "key-id", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL }, +}; + +static e_bconf_map_t smime_map[] = { + { "account_smime_encrypt_to_self_%i", "encrypt-to-self", E_BCONF_MAP_BOOL }, + { "account_smime_always_sign_%i", "always-sign", E_BCONF_MAP_BOOL }, + { "account_smime_key_%i", "key-id", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL }, +}; + +static e_bconf_map_t identity_sig_map[] = { + { "identity_autogenerated_signature_%i", "auto", E_BCONF_MAP_BOOL }, + { "identity_def_signature_%i", "default", E_BCONF_MAP_LONG }, + { NULL }, +}; + +static e_bconf_map_t identity_map[] = { + { "identity_name_%i", "name", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { "identity_address_%i", "addr-spec", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { "identity_reply_to_%i", "reply-to", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { "identity_organization_%i", "organization", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL, "signature", E_BCONF_MAP_CHILD, identity_sig_map }, + { NULL }, +}; + +static e_bconf_map_t source_map[] = { + { "source_save_passwd_%i", "save-passwd", E_BCONF_MAP_BOOL }, + { "source_keep_on_server_%i", "keep-on-server", E_BCONF_MAP_BOOL }, + { "source_auto_check_%i", "auto-check", E_BCONF_MAP_BOOL }, + { "source_auto_check_time_%i", "auto-check-timeout", E_BCONF_MAP_LONG }, + { "source_url_%i", "url", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL }, +}; + +static e_bconf_map_t transport_map[] = { + { "transport_save_passwd_%i", "save-passwd", E_BCONF_MAP_BOOL }, + { "transport_url_%i", "url", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL }, +}; + +static e_bconf_map_t account_map[] = { + { "account_name_%i", "name", E_BCONF_MAP_STRING }, + { "source_enabled_%i", "enabled", E_BCONF_MAP_BOOL }, + { NULL, "identity", E_BCONF_MAP_CHILD, identity_map }, + { NULL, "source", E_BCONF_MAP_CHILD, source_map }, + { NULL, "transport", E_BCONF_MAP_CHILD, transport_map }, + { "account_drafts_folder_uri_%i", "drafts-folder", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { "account_sent_folder_uri_%i", "sent-folder", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL, "auto-cc", E_BCONF_MAP_CHILD, cc_map }, + { NULL, "auto-bcc", E_BCONF_MAP_CHILD, bcc_map }, + { NULL, "pgp", E_BCONF_MAP_CHILD, pgp_map }, + { NULL, "smime", E_BCONF_MAP_CHILD, smime_map }, + { NULL }, +}; + +/* /Mail/Signatures/ * */ +static e_bconf_map_t signature_format_map[] = { + { "text/plain", }, + { "text/html", }, + { NULL } +}; + +static e_bconf_map_t signature_map[] = { + { "name_%i", "name", E_BCONF_MAP_STRING }, + { "html_%i", "format", E_BCONF_MAP_ENUM, signature_format_map }, + { "filename_%i", "filename", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { "script_%i", "script", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, + { NULL }, +}; + +/* ********************************************************************** */ +/* Tables for bonobo conf -> gconf conversion */ +/* ********************************************************************** */ + +static e_gconf_map_t mail_accounts_map[] = { + /* /Mail/Accounts - most entries are processed via the xml blob routine */ + /* This also works because the initial uid mapping is 1:1 with the list order */ + { "default_account", "mail/default_account", E_GCONF_MAP_SIMPLESTRING }, + { 0 }, +}; + +static e_gconf_map_t mail_display_map[] = { + /* /Mail/Display */ + { "side_bar_search", "mail/display/side_bar_search", E_GCONF_MAP_BOOL }, + { "thread_list", "mail/display/thread_list", E_GCONF_MAP_BOOL }, + { "thread_subject", "mail/display/thread_subject", E_GCONF_MAP_BOOL }, + { "hide_deleted", "mail/display/show_deleted", E_GCONF_MAP_BOOLNOT }, + { "preview_pane", "mail/display/show_preview", E_GCONF_MAP_BOOL }, + { "paned_size", "mail/display/paned_size", E_GCONF_MAP_INT }, + { "seen_timeout", "mail/display/mark_seen_timeout", E_GCONF_MAP_INT }, + { "do_seen_timeout", "mail/display/mark_seen", E_GCONF_MAP_BOOL }, + { "http_images", "mail/display/load_http_images", E_GCONF_MAP_INT }, + { "citation_highlight", "mail/display/mark_citations", E_GCONF_MAP_BOOL }, + { "citation_color", "mail/display/citation_colour", E_GCONF_MAP_COLOUR }, + { 0 }, +}; + +static e_gconf_map_t mail_format_map[] = { + /* /Mail/Format */ + { "message_display_style", "mail/display/message_style", E_GCONF_MAP_INT }, + { "send_html", "mail/composer/send_html", E_GCONF_MAP_BOOL }, + { "default_reply_style", "mail/format/reply_style", E_GCONF_MAP_INT }, + { "default_forward_style", "mail/format/forward_style", E_GCONF_MAP_INT }, + { "default_charset", "mail/composer/charset", E_GCONF_MAP_STRING }, + { "confirm_unwanted_html", "mail/prompts/unwanted_html", E_GCONF_MAP_BOOL }, + { 0 }, +}; + +static e_gconf_map_t mail_trash_map[] = { + /* /Mail/Trash */ + { "empty_on_exit", "mail/trash/empty_on_exit", E_GCONF_MAP_BOOL }, + { 0 }, +}; + +static e_gconf_map_t mail_prompts_map[] = { + /* /Mail/Prompts */ + { "confirm_expunge", "mail/prompts/expunge", E_GCONF_MAP_BOOL }, + { "empty_subject", "mail/prompts/empty_subject", E_GCONF_MAP_BOOL }, + { "only_bcc", "mail/prompts/only_bcc", E_GCONF_MAP_BOOL }, + { 0 } +}; + +static e_gconf_map_t mail_filters_map[] = { + /* /Mail/Filters */ + { "log", "mail/filters/log", E_GCONF_MAP_BOOL }, + { "log_path", "mail/filters/logfile", E_GCONF_MAP_STRING }, + { 0 } +}; + +static e_gconf_map_t mail_notify_map[] = { + /* /Mail/Notify */ + { "new_mail_notification", "mail/notify/type", E_GCONF_MAP_INT }, + { "new_mail_notification_sound_file", "mail/notify/sound", E_GCONF_MAP_STRING }, + { 0 } +}; + +static e_gconf_map_t mail_filesel_map[] = { + /* /Mail/Filesel */ + { "last_filesel_dir", "mail/save_dir", E_GCONF_MAP_STRING }, + { 0 } +}; + +static e_gconf_map_t mail_composer_map[] = { + /* /Mail/Composer */ + { "ViewFrom", "mail/composer/view/From", E_GCONF_MAP_BOOL }, + { "ViewReplyTo", "mail/composer/view/ReplyTo", E_GCONF_MAP_BOOL }, + { "ViewCC", "mail/composer/view/Cc", E_GCONF_MAP_BOOL }, + { "ViewBCC", "mail/composer/view/Bcc", E_GCONF_MAP_BOOL }, + { "ViewSubject", "mail/composer/view/Subject", E_GCONF_MAP_BOOL }, + { 0 }, +}; + +/* ********************************************************************** */ + +static e_gconf_map_t importer_elm_map[] = { + /* /Importer/Elm */ + { "mail", "importer/elm/mail", E_GCONF_MAP_BOOL }, + { "mail-imported", "importer/elm/mail-imported", E_GCONF_MAP_BOOL }, + { 0 }, +}; + +static e_gconf_map_t importer_pine_map[] = { + /* /Importer/Pine */ + { "mail", "importer/elm/mail", E_GCONF_MAP_BOOL }, + { "address", "importer/elm/address", E_GCONF_MAP_BOOL }, + { 0 }, +}; + +static e_gconf_map_t importer_netscape_map[] = { + /* /Importer/Netscape */ + { "mail", "importer/netscape/mail", E_GCONF_MAP_BOOL }, + { "settings", "importer/netscape/settings", E_GCONF_MAP_BOOL }, + { "filters", "importer/netscape/filters", E_GCONF_MAP_BOOL }, + { 0 }, +}; + +/* ********************************************************************** */ + +static e_gconf_map_list_t gconf_remap_list[] = { + { "/Mail/Accounts", mail_accounts_map }, + { "/Mail/Display", mail_display_map }, + { "/Mail/Format", mail_format_map }, + { "/Mail/Trash", mail_trash_map }, + { "/Mail/Prompts", mail_prompts_map }, + { "/Mail/Filters", mail_filters_map }, + { "/Mail/Notify", mail_notify_map }, + { "/Mail/Filesel", mail_filesel_map }, + { "/Mail/Composer", mail_composer_map }, + + { "/Importer/Elm", importer_elm_map }, + { "/Importer/Pine", importer_pine_map }, + { "/Importer/Netscape", importer_netscape_map }, + + { 0 }, +}; + +static struct { + char *label; + char *colour; +} label_default[5] = { + { N_("Important"), "#EF2929" }, /* red */ + { N_("Work"), "#F57900" }, /* orange */ + { N_("Personal"), "#4E9A06" }, /* green */ + { N_("To Do"), "#3465A4" }, /* blue */ + { N_("Later"), "#75507B" } /* purple */ +}; + +/* remaps mail config from bconf to gconf */ +static gboolean +bconf_import(GConfClient *gconf, xmlDocPtr config_xmldb) +{ + xmlNodePtr source; + char labx[16], colx[16]; + char *val, *lab, *col; + GSList *list, *l; + int i; + + e_bconf_import(gconf, config_xmldb, gconf_remap_list); + + /* Labels: + label string + label colour as integer + -> label string:# colour as hex */ + source = e_bconf_get_path(config_xmldb, "/Mail/Labels"); + if (source) { + list = NULL; + for (i = 0; i < 5; i++) { + sprintf(labx, "label_%d", i); + sprintf(colx, "color_%d", i); + lab = e_bconf_get_string(source, labx); + if ((col = e_bconf_get_value(source, colx))) { + sprintf(colx, "#%06x", atoi(col) & 0xffffff); + g_free(col); + } else + strcpy(colx, label_default[i].colour); + + val = g_strdup_printf("%s:%s", lab ? lab : label_default[i].label, colx); + list = g_slist_append(list, val); + g_free(lab); + } + + gconf_client_set_list(gconf, "/apps/evolution/mail/labels", GCONF_VALUE_STRING, list, NULL); + while (list) { + l = list->next; + g_free(list->data); + g_slist_free_1(list); + list = l; + } + } else { + g_warning("could not find /Mail/Labels in old config database, skipping"); + } + + /* Accounts: The flat bonobo-config structure is remapped to a list of xml blobs. Upgrades as necessary */ + e_bconf_import_xml_blob(gconf, config_xmldb, account_map, "/Mail/Accounts", + "/apps/evolution/mail/accounts", "account", "uid"); + + /* Same for signatures */ + e_bconf_import_xml_blob(gconf, config_xmldb, signature_map, "/Mail/Signatures", + "/apps/evolution/mail/signatures", "signature", NULL); + + return TRUE; +} + +static gboolean +em_migrate_1_2(const char *data_dir, xmlDocPtr config_xmldb, xmlDocPtr filters, xmlDocPtr vfolders, GError **error) +{ + GConfClient *gconf; + + gconf = gconf_client_get_default(); + bconf_import(gconf, config_xmldb); + g_object_unref(gconf); + + em_upgrade_xml_1_2(filters); + em_upgrade_xml_1_2(vfolders); + upgrade_passwords_1_2(); + + return TRUE; +} + +/* 1.4 upgrade functions */ + +#define EM_MIGRATE_SESSION_TYPE (em_migrate_session_get_type ()) +#define EM_MIGRATE_SESSION(obj) (CAMEL_CHECK_CAST((obj), EM_MIGRATE_SESSION_TYPE, EMMigrateSession)) +#define EM_MIGRATE_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), EM_MIGRATE_SESSION_TYPE, EMMigrateSessionClass)) +#define EM_MIGRATE_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), EM_MIGRATE_SESSION_TYPE)) + +typedef struct _EMMigrateSession { + CamelSession parent_object; + + CamelStore *store; /* new folder tree store */ + char *srcdir; /* old folder tree path */ +} EMMigrateSession; + +typedef struct _EMMigrateSessionClass { + CamelSessionClass parent_class; + +} EMMigrateSessionClass; + +static CamelType em_migrate_session_get_type (void); +static CamelSession *em_migrate_session_new (const char *path); + +static void +class_init (EMMigrateSessionClass *klass) +{ + ; +} + +static CamelType +em_migrate_session_get_type (void) +{ + static CamelType type = CAMEL_INVALID_TYPE; + + if (type == CAMEL_INVALID_TYPE) { + type = camel_type_register ( + camel_session_get_type (), + "EMMigrateSession", + sizeof (EMMigrateSession), + sizeof (EMMigrateSessionClass), + (CamelObjectClassInitFunc) class_init, + NULL, + NULL, + NULL); + } + + return type; +} + +static CamelSession * +em_migrate_session_new (const char *path) +{ + CamelSession *session; + + session = CAMEL_SESSION (camel_object_new (EM_MIGRATE_SESSION_TYPE)); + + camel_session_construct (session, path); + + return session; +} + + +#endif /* !G_OS_WIN32 */ + +static GtkWidget *window; +static GtkLabel *label; +static GtkProgressBar *progress; + +static void +em_migrate_setup_progress_dialog (const char *desc) +{ + GtkWidget *vbox, *hbox, *w; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title ((GtkWindow *) window, _("Migrating...")); + gtk_window_set_modal ((GtkWindow *) window, TRUE); + gtk_container_set_border_width ((GtkContainer *) window, 6); + + vbox = gtk_vbox_new (FALSE, 6); + gtk_widget_show (vbox); + gtk_container_add ((GtkContainer *) window, vbox); + + w = gtk_label_new (desc); + + gtk_label_set_line_wrap ((GtkLabel *) w, TRUE); + gtk_widget_show (w); + gtk_box_pack_start_defaults ((GtkBox *) vbox, w); + + hbox = gtk_hbox_new (FALSE, 6); + gtk_widget_show (hbox); + gtk_box_pack_start_defaults ((GtkBox *) vbox, hbox); + + label = (GtkLabel *) gtk_label_new (""); + gtk_widget_show ((GtkWidget *) label); + gtk_box_pack_start_defaults ((GtkBox *) hbox, (GtkWidget *) label); + + progress = (GtkProgressBar *) gtk_progress_bar_new (); + gtk_widget_show ((GtkWidget *) progress); + gtk_box_pack_start_defaults ((GtkBox *) hbox, (GtkWidget *) progress); + + gtk_widget_show (window); +} + +static void +em_migrate_close_progress_dialog (void) +{ + gtk_widget_destroy ((GtkWidget *) window); +} + +static void +em_migrate_set_folder_name (const char *folder_name) +{ + char *text; + + text = g_strdup_printf (_("Migrating '%s':"), folder_name); + gtk_label_set_text (label, text); + g_free (text); + + gtk_progress_bar_set_fraction (progress, 0.0); + while (gtk_events_pending ()) + gtk_main_iteration (); +} + +static void +em_migrate_set_progress (double percent) +{ + char text[5]; + + snprintf (text, sizeof (text), "%d%%", (int) (percent * 100.0f)); + + gtk_progress_bar_set_fraction (progress, percent); + gtk_progress_bar_set_text (progress, text); + + while (gtk_events_pending ()) + gtk_main_iteration (); +} + +#ifndef G_OS_WIN32 + +static gboolean +is_mail_folder (const char *metadata) +{ + xmlNodePtr node; + xmlDocPtr doc; + char *type; + + if (!(doc = xmlParseFile (metadata))) { + g_warning ("Cannot parse `%s'", metadata); + return FALSE; + } + + if (!(node = xmlDocGetRootElement (doc))) { + g_warning ("`%s' corrupt: document contains no root node", metadata); + xmlFreeDoc (doc); + return FALSE; + } + + if (!node->name || strcmp ((char *)node->name, "efolder") != 0) { + g_warning ("`%s' corrupt: root node is not 'efolder'", metadata); + xmlFreeDoc (doc); + return FALSE; + } + + node = node->children; + while (node != NULL) { + if (node->name && !strcmp ((char *)node->name, "type")) { + type = (char *)xmlNodeGetContent (node); + if (!strcmp ((char *)type, "mail")) { + xmlFreeDoc (doc); + xmlFree (type); + + return TRUE; + } + + xmlFree (type); + + break; + } + + node = node->next; + } + + xmlFreeDoc (doc); + + return FALSE; +} + +static gboolean +get_local_et_expanded (const char *dirname) +{ + xmlNodePtr node; + xmlDocPtr doc; + struct stat st; + char *buf, *p; + int thread_list; + + buf = g_strdup_printf ("%s/evolution/config/file:%s", g_get_home_dir (), dirname); + p = buf + strlen (g_get_home_dir ()) + strlen ("/evolution/config/file:"); + e_filename_make_safe (p); + + if (stat (buf, &st) == -1) { + g_free (buf); + return FALSE; + } + + if (!(doc = xmlParseFile (buf))) { + g_free (buf); + return FALSE; + } + + g_free (buf); + + if (!(node = xmlDocGetRootElement (doc)) || strcmp ((char *)node->name, "expanded_state") != 0) { + xmlFreeDoc (doc); + return FALSE; + } + + if (!(buf = (char *)xmlGetProp (node, (const unsigned char *)"default"))) { + xmlFreeDoc (doc); + return FALSE; + } + + thread_list = strcmp (buf, "0") == 0 ? 0 : 1; + xmlFree (buf); + + xmlFreeDoc (doc); + + return thread_list; +} + +static char * +get_local_store_uri (const char *dirname, char **namep, int *indexp) +{ + char *protocol, *name, *metadata, *tmp; + int index; + struct stat st; + xmlNodePtr node; + xmlDocPtr doc; + + metadata = g_build_filename(dirname, "local-metadata.xml", NULL); + + /* in 1.4, any errors are treated as defaults, this function cannot fail */ + + /* defaults */ + name = "mbox"; + protocol = "mbox"; + index = TRUE; + + if (stat (metadata, &st) == -1 || !S_ISREG (st.st_mode)) + goto nofile; + + doc = xmlParseFile(metadata); + if (doc == NULL) + goto nofile; + + node = doc->children; + if (strcmp((char *)node->name, "folderinfo")) + goto dodefault; + + for (node = node->children; node; node = node->next) { + if (node->name && !strcmp ((char *)node->name, "folder")) { + tmp = (char *)xmlGetProp (node, (const unsigned char *)"type"); + if (tmp) { + protocol = alloca(strlen(tmp)+1); + strcpy(protocol, tmp); + xmlFree(tmp); + } + tmp = (char *)xmlGetProp (node, (const unsigned char *)"name"); + if (tmp) { + name = alloca(strlen(tmp)+1); + strcpy(name, tmp); + xmlFree(tmp); + } + tmp = (char *)xmlGetProp (node, (const unsigned char *)"index"); + if (tmp) { + index = atoi(tmp); + xmlFree(tmp); + } + } + } +dodefault: + xmlFreeDoc (doc); +nofile: + g_free(metadata); + + *namep = g_strdup(name); + *indexp = index; + + return g_strdup_printf("%s:%s", protocol, dirname); +} + +#endif /* !G_OS_WIN32 */ + +enum { + CP_UNIQUE = 0, + CP_OVERWRITE, + CP_APPEND, +}; + +static int open_flags[3] = { + O_WRONLY | O_CREAT | O_TRUNC, + O_WRONLY | O_CREAT | O_TRUNC, + O_WRONLY | O_CREAT | O_APPEND, +}; + +static gboolean +cp (const char *src, const char *dest, gboolean show_progress, int mode) +{ + unsigned char readbuf[65536]; + ssize_t nread, nwritten; + int errnosav, readfd, writefd; + size_t total = 0; + struct stat st; + struct utimbuf ut; + + /* if the dest file exists and has content, abort - we don't + * want to corrupt their existing data */ + if (g_stat (dest, &st) == 0 && st.st_size > 0 && mode == CP_UNIQUE) { + errno = EEXIST; + return FALSE; + } + + if (g_stat (src, &st) == -1 + || (readfd = g_open (src, O_RDONLY | O_BINARY, 0)) == -1) + return FALSE; + + if ((writefd = g_open (dest, open_flags[mode] | O_BINARY, 0666)) == -1) { + errnosav = errno; + close (readfd); + errno = errnosav; + return FALSE; + } + + do { + do { + nread = read (readfd, readbuf, sizeof (readbuf)); + } while (nread == -1 && errno == EINTR); + + if (nread == 0) + break; + else if (nread < 0) + goto exception; + + do { + nwritten = write (writefd, readbuf, nread); + } while (nwritten == -1 && errno == EINTR); + + if (nwritten < nread) + goto exception; + + total += nwritten; + if (show_progress) + em_migrate_set_progress (((double) total) / ((double) st.st_size)); + } while (total < st.st_size); + + if (fsync (writefd) == -1) + goto exception; + + close (readfd); + if (close (writefd) == -1) + goto failclose; + + ut.actime = st.st_atime; + ut.modtime = st.st_mtime; + utime (dest, &ut); + chmod (dest, st.st_mode); + + return TRUE; + + exception: + + errnosav = errno; + close (readfd); + close (writefd); + errno = errnosav; + + failclose: + + errnosav = errno; + unlink (dest); + errno = errnosav; + + return FALSE; +} + +#ifndef G_OS_WIN32 + +static gboolean +cp_r (const char *src, const char *dest, const char *pattern, int mode) +{ + GString *srcpath, *destpath; + struct dirent *dent; + size_t slen, dlen; + struct stat st; + DIR *dir; + + if (g_mkdir_with_parents (dest, 0777) == -1) + return FALSE; + + if (!(dir = opendir (src))) + return FALSE; + + srcpath = g_string_new (src); + g_string_append_c (srcpath, '/'); + slen = srcpath->len; + + destpath = g_string_new (dest); + g_string_append_c (destpath, '/'); + dlen = destpath->len; + + while ((dent = readdir (dir))) { + if (!strcmp (dent->d_name, ".") || !strcmp (dent->d_name, "..")) + continue; + + g_string_truncate (srcpath, slen); + g_string_truncate (destpath, dlen); + + g_string_append (srcpath, dent->d_name); + g_string_append (destpath, dent->d_name); + + if (stat (srcpath->str, &st) == -1) + continue; + + if (S_ISDIR (st.st_mode)) { + cp_r (srcpath->str, destpath->str, pattern, mode); + } else if (!pattern || !strcmp (dent->d_name, pattern)) { + cp (srcpath->str, destpath->str, FALSE, mode); + } + } + + closedir (dir); + + g_string_free (destpath, TRUE); + g_string_free (srcpath, TRUE); + + return TRUE; +} + +static void +mbox_build_filename (GString *path, const char *toplevel_dir, const char *full_name) +{ + const char *start, *inptr = full_name; + int subdirs = 0; + + while (*inptr != '\0') { + if (*inptr == '/') + subdirs++; + inptr++; + } + + g_string_assign(path, toplevel_dir); + g_string_append_c (path, '/'); + + inptr = full_name; + while (*inptr != '\0') { + start = inptr; + while (*inptr != '/' && *inptr != '\0') + inptr++; + + g_string_append_len (path, start, inptr - start); + + if (*inptr == '/') { + g_string_append (path, ".sbd/"); + inptr++; + + /* strip extranaeous '/'s */ + while (*inptr == '/') + inptr++; + } + } +} + +static gboolean +em_migrate_folder(EMMigrateSession *session, const char *dirname, const char *full_name, GError **error) +{ + CamelFolder *old_folder = NULL, *new_folder = NULL; + CamelStore *local_store = NULL; + CamelException ex; + char *name, *uri; + GPtrArray *uids; + struct stat st; + gboolean thread_list; + int index, i; + GString *src, *dest; + gboolean success = FALSE; + + camel_exception_init (&ex); + + src = g_string_new(""); + + g_string_printf(src, "%s/folder-metadata.xml", dirname); + if (stat (src->str, &st) == -1 + || !S_ISREG (st.st_mode) + || !is_mail_folder(src->str)) { + /* Not an evolution mail folder */ + g_string_free(src, TRUE); + return TRUE; + } + + dest = g_string_new(""); + uri = get_local_store_uri(dirname, &name, &index); + em_migrate_set_folder_name (full_name); + thread_list = get_local_et_expanded (dirname); + + /* Manually copy local mbox files, its much faster */ + if (!strncmp (uri, "mbox:", 5)) { + static char *meta_ext[] = { ".summary", ".ibex.index", ".ibex.index.data" }; + size_t slen, dlen; + FILE *fp; + char *p; + int mode; + + g_string_printf (src, "%s/%s", uri + 5, name); + mbox_build_filename (dest, ((CamelService *)session->store)->url->path, full_name); + p = strrchr (dest->str, '/'); + *p = '\0'; + + slen = src->len; + dlen = dest->len; + + if (g_mkdir_with_parents (dest->str, 0777) == -1 && errno != EEXIST) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to create new folder `%s': %s"), + dest->str, g_strerror (errno)); + goto fatal; + } + + *p = '/'; + mode = CP_UNIQUE; + retry_copy: + if (!cp (src->str, dest->str, TRUE, mode)) { + if (errno == EEXIST) { + int save = errno; + + switch (e_error_run(NULL, "mail:ask-migrate-existing", src->str, dest->str, NULL)) { + case GTK_RESPONSE_ACCEPT: + mode = CP_OVERWRITE; + goto retry_copy; + case GTK_RESPONSE_OK: + mode = CP_APPEND; + goto retry_copy; + case GTK_RESPONSE_REJECT: + goto ignore; + } + + errno = save; + } + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to copy folder `%s' to `%s': %s"), + src->str, dest->str, g_strerror (errno)); + goto fatal; + } + ignore: + + /* create a .cmeta file specifying to index and/or thread the folder */ + g_string_truncate (dest, dlen); + g_string_append (dest, ".cmeta"); + if ((fp = fopen (dest->str, "w")) != NULL) { + int fd = fileno (fp); + + /* write the magic string */ + if (fwrite ("CLMD", 4, 1, fp) != 1) + goto cmeta_err; + + /* write the version (1) */ + if (camel_file_util_encode_uint32 (fp, 1) == -1) + goto cmeta_err; + + /* write the meta count */ + if (camel_file_util_encode_uint32 (fp, thread_list ? 1 : 0) == -1) + goto cmeta_err; + + if (!thread_list) { + if (camel_file_util_encode_string (fp, "evolution:thread_list") == -1) + goto cmeta_err; + + if (camel_file_util_encode_string (fp, !thread_list ? "1" : "0") == -1) + goto cmeta_err; + } + + /* write the prop count (only prop is the index prop) */ + if (camel_file_util_encode_uint32 (fp, 1) == -1) + goto cmeta_err; + + /* write the index prop tag (== CAMEL_FOLDER_ARG_LAST|CAMEL_ARG_BOO) */ + if (camel_file_util_encode_uint32 (fp, CAMEL_FOLDER_ARG_LAST|CAMEL_ARG_BOO) == -1) + goto cmeta_err; + + /* write the index prop value */ + if (camel_file_util_encode_uint32 (fp, 1) == -1) + goto cmeta_err; + + fflush (fp); + + if (fsync (fd) == -1) { + cmeta_err: + fclose (fp); + unlink (dest->str); + } else { + fclose (fp); + } + } + + /* copy over the metadata files */ + for (i = 0; i < sizeof(meta_ext)/sizeof(meta_ext[0]); i++) { + g_string_truncate (src, slen); + g_string_truncate (dest, dlen); + + g_string_append (src, meta_ext[i]); + g_string_append (dest, meta_ext[i]); + cp (src->str, dest->str, FALSE, CP_OVERWRITE); + } + } else { + guint32 flags = CAMEL_STORE_FOLDER_CREATE; + + if (!(local_store = camel_session_get_store ((CamelSession *) session, uri, &ex)) + || !(old_folder = camel_store_get_folder (local_store, name, 0, &ex))) + goto fatal; + + flags |= (index ? CAMEL_STORE_FOLDER_BODY_INDEX : 0); + if (!(new_folder = camel_store_get_folder (session->store, full_name, flags, &ex))) + goto fatal; + + if (!thread_list) { + camel_object_meta_set (new_folder, "evolution:thread_list", !thread_list ? "1" : "0"); + camel_object_state_write (new_folder); + } + + uids = camel_folder_get_uids (old_folder); + for (i = 0; i < uids->len; i++) { + CamelMimeMessage *message; + CamelMessageInfo *info; + + if (!(info = camel_folder_get_message_info (old_folder, uids->pdata[i]))) + continue; + + if (!(message = camel_folder_get_message (old_folder, uids->pdata[i], &ex))) { + camel_folder_free_message_info (old_folder, info); + camel_folder_free_uids (old_folder, uids); + goto fatal; + } + + camel_folder_append_message (new_folder, message, info, NULL, &ex); + camel_folder_free_message_info (old_folder, info); + camel_object_unref (message); + + if (camel_exception_is_set (&ex)) + break; + + em_migrate_set_progress (((double) i + 1) / ((double) uids->len)); + } + + camel_folder_free_uids (old_folder, uids); + + if (camel_exception_is_set (&ex)) + goto fatal; + } + success = TRUE; +fatal: + g_free (uri); + g_free (name); + g_string_free(src, TRUE); + g_string_free(dest, TRUE); + if (local_store) + camel_object_unref(local_store); + if (old_folder) + camel_object_unref(old_folder); + if (new_folder) + camel_object_unref(new_folder); + + if (camel_exception_is_set (&ex)) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + "%s", camel_exception_get_description (&ex)); + camel_exception_clear (&ex); + } + + return success; +} + +static gboolean +em_migrate_dir (EMMigrateSession *session, const char *dirname, const char *full_name, GError **error) +{ + char *path; + DIR *dir; + struct stat st; + struct dirent *dent; + gboolean success = TRUE; + + if (!em_migrate_folder(session, dirname, full_name, error)) + return FALSE; + + /* no subfolders, not readable, don't care */ + path = g_strdup_printf ("%s/subfolders", dirname); + if (stat (path, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_free (path); + return TRUE; + } + + if (!(dir = opendir (path))) { + g_free (path); + return TRUE; + } + + while (success && (dent = readdir (dir))) { + char *full_path; + char *name; + + if (dent->d_name[0] == '.') + continue; + + full_path = g_strdup_printf ("%s/%s", path, dent->d_name); + if (stat (full_path, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_free (full_path); + continue; + } + + name = g_strdup_printf ("%s/%s", full_name, dent->d_name); + success = em_migrate_dir (session, full_path, name, error); + g_free (full_path); + g_free (name); + } + + closedir (dir); + + g_free (path); + + return success; +} + +static gboolean +em_migrate_local_folders_1_4 (EMMigrateSession *session, GError **error) +{ + struct dirent *dent; + struct stat st; + DIR *dir; + gboolean success = TRUE; + + if (!(dir = opendir (session->srcdir))) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to scan for existing mailboxes at " + "`%s': %s"), session->srcdir, g_strerror (errno)); + return FALSE; + } + + em_migrate_setup_progress_dialog (_("The location and hierarchy of the Evolution mailbox " + "folders has changed since Evolution 1.x.\n\nPlease be " + "patient while Evolution migrates your folders...")); + + while (success && (dent = readdir (dir))) { + char *full_path; + + if (dent->d_name[0] == '.') + continue; + + full_path = g_strdup_printf ("%s/%s", session->srcdir, dent->d_name); + if (stat (full_path, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_free (full_path); + continue; + } + + success = em_migrate_dir (session, full_path, dent->d_name, error); + g_free (full_path); + } + + closedir (dir); + + em_migrate_close_progress_dialog (); + + return success; +} + +static char * +upgrade_xml_uris_1_4 (const char *uri) +{ + char *path, *prefix, *p; + CamelURL *url; + + if (!strncmp (uri, "file:", 5)) { + url = camel_url_new (uri, NULL); + camel_url_set_protocol (url, "email"); + camel_url_set_user (url, "local"); + camel_url_set_host (url, "local"); + + prefix = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); + if (strncmp (url->path, prefix, strlen (prefix)) != 0) { + /* uri is busticated - user probably copied from another user's home directory */ + camel_url_free (url); + g_free (prefix); + + return g_strdup (uri); + } + path = g_strdup (url->path + strlen (prefix)); + g_free (prefix); + + /* modify the path in-place */ + p = path + strlen (path) - 12; + while (p > path) { + if (!strncmp (p, "/subfolders/", 12)) + memmove (p, p + 11, strlen (p + 11) + 1); + + p--; + } + + camel_url_set_path (url, path); + g_free (path); + + path = camel_url_to_string (url, 0); + camel_url_free (url); + + return path; + } else { + return em_uri_from_camel (uri); + } +} + +static void +upgrade_vfolder_sources_1_4 (xmlDocPtr doc) +{ + xmlNodePtr root, node; + + if (!doc || !(root = xmlDocGetRootElement (doc))) + return; + + if (!root->name || strcmp ((char *)root->name, "filteroptions") != 0) { + /* root node is not , nothing to upgrade */ + return; + } + + if (!(node = xml_find_node (root, "ruleset"))) { + /* no ruleset node, nothing to upgrade */ + return; + } + + node = node->children; + while (node != NULL) { + if (node->name && !strcmp ((char *)node->name, "rule")) { + xmlNodePtr sources; + char *src; + + if (!(src = (char *)xmlGetProp (node, (const unsigned char *)"source"))) + src = (char *)xmlStrdup ((const unsigned char *)"local"); /* default to all local folders? */ + + xmlSetProp (node, (const unsigned char *)"source", (const unsigned char *)"incoming"); + + if (!(sources = xml_find_node (node, "sources"))) + sources = xmlNewChild (node, NULL, (const unsigned char *)"sources", NULL); + + xmlSetProp (sources, (const unsigned char *)"with", (unsigned char *)src); + xmlFree (src); + } + + node = node->next; + } +} + +static char * +get_nth_sig (int id) +{ + ESignatureList *list; + ESignature *sig; + EIterator *iter; + char *uid = NULL; + int i = 0; + + list = mail_config_get_signatures (); + iter = e_list_get_iterator ((EList *) list); + + while (e_iterator_is_valid (iter) && i < id) { + e_iterator_next (iter); + i++; + } + + if (i == id && e_iterator_is_valid (iter)) { + sig = (ESignature *) e_iterator_get (iter); + uid = g_strdup (sig->uid); + } + + g_object_unref (iter); + + return uid; +} + +static void +em_upgrade_accounts_1_4 (void) +{ + EAccountList *accounts; + EIterator *iter; + + if (!(accounts = mail_config_get_accounts ())) + return; + + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + EAccount *account = (EAccount *) e_iterator_get (iter); + char *url; + + if (account->drafts_folder_uri) { + url = upgrade_xml_uris_1_4 (account->drafts_folder_uri); + g_free (account->drafts_folder_uri); + account->drafts_folder_uri = url; + } + + if (account->sent_folder_uri) { + url = upgrade_xml_uris_1_4 (account->sent_folder_uri); + g_free (account->sent_folder_uri); + account->sent_folder_uri = url; + } + + if (account->id->sig_uid && !strncmp (account->id->sig_uid, "::", 2)) { + int sig_id; + + sig_id = strtol (account->id->sig_uid + 2, NULL, 10); + g_free (account->id->sig_uid); + account->id->sig_uid = get_nth_sig (sig_id); + } + + e_iterator_next (iter); + } + + g_object_unref (iter); + + mail_config_save_accounts (); +} + +static gboolean +em_migrate_pop_uid_caches_1_4 (const char *data_dir, GError **error) +{ + GString *oldpath, *newpath; + struct dirent *dent; + size_t olen, nlen; + char *cache_dir; + DIR *dir; + gboolean success = TRUE; + + /* Sigh, too many unique strings to translate, for cases which shouldn't ever happen */ + + /* open the old cache dir */ + cache_dir = g_build_filename (g_get_home_dir (), "evolution", "mail", "pop3", NULL); + if (!(dir = opendir (cache_dir))) { + if (errno == ENOENT) { + g_free(cache_dir); + return TRUE; + } + + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to open old POP keep-on-server data " + "`%s': %s"), cache_dir, g_strerror (errno)); + g_free (cache_dir); + return FALSE; + } + + oldpath = g_string_new (cache_dir); + g_string_append_c (oldpath, '/'); + olen = oldpath->len; + g_free (cache_dir); + + cache_dir = g_build_filename (data_dir, "pop", NULL); + if (g_mkdir_with_parents (cache_dir, 0777) == -1) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to create POP3 keep-on-server data " + "directory `%s': %s"), cache_dir, + g_strerror (errno)); + g_string_free (oldpath, TRUE); + g_free (cache_dir); + closedir (dir); + return FALSE; + } + + newpath = g_string_new (cache_dir); + g_string_append_c (newpath, '/'); + nlen = newpath->len; + g_free (cache_dir); + + while (success && (dent = readdir (dir))) { + if (strncmp (dent->d_name, "cache-pop:__", 12) != 0) + continue; + + g_string_truncate (oldpath, olen); + g_string_truncate (newpath, nlen); + + g_string_append (oldpath, dent->d_name); + g_string_append (newpath, dent->d_name + 12); + + /* strip the trailing '_' */ + g_string_truncate (newpath, newpath->len - 1); + + if (g_mkdir_with_parents (newpath->str, 0777) == -1 + || !cp(oldpath->str, (g_string_append(newpath, "/uid-cache"))->str, FALSE, CP_UNIQUE)) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to copy POP3 keep-on-server data " + "`%s': %s"), oldpath->str, + g_strerror (errno)); + success = FALSE; + } + + } + + g_string_free (oldpath, TRUE); + g_string_free (newpath, TRUE); + + closedir (dir); + + return success; +} + +static gboolean +em_migrate_imap_caches_1_4 (const char *data_dir, GError **error) +{ + char *src, *dest; + struct stat st; + + src = g_build_filename (g_get_home_dir (), "evolution", "mail", "imap", NULL); + if (stat (src, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_free (src); + return TRUE; + } + + dest = g_build_filename (data_dir, "imap", NULL); + + /* we don't care if this fails, it's only a cache... */ + cp_r (src, dest, "summary", CP_OVERWRITE); + + g_free (dest); + g_free (src); + + return TRUE; +} + +static gboolean +em_migrate_folder_expand_state_1_4 (const char *data_dir, GError **error) +{ + GString *srcpath, *destpath; + size_t slen, dlen, rlen; + char *evo14_mbox_root; + struct dirent *dent; + struct stat st; + DIR *dir; + + srcpath = g_string_new (g_get_home_dir ()); + g_string_append (srcpath, "/evolution/config"); + if (stat (srcpath->str, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_string_free (srcpath, TRUE); + return TRUE; + } + + destpath = g_string_new (data_dir); + g_string_append (destpath, "/config"); + if (g_mkdir_with_parents (destpath->str, 0777) == -1 || !(dir = opendir (srcpath->str))) { + g_string_free (destpath, TRUE); + g_string_free (srcpath, TRUE); + return TRUE; + } + + g_string_append (srcpath, "/et-expanded-"); + slen = srcpath->len; + g_string_append (destpath, "/et-expanded-"); + dlen = destpath->len; + + evo14_mbox_root = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); + e_filename_make_safe (evo14_mbox_root); + rlen = strlen (evo14_mbox_root); + evo14_mbox_root = g_realloc (evo14_mbox_root, rlen + 2); + evo14_mbox_root[rlen++] = '_'; + evo14_mbox_root[rlen] = '\0'; + + while ((dent = readdir (dir))) { + char *full_name, *inptr, *buf = NULL; + const char *filename; + GString *new; + + if (strncmp (dent->d_name, "et-expanded-", 12) != 0) + continue; + + if (!strncmp (dent->d_name + 12, "file:", 5)) { + /* need to munge the filename */ + inptr = dent->d_name + 17; + + if (!strncmp (inptr, evo14_mbox_root, rlen)) { + /* this should always be the case afaik... */ + inptr += rlen; + new = g_string_new ("mbox:"); + g_string_append_printf (new, "%s/local#", data_dir); + + full_name = g_strdup (inptr); + inptr = full_name + strlen (full_name) - 12; + while (inptr > full_name) { + if (!strncmp (inptr, "_subfolders_", 12)) + memmove (inptr, inptr + 11, strlen (inptr + 11) + 1); + + inptr--; + } + + g_string_append (new, full_name); + g_free (full_name); + + filename = buf = new->str; + g_string_free (new, FALSE); + e_filename_make_safe (buf); + } else { + /* but just in case... */ + filename = dent->d_name + 12; + } + } else { + /* no munging needed */ + filename = dent->d_name + 12; + } + + g_string_append (srcpath, dent->d_name + 12); + g_string_append (destpath, filename); + g_free (buf); + + cp (srcpath->str, destpath->str, FALSE, CP_UNIQUE); + + g_string_truncate (srcpath, slen); + g_string_truncate (destpath, dlen); + } + + closedir (dir); + + g_free (evo14_mbox_root); + g_string_free (destpath, TRUE); + g_string_free (srcpath, TRUE); + + return TRUE; +} + +static gboolean +em_migrate_folder_view_settings_1_4 (const char *data_dir, GError **error) +{ + GString *srcpath, *destpath; + size_t slen, dlen, rlen; + char *evo14_mbox_root; + struct dirent *dent; + struct stat st; + DIR *dir; + + srcpath = g_string_new (g_get_home_dir ()); + g_string_append (srcpath, "/evolution/views/mail"); + if (stat (srcpath->str, &st) == -1 || !S_ISDIR (st.st_mode)) { + g_string_free (srcpath, TRUE); + return TRUE; + } + + destpath = g_string_new (data_dir); + g_string_append (destpath, "/views"); + if (g_mkdir_with_parents (destpath->str, 0777) == -1 || !(dir = opendir (srcpath->str))) { + g_string_free (destpath, TRUE); + g_string_free (srcpath, TRUE); + return TRUE; + } + + g_string_append_c (srcpath, '/'); + slen = srcpath->len; + g_string_append_c (destpath, '/'); + dlen = destpath->len; + + evo14_mbox_root = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); + e_filename_make_safe (evo14_mbox_root); + rlen = strlen (evo14_mbox_root); + evo14_mbox_root = g_realloc (evo14_mbox_root, rlen + 2); + evo14_mbox_root[rlen++] = '_'; + evo14_mbox_root[rlen] = '\0'; + + while ((dent = readdir (dir))) { + char *full_name, *inptr, *buf = NULL; + const char *filename, *ext; + size_t prelen = 0; + GString *new; + + if (dent->d_name[0] == '.') + continue; + + if (!(ext = strrchr (dent->d_name, '.'))) + continue; + + if (!strcmp (ext, ".galview") || !strcmp ((char *)dent->d_name, "galview.xml")) { + /* just copy the file */ + filename = dent->d_name; + goto copy; + } else if (strcmp (ext, ".xml") != 0) { + continue; + } + + if (!strncmp ((const char *)dent->d_name, "current_view-", 13)) { + prelen = 13; + } else if (!strncmp ((const char *)dent->d_name, "custom_view-", 12)) { + prelen = 12; + } else { + /* huh? wtf is this file? */ + continue; + } + + if (!strncmp (dent->d_name + prelen, "file:", 5)) { + /* need to munge the filename */ + inptr = dent->d_name + prelen + 5; + + if (!strncmp (inptr, evo14_mbox_root, rlen)) { + /* this should always be the case afaik... */ + inptr += rlen; + new = g_string_new ("mbox:"); + g_string_append_printf (new, "%s/local#", data_dir); + + full_name = g_strdup (inptr); + inptr = full_name + strlen (full_name) - 12; + while (inptr > full_name) { + if (!strncmp (inptr, "_subfolders_", 12)) + memmove (inptr, inptr + 11, strlen (inptr + 11) + 1); + + inptr--; + } + + g_string_append (new, full_name); + g_free (full_name); + + filename = buf = new->str; + g_string_free (new, FALSE); + e_filename_make_safe (buf); + } else { + /* but just in case... */ + filename = dent->d_name + prelen; + } + } else { + /* no munging needed */ + filename = dent->d_name + prelen; + } + + copy: + g_string_append (srcpath, dent->d_name); + if (prelen > 0) + g_string_append_len (destpath, dent->d_name, prelen); + g_string_append (destpath, filename); + g_free (buf); + + cp (srcpath->str, destpath->str, FALSE, CP_UNIQUE); + + g_string_truncate (srcpath, slen); + g_string_truncate (destpath, dlen); + } + + closedir (dir); + + g_free (evo14_mbox_root); + g_string_free (destpath, TRUE); + g_string_free (srcpath, TRUE); + + return TRUE; +} + +#define SUBFOLDER_DIR_NAME "subfolders" +#define SUBFOLDER_DIR_NAME_LEN 10 + +static char * +e_path_to_physical (const char *prefix, const char *vpath) +{ + const char *p, *newp; + char *dp; + char *ppath; + int ppath_len; + int prefix_len; + + while (*vpath == '/') + vpath++; + if (!prefix) + prefix = ""; + + /* Calculate the length of the real path. */ + ppath_len = strlen (vpath); + ppath_len++; /* For the ending zero. */ + + prefix_len = strlen (prefix); + ppath_len += prefix_len; + ppath_len++; /* For the separating slash. */ + + /* Take account of the fact that we need to translate every + * separator into `subfolders/'. + */ + p = vpath; + while (1) { + newp = strchr (p, '/'); + if (newp == NULL) + break; + + ppath_len += SUBFOLDER_DIR_NAME_LEN; + ppath_len++; /* For the separating slash. */ + + /* Skip consecutive slashes. */ + while (*newp == '/') + newp++; + + p = newp; + }; + + ppath = g_malloc (ppath_len); + dp = ppath; + + memcpy (dp, prefix, prefix_len); + dp += prefix_len; + *(dp++) = '/'; + + /* Copy the mangled path. */ + p = vpath; + while (1) { + newp = strchr (p, '/'); + if (newp == NULL) { + strcpy (dp, p); + break; + } + + memcpy (dp, p, newp - p + 1); /* `+ 1' to copy the slash too. */ + dp += newp - p + 1; + + memcpy (dp, SUBFOLDER_DIR_NAME, SUBFOLDER_DIR_NAME_LEN); + dp += SUBFOLDER_DIR_NAME_LEN; + + *(dp++) = '/'; + + /* Skip consecutive slashes. */ + while (*newp == '/') + newp++; + + p = newp; + } + + return ppath; +} + +static gboolean +em_migrate_imap_cmeta_1_4(const char *data_dir, GError **error) +{ + GConfClient *gconf; + GSList *paths, *p; + EAccountList *accounts; + const EAccount *account; + + if (!(accounts = mail_config_get_accounts())) + return TRUE; + + gconf = gconf_client_get_default(); + paths = gconf_client_get_list(gconf, "/apps/evolution/shell/offline/folder_paths", GCONF_VALUE_STRING, NULL); + for (p = paths;p;p = g_slist_next(p)) { + char *name, *path; + + name = p->data; + if (*name) + name++; + path = strchr(name, '/'); + if (path) { + *path++ = 0; + account = e_account_list_find(accounts, E_ACCOUNT_FIND_NAME, name); + if (account && !strncmp(account->source->url, "imap:", 5)) { + CamelURL *url = camel_url_new(account->source->url, NULL); + + if (url) { + char *dir, *base; + + base = g_strdup_printf("%s/imap/%s@%s/folders", + data_dir, + url->user?url->user:"", + url->host?url->host:""); + + dir = e_path_to_physical(base, path); + if (g_mkdir_with_parents(dir, 0777) == 0) { + char *cmeta; + FILE *fp; + + cmeta = g_build_filename(dir, "cmeta", NULL); + fp = fopen(cmeta, "w"); + if (fp) { + /* header/version */ + fwrite("CLMD", 4, 1, fp); + camel_file_util_encode_uint32(fp, 1); + /* meta count, do we have any metadata? */ + camel_file_util_encode_uint32(fp, 0); + /* prop count */ + camel_file_util_encode_uint32(fp, 1); + /* sync offline property */ + camel_file_util_encode_uint32(fp, CAMEL_DISCO_FOLDER_OFFLINE_SYNC); + camel_file_util_encode_uint32(fp, 1); + fclose(fp); + } else { + g_warning("couldn't create imap folder cmeta file '%s'", cmeta); + } + g_free(cmeta); + } else { + g_warning("couldn't create imap folder directory '%s'", dir); + } + g_free(dir); + g_free(base); + camel_url_free(url); + } + } else + g_warning("can't find offline folder '%s' '%s'", name, path); + } + g_free(p->data); + } + g_slist_free(paths); + g_object_unref(gconf); + + /* we couldn't care less if this doesn't work */ + + return TRUE; +} + +static void +remove_system_searches(xmlDocPtr searches) +{ + xmlNodePtr node; + + /* in pre 2.0, system searches were stored in the user + * searches.xml file with the source set to 'demand'. In 2.0+ + * the system searches are stored in the system + * searchtypes.xml file instead */ + + node = xmlDocGetRootElement(searches); + if (!node->name || strcmp((char *)node->name, "filteroptions")) + return; + + if (!(node = xml_find_node(node, "ruleset"))) + return; + + node = node->children; + while (node != NULL) { + xmlNodePtr nnode = node->next; + + if (node->name && !strcmp ((char *)node->name, "rule")) { + char *src; + + src = (char *)xmlGetProp(node, (unsigned char *)"source"); + if (src && !strcmp((char *)src, "demand")) { + xmlUnlinkNode(node); + xmlFreeNodeList(node); + } + xmlFree (src); + } + + node = nnode; + } +} + +static gboolean +em_migrate_1_4 (const char *data_dir, xmlDocPtr filters, xmlDocPtr vfolders, GError **error) +{ + EMMigrateSession *session; + CamelException lex; + struct stat st; + gchar *path; + xmlDocPtr searches; + + camel_init (data_dir, TRUE); + camel_provider_init(); + session = (EMMigrateSession *) em_migrate_session_new (data_dir); + + session->srcdir = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); + + path = g_strdup_printf ("mbox:%s/.evolution/mail/local", g_get_home_dir ()); + if (stat (path + 5, &st) == -1) { + if (errno != ENOENT || g_mkdir_with_parents (path + 5, 0777) == -1) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Failed to create local mail storage " + "`%s': %s"), path + 5, g_strerror (errno)); + g_free (session->srcdir); + camel_object_unref (session); + g_free (path); + return FALSE; + } + } + + camel_exception_init (&lex); + if (!(session->store = camel_session_get_store ((CamelSession *) session, path, &lex))) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Failed to create local mail storage `%s': %s"), + path, lex.desc); + g_free (session->srcdir); + camel_object_unref (session); + camel_exception_clear (&lex); + g_free (path); + return FALSE; + } + g_free (path); + + if (!em_migrate_local_folders_1_4 (session, error)) + return FALSE; + + camel_object_unref (session->store); + g_free (session->srcdir); + + camel_object_unref (session); + + em_upgrade_accounts_1_4(); + + upgrade_xml_uris(filters, upgrade_xml_uris_1_4); + upgrade_vfolder_sources_1_4(vfolders); + upgrade_xml_uris(vfolders, upgrade_xml_uris_1_4); + + path = g_build_filename(g_get_home_dir(), "evolution", NULL); + searches = emm_load_xml(path, "searches.xml"); + g_free(path); + if (searches) { + remove_system_searches(searches); + emm_save_xml(searches, data_dir, "searches.xml"); + xmlFreeDoc(searches); + } + + if (!em_migrate_pop_uid_caches_1_4 (data_dir, error)) + return FALSE; + + /* these are non-fatal */ + em_migrate_imap_caches_1_4 (data_dir, error); + g_clear_error (error); + em_migrate_folder_expand_state_1_4 (data_dir, error); + g_clear_error (error); + em_migrate_folder_view_settings_1_4 (data_dir, error); + g_clear_error (error); + em_migrate_imap_cmeta_1_4 (data_dir, error); + g_clear_error (error); + + return TRUE; +} + +static void +em_update_accounts_2_11 (void) +{ + EAccountList *accounts; + EIterator *iter; + gboolean changed = FALSE; + + if (!(accounts = mail_config_get_accounts ())) + return; + + iter = e_list_get_iterator ((EList *) accounts); + while (e_iterator_is_valid (iter)) { + EAccount *account = (EAccount *) e_iterator_get (iter); + + if (g_str_has_prefix (account->source->url, "spool://")) { + if (g_file_test (account->source->url + 8, G_FILE_TEST_IS_DIR)) { + char *str = g_strdup_printf ("spooldir://%s", account->source->url + 8); + + g_free (account->source->url); + account->source->url = str; + changed = TRUE; + } + } + + e_iterator_next (iter); + } + + g_object_unref (iter); + + if (changed) + mail_config_save_accounts (); +} + +#endif /* !G_OS_WIN32 */ + +static gboolean +emm_setup_initial(const gchar *data_dir) +{ + GDir *dir; + const char *d; + char *local = NULL, *base; + const gchar * const *language_names; + + /* special-case - this means brand new install of evolution */ + /* FIXME: create default folders and stuff... */ + + d(printf("Setting up initial mail tree\n")); + + base = g_build_filename(data_dir, "local", NULL); + if (g_mkdir_with_parents(base, 0777) == -1 && errno != EEXIST) { + g_free(base); + return FALSE; + } + + /* e.g. try en-AU then en, etc */ + language_names = g_get_language_names (); + while (*language_names != NULL) { + local = g_build_filename ( + EVOLUTION_PRIVDATADIR, "default", + *language_names, "mail", "local", NULL); + if (g_file_test (local, G_FILE_TEST_EXISTS)) + break; + g_free (local); + language_names++; + } + + /* Make sure we found one. */ + g_return_val_if_fail (*language_names != NULL, FALSE); + + dir = g_dir_open(local, 0, NULL); + if (dir) { + while ((d = g_dir_read_name(dir))) { + char *src, *dest; + + src = g_build_filename(local, d, NULL); + dest = g_build_filename(base, d, NULL); + + cp(src, dest, FALSE, CP_UNIQUE); + g_free(dest); + g_free(src); + } + g_dir_close(dir); + } + + g_free(local); + g_free(base); + + return TRUE; +} + +static gboolean +is_in_plugs_list (GSList *list, const gchar *value) +{ + GSList *l; + + for (l = list; l; l = l->next) { + if (l->data && !strcmp (l->data, value)) + return TRUE; + } + + return FALSE; +} + +/* + * em_update_message_notify_settings_2_21 + * DBus plugin and sound email notification was merged to mail-notification plugin, + * so move these options to new locations. + */ +static void +em_update_message_notify_settings_2_21 (void) +{ + GConfClient *client; + GConfValue *is_key; + gboolean dbus, status; + GSList *list; + gchar *str; + gint val; + + client = gconf_client_get_default (); + + is_key = gconf_client_get (client, "/apps/evolution/eplugin/mail-notification/dbus-enabled", NULL); + if (is_key) { + /* already migrated, so do not migrate again */ + gconf_value_free (is_key); + g_object_unref (client); + + return; + } + + gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/status-blink-icon", + gconf_client_get_bool (client, "/apps/evolution/mail/notification/blink-status-icon", NULL), NULL); + gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/status-notification", + gconf_client_get_bool (client, "/apps/evolution/mail/notification/notification", NULL), NULL); + + list = gconf_client_get_list (client, "/apps/evolution/eplugin/disabled", GCONF_VALUE_STRING, NULL); + dbus = !is_in_plugs_list (list, "org.gnome.evolution.new_mail_notify"); + status = !is_in_plugs_list (list, "org.gnome.evolution.mail_notification"); + + gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/dbus-enabled", dbus, NULL); + gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/status-enabled", status, NULL); + + if (!status) { + /* enable this plugin, because it holds all those other things */ + GSList *plugins, *l; + + plugins = e_plugin_list_plugins (); + + for (l = plugins; l; l = l->next) { + EPlugin *p = l->data; + + if (p && p->id && !strcmp (p->id, "org.gnome.evolution.mail_notification")) { + e_plugin_enable (p, 1); + break; + } + } + + g_slist_foreach (plugins, (GFunc)g_object_unref, NULL); + g_slist_free (plugins); + } + + g_slist_foreach (list, (GFunc) g_free, NULL); + g_slist_free (list); + + val = gconf_client_get_int (client, "/apps/evolution/mail/notify/type", NULL); + gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/sound-enabled", val == 1 || val == 2, NULL); + gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/sound-beep", val == 0 || val == 1, NULL); + + str = gconf_client_get_string (client, "/apps/evolution/mail/notify/sound", NULL); + gconf_client_set_string (client, "/apps/evolution/eplugin/mail-notification/sound-file", str ? str : "", NULL); + g_free (str); + + g_object_unref (client); +} + +/* fixing typo in SpamAssassin name */ +static void +em_update_sa_junk_setting_2_23 (void) +{ + GConfClient *client; + GConfValue *key; + + client = gconf_client_get_default (); + + key = gconf_client_get (client, "/apps/evolution/mail/junk/default_plugin", NULL); + if (key) { + const char *str = gconf_value_get_string (key); + + if (str && strcmp (str, "Spamassasin") == 0) + gconf_client_set_string (client, "/apps/evolution/mail/junk/default_plugin", "SpamAssassin", NULL); + + gconf_value_free (key); + g_object_unref (client); + + return; + } + + g_object_unref (client); +} + + +static void +migrate_folders(CamelStore *store, CamelFolderInfo *fi, const char *acc, CamelException *ex) +{ + CamelFolder *folder; + + while (fi) { + char *tmp = g_strdup_printf ("%s/%s", acc, fi->full_name); + em_migrate_set_folder_name (tmp); + g_free (tmp); + folder = camel_store_get_folder (store, fi->full_name, 0, ex); + if (folder != NULL) + camel_folder_summary_migrate_infos (folder->summary); + migrate_folders(store, fi->child, acc, ex); + fi = fi->next; + } +} + +static CamelStore * +setup_local_store (EShellModule *shell_module, + EMMigrateSession *session) +{ + CamelURL *url; + const gchar *data_dir; + char *tmp; + CamelStore *store; + + url = camel_url_new("mbox:", NULL); + data_dir = e_shell_module_get_data_dir (shell_module); + tmp = g_build_filename (data_dir, "local", NULL); + camel_url_set_path(url, tmp); + g_free(tmp); + tmp = camel_url_to_string(url, 0); + store = (CamelStore *)camel_session_get_service(CAMEL_SESSION (session), tmp, CAMEL_PROVIDER_STORE, NULL); + g_free(tmp); + + return store; + +} +static void +migrate_to_db (EShellModule *shell_module) +{ + EMMigrateSession *session; + EAccountList *accounts; + EIterator *iter; + int i=0, len; + CamelStore *store = NULL; + CamelFolderInfo *info; + const gchar *data_dir; + + if (!(accounts = mail_config_get_accounts ())) + return; + + iter = e_list_get_iterator ((EList *) accounts); + len = e_list_length ((EList *) accounts); + + data_dir = e_shell_module_get_data_dir (shell_module); + session = (EMMigrateSession *) em_migrate_session_new (data_dir); + camel_session_set_online ((CamelSession *) session, FALSE); + em_migrate_setup_progress_dialog (_("The summary format of the Evolution mailbox " + "folders has been moved to SQLite since Evolution 2.24.\n\nPlease be " + "patient while Evolution migrates your folders...")); + + em_migrate_set_progress ( (double)i/(len+1)); + store = setup_local_store (shell_module, session); + info = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, NULL); + if (info) { + migrate_folders(store, info, _("On This Computer"), NULL); + } + i++; + em_migrate_set_progress ( (double)i/(len+1)); + + + while (e_iterator_is_valid (iter)) { + EAccount *account = (EAccount *) e_iterator_get (iter); + EAccountService *service; + const char *name; + + + service = account->source; + name = account->name; + em_migrate_set_progress ( (double)i/(len+1)); + if (account->enabled + && service->url != NULL + && service->url[0] + && strncmp(service->url, "mbox:", 5) != 0) { + + CamelException ex; + + camel_exception_init (&ex); + e_mail_shell_module_load_store_by_uri (service->url, name); + + store = (CamelStore *) camel_session_get_service (CAMEL_SESSION (session), service->url, CAMEL_PROVIDER_STORE, &ex); + info = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, &ex); + if (info) { + migrate_folders(store, info, account->name, &ex); + + } else + printf("%s:%s: failed to get folder infos \n", G_STRLOC, G_STRFUNC); + camel_exception_clear(&ex); + + } + i++; + e_iterator_next (iter); + + } + + //camel_session_set_online ((CamelSession *) session, TRUE); + + g_object_unref (iter); + em_migrate_close_progress_dialog (); + + g_object_unref (session); +} + +gboolean +e_mail_shell_module_migrate (EShellModule *shell_module, + gint major, + gint minor, + gint micro, + GError **error) +{ + struct stat st; + const gchar *data_dir; + gchar *path; + + /* make sure ~/.evolution/mail exists */ + data_dir = e_shell_module_get_data_dir (shell_module); + if (g_stat (data_dir, &st) == -1) { + if (errno != ENOENT || g_mkdir_with_parents (data_dir, 0777) == -1) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to create local mail folders at " + "`%s': %s"), data_dir, g_strerror (errno)); + return FALSE; + } + } + + if (major == 0) + return emm_setup_initial (data_dir); + + if (major == 1 && minor < 5) { +#ifndef G_OS_WIN32 + xmlDocPtr config_xmldb = NULL, filters, vfolders; + + path = g_build_filename (g_get_home_dir (), "evolution", NULL); + if (minor <= 2 && !(config_xmldb = emm_load_xml (path, "config.xmldb"))) { + g_set_error ( + error, E_SHELL_MIGRATE_ERROR, + E_SHELL_MIGRATE_ERROR_FAILED, + _("Unable to read settings from previous " + "Evolution install, `evolution/config.xmldb' " + "does not exist or is corrupt.")); + return FALSE; + } + filters = emm_load_xml (path, "filters.xml"); + vfolders = emm_load_xml (path, "vfolders.xml"); + g_free (path); + + if (minor == 0) { + if (!em_migrate_1_0 (data_dir, config_xmldb, filters, vfolders, error)) { + xmlFreeDoc (config_xmldb); + xmlFreeDoc (filters); + xmlFreeDoc (vfolders); + return FALSE; + } + } + + if (minor <= 2) { + if (!em_migrate_1_2 (data_dir, config_xmldb, filters, vfolders, error)) { + xmlFreeDoc (config_xmldb); + xmlFreeDoc (filters); + xmlFreeDoc (vfolders); + return FALSE; + } + + xmlFreeDoc (config_xmldb); + } + + if (minor <= 4) { + if (!em_migrate_1_4 (data_dir, filters, vfolders, error)) { + xmlFreeDoc (filters); + xmlFreeDoc (vfolders); + return FALSE; + } + } + + if (filters) { + emm_save_xml (filters, path, "filters.xml"); + xmlFreeDoc (filters); + } + + if (vfolders) { + emm_save_xml (vfolders, path, "vfolders.xml"); + xmlFreeDoc (vfolders); + } + + g_free (path); +#else + g_error ("Upgrading from ancient versions not supported on Windows"); +#endif + } + + if (major < 2 || (major == 2 && minor < 12)) { +#ifndef G_OS_WIN32 + em_update_accounts_2_11 (); +#else + g_error ("Upgrading from ancient versions not supported on Windows"); +#endif + } + + + if (major < 2 || (major == 2 && minor < 22)) + em_update_message_notify_settings_2_21 (); + + if (major < 2 || (major == 2 && minor < 24)) { + em_update_sa_junk_setting_2_23 (); + migrate_to_db (shell_module); + } + + return TRUE; +} diff --git a/mail/e-mail-shell-module-migrate.h b/mail/e-mail-shell-module-migrate.h new file mode 100644 index 0000000000..e9ec2115c0 --- /dev/null +++ b/mail/e-mail-shell-module-migrate.h @@ -0,0 +1,38 @@ +/* + * e-mail-shell-module-migrate.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SHELL_MODULE_MIGRATE_H +#define E_MAIL_SHELL_MODULE_MIGRATE_H + +#include +#include + +G_BEGIN_DECLS + +gboolean e_mail_shell_module_migrate (EShellModule *shell_module, + gint major, + gint minor, + gint micro, + GError **error); + +G_END_DECLS + +#endif /* E_MAIL_SHELL_MODULE_MIGRATE_H */ diff --git a/mail/e-mail-shell-module.c b/mail/e-mail-shell-module.c new file mode 100644 index 0000000000..cd74a76cd9 --- /dev/null +++ b/mail/e-mail-shell-module.c @@ -0,0 +1,175 @@ +/* + * e-mail-shell-module.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include + +#include "shell/e-shell.h" +#include "shell/e-shell-module.h" +#include "shell/e-shell-window.h" + +#include "e-mail-shell-view.h" +#include "e-mail-shell-module.h" +#include "e-mail-shell-module-migrate.h" + +#define MODULE_NAME "mail" +#define MODULE_ALIASES "" +#define MODULE_SCHEMES "mailto:email" +#define MODULE_SORT_ORDER 200 + +/* Module Entry Point */ +void e_shell_module_init (GTypeModule *type_module); + +static void +action_mail_folder_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ + /* FIXME */ +} + +static void +action_mail_message_new_cb (GtkAction *action, + EShellWindow *shell_window) +{ + /* FIXME */ +} + +static GtkActionEntry item_entries[] = { + + { "mail-message-new", + "mail-message-new", + N_("_Mail Message"), /* XXX C_() here */ + "m", + N_("Compose a new mail message"), + G_CALLBACK (action_mail_message_new_cb) } +}; + +static GtkActionEntry source_entries[] = { + + { "mail-folder-new", + "folder-new", + N_("Mail _Folder"), + NULL, + N_("Create a new mail folder"), + G_CALLBACK (action_mail_folder_new_cb) } +}; + +static gboolean +mail_module_handle_uri (EShellModule *shell_module, + const gchar *uri) +{ + /* FIXME */ + return FALSE; +} + +static void +mail_module_window_created (EShellModule *shell_module, + EShellWindow *shell_window) +{ + const gchar *module_name; + + module_name = G_TYPE_MODULE (shell_module)->name; + + e_shell_window_register_new_item_actions ( + shell_window, module_name, + item_entries, G_N_ELEMENTS (item_entries)); + + e_shell_window_register_new_source_actions ( + shell_window, module_name, + source_entries, G_N_ELEMENTS (source_entries)); +} + +static EShellModuleInfo module_info = { + + MODULE_NAME, + MODULE_ALIASES, + MODULE_SCHEMES, + MODULE_SORT_ORDER, + + /* is_busy */ NULL, + /* shutdown */ NULL, + e_mail_shell_module_migrate +}; + +void +e_shell_module_init (GTypeModule *type_module) +{ + EShell *shell; + EShellModule *shell_module; + + shell_module = E_SHELL_MODULE (type_module); + shell = e_shell_module_get_shell (shell_module); + + e_shell_module_set_info ( + shell_module, &module_info, + e_mail_shell_view_get_type (type_module)); + + g_signal_connect_swapped ( + shell, "handle-uri", + G_CALLBACK (mail_module_handle_uri), shell_module); + + g_signal_connect_swapped ( + shell, "window-created", + G_CALLBACK (mail_module_window_created), shell_module); +} + +/** + * e_mail_shell_module_load_store_by_uri: + * @uri: URI of the #CamelStore + * @name: name of the #CamelStore (for display purposes) + * + * Returns the newly added #CamelStore, or %NULL if a store could not + * be loaded for @uri. + * + * Returns: the newly added #CamelStore, or %NULL + **/ +CamelStore * +e_mail_shell_module_load_store_by_uri (const gchar *uri, + const gchar *name) +{ + return NULL; /* FIXME */ +} + +EAccountList * +mail_config_get_accounts (void) +{ + /* XXX Temporary placeholder. */ + return NULL; +} + +void +mail_config_save_accounts (void) +{ + /* XXX Temporary placeholder. */ +} + +ESignatureList * +mail_config_get_signatures (void) +{ + /* XXX Temporary placeholder. */ + return NULL; +} + +gchar * +em_uri_from_camel (const gchar *curi) +{ + /* XXX Temporary placeholder. */ + return NULL; +} diff --git a/mail/e-mail-shell-module.h b/mail/e-mail-shell-module.h new file mode 100644 index 0000000000..4d48adbcd7 --- /dev/null +++ b/mail/e-mail-shell-module.h @@ -0,0 +1,41 @@ +/* + * e-mail-shell-module.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SHELL_MODULE_H +#define E_MAIL_SHELL_MODULE_H + +#include +#include +#include + +G_BEGIN_DECLS + +CamelStore * e_mail_shell_module_load_store_by_uri + (const gchar *uri, + const gchar *name); +EAccountList * mail_config_get_accounts (void); +void mail_config_save_accounts (void); +ESignatureList *mail_config_get_signatures (void); +gchar * em_uri_from_camel (const gchar *curi); + +G_END_DECLS + +#endif /* E_MAIL_SHELL_MODULE_H */ diff --git a/mail/e-mail-shell-sidebar.c b/mail/e-mail-shell-sidebar.c new file mode 100644 index 0000000000..21dc949f6f --- /dev/null +++ b/mail/e-mail-shell-sidebar.c @@ -0,0 +1,139 @@ +/* + * e-mail-shell-sidebar.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-shell-sidebar.h" + +#define E_MAIL_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SHELL_SIDEBAR, EMailShellSidebarPrivate)) + +struct _EMailShellSidebarPrivate { + gint dummy; +}; + +enum { + PROP_0 +}; + +static gpointer parent_class; + +static void +mail_shell_sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_shell_sidebar_dispose (GObject *object) +{ + EMailShellSidebarPrivate *priv; + + priv = E_MAIL_SHELL_SIDEBAR_GET_PRIVATE (object); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +mail_shell_sidebar_finalize (GObject *object) +{ + EMailShellSidebarPrivate *priv; + + priv = E_MAIL_SHELL_SIDEBAR_GET_PRIVATE (object); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +mail_shell_sidebar_constructed (GObject *object) +{ + EMailShellSidebarPrivate *priv; + + priv = E_MAIL_SHELL_SIDEBAR_GET_PRIVATE (object); + + /* Chain up to parent's constructed method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); +} + +static void +mail_shell_sidebar_class_init (EMailShellSidebarClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMailShellSidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = mail_shell_sidebar_get_property; + object_class->dispose = mail_shell_sidebar_dispose; + object_class->finalize = mail_shell_sidebar_finalize; + object_class->constructed = mail_shell_sidebar_constructed; +} + +static void +mail_shell_sidebar_init (EMailShellSidebar *mail_shell_sidebar) +{ + mail_shell_sidebar->priv = + E_MAIL_SHELL_SIDEBAR_GET_PRIVATE (mail_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ +} + +GType +e_mail_shell_sidebar_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMailShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_shell_sidebar_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SHELL_SIDEBAR, "EMailShellSidebar", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_mail_shell_sidebar_new (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return g_object_new ( + E_TYPE_MAIL_SHELL_SIDEBAR, + "shell-view", shell_view, NULL); +} diff --git a/mail/e-mail-shell-sidebar.h b/mail/e-mail-shell-sidebar.h new file mode 100644 index 0000000000..ff35b96c0d --- /dev/null +++ b/mail/e-mail-shell-sidebar.h @@ -0,0 +1,67 @@ +/* + * e-mail-shell-sidebar.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SHELL_SIDEBAR_H +#define E_MAIL_SHELL_SIDEBAR_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MAIL_SHELL_SIDEBAR \ + (e_mail_shell_sidebar_get_type ()) +#define E_MAIL_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_SHELL_SIDEBAR, EMailShellSidebar)) +#define E_MAIL_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_SHELL_SIDEBAR, EMailShellSidebarClass)) +#define E_IS_MAIL_SHELL_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_SHELL_SIDEBAR)) +#define E_IS_MAIL_SHELL_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_SHELL_SIDEBAR)) +#define E_MAIL_SHELL_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_SHELL_SIDEBAR, EMailShellSidebarClass)) + +G_BEGIN_DECLS + +typedef struct _EMailShellSidebar EMailShellSidebar; +typedef struct _EMailShellSidebarClass EMailShellSidebarClass; +typedef struct _EMailShellSidebarPrivate EMailShellSidebarPrivate; + +struct _EMailShellSidebar { + EShellSidebar parent; + EMailShellSidebarPrivate *priv; +}; + +struct _EMailShellSidebarClass { + EShellSidebarClass parent_class; +}; + +GType e_mail_shell_sidebar_get_type (void); +GtkWidget * e_mail_shell_sidebar_new (EShellView *shell_view); + +G_END_DECLS + +#endif /* E_MAIL_SHELL_SIDEBAR_H */ diff --git a/mail/e-mail-shell-view-actions.c b/mail/e-mail-shell-view-actions.c new file mode 100644 index 0000000000..fd1abe6b64 --- /dev/null +++ b/mail/e-mail-shell-view-actions.c @@ -0,0 +1,1713 @@ +/* + * e-mail-shell-view-actions.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-shell-view-private.h" + +static void +action_mail_add_sender_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_caret_mode_cb (GtkToggleAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_check_for_junk_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_clipboard_copy_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_copy_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_create_search_folder_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_delete_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_download_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_empty_trash_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_filter_on_mailing_list_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_filter_on_recipients_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_filter_on_sender_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_filter_on_subject_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_filters_apply_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_find_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_flag_clear_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_flag_completed_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_flag_for_followup_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_copy_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_delete_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_expunge_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_mark_all_as_read_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_move_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_new_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_properties_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_refresh_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_rename_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_select_all_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_select_thread_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_folder_select_subthread_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_forward_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_forward_attached_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_forward_inline_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_forward_quoted_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_hide_deleted_cb (GtkToggleAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_hide_read_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_hide_selected_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_load_images_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_mark_important_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_mark_junk_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_mark_notjunk_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_mark_read_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_mark_unimportant_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_mark_unread_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_message_edit_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_message_new_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_message_open_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_message_post_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_move_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_next_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_next_important_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_next_thread_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_next_unread_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_preview_cb (GtkToggleAction *action, + EMailShellView *mail_shell_view) +{ + EMailShellContent *mail_shell_content; + gboolean preview_visible; + + mail_shell_content = mail_shell_view->priv->mail_shell_content; + preview_visible = gtk_toggle_action_get_active (action); + + e_mail_shell_content_set_preview_visible ( + mail_shell_content, preview_visible); +} + +static void +action_mail_previous_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_previous_important_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_previous_unread_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_print_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_print_preview_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_redirect_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_reply_all_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_reply_list_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_reply_post_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_reply_sender_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_save_as_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_search_folder_from_mailing_list_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_search_folder_from_recipients_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_search_folder_from_sender_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_search_folder_from_subject_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_select_all_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_show_all_headers_cb (GtkToggleAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_show_hidden_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_show_source_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_stop_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_threads_collapse_all_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_threads_expand_all_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_threads_group_by_cb (GtkToggleAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_tools_filters_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_tools_search_folders_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_tools_subscriptions_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_undelete_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_zoom_100_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_zoom_in_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_zoom_out_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + /* FIXME */ + g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); +} + +static void +action_mail_view_cb (GtkRadioAction *action, + GtkRadioAction *current, + EMailShellView *mail_shell_view) +{ + EMailShellContent *mail_shell_content; + gboolean vertical_view; + + mail_shell_content = mail_shell_view->priv->mail_shell_content; + vertical_view = (gtk_radio_action_get_current_value (action) == 1); + + e_mail_shell_content_set_vertical_view ( + mail_shell_content, vertical_view); +} + +static GtkActionEntry mail_entries[] = { + + { "mail-add-sender", + NULL, + N_("A_dd Sender to Address Book"), + NULL, + N_("Add sender to address book"), + G_CALLBACK (action_mail_add_sender_cb) }, + + { "mail-check-for-junk", + "mail-mark-junk", + N_("Check for _Junk"), + NULL, + N_("Filter the selected messages for junk status"), + G_CALLBACK (action_mail_check_for_junk_cb) }, + + { "mail-clipboard-copy", + GTK_STOCK_COPY, + NULL, + NULL, + N_("Copy selected messages to the clipboard"), + G_CALLBACK (action_mail_clipboard_copy_cb) }, + + { "mail-copy", + "mail-copy", + N_("_Copy to Folder"), + "y", + N_("Copy selected messages to another folder"), + G_CALLBACK (action_mail_copy_cb) }, + + { "mail-create-search-folder" }, + + { "mail-delete", + "user-trash", + N_("_Delete Message"), + "d", + N_("Mark the selected messages for deletion"), + G_CALLBACK (action_mail_delete_cb) }, + + /* XXX Work around one-accelerator-per-action limit. */ + { "mail-delete-1", + NULL, + NULL, + "Delete", + NULL, + G_CALLBACK (action_mail_delete_cb) }, + + /* XXX Work around one-accelerator-per-action limit. */ + { "mail-delete-2", + NULL, + NULL, + "KP_Delete", + NULL, + G_CALLBACK (action_mail_delete_cb) }, + + { "mail-download", + NULL, + N_("_Download Messages for Offline Usage"), + NULL, + N_("Download messages of accounts and folders marked for offline"), + G_CALLBACK (action_mail_download_cb) }, + + { "mail-empty-trash", + NULL, + N_("Empty _Trash"), + NULL, + N_("Permanently remove all the deleted messages from all folders"), + G_CALLBACK (action_mail_empty_trash_cb) }, + + { "mail-filter-on-mailing-list", + NULL, + N_("Filter on Mailing _List..."), + NULL, + N_("Create a rule to filter messages to this mailing list"), + G_CALLBACK (action_mail_filter_on_mailing_list_cb) }, + + { "mail-filter-on-recipients", + NULL, + N_("Filter on _Recipients..."), + NULL, + N_("Create a rule to filter messages to these recipients"), + G_CALLBACK (action_mail_filter_on_recipients_cb) }, + + { "mail-filter-on-sender", + NULL, + N_("Filter on Se_nder..."), + NULL, + N_("Create a rule to filter messages from this sender"), + G_CALLBACK (action_mail_filter_on_sender_cb) }, + + { "mail-filter-on-subject", + NULL, + N_("Filter on _Subject..."), + NULL, + N_("Create a rule to filter messages with this subject"), + G_CALLBACK (action_mail_filter_on_subject_cb) }, + + { "mail-filters-apply", + "stock_mail-filters-apply", + N_("A_pply filters"), + "y", + N_("Apply filter rules to the selected messages"), + G_CALLBACK (action_mail_filters_apply_cb) }, + + { "mail-find", + GTK_STOCK_FIND, + N_("_Find in Message..."), + "f", + N_("Search for text in the body of the displayed message"), + G_CALLBACK (action_mail_find_cb) }, + + { "mail-flag-clear", + NULL, + N_("_Clear Flag"), + NULL, + N_("Remove the follow-up flag from the selected messages"), + G_CALLBACK (action_mail_flag_clear_cb) }, + + { "mail-flag-completed", + NULL, + N_("_Flag Completed"), + NULL, + N_("Set the follow-up flag to completed on the selected messages"), + G_CALLBACK (action_mail_flag_completed_cb) }, + + { "mail-flag-for-followup", + "stock_mail-flag-for-followup", + N_("Follow _Up..."), + "g", + N_("Flag the selected messages for follow-up"), + G_CALLBACK (action_mail_flag_for_followup_cb) }, + + { "mail-folder-copy", + "folder-copy", + N_("_Copy Folder To..."), + NULL, + N_("Copy the selected folder into another folder"), + G_CALLBACK (action_mail_folder_copy_cb) }, + + { "mail-folder-delete", + GTK_STOCK_DELETE, + NULL, + NULL, + N_("Permanently remove this folder"), + G_CALLBACK (action_mail_folder_delete_cb) }, + + { "mail-folder-expunge", + NULL, + N_("E_xpunge"), + "e", + N_("Permanently remove all deleted messages from this folder"), + G_CALLBACK (action_mail_folder_expunge_cb) }, + + { "mail-folder-mark-all-as-read", + "mail-read", + N_("Mar_k All Messages as Read"), + NULL, + N_("Mark all messages in the folder as read"), + G_CALLBACK (action_mail_folder_mark_all_as_read_cb) }, + + { "mail-folder-move", + "folder-move", + N_("_Move Folder To..."), + NULL, + N_("Move the selected folder into another folder"), + G_CALLBACK (action_mail_folder_move_cb) }, + + { "mail-folder-new", + "folder-new", + N_("_New..."), + NULL, + N_("Create a new folder for storing mail"), + G_CALLBACK (action_mail_folder_new_cb) }, + + { "mail-folder-properties", + GTK_STOCK_PROPERTIES, + NULL, + NULL, + N_("Change the properties of this folder"), + G_CALLBACK (action_mail_folder_properties_cb) }, + + { "mail-folder-refresh", + GTK_STOCK_REFRESH, + NULL, + "F5", + N_("Refresh the folder"), + G_CALLBACK (action_mail_folder_refresh_cb) }, + + { "mail-folder-rename", + NULL, + N_("_Rename..."), + "F2", + N_("Change the name of this folder"), + G_CALLBACK (action_mail_folder_rename_cb) }, + + { "mail-folder-select-all", + NULL, + N_("Select _All Messages"), + "a", + N_("Select all visible messages"), + G_CALLBACK (action_mail_folder_select_all_cb) }, + + { "mail-folder-select-thread", + NULL, + N_("Select Message _Thread"), + "h", + N_("Select all messages in the same thread as the selected message"), + G_CALLBACK (action_mail_folder_select_thread_cb) }, + + { "mail-folder-select-subthread", + NULL, + N_("Select Message S_ubthread"), + "h", + N_("Select all replies to the currently selected message"), + G_CALLBACK (action_mail_folder_select_subthread_cb) }, + + { "mail-forward", + "mail-forward", + N_("_Forward"), + "f", + N_("Forward the selected message to someone"), + G_CALLBACK (action_mail_forward_cb) }, + + { "mail-forward-attached", + NULL, + N_("_Attached"), + NULL, + N_("Forward the selected message to someone as an attachment"), + G_CALLBACK (action_mail_forward_attached_cb) }, + + { "mail-forward-inline", + NULL, + N_("_Inline"), + NULL, + N_("Forward the selected message in the body of a new message"), + G_CALLBACK (action_mail_forward_inline_cb) }, + + { "mail-forward-quoted", + NULL, + N_("_Quoted"), + NULL, + N_("Forward the selected message quoted like a reply"), + G_CALLBACK (action_mail_forward_quoted_cb) }, + + { "mail-hide-read", + NULL, + N_("Hide _Read Messages"), + NULL, + N_("Temporarily hide all messages that have already been read"), + G_CALLBACK (action_mail_hide_read_cb) }, + + { "mail-hide-selected", + NULL, + N_("Hide S_elected Messages"), + NULL, + N_("Temporarily hide the selected messages"), + G_CALLBACK (action_mail_hide_selected_cb) }, + + { "mail-load-images", + "image-x-generic", + N_("_Load Images"), + "i", + N_("Force images in HTML mail to be loaded"), + G_CALLBACK (action_mail_load_images_cb) }, + + { "mail-mark-important", + "mail-mark-important", + N_("_Important"), + NULL, + N_("Mark the selected messages as important"), + G_CALLBACK (action_mail_mark_important_cb) }, + + { "mail-mark-junk", + "mail-mark-junk", + N_("_Junk"), + "j", + N_("Mark the selected messages as junk"), + G_CALLBACK (action_mail_mark_junk_cb) }, + + { "mail-mark-notjunk", + "mail-mark-notjunk", + N_("_Not Junk"), + "j", + N_("Mark the selected messages as not being junk"), + G_CALLBACK (action_mail_mark_notjunk_cb) }, + + { "mail-mark-read", + "mail-mark-read", + N_("_Read"), + "k", + N_("Mark the selected messages as having been read"), + G_CALLBACK (action_mail_mark_read_cb) }, + + { "mail-mark-unimportant", + NULL, + N_("Uni_mportant"), + NULL, + N_("Mark the selected messages as unimportant"), + G_CALLBACK (action_mail_mark_unimportant_cb) }, + + { "mail-mark-unread", + "mail-mark-unread", + N_("_Unread"), + "k", + N_("Mark the selected messages as not having been read"), + G_CALLBACK (action_mail_mark_unread_cb) }, + + { "mail-message-edit", + NULL, + N_("_Edit as New Message..."), + NULL, + N_("Open the selected messages in the composer for editing"), + G_CALLBACK (action_mail_message_edit_cb) }, + + { "mail-message-new", + "mail-message-new", + N_("Compose _New Message"), + "m", + N_("Open a window for composing a mail message"), + G_CALLBACK (action_mail_message_new_cb) }, + + { "mail-message-open", + NULL, + N_("_Open in New Window"), + "o", + N_("Open the selected messages in a new window"), + G_CALLBACK (action_mail_message_open_cb) }, + + { "mail-message-post", + NULL, + N_("Pos_t New Message to Folder"), + NULL, + N_("Post a message to a public folder"), + G_CALLBACK (action_mail_message_post_cb) }, + + { "mail-move", + "mail-move", + N_("_Move to Folder"), + "v", + N_("Move selected messages to another folder"), + G_CALLBACK (action_mail_move_cb) }, + + { "mail-next", + GTK_STOCK_GO_FORWARD, + N_("_Next Message"), + "Page_Down", + N_("Display the next message"), + G_CALLBACK (action_mail_next_cb) }, + + { "mail-next-important", + NULL, + N_("Next _Important Message"), + NULL, + N_("Display the next important message"), + G_CALLBACK (action_mail_next_important_cb) }, + + { "mail-next-thread", + NULL, + N_("Next _Thread"), + NULL, + N_("Display the next thread"), + G_CALLBACK (action_mail_next_thread_cb) }, + + { "mail-next-unread", + NULL, + N_("Next _Unread Message"), + "bracketright", + N_("Display the next unread message"), + G_CALLBACK (action_mail_next_unread_cb) }, + + /* XXX Work around one-accelerator-per-action limit. */ + { "mail-next-unread-1", + NULL, + NULL, + "period", + NULL, + G_CALLBACK (action_mail_next_unread_cb) }, + + /* XXX Work around one-accelerator-per-action limit. */ + { "mail-next-unread-2", + NULL, + NULL, + "period", + NULL, + G_CALLBACK (action_mail_next_unread_cb) }, + + { "mail-previous", + GTK_STOCK_GO_BACK, + N_("_Previous Message"), + "Page_Up", + N_("Display the previous message"), + G_CALLBACK (action_mail_previous_cb) }, + + { "mail-previous-important", + NULL, + N_("Pr_evious Important Message"), + NULL, + N_("Display the previous important message"), + G_CALLBACK (action_mail_previous_important_cb) }, + + { "mail-previous-unread", + NULL, + N_("P_revious Unread Message"), + "bracketleft", + N_("Display the previous unread message"), + G_CALLBACK (action_mail_previous_unread_cb) }, + + /* XXX Work around one-accelerator-per-action limit. */ + { "mail-previous-unread-1", + NULL, + NULL, + "comma", + NULL, + G_CALLBACK (action_mail_previous_unread_cb) }, + + /* XXX Work around one-accelerator-per-action limit. */ + { "mail-previous-unread-2", + NULL, + NULL, + "comma", + NULL, + G_CALLBACK (action_mail_previous_unread_cb) }, + + { "mail-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print this message"), + G_CALLBACK (action_mail_print_cb) }, + + { "mail-print-preview", + GTK_STOCK_PRINT_PREVIEW, + NULL, + NULL, + N_("Preview the message to be printed"), + G_CALLBACK (action_mail_print_preview_cb) }, + + { "mail-redirect", + NULL, + N_("Re_direct"), + NULL, + N_("Redirect (bounce) the selected message to someone"), + G_CALLBACK (action_mail_redirect_cb) }, + + { "mail-reply-all", + "mail-reply-all", + N_("Reply to _All"), + "r", + N_("Compose a reply to all the recipients of the selected message"), + G_CALLBACK (action_mail_reply_all_cb) }, + + { "mail-reply-list", + NULL, + N_("Reply to _List"), + "l", + N_("Compose a reply to the mailing list of the selected message"), + G_CALLBACK (action_mail_reply_list_cb) }, + + { "mail-reply-post", + NULL, + N_("Post a Repl_y"), + NULL, + N_("Post a reply to a message in a public folder"), + G_CALLBACK (action_mail_reply_post_cb) }, + + { "mail-reply-sender", + "mail-reply-sender", + N_("_Reply to Sender"), + "r", + N_("Compose a reply to the sender of the selected message"), + G_CALLBACK (action_mail_reply_sender_cb) }, + + { "mail-save-as", + GTK_STOCK_SAVE_AS, + N_("_Save As mbox..."), + NULL, + N_("Save selected message as an mbox file"), + G_CALLBACK (action_mail_save_as_cb) }, + + { "mail-search-folder-from-mailing-list", + NULL, + N_("Search Folder from Mailing _List..."), + NULL, + N_("Create a search folder for this mailing list"), + G_CALLBACK (action_mail_search_folder_from_mailing_list_cb) }, + + { "mail-search-folder-from-recipients", + NULL, + N_("Search Folder from Recipien_ts..."), + NULL, + N_("Create a search folder for these recipients"), + G_CALLBACK (action_mail_search_folder_from_recipients_cb) }, + + { "mail-search-folder-from-sender", + NULL, + N_("Search Folder from Sen_der..."), + NULL, + N_("Create a search folder for this sender"), + G_CALLBACK (action_mail_search_folder_from_sender_cb) }, + + { "mail-search-folder-from-subject", + NULL, + N_("Search Folder from S_ubject..."), + NULL, + N_("Create a search folder for this subject"), + G_CALLBACK (action_mail_search_folder_from_subject_cb) }, + + { "mail-select-all", + NULL, + N_("Select _All Text"), + "x", + N_("Select all the text in a message"), + G_CALLBACK (action_mail_select_all_cb) }, + + { "mail-show-hidden", + NULL, + N_("Show Hidde_n Messages"), + NULL, + N_("Show messages that have been temporarily hidden"), + G_CALLBACK (action_mail_show_hidden_cb) }, + + { "mail-show-source", + NULL, + N_("_Message Source"), + "u", + N_("Show the raw email source of the message"), + G_CALLBACK (action_mail_show_source_cb) }, + + { "mail-stop", + GTK_STOCK_STOP, + N_("Cancel"), + NULL, + N_("Cancel the current mail operation"), + G_CALLBACK (action_mail_stop_cb) }, + + { "mail-threads-collapse-all", + NULL, + N_("Collapse All _Threads"), + "b", + N_("Collapse all message threads"), + G_CALLBACK (action_mail_threads_collapse_all_cb) }, + + { "mail-threads-expand-all", + NULL, + N_("E_xpand All Threads"), + NULL, + N_("Expand all message threads"), + G_CALLBACK (action_mail_threads_expand_all_cb) }, + + { "mail-tools-filters", + NULL, + N_("_Message Filters"), + NULL, + N_("Create or edit rules for filtering new mail"), + G_CALLBACK (action_mail_tools_filters_cb) }, + + { "mail-tools-search-folders", + NULL, + N_("Search F_olders"), + NULL, + N_("Create or edit search folder definitions"), + G_CALLBACK (action_mail_tools_search_folders_cb) }, + + { "mail-tools-subscriptions", + NULL, + N_("_Subscriptions"), + NULL, + N_("Subscribe or unsubscribe to folders on remote servers"), + G_CALLBACK (action_mail_tools_subscriptions_cb) }, + + { "mail-undelete", + NULL, + N_("_Undelete Message"), + "d", + N_("Undelete the selected messages"), + G_CALLBACK (action_mail_undelete_cb) }, + + { "mail-zoom-100", + GTK_STOCK_ZOOM_100, + N_("_Normal Size"), + "0", + N_("Reset the text to its original size"), + G_CALLBACK (action_mail_zoom_100_cb) }, + + { "mail-zoom-in", + GTK_STOCK_ZOOM_IN, + N_("_Zoom In"), + "plus", + N_("Increase the text size"), + G_CALLBACK (action_mail_zoom_in_cb) }, + + { "mail-zoom-out", + GTK_STOCK_ZOOM_OUT, + N_("Zoom _Out"), + "minus", + N_("Decreate the text size"), + G_CALLBACK (action_mail_zoom_out_cb) }, + + /*** Menus ***/ + + { "mail-create-rule-menu", + NULL, + N_("Create R_ule"), + NULL, + NULL, + NULL }, + + { "mail-encoding-menu", + NULL, + N_("Ch_aracter Encoding"), + NULL, + NULL, + NULL }, + + { "mail-folder-menu", + NULL, + N_("F_older"), + NULL, + NULL, + NULL }, + + { "mail-forward-as-menu", + NULL, + N_("F_orward As..."), + NULL, + NULL, + NULL }, + + { "mail-goto-menu", + GTK_STOCK_JUMP_TO, + N_("_Go To"), + NULL, + NULL, + NULL }, + + { "mail-label-menu", + NULL, + N_("_Label"), + NULL, + NULL, + NULL }, + + { "mail-mark-as-menu", + NULL, + N_("Mar_k As"), + NULL, + NULL, + NULL }, + + { "mail-message-menu", + NULL, + N_("_Message"), + NULL, + NULL, + NULL }, + + { "mail-preview-menu", + NULL, + N_("_Preview"), + NULL, + NULL, + NULL }, + + { "mail-zoom-menu", + NULL, + N_("_Zoom"), + NULL, + NULL, + NULL } +}; + +static GtkToggleActionEntry mail_toggle_entries[] = { + + { "mail-caret-mode", + NULL, + N_("_Caret Mode"), + "F7", + N_("Show a blinking cursor in the body of displayed messages"), + G_CALLBACK (action_mail_caret_mode_cb), + FALSE }, + + { "mail-hide-deleted", + NULL, + N_("Hide _Deleted Messages"), + NULL, + N_("Hide deleted messages rather than displaying " + "them with a line through them"), + G_CALLBACK (action_mail_hide_deleted_cb), + TRUE }, + + { "mail-preview", + NULL, + N_("Show Message _Preview"), + "m", + N_("Show message preview pane"), + G_CALLBACK (action_mail_preview_cb), + TRUE }, + + { "mail-show-all-headers", + NULL, + N_("All Message _Headers"), + NULL, + N_("Show messages with all email headers"), + G_CALLBACK (action_mail_show_all_headers_cb), + FALSE }, + + { "mail-threads-group-by", + NULL, + N_("_Group By Threads"), + "t", + N_("Threaded message list"), + G_CALLBACK (action_mail_threads_group_by_cb), + FALSE } +}; + +static GtkRadioActionEntry mail_view_entries[] = { + + /* This action represents the initial active mail view. + * It should not be visible in the UI, nor should it be + * possible to switch to it from another shell view. */ + { "mail-view-internal", + NULL, + NULL, + NULL, + NULL, + -1 }, + + { "mail-view-classic", + NULL, + N_("_Classic View"), + NULL, + N_("Show message preview below the message list"), + 0 }, + + { "mail-view-vertical", + NULL, + N_("_Vertical View"), + NULL, + N_("Show message preview alongside the message list"), + 1 } +}; + +static GtkRadioActionEntry mail_filter_entries[] = { + + { "mail-filter-all-messages", + NULL, + N_("All Messages"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_ALL_MESSAGES }, + + { "mail-filter-important-messages", + "emblem-important", + N_("Important Messages"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_IMPORTANT_MESSAGES }, + + { "mail-filter-label-important", + NULL, + N_("Important"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_LABEL_IMPORTANT }, + + { "mail-filter-label-later", + NULL, + N_("Later"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_LABEL_LATER }, + + { "mail-filter-label-personal", + NULL, + N_("Personal"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_LABEL_PERSONAL }, + + { "mail-filter-label-to-do", + NULL, + N_("To Do"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_LABEL_TO_DO }, + + { "mail-filter-label-work", + NULL, + N_("Work"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_LABEL_WORK }, + + { "mail-filter-last-5-days-messages", + NULL, + N_("Last 5 Days' Messages"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_LAST_5_DAYS_MESSAGES }, + + { "mail-filter-messages-not-junk", + "mail-mark-notjunk", + N_("Messages Not Junk"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_MESSAGES_NOT_JUNK }, + + { "mail-filter-messages-with-attachments", + "mail-attachment", + N_("Messages with Attachments"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_MESSAGES_WITH_ATTACHMENTS }, + + { "mail-filter-no-label", + NULL, + N_("No Label"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_NO_LABEL }, + + { "mail-filter-read-messages", + "mail-read", + N_("Read Messages"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_READ_MESSAGES }, + + { "mail-filter-recent-messages", + NULL, + N_("Recent Messages"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_RECENT_MESSAGES }, + + { "mail-filter-unread-messages", + "mail-unread", + N_("Unread Messages"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_FILTER_UNREAD_MESSAGES } +}; + +static GtkRadioActionEntry mail_search_entries[] = { + + { "mail-search-body-contains", + NULL, + N_("Body contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SEARCH_BODY_CONTAINS }, + + { "mail-search-message-contains", + NULL, + N_("Message contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SEARCH_MESSAGE_CONTAINS }, + + { "mail-search-recipients-contain", + NULL, + N_("Recipients contain"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SEARCH_RECIPIENTS_CONTAIN }, + + { "mail-search-sender-contains", + NULL, + N_("Sender contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SEARCH_SENDER_CONTAINS }, + + { "mail-search-subject-contains", + NULL, + N_("Subject contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SEARCH_SUBJECT_CONTAINS }, + + { "mail-search-subject-or-recipients-contains", + NULL, + N_("Subject or Recipients contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SEARCH_SUBJECT_OR_RECIPIENTS_CONTAINS }, + + { "mail-search-subject-or-sender-contains", + NULL, + N_("Subject or Sender contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SEARCH_SUBJECT_OR_SENDER_CONTAINS } +}; + +static GtkRadioActionEntry mail_scope_entries[] = { + + { "mail-scope-all-accounts", + NULL, + N_("All Accounts"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SCOPE_ALL_ACCOUNTS }, + + { "mail-scope-current-account", + NULL, + N_("Current Account"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SCOPE_CURRENT_ACCOUNT }, + + { "mail-scope-current-folder", + NULL, + N_("Current Folder"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SCOPE_CURRENT_FOLDER }, + + { "mail-scope-current-message", + NULL, + N_("Current Message"), + NULL, + NULL, /* XXX Add a tooltip! */ + MAIL_SCOPE_CURRENT_MESSAGE } +}; + +void +e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + GConfBridge *bridge; + GtkAction *action; + GObject *object; + const gchar *domain; + const gchar *key; + + shell_view = E_SHELL_VIEW (mail_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + ui_manager = e_shell_window_get_ui_manager (shell_window); + domain = GETTEXT_PACKAGE; + + action_group = mail_shell_view->priv->mail_actions; + gtk_action_group_set_translation_domain (action_group, domain); + gtk_action_group_add_actions ( + action_group, mail_entries, + G_N_ELEMENTS (mail_entries), mail_shell_view); + gtk_action_group_add_toggle_actions ( + action_group, mail_toggle_entries, + G_N_ELEMENTS (mail_toggle_entries), mail_shell_view); + gtk_action_group_add_radio_actions ( + action_group, mail_view_entries, + G_N_ELEMENTS (mail_view_entries), -1, + G_CALLBACK (action_mail_view_cb), mail_shell_view); + gtk_action_group_add_radio_actions ( + action_group, mail_search_entries, + G_N_ELEMENTS (mail_search_entries), + MAIL_SEARCH_SUBJECT_OR_SENDER_CONTAINS, + NULL, NULL); + gtk_action_group_add_radio_actions ( + action_group, mail_scope_entries, + G_N_ELEMENTS (mail_scope_entries), + MAIL_SCOPE_CURRENT_FOLDER, + NULL, NULL); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + /* Bind GObject properties for GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (ACTION (MAIL_PREVIEW)); + key = "/apps/evolution/mail/display/show_preview"; + gconf_bridge_bind_property (bridge, key, object, "active"); + + /* XXX This is ugly. We're binding an integer property to a + * boolean GConf key. But since there's only two possible + * mail views (for now, anyway), it happens to work. */ + object = G_OBJECT (ACTION (MAIL_VIEW_CLASSIC)); + key = "/apps/evolution/mail/display/show_wide"; + gconf_bridge_bind_property (bridge, key, object, "current-value"); + + /* Fine tuning. */ + + action = ACTION (MAIL_DELETE); + g_object_set (action, "short-label", _("Delete"), NULL); + + action = ACTION (MAIL_NEXT); + g_object_set (action, "short-label", _("Next"), NULL); + + action = ACTION (MAIL_PREVIOUS); + g_object_set (action, "short-label", _("Previous"), NULL); + + action = ACTION (MAIL_REPLY_SENDER); + g_object_set (action, "short-label", _("Reply"), NULL); +} diff --git a/mail/e-mail-shell-view-actions.h b/mail/e-mail-shell-view-actions.h new file mode 100644 index 0000000000..98500b40e1 --- /dev/null +++ b/mail/e-mail-shell-view-actions.h @@ -0,0 +1,255 @@ +/* + * e-mail-shell-view-actions.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SHELL_VIEW_ACTIONS_H +#define E_MAIL_SHELL_VIEW_ACTIONS_H + +#include + +/* Mail Actions */ +#define E_SHELL_WINDOW_ACTION_MAIL_ADD_SENDER(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-add-sender") +#define E_SHELL_WINDOW_ACTION_MAIL_CARET_MODE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-caret-mode") +#define E_SHELL_WINDOW_ACTION_MAIL_CHECK_FOR_JUNK(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-check-for-junk") +#define E_SHELL_WINDOW_ACTION_MAIL_CLIPBOARD_COPY(window) \ + E_SHELL_WINDOw_ACTION ((window), "mail-clipboard-copy") +#define E_SHELL_WINDOW_ACTION_MAIL_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-copy") +#define E_SHELL_WINDOW_ACTION_MAIL_CREATE_SEARCH_FOLDER(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-create-search-folder") +#define E_SHELL_WINDOW_ACTION_MAIL_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-delete") +#define E_SHELL_WINDOW_ACTION_MAIL_DOWNLOAD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-download") +#define E_SHELL_WINDOW_ACTION_MAIL_EMPTY_TRASH(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-empty-trash") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_ON_MAILING_LIST(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-on-mailing-list") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_ON_RECIPIENTS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-on-recipients") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_ON_SENDER(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-on-sender") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_ON_SUBJECT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-on-subject") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTERS_APPLY(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filters-apply") +#define E_SHELL_WINDOW_ACTION_MAIL_FIND(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-find") +#define E_SHELL_WINDOW_ACTION_MAIL_FLAG_CLEAR(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-flag-clear") +#define E_SHELL_WINDOW_ACTION_MAIL_FLAG_COMPLETED(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-flag-completed") +#define E_SHELL_WINDOW_ACTION_MAIL_FLAG_FOR_FOLLOWUP(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-flag-for-followup") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-copy") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-delete") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_EXPUNGE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-expunge") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_MARK_ALL_READ(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-mark-all-read") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_MOVE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-move") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-new") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_PROPERTIES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-properties") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_REFRESH(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-refresh") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_RENAME(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-rename") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_SELECT_ALL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-select-all") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_SELECT_THREAD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-select-thread") +#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_SELECT_SUBTHREAD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-folder-select-subthread") +#define E_SHELL_WINDOW_ACTION_MAIL_FORWARD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-forward") +#define E_SHELL_WINDOW_ACTION_MAIL_FORWARD_ATTACHED(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-forward-attached") +#define E_SHELL_WINDOW_ACTION_MAIL_FORWARD_INLINE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-forward-inline") +#define E_SHELL_WINDOW_ACTION_MAIL_FORWARD_QUOTED(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-forward-quoted") +#define E_SHELL_WINDOW_ACTION_MAIL_HIDE_DELETED(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-hide-deleted") +#define E_SHELL_WINDOW_ACTION_MAIL_HIDE_READ(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-hide-read") +#define E_SHELL_WINDOW_ACTION_MAIL_HIDE_SELECTED(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-hide-selected") +#define E_SHELL_WINDOW_ACTION_MAIL_LOAD_IMAGES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-load-images") +#define E_SHELL_WINDOW_ACTION_MAIL_MARK_IMPORTANT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-mark-important") +#define E_SHELL_WINDOW_ACTION_MAIL_MARK_JUNK(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-mark-junk") +#define E_SHELL_WINDOW_ACTION_MAIL_MARK_NOTJUNK(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-mark-notjunk") +#define E_SHELL_WINDOW_ACTION_MAIL_MARK_READ(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-mark-read") +#define E_SHELL_WINDOW_ACTION_MAIL_MARK_UNIMPORTANT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-mark-unimportant") +#define E_SHELL_WINDOW_ACTION_MAIL_MARK_UNREAD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-mark-unread") +#define E_SHELL_WINDOW_ACTION_MAIL_MESSAGE_EDIT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-message-edit") +#define E_SHELL_WINDOW_ACTION_MAIL_MESSAGE_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-message-new") +#define E_SHELL_WINDOW_ACTION_MAIL_MESSAGE_OPEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-message-open") +#define E_SHELL_WINDOW_ACTION_MAIL_MESSAGE_POST(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-message-post") +#define E_SHELL_WINDOW_ACTION_MAIL_MOVE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-move") +#define E_SHELL_WINDOW_ACTION_MAIL_NEXT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-next") +#define E_SHELL_WINDOW_ACTION_MAIL_NEXT_IMPORTANT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-next-important") +#define E_SHELL_WINDOW_ACTION_MAIL_NEXT_THREAD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-next-thread") +#define E_SHELL_WINDOW_ACTION_MAIL_NEXT_UNREAD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-next-unread") +#define E_SHELL_WINDOW_ACTION_MAIL_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-preview") +#define E_SHELL_WINDOW_ACTION_MAIL_PREVIOUS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-previous") +#define E_SHELL_WINDOW_ACTION_MAIL_PREVIOUS_IMPORTANT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-previous-important") +#define E_SHELL_WINDOW_ACTION_MAIL_PREVIOUS_UNREAD(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-previous-unread") +#define E_SHELL_WINDOW_ACTION_MAIL_PRINT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-print") +#define E_SHELL_WINDOW_ACTION_MAIL_PRINT_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-print-preview") +#define E_SHELL_WINDOW_ACTION_MAIL_REDIRECT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-redirect") +#define E_SHELL_WINDOW_ACTION_MAIL_REPLY_ALL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-reply-all") +#define E_SHELL_WINDOW_ACTION_MAIL_REPLY_LIST(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-reply-list") +#define E_SHELL_WINDOW_ACTION_MAIL_REPLY_POST(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-reply-post") +#define E_SHELL_WINDOW_ACTION_MAIL_REPLY_SENDER(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-reply-sender") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_FOLDER_FROM_MAILING_LIST(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-folder-from-mailing-list") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_FOLDER_FROM_RECIPIENTS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-folder-from-recipients") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_FOLDER_FROM_SENDER(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-folder-from-sender") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_FOLDER_FROM_SUBJECT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-folder-from-subject") +#define E_SHELL_WINDOW_ACTION_MAIL_SELECT_ALL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-select-all") +#define E_SHELL_WINDOW_ACTION_MAIL_SHOW_ALL_HEADERS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-show-all-headers") +#define E_SHELL_WINDOW_ACTION_MAIL_SHOW_HIDDEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-show-hidden") +#define E_SHELL_WINDOW_ACTION_MAIL_SHOW_SOURCE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-show-source") +#define E_SHELL_WINDOW_ACTION_MAIL_STOP(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-stop") +#define E_SHELL_WINDOW_ACTION_MAIL_THREADS_COLLAPSE_ALL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-threads-collapse-all") +#define E_SHELL_WINDOW_ACTION_MAIL_THREADS_EXPAND_ALL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-threads-expand-all") +#define E_SHELL_WINDOW_ACTION_MAIL_THREADS_GROUP_BY(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-threads-group-by") +#define E_SHELL_WINDOW_ACTION_MAIL_TOOLS_FILTERS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-tools-filters") +#define E_SHELL_WINDOW_ACTION_MAIL_TOOLS_SEARCH_FOLDERS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-tools-search-folders") +#define E_SHELL_WINDOW_ACTION_MAIL_TOOLS_SUBSCRIPTIONS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-tools-subscriptions") +#define E_SHELL_WINDOW_ACTION_MAIL_UNDELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-undelete") +#define E_SHELL_WINDOW_ACTION_MAIL_VIEW_CLASSIC(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-view-classic") +#define E_SHELL_WINDOW_ACTION_MAIL_VIEW_VERTICAL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-view-vertical") +#define E_SHELL_WINDOW_ACTION_MAIL_ZOOM_100(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-zoom-100") +#define E_SHELL_WINDOW_ACTION_MAIL_ZOOM_IN(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-zoom-in") +#define E_SHELL_WINDOW_ACTION_MAIL_ZOOM_OUT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-zoom-out") + +/* Mail Query Actions */ +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_ALL_MESSAGES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-all-messages") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_IMPORTANT_MESSAGES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-important-messages") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_LABEL_IMPORTANT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-label-important") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_LABEL_LATER(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-label-later") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_LABEL_PERSONAL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-label-personal") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_LABEL_TO_DO(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-label-to-do") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_LABEL_WORK(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-label-work") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_LAST_5_DAYS_MESSAGES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-last-5-days-messages") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_MESSAGES_NOT_JUNK(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-messages-not-junk") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_MESSAGES_WITH_ATTACHMENTS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-messages-with-attachments") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_NO_LABEL(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-no-label") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_READ_MESSAGES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-read-messages") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_RECENT_MESSAGES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-recent-messages") +#define E_SHELL_WINDOW_ACTION_MAIL_FILTER_UNREAD_MESSAGES(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-filter-unread-messages") +#define E_SHELL_WINDOW_ACTION_MAIL_SCOPE_ALL_ACCOUNTS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-scope-all-accounts") +#define E_SHELL_WINDOW_ACTION_MAIL_SCOPE_CURRENT_ACCOUNT(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-scope-current-account") +#define E_SHELL_WINDOW_ACTION_MAIL_SCOPE_CURRENT_FOLDER(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-scope-current-folder") +#define E_SHELL_WINDOW_ACTION_MAIL_SCOPE_CURRENT_MESSAGE(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-scope-current-message") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_BODY_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-body-contains") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_MESSAGE_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-message-contains") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_RECIPIENTS_CONTAIN(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-recipients-contain") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_SENDER_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-sender-contains") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_SUBJECT_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-subject-contains") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_SUBJECT_OR_RECIPIENTS_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-subject-or-recipients-contains") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_SUBJECT_OR_SENDER_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-subject-or-sender-contains") + +/* Action Groups */ +#define E_SHELL_WINDOW_ACTION_GROUP_MAIL(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "mail") + +#endif /* E_MAIL_SHELL_VIEW_ACTIONS_H */ diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c new file mode 100644 index 0000000000..ebbde76d03 --- /dev/null +++ b/mail/e-mail-shell-view-private.c @@ -0,0 +1,126 @@ +/* + * e-mail-shell-view-private.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-shell-view-private.h" + +#include + +static void +mail_shell_view_load_view_collection (EShellViewClass *shell_view_class) +{ + GalViewCollection *collection; + GalViewFactory *factory; + ETableSpecification *spec; + const gchar *base_dir; + gchar *filename; + + collection = shell_view_class->view_collection; + + base_dir = EVOLUTION_ETSPECDIR; + spec = e_table_specification_new (); + filename = g_build_filename (base_dir, ETSPEC_FILENAME, NULL); + if (!e_table_specification_load_from_file (spec, filename)) + g_critical ("Unable to load ETable specification file " + "for mail"); + g_free (filename); + + factory = gal_view_factory_etable_new (spec); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + g_object_unref (spec); + + gal_view_collection_load (collection); +} + +static void +mail_shell_view_notify_view_id_cb (EMailShellView *mail_shell_view) +{ + EMailShellContent *mail_shell_content; + GalViewInstance *view_instance; + const gchar *view_id; + + mail_shell_content = mail_shell_view->priv->mail_shell_content; + view_instance = NULL; /* FIXME */ + view_id = e_shell_view_get_view_id (E_SHELL_VIEW (mail_shell_view)); + + /* A NULL view ID implies we're in a custom view. But you can + * only get to a custom view via the "Define Views" dialog, which + * would have already modified the view instance appropriately. + * Furthermore, there's no way to refer to a custom view by ID + * anyway, since custom views have no IDs. */ + if (view_id == NULL) + return; + + gal_view_instance_set_current_view_id (view_instance, view_id); +} + +void +e_mail_shell_view_private_init (EMailShellView *mail_shell_view, + EShellViewClass *shell_view_class) +{ + EMailShellViewPrivate *priv = mail_shell_view->priv; + + priv->mail_actions = gtk_action_group_new ("mail"); + priv->filter_actions = gtk_action_group_new ("mail-filter"); + + if (!gal_view_collection_loaded (shell_view_class->view_collection)) + mail_shell_view_load_view_collection (shell_view_class); + + g_signal_connect ( + mail_shell_view, "notify::view-id", + G_CALLBACK (mail_shell_view_notify_view_id_cb), NULL); +} + +void +e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) +{ + EMailShellViewPrivate *priv = mail_shell_view->priv; + EShellView *shell_view; + EShellContent *shell_content; + EShellSidebar *shell_sidebar; + + shell_view = E_SHELL_VIEW (mail_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + + /* Cache these to avoid lots of awkward casting. */ + priv->mail_shell_content = g_object_ref (shell_content); + priv->mail_shell_sidebar = g_object_ref (shell_content); + + e_mail_shell_view_actions_init (mail_shell_view); +} + +void +e_mail_shell_view_private_dispose (EMailShellView *mail_shell_view) +{ + EMailShellViewPrivate *priv = mail_shell_view->priv; + + DISPOSE (priv->mail_actions); + DISPOSE (priv->filter_actions); + + DISPOSE (priv->mail_shell_content); + DISPOSE (priv->mail_shell_sidebar); +} + +void +e_mail_shell_view_private_finalize (EMailShellView *mail_shell_view) +{ +} diff --git a/mail/e-mail-shell-view-private.h b/mail/e-mail-shell-view-private.h new file mode 100644 index 0000000000..cc5f721d67 --- /dev/null +++ b/mail/e-mail-shell-view-private.h @@ -0,0 +1,126 @@ +/* + * e-mail-shell-view-private.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SHELL_VIEW_PRIVATE_H +#define E_MAIL_SHELL_VIEW_PRIVATE_H + +#include "e-mail-shell-view.h" + +#include + +#include "e-util/gconf-bridge.h" + +#include "widgets/menus/gal-view-instance.h" + +#include "e-mail-shell-content.h" +#include "e-mail-shell-sidebar.h" +#include "e-mail-shell-view-actions.h" + +#define E_MAIL_SHELL_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SHELL_VIEW, EMailShellViewPrivate)) + +/* Shorthand, requires a variable named "shell_window". */ +#define ACTION(name) \ + (E_SHELL_WINDOW_ACTION_##name (shell_window)) +#define ACTION_GROUP(name) \ + (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window)) + +/* For use in dispose() methods. */ +#define DISPOSE(obj) \ + G_STMT_START { \ + if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ + } G_STMT_END + +/* ETable Specifications */ +#define ETSPEC_FILENAME "message-list.etspec" + +G_BEGIN_DECLS + +/* Filter items are displayed in ascending order. */ +enum { + MAIL_FILTER_ALL_MESSAGES, + MAIL_FILTER_UNREAD_MESSAGES, + MAIL_FILTER_NO_LABEL, + MAIL_FILTER_LABEL_IMPORTANT, + MAIL_FILTER_LABEL_WORK, + MAIL_FILTER_LABEL_PERSONAL, + MAIL_FILTER_LABEL_TO_DO, + MAIL_FILTER_LABEL_LATER, + MAIL_FILTER_READ_MESSAGES, + MAIL_FILTER_RECENT_MESSAGES, + MAIL_FILTER_LAST_5_DAYS_MESSAGES, + MAIL_FILTER_MESSAGES_WITH_ATTACHMENTS, + MAIL_FILTER_IMPORTANT_MESSAGES, + MAIL_FILTER_MESSAGES_NOT_JUNK +}; + +/* Search items are displayed in ascending order. */ +enum { + MAIL_SEARCH_SUBJECT_OR_SENDER_CONTAINS, + MAIL_SEARCH_SUBJECT_OR_RECIPIENTS_CONTAINS, + MAIL_SEARCH_RECIPIENTS_CONTAIN, + MAIL_SEARCH_MESSAGE_CONTAINS, + MAIL_SEARCH_SUBJECT_CONTAINS, + MAIL_SEARCH_SENDER_CONTAINS, + MAIL_SEARCH_BODY_CONTAINS +}; + +/* Scope items are displayed in ascending order. */ +enum { + MAIL_SCOPE_CURRENT_FOLDER, + MAIL_SCOPE_CURRENT_ACCOUNT, + MAIL_SCOPE_ALL_ACCOUNTS, + MAIL_SCOPE_CURRENT_MESSAGE +}; + +struct _EMailShellViewPrivate { + + /*** UI Management ***/ + + GtkActionGroup *mail_actions; + GtkActionGroup *filter_actions; + + /*** Other Stuff ***/ + + /* These are just for convenience. */ + EMailShellContent *mail_shell_content; + EMailShellSidebar *mail_shell_sidebar; +}; + +void e_mail_shell_view_private_init + (EMailShellView *mail_shell_view, + EShellViewClass *shell_view_class); +void e_mail_shell_view_private_constructed + (EMailShellView *mail_shell_view); +void e_mail_shell_view_private_dispose + (EMailShellView *mail_shell_view); +void e_mail_shell_view_private_finalize + (EMailShellView *mail_shell_view); + +/* Private Utilities */ + +void e_mail_shell_view_actions_init + (EMailShellView *mail_shell_view); + +G_END_DECLS + +#endif /* E_MAIL_SHELL_VIEW_PRIVATE_H */ diff --git a/mail/e-mail-shell-view.c b/mail/e-mail-shell-view.c new file mode 100644 index 0000000000..d8c386754f --- /dev/null +++ b/mail/e-mail-shell-view.c @@ -0,0 +1,135 @@ +/* + * e-mail-shell-view.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-shell-view-private.h" + +enum { + PROP_0 +}; + +GType e_mail_shell_view_type = 0; +static gpointer parent_class; + +static void +mail_shell_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_shell_view_dispose (GObject *object) +{ + e_mail_shell_view_private_dispose (E_MAIL_SHELL_VIEW (object)); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +mail_shell_view_finalize (GObject *object) +{ + e_mail_shell_view_private_finalize (E_MAIL_SHELL_VIEW (object)); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +mail_shell_view_constructed (GObject *object) +{ + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (parent_class)->constructed (object); + + e_mail_shell_view_private_constructed (E_MAIL_SHELL_VIEW (object)); +} + +static void +mail_shell_view_update_actions (EShellView *shell_view) +{ + /* FIXME */ +} + +static void +mail_shell_view_class_init (EMailShellViewClass *class, + GTypeModule *type_module) +{ + GObjectClass *object_class; + EShellViewClass *shell_view_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMailShellViewPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->get_property = mail_shell_view_get_property; + object_class->dispose = mail_shell_view_dispose; + object_class->finalize = mail_shell_view_finalize; + object_class->constructed = mail_shell_view_constructed; + + shell_view_class = E_SHELL_VIEW_CLASS (class); + shell_view_class->label = N_("Mail"); + shell_view_class->icon_name = "evolution-mail"; + shell_view_class->ui_definition = "evolution-mail.ui"; + shell_view_class->search_options = "/mail-search-options"; + shell_view_class->search_rules = "searchtypes.xml"; + shell_view_class->type_module = type_module; + shell_view_class->new_shell_content = e_mail_shell_content_new; + shell_view_class->new_shell_sidebar = e_mail_shell_sidebar_new; + shell_view_class->update_actions = mail_shell_view_update_actions; +} + +static void +mail_shell_view_init (EMailShellView *mail_shell_view, + EShellViewClass *shell_view_class) +{ + mail_shell_view->priv = + E_MAIL_SHELL_VIEW_GET_PRIVATE (mail_shell_view); + + e_mail_shell_view_private_init (mail_shell_view, shell_view_class); +} + +GType +e_mail_shell_view_get_type (GTypeModule *type_module) +{ + if (e_mail_shell_view_type == 0) { + const GTypeInfo type_info = { + sizeof (EMailShellViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_shell_view_class_init, + (GClassFinalizeFunc) NULL, + type_module, + sizeof (EMailShellView), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_shell_view_init, + NULL /* value_table */ + }; + + e_mail_shell_view_type = + g_type_module_register_type ( + type_module, E_TYPE_SHELL_VIEW, + "EMailShellView", &type_info, 0); + } + + return e_mail_shell_view_type; +} diff --git a/mail/e-mail-shell-view.h b/mail/e-mail-shell-view.h new file mode 100644 index 0000000000..62f3f78524 --- /dev/null +++ b/mail/e-mail-shell-view.h @@ -0,0 +1,71 @@ +/* + * e-mail-shell-view.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_SHELL_VIEW_H +#define E_MAIL_SHELL_VIEW_H + +#include + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_MAIL_SHELL_VIEW \ + (e_mail_shell_view_type) +#define E_MAIL_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_SHELL_VIEW, EMailShellView)) +#define E_MAIL_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_SHELL_VIEW, EMailShellViewClass)) +#define E_IS_MAIL_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_SHELL_VIEW)) +#define E_IS_MAIL_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_SHELL_VIEW)) +#define E_MAIL_SHELL_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_SHELL_VIEW, EMailShellViewClass)) + +G_BEGIN_DECLS + +extern GType e_mail_shell_view_type; + +typedef struct _EMailShellView EMailShellView; +typedef struct _EMailShellViewClass EMailShellViewClass; +typedef struct _EMailShellViewPrivate EMailShellViewPrivate; + +struct _EMailShellView { + EShellView parent; + EMailShellViewPrivate *priv; +}; + +struct _EMailShellViewClass { + EShellViewClass parent_class; +}; + +GType e_mail_shell_view_get_type + (GTypeModule *type_module); + +G_END_DECLS + +#endif /* E_MAIL_SHELL_VIEW_H */ diff --git a/mail/em-migrate.c b/mail/em-migrate.c deleted file mode 100644 index e22cbae273..0000000000 --- a/mail/em-migrate.c +++ /dev/null @@ -1,3055 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Jeffrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include "e-util/e-bconf-map.h" -#include "libedataserver/e-account-list.h" -#include "e-util/e-signature-list.h" -#include "e-util/e-error.h" -#include "e-util/e-util-private.h" -#include "e-util/e-plugin.h" - -#include "mail-component.h" -#include "mail-config.h" -#include "mail-session.h" -#include "em-utils.h" -#include "em-migrate.h" - -#define d(x) x - -#ifndef G_OS_WIN32 -/* No versions previous to 2.8 or thereabouts have been available on - * Windows, so don't bother with upgrade support from earlier versions - * on Win32. Do try to support upgrades from 2.12 and later to the - * current version. - */ - -/* upgrade helper functions */ -static xmlDocPtr -emm_load_xml (const char *dirname, const char *filename) -{ - xmlDocPtr doc; - struct stat st; - char *path; - - path = g_strdup_printf ("%s/%s", dirname, filename); - if (stat (path, &st) == -1 || !(doc = xmlParseFile (path))) { - g_free (path); - return NULL; - } - - g_free (path); - - return doc; -} - -static int -emm_save_xml (xmlDocPtr doc, const char *dirname, const char *filename) -{ - char *path; - int retval; - - path = g_strdup_printf ("%s/%s", dirname, filename); - retval = e_xml_save_file (path, doc); - g_free (path); - - return retval; -} - -static xmlNodePtr -xml_find_node (xmlNodePtr parent, const char *name) -{ - xmlNodePtr node; - - node = parent->children; - while (node != NULL) { - if (node->name && !strcmp ((char *)node->name, name)) - return node; - - node = node->next; - } - - return NULL; -} - -static void -upgrade_xml_uris (xmlDocPtr doc, char * (* upgrade_uri) (const char *uri)) -{ - xmlNodePtr root, node; - char *uri, *new; - - if (!doc || !(root = xmlDocGetRootElement (doc))) - return; - - if (!root->name || strcmp ((char *)root->name, "filteroptions") != 0) { - /* root node is not , nothing to upgrade */ - return; - } - - if (!(node = xml_find_node (root, "ruleset"))) { - /* no ruleset node, nothing to upgrade */ - return; - } - - node = node->children; - while (node != NULL) { - if (node->name && !strcmp ((char *)node->name, "rule")) { - xmlNodePtr actionset, part, val, n; - - if ((actionset = xml_find_node (node, "actionset"))) { - /* filters.xml */ - part = actionset->children; - while (part != NULL) { - if (part->name && !strcmp ((char *)part->name, "part")) { - val = part->children; - while (val != NULL) { - if (val->name && !strcmp ((char *)val->name, "value")) { - char *type; - - type = (char *)xmlGetProp (val, (const unsigned char *)"type"); - if (type && !strcmp ((char *)type, "folder")) { - if ((n = xml_find_node (val, "folder"))) { - uri = (char *)xmlGetProp (n, (const unsigned char *)"uri"); - new = upgrade_uri (uri); - xmlFree (uri); - - xmlSetProp (n, (const unsigned char *)"uri", (unsigned char *)new); - g_free (new); - } - } - - xmlFree (type); - } - - val = val->next; - } - } - - part = part->next; - } - } else if ((actionset = xml_find_node (node, "sources"))) { - /* vfolders.xml */ - n = actionset->children; - while (n != NULL) { - if (n->name && !strcmp ((char *)n->name, "folder")) { - uri = (char *)xmlGetProp (n, (const unsigned char *)"uri"); - new = upgrade_uri (uri); - xmlFree (uri); - - xmlSetProp (n, (const unsigned char *)"uri", (unsigned char *)new); - g_free (new); - } - - n = n->next; - } - } - } - - node = node->next; - } -} - -/* 1.0 upgrade functions & data */ - -/* as much info as we have on a given account */ -struct _account_info_1_0 { - char *name; - char *uri; - char *base_uri; - union { - struct { - /* for imap */ - char *namespace; - char *namespace_full; - guint32 capabilities; - GHashTable *folders; - char dir_sep; - } imap; - } u; -}; - -struct _imap_folder_info_1_0 { - char *folder; - /* encoded? decoded? canonicalised? */ - char dir_sep; -}; - -static GHashTable *accounts_1_0 = NULL; -static GHashTable *accounts_name_1_0 = NULL; - -static void -imap_folder_info_1_0_free (struct _imap_folder_info_1_0 *fi) -{ - g_free(fi->folder); - g_free(fi); -} - -static void -account_info_1_0_free (struct _account_info_1_0 *ai) -{ - g_free(ai->name); - g_free(ai->uri); - g_free(ai->base_uri); - g_free(ai->u.imap.namespace); - g_free(ai->u.imap.namespace_full); - g_hash_table_destroy(ai->u.imap.folders); - g_free(ai); -} - -static char * -get_base_uri(const char *val) -{ - const char *tmp; - - tmp = strchr(val, ':'); - if (tmp) { - tmp++; - if (strncmp(tmp, "//", 2) == 0) - tmp += 2; - tmp = strchr(tmp, '/'); - } - - if (tmp) - return g_strndup(val, tmp-val); - else - return g_strdup(val); -} - -static char * -upgrade_xml_uris_1_0 (const char *uri) -{ - char *out = NULL; - - /* upgrades camel uri's */ - if (strncmp (uri, "imap:", 5) == 0) { - char *base_uri, dir_sep, *folder, *p; - struct _account_info_1_0 *ai; - - /* add namespace, canonicalise dir_sep to / */ - base_uri = get_base_uri (uri); - ai = g_hash_table_lookup (accounts_1_0, base_uri); - - if (ai == NULL) { - g_free (base_uri); - return NULL; - } - - dir_sep = ai->u.imap.dir_sep; - if (dir_sep == 0) { - /* no dir_sep listed, try get it from the namespace, if set */ - if (ai->u.imap.namespace != NULL) { - p = ai->u.imap.namespace; - while ((dir_sep = *p++)) { - if (dir_sep < '0' - || (dir_sep > '9' && dir_sep < 'A') - || (dir_sep > 'Z' && dir_sep < 'a') - || (dir_sep > 'z')) { - break; - } - p++; - } - } - - /* give up ... */ - if (dir_sep == 0) { - g_free (base_uri); - return NULL; - } - } - - folder = g_strdup (uri + strlen (base_uri) + 1); - - /* Add the namespace before the mailbox name, unless the mailbox is INBOX */ - if (ai->u.imap.namespace && strcmp ((char *)folder, "INBOX") != 0) - out = g_strdup_printf ("%s/%s/%s", base_uri, ai->u.imap.namespace, folder); - else - out = g_strdup_printf ("%s/%s", base_uri, folder); - - p = out; - while (*p) { - if (*p == dir_sep) - *p = '/'; - p++; - } - - g_free (folder); - g_free (base_uri); - } else if (strncmp (uri, "exchange:", 9) == 0) { - char *base_uri, *folder, *p; - - /* exchange://user@host/exchange/ * -> exchange://user@host/personal/ * */ - /* Any url encoding (%xx) in the folder name is also removed */ - base_uri = get_base_uri (uri); - uri += strlen (base_uri) + 1; - if (strncmp (uri, "exchange/", 9) == 0) { - folder = e_bconf_url_decode (uri + 9); - p = strchr (folder, '/'); - out = g_strdup_printf ("%s/personal%s", base_uri, p ? p : "/"); - g_free (folder); - } - } else if (strncmp (uri, "exchanget:", 10) == 0) { - /* these should be converted in the accounts table when it is loaded */ - g_warning ("exchanget: uri not converted: '%s'", uri); - } - - return out; -} - -static char * -parse_lsub (const char *lsub, char *dir_sep) -{ - static int comp; - static regex_t pat; - regmatch_t match[3]; - char *m = "^\\* LSUB \\([^)]*\\) \"?([^\" ]+)\"? \"?(.*)\"?$"; - - if (!comp) { - if (regcomp (&pat, m, REG_EXTENDED|REG_ICASE) == -1) { - g_warning ("reg comp '%s' failed: %s", m, g_strerror (errno)); - return NULL; - } - comp = 1; - } - - if (regexec (&pat, lsub, 3, match, 0) == 0) { - if (match[1].rm_so != -1 && match[2].rm_so != -1) { - if (dir_sep) - *dir_sep = (match[1].rm_eo - match[1].rm_so == 1) ? lsub[match[1].rm_so] : 0; - return g_strndup (lsub + match[2].rm_so, match[2].rm_eo - match[2].rm_so); - } - } - - return NULL; -} - -static int -read_imap_storeinfo (struct _account_info_1_0 *si) -{ - FILE *storeinfo; - guint32 tmp; - char *buf, *folder, dir_sep, *path, *name, *p; - struct _imap_folder_info_1_0 *fi; - - si->u.imap.folders = g_hash_table_new_full ( - g_str_hash, g_str_equal, - (GDestroyNotify) NULL, - (GDestroyNotify) imap_folder_info_1_0_free); - - /* get details from uri first */ - name = strstr (si->uri, ";override_namespace"); - if (name) { - name = strstr (si->uri, ";namespace="); - if (name) { - char *end; - - name += strlen (";namespace="); - if (*name == '\"') { - name++; - end = strchr (name, '\"'); - } else { - end = strchr (name, ';'); - } - - if (end) { - /* try get the dir_sep from the namespace */ - si->u.imap.namespace = g_strndup (name, end-name); - - p = si->u.imap.namespace; - while ((dir_sep = *p++)) { - if (dir_sep < '0' - || (dir_sep > '9' && dir_sep < 'A') - || (dir_sep > 'Z' && dir_sep < 'a') - || (dir_sep > 'z')) { - si->u.imap.dir_sep = dir_sep; - break; - } - p++; - } - } - } - } - - /* now load storeinfo if it exists */ - path = g_build_filename (g_get_home_dir (), "evolution", "mail", "imap", si->base_uri + 7, "storeinfo", NULL); - storeinfo = fopen (path, "r"); - g_free (path); - if (storeinfo == NULL) { - g_warning ("could not find imap store info '%s'", path); - return -1; - } - - /* ignore version */ - camel_file_util_decode_uint32 (storeinfo, &tmp); - camel_file_util_decode_uint32 (storeinfo, &si->u.imap.capabilities); - g_free (si->u.imap.namespace); - camel_file_util_decode_string (storeinfo, &si->u.imap.namespace); - camel_file_util_decode_uint32 (storeinfo, &tmp); - si->u.imap.dir_sep = tmp; - /* strip trailing dir_sep or / */ - if (si->u.imap.namespace - && (si->u.imap.namespace[strlen (si->u.imap.namespace) - 1] == si->u.imap.dir_sep - || si->u.imap.namespace[strlen (si->u.imap.namespace) - 1] == '/')) { - si->u.imap.namespace[strlen (si->u.imap.namespace) - 1] = 0; - } - - d(printf ("namespace '%s' dir_sep '%c'\n", si->u.imap.namespace, si->u.imap.dir_sep ? si->u.imap.dir_sep : '?')); - - while (camel_file_util_decode_string (storeinfo, &buf) == 0) { - folder = parse_lsub (buf, &dir_sep); - if (folder) { - fi = g_new0 (struct _imap_folder_info_1_0, 1); - fi->folder = folder; - fi->dir_sep = dir_sep; -#if d(!)0 - printf (" add folder '%s' ", folder); - if (dir_sep) - printf ("'%c'\n", dir_sep); - else - printf ("NIL\n"); -#endif - g_hash_table_insert (si->u.imap.folders, fi->folder, fi); - } else { - g_warning ("Could not parse LIST result '%s'\n", buf); - } - } - - fclose (storeinfo); - - return 0; -} - -static int -load_accounts_1_0 (xmlDocPtr doc) -{ - xmlNodePtr source; - char *val, *tmp; - int count = 0, i; - char key[32]; - - if (!(source = e_bconf_get_path (doc, "/Mail/Accounts"))) - return 0; - - if ((val = e_bconf_get_value (source, "num"))) { - count = atoi (val); - xmlFree (val); - } - - /* load account upgrade info for each account */ - for (i = 0; i < count; i++) { - struct _account_info_1_0 *ai; - char *rawuri; - - sprintf (key, "source_url_%d", i); - if (!(rawuri = e_bconf_get_value (source, key))) - continue; - - ai = g_malloc0 (sizeof (struct _account_info_1_0)); - ai->uri = e_bconf_hex_decode (rawuri); - ai->base_uri = get_base_uri (ai->uri); - sprintf (key, "account_name_%d", i); - ai->name = e_bconf_get_string (source, key); - - d(printf("load account '%s'\n", ai->uri)); - - if (!strncmp (ai->uri, "imap:", 5)) { - read_imap_storeinfo (ai); - } else if (!strncmp (ai->uri, "exchange:", 9)) { - xmlNodePtr node; - - d(printf (" upgrade exchange account\n")); - /* small hack, poke the source_url into the transport_url for exchanget: transports - - this will be picked up later in the conversion */ - sprintf (key, "transport_url_%d", i); - node = e_bconf_get_entry (source, key); - if (node && (val = (char *)xmlGetProp (node, (const unsigned char *)"value"))) { - tmp = e_bconf_hex_decode (val); - xmlFree (val); - if (strncmp (tmp, "exchanget:", 10) == 0) - xmlSetProp (node, (const unsigned char *)"value", (unsigned char *)rawuri); - g_free (tmp); - } else { - d(printf (" couldn't find transport uri?\n")); - } - } - xmlFree (rawuri); - - g_hash_table_insert (accounts_1_0, ai->base_uri, ai); - if (ai->name) - g_hash_table_insert (accounts_name_1_0, ai->name, ai); - } - - return 0; -} - -static int -em_migrate_1_0 (const char *evolution_dir, xmlDocPtr config_xmldb, xmlDocPtr filters, xmlDocPtr vfolders, CamelException *ex) -{ - accounts_1_0 = g_hash_table_new_full ( - g_str_hash, g_str_equal, - (GDestroyNotify) NULL, - (GDestroyNotify) account_info_1_0_free); - accounts_name_1_0 = g_hash_table_new (g_str_hash, g_str_equal); - load_accounts_1_0 (config_xmldb); - - upgrade_xml_uris(filters, upgrade_xml_uris_1_0); - upgrade_xml_uris(vfolders, upgrade_xml_uris_1_0); - - g_hash_table_destroy (accounts_1_0); - g_hash_table_destroy (accounts_name_1_0); - - return 0; -} - -/* 1.2 upgrade functions */ -static int -is_xml1encoded (const char *txt) -{ - const unsigned char *p; - int isxml1 = FALSE; - int is8bit = FALSE; - - p = (const unsigned char *)txt; - while (*p) { - if (p[0] == '\\' && p[1] == 'U' && p[2] == '+' - && isxdigit (p[3]) && isxdigit (p[4]) && isxdigit (p[5]) && isxdigit (p[6]) - && p[7] == '\\') { - isxml1 = TRUE; - p+=7; - } else if (p[0] >= 0x80) - is8bit = TRUE; - p++; - } - - /* check for invalid utf8 that needs cleaning */ - if (is8bit && !isxml1) - isxml1 = !g_utf8_validate (txt, -1, NULL); - - return isxml1; -} - -static char * -decode_xml1 (const char *txt) -{ - GString *out = g_string_new (""); - const unsigned char *p; - char *res; - - /* convert: - \U+XXXX\ -> utf8 - 8 bit characters -> utf8 (iso-8859-1) */ - - p = (const unsigned char *) txt; - while (*p) { - if (p[0] > 0x80 - || (p[0] == '\\' && p[1] == 'U' && p[2] == '+' - && isxdigit (p[3]) && isxdigit (p[4]) && isxdigit (p[5]) && isxdigit (p[6]) - && p[7] == '\\')) { - char utf8[8]; - gunichar u; - - if (p[0] == '\\') { - memcpy (utf8, p + 3, 4); - utf8[4] = 0; - u = strtoul (utf8, NULL, 16); - p+=7; - } else - u = p[0]; - utf8[g_unichar_to_utf8 (u, utf8)] = 0; - g_string_append (out, utf8); - } else { - g_string_append_c (out, *p); - } - p++; - } - - res = out->str; - g_string_free (out, FALSE); - - return res; -} - -static char * -utf8_reencode (const char *txt) -{ - GString *out = g_string_new (""); - gchar *p; - char *res; - - /* convert: - libxml1 8 bit utf8 converted to xml entities byte-by-byte chars -> utf8 */ - - p = (gchar *)txt; - - while (*p) { - g_string_append_c (out, (gchar)g_utf8_get_char ((const gchar *)p)); - p = (gchar *)g_utf8_next_char (p); - } - - res = out->str; - if (g_utf8_validate (res, -1, NULL)) { - g_string_free (out, FALSE); - return res; - } else { - g_string_free (out, TRUE); - return g_strdup (txt); - } -} - -static int -upgrade_xml_1_2_rec (xmlNodePtr node) -{ - const char *value_tags[] = { "string", "address", "regex", "file", "command", NULL }; - const char *rule_tags[] = { "title", NULL }; - const char *item_props[] = { "name", NULL }; - struct { - const char *name; - const char **tags; - const char **props; - } tags[] = { - { "value", value_tags, NULL }, - { "rule", rule_tags, NULL }, - { "item", NULL, item_props }, - { 0 }, - }; - xmlNodePtr work; - int i,j; - char *txt, *tmp; - - /* upgrades the content of a node, if the node has a specific parent/node name */ - - for (i = 0; tags[i].name; i++) { - if (!strcmp ((char *)node->name, tags[i].name)) { - if (tags[i].tags != NULL) { - work = node->children; - while (work) { - for (j = 0; tags[i].tags[j]; j++) { - if (!strcmp ((char *)work->name, tags[i].tags[j])) { - txt = (char *)xmlNodeGetContent (work); - if (is_xml1encoded (txt)) { - tmp = decode_xml1 (txt); - d(printf ("upgrading xml node %s/%s '%s' -> '%s'\n", - tags[i].name, tags[i].tags[j], txt, tmp)); - xmlNodeSetContent (work, (unsigned char *)tmp); - g_free (tmp); - } - xmlFree (txt); - } - } - work = work->next; - } - break; - } - - if (tags[i].props != NULL) { - for (j = 0; tags[i].props[j]; j++) { - txt = (char *)xmlGetProp (node, (unsigned char *)tags[i].props[j]); - tmp = utf8_reencode (txt); - d(printf ("upgrading xml property %s on node %s '%s' -> '%s'\n", - tags[i].props[j], tags[i].name, txt, tmp)); - xmlSetProp (node, (const unsigned char *)tags[i].props[j], (unsigned char *)tmp); - g_free (tmp); - xmlFree (txt); - } - } - } - } - - node = node->children; - while (node) { - upgrade_xml_1_2_rec (node); - node = node->next; - } - - return 0; -} - -static int -em_upgrade_xml_1_2 (xmlDocPtr doc) -{ - xmlNodePtr root; - - if (!doc || !(root = xmlDocGetRootElement (doc))) - return 0; - - return upgrade_xml_1_2_rec (root); -} - -/* converts passwords from ~/evolution/private/config.xmldb to gnome_private() */ -static int -upgrade_passwords_1_2(void) -{ - xmlNodePtr root, entry; - char *filename; - xmlDocPtr priv_doc = NULL; - struct stat st; - int work = 0, res = -1; - - filename = g_build_filename(g_get_home_dir(), "evolution/private/config.xmldb", NULL); - if (lstat(filename, &st) == 0 && S_ISREG(st.st_mode)) - priv_doc = xmlParseFile(filename); - g_free(filename); - - if (priv_doc == NULL) - return 0; - - root = priv_doc->children; - if (strcmp((char *)root->name, "bonobo-config") != 0) { - xmlFreeDoc(priv_doc); - return 0; - } - - root = root->children; - while (root) { - if (!strcmp((char *)root->name, "section")) { - char *path = (char *)xmlGetProp(root, (const unsigned char *)"path"); - - /* All sections of form -
- - Are converted to: - /Evolution/Passwords-COMPONENT/name = value - */ - - if (path && !strncmp(path, "/Passwords/", 11)) { - entry = root->children; - while (entry) { - if (!strcmp((char *)entry->name, "entry")) { - char *namep = (char *)xmlGetProp(entry, (const unsigned char *)"name"), - *valuep = (char *)xmlGetProp(entry, (const unsigned char *)"value"); - - if (namep && valuep) { - char *value = e_bconf_hex_decode(valuep); - guchar *decoded; - char *p, *new; - gsize len; - - decoded = g_base64_decode (namep, &len); - memcpy (namep, decoded, len); - g_free (decoded); - namep[len] = 0; - p = namep; - - d(printf("Found password entry '%s' = '%s'\n", namep, value)); - - while (*p) { - if (*p == '/' || *p == '=') - *p = '_'; - p++; - } - - p = g_strdup_printf("/Evolution/Passwords-%s/%s", path+11, namep); - new = gnome_config_private_get_string_with_default(p, NULL); - if (new == NULL) { - d(printf("password not there, setting '%s' = '%s'\n", p, value)); - gnome_config_private_set_string(p, value); - work = TRUE; - } else { - d(printf("password already there, leaving\n")); - } - g_free(p); - g_free(value); - } - xmlFree(namep); - xmlFree(valuep); - } - entry = entry->next; - } - } - xmlFree(path); - } - root = root->next; - } - - xmlFreeDoc(priv_doc); - - if (work) { - if (gnome_config_private_sync_file("/Evolution")) - res = 0; - } else { - res = 0; - } - - return res; -} - -/* ********************************************************************** */ -/* Tables for converting flat bonobo conf -> gconf xml blob */ -/* ********************************************************************** */ - -/* Mail/Accounts/ * */ -static e_bconf_map_t cc_map[] = { - { "account_always_cc_%i", "always", E_BCONF_MAP_BOOL }, - { "account_always_cc_addrs_%i", "recipients", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL }, -}; - -static e_bconf_map_t bcc_map[] = { - { "account_always_cc_%i", "always", E_BCONF_MAP_BOOL }, - { "account_always_bcc_addrs_%i", "recipients", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL }, -}; - -static e_bconf_map_t pgp_map[] = { - { "account_pgp_encrypt_to_self_%i", "encrypt-to-self", E_BCONF_MAP_BOOL }, - { "account_pgp_always_trust_%i", "always-trust", E_BCONF_MAP_BOOL }, - { "account_pgp_always_sign_%i", "always-sign", E_BCONF_MAP_BOOL }, - { "account_pgp_no_imip_sign_%i", "no-imip-sign", E_BCONF_MAP_BOOL }, - { "account_pgp_key_%i", "key-id", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL }, -}; - -static e_bconf_map_t smime_map[] = { - { "account_smime_encrypt_to_self_%i", "encrypt-to-self", E_BCONF_MAP_BOOL }, - { "account_smime_always_sign_%i", "always-sign", E_BCONF_MAP_BOOL }, - { "account_smime_key_%i", "key-id", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL }, -}; - -static e_bconf_map_t identity_sig_map[] = { - { "identity_autogenerated_signature_%i", "auto", E_BCONF_MAP_BOOL }, - { "identity_def_signature_%i", "default", E_BCONF_MAP_LONG }, - { NULL }, -}; - -static e_bconf_map_t identity_map[] = { - { "identity_name_%i", "name", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { "identity_address_%i", "addr-spec", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { "identity_reply_to_%i", "reply-to", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { "identity_organization_%i", "organization", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL, "signature", E_BCONF_MAP_CHILD, identity_sig_map }, - { NULL }, -}; - -static e_bconf_map_t source_map[] = { - { "source_save_passwd_%i", "save-passwd", E_BCONF_MAP_BOOL }, - { "source_keep_on_server_%i", "keep-on-server", E_BCONF_MAP_BOOL }, - { "source_auto_check_%i", "auto-check", E_BCONF_MAP_BOOL }, - { "source_auto_check_time_%i", "auto-check-timeout", E_BCONF_MAP_LONG }, - { "source_url_%i", "url", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL }, -}; - -static e_bconf_map_t transport_map[] = { - { "transport_save_passwd_%i", "save-passwd", E_BCONF_MAP_BOOL }, - { "transport_url_%i", "url", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL }, -}; - -static e_bconf_map_t account_map[] = { - { "account_name_%i", "name", E_BCONF_MAP_STRING }, - { "source_enabled_%i", "enabled", E_BCONF_MAP_BOOL }, - { NULL, "identity", E_BCONF_MAP_CHILD, identity_map }, - { NULL, "source", E_BCONF_MAP_CHILD, source_map }, - { NULL, "transport", E_BCONF_MAP_CHILD, transport_map }, - { "account_drafts_folder_uri_%i", "drafts-folder", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { "account_sent_folder_uri_%i", "sent-folder", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL, "auto-cc", E_BCONF_MAP_CHILD, cc_map }, - { NULL, "auto-bcc", E_BCONF_MAP_CHILD, bcc_map }, - { NULL, "pgp", E_BCONF_MAP_CHILD, pgp_map }, - { NULL, "smime", E_BCONF_MAP_CHILD, smime_map }, - { NULL }, -}; - -/* /Mail/Signatures/ * */ -static e_bconf_map_t signature_format_map[] = { - { "text/plain", }, - { "text/html", }, - { NULL } -}; - -static e_bconf_map_t signature_map[] = { - { "name_%i", "name", E_BCONF_MAP_STRING }, - { "html_%i", "format", E_BCONF_MAP_ENUM, signature_format_map }, - { "filename_%i", "filename", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { "script_%i", "script", E_BCONF_MAP_STRING|E_BCONF_MAP_CONTENT }, - { NULL }, -}; - -/* ********************************************************************** */ -/* Tables for bonobo conf -> gconf conversion */ -/* ********************************************************************** */ - -static e_gconf_map_t mail_accounts_map[] = { - /* /Mail/Accounts - most entries are processed via the xml blob routine */ - /* This also works because the initial uid mapping is 1:1 with the list order */ - { "default_account", "mail/default_account", E_GCONF_MAP_SIMPLESTRING }, - { 0 }, -}; - -static e_gconf_map_t mail_display_map[] = { - /* /Mail/Display */ - { "side_bar_search", "mail/display/side_bar_search", E_GCONF_MAP_BOOL }, - { "thread_list", "mail/display/thread_list", E_GCONF_MAP_BOOL }, - { "thread_subject", "mail/display/thread_subject", E_GCONF_MAP_BOOL }, - { "hide_deleted", "mail/display/show_deleted", E_GCONF_MAP_BOOLNOT }, - { "preview_pane", "mail/display/show_preview", E_GCONF_MAP_BOOL }, - { "paned_size", "mail/display/paned_size", E_GCONF_MAP_INT }, - { "seen_timeout", "mail/display/mark_seen_timeout", E_GCONF_MAP_INT }, - { "do_seen_timeout", "mail/display/mark_seen", E_GCONF_MAP_BOOL }, - { "http_images", "mail/display/load_http_images", E_GCONF_MAP_INT }, - { "citation_highlight", "mail/display/mark_citations", E_GCONF_MAP_BOOL }, - { "citation_color", "mail/display/citation_colour", E_GCONF_MAP_COLOUR }, - { 0 }, -}; - -static e_gconf_map_t mail_format_map[] = { - /* /Mail/Format */ - { "message_display_style", "mail/display/message_style", E_GCONF_MAP_INT }, - { "send_html", "mail/composer/send_html", E_GCONF_MAP_BOOL }, - { "default_reply_style", "mail/format/reply_style", E_GCONF_MAP_INT }, - { "default_forward_style", "mail/format/forward_style", E_GCONF_MAP_INT }, - { "default_charset", "mail/composer/charset", E_GCONF_MAP_STRING }, - { "confirm_unwanted_html", "mail/prompts/unwanted_html", E_GCONF_MAP_BOOL }, - { 0 }, -}; - -static e_gconf_map_t mail_trash_map[] = { - /* /Mail/Trash */ - { "empty_on_exit", "mail/trash/empty_on_exit", E_GCONF_MAP_BOOL }, - { 0 }, -}; - -static e_gconf_map_t mail_prompts_map[] = { - /* /Mail/Prompts */ - { "confirm_expunge", "mail/prompts/expunge", E_GCONF_MAP_BOOL }, - { "empty_subject", "mail/prompts/empty_subject", E_GCONF_MAP_BOOL }, - { "only_bcc", "mail/prompts/only_bcc", E_GCONF_MAP_BOOL }, - { 0 } -}; - -static e_gconf_map_t mail_filters_map[] = { - /* /Mail/Filters */ - { "log", "mail/filters/log", E_GCONF_MAP_BOOL }, - { "log_path", "mail/filters/logfile", E_GCONF_MAP_STRING }, - { 0 } -}; - -static e_gconf_map_t mail_notify_map[] = { - /* /Mail/Notify */ - { "new_mail_notification", "mail/notify/type", E_GCONF_MAP_INT }, - { "new_mail_notification_sound_file", "mail/notify/sound", E_GCONF_MAP_STRING }, - { 0 } -}; - -static e_gconf_map_t mail_filesel_map[] = { - /* /Mail/Filesel */ - { "last_filesel_dir", "mail/save_dir", E_GCONF_MAP_STRING }, - { 0 } -}; - -static e_gconf_map_t mail_composer_map[] = { - /* /Mail/Composer */ - { "ViewFrom", "mail/composer/view/From", E_GCONF_MAP_BOOL }, - { "ViewReplyTo", "mail/composer/view/ReplyTo", E_GCONF_MAP_BOOL }, - { "ViewCC", "mail/composer/view/Cc", E_GCONF_MAP_BOOL }, - { "ViewBCC", "mail/composer/view/Bcc", E_GCONF_MAP_BOOL }, - { "ViewSubject", "mail/composer/view/Subject", E_GCONF_MAP_BOOL }, - { 0 }, -}; - -/* ********************************************************************** */ - -static e_gconf_map_t importer_elm_map[] = { - /* /Importer/Elm */ - { "mail", "importer/elm/mail", E_GCONF_MAP_BOOL }, - { "mail-imported", "importer/elm/mail-imported", E_GCONF_MAP_BOOL }, - { 0 }, -}; - -static e_gconf_map_t importer_pine_map[] = { - /* /Importer/Pine */ - { "mail", "importer/elm/mail", E_GCONF_MAP_BOOL }, - { "address", "importer/elm/address", E_GCONF_MAP_BOOL }, - { 0 }, -}; - -static e_gconf_map_t importer_netscape_map[] = { - /* /Importer/Netscape */ - { "mail", "importer/netscape/mail", E_GCONF_MAP_BOOL }, - { "settings", "importer/netscape/settings", E_GCONF_MAP_BOOL }, - { "filters", "importer/netscape/filters", E_GCONF_MAP_BOOL }, - { 0 }, -}; - -/* ********************************************************************** */ - -static e_gconf_map_list_t gconf_remap_list[] = { - { "/Mail/Accounts", mail_accounts_map }, - { "/Mail/Display", mail_display_map }, - { "/Mail/Format", mail_format_map }, - { "/Mail/Trash", mail_trash_map }, - { "/Mail/Prompts", mail_prompts_map }, - { "/Mail/Filters", mail_filters_map }, - { "/Mail/Notify", mail_notify_map }, - { "/Mail/Filesel", mail_filesel_map }, - { "/Mail/Composer", mail_composer_map }, - - { "/Importer/Elm", importer_elm_map }, - { "/Importer/Pine", importer_pine_map }, - { "/Importer/Netscape", importer_netscape_map }, - - { 0 }, -}; - -static struct { - char *label; - char *colour; -} label_default[5] = { - { N_("Important"), "#EF2929" }, /* red */ - { N_("Work"), "#F57900" }, /* orange */ - { N_("Personal"), "#4E9A06" }, /* green */ - { N_("To Do"), "#3465A4" }, /* blue */ - { N_("Later"), "#75507B" } /* purple */ -}; - -/* remaps mail config from bconf to gconf */ -static int -bconf_import(GConfClient *gconf, xmlDocPtr config_xmldb) -{ - xmlNodePtr source; - char labx[16], colx[16]; - char *val, *lab, *col; - GSList *list, *l; - int i; - - e_bconf_import(gconf, config_xmldb, gconf_remap_list); - - /* Labels: - label string + label colour as integer - -> label string:# colour as hex */ - source = e_bconf_get_path(config_xmldb, "/Mail/Labels"); - if (source) { - list = NULL; - for (i = 0; i < 5; i++) { - sprintf(labx, "label_%d", i); - sprintf(colx, "color_%d", i); - lab = e_bconf_get_string(source, labx); - if ((col = e_bconf_get_value(source, colx))) { - sprintf(colx, "#%06x", atoi(col) & 0xffffff); - g_free(col); - } else - strcpy(colx, label_default[i].colour); - - val = g_strdup_printf("%s:%s", lab ? lab : label_default[i].label, colx); - list = g_slist_append(list, val); - g_free(lab); - } - - gconf_client_set_list(gconf, "/apps/evolution/mail/labels", GCONF_VALUE_STRING, list, NULL); - while (list) { - l = list->next; - g_free(list->data); - g_slist_free_1(list); - list = l; - } - } else { - g_warning("could not find /Mail/Labels in old config database, skipping"); - } - - /* Accounts: The flat bonobo-config structure is remapped to a list of xml blobs. Upgrades as necessary */ - e_bconf_import_xml_blob(gconf, config_xmldb, account_map, "/Mail/Accounts", - "/apps/evolution/mail/accounts", "account", "uid"); - - /* Same for signatures */ - e_bconf_import_xml_blob(gconf, config_xmldb, signature_map, "/Mail/Signatures", - "/apps/evolution/mail/signatures", "signature", NULL); - - return 0; -} - -static int -em_migrate_1_2(const char *evolution_dir, xmlDocPtr config_xmldb, xmlDocPtr filters, xmlDocPtr vfolders, CamelException *ex) -{ - GConfClient *gconf; - - gconf = gconf_client_get_default(); - bconf_import(gconf, config_xmldb); - g_object_unref(gconf); - - em_upgrade_xml_1_2(filters); - em_upgrade_xml_1_2(vfolders); - upgrade_passwords_1_2(); - - return 0; -} - -/* 1.4 upgrade functions */ - -#define EM_MIGRATE_SESSION_TYPE (em_migrate_session_get_type ()) -#define EM_MIGRATE_SESSION(obj) (CAMEL_CHECK_CAST((obj), EM_MIGRATE_SESSION_TYPE, EMMigrateSession)) -#define EM_MIGRATE_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), EM_MIGRATE_SESSION_TYPE, EMMigrateSessionClass)) -#define EM_MIGRATE_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), EM_MIGRATE_SESSION_TYPE)) - -typedef struct _EMMigrateSession { - CamelSession parent_object; - - CamelStore *store; /* new folder tree store */ - char *srcdir; /* old folder tree path */ -} EMMigrateSession; - -typedef struct _EMMigrateSessionClass { - CamelSessionClass parent_class; - -} EMMigrateSessionClass; - -static CamelType em_migrate_session_get_type (void); -static CamelSession *em_migrate_session_new (const char *path); - -static void -class_init (EMMigrateSessionClass *klass) -{ - ; -} - -static CamelType -em_migrate_session_get_type (void) -{ - static CamelType type = CAMEL_INVALID_TYPE; - - if (type == CAMEL_INVALID_TYPE) { - type = camel_type_register ( - camel_session_get_type (), - "EMMigrateSession", - sizeof (EMMigrateSession), - sizeof (EMMigrateSessionClass), - (CamelObjectClassInitFunc) class_init, - NULL, - NULL, - NULL); - } - - return type; -} - -static CamelSession * -em_migrate_session_new (const char *path) -{ - CamelSession *session; - - session = CAMEL_SESSION (camel_object_new (EM_MIGRATE_SESSION_TYPE)); - - camel_session_construct (session, path); - - return session; -} - - -#endif /* !G_OS_WIN32 */ - -static GtkWidget *window; -static GtkLabel *label; -static GtkProgressBar *progress; - -static void -em_migrate_setup_progress_dialog (const char *desc) -{ - GtkWidget *vbox, *hbox, *w; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title ((GtkWindow *) window, _("Migrating...")); - gtk_window_set_modal ((GtkWindow *) window, TRUE); - gtk_container_set_border_width ((GtkContainer *) window, 6); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_widget_show (vbox); - gtk_container_add ((GtkContainer *) window, vbox); - - w = gtk_label_new (desc); - - gtk_label_set_line_wrap ((GtkLabel *) w, TRUE); - gtk_widget_show (w); - gtk_box_pack_start_defaults ((GtkBox *) vbox, w); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_widget_show (hbox); - gtk_box_pack_start_defaults ((GtkBox *) vbox, hbox); - - label = (GtkLabel *) gtk_label_new (""); - gtk_widget_show ((GtkWidget *) label); - gtk_box_pack_start_defaults ((GtkBox *) hbox, (GtkWidget *) label); - - progress = (GtkProgressBar *) gtk_progress_bar_new (); - gtk_widget_show ((GtkWidget *) progress); - gtk_box_pack_start_defaults ((GtkBox *) hbox, (GtkWidget *) progress); - - gtk_widget_show (window); -} - -static void -em_migrate_close_progress_dialog (void) -{ - gtk_widget_destroy ((GtkWidget *) window); -} - -static void -em_migrate_set_folder_name (const char *folder_name) -{ - char *text; - - text = g_strdup_printf (_("Migrating '%s':"), folder_name); - gtk_label_set_text (label, text); - g_free (text); - - gtk_progress_bar_set_fraction (progress, 0.0); - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -static void -em_migrate_set_progress (double percent) -{ - char text[5]; - - snprintf (text, sizeof (text), "%d%%", (int) (percent * 100.0f)); - - gtk_progress_bar_set_fraction (progress, percent); - gtk_progress_bar_set_text (progress, text); - - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -#ifndef G_OS_WIN32 - -static gboolean -is_mail_folder (const char *metadata) -{ - xmlNodePtr node; - xmlDocPtr doc; - char *type; - - if (!(doc = xmlParseFile (metadata))) { - g_warning ("Cannot parse `%s'", metadata); - return FALSE; - } - - if (!(node = xmlDocGetRootElement (doc))) { - g_warning ("`%s' corrupt: document contains no root node", metadata); - xmlFreeDoc (doc); - return FALSE; - } - - if (!node->name || strcmp ((char *)node->name, "efolder") != 0) { - g_warning ("`%s' corrupt: root node is not 'efolder'", metadata); - xmlFreeDoc (doc); - return FALSE; - } - - node = node->children; - while (node != NULL) { - if (node->name && !strcmp ((char *)node->name, "type")) { - type = (char *)xmlNodeGetContent (node); - if (!strcmp ((char *)type, "mail")) { - xmlFreeDoc (doc); - xmlFree (type); - - return TRUE; - } - - xmlFree (type); - - break; - } - - node = node->next; - } - - xmlFreeDoc (doc); - - return FALSE; -} - -static int -get_local_et_expanded (const char *dirname) -{ - xmlNodePtr node; - xmlDocPtr doc; - struct stat st; - char *buf, *p; - int thread_list; - - buf = g_strdup_printf ("%s/evolution/config/file:%s", g_get_home_dir (), dirname); - p = buf + strlen (g_get_home_dir ()) + strlen ("/evolution/config/file:"); - e_filename_make_safe (p); - - if (stat (buf, &st) == -1) { - g_free (buf); - return -1; - } - - if (!(doc = xmlParseFile (buf))) { - g_free (buf); - return -1; - } - - g_free (buf); - - if (!(node = xmlDocGetRootElement (doc)) || strcmp ((char *)node->name, "expanded_state") != 0) { - xmlFreeDoc (doc); - return -1; - } - - if (!(buf = (char *)xmlGetProp (node, (const unsigned char *)"default"))) { - xmlFreeDoc (doc); - return -1; - } - - thread_list = strcmp (buf, "0") == 0 ? 0 : 1; - xmlFree (buf); - - xmlFreeDoc (doc); - - return thread_list; -} - -static char * -get_local_store_uri (const char *dirname, char **namep, int *indexp) -{ - char *protocol, *name, *metadata, *tmp; - int index; - struct stat st; - xmlNodePtr node; - xmlDocPtr doc; - - metadata = g_build_filename(dirname, "local-metadata.xml", NULL); - - /* in 1.4, any errors are treated as defaults, this function cannot fail */ - - /* defaults */ - name = "mbox"; - protocol = "mbox"; - index = TRUE; - - if (stat (metadata, &st) == -1 || !S_ISREG (st.st_mode)) - goto nofile; - - doc = xmlParseFile(metadata); - if (doc == NULL) - goto nofile; - - node = doc->children; - if (strcmp((char *)node->name, "folderinfo")) - goto dodefault; - - for (node = node->children; node; node = node->next) { - if (node->name && !strcmp ((char *)node->name, "folder")) { - tmp = (char *)xmlGetProp (node, (const unsigned char *)"type"); - if (tmp) { - protocol = alloca(strlen(tmp)+1); - strcpy(protocol, tmp); - xmlFree(tmp); - } - tmp = (char *)xmlGetProp (node, (const unsigned char *)"name"); - if (tmp) { - name = alloca(strlen(tmp)+1); - strcpy(name, tmp); - xmlFree(tmp); - } - tmp = (char *)xmlGetProp (node, (const unsigned char *)"index"); - if (tmp) { - index = atoi(tmp); - xmlFree(tmp); - } - } - } -dodefault: - xmlFreeDoc (doc); -nofile: - g_free(metadata); - - *namep = g_strdup(name); - *indexp = index; - - return g_strdup_printf("%s:%s", protocol, dirname); -} - -#endif /* !G_OS_WIN32 */ - -enum { - CP_UNIQUE = 0, - CP_OVERWRITE, - CP_APPEND, -}; - -static int open_flags[3] = { - O_WRONLY | O_CREAT | O_TRUNC, - O_WRONLY | O_CREAT | O_TRUNC, - O_WRONLY | O_CREAT | O_APPEND, -}; - -static int -cp (const char *src, const char *dest, gboolean show_progress, int mode) -{ - unsigned char readbuf[65536]; - ssize_t nread, nwritten; - int errnosav, readfd, writefd; - size_t total = 0; - struct stat st; - struct utimbuf ut; - - /* if the dest file exists and has content, abort - we don't - * want to corrupt their existing data */ - if (g_stat (dest, &st) == 0 && st.st_size > 0 && mode == CP_UNIQUE) { - errno = EEXIST; - return -1; - } - - if (g_stat (src, &st) == -1 - || (readfd = g_open (src, O_RDONLY | O_BINARY, 0)) == -1) - return -1; - - if ((writefd = g_open (dest, open_flags[mode] | O_BINARY, 0666)) == -1) { - errnosav = errno; - close (readfd); - errno = errnosav; - return -1; - } - - do { - do { - nread = read (readfd, readbuf, sizeof (readbuf)); - } while (nread == -1 && errno == EINTR); - - if (nread == 0) - break; - else if (nread < 0) - goto exception; - - do { - nwritten = write (writefd, readbuf, nread); - } while (nwritten == -1 && errno == EINTR); - - if (nwritten < nread) - goto exception; - - total += nwritten; - if (show_progress) - em_migrate_set_progress (((double) total) / ((double) st.st_size)); - } while (total < st.st_size); - - if (fsync (writefd) == -1) - goto exception; - - close (readfd); - if (close (writefd) == -1) - goto failclose; - - ut.actime = st.st_atime; - ut.modtime = st.st_mtime; - utime (dest, &ut); - chmod (dest, st.st_mode); - - return 0; - - exception: - - errnosav = errno; - close (readfd); - close (writefd); - errno = errnosav; - - failclose: - - errnosav = errno; - unlink (dest); - errno = errnosav; - - return -1; -} - -#ifndef G_OS_WIN32 - -static int -cp_r (const char *src, const char *dest, const char *pattern, int mode) -{ - GString *srcpath, *destpath; - struct dirent *dent; - size_t slen, dlen; - struct stat st; - DIR *dir; - - if (g_mkdir_with_parents (dest, 0777) == -1) - return -1; - - if (!(dir = opendir (src))) - return -1; - - srcpath = g_string_new (src); - g_string_append_c (srcpath, '/'); - slen = srcpath->len; - - destpath = g_string_new (dest); - g_string_append_c (destpath, '/'); - dlen = destpath->len; - - while ((dent = readdir (dir))) { - if (!strcmp (dent->d_name, ".") || !strcmp (dent->d_name, "..")) - continue; - - g_string_truncate (srcpath, slen); - g_string_truncate (destpath, dlen); - - g_string_append (srcpath, dent->d_name); - g_string_append (destpath, dent->d_name); - - if (stat (srcpath->str, &st) == -1) - continue; - - if (S_ISDIR (st.st_mode)) { - cp_r (srcpath->str, destpath->str, pattern, mode); - } else if (!pattern || !strcmp (dent->d_name, pattern)) { - cp (srcpath->str, destpath->str, FALSE, mode); - } - } - - closedir (dir); - - g_string_free (destpath, TRUE); - g_string_free (srcpath, TRUE); - - return 0; -} - -static void -mbox_build_filename (GString *path, const char *toplevel_dir, const char *full_name) -{ - const char *start, *inptr = full_name; - int subdirs = 0; - - while (*inptr != '\0') { - if (*inptr == '/') - subdirs++; - inptr++; - } - - g_string_assign(path, toplevel_dir); - g_string_append_c (path, '/'); - - inptr = full_name; - while (*inptr != '\0') { - start = inptr; - while (*inptr != '/' && *inptr != '\0') - inptr++; - - g_string_append_len (path, start, inptr - start); - - if (*inptr == '/') { - g_string_append (path, ".sbd/"); - inptr++; - - /* strip extranaeous '/'s */ - while (*inptr == '/') - inptr++; - } - } -} - -static int -em_migrate_folder(EMMigrateSession *session, const char *dirname, const char *full_name, CamelException *ex) -{ - CamelFolder *old_folder = NULL, *new_folder = NULL; - CamelStore *local_store = NULL; - char *name, *uri; - GPtrArray *uids; - struct stat st; - int thread_list; - int index, i; - GString *src, *dest; - int res = -1; - - src = g_string_new(""); - - g_string_printf(src, "%s/folder-metadata.xml", dirname); - if (stat (src->str, &st) == -1 - || !S_ISREG (st.st_mode) - || !is_mail_folder(src->str)) { - /* Not an evolution mail folder */ - g_string_free(src, TRUE); - return 0; - } - - dest = g_string_new(""); - uri = get_local_store_uri(dirname, &name, &index); - em_migrate_set_folder_name (full_name); - thread_list = get_local_et_expanded (dirname); - - /* Manually copy local mbox files, its much faster */ - if (!strncmp (uri, "mbox:", 5)) { - static char *meta_ext[] = { ".summary", ".ibex.index", ".ibex.index.data" }; - size_t slen, dlen; - FILE *fp; - char *p; - int mode; - - g_string_printf (src, "%s/%s", uri + 5, name); - mbox_build_filename (dest, ((CamelService *)session->store)->url->path, full_name); - p = strrchr (dest->str, '/'); - *p = '\0'; - - slen = src->len; - dlen = dest->len; - - if (g_mkdir_with_parents (dest->str, 0777) == -1 && errno != EEXIST) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to create new folder `%s': %s"), - dest->str, g_strerror(errno)); - goto fatal; - } - - *p = '/'; - mode = CP_UNIQUE; - retry_copy: - if (cp (src->str, dest->str, TRUE, mode) == -1) { - if (errno == EEXIST) { - int save = errno; - - switch (e_error_run(NULL, "mail:ask-migrate-existing", src->str, dest->str, NULL)) { - case GTK_RESPONSE_ACCEPT: - mode = CP_OVERWRITE; - goto retry_copy; - case GTK_RESPONSE_OK: - mode = CP_APPEND; - goto retry_copy; - case GTK_RESPONSE_REJECT: - goto ignore; - } - - errno = save; - } - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to copy folder `%s' to `%s': %s"), - src->str, dest->str, g_strerror(errno)); - goto fatal; - } - ignore: - - /* create a .cmeta file specifying to index and/or thread the folder */ - g_string_truncate (dest, dlen); - g_string_append (dest, ".cmeta"); - if ((fp = fopen (dest->str, "w")) != NULL) { - int fd = fileno (fp); - - /* write the magic string */ - if (fwrite ("CLMD", 4, 1, fp) != 1) - goto cmeta_err; - - /* write the version (1) */ - if (camel_file_util_encode_uint32 (fp, 1) == -1) - goto cmeta_err; - - /* write the meta count */ - if (camel_file_util_encode_uint32 (fp, thread_list != -1 ? 1 : 0) == -1) - goto cmeta_err; - - if (thread_list != -1) { - if (camel_file_util_encode_string (fp, "evolution:thread_list") == -1) - goto cmeta_err; - - if (camel_file_util_encode_string (fp, thread_list ? "1" : "0") == -1) - goto cmeta_err; - } - - /* write the prop count (only prop is the index prop) */ - if (camel_file_util_encode_uint32 (fp, 1) == -1) - goto cmeta_err; - - /* write the index prop tag (== CAMEL_FOLDER_ARG_LAST|CAMEL_ARG_BOO) */ - if (camel_file_util_encode_uint32 (fp, CAMEL_FOLDER_ARG_LAST|CAMEL_ARG_BOO) == -1) - goto cmeta_err; - - /* write the index prop value */ - if (camel_file_util_encode_uint32 (fp, 1) == -1) - goto cmeta_err; - - fflush (fp); - - if (fsync (fd) == -1) { - cmeta_err: - fclose (fp); - unlink (dest->str); - } else { - fclose (fp); - } - } - - /* copy over the metadata files */ - for (i = 0; i < sizeof(meta_ext)/sizeof(meta_ext[0]); i++) { - g_string_truncate (src, slen); - g_string_truncate (dest, dlen); - - g_string_append (src, meta_ext[i]); - g_string_append (dest, meta_ext[i]); - cp (src->str, dest->str, FALSE, CP_OVERWRITE); - } - } else { - guint32 flags = CAMEL_STORE_FOLDER_CREATE; - - if (!(local_store = camel_session_get_store ((CamelSession *) session, uri, ex)) - || !(old_folder = camel_store_get_folder (local_store, name, 0, ex))) - goto fatal; - - flags |= (index ? CAMEL_STORE_FOLDER_BODY_INDEX : 0); - if (!(new_folder = camel_store_get_folder (session->store, full_name, flags, ex))) - goto fatal; - - if (thread_list != -1) { - camel_object_meta_set (new_folder, "evolution:thread_list", thread_list ? "1" : "0"); - camel_object_state_write (new_folder); - } - - uids = camel_folder_get_uids (old_folder); - for (i = 0; i < uids->len; i++) { - CamelMimeMessage *message; - CamelMessageInfo *info; - - if (!(info = camel_folder_get_message_info (old_folder, uids->pdata[i]))) - continue; - - if (!(message = camel_folder_get_message (old_folder, uids->pdata[i], ex))) { - camel_folder_free_message_info (old_folder, info); - camel_folder_free_uids (old_folder, uids); - goto fatal; - } - - camel_folder_append_message (new_folder, message, info, NULL, ex); - camel_folder_free_message_info (old_folder, info); - camel_object_unref (message); - - if (camel_exception_is_set (ex)) - break; - - em_migrate_set_progress (((double) i + 1) / ((double) uids->len)); - } - - camel_folder_free_uids (old_folder, uids); - - if (camel_exception_is_set (ex)) - goto fatal; - } - res = 0; -fatal: - g_free (uri); - g_free (name); - g_string_free(src, TRUE); - g_string_free(dest, TRUE); - if (local_store) - camel_object_unref(local_store); - if (old_folder) - camel_object_unref(old_folder); - if (new_folder) - camel_object_unref(new_folder); - - return res; -} - -static int -em_migrate_dir (EMMigrateSession *session, const char *dirname, const char *full_name, CamelException *ex) -{ - char *path; - DIR *dir; - struct stat st; - struct dirent *dent; - int res = 0; - - if (em_migrate_folder(session, dirname, full_name, ex) == -1) - return -1; - - /* no subfolders, not readable, don't care */ - path = g_strdup_printf ("%s/subfolders", dirname); - if (stat (path, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_free (path); - return 0; - } - - if (!(dir = opendir (path))) { - g_free (path); - return 0; - } - - while (res == 0 && (dent = readdir (dir))) { - char *full_path; - char *name; - - if (dent->d_name[0] == '.') - continue; - - full_path = g_strdup_printf ("%s/%s", path, dent->d_name); - if (stat (full_path, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_free (full_path); - continue; - } - - name = g_strdup_printf ("%s/%s", full_name, dent->d_name); - res = em_migrate_dir (session, full_path, name, ex); - g_free (full_path); - g_free (name); - } - - closedir (dir); - - g_free (path); - - return res; -} - -static int -em_migrate_local_folders_1_4 (EMMigrateSession *session, CamelException *ex) -{ - struct dirent *dent; - struct stat st; - DIR *dir; - int res = 0; - - if (!(dir = opendir (session->srcdir))) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to scan for existing mailboxes at `%s': %s"), - session->srcdir, g_strerror(errno)); - return -1; - } - - em_migrate_setup_progress_dialog (_("The location and hierarchy of the Evolution mailbox " - "folders has changed since Evolution 1.x.\n\nPlease be " - "patient while Evolution migrates your folders...")); - - while (res == 0 && (dent = readdir (dir))) { - char *full_path; - - if (dent->d_name[0] == '.') - continue; - - full_path = g_strdup_printf ("%s/%s", session->srcdir, dent->d_name); - if (stat (full_path, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_free (full_path); - continue; - } - - res = em_migrate_dir (session, full_path, dent->d_name, ex); - g_free (full_path); - } - - closedir (dir); - - em_migrate_close_progress_dialog (); - - return res; -} - -static char * -upgrade_xml_uris_1_4 (const char *uri) -{ - char *path, *prefix, *p; - CamelURL *url; - - if (!strncmp (uri, "file:", 5)) { - url = camel_url_new (uri, NULL); - camel_url_set_protocol (url, "email"); - camel_url_set_user (url, "local"); - camel_url_set_host (url, "local"); - - prefix = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); - if (strncmp (url->path, prefix, strlen (prefix)) != 0) { - /* uri is busticated - user probably copied from another user's home directory */ - camel_url_free (url); - g_free (prefix); - - return g_strdup (uri); - } - path = g_strdup (url->path + strlen (prefix)); - g_free (prefix); - - /* modify the path in-place */ - p = path + strlen (path) - 12; - while (p > path) { - if (!strncmp (p, "/subfolders/", 12)) - memmove (p, p + 11, strlen (p + 11) + 1); - - p--; - } - - camel_url_set_path (url, path); - g_free (path); - - path = camel_url_to_string (url, 0); - camel_url_free (url); - - return path; - } else { - return em_uri_from_camel (uri); - } -} - -static void -upgrade_vfolder_sources_1_4 (xmlDocPtr doc) -{ - xmlNodePtr root, node; - - if (!doc || !(root = xmlDocGetRootElement (doc))) - return; - - if (!root->name || strcmp ((char *)root->name, "filteroptions") != 0) { - /* root node is not , nothing to upgrade */ - return; - } - - if (!(node = xml_find_node (root, "ruleset"))) { - /* no ruleset node, nothing to upgrade */ - return; - } - - node = node->children; - while (node != NULL) { - if (node->name && !strcmp ((char *)node->name, "rule")) { - xmlNodePtr sources; - char *src; - - if (!(src = (char *)xmlGetProp (node, (const unsigned char *)"source"))) - src = (char *)xmlStrdup ((const unsigned char *)"local"); /* default to all local folders? */ - - xmlSetProp (node, (const unsigned char *)"source", (const unsigned char *)"incoming"); - - if (!(sources = xml_find_node (node, "sources"))) - sources = xmlNewChild (node, NULL, (const unsigned char *)"sources", NULL); - - xmlSetProp (sources, (const unsigned char *)"with", (unsigned char *)src); - xmlFree (src); - } - - node = node->next; - } -} - -static char * -get_nth_sig (int id) -{ - ESignatureList *list; - ESignature *sig; - EIterator *iter; - char *uid = NULL; - int i = 0; - - list = mail_config_get_signatures (); - iter = e_list_get_iterator ((EList *) list); - - while (e_iterator_is_valid (iter) && i < id) { - e_iterator_next (iter); - i++; - } - - if (i == id && e_iterator_is_valid (iter)) { - sig = (ESignature *) e_iterator_get (iter); - uid = g_strdup (sig->uid); - } - - g_object_unref (iter); - - return uid; -} - -static void -em_upgrade_accounts_1_4 (void) -{ - EAccountList *accounts; - EIterator *iter; - - if (!(accounts = mail_config_get_accounts ())) - return; - - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - EAccount *account = (EAccount *) e_iterator_get (iter); - char *url; - - if (account->drafts_folder_uri) { - url = upgrade_xml_uris_1_4 (account->drafts_folder_uri); - g_free (account->drafts_folder_uri); - account->drafts_folder_uri = url; - } - - if (account->sent_folder_uri) { - url = upgrade_xml_uris_1_4 (account->sent_folder_uri); - g_free (account->sent_folder_uri); - account->sent_folder_uri = url; - } - - if (account->id->sig_uid && !strncmp (account->id->sig_uid, "::", 2)) { - int sig_id; - - sig_id = strtol (account->id->sig_uid + 2, NULL, 10); - g_free (account->id->sig_uid); - account->id->sig_uid = get_nth_sig (sig_id); - } - - e_iterator_next (iter); - } - - g_object_unref (iter); - - mail_config_save_accounts (); -} - -static int -em_migrate_pop_uid_caches_1_4 (const char *evolution_dir, CamelException *ex) -{ - GString *oldpath, *newpath; - struct dirent *dent; - size_t olen, nlen; - char *cache_dir; - DIR *dir; - int res = 0; - - /* Sigh, too many unique strings to translate, for cases which shouldn't ever happen */ - - /* open the old cache dir */ - cache_dir = g_build_filename (g_get_home_dir (), "evolution", "mail", "pop3", NULL); - if (!(dir = opendir (cache_dir))) { - if (errno == ENOENT) { - g_free(cache_dir); - return 0; - } - - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to open old POP keep-on-server data `%s': %s"), - cache_dir, g_strerror (errno)); - g_free (cache_dir); - return -1; - } - - oldpath = g_string_new (cache_dir); - g_string_append_c (oldpath, '/'); - olen = oldpath->len; - g_free (cache_dir); - - cache_dir = g_build_filename (evolution_dir, "mail", "pop", NULL); - if (g_mkdir_with_parents (cache_dir, 0777) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to create POP3 keep-on-server data directory `%s': %s"), - cache_dir, g_strerror(errno)); - g_string_free (oldpath, TRUE); - g_free (cache_dir); - closedir (dir); - return -1; - } - - newpath = g_string_new (cache_dir); - g_string_append_c (newpath, '/'); - nlen = newpath->len; - g_free (cache_dir); - - while (res == 0 && (dent = readdir (dir))) { - if (strncmp (dent->d_name, "cache-pop:__", 12) != 0) - continue; - - g_string_truncate (oldpath, olen); - g_string_truncate (newpath, nlen); - - g_string_append (oldpath, dent->d_name); - g_string_append (newpath, dent->d_name + 12); - - /* strip the trailing '_' */ - g_string_truncate (newpath, newpath->len - 1); - - if (g_mkdir_with_parents (newpath->str, 0777) == -1 - || cp(oldpath->str, (g_string_append(newpath, "/uid-cache"))->str, FALSE, CP_UNIQUE)) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to copy POP3 keep-on-server data `%s': %s"), - oldpath->str, g_strerror(errno)); - res = -1; - } - - } - - g_string_free (oldpath, TRUE); - g_string_free (newpath, TRUE); - - closedir (dir); - - return res; -} - -static int -em_migrate_imap_caches_1_4 (const char *evolution_dir, CamelException *ex) -{ - char *src, *dest; - struct stat st; - - src = g_build_filename (g_get_home_dir (), "evolution", "mail", "imap", NULL); - if (stat (src, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_free (src); - return 0; - } - - dest = g_build_filename (evolution_dir, "mail", "imap", NULL); - - /* we don't care if this fails, it's only a cache... */ - cp_r (src, dest, "summary", CP_OVERWRITE); - - g_free (dest); - g_free (src); - - return 0; -} - -static int -em_migrate_folder_expand_state_1_4 (const char *evolution_dir, CamelException *ex) -{ - GString *srcpath, *destpath; - size_t slen, dlen, rlen; - char *evo14_mbox_root; - struct dirent *dent; - struct stat st; - DIR *dir; - - srcpath = g_string_new (g_get_home_dir ()); - g_string_append (srcpath, "/evolution/config"); - if (stat (srcpath->str, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_string_free (srcpath, TRUE); - return 0; - } - - destpath = g_string_new (evolution_dir); - g_string_append (destpath, "/mail/config"); - if (g_mkdir_with_parents (destpath->str, 0777) == -1 || !(dir = opendir (srcpath->str))) { - g_string_free (destpath, TRUE); - g_string_free (srcpath, TRUE); - return 0; - } - - g_string_append (srcpath, "/et-expanded-"); - slen = srcpath->len; - g_string_append (destpath, "/et-expanded-"); - dlen = destpath->len; - - evo14_mbox_root = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); - e_filename_make_safe (evo14_mbox_root); - rlen = strlen (evo14_mbox_root); - evo14_mbox_root = g_realloc (evo14_mbox_root, rlen + 2); - evo14_mbox_root[rlen++] = '_'; - evo14_mbox_root[rlen] = '\0'; - - while ((dent = readdir (dir))) { - char *full_name, *inptr, *buf = NULL; - const char *filename; - GString *new; - - if (strncmp (dent->d_name, "et-expanded-", 12) != 0) - continue; - - if (!strncmp (dent->d_name + 12, "file:", 5)) { - /* need to munge the filename */ - inptr = dent->d_name + 17; - - if (!strncmp (inptr, evo14_mbox_root, rlen)) { - /* this should always be the case afaik... */ - inptr += rlen; - new = g_string_new ("mbox:"); - g_string_append_printf (new, "%s/mail/local#", evolution_dir); - - full_name = g_strdup (inptr); - inptr = full_name + strlen (full_name) - 12; - while (inptr > full_name) { - if (!strncmp (inptr, "_subfolders_", 12)) - memmove (inptr, inptr + 11, strlen (inptr + 11) + 1); - - inptr--; - } - - g_string_append (new, full_name); - g_free (full_name); - - filename = buf = new->str; - g_string_free (new, FALSE); - e_filename_make_safe (buf); - } else { - /* but just in case... */ - filename = dent->d_name + 12; - } - } else { - /* no munging needed */ - filename = dent->d_name + 12; - } - - g_string_append (srcpath, dent->d_name + 12); - g_string_append (destpath, filename); - g_free (buf); - - cp (srcpath->str, destpath->str, FALSE, CP_UNIQUE); - - g_string_truncate (srcpath, slen); - g_string_truncate (destpath, dlen); - } - - closedir (dir); - - g_free (evo14_mbox_root); - g_string_free (destpath, TRUE); - g_string_free (srcpath, TRUE); - - return 0; -} - -static int -em_migrate_folder_view_settings_1_4 (const char *evolution_dir, CamelException *ex) -{ - GString *srcpath, *destpath; - size_t slen, dlen, rlen; - char *evo14_mbox_root; - struct dirent *dent; - struct stat st; - DIR *dir; - - srcpath = g_string_new (g_get_home_dir ()); - g_string_append (srcpath, "/evolution/views/mail"); - if (stat (srcpath->str, &st) == -1 || !S_ISDIR (st.st_mode)) { - g_string_free (srcpath, TRUE); - return 0; - } - - destpath = g_string_new (evolution_dir); - g_string_append (destpath, "/mail/views"); - if (g_mkdir_with_parents (destpath->str, 0777) == -1 || !(dir = opendir (srcpath->str))) { - g_string_free (destpath, TRUE); - g_string_free (srcpath, TRUE); - return 0; - } - - g_string_append_c (srcpath, '/'); - slen = srcpath->len; - g_string_append_c (destpath, '/'); - dlen = destpath->len; - - evo14_mbox_root = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); - e_filename_make_safe (evo14_mbox_root); - rlen = strlen (evo14_mbox_root); - evo14_mbox_root = g_realloc (evo14_mbox_root, rlen + 2); - evo14_mbox_root[rlen++] = '_'; - evo14_mbox_root[rlen] = '\0'; - - while ((dent = readdir (dir))) { - char *full_name, *inptr, *buf = NULL; - const char *filename, *ext; - size_t prelen = 0; - GString *new; - - if (dent->d_name[0] == '.') - continue; - - if (!(ext = strrchr (dent->d_name, '.'))) - continue; - - if (!strcmp (ext, ".galview") || !strcmp ((char *)dent->d_name, "galview.xml")) { - /* just copy the file */ - filename = dent->d_name; - goto copy; - } else if (strcmp (ext, ".xml") != 0) { - continue; - } - - if (!strncmp ((const char *)dent->d_name, "current_view-", 13)) { - prelen = 13; - } else if (!strncmp ((const char *)dent->d_name, "custom_view-", 12)) { - prelen = 12; - } else { - /* huh? wtf is this file? */ - continue; - } - - if (!strncmp (dent->d_name + prelen, "file:", 5)) { - /* need to munge the filename */ - inptr = dent->d_name + prelen + 5; - - if (!strncmp (inptr, evo14_mbox_root, rlen)) { - /* this should always be the case afaik... */ - inptr += rlen; - new = g_string_new ("mbox:"); - g_string_append_printf (new, "%s/mail/local#", evolution_dir); - - full_name = g_strdup (inptr); - inptr = full_name + strlen (full_name) - 12; - while (inptr > full_name) { - if (!strncmp (inptr, "_subfolders_", 12)) - memmove (inptr, inptr + 11, strlen (inptr + 11) + 1); - - inptr--; - } - - g_string_append (new, full_name); - g_free (full_name); - - filename = buf = new->str; - g_string_free (new, FALSE); - e_filename_make_safe (buf); - } else { - /* but just in case... */ - filename = dent->d_name + prelen; - } - } else { - /* no munging needed */ - filename = dent->d_name + prelen; - } - - copy: - g_string_append (srcpath, dent->d_name); - if (prelen > 0) - g_string_append_len (destpath, dent->d_name, prelen); - g_string_append (destpath, filename); - g_free (buf); - - cp (srcpath->str, destpath->str, FALSE, CP_UNIQUE); - - g_string_truncate (srcpath, slen); - g_string_truncate (destpath, dlen); - } - - closedir (dir); - - g_free (evo14_mbox_root); - g_string_free (destpath, TRUE); - g_string_free (srcpath, TRUE); - - return 0; -} - -#define SUBFOLDER_DIR_NAME "subfolders" -#define SUBFOLDER_DIR_NAME_LEN 10 - -static char * -e_path_to_physical (const char *prefix, const char *vpath) -{ - const char *p, *newp; - char *dp; - char *ppath; - int ppath_len; - int prefix_len; - - while (*vpath == '/') - vpath++; - if (!prefix) - prefix = ""; - - /* Calculate the length of the real path. */ - ppath_len = strlen (vpath); - ppath_len++; /* For the ending zero. */ - - prefix_len = strlen (prefix); - ppath_len += prefix_len; - ppath_len++; /* For the separating slash. */ - - /* Take account of the fact that we need to translate every - * separator into `subfolders/'. - */ - p = vpath; - while (1) { - newp = strchr (p, '/'); - if (newp == NULL) - break; - - ppath_len += SUBFOLDER_DIR_NAME_LEN; - ppath_len++; /* For the separating slash. */ - - /* Skip consecutive slashes. */ - while (*newp == '/') - newp++; - - p = newp; - }; - - ppath = g_malloc (ppath_len); - dp = ppath; - - memcpy (dp, prefix, prefix_len); - dp += prefix_len; - *(dp++) = '/'; - - /* Copy the mangled path. */ - p = vpath; - while (1) { - newp = strchr (p, '/'); - if (newp == NULL) { - strcpy (dp, p); - break; - } - - memcpy (dp, p, newp - p + 1); /* `+ 1' to copy the slash too. */ - dp += newp - p + 1; - - memcpy (dp, SUBFOLDER_DIR_NAME, SUBFOLDER_DIR_NAME_LEN); - dp += SUBFOLDER_DIR_NAME_LEN; - - *(dp++) = '/'; - - /* Skip consecutive slashes. */ - while (*newp == '/') - newp++; - - p = newp; - } - - return ppath; -} - -static int -em_migrate_imap_cmeta_1_4(const char *evolution_dir, CamelException *ex) -{ - GConfClient *gconf; - GSList *paths, *p; - EAccountList *accounts; - const EAccount *account; - - if (!(accounts = mail_config_get_accounts())) - return 0; - - gconf = gconf_client_get_default(); - paths = gconf_client_get_list(gconf, "/apps/evolution/shell/offline/folder_paths", GCONF_VALUE_STRING, NULL); - for (p = paths;p;p = g_slist_next(p)) { - char *name, *path; - - name = p->data; - if (*name) - name++; - path = strchr(name, '/'); - if (path) { - *path++ = 0; - account = e_account_list_find(accounts, E_ACCOUNT_FIND_NAME, name); - if (account && !strncmp(account->source->url, "imap:", 5)) { - CamelURL *url = camel_url_new(account->source->url, NULL); - - if (url) { - char *dir, *base; - - base = g_strdup_printf("%s/mail/imap/%s@%s/folders", - evolution_dir, - url->user?url->user:"", - url->host?url->host:""); - - dir = e_path_to_physical(base, path); - if (g_mkdir_with_parents(dir, 0777) == 0) { - char *cmeta; - FILE *fp; - - cmeta = g_build_filename(dir, "cmeta", NULL); - fp = fopen(cmeta, "w"); - if (fp) { - /* header/version */ - fwrite("CLMD", 4, 1, fp); - camel_file_util_encode_uint32(fp, 1); - /* meta count, do we have any metadata? */ - camel_file_util_encode_uint32(fp, 0); - /* prop count */ - camel_file_util_encode_uint32(fp, 1); - /* sync offline property */ - camel_file_util_encode_uint32(fp, CAMEL_DISCO_FOLDER_OFFLINE_SYNC); - camel_file_util_encode_uint32(fp, 1); - fclose(fp); - } else { - g_warning("couldn't create imap folder cmeta file '%s'", cmeta); - } - g_free(cmeta); - } else { - g_warning("couldn't create imap folder directory '%s'", dir); - } - g_free(dir); - g_free(base); - camel_url_free(url); - } - } else - g_warning("can't find offline folder '%s' '%s'", name, path); - } - g_free(p->data); - } - g_slist_free(paths); - g_object_unref(gconf); - - /* we couldn't care less if this doesn't work */ - - return 0; -} - -static void -remove_system_searches(xmlDocPtr searches) -{ - xmlNodePtr node; - - /* in pre 2.0, system searches were stored in the user - * searches.xml file with the source set to 'demand'. In 2.0+ - * the system searches are stored in the system - * searchtypes.xml file instead */ - - node = xmlDocGetRootElement(searches); - if (!node->name || strcmp((char *)node->name, "filteroptions")) - return; - - if (!(node = xml_find_node(node, "ruleset"))) - return; - - node = node->children; - while (node != NULL) { - xmlNodePtr nnode = node->next; - - if (node->name && !strcmp ((char *)node->name, "rule")) { - char *src; - - src = (char *)xmlGetProp(node, (unsigned char *)"source"); - if (src && !strcmp((char *)src, "demand")) { - xmlUnlinkNode(node); - xmlFreeNodeList(node); - } - xmlFree (src); - } - - node = nnode; - } -} - -static int -em_migrate_1_4 (const char *evolution_dir, xmlDocPtr filters, xmlDocPtr vfolders, CamelException *ex) -{ - EMMigrateSession *session; - CamelException lex; - struct stat st; - char *path; - xmlDocPtr searches; - - path = g_build_filename (evolution_dir, "mail", NULL); - - camel_init (path, TRUE); - camel_provider_init(); - session = (EMMigrateSession *) em_migrate_session_new (path); - g_free (path); - - session->srcdir = g_build_filename (g_get_home_dir (), "evolution", "local", NULL); - - path = g_strdup_printf ("mbox:%s/.evolution/mail/local", g_get_home_dir ()); - if (stat (path + 5, &st) == -1) { - if (errno != ENOENT || g_mkdir_with_parents (path + 5, 0777) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Failed to create local mail storage `%s': %s"), - path + 5, g_strerror (errno)); - g_free (session->srcdir); - camel_object_unref (session); - g_free (path); - return -1; - } - } - - camel_exception_init (&lex); - if (!(session->store = camel_session_get_store ((CamelSession *) session, path, &lex))) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Failed to create local mail storage `%s': %s"), - path, lex.desc); - g_free (session->srcdir); - camel_object_unref (session); - camel_exception_clear (&lex); - g_free (path); - return -1; - } - g_free (path); - - if (em_migrate_local_folders_1_4 (session, ex) == -1) - return -1; - - camel_object_unref (session->store); - g_free (session->srcdir); - - camel_object_unref (session); - - em_upgrade_accounts_1_4(); - - upgrade_xml_uris(filters, upgrade_xml_uris_1_4); - upgrade_vfolder_sources_1_4(vfolders); - upgrade_xml_uris(vfolders, upgrade_xml_uris_1_4); - - path = g_build_filename(g_get_home_dir(), "evolution", NULL); - searches = emm_load_xml(path, "searches.xml"); - g_free(path); - if (searches) { - remove_system_searches(searches); - path = g_build_filename(evolution_dir, "mail", NULL); - emm_save_xml(searches, path, "searches.xml"); - g_free(path); - xmlFreeDoc(searches); - } - - if (em_migrate_pop_uid_caches_1_4 (evolution_dir, ex) == -1) - return -1; - - /* these are non-fatal */ - em_migrate_imap_caches_1_4 (evolution_dir, ex); - camel_exception_clear(ex); - em_migrate_folder_expand_state_1_4 (evolution_dir, ex); - camel_exception_clear(ex); - em_migrate_folder_view_settings_1_4 (evolution_dir, ex); - camel_exception_clear(ex); - em_migrate_imap_cmeta_1_4(evolution_dir, ex); - camel_exception_clear(ex); - - return 0; -} - -static void -em_update_accounts_2_11 (void) -{ - EAccountList *accounts; - EIterator *iter; - gboolean changed = FALSE; - - if (!(accounts = mail_config_get_accounts ())) - return; - - iter = e_list_get_iterator ((EList *) accounts); - while (e_iterator_is_valid (iter)) { - EAccount *account = (EAccount *) e_iterator_get (iter); - - if (g_str_has_prefix (account->source->url, "spool://")) { - if (g_file_test (account->source->url + 8, G_FILE_TEST_IS_DIR)) { - char *str = g_strdup_printf ("spooldir://%s", account->source->url + 8); - - g_free (account->source->url); - account->source->url = str; - changed = TRUE; - } - } - - e_iterator_next (iter); - } - - g_object_unref (iter); - - if (changed) - mail_config_save_accounts (); -} - -#endif /* !G_OS_WIN32 */ - -static int -emm_setup_initial(const char *evolution_dir) -{ - GDir *dir; - const char *d; - char *local = NULL, *base; - const gchar * const *language_names; - - /* special-case - this means brand new install of evolution */ - /* FIXME: create default folders and stuff... */ - - d(printf("Setting up initial mail tree\n")); - - base = g_build_filename(evolution_dir, "mail", "local", NULL); - if (g_mkdir_with_parents(base, 0777) == -1 && errno != EEXIST) { - g_free(base); - return -1; - } - - /* e.g. try en-AU then en, etc */ - language_names = g_get_language_names (); - while (*language_names != NULL) { - local = g_build_filename ( - EVOLUTION_PRIVDATADIR, "default", - *language_names, "mail", "local", NULL); - if (g_file_test (local, G_FILE_TEST_EXISTS)) - break; - g_free (local); - language_names++; - } - - /* Make sure we found one. */ - g_return_val_if_fail (*language_names != NULL, 0); - - dir = g_dir_open(local, 0, NULL); - if (dir) { - while ((d = g_dir_read_name(dir))) { - char *src, *dest; - - src = g_build_filename(local, d, NULL); - dest = g_build_filename(base, d, NULL); - - cp(src, dest, FALSE, CP_UNIQUE); - g_free(dest); - g_free(src); - } - g_dir_close(dir); - } - - g_free(local); - g_free(base); - - return 0; -} - -static gboolean -is_in_plugs_list (GSList *list, const gchar *value) -{ - GSList *l; - - for (l = list; l; l = l->next) { - if (l->data && !strcmp (l->data, value)) - return TRUE; - } - - return FALSE; -} - -/* - * em_update_message_notify_settings_2_21 - * DBus plugin and sound email notification was merged to mail-notification plugin, - * so move these options to new locations. - */ -static void -em_update_message_notify_settings_2_21 (void) -{ - GConfClient *client; - GConfValue *is_key; - gboolean dbus, status; - GSList *list; - gchar *str; - gint val; - - client = gconf_client_get_default (); - - is_key = gconf_client_get (client, "/apps/evolution/eplugin/mail-notification/dbus-enabled", NULL); - if (is_key) { - /* already migrated, so do not migrate again */ - gconf_value_free (is_key); - g_object_unref (client); - - return; - } - - gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/status-blink-icon", - gconf_client_get_bool (client, "/apps/evolution/mail/notification/blink-status-icon", NULL), NULL); - gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/status-notification", - gconf_client_get_bool (client, "/apps/evolution/mail/notification/notification", NULL), NULL); - - list = gconf_client_get_list (client, "/apps/evolution/eplugin/disabled", GCONF_VALUE_STRING, NULL); - dbus = !is_in_plugs_list (list, "org.gnome.evolution.new_mail_notify"); - status = !is_in_plugs_list (list, "org.gnome.evolution.mail_notification"); - - gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/dbus-enabled", dbus, NULL); - gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/status-enabled", status, NULL); - - if (!status) { - /* enable this plugin, because it holds all those other things */ - GSList *plugins, *l; - - plugins = e_plugin_list_plugins (); - - for (l = plugins; l; l = l->next) { - EPlugin *p = l->data; - - if (p && p->id && !strcmp (p->id, "org.gnome.evolution.mail_notification")) { - e_plugin_enable (p, 1); - break; - } - } - - g_slist_foreach (plugins, (GFunc)g_object_unref, NULL); - g_slist_free (plugins); - } - - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); - - val = gconf_client_get_int (client, "/apps/evolution/mail/notify/type", NULL); - gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/sound-enabled", val == 1 || val == 2, NULL); - gconf_client_set_bool (client, "/apps/evolution/eplugin/mail-notification/sound-beep", val == 0 || val == 1, NULL); - - str = gconf_client_get_string (client, "/apps/evolution/mail/notify/sound", NULL); - gconf_client_set_string (client, "/apps/evolution/eplugin/mail-notification/sound-file", str ? str : "", NULL); - g_free (str); - - g_object_unref (client); -} - -/* fixing typo in SpamAssassin name */ -static void -em_update_sa_junk_setting_2_23 (void) -{ - GConfClient *client; - GConfValue *key; - - client = gconf_client_get_default (); - - key = gconf_client_get (client, "/apps/evolution/mail/junk/default_plugin", NULL); - if (key) { - const char *str = gconf_value_get_string (key); - - if (str && strcmp (str, "Spamassasin") == 0) - gconf_client_set_string (client, "/apps/evolution/mail/junk/default_plugin", "SpamAssassin", NULL); - - gconf_value_free (key); - g_object_unref (client); - - return; - } - - g_object_unref (client); -} - - -static void -migrate_folders(CamelStore *store, CamelFolderInfo *fi, const char *acc, CamelException *ex) -{ - CamelFolder *folder; - - while (fi) { - char *tmp = g_strdup_printf ("%s/%s", acc, fi->full_name); - em_migrate_set_folder_name (tmp); - g_free (tmp); - folder = camel_store_get_folder (store, fi->full_name, 0, ex); - if (folder != NULL) - camel_folder_summary_migrate_infos (folder->summary); - migrate_folders(store, fi->child, acc, ex); - fi = fi->next; - } -} - -static CamelStore * -setup_local_store (MailComponent *mc) -{ - CamelURL *url; - char *tmp; - CamelStore *store; - - url = camel_url_new("mbox:", NULL); - tmp = g_build_filename (mail_component_peek_base_directory(mc), "local", NULL); - camel_url_set_path(url, tmp); - g_free(tmp); - tmp = camel_url_to_string(url, 0); - store = (CamelStore *)camel_session_get_service(session, tmp, CAMEL_PROVIDER_STORE, NULL); - g_free(tmp); - - return store; - -} -static void -migrate_to_db() -{ - EAccountList *accounts; - EIterator *iter; - int i=0, len; - MailComponent *component = mail_component_peek (); - CamelStore *store = NULL; - CamelFolderInfo *info; - - if (!(accounts = mail_config_get_accounts ())) - return; - - iter = e_list_get_iterator ((EList *) accounts); - len = e_list_length ((EList *) accounts); - - camel_session_set_online ((CamelSession *) session, FALSE); - em_migrate_setup_progress_dialog (_("The summary format of the Evolution mailbox " - "folders has been moved to SQLite since Evolution 2.24.\n\nPlease be " - "patient while Evolution migrates your folders...")); - - em_migrate_set_progress ( (double)i/(len+1)); - store = setup_local_store (component); - info = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, NULL); - if (info) { - migrate_folders(store, info, _("On This Computer"), NULL); - } - i++; - em_migrate_set_progress ( (double)i/(len+1)); - - - while (e_iterator_is_valid (iter)) { - EAccount *account = (EAccount *) e_iterator_get (iter); - EAccountService *service; - const char *name; - - - service = account->source; - name = account->name; - em_migrate_set_progress ( (double)i/(len+1)); - if (account->enabled - && service->url != NULL - && service->url[0] - && strncmp(service->url, "mbox:", 5) != 0) { - - CamelException ex; - - camel_exception_init (&ex); - mail_component_load_store_by_uri (component, service->url, name); - - store = (CamelStore *) camel_session_get_service (session, service->url, CAMEL_PROVIDER_STORE, &ex); - info = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, &ex); - if (info) { - migrate_folders(store, info, account->name, &ex); - - } else - printf("%s:%s: failed to get folder infos \n", G_STRLOC, G_STRFUNC); - camel_exception_clear(&ex); - - } - i++; - e_iterator_next (iter); - - } - - //camel_session_set_online ((CamelSession *) session, TRUE); - - g_object_unref (iter); - em_migrate_close_progress_dialog (); -} - -int -em_migrate (const char *evolution_dir, int major, int minor, int revision, CamelException *ex) -{ - struct stat st; - char *path; - - /* make sure ~/.evolution/mail exists */ - path = g_build_filename (evolution_dir, "mail", NULL); - if (g_stat (path, &st) == -1) { - if (errno != ENOENT || g_mkdir_with_parents (path, 0777) == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to create local mail folders at `%s': %s"), - path, g_strerror (errno)); - g_free (path); - return -1; - } - } - - g_free (path); - - if (major == 0) - return emm_setup_initial(evolution_dir); - - if (major == 1 && minor < 5) { -#ifndef G_OS_WIN32 - xmlDocPtr config_xmldb = NULL, filters, vfolders; - - path = g_build_filename (g_get_home_dir (), "evolution", NULL); - if (minor <= 2 && !(config_xmldb = emm_load_xml (path, "config.xmldb"))) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("Unable to read settings from previous Evolution install, " - "`evolution/config.xmldb' does not exist or is corrupt.")); - g_free (path); - return -1; - } - filters = emm_load_xml (path, "filters.xml"); - vfolders = emm_load_xml (path, "vfolders.xml"); - g_free (path); - - if (minor == 0) { - if (em_migrate_1_0 (evolution_dir, config_xmldb, filters, vfolders, ex) == -1) { - xmlFreeDoc (config_xmldb); - xmlFreeDoc (filters); - xmlFreeDoc (vfolders); - return -1; - } - } - - if (minor <= 2) { - if (em_migrate_1_2 (evolution_dir, config_xmldb, filters, vfolders, ex) == -1) { - xmlFreeDoc (config_xmldb); - xmlFreeDoc (filters); - xmlFreeDoc (vfolders); - return -1; - } - - xmlFreeDoc (config_xmldb); - } - - if (minor <= 4) { - if (em_migrate_1_4 (evolution_dir, filters, vfolders, ex) == -1) { - xmlFreeDoc (filters); - xmlFreeDoc (vfolders); - return -1; - } - } - - path = g_build_filename (evolution_dir, "mail", NULL); - - if (filters) { - emm_save_xml (filters, path, "filters.xml"); - xmlFreeDoc (filters); - } - - if (vfolders) { - emm_save_xml (vfolders, path, "vfolders.xml"); - xmlFreeDoc (vfolders); - } - - g_free (path); -#else - g_error ("Upgrading from ancient versions not supported on Windows"); -#endif - } - - if (major < 2 || (major == 2 && minor < 12)) { -#ifndef G_OS_WIN32 - em_update_accounts_2_11 (); -#else - g_error ("Upgrading from ancient versions not supported on Windows"); -#endif - } - - - if (major < 2 || (major == 2 && minor < 22)) - em_update_message_notify_settings_2_21 (); - - if (major < 2 || (major == 2 && minor < 24)) { - em_update_sa_junk_setting_2_23 (); - migrate_to_db(); - } - - return 0; -} diff --git a/mail/em-migrate.h b/mail/em-migrate.h deleted file mode 100644 index c755ef9b39..0000000000 --- a/mail/em-migrate.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Jeffrey Stedfast - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __EM_MIGRATE_H__ -#define __EM_MIGRATE_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -int em_migrate (const char *evolution_dir, int major, int minor, int revision, CamelException *ex); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EM_MIGRATE_H__ */ diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c index 64d5efc41e..1fff07ee97 100644 --- a/shell/e-shell-module.c +++ b/shell/e-shell-module.c @@ -48,6 +48,8 @@ struct _EShellModulePrivate { gchar *config_dir; gchar *data_dir; + GType shell_view_type; + /* Initializes the loaded type module. */ void (*init) (GTypeModule *type_module); }; @@ -420,6 +422,22 @@ e_shell_module_get_shell (EShellModule *shell_module) return shell_module->priv->shell; } +/** + * e_shell_module_get_shell_view_type: + * @shell_module: an #EShellModule + * + * Returns the #GType of the #EShellView subclass for @shell_module. + * + * Returns: the #GType of an #EShellView subclass + **/ +GType +e_shell_module_get_shell_view_type (EShellModule *shell_module) +{ + g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), 0); + + return shell_module->priv->shell_view_type; +} + /** * e_shell_module_add_activity: * @shell_module: an #EShellModule @@ -536,6 +554,7 @@ e_shell_module_migrate (EShellModule *shell_module, * e_shell_module_set_info: * @shell_module: an #EShellModule * @info: an #EShellModuleInfo + * @shell_view_type: the #GType of a #EShellView subclass * * Registers basic configuration information about @shell_module that * the #EShell can use for processing command-line arguments. @@ -546,7 +565,8 @@ e_shell_module_migrate (EShellModule *shell_module, **/ void e_shell_module_set_info (EShellModule *shell_module, - const EShellModuleInfo *info) + const EShellModuleInfo *info, + GType shell_view_type) { GTypeModule *type_module; EShellModuleInfo *module_info; @@ -588,4 +608,6 @@ e_shell_module_set_info (EShellModule *shell_module, g_critical ( "Cannot create directory %s: %s", pathname, g_strerror (errno)); + + shell_module->priv->shell_view_type = shell_view_type; } diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h index 8dff5a1425..24bc690533 100644 --- a/shell/e-shell-module.h +++ b/shell/e-shell-module.h @@ -125,6 +125,8 @@ const gchar * e_shell_module_get_config_dir (EShellModule *shell_module); const gchar * e_shell_module_get_data_dir (EShellModule *shell_module); const gchar * e_shell_module_get_filename (EShellModule *shell_module); struct _EShell *e_shell_module_get_shell (EShellModule *shell_module); +GType e_shell_module_get_shell_view_type + (EShellModule *shell_module); void e_shell_module_add_activity (EShellModule *shell_module, EActivity *activity); gboolean e_shell_module_is_busy (EShellModule *shell_module); @@ -135,7 +137,8 @@ gboolean e_shell_module_migrate (EShellModule *shell_module, gint micro, GError **error); void e_shell_module_set_info (EShellModule *shell_module, - const EShellModuleInfo *info); + const EShellModuleInfo *info, + GType shell_view_type); G_END_DECLS diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 2e80ab6bf6..a5ca5b310d 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -1435,7 +1435,7 @@ static GtkActionEntry shell_entries[] = { { "contents", GTK_STOCK_HELP, N_("_Contents"), - NULL, + "F1", N_("Open the Evolution User Guide"), G_CALLBACK (action_contents_cb) }, @@ -1889,6 +1889,10 @@ e_shell_window_actions_init (EShellWindow *shell_window) G_N_ELEMENTS (shell_switcher_entries), -1, G_CALLBACK (action_switcher_cb), shell_window); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + /* Fine tuning. */ + + g_object_set (ACTION (SEND_RECEIVE), "is-important", TRUE, NULL); } GtkWidget * @@ -1967,22 +1971,24 @@ e_shell_window_create_new_menu (EShellWindow *shell_window) void e_shell_window_create_switcher_actions (EShellWindow *shell_window) { - GType *children; GSList *group = NULL; GtkRadioAction *action; GtkActionGroup *action_group; GtkUIManager *ui_manager; EShellSwitcher *switcher; - guint n_children, ii; + EShell *shell; + GList *list, *iter; guint merge_id; + guint ii = 0; g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); action_group = shell_window->priv->switcher_actions; - children = g_type_children (E_TYPE_SHELL_VIEW, &n_children); switcher = E_SHELL_SWITCHER (shell_window->priv->switcher); ui_manager = e_shell_window_get_ui_manager (shell_window); merge_id = gtk_ui_manager_new_merge_id (ui_manager); + shell = e_shell_window_get_shell (shell_window); + list = e_shell_list_modules (shell); /* Construct a group of radio actions from the various EShellView * subclasses and register them with the EShellSwitcher. These @@ -1993,14 +1999,26 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) gtk_radio_action_set_group (action, group); group = gtk_radio_action_get_group (action); - for (ii = 0; ii < n_children; ii++) { + for (iter = list; iter != NULL; iter = iter->next) { + EShellModule *shell_module = iter->data; EShellViewClass *class; + GType type; const gchar *view_name; gchar *accelerator; gchar *action_name; gchar *tooltip; - class = g_type_class_ref (children[ii]); + type = e_shell_module_get_shell_view_type (shell_module); + + if (!g_type_is_a (type, E_TYPE_SHELL_VIEW)) { + g_critical ( + "%s is not a subclass of %s", + g_type_name (type), + g_type_name (E_TYPE_SHELL_VIEW)); + continue; + } + + class = g_type_class_ref (type); if (class->label == NULL) { g_critical ( @@ -2026,7 +2044,7 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) action = gtk_radio_action_new ( action_name, class->label, - tooltip, NULL, ii); + tooltip, NULL, ii++); g_object_set ( G_OBJECT (action), @@ -2040,8 +2058,8 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) group = gtk_radio_action_get_group (action); /* The first nine views have accelerators Ctrl+(1-9). */ - if (ii < 9) - accelerator = g_strdup_printf ("%d", ii + 1); + if (ii < 10) + accelerator = g_strdup_printf ("%d", ii); else accelerator = g_strdup (""); @@ -2062,8 +2080,6 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window) g_type_class_unref (class); } - - g_free (children); } void diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index c6283a1481..9432014a88 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -173,12 +173,9 @@ e_shell_window_private_init (EShellWindow *shell_window) { EShellWindowPrivate *priv = shell_window->priv; GHashTable *loaded_views; - GConfBridge *bridge; GtkToolItem *item; GtkWidget *container; GtkWidget *widget; - GObject *object; - const gchar *key; guint merge_id; gint height; @@ -317,6 +314,15 @@ e_shell_window_private_init (EShellWindow *shell_window) gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); priv->status_notebook = g_object_ref (widget); gtk_widget_show (widget); +} + +void +e_shell_window_private_constructed (EShellWindow *shell_window) +{ + EShellWindowPrivate *priv = shell_window->priv; + GConfBridge *bridge; + GObject *object; + const gchar *key; /* Create the switcher actions before we set the initial * shell view, because the shell view relies on them for @@ -356,10 +362,6 @@ e_shell_window_private_init (EShellWindow *shell_window) gconf_bridge_bind_property (bridge, key, object, "active"); shell_window_init_switcher_style (shell_window); - - /* Fine tuning. */ - - g_object_set (ACTION (SEND_RECEIVE), "is-important", TRUE, NULL); } void @@ -435,6 +437,8 @@ e_shell_window_switch_to_view (EShellWindow *shell_window, e_shell_window_update_new_menu (shell_window); e_shell_window_update_view_menu (shell_window); e_shell_window_update_search_menu (shell_window); + + e_shell_view_update_actions (shell_view); } void diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h index 98749e1036..a31640d347 100644 --- a/shell/e-shell-window-private.h +++ b/shell/e-shell-window-private.h @@ -104,6 +104,8 @@ struct _EShellWindowPrivate { }; void e_shell_window_private_init (EShellWindow *shell_window); +void e_shell_window_private_constructed + (EShellWindow *shell_window); void e_shell_window_private_dispose (EShellWindow *shell_window); void e_shell_window_private_finalize (EShellWindow *shell_window); diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 427e1311a0..0d54b92bd8 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -214,6 +214,12 @@ shell_window_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static void +shell_window_constructed (GObject *object) +{ + e_shell_window_private_constructed (E_SHELL_WINDOW (object)); +} + static void shell_window_class_init (EShellWindowClass *class) { @@ -227,6 +233,7 @@ shell_window_class_init (EShellWindowClass *class) object_class->get_property = shell_window_get_property; object_class->dispose = shell_window_dispose; object_class->finalize = shell_window_finalize; + object_class->constructed = shell_window_constructed; /** * EShellWindow:active-view diff --git a/shell/shell.error.xml b/shell/shell.error.xml index a69adec801..603d5ed955 100644 --- a/shell/shell.error.xml +++ b/shell/shell.error.xml @@ -16,9 +16,8 @@ You will need to make more space available in your home directory before you can - <_primary>Upgrade from previous version failed: -{0} - <_secondary xml:space="preserve">{1} + <_primary>Upgrade from previous version failed: + <_secondary xml:space="preserve">{0} If you choose to continue, you may not have access to some of your old data. diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c index 19b5d3bd96..2668396a12 100644 --- a/shell/test/e-test-shell-module.c +++ b/shell/test/e-test-shell-module.c @@ -161,8 +161,9 @@ e_shell_module_init (GTypeModule *type_module) shell_module = E_SHELL_MODULE (type_module); shell = e_shell_module_get_shell (shell_module); - e_test_shell_view_get_type (type_module); - e_shell_module_set_info (shell_module, &module_info); + e_shell_module_set_info ( + shell_module, &module_info, + e_test_shell_view_get_type (type_module)); g_signal_connect_swapped ( shell, "handle-uri", diff --git a/ui/Makefile.am b/ui/Makefile.am index fb02f4f427..a794a869fb 100644 --- a/ui/Makefile.am +++ b/ui/Makefile.am @@ -8,6 +8,7 @@ XML_FILES = \ UI_FILES = \ evolution-calendars.ui \ evolution-contacts.ui \ + evolution-mail.ui \ evolution-memos.ui \ evolution-shell.ui \ evolution-tasks.ui diff --git a/ui/evolution-calendars.ui b/ui/evolution-calendars.ui index a32cf182bc..761b7fd14a 100644 --- a/ui/evolution-calendars.ui +++ b/ui/evolution-calendars.ui @@ -54,6 +54,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/evolution-mail.ui b/ui/evolution-mail.ui new file mode 100644 index 0000000000..ec1934d0ef --- /dev/null +++ b/ui/evolution-mail.ui @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/evolution-shell.ui b/ui/evolution-shell.ui index 6204055e82..9802059a6c 100644 --- a/ui/evolution-shell.ui +++ b/ui/evolution-shell.ui @@ -12,6 +12,7 @@ + @@ -22,6 +23,7 @@ + @@ -39,6 +41,7 @@ + diff --git a/widgets/misc/e-calendar.h b/widgets/misc/e-calendar.h index aebc615cfc..1330eb4cf3 100644 --- a/widgets/misc/e-calendar.h +++ b/widgets/misc/e-calendar.h @@ -39,9 +39,24 @@ extern "C" { * to got to the current day. */ -#define E_CALENDAR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_get_type (), ECalendar) -#define E_CALENDAR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_get_type (), ECalendarClass) -#define E_IS_CALENDAR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_get_type ()) +/* Standard GObject macros */ +#define E_TYPE_CALENDAR \ + (e_calendar_get_type ()) +#define E_CALENDAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_CALENDAR, ECalendar)) +#define E_CALENDAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_CALENDAR, ECalendarClass)) +#define E_IS_CALENDAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_CALENDAR)) +#define E_IS_CALENDAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_CALENDAR)) +#define E_CALENDAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_CALENDAR, ECalendarClass)) typedef struct _ECalendar ECalendar; -- cgit v1.2.3