file-roller r2203 - in trunk: . nautilus src



Author: paobac
Date: Mon Mar 31 18:07:39 2008
New Revision: 2203
URL: http://svn.gnome.org/viewvc/file-roller?rev=2203&view=rev

Log:
2008-03-31  Paolo Bacchilega  <paobac svn gnome org>

	* src/gnome-vfs-helpers.c:
	* src/gnome-vfs-helpers.h: removed
	
	* src/Makefile.am: 
	* src/main.h: 
	* src/main.c: 
	* src/fr-window.c: 
	* src/fr-archive.c: 
	* src/file-utils.h: 
	* src/file-utils.c: 
	* src/file-data.h: 
	* src/dlg-prop.c: 
	* src/dlg-batch-add.c: 
	* src/dlg-add-folder.c: 
	* src/actions.c: 
	* nautilus/nautilus-fileroller.c: 
	
	Applied a first batch of changes to complete the GIO port.
	Patch by Andreas Henriksson (see bug #501542).

Removed:
   trunk/src/gnome-vfs-helpers.c
   trunk/src/gnome-vfs-helpers.h
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/nautilus/nautilus-fileroller.c
   trunk/src/Makefile.am
   trunk/src/actions.c
   trunk/src/dlg-add-folder.c
   trunk/src/dlg-batch-add.c
   trunk/src/dlg-prop.c
   trunk/src/file-data.h
   trunk/src/file-utils.c
   trunk/src/file-utils.h
   trunk/src/fr-archive.c
   trunk/src/fr-window.c
   trunk/src/main.c
   trunk/src/main.h

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Mon Mar 31 18:07:39 2008
@@ -24,8 +24,7 @@
 LIBGNOME_REQUIRED=2.6.0
 LIBGNOMEUI_REQUIRED=2.6.0
 LIBGLADE_REQUIRED=2.4.0
-GNOME_VFS_REQUIRED=2.22.0
-NAUTILUS_REQUIRED=2.10.0
+NAUTILUS_REQUIRED=2.22.0
 
 AC_SUBST(GLIB_REQUIRED)
 AC_SUBST(GIO_REQUIRED)
@@ -44,8 +43,6 @@
 	gtk+-2.0 >= $GTK_REQUIRED			\
 	libgnome-2.0 >= $LIBGNOME_REQUIRED		\
 	libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED		\
-	gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED		\
-	gnome-vfs-module-2.0				\
 	libglade-2.0 >= $LIBGLADE_REQUIRED)
 AC_SUBST(FR_CFLAGS)
 AC_SUBST(FR_LIBS)
@@ -58,8 +55,8 @@
 
 if test x"$enable_nautilus_actions" != xno; then
 	if pkg-config --atleast-version=$NAUTILUS_REQUIRED libnautilus-extension; then
-		NAUTILUS_CFLAGS=`pkg-config --cflags libnautilus-extension glib-2.0 gnome-vfs-2.0`
-		NAUTILUS_LIBS=`pkg-config --libs libnautilus-extension glib-2.0 gnome-vfs-2.0`
+		NAUTILUS_CFLAGS=`pkg-config --cflags libnautilus-extension glib-2.0 gio-2.0`
+		NAUTILUS_LIBS=`pkg-config --libs libnautilus-extension glib-2.0 gio-2.0`
 		build_nautilus_actions=yes
 	fi
 fi

Modified: trunk/nautilus/nautilus-fileroller.c
==============================================================================
--- trunk/nautilus/nautilus-fileroller.c	(original)
+++ trunk/nautilus/nautilus-fileroller.c	Mon Mar 31 18:07:39 2008
@@ -24,9 +24,7 @@
 #include <config.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
+#include <gio/gio.h>
 #include <libnautilus-extension/nautilus-extension-types.h>
 #include <libnautilus-extension/nautilus-file-info.h>
 #include <libnautilus-extension/nautilus-menu-provider.h>
@@ -209,23 +207,21 @@
 		if (all_archives && ! is_archive (file))
 			all_archives = FALSE;
 
