File nautilus-cd-burner-142860-get-drive-from-desktop-icon.diff of Package nautilus-cd-burner
https://bugzilla.novell.com/show_bug.cgi?id=142860
2006-05-09 Federico Mena Quintero <federico@novell.com>
* burn-extension.c (nautilus_burn_get_file_items): If we get an
"application/x-nautilus-link", see if it is a CD-ROM from a
desktop icon, and add the appropriate menu items.
(add_cdrom_menu_items): New helper function.
--- nautilus-cd-burner/burn-extension.c.orig 2006-05-09 18:52:36.000000000 -0500
+++ nautilus-cd-burner/burn-extension.c 2006-05-09 19:03:32.000000000 -0500
@@ -228,6 +228,27 @@ copy_disc_activate_cb (NautilusMenuItem
g_free (argv [0]);
}
+static void
+add_cdrom_menu_items (GList **items,
+ GnomeVFSDrive *drive,
+ NautilusFileInfo *file,
+ GtkWidget *window)
+{
+ char *device_path = gnome_vfs_drive_get_device_path (drive);
+ NautilusMenuItem *item;
+
+ item = nautilus_menu_item_new ("NautilusBurn::copy_disc",
+ _("_Copy Disc..."),
+ _("Create a copy of this CD or DVD disc"),
+ "gnome-dev-cdrom");
+ g_object_set_data (G_OBJECT (item), "file", file);
+ g_object_set_data (G_OBJECT (item), "window", window);
+ g_object_set_data_full (G_OBJECT (item), "drive_device_path", device_path, g_free);
+ g_signal_connect (item, "activate",
+ G_CALLBACK (copy_disc_activate_cb), NULL);
+ *items = g_list_append (*items, item);
+}
+
static GList *
nautilus_burn_get_file_items (NautilusMenuProvider *provider,
GtkWidget *window,
@@ -242,6 +263,7 @@ nautilus_burn_get_file_items (NautilusMe
gboolean is_iso;
gboolean is_cue;
gboolean is_desktop_file;
+ gboolean is_nautilus_link;
char *uri;
if (!selection || selection->next != NULL) {
@@ -273,6 +295,8 @@ nautilus_burn_get_file_items (NautilusMe
is_desktop_file = strcmp (mime_type, "application/x-desktop") == 0;
is_cue = strcmp (mime_type, "application/x-cue") == 0;
+ is_nautilus_link = strcmp (mime_type, "application/x-nautilus-link") == 0;
+
if (is_iso && is_local) {
item = nautilus_menu_item_new ("NautilusBurn::write_iso",
_("_Write to Disc..."),
@@ -305,29 +329,29 @@ nautilus_burn_get_file_items (NautilusMe
if (drive_id >= 0) {
GnomeVFSVolumeMonitor *monitor;
GnomeVFSDrive *drive;
- GnomeVFSDeviceType device_type;
-
- device_type = GNOME_VFS_DEVICE_TYPE_UNKNOWN;
monitor = gnome_vfs_get_volume_monitor ();
drive = gnome_vfs_volume_monitor_get_drive_by_id (monitor, drive_id);
- device_type = gnome_vfs_drive_get_device_type (drive);
+
+ if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_CDROM) {
+ add_cdrom_menu_items (&items, drive, file, window);
+ }
+
gnome_vfs_drive_unref (drive);
+ }
+ }
+
+ if (is_nautilus_link) {
+ GnomeVFSDrive *drive;
- if (device_type == GNOME_VFS_DEVICE_TYPE_CDROM) {
- char *device_path = gnome_vfs_drive_get_device_path (drive);
+ drive = nautilus_file_info_get_drive (file);
- item = nautilus_menu_item_new ("NautilusBurn::copy_disc",
- _("_Copy Disc..."),
- _("Create a copy of this CD or DVD disc"),
- "gnome-dev-cdrom");
- g_object_set_data (G_OBJECT (item), "file", file);
- g_object_set_data (G_OBJECT (item), "window", window);
- g_object_set_data_full (G_OBJECT (item), "drive_device_path", device_path, g_free);
- g_signal_connect (item, "activate",
- G_CALLBACK (copy_disc_activate_cb), NULL);
- items = g_list_append (items, item);
+ if (drive) {
+ if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_CDROM) {
+ add_cdrom_menu_items (&items, drive, file, window);
}
+
+ gnome_vfs_drive_unref (drive);
}
}