nw_sys/shell.rs
1//!
2//! Access to the system shell. Allows running external programs, open Shell
3//! (File Explorer / Finder) windows at different locations as well as
4//! launching external applications based on file type associations.
5//!
6//! # Synopsis
7//! ```
8//! // Open URL with default browser.
9//! nw_sys::shell::open_external("https://github.com/nwjs/nw.js");
10//!
11//! // Open a text file with default text editor.
12//! nw_sys::shell::open_item("/absolute/path/to/file.txt");
13//!
14//! // Show a file in parent folder with file manager.
15//! nw_sys::shell::show_item_in_folder("/absolute/path/to/file.txt");
16//! ```
17//!
18
19use wasm_bindgen::prelude::*;
20
21#[wasm_bindgen]
22extern "C" {
23
24 #[wasm_bindgen(js_namespace=["nw", "Shell"], js_name = openExternal)]
25 /// Open the given external URI in the desktop’s default manner.
26 ///
27 /// Shell (Explorer / Finder) interface. For usage example please refer to [nw_sys::shell](self)
28 ///
29 /// For example, mailto: URLs in the default mail user agent.
30 ///
31 /// ⧉ [NWJS Documentation](https://docs.nwjs.io/en/latest/References/Shell/#shellopenexternaluri)
32 ///
33 pub fn open_external(uri: &str);
34
35 #[wasm_bindgen(js_namespace=["nw", "Shell"], js_name = openItem)]
36 /// Open the given `file_path` in the desktop’s default manner.
37 ///
38 /// ⧉ [NWJS Documentation](https://docs.nwjs.io/en/latest/References/Shell/#shellopenitemfile_path)
39 ///
40 pub fn open_item(file_path: &str);
41
42 #[wasm_bindgen(js_namespace=["nw", "Shell"], js_name = showItemInFolder)]
43 /// Show the given `file_path` in the parent folder with file manager.
44 ///
45 /// If possible, select the file.
46 ///
47 /// ⧉ [NWJS Documentation](https://docs.nwjs.io/en/latest/References/Shell/#shellshowiteminfolderfile_path)
48 ///
49 pub fn show_item_in_folder(file_path: &str);
50}