core/collection: Rename library_q -> c_queue
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
7065b6312e
commit
696933c6b4
|
@ -8,7 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
|
||||
static struct queue library_q;
|
||||
static struct queue c_queue;
|
||||
static struct file c_file;
|
||||
|
||||
struct scan_data {
|
||||
|
@ -40,7 +40,7 @@ static void __scan_path(struct scan_data *scan, const gchar *name)
|
|||
else {
|
||||
track = track_add(scan->sd_lib, path);
|
||||
if (track)
|
||||
queue_add(&library_q, track);
|
||||
queue_add(&c_queue, track);
|
||||
}
|
||||
|
||||
g_free(path);
|
||||
|
@ -85,7 +85,7 @@ static void __validate_library(void *data)
|
|||
|
||||
path = track_path(track);
|
||||
if (g_file_test(path, G_FILE_TEST_EXISTS) == false) {
|
||||
queue_remove_all(&library_q, track);
|
||||
queue_remove_all(&c_queue, track);
|
||||
track_remove(track);
|
||||
}
|
||||
g_free(path);
|
||||
|
@ -104,51 +104,51 @@ void collection_init(struct queue_ops *ops)
|
|||
int field, ascending;
|
||||
|
||||
file_init(&c_file, "library.q", 0);
|
||||
queue_init(&library_q, Q_ENABLED | Q_REPEAT | Q_ADD_FRONT, ops);
|
||||
queue_init(&c_queue, Q_ENABLED | Q_REPEAT | Q_ADD_FRONT, ops);
|
||||
|
||||
db_for_each(track, next, track_db_get()) {
|
||||
if (TRACK(track)->tr_library->li_enabled)
|
||||
queue_add(&library_q, TRACK(track));
|
||||
queue_add(&c_queue, TRACK(track));
|
||||
}
|
||||
queue_unset_flag(&library_q, Q_ADD_FRONT);
|
||||
queue_unset_flag(&c_queue, Q_ADD_FRONT);
|
||||
|
||||
if (file_open(&c_file, OPEN_READ))
|
||||
file_readf(&c_file, "%u %u", &library_q.q_flags, &n);
|
||||
file_readf(&c_file, "%u %u", &c_queue.q_flags, &n);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
file_readf(&c_file, "%u %d", &field, &ascending);
|
||||
queue_sort(&library_q, field + 1, (i == 0) ? true : false);
|
||||
queue_sort(&c_queue, field + 1, (i == 0) ? true : false);
|
||||
if (ascending == false)
|
||||
queue_sort(&library_q, field + 1, false);
|
||||
queue_sort(&c_queue, field + 1, false);
|
||||
}
|
||||
file_close(&c_file);
|
||||
|
||||
if (!library_q.q_sort) {
|
||||
queue_sort(&library_q, COMPARE_ARTIST, true);
|
||||
queue_sort(&library_q, COMPARE_YEAR, false);
|
||||
queue_sort(&library_q, COMPARE_TRACK, false);
|
||||
if (!c_queue.q_sort) {
|
||||
queue_sort(&c_queue, COMPARE_ARTIST, true);
|
||||
queue_sort(&c_queue, COMPARE_YEAR, false);
|
||||
queue_sort(&c_queue, COMPARE_TRACK, false);
|
||||
}
|
||||
|
||||
queue_set_flag(&library_q, Q_SAVE_SORT);
|
||||
queue_set_flag(&library_q, Q_SAVE_FLAGS);
|
||||
queue_set_flag(&c_queue, Q_SAVE_SORT);
|
||||
queue_set_flag(&c_queue, Q_SAVE_FLAGS);
|
||||
}
|
||||
|
||||
void collection_deinit()
|
||||
{
|
||||
queue_deinit(&library_q);
|
||||
queue_deinit(&c_queue);
|
||||
}
|
||||
|
||||
void collection_save(struct queue *queue, enum queue_flags flag)
|
||||
{
|
||||
GSList *cur = library_q.q_sort;
|
||||
GSList *cur = c_queue.q_sort;
|
||||
int field;
|
||||
|
||||
if (&library_q != queue)
|
||||
if (&c_queue != queue)
|
||||
return;
|
||||
if (!file_open(&c_file, OPEN_WRITE))
|
||||
return;
|
||||
|
||||
file_writef(&c_file, "%u %u", library_q.q_flags, g_slist_length(cur));
|
||||
file_writef(&c_file, "%u %u", c_queue.q_flags, g_slist_length(cur));
|
||||
while (cur) {
|
||||
field = GPOINTER_TO_INT(cur->data);
|
||||
file_writef(&c_file, " %u %d", abs(field) - 1, field > 0);
|
||||
|
@ -206,23 +206,23 @@ void collection_set_enabled(struct library *library, bool enabled)
|
|||
return;
|
||||
|
||||
library_set_enabled(library, enabled);
|
||||
queue_set_flag(&library_q, Q_ADD_FRONT);
|
||||
queue_set_flag(&c_queue, Q_ADD_FRONT);
|
||||
|
||||
db_for_each(dbe, next, track_db_get()) {
|
||||
track = TRACK(dbe);
|
||||
if (track->tr_library == library) {
|
||||
if (enabled)
|
||||
queue_add(&library_q, track);
|
||||
queue_add(&c_queue, track);
|
||||
else
|
||||
queue_remove_all(&library_q, track);
|
||||
queue_remove_all(&c_queue, track);
|
||||
}
|
||||
}
|
||||
|
||||
queue_unset_flag(&library_q, Q_ADD_FRONT);
|
||||
queue_resort(&library_q);
|
||||
queue_unset_flag(&c_queue, Q_ADD_FRONT);
|
||||
queue_resort(&c_queue);
|
||||
}
|
||||
|
||||
struct queue *collection_get_queue()
|
||||
{
|
||||
return &library_q;
|
||||
return &c_queue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue