diff --git a/.changes/refactor-tray-features.md b/.changes/refactor-tray-features.md new file mode 100644 index 000000000..faca837b0 --- /dev/null +++ b/.changes/refactor-tray-features.md @@ -0,0 +1,5 @@ +--- +"tao": minor +--- + +**Breaking change:** Renamed the `ayatana` Cargo feature to `ayatana-tray`, now the default feature for tray on Linux, and added the `gtk-tray` feature. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ae3b9b4c..b772b0f3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,10 +50,10 @@ jobs: sudo apt-get update sudo apt-get install -y libgtk-3-dev - - name: Install libappindicator3 (ubuntu[default/tray] only) + - name: Install ayatana-libappindicator (ubuntu[default/tray] only) if: matrix.platform.id == 'ubuntu' run: | - sudo apt-get install -y libappindicator3-dev + sudo apt-get install -y libayatana-appindicator3-dev - name: Install GCC Multilib if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686') diff --git a/Cargo.toml b/Cargo.toml index 32b90cc07..bdcb5bc70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,9 +27,10 @@ targets = [ ] [features] -default = [ "tray" ] -tray = [ "libappindicator" ] -ayatana = [ "libayatana-appindicator" ] +default = [ "tray", "ayatana-tray" ] +tray = [] +gtk-tray = [ "tray", "libappindicator" ] +ayatana-tray = [ "tray", "libayatana-appindicator" ] dox = [ "gtk/dox" ] [dependencies] diff --git a/README.md b/README.md index 40d228ac4..1bf0c5422 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,11 @@ Windows, macOS, Linux, iOS and Android. Built for you, maintained for Tauri. Tao provides the following features, which can be enabled in your `Cargo.toml` file: * `serde`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde). * `tray`: Enables system tray and more menu item variants on **Linux**. This flag is enabled by default. - You can still create those types if you disable it. They just don't create the actual objects. We set this flag because some implementations require more installed packages. Disable this if you don't want to install `libappindicator` package. -* `ayatana`: Enable this if you wish to use more update `libayatana-appindicator` since `libappindicator` is no longer - maintained. + You can still create those types if you disable it. They just don't create the actual objects. We set this flag because some implementations require more installed packages. +* `ayatana-tray`: Enable this if you wish to use more update `libayatana-appindicator` since `libappindicator` is no longer maintained. + This flag is enabled by default. Disable this if you don't want to install the `libayatana-appindicator` package. +* `gtk-tray`: Enable this if you wish ot use `libappindicator` for tray on **Linux**. The package is supported on more Linux distributions, but it is not maintained anymore. + Note that `ayatana-tray` and `gtk-tray` cannot be enabled at the same time, so `default-features` must be set to `false`. ## Platform-specific notes diff --git a/src/lib.rs b/src/lib.rs index af0a8008d..f050ccf42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -183,7 +183,11 @@ mod platform_impl; target_os = "netbsd", target_os = "openbsd" ))] -#[cfg(any(feature = "tray", feature = "ayatana"))] +#[cfg(all( + feature = "tray", + any(feature = "gtk-tray", feature = "ayatana-tray"), + not(all(feature = "gtk-tray", feature = "ayatana-tray")) +))] pub mod system_tray; pub mod window; diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index 784707f91..c2f4e1c61 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -9,6 +9,14 @@ target_os = "openbsd" ))] +#[cfg(all(feature = "tray", feature = "gtk-tray", feature = "ayatana-tray"))] +compile_error!("`gtk-tray` and `ayatana-tray` Cargo features cannot be enabled at the same time"); +#[cfg(all( + feature = "tray", + not(any(feature = "gtk-tray", feature = "ayatana-tray")) +))] +compile_error!("You must enable one of `gtk-tray` or `ayatana-tray` Cargo features"); + mod clipboard; mod event_loop; mod global_shortcut; @@ -16,11 +24,19 @@ mod keyboard; mod keycode; mod menu; mod monitor; -#[cfg(any(feature = "tray", feature = "ayatana"))] +#[cfg(all( + feature = "tray", + any(feature = "gtk-tray", feature = "ayatana-tray"), + not(all(feature = "gtk-tray", feature = "ayatana-tray")) +))] mod system_tray; mod window; -#[cfg(any(feature = "tray", feature = "ayatana"))] +#[cfg(all( + feature = "tray", + any(feature = "gtk-tray", feature = "ayatana-tray"), + not(all(feature = "gtk-tray", feature = "ayatana-tray")) +))] pub use self::system_tray::{SystemTray, SystemTrayBuilder}; pub use self::{ clipboard::Clipboard, diff --git a/src/platform_impl/linux/system_tray.rs b/src/platform_impl/linux/system_tray.rs index 071977e09..032a091a4 100644 --- a/src/platform_impl/linux/system_tray.rs +++ b/src/platform_impl/linux/system_tray.rs @@ -9,9 +9,9 @@ use glib::Sender; use std::path::PathBuf; use gtk::{prelude::WidgetExt, AccelGroup}; -#[cfg(not(feature = "ayatana"))] +#[cfg(feature = "gtk-tray")] use libappindicator::{AppIndicator, AppIndicatorStatus}; -#[cfg(feature = "ayatana")] +#[cfg(feature = "ayatana-tray")] use libayatana_appindicator::{AppIndicator, AppIndicatorStatus}; use super::{menu::Menu, window::WindowRequest, WindowId};