And here is a bigger patch cleaning some memory leaks. It's probably better to review it carefully since I coded it quickly while browsing the rb-album-cover.c source file. I removed the if (pointer) g_free (pointer) tests since g_free (NULL) 'works' (ie it silently returns), so the test isn't useful. The "No Cover Found"/"Searching Cover" can't be bitmaps for i18n/a11y reasons, maybe the best thing to do it to just hide the cover entry when there is nothing to show? The rb_album_cover_load_xml_async and rb_album_cover_load_async functions (and the various callbacks they use) are pretty similar, would it help if gnome-vfs provided a gnome_vfs_read_entire_file_async function (ie could such a function be used to simplify this code)? I haven't looked at the code in detail, so maybe it's not that easy ;) Christophe Le samedi 11 décembre 2004 à 21:27 +0100, Christophe Fergeau a écrit : > Hi, > > I finally gave a try to your arch tree (I also added it to rb website > development page, it will show up when the web site is synced with the > content of the arch repo). All in all, it's working really nicely though > I'm not a big fan of the UI decisions :-/ I also had to apply the small > attached patch, otherwise it crashed when I tried to play a song. > The bottom left part of rb window is too big to display an amazon cover, > some look really fuzzy... > The "cover manager" should probably be integrated somehow with the song > properties and extended to be a "fix my song tags using amazon" a bit > like http://www.softpointer.com/images/TRAll.gif I'm not sure how to get > that 100% right though since song properties are per song, and this > "cover editor/tag fixer" would be per album. This is just food for > thought anyway ;) > Finally, I think I'd just grab the missing covers from amazon at startup > without asking the user or requiring him to go to the cover editor. > > All in all, excellent travail ;) , cheers, > > Christophe > > > Le jeudi 09 décembre 2004 à 16:47 +0100, Marc Pavot a écrit : > > Hi, > > > > I have made a lot of changes in my arch branch for the support of the > > album covers. It now works like this : > > > > *When you play a song : > > - It search a cover in ~/.gnome2/rhythmbox/covers > > - If none is found, it search a cover in the directory of the song > > - If none is found, it search a cover on amazon.com > > - If a cover is found in one of this place, the cover is displayed and > > saved in ~/.gnome2/rhythmbox/covers. > > > > *When you launch the cover manager (screenshot : > > http://perso.enst.fr/~pavot/Capture3.png > > - It now shows all the covers found in ~/.gnome2/rhythmbox/covers with a > > tree structure (Artist/Album) > > - You can : > > - Automatically get all the covers of an artist (or of all > > artists) from the directory of the albums. > > - Automatically download all the covers of an artist (or of all > > artists) from amazon. > > - Download a cover from amazon and select between different > > covers and different sizes if you only select one album. > > - Choose a cover for an album on your hard disk if you only > > select one album. > > > > All your comments, ideas and bug reports are really welcome. > > > > Marc > > > > PS : my arch branch is here: > > m pavot laposte net--2004 > > http://perso.enst.fr/~pavot/archive > > > > > > _______________________________________________ > > rhythmbox-devel mailing list > > rhythmbox-devel gnome org > > http://mail.gnome.org/mailman/listinfo/rhythmbox-devel > > > > > _______________________________________________ > rhythmbox-devel mailing list > rhythmbox-devel gnome org > http://mail.gnome.org/mailman/listinfo/rhythmbox-devel
* looking for m pavot laposte net--2004/rhythmbox--main--0.8--patch-17 to compare with
* comparing to m pavot laposte net--2004/rhythmbox--main--0.8--patch-17
M widgets/rb-album-cover.c
* modified files
--- orig/widgets/rb-album-cover.c
+++ mod/widgets/rb-album-cover.c
@@ -53,10 +53,10 @@
static char* rb_album_cover_find_local_image (RBAlbumCover* album_cover,
const char *location);
static void rb_album_cover_find_amazon_image (RBAlbumCover *album_cover,
- char *artist,
- char *album);
+ const char *artist,
+ const char *album);
static void rb_album_cover_load_xml_async (RBAlbumCover *album_cover,
- char *xml_uri);
+ const char *xml_uri);
static void rb_album_cover_xml_open_cb (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
RBAlbumCover *album_cover);
@@ -106,8 +106,7 @@
rb_album_cover_save_cover_close_cb (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
RBAlbumCover *album_cover);
-
-
+
struct RBAlbumCoverPrivate
{
GtkWidget *image;
@@ -227,15 +226,9 @@
rb_album_cover_set_nocover (album_cover);
- album_cover->priv->uri = NULL;
- album_cover->priv->artist = "";
- album_cover->priv->album = "";
- album_cover->priv->uri_has_changed = FALSE;
-
- album_cover->priv->size = 0;
+ album_cover->priv->artist = g_strdup ("");
+ album_cover->priv->album = g_strdup ("");
album_cover->priv->searching_cover = -1;
- album_cover->priv->xmldata = NULL;
- album_cover->priv->imagedata = NULL;
}
static void
@@ -250,12 +243,9 @@
g_return_if_fail (album_cover->priv != NULL);
- if (album_cover->priv->uri)
- g_free (album_cover->priv->uri);
- if (album_cover->priv->artist)
- g_free (album_cover->priv->artist);
- if (album_cover->priv->album)
- g_free (album_cover->priv->album);
+ g_free (album_cover->priv->uri);
+ g_free (album_cover->priv->artist);
+ g_free (album_cover->priv->album);
g_free (album_cover->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -280,28 +270,23 @@
/* Check if the uri has changed. If not, don't do anything :-) */
if (rb_album_cover_uris_equal (album_cover->priv->uri, uri))
return;
- if (album_cover->priv->imagedata)
- g_free (album_cover->priv->imagedata);
- if (album_cover->priv->xmldata)
- g_free (album_cover->priv->xmldata);
+ g_free (album_cover->priv->imagedata);
+ g_free (album_cover->priv->xmldata);
+ g_free (album_cover->priv->uri);
album_cover->priv->imagedata = NULL;
album_cover->priv->xmldata = NULL;
album_cover->priv->size = 0;
- if (album_cover->priv->uri)
- g_free (album_cover->priv->uri);
album_cover->priv->uri = g_strdup (uri);
album_cover->priv->uri_has_changed = TRUE;
break;
case PROP_ARTIST:
artist = g_value_get_string (value);
- if (album_cover->priv->artist)
- g_free (album_cover->priv->artist);
+ g_free (album_cover->priv->artist);
album_cover->priv->artist = g_strdup (artist);
break;
case PROP_ALBUM:
album = g_value_get_string (value);
- if (album_cover->priv->album)
- g_free (album_cover->priv->album);
+ g_free (album_cover->priv->album);
album_cover->priv->album = g_strdup (album);
break;
default:
@@ -334,8 +319,8 @@
}
}
-GtkWidget
-*rb_album_cover_new (void)
+GtkWidget *
+rb_album_cover_new (void)
{
RBAlbumCover *album_cover;
@@ -419,10 +404,13 @@
g_object_set (G_OBJECT (album_cover), "artist", artist, NULL);
g_object_set (G_OBJECT (album_cover), "album", album, NULL);
- cover_home = g_strdup (rb_album_cover_make_cover_path (artist, album));
+ cover_home = rb_album_cover_make_cover_path (artist, album);
- if (rb_uri_exists(cover_home))
- cover_uri = g_strdup (cover_home);
+ if (rb_uri_exists(cover_home)) {
+ cover_uri = cover_home;
+ } else {
+ g_free (cover_home);
+ }
if (!cover_uri) {
if (!location) {
@@ -433,7 +421,6 @@
}
if (!cover_uri) {
- g_free (cover_uri);
rb_album_cover_find_amazon_image (album_cover,
artist,
album);
@@ -507,26 +494,30 @@
static void
rb_album_cover_find_amazon_image (RBAlbumCover *album_cover,
- char *artist,
- char *album)
+ const char *artist,
+ const char *album)
{
char *xml_uri;
+ char *tmp;
- xml_uri = g_strdup_printf ("%s %s", artist, album);
-
- xml_uri = gnome_vfs_escape_path_string (xml_uri);
-
- xml_uri = g_strdup_printf ("http://xml.amazon.com/onca/xml3?t=webservices-20&dev-t=D1EEUYQ7Y68BJ3&KeywordSearch=%s&mode=music&type=lite&page=1&f=xml", xml_uri);
+ xml_uri = g_strdup_printf ("%s %s", artist, album);
+ tmp = gnome_vfs_escape_path_string (xml_uri);
+ g_free (xml_uri);
+ xml_uri = g_strdup_printf ("http://xml.amazon.com/onca/xml3?t=webservices-20&dev-t=D1EEUYQ7Y68BJ3&KeywordSearch=%s&mode=music&type=lite&page=1&f=xml", tmp);
+ g_free (tmp);
rb_album_cover_load_xml_async (album_cover, xml_uri);
+ g_free (xml_uri);
}
static void
rb_album_cover_load_xml_async (RBAlbumCover *album_cover,
- char *xml_uri)
+ const char *xml_uri)
{
GnomeVFSAsyncHandle *handle;
album_cover->priv->size = 0;
+ g_free (album_cover->priv->xmldata);
+ g_free (album_cover->priv->buffer);
album_cover->priv->xmldata = NULL;
album_cover->priv->buffer = NULL;
album_cover->priv->total_bytes_read = 0;
@@ -568,6 +559,7 @@
{
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
g_free (album_cover->priv->buffer);
+ album_cover->priv->buffer = NULL;
rb_album_cover_set_nocover (album_cover);
gnome_vfs_async_close (handle,
(GnomeVFSAsyncCloseCallback) rb_album_cover_xml_close_cb,
@@ -600,6 +592,7 @@
if (result != GNOME_VFS_OK) {
g_free (album_cover->priv->buffer);
+ album_cover->priv->buffer = NULL;
rb_album_cover_set_nocover (album_cover);
return;
}
@@ -693,12 +686,13 @@
if (info->size < 900) tests = FALSE; /*remove amazon empty cover*/
if (info->type != GNOME_VFS_FILE_TYPE_REGULAR) tests = FALSE;
} else tests = FALSE;
+
+ gnome_vfs_file_info_unref (info);
if (!tests) {
rb_album_cover_set_nocover (album_cover);
return;
}
- gnome_vfs_file_info_unref (info);
gnome_vfs_async_open (&handle, album_cover->priv->uri,
GNOME_VFS_OPEN_READ,
@@ -717,8 +711,7 @@
return;
}
- if (album_cover->priv->buffer)
- g_free (album_cover->priv->buffer);
+ g_free (album_cover->priv->buffer);
album_cover->priv->buffer = g_malloc0 (READ_CHUNK_SIZE);
gnome_vfs_async_read (handle,
@@ -738,6 +731,7 @@
{
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
g_free (album_cover->priv->buffer);
+ album_cover->priv->buffer = NULL;
rb_album_cover_set_nocover (album_cover);
gnome_vfs_async_close (handle,
(GnomeVFSAsyncCloseCallback) rb_album_cover_uri_close_cb,
@@ -770,6 +764,7 @@
if (result != GNOME_VFS_OK) {
g_free (album_cover->priv->buffer);
+ album_cover->priv->buffer = NULL;
rb_album_cover_set_nocover (album_cover);
return;
}
@@ -843,8 +838,9 @@
result = gnome_vfs_make_directory (cover_path, GNOME_VFS_PERM_USER_ALL
| GNOME_VFS_PERM_GROUP_READ
| GNOME_VFS_PERM_OTHER_READ);
+ g_free (cover_path);
- cover_home = g_strdup (rb_album_cover_make_cover_path (album_cover->priv->artist, album_cover->priv->album));
+ cover_home = rb_album_cover_make_cover_path (album_cover->priv->artist, album_cover->priv->album);
album_cover->priv->uri = g_strdup (cover_home);
@@ -860,6 +856,7 @@
(GnomeVFSAsyncOpenCallback) rb_album_cover_save_cover_open_cb,
album_cover);
}
+ g_free (cover_home);
}
static void
@@ -925,6 +922,10 @@
gchar *album)
{
char *cover_path;
- cover_path = g_build_filename (rb_dot_dir (), "covers", g_strdup_printf ("%s-%s.jpg", artist, album), NULL);
+ char *filename;
+
+ filename = g_strdup_printf ("%s-%s.jpg", artist, album);
+ cover_path = g_build_filename (rb_dot_dir (), "covers", filename, NULL);
+ g_free (filename);
return cover_path;
}
Attachment:
signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=