Commit a9e16f06 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler

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.
parent 38b74892
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.
2001-04-30 Dan Mueth <dan@eazel.com>
Updating screenshots for Nautilus User Manual for Nautilus 1.0.3.
......@@ -82,6 +130,7 @@
2001-04-30 Andy Hertzfeld <andy@eazel.com>
>>>>>>> 1.4538
* components/news/nautilus-news.c: (extract_items),
(has_matching_uri), (rss_read_error), (extract_rss_title),
(extract_scripting_news_title), (extract_rss_image),
......
......@@ -1740,7 +1740,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
if (target_dir != NULL) {
if (target_is_trash) {
gnome_vfs_find_directory (source_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
&target_dir_uri, FALSE, FALSE, 0777);
&target_dir_uri, FALSE, FALSE, 0777);
}
if (target_dir_uri != NULL) {
target_uri = append_basename (target_dir_uri, source_uri);
......@@ -1772,6 +1772,11 @@ nautilus_file_operations_copy_move (const GList *item_uris,
gnome_vfs_uri_unref (source_dir_uri);
}
if (target_is_trash) {
/* Make sure new trash directories that we don't show yet get integrated. */
nautilus_trash_monitor_add_new_trash_directories ();
}
move_options = GNOME_VFS_XFER_RECURSIVE;
if (duplicate) {
/* Copy operation, parents match -> duplicate
......
......@@ -28,6 +28,7 @@
#include "nautilus-directory-private.h"
#include "nautilus-file.h"
#include "nautilus-trash-monitor.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-gtk-macros.h>
......@@ -133,6 +134,38 @@ find_directory_callback (GnomeVFSAsyncHandle *handle,
directory);
}
static gboolean
get_trash_volume (NautilusTrashDirectory *trash,
NautilusVolume *volume,
TrashVolume **trash_volume,
GnomeVFSURI **volume_mount_uri)
{
/* Quick out if we already know about this volume. */
*trash_volume = g_hash_table_lookup (trash->details->volumes,
volume);
if (*trash_volume != NULL && (*trash_volume)->real_directory != NULL) {
return FALSE;
}
if (!nautilus_volume_monitor_should_integrate_trash (volume)) {
return FALSE;
}
*volume_mount_uri = gnome_vfs_uri_new
(nautilus_volume_monitor_get_volume_mount_uri (volume));
if (*trash_volume == NULL) {
/* Make the structure used to track the trash for this volume. */
*trash_volume = g_new0 (TrashVolume, 1);
(*trash_volume)->trash = trash;
(*trash_volume)->volume = volume;
g_hash_table_insert (trash->details->volumes, volume, *trash_volume);
}
return TRUE;
}
static void
add_volume (NautilusTrashDirectory *trash,
NautilusVolume *volume)
......@@ -141,25 +174,9 @@ add_volume (NautilusTrashDirectory *trash,
GnomeVFSURI *volume_mount_uri;
GList vfs_uri_as_list;
/* Quick out if we already know about this volume. */
trash_volume = g_hash_table_lookup (trash->details->volumes,
volume);
if (trash_volume != NULL) {
return;
}
if (!nautilus_volume_monitor_should_integrate_trash (volume)) {
if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
return;
}
volume_mount_uri = gnome_vfs_uri_new
(nautilus_volume_monitor_get_volume_mount_uri (volume));
/* Make the structure used to track the trash for this volume. */
trash_volume = g_new0 (TrashVolume, 1);
trash_volume->trash = trash;
trash_volume->volume = volume;
g_hash_table_insert (trash->details->volumes, volume, trash_volume);
/* Find the real trash directory for this one. */
vfs_uri_as_list.data = volume_mount_uri;
......@@ -174,6 +191,46 @@ add_volume (NautilusTrashDirectory *trash,
find_directory_callback, trash_volume);
}
static void
check_trash_created (NautilusTrashDirectory *trash,
NautilusVolume *volume)
{
GnomeVFSResult result;
TrashVolume *trash_volume;
GnomeVFSURI *volume_mount_uri;
GnomeVFSURI *trash_uri;
char *uri;
if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
return;
}
/* Do a synch trash lookup -- if the trash directory was just created, it's location will
* be known and returned immediately without any blocking.
*/
result = gnome_vfs_find_directory (volume_mount_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
&trash_uri, FALSE, FALSE, 077);
gnome_vfs_uri_unref (volume_mount_uri);
if (result != GNOME_VFS_OK) {
return;
}
uri = gnome_vfs_uri_to_string (trash_uri,
GNOME_VFS_URI_HIDE_NONE);
trash_volume->real_directory = nautilus_directory_get (uri);
g_free (uri);
gnome_vfs_uri_unref (trash_uri);
if (trash_volume->real_directory == NULL) {
return;
}
/* Add the directory object. */
nautilus_merged_directory_add_real_directory
(NAUTILUS_MERGED_DIRECTORY (trash_volume->trash),
trash_volume->real_directory);
}
static void
remove_trash_volume (TrashVolume *trash_volume)
{
......@@ -219,11 +276,11 @@ add_one_volume (const NautilusVolume *volume,
}
static void
volume_mounted_callback (NautilusVolumeMonitor *monitor,
check_trash_directory_added_callback (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
NautilusTrashDirectory *trash)
{
add_volume (trash, volume);
check_trash_created (trash, volume);
}
static void
......@@ -234,6 +291,14 @@ volume_unmount_started_callback (NautilusVolumeMonitor *monitor,
remove_volume (trash, volume);
}
static void
volume_mounted_callback (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
NautilusTrashDirectory *trash)
{
add_volume (trash, volume);
}
static void
nautilus_trash_directory_initialize (gpointer object, gpointer klass)
{
......@@ -253,6 +318,23 @@ nautilus_trash_directory_initialize (gpointer object, gpointer klass)
gtk_signal_connect
(GTK_OBJECT (volume_monitor), "volume_unmount_started",
volume_unmount_started_callback, trash);
}
/* Finish initializing a new NautilusTrashDirectory. We have to do the
* remaining initialization here rather than in nautilus_trash_directory_initialize
* because of a cyclic dependency between the NautilusTrashDirectory and
* NautilusTrashMonitor instances.
*/
void
nautilus_trash_directory_finish_initializing (NautilusTrashDirectory *trash)
{
NautilusVolumeMonitor *volume_monitor;
volume_monitor = nautilus_volume_monitor_get ();
gtk_signal_connect
(GTK_OBJECT (nautilus_trash_monitor_get ()), "check_trash_directory_added",
check_trash_directory_added_callback, trash);
nautilus_volume_monitor_each_mounted_volume
(volume_monitor, add_one_volume, trash);
}
......@@ -314,3 +396,4 @@ nautilus_trash_directory_initialize_class (gpointer klass)
directory_class->get_name_for_self_as_new_file = trash_get_name_for_self_as_new_file;
}
......@@ -51,5 +51,6 @@ typedef struct {
} NautilusTrashDirectoryClass;
GtkType nautilus_trash_directory_get_type (void);
void nautilus_trash_directory_finish_initializing (NautilusTrashDirectory *trash);
#endif /* NAUTILUS_TRASH_DIRECTORY_H */
......@@ -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);
}
......@@ -29,6 +29,8 @@
#include <gtk/gtkobject.h>
#include <libgnomevfs/gnome-vfs.h>
#include "nautilus-volume-monitor.h"
typedef struct NautilusTrashMonitor NautilusTrashMonitor;
typedef struct NautilusTrashMonitorClass NautilusTrashMonitorClass;
typedef struct NautilusTrashMonitorDetails NautilusTrashMonitorDetails;
......@@ -52,8 +54,10 @@ struct NautilusTrashMonitor {
struct NautilusTrashMonitorClass {
GtkObjectClass parent_class;
void (* trash_state_changed) (NautilusTrashMonitor *trash_monitor,
gboolean new_state);
void (* trash_state_changed) (NautilusTrashMonitor *trash_monitor,
gboolean new_state);
void (* check_trash_directory_added) (NautilusTrashMonitor *trash_monitor,
NautilusVolume *volume);
};
GtkType nautilus_trash_monitor_get_type (void);
......@@ -61,5 +65,6 @@ GtkType nautilus_trash_monitor_get_type (void);
NautilusTrashMonitor *nautilus_trash_monitor_get (void);
gboolean nautilus_trash_monitor_is_empty (void);
GList * nautilus_trash_monitor_get_trash_directories (void);
void nautilus_trash_monitor_add_new_trash_directories (void);
#endif
......@@ -132,5 +132,4 @@ void nautilus_volume_monitor_set_volume_name (NautilusVolumeMonitor *monit
const char *volume_name);
char *nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor,
NautilusVolume *volume);
#endif /* NAUTILUS_VOLUME_MONITOR_H */
......@@ -1740,7 +1740,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
if (target_dir != NULL) {
if (target_is_trash) {
gnome_vfs_find_directory (source_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
&target_dir_uri, FALSE, FALSE, 0777);
&target_dir_uri, FALSE, FALSE, 0777);
}
if (target_dir_uri != NULL) {
target_uri = append_basename (target_dir_uri, source_uri);
......@@ -1772,6 +1772,11 @@ nautilus_file_operations_copy_move (const GList *item_uris,
gnome_vfs_uri_unref (source_dir_uri);
}
if (target_is_trash) {
/* Make sure new trash directories that we don't show yet get integrated. */
nautilus_trash_monitor_add_new_trash_directories ();
}
move_options = GNOME_VFS_XFER_RECURSIVE;
if (duplicate) {
/* Copy operation, parents match -> duplicate
......
......@@ -28,6 +28,7 @@
#include "nautilus-directory-private.h"
#include "nautilus-file.h"
#include "nautilus-trash-monitor.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-gtk-macros.h>
......@@ -133,6 +134,38 @@ find_directory_callback (GnomeVFSAsyncHandle *handle,
directory);
}
static gboolean
get_trash_volume (NautilusTrashDirectory *trash,
NautilusVolume *volume,
TrashVolume **trash_volume,
GnomeVFSURI **volume_mount_uri)
{
/* Quick out if we already know about this volume. */
*trash_volume = g_hash_table_lookup (trash->details->volumes,
volume);
if (*trash_volume != NULL && (*trash_volume)->real_directory != NULL) {
return FALSE;
}
if (!nautilus_volume_monitor_should_integrate_trash (volume)) {
return FALSE;
}
*volume_mount_uri = gnome_vfs_uri_new
(nautilus_volume_monitor_get_volume_mount_uri (volume));
if (*trash_volume == NULL) {
/* Make the structure used to track the trash for this volume. */
*trash_volume = g_new0 (TrashVolume, 1);
(*trash_volume)->trash = trash;
(*trash_volume)->volume = volume;
g_hash_table_insert (trash->details->volumes, volume, *trash_volume);
}
return TRUE;
}
static void
add_volume (NautilusTrashDirectory *trash,
NautilusVolume *volume)
......@@ -141,25 +174,9 @@ add_volume (NautilusTrashDirectory *trash,
GnomeVFSURI *volume_mount_uri;
GList vfs_uri_as_list;
/* Quick out if we already know about this volume. */
trash_volume = g_hash_table_lookup (trash->details->volumes,
volume);
if (trash_volume != NULL) {
return;
}
if (!nautilus_volume_monitor_should_integrate_trash (volume)) {
if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
return;
}
volume_mount_uri = gnome_vfs_uri_new
(nautilus_volume_monitor_get_volume_mount_uri (volume));
/* Make the structure used to track the trash for this volume. */
trash_volume = g_new0 (TrashVolume, 1);
trash_volume->trash = trash;
trash_volume->volume = volume;
g_hash_table_insert (trash->details->volumes, volume, trash_volume);
/* Find the real trash directory for this one. */
vfs_uri_as_list.data = volume_mount_uri;
......@@ -174,6 +191,46 @@ add_volume (NautilusTrashDirectory *trash,
find_directory_callback, trash_volume);
}
static void
check_trash_created (NautilusTrashDirectory *trash,
NautilusVolume *volume)
{
GnomeVFSResult result;
TrashVolume *trash_volume;
GnomeVFSURI *volume_mount_uri;
GnomeVFSURI *trash_uri;
char *uri;
if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
return;
}
/* Do a synch trash lookup -- if the trash directory was just created, it's location will
* be known and returned immediately without any blocking.
*/
result = gnome_vfs_find_directory (volume_mount_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
&trash_uri, FALSE, FALSE, 077);
gnome_vfs_uri_unref (volume_mount_uri);
if (result != GNOME_VFS_OK) {
return;
}
uri = gnome_vfs_uri_to_string (trash_uri,
GNOME_VFS_URI_HIDE_NONE);
trash_volume->real_directory = nautilus_directory_get (uri);
g_free (uri);
gnome_vfs_uri_unref (trash_uri);
if (trash_volume->real_directory == NULL) {
return;
}
/* Add the directory object. */
nautilus_merged_directory_add_real_directory
(NAUTILUS_MERGED_DIRECTORY (trash_volume->trash),
trash_volume->real_directory);
}
static void
remove_trash_volume (TrashVolume *trash_volume)
{
......@@ -219,11 +276,11 @@ add_one_volume (const NautilusVolume *volume,
}
static void
volume_mounted_callback (NautilusVolumeMonitor *monitor,
check_trash_directory_added_callback (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
NautilusTrashDirectory *trash)
{
add_volume (trash, volume);
check_trash_created (trash, volume);
}
static void
......@@ -234,6 +291,14 @@ volume_unmount_started_callback (NautilusVolumeMonitor *monitor,
remove_volume (trash, volume);
}
static void
volume_mounted_callback (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
NautilusTrashDirectory *trash)
{
add_volume (trash, volume);
}
static void
nautilus_trash_directory_initialize (gpointer object, gpointer klass)
{
......@@ -253,6 +318,23 @@ nautilus_trash_directory_initialize (gpointer object, gpointer klass)
gtk_signal_connect
(GTK_OBJECT (volume_monitor), "volume_unmount_started",
volume_unmount_started_callback, trash);
}
/* Finish initializing a new NautilusTrashDirectory. We have to do the
* remaining initialization here rather than in nautilus_trash_directory_initialize
* because of a cyclic dependency between the NautilusTrashDirectory and
* NautilusTrashMonitor instances.
*/
void
nautilus_trash_directory_finish_initializing (NautilusTrashDirectory *trash)
{
NautilusVolumeMonitor *volume_monitor;
volume_monitor = nautilus_volume_monitor_get ();
gtk_signal_connect
(GTK_OBJECT (nautilus_trash_monitor_get ()), "check_trash_directory_added",
check_trash_directory_added_callback, trash);
nautilus_volume_monitor_each_mounted_volume
(volume_monitor, add_one_volume, trash);
}
......@@ -314,3 +396,4 @@ nautilus_trash_directory_initialize_class (gpointer klass)
directory_class->get_name_for_self_as_new_file = trash_get_name_for_self_as_new_file;
}
......@@ -51,5 +51,6 @@ typedef struct {
} NautilusTrashDirectoryClass;
GtkType nautilus_trash_directory_get_type (void);
void nautilus_trash_directory_finish_initializing (NautilusTrashDirectory *trash);
#endif /* NAUTILUS_TRASH_DIRECTORY_H */
......@@ -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);
}
......@@ -29,6 +29,8 @@
#include <gtk/gtkobject.h>
#include <libgnomevfs/gnome-vfs.h>
#include "nautilus-volume-monitor.h"
typedef struct NautilusTrashMonitor NautilusTrashMonitor;
typedef struct NautilusTrashMonitorClass NautilusTrashMonitorClass;
typedef struct NautilusTrashMonitorDetails NautilusTrashMonitorDetails;
......@@ -52,8 +54,10 @@ struct NautilusTrashMonitor {
struct NautilusTrashMonitorClass {
GtkObjectClass parent_class;
void (* trash_state_changed) (NautilusTrashMonitor *trash_monitor,
gboolean new_state);
void (* trash_state_changed) (NautilusTrashMonitor *trash_monitor,
gboolean new_state);
void (* check_trash_directory_added) (NautilusTrashMonitor *trash_monitor,
NautilusVolume *volume);
};
GtkType nautilus_trash_monitor_get_type (void);
......@@ -61,5 +65,6 @@ GtkType nautilus_trash_monitor_get_type (void);
NautilusTrashMonitor *nautilus_trash_monitor_get (void);
gboolean nautilus_trash_monitor_is_empty (void);
GList * nautilus_trash_monitor_get_trash_directories (void);
void nautilus_trash_monitor_add_new_trash_directories (void);
#endif
......@@ -132,5 +132,4 @@ void nautilus_volume_monitor_set_volume_name (NautilusVolumeMonitor *monit
const char *volume_name);
char *nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor,
NautilusVolume *volume);
#endif /* NAUTILUS_VOLUME_MONITOR_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment