nautilus r13571 - in trunk: . libnautilus-private
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r13571 - in trunk: . libnautilus-private
- Date: Tue, 8 Jan 2008 14:27:49 +0000 (GMT)
Author: alexl
Date: Tue Jan 8 14:27:49 2008
New Revision: 13571
URL: http://svn.gnome.org/viewvc/nautilus?rev=13571&view=rev
Log:
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>
Modified:
trunk/ChangeLog
trunk/libnautilus-private/nautilus-desktop-icon-file.c
trunk/libnautilus-private/nautilus-file-operations.c
trunk/libnautilus-private/nautilus-vfs-file.c
Modified: trunk/libnautilus-private/nautilus-desktop-icon-file.c
==============================================================================
--- trunk/libnautilus-private/nautilus-desktop-icon-file.c (original)
+++ trunk/libnautilus-private/nautilus-desktop-icon-file.c Tue Jan 8 14:27:49 2008
@@ -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>
@@ -301,6 +302,43 @@
}
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)
{
GObjectClass *object_class;
@@ -320,6 +358,8 @@
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));
}
Modified: trunk/libnautilus-private/nautilus-file-operations.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file-operations.c (original)
+++ trunk/libnautilus-private/nautilus-file-operations.c Tue Jan 8 14:27:49 2008
@@ -1716,10 +1716,18 @@
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 @@
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 @@
/* 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);
Modified: trunk/libnautilus-private/nautilus-vfs-file.c
==============================================================================
--- trunk/libnautilus-private/nautilus-vfs-file.c (original)
+++ trunk/libnautilus-private/nautilus-vfs-file.c Tue Jan 8 14:27:49 2008
@@ -285,12 +285,96 @@
}
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 @@
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]