yelp r3132 - in trunk: . src



Author: dscorgie
Date: Fri May 23 18:39:09 2008
New Revision: 3132
URL: http://svn.gnome.org/viewvc/yelp?rev=3132&view=rev

Log:
* configure.in:
* src/test-resolver.c (main):
* src/test-uri.c (main):
* src/yelp-base.c:
* src/yelp-main.c (main):
* src/yelp-search-pager.c:
* src/yelp-search-parser.c:
* src/yelp-toc-pager.c (process_omf_pending):
* src/yelp-utils.c (resolve_process_ghelp), (resolve_full_file):
* src/yelp-window.c (window_do_load_html), 
(window_print_page_cb):
Port to use gio instead of gnome_vfs
bug #513852 - patch from Alon Zakai


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/test-resolver.c
   trunk/src/test-uri.c
   trunk/src/yelp-base.c
   trunk/src/yelp-main.c
   trunk/src/yelp-search-pager.c
   trunk/src/yelp-search-parser.c
   trunk/src/yelp-toc-pager.c
   trunk/src/yelp-utils.c
   trunk/src/yelp-window.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri May 23 18:39:09 2008
@@ -67,10 +67,10 @@
 
 PKG_CHECK_MODULES(YELP,
 [
+	gio-2.0
 	gconf-2.0
 	gnome-doc-utils >= 0.11.1
 	gtk+-unix-print-2.0
-	gnome-vfs-2.0 >= 1.1
 	gtk+-2.0 >= 2.10.0
 	libglade-2.0 >= 2.0.0
 	libgnome-2.0 >= 2.14.0

Modified: trunk/src/test-resolver.c
==============================================================================
--- trunk/src/test-resolver.c	(original)
+++ trunk/src/test-resolver.c	Fri May 23 18:39:09 2008
@@ -7,7 +7,6 @@
 
 #include <stdio.h>
 #include <glib.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include "yelp-utils.h"
 
 
@@ -203,9 +202,6 @@
 {
   int i=1;
 
-  /* Used within yelp-utils */
-  gnome_vfs_init ();
-
   if (argc % 2 != 1) {
     printf ("Usage: %s [<test-uri> <type> <test-uri> <type> ... ]\n", argv[0]);
     printf ("type can be one of:\n");

Modified: trunk/src/test-uri.c
==============================================================================
--- trunk/src/test-uri.c	(original)
+++ trunk/src/test-uri.c	Fri May 23 18:39:09 2008
@@ -24,7 +24,6 @@
 
 #include <libgnome/gnome-init.h>
 #include <libgnome/gnome-program.h>
-#include <libgnomevfs/gnome-vfs.h>
 
 #include "yelp-utils.h"
 
@@ -107,8 +106,6 @@
 				  GNOME_PROGRAM_STANDARD_PROPERTIES,
 				  NULL);
 
-    gnome_vfs_init ();
-
     for (i = 1; i < argc; i++) {
 	if (i != 1)
 	    printf ("\n");
@@ -119,7 +116,5 @@
 	    printf ("Failed to load URI: %s\n", argv[i]);
     }
 
-    gnome_vfs_shutdown ();
-
     return 0;
 }

Modified: trunk/src/yelp-base.c
==============================================================================
--- trunk/src/yelp-base.c	(original)
+++ trunk/src/yelp-base.c	Fri May 23 18:39:09 2008
@@ -23,7 +23,6 @@
 #include <config.h>
 
 #include <dbus/dbus-glib-bindings.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <gdk/gdkx.h>
 #define SN_API_NOT_YET_FROZEN
 #include <libsn/sn-launchee.h>

Modified: trunk/src/yelp-main.c
==============================================================================
--- trunk/src/yelp-main.c	(original)
+++ trunk/src/yelp-main.c	Fri May 23 18:39:09 2008
@@ -30,7 +30,6 @@
 #include <gdk/gdkx.h>
 #include <libgnome/gnome-program.h>
 #include <libgnomeui/gnome-ui-init.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <libgnomeui/gnome-client.h>
 #include <dbus/dbus-glib-bindings.h>
 #include <string.h>
@@ -378,8 +377,6 @@
 	g_set_application_name (_("Help"));
 	gtk_window_set_default_icon_name ("gnome-help");
 
-	gnome_vfs_init ();
-
 	if (!private) {
 		connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
 		if (!connection) {

Modified: trunk/src/yelp-search-pager.c
==============================================================================
--- trunk/src/yelp-search-pager.c	(original)
+++ trunk/src/yelp-search-pager.c	Fri May 23 18:39:09 2008
@@ -27,7 +27,6 @@
 #include <string.h>
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 #include <libxml/xmlreader.h>

Modified: trunk/src/yelp-search-parser.c
==============================================================================
--- trunk/src/yelp-search-parser.c	(original)
+++ trunk/src/yelp-search-parser.c	Fri May 23 18:39:09 2008
@@ -27,7 +27,6 @@
 #include <string.h>
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 #include <libxml/xmlreader.h>

Modified: trunk/src/yelp-toc-pager.c
==============================================================================
--- trunk/src/yelp-toc-pager.c	(original)
+++ trunk/src/yelp-toc-pager.c	Fri May 23 18:39:09 2008
@@ -32,7 +32,7 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
 #include <libxml/xmlreader.h>
@@ -894,9 +894,9 @@
     /* if this is NULL, then we are done processing */
     /* FIXME: cleanup any leftover stuff here */
     if (!first) {
-	GnomeVFSURI *fromfile = gnome_vfs_uri_new (content_list);
-	GnomeVFSURI *tofile = gnome_vfs_uri_new (sk_file);
-	gint result = 0;
+	GFile *fromfile = g_file_new_for_uri (content_list);
+	GFile *tofile   = g_file_new_for_uri (sk_file);
+	gboolean result = FALSE;
 
 	/* create the new cache file */
 	if (!(newindex = g_fopen (index_file, "w")))
@@ -908,16 +908,13 @@
 
 	/* copy the newly created file to ~/.gnome2/yelp.d/omfindex.xml,
 	 * overwriting the old one if necessary */
-	result = gnome_vfs_xfer_uri (fromfile, tofile, 
-	                             GNOME_VFS_XFER_DEFAULT,
-			             GNOME_VFS_XFER_ERROR_MODE_ABORT,
-			             GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
-			             NULL, NULL);
+	result = g_file_copy (fromfile, tofile, G_FILE_COPY_OVERWRITE,
+	                      NULL, NULL, NULL, NULL);
 
-	gnome_vfs_uri_unref (fromfile);
-	gnome_vfs_uri_unref (tofile);
+	g_object_unref (fromfile);
+	g_object_unref (tofile);
 
-	if (result != GNOME_VFS_OK) 
+	if (result != TRUE) 
 	    g_critical ("Unable to copy %s to %s\n", content_list, sk_file);
 
 	if (priv->omf_dirhash)

Modified: trunk/src/yelp-utils.c
==============================================================================
--- trunk/src/yelp-utils.c	(original)
+++ trunk/src/yelp-utils.c	Fri May 23 18:39:09 2008
@@ -27,8 +27,7 @@
 
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <gio/gio.h>
 
 #include <string.h>
 #define I_KNOW_RARIAN_0_8_IS_UNSTABLE
@@ -56,6 +55,7 @@
 YelpRrnType
 resolve_process_ghelp (char *uri, gchar **result)
 {
+    gboolean uncertain;
     RrnReg *reg = rrn_find_from_ghelp (&uri[6]);
     YelpRrnType type = YELP_RRN_TYPE_ERROR;
 
@@ -70,8 +70,8 @@
 	if (reg->type && *(reg->type))
 	    mime = g_strdup (reg->type);
 	else 
-	    mime = gnome_vfs_get_mime_type (*result);
-	
+	    mime = g_content_type_guess (*result, NULL, 0, &uncertain);
+
 	if (!mime) {
 	    type = YELP_RRN_TYPE_ERROR;
 	} else if (g_str_equal (mime, "text/xml") || 
@@ -149,13 +149,15 @@
 YelpRrnType
 resolve_full_file (const gchar *path)
 {
-    gchar *mime_type;
+    gchar    *mime_type;
+    gboolean  uncertain;
+
     YelpRrnType type = YELP_RRN_TYPE_ERROR;
 
     if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
 	return YELP_RRN_TYPE_ERROR;
     }
-    mime_type = gnome_vfs_get_mime_type (path);
+    mime_type = g_content_type_guess (path, NULL, 0, &uncertain);
     if (mime_type == NULL) {
 	return YELP_RRN_TYPE_ERROR;
     }

Modified: trunk/src/yelp-window.c
==============================================================================
--- trunk/src/yelp-window.c	(original)
+++ trunk/src/yelp-window.c	Fri May 23 18:39:09 2008
@@ -27,10 +27,10 @@
 #endif
 
 #include <glib/gi18n.h>
+#include <gio/gio.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <glade/glade.h>
 #include <string.h>
 #include <libgnome/gnome-config.h>
@@ -1602,12 +1602,12 @@
 		     YelpRrnType    type,
 		     gboolean       need_history)
 {
-    YelpWindowPriv  *priv;
-    GnomeVFSHandle  *handle;
-    GnomeVFSResult   result;
-    GnomeVFSFileSize n;
-    gchar            buffer[BUFFER_SIZE];
-    GtkAction       *action;
+    YelpWindowPriv   *priv;
+    GFile            *file;
+    GFileInputStream *stream;
+    gsize             n;
+    gchar             buffer[BUFFER_SIZE];
+    GtkAction        *action;
     gchar *real_uri = NULL;
     gchar *base_uri = NULL;
 
@@ -1631,9 +1631,10 @@
     
     window_setup_window (window, type, uri, frag_id, uri, priv->base_uri, need_history);
 
-    result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
+    file   = g_file_new_for_uri (uri);
+    stream = g_file_read (file, NULL, NULL);
 
-    if (result != GNOME_VFS_OK) {
+    if (stream == NULL) {
 	gchar *message;
 
 	message = g_strdup_printf (_("The file â%sâ could not be read.  This file might "
@@ -1665,8 +1666,8 @@
 	g_assert_not_reached ();
     }
 
-    while ((result = gnome_vfs_read
-	    (handle, buffer, BUFFER_SIZE, &n)) == GNOME_VFS_OK) {
+    while ((g_input_stream_read_all
+	    ((GInputStream *)stream, buffer, BUFFER_SIZE, &n, NULL, NULL))) {
 	gchar *tmp;
 	tmp = g_utf8_strup (buffer, n);
 	if (strstr (tmp, "<FRAMESET")) {
@@ -1679,8 +1680,11 @@
     yelp_html_close (priv->html_view);
 
  done:
-    if (handle)
-	gnome_vfs_close (handle);
+    if (file)
+        g_object_unref (file);
+    if (stream)
+        g_object_unref (stream);
+
     g_free (real_uri);
     gdk_window_set_cursor (GTK_WIDGET (window)->window, NULL);
 
@@ -2044,14 +2048,15 @@
     } else {
 	/* HTML file */
 
-	GnomeVFSHandle  *handle;
-	GnomeVFSResult   result;
-	GnomeVFSFileSize n;
-	gchar            buffer[BUFFER_SIZE];	
+	GFile            *file;
+	GFileInputStream *stream;
+	gsize             n;
+	gchar             buffer[BUFFER_SIZE];	
 	
-	result = gnome_vfs_open (&handle, priv->uri, GNOME_VFS_OPEN_READ);
+    file   = g_file_new_for_uri (priv->uri);
+    stream = g_file_read (file, NULL, NULL);
 	
-	if (result != GNOME_VFS_OK) {
+	if (stream == NULL) {
 	    /*GError *error = NULL;
 	    g_set_error (&error, YELP_ERROR, YELP_ERROR_IO,
 			 _("The file â%sâ could not be read.  This file might "
@@ -2060,6 +2065,11 @@
 			 uri);
 			 window_error (window, error, TRUE);*/
 	    /* TODO: Proper errors */
+
+	    if (file)
+	        g_object_unref (file);
+	    if (stream)
+	        g_object_unref (stream);
 	    return;
 	}
 	/* Assuming the file exists.  If it doesn't how did we get this far?
@@ -2077,10 +2087,15 @@
 	    g_assert_not_reached ();
 	}
 	
-	while ((result = gnome_vfs_read
-		(handle, buffer, BUFFER_SIZE, &n)) == GNOME_VFS_OK) {
+	while ((g_input_stream_read_all
+	    ((GInputStream *)stream, buffer, BUFFER_SIZE, &n, NULL, NULL))) {
 	    yelp_html_write (html, buffer, n);
 	}
+
+    if (file)
+        g_object_unref (file);
+    if (stream)
+        g_object_unref (stream);
 	
 	yelp_html_close (html);
 	



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