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