Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecb6984b2f | ||
|
|
2a4d7da8df | ||
|
|
095b8fc561 | ||
|
|
ba8d255eb7 | ||
|
|
aaf1ca4772 |
2
.github/workflows/archive.yml
vendored
2
.github/workflows/archive.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.3.0
|
||||
uses: actions/checkout@v3.5.3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Create zip including submodules
|
||||
|
||||
2
.github/workflows/cla.yml
vendored
2
.github/workflows/cla.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
- 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'
|
||||
# Beta Release
|
||||
uses: cla-assistant/github-action@v2.2.1
|
||||
uses: cla-assistant/github-action@v2.3.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# the below token should have repo scope and must be manually added by you in the repository's secret
|
||||
|
||||
2
.github/workflows/lockfile.yml
vendored
2
.github/workflows/lockfile.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3.3.0
|
||||
uses: actions/checkout@v3.5.3
|
||||
- name: NPM Lockfile Changes
|
||||
uses: codepunkt/npm-lockfile-changes@b40543471c36394409466fdb277a73a0856d7891
|
||||
with:
|
||||
|
||||
10
.github/workflows/tauri.yml
vendored
10
.github/workflows/tauri.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.3.0
|
||||
uses: actions/checkout@v3.5.3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Get release
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.3.0
|
||||
uses: actions/checkout@v3.5.3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Get release
|
||||
@@ -129,7 +129,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.3.0
|
||||
uses: actions/checkout@v3.5.3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Get release
|
||||
@@ -181,7 +181,7 @@ jobs:
|
||||
# runs-on: macos-12
|
||||
# steps:
|
||||
# - name: Checkout repository
|
||||
# uses: actions/checkout@v3.3.0
|
||||
# uses: actions/checkout@v3.5.3
|
||||
# with:
|
||||
# submodules: true
|
||||
# - name: Get release
|
||||
@@ -243,7 +243,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.3.0
|
||||
uses: actions/checkout@v3.5.3
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Run release.json
|
||||
|
||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.3.0
|
||||
uses: actions/checkout@v3.5.3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Setup node
|
||||
|
||||
2
cinny
2
cinny
Submodule cinny updated: f6694031a1...b80f801d23
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cinny",
|
||||
"version": "2.2.6",
|
||||
"version": "3.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cinny",
|
||||
"version": "2.2.6",
|
||||
"version": "3.0.0",
|
||||
"description": "Yet another matrix client",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
|
||||
38
src-tauri/Cargo.lock
generated
38
src-tauri/Cargo.lock
generated
@@ -247,7 +247,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cinny"
|
||||
version = "2.2.6"
|
||||
version = "3.0.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1240,6 +1240,30 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libappindicator"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db2d3cb96d092b4824cb306c9e544c856a4cb6210c1081945187f7f1924b47e8"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"gtk",
|
||||
"gtk-sys",
|
||||
"libappindicator-sys",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libappindicator-sys"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1b3b6681973cea8cc3bce7391e6d7d5502720b80a581c9a95c9cbaf592826aa"
|
||||
dependencies = [
|
||||
"gtk-sys",
|
||||
"libloading",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.138"
|
||||
@@ -1255,6 +1279,16 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "line-wrap"
|
||||
version = "0.1.1"
|
||||
@@ -2561,6 +2595,7 @@ dependencies = [
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"crossbeam-channel",
|
||||
"dirs-next",
|
||||
"dispatch",
|
||||
"gdk",
|
||||
"gdk-pixbuf",
|
||||
@@ -2574,6 +2609,7 @@ dependencies = [
|
||||
"instant",
|
||||
"jni",
|
||||
"lazy_static",
|
||||
"libappindicator",
|
||||
"libc",
|
||||
"log",
|
||||
"ndk",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[package]
|
||||
name = "cinny"
|
||||
version = "2.2.6"
|
||||
version = "3.0.0"
|
||||
description = "Yet another matrix client"
|
||||
authors = ["Ajay Bura"]
|
||||
license = "AGPL-3.0-only"
|
||||
@@ -16,8 +16,8 @@ tauri-build = { version = "1.2.1", features = [] }
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0.91"
|
||||
serde = { version = "1.0.152", features = ["derive"] }
|
||||
tauri = { version = "1.2.3", features = ["api-all", "devtools", "updater"] }
|
||||
serde = { version = "1.0.147", features = ["derive"] }
|
||||
tauri = { version = "1.2.3", features = ["api-all", "devtools", "system-tray", "updater"] }
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
#![cfg_attr(
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
mod menu;
|
||||
mod tray;
|
||||
|
||||
fn main() {
|
||||
let builder = tauri::Builder::default();
|
||||
let builder = tauri::Builder::default();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let builder = builder.menu(menu::menu());
|
||||
#[cfg(target_os = "macos")]
|
||||
let builder = builder.menu(menu::menu());
|
||||
|
||||
builder
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
let builder = builder
|
||||
.system_tray(tray::system_tray())
|
||||
.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
87
src-tauri/src/tray.rs
Normal 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)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"package": {
|
||||
"productName": "Cinny",
|
||||
"version": "2.2.6"
|
||||
"version": "3.0.0"
|
||||
},
|
||||
"build": {
|
||||
"distDir": "../cinny/dist",
|
||||
@@ -72,6 +72,11 @@
|
||||
],
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user