Skip to content

Commit

Permalink
feat(core): make setting of gtk app id optional (#10397)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
vlabo and FabianLars authored Jul 29, 2024
1 parent 498f405 commit 7aeac39
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/linux-option-gtk-app-id.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"app": {
"description": "The App configuration.",
"default": {
"enableGTKAppId": false,
"macOSPrivateApi": false,
"security": {
"assetProtocol": {
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -2740,7 +2744,8 @@ mod build {
security,
tray_icon,
macos_private_api,
with_global_tauri
with_global_tauri,
enable_gtk_app_id
);
}
}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion core/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions core/tauri/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"app": {
"description": "The App configuration.",
"default": {
"enableGTKAppId": false,
"macOSPrivateApi": false,
"security": {
"assetProtocol": {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7aeac39

Please sign in to comment.