-
 		if (can_write) {
-			char             *parent_uri;
-			GnomeVFSFileInfo *info;
-			GnomeVFSResult    result;
+			char      *parent_uri;
+			GFile     *parent;
+			GFileInfo *info;
 
 			parent_uri = nautilus_file_info_get_parent_uri (file);
-			info = gnome_vfs_file_info_new ();
+			parent =  g_file_new_for_uri (parent_uri);
+			
+			info = g_file_query_info (parent, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, 0, NULL, NULL);
+			if (info != NULL) { 
+				can_write = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+				g_object_unref (info);
+			}
 			
-			result = gnome_vfs_get_file_info (parent_uri,
-							  info,
-							  (GNOME_VFS_FILE_INFO_FOLLOW_LINKS
-					                   | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS));
-			if ((result == GNOME_VFS_OK) && (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS))
-				can_write = (info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) || (info->permissions & GNOME_VFS_PERM_USER_WRITE);
-				
-			gnome_vfs_file_info_unref (info);
+			g_object_unref (parent);
 			g_free (parent_uri);
 		}
 	}

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Mon Mar 31 18:07:39 2008
@@ -115,8 +115,6 @@
 	gio-utils.h			\
 	glib-utils.c			\
 	glib-utils.h			\
-	gnome-vfs-helpers.c		\
-	gnome-vfs-helpers.h		\
 	gtk-utils.c			\
 	gtk-utils.h			\
 	java-utils.c			\

