[telegnome] Port from GnomeVFS to GIO.



commit 303c3363245100a141c633101472e5cadb73c51e
Author: Colin Watson <cjwatson debian org>
Date:   Wed Nov 3 02:13:33 2010 +0000

    Port from GnomeVFS to GIO.
    
    * configure.ac (PKG_CHECK_MODULES): Check for gio-2.0 rather than
    gnome-vfs-2.0.
    * src/http.c (get_the_image): Fetch the image using GIO.
    * NEWS: Document this.

 ChangeLog    |    9 +++++++++
 NEWS         |    1 +
 configure.ac |    2 +-
 src/http.c   |   22 ++++++++++++----------
 4 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fa3033e..92fd21c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2010-11-03  Colin Watson  <cjwatson debian org>
 
+	Port from GnomeVFS to GIO.
+
+	* configure.ac (PKG_CHECK_MODULES): Check for gio-2.0 rather than
+	gnome-vfs-2.0.
+	* src/http.c (get_the_image): Fetch the image using GIO.
+	* NEWS: Document this.
+
+2010-11-03  Colin Watson  <cjwatson debian org>
+
 	Build cleanly with -DGSEAL_ENABLE.
 
 	* configure.ac (PKG_CHECK_MODULES): Bump gtk+-2.0 requirement to
diff --git a/NEWS b/NEWS
index 206a84a..3389586 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Changes in TeleGNOME 0.1.2
 ==========================
 
  * Build cleanly with -DGSEAL_ENABLE.
+ * Port from GnomeVFS to GIO.
 
 Changes in TeleGNOME 0.1.1
 ==========================
diff --git a/configure.ac b/configure.ac
index 730827a..2965210 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@ AC_PROG_CPP
 AC_HEADER_STDC
 AC_PROG_INSTALL
 
-PKG_CHECK_MODULES([TELEGNOME], [glib-2.0 gtk+-2.0 >= 2.20 gdk-pixbuf-2.0 libgnomeui-2.0 gnome-vfs-2.0])
+PKG_CHECK_MODULES([TELEGNOME], [glib-2.0 gtk+-2.0 >= 2.20 gdk-pixbuf-2.0 libgnomeui-2.0 gio-2.0])
 
 PROGRAMS_TELEGNOME="telegnome"
 AC_SUBST(PROGRAMS_TELEGNOME)
diff --git a/src/http.c b/src/http.c
index 2acfa1f..8730d52 100644
--- a/src/http.c
+++ b/src/http.c
@@ -22,7 +22,7 @@
   
 #include <string.h>
 
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include "http.h"
 #include "main.h"
@@ -70,26 +70,28 @@ get_the_image (GdkPixbuf **pixbuf)
 {
     gchar http_query[100];
     gint retval=0;
-    GnomeVFSHandle *handle = NULL;
+    GFile *http_file;
+    GFileInputStream *http_input;
     GdkPixbufLoader *loader = NULL;
     guchar buf[4096];
-    GnomeVFSResult vfs_result;
-    GnomeVFSFileSize bytes_read;
+    gssize bytes_read;
     GError *err = NULL;
     
     if ( -1 == get_http_query(http_query, currentview->page_nr, currentview->subpage_nr))	
 	return TG_ERR_HTTPQUERY;
 
     /* get the image from remote server */
-    vfs_result = gnome_vfs_open(&handle, http_query, GNOME_VFS_OPEN_READ);
-    if (vfs_result != GNOME_VFS_OK)
+    http_file = g_file_new_for_uri(http_query);
+    http_input = g_file_read(http_file, NULL, NULL);
+    if (!http_input)
 	return TG_ERR_VFS;
 
     loader = gdk_pixbuf_loader_new();
 
     for (;;) {
-	vfs_result = gnome_vfs_read(handle, buf, 4096, &bytes_read);
-	if (vfs_result == GNOME_VFS_ERROR_EOF)
+	bytes_read = g_input_stream_read(G_INPUT_STREAM(http_input), buf, 4096,
+					 NULL, NULL);
+	if (bytes_read == 0)
 	    break;
 	err = NULL;
 	if (!gdk_pixbuf_loader_write(loader, buf, (gsize)bytes_read, &err)) {
@@ -110,8 +112,8 @@ out:
 	if (!gdk_pixbuf_loader_close(loader, &err) && !retval)
 	    retval = TG_ERR_PIXBUF;
     }
-    if (handle)
-	gnome_vfs_close(handle);
+    if (http_input)
+	g_input_stream_close(G_INPUT_STREAM(http_input), NULL, NULL);
 
     return retval;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]