feat(core): make setting of gtk app id optional (#10397)

* feat(core): make setting of gtk app id optional

* Fix change file

* Update .changes/linux-option-gtk-app-id.md

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>

* [skip ci] Update linux-option-gtk-app-id.md

* Update app.rs

* Update app.rs

---------

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
This commit is contained in:
Vladimir Stoilov 2024-07-29 16:26:13 +03:00 committed by GitHub
parent 498f405ca8
commit 7aeac39e7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-utils": "patch:enhance"
"tauri": "patch:enhance"
---
Make the set of gtk application id optional, to allow more then one instance of the app running at the same time.

View File

@ -34,6 +34,7 @@
"app": {
"description": "The App configuration.",
"default": {
"enableGTKAppId": false,
"macOSPrivateApi": false,
"security": {
"assetProtocol": {
@ -195,6 +196,11 @@
"description": "Whether we should inject the Tauri API on `window.__TAURI__` or not.",
"default": false,
"type": "boolean"
},
"enableGTKAppId": {
"description": "If set to true \"identifier\" will be set as GTK app ID (on systems that use GTK).",
"default": false,
"type": "boolean"
}
},
"additionalProperties": false

View File

@ -1803,6 +1803,9 @@ pub struct AppConfig {
/// Whether we should inject the Tauri API on `window.__TAURI__` or not.
#[serde(default, alias = "with-global-tauri")]
pub with_global_tauri: bool,
/// If set to true "identifier" will be set as GTK app ID (on systems that use GTK).
#[serde(rename = "enableGTKAppId", alias = "enable-gtk-app-id", default)]
pub enable_gtk_app_id: bool,
}
impl AppConfig {
@ -2732,6 +2735,7 @@ mod build {
let tray_icon = opt_lit(self.tray_icon.as_ref());
let macos_private_api = self.macos_private_api;
let with_global_tauri = self.with_global_tauri;
let enable_gtk_app_id = self.enable_gtk_app_id;
literal_struct!(
tokens,
@ -2740,7 +2744,8 @@ mod build {
security,
tray_icon,
macos_private_api,
with_global_tauri
with_global_tauri,
enable_gtk_app_id
);
}
}
@ -2817,6 +2822,7 @@ mod test {
tray_icon: None,
macos_private_api: false,
with_global_tauri: false,
enable_gtk_app_id: false,
};
// create a build config

View File

@ -1706,6 +1706,12 @@ tauri::Builder::default()
self.invoke_key,
));
let app_id = if manager.config.app.enable_gtk_app_id {
Some(manager.config.identifier.clone())
} else {
None
};
let runtime_args = RuntimeInitArgs {
#[cfg(any(
target_os = "linux",
@ -1714,7 +1720,7 @@ tauri::Builder::default()
target_os = "netbsd",
target_os = "openbsd"
))]
app_id: Some(manager.config.identifier.clone()),
app_id,
#[cfg(windows)]
msg_hook: {

View File

@ -113,6 +113,7 @@ pub fn mock_context<R: Runtime, A: Assets<R>>(assets: A) -> crate::Context<R> {
security: Default::default(),
tray_icon: None,
macos_private_api: false,
enable_gtk_app_id: false,
},
bundle: Default::default(),
build: Default::default(),

View File

@ -34,6 +34,7 @@
"app": {
"description": "The App configuration.",
"default": {
"enableGTKAppId": false,
"macOSPrivateApi": false,
"security": {
"assetProtocol": {
@ -195,6 +196,11 @@
"description": "Whether we should inject the Tauri API on `window.__TAURI__` or not.",
"default": false,
"type": "boolean"
},
"enableGTKAppId": {
"description": "If set to true \"identifier\" will be set as GTK app ID (on systems that use GTK).",
"default": false,
"type": "boolean"
}
},
"additionalProperties": false