Modified: trunk/src/actions.c
==============================================================================
--- trunk/src/actions.c	(original)
+++ trunk/src/actions.c	Mon Mar 31 18:07:39 2008
@@ -189,9 +189,10 @@
 	debug (DEBUG_INFO, "create/save %s\n", path);
 
 	if (path_is_file (path)) {
-		GtkWidget      *dialog;
-		int             r;
-		GnomeVFSResult  result;
+		GtkWidget *dialog;
+		int        r;
+		GFile     *file;
+		GError    *err = NULL;
 
 		if (! is_supported_extension (file_sel, path)) {
 			dialog = _gtk_error_dialog_new (GTK_WINDOW (file_sel),
@@ -224,17 +225,20 @@
 			return NULL;
 		}
 
-		result = gnome_vfs_unlink (path);
-		if (result != GNOME_VFS_OK) {
+		file = g_file_new_for_uri (path);
+		g_file_delete (file, NULL, &err);
+		g_object_unref (file);
+		if (err != NULL) {
 			GtkWidget *dialog;
 			dialog = _gtk_error_dialog_new (GTK_WINDOW (file_sel),
 							GTK_DIALOG_DESTROY_WITH_PARENT,
 							NULL,
 							_("Could not delete the old archive."),
-							gnome_vfs_result_to_string (result));
+							err->message);
 			gtk_dialog_run (GTK_DIALOG (dialog));
 			gtk_widget_destroy (GTK_WIDGET (dialog));
 			g_free (path);
+			g_error_free (err);
 			return NULL;
 		}
 	}

Modified: trunk/src/dlg-add-folder.c
==============================================================================
--- trunk/src/dlg-add-folder.c	(original)
+++ trunk/src/dlg-add-folder.c	Mon Mar 31 18:07:39 2008
@@ -28,10 +28,7 @@
 #include <gtk/gtk.h>
 #include <libgnome/gnome-config.h>
 #include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-directory.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
+#include <gio/gio.h>
 #include "file-utils.h"
 #include "fr-stock.h"
 #include "fr-window.h"
@@ -525,42 +522,54 @@
 aod_update_option_list (LoadOptionsDialogData *aod_data)
 {
 	GtkListStore   *list_store = GTK_LIST_STORE (aod_data->aod_model);
-	char           *options_dir;
-	GnomeVFSResult  result;
-	GList          *list = NULL;
+	char            *options_dir;
+	GFile           *file;
+	GFileEnumerator *fileenum;
+	GFileInfo       *info;
+	GError          *err = NULL;	
 
 	gtk_list_store_clear (list_store);
 
 	options_dir = get_home_relative_dir (RC_OPTIONS_DIR);
 	ensure_dir_exists (options_dir, 0700);
 
-	result = gnome_vfs_directory_list_load (&list,
-						options_dir,
-						GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
-
-	if (result == GNOME_VFS_OK) {
-		GList *scan;
-
-		for (scan = list; scan; scan = scan->next) {
-			GnomeVFSFileInfo *file_info = scan->data;
-			GtkTreeIter       iter;
-			char             *full_path;
-
-			if ((strcmp (file_info->name, ".") == 0)
-			    || (strcmp (file_info->name, "..") == 0))
-				continue;
-
-			full_path = g_build_filename (options_dir,
-						      file_info->name,
-						      NULL);
-			gtk_list_store_append (GTK_LIST_STORE (aod_data->aod_model),
-					       &iter);
-			gtk_list_store_set (GTK_LIST_STORE (aod_data->aod_model), &iter,
-					    0, file_info->name,
-					    1, full_path,
-					    -1);
-			g_free (full_path);
+	file = g_file_new_for_path (options_dir);
+	fileenum = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &err);
+	if (err != NULL) {
+		g_warning ("Failed to enumerate children in %s: %s", options_dir, err->message);
+		g_error_free (err);
+		return;
+	}
+
+	while ((info = g_file_enumerator_next_file (fileenum, NULL, &err)) != NULL) {
+		const char  *name;
+		char        *full_path;
+		GtkTreeIter  iter;
+
+		if (err != NULL) {
+			g_warning ("Failed to get info while enumerating: %s", err->message);
+			g_clear_error (&err);
+			continue;
 		}
+
+		name = g_file_info_get_name (info);
+		if ((strcmp (name, ".") == 0) || (strcmp (name, "..") == 0))
+			continue;
+		
+		full_path = g_build_filename (options_dir, name, NULL);
+		gtk_list_store_append (GTK_LIST_STORE (aod_data->aod_model), &iter);
+		gtk_list_store_set (GTK_LIST_STORE (aod_data->aod_model), &iter,
+				    0, name,
+				    1, full_path,
+				    -1);
+
+		g_free (full_path);
+		g_object_unref (info);
+	}
+
+	if (err != NULL) {
+		g_warning ("Failed to get info after enumeration: %s", err->message);
+		g_clear_error (&err);
 	}
 
 	gnome_vfs_file_info_list_free (list);

Modified: trunk/src/dlg-batch-add.c
==============================================================================
--- trunk/src/dlg-batch-add.c	(original)
+++ trunk/src/dlg-batch-add.c	Mon Mar 31 18:07:39 2008
@@ -28,10 +28,7 @@
 #include <gtk/gtk.h>
 #include <libgnomeui/gnome-icon-lookup.h>
 #include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio.h>
 
 #include "file-utils.h"
 #include "fr-stock.h"
@@ -288,8 +285,21 @@
 		r = gtk_dialog_run (GTK_DIALOG (d));
 		gtk_widget_destroy (GTK_WIDGET (d));
 
-		if (r == GTK_RESPONSE_YES)
-			gnome_vfs_unlink (archive_file);
+		if (r == GTK_RESPONSE_YES) {
+			GFile  *file;
+			GError *err = NULL;
+
+			/* FIXME: convert this code in a function in file-utils.c */
+			file = g_file_new_for_uri (archive_file);
+			g_file_delete (file, NULL, &err);
+			if (err != NULL) {
+				g_warning ("Failed to delete file %s: %s", 
+					   archive_file, 
+					   err->message);
+				g_clear_error (&err);
+			}
+			g_object_unref (file);
+		}
 		else {
 			g_free (archive_name);
 			g_free (archive_dir);

Modified: trunk/src/dlg-prop.c
==============================================================================
--- trunk/src/dlg-prop.c	(original)
+++ trunk/src/dlg-prop.c	Mon Mar 31 18:07:39 2008
@@ -86,7 +86,7 @@
 	GtkWidget        *label_label;
 	GtkWidget        *label;
 	char             *s;
-	GnomeVFSFileSize  size, uncompressed_size;
+	goffset           size, uncompressed_size;
 	char             *utf8_name;
 	char             *title_txt;
 	double            ratio;
@@ -150,7 +150,7 @@
 
 	label = glade_xml_get_widget (data->gui, "p_size_label");
 	size = get_file_size (fr_window_get_archive_uri (window));
-	s = gnome_vfs_format_file_size_for_display (size);
+	s = g_format_size_for_display (size);
 	gtk_label_set_text (GTK_LABEL (label), s);
 	g_free (s);
 
@@ -170,7 +170,7 @@
 	}
 
 	label = glade_xml_get_widget (data->gui, "p_uncomp_size_label");
-	s = gnome_vfs_format_file_size_for_display (uncompressed_size);
+	s = g_format_size_for_display (uncompressed_size);
 	gtk_label_set_text (GTK_LABEL (label), s);
 	g_free (s);
 

Modified: trunk/src/file-data.h
==============================================================================
--- trunk/src/file-data.h	(original)
+++ trunk/src/file-data.h	Mon Mar 31 18:07:39 2008
@@ -31,14 +31,14 @@
 	char       *original_path;    /* path read from command line. */
 	char       *full_path;        /* "/" + original_path. */
 	char       *link;
-	guint64     size;
+	goffset     size;
 	time_t      modified;
 
 	char       *name;             /* The file name. */
 	char       *path;             /* The directory. */
 	gboolean    encrypted;        /* Whether the file is encrypted. */
 	gboolean    dir;              /* Whether this is a directory listed in the archive */
-	guint64     dir_size;
+	goffset     dir_size;
 	
 	/* Additional data. */
 

Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c	(original)
+++ trunk/src/file-utils.c	Mon Mar 31 18:07:39 2008
@@ -37,6 +37,7 @@
 #include <glib.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <libgnomevfs/gnome-vfs-mime.h>
+#include <gio/gio.h>
 #include <gconf/gconf-client.h>
 #include "file-utils.h"
 #include "glib-utils.h"
@@ -53,101 +54,67 @@
 
 
 gboolean
-path_exists (const gchar *path)
+uri_exists (const char *uri)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult result;
-	gboolean exists;
-	gchar *escaped;
-
-	if (! path || ! *path) return FALSE;
-
-	info = gnome_vfs_file_info_new ();
-	escaped = gnome_vfs_escape_path_string (path);
-	result = gnome_vfs_get_file_info (escaped,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-
-	exists = (result == GNOME_VFS_OK);
-
-	g_free (escaped);
-	gnome_vfs_file_info_unref (info);
-
-	return exists;
-}
-
-
-gboolean
-uri_exists (const char  *uri)
-{
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	gboolean          exists;
+	GFile     *file;
+	GFileInfo *info;
+	GError    *err = NULL;
+	gboolean   exists;
 
 	if (uri == NULL) 
 		return FALSE;
 
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (uri,
-					  info,
-					  GNOME_VFS_FILE_INFO_DEFAULT);
+	file = g_file_new_for_uri (uri);
+	info = g_file_query_info (file,	G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &err);
+	
+	exists = (err != NULL);
+	
+	if (err != NULL)
+		g_error_free (err);
+	g_object_unref (info);
+	g_object_unref (file);
 
-	exists = (result == GNOME_VFS_OK);
+	return exists;	
+}
 
-	gnome_vfs_file_info_unref (info);
 
-	return exists;	
+static gboolean
+uri_is_filetype (const char *uri, 
+		 GFileType   file_type)
+{
+	gboolean   result = FALSE;
+	GFile     *file;
+	GFileInfo *info;
+	GError    *error = NULL;
+	
+	file = g_file_new_for_uri (uri);
+	info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, 0, NULL, &error);
+	if (error == NULL) {
+		result = (g_file_info_get_file_type (info) == file_type);
+	}
+	else {
+		g_warning ("Failed to get file type for uri %s: %s", uri, err->message);
+		g_error_free (error);
+	}
+	
+	g_object_unref (info);
+	g_object_unref (file);
+	
+	return result;
 }
 
 
 gboolean
 path_is_file (const char *uri)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	gboolean          is_file;
-
-	if (! uri || ! *uri)
-		return FALSE;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (uri,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	is_file = FALSE;
-	if (result == GNOME_VFS_OK)
-		is_file = (info->type == GNOME_VFS_FILE_TYPE_REGULAR);
-
-	gnome_vfs_file_info_unref (info);
-
-	return is_file;
+	return uri_is_filetype (uri, G_FILE_TYPE_REGULAR);
 }
 
 
 gboolean
 path_is_dir (const char *uri)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	gboolean          is_dir;
-
-	if (! uri || ! *uri)
-		return FALSE;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (uri,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	is_dir = FALSE;
-	if (result == GNOME_VFS_OK)
-		is_dir = (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY);
-
-	gnome_vfs_file_info_unref (info);
-
-	return is_dir;
+	return uri_is_filetype (uri, G_FILE_TYPE_DIRECTORY);
 }
 
 
@@ -181,24 +148,46 @@
 gboolean
 dir_contains_one_object (const char *uri)
 {
-	GnomeVFSDirectoryHandle *handle;
-	GnomeVFSResult           result;
-	int                      n;
-	GnomeVFSFileInfo         info;
-	
-	result = gnome_vfs_directory_open (&handle, uri, GNOME_VFS_FILE_INFO_DEFAULT);
-	if (result != GNOME_VFS_OK)
+	GFile           *file;
+	GFileEnumerator *file_enum;
+	GFileInfo       *info;
+	GError          *err = NULL;
+	int              n = 0;
+
+	file = g_file_new_for_uri (uri);
+	file_enum = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &err);
+	if (err != NULL) {
+		g_warning ("Failed to enumerate children of %s: %s", uri, err->message);
+		g_error_free (err);
+		g_object_unref (file_enum);
+		g_object_unref (file);
 		return FALSE;
-		
-	n = 0;
-	while (gnome_vfs_directory_read_next (handle, &info) == GNOME_VFS_OK) {
-		if ((strcmp (info.name, ".") == 0) || (strcmp (info.name, "..") == 0))
+	}
+	
+	while ((info = g_file_enumerator_next_file (file_enum, NULL, &err)) != NULL) {
+		const char *name;
+
+		if (err != NULL) {
+			g_warning ("Encountered error while enumerating children of %s, ignoring: %s", uri, err->message);
+			g_error_free (err);
+			g_object_unref (info);
 			continue;
+		}
+
+		name = g_file_info_get_name (info);
+		if (strcmp (name, ".") == 0 || strcmp (name, "..") == 0) {
+			g_object_unref (info);
+ 			continue;
+		}
+		
+		g_object_unref (info);
+	
 		if (++n > 1) 
 			break;
 	}
 
-	gnome_vfs_directory_close (handle);
+	g_object_unref (file);
+	g_object_unref (file_enum);
 	
 	return (n == 1);
 }
@@ -207,29 +196,55 @@
 char *
 get_directory_content_if_unique (const char  *uri)
 {
-	GnomeVFSDirectoryHandle *handle;
-	GnomeVFSResult           result;
-	GnomeVFSFileInfo        *info;
-	char                    *content_uri = NULL;
+	GFile           *file;
+	GFileEnumerator *file_enum;
+	GFileInfo       *info;
+	GError          *err = NULL;
+	char            *content_uri = NULL;
 	
-	result = gnome_vfs_directory_open (&handle, uri, GNOME_VFS_FILE_INFO_DEFAULT);
-	if (result != GNOME_VFS_OK)
+	file = g_file_new_for_uri (uri);
+	file_enum = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &err);
+	if (err != NULL) {
+		g_warning ("Failed to enumerate children of %s: %s", uri, err->message);
+		g_error_free (err);
 		return NULL;
+	}
 	
-	info = gnome_vfs_file_info_new ();
-	while (gnome_vfs_directory_read_next (handle, info) == GNOME_VFS_OK) {
-		if ((strcmp (info->name, ".") == 0) || (strcmp (info->name, "..") == 0))
+	while ((info = g_file_enumerator_next_file (file_enum, NULL, &err)) != NULL) {
+		const char *name;
+
+		if (err != NULL) {
+			g_warning ("Failed to get info while enumerating children: %s", err->message);
+			g_clear_error (&err);
+			g_object_unref (info);
 			continue;
+		}
+		
+		name = g_file_info_get_name (info);
+		if ((strcmp (name, ".") == 0) || (strcmp (name, "..") == 0)) {
+			g_object_unref (info);
+			continue;
+		}
+		
 		if (content_uri != NULL) {
 			g_free (content_uri);
+			g_object_unref (info);
 			content_uri = NULL;
 			break;
 		}
-		else
-			content_uri = g_strconcat (uri, "/", info->name, NULL);
+		
+		content_uri = g_build_path (uri, name, NULL);
+		g_object_unref (info);
 	}
-	gnome_vfs_file_info_unref (info);
-	gnome_vfs_directory_close (handle);
+	
+	if (err != NULL) {
+		g_warning ("Failed to get info after enumerating children: %s",
+			   err->message);
+		g_clear_error (&err);
+	}
+
+	g_object_unref (file_enum);
+	g_object_unref (file);
 	
 	return content_uri;	
 }
@@ -267,78 +282,73 @@
 }
 
 
-GnomeVFSFileSize
+goffset
 get_file_size (const char *uri)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	GnomeVFSFileSize  size;
+	GFile     *file;
+	GFileInfo *info;
+	goffset    size;
+	GError    *err = NULL;
 
 	if ((uri == NULL) || (*uri == '\0'))
 		return 0;
 
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (uri,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	size = 0;
-	if (result == GNOME_VFS_OK)
-		size = info->size;
-
-	gnome_vfs_file_info_unref (info);
+	file = g_file_new_for_uri (uri);
+	info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, &err);
+	if (err == NULL) {
+		size = g_file_info_get_size (info);
+	}
+	else {
+		g_warning ("Failed to get file size for %s: %s", uri, err->message);
+		g_error_free (err);
+	}	
 
-	return size;
+	g_object_unref (info);
+	g_object_unref (file);
 }
 
 
-time_t
-get_file_mtime (const char *uri)
+static time_t
+get_file_time_type (const char *uri, 
+		    const char *type)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	time_t            mtime;
+	time_t     result = 0;
+	GFile     *file;
+	GFileInfo *info;
+	GError    *err = NULL;
 
 	if ((uri == NULL) || (*uri == '\0'))
-		return 0;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (uri,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	mtime = 0;
-	if (result == GNOME_VFS_OK)
-		mtime = info->mtime;
+ 		return 0;
+	
+	file = g_file_new_for_uri (uri);
+	info = g_file_query_info (file, type, 0, NULL, &err);
+	if (err == NULL) {
+		result = (time_t) g_file_info_get_attribute_uint64 (info, type);
+	}
+	else {
+		g_warning ("Failed to get %s for %s: %s", type, uri, err->message);
+		g_error_free (err);
+		result = 0;		
+	}		
+	
+	g_object_unref (info);
+	g_object_unref (file);
+	
+	return result;
+}
 
-	gnome_vfs_file_info_unref (info);
 
-	return mtime;
+time_t
+get_file_mtime (const char *uri)
+{
+	return get_file_time_type (uri, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 }
 
 
 time_t
 get_file_ctime (const char *uri)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	time_t            ctime;
-
-	if ((uri == NULL) || (*uri == '\0'))
-		return 0;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (uri,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	ctime = 0;
-	if (result == GNOME_VFS_OK)
-		ctime = info->ctime;
-
-	gnome_vfs_file_info_unref (info);
-
-	return ctime;
+	return get_file_time_type (uri, G_FILE_ATTRIBUTE_TIME_CREATED);
 }
 
 
@@ -711,21 +721,25 @@
 }
 
 
-GnomeVFSFileSize
+guint64
 get_dest_free_space (const char *uri)
 {
-	GnomeVFSURI      *vfs_uri;
-	GnomeVFSResult    result;
-	GnomeVFSFileSize  ret_val;
-
-	vfs_uri = gnome_vfs_uri_new (uri);
-	result = gnome_vfs_get_volume_free_space (vfs_uri, &ret_val);
-	gnome_vfs_uri_unref (vfs_uri);
+	GFile     *file;
+	GFileInfo *info;
+	goffset    freespace;
+	GError    *err = NULL;
+
+	file = g_file_new_for_uri (uri);
+	info = g_file_query_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, 0, NULL, &err);
+	if (err != NULL) {
+		freespace = 0;
+		g_warning ("Could not get filesystem free space on volume that contains %s: %s", uri, err->message);
+		g_error_free (err);
+	}
+	g_object_unref (info);
+	g_object_unref (file);
 
-	if (result != GNOME_VFS_OK)
-		return (GnomeVFSFileSize) 0;
-	else
-		return ret_val;
+	return freespace;
 }
 
 
