aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-file-utils.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 /e-util/e-file-utils.c
parentaa66a17e401d73cbe394ed7f99bf73350e9b938b (diff)
downloadgsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.tar
gsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.tar.gz
gsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.tar.bz2
gsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.tar.lz
gsoc2013-evolution-86ecfc50539ddef82205551c11a6a13b135bbab4.tar.xz
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 'e-util/e-file-utils.c')
-rw-r--r--e-util/e-file-utils.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/e-util/e-file-utils.c b/e-util/e-file-utils.c
index f8adcc7a60..015da072f3 100644
--- a/e-util/e-file-utils.c
+++ b/e-util/e-file-utils.c
@@ -86,6 +86,24 @@ file_replace_contents_cb (GFile *file,
g_object_unref (activity);
}
+/**
+ * e_file_replace_contents_async:
+ * @file: input #GFile
+ * @contents: string of contents to replace the file with
+ * @length: the length of @contents in bytes
+ * @etag: a new entity tag for the @file, or %NULL
+ * @make_backup: %TRUE if a backup should be created
+ * @flags: a set of #GFileCreateFlags
+ * @callback: a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: the data to pass to the callback function
+ *
+ * This is a wrapper for g_file_replace_contents_async() that also returns
+ * an #EActivity to track the file operation. Cancelling the activity will
+ * cancel the file operation. See g_file_replace_contents_async() for more
+ * details.
+ *
+ * Returns: an #EActivity for the file operation
+ **/
EActivity *
e_file_replace_contents_async (GFile *file,
const gchar *contents,
@@ -111,9 +129,12 @@ e_file_replace_contents_async (GFile *file,
uri = g_file_get_uri (file);
filename = g_filename_from_uri (uri, &hostname, NULL);
- basename = g_filename_display_basename (filename);
+ if (filename != NULL)
+ basename = g_filename_display_basename (filename);
+ else
+ basename = g_strdup (_("(Unknown Filename)"));
- if (hostname != NULL) {
+ if (hostname == NULL) {
/* Translators: The string value is the basename of a file. */
format = _("Writing \"%s\"");
description = g_strdup_printf (format, basename);
@@ -151,6 +172,20 @@ e_file_replace_contents_async (GFile *file,
return activity;
}
+/**
+ * e_file_replace_contents_finish:
+ * @file: input #GFile
+ * @result: a #GAsyncResult
+ * @new_etag: return location for a new entity tag
+ * @error: return location for a #GError, or %NULL
+ *
+ * Finishes an asynchronous replace of the given @file. See
+ * e_file_replace_contents_async(). Sets @new_etag to the new entity
+ * tag for the document, if present. Free it with g_free() when it is
+ * no longer needed.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
+ **/
gboolean
e_file_replace_contents_finish (GFile *file,
GAsyncResult *result,