From cdbb5bff4956e4b329adcf3aa946d81f297df319 Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Sat, 13 Apr 2024 13:40:38 -0700 Subject: [PATCH] Remove play button and use GTK data --- backends/ui/gtk/main_window.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backends/ui/gtk/main_window.cpp b/backends/ui/gtk/main_window.cpp index 74ac298..9084ed7 100644 --- a/backends/ui/gtk/main_window.cpp +++ b/backends/ui/gtk/main_window.cpp @@ -49,23 +49,24 @@ void MainWindow::update_file(optional new_file) { idLabel.set_text(Glib::ustring(std::format("{}", id).c_str())); Gtk::Label nameLabel; nameLabel.set_text(name); - Gtk::Button playBtn; - playBtn.set_icon_name("media-playback-start"); - playBtn.signal_clicked().connect([=,this]() { - this->playback->play_stream(id); - }); Gtk::Box parentBox; parentBox.append(idLabel); parentBox.append(nameLabel); - parentBox.append(playBtn); parentBox.set_orientation(Gtk::Orientation::HORIZONTAL); parentBox.set_hexpand(); nameLabel.set_hexpand(); Gtk::ListBoxRow listBoxRow; listBoxRow.set_child(parentBox); listBoxRow.set_hexpand(); + listBoxRow.set_data(Glib::Quark("id"), (void*)id); stream_selection_box.append(listBoxRow); + if (id == this->playback->get_current_stream()) { + stream_selection_box.select_row(listBoxRow); + } } + stream_selection_box.signal_row_selected().connect([=,this](auto *row) { + this->playback->play_stream((int)row->get_data(Glib::Quark("id"))); + }); std::optional title = playback->get_current_title(); song_name = title.value_or(""); subTitleLabel.set_visible(title.has_value());