1 /* 2 | Copyright (C) 2002-2007 Jorg Schuler <jcsjcs 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 | This program 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 | This program 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 this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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_H__ 30 #define __DISPLAY_H__ 31 32 #ifdef HAVE_CONFIG_H 33 # include <config.h> 34 #endif 35 36 #include <gtk/gtk.h> 37 #include <glade/glade.h> 38 #include "itdb.h" 39 #include "display_itdb.h" 40 #include "display_coverart.h" 41 42 /* Main XML glade file */ 43 extern GladeXML *main_window_xml; 44 45 /* pointer to main window */ 46 extern GtkWidget *gtkpod_window; 47 48 /* types for sort */ 49 enum 50 { 51 SORT_ASCENDING = GTK_SORT_ASCENDING, 52 SORT_DESCENDING = GTK_SORT_DESCENDING, 53 SORT_NONE = 10*(GTK_SORT_ASCENDING+GTK_SORT_DESCENDING), 54 }; 55 56 /* Categories in each sort tab (page numbers) */ 57 typedef enum { 58 ST_CAT_ARTIST = 0, 59 ST_CAT_ALBUM, 60 ST_CAT_GENRE, 61 ST_CAT_COMPOSER, 62 ST_CAT_TITLE, 63 ST_CAT_YEAR, 64 ST_CAT_SPECIAL, 65 ST_CAT_NUM 66 } ST_CAT_item; 67 68 /* Number of search tabs to be supported. */ 69 #define SORT_TAB_MAX (ST_CAT_NUM-1) 70 71 /* Number of GtkPaned elements in the main window. The positions of 72 * these elements will be stored in the prefs file and be set to the 73 * last value when starting gtkpod again */ 74 /* Number defined with glade ("paned%d") */ 75 enum { 76 PANED_PLAYLIST = 0, 77 PANED_TRACKLIST, 78 PANED_STATUS1, 79 PANED_STATUS2, 80 PANED_NUM_GLADE 81 }; 82 /* Number created in display.c (for sort tabs, stored in st_paned[]) */ 83 #define PANED_NUM_ST (SORT_TAB_MAX-1) 84 /* Total number */ 85 #define PANED_NUM (PANED_NUM_GLADE+PANED_NUM_ST) 86 87 /* max. number of stars */ 88 #define RATING_MAX 5 89 90 /* struct for each entry in sort tab */ 91 typedef struct { 92 gchar *name; 93 94 /* The sort key can be compared with other sort keys using strcmp 95 * and it will give the expected result, according to the user 96 * settings. Must be regenerated if the user settings change. 97 */ 98 gchar *name_sortkey; 99 100 /* The fuzzy sortkey can be used to compare discarding some 101 * prefixes, such as "the", "el", "la", etc. If NULL, you should use 102 * name_sortkey instead. 103 */ 104 gchar *name_fuzzy_sortkey; 105 106 gboolean master; /* set if this is the "All" entry */ 107 gboolean compilation; /* set if this is the "Compilation" entry */ 108 GList *members; /* GList with member tracks (pointer to "Track") */ 109 } TabEntry; 110 111 /* struct for time info (added, played, modified) */ 112 typedef struct { 113 gchar *int_str; /* copy of string specified in the sort tab */ 114 gboolean valid; /* is current string valid? */ 115 time_t lower; /* timestamp for lower limit */ 116 time_t upper; /* timestamp for upper limit ("-1": no limit) */ 117 GtkWidget *entry; /* pointer to GtkEntry in sort tab */ 118 GtkWidget *active;/* pointer to toggle button */ 119 } TimeInfo; 120 121 /* struct with data corresponding to each sort tab */ 122 typedef struct { 123 guint current_category; /* current page (category) selected) */ 124 gboolean final; /* have all tracks been added? */ 125 GtkWidget *window[ST_CAT_NUM]; /* pointer to scrolled window */ 126 /* The following are used for "normal" categories (not ST_CAT_SPECIAL) */ 127 GtkTreeModel *model; /* pointer to model used */ 128 GtkNotebook *notebook; /* pointer to notebook used */ 129 GtkTreeView *treeview[ST_CAT_NUM]; /* pointer to treeviews used */ 130 GList *entries; /* list with entries */ 131 TabEntry *current_entry; /* pointer to currently selected entry */ 132 gchar *lastselection[ST_CAT_NUM]; /* name of entry last selected */ 133 GHashTable *entry_hash; /* table for quick find of tab entries */ 134 gboolean unselected; /* unselected item since last st_init? */ 135 /* The following are used for "special" categories (ST_CAT_SPECIAL) */ 136 GList *sp_members; /* list of tracks in sorttab */ 137 GList *sp_selected; /* list of tracks selected */ 138 gboolean is_go; /* pass new members on automatically */ 139 TimeInfo ti_added; /* TimeInfo "added" (sp) */ 140 TimeInfo ti_modified; /* TimeInfo "modified" (sp) */ 141 TimeInfo ti_played; /* TimeInfo "played" (sp) */ 142 GtkTooltipsData *sp_tooltips_data; /* ptr to tooltips in special st */ 143 /* function used for string comparisons, set in on_st_switch_page */ 144 gint (*entry_compare_func) (const TabEntry *a, const TabEntry *b); 145 } SortTab; 146 147 /* "Column numbers" in sort tab model */ 148 typedef enum { 149 ST_COLUMN_ENTRY = 0, 150 ST_NUM_COLUMNS 151 } ST_item; 152 153 /* Column numbers in track model */ 154 /* Note: add corresponding entries to T_item and TM_to_T() as well 155 * (below and in misc_conversion.c). 156 * IMPORTANT: Do not change the order -- always add new entries at the 157 * end */ 158 typedef enum { 159 TM_COLUMN_TITLE = 0, 160 TM_COLUMN_ARTIST, 161 TM_COLUMN_ALBUM, 162 TM_COLUMN_GENRE, 163 TM_COLUMN_COMPOSER, 164 TM_COLUMN_TRACK_NR, /* 5 */ 165 TM_COLUMN_IPOD_ID, 166 TM_COLUMN_PC_PATH, 167 TM_COLUMN_TRANSFERRED, 168 TM_COLUMN_SIZE, 169 TM_COLUMN_TRACKLEN, /* 10 */ 170 TM_COLUMN_BITRATE, 171 TM_COLUMN_PLAYCOUNT, 172 TM_COLUMN_RATING, 173 TM_COLUMN_TIME_PLAYED, 174 TM_COLUMN_TIME_MODIFIED, /* 15 */ 175 TM_COLUMN_VOLUME, 176 TM_COLUMN_YEAR, 177 TM_COLUMN_CD_NR, 178 TM_COLUMN_TIME_ADDED, 179 TM_COLUMN_IPOD_PATH, /* 20 */ 180 TM_COLUMN_SOUNDCHECK, 181 TM_COLUMN_SAMPLERATE, 182 TM_COLUMN_BPM, 183 TM_COLUMN_FILETYPE, 184 TM_COLUMN_GROUPING, /* 25 */ 185 TM_COLUMN_COMPILATION, 186 TM_COLUMN_COMMENT, 187 TM_COLUMN_CATEGORY, 188 TM_COLUMN_DESCRIPTION, 189 TM_COLUMN_PODCASTURL, /* 30 */ 190 TM_COLUMN_PODCASTRSS, 191 TM_COLUMN_SUBTITLE, 192 TM_COLUMN_TIME_RELEASED, 193 TM_COLUMN_THUMB_PATH, 194 TM_COLUMN_MEDIA_TYPE, /* 35 */ 195 TM_COLUMN_TV_SHOW, 196 TM_COLUMN_TV_EPISODE, 197 TM_COLUMN_TV_NETWORK, 198 TM_COLUMN_SEASON_NR, 199 TM_COLUMN_EPISODE_NR, /* 40 */ 200 TM_COLUMN_ALBUMARTIST, 201 TM_COLUMN_SORT_ARTIST, 202 TM_COLUMN_SORT_TITLE, 203 TM_COLUMN_SORT_ALBUM, 204 TM_COLUMN_SORT_ALBUMARTIST, /* 45 */ 205 TM_COLUMN_SORT_COMPOSER, 206 TM_COLUMN_SORT_TVSHOW, 207 TM_COLUMN_LYRICS, 208 TM_NUM_COLUMNS 209 } TM_item; 210 211 /* A means to address the fields by uniform IDs. May be extended as 212 * needed. You should extend "track_get_item_pointer()" defined in 213 * track.c as well for string fields. */ 214 /* Add corresponding entries to t_strings[] and t_tooltips[] in 215 misc_conversion.c! */ 216 /* Used in prefs_window.c to label the sort_ign_field<num> buttons */ 217 /* Used in details.c to label the detail_label_<num> labels */ 218 typedef enum { 219 T_ALL = 0, /* all fields */ 220 T_ALBUM, 221 T_ARTIST, 222 T_TITLE, 223 T_GENRE, 224 T_COMMENT, /* 5 */ 225 T_COMPOSER, 226 T_FILETYPE, 227 T_PC_PATH, 228 T_IPOD_PATH, 229 T_IPOD_ID, /* 10 */ 230 T_TRACK_NR, 231 T_TRANSFERRED, 232 T_SIZE, 233 T_TRACKLEN, 234 T_BITRATE, /* 15 */ 235 T_SAMPLERATE, 236 T_BPM, 237 T_PLAYCOUNT, 238 T_RATING, 239 T_TIME_ADDED, /* 20 */ 240 T_TIME_PLAYED, 241 T_TIME_MODIFIED, 242 T_VOLUME, 243 T_SOUNDCHECK, 244 T_YEAR, /* 25 */ 245 T_CD_NR, 246 T_GROUPING, 247 T_COMPILATION, 248 T_CATEGORY, 249 T_DESCRIPTION, /* 30 */ 250 T_PODCASTURL, 251 T_PODCASTRSS, 252 T_SUBTITLE, 253 T_TIME_RELEASED, 254 T_CHECKED, /* 35 */ 255 T_STARTTIME, 256 T_STOPTIME, 257 T_REMEMBER_PLAYBACK_POSITION, 258 T_SKIP_WHEN_SHUFFLING, 259 T_THUMB_PATH, /* 40 */ 260 T_MEDIA_TYPE, 261 T_TV_SHOW, 262 T_TV_EPISODE, 263 T_TV_NETWORK, 264 T_SEASON_NR, /* 45 */ 265 T_EPISODE_NR, 266 T_ALBUMARTIST, 267 T_SORT_ARTIST, 268 T_SORT_TITLE, 269 T_SORT_ALBUM, /* 50 */ 270 T_SORT_ALBUMARTIST, 271 T_SORT_COMPOSER, 272 T_SORT_TVSHOW, 273 T_GAPLESS_TRACK_FLAG, 274 T_LYRICS, 275 T_ITEM_NUM, 276 } T_item; 277 278 279 /* number of entries with "autoset empty tag to filename " feature */ 280 #define TM_NUM_TAGS_PREFS (5) 281 282 /* "Column numbers" in playlist model */ 283 typedef enum { 284 PM_COLUMN_ITDB = 0, 285 PM_COLUMN_TYPE, 286 PM_COLUMN_PLAYLIST, 287 PM_COLUMN_PHOTOS, 288 PM_NUM_COLUMNS 289 } PM_column_type; 290 291 /* Drag and drop types */ 292 enum { 293 DND_GTKPOD_TRACKLIST = 1000, 294 DND_GTKPOD_TM_PATHLIST, 295 DND_GTKPOD_PLAYLISTLIST, 296 DND_TEXT_URI_LIST, 297 DND_TEXT_PLAIN, 298 DND_IMAGE_JPEG 299 }; 300 301 /* used for the ST_CAT_SPECIAL user_data (see st_create_special and 302 * the corresponding signal functions) */ 303 #define SP_SHIFT 9 304 #define SP_MASK ((1<<SP_SHIFT)-1) 305 306 void display_create (void); 307 void display_cleanup (void); 308 void display_adjust_menus (void); 309 void display_show_hide_toolbar (void); 310 void display_show_hide_searchbar (void); 311 void display_reset (gint inst); 312 GList *display_get_selection (guint32 inst); 313 GList *display_get_selected_members (gint inst); 314 void display_remove_autoscroll_row_timeout (GtkWidget *widget); 315 void display_install_autoscroll_row_timeout (GtkWidget *widget); 316 void display_image_dialog (GdkPixbuf *image); 317 318 Playlist* pm_get_selected_playlist (void); 319 iTunesDB* pm_get_selected_itdb (void); 320 gint pm_get_position_for_itdb (iTunesDB *itdb); 321 void pm_remove_playlist (Playlist *playlist, gboolean select); 322 void pm_add_child (iTunesDB *itdb, PM_column_type type, gpointer item, gint position); 323 void pm_add_itdb (iTunesDB *itdb, gint pos); 324 void pm_select_playlist (Playlist *playlist); 325 void pm_unselect_playlist (Playlist *playlist); 326 void pm_remove_track (Playlist *playlist, Track *track); 327 void pm_add_track (Playlist *playlist, Track *track, gboolean display); 328 void pm_itdb_name_changed (iTunesDB *itdb); 329 void pm_track_changed (Track *track); 330 void pm_sort (GtkSortType order); 331 void pm_stop_editing (gboolean cancel); 332 void pm_set_playlist_renderer_pix (GtkCellRenderer *renderer, 333 Playlist *playlist); 334 void pm_set_playlist_renderer_text (GtkCellRenderer *renderer, 335 Playlist *playlist); 336 void pm_show_all_playlists (); 337 338 void st_stop_editing (gint inst, gboolean cancel); 339 gboolean st_set_selection (Itdb_Track *track); 340 void st_redisplay (guint32 inst); 341 void st_sort (GtkSortType order); 342 void st_remove_entry (TabEntry *entry, guint32 inst); 343 gint st_get_instance_from_treeview (GtkTreeView *tv); 344 void st_show_visible (void); 345 void st_arrange_visible_sort_tabs (void); 346 void st_adopt_order_in_playlist (void); 347 TabEntry *st_get_selected_entry (gint inst); 348 void st_update_paned_position (); 349 void st_rebuild_sortkeys (); 350 351 352 void cal_open_calendar (gint inst, T_item item); 353 void sp_go (guint32 inst); 354 void sp_conditions_changed (guint32 inst); 355 356 void tm_add_track_to_track_model (Track *track, GtkTreeIter *into_iter); 357 gint tm_get_nr_of_tracks(void); 358 void tm_rows_reordered(void); 359 gboolean tm_add_filelist (gchar *data, GtkTreePath *path, 360 GtkTreeViewDropPosition pos); 361 void tm_stop_editing (gboolean cancel); 362 void tm_show_preferred_columns(void); 363 void tm_store_col_order (void); 364 void tm_adopt_order_in_sorttab (void); 365 366 void tm_sort (TM_item col, GtkSortType order); 367 gint tm_sort_counter (gint inc); 368 GList* tm_get_selected_trackids(void); 369 GList* tm_get_selected_tracks(void); 370 GList* tm_get_all_trackids(void); 371 GList* tm_get_all_tracks(void); 372 373 void display_update_default_sizes (void); 374 void display_set_default_sizes (void); 375 void display_show_hide_tooltips (void); 376 void display_set_info_window_menu (void); 377 378 void spl_edit (Playlist *spl); 379 void spl_edit_new (iTunesDB *itdb, gchar *name, gint32 pos); 380 #endif 381