/* * Copyright 2014 (c) Anna Schumaker. */ #include #include #include static Glib::ustring current_playlist(); /** * Playlist tab stuff */ class PlaylistTab : public Tab { public: PlaylistTab(); ~PlaylistTab(); bool on_key_press_event(const std::string &); }; PlaylistTab :: PlaylistTab() : Tab(playlist :: get_queue()) { tab_search = lib :: get_widget("o_playlist_entry"); tab_treeview = lib :: get_widget("o_playlist_pq_treeview"); tab_widget = lib :: get_widget("o_playlist_page"); tab_finish_init(); } PlaylistTab :: ~PlaylistTab() { tab_unmap(); } bool PlaylistTab :: on_key_press_event(const std::string &key) { std::vector ids; if (key != "Delete") return Tab :: on_key_press_event(key); tab_selected_ids(ids); for (unsigned int i = 0; i < ids.size(); i++) playlist :: del(tagdb :: lookup(ids[i]), current_playlist()); return true; } /** * Playlist "sidebar" stuff */ static Gtk::TreeView *playlist_tv; static bool find_cur_path(Gtk::TreePath &path) { Gtk::TreeViewColumn *col; playlist_tv->get_cursor(path, col); return !path.empty(); } static Glib::ustring current_playlist() { Gtk::TreePath path; if (find_cur_path(path)) return plist :: get_path(path); return ""; } static void on_playlist_cursor_changed() { playlist::select(current_playlist()); } static bool on_playlist_clicked(GdkEventButton *button) { if (button->button != 3) return false; return true; } static PlaylistTab *playlist_tab; void init_playlist_tab() { plist :: init(); playlist_tab = new PlaylistTab; playlist_tv = lib :: get_widget("o_playlist_treeview"); playlist_tv->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed)); playlist_tv->signal_button_press_event().connect(sigc::ptr_fun(on_playlist_clicked)); playlist_tv->set_cursor(Gtk::TreePath("0")); }