MCPcopy Create free account
hub / github.com/codename-co/stack / create_tray

Function create_tray

packages/app/src-tauri/src/tray.rs:84–269  ·  view source on GitHub ↗
(app: &tauri::AppHandle<tauri::Wry>)

Source from the content-addressed store, hash-verified

82}
83
84pub fn create_tray(app: &tauri::AppHandle<tauri::Wry>) -> tauri::Result<()> {
85 let handle = app.app_handle();
86
87 // let new_window_i = MenuItem::with_id(app, "new-window", "New window", true, None::<&str>)?;
88 // let icon_light = MenuItem::with_id(app, "icon-light", "Icon light", true, None::<&str>)?;
89 // let icon_dark = MenuItem::with_id(app, "icon-dark", "Icon dark", true, None::<&str>)?;
90 // #[cfg(target_os = "macos")]
91 // let switch_i = MenuItem::with_id(app, "switch-menu", "Switch Menu", true, None::<&str>)?;
92 // let quit_i = MenuItem::with_id(app, "quit", "Quit", true, Some("cmd+q"))?;
93
94 // let submenu = SubmenuBuilder::new(handle, "File")
95 // .item(&MenuItem::new(handle, "MenuItem 1", true, None::<&str>)?)
96 // .items(&[
97 // &CheckMenuItem::new(handle, "CheckMenuItem 1", true, true, None::<&str>)?,
98 // // &IconMenuItem::new(handle, "IconMenuItem 1", true, Some(icon1), None::<&str>)?,
99 // ])
100 // .separator()
101 // .cut()
102 // .copy()
103 // .paste()
104 // .separator()
105 // .text("item2", "MenuItem 2")
106 // .check("checkitem2", "CheckMenuItem 2")
107 // .icon(
108 // "iconitem2",
109 // "IconMenuItem 2",
110 // app.default_window_icon().cloned().unwrap(),
111 // )
112 // .build()?;
113
114 // let menu1 = Menu::with_items(
115 // app,
116 // &[
117 // &new_window_i,
118 // &icon_light,
119 // &icon_dark,
120 // #[cfg(target_os = "macos")]
121 // &switch_i,
122 // &MenuItem::with_id(app, "separator", "", false, None::<&str>)?,
123 // &quit_i,
124 // ],
125 // )?;
126 // menu1.append(&submenu)?;
127 // let menu2 = Menu::with_items(app, &[&new_window_i, &switch_i, &quit_i])?;
128
129 // let is_menu1 = AtomicBool::new(true);
130
131 let _ = TrayIconBuilder::with_id("tray-1")
132 .tooltip("Stack")
133 .icon(include_image!("icons/32x32-white.png"))
134 .menu(&create_menu(handle).unwrap())
135 // .show_menu_on_left_click(false)
136 .on_menu_event(
137 move |app: &tauri::AppHandle, event| match event.id.as_ref() {
138 // "test_download" => {
139 // let url = "https://stack.lol/downloads/excalidraw.stack";
140 // debug!("Downloading... {:?}", url);
141 // tauri::async_runtime::spawn(async move {

Callers 1

runFunction · 0.85

Calls 3

create_menuFunction · 0.85
trust_certificateFunction · 0.85
updateFunction · 0.85

Tested by

no test coverage detected