gui: Various playlist cleanups
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
4bfdb2d0d4
commit
1935cf9c5e
|
@ -67,7 +67,7 @@ public:
|
|||
set_markup(o_title, "xx-large", track->name());
|
||||
o_duration->set_text(track->length_str());
|
||||
|
||||
on_track_loaded(track);
|
||||
plist :: track_loaded(track);
|
||||
}
|
||||
|
||||
void play()
|
||||
|
|
|
@ -18,8 +18,8 @@ Gtk::Window *ocarina_init(int *argc, char ***argv)
|
|||
|
||||
lib :: init(argc, argv, "ocarina6.glade");
|
||||
|
||||
gst :: init(argc, argv);
|
||||
init_playlist_tab();
|
||||
gst :: init(argc, argv);
|
||||
plist :: init();
|
||||
|
||||
core :: init();
|
||||
|
||||
|
|
|
@ -6,23 +6,23 @@
|
|||
#include <gui/tabs.h>
|
||||
|
||||
|
||||
static Glib::ustring get_path(const Gtk::TreePath &);
|
||||
static bool find_cur_path(Gtk::TreePath &);
|
||||
static void del_path_ids(const Gtk::TreePath &, std::vector<unsigned int> &);
|
||||
static Gtk::ToggleButton *o_ban;
|
||||
static Gtk::ToggleButton *o_fav;
|
||||
static Gtk::TreeView *p_treeview;
|
||||
static Glib::RefPtr<Gtk::ListStore> p_list;
|
||||
|
||||
static Glib::ustring current_playlist();
|
||||
|
||||
|
||||
static class PlaylistColumns : public Gtk::TreeModelColumnRecord {
|
||||
public:
|
||||
Gtk::TreeModelColumn<Glib::ustring> p_name;
|
||||
|
||||
PlaylistColumns()
|
||||
{
|
||||
add(p_name);
|
||||
}
|
||||
PlaylistColumns() { add(p_name); }
|
||||
} p_cols;
|
||||
|
||||
|
||||
class PlaylistTab : public Tab {
|
||||
|
||||
static class PlaylistTab : public Tab {
|
||||
public:
|
||||
PlaylistTab() : Tab(playlist :: get_queue())
|
||||
{
|
||||
|
@ -39,67 +39,46 @@ public:
|
|||
|
||||
bool on_key_press_event(const std::string &key)
|
||||
{
|
||||
Gtk::TreePath path;
|
||||
std::string cur;
|
||||
std::vector<unsigned int> ids;
|
||||
|
||||
if (key != "Delete")
|
||||
return Tab :: on_key_press_event(key);
|
||||
if (find_cur_path(path)) {
|
||||
tab_selected_ids(ids);
|
||||
del_path_ids(path, ids);
|
||||
}
|
||||
|
||||
cur = current_playlist();
|
||||
if (cur == "")
|
||||
return true;
|
||||
|
||||
tab_selected_ids(ids);
|
||||
for (unsigned int i = 0; i < ids.size(); i++)
|
||||
playlist :: del(tags :: get_track(ids[i]), cur);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static Gtk::ToggleButton *o_ban;
|
||||
static Gtk::ToggleButton *o_fav;
|
||||
|
||||
static PlaylistTab *p_tab;
|
||||
static Gtk::TreeView *p_treeview;
|
||||
static Glib::RefPtr<Gtk::ListStore> p_list;
|
||||
} *p_tab;
|
||||
|
||||
|
||||
/*
|
||||
* Sidebar code
|
||||
*/
|
||||
static Glib::ustring get_path(const Gtk::TreePath &path)
|
||||
|
||||
static Glib::ustring current_playlist()
|
||||
{
|
||||
Gtk::TreeModel::Row row = *(p_list->get_iter(path));
|
||||
Gtk::TreePath path;
|
||||
Gtk::TreeModel::Row row;
|
||||
Gtk::TreeViewColumn *col;
|
||||
|
||||
p_treeview->get_cursor(path, col);
|
||||
row = *(p_list->get_iter(path));
|
||||
return row[p_cols.p_name];
|
||||
}
|
||||
|
||||
static bool find_cur_path(Gtk::TreePath &path)
|
||||
static void on_cursor_changed()
|
||||
{
|
||||
Gtk::TreeViewColumn *col;
|
||||
p_treeview->get_cursor(path, col);
|
||||
return !path.empty();
|
||||
playlist :: select(current_playlist());
|
||||
}
|
||||
|
||||
static void del_path_ids(const Gtk::TreePath &path,
|
||||
std::vector<unsigned int> &ids)
|
||||
static bool on_clicked(GdkEventButton *button)
|
||||
{
|
||||
std::string name = get_path(path);
|
||||
|
||||
for (unsigned int i = 0; i < ids.size(); i++)
|
||||
playlist :: del(tags :: get_track(ids[i]), name);
|
||||
return button->button == 3;
|
||||
}
|
||||
|
||||
static void on_playlist_cursor_changed()
|
||||
{
|
||||
Gtk::TreePath path;
|
||||
if (find_cur_path(path))
|
||||
playlist :: select(get_path(path));
|
||||
}
|
||||
|
||||
static bool on_playlist_clicked(GdkEventButton *button)
|
||||
{
|
||||
if (button->button != 3)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void on_ban()
|
||||
{
|
||||
Track *track = audio :: current_track();
|
||||
|
@ -121,22 +100,22 @@ static void on_favorite()
|
|||
playlist :: del(track, "Favorites");
|
||||
}
|
||||
|
||||
void on_track_loaded(Track *track)
|
||||
|
||||
|
||||
void plist :: track_loaded(Track *track)
|
||||
{
|
||||
o_ban->set_active(playlist :: has(track, "Banned"));
|
||||
o_fav->set_active(playlist :: has(track, "Favorites"));
|
||||
}
|
||||
|
||||
|
||||
void init_playlist_tab()
|
||||
void plist :: init()
|
||||
{
|
||||
p_tab = new PlaylistTab;
|
||||
p_list = lib :: get_object<Gtk::ListStore>("plist_list");
|
||||
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"));
|
||||
p_treeview->signal_cursor_changed().connect(sigc::ptr_fun(on_cursor_changed));
|
||||
p_treeview->signal_button_press_event().connect(sigc::ptr_fun(on_clicked));
|
||||
|
||||
o_ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
|
||||
o_fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
|
||||
|
|
|
@ -18,7 +18,6 @@ void connect_button(const std::string &, void (*func)());
|
|||
|
||||
|
||||
void on_pq_created(Queue *, unsigned int);
|
||||
void on_track_loaded(Track *);
|
||||
void post_init_queue_tabs();
|
||||
|
||||
|
||||
|
@ -32,6 +31,14 @@ namespace gst
|
|||
}
|
||||
|
||||
|
||||
/* playlist.cpp */
|
||||
namespace plist
|
||||
{
|
||||
void track_loaded(Track *track);
|
||||
void init();
|
||||
}
|
||||
|
||||
|
||||
/* window.cpp */
|
||||
Gtk::Window *window_init();
|
||||
|
||||
|
|
|
@ -104,7 +104,6 @@ void cleanup_tabs();
|
|||
|
||||
void init_collection_tab();
|
||||
void init_history_tab();
|
||||
void init_playlist_tab();
|
||||
void init_queue_tabs();
|
||||
|
||||
#endif /* OCARINA_TABS_H */
|
||||
|
|
Loading…
Reference in New Issue