3 Commits

Author SHA1 Message Date
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
3 changed files with 16 additions and 12 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

@@ -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 {
@@ -135,7 +137,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();
}); });