From: <pha...@us...> - 2008-05-31 10:15:01
|
Revision: 1997 http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1997&view=rev Author: phantom_sf Date: 2008-05-31 03:15:05 -0700 (Sat, 31 May 2008) Log Message: ----------- 2008-05-31 P.G. Richardson <phantom_sf at users.sourceforge.net> * context_menus.c Added coverart update call to eject ipod action. * display_coverart.c * display_covarart.h Tidied up function doc comments. Ensured when no playlist is selected, coverart_display_update clears the artwork display. Modified Paths: -------------- gtkpod/trunk/ChangeLog gtkpod/trunk/src/context_menus.c gtkpod/trunk/src/display_coverart.c gtkpod/trunk/src/display_coverart.h Modified: gtkpod/trunk/ChangeLog =================================================================== --- gtkpod/trunk/ChangeLog 2008-05-30 13:21:09 UTC (rev 1996) +++ gtkpod/trunk/ChangeLog 2008-05-31 10:15:05 UTC (rev 1997) @@ -1,3 +1,16 @@ +2008-05-31 P.G. Richardson <phantom_sf at users.sourceforge.net> + + * context_menus.c + + Added coverart update call to eject ipod action. + + * display_coverart.c + * display_covarart.h + + Tidied up function doc comments. + Ensured when no playlist is selected, coverart_display_update + clears the artwork display. + 2008-05-30 Christophe Fergeau <teuf at gnome.org> * src/details.c: Modified: gtkpod/trunk/src/context_menus.c =================================================================== --- gtkpod/trunk/src/context_menus.c 2008-05-30 13:21:09 UTC (rev 1996) +++ gtkpod/trunk/src/context_menus.c 2008-05-31 10:15:05 UTC (rev 1997) @@ -319,6 +319,8 @@ g_return_if_fail (eitdb->itdb_imported == TRUE); gp_eject_ipod (itdb); + /* Set the coverart display based on the selected playlist */ + coverart_display_update(TRUE); } @@ -1158,15 +1160,7 @@ if (selected_tracks) g_list_free (selected_tracks); selected_tracks = g_list_copy (coverart_get_displayed_tracks()); - /* - int i; - for (i = 0; i < g_list_length(selected_tracks); ++i) - { - Track *track; - track = g_list_nth_data (selected_tracks, i); - printf ("context_menu_init - Artist:%s Album:%s Title:%s\n", track->artist, track->album, track->title); - } - */ + if(selected_tracks) create_context_menu (CM_CAD); } Modified: gtkpod/trunk/src/display_coverart.c =================================================================== --- gtkpod/trunk/src/display_coverart.c 2008-05-30 13:21:09 UTC (rev 1996) +++ gtkpod/trunk/src/display_coverart.c 2008-05-31 10:15:05 UTC (rev 1997) @@ -54,6 +54,8 @@ static void set_highlight (Cover_Item *cover, gint index, cairo_t *cr); static void set_shadow_reflection (Cover_Item *cover, cairo_t *cr); static void remove_track_from_album (Album_Item *album, Track *track, gchar *key, gint index, GList *keylistitem); +static GdkPixbuf *coverart_get_default_track_thumb (gint default_img_size); +static GdkPixbuf *coverart_get_track_thumb (Track *track, Itdb_Device *device, gint default_img_size); /* callback declarations */ static gboolean on_gtkpod_window_configure (GtkWidget *widget, GdkEventConfigure *event, gpointer data); @@ -147,7 +149,10 @@ * Initialises the image file used if an album has no cover. This * needs to be loaded early as it uses the path of the binary * to determine where to load the file from, in the same way as - * main() determines where to load the glade file from. + * main() determines where to load the glade file from. + * + * Currently called from gtkpod_init. Should not need to be called + * subsequent to this. * * @progpath: path of the gtkpod binary being loaded. * @@ -378,6 +383,17 @@ cdwidget->block_display_change = val; } +/** + * redraw: + * + * Draw the artist and album text strings. + * + * @cairo_context: the context of the artwork display + * @text: the text to be added to the artwork display + * @x: the x coordinate of its location + * @y: the y coordinate of its location + * + */ static void draw_string (cairo_t *cairo_context, const gchar *text, gdouble x, @@ -410,6 +426,44 @@ g_object_unref (layout); } +/** + * redraw: + * + * Utility function for set all the x, y, width and height + * dimensions applicable to a single cover widget + * + * @force_pixbuf_update: flag indicating whether to force an update of the pixbuf covers + */ +static void redraw (gboolean force_pixbuf_update) +{ + force_pixbuf_covers = force_pixbuf_update; + GdkRegion *region = gdk_drawable_get_clip_region (cdwidget->draw_area->window); + /* redraw the cairo canvas completely by exposing it */ + gdk_window_invalidate_region (cdwidget->draw_area->window, region, TRUE); + gdk_window_process_updates (cdwidget->draw_area->window, TRUE); + gdk_region_destroy (region); + + if (g_list_length (album_key_list) <= 1) + { + gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->cdslider), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->leftbutton), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->rightbutton), FALSE); + } + else + { + gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->cdslider), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->leftbutton), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->rightbutton), TRUE); + } +} + +/** + * draw: + * + * Paint the coverart display using cairo. + * + * @cairo_context: the coverart display context + */ static void draw (cairo_t *cairo_context) { gint cover_index[] = {0, 8, 1, 7, 2, 6, 3, 5, 4}; @@ -566,7 +620,10 @@ /** * coverart_display_update: * - * Takes a list of tracks and sets the 9 image cover display. + * Refreshes the coverart display depending on the playlist selection. Using the + * clear_track_list, the refresh can be quicker is set to FALSE. However, the track + * list is not updated in this case. Using TRUE, the display is completely cleared and + * redrawn. * * @clear_track_list: flag indicating whether to clear the displaytracks list or not * @@ -594,20 +651,18 @@ if (clear_track_list) { - /* Find the selected playlist */ - playlist = pm_get_selected_playlist (); - if (playlist == NULL) - return; - - tracks = playlist->members; /* Free up the hash table and the key list */ g_hash_table_foreach_remove(album_hash, (GHRFunc) gtk_true, NULL); - g_list_free (album_key_list); + album_key_list = NULL; - album_key_list = NULL;; + /* Find the selected playlist */ + playlist = pm_get_selected_playlist (); + + if (playlist) + tracks = playlist->members; - if (tracks == NULL) + if (! playlist || ! tracks) { redraw (FALSE); return; @@ -679,29 +734,6 @@ */ } -static void redraw (gboolean force_pixbuf_update) -{ - force_pixbuf_covers = force_pixbuf_update; - GdkRegion *region = gdk_drawable_get_clip_region (cdwidget->draw_area->window); - /* redraw the cairo canvas completely by exposing it */ - gdk_window_invalidate_region (cdwidget->draw_area->window, region, TRUE); - gdk_window_process_updates (cdwidget->draw_area->window, TRUE); - gdk_region_destroy (region); - - if (g_list_length (album_key_list) <= 1) - { - gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->cdslider), FALSE); - gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->leftbutton), FALSE); - gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->rightbutton), FALSE); - } - else - { - gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->cdslider), TRUE); - gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->leftbutton), TRUE); - gtk_widget_set_sensitive (GTK_WIDGET(cdwidget->rightbutton), TRUE); - } -} - /** * set_cover_dimensions: * @@ -882,12 +914,19 @@ /** * - * Convenience function that will only allow set images to be - * called if the track that was affected was in the list of displaytracks - * used by the coverart display. So if a whole album is deleted then this - * will only reset the display if the first track in the album is deleted. + * Function to cause a refresh on the given track. + * The signal will be one of: * + * COVERART_REMOVE_SIGNAL - track deleted + * COVERART_CREATE_SIGNAL - track created + * COVERART_CHANGE_SIGNAL - track modified + * + * If the track was in the current display of artwork then the + * artwork will be updated. If it was not then a refresh is unnecessary + * and the function will return accordingly. + * * @track: affected track + * @signal: flag indicating the type of track change that has occurred. */ void coverart_track_changed (Track *track, gint signal) { @@ -1445,7 +1484,7 @@ * pixbuf referenced by the provided track or the pixbuf of the * default file if track has no cover art. */ -GdkPixbuf *coverart_get_track_thumb (Track *track, Itdb_Device *device, gint default_size) +static GdkPixbuf *coverart_get_track_thumb (Track *track, Itdb_Device *device, gint default_size) { GdkPixbuf *pixbuf = NULL; GdkPixbuf *image = NULL; @@ -1532,7 +1571,7 @@ * Returns: * pixbuf of the default file for tracks with no cover art. */ -GdkPixbuf *coverart_get_default_track_thumb (gint default_img_size) +static GdkPixbuf *coverart_get_default_track_thumb (gint default_img_size) { GdkPixbuf *pixbuf = NULL; GdkPixbuf *scaled = NULL; @@ -1835,6 +1874,13 @@ redraw (FALSE); } +/** + * coverart_get_background_display_color: + * + * Used by coverart draw functions to determine the background color + * of the coverart display, which is selected from the preferences. + * + */ GdkColor *coverart_get_background_display_color () { gchar *hex_string; @@ -1851,6 +1897,14 @@ return color; } +/** + * coverart_get_foreground_display_color: + * + * Used by coverart draw functions to determine the foreground color + * of the coverart display, which is selected from the preferences. The + * foreground color refers to the color used by the artist and album text. + * + */ GdkColor *coverart_get_foreground_display_color () { gchar *hex_string; @@ -1945,6 +1999,14 @@ cdwidget = NULL; } + /** + * dnd_coverart_drag_drop: + * + * Used by the drag and drop of a jpg. When a drop is + * made, this determines whether the drop is valid + * then requests the data from the source widget. + * + */ static gboolean dnd_coverart_drag_drop(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, gpointer user_data) { GdkAtom target; @@ -1955,20 +2017,18 @@ gtk_drag_get_data (widget, drag_context, target, time); return TRUE; } - /* - printf ("drop item\n"); - gint i = 0; - for (i = 0; i < g_list_length(drag_context->targets); ++i) - { - target = g_list_nth_data (drag_context->targets, i); - printf ("Atom: %s\n", gdk_atom_name(target)); - gtk_drag_get_data (widget, drag_context, target, time); - return TRUE; - } - */ + return FALSE; } +/** + * dnd_coverart_drag_motion: + * + * Used by the drag and drop of a jpg. While the jpg is being + * dragged, this reports to the source widget whether it is an + * acceptable location to allow a drop. + * + */ static gboolean dnd_coverart_drag_motion (GtkWidget *widget, GdkDragContext *dc, gint x, @@ -2010,6 +2070,14 @@ return TRUE; } +/** + * dnd_coverart_drag_data_received: + * + * Used by the drag and drop of a jpg. When the drop is performed, this + * acts on the receipt of the data from the source widget and applies + * the jpg to the track. + * + */ static void dnd_coverart_drag_data_received(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data) { Modified: gtkpod/trunk/src/display_coverart.h =================================================================== --- gtkpod/trunk/src/display_coverart.h 2008-05-30 13:21:09 UTC (rev 1996) +++ gtkpod/trunk/src/display_coverart.h 2008-05-31 10:15:05 UTC (rev 1997) @@ -80,19 +80,127 @@ extern const gchar *DISPLAY_COVER_SHOW; +/** + * coverart_init: + * + * Initialises the image file used if an album has no cover. This + * needs to be loaded early as it uses the path of the binary + * to determine where to load the file from, in the same way as + * main() determines where to load the glade file from. + * + * Currently called from gtkpod_init. Should not need to be called + * subsequent to this. + * + * @progpath: path of the gtkpod binary being loaded. + * + */ +void coverart_init (gchar *progpath); -GList *coverart_get_displayed_tracks (void); -GdkPixbuf *coverart_get_default_track_thumb (gint default_img_size); -void coverart_init (gchar *progpath); -void coverart_display_big_artwork (); -void coverart_select_cover (Itdb_Track *track); +/** + * coverart_init_display: + * + * Initialise the boxes and canvases of the coverart_display. + * Called during the creation of the listviews and toolbars etc... + * + */ +void coverart_init_display (); + +/** + * coverart_display_update: + * + * Refreshes the coverart display depending on the playlist selection. Using the + * clear_track_list, the refresh can be quicker is set to FALSE. However, the track + * list is not updated in this case. Using TRUE, the display is completely cleared and + * redrawn. + * + * @clear_track_list: flag indicating whether to clear the displaytracks list or not + * + */ void coverart_display_update (gboolean clear_track_list); + +/** + * + * Function to cause a refresh on the given track. + * The signal will be one of: + * + * COVERART_REMOVE_SIGNAL - track deleted + * COVERART_CREATE_SIGNAL - track created + * COVERART_CHANGE_SIGNAL - track modified + * + * If the track was in the current display of artwork then the + * artwork will be updated. If it was not then a refresh is unnecessary + * and the function will return accordingly. + * + * @track: affected track + * @signal: flag indicating the type of track change that has occurred. + */ void coverart_track_changed (Track *track, gint signal); -void coverart_clear_images (); + +/** + * coverart_block_change: + * + * Select covers events can be switched off when automatic + * selections of tracks are taking place. + * + * @val: indicating whether to block or unblock select cover events + * + */ void coverart_block_change (gboolean val); -void coverart_init_display (); -GdkPixbuf *coverart_get_track_thumb (Track *track, Itdb_Device *device, gint default_img_size); + +/** + * coverart_set_cover_from_file: + * + * Add a cover to the displayed track by setting it from a + * picture file. + * + */ void coverart_set_cover_from_file (); + +/** + * coverart_get_displayed_tracks: + * + * Get all tracks suggested by the displayed album cover. + * + * Returns: + * GList containing references to all the displayed covered tracks + */ +GList *coverart_get_displayed_tracks (void); + +/** + * coverart_display_big_artwork: + * + * Display a big version of the artwork in a dialog + * + */ +void coverart_display_big_artwork (); + +/** + * coverart_select_cover + * + * When a track / album is selected, the artwork cover + * is selected in the display + * + * @track: chosen track + * + */ +void coverart_select_cover (Itdb_Track *track); + +/** + * coverart_get_background_display_color: + * + * Used by coverart draw functions to determine the background color + * of the coverart display, which is selected from the preferences. + * + */ GdkColor *coverart_get_background_display_color (); + +/** + * coverart_get_foreground_display_color: + * + * Used by coverart draw functions to determine the foreground color + * of the coverart display, which is selected from the preferences. The + * foreground color refers to the color used by the artist and album text. + * + */ GdkColor *coverart_get_foreground_display_color (); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |