diff options
-rw-r--r-- | src/itdb.h | 15 | ||||
-rw-r--r-- | src/itdb_thumb.c | 27 | ||||
-rw-r--r-- | src/itdb_thumb.h | 19 | ||||
-rw-r--r-- | tests/test-covers.c | 6 | ||||
-rw-r--r-- | tests/test-photos.c | 4 |
5 files changed, 45 insertions, 26 deletions
@@ -478,18 +478,6 @@ struct _Itdb_Chapterdata /* one star is how much (track->rating) */ #define ITDB_RATING_STEP 20 -/* Types of thumbnails in Itdb_Image */ -enum _ItdbThumbDataType { - ITDB_THUMB_TYPE_INVALID, - ITDB_THUMB_TYPE_FILE, - ITDB_THUMB_TYPE_MEMORY, - ITDB_THUMB_TYPE_PIXBUF, - ITDB_THUMB_TYPE_IPOD -}; -typedef enum _ItdbThumbDataType ItdbThumbDataType; - - - struct _Itdb_Artwork { Itdb_Thumb *thumbnail; guint32 id; /* Artwork id used by photoalbums, starts at @@ -1210,6 +1198,9 @@ gpointer itdb_artwork_get_pixbuf (Itdb_Device *device, Itdb_Artwork *artwork, /* itdb_thumb_... */ Itdb_Thumb *itdb_thumb_duplicate (Itdb_Thumb *thumb); +gpointer itdb_thumb_to_pixbuf_at_size (Itdb_Device *dev, Itdb_Thumb *thumb, + gint width, gint height); +GList *itdb_thumb_to_pixbufs (Itdb_Device *dev, Itdb_Thumb *thumb); void itdb_thumb_free (Itdb_Thumb *thumb); /* itdb_chapterdata_... */ diff --git a/src/itdb_thumb.c b/src/itdb_thumb.c index fe89e94..b55fe6c 100644 --- a/src/itdb_thumb.c +++ b/src/itdb_thumb.c @@ -504,7 +504,7 @@ gpointer itdb_thumb_to_pixbuf_at_size (Itdb_Device *device, Itdb_Thumb *thumb, return pixbuf; } -GList *itdb_thumb_ipod_to_pixbufs (Itdb_Device *dev, Itdb_Thumb_Ipod *thumb) +static GList *itdb_thumb_ipod_to_pixbufs (Itdb_Device *dev, Itdb_Thumb_Ipod *thumb) { const GList *items; GList *pixbufs = NULL; @@ -524,6 +524,28 @@ GList *itdb_thumb_ipod_to_pixbufs (Itdb_Device *dev, Itdb_Thumb_Ipod *thumb) return pixbufs; } + +GList *itdb_thumb_to_pixbufs (Itdb_Device *dev, Itdb_Thumb *thumb) +{ + GList *pixbufs = NULL; + GdkPixbuf *pixbuf; + + switch (thumb->data_type) { + case ITDB_THUMB_TYPE_IPOD: + pixbufs = itdb_thumb_ipod_to_pixbufs (dev, (Itdb_Thumb_Ipod *)thumb); + break; + case ITDB_THUMB_TYPE_FILE: + case ITDB_THUMB_TYPE_MEMORY: + case ITDB_THUMB_TYPE_PIXBUF: + pixbuf = itdb_thumb_to_pixbuf_at_size (dev, thumb, -1, -1); + pixbufs = g_list_append (pixbufs, pixbuf); + break; + case ITDB_THUMB_TYPE_INVALID: + g_assert_not_reached (); + } + + return pixbufs; +} #else gpointer itdb_thumb_to_pixbuf_at_size (Itdb_Device *dev, Itdb_Thumb *thumb, gint width, gint height) @@ -531,7 +553,8 @@ gpointer itdb_thumb_to_pixbuf_at_size (Itdb_Device *dev, Itdb_Thumb *thumb, return NULL; } -GList *itdb_thumb_ipod_to_pixbufs (Itdb_Device *dev, Itdb_Thumb_Ipod *thumb) + +GList *itdb_thumb_to_pixbufs (Itdb_Device *dev, Itdb_Thumb *thumb) { return NULL; } diff --git a/src/itdb_thumb.h b/src/itdb_thumb.h index 940128a..55672ff 100644 --- a/src/itdb_thumb.h +++ b/src/itdb_thumb.h @@ -26,6 +26,16 @@ #include "itdb.h" #include "itdb_device.h" +/* Types of thumbnails in Itdb_Image */ +enum _ItdbThumbDataType { + ITDB_THUMB_TYPE_INVALID, + ITDB_THUMB_TYPE_FILE, + ITDB_THUMB_TYPE_MEMORY, + ITDB_THUMB_TYPE_PIXBUF, + ITDB_THUMB_TYPE_IPOD +}; +typedef enum _ItdbThumbDataType ItdbThumbDataType; + /* The Itdb_Thumb structure can represent two slightly different thumbnails: @@ -105,10 +115,7 @@ G_GNUC_INTERNAL const GList *itdb_thumb_ipod_get_thumbs (Itdb_Thumb_Ipod *thumbs G_GNUC_INTERNAL char *itdb_thumb_ipod_get_filename (Itdb_Device *device, Itdb_Thumb_Ipod_Item *thumb); G_GNUC_INTERNAL Itdb_Thumb_Ipod_Item *itdb_thumb_ipod_get_item_by_type (Itdb_Thumb *thumbs, const Itdb_ArtworkFormat *format); -G_GNUC_INTERNAL -gpointer itdb_thumb_ipod_item_to_pixbuf (Itdb_Device *device, - Itdb_Thumb_Ipod_Item *item); -gpointer itdb_thumb_to_pixbuf_at_size (Itdb_Device *dev, Itdb_Thumb *thumb, - gint width, gint height); -GList *itdb_thumb_ipod_to_pixbufs (Itdb_Device *dev, Itdb_Thumb_Ipod *thumb); +G_GNUC_INTERNAL gpointer +itdb_thumb_ipod_item_to_pixbuf (Itdb_Device *device, + Itdb_Thumb_Ipod_Item *item); #endif diff --git a/tests/test-covers.c b/tests/test-covers.c index 195f907..20b4d7b 100644 --- a/tests/test-covers.c +++ b/tests/test-covers.c @@ -64,11 +64,11 @@ save_song_thumbnails (Itdb_Track *song) static guint count = 0; GList *it; GList *thumbs; - Itdb_Thumb_Ipod *thumb = (Itdb_Thumb_Ipod*)song->artwork->thumbnail; - if (thumb == NULL) { + if (song->artwork->thumbnail == NULL) { return; } - thumbs = itdb_thumb_ipod_to_pixbufs (song->itdb->device, thumb); + thumbs = itdb_thumb_to_pixbufs (song->itdb->device, + song->artwork->thumbnail); for (it = thumbs; it != NULL; it = it->next) { GdkPixbuf *pixbuf; diff --git a/tests/test-photos.c b/tests/test-photos.c index 02ecaa3..27703ad 100644 --- a/tests/test-photos.c +++ b/tests/test-photos.c @@ -68,10 +68,8 @@ dump_thumbs (Itdb_PhotoDB *db, Itdb_Artwork *artwork, GList *it; gint i = 0; GList *thumbnails; - Itdb_Thumb_Ipod *thumb; - thumb = (Itdb_Thumb_Ipod *)artwork->thumbnail; - thumbnails = itdb_thumb_ipod_to_pixbufs (db->device, thumb); + thumbnails = itdb_thumb_to_pixbufs (db->device, artwork->thumbnail); for (it = thumbnails; it != NULL; it = it->next, i++) { gchar *filename, *path; GdkPixbuf *pixbuf; |