Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv24885/src
Modified Files:
display_coverart.c
Log Message:
2007-04-21 P.G. Richardson <phantom_sf at users.sourceforge.net>
* Consideration of extra scenario for removal of a track with
respect to display of coverart. Basically, needed to cater
for situation where user removes the first track in an album
but leaves the remaining tracks behind. Need to remove the
first track from displaytracks list but add in the second.
Index: display_coverart.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display_coverart.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- display_coverart.c 22 Apr 2007 18:06:16 -0000 1.11
+++ display_coverart.c 22 Apr 2007 19:09:29 -0000 1.12
@@ -56,6 +56,7 @@
static void set_slider_range (gint index);
static void set_covers ();
static gint search_tracks (Track *a, Track *b);
+static gint search_other_tracks (Track *a, Track *b);
/* Prefs keys */
const gchar *KEY_DISPLAY_COVERART="display_coverart";
@@ -664,7 +665,7 @@
* find function used by glist_find_custom to compare 2
* tracks
*
- * @a: First track to compare
+ * @a: First track to compare from GList
* @b: Second track to compare
*
* Returns:
@@ -684,6 +685,41 @@
}
/**
+ * search_other_tracks:
+ *
+ * find function used by glist_find_custom to compare 2
+ * tracks but only return if tracks are from the same album
+ * BUT not the same track.
+ *
+ * @a: First track to compare from GList
+ * @b: Second track to compare
+ *
+ * Returns:
+ * 0 if the two tracks match
+ * -1 if the two tracks are different
+ *
+ */
+static gint search_other_tracks (Track *a, Track *b)
+{
+ if(a == NULL || b == NULL)
+ return -1;
+
+ /* Are a and b referencing the same track */
+ if (a == b)
+ return -1;
+
+ /* Are the tracks by the same artist? */
+ if (g_ascii_strcasecmp (a->artist, b->artist) != 0)
+ return -1;
+
+ /* Is the track from the same album? */
+ if (g_ascii_strcasecmp (a->album, b->album) != 0)
+ return -1;
+
+ return 0;
+}
+
+/**
* init_default_file:
*
* Initialises the image file used if an album has no cover. This
@@ -1347,8 +1383,26 @@
* Frees the cdcover widget of the track ready
for deletion
*/
coverart_clear_images ();
+
+ /* Need to address scenario that user deleted
the first track in the display but
+ * left the rest of the album!! Find another
track from the same album.
+ */
+ GList *new_trk_item;
+ Playlist *playlist = pm_get_selected_playlist
();
+ g_return_if_fail (playlist);
+
+ new_trk_item = g_list_find_custom
(playlist->members, track, (GCompareFunc) search_other_tracks);
+ if (new_trk_item != NULL)
+ {
+ /* A different track from the album was
returned so insert it into the
+ * list before the to-be-deleted track
+ */
+ cdwidget->displaytracks =
g_list_insert_before (cdwidget->displaytracks, trkpos, new_trk_item->data);
+ }
+
/* Remove the track from displaytracks */
cdwidget->displaytracks = g_list_delete_link
(cdwidget->displaytracks, trkpos);
+
/* reset the covers and should reset to
original position but without the index */
set_covers ();
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2