diff -Nur thunar-0.8.0/thunar/Makefile.in thunar-0.8.0.new/thunar/Makefile.in --- thunar-0.8.0/thunar/Makefile.in 2007-01-20 21:41:11.000000000 +0100 +++ thunar-0.8.0.new/thunar/Makefile.in 2007-10-03 14:54:31.000000000 +0200 @@ -702,7 +702,7 @@ xfce-titled-dialog.h Thunar_CFLAGS = $(EXO_CFLAGS) $(GTHREAD_CFLAGS) $(LIBSM_CFLAGS) \ - $(PLATFORM_CFLAGS) $(am__append_2) + $(PLATFORM_CFLAGS) $(am__append_2) $(HAL_CFLAGS) Thunar_LDFLAGS = \ -no-undefined \ $(LIBSM_LDFLAGS) \ diff -Nur thunar-0.8.0/thunar/thunar-application.c thunar-0.8.0.new/thunar/thunar-application.c --- thunar-0.8.0/thunar/thunar-application.c 2007-01-20 21:39:02.000000000 +0100 +++ thunar-0.8.0.new/thunar/thunar-application.c 2007-10-03 14:54:45.000000000 +0200 @@ -46,6 +46,10 @@ #include +#include +#include +#include +#include /* Prototype for the Thunar-VFS job launchers */ typedef ThunarVfsJob *(*Launcher) (GList *source_path_list, @@ -592,6 +596,61 @@ } } +static gchar * +thunar_get_real_udi (gchar *udi, LibHalContext *hal_ctx) +{ + char *storage, **volumes = NULL; + const char *volume = udi; + DBusError error; + int i, n; + + if (!libhal_device_get_property_bool (hal_ctx, udi, "block.is_volume", NULL)) { + dbus_error_init (&error); + volumes = libhal_find_device_by_capability (hal_ctx, "volume", &n, &error); + if (dbus_error_is_set (&error)) { + dbus_error_free (&error); + return; + } + + volume = NULL; + for (i = 0; i < n; i++) { + volume = volumes[i]; + if (!(storage = libhal_device_get_property_string (hal_ctx, volume, "info.parent", NULL))) + continue; + + if (!strcmp (udi, storage)) { + libhal_free_string (storage); + break; + } + + libhal_free_string (storage); + } + } + + return (gchar *)volume; +} + +/* HACK: gross layering violation, but I could see no shorter way + * of getting the HAL context + */ +struct _ThunarVfsVolumeManager +{ + /*< private >*/ + GObject __parent__; + + /*< public >*/ + + /* the list of available volumes */ + GList *volumes; +}; + +struct _ThunarVfsVolumeManagerHal +{ + struct _ThunarVfsVolumeManager __parent__; + DBusConnection *dbus_connection; + LibHalContext *context; + GList *volumes; +}; static void @@ -602,15 +661,18 @@ GdkScreen *screen; GError *err = NULL; gchar *argv[4]; - + gchar *real_udi; + _thunar_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER (volume_manager)); _thunar_return_if_fail (application->volman == volume_manager); _thunar_return_if_fail (THUNAR_IS_APPLICATION (application)); + real_udi = thunar_get_real_udi ((gchar *)udi, ((struct _ThunarVfsVolumeManagerHal *)(volume_manager))->context); + /* generate the argument list for exo-eject */ argv[0] = (gchar *) "exo-eject"; argv[1] = (gchar *) "-h"; - argv[2] = (gchar *) udi; + argv[2] = (gchar *) real_udi; argv[3] = NULL; /* locate the currently active screen (the one with the pointer) */