summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@fedoraproject.org>2008-01-26 03:10:06 +0000
committerMatthias Clasen <mclasen@fedoraproject.org>2008-01-26 03:10:06 +0000
commitbed896b3793a4a83e97c7ad96499e66cbe007f92 (patch)
tree9f89830a2e67f76aad343d6beb6c293d663707ee
parentbf71ec38907e622f669bf4bf0a116576297b8066 (diff)
downloadgnome-applets-bed896b3793a4a83e97c7ad96499e66cbe007f92.tar.gz
gnome-applets-bed896b3793a4a83e97c7ad96499e66cbe007f92.tar.xz
gnome-applets-bed896b3793a4a83e97c7ad96499e66cbe007f92.zip
gvfs porting
-rw-r--r--gnome-applets.spec11
-rw-r--r--gweather-gnome-vfs.patch38
-rw-r--r--trash-gio.patch906
3 files changed, 954 insertions, 1 deletions
diff --git a/gnome-applets.spec b/gnome-applets.spec
index 1de7d0d..b3ccdc1 100644
--- a/gnome-applets.spec
+++ b/gnome-applets.spec
@@ -35,7 +35,7 @@
Summary: Small applications for the GNOME panel
Name: gnome-applets
Version: 2.21.4
-Release: 3%{?dist}
+Release: 4%{?dist}
Epoch: 1
License: GPLv2+ and GFDL+
Group: User Interface/Desktops
@@ -77,6 +77,9 @@ Patch41: locations.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=382100
Patch42: vertical-invest.patch
+Patch43: trash-gio.patch
+Patch44: gweather-gnome-vfs.patch
+
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: gtk2-devel >= %{gtk2_version}
BuildRequires: libgnomeui-devel >= %{libgnomeui_version}
@@ -168,6 +171,8 @@ small utilities for the GNOME panel.
%patch40 -p1 -b .battstat-null
%patch41 -p1 -b .locations
%patch42 -p1 -b .vertical-invest
+%patch43 -p1 -b .trash-gio
+%patch44 -p1 -b .gweather-gnome-vfs
cp gswitchit/gswitchit-applet.png gswitchit/gswitchit-properties-capplet.png
@@ -339,6 +344,10 @@ fi
%{_sysconfdir}/security/console.apps/*
%changelog
+* Fri Jan 25 2008 Matthias Clasen <mclasen@redhat.com> - 1:2.21.4-4
+- Port trash applet to gvfs
+- Remove gnome-vfs dependency in gweather
+
* Mon Jan 21 2008 Matthias Clasen <mclasen@redhat.com> - 1:2.21.4-3
- Fix the invest applet on vertical panels
diff --git a/gweather-gnome-vfs.patch b/gweather-gnome-vfs.patch
new file mode 100644
index 0000000..c19d52c
--- /dev/null
+++ b/gweather-gnome-vfs.patch
@@ -0,0 +1,38 @@
+diff -up gnome-applets-2.21.4/Makefile.am.gweather gnome-applets-2.21.4/Makefile.am
+--- gnome-applets-2.21.4/Makefile.am.gweather 2008-01-22 23:54:12.000000000 -0500
++++ gnome-applets-2.21.4/Makefile.am 2008-01-22 23:54:32.000000000 -0500
+@@ -7,7 +7,6 @@ endif
+
+ vfs_applets = \
+ drivemount \
+- gweather \
+ trashapplet
+ if BUILD_GNOME_VFS_APPLETS
+ vfs_SUBDIRS = $(vfs_applets)
+@@ -48,6 +47,7 @@ endif
+ always_built_SUBDIRS = \
+ charpick \
+ geyes \
++ gweather \
+ mini-commander \
+ gkb-new \
+ stickynotes \
+diff -up gnome-applets-2.21.4/gweather/Makefile.am.gweather gnome-applets-2.21.4/gweather/Makefile.am
+--- gnome-applets-2.21.4/gweather/Makefile.am.gweather 2008-01-22 23:54:41.000000000 -0500
++++ gnome-applets-2.21.4/gweather/Makefile.am 2008-01-22 23:54:59.000000000 -0500
+@@ -7,7 +7,6 @@ INCLUDES = \
+ -I$(top_srcdir) \
+ -DGTK_ENABLE_BROKEN \
+ $(GNOME_APPLETS_CFLAGS) \
+- $(GNOME_VFS_APPLETS_CFLAGS) \
+ $(LIBNOTIFY_CFLAGS) \
+ $(XML2_CFLAGS) \
+ $(LIBGWEATHER_CFLAGS) \
+@@ -27,7 +26,6 @@ gweather_applet_2_SOURCES = \
+ gweather_applet_2_LDADD = \
+ $(LIBNOTIFY_LIBS) \
+ $(GNOME_APPLETS_LIBS) \
+- $(GNOME_VFS_APPLETS_LIBS) \
+ $(XML2_LIBS) \
+ $(LIBGWEATHER_LIBS)
+
diff --git a/trash-gio.patch b/trash-gio.patch
new file mode 100644
index 0000000..2c9808d
--- /dev/null
+++ b/trash-gio.patch
@@ -0,0 +1,906 @@
+diff -up gnome-applets-2.21.4/trashapplet/src/trash-monitor.c.giotrash gnome-applets-2.21.4/trashapplet/src/trash-monitor.c
+--- gnome-applets-2.21.4/trashapplet/src/trash-monitor.c.giotrash 2007-11-27 03:48:48.000000000 -0500
++++ gnome-applets-2.21.4/trashapplet/src/trash-monitor.c 2008-01-22 23:14:52.000000000 -0500
+@@ -22,14 +22,12 @@
+
+ #include "trash-monitor.h"
+ #include <string.h>
+-#include <libgnomevfs/gnome-vfs.h>
++#include <gio/gio.h>
+
+ struct _TrashMonitor {
+ GObject parent;
+-
+- GHashTable *volumes;
++ GFileMonitor *file_monitor;
+ gint total_item_count;
+- gint notify_id;
+ };
+
+ struct _TrashMonitorClass {
+@@ -38,16 +36,6 @@ struct _TrashMonitorClass {
+ void (* item_count_changed) (TrashMonitor *monitor);
+ };
+
+-typedef struct {
+- TrashMonitor *monitor;
+- GnomeVFSVolume *volume;
+- gchar *trash_uri;
+- GnomeVFSAsyncHandle *find_handle;
+- GnomeVFSMonitorHandle *trash_change_monitor;
+- gint item_count;
+-} VolumeInfo;
+-
+-
+ static void trash_monitor_init (TrashMonitor *monitor);
+ static void trash_monitor_class_init (TrashMonitorClass *class);
+
+@@ -59,21 +47,14 @@ static GObjectClass *parent_class;
+ static guint signals[LAST_SIGNAL];
+
+
+-static void volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
+- GnomeVFSVolume *volume,
+- TrashMonitor *monitor);
+-static void volume_unmount_started_callback (GnomeVFSVolumeMonitor *volume_monitor,
+- GnomeVFSVolume *volume,
+- TrashMonitor *monitor);
+-
+-static void add_volume (TrashMonitor *monitor, GnomeVFSVolume *volume);
+-static void remove_volume (TrashMonitor *monitor, GnomeVFSVolume *volume);
+-
+-static void trash_changed_queue_notify (TrashMonitor *monitor);
++static void file_changed (GFileMonitor *monitor,
++ GFile *child,
++ GFile *other_child,
++ GFileMonitorEvent event_type,
++ gpointer user_data);
+
+ G_DEFINE_TYPE (TrashMonitor, trash_monitor, G_TYPE_OBJECT)
+
+-
+ static void
+ trash_monitor_class_init (TrashMonitorClass *class)
+ {
+@@ -90,32 +71,62 @@ trash_monitor_class_init (TrashMonitorCl
+ }
+
+ static void
+-trash_monitor_init (TrashMonitor *monitor)
++count_children (TrashMonitor *monitor,
++ GFile *file)
+ {
+- GnomeVFSVolumeMonitor *volume_monitor;
+- GList *volumes, *tmp;
++ GFileEnumerator *enumerator;
++ GError *error = NULL;
++ GFileInfo *info;
++ gint count;
+
+- monitor->volumes = g_hash_table_new (NULL, NULL);
+ monitor->total_item_count = 0;
+- monitor->notify_id = 0;
+
+- volume_monitor = gnome_vfs_get_volume_monitor ();
++ enumerator = g_file_enumerate_children (file,
++ G_FILE_ATTRIBUTE_STANDARD_TYPE,
++ G_FILE_QUERY_INFO_NONE,
++ NULL, &error);
++
++ count = 0;
++
++ if (error)
++ {
++ g_print ("failed to count trash content: %s\n", error->message);
++ return;
++ }
+
+- g_signal_connect_object (volume_monitor, "volume_mounted",
+- G_CALLBACK (volume_mounted_callback),
+- monitor, 0);
+- g_signal_connect_object (volume_monitor, "volume_pre_unmount",
+- G_CALLBACK (volume_unmount_started_callback),
+- monitor, 0);
+-
+- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
+- for (tmp = volumes; tmp != NULL; tmp = tmp->next) {
+- GnomeVFSVolume *volume = tmp->data;
++ while (1)
++ {
++ info = g_file_enumerator_next_file (enumerator, NULL, &error);
++ if (error)
++ {
++ g_print ("failed to count trash content: %s\n", error->message);
++ return;
++ }
++ if (!info)
++ break;
+
+- add_volume (monitor, volume);
+- gnome_vfs_volume_unref (volume);
+- }
+- g_list_free (volumes);
++ g_object_unref (info);
++ count++;
++ }
++
++ monitor->total_item_count = count;
++ g_object_unref (enumerator);
++}
++
++static void
++trash_monitor_init (TrashMonitor *monitor)
++{
++ GFile *location;
++
++ monitor->total_item_count = 0;
++
++ location = g_file_new_for_uri ("trash:///");
++ count_children (monitor, location);
++ monitor->file_monitor = g_file_monitor_directory (location, 0, NULL, NULL);
++ g_object_unref (location);
++
++ g_signal_connect_object (monitor->file_monitor, "changed",
++ G_CALLBACK (file_changed), monitor, 0);
+ }
+
+ TrashMonitor *
+@@ -130,293 +141,157 @@ trash_monitor_get (void)
+ }
+
+ static void
+-volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
+- GnomeVFSVolume *volume,
+- TrashMonitor *monitor)
++file_changed (GFileMonitor *file_monitor,
++ GFile *child,
++ GFile *other_file,
++ GFileMonitorEvent event_type,
++ gpointer user_data)
+ {
+- add_volume (monitor, volume);
+-}
+-
+-static void
+-volume_unmount_started_callback (GnomeVFSVolumeMonitor *volume_monitor,
+- GnomeVFSVolume *volume,
+- TrashMonitor *monitor)
+-{
+- remove_volume (monitor, volume);
+-}
+-
+-static void
+-trash_dir_changed (GnomeVFSMonitorHandle *handle,
+- const gchar *monitor_uri,
+- const gchar *info_uri,
+- GnomeVFSMonitorEventType type,
+- gpointer user_data)
+-{
+- VolumeInfo *volinfo;
+- GnomeVFSResult res;
+- GList *dirlist, *tmp;
+- gint count = 0;
+-
+- volinfo = user_data;
+-
+- res = gnome_vfs_directory_list_load (&dirlist, volinfo->trash_uri,
+- GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+- if (res != GNOME_VFS_OK) {
+- g_warning("GNOME VFS Error: %s", gnome_vfs_result_to_string (res));
+- return;
+- }
+-
+- for (tmp = dirlist; tmp != NULL; tmp = tmp->next) {
+- GnomeVFSFileInfo *info = tmp->data;
+-
+- if (!strcmp (info->name, ".") || !strcmp (info->name, ".."))
+- continue;
+- count++;
+- }
+- gnome_vfs_file_info_list_free (dirlist);
+-
+- if (count != volinfo->item_count) {
+- volinfo->item_count = count;
+- trash_changed_queue_notify (volinfo->monitor);
+- }
+-}
+-
+-static void
+-find_directory_callback (GnomeVFSAsyncHandle *handle,
+- GList *results,
+- gpointer callback_data)
+-{
+- VolumeInfo *volinfo;
+- GnomeVFSFindDirectoryResult *result;
+- GnomeVFSResult res;
+-
+- volinfo = callback_data;
+-
+- /* we are done finding the volume */
+- volinfo->find_handle = NULL;
+-
+- /* If we can't find the trash, ignore it silently. */
+- result = results->data;
+- if (result->result != GNOME_VFS_OK)
+- return;
++ TrashMonitor *monitor;
+
+- volinfo->trash_uri = gnome_vfs_uri_to_string (result->uri,
+- GNOME_VFS_URI_HIDE_NONE);
+- /* g_message ("found trash dir: %s", volinfo->trash_uri); */
+-
+- /* simulate a change to update the directory count */
+- trash_dir_changed (NULL, NULL, NULL, GNOME_VFS_MONITOR_EVENT_CHANGED,
+- volinfo);
+-
+- res = gnome_vfs_monitor_add (&volinfo->trash_change_monitor,
+- volinfo->trash_uri, GNOME_VFS_MONITOR_DIRECTORY,
+- trash_dir_changed,
+- volinfo);
+-
+- if (res != GNOME_VFS_OK) {
+- g_warning("GNOME VFS Error: %s", gnome_vfs_result_to_string (res));
+- volinfo->trash_change_monitor = NULL;
+- }
+-}
++ monitor = TRASH_MONITOR (user_data);
+
+-static gboolean
+-get_trash_volume (TrashMonitor *monitor,
+- GnomeVFSVolume *volume,
+- VolumeInfo **volinfo,
+- GnomeVFSURI **mount_uri)
+-{
+- char *uri_str;
+-
+- *volinfo = g_hash_table_lookup (monitor->volumes, volume);
+-
+- if (*volinfo != NULL && (*volinfo)->trash_uri != NULL)
+- return FALSE;
+-
+- if (!gnome_vfs_volume_handles_trash (volume))
+- return FALSE;
+-
+- uri_str = gnome_vfs_volume_get_activation_uri (volume);
+- *mount_uri = gnome_vfs_uri_new (uri_str);
+- g_free (uri_str);
+-
+- if (*volinfo == NULL) {
+- *volinfo = g_new0 (VolumeInfo, 1);
+- (*volinfo)->monitor = monitor;
+- (*volinfo)->volume = gnome_vfs_volume_ref (volume);
+- g_hash_table_insert (monitor->volumes, volume, *volinfo);
+- }
+-
+- return TRUE;
++ switch (event_type)
++ {
++ case G_FILE_MONITOR_EVENT_DELETED:
++ monitor->total_item_count--;
++ g_signal_emit (monitor, signals[ITEM_COUNT_CHANGED], 0);
++ break;
++ case G_FILE_MONITOR_EVENT_CREATED:
++ monitor->total_item_count++;
++ g_signal_emit (monitor, signals[ITEM_COUNT_CHANGED], 0);
++ break;
++ default: ;
++ }
+ }
+
+-static void
+-add_volume (TrashMonitor *monitor, GnomeVFSVolume *volume)
++typedef struct _EmptyTrashJob EmptyTrashJob;
++struct _EmptyTrashJob
+ {
+- VolumeInfo *volinfo;
+- GnomeVFSURI *mount_uri;
+- GList vfs_uri_as_list;
++ GCancellable *cancellable;
++ GList *trash_dirs;
++ gint ref_count;
++};
+
+- if (!get_trash_volume (monitor, volume, &volinfo, &mount_uri))
+- return;
++static EmptyTrashJob *
++empty_trash_job_new (void)
++{
++ EmptyTrashJob *job;
+
+- if (volinfo->find_handle) {
+- /* already searchinf for trash */
+- gnome_vfs_uri_unref (mount_uri);
+- return;
+- }
++ job = g_new0 (EmptyTrashJob, 1);
++ job->ref_count = 1;
+
+-
+- vfs_uri_as_list.data = mount_uri;
+- vfs_uri_as_list.next = NULL;
+- vfs_uri_as_list.prev = NULL;
+-
+- gnome_vfs_async_find_directory (&volinfo->find_handle, &vfs_uri_as_list,
+- GNOME_VFS_DIRECTORY_KIND_TRASH,
+- FALSE, TRUE, 0777,
+- GNOME_VFS_PRIORITY_DEFAULT,
+- find_directory_callback, volinfo);
+- gnome_vfs_uri_unref (mount_uri);
++ return job;
+ }
+
+ static void
+-remove_volume (TrashMonitor *monitor, GnomeVFSVolume *volume)
++empty_trash_job_ref (EmptyTrashJob *job)
+ {
+- VolumeInfo *volinfo;
+-
+- volinfo = g_hash_table_lookup (monitor->volumes, volume);
+- if (volinfo != NULL) {
+- g_hash_table_remove (monitor->volumes, volume);
+-
+- /* g_message ("removing volume %s", volinfo->trash_uri); */
+- if (volinfo->find_handle != NULL)
+- gnome_vfs_async_cancel (volinfo->find_handle);
+- if (volinfo->trash_change_monitor != NULL)
+- gnome_vfs_monitor_cancel (volinfo->trash_change_monitor);
+-
+- if (volinfo->trash_uri)
+- g_free (volinfo->trash_uri);
+-
+- /* if this volume contained some trash, then notify that the trash
+- * state has changed */
+- if (volinfo->item_count != 0)
+- trash_changed_queue_notify (monitor);
+-
+- gnome_vfs_volume_unref (volinfo->volume);
+- g_free (volinfo);
+- }
++ job->ref_count++;
+ }
+
+-/* --- */
+-
+ static void
+-readd_volumes (gpointer key, gpointer value, gpointer user_data)
++empty_trash_job_unref (EmptyTrashJob *job)
+ {
+- TrashMonitor *monitor = user_data;
+- GnomeVFSVolume *volume;
++ job->ref_count--;
++ if (job->ref_count == 0)
++ {
++ g_list_foreach (job->trash_dirs, (GFunc)g_object_unref, NULL);
++ g_list_free (job->trash_dirs);
+
+- volume = key;
+- add_volume (monitor, volume);
+-}
+-void
+-trash_monitor_recheck_trash_dirs (TrashMonitor *monitor)
+-{
+- /* call add_volume() on each volume, to add trash dirs where missing */
+- g_hash_table_foreach (monitor->volumes, readd_volumes, monitor);
++ g_object_unref (job->cancellable);
++ g_free (job);
++ }
+ }
+
+-/* --- */
+-
+-void
+-trash_monitor_empty_trash (TrashMonitor *monitor,
+- GnomeVFSAsyncHandle **handle,
+- GnomeVFSAsyncXferProgressCallback func,
+- gpointer user_data)
+-{
+- GList *trash_dirs = NULL, *volumes, *tmp;
+- GnomeVFSVolume *volume;
+- GnomeVFSURI *mount_uri, *trash_uri;
+- gchar *uri_str;
+-
+- /* collect the trash directories */
+- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
+- for (tmp = volumes; tmp != NULL; tmp = tmp->next) {
+- volume = tmp->data;
+- if (gnome_vfs_volume_handles_trash (volume)) {
+- /* get the mount point for this volume */
+- uri_str = gnome_vfs_volume_get_activation_uri (volume);
+- mount_uri = gnome_vfs_uri_new (uri_str);
+- g_free (uri_str);
+-
+- g_assert (mount_uri != NULL);
+-
+- /* Look for the trash directory. Since we tell it not to create or
+- * look for the dir, it doesn't block. */
+- if (gnome_vfs_find_directory (mount_uri,
+- GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
+- FALSE, FALSE, 0777) == GNOME_VFS_OK) {
+- trash_dirs = g_list_prepend (trash_dirs, trash_uri);
+- }
+- gnome_vfs_uri_unref (mount_uri);
+- }
+- gnome_vfs_volume_unref (volume);
+- }
+- g_list_free (volumes);
++static void
++delete_trash_file (EmptyTrashJob *job,
++ GFile *file,
++ gboolean del_dir)
++{
++ GFileInfo *info;
++ GFile *child;
++ GFileEnumerator *enumerator;
+
+- if (trash_dirs != NULL)
+- gnome_vfs_async_xfer (handle, trash_dirs, NULL,
+- GNOME_VFS_XFER_EMPTY_DIRECTORIES,
+- GNOME_VFS_XFER_ERROR_MODE_ABORT,
+- GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+- GNOME_VFS_PRIORITY_DEFAULT,
+- func, user_data, NULL, NULL);
+- gnome_vfs_uri_list_free (trash_dirs);
+-}
++ if (g_cancellable_is_cancelled (job->cancellable))
++ return;
+
++ /* FIXME: progress */
+
+-/* --- */
++ enumerator = g_file_enumerate_children (file,
++ G_FILE_ATTRIBUTE_STANDARD_NAME,
++ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
++ job->cancellable,
++ NULL);
++ if (enumerator)
++ {
++ while ((info = g_file_enumerator_next_file (enumerator, job->cancellable, NULL)) != NULL)
++ {
++ child = g_file_get_child (file,
++ g_file_info_get_name (info));
++ delete_trash_file (job, child, TRUE);
++ g_object_unref (child);
++ g_object_unref (info);
++
++ if (g_cancellable_is_cancelled (job->cancellable))
++ break;
++ }
+
+-static void
+-count_items (gpointer key, gpointer value, gpointer user_data)
+-{
+- VolumeInfo *volinfo;
+- gint *item_count;
++ g_object_unref (enumerator);
++ }
+
+- volinfo = value;
+- item_count = user_data;
+- *item_count += volinfo->item_count;
++ if (!g_cancellable_is_cancelled (job->cancellable) && del_dir)
++ g_file_delete (file, job->cancellable, NULL);
+ }
+
+ static gboolean
+-trash_changed_notify (gpointer user_data)
++empty_trash_job_done (gpointer user_data)
+ {
+- TrashMonitor *monitor = user_data;
+- gint item_count;
++ EmptyTrashJob *job = user_data;
+
+- /* reset notification id */
+- monitor->notify_id = 0;
++ /* FIXME finish progress */
+
+- /* count the volumes */
+- item_count = 0;
+- g_hash_table_foreach (monitor->volumes, count_items, &item_count);
+-
+- /* if the item count has changed ... */
+- if (item_count != monitor->total_item_count) {
+- monitor->total_item_count = item_count;
+- /* g_message ("item count is %d", item_count); */
+- g_signal_emit (monitor, signals[ITEM_COUNT_CHANGED], 0);
+- }
++ empty_trash_job_unref (job);
+
+ return FALSE;
+ }
+
+ static void
+-trash_changed_queue_notify (TrashMonitor *monitor)
++empty_trash_job (GIOSchedulerJob *io_job,
++ GCancellable *cancellable,
++ gpointer user_data)
+ {
+- /* already queued */
+- if (monitor->notify_id != 0)
+- return;
++ EmptyTrashJob *job = user_data;
++ GList *l;
+
+- monitor->notify_id = g_idle_add (trash_changed_notify, monitor);
++ /* FIXME start progress */
++
++ for (l = job->trash_dirs;
++ l && !g_cancellable_is_cancelled (cancellable);
++ l = l->next)
++ delete_trash_file (job, l->data, FALSE);
++
++ empty_trash_job_ref (job);
++ g_io_scheduler_job_send_to_mainloop_async (io_job,
++ empty_trash_job_done,
++ job,
++ (GDestroyNotify)empty_trash_job_unref);
++}
++
++void
++trash_monitor_empty_trash (TrashMonitor *monitor,
++ GCancellable *cancellable,
++ gpointer func,
++ gpointer user_data)
++{
++ EmptyTrashJob *job;
++
++ job = empty_trash_job_new ();
++ job->cancellable = g_object_ref (cancellable);
++ job->trash_dirs = g_list_prepend (job->trash_dirs,
++ g_file_new_for_uri ("trash:"));
++
++ g_io_scheduler_push_job (empty_trash_job, job, (GDestroyNotify)empty_trash_job_unref, 0, cancellable);
+ }
+
+ int
+@@ -433,11 +308,6 @@ main (int argc, char **argv)
+ {
+ TrashMonitor *monitor;
+
+- if (!gnome_vfs_init ()) {
+- g_printerr ("Can not initialise gnome-vfs.\n");
+- return 1;
+- }
+-
+ monitor = trash_monitor_get ();
+
+ g_main_loop_run (g_main_loop_new (NULL, FALSE));
+diff -up gnome-applets-2.21.4/trashapplet/src/Makefile.am.giotrash gnome-applets-2.21.4/trashapplet/src/Makefile.am
+--- gnome-applets-2.21.4/trashapplet/src/Makefile.am.giotrash 2007-11-27 03:48:48.000000000 -0500
++++ gnome-applets-2.21.4/trashapplet/src/Makefile.am 2008-01-22 23:14:52.000000000 -0500
+@@ -1,6 +1,6 @@
+ INCLUDES = -I$(top_srcdir) \
+ $(GNOME_APPLETS_CFLAGS) \
+- $(GNOME_VFS_APPLETS_CFLAGS) \
++ $(GIO_CFLAGS) \
+ $(LIBGLADE_CFLAGS)
+
+ libexec_PROGRAMS = trashapplet
+@@ -13,7 +13,7 @@ trashapplet_SOURCES = \
+ xstuff.c \
+ xstuff.h
+
+-trashapplet_LDADD = \
+- $(GNOME_APPLETS_LIBS) \
+- $(GNOME_VFS_APPLETS_LIBS) \
++trashapplet_LDADD = \
++ $(GNOME_APPLETS_LIBS) \
++ $(GIO_LIBS) \
+ $(LIBGLADE_LIBS)
+diff -up gnome-applets-2.21.4/trashapplet/src/trashapplet.c.giotrash gnome-applets-2.21.4/trashapplet/src/trashapplet.c
+--- gnome-applets-2.21.4/trashapplet/src/trashapplet.c.giotrash 2007-11-27 03:48:48.000000000 -0500
++++ gnome-applets-2.21.4/trashapplet/src/trashapplet.c 2008-01-22 23:14:52.000000000 -0500
+@@ -31,6 +31,7 @@
+ #include <gconf/gconf-client.h>
+ #include <libgnome/gnome-help.h>
+ #include <glade/glade.h>
++#include <gio/gio.h>
+
+ #include "trashapplet.h"
+ #include "trash-monitor.h"
+@@ -118,9 +119,6 @@ trash_applet_class_init (TrashAppletClas
+ static void
+ trash_applet_init (TrashApplet *applet)
+ {
+- GnomeVFSResult res;
+- GnomeVFSURI *trash_uri;
+-
+ gtk_window_set_default_icon_name (TRASH_ICON_FULL);
+
+ panel_applet_set_flags (PANEL_APPLET (applet),
+@@ -148,20 +146,6 @@ trash_applet_init (TrashApplet *applet)
+ gtk_widget_show (applet->image);
+ applet->icon_state = TRASH_STATE_UNKNOWN;
+
+- /* create local trash directory if needed */
+- res = gnome_vfs_find_directory (NULL,
+- GNOME_VFS_DIRECTORY_KIND_TRASH,
+- &trash_uri,
+- TRUE,
+- TRUE,
+- 0700);
+- if (trash_uri)
+- gnome_vfs_uri_unref (trash_uri);
+- if (res != GNOME_VFS_OK) {
+- g_warning (_("Unable to find the Trash directory: %s"),
+- gnome_vfs_result_to_string (res));
+- }
+-
+ /* set up trash monitor */
+ applet->monitor = trash_monitor_get ();
+ applet->monitor_signal_id =
+@@ -239,6 +223,7 @@ trash_applet_change_orient (PanelApplet
+ break;
+ case PANEL_APPLET_ORIENT_UP:
+ case PANEL_APPLET_ORIENT_DOWN:
++ default:
+ applet->orient = GTK_ORIENTATION_HORIZONTAL;
+ new_size = GTK_WIDGET (applet)->allocation.height;
+ break;
+@@ -503,6 +488,7 @@ error_dialog (TrashApplet *applet, const
+ g_free (error_string);
+ }
+
++#if 0
+ static gint
+ update_transfer_callback (GnomeVFSAsyncHandle *handle,
+ GnomeVFSXferProgressInfo *progress_info,
+@@ -561,6 +547,7 @@ update_transfer_callback (GnomeVFSAsyncH
+
+ return 1;
+ }
++#endif
+
+ /* this function is based on the one with the same name in
+ libnautilus-private/nautilus-file-operations.c */
+@@ -627,12 +614,9 @@ confirm_empty_trash (GtkWidget *parent_v
+ }
+
+ static void
+-on_empty_trash_cancel (GtkWidget *widget, GnomeVFSAsyncHandle **handle)
++on_empty_trash_cancel (GtkWidget *widget, GCancellable *cancellable)
+ {
+- if (handle != NULL) {
+- gnome_vfs_async_cancel ((GnomeVFSAsyncHandle *) handle);
+- }
+-
++ g_cancellable_cancel (cancellable);
+ gtk_widget_hide (widget);
+ }
+
+@@ -643,7 +627,7 @@ trash_applet_do_empty (BonoboUIComponent
+ {
+ GtkWidget *dialog;
+
+- GnomeVFSAsyncHandle *hnd;
++ GCancellable *cancellable;
+
+ g_return_if_fail (TRASH_IS_APPLET (applet));
+
+@@ -656,16 +640,17 @@ trash_applet_do_empty (BonoboUIComponent
+ if (!applet->xml)
+ applet->xml = glade_xml_new (GNOME_GLADEDIR "/trashapplet.glade", NULL, NULL);
+
+- dialog = glade_xml_get_widget(applet->xml, "empty_trash");
++ dialog = glade_xml_get_widget (applet->xml, "empty_trash");
+
+- g_signal_connect(dialog, "response", G_CALLBACK (on_empty_trash_cancel), &hnd);
++ cancellable = g_cancellable_new ();
++ g_signal_connect (dialog, "response", G_CALLBACK (on_empty_trash_cancel), cancellable);
+
+- gtk_widget_show_all(dialog);
++ gtk_widget_show_all (dialog);
+
+ trash_monitor_empty_trash (applet->monitor,
+- &hnd, update_transfer_callback, applet);
++ cancellable, NULL, applet);
+
+- gtk_widget_hide(dialog);
++ gtk_widget_hide (dialog);
+
+ }
+
+@@ -846,80 +831,50 @@ trash_applet_drag_data_received (GtkWidg
+ guint time_)
+ {
+ TrashApplet *applet = TRASH_APPLET (widget);
+- GList *list, *scan;
+- GList *source_uri_list, *target_uri_list, *unmovable_uri_list;
+- GnomeVFSResult result;
+-
+- list = gnome_vfs_uri_list_parse ((gchar *)selectiondata->data);
+-
+- source_uri_list = NULL;
+- target_uri_list = NULL;
+- unmovable_uri_list = NULL;
+- for (scan = g_list_first (list); scan; scan = g_list_next (scan)) {
+- GnomeVFSURI *source_uri = scan->data;
+- GnomeVFSURI *trash_uri, *target_uri;
+- gchar *source_basename;
+-
+- /* find the trash directory for this file */
+- result = gnome_vfs_find_directory (source_uri,
+- GNOME_VFS_DIRECTORY_KIND_TRASH,
+- &trash_uri, TRUE, FALSE, 0);
+- if (result != GNOME_VFS_OK) {
+- unmovable_uri_list = g_list_prepend (unmovable_uri_list,
+- gnome_vfs_uri_ref (source_uri));
+- continue;
++ gchar **list;
++ gint i;
++ GList *trashed = NULL;
++ GList *untrashable = NULL;
++ GList *l;
++ GError *error = NULL;
++
++ list = g_uri_list_extract_uris ((gchar *)selectiondata->data);
++
++ for (i = 0; list[i]; i++) {
++ GFile *file;
++
++ file = g_file_new_for_uri (list[i]);
++ if (!g_file_trash (file, NULL, NULL)) {
++ untrashable = g_list_prepend (untrashable, file);
+ }
+-
+- source_basename = gnome_vfs_uri_extract_short_name
+- (source_uri);
+-
+- target_uri = gnome_vfs_uri_append_file_name(trash_uri,
+- source_basename);
+- g_free (source_basename);
+- gnome_vfs_uri_unref (trash_uri);
+-
+- source_uri_list = g_list_prepend (source_uri_list,
+- gnome_vfs_uri_ref (source_uri));
+- target_uri_list = g_list_prepend (target_uri_list,
+- target_uri);
+- }
+-
+- gnome_vfs_uri_list_free(list);
+-
+- /* we might have added a trash dir, so recheck */
+- trash_monitor_recheck_trash_dirs (applet->monitor);
+-
+- if (source_uri_list) {
+- result = gnome_vfs_xfer_uri_list (source_uri_list, target_uri_list,
+- GNOME_VFS_XFER_REMOVESOURCE |
+- GNOME_VFS_XFER_RECURSIVE,
+- GNOME_VFS_XFER_ERROR_MODE_ABORT,
+- GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+- NULL, NULL);
+- gnome_vfs_uri_list_free (source_uri_list);
+- gnome_vfs_uri_list_free (target_uri_list);
+- if (result != GNOME_VFS_OK) {
+- error_dialog (applet, _("Unable to move to trash:\n%s"),
+- gnome_vfs_result_to_string (result));
++ else {
++ trashed = g_list_prepend (trashed, file);
+ }
+ }
+- if (unmovable_uri_list) {
+- if (confirm_delete_immediately (widget,
+- g_list_length (unmovable_uri_list),
+- source_uri_list == NULL)) {
+- result = gnome_vfs_xfer_delete_list (unmovable_uri_list,
+- GNOME_VFS_XFER_ERROR_MODE_ABORT,
+- GNOME_VFS_XFER_RECURSIVE,
+- NULL, NULL);
+- } else {
+- result = GNOME_VFS_OK;
+- }
+- gnome_vfs_uri_list_free (unmovable_uri_list);
+- if (result != GNOME_VFS_OK) {
+- error_dialog (applet, _("Unable to move to trash:\n%s"),
+- gnome_vfs_result_to_string (result));
++
++ if (untrashable) {
++ if (confirm_delete_immediately (widget,
++ g_list_length (untrashable),
++ trashed == NULL)) {
++ for (l = untrashable; l; l = l->next) {
++ if (!g_file_delete (l->data, NULL, &error)) {
++ error_dialog (applet,
++ _("Unable to delete '%s': %s"),
++ g_file_get_uri (l->data),
++ error->message);
++ g_clear_error (&error);
++ }
++ }
+ }
+ }
++
++ g_list_foreach (untrashable, (GFunc)g_object_unref, NULL);
++ g_list_free (untrashable);
++ g_list_foreach (trashed, (GFunc)g_object_unref, NULL);
++ g_list_free (trashed);
++
++ g_strfreev (list);
++
+ gtk_drag_finish (context, TRUE, FALSE, time_);
+ }
+
+@@ -951,6 +906,8 @@ trash_applet_factory (PanelApplet *apple
+ int
+ main (int argc, char *argv [])
+ {
++ g_thread_init (NULL);
++
+ /* gettext stuff */
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+diff -up gnome-applets-2.21.4/trashapplet/src/trash-monitor.h.giotrash gnome-applets-2.21.4/trashapplet/src/trash-monitor.h
+--- gnome-applets-2.21.4/trashapplet/src/trash-monitor.h.giotrash 2007-11-27 03:48:48.000000000 -0500
++++ gnome-applets-2.21.4/trashapplet/src/trash-monitor.h 2008-01-22 23:14:52.000000000 -0500
+@@ -23,7 +23,7 @@
+ #ifndef __TRASH_MONITOR_H__
+ #define __TRASH_MONITOR_H__
+
+-#include <libgnomevfs/gnome-vfs.h>
++#include <gio/gio.h>
+
+ typedef struct _TrashMonitor TrashMonitor;
+ typedef struct _TrashMonitorClass TrashMonitorClass;
+@@ -41,9 +41,9 @@ TrashMonitor *trash_monitor_get (v
+ /* check if new trash dirs have been created */
+ void trash_monitor_recheck_trash_dirs (TrashMonitor *monitor);
+ void trash_monitor_empty_trash (TrashMonitor *monitor,
+- GnomeVFSAsyncHandle **handle,
+- GnomeVFSAsyncXferProgressCallback func,
+- gpointer user_data);
++ GCancellable *cancellable,
++ gpointer func,
++ gpointer user_data);
+ int trash_monitor_get_item_count (TrashMonitor *monitor);
+
+ #endif
+diff -up gnome-applets-2.21.4/Makefile.am.giotrash gnome-applets-2.21.4/Makefile.am
+--- gnome-applets-2.21.4/Makefile.am.giotrash 2008-01-12 19:32:14.000000000 -0500
++++ gnome-applets-2.21.4/Makefile.am 2008-01-22 23:14:52.000000000 -0500
+@@ -7,8 +7,7 @@ endif
+
+ vfs_applets = \
+ drivemount \
+- gweather \
+- trashapplet
++ gweather
+ if BUILD_GNOME_VFS_APPLETS
+ vfs_SUBDIRS = $(vfs_applets)
+ endif
+@@ -45,12 +44,13 @@ if BUILD_INVEST_APPLET
+ invest_applet_SUBDIR = invest-applet
+ endif
+
+-always_built_SUBDIRS = \
++always_built_SUBDIRS = \
+ charpick \
+ geyes \
+ mini-commander \
+ gkb-new \
+ stickynotes \
++ trashapplet \
+ null_applet
+
+ SUBDIRS = \
+diff -up gnome-applets-2.21.4/configure.in.giotrash gnome-applets-2.21.4/configure.in
+--- gnome-applets-2.21.4/configure.in.giotrash 2008-01-22 23:14:52.000000000 -0500
++++ gnome-applets-2.21.4/configure.in 2008-01-22 23:17:06.000000000 -0500
+@@ -13,6 +13,7 @@ dnl *** Minimum library versions for GNO
+ dnl ***************************************************************************
+ GTK_REQUIRED=2.11.0
+ GLIB_REQUIRED=2.13.0
++GIO_REQUIRED=2.15.3
+ LIBGNOME_REQUIRED=2.8.0
+ LIBGNOMEUI_REQUIRED=2.8.0
+ GNOME_VFS_REQUIRED=2.15.4
+@@ -110,6 +111,11 @@ PKG_CHECK_MODULES(GAILUTIL, gail >= $LIB
+ AC_SUBST(GAILUTIL_CFLAGS)
+ AC_SUBST(GAILUTIL_LIBS)
+
++dnl -- check for gio (required) ------------------------------------------
++PKG_CHECK_MODULES(GIO, gio-2.0 >= $GIO_REQUIRED)
++AC_SUBST(GIO_CFLAGS)
++AC_SUBST(GIO_LIBS)
++
+ dnl -- Check for GTK+ 2.0 (required) ------------------------------------------
+ PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED)
+ AC_SUBST(GTK_FLAGS)