From 37e1533b203557602942eea32cc9f2397004023c Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Fri, 30 May 2008 12:00:21 +0000 Subject: * src/Makefile.am: * src/db-artwork-parser.c: * src/db-artwork-writer.c: * src/db-image-parser.c: * src/db-image-parser.h: * src/itdb.h: * src/itdb_artwork.c: * src/itdb_device.h: * src/itdb_photoalbum.c: * src/itdb_track.c: * src/ithumb-writer.c: * tests/test-covers.c: * tests/test-photos.c: rework Itdb_Thumb type. Now it's split into different subtypes depending on what it represents (GdkPixbuf, thumbnail read from the ipod, ...). Itdb_Artwork now contains only a pointer to a single Itdb_Thumb (it used to contain a GList * of Itdb_Thumb) since the only time when the list is useful is for thumbs read from the ipod. Using a list for the other types of thumbnails created some complications when trying to set art on an Itdb_Track that wasn't attached to an Itdb_iTunesDB. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1991 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- tests/test-photos.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'tests/test-photos.c') diff --git a/tests/test-photos.c b/tests/test-photos.c index af98b1c..02ecaa3 100644 --- a/tests/test-photos.c +++ b/tests/test-photos.c @@ -31,6 +31,8 @@ #include #include +#include "itdb_thumb.h" + static void usage (int argc, char **argv) { /* gchar *name = argv[0];*/ @@ -59,41 +61,34 @@ static Itdb_Artwork *get_photo_by_id (Itdb_PhotoDB *db, guint32 id) return NULL; } -static void -save_itdb_thumb (Itdb_PhotoDB *itdb, Itdb_Thumb *thumb, - const gchar *filename) -{ - GdkPixbuf *pixbuf; - - pixbuf = itdb_thumb_get_gdk_pixbuf (itdb->device, thumb); - - if (pixbuf != NULL) { - gdk_pixbuf_save (pixbuf, filename, "png", NULL, NULL); - gdk_pixbuf_unref (pixbuf); - } -} - static void dump_thumbs (Itdb_PhotoDB *db, Itdb_Artwork *artwork, const gchar *album_name, const gchar *dir) { GList *it; gint i = 0; + GList *thumbnails; + Itdb_Thumb_Ipod *thumb; - for (it = artwork->thumbnails; it != NULL; it = it->next, i++) { - Itdb_Thumb *thumb; + thumb = (Itdb_Thumb_Ipod *)artwork->thumbnail; + thumbnails = itdb_thumb_ipod_to_pixbufs (db->device, thumb); + for (it = thumbnails; it != NULL; it = it->next, i++) { gchar *filename, *path; + GdkPixbuf *pixbuf; - thumb = (Itdb_Thumb *)it->data; - g_return_if_fail (thumb); + pixbuf = GDK_PIXBUF (it->data); + + g_return_if_fail (pixbuf); filename = g_strdup_printf ("%s-%d-%d.png", album_name, artwork->id, i ); path = g_build_filename (dir, filename, NULL); g_free (filename); - save_itdb_thumb (db, thumb, path); + gdk_pixbuf_save (pixbuf, path, "png", NULL, NULL); + gdk_pixbuf_unref (pixbuf); g_free (path); } + g_list_free (thumbnails); } static void -- cgit