Index: drive-button.c
===================================================================
--- drive-button.c	(revision 10942)
+++ drive-button.c	(working copy)
@@ -1,6 +1,7 @@
 /* -*- mode: C; c-basic-offset: 4 -*-
  * Drive Mount Applet
  * Copyright (c) 2004 Canonical Ltd
+ * Copyright 2008 Pierre Ossman
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
@@ -43,10 +44,10 @@
 /* type registration boilerplate code */
 G_DEFINE_TYPE(DriveButton, drive_button, GTK_TYPE_BUTTON)
 
-static void     drive_button_set_drive    (DriveButton    *self,
-				           GnomeVFSDrive  *drive);
 static void     drive_button_set_volume   (DriveButton    *self,
-				           GnomeVFSVolume *volume);
+				           GVolume        *volume);
+static void     drive_button_set_mount    (DriveButton    *self,
+				           GMount         *mount);
 static void     drive_button_reset_popup  (DriveButton    *self);
 static void     drive_button_ensure_popup (DriveButton    *self);
 
@@ -92,8 +93,8 @@
     gtk_container_add (GTK_CONTAINER (self), image);
     gtk_widget_show(image);
 
-    self->drive = NULL;
     self->volume = NULL;
+    self->mount = NULL;
     self->icon_size = 24;
     self->update_tag = 0;
 
@@ -101,12 +102,12 @@
 }
 
 GtkWidget *
