diff --git a/gui/ocarina6.glade b/gui/ocarina6.glade index 3ca82ec1..ce596f70 100644 --- a/gui/ocarina6.glade +++ b/gui/ocarina6.glade @@ -139,6 +139,20 @@ + + + + + + + + Favorites + + + Banned + + + 100000000000 1000000000 @@ -713,15 +727,241 @@ True False + 1 + 1 vertical - + + True + True + 5 + 5 + 5 + 5 + edit-find-symbolic + False + False + + + False + True + 0 + - - - - + + True + False + + + True + True + 5 + 5 + in + + + True + True + o_playlists + False + 0 + + + browse + + + + + Playlists + + + + 0 + + + + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + in + + + True + True + True + False + True + 9 + + + multiple + + + + + True + fixed + 20 + # + True + + + + 0 + + + + + + + True + fixed + 300 + Title + True + + + + 1 + + + + + + + True + fixed + 60 + Length + True + + + + 2 + + + + + + + True + fixed + 100 + Artist + True + + + + 3 + + + + + + + True + fixed + 100 + Album + True + + + + 4 + + + + + + + True + fixed + 45 + Year + True + + + + 5 + + + + + + + True + fixed + 100 + Genre + True + + + + 6 + + + + + + + True + fixed + 60 + Count + True + + + + 7 + + + + + + + True + fixed + 1 + Played + True + + + + 8 + + + + + + + + + True + True + 1 + + + + + True + True + 1 + @@ -812,7 +1052,7 @@ Manager - + 20 @@ -823,7 +1063,7 @@ Manager - + 60 Size @@ -835,7 +1075,7 @@ Manager - + Path diff --git a/gui/playlist.cpp b/gui/playlist.cpp new file mode 100644 index 00000000..f3ac9ce1 --- /dev/null +++ b/gui/playlist.cpp @@ -0,0 +1,114 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#include +#include + +static Glib::RefPtr model; + +static class PlaylistColumns : public Gtk::TreeModelColumnRecord { +public: + PlaylistColumns() + { add(plist_col_name); } + + Gtk::TreeModelColumn plist_col_name; +} plist_cols; + + +/* + * Basic helper functions + */ +static inline Playqueue *playlist_pq() +{ + return playlist::get_pq(); +} + +static Gtk::TreeView *get_playlist_treeview() +{ + return get_widget("o_playlist_treeview"); +} + +static Glib::RefPtr get_playlists() +{ + return get_object("o_playlists"); +} + + + +/* + * Gtk signal functions + */ + +static void on_playlist_cursor_changed() +{ + Gtk::TreePath path; + Gtk::TreeViewColumn *col; + Gtk::TreeModel::Row row; + + get_playlist_treeview()->get_cursor(path, col); + row = *(get_playlists()->get_iter(path)); + + print("%s\n", row[plist_cols.plist_col_name]); + //playlist::select(row[plist_cols.plist_col_name]); +} + +static bool on_playlist_clicked(GdkEventButton *button) +{ + if (button->button != 3) + return false; + return true; +} + + + +/* + * Functions exposed through a TabFuncs structure + */ + +static void playlist_init_late() {} +static void playlist_cleanup() {} + +static bool playlist_has_queue(Playqueue *pq) +{ + return pq == playlist_pq(); +} + +static void playlist_track_added(Playqueue *pq, unsigned int row) +{ + model->on_row_inserted(row); +} + +static void playlist_track_deleted(Playqueue *pq, unsigned int row) +{ + model->on_row_deleted(row); +} + + +static struct TabFuncs playlist_funcs = { + .init_late = playlist_init_late, + .cleanup = playlist_cleanup, + + .has_queue = playlist_has_queue, + .track_added = playlist_track_added, + .track_deleted = playlist_track_deleted, +}; + + + +/* + * Basic tab setup + */ + +struct TabFuncs *init_playlist_tab() +{ + Gtk::TreeView *playlist = get_playlist_treeview(); + + model = Glib::RefPtr(new PlayqueueModel(playlist_pq())); + get_widget("o_playlist_pq_treeview")->set_model(model); + + playlist->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed)); + playlist->signal_button_press_event().connect(sigc::ptr_fun(on_playlist_clicked)); + playlist->set_cursor(Gtk::TreePath("0")); + + return &playlist_funcs; +} diff --git a/gui/tabs.cpp b/gui/tabs.cpp index e219f210..156c7b20 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -945,6 +945,7 @@ void init_tabs() tab_types.push_back(init_collection_tab()); tab_types.push_back(init_history_tab()); + tab_types.push_back(init_playlist_tab()); notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page)); notebook->signal_page_reordered().connect(sigc::ptr_fun(on_page_reordered)); diff --git a/include/ocarina.h b/include/ocarina.h index 1e9a9e98..e35c48fe 100644 --- a/include/ocarina.h +++ b/include/ocarina.h @@ -63,6 +63,9 @@ public: unsigned int path_to_id(const Gtk::TreePath &); }; +/* playlist.cpp */ +struct TabFuncs *init_playlist_tab(); + /* tabs.cpp */ void queue_selected(bool);