diff --git a/gui/collection.cpp b/gui/collection.cpp index a07b9b03..3585e469 100644 --- a/gui/collection.cpp +++ b/gui/collection.cpp @@ -2,6 +2,7 @@ * Copyright 2014 (c) Anna Schumaker. */ #include +#include #include #include @@ -16,7 +17,7 @@ public: CollectionTab :: CollectionTab() - : Tab(deck::get_library_pq()) + : Tab(library::get_queue()) { tab_random = get_widget("o_collection_random"); tab_search = get_widget("o_collection_entry"); diff --git a/gui/collection_mgr.cpp b/gui/collection_mgr.cpp index e2d11f16..8b1aa08e 100644 --- a/gui/collection_mgr.cpp +++ b/gui/collection_mgr.cpp @@ -5,6 +5,7 @@ #include #include +static void on_library_add(unsigned int id, Library *library); static class CollectionColumns : public Gtk::TreeModelColumnRecord { public: @@ -29,8 +30,9 @@ static void on_collection_ok() chooser = get_widget("o_collection_chooser"); path = chooser->get_filename(); - library::add_path(path); + Library *library = library::add(path); enable_idle(); + on_library_add(library->id, library); } static void on_collection_update() @@ -63,7 +65,7 @@ void do_collection_delete() if (path) { Glib::RefPtr list = get_collection_list(); Gtk::TreeModel::Row row = *(list->get_iter(path)); - library :: del_path(row[collection_cols.c_col_id]); + library :: remove(tagdb :: lookup_library(row[collection_cols.c_col_id])); list->erase(row); } } @@ -86,7 +88,7 @@ void on_collection_toggled(const Glib::ustring &path) Glib::RefPtr list = get_collection_list(); Gtk::TreeModel::Row row = *(list->get_iter(path)); row[collection_cols.c_col_enabled] = !row[collection_cols.c_col_enabled]; - library :: set_enabled(row[collection_cols.c_col_id], + library :: set_enabled(tagdb :: lookup_library(row[collection_cols.c_col_id]), row[collection_cols.c_col_enabled]); } @@ -102,7 +104,7 @@ static void on_library_add(unsigned int id, Library *library) row[collection_cols.c_col_path] = library->root_path; } -static void on_library_update(unsigned int id, Library *library) +/*static void on_library_update(unsigned int id, Library *library) { Gtk::TreeModel::Row row; Glib::RefPtr list = get_collection_list(); @@ -114,11 +116,11 @@ static void on_library_update(unsigned int id, Library *library) if (row[collection_cols.c_col_id] == id) row[collection_cols.c_col_size] = library->count; } -} +}*/ void collection_mgr_init() { - struct Callbacks *cb = get_callbacks(); + //struct Callbacks *cb = get_callbacks(); Gtk::TreeView *treeview = get_widget("o_collection_treeview"); Glib::RefPtr list = get_collection_list(); @@ -126,8 +128,7 @@ void collection_mgr_init() toggle = get_object("o_collection_toggle"); - cb->on_library_add = on_library_add; - cb->on_library_update = on_library_update; + //cb->on_library_update = on_library_update; connect_button("o_collection_ok", on_collection_ok); connect_button("o_collection_update", on_collection_update); diff --git a/gui/main.cpp b/gui/main.cpp index c60ec9ef..ce114f45 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -29,9 +29,9 @@ Gtk::Window *ocarina_init(int *argc, char ***argv) { Gtk::Window *window = setup_gui(); tagdb :: init(); + library::init(); audio::init(argc, argv); deck::init(); - library::init(); playlist::init(); playlist :: select("Favorites"); diff --git a/include/callback.h b/include/callback.h index 07c4da54..722f1516 100644 --- a/include/callback.h +++ b/include/callback.h @@ -19,11 +19,6 @@ struct Callbacks { void (*on_pq_created)(Queue *, unsigned int); void (*on_pq_removed)(Queue *); - /* Library callbacks */ - void (*on_library_update)(unsigned int, Library *); - void (*on_library_track_add)(unsigned int); - void (*on_library_track_del)(unsigned int); - /* Queue callbacks */ void (*on_queue_track_add)(Queue *, unsigned int); void (*on_queue_track_del)(Queue *, unsigned int); diff --git a/include/deck.h b/include/deck.h index 9942b860..5c776b83 100644 --- a/include/deck.h +++ b/include/deck.h @@ -8,7 +8,6 @@ namespace deck { - void change_library_track(unsigned int); void init(); void read(); diff --git a/lib/audio.cpp b/lib/audio.cpp index c40aa8a5..9914304c 100644 --- a/lib/audio.cpp +++ b/lib/audio.cpp @@ -81,7 +81,7 @@ static gboolean on_message(GstBus *bus, GstMessage *message, gpointer data) track = tagdb :: lookup(cur_trackid); if (track) { track->played(); - deck :: change_library_track(track->id); + library :: get_queue()->updated(track); } audio :: next(); audio :: seek_to(0); diff --git a/lib/callback.cpp b/lib/callback.cpp index fbe006db..3f71a2c9 100644 --- a/lib/callback.cpp +++ b/lib/callback.cpp @@ -5,9 +5,7 @@ static void no_op() {} -static void no_op(unsigned int) {} static void no_op(bool, unsigned int) {} -static void no_op(unsigned int id, Library *path) {} static void no_op(Queue *, unsigned int) {} static void no_op(Queue *) {} static void no_op(Track *) {} @@ -22,10 +20,6 @@ static struct Callbacks callbacks = { .on_pq_created = no_op, .on_pq_removed = no_op, - .on_library_update = no_op, - .on_library_track_add = no_op, - .on_library_track_del = no_op, - .on_queue_track_add = no_op, .on_queue_track_del = no_op, .on_queue_track_changed = no_op, diff --git a/lib/deck.cpp b/lib/deck.cpp index 1f53308b..36649fbd 100644 --- a/lib/deck.cpp +++ b/lib/deck.cpp @@ -10,35 +10,11 @@ #include static std::list playqueue_deck; -static Queue library_playqueue(Q_ENABLED); static File deck_file("deck"); -static void add_library_track(unsigned int id) -{ - library_playqueue.add(tagdb :: lookup(id)); -} - -static void del_library_track(unsigned int id) -{ - library_playqueue.del(tagdb :: lookup(id)); -} - -void deck :: change_library_track(unsigned int id) -{ - library_playqueue.updated(tagdb :: lookup(id)); -} - void deck :: init() { - library_playqueue.set_flag(Q_REPEAT); - library_playqueue.set_flag(Q_DISABLE_CHANGED_SIZE); - library_playqueue.sort(SORT_ARTIST, true); - library_playqueue.sort(SORT_YEAR, false); - library_playqueue.sort(SORT_TRACK, false); read(); - - get_callbacks()->on_library_track_add = add_library_track; - get_callbacks()->on_library_track_del = del_library_track; get_callbacks()->on_queue_changed = write; } @@ -57,15 +33,12 @@ void deck :: read() deck_file >> random >> num; for (unsigned int i = 0; i < num; i++) { deck_file >> field >> ascending; - library_playqueue.sort((sort_t)field, i == 0); - if (!ascending) - library_playqueue.sort((sort_t)field, false); + //library_playqueue.sort((sort_t)field, i == 0); + //if (!ascending) + // library_playqueue.sort((sort_t)field, false); } deck_file >> num; - if (random) - library_playqueue.set_flag(Q_RANDOM); - playqueue_deck.resize(num); num = 0; @@ -87,7 +60,7 @@ void deck :: write() /* Save library playqueue */ //sort_order = library_playqueue.get_sort_order(); - deck_file << library_playqueue.has_flag(Q_RANDOM) << " "; + deck_file << false << " "; //library_playqueue.has_flag(Q_RANDOM) << " "; deck_file << 0 /* sort_order.size() */ << " "; //for (st = sort_order.begin(); st != sort_order.end(); st++) // deck_file << st->field << " " << st->ascending << " "; @@ -195,12 +168,7 @@ Track *deck :: next() } } - return library_playqueue.next(); -} - -Queue *deck :: get_library_pq() -{ - return &library_playqueue; + return library :: get_queue()->next(); } #ifdef CONFIG_TEST