[Xfce4-commits] r24300 - in thunar/trunk: . thunar-vfs
Benedikt Meurer
benny at xfce.org
Sun Jan 7 23:58:40 CET 2007
Author: benny
Date: 2007-01-07 22:58:40 +0000 (Sun, 07 Jan 2007)
New Revision: 24300
Modified:
thunar/trunk/ChangeLog
thunar/trunk/acinclude.m4
thunar/trunk/thunar-vfs/Makefile.am
thunar/trunk/thunar-vfs/thunar-vfs-volume-hal.c
thunar/trunk/thunar-vfs/thunar-vfs-volume.c
thunar/trunk/thunar-vfs/thunar-vfs-volume.h
Log:
2007-01-07 Benedikt Meurer <benny at xfce.org>
* thunar-vfs/Makefile.am, thunar-vfs/thunar-vfs-volume-hal.c,
acinclude.m4: Use exo-hal to determine icons and display names
for the volumes.
* thunar-vfs/thunar-vfs-volume-hal.c,
thunar-vfs/thunar-vfs-volume.{c,h}: Do not discard blank discs and
pure audio discs. Bug #2599.
Modified: thunar/trunk/ChangeLog
===================================================================
--- thunar/trunk/ChangeLog 2007-01-07 22:42:26 UTC (rev 24299)
+++ thunar/trunk/ChangeLog 2007-01-07 22:58:40 UTC (rev 24300)
@@ -1,3 +1,12 @@
+2007-01-07 Benedikt Meurer <benny at xfce.org>
+
+ * thunar-vfs/Makefile.am, thunar-vfs/thunar-vfs-volume-hal.c,
+ acinclude.m4: Use exo-hal to determine icons and display names
+ for the volumes.
+ * thunar-vfs/thunar-vfs-volume-hal.c,
+ thunar-vfs/thunar-vfs-volume.{c,h}: Do not discard blank discs and
+ pure audio discs. Bug #2599.
+
2007-01-06 Benedikt Meurer <benny at xfce.org>
* README, configure.in.in: Requires libexo 0.3.1.13svn.
Modified: thunar/trunk/acinclude.m4
===================================================================
--- thunar/trunk/acinclude.m4 2007-01-07 22:42:26 UTC (rev 24299)
+++ thunar/trunk/acinclude.m4 2007-01-07 22:58:40 UTC (rev 24300)
@@ -219,6 +219,7 @@
dnl # We need HAL >= 0.5.x and D-BUS >= 0.23 for the HAL volume manager
if test x"$ac_bm_thunar_vfs_volume_impl" = x"hal"; then
+ XDT_CHECK_PACKAGE([EXO_HAL], [exo-hal-0.3], [0.3.1.13])
XDT_CHECK_PACKAGE([HAL], [hal-storage], [0.5.0])
XDT_CHECK_PACKAGE([HAL_DBUS], [dbus-glib-1], [0.23])
fi
Modified: thunar/trunk/thunar-vfs/Makefile.am
===================================================================
--- thunar/trunk/thunar-vfs/Makefile.am 2007-01-07 22:42:26 UTC (rev 24299)
+++ thunar/trunk/thunar-vfs/Makefile.am 2007-01-07 22:58:40 UTC (rev 24300)
@@ -274,10 +274,12 @@
thunar-vfs-volume-hal.h
libthunar_vfs_1_la_CFLAGS += \
+ $(EXO_HAL_CFLAGS) \
$(HAL_CFLAGS) \
$(HAL_DBUS_CFLAGS)
libthunar_vfs_1_la_LIBADD += \
+ $(EXO_HAL_LIBS) \
$(HAL_LIBS) \
$(HAL_DBUS_LIBS)
endif
Modified: thunar/trunk/thunar-vfs/thunar-vfs-volume-hal.c
===================================================================
--- thunar/trunk/thunar-vfs/thunar-vfs-volume-hal.c 2007-01-07 22:42:26 UTC (rev 24299)
+++ thunar/trunk/thunar-vfs/thunar-vfs-volume-hal.c 2007-01-07 22:58:40 UTC (rev 24300)
@@ -48,9 +48,10 @@
#include <dbus/dbus-glib-lowlevel.h>
-#include <libhal.h>
#include <libhal-storage.h>
+#include <exo-hal/exo-hal.h>
+
#include <thunar-vfs/thunar-vfs-exec.h>
#include <thunar-vfs/thunar-vfs-private.h>
#include <thunar-vfs/thunar-vfs-volume-hal.h>
@@ -65,6 +66,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);
@@ -96,6 +99,10 @@
gchar *device_file;
gchar *device_label;
+
+ /* list of possible icons */
+ GList *icon_list;
+
ThunarVfsPath *mount_point;
ThunarVfsVolumeKind kind;
ThunarVfsVolumeStatus status;
@@ -145,6 +152,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;
@@ -162,6 +170,9 @@
g_free (volume_hal->device_file);
g_free (volume_hal->device_label);
+ g_list_foreach (volume_hal->icon_list, (GFunc) g_free, NULL);
+ g_list_free (volume_hal->icon_list);
+
/* release the mount point (if any) */
if (G_LIKELY (volume_hal->mount_point != NULL))
thunar_vfs_path_unref (volume_hal->mount_point);
@@ -203,6 +214,23 @@
+static const gchar*
+thunar_vfs_volume_hal_lookup_icon_name (ThunarVfsVolume *volume,
+ GtkIconTheme *icon_theme)
+{
+ GList *lp;
+
+ /* check if we have atleast one usable icon in our icon_list */
+ for (lp = THUNAR_VFS_VOLUME_HAL (volume)->icon_list; lp != NULL; lp = lp->next)
+ if (gtk_icon_theme_has_icon (icon_theme, lp->data))
+ return lp->data;
+
+ /* fallback in thunar_vfs_volume_lookup_icon() */
+ return NULL;
+}
+
+
+
static gboolean
thunar_vfs_volume_hal_eject (ThunarVfsVolume *volume,
GtkWidget *window,
@@ -212,17 +240,6 @@
gboolean result = TRUE;
gchar *quoted;
- /* check if the volume is currently mounted (FIXME: Why? Just confusing!) */
-#if 0
- path = thunar_vfs_volume_hal_find_active_mount_point (volume_hal);
- if (G_LIKELY (path != NULL))
- {
- /* try to unmount the volume first */
- result = thunar_vfs_volume_hal_unmount (volume, window, error);
- thunar_vfs_path_unref (path);
- }
-#endif
-
/* use exo-eject to eject the device */
quoted = g_shell_quote (volume_hal->udi);
result = thunar_vfs_exec_sync ("exo-eject -n -h %s", error, quoted);
@@ -447,11 +464,10 @@
LibHalVolume *hv,
LibHalDrive *hd)
{
- const gchar *volume_label;
- gchar *desired_mount_point;
- gchar *mount_root;
- gchar *basename;
- gchar *filename;
+ gchar *desired_mount_point;
+ gchar *mount_root;
+ gchar *basename;
+ gchar *filename;
_thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_HAL (volume_hal));
_thunar_vfs_return_if_fail (hd != NULL);
@@ -463,20 +479,24 @@
g_free (volume_hal->device_file);
volume_hal->device_file = g_strdup ((hv != NULL) ? libhal_volume_get_device_file (hv) : libhal_drive_get_device_file (hd));
- /* determine the new label */
+ /* compute a usable display name for the volume/drive */
g_free (volume_hal->device_label);
- volume_label = (hv != NULL) ? libhal_volume_get_label (hv) : libhal_drive_get_model (hd);
- if (G_LIKELY (volume_label != NULL && *volume_label != '\0'))
+ volume_hal->device_label = (hv == NULL)
+ ? exo_hal_drive_compute_display_name (context, hd)
+ : exo_hal_volume_compute_display_name (context, hv, hd);
+ if (G_UNLIKELY (volume_hal->device_label == NULL))
{
- /* just use the label provided by HAL */
- volume_hal->device_label = g_strdup (volume_label);
- }
- else
- {
/* use the basename of the device file as label */
volume_hal->device_label = g_path_get_basename (volume_hal->device_file);
}
+ /* compute a usable list of icon names for the volume/drive */
+ g_list_foreach (volume_hal->icon_list, (GFunc) g_free, NULL);
+ g_list_free (volume_hal->icon_list);
+ volume_hal->icon_list = (hv == NULL)
+ ? exo_hal_drive_compute_icon_list (context, hd)
+ : exo_hal_volume_compute_icon_list (context, hv, hd);
+
/* release the previous mount point (if any) */
if (G_LIKELY (volume_hal->mount_point != NULL))
{
@@ -488,49 +508,58 @@
switch (libhal_drive_get_type (hd))
{
case LIBHAL_DRIVE_TYPE_CDROM:
- /* check which kind of CD-ROM/DVD we have */
- switch (libhal_volume_get_disc_type (hv))
+ /* check if we have a pure audio CD without any data track */
+ if (libhal_volume_disc_has_audio (hv) && !libhal_volume_disc_has_data (hv))
{
- case LIBHAL_VOLUME_DISC_TYPE_CDROM:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_CDROM;
- break;
+ /* special treatment for pure audio CDs */
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_AUDIO_CD;
+ }
+ else
+ {
+ /* check which kind of CD-ROM/DVD we have */
+ switch (libhal_volume_get_disc_type (hv))
+ {
+ case LIBHAL_VOLUME_DISC_TYPE_CDROM:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_CDROM;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_CDR:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_CDR;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_CDR:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_CDR;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_CDRW:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_CDRW;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_CDRW:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_CDRW;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_DVDROM:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDROM;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_DVDROM:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDROM;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_DVDRAM:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDRAM;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_DVDRAM:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDRAM;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_DVDR:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDR;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_DVDR:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDR;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_DVDRW:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDRW;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_DVDRW:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDRW;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDPLUSR;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDPLUSR;
+ break;
- case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW:
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDPLUSRW;
- break;
+ case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW:
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_DVDPLUSRW;
+ break;
- default:
- /* unsupported disc type */
- volume_hal->kind = THUNAR_VFS_VOLUME_KIND_UNKNOWN;
- break;
+ default:
+ /* unsupported disc type */
+ volume_hal->kind = THUNAR_VFS_VOLUME_KIND_UNKNOWN;
+ break;
+ }
}
break;
@@ -557,9 +586,10 @@
break;
}
- /* non-disc drives are always present, otherwise it must be a data disc to be usable */
- if (hv == NULL || !libhal_volume_is_disc (hv) || libhal_volume_disc_has_data (hv))
- volume_hal->status |= THUNAR_VFS_VOLUME_STATUS_PRESENT;
+ /* either we have a volume, which means we have media, or
+ * a drive, which means non-pollable then, so it's present
+ */
+ volume_hal->status |= THUNAR_VFS_VOLUME_STATUS_PRESENT;
/* check if the volume is currently mounted */
if (hv != NULL && libhal_volume_is_mounted (hv))
@@ -710,6 +740,13 @@
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = thunar_vfs_volume_manager_hal_finalize;
+
+ /* initialize exo-hal support */
+ if (!exo_hal_init ())
+ {
+ /* atleast warn the user here, so he/she can rebuild libexo with HAL support or ask the admin */
+ g_warning ("exo was built without HAL support. Volume management may not work as expected.");
+ }
}
@@ -953,13 +990,6 @@
hv = libhal_volume_from_udi (context, udi);
if (G_LIKELY (hv != NULL))
{
- /* we don't care for anything other than mountable filesystems */
- if (G_UNLIKELY (libhal_volume_get_fsusage (hv) != LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM))
- {
- libhal_volume_free (hv);
- return;
- }
-
/* determine the UDI of the drive to which this volume belongs */
drive_udi = libhal_volume_get_storage_device_udi (hv);
if (G_LIKELY (drive_udi != NULL))
Modified: thunar/trunk/thunar-vfs/thunar-vfs-volume.c
===================================================================
--- thunar/trunk/thunar-vfs/thunar-vfs-volume.c 2007-01-07 22:42:26 UTC (rev 24299)
+++ thunar/trunk/thunar-vfs/thunar-vfs-volume.c 2007-01-07 22:58:40 UTC (rev 24300)
@@ -237,7 +237,8 @@
kind = thunar_vfs_volume_get_kind (volume);
- return (kind >= THUNAR_VFS_VOLUME_KIND_CDROM && kind <= THUNAR_VFS_VOLUME_KIND_DVDPLUSRW);
+ return (kind >= THUNAR_VFS_VOLUME_KIND_CDROM && kind <= THUNAR_VFS_VOLUME_KIND_DVDPLUSRW)
+ || (kind == THUNAR_VFS_VOLUME_KIND_AUDIO_CD);
}
@@ -333,6 +334,7 @@
case THUNAR_VFS_VOLUME_KIND_FLOPPY:
case THUNAR_VFS_VOLUME_KIND_USBSTICK:
case THUNAR_VFS_VOLUME_KIND_AUDIO_PLAYER:
+ case THUNAR_VFS_VOLUME_KIND_AUDIO_CD:
return TRUE;
default:
@@ -445,6 +447,11 @@
return "gnome-dev-ipod";
break;
+ case THUNAR_VFS_VOLUME_KIND_AUDIO_CD:
+ if (gtk_icon_theme_has_icon (icon_theme, "gnome-dev-cdrom-audio"))
+ return "gnome-dev-cdrom-audio";
+ goto cdrom;
+
default:
break;
}
Modified: thunar/trunk/thunar-vfs/thunar-vfs-volume.h
===================================================================
--- thunar/trunk/thunar-vfs/thunar-vfs-volume.h 2007-01-07 22:42:26 UTC (rev 24299)
+++ thunar/trunk/thunar-vfs/thunar-vfs-volume.h 2007-01-07 22:58:40 UTC (rev 24300)
@@ -53,6 +53,7 @@
* @THUNAR_VFS_VOLUME_KIND_HARDDISK : Hard disk drives.
* @THUNAR_VFS_VOLUME_KIND_USBSTICK : USB sticks.
* @THUNAR_VFS_VOLUME_KIND_AUDIO_PLAYER : Portable audio players (i.e. iPod).
+ * @THUNAR_VFS_VOLUME_KIND_AUDIO_CD : Audio CDs.
*
* Describes the type of a VFS volume.
**/
@@ -72,6 +73,7 @@
THUNAR_VFS_VOLUME_KIND_HARDDISK,
THUNAR_VFS_VOLUME_KIND_USBSTICK,
THUNAR_VFS_VOLUME_KIND_AUDIO_PLAYER,
+ THUNAR_VFS_VOLUME_KIND_AUDIO_CD,
} ThunarVfsVolumeKind;
/**
More information about the Xfce4-commits
mailing list