@@ -909,18 +923,18 @@
 char *
 get_temp_work_dir (void)
 {
-	GnomeVFSFileSize  max_size = 0;
-	char             *best_folder = NULL;
-	int               i;
-	char             *template;
-	char             *result = NULL;
+	guint64  max_size = 0;
+	char    *best_folder = NULL;
+	int      i;
+	char    *template;
+	char    *result = NULL;
 
 	/* find the folder with more free space. */
 
 	for (i = 0; try_folder[i] != NULL; i++) {
-		const char       *folder;
-		char             *uri;
-		GnomeVFSFileSize  size;
+		const char *folder;
+		char       *uri;
+		guint64     size;
 
 		folder = get_folder_from_try_folder_list (i);
 		uri = g_strconcat ("file://", folder, NULL);
@@ -1125,7 +1139,8 @@
 	if (method != NULL) {
 		euri = g_strdup_printf ("%s://%s", method, epath);
 		g_free (epath);
-	} else
+	} 
+	else
 		euri = epath;
 
 	g_free (method);

Modified: trunk/src/file-utils.h
==============================================================================
--- trunk/src/file-utils.h	(original)
+++ trunk/src/file-utils.h	Mon Mar 31 18:07:39 2008
@@ -39,7 +39,6 @@
 		     NULL)
 
 gboolean            path_is_file                 (const gchar *s);
