aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-image-chooser.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-11-20 11:02:04 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-11-20 11:02:04 +0800
commitda2ca5896d9a0ce1ead4af6dde295c5cfa2892df (patch)
tree8e734b51067516746e708c7049c422e2781dbaec /widgets/misc/e-image-chooser.c
parent28589a30975f3e68615ea9eb2086d7d251013563 (diff)
downloadgsoc2013-evolution-da2ca5896d9a0ce1ead4af6dde295c5cfa2892df.tar
gsoc2013-evolution-da2ca5896d9a0ce1ead4af6dde295c5cfa2892df.tar.gz
gsoc2013-evolution-da2ca5896d9a0ce1ead4af6dde295c5cfa2892df.tar.bz2
gsoc2013-evolution-da2ca5896d9a0ce1ead4af6dde295c5cfa2892df.tar.lz
gsoc2013-evolution-da2ca5896d9a0ce1ead4af6dde295c5cfa2892df.tar.xz
gsoc2013-evolution-da2ca5896d9a0ce1ead4af6dde295c5cfa2892df.tar.zst
gsoc2013-evolution-da2ca5896d9a0ce1ead4af6dde295c5cfa2892df.zip
Kill e_util_read_file().
Diffstat (limited to 'widgets/misc/e-image-chooser.c')
-rw-r--r--widgets/misc/e-image-chooser.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/widgets/misc/e-image-chooser.c b/widgets/misc/e-image-chooser.c
index 5ef4e7cd3e..4ea76099aa 100644
--- a/widgets/misc/e-image-chooser.c
+++ b/widgets/misc/e-image-chooser.c
@@ -241,6 +241,32 @@ image_drag_drop_cb (GtkWidget *widget,
}
static void
+image_chooser_file_loaded_cb (GFile *file,
+ GAsyncResult *result,
+ EImageChooser *chooser)
+{
+ gchar *contents;
+ gsize length;
+ GError *error = NULL;
+
+ g_file_load_contents_finish (
+ file, result, &contents, &length, NULL, &error);
+
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ goto exit;
+ }
+
+ set_image_from_data (chooser, contents, length);
+
+ g_free (contents);
+
+exit:
+ g_object_unref (chooser);
+}
+
+static void
image_drag_data_received_cb (GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -250,29 +276,28 @@ image_drag_data_received_cb (GtkWidget *widget,
guint time,
EImageChooser *chooser)
{
+ GFile *file;
gboolean handled = FALSE;
gchar **uris;
- gchar *buf = NULL;
- gsize read = 0;
- GError *error = NULL;
uris = gtk_selection_data_get_uris (selection_data);
if (uris == NULL)
goto exit;
- if (e_util_read_file (uris[0], TRUE, &buf, &read, &error) && read > 0 && buf)
- handled = set_image_from_data (chooser, buf, read);
+ file = g_file_new_for_uri (uris[0]);
- if (!handled)
- g_free (buf);
+ /* XXX Not cancellable. */
+ g_file_load_contents_async (
+ file, NULL, (GAsyncReadyCallback)
+ image_chooser_file_loaded_cb,
+ g_object_ref (chooser));
+ g_object_unref (file);
g_strfreev (uris);
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ /* Assume success. We won't know til later. */
+ handled = TRUE;
exit:
gtk_drag_finish (context, handled, FALSE, time);