diff options
author | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2005-12-11 07:41:42 +0000 |
---|---|---|
committer | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2005-12-11 07:41:42 +0000 |
commit | 5ffa97e2eaec4bc9cfc489bc14077877fec71081 (patch) | |
tree | c0da1edfa44cb62fa0c558227cfa249a3d4e6c3b | |
parent | 0d91e06ab2d3917f91567b5963164a0ac49da2b4 (diff) | |
download | libgpod-5ffa97e2eaec4bc9cfc489bc14077877fec71081.tar.gz libgpod-5ffa97e2eaec4bc9cfc489bc14077877fec71081.tar.xz libgpod-5ffa97e2eaec4bc9cfc489bc14077877fec71081.zip |
* src/itdb_artwork.c: (itdb_thumb_get_gdk_pixbuf) allow to get
pixbuf even if no iPod is present if the thumbnail points to a
local filename. This way artwork support is also possible on the
'Local' repository in gtkpod (or any other application).
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1193 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/itdb_artwork.c | 97 | ||||
-rw-r--r-- | src/itdb_itunesdb.c | 9 |
3 files changed, 83 insertions, 30 deletions
@@ -1,3 +1,10 @@ +2005-12-11 Jorg Schuler <jcsjcs at users.sourceforge.net> + + * src/itdb_artwork.c: (itdb_thumb_get_gdk_pixbuf) allow to get + pixbuf even if no iPod is present if the thumbnail points to a + local filename. This way artwork support is also possible on the + 'Local' repository in gtkpod (or any other application). + 2005-12-10 Jorg Schuler <jcsjcs at users.sourceforge.net> * src/ithumb-writer.c: fixed typo leading to segfault. diff --git a/src/itdb_artwork.c b/src/itdb_artwork.c index 8e34199..8142403 100644 --- a/src/itdb_artwork.c +++ b/src/itdb_artwork.c @@ -1,4 +1,4 @@ -/* Time-stamp: <2005-12-10 00:03:26 jcs> +/* Time-stamp: <2005-12-11 16:27:33 jcs> | | Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net> | Part of the gtkpod project. @@ -343,33 +343,64 @@ gpointer itdb_thumb_get_gdk_pixbuf (IpodDevice *device, Itdb_Thumb *thumb) { #if HAVE_GDKPIXBUF - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf=NULL; guchar *pixels; - const IpodArtworkFormat *img_info; + const IpodArtworkFormat *img_info=NULL; - g_return_val_if_fail (device, NULL); g_return_val_if_fail (thumb, NULL); - img_info = ipod_get_artwork_info_from_type (device, thumb->type); + /* If we are dealing with an iPod (device != NULL), use default + image dimensions as used on the iPod in question. - if (img_info == NULL) + If we are not dealing with an iPod, we can only return a pixmap + for thumbnails "not transferred to the iPod" (thumb->size == + 0). + */ + if (device != NULL) { - g_print (_("Unable to obtain image info on thumb (type: %d, filename: '%s'\n)"), thumb->type, thumb->filename); - return NULL; + img_info = ipod_get_artwork_info_from_type (device, thumb->type); } if (thumb->size == 0) - { /* pixbuf has not yet been transfered to the iPod */ - gint width, height; + { /* thumbnail has not yet been transferred to the iPod */ + gint width=0, height=0; + + if (img_info != NULL) + { /* use image dimensions from iPod */ + width = img_info->width; + height = img_info->height; + } + else + { /* use default dimensions */ + /* FIXME: better way to use the ipod_color dimensions? */ + switch (thumb->type) + { + case ITDB_THUMB_COVER_SMALL: + width = 56; height = 56; break; + case ITDB_THUMB_COVER_LARGE: + width = 140; height = 140; break; + case ITDB_THUMB_PHOTO_SMALL: + width = 42; height = 30; break; + case ITDB_THUMB_PHOTO_LARGE: + width = 130; height = 88; break; + case ITDB_THUMB_PHOTO_FULL_SCREEN: + width = 220; height = 176; break; + case ITDB_THUMB_PHOTO_TV_SCREEN: + width = 720; height = 480; break; + } + if (width == 0) + { + width = 140; + height = 140; + } + } pixbuf = gdk_pixbuf_new_from_file_at_size (thumb->filename, - img_info->width, - img_info->height, + width, height, NULL); if (!pixbuf) return NULL; - /* !! cannot write directly to &thumb->width/height because g_object_get() returns a gint, but thumb->width/height are gint16 !! */ @@ -380,26 +411,36 @@ itdb_thumb_get_gdk_pixbuf (IpodDevice *device, Itdb_Thumb *thumb) thumb->width = width; thumb->height = height; - - return pixbuf; } - - /* pixbuf is already on the iPod -> read from there */ - pixels = itdb_thumb_get_rgb_data (device, thumb); - if (pixels == NULL) + else { - return NULL; - } + /* pixbuf is already on the iPod -> read from there */ - pixbuf = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, FALSE, - 8, thumb->width, thumb->height, - img_info->width*3, - (GdkPixbufDestroyNotify)g_free, - NULL); + if (img_info == NULL) + { + g_print (_("Unable to retreive thumbnail (appears to be on iPod, but no image info available): type: %d, filename: '%s'\n"), + thumb->type, thumb->filename); + return NULL; + } + pixels = itdb_thumb_get_rgb_data (device, thumb); + if (pixels == NULL) + { + return NULL; + } - /* !! do not g_free(pixels) here: it will be freed when doing a - * gdk_pixbuf_unref() on the GdkPixbuf !! */ + pixbuf = gdk_pixbuf_new_from_data (pixels, + GDK_COLORSPACE_RGB, + FALSE, + 8, thumb->width, + thumb->height, + img_info->width*3, + (GdkPixbufDestroyNotify)g_free, + NULL); + + /* !! do not g_free(pixels) here: it will be freed when doing a + * gdk_pixbuf_unref() on the GdkPixbuf !! */ + } return pixbuf; #else diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c index cab4d8e..54c076a 100644 --- a/src/itdb_itunesdb.c +++ b/src/itdb_itunesdb.c @@ -1,4 +1,4 @@ -/* Time-stamp: <2005-12-06 22:20:40 jcs> +/* Time-stamp: <2005-12-11 16:27:34 jcs> | | Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net> | Part of the gtkpod project. @@ -3582,7 +3582,12 @@ gboolean itdb_write_file (Itdb_iTunesDB *itdb, const gchar *filename, if (!filename) filename = itdb->filename; #if HAVE_GDKPIXBUF - ipod_write_artwork_db (itdb); + /* only write ArtworkDB if we deal with an iPod + FIXME: figure out a way to store the artwork data when storint + to local directories. At the moment it's the application's task + to handle this. */ + if (itdb->device) + ipod_write_artwork_db (itdb); #endif fexp = g_new0 (FExport, 1); |