From 3c3f11b95800835f739df71217b5615760ad2377 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Fri, 1 Jan 2016 11:52:46 -0500 Subject: [PATCH] gui/collection: Remove old collection manager code Signed-off-by: Anna Schumaker --- gui/collection.c | 1 - gui/manager.cpp | 190 ---------------------------------- gui/ocarina.cpp | 1 - include/gui/ocarina.h | 7 -- share/ocarina/ocarina6.glade | 194 ++--------------------------------- tests/gui/collection.c | 2 +- 6 files changed, 9 insertions(+), 386 deletions(-) delete mode 100644 gui/manager.cpp diff --git a/gui/collection.c b/gui/collection.c index 8d76e89c..14a9a071 100644 --- a/gui/collection.c +++ b/gui/collection.c @@ -183,7 +183,6 @@ void gui_collection_init() gtk_tree_view_get_selection(treeview), __collection_select, NULL, NULL); - collection_update_all(); gui_collection_idle_enable(); } diff --git a/gui/manager.cpp b/gui/manager.cpp deleted file mode 100644 index 9ea170ad..00000000 --- a/gui/manager.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2014 (c) Anna Schumaker. - */ -extern "C" { -#include -#include -#include -#include -#include -} -#include - - -static Gtk::Button *c_add; -static Gtk::Button *c_update; -static Gtk::FileChooserWidget *c_chooser; -static Gtk::ProgressBar *c_progress; -static Gtk::TreeView *c_treeview; -static Glib::RefPtr c_list; -static Gtk::CellRendererToggle *c_toggle; - -static class CollectionColumns : public Gtk::TreeModelColumnRecord { -public: - Gtk::TreeModelColumn c_id; - Gtk::TreeModelColumn c_enabled; - Gtk::TreeModelColumn c_size; - Gtk::TreeModelColumn c_path; - - CollectionColumns() - { add(c_id); add(c_enabled); add(c_size); add(c_path); } -} c_cols; - - - -static void list_path(struct library *lib) -{ - Gtk::TreeModel::Row row; - - if (lib) { - row = *(c_list->append()); - row[c_cols.c_id] = lib->li_dbe.dbe_index; - row[c_cols.c_enabled] = lib->li_enabled; - row[c_cols.c_size] = lib->li_size; - row[c_cols.c_path] = lib->li_path; - } -} - -static struct library *get_library_and_row(const Gtk::TreePath &path, - Gtk::TreeModel::Row &row) -{ - row = *(c_list->get_iter(path)); - return library_get(row[c_cols.c_id]); -} - -static struct library *get_library(const Gtk::TreePath &path) -{ - Gtk::TreeModel::Row row; - return get_library_and_row(path, row); -} - -static struct library *current_library_and_row(Gtk::TreeModel::Row &row) -{ - Gtk::TreePath path; - Gtk::TreeViewColumn *col; - - c_treeview->get_cursor(path, col); - if (path.empty()) - return NULL; - return get_library_and_row(path, row); -} - -static struct library *current_library() -{ - Gtk::TreeModel::Row row; - return current_library_and_row(row); -} - - - -void update_paths() -{ - struct library *lib; - Gtk::TreeModel::Children::iterator it; - - for (it = c_list->children().begin(); it != c_list->children().end(); it++) { - lib = library_get((*it)[c_cols.c_id]); - if (lib) - (*it)[c_cols.c_size] = lib->li_size; - } -} - - - -static bool on_idle() -{ - bool ret = idle_run_task(); - - if (ret) { - c_progress->show(); - c_progress->set_fraction(idle_progress()); - } else - c_progress->hide(); - - update_paths(); - return ret; -} - -static void idle_enable() -{ - Glib :: signal_idle().connect(sigc::ptr_fun(on_idle)); -} - -static void on_add() -{ - list_path(collection_add(c_chooser->get_filename().c_str())); - idle_enable(); -} - -static void on_update() -{ - collection_update_all(); - idle_enable(); -} - -static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) -{ - collection_update(get_library(path)); - idle_enable(); -} - -static void on_cursor_changed() -{ - struct library *lib = current_library(); - if (lib && (c_chooser->get_current_folder() != lib->li_path)) - c_chooser->set_current_folder(lib->li_path); -} - -static bool on_key_pressed(GdkEventKey *event) -{ - struct library *lib; - Gtk::TreeModel::Row row; - std::string key = gdk_keyval_name(event->keyval); - - if (key != "Delete") - return false; - - lib = current_library_and_row(row); - collection_remove(lib); - c_list->erase(row); - return true; -} - -static void on_toggled(const Glib::ustring &str) -{ - Gtk::TreeModel::Row row; - struct library *lib = get_library_and_row(Gtk::TreePath(str), row); - - collection_set_enabled(lib, !lib->li_enabled); - row[c_cols.c_enabled] = lib->li_enabled; -} - - - -void manager :: init() -{ - struct db_entry *library, *next; - - c_add = Glib :: wrap(GTK_BUTTON(gui_builder_widget("colmgr_add")), false); - c_update = Glib :: wrap(GTK_BUTTON(gui_builder_widget("colmgr_update")), false); - - c_chooser = Glib :: wrap(GTK_FILE_CHOOSER_WIDGET(gui_builder_widget("colmgr_chooser")), false); - c_progress = Glib :: wrap(GTK_PROGRESS_BAR(gui_builder_widget("o_idle_progress")), false); - c_list = Glib :: wrap(GTK_LIST_STORE(gui_builder_object("colmgr_list")), false); - c_toggle = Glib :: wrap(GTK_CELL_RENDERER_TOGGLE(gui_builder_object("colmgr_toggle")), false); - c_treeview = Glib :: wrap(GTK_TREE_VIEW(gui_builder_widget("colmgr_treeview")), false); - - c_add->signal_clicked().connect(sigc::ptr_fun(on_add)); - c_update->signal_clicked().connect(sigc::ptr_fun(on_update)); - - c_toggle->signal_toggled().connect(sigc::ptr_fun(on_toggled)); - c_list->set_sort_column(c_cols.c_path, Gtk::SORT_ASCENDING); - c_treeview->signal_row_activated().connect(sigc::ptr_fun(on_row_activated)); - c_treeview->signal_cursor_changed().connect(sigc::ptr_fun(on_cursor_changed)); - c_treeview->signal_key_press_event().connect(sigc::ptr_fun(on_key_pressed)); - - db_for_each(library, next, library_db_get()) - list_path(LIBRARY(library)); - - idle_enable(); -} diff --git a/gui/ocarina.cpp b/gui/ocarina.cpp index 0859cc3b..6c27b7bb 100644 --- a/gui/ocarina.cpp +++ b/gui/ocarina.cpp @@ -72,7 +72,6 @@ int main(int argc, char **argv) gui_audio_init(); plist :: init(); - manager :: init(); init_tabs(); post_init_tabs(); diff --git a/include/gui/ocarina.h b/include/gui/ocarina.h index ee440a17..2b50565c 100644 --- a/include/gui/ocarina.h +++ b/include/gui/ocarina.h @@ -23,13 +23,6 @@ void on_pq_created(queue *, unsigned int); void post_init_queue_tabs(); -/* manager.cpp */ -namespace manager -{ - void init(); -} - - /* playlist.cpp */ namespace plist { diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 448c473e..836a5db1 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -283,8 +283,8 @@ media-skip-backward - + False @@ -318,8 +318,8 @@ 5 - + False @@ -352,8 +352,8 @@ 5 - + False @@ -386,8 +386,8 @@ media-playback-stop - + False @@ -420,8 +420,8 @@ media-skip-forward - + False @@ -631,7 +631,7 @@ - + @@ -706,7 +706,7 @@ False vertical - + True False 5 @@ -723,184 +723,6 @@ 0 - - - True - False - - - True - True - in - - - True - True - natural - natural - colmgr_list - False - False - - - - - - 20 - - - - 1 - - - - - - - 60 - Size - - - - 2 - - - - - - - Collection - - - - 3 - - - - - - - - - True - True - 5 - 0 - - - - - True - False - vertical - True - - - True - True - True - Add the selected directory to the collection. - - - True - False - True - - - True - False - dialog-ok - - - False - True - 0 - - - - - True - False - Add - center - - - False - True - 1 - - - - - - - False - True - 5 - 0 - - - - - True - True - True - Update all collections. - - - True - False - True - - - True - False - view-refresh - - - False - True - 0 - - - - - True - False - Update - center - - - False - True - 1 - - - - - - - False - True - 5 - 1 - - - - - False - True - 5 - 1 - - - - - False - True - 1 - - True @@ -916,7 +738,7 @@ True center image11 - + True diff --git a/tests/gui/collection.c b/tests/gui/collection.c index d66c103c..e3f2c9a2 100644 --- a/tests/gui/collection.c +++ b/tests/gui/collection.c @@ -43,7 +43,7 @@ static void test_collection_sidebar() notebook = GTK_NOTEBOOK(gui_builder_widget("o_notebook")); progress = GTK_PROGRESS_BAR(gui_builder_widget("o_idle_progress")); - chooser = GTK_FILE_CHOOSER(gui_builder_widget("colmgr_chooser")); + chooser = GTK_FILE_CHOOSER(gui_builder_widget("o_collection_chooser")); treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view")); selection = gtk_tree_view_get_selection(treeview); model = GTK_TREE_MODEL(gui_builder_object("o_collection_store"));