GNOME Bugzilla – Bug 556774
Send files to be burnt
Last modified: 2009-02-06 16:03:20 UTC
From https://bugzilla.novell.com/show_bug.cgi?id=169733 It would be really nice to be able to click on single or multiple files and then have a right click option that would bring up the Nautilus "Write to CD" option so that you could easily burn the files to a CD.
This could be a very simple nautilus-sendto plugin. Would empty burn:///, add the files in question to burn:/// and launch the n-c-b front-end.
Created attachment 125196 [details] Nautilus sendto CD/DVD burn plugin
Comment on attachment 125196 [details] Nautilus sendto CD/DVD burn plugin Please provide patches instead of whole new files, so the code is testable (if you don't have an account, and want to add new files, use "diff -up /dev/null path/to/the/file.c"). <snip> > type = g_file_info_get_file_type (burn_info); > > g_object_unref (burn_info); > > if (type != G_FILE_TYPE_DIRECTORY) > return FALSE; Sanity checking is good, but this is a bit paranoid :) >static >GtkWidget* get_contacts_widget (NstPlugin *plugin) >{ > GtkWidget *cb; > GtkCellRenderer *renderer; > GtkListStore *store; > GtkTreeModel *model; > GtkTreeIter *iter; > GdkPixbuf *icon; > GtkIconTheme *it; > GFileEnumerator *fenum; > GFileInfo *file_info = NULL; > > it = gtk_icon_theme_get_default (); > icon = gtk_icon_theme_load_icon (it, > "nautilus-cd-burner", > 16, > GTK_ICON_LOOKUP_USE_BUILTIN, > NULL); > iter = g_malloc (sizeof(GtkTreeIter)); > store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING); > gtk_list_store_append (store, iter); > gtk_list_store_set (store, iter, 0, icon, 1, _("Current CD/DVD"), -1); > gtk_list_store_append (store, iter); > gtk_list_store_set (store, iter, 0, icon, 1, _("New CD/DVD"), -1); > g_free (iter); > model = GTK_TREE_MODEL (store); > cb = gtk_combo_box_new_with_model (model); > renderer = gtk_cell_renderer_pixbuf_new (); > gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cb), Please make sure you use tabs for indentation, and use it consistently. > renderer, > FALSE); > gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cb), > renderer, > "pixbuf", 0, > NULL); > renderer = gtk_cell_renderer_text_new (); > gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cb), > renderer, > TRUE); > gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cb), > renderer, > "text", 1, > NULL); > > gtk_combo_box_set_active (GTK_COMBO_BOX (cb), 1); > > fenum = g_file_enumerate_children (burn, > G_FILE_ATTRIBUTE_STANDARD_NAME, > G_FILE_QUERY_INFO_NONE, > NULL, > NULL); > > if (fenum != NULL) > { > file_info = g_file_enumerator_next_file (fenum, NULL, NULL); > g_object_unref (fenum); > } > > if (file_info == NULL) > { > gtk_combo_box_set_active (GTK_COMBO_BOX (cb), 1); > gtk_widget_set_sensitive (cb, FALSE); > } > else > { > gtk_combo_box_set_active (GTK_COMBO_BOX (cb), 0); > g_object_unref (file_info); > } > > return cb; Why use a combobox if you're only adding a single target? Use a label instead... <snip> > path = g_strdup_printf("burn:///%s", > g_file_info_get_name(file_info)); This is wrong, use g_file_get_child() instead. Rest looks alright, might need a further check when the plugin is available as a patch. Thanks!
Created attachment 125489 [details] [review] Nautilus sendto CD/DVD burn plugin Thanks for the sugestions Burn path sanity check, indentation, combobox and destination file handler. The combobox purpose is to support the current CD/DVD or to a new CD/DVD (empty burn:/) as targets. When burn:/ is empty, it is replaced by a label.
I committed this: 2009-01-06 Bastien Nocera <hadess@hadess.net> * configure.in: * src/plugins/Makefile.am: * src/plugins/nautilus-burn.c (init), (get_contacts_widget), (send_files), (destroy): Add a nautilus-cd-burner plugin, to send files to burn:///, patch from Jader Henrique da Silva <vovozito@gmail.com> I fixed a couple of style problems, the wrong use of GtkTreeIter (it's supposed to be used on the stack, not created and then freed), and used #defines instead of magic numbers. g_file_copy() doesn't work for directories, so the feature request from bug 498506 should help. Note that we should also launch nautilus-cd-burner itself after having added the files to burn:///
2009-02-06 Bastien Nocera <hadess@hadess.net> * src/plugins/nst-common.c (copy_fobject), (copy_files_to): * src/plugins/nst-common.h: Add helper functions to copy files (or directories) recursively to a destination * configure.in: Changes for the above, and do enable the burn plugin when dependencies are available * src/plugins/Makefile.am: Changes for the above * src/plugins/removable-devices/Makefile.am: * src/plugins/removable-devices/removable-devices.c (send_files): Use the helper function * src/plugins/nautilus-burn/Makefile.am: * src/plugins/nautilus-burn/nautilus-burn.c (send_files): Use the helper function, and launch nautilus to show burn:/// after copying the files (Closes: #556774)