diff --git a/ChangeLog b/ChangeLog index 87ed5755d88c0510f9112872f6287ad0ef3eec71..35c9c59c8ff15ed7ae48e51ea99bbcfb9723b2a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-04-27 Benedikt Meurer <benny@xfce.org> + + * thunar-vfs/thunar-vfs-volume-freebsd.c, + thunar-vfs/thunar-vfs-volume-hal.c, + thunar-vfs/thunar-vfs-volume-private.h, + thunar-vfs/thunar-vfs-volume.c: Use the requires_eject HAL + property to determine whether a given volume is ejectable. + Bug #3119. + 2007-04-27 Benedikt Meurer <benny@xfce.org> * thunar/thunar-util.c(thunar_util_humanize_file_time): Use larger diff --git a/thunar-vfs/thunar-vfs-volume-freebsd.c b/thunar-vfs/thunar-vfs-volume-freebsd.c index 944b2b4b3920666aaae7e39e838455946943d8b9..8c01b290696eb5138b42697bf5bfc4b4049ae9b6 100644 --- a/thunar-vfs/thunar-vfs-volume-freebsd.c +++ b/thunar-vfs/thunar-vfs-volume-freebsd.c @@ -59,6 +59,7 @@ static ThunarVfsVolumeKind thunar_vfs_volume_freebsd_get_kind (Thun static const gchar *thunar_vfs_volume_freebsd_get_name (ThunarVfsVolume *volume); static ThunarVfsVolumeStatus thunar_vfs_volume_freebsd_get_status (ThunarVfsVolume *volume); static ThunarVfsPath *thunar_vfs_volume_freebsd_get_mount_point (ThunarVfsVolume *volume); +static gboolean thunar_vfs_volume_freebsd_is_ejectable (ThunarVfsVolume *volume); static gboolean thunar_vfs_volume_freebsd_eject (ThunarVfsVolume *volume, GtkWidget *window, GError **error); @@ -142,6 +143,7 @@ thunar_vfs_volume_freebsd_class_init (ThunarVfsVolumeFreeBSDClass *klass) thunarvfs_volume_class->get_name = thunar_vfs_volume_freebsd_get_name; thunarvfs_volume_class->get_status = thunar_vfs_volume_freebsd_get_status; thunarvfs_volume_class->get_mount_point = thunar_vfs_volume_freebsd_get_mount_point; + thunarvfs_volume_class->is_ejectable = thunar_vfs_volume_freebsd_is_ejectable; thunarvfs_volume_class->eject = thunar_vfs_volume_freebsd_eject; thunarvfs_volume_class->mount = thunar_vfs_volume_freebsd_mount; thunarvfs_volume_class->unmount = thunar_vfs_volume_freebsd_unmount; @@ -201,6 +203,15 @@ thunar_vfs_volume_freebsd_get_mount_point (ThunarVfsVolume *volume) +static gboolean +thunar_vfs_volume_freebsd_is_ejectable (ThunarVfsVolume *volume) +{ + /* we can only eject removable media, that are present (surprise, surprise) */ + return (thunar_vfs_volume_is_present (volume) && thunar_vfs_volume_is_removable (volume)); +} + + + static gboolean thunar_vfs_volume_freebsd_eject (ThunarVfsVolume *volume, GtkWidget *window, diff --git a/thunar-vfs/thunar-vfs-volume-hal.c b/thunar-vfs/thunar-vfs-volume-hal.c index ecc42f05be2c4abd0abcf055797a8e8fd7da994c..34110e8f9fd80a1d152a4d48cf884861224db080 100644 --- a/thunar-vfs/thunar-vfs-volume-hal.c +++ b/thunar-vfs/thunar-vfs-volume-hal.c @@ -53,6 +53,7 @@ static ThunarVfsVolumeKind thunar_vfs_volume_hal_get_kind (Thu static const gchar *thunar_vfs_volume_hal_get_name (ThunarVfsVolume *volume); static ThunarVfsVolumeStatus thunar_vfs_volume_hal_get_status (ThunarVfsVolume *volume); static ThunarVfsPath *thunar_vfs_volume_hal_get_mount_point (ThunarVfsVolume *volume); +static gboolean thunar_vfs_volume_hal_is_ejectable (ThunarVfsVolume *volume); static const gchar *thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume, GtkIconTheme *icon_theme); static gboolean thunar_vfs_volume_hal_eject (ThunarVfsVolume *volume, @@ -90,6 +91,7 @@ struct _ThunarVfsVolumeHal /* list of possible icons */ GList *icon_list; + gboolean requires_eject; ThunarVfsPath *mount_point; ThunarVfsVolumeKind kind; ThunarVfsVolumeStatus status; @@ -139,6 +141,7 @@ thunar_vfs_volume_hal_class_init (ThunarVfsVolumeHalClass *klass) thunarvfs_volume_class->get_name = thunar_vfs_volume_hal_get_name; thunarvfs_volume_class->get_status = thunar_vfs_volume_hal_get_status; thunarvfs_volume_class->get_mount_point = thunar_vfs_volume_hal_get_mount_point; + thunarvfs_volume_class->is_ejectable = thunar_vfs_volume_hal_is_ejectable; thunarvfs_volume_class->lookup_icon_name = thunar_vfs_volume_hal_lookup_icon_name; thunarvfs_volume_class->eject = thunar_vfs_volume_hal_eject; thunarvfs_volume_class->mount = thunar_vfs_volume_hal_mount; @@ -201,6 +204,19 @@ thunar_vfs_volume_hal_get_mount_point (ThunarVfsVolume *volume) +static gboolean +thunar_vfs_volume_hal_is_ejectable (ThunarVfsVolume *volume) +{ + /* check if HAL drive requires eject */ + if (THUNAR_VFS_VOLUME_HAL (volume)->requires_eject) + return TRUE; + + /* otherwise we can only eject removable media, that are present (surprise, surprise) */ + return (thunar_vfs_volume_is_present (volume) && thunar_vfs_volume_is_removable (volume)); +} + + + static const gchar* thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume, GtkIconTheme *icon_theme) @@ -521,6 +537,9 @@ thunar_vfs_volume_hal_update (ThunarVfsVolumeHal *volume_hal, */ volume_hal->status |= THUNAR_VFS_VOLUME_STATUS_PRESENT; + /* check if the drive requires eject */ + volume_hal->requires_eject = libhal_drive_requires_eject (hd); + /* check if the volume is currently mounted */ if (hv != NULL && libhal_volume_is_mounted (hv)) { diff --git a/thunar-vfs/thunar-vfs-volume-private.h b/thunar-vfs/thunar-vfs-volume-private.h index fc5439d71df1b2403906f15014edab4e5c900f17..74ebb0c6be493107115f0108ceca8c6014bf8993 100644 --- a/thunar-vfs/thunar-vfs-volume-private.h +++ b/thunar-vfs/thunar-vfs-volume-private.h @@ -37,6 +37,7 @@ struct _ThunarVfsVolumeClass const gchar *(*get_name) (ThunarVfsVolume *volume); ThunarVfsVolumeStatus (*get_status) (ThunarVfsVolume *volume); ThunarVfsPath *(*get_mount_point) (ThunarVfsVolume *volume); + gboolean (*is_ejectable) (ThunarVfsVolume *volume); const gchar *(*lookup_icon_name) (ThunarVfsVolume *volume, GtkIconTheme *icon_theme); diff --git a/thunar-vfs/thunar-vfs-volume.c b/thunar-vfs/thunar-vfs-volume.c index b58819851aed8629b497a55a33224ef31b602155..d9e87b833909f5523ab331653c174d55f4a5779f 100644 --- a/thunar-vfs/thunar-vfs-volume.c +++ b/thunar-vfs/thunar-vfs-volume.c @@ -296,9 +296,7 @@ gboolean thunar_vfs_volume_is_ejectable (ThunarVfsVolume *volume) { g_return_val_if_fail (THUNAR_VFS_IS_VOLUME (volume), FALSE); - - /* we can only eject removable media, that are present (surprise, surprise) */ - return (thunar_vfs_volume_is_present (volume) && thunar_vfs_volume_is_removable (volume)); + return (*THUNAR_VFS_VOLUME_GET_CLASS (volume)->is_ejectable) (volume); }