Index: plugins/magnatune/magnatune/MagnatuneSource.py
===================================================================
RCS file: /cvs/gnome/rhythmbox/plugins/magnatune/magnatune/MagnatuneSource.py,v
retrieving revision 1.2
diff -u -r1.2 MagnatuneSource.py
--- plugins/magnatune/magnatune/MagnatuneSource.py	6 Oct 2006 10:44:32 -0000	1.2
+++ plugins/magnatune/magnatune/MagnatuneSource.py	22 Oct 2006 18:14:42 -0000
@@ -437,9 +437,13 @@
 	
 	def __download_album(self, audio_dl_uri):
 			library_location = self.__client.get_list("/apps/rhythmbox/library_locations", gconf.VALUE_STRING)[0] # Just use the first library location
-			to_file_uri = gnomevfs.URI(library_location + "/" + audio_dl_uri.short_name)
+			to_file_uri = gnomevfs.URI(magnatune_dir + audio_dl_uri.short_name)
 			
+			shell = self.get_property('shell')
+			manager = shell.get_player().get_property('ui-manager')
+			manager.get_action("/ToolBar/ToolBarPluginPlaceholder/CancelDownload").set_sensitive(True)
 			self.__downloading = True
+			self.cancelled = False
 			self.purchase_filesize += gnomevfs.get_file_info(audio_dl_uri).size
 			create_if_needed(to_file_uri, gnomevfs.OPEN_WRITE).close()
 			gnomevfs.async.xfer (source_uri_list = [audio_dl_uri],
@@ -458,8 +462,11 @@
 			library_location = data[1]
 			audio_dl_uri = data[2]
 			
+			try:
+				del self.__downloads[str(audio_dl_uri)]
+			except:
+				return 0
 			self.purchase_filesize -= gnomevfs.get_file_info(audio_dl_uri).size
-			del self.__downloads[str(audio_dl_uri)]
 			album = zipfile.ZipFile(to_file_uri.path)
 			for track in album.namelist():
 				track_uri = gnomevfs.URI(library_location + "/" + track)
@@ -478,6 +485,18 @@
 		to_file_uri = data[0]
 		audio_dl_uri = data[1]
 		
+		if self.cancelled:
+			try:
+				del self.__downloads[str(audio_dl_uri)]
+				self.purchase_filesize -= gnomevfs.get_file_info(audio_dl_uri).size
+				gnomevfs.unlink(gnomevfs.URI(magnatune_dir + "in_progress_" + to_file_uri.short_name))
+				gnomevfs.unlink(to_file_uri)
+			except: # this may get run more than once
+				pass
+			if self.purchase_filesize == 0:
+				self.__downloading = False
+			return 0
+		
 		self.__downloads[str(audio_dl_uri)] = info.bytes_copied
 		purchase_downloaded = 0
 		for i in self.__downloads.values():
@@ -485,7 +504,12 @@
 		self.__download_progress = purchase_downloaded / float(self.purchase_filesize)
 		self.__notify_status_changed()
 		return 1
-
+	
+	def cancel_downloads(self):
+		self.cancelled = True
+		shell = self.get_property('shell')
+		manager = shell.get_player().get_property('ui-manager')
+		manager.get_action("/ToolBar/ToolBarPluginPlaceholder/CancelDownload").set_sensitive(False)
 
 gobject.type_register(MagnatuneSource)
 
Index: plugins/magnatune/magnatune/__init__.py
===================================================================
RCS file: /cvs/gnome/rhythmbox/plugins/magnatune/magnatune/__init__.py,v
retrieving revision 1.1
diff -u -r1.1 __init__.py
--- plugins/magnatune/magnatune/__init__.py	6 Oct 2006 10:14:38 -0000	1.1
+++ plugins/magnatune/magnatune/__init__.py	22 Oct 2006 18:14:42 -0000
@@ -25,6 +25,14 @@
     <separator/>
     <menuitem name="PropertiesLibraryPopup" action="MusicProperties"/>
   </popup>
+
+  <toolbar name="ToolBar">
+      <placeholder name="ToolBarPluginPlaceholder">
+        <toolitem name="PurchaseAlbum" action="PurchaseAlbum"/>
+        <toolitem name="CancelDownload" action="CancelDownload"/>
+        <toolitem name="ArtistInfo" action="ArtistInfo"/>
+      </placeholder>
+  </toolbar>
 </ui>
 """
 
@@ -67,6 +75,7 @@
 		shell.append_source(self.source, None) # Add the source to the list
 		
 		manager = shell.get_player().get_property('ui-manager')
+		# Add the popup menu actions
 		action = gtk.Action('MagnatunePurchase', _('Purchase Album'),
 				_("Purchase this album from Magnatune"),
 				'gnome-mime-audio')
@@ -78,6 +87,24 @@
 				'gnome-mime-audio')
 		action.connect('activate', lambda a: self.shell.get_property("selected-source").display_artist_info())
 		self.action_group.add_action(action)
+		# Add the toolbar actions
+		action = gtk.Action('PurchaseAlbum', _('Purchase Album'),
+				_("Purchase this album from Magnatune"),
+				'gnome-mime-audio')
+		action.connect('activate', lambda a: self.shell.get_property("selected-source").purchase_tracks())
+		self.action_group.add_action(action)
+		action = gtk.Action('CancelDownload', _('Cancel Downloads'),
+				_("Stop downloading purchased albums"),
+				'stock_stop')
+		action.connect('activate', lambda a: self.shell.get_property("selected-source").cancel_downloads())
+		action.set_sensitive(False)
+		self.action_group.add_action(action)
+		action = gtk.Action('ArtistInfo', _('Artist Information'),
+				_("Get information about this artist"),
+				'gnome-mime-audio')
+		action.connect('activate', lambda a: self.shell.get_property("selected-source").display_artist_info())
+		self.action_group.add_action(action)
+		
 		manager.insert_action_group(self.action_group, 0)
 		self.ui_id = manager.add_ui_from_string(popup_ui)
 		manager.ensure_update()
