summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <teuf@gnome.org>2008-07-29 20:11:37 +0000
committerChristophe Fergeau <teuf@gnome.org>2008-07-29 20:11:37 +0000
commit924df8a406041b58af100d28a45df8775eab4698 (patch)
tree891c46cc83b935787bb7939cd91adddb4fb7fd71
parent89fd72c08236360e279847e89edc8402dfa4a04b (diff)
downloadlibgpod-924df8a406041b58af100d28a45df8775eab4698.tar.gz
libgpod-924df8a406041b58af100d28a45df8775eab4698.tar.xz
libgpod-924df8a406041b58af100d28a45df8775eab4698.zip
Some public API work, hide ItdbThumbType as well as ItdbThumbIpod
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@2070 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r--src/itdb.h15
-rw-r--r--src/itdb_thumb.c27
-rw-r--r--src/itdb_thumb.h19
-rw-r--r--tests/test-covers.c6
-rw-r--r--tests/test-photos.c4
5 files changed, 45 insertions, 26 deletions
diff --git a/src/itdb.h b/src/itdb.h
index 6201006..c5f1866 100644
--- a/src/itdb.h
+++ b/src/itdb.h
@@ -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;