From 8ab973cd85b01dc2b9ce48d1fcded062acc037a1 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 26 Jan 2014 12:44:48 -0500 Subject: [PATCH] gui: Play tracks when rows are selected Signed-off-by: Anna Schumaker --- gui/model.cpp | 7 +++++++ gui/tabs.cpp | 8 ++++++++ include/ocarina.h | 1 + 3 files changed, 16 insertions(+) diff --git a/gui/model.cpp b/gui/model.cpp index c55a7e0e..75baf70d 100644 --- a/gui/model.cpp +++ b/gui/model.cpp @@ -4,6 +4,7 @@ * See the example at: * https://git.gnome.org/browse/gtkmm-documentation/tree/examples/others/treemodelcustom */ +#include #include #include @@ -33,6 +34,12 @@ void PlayqueueModel::on_row_deleted(unsigned int row) row_deleted(path); } +void PlayqueueModel::on_path_selected(const Gtk::TreePath &path) +{ + audio :: load_trackid(queue->operator[](path[0])); + audio :: play(); +} + /* diff --git a/gui/tabs.cpp b/gui/tabs.cpp index ebde300a..800e9462 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -114,6 +114,7 @@ public: void on_row_deleted(unsigned int); void on_runtime_changed(); void on_random_toggled(); + void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *); }; @@ -150,6 +151,8 @@ OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon, page_view.append_column("Count", queue_cols.q_col_count); page_view.append_column("Played", queue_cols.q_col_played); + page_view.signal_row_activated().connect(sigc::mem_fun(*this, + &OcarinaPage::on_row_activated)); page_view.set_model(model); page_view.set_rules_hint(); page_scroll.add(page_view); @@ -232,6 +235,11 @@ void OcarinaPage::on_random_toggled() model->queue->unset_flag(PQ_RANDOM); } +void OcarinaPage::on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) +{ + model->on_path_selected(path); +} + diff --git a/include/ocarina.h b/include/ocarina.h index f6382969..b79379d7 100644 --- a/include/ocarina.h +++ b/include/ocarina.h @@ -41,6 +41,7 @@ public: void on_row_inserted(unsigned int); void on_row_deleted(unsigned int); + void on_path_selected(const Gtk::TreePath &); }; /* tabs.cpp */