aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar/e-cal-shell-view-actions.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-11-08 01:44:44 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-11-08 03:01:46 +0800
commit86ecfc50539ddef82205551c11a6a13b135bbab4 (patch)
treecc25ca582935748885a23d665a1d9e1bbc1d4d9c /modules/calendar/e-cal-shell-view-actions.c
parentaa66a17e401d73cbe394ed7f99bf73350e9b938b (diff)
downloadgsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.tar.gz
gsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.tar.zst
gsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.zip
Convert some "Save As" actions to run asynchronously.
This introduces e-shell-utils for miscellaneous utility functions that integrate with the shell or shell settings. First function is e_shell_run_save_dialog(), which automatically remembers the selected folder in the file chooser dialog. Also, kill some redundant save dialog functions, as well as some write-this-string-to-disk functions that block.
Diffstat (limited to 'modules/calendar/e-cal-shell-view-actions.c')
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c32
1 files changed, 23 insertions, 9 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) },