Simplify finding artist name which is displayed in the tree window
[cmus.git] / lib.h
blob13f82cc674783000f2563b65163bda12ef5d9499
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;
51 char *raw_name;
52 char *name;
54 /* albums visible for this artist in the tree_win? */
55 unsigned int expanded : 1;
58 enum aaa_mode {
59 AAA_MODE_ALL,
60 AAA_MODE_ARTIST,
61 AAA_MODE_ALBUM
64 extern struct editable lib_editable;
65 extern struct tree_track *lib_cur_track;
66 extern enum aaa_mode aaa_mode;
67 extern unsigned int play_sorted;
69 extern struct searchable *tree_searchable;
70 extern struct window *lib_tree_win;
71 extern struct window *lib_track_win;
72 extern struct window *lib_cur_win;
73 extern struct list_head lib_artist_head;
75 #define CUR_ALBUM (lib_cur_track->album)
76 #define CUR_ARTIST (lib_cur_track->album->artist)
78 void lib_init(void);
79 void tree_init(void);
80 struct track_info *lib_set_next(void);
81 struct track_info *lib_set_prev(void);
82 void lib_add_track(struct track_info *track_info);
83 void lib_set_filter(struct expr *expr);
84 int lib_remove(struct track_info *ti);
85 void lib_clear_store(void);
86 void lib_reshuffle(void);
87 void lib_set_view(int view);
88 int lib_for_each(int (*cb)(void *data, struct track_info *ti), void *data);
90 struct track_info *tree_set_selected(void);
91 void tree_add_track(struct tree_track *track);
92 void tree_remove(struct tree_track *track);
93 void tree_remove_sel(void);
94 void tree_toggle_active_window(void);
95 void tree_toggle_expand_artist(void);
96 void tree_sel_current(void);
97 int tree_for_each_sel(int (*cb)(void *data, struct track_info *ti), void *data, int reverse);
98 int __tree_for_each_sel(int (*cb)(void *data, struct track_info *ti), void *data, int reverse);
100 struct track_info *sorted_set_selected(void);
101 void sorted_sel_current(void);
103 static inline struct tree_track *iter_to_sorted_track(const struct iter *iter)
105 return iter->data1;
108 static inline struct artist *iter_to_artist(const struct iter *iter)
110 return iter->data1;
113 static inline struct album *iter_to_album(const struct iter *iter)
115 return iter->data2;
118 static inline struct tree_track *iter_to_tree_track(const struct iter *iter)
120 return iter->data1;
123 static inline struct artist *to_artist(const struct list_head *item)
125 return container_of(item, struct artist, node);
128 static inline struct album *to_album(const struct list_head *item)
130 return container_of(item, struct album, node);
133 #endif