Download packages/tauri/examples/api/src-tauri/src/menu_plugin.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri/examples/api/src-tauri/src/menu_plugin.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri/examples/api/src-tauri/src/menu_plugin.rs
-
curl -L -o menu_plugin.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri/examples/api/src-tauri/src/menu_plugin.rs
1.22 kB
| // Copyright 2019-2024 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| use tauri::{ | |
| command, | |
| plugin::{Builder, TauriPlugin}, | |
| Runtime, | |
| }; | |
| pub fn toggle<R: tauri::Runtime>(window: tauri::Window<R>) { | |
| if window.is_menu_visible().unwrap_or_default() { | |
| let _ = window.hide_menu(); | |
| } else { | |
| let _ = window.show_menu(); | |
| } | |
| } | |
| pub fn toggle<R: tauri::Runtime>( | |
| app: tauri::AppHandle<R>, | |
| app_menu: tauri::State<'_, crate::AppMenu<R>>, | |
| ) { | |
| if let Some(menu) = app.remove_menu().unwrap() { | |
| app_menu.0.lock().unwrap().replace(menu); | |
| } else { | |
| app | |
| .set_menu(app_menu.0.lock().unwrap().clone().expect("no app menu")) | |
| .unwrap(); | |
| } | |
| } | |
| pub fn popup<R: tauri::Runtime>( | |
| window: tauri::Window<R>, | |
| popup_menu: tauri::State<'_, crate::PopupMenu<R>>, | |
| ) { | |
| window.popup_menu(&popup_menu.0).unwrap(); | |
| } | |
| pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| Builder::new("app-menu") | |
| .invoke_handler(tauri::generate_handler![ | |
| popup, toggle | |
| ]) | |
| .build() | |
| } | |