1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
/*
* Copyright 2008-2013 Various Authors
* Copyright 2004-2006 Timo Hirvonen
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CMUS_LIB_H
#define CMUS_LIB_H
#include "editable.h"
#include "search.h"
#include "track_info.h"
#include "expr.h"
#include "rbtree.h"
struct tree_track {
struct simple_track simple_track;
/* position in track search tree */
struct rb_node tree_node;
struct album *album;
};
static inline struct track_info *tree_track_info(const struct tree_track *track)
{
return ((struct simple_track *)track)->info;
}
static inline struct tree_track *to_tree_track(const struct rb_node *node)
{
return container_of(node, struct tree_track, tree_node);
}
struct album {
struct shuffle_info shuffle_info;
/* position in album search tree */
struct rb_node tree_node;
/* root of track tree */
struct rb_root track_root;
struct artist *artist;
char *name;
char *sort_name;
char *collkey_name;
char *collkey_sort_name;
/* max date of the tracks added to this album */
int date;
/* min date of the tracks added to this album */
int min_date;
};
struct artist {
/* position in artist search tree */
struct rb_node tree_node;
/* root of album tree */
struct rb_root album_root;
char *name;
char *sort_name;
char *auto_sort_name;
char *collkey_name;
char *collkey_sort_name;
char *collkey_auto_sort_name;
/* albums visible for this artist in the tree_win? */
unsigned int expanded : 1;
unsigned int is_compilation : 1;
};
const char *artist_sort_name(const struct artist *);
enum aaa_mode {
AAA_MODE_ALL,
AAA_MODE_ARTIST,
AAA_MODE_ALBUM
};
extern struct editable lib_editable;
extern struct tree_track *lib_cur_track;
extern struct rb_root lib_shuffle_root;
extern struct rb_root lib_album_shuffle_root;
extern enum aaa_mode aaa_mode;
extern unsigned int play_sorted;
extern char *lib_live_filter;
extern struct searchable *tree_searchable;
extern struct window *lib_tree_win;
extern struct window *lib_track_win;
extern struct window *lib_cur_win;
extern struct rb_root lib_artist_root;
#define CUR_ALBUM (lib_cur_track->album)
#define CUR_ARTIST (lib_cur_track->album->artist)
void lib_init(void);
void tree_init(void);
struct track_info *lib_goto_next(void);
struct track_info *lib_goto_prev(void);
struct track_info *lib_goto_next_album(void);
struct track_info *lib_goto_prev_album(void);
void lib_add_track(struct track_info *track_info, void *opaque);
void lib_set_filter(struct expr *expr);
void lib_set_live_filter(const char *str);
void lib_set_add_filter(struct expr *expr);
int lib_remove(struct track_info *ti);
void lib_clear_store(void);
void lib_reshuffle(void);
void lib_sort_artists(void);
void lib_set_view(int view);
int lib_for_each(int (*cb)(void *data, struct track_info *ti), void *data,
void *opaque);
int lib_for_each_filtered(int (*cb)(void *data, struct track_info *ti),
void *data, void *opaque);
struct tree_track *lib_find_track(struct track_info *ti);
struct track_info *lib_set_track(struct tree_track *track);
void lib_store_cur_track(struct track_info *ti);
struct track_info *lib_get_cur_stored_track(void);
struct tree_track *tree_get_selected(void);
struct track_info *tree_activate_selected(void);
const char *tree_artist_name(const struct track_info* ti);
const char *tree_album_name(const struct track_info* ti);
void tree_sort_artists(void (*add_album_cb)(struct album *), void (*remove_album_cb)(struct album *));
void tree_add_track(struct tree_track *track, void (*add_album_cb)(struct album *));
void tree_remove(struct tree_track *track, void (*remove_album_cb)(struct album *));
void tree_remove_sel(void);
void tree_toggle_active_window(void);
void tree_toggle_expand_artist(void);
void tree_expand_matching(const char *text);
void tree_expand_all(void);
void tree_sel_update(int changed);
void tree_sel_current(int auto_expand_albums);
void tree_sel_first(void);
void tree_sel_track(struct tree_track *t, int auto_expand_albums);
int tree_for_each_sel(int (*cb)(void *data, struct track_info *ti), void *data, int reverse, int advance);
int _tree_for_each_sel(int (*cb)(void *data, struct track_info *ti), void *data, int reverse);
struct track_info *sorted_activate_selected(void);
void sorted_sel_current(void);
static inline struct tree_track *iter_to_sorted_track(const struct iter *iter)
{
return iter->data1;
}
static inline struct artist *iter_to_artist(const struct iter *iter)
{
return iter->data1;
}
static inline struct album *iter_to_album(const struct iter *iter)
{
return iter->data2;
}
static inline struct tree_track *iter_to_tree_track(const struct iter *iter)
{
return iter->data1;
}
static inline struct artist *to_artist(const struct rb_node *node)
{
return container_of(node, struct artist, tree_node);
}
static inline struct album *to_album(const struct rb_node *node)
{
return container_of(node, struct album, tree_node);
}
#endif
|