summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-trash-monitor.c
diff options
context:
space:
mode:
authorPavel Cisler <pavel@eazel.com>2001-05-01 02:11:14 +0000
committerPavel Cisler <pce@src.gnome.org>2001-05-01 02:11:14 +0000
commita9e16f06aae9486f53ac3328937d2b4c59107a39 (patch)
treec18ebd5922dc05dc90c359bcc6a30b8f60adea32 /libnautilus-private/nautilus-trash-monitor.c
parent38b74892e08d47fecd0dd9c3b6148b72d589560d (diff)
downloadnautilus-a9e16f06aae9486f53ac3328937d2b4c59107a39.tar.gz
reviewed by: Darin Adler <darin@eazel.com>
2001-04-30 Pavel Cisler <pavel@eazel.com> reviewed by: Darin Adler <darin@eazel.com> Fixed 4964 (Files dragged to Trash from floppy don't appear in Trash Can) Fixed 7406 (Trash doesn't work until first restart of Nautilus) Fixed 7976 (some files that you can't leave in the Trash just silently go away instead of showing the dialog as they should) New trash directories are created lazily, when someone tries to delete an item on the respective disk for the first time. The problem was that these new trash directories do not get integrated into the unified trash directory. Added logic to do that. * libnautilus-extensions/nautilus-file-operations.c: (nautilus_file_operations_copy_move): Before a move to trash operation is started check for any new trash directories and integrate them if needed. * libnautilus-extensions/nautilus-trash-directory.c: (check_trash_created), (check_trash_directory_added_callback), (volume_mounted_callback) Add calls to allow adding a new physical trash directory to the unified trash. * libnautilus-extensions/nautilus-trash-directory.h: * libnautilus-extensions/nautilus-trash-monitor.c: (nautilus_trash_monitor_initialize_class), (nautilus_trash_monitor_get), * libnautilus-extensions/nautilus-trash-directory.c: (nautilus_trash_directory_initialize), (nautilus_trash_directory_finish_initializing): Rearrange to allow initializing the nautilus trash directory and nautilus trash monitor properly, dodging a cyclic dependency. * libnautilus-extensions/nautilus-trash-monitor.c: * libnautilus-extensions/nautilus-trash-monitor.h: (nautilus_trash_monitor_get_trash_directories), (add_one_trash_directory_if_needed), (nautilus_trash_monitor_add_new_trash_directories): Add a new signal to allow clients get notified when a new trash directory might get added to the unified trash.
Diffstat (limited to 'libnautilus-private/nautilus-trash-monitor.c')
-rw-r--r--libnautilus-private/nautilus-trash-monitor.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/libnautilus-private/nautilus-trash-monitor.c b/libnautilus-private/nautilus-trash-monitor.c
index f10d7e540..d3f9cc74d 100644
--- a/libnautilus-private/nautilus-trash-monitor.c
+++ b/libnautilus-private/nautilus-trash-monitor.c
@@ -29,7 +29,7 @@
#include "nautilus-directory-notify.h"
#include "nautilus-directory.h"
#include "nautilus-file-attributes.h"
-#include "nautilus-volume-monitor.h"
+#include "nautilus-trash-directory.h"
#include <eel/eel-gtk-macros.h>
#include <eel/eel-vfs-extensions.h>
#include <gtk/gtksignal.h>
@@ -44,6 +44,7 @@ struct NautilusTrashMonitorDetails {
enum {
TRASH_STATE_CHANGED,
+ CHECK_TRASH_DIRECTORY_ADDED,
LAST_SIGNAL
};
@@ -75,6 +76,15 @@ nautilus_trash_monitor_initialize_class (NautilusTrashMonitorClass *klass)
GTK_TYPE_NONE, 1,
GTK_TYPE_BOOL);
+ signals[CHECK_TRASH_DIRECTORY_ADDED] = gtk_signal_new
+ ("check_trash_directory_added",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusTrashMonitorClass, check_trash_directory_added),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_POINTER);
+
gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
@@ -170,13 +180,23 @@ unref_trash_monitor (void)
NautilusTrashMonitor *
nautilus_trash_monitor_get (void)
{
+ NautilusDirectory *trash_directory;
+
if (nautilus_trash_monitor == NULL) {
/* not running yet, start it up */
+
+ /* the trash directory object will get created by this */
+ trash_directory = nautilus_directory_get (EEL_TRASH_URI);
+
nautilus_trash_monitor = NAUTILUS_TRASH_MONITOR
(gtk_object_new (NAUTILUS_TYPE_TRASH_MONITOR, NULL));
gtk_object_ref (GTK_OBJECT (nautilus_trash_monitor));
gtk_object_sink (GTK_OBJECT (nautilus_trash_monitor));
g_atexit (unref_trash_monitor);
+
+ /* make sure we get signalled when trash directories get added */
+ nautilus_trash_directory_finish_initializing
+ (NAUTILUS_TRASH_DIRECTORY (trash_directory));
}
return nautilus_trash_monitor;
@@ -241,3 +261,28 @@ nautilus_trash_monitor_get_trash_directories (void)
return result;
}
+static gboolean
+add_one_trash_directory_if_needed (const NautilusVolume *volume,
+ gpointer callback_data)
+{
+ NautilusTrashMonitor *trash_monitor;
+
+ trash_monitor = NAUTILUS_TRASH_MONITOR (callback_data);
+ gtk_signal_emit (GTK_OBJECT (trash_monitor),
+ signals[CHECK_TRASH_DIRECTORY_ADDED],
+ volume);
+
+ return FALSE;
+}
+
+void
+nautilus_trash_monitor_add_new_trash_directories (void)
+{
+ NautilusTrashMonitor *trash_monitor;
+
+ trash_monitor = nautilus_trash_monitor_get ();
+ nautilus_volume_monitor_each_mounted_volume
+ (nautilus_volume_monitor_get (), add_one_trash_directory_if_needed,
+ trash_monitor);
+}
+