1 /* 2 | Copyright (C) 2007 P.G. Richardson <phantom_sf at users.sourceforge.net> 3 | Part of the gtkpod project. 4 | 5 | URL: http://www.gtkpod.org/ 6 | URL: http://gtkpod.sourceforge.net/ 7 | 8 | Gtkpod is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | Gtkpod is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with gtkpod; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | 22 | iTunes and iPod are trademarks of Apple 23 | 24 | This product is not supported/written/published by Apple! 25 | 26 | $Id$ 27 */ 28 29 #ifndef __DISPLAY_COVERART_H__ 30 #define __DISPLAY_COVERART_H__ 31 32 #include <gtk/gtk.h> 33 #include <cairo/cairo.h> 34 35 #define IMG_MAIN 4 36 #define IMG_NEXT 1 37 #define IMG_PREV 2 38 #define IMG_TOTAL 9 39 #define BORDER 10 40 #define DEFAULT_IMG_SIZE 140 41 42 #define COVERART_REMOVE_SIGNAL 1 43 #define COVERART_CREATE_SIGNAL 2 44 #define COVERART_CHANGE_SIGNAL 3 45 46 typedef struct { 47 GList *tracks; 48 gchar *albumname; 49 gchar *artist; 50 GdkPixbuf *albumart; 51 GdkPixbuf *scaled_art; 52 } Album_Item; 53 54 typedef struct { 55 /* Data */ 56 Album_Item *album; 57 gdouble img_x; 58 gdouble img_y; 59 gdouble img_width; 60 gdouble img_height; 61 } Cover_Item; 62 63 typedef struct { 64 /* Gtk widgets */ 65 GtkWidget *contentpanel; 66 GtkWidget *canvasbox; 67 GtkWidget *controlbox; 68 GtkButton *leftbutton; 69 GtkHScale *cdslider; 70 GtkButton *rightbutton; 71 72 /* Utility data */ 73 GPtrArray *cdcovers; 74 gint first_imgindex; 75 gboolean block_display_change; 76 77 /* Drawing area related widgets */ 78 GtkWidget *draw_area; 79 } CD_Widget; 80 81 extern const gchar *DISPLAY_COVER_SHOW; 82 83 /** 84 * coverart_init: 85 * 86 * Initialises the image file used if an album has no cover. This 87 * needs to be loaded early as it uses the path of the binary 88 * to determine where to load the file from, in the same way as 89 * main() determines where to load the glade file from. 90 * 91 * Currently called from gtkpod_init. Should not need to be called 92 * subsequent to this. 93 * 94 * @progpath: path of the gtkpod binary being loaded. 95 * 96 */ 97 void coverart_init (gchar *progpath); 98 99 /** 100 * coverart_init_display: 101 * 102 * Initialise the boxes and canvases of the coverart_display. 103 * Called during the creation of the listviews and toolbars etc... 104 * 105 */ 106 void coverart_init_display (); 107 108 /** 109 * coverart_display_update: 110 * 111 * Refreshes the coverart display depending on the playlist selection. Using the 112 * clear_track_list, the refresh can be quicker is set to FALSE. However, the track 113 * list is not updated in this case. Using TRUE, the display is completely cleared and 114 * redrawn. 115 * 116 * @clear_track_list: flag indicating whether to clear the displaytracks list or not 117 * 118 */ 119 void coverart_display_update (gboolean clear_track_list); 120 121 /** 122 * 123 * Function to cause a refresh on the given track. 124 * The signal will be one of: 125 * 126 * COVERART_REMOVE_SIGNAL - track deleted 127 * COVERART_CREATE_SIGNAL - track created 128 * COVERART_CHANGE_SIGNAL - track modified 129 * 130 * If the track was in the current display of artwork then the 131 * artwork will be updated. If it was not then a refresh is unnecessary 132 * and the function will return accordingly. 133 * 134 * @track: affected track 135 * @signal: flag indicating the type of track change that has occurred. 136 */ 137 void coverart_track_changed (Track *track, gint signal); 138 139 /** 140 * coverart_block_change: 141 * 142 * Select covers events can be switched off when automatic 143 * selections of tracks are taking place. 144 * 145 * @val: indicating whether to block or unblock select cover events 146 * 147 */ 148 void coverart_block_change (gboolean val); 149 150 /** 151 * coverart_set_cover_from_file: 152 * 153 * Add a cover to the displayed track by setting it from a 154 * picture file. 155 * 156 */ 157 void coverart_set_cover_from_file (); 158 159 /** 160 * coverart_get_displayed_tracks: 161 * 162 * Get all tracks suggested by the displayed album cover. 163 * 164 * Returns: 165 * GList containing references to all the displayed covered tracks 166 */ 167 GList *coverart_get_displayed_tracks (void); 168 169 /** 170 * coverart_display_big_artwork: 171 * 172 * Display a big version of the artwork in a dialog 173 * 174 */ 175 void coverart_display_big_artwork (); 176 177 /** 178 * coverart_select_cover 179 * 180 * When a track / album is selected, the artwork cover 181 * is selected in the display 182 * 183 * @track: chosen track 184 * 185 */ 186 void coverart_select_cover (Itdb_Track *track); 187 188 /** 189 * coverart_get_background_display_color: 190 * 191 * Used by coverart draw functions to determine the background color 192 * of the coverart display, which is selected from the preferences. 193 * 194 */ 195 GdkColor *coverart_get_background_display_color (); 196 197 /** 198 * coverart_get_foreground_display_color: 199 * 200 * Used by coverart draw functions to determine the foreground color 201 * of the coverart display, which is selected from the preferences. The 202 * foreground color refers to the color used by the artist and album text. 203 * 204 */ 205 GdkColor *coverart_get_foreground_display_color (); 206 #endif 207