diff --git a/gui/playlist.cpp b/gui/playlist.cpp index 8665ddde..4792a843 100644 --- a/gui/playlist.cpp +++ b/gui/playlist.cpp @@ -6,12 +6,6 @@ #include -static bool find_cur_path(Gtk::TreePath &path); - -/** - * Playlist tab stuff - */ - class PlaylistTab : public Tab { public: PlaylistTab(); @@ -19,7 +13,49 @@ public: 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("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()) { @@ -42,55 +78,9 @@ bool PlaylistTab :: on_key_press_event(const std::string &key) 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; } - - - -/** - * 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 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; -} - - - -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")); -} diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 1e410656..61f041a9 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -816,7 +816,7 @@ 5 in - + True True plist_list