--- gnome-applets-2.10.1/drivemount/drive-button.c	2004-11-29 06:46:12.000000000 +0100
+++ gnome-applets-2.10.1-emmanuel/drivemount/drive-button.c	2005-06-26 20:47:13.434025392 +0200
@@ -27,13 +27,18 @@
 #include "drive-button.h"
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
+#include <gconf/gconf-client.h>
 
 enum {
     CMD_MOUNT,
     CMD_UNMOUNT,
-    CMD_EJECT
+    CMD_EJECT,
+    CMD_PLAY_AUDIOCD,
+    CMD_PLAY_DVDVIDEO
 };
 
+#define GCONF_ROOT_AUTOPLAY  "/desktop/gnome/volume_manager/"
+
 /* type registration boilerplate code */
 G_DEFINE_TYPE(DriveButton, drive_button, GTK_TYPE_BUTTON);
 
@@ -581,6 +586,72 @@
     }
 }
 
+/* copied from gnome-volume-manager/src/manager.c */
+/*
+ * 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)
+		warn ("failed to exec %s: %s\n", exec->str, error->message);
+
+	g_string_free (exec, TRUE);
+	g_free (new_command);
+}
+
+static void
+run_command(DriveButton *self, const char *command)
+{
+	char *device_path = gnome_vfs_drive_get_device_path (self->drive);
+
+	char *uri = gnome_vfs_volume_get_activation_uri (self->volume);
+	char *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_free (mount_path);
+	g_free (device_path);
+}
+
 static void
 mount_drive (DriveButton *self, GtkWidget *item)
 {
@@ -617,6 +688,27 @@
 	g_return_if_reached();
     }
 }
+static void
+play_dvd (DriveButton *self, GtkWidget *item)
+{
+	GConfClient *gconf_client = gconf_client_get_default ();
+	char *dvd_command = gconf_client_get_string (gconf_client,
+			GCONF_ROOT_AUTOPLAY "autoplay_dvd_command", NULL);
+	run_command (self, dvd_command);
+	g_free (dvd_command);
+	g_object_unref (gconf_client);
+}
+
+static void
+play_cda (DriveButton *self, GtkWidget *item)
+{
+	GConfClient *gconf_client = gconf_client_get_default ();
+	char *cda_command = gconf_client_get_string (gconf_client,
+			GCONF_ROOT_AUTOPLAY "autoplay_cda_command", NULL);
+	run_command (self, cda_command);
+	g_free (cda_command);
+	g_object_unref (gconf_client);
+}
 
 static void
 drive_button_ensure_popup (DriveButton *self)
@@ -640,6 +732,12 @@
 	    case GNOME_VFS_DEVICE_TYPE_JAZ:
 		action = CMD_EJECT;
 		break;
+	    case GNOME_VFS_DEVICE_TYPE_VIDEO_DVD:
+		action = CMD_PLAY_DVDVIDEO;
+		break;
+	    case GNOME_VFS_DEVICE_TYPE_AUDIO_CD:
+		action = CMD_PLAY_AUDIOCD;
+		break;
 	    default:
 		action = CMD_UNMOUNT;
 	    }
@@ -669,9 +767,23 @@
     g_free (display_name);
     display_name = tmp;
 
-    label = g_strdup_printf (_("_Open %s"), display_name);
-    item = create_menu_item (self, GTK_STOCK_OPEN, label,
-			     G_CALLBACK (open_drive),
+	GCallback callback = G_CALLBACK (open_drive);
+
+	switch (device_type) {
+	case GNOME_VFS_DEVICE_TYPE_VIDEO_DVD:
+		label = g_strdup (_("_Play DVD"));
+		callback = G_CALLBACK (play_dvd);
+		break;
+	case GNOME_VFS_DEVICE_TYPE_AUDIO_CD:
+		label = g_strdup (_("_Play CD"));
+		callback = G_CALLBACK (play_cda);
+		break;
+	default:
+		label = g_strdup_printf (_("_Open %s"), display_name);
+	}
+
+	item = create_menu_item (self, GTK_STOCK_OPEN, label,
+			     callback,
 			     action != CMD_MOUNT);
     g_free (label);
     gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