-gboolean            path_exists                  (const gchar *s);
 gboolean            uri_exists                   (const char  *uri);
 gboolean            path_is_dir                  (const gchar *s);
 gboolean            dir_is_empty                 (const gchar *s);
@@ -47,7 +46,7 @@
 char *              get_directory_content_if_unique (const char  *uri);
 gboolean            path_in_path                 (const char  *path_src,
 						  const char  *path_dest);
-GnomeVFSFileSize    get_file_size                (const gchar *s);
+goffset             get_file_size                (const char *uri);
 time_t              get_file_mtime               (const gchar *s);
 time_t              get_file_ctime               (const gchar *s);
 gboolean            file_copy                    (const gchar *from,
@@ -71,7 +70,7 @@
 						  const char* pattern);
 const char*         get_file_mime_type           (const char *filename,
                     				  gboolean    fast_file_type);
-GnomeVFSFileSize    get_dest_free_space          (const char  *path);
+guint64             get_dest_free_space          (const char  *path);
 gboolean            remove_directory             (const char  *uri);
 gboolean            remove_local_directory       (const char  *directory);
 GnomeVFSResult      make_tree                    (const char  *uri);

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Mon Mar 31 18:07:39 2008
@@ -29,10 +29,7 @@
 
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
 #include "glib-utils.h"
 #include "file-utils.h"
 #include "gio-utils.h"
