1
0
mirror of https://gitlab.gnome.org/GNOME/nautilus synced 2024-06-30 23:46:35 +00:00

Set initiated_unmount on windows while unmounting

This commit is contained in:
Alexander Larsson 2010-03-08 14:36:46 +01:00
parent 5e7f958422
commit 80dd8fb8ff
3 changed files with 85 additions and 11 deletions

View File

@ -6230,6 +6230,12 @@ file_unmount_callback (NautilusFile *file,
GError *error,
gpointer callback_data)
{
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (callback_data);
fm_directory_view_set_initiated_unmount (view, FALSE);
g_object_unref (view);
if (error != NULL &&
(error->domain != G_IO_ERROR ||
(error->code != G_IO_ERROR_CANCELLED &&
@ -6245,6 +6251,12 @@ file_eject_callback (NautilusFile *file,
GError *error,
gpointer callback_data)
{
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (callback_data);
fm_directory_view_set_initiated_unmount (view, FALSE);
g_object_unref (view);
if (error != NULL &&
(error->domain != G_IO_ERROR ||
(error->code != G_IO_ERROR_CANCELLED &&
@ -6311,8 +6323,9 @@ action_unmount_volume_callback (GtkAction *action,
if (nautilus_file_can_unmount (file)) {
GMountOperation *mount_op;
mount_op = gtk_mount_operation_new (fm_directory_view_get_containing_window (view));
fm_directory_view_set_initiated_unmount (view, TRUE);
nautilus_file_unmount (file, mount_op, NULL,
file_unmount_callback, NULL);
file_unmount_callback, g_object_ref (view));
g_object_unref (mount_op);
}
}
@ -6359,8 +6372,9 @@ action_eject_volume_callback (GtkAction *action,
if (nautilus_file_can_eject (file)) {
GMountOperation *mount_op;
mount_op = gtk_mount_operation_new (fm_directory_view_get_containing_window (view));
fm_directory_view_set_initiated_unmount (view, TRUE);
nautilus_file_eject (file, mount_op, NULL,
file_eject_callback, NULL);
file_eject_callback, g_object_ref (view));
g_object_unref (mount_op);
}
}
@ -6490,7 +6504,8 @@ action_self_unmount_volume_callback (GtkAction *action,
}
mount_op = gtk_mount_operation_new (fm_directory_view_get_containing_window (view));
nautilus_file_unmount (file, mount_op, NULL, file_unmount_callback, NULL);
fm_directory_view_set_initiated_unmount (view, TRUE);
nautilus_file_unmount (file, mount_op, NULL, file_unmount_callback, g_object_ref (view));
g_object_unref (mount_op);
}
@ -6510,7 +6525,8 @@ action_self_eject_volume_callback (GtkAction *action,
}
mount_op = gtk_mount_operation_new (fm_directory_view_get_containing_window (view));
nautilus_file_eject (file, mount_op, NULL, file_eject_callback, NULL);
fm_directory_view_set_initiated_unmount (view, TRUE);
nautilus_file_eject (file, mount_op, NULL, file_eject_callback, g_object_ref (view));
g_object_unref (mount_op);
}
@ -6629,8 +6645,9 @@ action_location_unmount_volume_callback (GtkAction *action,
}
mount_op = gtk_mount_operation_new (fm_directory_view_get_containing_window (view));
fm_directory_view_set_initiated_unmount (view, TRUE);
nautilus_file_unmount (file, mount_op, NULL,
file_unmount_callback, NULL);
file_unmount_callback, g_object_ref (view));
g_object_unref (mount_op);
}
@ -6650,8 +6667,9 @@ action_location_eject_volume_callback (GtkAction *action,
}
mount_op = gtk_mount_operation_new (fm_directory_view_get_containing_window (view));
fm_directory_view_set_initiated_unmount (view, TRUE);
nautilus_file_eject (file, mount_op, NULL,
file_eject_callback, NULL);
file_eject_callback, g_object_ref (view));
g_object_unref (mount_op);
}
@ -9837,6 +9855,16 @@ fm_directory_view_is_editable (FMDirectoryView *view)
return TRUE;
}
void
fm_directory_view_set_initiated_unmount (FMDirectoryView *view,
gboolean initiated_unmount)
{
if (view->details->window != NULL) {
nautilus_window_info_set_initiated_unmount(view->details->window,
initiated_unmount);
}
}
static gboolean
real_is_read_only (FMDirectoryView *view)
{

View File

@ -484,6 +484,8 @@ void fm_directory_view_remove_subdirectory (FMDirecto
NautilusDirectory*directory);
gboolean fm_directory_view_is_editable (FMDirectoryView *view);
void fm_directory_view_set_initiated_unmount (FMDirectoryView *view,
gboolean inititated_unmount);
/* operations affecting two directory views */
void fm_directory_view_move_copy_items_between_views (FMDirectoryView *source, FMDirectoryView *target, gboolean copy);

View File

@ -1737,12 +1737,25 @@ mount_shortcut_cb (GtkMenuItem *item,
}
}
static void
unmount_done (gpointer data)
{
NautilusWindow *window;
window = data;
nautilus_window_info_set_initiated_unmount (window, FALSE);
g_object_unref (window);
}
static void
do_unmount (GMount *mount,
NautilusPlacesSidebar *sidebar)
{
if (mount != NULL) {
nautilus_file_operations_unmount_mount (NULL, mount, FALSE, TRUE);
nautilus_window_info_set_initiated_unmount (sidebar->window, TRUE);
nautilus_file_operations_unmount_mount_full (NULL, mount, FALSE, TRUE,
unmount_done,
g_object_ref (sidebar->window));
}
}
@ -1778,9 +1791,15 @@ drive_eject_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
NautilusWindow *window;
GError *error;
char *primary;
char *name;
window = user_data;
nautilus_window_info_set_initiated_unmount (window, FALSE);
g_object_unref (window);
error = NULL;
if (!g_drive_eject_with_operation_finish (G_DRIVE (source_object), res, &error)) {
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
@ -1801,9 +1820,15 @@ volume_eject_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
NautilusWindow *window;
GError *error;
char *primary;
char *name;
window = user_data;
nautilus_window_info_set_initiated_unmount (window, FALSE);
g_object_unref (window);
error = NULL;
if (!g_volume_eject_with_operation_finish (G_VOLUME (source_object), res, &error)) {
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
@ -1824,9 +1849,15 @@ mount_eject_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
NautilusWindow *window;
GError *error;
char *primary;
char *name;
window = user_data;
nautilus_window_info_set_initiated_unmount (window, FALSE);
g_object_unref (window);
error = NULL;
if (!g_mount_eject_with_operation_finish (G_MOUNT (source_object), res, &error)) {
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
@ -1852,11 +1883,17 @@ do_eject (GMount *mount,
mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar))));
if (mount != NULL) {
g_mount_eject_with_operation (mount, 0, mount_op, NULL, mount_eject_cb, NULL);
nautilus_window_info_set_initiated_unmount (sidebar->window, TRUE);
g_mount_eject_with_operation (mount, 0, mount_op, NULL, mount_eject_cb,
g_object_ref (sidebar->window));
} else if (volume != NULL) {
g_volume_eject_with_operation (volume, 0, mount_op, NULL, volume_eject_cb, NULL);
nautilus_window_info_set_initiated_unmount (sidebar->window, TRUE);
g_volume_eject_with_operation (volume, 0, mount_op, NULL, volume_eject_cb,
g_object_ref (sidebar->window));
} else if (drive != NULL) {
g_drive_eject_with_operation (drive, 0, mount_op, NULL, drive_eject_cb, NULL);
nautilus_window_info_set_initiated_unmount (sidebar->window, TRUE);
g_drive_eject_with_operation (drive, 0, mount_op, NULL, drive_eject_cb,
g_object_ref (sidebar->window));
}
g_object_unref (mount_op);
}
@ -2063,10 +2100,15 @@ drive_stop_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
NautilusWindow *window;
GError *error;
char *primary;
char *name;
window = user_data;
nautilus_window_info_set_initiated_unmount (window, FALSE);
g_object_unref (window);
error = NULL;
if (!g_drive_poll_for_media_finish (G_DRIVE (source_object), res, &error)) {
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
@ -2101,7 +2143,9 @@ stop_shortcut_cb (GtkMenuItem *item,
GMountOperation *mount_op;
mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar))));
g_drive_stop (drive, G_MOUNT_UNMOUNT_NONE, mount_op, NULL, drive_stop_cb, NULL);
nautilus_window_info_set_initiated_unmount (sidebar->window, TRUE);
g_drive_stop (drive, G_MOUNT_UNMOUNT_NONE, mount_op, NULL, drive_stop_cb,
g_object_ref (sidebar->window));
g_object_unref (mount_op);
}
g_object_unref (drive);