summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--configure.in2
-rw-r--r--src/test-resolver.c4
-rw-r--r--src/test-uri.c5
-rw-r--r--src/yelp-base.c1
-rw-r--r--src/yelp-main.c3
-rw-r--r--src/yelp-search-pager.c1
-rw-r--r--src/yelp-search-parser.c1
-rw-r--r--src/yelp-toc-pager.c21
-rw-r--r--src/yelp-utils.c14
-rw-r--r--src/yelp-window.c57
11 files changed, 69 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index 49f9dd7a..f6db9b4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,21 @@
2008-05-23 Don Scorgie <dscorgie@svn.gnome.org>
* 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
+
+2008-05-23 Don Scorgie <dscorgie@svn.gnome.org>
+
+ * configure.in:
* m4/gecko.m4:
* src/Makefile.am:
* src/yelp-gecko-services.cpp:
diff --git a/configure.in b/configure.in
index 99d6d81f..cd154155 100644
--- a/configure.in
+++ b/configure.in
@@ -67,10 +67,10 @@ AM_GLIB_DEFINE_LOCALEDIR([GNOMELOCALEDIR])
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
diff --git a/src/test-resolver.c b/src/test-resolver.c
index b39d11a5..cfadb956 100644
--- a/src/test-resolver.c
+++ b/src/test-resolver.c
@@ -7,7 +7,6 @@
#include <stdio.h>
#include <glib.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "yelp-utils.h"
@@ -203,9 +202,6 @@ main (int argc, char *argv[])
{
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");
diff --git a/src/test-uri.c b/src/test-uri.c
index 0b514226..6d0caeb3 100644
--- a/src/test-uri.c
+++ b/src/test-uri.c
@@ -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 @@ main (int argc, char **argv)
GNOME_PROGRAM_STANDARD_PROPERTIES,
NULL);
- gnome_vfs_init ();
-
for (i = 1; i < argc; i++) {
if (i != 1)
printf ("\n");
@@ -119,7 +116,5 @@ main (int argc, char **argv)
printf ("Failed to load URI: %s\n", argv[i]);
}
- gnome_vfs_shutdown ();
-
return 0;
}
diff --git a/src/yelp-base.c b/src/yelp-base.c
index 46e148e3..066568bd 100644
--- a/src/yelp-base.c
+++ b/src/yelp-base.c
@@ -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>
diff --git a/src/yelp-main.c b/src/yelp-main.c
index 61f03937..8322cfd9 100644
--- a/src/yelp-main.c
+++ b/src/yelp-main.c
@@ -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 @@ main (int argc, char **argv)
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) {
diff --git a/src/yelp-search-pager.c b/src/yelp-search-pager.c
index 63aa8edc..afa9fd51 100644
--- a/src/yelp-search-pager.c
+++ b/src/yelp-search-pager.c
@@ -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>
diff --git a/src/yelp-search-parser.c b/src/yelp-search-parser.c
index b0df2ace..7c84a2da 100644
--- a/src/yelp-search-parser.c
+++ b/src/yelp-search-parser.c
@@ -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>
diff --git a/src/yelp-toc-pager.c b/src/yelp-toc-pager.c
index 624a6ebf..7e9a132e 100644
--- a/src/yelp-toc-pager.c
+++ b/src/yelp-toc-pager.c
@@ -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 @@ process_omf_pending (YelpTocPager *pager)
/* 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 @@ process_omf_pending (YelpTocPager *pager)
/* 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)
diff --git a/src/yelp-utils.c b/src/yelp-utils.c
index 71c871e9..088d4835 100644
--- a/src/yelp-utils.c
+++ b/src/yelp-utils.c
@@ -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 yelp_uri_resolve (gchar *uri,
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 @@ resolve_process_ghelp (char *uri, gchar **result)
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 @@ resolve_is_man_path (const gchar *path, const gchar *encoding)
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;
}
diff --git a/src/yelp-window.c b/src/yelp-window.c
index ff296dce..911405ab 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -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 @@ window_do_load_html (YelpWindow *window,
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_do_load_html (YelpWindow *window,
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 @@ window_do_load_html (YelpWindow *window,
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 @@ window_do_load_html (YelpWindow *window,
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 @@ window_print_page_cb (GtkAction *action, YelpWindow *window)
} 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 @@ window_print_page_cb (GtkAction *action, YelpWindow *window)
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 @@ window_print_page_cb (GtkAction *action, YelpWindow *window)
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);