@@ -410,17 +407,29 @@
 		    const char *uri)
 {
 	if ((archive->local_filename != NULL) && archive->is_remote) {
-		char *file_uri;
-		char *folder_uri;
+		GFile  *file, *folder;
+		GError *err = NULL;
 
-		file_uri = get_uri_from_local_path (archive->local_filename);
-		gnome_vfs_unlink (file_uri);
-
-		folder_uri = remove_level_from_path (file_uri);
-		gnome_vfs_remove_directory (folder_uri);
-
-		g_free (file_uri);
-		g_free (folder_uri);
+		file = g_file_new_for_path (archive->local_filename);
+		g_file_delete (file, NULL, &err);
+		if (err != NULL) {
+			g_warning ("Failed to delete file %s: %s",
+				   archive->local_filename,
+				   err->message);
+			g_clear_error (&err);
+		}
+		
+		folder = g_file_get_parent (file);
+		g_file_delete (folder, NULL, &err);
+		if (err != NULL) {
+			g_warning ("Failed to delete parent folder of %s: %s",
+				   archive->local_filename,
+				   err->message);
+			g_clear_error (&err);
+		}
+		
+		g_object_unref (folder);
+		g_object_unref (file);
 	}
 
 	if (uri != archive->uri) {
@@ -2981,13 +2990,13 @@
 
 		if (! archive->command->propExtractCanSkipOlder
 		    && skip_older
-		    && path_exists (dest_filename)
+		    && g_file_test (dest_filename, G_FILE_TEST_EXISTS)
 		    && (fdata->modified < get_file_mtime (dest_filename)))
 			continue;
 
 		if (! archive->command->propExtractCanAvoidOverwrite
 		    && ! overwrite
-		    && path_exists (dest_filename))
+		    && g_file_test (dest_filename, G_FILE_TEST_EXISTS))
 			continue;
 
 		filtered = g_list_prepend (filtered, fdata->original_path);

Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c	(original)
+++ trunk/src/fr-window.c	Mon Mar 31 18:07:39 2008
@@ -34,6 +34,7 @@
 #include <libgnomevfs/gnome-vfs-ops.h>
 #include <libgnomevfs/gnome-vfs-uri.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "actions.h"
@@ -1387,11 +1388,11 @@
 static void
 fr_window_update_statusbar_list_info (FrWindow *window)
 {
-	char             *info, *archive_info, *selected_info;
-	char             *size_txt, *sel_size_txt;
-	int               tot_n, sel_n;
-	GnomeVFSFileSize  tot_size, sel_size;
-	GList            *scan;
+	char    *info, *archive_info, *selected_info;
+	char    *size_txt, *sel_size_txt;
+	int      tot_n, sel_n;
+	goffset  tot_size, sel_size;
+	GList   *scan;
 	
 	if (window == NULL)
 		return;
@@ -1436,9 +1437,9 @@
 		g_list_free (selection);
 	}
 
-	size_txt = gnome_vfs_format_file_size_for_display (tot_size);
-	sel_size_txt = gnome_vfs_format_file_size_for_display (sel_size);
-
+	size_txt = g_format_size_for_display (tot_size);
+	sel_size_txt = g_format_size_for_display (sel_size);
+	
 	if (tot_n == 0)
 		archive_info = g_strdup ("");
 	else

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Mon Mar 31 18:07:39 2008
@@ -25,8 +25,7 @@
 
 #include <libgnome/gnome-config.h>
 #include <libgnomeui/libgnomeui.h>
-#include <libgnomevfs/gnome-vfs-init.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
 #include <glade/glade.h>
 #include "file-utils.h"
 #include "glib-utils.h"
@@ -106,6 +105,7 @@
 	{ "zip",        TRUE,  TRUE,  TRUE,  FR_FILE_TYPE_ZIP },
 	{ "unzip",      TRUE,  FALSE, TRUE,  FR_FILE_TYPE_ZIP },
 	{ "rar",        TRUE,  TRUE,  TRUE,  FR_FILE_TYPE_RAR },
+	{ "unrar",      TRUE,  FALSE, TRUE,  FR_FILE_TYPE_RAR },
 	{ "gzip",       TRUE,  TRUE,  FALSE, FR_FILE_TYPE_GZIP },
 	{ "bzip2",      TRUE,  TRUE,  FALSE, FR_FILE_TYPE_BZIP2 },
 	{ "unace",      TRUE,  FALSE, TRUE,  FR_FILE_TYPE_ACE },
@@ -228,11 +228,6 @@
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
 					   PKG_DATA_DIR G_DIR_SEPARATOR_S "icons");
 
