Compare commits
2 Commits
dear_imgui
...
0afc497f78
| Author | SHA1 | Date | |
|---|---|---|---|
| 0afc497f78 | |||
| b281f8af00 |
@@ -9,6 +9,7 @@ crate_type = "bin"
|
||||
|
||||
[dependencies]
|
||||
dirs = "^3.0.1"
|
||||
gdk = "^0.13.2"
|
||||
gio = "^0"
|
||||
gtk = "^0"
|
||||
rodio = "^0.11.0"
|
||||
|
||||
26
src/main.rs
26
src/main.rs
@@ -12,27 +12,29 @@ use std::process::Command;
|
||||
|
||||
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) {
|
||||
let popup = gtk::Window::new(gtk::WindowType::Toplevel);
|
||||
popup.set_title("error");
|
||||
popup.set_border_width(SPACING as u32);
|
||||
popup.set_position(gtk::WindowPosition::Center);
|
||||
popup.set_default_size(256, 64);
|
||||
|
||||
let vertical = gtk::Box::new(Orientation::Vertical, SPACING);
|
||||
popup.add(&vertical);
|
||||
popup.set_type_hint(gdk::WindowTypeHint::Dialog);
|
||||
popup.set_resizable(false);
|
||||
|
||||
let message = gtk::Label::new(Some(message));
|
||||
vertical.add(&message);
|
||||
|
||||
let button_ok = gtk::Button::with_label("OK");
|
||||
vertical.add(&button_ok);
|
||||
popup.add(&message);
|
||||
|
||||
popup.show_all();
|
||||
|
||||
button_ok.connect_clicked(move |_| unsafe {
|
||||
popup.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
fn get_data_dir() -> PathBuf {
|
||||
@@ -135,7 +137,7 @@ fn build_ui(application: >k::Application) {
|
||||
let button_manage_sounds = gtk::Button::with_label("manage sounds");
|
||||
|
||||
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.output().unwrap();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user