After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 556774 - Send files to be burnt
Send files to be burnt
Status: RESOLVED FIXED
Product: nautilus-sendto
Classification: Applications
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: nautilus-sendto-maint
nautilus-sendto-maint
Depends on: 498506
Blocks:
 
 
Reported: 2008-10-17 19:26 UTC by JP Rosevear
Modified: 2009-02-06 16:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Nautilus sendto CD/DVD burn plugin (5.17 KB, text/plain)
2008-12-23 13:33 UTC, Jader Henrique da Silva
  Details
Nautilus sendto CD/DVD burn plugin (4.75 KB, patch)
2008-12-29 19:06 UTC, Jader Henrique da Silva
none Details | Review

Description JP Rosevear 2008-10-17 19:26:51 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.
Comment 1 Bastien Nocera 2008-12-16 10:32:36 UTC
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.
Comment 2 Jader Henrique da Silva 2008-12-23 13:33:57 UTC
Created attachment 125196 [details]
Nautilus sendto CD/DVD burn plugin
Comment 3 Bastien Nocera 2008-12-25 16:15:18 UTC
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!
Comment 4 Jader Henrique da Silva 2008-12-29 19:06:35 UTC
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.
Comment 5 Bastien Nocera 2009-01-06 18:12:19 UTC
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:///
Comment 6 Bastien Nocera 2009-02-06 16:03:20 UTC
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)