libsaria: Move library random into a preference variable
Rather than hardcode this as a flag, if I set this through the preferences code users can change the value. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
bf5b8a3bdd
commit
848faa2bc6
|
@ -35,6 +35,7 @@ namespace libsaria
|
|||
void show_path(Path *);
|
||||
|
||||
Track *lookup(unsigned int, unsigned int);
|
||||
void set_random(bool);
|
||||
Playlist *get_playlist();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ using namespace std;
|
|||
|
||||
static unsigned int next_id = 0;
|
||||
static list<struct libsaria::library::Path> path_list;
|
||||
libsaria::Playlist lib_playlist("Library", PL_STATIC | PL_NO_DRAIN | PL_RANDOM | PL_SORTED);
|
||||
libsaria::Playlist lib_playlist("Library", PL_STATIC | PL_NO_DRAIN | PL_SORTED);
|
||||
|
||||
libsaria::library::Path *push_path(libsaria::library::Path &path)
|
||||
{
|
||||
|
@ -169,6 +169,12 @@ namespace libsaria
|
|||
return &track->get_value();
|
||||
}
|
||||
|
||||
void library::set_random(bool random)
|
||||
{
|
||||
prefs::set("libsaria.library.random", random);
|
||||
lib_playlist.set_random(random);
|
||||
}
|
||||
|
||||
Playlist *library::get_playlist()
|
||||
{
|
||||
return &lib_playlist;
|
||||
|
@ -177,6 +183,8 @@ namespace libsaria
|
|||
void library::init()
|
||||
{
|
||||
IdleCallback *task;
|
||||
bool random = prefs::init("libsaria.library.random", true);
|
||||
lib_playlist.set_random(random);
|
||||
|
||||
app::mkdir("library");
|
||||
next_id = schedule_load();
|
||||
|
|
Loading…
Reference in New Issue