A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add menu items to tauri app

+45 -5
+45 -5
src-tauri/src/main.rs
··· 4 4 )] 5 5 6 6 use tauri::{App, PhysicalPosition, PhysicalSize, Position, Size}; 7 + use tauri::{CustomMenuItem, Menu, MenuItem, Submenu}; 7 8 use tauri::{Window, WindowBuilder, WindowUrl}; 8 9 9 10 fn main() { ··· 14 15 .setup(move |app| { 15 16 let w = create_window(app, port).unwrap(); 16 17 18 + // Scale window to a bit smaller than screen size 17 19 let monitor = w.current_monitor().unwrap().unwrap(); 18 20 let screen_size = tauri::window::Monitor::size(&monitor); 19 21 ··· 23 25 })) 24 26 .unwrap(); 25 27 26 - w.set_position(Position::Physical(PhysicalPosition { x: 30, y: 30 })) 27 - .unwrap(); 28 + // Put the window in the middle of the screen 29 + let window_offset = Position::Physical(PhysicalPosition { x: 30, y: 30 }); 30 + 31 + w.set_position(window_offset).unwrap(); 28 32 33 + // Fin 29 34 Ok(()) 30 35 }) 31 36 .run(tauri::generate_context!()) 32 37 .expect("error while running tauri application"); 33 38 } 34 39 40 + /** 41 + * Create a window that loads our localhost server. 42 + */ 35 43 fn create_window(app: &mut App, port: u16) -> tauri::Result<Window> { 36 44 return app.create_window( 37 45 "Diffuse", 38 46 WindowUrl::External(format!("http://localhost:{}", port).parse().unwrap()), 39 47 |window_builder, webview_attributes| { 40 48 let w = window_builder 41 - .title("Diffuse") 42 49 .maximized(true) 43 - // .position(10.0, 10.0) 44 - // .inner_size(screen_size.width - 20, screen_size.height - 20) 50 + .menu(menu()) 45 51 .resizable(true) 52 + .title("Diffuse") 46 53 .transparent(true); 47 54 48 55 (w, webview_attributes) 49 56 }, 50 57 ); 51 58 } 59 + 60 + /** 61 + * Menu 62 + */ 63 + fn menu() -> Menu { 64 + let app_menu = Menu::new() 65 + .add_native_item(MenuItem::Hide) 66 + .add_native_item(MenuItem::Services) 67 + .add_native_item(MenuItem::Separator) 68 + .add_native_item(MenuItem::Quit); 69 + 70 + let file_menu = Menu::new().add_native_item(MenuItem::CloseWindow); 71 + 72 + let edit_menu = Menu::new() 73 + .add_native_item(MenuItem::Undo) 74 + .add_native_item(MenuItem::Redo) 75 + .add_native_item(MenuItem::Separator) 76 + .add_native_item(MenuItem::Cut) 77 + .add_native_item(MenuItem::Copy) 78 + .add_native_item(MenuItem::Paste) 79 + .add_native_item(MenuItem::SelectAll); 80 + 81 + let window_menu = Menu::new() 82 + .add_native_item(MenuItem::Minimize) 83 + .add_native_item(MenuItem::Separator) 84 + .add_native_item(MenuItem::ShowAll); 85 + 86 + return Menu::new() 87 + .add_submenu(Submenu::new("Diffuse", app_menu)) 88 + .add_submenu(Submenu::new("File", file_menu)) 89 + .add_submenu(Submenu::new("Edit", edit_menu)) 90 + .add_submenu(Submenu::new("Window", window_menu)); 91 + }