| 1 |
/* |
| 2 |
* Copyright 2008-2011 Various Authors |
| 3 |
* Copyright 2005 Timo Hirvonen |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License as |
| 7 |
* published by the Free Software Foundation; either version 2 of the |
| 8 |
* License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef OPTIONS_H |
| 20 |
#define OPTIONS_H |
| 21 |
|
| 22 |
#include "list.h" |
| 23 |
|
| 24 |
#define OPTION_MAX_SIZE 256 |
| 25 |
|
| 26 |
typedef void (*opt_get_cb)(unsigned int id, char *buf); |
| 27 |
typedef void (*opt_set_cb)(unsigned int id, const char *buf); |
| 28 |
typedef void (*opt_toggle_cb)(unsigned int id); |
| 29 |
|
| 30 |
enum { |
| 31 |
OPT_PROGRAM_PATH = 1 << 0, |
| 32 |
}; |
| 33 |
|
| 34 |
struct cmus_opt { |
| 35 |
struct list_head node; |
| 36 |
|
| 37 |
const char *name; |
| 38 |
|
| 39 |
/* If there are many similar options you should write generic get(), |
| 40 |
* set() and optionally toggle() and set id to index of option array or |
| 41 |
* what ever. |
| 42 |
* |
| 43 |
* Useful for colors, format strings and plugin options. |
| 44 |
*/ |
| 45 |
unsigned int id; |
| 46 |
|
| 47 |
opt_get_cb get; |
| 48 |
opt_set_cb set; |
| 49 |
|
| 50 |
/* NULL if not toggle-able */ |
| 51 |
opt_toggle_cb toggle; |
| 52 |
|
| 53 |
unsigned int flags; |
| 54 |
}; |
| 55 |
|
| 56 |
extern struct list_head option_head; |
| 57 |
extern int nr_options; |
| 58 |
|
| 59 |
enum { |
| 60 |
TREE_VIEW, |
| 61 |
SORTED_VIEW, |
| 62 |
PLAYLIST_VIEW, |
| 63 |
QUEUE_VIEW, |
| 64 |
BROWSER_VIEW, |
| 65 |
FILTERS_VIEW, |
| 66 |
HELP_VIEW, |
| 67 |
NR_VIEWS |
| 68 |
}; |
| 69 |
|
| 70 |
enum { |
| 71 |
COLOR_CMDLINE_BG, |
| 72 |
COLOR_CMDLINE_FG, |
| 73 |
COLOR_ERROR, |
| 74 |
COLOR_INFO, |
| 75 |
|
| 76 |
COLOR_SEPARATOR, |
| 77 |
COLOR_STATUSLINE_BG, |
| 78 |
COLOR_STATUSLINE_FG, |
| 79 |
COLOR_TITLELINE_BG, |
| 80 |
|
| 81 |
COLOR_TITLELINE_FG, |
| 82 |
COLOR_WIN_BG, |
| 83 |
COLOR_WIN_CUR, |
| 84 |
COLOR_WIN_CUR_SEL_BG, |
| 85 |
|
| 86 |
COLOR_WIN_CUR_SEL_FG, |
| 87 |
COLOR_WIN_DIR, |
| 88 |
COLOR_WIN_FG, |
| 89 |
COLOR_WIN_INACTIVE_CUR_SEL_BG, |
| 90 |
|
| 91 |
COLOR_WIN_INACTIVE_CUR_SEL_FG, |
| 92 |
COLOR_WIN_INACTIVE_SEL_BG, |
| 93 |
COLOR_WIN_INACTIVE_SEL_FG, |
| 94 |
COLOR_WIN_SEL_BG, |
| 95 |
|
| 96 |
COLOR_WIN_SEL_FG, |
| 97 |
COLOR_WIN_TITLE_BG, |
| 98 |
COLOR_WIN_TITLE_FG, |
| 99 |
NR_COLORS |
| 100 |
}; |
| 101 |
|
| 102 |
#define BRIGHT (1 << 3) |
| 103 |
|
| 104 |
extern char *cdda_device; |
| 105 |
extern char *output_plugin; |
| 106 |
extern char *status_display_program; |
| 107 |
extern char *server_password; |
| 108 |
extern int auto_reshuffle; |
| 109 |
extern int confirm_run; |
| 110 |
extern int resume_cmus; |
| 111 |
extern int show_hidden; |
| 112 |
extern int show_current_bitrate; |
| 113 |
extern int show_remaining_time; |
| 114 |
extern int set_term_title; |
| 115 |
extern int wrap_search; |
| 116 |
extern int play_library; |
| 117 |
extern int repeat; |
| 118 |
extern int shuffle; |
| 119 |
extern int display_artist_sort_name; |
| 120 |
extern int smart_artist_sort; |
| 121 |
|
| 122 |
extern const char * const aaa_mode_names[]; |
| 123 |
extern const char * const view_names[NR_VIEWS + 1]; |
| 124 |
|
| 125 |
extern int colors[NR_COLORS]; |
| 126 |
|
| 127 |
/* format string for track window (tree view) */ |
| 128 |
extern char *track_win_format; |
| 129 |
extern char *track_win_format_va; |
| 130 |
extern char *track_win_alt_format; |
| 131 |
|
| 132 |
/* format string for shuffle, sorted and play queue views */ |
| 133 |
extern char *list_win_format; |
| 134 |
extern char *list_win_format_va; |
| 135 |
extern char *list_win_alt_format; |
| 136 |
|
| 137 |
/* format string for currently playing track */ |
| 138 |
extern char *current_format; |
| 139 |
extern char *current_alt_format; |
| 140 |
|
| 141 |
/* format string for window title */ |
| 142 |
extern char *window_title_format; |
| 143 |
extern char *window_title_alt_format; |
| 144 |
|
| 145 |
extern char *id3_default_charset; |
| 146 |
|
| 147 |
/* build option list */ |
| 148 |
void options_add(void); |
| 149 |
|
| 150 |
/* load options from the config file */ |
| 151 |
void options_load(void); |
| 152 |
|
| 153 |
int source_file(const char *filename); |
| 154 |
|
| 155 |
/* save options */ |
| 156 |
void options_exit(void); |
| 157 |
|
| 158 |
/* load resume file */ |
| 159 |
void resume_load(void); |
| 160 |
/* save resume file */ |
| 161 |
void resume_exit(void); |
| 162 |
|
| 163 |
void option_add(const char *name, unsigned int id, opt_get_cb get, |
| 164 |
opt_set_cb set, opt_toggle_cb toggle, unsigned int flags); |
| 165 |
struct cmus_opt *option_find(const char *name); |
| 166 |
void option_set(const char *name, const char *value); |
| 167 |
int parse_enum(const char *buf, int minval, int maxval, const char * const names[], int *val); |
| 168 |
|
| 169 |
#endif |