Index: thunar-vfs/thunar-vfs-volume-hal.c =================================================================== --- thunar-vfs/thunar-vfs-volume-hal.c (revision 23781) +++ thunar-vfs/thunar-vfs-volume-hal.c (working copy) @@ -65,6 +65,8 @@ 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 const gchar *thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume, + GtkIconTheme *icon_theme); static gboolean thunar_vfs_volume_hal_eject (ThunarVfsVolume *volume, GtkWidget *window, GError **error); @@ -100,6 +102,8 @@ ThunarVfsPath *mount_point; ThunarVfsVolumeKind kind; ThunarVfsVolumeStatus status; + + gchar *custom_icon_info; }; @@ -146,6 +150,7 @@ 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->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; thunarvfs_volume_class->unmount = thunar_vfs_volume_hal_unmount; @@ -168,6 +173,9 @@ if (G_LIKELY (volume_hal->mount_point != NULL)) thunar_vfs_path_unref (volume_hal->mount_point); + if (volume_hal->custom_icon_info) + libhal_free_string (volume_hal->custom_icon_info); + (*G_OBJECT_CLASS (thunar_vfs_volume_hal_parent_class)->finalize) (object); } @@ -205,6 +213,51 @@ +static const gchar * +thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume, + GtkIconTheme *icon_theme) +{ + ThunarVfsVolumeHal *volume_hal = THUNAR_VFS_VOLUME_HAL (volume); + + if (volume_hal->custom_icon_info) + { + switch (volume_hal->kind) + { + case THUNAR_VFS_VOLUME_KIND_AUDIO_PLAYER: + if (exo_str_is_equal (volume_hal->custom_icon_info, "ipod")) + { + if (gtk_icon_theme_has_icon (icon_theme, + "multimedia-player-ipod-standard-color")) + { + return "multimedia-player-ipod-standard-color"; + } + else if (gtk_icon_theme_has_icon (icon_theme, + "multimedia-player-ipod-mini-silver")) + { + return "multimedia-player-ipod-mini-silver"; + } + else if (gtk_icon_theme_has_icon (icon_theme, "gnome-dev-ipod")) + { + return "gnome-dev-ipod"; + } + } + /* tango-icon-theme-extras also includes: + * multimedia-player-dell-dj-pocket + * multimedia-player-motorola-rokr + * but i can't figure out what their portable_audio_player.type + * should be. */ + break; + + default: + break; + } + } + + return NULL; +} + + + static gboolean thunar_vfs_volume_hal_eject (ThunarVfsVolume *volume, GtkWidget *window, @@ -542,6 +595,7 @@ gchar *mount_root; gchar *basename; gchar *filename; + gchar *storage_udi; _thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_HAL (volume_hal)); _thunar_vfs_return_if_fail (hv != NULL); @@ -718,7 +772,34 @@ /* if we get here, we must have a valid mount point */ g_assert (volume_hal->mount_point != NULL); + + /* for some devices, we can try to set a custom icon */ + switch (volume_hal->kind) + { + case THUNAR_VFS_VOLUME_KIND_AUDIO_PLAYER: + /* we need to know the UDI of the storage device, which the parent + * of the volume should know. this lets us get the correct audio + * player type. well, almost. farther up in the tree we can get + * something more fine-grained, like 'iPod mini', but i haven't + * yet figured out how to get the proper UDI for it. */ + storage_udi = libhal_device_get_property_string (context, + volume_hal->udi, + "block.storage_device", + NULL); + if (G_LIKELY (storage_udi)) + { + volume_hal->custom_icon_info = libhal_device_get_property_string (context, + storage_udi, + "portable_audio_player.type", + NULL); + libhal_free_string (storage_udi); + } + break; + default: + break; + } + /* emit the "changed" signal */ thunar_vfs_volume_changed (THUNAR_VFS_VOLUME (volume_hal)); }