Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv6531/src
Modified Files:
Tag: coverart_display_development_branch
display_coverart.c display_tracks.c display_sorttabs.c
prefs_window.c display_coverart.h
Log Message:
- Selection of a track causes the display to swith to the relevant album cover
- tick
- Selection of an album from either sort list causes switching display to
relevant album cover -tick
- Selection of an artist / genre ... causes selection of the first album
corresponding to the selected criteria - tick
- Order of tracks is updated when the alphabetize function is clicked - tick
- Images are clear before setting them in case a null is returned from
get_thumb()
- Preference for visibility removed. Now displays by default. Arrows to
minimize still to do.
- Framework for artist/album title started.
Index: display_coverart.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/Attic/display_coverart.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- display_coverart.c 8 Jan 2007 21:47:07 -0000 1.1.2.2
+++ display_coverart.c 22 Jan 2007 00:05:08 -0000 1.1.2.3
@@ -48,6 +48,8 @@
static void raise_cdimages (GPtrArray *cdcovers);
static GdkPixbuf *get_thumb (Itdb_Track *track);
static void scroll_covers (gint direction);
+static gint sort_tracks (Itdb_Track *a, Itdb_Track *b);
+static gint search_tracks_by_album (Itdb_Track *a, gchar *b);
static void on_cover_display_button_clicked (GtkWidget *widget, gpointer data);
static void on_main_cover_image_clicked (GnomeCanvas *canvas, GdkEvent *event,
gpointer data);
static void on_cover_display_slider_value_changed (GtkRange *range, gpointer
user_data);
@@ -417,6 +419,8 @@
}
cover = g_ptr_array_index(cdcovers, IMG_MAIN);
gnome_canvas_item_raise_to_top(cover->cdcvrgrp);
+
+ gnome_canvas_item_raise_to_top(cdwidget->cvrtext);
}
/**
@@ -508,7 +512,7 @@
return;
/* Use the index value from the slider for the main image index */
- cdwidget->first_imgindex = index - IMG_MAIN -1;
+ cdwidget->first_imgindex = index - IMG_MAIN - 1;
if (cdwidget->first_imgindex < 0)
cdwidget->first_imgindex = 0;
else if((cdwidget->first_imgindex + IMG_TOTAL) >= displaytotal)
@@ -714,6 +718,13 @@
cover = NULL;
}
+ cdwidget->cvrtext =
gnome_canvas_item_new(gnome_canvas_root(cdwidget->canvas),
+
gnome_canvas_text_get_type(),
+
"text", "Aerosmith\nArmageddon SoundTrack",
+
NULL);
+
+
+
raise_cdimages (cdwidget->cdcovers);
free_shadow(imgshadow);
@@ -819,6 +830,31 @@
}
/**
+ * search_tracks_by_album:
+ *
+ * find function used by glist_find_custom to compare 2
+ * tracks
+ *
+ * @a: Track from list to compare against
+ * @b: Album string to compare with
+ *
+ * Returns:
+ * 0 if the two tracks match
+ * -1 if the two tracks are different
+ *
+ */
+static gint search_tracks_by_album (Itdb_Track *a, gchar *b)
+{
+ if(a == NULL)
+ return -1;
+
+ if (g_ascii_strcasecmp (a->album, b) == 0)
+ return 0;
+
+ return -1;
+}
+
+/**
* init_default_file:
*
* Initialises the image file used if an album has no cover. This
@@ -942,6 +978,116 @@
gtk_widget_show_all(cdwidget->contentpanel);
}
+
+static gint sort_tracks (Itdb_Track *a, Itdb_Track *b)
+{
+ gint artistval;
+
+ g_return_val_if_fail (a, -1);
+ g_return_val_if_fail (b, -1);
+
+ artistval = g_ascii_strcasecmp (a->artist, b->artist);
+
+ /* Artists are not the same so return, no more checking needed */
+ if(artistval != 0)
+ return artistval;
+ else
+ return g_ascii_strcasecmp (a->album, b->album);
+}
+
+/**
+ * coverart_select_cover
+ *
+ * When a track / album is selected, the artwork cover
+ * is selected in the display
+ *
+ * @track: chosen album
+ *
+ */
+ void coverart_select_cover (gchar *album)
+ {
+ GList *selectedtrk;
+ GdkPixbuf *imgbuf;
+ gint i, index, displaytotal, dataindex;
+ Cover_Item *cover;
+ Itdb_Track *track;
+
+ displaytotal = g_list_length(cdwidget->displaytracks);
+ if (displaytotal <= 0)
+ return;
+
+ /* Find the track that matches the given album */
+ selectedtrk = g_list_find_custom (cdwidget->displaytracks,
album, (GCompareFunc) search_tracks_by_album);
+ g_return_if_fail (selectedtrk);
+
+ /* Determine the index of the found track */
+ index = g_list_position (cdwidget->displaytracks, selectedtrk);
+
+ /* Use the index value for the main image index */
+ cdwidget->first_imgindex = index - IMG_MAIN;
+ if (cdwidget->first_imgindex < 0)
+ cdwidget->first_imgindex = 0;
+ else if((cdwidget->first_imgindex + IMG_TOTAL) >= displaytotal)
+ cdwidget->first_imgindex = displaytotal - IMG_TOTAL;
+
+ for(i = 0; i < IMG_TOTAL; ++i)
+ {
+ cover = g_ptr_array_index(cdwidget->cdcovers, i);
+ dataindex = cdwidget->first_imgindex + i;
+ track = g_list_nth_data (cdwidget->displaytracks, dataindex);
+
+ if (track == NULL)
+ imgbuf = draw_blank_cdimage();
+ else
+ imgbuf = get_thumb (track);
+
+ if(imgbuf == NULL)
+ printf("image buffer is null\n");
+
+ imgbuf = gdk_pixbuf_scale_simple(imgbuf,
cover->img_width, cover->img_height, GDK_INTERP_NEAREST);
+ gnome_canvas_item_set(cover->cdimage, "pixbuf", imgbuf,
NULL);
+ cover->track = track;
+ }
+ }
+
+
+/**
+ * coverart_sort_images:
+ *
+ * When the alphabetize function is initiated this will
+ * sort the covers in the same way
+ *
+ * @order: order type
+ *
+ */
+ void coverart_sort_images (GtkSortType order)
+ {
+ Playlist* pl;
+ GList *newlist = NULL;
+
+ if (order == SORT_NONE)
+ {
+ pl = pm_get_selected_playlist ();
+ newlist = pl->members;
+ }
+ else
+ {
+ newlist = g_list_copy(cdwidget->displaytracks);
+
+ /* Remove all the null tracks before sorting */
+ newlist = g_list_remove_all (newlist, NULL);
+
+ newlist = g_list_sort (newlist, (GCompareFunc) sort_tracks);
+ }
+
+ if (order == GTK_SORT_DESCENDING)
+ {
+ newlist = g_list_reverse (newlist);
+ }
+
+ coverart_set_images (newlist);
+ }
+
/**
* coverart_set_images:
*
@@ -962,24 +1108,8 @@
if (!cdwidget) coverart_init_display();
cover_window = gtkpod_xml_get_widget (main_window_xml,
"cover_display_window");
- /* Check the preference has been set */
- if (! prefs_get_int("display_artcovers"))
- {
- gtk_widget_set (cover_window,
-
"visible", FALSE,
-
NULL);
- return;
- }
- else
- {
- gtk_widget_set (cover_window,
-
"visible", TRUE,
-
NULL);
- }
- /* Check that the cdwidget has been initialised */
- if (cdwidget == NULL)
- coverart_init_display ();
+ //gtk_widget_set (cover_window, "visible", TRUE, NULL);
clear_cdimages ();
cdwidget->displaytracks = NULL;
Index: display_tracks.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display_tracks.c,v
retrieving revision 1.114
retrieving revision 1.114.2.1
diff -u -d -r1.114 -r1.114.2.1
--- display_tracks.c 26 Nov 2006 05:49:48 -0000 1.114
+++ display_tracks.c 22 Jan 2007 00:05:08 -0000 1.114.2.1
@@ -2077,6 +2077,15 @@
if (col_id != -1) tm_set_search_column (col_id);
}
info_update_track_view_selected ();
+
+ /* update the coverart display */
+ GList *selected = display_get_selection (prefs_get_int("sort_tab_num"));
+ if (selected != NULL)
+ {
+ Track *track = selected->data;
+ if(track != NULL)
+ coverart_select_cover (track->album);
+ }
}
Index: display_sorttabs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display_sorttabs.c,v
retrieving revision 1.85.2.1
retrieving revision 1.85.2.2
diff -u -d -r1.85.2.1 -r1.85.2.2
--- display_sorttabs.c 8 Jan 2007 21:08:44 -0000 1.85.2.1
+++ display_sorttabs.c 22 Jan 2007 00:05:08 -0000 1.85.2.2
@@ -2025,9 +2025,12 @@
void st_sort (GtkSortType order)
{
- gint i;
- for (i=0; i < prefs_get_int("sort_tab_num"); ++i)
- st_sort_inst (i, order);
+ gint i;
+ for (i=0; i < prefs_get_int("sort_tab_num"); ++i)
+ st_sort_inst (i, order);
+
+ coverart_sort_images (order);
+
}
gboolean st_set_selection (Itdb_Track *track)
@@ -2142,8 +2145,8 @@
gtk_tree_model_get (model, &iter,
ST_COLUMN_ENTRY, &new_entry,
-1);
- /* printf("selected instance %d, entry %x (was: %x)\n", inst,
- * new_entry, st->current_entry);*/
+ /*printf("selected instance %d, entry %x (was: %x)\n", inst,
+ *new_entry, st->current_entry);*/
/* initialize next instance */
st_init (-1, inst+1);
@@ -2169,6 +2172,7 @@
g_get_current_time (&time);
}
st_enable_disable_view_sort (inst+1, FALSE);
+
for (gl=new_entry->members; gl; gl=gl->next)
{ /* add all member tracks to next instance */
Track *track = gl->data;
@@ -2201,7 +2205,13 @@
}
}
gtkpod_tracks_statusbar_update();
+
+ GList *gl = g_list_first(new_entry->members);
+ Track *track = gl->data;
+ printf("track artist: %s Track Album: %s\n", track->artist,
track->album);
+ coverart_select_cover (track->album);
}
+
#if DEBUG_TIMING
g_get_current_time (&time);
printf ("st_selection_changed_cb exit: %ld.%06ld sec\n",
Index: prefs_window.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs_window.c,v
retrieving revision 1.188.2.1
retrieving revision 1.188.2.2
diff -u -d -r1.188.2.1 -r1.188.2.2
--- prefs_window.c 8 Jan 2007 21:08:44 -0000 1.188.2.1
+++ prefs_window.c 22 Jan 2007 00:05:08 -0000 1.188.2.2
@@ -1252,14 +1252,6 @@
}
void
-on_cfg_coverart_display_toggled
(GtkToggleButton *togglebutton,
- gpointer
user_data)
-{
- temp_prefs_set_int(temp_prefs, "display_artcovers",
- gtk_toggle_button_get_active (togglebutton));
-}
-
-void
on_cfg_display_toolbar_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
Index: display_coverart.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/Attic/display_coverart.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- display_coverart.h 8 Jan 2007 21:47:07 -0000 1.1.2.2
+++ display_coverart.h 22 Jan 2007 00:05:08 -0000 1.1.2.3
@@ -40,6 +40,7 @@
typedef struct {
GtkWidget *contentpanel;
GnomeCanvas *canvas;
+ GnomeCanvasText *cvrtext;
GtkButton *leftbutton;
GtkHScale *cdslider;
GtkButton *rightbutton;
@@ -49,6 +50,8 @@
} CD_Widget;
void init_default_file (gchar *progpath);
+void coverart_sort_images (GtkSortType order);
+void coverart_select_cover (gchar *album);
void coverart_set_images (GList *tracks);
#endif
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2