nautilus-cd-burner r2121 - in trunk: . src
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus-cd-burner r2121 - in trunk: . src
- Date: Mon, 21 Jan 2008 01:17:00 +0000 (GMT)
Author: mccann
Date: Mon Jan 21 01:17:00 2008
New Revision: 2121
URL: http://svn.gnome.org/viewvc/nautilus-cd-burner?rev=2121&view=rev
Log:
2008-01-20 William Jon McCann <mccann jhu edu>
* configure.in:
* src/Makefile.am:
* src/burn-extension.c: (uri_to_path), (write_iso_activate_cb),
(write_cue_activate_cb), (_is_blank), (drive_get_first_volume),
(_is_cd_device), (nautilus_burn_get_file_items), (dir_is_empty),
(update_empty_idle), (burn_monitor_cb), (start_monitor),
(nautilus_burn_finalize):
* src/make-iso.c: (make_iso_get_free_space), (dir_is_empty),
(get_backing_file), (file_info_is_allowed), (graft_file_visitor),
(create_graft_file), (nautilus_burn_iso_graft_new),
(nautilus_burn_iso_make_from_graft),
(nautilus_burn_iso_make_from_drive):
* src/mapping-daemon.c:
* src/mapping-daemon.h:
* src/mapping-method.c:
* src/mapping-method.h:
* src/mapping-protocol.c:
* src/mapping-protocol.h:
* src/nautilus-cd-burner.c: (expand_path_input), (main):
* src/ncb-rename-dialog.c: (treemodel_file_move_cb),
(delete_menu_item_cb), (check_filename_visitor),
(set_invalid_filenames_internal),
(ncb_rename_dialog_set_invalid_filenames):
* src/ncb-selection.c: (get_backing_file), (file_info_is_image),
(file_info_is_allowed), (estimate_size_visitor),
(estimate_size_internal), (estimate_size):
Initial port to GIO.
Based on patch from Alexander Larsson <alexl redhat com>
Removed:
trunk/src/mapping-daemon.c
trunk/src/mapping-daemon.h
trunk/src/mapping-method.c
trunk/src/mapping-method.h
trunk/src/mapping-protocol.c
trunk/src/mapping-protocol.h
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/src/Makefile.am
trunk/src/burn-extension.c
trunk/src/make-iso.c
trunk/src/nautilus-cd-burner.c
trunk/src/ncb-rename-dialog.c
trunk/src/ncb-selection.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Mon Jan 21 01:17:00 2008
@@ -7,7 +7,7 @@
AC_INIT(nautilus-cd-burner,
nautilus_burn_version_major.nautilus_burn_version_minor.nautilus_burn_version_micro)
-AC_CONFIG_SRCDIR(src/mapping-method.c)
+AC_CONFIG_SRCDIR(src/nautilus-cd-burner.c)
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE
@@ -57,8 +57,7 @@
dnl ===========================================================================
dnl Minimum versions of the libraries
-GNOME_VFS_REQUIRED=2.1.3.1
-GLIB_REQUIRED=2.10.0
+GLIB_REQUIRED=2.15.2
GTK_REQUIRED=2.5.4
LIBGLADE_REQUIRED=2.0.0
LIBGNOME_REQUIRED=2.14.0
@@ -82,10 +81,6 @@
dnl ===========================================================================
dnl Check for modules and libraries
-PKG_CHECK_MODULES(MAPPING,
- gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED dnl
- gnome-vfs-module-2.0 >= $GNOME_VFS_REQUIRED)
-
PKG_CHECK_MODULES(DAEMON, glib-2.0 >= $GLIB_REQUIRED)
AC_CHECK_LIB(socket, bind,
DAEMON_LIBS="$DAEMON_LIBS -lsocket",
@@ -96,7 +91,6 @@
gthread-2.0 >= $GLIB_REQUIRED dnl
libgnome-2.0 >= $LIBGNOME_REQUIRED dnl
gtk+-2.0 >= $GTK_REQUIRED dnl
- gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED dnl
libglade-2.0 >= $LIBGLADE_REQUIRED dnl
libgnomeui-2.0 >= $LIBGNOME_REQUIRED dnl
$HAL)
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Jan 21 01:17:00 2008
@@ -1,7 +1,7 @@
module_flags = -avoid-version -module
lib_LTLIBRARIES = libnautilus-burn.la
-libexec_PROGRAMS = mapping-daemon
+
bin_PROGRAMS = nautilus-cd-burner
noinst_PROGRAMS = \
list_cddrives \
@@ -19,7 +19,6 @@
NULL =
INCLUDES = \
- $(MAPPING_CFLAGS) \
$(GUI_CFLAGS) \
$(EXTENSION_CFLAGS) \
$(WERROR) \
@@ -41,9 +40,6 @@
DISTCLEANFILES = \
$(NULL)
-modulesdir = $(libdir)/gnome-vfs-2.0/modules
-modules_LTLIBRARIES = libmapping.la
-
### GUI burner app
nautilus_cd_burner_SOURCES = \
nautilus-cd-burner.c \
@@ -88,36 +84,6 @@
test_blank_LDFLAGS = `pkg-config --libs gthread-2.0`
test_blank_LDADD = libnautilus-burn.la
-### Mapping daemon
-
-mapping_daemon_SOURCES = \
- mapping-daemon.c \
- mapping-daemon.h \
- mapping-protocol.h \
- mapping-protocol.c \
- $(MKDTEMP_FILES) \
- $(NULL)
-
-mapping_daemon_CFLAGS = $(AM_CFLAGS)
-mapping_daemon_LDADD = $(DAEMON_LIBS)
-
-### `mapping' method
-
-libmapping_la_SOURCES = \
- mapping-method.c \
- mapping-method.h \
- mapping-protocol.h \
- mapping-protocol.c \
- $(NULL)
-
-# we set this so that Automake will use different file names when
-# compiling, so that the copy of mapping-method.o compiled for
-# libmapping.la doesn't conflict with the copy compiled for
-# mapping-daemon (the library one should be PIC code).
-libmapping_la_CFLAGS = $(AM_CFLAGS)
-
-libmapping_la_LDFLAGS = $(module_flags)
-libmapping_la_LIBADD = $(MAPPING_LIBS)
### Nautilus Extension
nautilus_extensiondir = $(NAUTILUSDIR)
Modified: trunk/src/burn-extension.c
==============================================================================
--- trunk/src/burn-extension.c (original)
+++ trunk/src/burn-extension.c Mon Jan 21 01:17:00 2008
@@ -38,6 +38,8 @@
#include "nautilus-burn-bar.h"
+#define BURN_URI "burn:///"
+
#define NAUTILUS_TYPE_BURN (nautilus_burn_get_type ())
#define NAUTILUS_BURN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_BURN, NautilusBurn))
#define NAUTILUS_IS_BURN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_BURN))
@@ -59,13 +61,13 @@
struct _NautilusBurnPrivate
{
- GnomeVFSMonitorHandle *burn_monitor;
- guint empty : 1;
+ GFileMonitor *burn_monitor;
+ guint empty : 1;
- guint start_monitor_id;
- guint empty_update_id;
+ guint start_monitor_id;
+ guint empty_update_id;
- GSList *widget_list;
+ GSList *widget_list;
};
static GType nautilus_burn_get_type (void);
@@ -172,20 +174,33 @@
launch_ncb_on_window (GTK_WINDOW (user_data));
}
+static char *
+uri_to_path (const char *uri)
+{
+ GFile *file;
+ char *path;
+
+ file = g_file_new_for_uri (uri);
+ path = g_file_get_path (file);
+ g_object_unref (file);
+ return path;
+}
+
static void
write_iso_activate_cb (NautilusMenuItem *item,
gpointer user_data)
{
- NautilusFileInfo *file;
+ NautilusFileInfo *file_info;
char *argv [3];
char *uri;
char *image_name;
- file = g_object_get_data (G_OBJECT (item), "file");
+ file_info = g_object_get_data (G_OBJECT (item), "file_info");
- uri = nautilus_file_info_get_uri (file);
- image_name = gnome_vfs_get_local_path_from_uri (uri);
- if (!image_name) {
+ uri = nautilus_file_info_get_uri (file_info);
+ image_name = uri_to_path (uri);
+
+ if (image_name == NULL) {
g_warning ("Can not get local path for URI %s", uri);
g_free (uri);
return;
@@ -208,16 +223,16 @@
write_cue_activate_cb (NautilusMenuItem *item,
gpointer user_data)
{
- NautilusFileInfo *file;
+ NautilusFileInfo *file_info;
char *argv [3];
char *uri;
char *image_name;
- file = g_object_get_data (G_OBJECT (item), "file");
+ file_info = g_object_get_data (G_OBJECT (item), "file_info");
- uri = nautilus_file_info_get_uri (file);
- image_name = gnome_vfs_get_local_path_from_uri (uri);
- if (!image_name) {
+ uri = nautilus_file_info_get_uri (file_info);
+ image_name = uri_to_path (uri);
+ if (image_name == NULL) {
g_warning ("Can not get local path for URI %s", uri);
g_free (uri);
return;
@@ -301,10 +316,10 @@
}
static gboolean
-volume_is_blank (GnomeVFSVolume *volume)
+_is_blank (GFileInfo *info)
{
LibHalContext *ctx;
- char *udi;
+ const char *udi;
gboolean is_blank;
ctx = get_hal_context ();
@@ -314,7 +329,7 @@
is_blank = FALSE;
- udi = gnome_vfs_volume_get_hal_udi (volume);
+ udi = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI);
if (udi != NULL) {
is_blank = libhal_device_get_property_bool (ctx,
udi,
@@ -322,30 +337,36 @@
NULL);
}
- g_free (udi);
-
return is_blank;
}
-static GnomeVFSVolume *
-drive_get_first_volume (GnomeVFSDrive *drive)
+static GVolume *
+drive_get_first_volume (GDrive *drive)
{
- GnomeVFSVolume *volume;
- GList *volumes;
+ GVolume *volume;
+ GList *volumes;
- volumes = gnome_vfs_drive_get_mounted_volumes (drive);
+ volumes = g_drive_get_volumes (drive);
volume = g_list_nth_data (volumes, 0);
if (volume != NULL) {
- gnome_vfs_volume_ref (volume);
+ g_object_ref (volume);
}
- gnome_vfs_drive_volume_list_free (volumes);
+ g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
+ g_list_free (volumes);
return volume;
}
+static gboolean
+_is_cd_device (GFileInfo *info)
+{
+ /* FIXME: */
+ return TRUE;
+}
+
static GList *
nautilus_burn_get_file_items (NautilusMenuProvider *provider,
GtkWidget *window,
@@ -353,10 +374,12 @@
{
GList *items = NULL;
NautilusMenuItem *item;
- NautilusFileInfo *file;
- GnomeVFSFileInfo *info;
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
+ NautilusFileInfo *file_info;
+ GFile *file;
+ GFileInfo *info;
+ GMount *mount;
+ GVolume *volume;
+ GDrive *drive;
char *mime_type;
gboolean is_local;
gboolean is_iso;
@@ -366,22 +389,33 @@
return NULL;
}
- file = NAUTILUS_FILE_INFO (selection->data);
+ file_info = NAUTILUS_FILE_INFO (selection->data);
- if (nautilus_file_info_is_gone (file)) {
+ if (nautilus_file_info_is_gone (file_info)) {
return NULL;
}
- info = nautilus_file_info_get_vfs_file_info (file);
+ file = nautilus_file_info_get_location (file_info);
+
+ if (file == NULL) {
+ return NULL;
+ }
- if (! info) {
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+ G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE ","
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI,
+ 0,
+ NULL,
+ NULL);
+ if (info == NULL) {
return NULL;
}
- is_local = GNOME_VFS_FILE_INFO_LOCAL (info);
- gnome_vfs_file_info_unref (info);
+ is_local = TRUE;
- mime_type = nautilus_file_info_get_mime_type (file);
+ mime_type = nautilus_file_info_get_mime_type (file_info);
if (! mime_type) {
return NULL;
}
@@ -396,7 +430,7 @@
_("_Write to Disc..."),
_("Write disc image to a CD or DVD disc"),
"nautilus-cd-burner");
- g_object_set_data (G_OBJECT (item), "file", file);
+ g_object_set_data (G_OBJECT (item), "file_info", file_info);
g_object_set_data (G_OBJECT (item), "window", window);
g_signal_connect (item, "activate",
G_CALLBACK (write_iso_activate_cb), NULL);
@@ -406,7 +440,7 @@
_("_Write to Disc..."),
_("Write disc image cuesheet to a CD or DVD disc"),
"nautilus-cd-burner");
- g_object_set_data (G_OBJECT (item), "file", file);
+ g_object_set_data (G_OBJECT (item), "file_info", file_info);
g_object_set_data (G_OBJECT (item), "window", window);
g_signal_connect (item, "activate",
G_CALLBACK (write_cue_activate_cb), NULL);
@@ -422,21 +456,20 @@
* the two for CD/DVD media
*/
- drive = nautilus_file_info_get_drive (file);
- volume = nautilus_file_info_get_volume (file);
+ drive = NULL;
+ volume = NULL;
- /* nautilus-file-info doesn't increment refcount */
- if (drive != NULL) {
- gnome_vfs_drive_ref (drive);
- }
- /* nautilus-file-info doesn't increment refcount */
- if (volume != NULL) {
- gnome_vfs_volume_ref (volume);
+ mount = g_file_find_enclosing_mount (file, NULL, NULL);
+ if (mount != NULL) {
+ drive = g_mount_get_drive (mount);
+ volume = g_mount_get_volume (mount);
+ } else {
+ g_debug ("Mount not found");
}
if (drive == NULL && volume != NULL) {
/* case A */
- drive = gnome_vfs_volume_get_drive (volume);
+ drive = g_volume_get_drive (volume);
} else if (volume == NULL && drive != NULL) {
/* case B */
volume = drive_get_first_volume (drive);
@@ -444,29 +477,29 @@
if (drive != NULL
&& volume != NULL
- && (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_CDROM)
- && !volume_is_blank (volume)) {
- char *device_path;
+ && _is_cd_device (info)
+ && !_is_blank (info)) {
+ const char *device_path;
- device_path = gnome_vfs_drive_get_device_path (drive);
+ device_path = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE);
item = nautilus_menu_item_new ("NautilusBurn::copy_disc",
_("_Copy Disc..."),
_("Create a copy of this CD or DVD disc"),
"nautilus-cd-burner");
- g_object_set_data (G_OBJECT (item), "file", file);
+ g_object_set_data (G_OBJECT (item), "file_info", file_info);
g_object_set_data (G_OBJECT (item), "window", window);
- g_object_set_data_full (G_OBJECT (item), "drive_device_path", device_path, g_free);
+ g_object_set_data_full (G_OBJECT (item), "drive_device_path", g_strdup (device_path), g_free);
g_signal_connect (item, "activate",
G_CALLBACK (copy_disc_activate_cb), NULL);
items = g_list_append (items, item);
}
if (drive != NULL) {
- gnome_vfs_drive_unref (drive);
+ g_object_unref (drive);
}
if (volume != NULL) {
- gnome_vfs_volume_unref (volume);
+ g_object_unref (volume);
}
g_free (mime_type);
@@ -535,45 +568,59 @@
static gboolean
dir_is_empty (const char *uri)
{
- GnomeVFSFileInfo *info;
- GnomeVFSDirectoryHandle *handle;
- GnomeVFSResult result;
- gboolean found_file;
+ GFile *file;
+ GFileEnumerator *enumerator;
+ GError *error;
+ gboolean found_file;
- result = gnome_vfs_directory_open (&handle, uri, GNOME_VFS_FILE_INFO_DEFAULT);
+ file = g_file_new_for_uri (uri);
- if (result != GNOME_VFS_OK) {
+ error = NULL;
+ enumerator = g_file_enumerate_children (file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+ G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
+ 0,
+ NULL,
+ &error);
+ if (enumerator == NULL) {
DEBUG_PRINT ("Could not open burn uri %s: %s\n",
uri,
- gnome_vfs_result_to_string (result));
+ error->message);
+ g_error_free (error);
return TRUE;
}
- info = gnome_vfs_file_info_new ();
-
found_file = FALSE;
while (TRUE) {
- result = gnome_vfs_directory_read_next (handle, info);
- if (result != GNOME_VFS_OK) {
+ GFileInfo *info;
+ const char *name;
+
+ info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+ if (info == NULL) {
break;
}
+ name = g_file_info_get_name (info);
+
/* Skip "." and "..". */
- if (info->name != NULL
- && info->name [0] == '.'
- && (info->name [1] == 0
- || (info->name [1] == '.' && info->name [2] == 0))) {
- gnome_vfs_file_info_clear (info);
+ if (name != NULL
+ && name [0] == '.'
+ && (name [1] == 0
+ || (name [1] == '.' && name [2] == 0))) {
+ g_object_unref (info);
continue;
}
+ g_object_unref (info);
+
found_file = TRUE;
break;
}
- gnome_vfs_directory_close (handle);
- gnome_vfs_file_info_unref (info);
+ g_object_unref (enumerator);
+ g_object_unref (file);
return !found_file;
}
@@ -647,7 +694,7 @@
burn->priv->empty_update_id = 0;
- is_empty = dir_is_empty ("burn:///");
+ is_empty = dir_is_empty (BURN_URI);
DEBUG_PRINT ("Dir is %s\n", is_empty ? "empty" : "not empty");
@@ -674,24 +721,20 @@
}
static void
-burn_monitor_cb (GnomeVFSMonitorHandle *handle,
- const gchar *text_uri,
- const gchar *info_uri,
- GnomeVFSMonitorEventType event_type,
- gpointer data)
+burn_monitor_cb (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ NautilusBurn *burn)
{
- NautilusBurn *burn;
-
- burn = NAUTILUS_BURN (data);
-
DEBUG_PRINT ("Monitor callback type %d: %s: %s\n", event_type, text_uri, info_uri);
/* only queue the action if it has a chance of changing the state */
- if (event_type == GNOME_VFS_MONITOR_EVENT_CREATED) {
+ if (event_type == G_FILE_MONITOR_EVENT_CREATED) {
if (burn->priv->empty) {
queue_update_empty (burn);
}
- } else if (event_type == GNOME_VFS_MONITOR_EVENT_DELETED) {
+ } else if (event_type == G_FILE_MONITOR_EVENT_DELETED) {
if (! burn->priv->empty) {
queue_update_empty (burn);
}
@@ -701,31 +744,34 @@
static gboolean
start_monitor (NautilusBurn *burn)
{
- GnomeVFSResult result;
- char *directory;
-
- directory = g_strdup ("burn:///");
+ GFile *file;
+ GError *error;
- DEBUG_PRINT ("Starting monitor for %s\n", directory);
+ file = g_file_new_for_uri (BURN_URI);
- result = gnome_vfs_monitor_add (&burn->priv->burn_monitor,
- directory,
- GNOME_VFS_MONITOR_DIRECTORY,
- burn_monitor_cb,
- burn);
+ error = NULL;
+ burn->priv->burn_monitor = g_file_monitor_directory (file,
+ G_FILE_MONITOR_NONE,
+ NULL,
+ &error);
+ if (burn->priv->burn_monitor == NULL) {
+ g_warning ("Unable to add monitor: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
- if (result != GNOME_VFS_OK) {
- DEBUG_PRINT ("Could not monitor directory %d: %s\n",
- directory,
- gnome_vfs_result_to_string (result));
+ DEBUG_PRINT ("Starting monitor for %s\n", BURN_URI);
+ g_signal_connect (burn->priv->burn_monitor,
+ "changed",
+ G_CALLBACK (burn_monitor_cb),
+ burn);
- burn->priv->burn_monitor = NULL;
- }
+ burn->priv->empty = dir_is_empty (BURN_URI);
- burn->priv->empty = dir_is_empty (directory);
DEBUG_PRINT ("Init burn extension, empty: %d\n", burn->priv->empty);
- g_free (directory);
+ out:
+ g_object_unref (file);
burn->priv->start_monitor_id = 0;
@@ -769,7 +815,7 @@
}
if (burn->priv->burn_monitor != NULL) {
- gnome_vfs_monitor_cancel (burn->priv->burn_monitor);
+ g_file_monitor_cancel (burn->priv->burn_monitor);
}
if (burn->priv->widget_list != NULL) {
Modified: trunk/src/make-iso.c
==============================================================================
--- trunk/src/make-iso.c (original)
+++ trunk/src/make-iso.c Mon Jan 21 01:17:00 2008
@@ -46,7 +46,6 @@
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include <gtk/gtkmessagedialog.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "nautilus-burn-process.h"
#include "nautilus-burn-drive.h"
@@ -96,23 +95,29 @@
}
static gboolean
-make_iso_get_free_space (const char *filename,
- GnomeVFSFileSize *size)
+make_iso_get_free_space (const char *filename,
+ goffset *size)
{
- GnomeVFSURI *uri;
-
+ GFile *file;
+ GFileInfo *info;
+
*size = 0;
- uri = gnome_vfs_uri_new (filename);
- if (uri == NULL)
- return FALSE;
+ file = g_file_new_for_path (filename);
- if (gnome_vfs_get_volume_free_space (uri, size) != GNOME_VFS_OK) {
- gnome_vfs_uri_unref (uri);
- return FALSE;
+ info = g_file_query_filesystem_info (file,
+ G_FILE_ATTRIBUTE_FILESYSTEM_FREE,
+ NULL, NULL);
+
+ if (info) {
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE)) {
+ *size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+ g_object_unref (info);
+ return FALSE;
+ }
+ g_object_unref (info);
}
- gnome_vfs_uri_unref (uri);
return TRUE;
}
@@ -237,78 +242,54 @@
}
static gboolean
-dir_is_empty (const char *virtual_path)
+dir_is_empty (GFile *file)
{
- GnomeVFSFileInfo *info;
- GnomeVFSDirectoryHandle *handle;
- GnomeVFSResult result;
- char *escaped_path, *uri;
- gboolean found_file;
-
- escaped_path = gnome_vfs_escape_path_string (virtual_path);
- uri = g_strconcat ("burn:///", escaped_path, NULL);
- g_free (escaped_path);
-
- result = gnome_vfs_directory_open (&handle, uri, GNOME_VFS_FILE_INFO_DEFAULT);
- g_free (uri);
+ gboolean found_file;
+ GFileEnumerator *enumerator;
+ GError *error;
+ GFileInfo *info;
+
+ error = NULL;
+ enumerator = g_file_enumerate_children (file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME,
+ 0,
+ NULL, &error);
+
- if (result != GNOME_VFS_OK) {
+ if (enumerator != NULL) {
+ g_error_free (error);
return TRUE;
}
- info = gnome_vfs_file_info_new ();
-
found_file = FALSE;
- while (TRUE) {
- result = gnome_vfs_directory_read_next (handle, info);
- if (result != GNOME_VFS_OK)
- break;
-
- /* Skip "." and "..". */
- if (info->name [0] == '.'
- && (info->name [1] == 0
- || (info->name [1] == '.' && info->name [2] == 0))) {
- gnome_vfs_file_info_clear (info);
- continue;
- }
-
+ info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+ if (info) {
found_file = TRUE;
- break;
+ g_object_unref (info);
}
- gnome_vfs_directory_close (handle);
- gnome_vfs_file_info_unref (info);
-
+ g_object_unref (enumerator); /* Also closes it */
+
return !found_file;
}
static char *
-get_backing_file (const char *virtual_path)
+get_backing_file (GFile *file)
{
- GnomeVFSHandle *handle;
- GnomeVFSResult res;
- char *escaped_path, *uri;
char *mapping;
+ GFileInfo *info;
- escaped_path = gnome_vfs_escape_path_string (virtual_path);
- uri = g_strconcat ("burn:///", escaped_path, NULL);
- g_free (escaped_path);
- /* warning, this can hang on fifos etc */
- res = gnome_vfs_open (&handle,
- uri,
- GNOME_VFS_OPEN_READ);
- g_free (uri);
- if (res == GNOME_VFS_OK) {
- res = gnome_vfs_file_control (handle,
- "mapping:get_mapping",
- &mapping);
- gnome_vfs_close (handle);
- if (res == GNOME_VFS_OK) {
- return mapping;
- }
+ mapping = NULL;
+ info = g_file_query_info (file, "burn::backing-file",
+ 0, NULL, NULL);
+ if (info) {
+ mapping = g_strdup (g_file_info_get_attribute_byte_string (info,
+ "burn::backing-file"));
+ g_object_unref (info);
}
- return NULL;
+
+ return mapping;
}
static gboolean
@@ -363,17 +344,21 @@
/* FIXME: This should probably be an inline */
static gboolean
-file_info_is_allowed (GnomeVFSFileInfo *info)
+file_info_is_allowed (GFileInfo *info)
{
+ GFileType type;
+
g_return_val_if_fail (info != NULL, FALSE);
+ type = g_file_info_get_file_type (info);
+
/* only allow regular,directory,symlink files */
- if (info->type != GNOME_VFS_FILE_TYPE_REGULAR
- && info->type != GNOME_VFS_FILE_TYPE_DIRECTORY
- && info->type != GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK) {
+ if (type != G_FILE_TYPE_REGULAR
+ && type != G_FILE_TYPE_DIRECTORY
+ && type != G_FILE_TYPE_SYMBOLIC_LINK) {
return FALSE;
- } else if (info->type == GNOME_VFS_FILE_TYPE_REGULAR
- && !(info->permissions & GNOME_VFS_PERM_ACCESS_READABLE)) {
+ } else if (type == G_FILE_TYPE_REGULAR
+ && !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) {
return FALSE;
}
@@ -381,14 +366,17 @@
}
static gboolean
-graft_file_visitor (const char *rel_path,
- GnomeVFSFileInfo *info,
+graft_file_visitor (GFile *file,
+ const char *rel_path,
+ GFileInfo *info,
struct graft_state *state,
gboolean *recurse)
{
char *mapping, *path1, *path2;
char *new_copy_dir;
char *copy_path;
+ const char *name;
+ GFileType type;
*recurse = TRUE;
@@ -397,10 +385,12 @@
return TRUE;
}
+ name = g_file_info_get_name (info);
+ type = g_file_info_get_file_type (info);
if (state->copy_to_dir != NULL) {
- if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+ if (type == G_FILE_TYPE_DIRECTORY) {
new_copy_dir = g_build_filename (state->copy_to_dir,
- info->name,
+ name,
NULL);
g_free (state->copy_to_dir);
state->copy_to_dir = new_copy_dir;
@@ -408,8 +398,8 @@
state->remove_files = g_list_prepend (state->remove_files, g_strdup (state->copy_to_dir));
state->copy_depth++;
} else {
- copy_path = g_build_filename (state->copy_to_dir, info->name, NULL);
- mapping = get_backing_file (rel_path);
+ copy_path = g_build_filename (state->copy_to_dir, name, NULL);
+ mapping = get_backing_file (file);
if (mapping != NULL) {
copy_file (mapping, copy_path);
state->remove_files = g_list_prepend (state->remove_files, g_strdup (copy_path));
@@ -418,8 +408,8 @@
return TRUE;
}
- if (info->type != GNOME_VFS_FILE_TYPE_DIRECTORY) {
- mapping = get_backing_file (rel_path);
+ if (type != G_FILE_TYPE_DIRECTORY) {
+ mapping = get_backing_file (file);
if (mapping != NULL) {
path1 = escape_path (rel_path);
path2 = escape_path (mapping);
@@ -430,7 +420,7 @@
g_free (mapping);
}
} else {
- if (dir_is_empty (rel_path)) {
+ if (dir_is_empty (file)) {
path1 = escape_path (rel_path);
path2 = escape_path (state->emptydir);
state->found_file = TRUE;
@@ -462,89 +452,80 @@
}
static void
-create_graft_file (GnomeVFSURI *uri,
+create_graft_file (GFile *file,
const char *prefix,
struct graft_state *state)
{
- GnomeVFSFileInfo *info;
- GnomeVFSDirectoryHandle *handle;
- GnomeVFSResult result;
+ GFile *child;
+ GFileInfo *info;
gboolean stop;
+ GFileEnumerator *enumerator;
- result = gnome_vfs_directory_open_from_uri (&handle,
- uri,
- GNOME_VFS_FILE_INFO_DEFAULT
- | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
- if (result != GNOME_VFS_OK)
+ enumerator = g_file_enumerate_children (file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+ G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
+ 0,
+ NULL, NULL);
+ if (enumerator == NULL) {
return;
-
- info = gnome_vfs_file_info_new ();
+ }
stop = FALSE;
while (! stop) {
char *rel_path;
gboolean recurse;
- result = gnome_vfs_directory_read_next (handle, info);
- if (result != GNOME_VFS_OK) {
+ info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+ if (info == NULL) {
break;
}
- /* Skip "." and "..". */
- if (info->name [0] == '.'
- && (info->name [1] == 0
- || (info->name [1] == '.' && info->name [2] == 0))) {
- gnome_vfs_file_info_clear (info);
- continue;
- }
+ child = g_file_get_child (file, g_file_info_get_name (info));
if (prefix == NULL) {
- rel_path = g_strdup (info->name);
+ rel_path = g_strdup (g_file_info_get_name (info));
} else {
- rel_path = g_strconcat (prefix, info->name, NULL);
+ rel_path = g_strconcat (prefix, g_file_info_get_name (info), NULL);
}
recurse = FALSE;
- stop = ! graft_file_visitor (rel_path, info, state, &recurse);
+ stop = ! graft_file_visitor (child, rel_path, info, state, &recurse);
if (! stop
&& recurse
- && info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
- GnomeVFSURI *new_uri;
+ && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
char *new_prefix;
if (prefix == NULL) {
- new_prefix = g_strconcat (info->name, "/",
+ new_prefix = g_strconcat (g_file_info_get_name (info), "/",
NULL);
} else {
- new_prefix = g_strconcat (prefix, info->name,
+ new_prefix = g_strconcat (prefix, g_file_info_get_name (info),
"/", NULL);
}
- new_uri = gnome_vfs_uri_append_file_name (uri, info->name);
-
state->depth++;
- create_graft_file (new_uri,
+ create_graft_file (child,
new_prefix,
state);
state->depth--;
graft_file_end_dir_visitor (state);
- gnome_vfs_uri_unref (new_uri);
g_free (new_prefix);
}
+ g_object_unref (child);
g_free (rel_path);
- gnome_vfs_file_info_clear (info);
-
+ g_object_unref (info);
+
if (stop) {
break;
}
}
- gnome_vfs_directory_close (handle);
- gnome_vfs_file_info_unref (info);
+ g_object_unref (enumerator);
}
void
@@ -636,7 +617,7 @@
nautilus_burn_iso_graft_new (const char *uri_string)
{
NautilusBurnIsoGraft *graft;
- GnomeVFSURI *uri;
+ GFile *file;
struct graft_state state = { NULL };
int res;
@@ -658,9 +639,9 @@
state.found_file = FALSE;
state.graft_list = g_ptr_array_new ();
- uri = gnome_vfs_uri_new (uri_string);
- create_graft_file (uri, NULL, &state);
- gnome_vfs_uri_unref (uri);
+ file = g_file_new_for_uri (uri_string);
+ create_graft_file (file, NULL, &state);
+ g_object_unref (file);
/* terminate the array */
g_ptr_array_add (state.graft_list, NULL);
@@ -1203,7 +1184,7 @@
{
GPtrArray *argv;
guint64 iso_size;
- GnomeVFSFileSize size;
+ goffset size;
gboolean use_joliet;
int result = NAUTILUS_BURN_ISO_RESULT_ERROR;
char *dirname;
@@ -1246,7 +1227,7 @@
g_free (dirname);
- if (iso_size > size) {
+ if (iso_size > (guint64)size) {
char *message;
message = get_image_space_error_message (iso_size,
@@ -1475,7 +1456,7 @@
GError *sub_error;
char *dirname;
guint64 iso_size;
- GnomeVFSFileSize size;
+ goffset size;
NautilusBurnProcessLineFunc out_watch_func = NULL;
NautilusBurnProcessLineFunc err_watch_func = NULL;
int result;
@@ -1524,7 +1505,7 @@
g_free (dirname);
- if (iso_size > size) {
+ if (iso_size > (guint64)size) {
char *message;
message = get_image_space_error_message (iso_size,
Modified: trunk/src/nautilus-cd-burner.c
==============================================================================
--- trunk/src/nautilus-cd-burner.c (original)
+++ trunk/src/nautilus-cd-burner.c Mon Jan 21 01:17:00 2008
@@ -36,7 +36,6 @@
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libgnome/gnome-help.h>
#include <libgnomeui/gnome-ui-init.h>
@@ -260,17 +259,12 @@
static char *
expand_path_input (const char *input)
{
- char *uri;
+ GFile *file;
char *path;
- uri = gnome_vfs_make_uri_from_input_with_dirs (input, GNOME_VFS_MAKE_URI_DIR_CURRENT);
- if (uri == NULL) {
- g_warning ("Could not parse filename");
- return NULL;
- }
-
- path = gnome_vfs_get_local_path_from_uri (uri);
- g_free (uri);
+ file = g_file_new_for_commandline_arg (input);
+ path = g_file_get_path (file);
+ g_object_unref (file);
if (path == NULL) {
g_warning ("Only local files are supported at this time");
@@ -317,7 +311,6 @@
GNOME_PARAM_APP_DATADIR, SHAREDIR,
GNOME_PARAM_NONE);
- gnome_vfs_init ();
nautilus_burn_init ();
dialog = ncb_selection_dialog_new ();
@@ -382,7 +375,6 @@
out:
g_object_unref (program);
nautilus_burn_shutdown ();
- gnome_vfs_shutdown ();
return 0;
}
Modified: trunk/src/ncb-rename-dialog.c
==============================================================================
--- trunk/src/ncb-rename-dialog.c (original)
+++ trunk/src/ncb-rename-dialog.c Mon Jan 21 01:17:00 2008
@@ -32,7 +32,6 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libgnomeui/libgnomeui.h>
#include "ncb-rename-dialog.h"
@@ -65,7 +64,6 @@
/* List of NcbRenameDialogInvalidFile invalid filenames */
GSList *invalid_files;
- /* Root path, used by gnome_vfs_directory_visit() */
char *root_path;
};
@@ -109,9 +107,12 @@
char *source_uri = NULL;
char *dest_uri;
char *path_uri;
+ GFile *source_file;
+ GFile *dest_file;
char *shortname = NULL;
NcbRenameDialog *dialog;
- GnomeVFSResult res;
+ gboolean res;
+ GError *error;
dialog = (NcbRenameDialog *) data;
@@ -125,15 +126,31 @@
g_free (shortname);
g_free (path_uri);
- res = gnome_vfs_move (source_uri, dest_uri, FALSE);
- if (res != GNOME_VFS_OK) {
- g_warning ("Cannot move `%s' to `%s': %s", source_uri, dest_uri,
- gnome_vfs_result_to_string (res));
+ source_file = g_file_new_for_uri (source_uri);
+ dest_file = g_file_new_for_uri (dest_uri);
+
+ error = NULL;
+ res = g_file_move (source_file,
+ dest_file,
+ G_FILE_COPY_NONE,
+ NULL,
+ NULL,
+ NULL,
+ &error);
+ if (! res) {
+ g_warning ("Cannot move `%s' to `%s': %s",
+ source_uri,
+ dest_uri,
+ error->message);
+ g_error_free (error);
}
g_free (source_uri);
g_free (dest_uri);
+ g_object_unref (source_file);
+ g_object_unref (dest_file);
+
/* Done, but call me again for other rows.*/
return FALSE;
}
@@ -295,7 +312,9 @@
if (gtk_tree_model_get_iter (model, &iter, path)) {
char *name = NULL;
- GnomeVFSResult res;
+ gboolean res;
+ GFile *file;
+ GError *error;
gtk_tree_model_get (model,
&iter,
@@ -303,14 +322,19 @@
&name,
-1);
- res = gnome_vfs_unlink (name);
- if (res == GNOME_VFS_OK) {
+ file = g_file_new_for_uri (name);
+ error = NULL;
+ res = g_file_delete (file, NULL, &error);
+ if (res) {
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
} else {
- g_warning ("Cannot remove %s (%s)", name,
- gnome_vfs_result_to_string (res));
+ g_warning ("Cannot remove %s (%s)",
+ name,
+ error->message);
+ g_error_free (error);
}
g_free (name);
+ g_object_unref (file);
}
}
g_list_foreach (row_references, (GFunc)gtk_tree_row_reference_free, NULL);
@@ -564,43 +588,6 @@
return g_string_free (string, FALSE);
}
-/**
- * check_filename_cb
- *
- * Callback for gnome_vfs_directory_visit().
- * Checks each file and adds it to the @dialog->priv->invalid_files list
- * if the filename is not encoded properly.
- *
- * Returns: %TRUE
- **/
-static gboolean
-check_filename_cb (const char *rel_path,
- GnomeVFSFileInfo *info,
- gboolean will_loop,
- gpointer data,
- gboolean *recurse)
-{
- NcbRenameDialog *dialog;
-
- dialog = (NcbRenameDialog *) data;
-
- if (! g_utf8_validate (info->name, -1, NULL)) {
- NcbRenameDialogInvalidFile *invalid_file;
-
- invalid_file = g_new0 (NcbRenameDialogInvalidFile, 1);
- invalid_file->filename = g_strdup_printf ("%s/%s",
- dialog->priv->root_path, rel_path);
- invalid_file->mime_type = g_strdup (info->mime_type);
-
- dialog->priv->invalid_files = g_slist_prepend (dialog->priv->invalid_files,
- invalid_file);
- }
-
- *recurse = (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY && ! will_loop);
-
- /* Call me again. */
- return TRUE;
-}
/**
* pixmap_from_mime_type
@@ -703,6 +690,104 @@
dialog->priv->invalid_files = NULL;
}
+static gboolean
+check_filename_visitor (GFile *file,
+ const char *rel_path,
+ GFileInfo *info,
+ NcbRenameDialog *dialog,
+ gboolean *recurse)
+{
+
+ if (! g_utf8_validate (g_file_info_get_name (info), -1, NULL)) {
+ NcbRenameDialogInvalidFile *invalid_file;
+
+ invalid_file = g_new0 (NcbRenameDialogInvalidFile, 1);
+ invalid_file->filename = g_strdup_printf ("%s/%s",
+ dialog->priv->root_path,
+ rel_path);
+ invalid_file->mime_type = g_strdup (g_file_info_get_content_type (info));
+
+ dialog->priv->invalid_files = g_slist_prepend (dialog->priv->invalid_files,
+ invalid_file);
+ }
+
+ *recurse = (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
+
+ /* Call me again. */
+ return TRUE;
+}
+
+
+static gboolean
+set_invalid_filenames_internal (GFile *file,
+ const char *prefix,
+ NcbRenameDialog *dialog)
+{
+ GFileEnumerator *enumerator;
+ gboolean stop;
+
+ enumerator = g_file_enumerate_children (file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
+ 0,
+ NULL, NULL);
+ if (enumerator == NULL) {
+ return FALSE;
+ }
+
+ stop = FALSE;
+ while (! stop) {
+ GFile *child;
+ GFileInfo *info;
+ gboolean recurse;
+ char *rel_path;
+
+ info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+ if (info == NULL) {
+ break;
+ }
+
+ child = g_file_get_child (file, g_file_info_get_name (info));
+
+ if (prefix == NULL) {
+ rel_path = g_strdup (g_file_info_get_name (info));
+ } else {
+ rel_path = g_strconcat (prefix, g_file_info_get_name (info), NULL);
+ }
+
+ stop = ! check_filename_visitor (child, rel_path, info, dialog, &recurse);
+
+ if (! stop
+ && recurse
+ && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ char *new_prefix;
+ if (prefix == NULL) {
+ new_prefix = g_strconcat (g_file_info_get_name (info),
+ "/",
+ NULL);
+ } else {
+ new_prefix = g_strconcat (prefix,
+ g_file_info_get_name (info),
+ "/",
+ NULL);
+ }
+
+ set_invalid_filenames_internal (child, new_prefix, dialog);
+
+ g_free (new_prefix);
+
+ }
+ g_object_unref (child);
+ g_free (rel_path);
+ g_object_unref (info);
+ }
+ g_object_unref (enumerator);
+
+ return TRUE;
+}
+
/**
* ncb_rename_dialog_set_invalid_filenames
* @dialog: The #NcbRenameDialog
@@ -718,8 +803,9 @@
ncb_rename_dialog_set_invalid_filenames (NcbRenameDialog *dialog,
const char *uri)
{
- GnomeVFSResult res;
- gboolean found;
+ GFile *file;
+ gboolean found;
+ gboolean res;
g_return_val_if_fail (dialog != NULL, FALSE);
g_return_val_if_fail (NCB_IS_RENAME_DIALOG (dialog), FALSE);
@@ -729,15 +815,14 @@
dialog->priv->root_path = g_strdup (uri);
- res = gnome_vfs_directory_visit (uri,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE,
- GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
- check_filename_cb,
- dialog);
+ file = g_file_new_for_uri (uri);
+ res = set_invalid_filenames_internal (file, NULL, dialog);
+ g_object_unref (file);
+
g_free (dialog->priv->root_path);
- if (res != GNOME_VFS_OK) {
- g_warning ("gnome_vfs_directory_visit () failed for %s",
+ if (! res) {
+ g_warning ("detection of invalid filenames failed for %s",
uri);
return FALSE;
Modified: trunk/src/ncb-selection.c
==============================================================================
--- trunk/src/ncb-selection.c (original)
+++ trunk/src/ncb-selection.c Mon Jan 21 01:17:00 2008
@@ -30,7 +30,6 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <gconf/gconf-client.h>
#include "nautilus-burn-drive.h"
@@ -128,31 +127,22 @@
}
static char *
-get_backing_file (const char *virtual_path)
+get_backing_file (GFile *file)
{
- GnomeVFSHandle *handle;
- GnomeVFSResult res;
- char *escaped_path, *uri;
- char *mapping;
-
- escaped_path = gnome_vfs_escape_path_string (virtual_path);
- uri = g_strconcat (BURN_URI, escaped_path, NULL);
- g_free (escaped_path);
- /* warning, this can hang on fifos etc */
- res = gnome_vfs_open (&handle,
- uri,
- GNOME_VFS_OPEN_READ);
- g_free (uri);
- if (res == GNOME_VFS_OK) {
- res = gnome_vfs_file_control (handle,
- "mapping:get_mapping",
- &mapping);
- gnome_vfs_close (handle);
- if (res == GNOME_VFS_OK) {
- return mapping;
- }
+ char *mapping;
+ GFileInfo *info;
+
+ mapping = NULL;
+ info = g_file_query_info (file,
+ "burn::backing-file",
+ 0, NULL, NULL);
+ if (info) {
+ mapping = g_strdup (g_file_info_get_attribute_byte_string (info,
+ "burn::backing-file"));
+ g_object_unref (info);
}
- return NULL;
+
+ return mapping;
}
typedef struct
@@ -160,39 +150,50 @@
GList *unreadable_paths;
GList *image_paths;
gboolean only_images;
- GnomeVFSFileSize size;
+ goffset size;
} EstimateSizeCallbackData;
/* FIXME: This should probably be an inline */
static gboolean
-file_info_is_image (GnomeVFSFileInfo *info)
+file_info_is_image (GFileInfo *info)
{
- gboolean is_image;
+ gboolean is_image;
+ const char *content_type;
g_return_val_if_fail (info != NULL, FALSE);
- if (!info->mime_type) {
+ if (! g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)) {
return FALSE;
}
- is_image = (strcmp (info->mime_type, "application/x-cd-image") == 0);
+ content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
+
+ if (content_type == NULL) {
+ return FALSE;
+ }
+
+ is_image = (strcmp (content_type, "application/x-cd-image") == 0);
return is_image;
}
/* FIXME: This should probably be an inline */
static gboolean
-file_info_is_allowed (GnomeVFSFileInfo *info)
+file_info_is_allowed (GFileInfo *info)
{
+ GFileType type;
+
g_return_val_if_fail (info != NULL, FALSE);
+ type = g_file_info_get_file_type (info);
+
/* only allow regular,directory,symlink files */
- if (info->type != GNOME_VFS_FILE_TYPE_REGULAR
- && info->type != GNOME_VFS_FILE_TYPE_DIRECTORY
- && info->type != GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK) {
+ if (type != G_FILE_TYPE_REGULAR
+ && type != G_FILE_TYPE_DIRECTORY
+ && type != G_FILE_TYPE_SYMBOLIC_LINK) {
return FALSE;
- } else if (info->type == GNOME_VFS_FILE_TYPE_REGULAR
- && !(info->permissions & GNOME_VFS_PERM_ACCESS_READABLE)) {
+ } else if (type == G_FILE_TYPE_REGULAR
+ && !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) {
return FALSE;
}
@@ -200,26 +201,25 @@
}
static gboolean
-estimate_size_callback (const char *rel_path,
- GnomeVFSFileInfo *info,
- gboolean recursing_will_loop,
- gpointer data,
- gboolean *recurse)
+estimate_size_visitor (GFile *file,
+ const char *rel_path,
+ GFileInfo *info,
+ EstimateSizeCallbackData *data,
+ gboolean *recurse)
{
- EstimateSizeCallbackData *cb_data = data;
if (file_info_is_image (info)) {
- cb_data->image_paths = g_list_append (cb_data->image_paths, get_backing_file (rel_path));
+ data->image_paths = g_list_append (data->image_paths, get_backing_file (file));
} else {
- cb_data->only_images = FALSE;
+ data->only_images = FALSE;
}
if (file_info_is_allowed (info)) {
- if (info->type != GNOME_VFS_FILE_TYPE_DIRECTORY) {
- cb_data->size += info->size;
+ if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY) {
+ data->size += g_file_info_get_size (info);
}
} else {
- cb_data->unreadable_paths = g_list_append (cb_data->unreadable_paths, g_strdup (rel_path));
+ data->unreadable_paths = g_list_append (data->unreadable_paths, g_strdup (rel_path));
}
*recurse = TRUE;
@@ -227,36 +227,96 @@
return TRUE;
}
-static GnomeVFSFileSize
+static gboolean
+estimate_size_internal (GFile *file,
+ const char *prefix,
+ EstimateSizeCallbackData *data)
+{
+ GFileEnumerator *enumerator;
+ gboolean stop;
+
+ enumerator = g_file_enumerate_children (file,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_SIZE ","
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
+ 0,
+ NULL, NULL);
+ if (enumerator == NULL) {
+ return FALSE;
+ }
+
+ stop = FALSE;
+ while (! stop) {
+ GFile *child;
+ GFileInfo *info;
+ gboolean recurse;
+ char *rel_path;
+
+ info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+ if (info == NULL) {
+ break;
+ }
+
+ child = g_file_get_child (file, g_file_info_get_name (info));
+
+ if (prefix == NULL) {
+ rel_path = g_strdup (g_file_info_get_name (info));
+ } else {
+ rel_path = g_strconcat (prefix, g_file_info_get_name (info), NULL);
+ }
+ stop = ! estimate_size_visitor (child, rel_path, info, data, &recurse);
+
+ if (! stop
+ && recurse
+ && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ char *new_prefix;
+ if (prefix == NULL) {
+ new_prefix = g_strconcat (g_file_info_get_name (info),
+ "/",
+ NULL);
+ } else {
+ new_prefix = g_strconcat (prefix,
+ g_file_info_get_name (info),
+ "/",
+ NULL);
+ }
+
+ estimate_size_internal (child, new_prefix, data);
+
+ g_free (new_prefix);
+
+ }
+ g_object_unref (child);
+ g_free (rel_path);
+ g_object_unref (info);
+ }
+ g_object_unref (enumerator);
+
+ return TRUE;
+}
+
+static goffset
estimate_size (const char *uri,
GList **unreadable_paths,
GList **image_paths,
gboolean *only_images)
{
- GnomeVFSFileSize size;
+ GFile *file;
EstimateSizeCallbackData *data;
+ goffset size;
+ gboolean res;
data = g_new0 (EstimateSizeCallbackData, 1);
data->only_images = TRUE;
- gnome_vfs_directory_visit (uri,
- GNOME_VFS_FILE_INFO_DEFAULT
- | GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS
- | GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE,
- GNOME_VFS_DIRECTORY_VISIT_DEFAULT,
- (GnomeVFSDirectoryVisitFunc) estimate_size_callback,
- data);
+ file = g_file_new_for_uri (uri);
- if (data->size == 0) {
- GList *list;
+ res = estimate_size_internal (file, NULL, data);
- if (gnome_vfs_directory_list_load (&list, uri, GNOME_VFS_FILE_INFO_FIELDS_NONE) == GNOME_VFS_OK) {
- if (list != NULL) {
- data->size = 1;
- gnome_vfs_file_info_list_free (list);
- }
- }
+ if (data->size == 0) {
+ /* FIXME: if files exist then set to one */
}
if (data->unreadable_paths) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]