Skip to content

Commit

Permalink
refactor(core): use ayatana appindicator by default, keep option to u…
Browse files Browse the repository at this point in the history
…se gtk (#3916)
  • Loading branch information
lucasfernog committed Apr 19, 2022
1 parent c4320ed commit f2a30d8
Show file tree
Hide file tree
Showing 30 changed files with 263 additions and 127 deletions.
5 changes: 5 additions & 0 deletions .changes/ayatana-tray.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

**Breaking change:** Use ayatana-appindicator for Linux system tray by default. Use the `gtk-tray` Cargo feature to use `libappindicator` instead.
2 changes: 1 addition & 1 deletion .changes/config.json
Expand Up @@ -8,7 +8,7 @@
"getPublishedVersion": "cargo search ${ pkgFile.pkg.package.name } --limit 1 | sed -nE \"s/^[^\\\"]*\\\"//; s/\\\".*//1p\"",
"prepublish": [
"sudo apt-get update",
"sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf",
"sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf",
"cargo install cargo-audit --features=fix",
{
"command": "cargo generate-lockfile",
Expand Down
6 changes: 6 additions & 0 deletions .changes/dev-keep-default-features.md
@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---

**Breaking change:** Enable default Cargo features except `tauri/custom-protocol` on the dev command.
5 changes: 5 additions & 0 deletions .changes/tauri-build-resources-linux.md
@@ -0,0 +1,5 @@
---
"tauri-build": patch
---

Copy system tray icon resource to the target directory on Linux.
2 changes: 1 addition & 1 deletion .github/workflows/artifacts-updater.yml
Expand Up @@ -41,7 +41,7 @@ jobs:
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Expand Up @@ -43,7 +43,7 @@ jobs:
run: |
python -m pip install --upgrade pip
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf xvfb
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf xvfb
wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
sudo dpkg -i hyperfine_1.11.0_amd64.deb
pip install memory_profiler
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/lint-fmt-core.yml
Expand Up @@ -49,7 +49,10 @@ jobs:
args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray',
key: 'all'
}
- { args: '--no-default-features', key: 'no-default' }
- {
args: '--no-default-features --features ayatana-tray',
key: 'no-default'
}
- { args: '--features custom-protocol', key: 'custom-protocol' }
- { args: '--features api-all', key: 'api-all' }

Expand All @@ -58,7 +61,7 @@ jobs:
- name: install webkit2gtk
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- uses: actions-rs/toolchain@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-cli.yml
Expand Up @@ -255,7 +255,7 @@ jobs:
- name: install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- name: Test bindings
run: yarn test
test-linux-x64-musl-binding:
Expand Down Expand Up @@ -349,7 +349,7 @@ jobs:
set -e
export PATH=/usr/local/cargo/bin/:/usr/local/fnm:$PATH
apt-get update
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
bash
curl https://sh.rustup.rs -sSf | bash -s -- -y
curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/fnm" --skip-shell
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-cli.yml
Expand Up @@ -106,7 +106,7 @@ jobs:
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-core.yml
Expand Up @@ -40,7 +40,7 @@ jobs:
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
Expand Down
32 changes: 20 additions & 12 deletions .github/workflows/udeps.yml
Expand Up @@ -20,6 +20,24 @@ env:
jobs:
udeps:
runs-on: ubuntu-latest
strategy:
matrix:
clippy:
- {
path: './core/tauri/Cargo.toml',
args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray'
}
- { path: './core/tauri-build/Cargo.toml', args: '--all-features' }
- { path: './core/tauri-codegen/Cargo.toml', args: '--all-features' }
- { path: './core/tauri-macros/Cargo.toml', args: '--all-features' }
- { path: './core/tauri-runtime/Cargo.toml', args: '--all-features' }
- {
path: './core/tauri-runtime-wry/Cargo.toml',
args: '--features devtools,system-tray,macos-private-api,objc-exception,ayatana-tray'
}
- { path: './core/tauri-utils/Cargo.toml', args: '--all-features' }
- { path: './tooling/bundler/Cargo.toml', args: '--all-features' }
- { path: './tooling/cli/Cargo.toml', args: '--all-features' }
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -101,19 +119,9 @@ jobs:
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- uses: actions-rs/cargo@v1
with:
command: udeps
args: --all-targets --all-features

- uses: actions-rs/cargo@v1
with:
command: udeps
args: --manifest-path ./tooling/bundler/Cargo.toml --all-targets --all-features

- uses: actions-rs/cargo@v1
with:
command: udeps
args: --manifest-path ./tooling/cli/Cargo.toml --all-targets --all-features
args: --manifest-path ${{ matrix.clippy.path }} --all-targets ${{ matrix.clippy.args }}
9 changes: 7 additions & 2 deletions core/tauri-build/src/lib.rs
Expand Up @@ -236,9 +236,14 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
target_dir,
)?;
}
if let Some(paths) = config.tauri.bundle.resources {
copy_resources(ResourcePaths::new(paths.as_slice(), true), target_dir)?;

#[allow(unused_mut)]
let mut resources = config.tauri.bundle.resources.unwrap_or_default();
#[cfg(target_os = "linux")]
if let Some(tray) = config.tauri.system_tray {
resources.push(tray.icon_path.display().to_string());
}
copy_resources(ResourcePaths::new(resources.as_slice(), true), target_dir)?;

#[cfg(target_os = "macos")]
{
Expand Down
4 changes: 3 additions & 1 deletion core/tauri-runtime-wry/Cargo.toml
Expand Up @@ -32,10 +32,12 @@ gtk = { version = "0.15", features = [ "v3_20" ] }
[features]
dox = [ "wry/dox" ]
devtools = [ "wry/devtools", "tauri-runtime/devtools" ]
system-tray = [ "wry/tray", "tauri-runtime/system-tray" ]
system-tray = [ "tauri-runtime/system-tray", "wry/tray" ]
macos-private-api = [
"wry/fullscreen",
"wry/transparent",
"tauri-runtime/macos-private-api"
]
objc-exception = [ "wry/objc-exception" ]
gtk-tray = [ "wry/gtk-tray" ]
ayatana-tray = [ "wry/ayatana-tray" ]
4 changes: 2 additions & 2 deletions core/tauri-utils/Cargo.toml
Expand Up @@ -26,7 +26,7 @@ schemars = { version = "0.8", features = [ "url" ], optional = true }
serde_with = "1.12"
aes-gcm = { version = "0.9", optional = true }
getrandom = { version = "0.2", optional = true, features = [ "std" ] }
serialize-to-javascript = "=0.1.1"
serialize-to-javascript = { version = "=0.1.1", optional = true }
ctor = "0.1"
json5 = { version = "0.4", optional = true }
json-patch = "0.2"
Expand All @@ -40,7 +40,7 @@ heck = "0.4"
build = [ "proc-macro2", "quote" ]
compression = [ "brotli" ]
schema = [ "schemars" ]
isolation = [ "aes-gcm", "getrandom" ]
isolation = [ "aes-gcm", "getrandom", "serialize-to-javascript" ]
process-relaunch-dangerous-allow-symlink-macos = [ ]
config-json5 = [ "json5" ]
resources = [ "glob", "walkdir" ]
4 changes: 3 additions & 1 deletion core/tauri/Cargo.toml
Expand Up @@ -118,10 +118,12 @@ tokio-test = "0.4.2"
tokio = { version = "1.16", features = [ "full" ] }

[features]
default = [ "wry", "compression", "objc-exception" ]
default = [ "wry", "compression", "objc-exception", "ayatana-tray" ]
compression = [ "tauri-macros/compression", "tauri-utils/compression" ]
wry = [ "tauri-runtime-wry" ]
objc-exception = [ "tauri-runtime-wry/objc-exception" ]
ayatana-tray = [ "tauri-runtime-wry/ayatana-tray" ]
gtk-tray = [ "tauri-runtime-wry/gtk-tray" ]
isolation = [ "tauri-utils/isolation", "tauri-macros/isolation" ]
custom-protocol = [ "tauri-macros/custom-protocol" ]
updater = [
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/build.rs
Expand Up @@ -29,7 +29,7 @@ fn main() {
window_create: { any(window_all, feature = "window-create") },
window_center: { any(window_all, feature = "window-center") },
window_request_user_attention: { any(window_all, feature = "window-request-user-attention") },
window_set_resizable: { any(window_all, feature = "window-set-resizable") },
window_set_izable: { any(window_all, feature = "window-set-resizable") },
window_set_title: { any(window_all, feature = "window-set-title") },
window_maximize: { any(window_all, feature = "window-maximize") },
window_unmaximize: { any(window_all, feature = "window-unmaximize") },
Expand Down
36 changes: 9 additions & 27 deletions core/tauri/src/app.rs
Expand Up @@ -1294,41 +1294,23 @@ impl<R: Runtime> Builder<R> {
if let Some(menu) = system_tray.menu() {
tray::get_menu_ids(&mut ids, menu);
}
let mut tray = tray::SystemTray::new();
let mut tray = tray::SystemTray::new().with_icon(
system_tray
.icon
.or(system_tray_icon)
.expect("tray icon not found; please configure it on tauri.conf.json"),
);
if let Some(menu) = system_tray.menu {
tray = tray.with_menu(menu);
}

#[cfg(not(target_os = "macos"))]
let tray_handler = app
.runtime
.as_ref()
.unwrap()
.system_tray(
tray.with_icon(
system_tray
.icon
.or(system_tray_icon)
.expect("tray icon not found; please configure it on tauri.conf.json"),
),
)
.expect("failed to run tray");

#[cfg(target_os = "macos")]
let tray = tray.with_icon_as_template(system_tray_icon_as_template);

let tray_handler = app
.runtime
.as_ref()
.unwrap()
.system_tray(
tray
.with_icon(
system_tray
.icon
.or(system_tray_icon)
.expect("tray icon not found; please configure it on tauri.conf.json"),
)
.with_icon_as_template(system_tray_icon_as_template),
)
.system_tray(tray)
.expect("failed to run tray");

let tray_handle = tray::SystemTrayHandle {
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/updater/mod.rs
Expand Up @@ -404,7 +404,7 @@
//!
//! The *Private key* (privkey) is used to sign your update and should NEVER be shared with anyone. Also, if you lost this key, you'll NOT be able to publish a new update to the current user base (if pubkey is set in tauri.conf.json). It's important to save it at a safe place and you can always access it.
//!
//! To generate your keys you need to use the Tauri cli.
//! To generate your keys you need to use the Tauri cli.
//!
//! ```bash
//! # Generate the keys, follow the instructions
Expand Down

0 comments on commit f2a30d8

Please sign in to comment.