2890819cd3
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
87 lines
1.7 KiB
C++
87 lines
1.7 KiB
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/playlist.h>
|
|
#include <lib/plist.h>
|
|
#include <gui/tabs.h>
|
|
|
|
|
|
class PlaylistTab : public Tab {
|
|
public:
|
|
PlaylistTab();
|
|
~PlaylistTab();
|
|
bool on_key_press_event(const std::string &);
|
|
};
|
|
|
|
static PlaylistTab *p_tab;
|
|
static Gtk::TreeView *p_treeview;
|
|
|
|
|
|
/*
|
|
* Sidebar code
|
|
*/
|
|
static bool find_cur_path(Gtk::TreePath &path)
|
|
{
|
|
Gtk::TreeViewColumn *col;
|
|
p_treeview->get_cursor(path, col);
|
|
return !path.empty();
|
|
}
|
|
|
|
static void on_playlist_cursor_changed()
|
|
{
|
|
Gtk::TreePath path;
|
|
if (find_cur_path(path))
|
|
plist :: select_path(path);
|
|
}
|
|
|
|
static bool on_playlist_clicked(GdkEventButton *button)
|
|
{
|
|
if (button->button != 3)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void init_playlist_tab()
|
|
{
|
|
plist :: init();
|
|
p_tab = new PlaylistTab;
|
|
p_treeview = lib :: get_widget<Gtk::TreeView>("plist_treeview");
|
|
|
|
p_treeview->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed));
|
|
p_treeview->signal_button_press_event().connect(sigc::ptr_fun(on_playlist_clicked));
|
|
p_treeview->set_cursor(Gtk::TreePath("0"));
|
|
}
|
|
|
|
|
|
/*
|
|
* Playlist tab stuff
|
|
*/
|
|
PlaylistTab :: PlaylistTab()
|
|
: Tab(playlist :: get_queue())
|
|
{
|
|
tab_search = lib :: get_widget<Gtk::SearchEntry>("o_playlist_entry");
|
|
tab_treeview = lib :: get_widget<Gtk::TreeView>("o_playlist_pq_treeview");
|
|
tab_widget = lib :: get_widget<Gtk::Widget>("o_playlist_page");
|
|
|
|
tab_finish_init();
|
|
}
|
|
|
|
PlaylistTab :: ~PlaylistTab()
|
|
{
|
|
tab_unmap();
|
|
}
|
|
|
|
bool PlaylistTab :: on_key_press_event(const std::string &key)
|
|
{
|
|
Gtk::TreePath path;
|
|
std::vector<unsigned int> ids;
|
|
|
|
if (key != "Delete")
|
|
return Tab :: on_key_press_event(key);
|
|
if (find_cur_path(path)) {
|
|
tab_selected_ids(ids);
|
|
plist :: del_path_ids(path, ids);
|
|
}
|
|
return true;
|
|
}
|