commit e75a498aafae83f2f875684f5d3611042a856ba4
Author: Christophe Fergeau <teuf@gnome.org>
Date:   Sun Mar 1 20:35:40 2009 +0100

    Add menu entry to copy tracks from an iPod to the library

diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c
index 5b9907d..a1db7df 100644
--- a/plugins/ipod/rb-ipod-source.c
+++ b/plugins/ipod/rb-ipod-source.c
@@ -946,6 +946,7 @@ impl_get_ui_actions (RBSource *source)
 {
 	GList *actions = NULL;
 
+	actions = g_list_prepend (actions, g_strdup ("RemovableSourceCopySelectedTracks"));
 	actions = g_list_prepend (actions, g_strdup ("RemovableSourceEject"));
 
 	return actions;
diff --git a/shell/rb-removable-media-manager.c b/shell/rb-removable-media-manager.c
index 23df724..ffc2e49 100644
--- a/shell/rb-removable-media-manager.c
+++ b/shell/rb-removable-media-manager.c
@@ -96,6 +96,8 @@ static gboolean rb_removable_media_manager_load_media (RBRemovableMediaManager *
 static void do_transfer (RBRemovableMediaManager *manager);
 static void rb_removable_media_manager_cmd_copy_tracks (GtkAction *action,
 							RBRemovableMediaManager *mgr);
+static void rb_removable_media_manager_cmd_copy_selected_tracks (GtkAction *action,
+								 RBRemovableMediaManager *mgr);
 
 typedef struct
 {
@@ -155,6 +157,9 @@ static GtkActionEntry rb_removable_media_manager_actions [] =
 	{ "RemovableSourceCopyAllTracks", GTK_STOCK_CDROM, N_("_Extract to Library"), NULL,
 	  N_("Copy all tracks to the library"),
 	  G_CALLBACK (rb_removable_media_manager_cmd_copy_tracks) },
+	{ "RemovableSourceCopySelectedTracks", "audio-x-generic", N_("_Import into Library"), NULL,
+	  N_("Copy selected tracks to the library"),
+	  G_CALLBACK (rb_removable_media_manager_cmd_copy_selected_tracks) },
 	{ "MusicScanMedia", NULL, N_("_Scan Removable Media"), NULL,
 	  N_("Scan for new Removable Media"),
 	  G_CALLBACK (rb_removable_media_manager_cmd_scan_media) },
@@ -724,6 +729,11 @@ rb_removable_media_manager_set_uimanager (RBRemovableMediaManager *mgr,
 	   for Copy to Library action. */
 	g_object_set (G_OBJECT (action), "short-label", _("Extract"), NULL);
 
+	action = gtk_action_group_get_action (priv->actiongroup,
+					      "RemovableSourceCopySelectedTracks");
+	/* Translators: this is the toolbar button label
+	   for Copy Selected Tracks to Library action. */
+	g_object_set (G_OBJECT (action), "short-label", _("Import"), NULL);
 }
 
 static void
@@ -1128,3 +1138,28 @@ rb_removable_media_manager_cmd_copy_tracks (GtkAction *action, RBRemovableMediaM
 	g_object_unref (model);
 	g_object_unref (library);
 }
+
+static void
+rb_removable_media_manager_cmd_copy_selected_tracks (GtkAction *action, RBRemovableMediaManager *mgr)
+{
+	RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (mgr);
+	RBRemovableMediaSource *source;
+	RBLibrarySource *library;
+	GList *list = NULL;
+
+	g_object_get (priv->shell, "library-source", &library, NULL);
+	source = RB_REMOVABLE_MEDIA_SOURCE (priv->selected_source);
+	list = rb_source_copy (RB_SOURCE (source));
+	/* If there is nothing selected in the entry view, fall back to
+	 * copying everything in the query model to handle cases where the
+	 * user wants to copy a whole album or all tracks by a given artist
+	 */
+	if (list == NULL) {
+		rb_removable_media_manager_cmd_copy_tracks (action, mgr);
+	}
+
+	rb_source_paste (RB_SOURCE (library), list);
+
+	g_list_free (list);
+	g_object_unref (library);
+}
