summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristophe Fergeau <teuf@gnome.org>2008-05-30 12:00:21 +0000
committerChristophe Fergeau <teuf@gnome.org>2008-05-30 12:00:21 +0000
commit37e1533b203557602942eea32cc9f2397004023c (patch)
tree15322f7006e27473d2c0c69b2d891f26c66cde67 /tests
parent747eda0937e4bf51a586183d99a326b75ebf6a78 (diff)
downloadlibgpod-tmz-37e1533b203557602942eea32cc9f2397004023c.tar.gz
libgpod-tmz-37e1533b203557602942eea32cc9f2397004023c.tar.xz
libgpod-tmz-37e1533b203557602942eea32cc9f2397004023c.zip
* 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
Diffstat (limited to 'tests')
-rw-r--r--tests/test-covers.c70
-rw-r--r--tests/test-photos.c33
2 files changed, 55 insertions, 48 deletions
diff --git a/tests/test-covers.c b/tests/test-covers.c
index 36a87fa..195f907 100644
--- a/tests/test-covers.c
+++ b/tests/test-covers.c
@@ -30,43 +30,55 @@
#include <locale.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-
+#include "itdb_thumb.h"
static void
-save_itdb_thumb (Itdb_iTunesDB *itdb, Itdb_Thumb *thumb, const char *filename)
+save_itdb_thumb (Itdb_Track *track, GdkPixbuf *pixbuf, guint id)
{
- 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);
-/* g_print ("Saved %s\n", filename); */
- }
+ char *filename;
+ gint width;
+ gint height;
+
+ g_object_get (G_OBJECT (pixbuf),
+ "width", &width,
+ "height", &height,
+ NULL);
+ filename = g_strdup_printf ("%03d_%s-%s-%s-%xx%x-%016"G_GINT64_MODIFIER"x.png",
+ id,
+ track->artist, track->album,
+ track->title, width, height,
+ track->dbid);
+ if (filename == NULL) {
+ return;
+ }
+ g_print (" %s\n", filename);
+ gdk_pixbuf_save (pixbuf, filename, "png", NULL, NULL);
+ gdk_pixbuf_unref (pixbuf);
+ /* g_print ("Saved %s\n", filename); */
+ g_free (filename);
}
+
static void
save_song_thumbnails (Itdb_Track *song)
{
- static gint count = 0;
- GList *it;
- for (it = song->artwork->thumbnails; it != NULL; it = it->next) {
- Itdb_Thumb *thumb;
- gchar *filename;
-
- thumb = (Itdb_Thumb *)it->data;
- g_return_if_fail (thumb);
-
- filename = g_strdup_printf ("%03d_%s-%s-%s-%d-%016"G_GINT64_MODIFIER"x.png",
- count++,
- song->artist, song->album,
- song->title, thumb->type,
- song->dbid);
- if (filename != NULL) {
- g_print (" %s\n", filename);
- save_itdb_thumb (song->itdb, thumb, filename);
- g_free (filename);
- }
+ static guint count = 0;
+ GList *it;
+ GList *thumbs;
+ Itdb_Thumb_Ipod *thumb = (Itdb_Thumb_Ipod*)song->artwork->thumbnail;
+ if (thumb == NULL) {
+ return;
+ }
+ thumbs = itdb_thumb_ipod_to_pixbufs (song->itdb->device, thumb);
+ for (it = thumbs; it != NULL; it = it->next) {
+ GdkPixbuf *pixbuf;
+
+ pixbuf = GDK_PIXBUF (it->data);
+ g_return_if_fail (pixbuf);
+
+ save_itdb_thumb (song, pixbuf, count);
+ count++;
}
+ g_list_free (thumbs);
}
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 <gdk-pixbuf/gdk-pixbuf.h>
#include <glib/gi18n-lib.h>
+#include "itdb_thumb.h"
+
static void usage (int argc, char **argv)
{
/* gchar *name = argv[0];*/
@@ -60,40 +62,33 @@ static Itdb_Artwork *get_photo_by_id (Itdb_PhotoDB *db, guint32 id)
}
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