Compare commits

..

8 Commits

Author SHA1 Message Date
Krishan
3c22636bdf Release v3.2.0 2023-10-31 21:25:27 +11:00
renovate[bot]
e9c6369b2b fix(deps): update tauri monorepo (#219)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-27 23:06:48 +11:00
Krishan
32e9805abd Release v3.1.0 2023-10-27 22:18:42 +11:00
Krishan
ecb6984b2f Merge branch 'main' of https://github.com/cinnyapp/cinny-desktop 2023-10-21 22:04:21 +11:00
Krishan
2a4d7da8df Release v3.0.0 2023-10-21 22:04:11 +11:00
StevenDoesStuffs
095b8fc561 Add system tray support (#166)
* Added sytem tray with hide/show buttons

* Split tray into separate module

* Fix persistent console window

* Show/hide window on tray icon click

---------

Co-authored-by: serxka <serxka@protonmail.com>
Co-authored-by: Milo <40355097+serxka@users.noreply.github.com>
Co-authored-by: greentore <117551249+greentore@users.noreply.github.com>
2023-10-21 21:34:32 +11:00
dependabot[bot]
ba8d255eb7 Bump actions/checkout from 3.3.0 to 3.5.3 (#169)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.3.0...v3.5.3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-13 09:31:40 +10:00
dependabot[bot]
aaf1ca4772 Bump cla-assistant/github-action from 2.2.1 to 2.3.0 (#144)
Bumps [cla-assistant/github-action](https://github.com/cla-assistant/github-action) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/cla-assistant/github-action/releases)
- [Commits](https://github.com/cla-assistant/github-action/compare/v2.2.1...v2.3.0)

---
updated-dependencies:
- dependency-name: cla-assistant/github-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-12 21:41:19 +10:00
13 changed files with 1564 additions and 264 deletions

View File

@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.5.3
with: with:
submodules: true submodules: true
- name: Create zip including submodules - name: Create zip including submodules

View File

@@ -12,7 +12,7 @@ jobs:
- name: 'CLA Assistant' - name: 'CLA Assistant'
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release # Beta Release
uses: cla-assistant/github-action@v2.2.1 uses: cla-assistant/github-action@v2.3.0
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret # the below token should have repo scope and must be manually added by you in the repository's secret

View File

@@ -14,7 +14,7 @@ jobs:
pull-requests: write pull-requests: write
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.5.3
- name: NPM Lockfile Changes - name: NPM Lockfile Changes
uses: codepunkt/npm-lockfile-changes@b40543471c36394409466fdb277a73a0856d7891 uses: codepunkt/npm-lockfile-changes@b40543471c36394409466fdb277a73a0856d7891
with: with:

View File

@@ -9,7 +9,7 @@ jobs:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.5.3
with: with:
submodules: true submodules: true
- name: Get release - name: Get release
@@ -70,7 +70,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.5.3
with: with:
submodules: true submodules: true
- name: Get release - name: Get release
@@ -129,7 +129,7 @@ jobs:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.5.3
with: with:
submodules: true submodules: true
- name: Get release - name: Get release
@@ -181,7 +181,7 @@ jobs:
# runs-on: macos-12 # runs-on: macos-12
# steps: # steps:
# - name: Checkout repository # - name: Checkout repository
# uses: actions/checkout@v3.3.0 # uses: actions/checkout@v3.5.3
# with: # with:
# submodules: true # submodules: true
# - name: Get release # - name: Get release
@@ -243,7 +243,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.5.3
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Run release.json - name: Run release.json

View File

@@ -13,7 +13,7 @@ jobs:
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.5.3
with: with:
submodules: true submodules: true
- name: Setup node - name: Setup node

2
cinny

Submodule cinny updated: f6694031a1...9ecb233763

109
package-lock.json generated
View File

@@ -1,19 +1,19 @@
{ {
"name": "cinny", "name": "cinny",
"version": "2.2.6", "version": "3.2.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cinny", "name": "cinny",
"version": "2.2.6", "version": "3.2.0",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"@tauri-apps/api": "1.2.0" "@tauri-apps/api": "1.5.1"
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "5.1.1", "@actions/github": "5.1.1",
"@tauri-apps/cli": "1.2.2", "@tauri-apps/cli": "1.5.6",
"node-fetch": "3.3.0" "node-fetch": "3.3.0"
}, },
"engines": { "engines": {
@@ -173,9 +173,9 @@
} }
}, },
"node_modules/@tauri-apps/api": { "node_modules/@tauri-apps/api": {
"version": "1.2.0", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-1.2.0.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-1.5.1.tgz",
"integrity": "sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw==", "integrity": "sha512-6unsZDOdlXTmauU3NhWhn+Cx0rODV+rvNvTdvolE5Kls5ybA6cqndQENDt1+FS0tF7ozCP66jwWoH6a5h90BrA==",
"engines": { "engines": {
"node": ">= 14.6.0", "node": ">= 14.6.0",
"npm": ">= 6.6.0", "npm": ">= 6.6.0",
@@ -187,9 +187,9 @@
} }
}, },
"node_modules/@tauri-apps/cli": { "node_modules/@tauri-apps/cli": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-1.5.6.tgz",
"integrity": "sha512-D8zib3A0vWCvPPSyYLxww/OdDlVcY7fpcDVBH6qUvheOjj2aCyU7H9AYMRBwpgCfz8zY5+vomee+laLeB0H13w==", "integrity": "sha512-k4Y19oVCnt7WZb2TnDzLqfs7o98Jq0tUoVMv+JQSzuRDJqaVu2xMBZ8dYplEn+EccdR5SOMyzaLBJWu38TVK1A==",
"dev": true, "dev": true,
"bin": { "bin": {
"tauri": "tauri.js" "tauri": "tauri.js"
@@ -202,21 +202,22 @@
"url": "https://opencollective.com/tauri" "url": "https://opencollective.com/tauri"
}, },
"optionalDependencies": { "optionalDependencies": {
"@tauri-apps/cli-darwin-arm64": "1.2.2", "@tauri-apps/cli-darwin-arm64": "1.5.6",
"@tauri-apps/cli-darwin-x64": "1.2.2", "@tauri-apps/cli-darwin-x64": "1.5.6",
"@tauri-apps/cli-linux-arm-gnueabihf": "1.2.2", "@tauri-apps/cli-linux-arm-gnueabihf": "1.5.6",
"@tauri-apps/cli-linux-arm64-gnu": "1.2.2", "@tauri-apps/cli-linux-arm64-gnu": "1.5.6",
"@tauri-apps/cli-linux-arm64-musl": "1.2.2", "@tauri-apps/cli-linux-arm64-musl": "1.5.6",
"@tauri-apps/cli-linux-x64-gnu": "1.2.2", "@tauri-apps/cli-linux-x64-gnu": "1.5.6",
"@tauri-apps/cli-linux-x64-musl": "1.2.2", "@tauri-apps/cli-linux-x64-musl": "1.5.6",
"@tauri-apps/cli-win32-ia32-msvc": "1.2.2", "@tauri-apps/cli-win32-arm64-msvc": "1.5.6",
"@tauri-apps/cli-win32-x64-msvc": "1.2.2" "@tauri-apps/cli-win32-ia32-msvc": "1.5.6",
"@tauri-apps/cli-win32-x64-msvc": "1.5.6"
} }
}, },
"node_modules/@tauri-apps/cli-darwin-arm64": { "node_modules/@tauri-apps/cli-darwin-arm64": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.5.6.tgz",
"integrity": "sha512-W+Cp2weUMlvmGkRJeUjypbz9Lpl6o98xkgKAtobZSum5SNwpsBQfawJTESakNoD+FXyVg/snIk5sRdHge+tAaA==", "integrity": "sha512-NNvG3XLtciCMsBahbDNUEvq184VZmOveTGOuy0So2R33b/6FDkuWaSgWZsR1mISpOuP034htQYW0VITCLelfqg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -230,9 +231,9 @@
} }
}, },
"node_modules/@tauri-apps/cli-darwin-x64": { "node_modules/@tauri-apps/cli-darwin-x64": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.5.6.tgz",
"integrity": "sha512-vmVAqt+ECH2d6cbcGJ7ddcCAZgmKe5xmxlL5r4xoaphu7OqU4gnv4VFURYkVltOfwzIFQVOPVSqwYyIDToCYNQ==", "integrity": "sha512-nkiqmtUQw3N1j4WoVjv81q6zWuZFhBLya/RNGUL94oafORloOZoSY0uTZJAoeieb3Y1YK0rCHSDl02MyV2Fi4A==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -246,9 +247,9 @@
} }
}, },
"node_modules/@tauri-apps/cli-linux-arm-gnueabihf": { "node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.5.6.tgz",
"integrity": "sha512-yYTdQurgi4QZR8z+fANjl522jdQz/VtesFpw+C/A0+zXg7tiRjicsywBDdPsvNzCqFeGKKkmTR+Lny5qxhGaeQ==", "integrity": "sha512-z6SPx+axZexmWXTIVPNs4Tg7FtvdJl9EKxYN6JPjOmDZcqA13iyqWBQal2DA/GMZ1Xqo3vyJf6EoEaKaliymPQ==",
"cpu": [ "cpu": [
"arm" "arm"
], ],
@@ -262,9 +263,9 @@
} }
}, },
"node_modules/@tauri-apps/cli-linux-arm64-gnu": { "node_modules/@tauri-apps/cli-linux-arm64-gnu": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.5.6.tgz",
"integrity": "sha512-ZSOVT6Eq1ay2+27B8KfA0MnpO7KYzONU6TjenH7DNcQki6eWGG5JoNu8QQ9Mdn3dAzY0XBP9i1ZHQOFu4iPtEg==", "integrity": "sha512-QuQjMQmpsCbzBrmtQiG4uhnfAbdFx3nzm+9LtqjuZlurc12+Mj5MTgqQ3AOwQedH3f7C+KlvbqD2AdXpwTg7VA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -278,9 +279,9 @@
} }
}, },
"node_modules/@tauri-apps/cli-linux-arm64-musl": { "node_modules/@tauri-apps/cli-linux-arm64-musl": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.5.6.tgz",
"integrity": "sha512-/NHSkqNQ+Pr4PshvyD1CeNFaPCaCpe1OeuAQgVi0rboSecC9fXN96G5dQbSBoxOUcCo6f8aTVE7zkZ4WchFVog==", "integrity": "sha512-8j5dH3odweFeom7bRGlfzDApWVOT4jIq8/214Wl+JeiNVehouIBo9lZGeghZBH3XKFRwEvU23i7sRVjuh2s8mg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -294,9 +295,9 @@
} }
}, },
"node_modules/@tauri-apps/cli-linux-x64-gnu": { "node_modules/@tauri-apps/cli-linux-x64-gnu": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.5.6.tgz",
"integrity": "sha512-4YTmfPuyvlHsvCkATDMwhklfuQm3HKxYXv/IOW9H0ra6pS9efVhrFYIC9Vfv6XaKN85Vnn/FYTEGMJLwCxZw2Q==", "integrity": "sha512-gbFHYHfdEGW0ffk8SigDsoXks6USpilF6wR0nqB/JbWzbzFR/sBuLVNQlJl1RKNakyJHu+lsFxGy0fcTdoX8xA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -310,9 +311,9 @@
} }
}, },
"node_modules/@tauri-apps/cli-linux-x64-musl": { "node_modules/@tauri-apps/cli-linux-x64-musl": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.5.6.tgz",
"integrity": "sha512-wr46tbscwFuCcA931R+ItOiUTT0djMmgKLd1HFCmFF82V9BKE2reIjr6O9l0NCXCo2WeD4pe3jA/Pt1dxDu+JA==", "integrity": "sha512-9v688ogoLkeFYQNgqiSErfhTreLUd8B3prIBSYUt+x4+5Kcw91zWvIh+VSxL1n3KCGGsM7cuXhkGPaxwlEh1ug==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -325,10 +326,26 @@
"node": ">= 10" "node": ">= 10"
} }
}, },
"node_modules/@tauri-apps/cli-win32-arm64-msvc": {
"version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-1.5.6.tgz",
"integrity": "sha512-DRNDXFNZb6y5IZrw+lhTTA9l4wbzO4TNRBAlHAiXUrH+pRFZ/ZJtv5WEuAj9ocVSahVw2NaK5Yaold4NPAxHog==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-ia32-msvc": { "node_modules/@tauri-apps/cli-win32-ia32-msvc": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.5.6.tgz",
"integrity": "sha512-6VmbVJOWUZJK5/JKhb3mNFKrKGfq0KV7lJGumfN95WJgkHeyL61p8bZit+o6ZgUGUhrOabkAawhDkrRY+ZQhIw==", "integrity": "sha512-oUYKNR/IZjF4fsOzRpw0xesl2lOjhsQEyWlgbpT25T83EU113Xgck9UjtI7xemNI/OPCv1tPiaM1e7/ABdg5iA==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@@ -342,9 +359,9 @@
} }
}, },
"node_modules/@tauri-apps/cli-win32-x64-msvc": { "node_modules/@tauri-apps/cli-win32-x64-msvc": {
"version": "1.2.2", "version": "1.5.6",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.5.6.tgz",
"integrity": "sha512-YRPJguJma+zSuRZpFoSZqls6+laggG1vqG0FPQWQTi+ywATgMpai2b2RZnffDlpHKp9mt4V/s2dtqOy6bpGZHg==", "integrity": "sha512-RmEf1os9C8//uq2hbjXi7Vgz9ne7798ZxqemAZdUwo1pv3oLVZSz1/IvZmUHPdy2e6zSeySqWu1D0Y3QRNN+dg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"name": "cinny", "name": "cinny",
"version": "2.2.6", "version": "3.2.0",
"description": "Yet another matrix client", "description": "Yet another matrix client",
"main": "index.js", "main": "index.js",
"engines": { "engines": {
@@ -14,11 +14,11 @@
"author": "Ajay Bura", "author": "Ajay Bura",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"@tauri-apps/api": "1.2.0" "@tauri-apps/api": "1.5.1"
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "5.1.1", "@actions/github": "5.1.1",
"@tauri-apps/cli": "1.2.2", "@tauri-apps/cli": "1.5.6",
"node-fetch": "3.3.0" "node-fetch": "3.3.0"
} }
} }

