mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-27 02:53:38 +00:00
Fix the Clippy findings in the Linux-only code paths
This commit is contained in:
parent
08b6a190a8
commit
9c3fcbf815
@ -504,12 +504,12 @@ fn read_locale_from_environment() -> Option<(String, &'static str)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for key in ["LC_ALL", "LC_MESSAGES", "LANG"] {
|
for key in ["LC_ALL", "LC_MESSAGES", "LANG"] {
|
||||||
if let Ok(value) = env::var(key) {
|
if let Ok(value) = env::var(key)
|
||||||
if let Some(locale) = normalize_locale_tag(&value) {
|
&& let Some(locale) = normalize_locale_tag(&value)
|
||||||
|
{
|
||||||
return Some((locale, key));
|
return Some((locale, key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,6 +149,12 @@ struct ShortcutManager {
|
|||||||
/// Stores the backend-specific resources required by an active shortcut.
|
/// Stores the backend-specific resources required by an active shortcut.
|
||||||
enum ActiveBinding {
|
enum ActiveBinding {
|
||||||
/// Stores a shortcut registered through the Tauri plugin.
|
/// Stores a shortcut registered through the Tauri plugin.
|
||||||
|
///
|
||||||
|
/// Never constructed on Linux: registration there goes through the XDG portal and falls back
|
||||||
|
/// to the focused window, so nothing ever reaches the Tauri plugin. The variant stays all the
|
||||||
|
/// same, because the code which releases, suspends, and restores bindings is shared across
|
||||||
|
/// platforms and would otherwise have to be cut in two for one unreachable case.
|
||||||
|
#[cfg_attr(target_os = "linux", allow(dead_code))]
|
||||||
Tauri {
|
Tauri {
|
||||||
/// Contains the registered shortcut in Tauri syntax.
|
/// Contains the registered shortcut in Tauri syntax.
|
||||||
shortcut: String,
|
shortcut: String,
|
||||||
@ -247,13 +253,12 @@ pub async fn register(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
|
||||||
match prepare_portal_binding(&request, event_sender.clone()).await {
|
match prepare_portal_binding(&request, event_sender.clone()).await {
|
||||||
Ok(new_binding) => {
|
Ok(new_binding) => {
|
||||||
let effective_display_name = new_binding.effective_display_name();
|
let effective_display_name = new_binding.effective_display_name();
|
||||||
replace_portal_binding(&app_handle, &mut manager, request.id, new_binding).await;
|
replace_portal_binding(&app_handle, &mut manager, request.id, new_binding).await;
|
||||||
info!(Source = "XDG portal"; "Global shortcut '{}' is active through the desktop portal.", request.id);
|
info!(Source = "XDG portal"; "Global shortcut '{}' is active through the desktop portal.", request.id);
|
||||||
return ShortcutResponse::success(ShortcutBackend::Portal, effective_display_name);
|
ShortcutResponse::success(ShortcutBackend::Portal, effective_display_name)
|
||||||
},
|
},
|
||||||
|
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
@ -266,7 +271,7 @@ pub async fn register(
|
|||||||
}
|
}
|
||||||
|
|
||||||
manager.bindings.insert(request.id, ActiveBinding::Local { shortcut: request.shortcut.clone() });
|
manager.bindings.insert(request.id, ActiveBinding::Local { shortcut: request.shortcut.clone() });
|
||||||
return ShortcutResponse::success(ShortcutBackend::Local, request.shortcut);
|
ShortcutResponse::success(ShortcutBackend::Local, request.shortcut)
|
||||||
} else {
|
} else {
|
||||||
let cancelled = error.kind == PortalFailureKind::Cancelled;
|
let cancelled = error.kind == PortalFailureKind::Cancelled;
|
||||||
if cancelled {
|
if cancelled {
|
||||||
@ -277,11 +282,10 @@ pub async fn register(
|
|||||||
error!(Source = "XDG portal"; "Global shortcut registration failed; preserving the active portal binding: {}", error.message);
|
error!(Source = "XDG portal"; "Global shortcut registration failed; preserving the active portal binding: {}", error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShortcutResponse::error(error.message, ShortcutBackend::Portal, cancelled);
|
ShortcutResponse::error(error.message, ShortcutBackend::Portal, cancelled)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
match register_tauri_binding(&app_handle, &request.shortcut, request.id, event_sender) {
|
match register_tauri_binding(&app_handle, &request.shortcut, request.id, event_sender) {
|
||||||
|
|||||||
@ -23,11 +23,11 @@ fn issue_code(error: &KeyringError) -> SecretStoreIssueCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
if let KeyringError::PlatformFailure(error) | KeyringError::NoStorageAccess(error) = error {
|
if let KeyringError::PlatformFailure(error) | KeyringError::NoStorageAccess(error) = error
|
||||||
if let Some(error) = error.downcast_ref::<dbus_secret_service::Error>() {
|
&& let Some(error) = error.downcast_ref::<dbus_secret_service::Error>()
|
||||||
|
{
|
||||||
return secret_service_issue_code(error);
|
return secret_service_issue_code(error);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SecretStoreIssueCode::Unknown
|
SecretStoreIssueCode::Unknown
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user