Skip to content

Commit

Permalink
Undo system tray and single instance (#312)
Browse files Browse the repository at this point in the history
* Revert 5872ab9

* Undo 095b8fc
  • Loading branch information
kfiven authored Jul 25, 2024
1 parent 8921baf commit e8f5c4c
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 128 deletions.
3 changes: 1 addition & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ tauri-build = { version = "1.5.3", features = [] }
[dependencies]
serde_json = "1.0.109"
serde = { version = "1.0.193", features = ["derive"] }
tauri = { version = "1.6.8", features = ["api-all", "devtools", "system-tray", "updater"] }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri = { version = "1.6.8", features = ["api-all", "devtools", "updater"] }

[features]
# by default Tauri runs in production mode
Expand Down
35 changes: 1 addition & 34 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,16 @@
windows_subsystem = "windows"
)]

use tauri::Manager;
#[cfg(target_os = "macos")]
mod menu;
mod tray;

fn main() {
let builder = tauri::Builder::default();

#[cfg(target_os = "macos")]
let builder = builder.menu(menu::menu());

let builder = builder
.system_tray(tray::system_tray())
.on_system_tray_event(tray::system_tray_handler);

builder
.plugin(tauri_plugin_single_instance::init(|app, _, _| {
let tray_handle = match app.tray_handle_by_id(crate::tray::TRAY_LABEL) {
Some(h) => h,
None => return,
};
let window = app.get_window("main").unwrap();

if !window.is_visible().unwrap() || window.is_minimized().unwrap() {
window.unminimize().unwrap();
window.show().unwrap();
window.set_focus().unwrap();
tray_handle
.get_item("toggle")
.set_title("Hide Cinny")
.unwrap();
}
}))
.build(tauri::generate_context!())
.run(tauri::generate_context!())
.expect("error while building tauri application")
.run(run_event_handler)
}

fn run_event_handler<R: tauri::Runtime>(app: &tauri::AppHandle<R>, event: tauri::RunEvent) {
match event {
tauri::RunEvent::WindowEvent { label, event, .. } => {
tray::window_event_handler(app, &label, &event);
}
_ => {}
}
}
87 changes: 0 additions & 87 deletions src-tauri/src/tray.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@
],
"security": {
"csp": "script-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'"
},
"systemTray": {
"iconPath": "icons/32x32.png",
"iconAsTemplate": true,
"menuOnLeftClick": false
}
}
}

0 comments on commit e8f5c4c

Please sign in to comment.