provide an info popup when opening sounds folder

This commit is contained in:
Max Bradbury 2022-01-16 15:47:39 +00:00
parent cb6c5329a2
commit 811670b372
1 changed files with 14 additions and 5 deletions

View File

@ -9,9 +9,9 @@ use rodio::{Sink, Source};
const SPACING: i32 = 16;
fn error_popup(message: &str) {
fn popup(title: &str, message: &str) -> gtk::Window {
let popup = gtk::Window::new(gtk::WindowType::Toplevel);
popup.set_title("error");
popup.set_title(title);
popup.set_border_width(SPACING as u32);
popup.set_position(gtk::WindowPosition::Center);
popup.set_default_size(256, 64);
@ -21,7 +21,7 @@ fn error_popup(message: &str) {
let message = gtk::Label::new(Some(message));
popup.add(&message);
popup.show_all();
popup
}
fn build_ui(application: &gtk::Application) {
@ -40,6 +40,14 @@ fn build_ui(application: &gtk::Application) {
let button_manage_sounds = gtk::Button::with_label("open sounds folder");
button_manage_sounds.connect_clicked(|_| {
popup(
"info",
concat!(
"after changing the sounds in this folder, ",
"you will need to restart lull to see your changes."
)
);
let mut file_manager = Command::new(crate::file_manager());
file_manager.arg(crate::get_sounds_dir());
file_manager.output().unwrap();
@ -91,11 +99,12 @@ fn build_ui(application: &gtk::Application) {
);
if source.is_err() {
error_popup(&format!(
popup("error", &format!(
"Couldn't parse file {}. \n{}.",
path.to_str().unwrap(),
source.err().unwrap()
));
)).show_all();
continue;
}