[Rhythmbox-devel] More Album Art Fixes



This is an update to the patch I posted [0] to the list recently to add
support for non-square album art images to the merge branch.  This
update fixes a few bugs in my earlier implementation, namely:
 
 * The widgets in the left-hand pane never move or resize, regardless of
   the size and shape of the album art being displayed below them.
   (Previously, things would move around if a wide image were displayed,
   instead of making the image letterboxed.)

 * All rows in the Albums list in the browser are now always the same
   height, regardless of the size or shape of the album art thumbnail in
   the row.  (Previously, if the art was wide, the height of the row
   would shrink, which made things look weird and inconsistent.)

A cumulative patch to fix these issues is attached; this patch includes
the changes in [0].  Alternatively, the code can be checked out of my
arch repository:

    Name: kuliniew purdue edu--2004
    Location: http://web.ics.purdue.edu/~kuliniew/arch
    Branch: rhythmbox--cover--0.9

You'll want everything up to patch-4.  (patch-3 and patch-4,
respectively, fix the two problems mentioned above.)

[0]
http://mail.gnome.org/archives/rhythmbox-devel/2005-June/msg00025.html
--- orig/lib/rb-cover.c
+++ mod/lib/rb-cover.c
@@ -738,6 +738,7 @@
 	gchar *cover_path, *small_cover_path;
 	GdkPixbufLoader *loader;
 	GdkPixbuf *pixbuf, *small_pixbuf;
+	int width, height;
 
 	if (!artist || !album || !data)
 		return GNOME_VFS_ERROR_BAD_PARAMETERS;
@@ -767,10 +768,19 @@
 		gdk_pixbuf_loader_close (loader, NULL);
 
 		pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
-		small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
-							TREE_COVER_SIZE,
-							TREE_COVER_SIZE,
-							GDK_INTERP_BILINEAR);
+		width = gdk_pixbuf_get_width (pixbuf);
+		height = gdk_pixbuf_get_height (pixbuf);
+		if (width > height) {
+			small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+								TREE_COVER_SIZE,
+								height * TREE_COVER_SIZE / width,
+								GDK_INTERP_BILINEAR);
+		} else {
+			small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+								width * TREE_COVER_SIZE / height,
+								TREE_COVER_SIZE,
+								GDK_INTERP_BILINEAR);
+		}
 
 		if (gdk_pixbuf_save (pixbuf, cover_path, "jpeg", NULL, NULL) &&
 		    gdk_pixbuf_save (small_pixbuf, small_cover_path, "jpeg", NULL, NULL)) {
@@ -803,6 +813,7 @@
 	GdkPixbufLoader *loader;
 	GdkPixbuf *pixbuf, *small_pixbuf;
 	gboolean ret_val;
+	int width, height;
 
 	loader = gdk_pixbuf_loader_new ();
 
@@ -813,10 +824,19 @@
 		gdk_pixbuf_loader_close (loader, NULL);
 
 		pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
-		small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
-							TREE_COVER_SIZE,
-							TREE_COVER_SIZE,
-							GDK_INTERP_BILINEAR);
+		width = gdk_pixbuf_get_width (pixbuf);
+		height = gdk_pixbuf_get_height (pixbuf);
+		if (width > height) {
+			small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+								TREE_COVER_SIZE,
+								height * TREE_COVER_SIZE / width,
+								GDK_INTERP_BILINEAR);
+		} else {
+			small_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+								width * TREE_COVER_SIZE / height,
+								TREE_COVER_SIZE,
+								GDK_INTERP_BILINEAR);
+		}
 
 		ret_val = gdk_pixbuf_save_to_buffer (small_pixbuf,
 						     &write_handle->small_cover_data,


--- orig/widgets/rb-album-cover.c
+++ mod/widgets/rb-album-cover.c
@@ -251,10 +251,14 @@
 static void
 rb_album_cover_init (RBAlbumCover *album_cover)
 {
+	int cover_size;
+
+	cover_size = eel_gconf_get_integer (CONF_COVER_SIZE);
 
 	album_cover->priv = g_new0 (RBAlbumCoverPrivate, 1);
 
 	album_cover->priv->image = gtk_image_new ();
+	gtk_widget_set_size_request (album_cover->priv->image, cover_size, cover_size);
 	gtk_container_add (GTK_CONTAINER (album_cover), 
 			   album_cover->priv->image);
 			   
@@ -700,7 +704,11 @@
 	if (cover_size > MAX_COVER_SIZE)
 		cover_size = MAX_COVER_SIZE;
 
-	gdk_pixbuf_loader_set_size (loader, cover_size, cover_size);
+	if (w > h) {
+		gdk_pixbuf_loader_set_size (loader, cover_size, h * cover_size / w);
+	} else {
+		gdk_pixbuf_loader_set_size (loader, w * cover_size / h, cover_size);
+	}
 }
 
 static void 
@@ -903,5 +911,10 @@
 				 GConfEntry *entry,
 				 RBAlbumCover *album_cover)
 {
+	int cover_size;
+
+	cover_size = eel_gconf_get_integer (CONF_COVER_SIZE);
+	gtk_widget_set_size_request (album_cover->priv->image, cover_size, cover_size);
+
 	rb_album_cover_reload (album_cover);
 }


--- orig/widgets/rb-property-view.c
+++ mod/widgets/rb-property-view.c
@@ -757,6 +757,7 @@
 
 	if (view->priv->propid == RHYTHMDB_PROP_ALBUM) {
 		renderer = gtk_cell_renderer_pixbuf_new ();
+		gtk_cell_renderer_set_fixed_size (renderer, TREE_COVER_SIZE, TREE_COVER_SIZE);
 		column = gtk_tree_view_column_new_with_attributes ("Cover", 
 								  renderer, 
 								  "pixbuf", 

Attachment: signature.asc
Description: Digital signature



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