New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(core): read tray icon only on desktop, refactor Context #6719
Changes from 2 commits
cf7fd2e
96a1b2a
da00e86
d6663bf
24934fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"tauri-codegen": patch | ||
"tauri": patch | ||
--- | ||
|
||
Refactor the `Context` conditional fields and only parse the tray icon on desktop. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -552,6 +552,7 @@ pub struct Context<A: Assets> { | |||||||||||||||||||||||||||||||||
pub(crate) assets: Arc<A>, | ||||||||||||||||||||||||||||||||||
pub(crate) default_window_icon: Option<Icon>, | ||||||||||||||||||||||||||||||||||
pub(crate) app_icon: Option<Vec<u8>>, | ||||||||||||||||||||||||||||||||||
#[cfg(desktop)] | ||||||||||||||||||||||||||||||||||
pub(crate) system_tray_icon: Option<Icon>, | ||||||||||||||||||||||||||||||||||
pub(crate) package_info: PackageInfo, | ||||||||||||||||||||||||||||||||||
pub(crate) _info_plist: (), | ||||||||||||||||||||||||||||||||||
|
@@ -566,9 +567,12 @@ impl<A: Assets> fmt::Debug for Context<A> { | |||||||||||||||||||||||||||||||||
d.field("config", &self.config) | ||||||||||||||||||||||||||||||||||
.field("default_window_icon", &self.default_window_icon) | ||||||||||||||||||||||||||||||||||
.field("app_icon", &self.app_icon) | ||||||||||||||||||||||||||||||||||
.field("system_tray_icon", &self.system_tray_icon) | ||||||||||||||||||||||||||||||||||
.field("package_info", &self.package_info) | ||||||||||||||||||||||||||||||||||
.field("pattern", &self.pattern); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
#[cfg(desktop)] | ||||||||||||||||||||||||||||||||||
d.field("system_tray_icon", &self.system_tray_icon); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
#[cfg(shell_scope)] | ||||||||||||||||||||||||||||||||||
d.field("shell_scope", &self.shell_scope); | ||||||||||||||||||||||||||||||||||
d.finish() | ||||||||||||||||||||||||||||||||||
|
@@ -613,12 +617,14 @@ impl<A: Assets> Context<A> { | |||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/// The icon to use on the system tray UI. | ||||||||||||||||||||||||||||||||||
#[cfg(desktop)] | ||||||||||||||||||||||||||||||||||
#[inline(always)] | ||||||||||||||||||||||||||||||||||
pub fn system_tray_icon(&self) -> Option<&Icon> { | ||||||||||||||||||||||||||||||||||
self.system_tray_icon.as_ref() | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/// A mutable reference to the icon to use on the system tray UI. | ||||||||||||||||||||||||||||||||||
#[cfg(desktop)] | ||||||||||||||||||||||||||||||||||
#[inline(always)] | ||||||||||||||||||||||||||||||||||
pub fn system_tray_icon_mut(&mut self) -> &mut Option<Icon> { | ||||||||||||||||||||||||||||||||||
&mut self.system_tray_icon | ||||||||||||||||||||||||||||||||||
|
@@ -657,25 +663,38 @@ impl<A: Assets> Context<A> { | |||||||||||||||||||||||||||||||||
assets: Arc<A>, | ||||||||||||||||||||||||||||||||||
default_window_icon: Option<Icon>, | ||||||||||||||||||||||||||||||||||
app_icon: Option<Vec<u8>>, | ||||||||||||||||||||||||||||||||||
system_tray_icon: Option<Icon>, | ||||||||||||||||||||||||||||||||||
package_info: PackageInfo, | ||||||||||||||||||||||||||||||||||
info_plist: (), | ||||||||||||||||||||||||||||||||||
pattern: Pattern, | ||||||||||||||||||||||||||||||||||
#[cfg(shell_scope)] shell_scope: scope::ShellScopeConfig, | ||||||||||||||||||||||||||||||||||
) -> Self { | ||||||||||||||||||||||||||||||||||
Self { | ||||||||||||||||||||||||||||||||||
config, | ||||||||||||||||||||||||||||||||||
assets, | ||||||||||||||||||||||||||||||||||
default_window_icon, | ||||||||||||||||||||||||||||||||||
app_icon, | ||||||||||||||||||||||||||||||||||
system_tray_icon, | ||||||||||||||||||||||||||||||||||
#[cfg(desktop)] | ||||||||||||||||||||||||||||||||||
system_tray_icon: None, | ||||||||||||||||||||||||||||||||||
package_info, | ||||||||||||||||||||||||||||||||||
_info_plist: info_plist, | ||||||||||||||||||||||||||||||||||
pattern, | ||||||||||||||||||||||||||||||||||
#[cfg(shell_scope)] | ||||||||||||||||||||||||||||||||||
shell_scope, | ||||||||||||||||||||||||||||||||||
shell_scope: Default::default(), | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/// Sets the app tray icon. | ||||||||||||||||||||||||||||||||||
#[cfg(desktop)] | ||||||||||||||||||||||||||||||||||
#[inline(always)] | ||||||||||||||||||||||||||||||||||
pub fn with_system_tray_icon(&mut self, icon: Icon) { | ||||||||||||||||||||||||||||||||||
self.system_tray_icon.replace(icon); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/// Sets the app shell scope. | ||||||||||||||||||||||||||||||||||
#[cfg(shell_scope)] | ||||||||||||||||||||||||||||||||||
#[inline(always)] | ||||||||||||||||||||||||||||||||||
pub fn with_shell_scope(&mut self, scope: scope::ShellScopeConfig) { | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
self.shell_scope = scope; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
// TODO: expand these docs | ||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ impl From<Vec<String>> for ExecuteArgs { | |
} | ||
|
||
/// Shell scope configuration. | ||
#[derive(Debug, Clone)] | ||
#[derive(Debug, Default, Clone)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This derive will have the |
||
pub struct ScopeConfig { | ||
/// The validation regex that `shell > open` paths must match against. | ||
pub open: Option<Regex>, | ||
|
@@ -106,7 +106,7 @@ impl ScopeAllowedArg { | |
} | ||
|
||
/// Scope for filesystem access. | ||
#[derive(Clone)] | ||
#[derive(Default, Clone)] | ||
pub struct Scope(ScopeConfig); | ||
|
||
/// All errors that can happen while validating a scoped command. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure we've been following this convention throughout the codebase, but since these aren't returning a "field" on the item but a property of it we may want to use the
is_
prefix.