Commit 0059140a authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Implement some missing mount/unmount functionallity. Patch from Tomas

2008-01-08  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-desktop-icon-file.c:
        * libnautilus-private/nautilus-file-operations.c:
        * libnautilus-private/nautilus-vfs-file.c:
	Implement some missing mount/unmount functionallity.
	Patch from Tomas Bzatek <tbzatek@redhat.com>


svn path=/trunk/; revision=13571
parent f0e19cc3
2008-01-08 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-desktop-icon-file.c:
* libnautilus-private/nautilus-file-operations.c:
* libnautilus-private/nautilus-vfs-file.c:
Implement some missing mount/unmount functionallity.
Patch from Tomas Bzatek <tbzatek@redhat.com>
2008-01-08 Alexander Larsson <alexl@redhat.com>
* configure.in:
......
......@@ -31,6 +31,7 @@
#include "nautilus-file-attributes.h"
#include "nautilus-file-private.h"
#include "nautilus-file-utilities.h"
#include "nautilus-file-operations.h"
#include <eel/eel-glib-extensions.h>
#include "nautilus-desktop-directory.h"
#include <glib/gi18n.h>
......@@ -300,6 +301,43 @@ nautilus_desktop_icon_file_get_link (NautilusDesktopIconFile *icon_file)
return NULL;
}
static void
nautilus_desktop_icon_file_unmount (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
NautilusDesktopIconFile *desktop_file;
GMount *mount;
desktop_file = NAUTILUS_DESKTOP_ICON_FILE (file);
if (desktop_file) {
mount = nautilus_desktop_link_get_mount (desktop_file->details->link);
if (mount != NULL) {
nautilus_file_operations_unmount_mount (NULL, mount, FALSE);
}
}
}
static void
nautilus_desktop_icon_file_eject (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
NautilusDesktopIconFile *desktop_file;
GMount *mount;
desktop_file = NAUTILUS_DESKTOP_ICON_FILE (file);
if (desktop_file) {
mount = nautilus_desktop_link_get_mount (desktop_file->details->link);
if (mount != NULL) {
nautilus_file_operations_unmount_mount (NULL, mount, TRUE);
}
}
}
static void
nautilus_desktop_icon_file_class_init (NautilusDesktopIconFileClass *klass)
{
......@@ -320,6 +358,8 @@ nautilus_desktop_icon_file_class_init (NautilusDesktopIconFileClass *klass)
file_class->get_deep_counts = desktop_icon_file_get_deep_counts;
file_class->get_date = desktop_icon_file_get_date;
file_class->get_where_string = desktop_icon_file_get_where_string;
file_class->unmount = nautilus_desktop_icon_file_unmount;
file_class->eject = nautilus_desktop_icon_file_eject;
g_type_class_add_private (object_class, sizeof(NautilusDesktopIconFileDetails));
}
......@@ -1716,10 +1716,18 @@ unmount_mount_callback (GObject *source_object,
UnmountData *data = user_data;
GError *error;
char *primary;
gboolean unmounted;
error = NULL;
if (!g_mount_unmount_finish (G_MOUNT (source_object),
res, &error)) {
if (data->eject) {
unmounted = g_mount_unmount_finish (G_MOUNT (source_object),
res, &error);
} else {
unmounted = g_mount_eject_finish (G_MOUNT (source_object),
res, &error);
}
if (! unmounted) {
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
if (data->eject) {
primary = f (_("Unable to eject %V"), source_object);
......@@ -1745,19 +1753,10 @@ static void
do_unmount (UnmountData *data)
{
if (data->eject) {
#if 0
/* TODO */
GDrive *drive;
drive = g_mount_get_drive (drive);
if (drive != NULL) {
g_drive_eject (drive,
NULL,
unmount_mount_callback,
data);
g_object_unref (drive);
}
#endif
g_mount_eject (data->mount,
0, NULL,
unmount_mount_callback,
data);
} else {
g_mount_unmount (data->mount,
0, NULL,
......@@ -1897,8 +1896,10 @@ prompt_empty_trash (GtkWindow *parent_window)
/* Make transient for the window group */
gtk_widget_realize (dialog);
gdk_window_set_transient_for (GTK_WIDGET (dialog)->window,
gdk_screen_get_root_window (screen));
if (screen != NULL) {
gdk_window_set_transient_for (GTK_WIDGET (dialog)->window,
gdk_screen_get_root_window (screen));
}
result = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
......
......@@ -284,13 +284,97 @@ vfs_file_mount (NautilusFile *file,
g_object_unref (location);
}
static void
vfs_file_unmount_callback (GObject *source_object,
GAsyncResult *res,
gpointer callback_data)
{
NautilusFileOperation *op;
gboolean unmounted;
GError *error;
op = callback_data;
error = NULL;
unmounted = g_file_unmount_mountable_finish (G_FILE (source_object),
res, &error);
if ((! unmounted) && ((error->domain == G_IO_ERROR_FAILED_HANDLED) ||
(error->domain == G_IO_ERROR_CANCELLED))) {
g_error_free (error);
error = NULL;
}
nautilus_file_operation_complete (op, G_FILE (source_object), error);
if (error) {
g_error_free (error);
}
}
static void
vfs_file_unmount (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
NautilusFileOperation *op;
GFile *location;
op = nautilus_file_operation_new (file, callback, callback_data);
location = nautilus_file_get_location (file);
g_file_unmount_mountable (location,
G_MOUNT_UNMOUNT_NONE,
op->cancellable,
vfs_file_unmount_callback,
op);
g_object_unref (location);
}
static void
vfs_file_eject_callback (GObject *source_object,
GAsyncResult *res,
gpointer callback_data)
{
NautilusFileOperation *op;
gboolean ejected;
GError *error;
op = callback_data;
error = NULL;
ejected = g_file_eject_mountable_finish (G_FILE (source_object),
res, &error);
if ((! ejected) && ((error->domain == G_IO_ERROR_FAILED_HANDLED) ||
(error->domain == G_IO_ERROR_CANCELLED))) {
g_error_free (error);
error = NULL;
}
nautilus_file_operation_complete (op, G_FILE (source_object), error);
if (error) {
g_error_free (error);
}
}
static void
vfs_file_eject (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
NautilusFileOperation *op;
GFile *location;
op = nautilus_file_operation_new (file, callback, callback_data);
location = nautilus_file_get_location (file);
g_file_eject_mountable (location,
G_MOUNT_UNMOUNT_NONE,
op->cancellable,
vfs_file_eject_callback,
op);
g_object_unref (location);
}
static void
nautilus_vfs_file_init (gpointer object, gpointer klass)
......@@ -319,4 +403,5 @@ nautilus_vfs_file_class_init (gpointer klass)
file_class->get_where_string = vfs_file_get_where_string;
file_class->mount = vfs_file_mount;
file_class->unmount = vfs_file_unmount;
file_class->eject = vfs_file_eject;
}
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