rhythmbox r5552 - in trunk: . plugins/artdisplay/artdisplay



Author: jmatthew
Date: Thu Jan 24 13:04:12 2008
New Revision: 5552
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5552&view=rev

Log:
2008-01-24  Jonathan Matthew  <jonathan d14n org>

	patch by:  Mirco MÃller  <macslow bangang de>

	* plugins/artdisplay/artdisplay/CoverArtDatabase.py:
	When saving a pixbuf, save in PNG format if it has an alpha channel.
	When looking for cached images, check for PNG format first.
	Fixes #509880.


Modified:
   trunk/ChangeLog
   trunk/plugins/artdisplay/artdisplay/CoverArtDatabase.py

Modified: trunk/plugins/artdisplay/artdisplay/CoverArtDatabase.py
==============================================================================
--- trunk/plugins/artdisplay/artdisplay/CoverArtDatabase.py	(original)
+++ trunk/plugins/artdisplay/artdisplay/CoverArtDatabase.py	Thu Jan 24 13:04:12 2008
@@ -32,9 +32,12 @@
 ART_SEARCHES_LOCAL = [LocalCoverArtSearch]
 ART_SEARCHES_REMOTE = [PodcastCoverArtSearch, AmazonCoverArtSearch]
 ART_FOLDER = '~/.gnome2/rhythmbox/covers'
-ART_CACHE_EXTENSION = 'jpg'
-ART_CACHE_FORMAT = 'jpeg'
-ART_CACHE_SETTINGS = {"quality": "100"}
+ART_CACHE_EXTENSION_JPG = 'jpg'
+ART_CACHE_EXTENSION_PNG = 'png'
+ART_CACHE_FORMAT_JPG = 'jpeg'
+ART_CACHE_FORMAT_PNG = 'png'
+ART_CACHE_SETTINGS_JPG = {"quality": "100"}
+ART_CACHE_SETTINGS_PNG = {"compression": "9"}
 
 class TicketSystem:
 	def __init__ (self):
@@ -103,9 +106,16 @@
 	def set_pixbuf (self, db, entry, pixbuf, callback):
 		if entry is None or pixbuf is None:
 			return
-		art_location = self.build_art_cache_filename (db, entry, ART_CACHE_EXTENSION)
+		if pixbuf.get_has_alpha():
+			art_location = self.build_art_cache_filename (db, entry, ART_CACHE_EXTENSION_PNG)
+			art_cache_format = ART_CACHE_FORMAT_PNG
+			art_cache_settings = ART_CACHE_SETTINGS_PNG
+		else:
+			art_location = self.build_art_cache_filename (db, entry, ART_CACHE_EXTENSION_JPG)
+			art_cache_format = ART_CACHE_FORMAT_JPG
+			art_cache_settings = ART_CACHE_SETTINGS_JPG
 		self.ticket.purge (entry)
-		pixbuf.save (art_location, ART_CACHE_FORMAT, ART_CACHE_SETTINGS)
+		pixbuf.save (art_location, art_cache_format, art_cache_settings)
 		callback (entry, pixbuf, art_location)
 		for Engine in ART_SEARCHES_LOCAL:
 			try:
@@ -133,11 +143,18 @@
 		rb.Coroutine (self.image_search, db, st_album, st_artist, entry, callback).begin ()
 
 	def image_search (self, plexer, db, st_album, st_artist, entry, callback):
-		art_location = self.build_art_cache_filename (db, entry, ART_CACHE_EXTENSION)
+		art_location_jpg = self.build_art_cache_filename (db, entry, ART_CACHE_EXTENSION_JPG)
+		art_location_png = self.build_art_cache_filename (db, entry, ART_CACHE_EXTENSION_PNG)
 		blist_location = self.build_art_cache_filename (db, entry, "rb-blist")
 
+		art_location = None
+		if os.path.exists (art_location_jpg):
+			art_location = art_location_jpg
+		if os.path.exists (art_location_png):
+			art_location = art_location_png
+
 		# Check local cache
-		if os.path.exists (art_location):
+		if art_location:
 			self.ticket.purge (entry)
 			pixbuf = gtk.gdk.pixbuf_new_from_file (art_location)	
 			callback (entry, pixbuf, art_location)
@@ -164,7 +181,10 @@
 					if pixbuf:
 						if self.ticket.release (entry, ticket):
 							if engine_remote:
-								pixbuf.save (art_location, ART_CACHE_FORMAT, ART_CACHE_SETTINGS)
+								if pixbuf.get_has_alpha ():
+									pixbuf.save (art_location_png, ART_CACHE_FORMAT_PNG, ART_CACHE_SETTINGS_PNG)
+								else:
+									pixbuf.save (art_location_jpg, ART_CACHE_FORMAT_JPG, ART_CACHE_SETTINGS_JPG)
 								uri = art_location
 							else:
 								uri = unquote (str (url))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]