-drive_button_new (GnomeVFSDrive *drive)
+drive_button_new (GVolume *volume)
 {
     DriveButton *self;
 
     self = g_object_new (DRIVE_TYPE_BUTTON, NULL);
-    drive_button_set_drive (self, drive);
+    drive_button_set_volume (self, volume);
     
     g_signal_connect (gtk_icon_theme_get_default (),
         "changed", G_CALLBACK (drive_button_theme_change),
@@ -116,12 +117,12 @@
 }
 
 GtkWidget *
-drive_button_new_from_volume (GnomeVFSVolume *volume)
+drive_button_new_from_mount (GMount *mount)
 {
     DriveButton *self;
 
     self = g_object_new (DRIVE_TYPE_BUTTON, NULL);
-    drive_button_set_volume (self, volume);
+    drive_button_set_mount (self, mount);
     
     g_signal_connect (gtk_icon_theme_get_default (),
         "changed", G_CALLBACK (drive_button_theme_change),
@@ -135,7 +136,7 @@
 {
     DriveButton *self = DRIVE_BUTTON (object);
 
-    drive_button_set_drive (self, NULL);
+    drive_button_set_volume (self, NULL);
 
     if (self->update_tag)
 	g_source_remove (self->update_tag);
@@ -261,41 +262,41 @@
 }
 
 static void
-drive_button_set_drive (DriveButton *self, GnomeVFSDrive *drive)
+drive_button_set_volume (DriveButton *self, GVolume *volume)
 {
     g_return_if_fail (DRIVE_IS_BUTTON (self));
 
-    if (self->drive) {
-	gnome_vfs_drive_unref (self->drive);
-    }
-    self->drive = NULL;
     if (self->volume) {
-	gnome_vfs_volume_unref (self->volume);
+	g_object_unref (self->volume);
     }
     self->volume = NULL;
+    if (self->mount) {
+	g_object_unref (self->mount);
+    }
+    self->mount = NULL;
 
-    if (drive) {
-	self->drive = gnome_vfs_drive_ref (drive);
+    if (volume) {
+	self->volume = g_object_ref (volume);
     }
     drive_button_queue_update (self);
 }
 
 static void
-drive_button_set_volume (DriveButton *self, GnomeVFSVolume *volume)
+drive_button_set_mount (DriveButton *self, GMount *mount)
 {
     g_return_if_fail (DRIVE_IS_BUTTON (self));
 
-    if (self->drive) {
-	gnome_vfs_drive_unref (self->drive);
-    }
-    self->drive = NULL;
     if (self->volume) {
-	gnome_vfs_volume_unref (self->volume);
+	g_object_unref (self->volume);
     }
     self->volume = NULL;
+    if (self->mount) {
+	g_object_unref (self->mount);
+    }
+    self->mount = NULL;
 
-    if (volume) {
-	self->volume = gnome_vfs_volume_ref (volume);
+    if (mount) {
+	self->mount = g_object_ref (mount);
     }
     drive_button_queue_update (self);
 }
@@ -306,7 +307,8 @@
     DriveButton *self;
     GdkScreen *screen;
     GtkIconTheme *icon_theme;
-    char *icon_name;
+    GtkIconInfo *icon_info;
+    GIcon *icon;
     int width, height;
     GdkPixbuf *pixbuf, *scaled;
     GtkRequisition button_req, image_req;
@@ -318,51 +320,41 @@
 
     drive_button_reset_popup (self);
 
-    /* if no drive or volume, unset image */
-    if (!self->drive && !self->volume) {
+    /* if no volume or mount, unset image */
+    if (!self->volume && !self->mount) {
 	if (GTK_BIN (self)->child != NULL)
 	    gtk_image_set_from_pixbuf (GTK_IMAGE (GTK_BIN (self)->child), NULL);
 	return FALSE;
     }
 
-    if (self->drive) {
-	display_name = gnome_vfs_drive_get_display_name (self->drive);
-	if (gnome_vfs_drive_is_mounted (self->drive))
+    if (self->volume) {
+	GMount *mount;
+
+	display_name = g_volume_get_name (self->volume);
+	mount = g_volume_get_mount (self->volume);
+
+	if (mount)
 	    tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
-	else if (gnome_vfs_drive_is_connected (self->drive))
+	else
 	    tip = g_strdup_printf ("%s\n%s", display_name, _("(not mounted)"));
+
+	if (mount)
+	    icon = g_mount_get_icon (mount);
 	else
-	    tip = g_strdup_printf ("%s\n%s", display_name, _("(not connected)"));
+	    icon = g_volume_get_icon (self->volume);
+
+	if (mount)
+	    g_object_unref (mount);
     } else {
-	display_name = gnome_vfs_volume_get_display_name (self->volume);
-	if (gnome_vfs_volume_is_mounted (self->volume))
-	    tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
-	else
-	    tip = g_strdup_printf ("%s\n%s", display_name, _("(not mounted)"));
+	display_name = g_mount_get_name (self->mount);
+	tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
+	icon = g_mount_get_icon (self->mount);
     }
 
     gtk_widget_set_tooltip_text (GTK_WIDGET (self), tip);
     g_free (tip);
     g_free (display_name);
 
-    /* get the icon for the first mounted volume, or the drive itself */
-    if (self->drive) {
-	if (gnome_vfs_drive_is_mounted (self->drive)) {
-	    GList *volumes;
-	    GnomeVFSVolume *volume;
-
-	    volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
-	    volume = GNOME_VFS_VOLUME (volumes->data);
-	    icon_name = gnome_vfs_volume_get_icon (volume);
-	    g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
-	    g_list_free (volumes);
-	} else {
-	    icon_name = gnome_vfs_drive_get_icon (self->drive);
-	}
-    } else {
-	icon_name = gnome_vfs_volume_get_icon (self->volume);
-    }
-
     /* base the icon size on the desired button size */
     gtk_widget_size_request (GTK_WIDGET (self), &button_req);
     gtk_widget_size_request (GTK_BIN (self)->child, &image_req);
@@ -371,10 +363,17 @@
 
     screen = gtk_widget_get_screen (GTK_WIDGET (self));
     icon_theme = gtk_icon_theme_get_for_screen (screen);
-    pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
-				       MIN (width, height), 0, NULL);
-    g_free (icon_name);
+    icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon,
+    						MIN (width, height),
+    						GTK_ICON_LOOKUP_USE_BUILTIN);
+    if (icon_info)
+    {
+	pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+	gtk_icon_info_free (icon_info);
+    }
 
+    g_object_unref (icon);
+
     if (!pixbuf)
 	return FALSE;
 
@@ -415,16 +414,38 @@
 drive_button_compare (DriveButton *button, DriveButton *other_button)
 {
     /* sort drives before driveless volumes volumes */
-    if (button->drive) {
-	if (other_button->drive)
-	    return gnome_vfs_drive_compare (button->drive, other_button->drive);
-	else
+    if (button->volume) {
+	if (other_button->volume)
+	{
+	    int cmp;
+	    gchar *str1, *str2;
+
+	    str1 = g_volume_get_name (button->volume);
+	    str2 = g_volume_get_name (other_button->volume);
+	    cmp = g_utf8_collate (str1, str2);
+	    g_free (str2);
+	    g_free (str1);
+
+	    return cmp;
+	} else {
 	    return -1;
+	}
     } else {
-	if (other_button->drive)
+	if (other_button->volume)
+	{
 	    return 1;
-	else
-	    return gnome_vfs_volume_compare (button->volume, other_button->volume);
+	} else {
+	    int cmp;
+	    gchar *str1, *str2;
+
+	    str1 = g_mount_get_name (button->mount);
+	    str2 = g_mount_get_name (other_button->mount);
+	    cmp = g_utf8_collate (str1, str2);
+	    g_free (str2);
+	    g_free (str1);
+
+	    return cmp;
+	}
     }
 }
 
@@ -467,15 +488,15 @@
     return new_str;
 }
 static GtkWidget *
-create_menu_item (DriveButton *self, const gchar *stock_id,
+create_menu_item (DriveButton *self, const gchar *icon_name,
 		  const gchar *label, GCallback callback,
 		  gboolean sensitive)
 {
     GtkWidget *item, *image;
 
     item = gtk_image_menu_item_new_with_mnemonic (label);
-    if (stock_id) {
-	image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+    if (icon_name) {
+	image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
 	gtk_widget_show (image);
     }
@@ -497,26 +518,27 @@
 
     screen = gtk_widget_get_screen (GTK_WIDGET (self));
 
-    if (self->drive) {
-	argv[1] = gnome_vfs_drive_get_activation_uri (self->drive);
-	/* if the drive has no activation URI, get the activation URI
-	 * of it's first mounted volume */
-	if (!argv[1]) {
-	    GList *volumes;
-	    GnomeVFSVolume *volume;
+    if (self->volume) {
+	GMount *mount;
 
-	    volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
-	    if (volumes) {
-		volume = GNOME_VFS_VOLUME (volumes->data);
+	mount = g_volume_get_mount (self->volume);
+	if (mount) {
+	    GFile *file;
 
-		argv[1] = gnome_vfs_volume_get_activation_uri (volume);
-		g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
-		g_list_free (volumes);
-	    }
+	    file = g_mount_get_root (mount);
+
+	    argv[1] = g_file_get_uri (file);
+	    g_object_unref(file);
+
+	    g_object_unref(mount);
 	}
-    } else if (self->volume)
-	argv[1] = gnome_vfs_volume_get_activation_uri (self->volume);
-    else
+    } else if (self->mount) {
+	GFile *file;
+
+	file = g_mount_get_root (self->mount);
+	argv[1] = g_file_get_uri (file);
+	g_object_unref(file);
+    } else
 	g_return_if_reached();
 
     if (!gdk_spawn_on_screen (screen, NULL, argv, NULL,
@@ -538,226 +560,11 @@
 }
 
 static void
-mount_result (gboolean succeeded,
-	      char *error,
-	      char *detailed_error,
-	      gpointer data)
-{
-    GtkWidget *dialog, *hbox, *vbox, *image, *label;
-    char *title, *str;
-
-    if (!succeeded) {
-	switch (GPOINTER_TO_INT(data)) {
-	case CMD_MOUNT_OR_PLAY:
-	    title = _("Mount Error");
-	    break;
-	case CMD_UNMOUNT:
-	    title = _("Unmount Error");
-	    break;
-	case CMD_EJECT:
-	    title = _("Eject Error");
-	    break;
-	default:
-	    title = _("Error");
-	}
-
-	dialog = gtk_dialog_new ();
-	atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
-	gtk_window_set_title (GTK_WINDOW (dialog), title);
-	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
-	gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
-	hbox = gtk_hbox_new (FALSE, 12);
-	gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
-	gtk_widget_show (hbox);
-	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
-			    FALSE, FALSE, 0);
-
-	image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR,
-					  GTK_ICON_SIZE_DIALOG);
-	gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
-	gtk_widget_show (image);
-	gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
-	vbox = gtk_vbox_new (FALSE, 12);
-	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-	gtk_widget_show (vbox);
-
-	str = g_strconcat ("<span weight=\"bold\" size=\"larger\">",
-			   error, "</span>", NULL);
-	label = gtk_label_new (str);
-	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
-	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
-	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-	gtk_widget_show (label);
-	g_free (str);
-
-	label = gtk_label_new (detailed_error);
-	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
-	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-	gtk_widget_show (label);
-
-	gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK,
-			       GTK_RESPONSE_OK);
-	gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-					 GTK_RESPONSE_YES);
-
-	gtk_widget_show (dialog);
-	g_signal_connect (dialog, "response",
-			  G_CALLBACK (gtk_object_destroy), NULL);
-
-    }
-}
-
-/* copied from gnome-volume-manager/src/manager.c maybe there is a better way than
- * duplicating this code? */
-
-/*
- * gvm_run_command - run the given command, replacing %d with the device node
- * and %m with the given path
- */
-static void
-gvm_run_command (const char *device, const char *command, const char *path)
-{
-	char *argv[4];
-	gchar *new_command;
-	GError *error = NULL;
-	GString *exec = g_string_new (NULL);
-	char *p, *q;
-
-	/* perform s/%d/device/ and s/%m/path/ */
-	new_command = g_strdup (command);
-	q = new_command;
-	p = new_command;
-	while ((p = strchr (p, '%')) != NULL) {
-		if (*(p + 1) == 'd') {
-			*p = '\0';
-			g_string_append (exec, q);
-			g_string_append (exec, device);
-			q = p + 2;
-			p = p + 2;
-		} else if (*(p + 1) == 'm') {
-			*p = '\0';
-			g_string_append (exec, q);
-			g_string_append (exec, path);
-			q = p + 2;
-			p = p + 2;
-		}
-	}
-	g_string_append (exec, q);
-
-	argv[0] = "/bin/sh";
-	argv[1] = "-c";
-	argv[2] = exec->str;
-	argv[3] = NULL;
-
-	g_spawn_async (g_get_home_dir (), argv, NULL, 0, NULL, NULL,
-		       NULL, &error);
-	if (error) {
-		g_warning ("failed to exec %s: %s\n", exec->str, error->message);
-		g_error_free (error);
-	}
-
-	g_string_free (exec, TRUE);
-	g_free (new_command);
-}
-
-/*
- * gvm_check_dvd_only - is this a Video DVD?
- *
- * Returns TRUE if this was a Video DVD and FALSE otherwise.
- * (the original in gvm was also running the autoplay action,
- * I removed that code, so I renamed from gvm_check_dvd to
- * gvm_check_dvd_only)
- */
-static gboolean
-gvm_check_dvd_only (const char *udi, const char *device, const char *mount_point)
-{
-	char *path;
-	gboolean retval;
-	
-	path = g_build_path (G_DIR_SEPARATOR_S, mount_point, "video_ts", NULL);
-	retval = g_file_test (path, G_FILE_TEST_IS_DIR);
-	g_free (path);
-	
-	/* try the other name, if needed */
-	if (retval == FALSE) {
-		path = g_build_path (G_DIR_SEPARATOR_S, mount_point,
-				     "VIDEO_TS", NULL);
-		retval = g_file_test (path, G_FILE_TEST_IS_DIR);
-		g_free (path);
-	}
-	
-	return retval;
-}
-/* END copied from gnome-volume-manager/src/manager.c */
-
-static gboolean
-check_dvd_video (GnomeVFSVolume *volume)
-{
-	char *device_path = gnome_vfs_volume_get_device_path (volume);
-	char *uri = gnome_vfs_volume_get_activation_uri (volume);
-	char *mount_path = gnome_vfs_get_local_path_from_uri (uri);
-	char *udi = gnome_vfs_volume_get_hal_udi (volume);
-
-	gboolean result = gvm_check_dvd_only (udi, device_path, mount_path);
-
-	g_free (device_path);
-	g_free (udi);
-	g_free (uri);
-	g_free (mount_path);
-
-	return result;
-}
-
-static gboolean
-check_audio_cd (DriveButton *self, GnomeVFSVolume *volume)
-{
-	char *activation_uri = gnome_vfs_volume_get_activation_uri (volume);
-	// we have an audioCD if the activation URI starts by 'cdda://'
-	gboolean result = (strncmp ("cdda://", activation_uri, 7) == 0);
-	g_free (activation_uri);
-	return result;
-}
-
-static void
-run_command (DriveButton *self, const char *command)
-{
-	char *uri, *mount_path;
-	char *device_path = gnome_vfs_drive_get_device_path (self->drive);
-
-	GList *volumes;
-	GnomeVFSVolume *volume;
-
-	volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
-	volume = GNOME_VFS_VOLUME (volumes->data);
-	uri = gnome_vfs_volume_get_activation_uri (volume);
-	mount_path = gnome_vfs_get_local_path_from_uri (uri);
-	g_free (uri);
-
-	gnome_vfs_drive_get_display_name (self->drive);
-	gvm_run_command (device_path, command,
-				 mount_path);
-
-	g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
-	g_list_free (volumes);
-
-	g_free (mount_path);
-	g_free (device_path);
-}
-
-static void
 mount_drive (DriveButton *self, GtkWidget *item)
 {
-    if (self->drive) {
-	gnome_vfs_drive_mount (self->drive, mount_result,
-			       GINT_TO_POINTER(CMD_MOUNT_OR_PLAY));
+    if (self->volume) {
+	g_volume_mount (self->volume, G_MOUNT_MOUNT_NONE,
+			NULL, NULL, NULL, NULL);
     } else {
 	g_return_if_reached();
     }
@@ -765,12 +572,19 @@
 static void
 unmount_drive (DriveButton *self, GtkWidget *item)
 {
-    if (self->drive) {
-	gnome_vfs_drive_unmount (self->drive, mount_result,
-				 GINT_TO_POINTER(CMD_UNMOUNT));
-    } else if (self->volume) {
-	gnome_vfs_volume_unmount (self->volume, mount_result,
-				  GINT_TO_POINTER(CMD_UNMOUNT));
+    if (self->volume) {
+	GMount *mount;
+
+	mount = g_volume_get_mount (self->volume);
+	if (mount)
+	{
+	    g_mount_unmount (mount, G_MOUNT_UNMOUNT_NONE,
+			     NULL, NULL, NULL);
+	    g_object_unref (mount);
+	}
+    } else if (self->mount) {
+	g_mount_unmount (self->mount, G_MOUNT_UNMOUNT_NONE,
+			 NULL, NULL, NULL);
     } else {
 	g_return_if_reached();
     }
@@ -778,107 +592,46 @@
 static void
 eject_drive (DriveButton *self, GtkWidget *item)
 {
-    if (self->drive) {
-	gnome_vfs_drive_eject (self->drive, mount_result,
-			       GINT_TO_POINTER(CMD_EJECT));
-    } else if (self->volume) {
-	gnome_vfs_volume_eject (self->volume, mount_result,
-				GINT_TO_POINTER(CMD_EJECT));
+    if (self->volume) {
+	g_volume_eject (self->volume, G_MOUNT_UNMOUNT_NONE,
+			NULL, NULL, NULL);
+    } else if (self->mount) {
+	g_mount_eject (self->mount, G_MOUNT_UNMOUNT_NONE,
+		       NULL, NULL, NULL);
     } else {
 	g_return_if_reached();
     }
 }
-static void
-play_autoplay_media (DriveButton *self, const char *autoplay_key)
-{
-	GConfClient *gconf_client = gconf_client_get_default ();
-	char *command = gconf_client_get_string (gconf_client,
-			autoplay_key, NULL);
-	run_command (self, command);
-	g_free (command);
-	g_object_unref (gconf_client);
-}
 
 static void
-play_dvd (DriveButton *self, GtkWidget *item)
-{
-	play_autoplay_media (self, GCONF_ROOT_AUTOPLAY "autoplay_dvd_command");
-}
-
-static void
-play_cda (DriveButton *self, GtkWidget *item)
-{
-	play_autoplay_media (self, GCONF_ROOT_AUTOPLAY "autoplay_cda_command");
-}
-
-static void
 drive_button_ensure_popup (DriveButton *self)
 {
-    GnomeVFSDeviceType device_type;
     char *display_name, *tmp, *label;
     int action = CMD_NONE;
     GtkWidget *item;
-    GCallback callback;
-    const char *action_icon;
     gboolean ejectable;
 
     if (self->popup_menu) return;
 
-    if (self->drive) {
-	GnomeVFSVolume *volume = NULL;
-	GList *volumes;
+    if (self->volume) {
+	GMount *mount = NULL;
 
-	if (!gnome_vfs_drive_is_connected (self->drive)) return;
+	display_name = g_volume_get_name (self->volume);
+	ejectable = g_volume_can_eject (self->volume);
 
-	device_type = gnome_vfs_drive_get_device_type (self->drive);
-	display_name = gnome_vfs_drive_get_display_name (self->drive);
-	ejectable = gnome_vfs_drive_needs_eject (self->drive);
+	mount = g_volume_get_mount (self->volume);
 
-	if (gnome_vfs_drive_is_mounted (self->drive)) {
+	if (mount) {
 	    if (!ejectable)
 		action = CMD_UNMOUNT;
 	} else {
 	    action = CMD_MOUNT_OR_PLAY;
 	}
     
-	volumes = gnome_vfs_drive_get_mounted_volumes (self->drive);
-	if (volumes != NULL)
-	{
-		volume = GNOME_VFS_VOLUME (volumes->data);
-		device_type = gnome_vfs_volume_get_device_type (volume);
-	}
-
-	/*
-	 * For some reason, on my computer, I get GNOME_VFS_DEVICE_TYPE_CDROM
-	 * also for DVDs and Audio CDs, while for DVD the icon is correctly the
-	 * one for DVDs and for Audio CDs the description correctly that of an
-	 * audio CD? So i have this hack.
-	 */
-	if (volume)
-	{
-		if (check_dvd_video (volume))
-		{
-			device_type = GNOME_VFS_DEVICE_TYPE_VIDEO_DVD;
-		}
-		if (check_audio_cd (self, volume))
-		{
-			device_type = GNOME_VFS_DEVICE_TYPE_AUDIO_CD;
-		}
-	}
-
-	g_list_foreach (volumes, (GFunc)gnome_vfs_volume_unref, NULL);
-	g_list_free (volumes);
+	g_object_unref (mount);
     } else {
-	GnomeVFSDrive* drive = gnome_vfs_volume_get_drive (self->volume);
-
-	if (!gnome_vfs_volume_is_mounted (self->volume)) return;
-
-	device_type = gnome_vfs_volume_get_device_type (self->volume);
-	display_name = gnome_vfs_volume_get_display_name (self->volume);
-	if (drive)
-	    ejectable = gnome_vfs_drive_needs_eject (drive);
-	else
-	    ejectable = FALSE;
+	display_name = g_mount_get_name (self->mount);
+	ejectable = g_mount_can_eject (self->mount);
 	if (!ejectable)
 	    action = CMD_UNMOUNT;
     }
@@ -890,26 +643,9 @@
     g_free (display_name);
     display_name = tmp;
 
-	callback = G_CALLBACK (open_drive);
-	action_icon = GTK_STOCK_OPEN;
-
-	switch (device_type) {
-	case GNOME_VFS_DEVICE_TYPE_VIDEO_DVD:
-		label = g_strdup (_("_Play DVD"));
-		callback = G_CALLBACK (play_dvd);
-		action_icon = GTK_STOCK_MEDIA_PLAY;
-		break;
-	case GNOME_VFS_DEVICE_TYPE_AUDIO_CD:
-		label = g_strdup (_("_Play CD"));
-		callback = G_CALLBACK (play_cda);
-		action_icon = GTK_STOCK_MEDIA_PLAY;
-		break;
-	default:
-		label = g_strdup_printf (_("_Open %s"), display_name);
-	}
-
-	item = create_menu_item (self, action_icon, label,
-			     callback,
+    label = g_strdup_printf (_("_Open %s"), display_name);
+    item = create_menu_item (self, "document-open", label,
+			     G_CALLBACK (open_drive),
 			     action != CMD_MOUNT_OR_PLAY);
     g_free (label);
     gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
@@ -936,7 +672,7 @@
     if (ejectable)
     {
 	label = g_strdup_printf (_("_Eject %s"), display_name);
-	item = create_menu_item (self, NULL, label,
+	item = create_menu_item (self, "media-eject", label,
 				 G_CALLBACK (eject_drive), TRUE);
 	g_free (label);
 	gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
Index: drive-list.c
===================================================================
--- drive-list.c	(revision 10942)
+++ drive-list.c	(working copy)
@@ -1,6 +1,7 @@
 /* -*- mode: C; c-basic-offset: 4 -*-
  * Drive Mount Applet
  * Copyright (c) 2004 Canonical Ltd
+ * Copyright 2008 Pierre Ossman
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
@@ -30,33 +31,39 @@
 
 G_DEFINE_TYPE (DriveList, drive_list, GTK_TYPE_TABLE);
 
-static GnomeVFSVolumeMonitor *volume_monitor = NULL;
+static GVolumeMonitor *volume_monitor = NULL;
 
 static void drive_list_finalize (GObject *object);
 static void drive_list_destroy  (GtkObject *object);
 static void drive_list_add      (GtkContainer *container, GtkWidget *child);
 static void drive_list_remove   (GtkContainer *container, GtkWidget *child);
 
-static void volume_mounted     (GnomeVFSVolumeMonitor *monitor,
-				GnomeVFSVolume *volume,
+static void mount_added        (GVolumeMonitor *monitor,
+				GMount *mount,
 				DriveList *self);
-static void volume_unmounted   (GnomeVFSVolumeMonitor *monitor,
-				GnomeVFSVolume *volume,
+static void mount_changed      (GVolumeMonitor *monitor,
+				GMount *mount,
 				DriveList *self);
-static void drive_connected    (GnomeVFSVolumeMonitor *monitor,
-				GnomeVFSDrive *drive,
+static void mount_removed      (GVolumeMonitor *monitor,
+				GMount *mount,
 				DriveList *self);
-static void drive_disconnected (GnomeVFSVolumeMonitor *monitor,
-				GnomeVFSDrive *drive,
+static void volume_added       (GVolumeMonitor *monitor,
+				GVolume *volume,
 				DriveList *self);
-static void add_drive          (DriveList *self,
-				GnomeVFSDrive *drive);
-static void remove_drive       (DriveList *self,
-				GnomeVFSDrive *drive);
+static void volume_changed     (GVolumeMonitor *monitor,
+				GVolume *volume,
+				DriveList *self);
+static void volume_removed     (GVolumeMonitor *monitor,
+				GVolume *volume,
+				DriveList *self);
 static void add_volume         (DriveList *self,
-				GnomeVFSVolume *volume);
+				GVolume *volume);
 static void remove_volume      (DriveList *self,
-				GnomeVFSVolume *volume);
+				GVolume *volume);
+static void add_mount          (DriveList *self,
+				GMount *mount);
+static void remove_mount       (DriveList *self,
+				GMount *mount);
 
 static void
 drive_list_class_init (DriveListClass *class)
@@ -70,12 +77,12 @@
 static void
 drive_list_init (DriveList *self)
 {
-    GList *connected_drives, *mounted_volumes, *tmp;
+    GList *volumes, *mounts, *tmp;
 
     gtk_table_set_homogeneous (GTK_TABLE (self), TRUE);
 
-    self->drives = g_hash_table_new (NULL, NULL);
     self->volumes = g_hash_table_new (NULL, NULL);
+    self->mounts = g_hash_table_new (NULL, NULL);
     self->orientation = GTK_ORIENTATION_HORIZONTAL;
     self->layout_tag = 0;
     self->icon_size = 24;
@@ -84,33 +91,37 @@
     /* listen for drive connects/disconnects, and add
      * currently connected drives. */
     if (!volume_monitor)
-	volume_monitor = gnome_vfs_get_volume_monitor ();
+	volume_monitor = g_volume_monitor_get ();
 
-    g_signal_connect_object (volume_monitor, "volume_mounted",
-			     G_CALLBACK (volume_mounted), self, 0);
-    g_signal_connect_object (volume_monitor, "volume_unmounted",
-			     G_CALLBACK (volume_unmounted), self, 0);
-    g_signal_connect_object (volume_monitor, "drive_connected",
-			     G_CALLBACK (drive_connected), self, 0);
-    g_signal_connect_object (volume_monitor, "drive_disconnected",
-			     G_CALLBACK (drive_disconnected), self, 0);
-    connected_drives = gnome_vfs_volume_monitor_get_connected_drives (volume_monitor);
-    for (tmp = connected_drives; tmp != NULL; tmp = tmp->next) {
-	GnomeVFSDrive *drive = tmp->data;
+    g_signal_connect_object (volume_monitor, "mount_added",
+			     G_CALLBACK (mount_added), self, 0);
+    g_signal_connect_object (volume_monitor, "mount_changed",
+			     G_CALLBACK (mount_changed), self, 0);
+    g_signal_connect_object (volume_monitor, "mount_removed",
+			     G_CALLBACK (mount_removed), self, 0);
+    g_signal_connect_object (volume_monitor, "volume_added",
+			     G_CALLBACK (volume_added), self, 0);
+    g_signal_connect_object (volume_monitor, "volume_changed",
+			     G_CALLBACK (volume_changed), self, 0);
+    g_signal_connect_object (volume_monitor, "volume_removed",
+			     G_CALLBACK (volume_removed), self, 0);
+    volumes = g_volume_monitor_get_volumes (volume_monitor);
+    for (tmp = volumes; tmp != NULL; tmp = tmp->next) {
+	GVolume *volume = tmp->data;
 
-	add_drive (self, drive);
-	gnome_vfs_drive_unref (drive);
+	add_volume (self, volume);
+	g_object_unref (volume);
     }
-    g_list_free (connected_drives);
+    g_list_free (volumes);
 
-    mounted_volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
-    for (tmp = mounted_volumes; tmp != NULL; tmp = tmp->next) {
-	GnomeVFSVolume *volume = tmp->data;
+    mounts = g_volume_monitor_get_mounts (volume_monitor);
+    for (tmp = mounts; tmp != NULL; tmp = tmp->next) {
+	GMount *mount = tmp->data;
 
-	add_volume (self, volume);
-	gnome_vfs_volume_unref (volume);
+	add_mount (self, mount);
+	g_object_unref (mount);
     }
-    g_list_free (mounted_volumes);
+    g_list_free (mounts);
 }
 
 GtkWidget *
@@ -124,8 +135,8 @@
 {
     DriveList *self = DRIVE_LIST (object);
 
-    g_hash_table_destroy (self->drives);
     g_hash_table_destroy (self->volumes);
+    g_hash_table_destroy (self->mounts);
 
     if (G_OBJECT_CLASS (drive_list_parent_class)->finalize)
 	(* G_OBJECT_CLASS (drive_list_parent_class)->finalize) (object);
@@ -137,13 +148,17 @@
     DriveList *self = DRIVE_LIST (object);
 
     g_signal_handlers_disconnect_by_func (volume_monitor,
-					  G_CALLBACK (volume_mounted), self);
+					  G_CALLBACK (mount_added), self);
     g_signal_handlers_disconnect_by_func (volume_monitor,
-					  G_CALLBACK (volume_unmounted), self);
+					  G_CALLBACK (mount_changed), self);
     g_signal_handlers_disconnect_by_func (volume_monitor,
-					  G_CALLBACK (drive_connected), self);
+					  G_CALLBACK (mount_removed), self);
     g_signal_handlers_disconnect_by_func (volume_monitor,
-					  G_CALLBACK (drive_disconnected), self);
+					  G_CALLBACK (volume_added), self);
+    g_signal_handlers_disconnect_by_func (volume_monitor,
+					  G_CALLBACK (volume_changed), self);
+    g_signal_handlers_disconnect_by_func (volume_monitor,
+					  G_CALLBACK (volume_removed), self);
 
     if (self->layout_tag)
 	g_source_remove (self->layout_tag);
@@ -168,10 +183,10 @@
 
     self = DRIVE_LIST (container);
     button = DRIVE_BUTTON (child);
-    if (button->drive)
-	g_hash_table_insert (self->drives, button->drive, button);
+    if (button->volume)
+	g_hash_table_insert (self->volumes, button->volume, button);
     else
-	g_hash_table_insert (self->volumes, button->volume, button);
+	g_hash_table_insert (self->mounts, button->mount, button);
 }
 
 static void
@@ -185,10 +200,10 @@
 
     self = DRIVE_LIST (container);
     button = DRIVE_BUTTON (child);
-    if (button->drive)
-	g_hash_table_remove (self->drives, button->drive);
+    if (button->volume)
+	g_hash_table_remove (self->volumes, button->volume);
     else
-	g_hash_table_remove (self->volumes, button->volume);
+	g_hash_table_remove (self->mounts, button->mount);
 
     if (GTK_CONTAINER_CLASS (drive_list_parent_class)->remove)
 	(* GTK_CONTAINER_CLASS (drive_list_parent_class)->remove) (container,
@@ -214,8 +229,8 @@
 
 
     self->layout_tag = 0;
-    g_hash_table_foreach (self->drives, list_buttons, &sorted_buttons);
     g_hash_table_foreach (self->volumes, list_buttons, &sorted_buttons);
+    g_hash_table_foreach (self->mounts, list_buttons, &sorted_buttons);
 
     /* position buttons in the table according to their sorted order */
     for (tmp = sorted_buttons, i = 0; tmp != NULL; tmp = tmp->next, i++) {
@@ -252,77 +267,82 @@
 }
 
 static void
-volume_mounted (GnomeVFSVolumeMonitor *monitor,
-		GnomeVFSVolume *volume,
-		DriveList *self)
+mount_added (GVolumeMonitor *monitor,
+	     GMount *mount,
+	     DriveList *self)
 {
-    GnomeVFSDrive *drive;
+    add_mount (self, mount);
+
+    mount_changed(monitor, mount, self);
+}
+
+static void
+mount_changed (GVolumeMonitor *monitor,
+	       GMount *mount,
+	       DriveList *self)
+{
+    GVolume *volume;
     DriveButton *button = NULL;;
 
-    add_volume (self, volume);
-
-    drive = gnome_vfs_volume_get_drive (volume);
-    if (drive) {
-	button = g_hash_table_lookup (self->drives, drive);
-	gnome_vfs_drive_unref (drive);
+    volume = g_mount_get_volume (mount);
+    if (volume) {
+	button = g_hash_table_lookup (self->volumes, volume);
+	g_object_unref (volume);
     } else {
-	button = g_hash_table_lookup (self->volumes, volume);
+	button = g_hash_table_lookup (self->mounts, mount);
     }
     if (button)
 	drive_button_queue_update (button);
 }
 
 static void
-volume_unmounted (GnomeVFSVolumeMonitor *monitor,
-		  GnomeVFSVolume *volume,
-		  DriveList *self)
+mount_removed (GVolumeMonitor *monitor,
+	       GMount *mount,
+	       DriveList *self)
 {
-    GnomeVFSDrive *drive;
-    DriveButton *button = NULL;;
+    remove_mount (self, mount);
 
-    remove_volume (self, volume);
+    mount_changed(monitor, mount, self);
+}
 
-    drive = gnome_vfs_volume_get_drive (volume);
-    if (drive) {
-	button = g_hash_table_lookup (self->drives, drive);
-	gnome_vfs_drive_unref (drive);
-    } else {
-	button = g_hash_table_lookup (self->volumes, volume);
-    }
-    if (button)
-	drive_button_queue_update (button);
+static void
+volume_added (GVolumeMonitor *monitor,
+	      GVolume *volume,
+	      DriveList *self)
+{
+    add_volume (self, volume);
 }
 
 static void
-drive_connected (GnomeVFSVolumeMonitor *monitor,
-		 GnomeVFSDrive *drive,
-		 DriveList *self)
+volume_changed (GVolumeMonitor *monitor,
+		GVolume *volume,
+		DriveList *self)
 {
-    add_drive (self, drive);
+    DriveButton *button = NULL;;
+
+    button = g_hash_table_lookup (self->volumes, volume);
+    if (button)
+	drive_button_queue_update (button);
 }
 
 static void
-drive_disconnected (GnomeVFSVolumeMonitor *monitor,
-		    GnomeVFSDrive *drive,
-		    DriveList *self)
+volume_removed (GVolumeMonitor *monitor,
+		GVolume *volume,
+		DriveList *self)
 {
-    remove_drive (self, drive);
+    remove_volume (self, volume);
 }
 
 static void
-add_drive (DriveList *self, GnomeVFSDrive *drive)
+add_volume (DriveList *self, GVolume *volume)
 {
     GtkWidget *button;
 
-    /* ignore non user visible drives */
-    if (!gnome_vfs_drive_is_user_visible (drive))
+    /* if the volume has already been added, return */
+    if (g_hash_table_lookup (self->volumes, volume) != NULL)
 	return;
 
-    /* if the drive has already been added, return */
-    if (g_hash_table_lookup (self->drives, drive) != NULL)
-	return;
-
-    button = drive_button_new (drive);
+    button = drive_button_new (volume);
     gtk_button_set_relief (GTK_BUTTON (button), self->relief);
     drive_button_set_size (DRIVE_BUTTON (button), self->icon_size);
     gtk_container_add (GTK_CONTAINER (self), button);
@@ -331,12 +351,12 @@
 }
 
 static void
-remove_drive (DriveList *self, GnomeVFSDrive *drive)
+remove_volume (DriveList *self, GVolume *volume)
 {
     GtkWidget *button;
 
-    /* if the drive has already been added, return */
-    button = g_hash_table_lookup (self->drives, drive);
+    /* if the volume has already been added, return */
+    button = g_hash_table_lookup (self->volumes, volume);
     if (button) {
 	gtk_container_remove (GTK_CONTAINER (self), button);
 	queue_relayout (self);
@@ -344,32 +364,23 @@
 }
 
 static void
-add_volume (DriveList *self, GnomeVFSVolume *volume)
+add_mount (DriveList *self, GMount *mount)
 {
     GtkWidget *button;
-    GnomeVFSDrive *drive;
+    GVolume *volume;
 
-    /* ignore non user visible volumes */
-    if (!gnome_vfs_volume_is_user_visible (volume))
+    /* ignore mounts attached to a volume */
+    volume = g_mount_get_volume (mount);
+    if (volume) {
+	g_object_unref (volume);
 	return;
-
-    /* ignore "connected servers" style volumes */
-    if (gnome_vfs_volume_get_volume_type (volume)
-	== GNOME_VFS_VOLUME_TYPE_CONNECTED_SERVER)
-	return;
-
-    /* ignore volumes attached to a drive */
-    drive = gnome_vfs_volume_get_drive (volume);
-    if (drive) {
-	gnome_vfs_drive_unref (drive);
-	return;
     }
 
-    /* if the volume has already been added, return */
-    if (g_hash_table_lookup (self->volumes, volume) != NULL)
+    /* if the mount has already been added, return */
+    if (g_hash_table_lookup (self->mounts, mount) != NULL)
 	return;
 
-    button = drive_button_new_from_volume (volume);
+    button = drive_button_new_from_mount (mount);
     gtk_button_set_relief (GTK_BUTTON (button), self->relief);
     drive_button_set_size (DRIVE_BUTTON (button), self->icon_size);
     gtk_container_add (GTK_CONTAINER (self), button);
@@ -378,12 +389,12 @@
 }
 
 static void
-remove_volume (DriveList *self, GnomeVFSVolume *volume)
+remove_mount (DriveList *self, GMount *mount)
 {
     GtkWidget *button;
 
-    /* if the drive has already been added, return */
-    button = g_hash_table_lookup (self->volumes, volume);
+    /* if the mount has already been added, return */
+    button = g_hash_table_lookup (self->mounts, mount);
     if (button) {
 	gtk_container_remove (GTK_CONTAINER (self), button);
 	queue_relayout (self);
@@ -419,8 +430,8 @@
 
     if (self->icon_size != panel_size) {
 	self->icon_size = panel_size;
-	g_hash_table_foreach (self->drives, set_icon_size, self);
 	g_hash_table_foreach (self->volumes, set_icon_size, self);
+	g_hash_table_foreach (self->mounts, set_icon_size, self);
     }
 }
 
@@ -444,6 +455,6 @@
         return;
 
     self->relief = relief;
-    g_hash_table_foreach (self->drives, set_button_relief, self);
     g_hash_table_foreach (self->volumes, set_button_relief, self);
+    g_hash_table_foreach (self->mounts, set_button_relief, self);
 }
Index: drive-button.h
===================================================================
--- drive-button.h	(revision 10942)
+++ drive-button.h	(working copy)
@@ -24,7 +24,6 @@
 #define DRIVE_BUTTON_H
 
 #include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
 
 G_BEGIN_DECLS
 
@@ -42,8 +41,8 @@
 {
     GtkButton parent;
 
-    GnomeVFSDrive *drive;
-    GnomeVFSVolume *volume;
+    GVolume *volume;
+    GMount *mount;
     int icon_size;
     guint update_tag;
 
@@ -56,8 +55,8 @@
 };
 
 GType      drive_button_get_type        (void);
-GtkWidget *drive_button_new             (GnomeVFSDrive *drive);
-GtkWidget *drive_button_new_from_volume (GnomeVFSVolume *volume);
+GtkWidget *drive_button_new             (GVolume *volume);
+GtkWidget *drive_button_new_from_mount  (GMount *mount);
 void       drive_button_queue_update    (DriveButton *button);
 void       drive_button_set_size        (DriveButton *button,
 					 int          icon_size);
Index: drive-list.h
===================================================================
--- drive-list.h	(revision 10942)
+++ drive-list.h	(working copy)
@@ -24,7 +24,6 @@
 #define DRIVE_LIST_H
 
 #include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
 
 G_BEGIN_DECLS
 
@@ -42,8 +41,8 @@
 {
     GtkTable parent;
 
-    GHashTable *drives;
     GHashTable *volumes;
+    GHashTable *mounts;
     GtkOrientation orientation;
     guint layout_tag;
     GtkReliefStyle relief;
Index: drivemount.c
===================================================================
--- drivemount.c	(revision 10942)
+++ drivemount.c	(working copy)
@@ -27,7 +27,6 @@
 #include <string.h>
 
 #include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <libgnomeui/gnome-help.h>
 #include <panel-applet.h>
 
