From 86ecfc50539ddef82205551c11a6a13b135bbab4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 7 Nov 2009 12:44:44 -0500 Subject: 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. --- e-util/e-util.c | 59 --------------------------------------------------------- 1 file changed, 59 deletions(-) (limited to 'e-util/e-util.c') diff --git a/e-util/e-util.c b/e-util/e-util.c index bf1f387d15..9ad252a37d 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -618,65 +618,6 @@ e_int_compare (gconstpointer x, gconstpointer y) return (nx == ny) ? 0 : (nx < ny) ? -1 : 1; } -gboolean -e_write_file_uri (const gchar *filename, - const gchar *data) -{ - gboolean res; - gsize length; - GFile *file; - GOutputStream *stream; - GError *error = NULL; - - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (data != NULL, FALSE); - - length = strlen (data); - - /* if it is uri, then create file for uri, otherwise for path */ - if (strstr (filename, "://")) - file = g_file_new_for_uri (filename); - else - file = g_file_new_for_path (filename); - - if (!file) { - g_warning ("Couldn't save item"); - return FALSE; - } - - stream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error)); - g_object_unref (file); - - if (!stream || error) { - g_warning ("Couldn't save item%s%s", error ? ": " : "", error ? error->message : ""); - - if (stream) - g_object_unref (stream); - - if (error) - g_error_free (error); - - return FALSE; - } - - res = g_output_stream_write_all (stream, data, length, NULL, NULL, &error); - - if (error) { - g_warning ("Couldn't save item: %s", error->message); - g_clear_error (&error); - } - - g_output_stream_close (stream, NULL, &error); - g_object_unref (stream); - - if (error) { - g_warning ("Couldn't close output stream: %s", error->message); - g_error_free (error); - } - - return res; -} - /** * e_color_to_value: * color: a #GdkColor -- cgit