-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.c
1765 lines (1497 loc) · 37.9 KB
/
options.c
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2008-2013 Various Authors
* Copyright 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/>.
*/
#include "options.h"
#include "list.h"
#include "utils.h"
#include "xmalloc.h"
#include "player.h"
#include "buffer.h"
#include "ui_curses.h"
#include "cmus.h"
#include "misc.h"
#include "lib.h"
#include "pl.h"
#include "browser.h"
#include "keys.h"
#include "filters.h"
#include "command_mode.h"
#include "file.h"
#include "prog.h"
#include "output.h"
#include "input.h"
#include "xstrjoin.h"
#include "track_info.h"
#include "cache.h"
#include "debug.h"
#include "discid.h"
#include "mpris.h"
#include <stdio.h>
#include <errno.h>
#include <strings.h>
#if defined(__sun__)
#include <ncurses.h>
#else
#include <curses.h>
#endif
/* initialized option variables */
char *cdda_device = NULL;
char *output_plugin = NULL;
char *status_display_program = NULL;
char *server_password;
int auto_reshuffle = 1;
int confirm_run = 1;
int resume_cmus = 0;
int show_hidden = 0;
int show_current_bitrate = 0;
int show_playback_position = 1;
int show_remaining_time = 0;
int set_term_title = 1;
int wrap_search = 1;
int play_library = 1;
int repeat = 0;
int shuffle = 0;
int follow = 0;
int display_artist_sort_name;
int smart_artist_sort = 1;
int scroll_offset = 2;
int rewind_offset = 5;
int skip_track_info = 0;
int auto_expand_albums_follow = 1;
int auto_expand_albums_search = 1;
int auto_expand_albums_selcur = 1;
int show_all_tracks = 1;
int mouse = 0;
int mpris = 1;
int time_show_leading_zero = 1;
int start_view = TREE_VIEW;
int colors[NR_COLORS] = {
-1,
-1,
COLOR_RED | BRIGHT,
COLOR_YELLOW | BRIGHT,
COLOR_BLUE,
COLOR_WHITE,
COLOR_BLACK,
COLOR_BLUE,
COLOR_WHITE | BRIGHT,
-1,
COLOR_YELLOW | BRIGHT,
COLOR_BLUE,
COLOR_YELLOW | BRIGHT,
COLOR_BLUE | BRIGHT,
-1,
COLOR_WHITE,
COLOR_YELLOW | BRIGHT,
COLOR_WHITE,
COLOR_BLACK,
COLOR_BLUE,
COLOR_WHITE | BRIGHT,
COLOR_BLUE,
COLOR_WHITE | BRIGHT,
-1,
-1,
};
int attrs[NR_ATTRS] = {
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_NORMAL,
A_BOLD,
A_NORMAL,
};
/* uninitialized option variables */
char *tree_win_format = NULL;
char *tree_win_artist_format = NULL;
char *track_win_album_format = NULL;
char *track_win_format = NULL;
char *track_win_format_va = NULL;
char *track_win_alt_format = NULL;
char *list_win_format = NULL;
char *list_win_format_va = NULL;
char *list_win_alt_format = NULL;
char *current_format = NULL;
char *current_alt_format = NULL;
char *statusline_format = NULL;
char *window_title_format = NULL;
char *window_title_alt_format = NULL;
char *id3_default_charset = NULL;
char *icecast_default_charset = NULL;
char *lib_add_filter = NULL;
static void buf_int(char *buf, int val, size_t size)
{
snprintf(buf, size, "%d", val);
}
static int parse_int(const char *buf, int minval, int maxval, int *val)
{
long int tmp;
if (str_to_int(buf, &tmp) == -1 || tmp < minval || tmp > maxval) {
error_msg("integer in range %d..%d expected", minval, maxval);
return 0;
}
*val = tmp;
return 1;
}
int parse_enum(const char *buf, int minval, int maxval, const char * const names[], int *val)
{
long int tmp;
int i;
if (str_to_int(buf, &tmp) == 0) {
if (tmp < minval || tmp > maxval)
goto err;
*val = tmp;
return 1;
}
for (i = 0; names[i]; i++) {
if (strcasecmp(buf, names[i]) == 0) {
*val = i + minval;
return 1;
}
}
err:
error_msg("name or integer in range %d..%d expected", minval, maxval);
return 0;
}
static const char * const bool_names[] = {
"false", "true", NULL
};
static int parse_bool(const char *buf, int *val)
{
return parse_enum(buf, 0, 1, bool_names, val);
}
/* this is used as id in struct cmus_opt */
enum format_id {
FMT_CURRENT,
FMT_CURRENT_ALT,
FMT_STATUSLINE,
FMT_PLAYLIST,
FMT_PLAYLIST_ALT,
FMT_PLAYLIST_VA,
FMT_TITLE,
FMT_TITLE_ALT,
FMT_TRACKWIN,
FMT_TRACKWIN_ALBUM,
FMT_TRACKWIN_ALT,
FMT_TRACKWIN_VA,
FMT_TREEWIN,
FMT_TREEWIN_ARTIST,
NR_FMTS
};
/* default values for the variables which we must initialize but
* can't do it statically */
static const struct {
const char *name;
const char *value;
} str_defaults[] = {
[FMT_CURRENT_ALT] = { "altformat_current" , " %F " },
[FMT_CURRENT] = { "format_current" , " %a - %l -%3n. %t%= %y " },
[FMT_STATUSLINE] = { "format_statusline" ,
" %{status} %{?show_playback_position?%{position} %{?duration?/ %{duration} }?%{?duration?%{duration} }}"
"- %{total} %{?bpm>0?at %{bpm} BPM }"
"%{?volume>=0?vol: %{?lvolume!=rvolume?%{lvolume},%{rvolume} ?%{volume} }}"
"%{?stream?buf: %{buffer} }"
"%{?show_current_bitrate & bitrate>=0? %{bitrate} kbps }"
"%="
"%{?repeat_current?repeat current?%{?play_library?%{playlist_mode} from %{?play_sorted?sorted }library?playlist}}"
" | %1{continue}%1{follow}%1{repeat}%1{shuffle} "
},
[FMT_PLAYLIST_ALT] = { "altformat_playlist" , " %f%= %d " },
[FMT_PLAYLIST] = { "format_playlist" , " %-21%a %3n. %t%= %y %d %{?X!=0?%3X ? }" },
[FMT_PLAYLIST_VA] = { "format_playlist_va" , " %-21%A %3n. %t (%a)%= %y %d %{?X!=0?%3X ? }" },
[FMT_TITLE_ALT] = { "altformat_title" , "%f" },
[FMT_TITLE] = { "format_title" , "%a - %l - %t (%y)" },
[FMT_TRACKWIN_ALBUM] = { "format_trackwin_album" , " %l %= %{albumduration} " },
[FMT_TRACKWIN_ALT] = { "altformat_trackwin" , " %f%= %d " },
[FMT_TRACKWIN] = { "format_trackwin" , "%3n. %t%= %y %d " },
[FMT_TRACKWIN_VA] = { "format_trackwin_va" , "%3n. %t (%a)%= %y %d " },
[FMT_TREEWIN] = { "format_treewin" , " %l" },
[FMT_TREEWIN_ARTIST] = { "format_treewin_artist" , "%a" },
[NR_FMTS] =
{ "lib_sort", "albumartist date album discnumber tracknumber title filename play_count" },
{ "pl_sort", "" },
{ "id3_default_charset", "ISO-8859-1" },
{ "icecast_default_charset", "ISO-8859-1" },
{ NULL, NULL }
};
/* callbacks for normal options {{{ */
static void get_device(void *data, char *buf, size_t size)
{
strscpy(buf, cdda_device, size);
}
static void set_device(void *data, const char *buf)
{
free(cdda_device);
cdda_device = expand_filename(buf);
}
#define SECOND_SIZE (44100 * 16 / 8 * 2)
static void get_buffer_seconds(void *data, char *buf, size_t size)
{
int val = (player_get_buffer_chunks() * CHUNK_SIZE + SECOND_SIZE / 2) /
SECOND_SIZE;
buf_int(buf, val, size);
}
static void set_buffer_seconds(void *data, const char *buf)
{
int sec;
if (parse_int(buf, 1, 300, &sec))
player_set_buffer_chunks((sec * SECOND_SIZE + CHUNK_SIZE / 2) / CHUNK_SIZE);
}
static void get_scroll_offset(void *data, char *buf, size_t size)
{
buf_int(buf, scroll_offset, size);
}
static void set_scroll_offset(void *data, const char *buf)
{
int offset;
if (parse_int(buf, 0, 9999, &offset))
scroll_offset = offset;
}
static void get_rewind_offset(void *data, char *buf, size_t size)
{
buf_int(buf, rewind_offset, size);
}
static void set_rewind_offset(void *data, const char *buf)
{
int offset;
if (parse_int(buf, -1, 9999, &offset))
rewind_offset = offset;
}
static void get_id3_default_charset(void *data, char *buf, size_t size)
{
strscpy(buf, id3_default_charset, size);
}
static void get_icecast_default_charset(void *data, char *buf, size_t size)
{
strscpy(buf, icecast_default_charset, size);
}
static void set_id3_default_charset(void *data, const char *buf)
{
free(id3_default_charset);
id3_default_charset = xstrdup(buf);
}
static void set_icecast_default_charset(void *data, const char *buf)
{
free(icecast_default_charset);
icecast_default_charset = xstrdup(buf);
}
static void get_lib_sort(void *data, char *buf, size_t size)
{
strscpy(buf, lib_editable.shared->sort_str, size);
}
static void set_lib_sort(void *data, const char *buf)
{
sort_key_t *keys = parse_sort_keys(buf);
if (keys) {
editable_shared_set_sort_keys(lib_editable.shared, keys);
editable_sort(&lib_editable);
sort_keys_to_str(keys, lib_editable.shared->sort_str,
sizeof(lib_editable.shared->sort_str));
}
}
static void get_pl_sort(void *data, char *buf, size_t size)
{
pl_get_sort_str(buf, size);
}
static void set_pl_sort(void *data, const char *buf)
{
pl_set_sort_str(buf);
}
static void get_output_plugin(void *data, char *buf, size_t size)
{
const char *value = op_get_current();
if (value)
strscpy(buf, value, size);
}
static void set_output_plugin(void *data, const char *buf)
{
if (ui_initialized) {
if (!soft_vol)
mixer_close();
player_set_op(buf);
if (!soft_vol)
mixer_open();
} else {
/* must set it later manually */
output_plugin = xstrdup(buf);
}
}
static void get_passwd(void *data, char *buf, size_t size)
{
if (server_password)
strscpy(buf, server_password, size);
}
static void set_passwd(void *data, const char *buf)
{
int len = strlen(buf);
if (len == 0) {
free(server_password);
server_password = NULL;
} else if (len < 6) {
error_msg("unsafe password");
} else {
free(server_password);
server_password = xstrdup(buf);
}
}
static void get_replaygain_preamp(void *data, char *buf, size_t size)
{
snprintf(buf, size, "%f", replaygain_preamp);
}
static void set_replaygain_preamp(void *data, const char *buf)
{
double val;
char *end;
val = strtod(buf, &end);
if (end == buf) {
error_msg("floating point number expected (dB)");
return;
}
player_set_rg_preamp(val);
}
static void get_softvol_state(void *data, char *buf, size_t size)
{
snprintf(buf, size, "%d %d", soft_vol_l, soft_vol_r);
}
static void set_softvol_state(void *data, const char *buf)
{
char buffer[OPTION_MAX_SIZE];
char *ptr;
long int l, r;
strscpy(buffer, buf, sizeof(buffer));
ptr = strchr(buffer, ' ');
if (!ptr)
goto err;
while (*ptr == ' ')
*ptr++ = 0;
if (str_to_int(buffer, &l) == -1 || l < 0 || l > 100)
goto err;
if (str_to_int(ptr, &r) == -1 || r < 0 || r > 100)
goto err;
player_set_soft_volume(l, r);
return;
err:
error_msg("two integers in range 0..100 expected");
}
static void get_status_display_program(void *data, char *buf, size_t size)
{
if (status_display_program)
strscpy(buf, status_display_program, size);
}
static void set_status_display_program(void *data, const char *buf)
{
free(status_display_program);
status_display_program = NULL;
if (buf[0])
status_display_program = expand_filename(buf);
}
/* }}} */
/* callbacks for toggle options {{{ */
static void get_auto_reshuffle(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[auto_reshuffle], size);
}
static void set_auto_reshuffle(void *data, const char *buf)
{
parse_bool(buf, &auto_reshuffle);
}
static void toggle_auto_reshuffle(void *data)
{
auto_reshuffle ^= 1;
}
static void get_follow(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[follow], size);
}
static void set_follow(void *data, const char *buf)
{
if (!parse_bool(buf, &follow))
return;
update_statusline();
}
static void toggle_follow(void *data)
{
follow ^= 1;
update_statusline();
}
static void get_continue(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[player_cont], size);
}
static void set_continue(void *data, const char *buf)
{
if (!parse_bool(buf, &player_cont))
return;
update_statusline();
}
static void toggle_continue(void *data)
{
player_cont ^= 1;
update_statusline();
}
static void get_continue_album(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[player_cont_album], size);
}
static void set_continue_album(void *data, const char *buf)
{
if (!parse_bool(buf, &player_cont_album))
return;
update_statusline();
}
static void toggle_continue_album(void *data)
{
player_cont_album ^= 1;
update_statusline();
}
static void get_repeat_current(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[player_repeat_current], size);
}
static void set_repeat_current(void *data, const char *buf)
{
int old = player_repeat_current;
if (!parse_bool(buf, &player_repeat_current))
return;
if (old != player_repeat_current)
mpris_loop_status_changed();
update_statusline();
}
static void toggle_repeat_current(void *data)
{
player_repeat_current ^= 1;
mpris_loop_status_changed();
update_statusline();
}
static void get_confirm_run(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[confirm_run], size);
}
static void set_confirm_run(void *data, const char *buf)
{
parse_bool(buf, &confirm_run);
}
static void toggle_confirm_run(void *data)
{
confirm_run ^= 1;
}
const char * const view_names[NR_VIEWS + 1] = {
"tree", "sorted", "playlist", "queue", "browser", "filters", "settings", NULL
};
static void get_play_library(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[play_library], size);
}
static void set_play_library(void *data, const char *buf)
{
if (!parse_bool(buf, &play_library))
return;
update_statusline();
}
static void toggle_play_library(void *data)
{
play_library ^= 1;
update_statusline();
}
static void get_play_sorted(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[play_sorted], size);
}
static void set_play_sorted(void *data, const char *buf)
{
int tmp;
if (!parse_bool(buf, &tmp))
return;
play_sorted = tmp;
update_statusline();
}
static void toggle_play_sorted(void *data)
{
play_sorted = play_sorted ^ 1;
/* shuffle would override play_sorted... */
if (play_sorted) {
/* play_sorted makes no sense in playlist */
play_library = 1;
shuffle = 0;
}
update_statusline();
}
static void get_smart_artist_sort(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[smart_artist_sort], size);
}
static void set_smart_artist_sort(void *data, const char *buf)
{
if (parse_bool(buf, &smart_artist_sort))
tree_sort_artists();
}
static void toggle_smart_artist_sort(void *data)
{
smart_artist_sort ^= 1;
tree_sort_artists();
}
static void get_display_artist_sort_name(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[display_artist_sort_name], size);
}
static void set_display_artist_sort_name(void *data, const char *buf)
{
parse_bool(buf, &display_artist_sort_name);
lib_tree_win->changed = 1;
}
static void toggle_display_artist_sort_name(void *data)
{
display_artist_sort_name ^= 1;
lib_tree_win->changed = 1;
}
const char * const aaa_mode_names[] = {
"all", "artist", "album", NULL
};
static void get_aaa_mode(void *data, char *buf, size_t size)
{
strscpy(buf, aaa_mode_names[aaa_mode], size);
}
static void set_aaa_mode(void *data, const char *buf)
{
int tmp;
if (!parse_enum(buf, 0, 2, aaa_mode_names, &tmp))
return;
aaa_mode = tmp;
update_statusline();
}
static void toggle_aaa_mode(void *data)
{
/* aaa mode makes no sense in playlist */
play_library = 1;
aaa_mode++;
aaa_mode %= 3;
update_statusline();
}
static void get_repeat(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[repeat], size);
}
static void set_repeat(void *data, const char *buf)
{
int old = repeat;
if (!parse_bool(buf, &repeat))
return;
if (!player_repeat_current && old != repeat)
mpris_loop_status_changed();
update_statusline();
}
static void toggle_repeat(void *data)
{
repeat ^= 1;
if (!player_repeat_current)
mpris_loop_status_changed();
update_statusline();
}
static const char * const replaygain_names[] = {
"disabled", "track", "album", "track-preferred", "album-preferred", NULL
};
static void get_replaygain(void *data, char *buf, size_t size)
{
strscpy(buf, replaygain_names[replaygain], size);
}
static void set_replaygain(void *data, const char *buf)
{
int tmp;
if (!parse_enum(buf, 0, 4, replaygain_names, &tmp))
return;
player_set_rg(tmp);
}
static void toggle_replaygain(void *data)
{
player_set_rg((replaygain + 1) % 5);
}
static void get_replaygain_limit(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[replaygain_limit], size);
}
static void set_replaygain_limit(void *data, const char *buf)
{
int tmp;
if (!parse_bool(buf, &tmp))
return;
player_set_rg_limit(tmp);
}
static void toggle_replaygain_limit(void *data)
{
player_set_rg_limit(replaygain_limit ^ 1);
}
static void get_resume(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[resume_cmus], size);
}
static void set_resume(void *data, const char *buf)
{
parse_bool(buf, &resume_cmus);
}
static void toggle_resume(void *data)
{
resume_cmus ^= 1;
}
static void get_show_hidden(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[show_hidden], size);
}
static void set_show_hidden(void *data, const char *buf)
{
if (!parse_bool(buf, &show_hidden))
return;
browser_reload();
}
static void toggle_show_hidden(void *data)
{
show_hidden ^= 1;
browser_reload();
}
static void set_show_all_tracks_int(int); /* defined below */
static void get_auto_expand_albums_follow(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[auto_expand_albums_follow], size);
}
static void set_auto_expand_albums_follow_int(int value)
{
auto_expand_albums_follow = !!value;
if (!auto_expand_albums_follow && !show_all_tracks)
set_show_all_tracks_int(1);
}
static void set_auto_expand_albums_follow(void *data, const char *buf)
{
int tmp = 0;
parse_bool(buf, &tmp);
set_auto_expand_albums_follow_int(tmp);
}
static void toggle_auto_expand_albums_follow(void *data)
{
set_auto_expand_albums_follow_int(!auto_expand_albums_follow);
}
static void get_auto_expand_albums_search(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[auto_expand_albums_search], size);
}
static void set_auto_expand_albums_search_int(int value)
{
auto_expand_albums_search = !!value;
if (!auto_expand_albums_search && !show_all_tracks)
set_show_all_tracks_int(1);
}
static void set_auto_expand_albums_search(void *data, const char *buf)
{
int tmp = 0;
parse_bool(buf, &tmp);
set_auto_expand_albums_search_int(tmp);
}
static void toggle_auto_expand_albums_search(void *data)
{
set_auto_expand_albums_search_int(!auto_expand_albums_search);
}
static void get_auto_expand_albums_selcur(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[auto_expand_albums_selcur], size);
}
static void set_auto_expand_albums_selcur_int(int value)
{
auto_expand_albums_selcur = !!value;
if (!auto_expand_albums_selcur && !show_all_tracks)
set_show_all_tracks_int(1);
}
static void set_auto_expand_albums_selcur(void *data, const char *buf)
{
int tmp = 0;
parse_bool(buf, &tmp);
set_auto_expand_albums_selcur_int(tmp);
}
static void toggle_auto_expand_albums_selcur(void *data)
{
set_auto_expand_albums_selcur_int(!auto_expand_albums_selcur);
}
static void get_show_all_tracks(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[show_all_tracks], size);
}
static void set_show_all_tracks_int(int value)
{
value = !!value;
if (show_all_tracks == value)
return;
show_all_tracks = value;
if (!show_all_tracks) {
if (!auto_expand_albums_follow)
set_auto_expand_albums_follow_int(1);
if (!auto_expand_albums_search)
set_auto_expand_albums_search_int(1);
if (!auto_expand_albums_selcur)
set_auto_expand_albums_selcur_int(1);
}
tree_sel_update(0);
}
static void set_show_all_tracks(void *data, const char *buf)
{
int tmp = 0;
parse_bool(buf, &tmp);
set_show_all_tracks_int(tmp);
}
static void toggle_show_all_tracks(void *data)
{
set_show_all_tracks_int(!show_all_tracks);
}
static void get_show_current_bitrate(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[show_current_bitrate], size);
}
static void set_show_current_bitrate(void *data, const char *buf)
{
if (parse_bool(buf, &show_current_bitrate))
update_statusline();
}
static void toggle_show_current_bitrate(void *data)
{
show_current_bitrate ^= 1;
update_statusline();
}
static void get_show_playback_position(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[show_playback_position], size);
}
static void set_show_playback_position(void *data, const char *buf)
{
if (!parse_bool(buf, &show_playback_position))
return;
update_statusline();
}
static void toggle_show_playback_position(void *data)
{
show_playback_position ^= 1;
update_statusline();
}
static void get_show_remaining_time(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[show_remaining_time], size);
}
static void set_show_remaining_time(void *data, const char *buf)
{
if (!parse_bool(buf, &show_remaining_time))
return;
update_statusline();
}
static void toggle_show_remaining_time(void *data)
{
show_remaining_time ^= 1;
update_statusline();
}
static void get_set_term_title(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[set_term_title], size);
}
static void set_set_term_title(void *data, const char *buf)
{
parse_bool(buf, &set_term_title);
}
static void toggle_set_term_title(void *data)
{
set_term_title ^= 1;
}
static void get_shuffle(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[shuffle], size);
}
static void set_shuffle(void *data, const char *buf)
{
int old = shuffle;
if (!parse_bool(buf, &shuffle))
return;
if (old != shuffle)
mpris_shuffle_changed();
update_statusline();
}
static void toggle_shuffle(void *data)
{
shuffle ^= 1;
mpris_shuffle_changed();
update_statusline();
}
static void get_softvol(void *data, char *buf, size_t size)
{
strscpy(buf, bool_names[soft_vol], size);
}