1557
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
[package] [package]
name = "cinny" name = "cinny"
version = "2.2.6" version = "3.2.0"
description = "Yet another matrix client" description = "Yet another matrix client"
authors = ["Ajay Bura"] authors = ["Ajay Bura"]
license = "AGPL-3.0-only" license = "AGPL-3.0-only"
@@ -12,12 +12,12 @@ edition = "2021"
rust-version = "1.61" rust-version = "1.61"
[build-dependencies] [build-dependencies]
tauri-build = { version = "1.2.1", features = [] } tauri-build = { version = "1.5.0", features = [] }
[dependencies] [dependencies]
serde_json = "1.0.91" serde_json = "1.0.91"
serde = { version = "1.0.152", features = ["derive"] } serde = { version = "1.0.147", features = ["derive"] }
tauri = { version = "1.2.3", features = ["api-all", "devtools", "updater"] } tauri = { version = "1.5.2", features = ["api-all", "devtools", "system-tray", "updater"] }
[features] [features]
# by default Tauri runs in production mode # by default Tauri runs in production mode

View File

@@ -1,18 +1,32 @@
#![cfg_attr( #![cfg_attr(
all(not(debug_assertions), target_os = "windows"), all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows" windows_subsystem = "windows"
)] )]
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
mod menu; mod menu;
mod tray;
fn main() { fn main() {
let builder = tauri::Builder::default(); let builder = tauri::Builder::default();
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
let builder = builder.menu(menu::menu()); let builder = builder.menu(menu::menu());
builder let builder = builder
.run(tauri::generate_context!()) .system_tray(tray::system_tray())
.expect("error while running tauri application"); .on_system_tray_event(tray::system_tray_handler);
builder
.build(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
src-tauri/src/tray.rs Normal file
View File

@@ -0,0 +1,87 @@
use tauri::{
CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu,
SystemTrayMenuItem, WindowEvent, SystemTrayHandle, Window,
};
const TRAY_LABEL: &'static str = "main-tray";
pub fn window_event_handler<R: tauri::Runtime>(
app: &tauri::AppHandle<R>,
label: &str,
event: &WindowEvent,
) {
match event {
// Prevent Cinny from closing, instead hide it and let it be
// reopened through the tray.
WindowEvent::CloseRequested { api, .. } => {
api.prevent_close();
app.get_window(&label).unwrap().hide().unwrap();
app.tray_handle_by_id(TRAY_LABEL)
.unwrap()
.get_item("toggle")
.set_title("Show Cinny")
.unwrap();
}
_ => {}
}
}
/// Build the system tray object
pub fn system_tray() -> SystemTray {
let toggle = CustomMenuItem::new("toggle".to_owned(), "Hide Cinny");
let quit = CustomMenuItem::new("quit".to_owned(), "Quit");
let menu = SystemTrayMenu::new()
.add_item(toggle)
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(quit);
tauri::SystemTray::new()
.with_menu(menu)
.with_id(TRAY_LABEL.to_owned())
}
pub fn toggle_window_state<R: tauri::Runtime>(window: Window<R>, tray_handle: SystemTrayHandle<R>) {
// Hide the window if it's visible, show it if not
// `is_visible` returns true for minimized state for whatever reason
if window.is_visible().unwrap() {
window.hide().unwrap();
tray_handle
.get_item("toggle")
.set_title("Show Cinny")
.unwrap();
} else {
window.unminimize().unwrap();
window.show().unwrap();
window.set_focus().unwrap();
tray_handle
.get_item("toggle")
.set_title("Hide Cinny")
.unwrap();
};
}
pub fn system_tray_handler<R: tauri::Runtime>(app: &tauri::AppHandle<R>, event: SystemTrayEvent) {
let tray_handle = match app.tray_handle_by_id(TRAY_LABEL) {
Some(h) => h,
None => return,
};
let window = app.get_window("main").unwrap();
match event {
SystemTrayEvent::LeftClick { .. } => {
toggle_window_state(window, tray_handle);
}
SystemTrayEvent::MenuItemClick { id, .. } => {
match id.as_str() {
"quit" => {
app.exit(0);
}
"toggle" => {
toggle_window_state(window, tray_handle)
}
_ => {}
}
}
_ => {}
}
}

View File

@@ -1,7 +1,7 @@
{ {
"package": { "package": {
"productName": "Cinny", "productName": "Cinny",
"version": "2.2.6" "version": "3.2.0"
}, },
"build": { "build": {
"distDir": "../cinny/dist", "distDir": "../cinny/dist",
@@ -72,6 +72,11 @@
], ],
"security": { "security": {
"csp": "script-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" "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
} }
} }
} }