nautilus-cd-burner r2123 - in trunk: . src
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus-cd-burner r2123 - in trunk: . src
- Date: Mon, 21 Jan 2008 02:42:22 +0000 (GMT)
Author: mccann
Date: Mon Jan 21 02:42:22 2008
New Revision: 2123
URL: http://svn.gnome.org/viewvc/nautilus-cd-burner?rev=2123&view=rev
Log:
2008-01-20 William Jon McCann <mccann jhu edu>
* src/nautilus-burn-drive.c: (can_drive_eject),
(nautilus_burn_drive_can_eject):
* src/nautilus-burn-drive.h:
Add nautilus_burn_drive_can_eject (linux only atm).
Patch from: Dave Meikle <dkm dave meikle co uk>
Fixes #506930.
Modified:
trunk/ChangeLog
trunk/src/nautilus-burn-drive.c
trunk/src/nautilus-burn-drive.h
Modified: trunk/src/nautilus-burn-drive.c
==============================================================================
--- trunk/src/nautilus-burn-drive.c (original)
+++ trunk/src/nautilus-burn-drive.c Mon Jan 21 02:42:22 2008
@@ -1443,3 +1443,57 @@
FALSE,
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
+ *
+ * Report the whether the drive support ejections or not.
+ *
+ * Returns: %TRUE if the drive support ejections, otherwise return %FALSE.
+ **/
+gboolean
+nautilus_burn_drive_can_eject (NautilusBurnDrive *drive)
+{
+ gpointer ioctl_handle;
+ int fd;
+ 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);
+
+ return ret;
+}
Modified: trunk/src/nautilus-burn-drive.h
==============================================================================
--- trunk/src/nautilus-burn-drive.h (original)
+++ trunk/src/nautilus-burn-drive.h Mon Jan 21 02:42:22 2008
@@ -136,6 +136,8 @@
int nautilus_burn_drive_get_max_speed_read (NautilusBurnDrive *drive);
const int * nautilus_burn_drive_get_write_speeds (NautilusBurnDrive *drive);
+gboolean nautilus_burn_drive_can_eject (NautilusBurnDrive *drive);
+
/* Media handling */
NautilusBurnMediaType nautilus_burn_drive_get_media_type (NautilusBurnDrive *drive);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]