diff options
Diffstat (limited to 'modules/calendar')
-rw-r--r-- | modules/calendar/e-cal-shell-view-actions.c | 32 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-memopad.c | 31 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-private.h | 2 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-taskpad.c | 29 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-view-actions.c | 29 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-view-private.h | 2 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-view-actions.c | 30 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-view-private.h | 2 |
8 files changed, 119 insertions, 38 deletions
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c index 408d02ffc3..4fa8b07eae 100644 --- a/modules/calendar/e-cal-shell-view-actions.c +++ b/modules/calendar/e-cal-shell-view-actions.c @@ -1065,8 +1065,10 @@ static void action_event_save_as_cb (GtkAction *action, ECalShellView *cal_shell_view) { + EShell *shell; EShellView *shell_view; EShellWindow *shell_window; + EShellBackend *shell_backend; ECalShellContent *cal_shell_content; GnomeCalendarViewType view_type; GnomeCalendar *calendar; @@ -1074,12 +1076,15 @@ action_event_save_as_cb (GtkAction *action, ECalendarViewEvent *event; ECal *client; icalcomponent *icalcomp; + EActivity *activity; GList *selected; - gchar *filename = NULL; + GFile *file; gchar *string = NULL; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_window_get_shell (shell_window); cal_shell_content = cal_shell_view->priv->cal_shell_content; calendar = e_cal_shell_content_get_calendar (cal_shell_content); @@ -1093,10 +1098,10 @@ action_event_save_as_cb (GtkAction *action, client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; - filename = e_file_dialog_save ( - GTK_WINDOW (shell_window), _("Save As..."), NULL); - if (filename == NULL) - goto exit; + file = e_shell_run_save_dialog ( + shell, _("Save as iCalendar"), NULL, NULL); + if (file == NULL) + return; string = e_cal_get_component_as_string (client, icalcomp); if (string == NULL) { @@ -1104,11 +1109,20 @@ action_event_save_as_cb (GtkAction *action, goto exit; } - e_write_file_uri (filename, string); + /* XXX No callbacks means errors are discarded. */ + activity = e_file_replace_contents_async ( + file, string, strlen (string), NULL, FALSE, + G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL); + e_shell_backend_add_activity (shell_backend, activity); + + /* Free the string when the activity is finalized. */ + g_object_set_data_full ( + G_OBJECT (activity), + "file-content", string, + (GDestroyNotify) g_free); exit: - g_free (filename); - g_free (string); + g_object_unref (file); g_list_free (selected); } @@ -1372,7 +1386,7 @@ static GtkActionEntry calendar_entries[] = { { "event-save-as", GTK_STOCK_SAVE_AS, - NULL, + N_("Save as iCalendar..."), NULL, NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_event_save_as_cb) }, diff --git a/modules/calendar/e-cal-shell-view-memopad.c b/modules/calendar/e-cal-shell-view-memopad.c index 7d4c1a501f..88cb53ff54 100644 --- a/modules/calendar/e-cal-shell-view-memopad.c +++ b/modules/calendar/e-cal-shell-view-memopad.c @@ -233,17 +233,22 @@ static void action_calendar_memopad_save_as_cb (GtkAction *action, ECalShellView *cal_shell_view) { + EShell *shell; EShellView *shell_view; EShellWindow *shell_window; + EShellBackend *shell_backend; ECalShellContent *cal_shell_content; EMemoTable *memo_table; ECalModelComponent *comp_data; + EActivity *activity; GSList *list; - gchar *filename; + GFile *file; gchar *string; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_window_get_shell (shell_window); cal_shell_content = cal_shell_view->priv->cal_shell_content; memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); @@ -253,9 +258,9 @@ action_calendar_memopad_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save ( - GTK_WINDOW (shell_window), _("Save as..."), NULL); - if (filename == NULL) + file = e_shell_run_save_dialog ( + shell, _("Save as iCalendar"), NULL, NULL); + if (file == NULL) return; /* XXX We only save the first selected memo. */ @@ -263,13 +268,23 @@ action_calendar_memopad_save_as_cb (GtkAction *action, comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert memo to a string."); + g_object_unref (file); return; } - e_write_file_uri (filename, string); + /* XXX No callback means errors are discarded. */ + activity = e_file_replace_contents_async ( + file, string, strlen (string), NULL, FALSE, + G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL); + e_shell_backend_add_activity (shell_backend, activity); + + /* Free the string when the activity is finalized. */ + g_object_set_data_full ( + G_OBJECT (activity), + "file-content", string, + (GDestroyNotify) g_free); - g_free (filename); - g_free (string); + g_object_unref (file); } static GtkActionEntry calendar_memopad_entries[] = { @@ -332,7 +347,7 @@ static GtkActionEntry calendar_memopad_entries[] = { { "calendar-memopad-save-as", GTK_STOCK_SAVE_AS, - NULL, + N_("Save as iCalendar..."), NULL, NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_calendar_memopad_save_as_cb) } diff --git a/modules/calendar/e-cal-shell-view-private.h b/modules/calendar/e-cal-shell-view-private.h index 690031198e..2ee0cff6a4 100644 --- a/modules/calendar/e-cal-shell-view-private.h +++ b/modules/calendar/e-cal-shell-view-private.h @@ -33,8 +33,10 @@ #include "e-util/e-binding.h" #include "e-util/e-dialog-utils.h" +#include "e-util/e-file-utils.h" #include "e-util/e-error.h" #include "e-util/e-util.h" +#include "shell/e-shell-utils.h" #include "widgets/misc/e-popup-action.h" #include "calendar/common/authentication.h" diff --git a/modules/calendar/e-cal-shell-view-taskpad.c b/modules/calendar/e-cal-shell-view-taskpad.c index 3e83e04fcc..5f2fd3ad0f 100644 --- a/modules/calendar/e-cal-shell-view-taskpad.c +++ b/modules/calendar/e-cal-shell-view-taskpad.c @@ -301,17 +301,22 @@ static void action_calendar_taskpad_save_as_cb (GtkAction *action, ECalShellView *cal_shell_view) { + EShell *shell; EShellView *shell_view; EShellWindow *shell_window; + EShellBackend *shell_backend; ECalShellContent *cal_shell_content; ECalendarTable *task_table; ECalModelComponent *comp_data; + EActivity *activity; GSList *list; - gchar *filename; + GFile *file; gchar *string; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_window_get_shell (shell_window); cal_shell_content = cal_shell_view->priv->cal_shell_content; task_table = e_cal_shell_content_get_task_table (cal_shell_content); @@ -321,22 +326,32 @@ action_calendar_taskpad_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save ( - GTK_WINDOW (shell_window), _("Save as..."), NULL); - if (filename == NULL) + file = e_shell_run_save_dialog ( + shell, _("Save as iCalendar"), NULL, NULL); + if (file == 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"); + g_object_unref (file); return; } - e_write_file_uri (filename, string); + /* XXX No callback means errors are discarded. */ + activity = e_file_replace_contents_async ( + file, string, strlen (string), NULL, FALSE, + G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL); + e_shell_backend_add_activity (shell_backend, activity); + + /* Free the string when the activity is finalized. */ + g_object_set_data_full ( + G_OBJECT (activity), + "file-content", string, + (GDestroyNotify) g_free); - g_free (filename); - g_free (string); + g_object_unref (file); } static GtkActionEntry calendar_taskpad_entries[] = { diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c index ab8be53d04..31f12b3962 100644 --- a/modules/calendar/e-memo-shell-view-actions.c +++ b/modules/calendar/e-memo-shell-view-actions.c @@ -471,17 +471,22 @@ static void action_memo_save_as_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EShell *shell; EShellView *shell_view; EShellWindow *shell_window; + EShellBackend *shell_backend; EMemoShellContent *memo_shell_content; EMemoTable *memo_table; ECalModelComponent *comp_data; + EActivity *activity; GSList *list; - gchar *filename; + GFile *file; gchar *string; shell_view = E_SHELL_VIEW (memo_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_window_get_shell (shell_window); memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); @@ -491,9 +496,9 @@ action_memo_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save ( - GTK_WINDOW (shell_window), _("Save as..."), NULL); - if (filename == NULL) + file = e_shell_run_save_dialog ( + shell, _("Save as iCalendar"), NULL, NULL); + if (file == NULL) return; /* XXX We only save the first selected memo. */ @@ -501,13 +506,23 @@ action_memo_save_as_cb (GtkAction *action, comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert memo to a string"); + g_object_unref (file); return; } - e_write_file_uri (filename, string); + /* XXX No callback means errors are discarded. */ + activity = e_file_replace_contents_async ( + file, string, strlen (string), NULL, FALSE, + G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL); + e_shell_backend_add_activity (shell_backend, activity); + + /* Free the string when the activity is finalized. */ + g_object_set_data_full ( + G_OBJECT (activity), + "file-content", string, + (GDestroyNotify) g_free); - g_free (filename); - g_free (string); + g_object_unref (file); } static void diff --git a/modules/calendar/e-memo-shell-view-private.h b/modules/calendar/e-memo-shell-view-private.h index 276e6e5d30..37556943f2 100644 --- a/modules/calendar/e-memo-shell-view-private.h +++ b/modules/calendar/e-memo-shell-view-private.h @@ -31,9 +31,11 @@ #include "e-util/e-binding.h" #include "e-util/e-dialog-utils.h" +#include "e-util/e-file-utils.h" #include "e-util/e-error.h" #include "e-util/e-util.h" #include "e-util/gconf-bridge.h" +#include "shell/e-shell-utils.h" #include "widgets/misc/e-popup-action.h" #include "calendar/gui/comp-util.h" diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c index fb7b89b049..282d5a3e75 100644 --- a/modules/calendar/e-task-shell-view-actions.c +++ b/modules/calendar/e-task-shell-view-actions.c @@ -598,17 +598,22 @@ static void action_task_save_as_cb (GtkAction *action, ETaskShellView *task_shell_view) { + EShell *shell; EShellView *shell_view; EShellWindow *shell_window; + EShellBackend *shell_backend; ETaskShellContent *task_shell_content; ECalendarTable *task_table; ECalModelComponent *comp_data; + EActivity *activity; GSList *list; - gchar *filename; + GFile *file; gchar *string; shell_view = E_SHELL_VIEW (task_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_window_get_shell (shell_window); task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); @@ -618,22 +623,33 @@ action_task_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save ( - GTK_WINDOW (shell_window), _("Save as..."), NULL); - if (filename == NULL) + file = e_shell_run_save_dialog ( + shell, _("Save as iCalendar"), NULL, NULL); + if (file == NULL) return; + /* XXX We only save the first selected task. */ 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"); + g_object_unref (file); return; } - e_write_file_uri (filename, string); + /* XXX No callback means errors are discarded. */ + activity = e_file_replace_contents_async ( + file, string, strlen (string), NULL, FALSE, + G_FILE_CREATE_NONE, (GAsyncReadyCallback) NULL, NULL); + e_shell_backend_add_activity (shell_backend, activity); + + /* Free the string when the activity is finalized. */ + g_object_set_data_full ( + G_OBJECT (activity), + "file-content", string, + (GDestroyNotify) g_free); - g_free (filename); - g_free (string); + g_object_unref (file); } static void diff --git a/modules/calendar/e-task-shell-view-private.h b/modules/calendar/e-task-shell-view-private.h index b369b4c948..38b03ae359 100644 --- a/modules/calendar/e-task-shell-view-private.h +++ b/modules/calendar/e-task-shell-view-private.h @@ -32,9 +32,11 @@ #include "e-util/e-binding.h" #include "e-util/e-dialog-utils.h" +#include "e-util/e-file-utils.h" #include "e-util/e-error.h" #include "e-util/e-util.h" #include "e-util/gconf-bridge.h" +#include "shell/e-shell-utils.h" #include "widgets/misc/e-popup-action.h" #include "calendar/common/authentication.h" |