Remove play button and use GTK data

This commit is contained in:
Zachary Hall 2024-04-13 13:40:38 -07:00
parent 61333e185e
commit cdbb5bff49

View file

@ -49,23 +49,24 @@ void MainWindow::update_file(optional<std::string> new_file) {
idLabel.set_text(Glib::ustring(std::format("{}", id).c_str())); idLabel.set_text(Glib::ustring(std::format("{}", id).c_str()));
Gtk::Label nameLabel; Gtk::Label nameLabel;
nameLabel.set_text(name); 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; Gtk::Box parentBox;
parentBox.append(idLabel); parentBox.append(idLabel);
parentBox.append(nameLabel); parentBox.append(nameLabel);
parentBox.append(playBtn);
parentBox.set_orientation(Gtk::Orientation::HORIZONTAL); parentBox.set_orientation(Gtk::Orientation::HORIZONTAL);
parentBox.set_hexpand(); parentBox.set_hexpand();
nameLabel.set_hexpand(); nameLabel.set_hexpand();
Gtk::ListBoxRow listBoxRow; Gtk::ListBoxRow listBoxRow;
listBoxRow.set_child(parentBox); listBoxRow.set_child(parentBox);
listBoxRow.set_hexpand(); listBoxRow.set_hexpand();
listBoxRow.set_data(Glib::Quark("id"), (void*)id);
stream_selection_box.append(listBoxRow); 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<std::string> title = playback->get_current_title(); std::optional<std::string> title = playback->get_current_title();
song_name = title.value_or(""); song_name = title.value_or("");
subTitleLabel.set_visible(title.has_value()); subTitleLabel.set_visible(title.has_value());