aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-avatar-chooser.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-03-11 17:27:31 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-03-11 17:27:31 +0800
commitd4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f (patch)
tree23dbb7e56be25cbd18c4dee765f3e02efe9330d4 /libempathy-gtk/empathy-avatar-chooser.c
parenta72813f2339f5f3dc54ca50d88e9ff3d09a99d8d (diff)
downloadgsoc2013-empathy-d4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f.tar
gsoc2013-empathy-d4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f.tar.gz
gsoc2013-empathy-d4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f.tar.bz2
gsoc2013-empathy-d4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f.tar.lz
gsoc2013-empathy-d4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f.tar.xz
gsoc2013-empathy-d4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f.tar.zst
gsoc2013-empathy-d4b6c6c92bc1e1dcee12ef9a763e5d54f146b70f.zip
Drop gnome-vfs dependency and use gio instead. Fixes bug #514380 (Cosimo Cecchi).
svn path=/trunk/; revision=737
Diffstat (limited to 'libempathy-gtk/empathy-avatar-chooser.c')
-rw-r--r--libempathy-gtk/empathy-avatar-chooser.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c
index 78bb32938..aeaba5c94 100644
--- a/libempathy-gtk/empathy-avatar-chooser.c
+++ b/libempathy-gtk/empathy-avatar-chooser.c
@@ -27,7 +27,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
+#include <gio/gio.h>
#include <libempathy/empathy-debug.h>
@@ -329,9 +329,8 @@ avatar_chooser_drag_data_received_cb (GtkWidget *widget,
target_type = gdk_atom_name (selection_data->target);
if (!strcmp (target_type, URI_LIST_TYPE)) {
- GnomeVFSHandle *handle = NULL;
- GnomeVFSResult result;
- GnomeVFSFileInfo info;
+ GFile *file;
+ GFileInputStream *input_stream;
gchar *uri;
gchar *nl;
gchar *data = NULL;
@@ -343,31 +342,41 @@ avatar_chooser_drag_data_received_cb (GtkWidget *widget,
} else {
uri = g_strdup (selection_data->data);
}
-
- result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
- if (result == GNOME_VFS_OK) {
- result = gnome_vfs_get_file_info_from_handle (handle,
- &info,
- GNOME_VFS_FILE_INFO_DEFAULT);
- if (result == GNOME_VFS_OK) {
- GnomeVFSFileSize data_size;
-
- data = g_malloc (info.size);
-
- result = gnome_vfs_read (handle, data, info.size, &data_size);
- if (result == GNOME_VFS_OK) {
+
+ file = g_file_new_for_uri (uri);
+ input_stream = g_file_read (file, NULL, NULL);
+
+ if (input_stream != NULL) {
+ GFileInfo *info;
+
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_SIZE,
+ 0, NULL, NULL);
+ if (info != NULL) {
+ goffset size;
+ gssize bytes_read;
+
+ size = g_file_info_get_size (info);
+ data = g_malloc (size);
+
+ bytes_read = g_input_stream_read (G_INPUT_STREAM (input_stream),
+ data, size,
+ NULL, NULL);
+ g_object_unref (info);
+ if (bytes_read != -1) {
avatar_chooser_set_image_from_data (chooser,
data,
- data_size);
+ (gsize) bytes_read);
handled = TRUE;
} else {
g_free (data);
}
}
- gnome_vfs_close (handle);
+ g_input_stream_close (G_INPUT_STREAM (input_stream), NULL, NULL);
}
-
+
+ g_object_unref (file);
g_free (uri);
}