From 0a997551806573b6e495353bf9b5766a558c44f9 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Wed, 17 Dec 2008 11:52:37 +0000
Subject: Simplify _can_eject by calling out to GIO instead of our Linux specific

2008-12-17  Bastien Nocera  <hadess@hadess.net>

	* src/nautilus-burn-drive.c (nautilus_burn_drive_can_eject):
	Simplify _can_eject by calling out to GIO instead of our
	Linux specific ioctl


svn path=/trunk/; revision=2271
---
diff --git a/src/nautilus-burn-drive.c b/src/nautilus-burn-drive.c
index 2322937..541d6f2 100644
--- a/src/nautilus-burn-drive.c
+++ b/src/nautilus-burn-drive.c
@@ -1492,29 +1492,6 @@ nautilus_burn_drive_class_init (NautilusBurnDriveClass *klass)
                                                                G_PARAM_READWRITE));
 }
 
-static gboolean
-can_drive_eject (int fd)
-{
-        if (fd < 0) {
-                return FALSE;
-        }
-
-#ifdef __linux__
-        {
-                int status;
-
-                status = ioctl (fd, CDROM_GET_CAPABILITY, 0);
-                if (status < 0) {
-                        return FALSE;
-                }
-
-                return status & CDC_OPEN_TRAY;
-        }
-#else
-        return FALSE;
-#endif
-}
-
 /**
  * nautilus_burn_drive_can_eject:
  * @drive: #NautilusBurnDrive
@@ -1526,22 +1503,16 @@ can_drive_eject (int fd)
 gboolean
 nautilus_burn_drive_can_eject (NautilusBurnDrive *drive)
 {
-        gpointer ioctl_handle;
-        int      fd;
-        gboolean ret;
+	GDrive *gdrive;
+	gboolean ret;
 
         g_return_val_if_fail (drive != NULL, FALSE);
 
-        ioctl_handle = open_ioctl_handle (drive->priv->device);
-        if (ioctl_handle == INVALID_HANDLE) {
-                return FALSE;
-        }
-
-        fd = get_ioctl_handle_fd (ioctl_handle);
-
-        ret = can_drive_eject (fd);
-
-        close_ioctl_handle (ioctl_handle);
+	gdrive = nautilus_burn_drive_get_drive_for_node (drive);
+	if (gdrive == NULL)
+		return FALSE;
+	ret = g_drive_can_eject (gdrive);
+	g_object_unref (gdrive);
 
         return ret;
 }
--
cgit v0.8.3.1