Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv31816/src
Modified Files:
Tag: coverart_display_development_branch
display_coverart.h display_coverart.c display_sorttabs.c
Log Message:
See file TODOandBUGS.txt for latest status of things completed.
Index: display_coverart.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/Attic/display_coverart.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- display_coverart.h 22 Jan 2007 00:05:08 -0000 1.1.2.3
+++ display_coverart.h 25 Jan 2007 00:10:06 -0000 1.1.2.4
@@ -47,6 +47,7 @@
GPtrArray *cdcovers;
GList *displaytracks;
gint first_imgindex;
+ gboolean fire_display_change;
} CD_Widget;
void init_default_file (gchar *progpath);
Index: display_coverart.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/Attic/display_coverart.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- display_coverart.c 22 Jan 2007 00:05:08 -0000 1.1.2.3
+++ display_coverart.c 25 Jan 2007 00:10:06 -0000 1.1.2.4
@@ -54,6 +54,7 @@
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);
static void prepare_canvas ();
+static void set_covers ();
/* The structure that holds values used throughout all the functions */
static CD_Widget *cdwidget = NULL;
@@ -155,9 +156,9 @@
static GdkPixbuf *draw_shadow_top(gdouble width, gdouble height)
{
gint pixel_offset, rowstride, x, y;
- guchar *drawbuftop;
+ guchar *drawbuf;
- drawbuftop = g_malloc ((gint) (width * 16) * (gint) height);
+ drawbuf = g_malloc ((gint) (width * 16) * (gint) height);
/* drawing buffer length multiplied by 4
* due to 1 width per R, G, B & ALPHA
@@ -169,14 +170,14 @@
for(x = 0; x < width; ++x)
{
pixel_offset = (y * rowstride) + (x * 4);
- drawbuftop[pixel_offset] = 0;
- drawbuftop[pixel_offset + 1] = 0;
- drawbuftop[pixel_offset + 2] = 0;
- drawbuftop[pixel_offset + 3] = 255 - (y * (255 /
height));
- /* drawbuftop[pixel_offset + 3] = 255; */
+ drawbuf[pixel_offset] = 0;
+ drawbuf[pixel_offset + 1] = 0;
+ drawbuf[pixel_offset + 2] = 0;
+ drawbuf[pixel_offset + 3] = 255 - (y * (255 / height));
+ /* drawbuf[pixel_offset + 3] = 255; */
}
}
- return gdk_pixbuf_new_from_data(drawbuftop,
+ return gdk_pixbuf_new_from_data(drawbuf,
GDK_COLORSPACE_RGB,
TRUE,
8,
@@ -206,7 +207,6 @@
drawbuf[pixel_offset + 1] = 0;
drawbuf[pixel_offset + 2] = 0;
drawbuf[pixel_offset + 3] = y * (255 / height);
- /* drawbuf[pixel_offset + 3] = 255; */
}
}
return gdk_pixbuf_new_from_data(drawbuf,
@@ -420,7 +420,53 @@
cover = g_ptr_array_index(cdcovers, IMG_MAIN);
gnome_canvas_item_raise_to_top(cover->cdcvrgrp);
- gnome_canvas_item_raise_to_top(cdwidget->cvrtext);
+ gnome_canvas_item_raise_to_top(GNOME_CANVAS_ITEM(cdwidget->cvrtext));
+}
+
+/**
+ * set_covers:
+ *
+ * Internal function responsible for the resetting of the artwork
+ * covers in response to some kind of change in selection, eg. new
+ * selection in sort tab, button click etc...
+ *
+ */
+static void set_covers ()
+{
+ GdkPixbuf *imgbuf;
+ gint i, dataindex;
+ Itdb_Track *track;
+ Cover_Item *cover;
+
+ 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)
+ {
+ /* Set the pixbuf into the cd image */
+ cover = g_ptr_array_index(cdwidget->cdcovers, i);
+ cover->track = track;
+ imgbuf = gdk_pixbuf_scale_simple(imgbuf,
cover->img_width, cover->img_height, GDK_INTERP_NEAREST);
+ gnome_canvas_item_set(cover->cdimage, "pixbuf", imgbuf);
+ }
+
+ if (i == IMG_MAIN)
+ {
+ /* Set the text to display details of the main image */
+ gnome_canvas_item_set ( GNOME_CANVAS_ITEM
(cdwidget->cvrtext),
+
"text", g_strconcat (track->artist, " - ",
track->album, NULL),
+
"fill_color", "white",
+
NULL);
+ }
+ }
}
/**
@@ -434,10 +480,7 @@
*/
static void scroll_covers(gint direction)
{
- GdkPixbuf *imgbuf;
- gint i, displaytotal, dataindex;
- Itdb_Track *track;
- Cover_Item *cover;
+ gint displaytotal;
displaytotal = g_list_length(cdwidget->displaytracks);
printf("Display Total: %d\n", displaytotal);
@@ -469,24 +512,8 @@
break;
}
- 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;
- }
+ set_covers();
+
}
/**
@@ -500,10 +527,7 @@
*/
static void on_cover_display_slider_value_changed (GtkRange *range, gpointer
user_data)
{
- GdkPixbuf *imgbuf;
- gint i, index, displaytotal, dataindex;
- Cover_Item *cover;
- Itdb_Track *track;
+ gint index, displaytotal;
index = gtk_range_get_value (range);
displaytotal = g_list_length(cdwidget->displaytracks);
@@ -518,24 +542,8 @@
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;
- }
+ set_covers ();
+
}
/**
@@ -585,7 +593,17 @@
cover = g_ptr_array_index(cdwidget->cdcovers, IMG_MAIN);
+ /* Stop redisplay of the artwork as its already
+ * in the correct location
+ */
+ cdwidget->fire_display_change = FALSE;
+
+ /* Select the correct track in the sorttabs */
status = st_set_selection (cover->track);
+
+ /* Turn the display change back on */
+ cdwidget->fire_display_change = TRUE;
+
g_return_if_fail (status);
}
@@ -685,7 +703,7 @@
break;
case IMG_MAIN:
/* The Main Image CD Cover Image */
- y = HEIGHT - (BIG_IMG_HEIGHT + BORDER);
+ y = HEIGHT - (BIG_IMG_HEIGHT + BORDER + (BORDER
/ 2));
img_height = BIG_IMG_HEIGHT;
}
@@ -718,10 +736,16 @@
cover = NULL;
}
- cdwidget->cvrtext =
gnome_canvas_item_new(gnome_canvas_root(cdwidget->canvas),
-
gnome_canvas_text_get_type(),
-
"text", "Aerosmith\nArmageddon SoundTrack",
-
NULL);
+ cdwidget->cvrtext =
GNOME_CANVAS_TEXT(gnome_canvas_item_new(gnome_canvas_root(cdwidget->canvas),
+
GNOME_TYPE_CANVAS_TEXT,
+
"text", "No Artist",
+
"x", (gdouble) WIDTH / 2,
+
"y", (gdouble) HEIGHT - (BORDER + (BORDER / 2)),
+
"justification", GTK_JUSTIFY_LEFT,
+
"anchor", GTK_ANCHOR_NORTH,
+
"fill_color", "black",
+ "font",
"-*-clean-medium-r-normal-*-12-*-*-*-*-*-*",
+
NULL));
@@ -748,7 +772,7 @@
for (i = 0; i < IMG_TOTAL; i++)
{
- GdkPixbuf *buf2;
+ GdkPixbuf *buf2;
/* Reset the pixbuf */
cover = g_ptr_array_index(cdwidget->cdcovers, i);
buf2 = gdk_pixbuf_scale_simple(buf, cover->img_width,
cover->img_height, GDK_INTERP_NEAREST);
@@ -758,6 +782,15 @@
/* Reset track list too */
cover->track = NULL;
+
+ if (i == IMG_MAIN)
+ {
+ /* Set the text to display details of the main image */
+ gnome_canvas_item_set ( GNOME_CANVAS_ITEM
(cdwidget->cvrtext),
+
"text", "No Artist",
+
"fill_color", "black",
+
NULL);
+ }
}
g_object_unref(buf);
}
@@ -975,10 +1008,25 @@
g_signal_connect (G_OBJECT(cdwidget->cdslider), "value-changed",
G_CALLBACK(on_cover_display_slider_value_changed), NULL);
- gtk_widget_show_all(cdwidget->contentpanel);
+ cdwidget->fire_display_change = TRUE;
+
+ gtk_widget_show_all (cdwidget->contentpanel);
}
-
+/**
+ * sort_tracks:
+ *
+ * sort function used by glist_sort to compare 2
+ * tracks and determine their order based on firstly
+ * the artist and then the album
+ *
+ * @a: First track from list to compare
+ * @b: Second track from list to compare
+ *
+ * Returns:
+ * integer indicating order of tracks
+ *
+ */
static gint sort_tracks (Itdb_Track *a, Itdb_Track *b)
{
gint artistval;
@@ -1007,10 +1055,11 @@
void coverart_select_cover (gchar *album)
{
GList *selectedtrk;
- GdkPixbuf *imgbuf;
- gint i, index, displaytotal, dataindex;
- Cover_Item *cover;
- Itdb_Track *track;
+ gint displaytotal, index;
+
+ /* Only select covers if fire display change is enabled */
+ if (! cdwidget->fire_display_change)
+ return;
displaytotal = g_list_length(cdwidget->displaytracks);
if (displaytotal <= 0)
@@ -1030,24 +1079,7 @@
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;
- }
+ set_covers ();
}
@@ -1099,14 +1131,18 @@
void coverart_set_images (GList *tracks)
{
gint i;
- GdkPixbuf *pixbuf = NULL;
- Cover_Item *cover = NULL;
GtkWidget *cover_window;
Itdb_Track *track;
/* initialize display if not already done */
if (!cdwidget) coverart_init_display();
-
+
+ /* Ensure that the setting of images hasnt been turned off
+ * due to being in the middle of a selection operation
+ */
+ if (! cdwidget->fire_display_change)
+ return;
+
cover_window = gtkpod_xml_get_widget (main_window_xml,
"cover_display_window");
//gtk_widget_set (cover_window, "visible", TRUE, NULL);
@@ -1139,32 +1175,11 @@
cdwidget->displaytracks = g_list_reverse (cdwidget->displaytracks);
- for (i = 0; i < IMG_TOTAL; ++i)
- {
- /* i as an index beings at the main cd image
- * while the first display track should be
- * accessed hence i - IMG_MAIN
- */
- track = g_list_nth_data (cdwidget->displaytracks, i);
-
- if (track == NULL)
- pixbuf = draw_blank_cdimage();
- else
- pixbuf = get_thumb (track);
-
- if (pixbuf != NULL)
- {
- /* Set the pixbuf into the cd image */
- cover = g_ptr_array_index(cdwidget->cdcovers, i);
- cover->track = track;
- pixbuf = gdk_pixbuf_scale_simple(pixbuf,
cover->img_width, cover->img_height, GDK_INTERP_NEAREST);
- gnome_canvas_item_set(cover->cdimage, "pixbuf", pixbuf);
- }
- }
+ set_covers ();
/* Set the scale range */
gtk_range_set_range (GTK_RANGE (cdwidget->cdslider), 0, g_list_length
(cdwidget->displaytracks) - 1);
-
+
/*printf("######### ORIGINAL LINE UP ########\n");
debug_albums ();
printf("######### END OF ORIGINAL LINE UP #######\n");*/
Index: display_sorttabs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display_sorttabs.c,v
retrieving revision 1.85.2.2
retrieving revision 1.85.2.3
diff -u -d -r1.85.2.2 -r1.85.2.3
--- display_sorttabs.c 22 Jan 2007 00:05:08 -0000 1.85.2.2
+++ display_sorttabs.c 25 Jan 2007 00:10:06 -0000 1.85.2.3
@@ -2206,6 +2206,7 @@
}
gtkpod_tracks_statusbar_update();
+ /* Select the cover in the coverart_display */
GList *gl = g_list_first(new_entry->members);
Track *track = gl->data;
printf("track artist: %s Track Album: %s\n", track->artist,
track->album);
-------------------------------------------------------------------------
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