From b281f8af00d741186a1ec920b8ebb1807baa13e2 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sat, 3 Oct 2020 13:17:20 +0100 Subject: [PATCH] target-specific file manager --- src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 86c18ff..889f123 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,16 @@ 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"); @@ -135,7 +145,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(); });