Document Replay Gain
[cmus.git] / lib.h
blob4146f5dfe3b9672fa7a757bc427e54fb0b504325
1 /*
2 * Copyright 2004-2006 Timo Hirvonen
3 */
5 #ifndef LIB_H
6 #define LIB_H
8 #include "editable.h"
9 #include "search.h"
10 #include "track_info.h"
11 #include "expr.h"
13 #include <sys/time.h>
15 struct tree_track {
16 struct shuffle_track shuffle_track;
17 struct list_head node;
18 struct album *album;
21 static inline struct track_info *tree_track_info(const struct tree_track *track)
23 return ((struct simple_track *)track)->info;
26 static inline struct tree_track *to_tree_track(const struct list_head *item)
28 return container_of(item, struct tree_track, node);
31 struct album {
32 /* next/prev album */
33 struct list_head node;
35 /* list of tracks */
36 struct list_head track_head;
38 struct artist *artist;
39 char *name;
40 /* date of the first track added to this album */
41 int date;
44 struct artist {
45 /* next/prev artist */
46 struct list_head node;
48 /* list of albums */
49 struct list_head album_head;
50 char *name;
52 /* albums visible for this artist in the tree_win? */
53 unsigned int expanded : 1;
56 enum aaa_mode {
57 AAA_MODE_ALL,
58 AAA_MODE_ARTIST,
59 AAA_MODE_ALBUM
62 extern struct editable lib_editable;
63 extern struct tree_track *lib_cur_track;
64 extern enum aaa_mode aaa_mode;
65 extern unsigned int play_sorted;
67 extern struct searchable *tree_searchable;
68 extern struct window *lib_tree_win;
69 extern struct window *lib_track_win;
70 extern struct window *lib_cur_win;
71 extern struct list_head lib_artist_head;
73 #define CUR_ALBUM (lib_cur_track->album)
74 #define CUR_ARTIST (lib_cur_track->album->artist)
76 void lib_init(void);
77 void tree_init(void);
78 struct track_info *lib_set_next(void);
79 struct track_info *lib_set_prev(void);
80 void lib_add_track(struct track_info *track_info);
81 void lib_set_filter(struct expr *expr);
82 void lib_remove(struct track_info *ti);
83 void lib_clear_store(void);
84 void lib_reshuffle(void);
85 void lib_set_view(int view);
86 int lib_for_each(int (*cb)(void *data, struct track_info *ti), void *data);
88 struct track_info *tree_set_selected(void);
89 void tree_add_track(struct tree_track *track);
90 void tree_remove(struct tree_track *track);
91 void tree_remove_sel(void);
92 void tree_toggle_active_window(void);
93 void tree_toggle_expand_artist(void);
94 void tree_sel_current(void);
95 int tree_for_each_sel(int (*cb)(void *data, struct track_info *ti), void *data, int reverse);
96 int __tree_for_each_sel(int (*cb)(void *data, struct track_info *ti), void *data, int reverse);
98 struct track_info *sorted_set_selected(void);
99 void sorted_sel_current(void);
101 static inline struct tree_track *iter_to_sorted_track(const struct iter *iter)
103 return iter->data1;
106 static inline struct artist *iter_to_artist(const struct iter *iter)
108 return iter->data1;
111 static inline struct album *iter_to_album(const struct iter *iter)
113 return iter->data2;
116 static inline struct tree_track *iter_to_tree_track(const struct iter *iter)
118 return iter->data1;
121 static inline struct artist *to_artist(const struct list_head *item)
123 return container_of(item, struct artist, node);
126 static inline struct album *to_album(const struct list_head *item)
128 return container_of(item, struct album, node);
131 #endif