GNOME Bugzilla – Bug 361122
Menu item to duplicate cd
Last modified: 2008-01-08 10:34:58 UTC
That bug has been opened on https://launchpad.net/distros/ubuntu/+source/sound-juicer/+bug/65045 "It would be interesting if sound juicer has a menu item (under 'disc' menu) that duplicate the cd, by calling nautilus-cd-burner. When cd is inserted, sound juicer is opened, giving you the ability to listen and to rip it. If i want to make a 'backup' copy of my audio cd, i have to click on cd icon on desktop and choose 'copy disc' option. If sound juicer has just a shortcut to this feature (provided by nautilus-cd-burner), the user would have all things he could do on a audio cd centralized. Was i clear?"
This seems like a reasonable addition to the menu. Plan of action: 1) Check that nautilus-cd-burner --source-device=[device path] works for audio CDs 2) On startup SJ should check for the nautilus-cd-burner binary and if its present, add the menu item.
Created attachment 102178 [details] [review] Patch to add menu item to duplicate a cd.
Looking good. The Duplicate items also needs to enable/disable based on the presence of a disc.
Created attachment 102214 [details] [review] Update to enable/disable the duplicate disc item based on disc presence This patch also addresses an issue of device selection for duplication on a multiple device system.
Committed, thanks!
Created attachment 102267 [details] [review] Fix to stop duplication being enabled when no disc is present at startup A small problem - at startup the duplicate disc menu item is currently enabled if the facility to do so exists. This is wrong as it should only be if the facility to do so exists and there is a disc present. I have attached the change require to fix this in the last committed patch.
Good catch, can you tell I haven't actually tried this? :)
is_nautilus_cd_burner_available looks extremely complicated, for what it is, use g_find_program_in_path instead. Also, it would be useful to check for cdrdao, which is used to duplicate CDs in nautilus-cd-burner. Maybe it would be better to have a check for nautilus-cd-burner and cdrdao directly in libnautilus-burn. I also don't see any checks for whether there's a writer available on the system.
Aha, I knew there was a glib function to locale programs, but I couldn't find it when I had a search! Re-opening for gnome-love: 1) use g_find_program_in_path 2) check for cdrdao as well as n-c-b 3) check there is a writer on startup, using libnautilus-burn
(In reply to comment #9) <snip> > 3) check there is a writer on startup, using libnautilus-burn Note that the writer can be the same as the source, as nautilus-cd-burner handles that case using a temporary file.
Ah, I was looking for a function to do it as well but could not find one. It seems so obvious when you see the name! I will make these changes later today. Thanks, Dave
Created attachment 102346 [details] [review] Update to function to check if CD duplication is available
Created attachment 102348 [details] [review] Update to function to check if CD duplication is available The last one was missing g_free()'s for the g_find_program_in_path() results.
Comment on attachment 102348 [details] [review] Update to function to check if CD duplication is available Index: src/sj-main.c =================================================================== --- src/sj-main.c (revision 1964) +++ src/sj-main.c (working copy) @@ -1465,32 +1465,39 @@ } /** - * Searches for the nautilus-cd-burner tool in the system path. + * Performs various checks to ensure CD duplication is available. * If this is found TRUE is returned, otherwise FALSE is returned. */ static gboolean -is_nautilus_cd_burner_available() +is_cd_duplication_available() { - char **paths, *path; - guint n; - gboolean result = FALSE; + // First check the nautilus-cd-burner tool is available in the path + gchar* nautilus_cd_burner = g_find_program_in_path ("nautilus-cd-burne"); + if (nautilus_cd_burner == NULL) { + return FALSE; + } + g_free(nautilus_cd_burner); - paths = g_strsplit (g_getenv ("PATH"), ":", -1); - for (n = 0; paths[n] != NULL; ++n) { - path = paths[n]; - if (G_UNLIKELY (*path == '\0')) - continue; + // Second check the cdrdao tool is available in the path + gchar* cdrdao = g_find_program_in_path ("cdrdao"); + if (cdrdao == NULL) { + return FALSE; + } + g_free(cdrdao); - path = g_strconcat (path, "/nautilus-cd-burner", NULL); - if (g_file_test (path, G_FILE_TEST_EXISTS)) { - result = TRUE; - g_free (path); - break; - } - g_free (path); + // Now check that there is at least one cd recorder available + GList *drives; + NautilusBurnDriveMonitor *monitor; + + monitor = nautilus_burn_get_drive_monitor (); + drives = nautilus_burn_drive_monitor_get_recorder_drives (monitor); + + if (drives == NULL) { + return FALSE; } - g_strfreev (paths); - return result; + + g_list_free (drives); + return TRUE; } /** @@ -1774,7 +1781,7 @@ // Set whether duplication of a cd is available using the nautilus-cd-burner tool gtk_widget_set_sensitive (duplicate, FALSE); - duplication_enabled = is_nautilus_cd_burner_available (); + duplication_enabled = is_cd_duplication_available(); gconf_bridge_bind_window_size(gconf_bridge_get(), GCONF_WINDOW, GTK_WINDOW (main_window)); gtk_widget_show (main_window);
Created attachment 102350 [details] [review] Update to function to check if CD duplication is available Sorry, didn't mean last update there. I was meaning to do this. Maybe I should stop now as it clearly not my day ;-)
Nautilus can make iso images, so, i wouldn't check for a cd writer in the system.
(In reply to comment #16) > Nautilus can make iso images, so, i wouldn't check for a cd writer in the > system. You can't make an ISO image of an audio CD, and I don't think that nautilus-cd-burner can spit out a .bin/.cue combination from cdrdao in the UI.
Committed, thanks.