Compare commits
5 Commits
druid
...
ae81570c07
| Author | SHA1 | Date | |
|---|---|---|---|
| ae81570c07 | |||
| 6e203c3fbd | |||
| 0afc497f78 | |||
| b281f8af00 | |||
| 183f1064ec |
@@ -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"
|
||||||
|
|||||||
@@ -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?
|
||||||
|
|||||||
@@ -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/)
|
||||||
|
|||||||
36
src/main.rs
36
src/main.rs
@@ -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: >k::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: >k::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();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user