1 /* -*- linux-c -*- 2 Copyright (C) 2004 Tom Szilagyi 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 18 $Id: playlist.h 1293 2014-05-04 22:06:57Z tszilagyi $ 19 */ 20 21 #ifndef AQUALUNG_PLAYLIST_H 22 #define AQUALUNG_PLAYLIST_H 23 24 #include <config.h> 25 26 #include <glib.h> 27 #include <gdk/gdk.h> 28 #include <gtk/gtk.h> 29 30 #include "athread.h" 31 #include "common.h" 32 33 34 enum { 35 PLAYLIST_LOAD, 36 PLAYLIST_LOAD_TAB, 37 PLAYLIST_ENQUEUE 38 }; 39 40 typedef struct { 41 42 AQUALUNG_THREAD_DECLARE(thread_id) 43 AQUALUNG_MUTEX_DECLARE(thread_mutex) 44 AQUALUNG_MUTEX_DECLARE(wait_mutex) 45 AQUALUNG_COND_DECLARE(thread_wait) 46 47 volatile int thread_stop; 48 49 int progbar_semaphore; 50 int ms_semaphore; 51 52 int index; 53 54 char name[MAXLEN]; 55 int name_set; 56 int playing; 57 int closed; 58 59 GtkTreeStore * store; 60 GtkTreeSelection * select; 61 GtkWidget * view; 62 GtkWidget * scroll; 63 GtkWidget * label; 64 GtkWidget * tab_close_button; 65 GtkWidget * tab_menu; 66 GtkWidget * tab__close_undo; 67 68 GtkTreeViewColumn * track_column; 69 GtkTreeViewColumn * rva_column; 70 GtkTreeViewColumn * length_column; 71 72 GtkWidget * progbar; 73 GtkWidget * progbar_container; 74 GtkWidget * progbar_stop_button; 75 76 GtkWidget * widget; 77 78 } playlist_t; 79 80 typedef struct { 81 82 playlist_t * pl; 83 84 volatile int data_written; 85 int threshold; 86 87 GSList * list; 88 GList * pldata_list; 89 90 void * xml_doc; 91 void * xml_node; 92 int * xml_ref; 93 94 char * filename; 95 96 int clear; 97 int start_playback; 98 99 } playlist_transfer_t; 100 101 playlist_t * playlist_tab_new(char * name); 102 playlist_t * playlist_tab_new_if_nonempty(char * name); 103 104 playlist_t * playlist_get_current(void); 105 void playlist_set_current(playlist_t * pl); 106 playlist_t * playlist_get_playing(void); 107 108 GtkTreePath * playlist_get_playing_path(playlist_t * pl); 109 110 void playlist_reorder_columns_all(int * order); 111 void playlist_show_hide_close_buttons(gboolean state); 112 113 void create_playlist(void); 114 void show_playlist(void); 115 void hide_playlist(void); 116 117 void playlist_set_playing(playlist_t * pl, int playing); 118 119 void playlist_stats_set_busy(void); 120 void playlist_progress_bar_show(playlist_t * pl); 121 void playlist_progress_bar_hide_all(void); 122 void show_hide_close_buttons(gboolean state); 123 124 void playlist_ensure_tab_exists(void); 125 void playlist_load(GSList * list, int mode, char * tab_name, int start_playback); 126 void playlist_save(playlist_t * pl, char * filename); 127 void playlist_save_m3u(playlist_t * pl, char * filename); 128 void playlist_save_all(char * filename); 129 void playlist_auto_save_reset(void); 130 131 void playlist_set_color(void); 132 void playlist_reset_display_names(void); 133 void playlist_update_metadata(void); 134 void playlist_disable_bold_font(void); 135 void playlist_set_font(int cond); 136 137 void playlist_content_changed(playlist_t * pl); 138 void playlist_selection_changed(playlist_t * pl); 139 void playlist_drag_end(GtkWidget * widget, GdkDragContext * drag_context, gpointer data); 140 141 void playlist_menu_set_popup_sensitivity(playlist_t * pl); 142 gint playlist_window_key_pressed(GtkWidget * widget, GdkEventKey * kevent); 143 void playlist_foreach_selected(playlist_t * pl, 144 int (* foreach)(playlist_t *, GtkTreeIter *, void *), 145 void * data); 146 147 void recalc_album_node(playlist_t * pl, GtkTreeIter * iter); 148 void mark_track(playlist_t * pl, GtkTreeIter * piter); 149 void unmark_track(playlist_t * pl, GtkTreeIter * piter); 150 151 void show_active_position_in_playlist(playlist_t * pl); 152 153 #ifdef HAVE_CDDA 154 void playlist_add_cdda(GtkTreeIter * iter_drive, unsigned long hash); 155 void playlist_remove_cdda(char * device_path); 156 #endif /* HAVE_CDDA */ 157 158 gint playlist_window_button_pressed(GtkWidget * widget, GdkEventButton * event, gpointer data); 159 gboolean playlist_model_func(GtkTreeModel * model, GtkTreeIter iter, char**name, char**file); 160 161 enum { 162 PL_FLAG_ACTIVE = (1 << 0), 163 PL_FLAG_COVER = (1 << 1), 164 PL_FLAG_ALBUM_NODE = (1 << 2), 165 PL_FLAG_ALBUM_CHILD = (1 << 3) 166 }; 167 168 typedef struct { 169 170 char * artist; 171 char * album; 172 char * title; /* NULL for album nodes */ 173 char * file; /* NULL for album nodes */ 174 char * display; /* Already formatted title ready for display */ 175 float voladj; /* volume adjustment [dB] */ 176 float duration; /* length in seconds */ 177 unsigned size; /* file size in bytes */ 178 179 unsigned short ntracks; /* number of children nodes (for album nodes only) */ 180 unsigned short actrack; /* active children node (for album nodes only) */ 181 int flags; 182 183 } playlist_data_t; 184 185 playlist_data_t * playlist_data_new(void); 186 void playlist_data_get_display_name(char * list_str, playlist_data_t * pldata); 187 188 #define PL_IS_SET_FLAG(plist, flag) (plist->flags & flag) 189 #define PL_SET_FLAG(plist, flag) (plist->flags |= flag) 190 #define PL_UNSET_FLAG(plist, flag) (plist->flags &= ~flag) 191 192 #define IS_PL_ACTIVE(plist) PL_IS_SET_FLAG(plist, PL_FLAG_ACTIVE) 193 #define IS_PL_COVER(plist) PL_IS_SET_FLAG(plist, PL_FLAG_COVER) 194 #define IS_PL_ALBUM_NODE(plist) PL_IS_SET_FLAG(plist, PL_FLAG_ALBUM_NODE) 195 #define IS_PL_ALBUM_CHILD(plist) PL_IS_SET_FLAG(plist, PL_FLAG_ALBUM_CHILD) 196 #define IS_PL_TOPLEVEL(plist) (IS_PL_ALBUM_NODE(plist) || !IS_PL_ALBUM_CHILD(plist)) 197 198 199 enum { 200 PL_COL_NAME = 0, 201 PL_COL_VADJ, 202 PL_COL_DURA, 203 PL_COL_COLO, 204 PL_COL_FONT, 205 PL_COL_DATA, 206 207 PL_COL_COUNT 208 }; 209 210 211 #endif /* AQUALUNG_PLAYLIST_H */ 212 213 // vim: shiftwidth=8:tabstop=8:softtabstop=8 : 214