-/*
-	if (! gnome_vfs_init ())
-		g_error ("Cannot initialize the Virtual File System.");
-*/
-
 	gnome_authentication_manager_init ();
 	glade_init ();
 	fr_stock_init ();
@@ -312,7 +307,7 @@
 	}
 
 	g_free (cdata->command);
-	gnome_vfs_mime_application_free (cdata->app);
+	g_object_unref (cdata->app);
 	path_list_free (cdata->file_list);
 	g_free (cdata->temp_dir);
 	if (cdata->process != NULL)
@@ -582,26 +577,22 @@
 		fr_window_start_batch (FR_WINDOW (window));
 	}
 	else { /* Open each archive in a window */
-		const char *utf8_archive = NULL;
-		char       *locale_archive = NULL;
+		const char *filename = NULL;
 
 		int i = 0;
-		while ((utf8_archive = remaining_args[i++]) != NULL) {
+		while ((filename = remaining_args[i++]) != NULL) {
 			GtkWidget *window;
+			GFile     *file;
 			char      *uri;
 			
 			window = fr_window_new ();
 			gtk_widget_show (window);
 			
-			locale_archive = g_filename_from_utf8 (utf8_archive, -1, NULL, NULL, NULL);
-			if (locale_archive == NULL)
-				locale_archive = g_strdup (utf8_archive);
-			uri = gnome_vfs_make_uri_from_shell_arg (locale_archive);
-			g_free (locale_archive);
-
+			file = g_file_new_for_commandline_arg (filename);
+			uri = g_file_get_uri (file);
 			fr_window_archive_open (FR_WINDOW (window), uri, GTK_WINDOW (window));
-
 			g_free (uri);
+			g_object_unref (file);
 		}
 	}
 

Modified: trunk/src/main.h
==============================================================================
--- trunk/src/main.h	(original)
+++ trunk/src/main.h	Mon Mar 31 18:07:39 2008
@@ -3,7 +3,7 @@
 /*
  *  File-Roller
  *
- *  Copyright (C) 2001 The Free Software Foundation, Inc.
+ *  Copyright (C) 2001, 2008 The Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
 
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <gio/gio.h>
 #include "preferences.h"
 #include "fr-process.h"
 #include "fr-window.h"
@@ -41,12 +41,12 @@
 } ViewerData;
 
 typedef struct {
-	FrWindow                *window;
-	FrProcess               *process;
-	char                    *command;
-	GnomeVFSMimeApplication *app;
-	GList                   *file_list;
-	char                    *temp_dir;
+	FrWindow  *window;
+	FrProcess *process;
+	char      *command;
+	GAppInfo  *app;
+	GList     *file_list;
+	char      *temp_dir;
 } CommandData;
 
 



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