5 Commits

Author SHA1 Message Date
ae81570c07 alphabetical order 2020-10-20 21:36:55 +01:00
6e203c3fbd added sound 2020-10-20 21:33:15 +01:00
0afc497f78 better error popup 2020-10-04 12:28:28 +01:00
b281f8af00 target-specific file manager 2020-10-03 13:17:20 +01:00
183f1064ec todo 2020-09-30 12:47:26 +01:00
4 changed files with 25 additions and 15 deletions

View File

@@ -9,6 +9,7 @@ crate_type = "bin"
[dependencies] [dependencies]
dirs = "^3.0.1" dirs = "^3.0.1"
gdk = "^0.13.2"
gio = "^0" gio = "^0"
gtk = "^0" gtk = "^0"
rodio = "^0.11.0" rodio = "^0.11.0"

View File

@@ -22,5 +22,6 @@ released under the MIT license.
* vinyl crackle * vinyl crackle
* white noise? * white noise?
* fan * fan
* birdsong
* set a window icon * set a window icon
* create a nice icon? * create a nice icon?

View File

@@ -17,3 +17,5 @@ you can skip/remove any unwanted sounds, and add your own.
*campfire* by [sagetyrtle](https://freesound.org/people/sagetyrtle/) *campfire* by [sagetyrtle](https://freesound.org/people/sagetyrtle/)
*rain on glass* by [Benboncan](https://freesound.org/people/Benboncan/) *rain on glass* by [Benboncan](https://freesound.org/people/Benboncan/)
*birdsong* by [reinsamba](https://freesound.org/people/reinsamba/)

View File

@@ -12,27 +12,29 @@ use std::process::Command;
const SPACING: i32 = 16; const SPACING: i32 = 16;
#[cfg(target_os = "windows")]
fn file_manager() -> &'static str {
"explorer"
}
#[cfg(not(target_os = "windows"))]
fn file_manager() -> &'static str {
"xdg-open"
}
fn error_popup(message: &str) { fn error_popup(message: &str) {
let popup = gtk::Window::new(gtk::WindowType::Toplevel); let popup = gtk::Window::new(gtk::WindowType::Toplevel);
popup.set_title("error"); popup.set_title("error");
popup.set_border_width(SPACING as u32); popup.set_border_width(SPACING as u32);
popup.set_position(gtk::WindowPosition::Center); popup.set_position(gtk::WindowPosition::Center);
popup.set_default_size(256, 64); popup.set_default_size(256, 64);
popup.set_type_hint(gdk::WindowTypeHint::Dialog);
let vertical = gtk::Box::new(Orientation::Vertical, SPACING); popup.set_resizable(false);
popup.add(&vertical);
let message = gtk::Label::new(Some(message)); let message = gtk::Label::new(Some(message));
vertical.add(&message); popup.add(&message);
let button_ok = gtk::Button::with_label("OK");
vertical.add(&button_ok);
popup.show_all(); popup.show_all();
button_ok.connect_clicked(move |_| unsafe {
popup.destroy();
});
} }
fn get_data_dir() -> PathBuf { fn get_data_dir() -> PathBuf {
@@ -62,11 +64,15 @@ fn build_ui(application: &gtk::Application) {
let device = rodio::default_output_device().unwrap(); let device = rodio::default_output_device().unwrap();
let paths = std::fs::read_dir(get_data_dir()) let mut paths = std::fs::read_dir(get_data_dir())
.expect("Couldn't read from lull data directory"); .expect("Couldn't read lull sounds directory")
.map(|res| res.map(|e| e.path()))
.collect::<Result<Vec<_>, std::io::Error>>()
.expect("Couldn't read files from lull sounds directory");
paths.sort();
for path in paths { for path in paths {
let path = path.unwrap().path();
let name: &str = path.file_stem().unwrap().to_str().unwrap(); let name: &str = path.file_stem().unwrap().to_str().unwrap();
let file = File::open(&path) let file = File::open(&path)
@@ -135,7 +141,7 @@ fn build_ui(application: &gtk::Application) {
let button_manage_sounds = gtk::Button::with_label("manage sounds"); let button_manage_sounds = gtk::Button::with_label("manage sounds");
button_manage_sounds.connect_clicked(|_| { button_manage_sounds.connect_clicked(|_| {
let mut file_manager = Command::new("xdg-open"); let mut file_manager = Command::new(file_manager());
file_manager.arg(get_data_dir()); file_manager.arg(get_data_dir());
file_manager.output().unwrap(); file_manager.output().unwrap();
}); });