Compare commits
2 Commits
iui
...
0afc497f78
| Author | SHA1 | Date | |
|---|---|---|---|
| 0afc497f78 | |||
| b281f8af00 |
@@ -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"
|
||||||
|
|||||||
26
src/main.rs
26
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 {
|
||||||
@@ -135,7 +137,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