Skip to content

Commit 5fb7433

Browse files
authored
chore(deps): update wry to 0.14, tao to 0.7 (#3790)
1 parent 8b807e0 commit 5fb7433

File tree

6 files changed

+148
-40
lines changed

6 files changed

+148
-40
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri": patch
3+
"tauri-runtime-wry": minor
4+
"tauri-runtime": minor
5+
---
6+
7+
**Breaking change:** The `MenuItem::About` variant is now associated with a tuple value `(String, AboutMetadata)`.

.changes/update-wry.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri": patch
3+
"tauri-runtime-wry": minor
4+
---
5+
6+
Update `wry` to `0.14` and `tao` to `0.7`.

core/tauri-runtime-wry/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
1313
readme = "README.md"
1414

1515
[dependencies]
16-
wry = { version = "0.13.3", default-features = false, features = [ "file-drop", "protocol" ] }
16+
wry = { version = "0.14", default-features = false, features = [ "file-drop", "protocol" ] }
1717
tauri-runtime = { version = "0.3.3", path = "../tauri-runtime" }
1818
tauri-utils = { version = "1.0.0-rc.3", path = "../tauri-utils" }
1919
uuid = { version = "0.8.2", features = [ "v4" ] }
@@ -31,7 +31,7 @@ gtk = { version = "0.15", features = [ "v3_20" ] }
3131

3232
[features]
3333
dox = [ "wry/dox" ]
34-
devtools = [ "wry/devtool", "tauri-runtime/devtools" ]
34+
devtools = [ "wry/devtools", "tauri-runtime/devtools" ]
3535
system-tray = [ "wry/tray", "tauri-runtime/system-tray" ]
3636
macos-private-api = [
3737
"wry/fullscreen",

core/tauri-runtime-wry/src/lib.rs

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tauri_runtime::{
99
Request as HttpRequest, RequestParts as HttpRequestParts, Response as HttpResponse,
1010
ResponseParts as HttpResponseParts,
1111
},
12-
menu::{CustomMenuItem, Menu, MenuEntry, MenuHash, MenuId, MenuItem, MenuUpdate},
12+
menu::{AboutMetadata, CustomMenuItem, Menu, MenuEntry, MenuHash, MenuId, MenuItem, MenuUpdate},
1313
monitor::Monitor,
1414
webview::{WebviewIpcHandler, WindowBuilder, WindowBuilderBase},
1515
window::{
@@ -55,8 +55,9 @@ use wry::{
5555
},
5656
global_shortcut::{GlobalShortcut, ShortcutManager as WryShortcutManager},
5757
menu::{
58-
CustomMenuItem as WryCustomMenuItem, MenuBar, MenuId as WryMenuId, MenuItem as WryMenuItem,
59-
MenuItemAttributes as WryMenuItemAttributes, MenuType,
58+
AboutMetadata as WryAboutMetadata, CustomMenuItem as WryCustomMenuItem, MenuBar,
59+
MenuId as WryMenuId, MenuItem as WryMenuItem, MenuItemAttributes as WryMenuItemAttributes,
60+
MenuType,
6061
},
6162
monitor::MonitorHandle,
6263
window::{Fullscreen, Icon as WryWindowIcon, UserAttentionType as WryUserAttentionType},
@@ -331,12 +332,31 @@ impl<'a> From<&'a CustomMenuItem> for MenuItemAttributesWrapper<'a> {
331332
}
332333
}
333334

335+
pub struct AboutMetadataWrapper(pub WryAboutMetadata);
336+
337+
impl From<AboutMetadata> for AboutMetadataWrapper {
338+
fn from(metadata: AboutMetadata) -> Self {
339+
Self(WryAboutMetadata {
340+
version: metadata.version,
341+
authors: metadata.authors,
342+
comments: metadata.comments,
343+
copyright: metadata.copyright,
344+
license: metadata.license,
345+
website: metadata.website,
346+
website_label: metadata.website_label,
347+
})
348+
}
349+
}
350+
334351
pub struct MenuItemWrapper(pub WryMenuItem);
335352

336353
impl From<MenuItem> for MenuItemWrapper {
337354
fn from(item: MenuItem) -> Self {
338355
match item {
339-
MenuItem::About(v) => Self(WryMenuItem::About(v)),
356+
MenuItem::About(name, metadata) => Self(WryMenuItem::About(
357+
name,
358+
AboutMetadataWrapper::from(metadata).0,
359+
)),
340360
MenuItem::Hide => Self(WryMenuItem::Hide),
341361
MenuItem::Services => Self(WryMenuItem::Services),
342362
MenuItem::HideOthers => Self(WryMenuItem::HideOthers),
@@ -1979,7 +1999,7 @@ fn handle_user_message<T: UserEvent>(
19791999
#[cfg(any(debug_assertions, feature = "devtools"))]
19802000
WindowMessage::OpenDevTools => {
19812001
if let WindowHandle::Webview(w) = &webview.inner {
1982-
w.devtool();
2002+
w.open_devtools();
19832003
}
19842004
}
19852005
// Getters
@@ -2731,7 +2751,7 @@ fn create_webview<T: UserEvent>(
27312751

27322752
#[cfg(any(debug_assertions, feature = "devtools"))]
27332753
{
2734-
webview_builder = webview_builder.with_dev_tool(true);
2754+
webview_builder = webview_builder.with_devtools(true);
27352755
}
27362756

27372757
let webview = webview_builder
@@ -2743,36 +2763,35 @@ fn create_webview<T: UserEvent>(
27432763

27442764
#[cfg(windows)]
27452765
{
2746-
if let Some(controller) = webview.controller() {
2747-
let proxy_ = proxy.clone();
2748-
let mut token = EventRegistrationToken::default();
2749-
unsafe {
2750-
controller.GotFocus(
2751-
FocusChangedEventHandler::create(Box::new(move |_, _| {
2752-
let _ = proxy_.send_event(Message::Webview(
2753-
window_id,
2754-
WebviewMessage::WebviewEvent(WebviewEvent::Focused(true)),
2755-
));
2756-
Ok(())
2757-
})),
2758-
&mut token,
2759-
)
2760-
}
2761-
.unwrap();
2762-
unsafe {
2763-
controller.LostFocus(
2764-
FocusChangedEventHandler::create(Box::new(move |_, _| {
2765-
let _ = proxy.send_event(Message::Webview(
2766-
window_id,
2767-
WebviewMessage::WebviewEvent(WebviewEvent::Focused(false)),
2768-
));
2769-
Ok(())
2770-
})),
2771-
&mut token,
2772-
)
2773-
}
2774-
.unwrap();
2766+
let controller = webview.controller();
2767+
let proxy_ = proxy.clone();
2768+
let mut token = EventRegistrationToken::default();
2769+
unsafe {
2770+
controller.GotFocus(
2771+
FocusChangedEventHandler::create(Box::new(move |_, _| {
2772+
let _ = proxy_.send_event(Message::Webview(
2773+
window_id,
2774+
WebviewMessage::WebviewEvent(WebviewEvent::Focused(true)),
2775+
));
2776+
Ok(())
2777+
})),
2778+
&mut token,
2779+
)
2780+
}
2781+
.unwrap();
2782+
unsafe {
2783+
controller.LostFocus(
2784+
FocusChangedEventHandler::create(Box::new(move |_, _| {
2785+
let _ = proxy.send_event(Message::Webview(
2786+
window_id,
2787+
WebviewMessage::WebviewEvent(WebviewEvent::Focused(false)),
2788+
));
2789+
Ok(())
2790+
})),
2791+
&mut token,
2792+
)
27752793
}
2794+
.unwrap();
27762795
}
27772796

27782797
Ok(WindowWrapper {

core/tauri-runtime/src/menu.rs

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,95 @@ impl From<Submenu> for MenuEntry {
396396
}
397397
}
398398

399+
/// Application metadata for the [`MenuItem::About`] action.
400+
///
401+
/// ## Platform-specific
402+
///
403+
/// - **Windows / macOS / Android / iOS:** The metadata is ignored on these platforms.
404+
#[derive(Debug, Clone, Default)]
405+
#[non_exhaustive]
406+
pub struct AboutMetadata {
407+
/// The application name.
408+
pub version: Option<String>,
409+
/// The authors of the application.
410+
pub authors: Option<Vec<String>>,
411+
/// Application comments.
412+
pub comments: Option<String>,
413+
/// The copyright of the application.
414+
pub copyright: Option<String>,
415+
/// The license of the application.
416+
pub license: Option<String>,
417+
/// The application website.
418+
pub website: Option<String>,
419+
/// The website label.
420+
pub website_label: Option<String>,
421+
}
422+
423+
impl AboutMetadata {
424+
/// Creates the default metadata for the [`MenuItem::About`] action, which is just empty.
425+
pub fn new() -> Self {
426+
Default::default()
427+
}
428+
429+
/// Defines the application version.
430+
pub fn version(mut self, version: String) -> Self {
431+
self.version.replace(version);
432+
self
433+
}
434+
435+
/// Defines the application authors.
436+
pub fn authors(mut self, authors: Vec<String>) -> Self {
437+
self.authors.replace(authors);
438+
self
439+
}
440+
441+
/// Defines the application comments.
442+
pub fn comments(mut self, comments: String) -> Self {
443+
self.comments.replace(comments);
444+
self
445+
}
446+
447+
/// Defines the application copyright.
448+
pub fn copyright(mut self, copyright: String) -> Self {
449+
self.copyright.replace(copyright);
450+
self
451+
}
452+
453+
/// Defines the application license.
454+
pub fn license(mut self, license: String) -> Self {
455+
self.license.replace(license);
456+
self
457+
}
458+
459+
/// Defines the application version.
460+
pub fn website(mut self, website: String) -> Self {
461+
self.website.replace(website);
462+
self
463+
}
464+
465+
/// Defines the application version.
466+
pub fn website_label(mut self, website_label: String) -> Self {
467+
self.website_label.replace(website_label);
468+
self
469+
}
470+
}
471+
399472
/// A menu item, bound to a pre-defined action or `Custom` emit an event. Note that status bar only
400473
/// supports `Custom` menu item variants. And on the menu bar, some platforms might not support some
401474
/// of the variants. Unsupported variant will be no-op on such platform.
402475
#[derive(Debug, Clone)]
403476
#[non_exhaustive]
404477
pub enum MenuItem {
405-
/// Shows a standard "About" item
478+
/// Shows a standard "About" item.
479+
///
480+
/// The first value is the application name, and the second is its metadata.
406481
///
407482
/// ## Platform-specific
408483
///
409484
/// - **Windows / Android / iOS:** Unsupported
485+
/// - **Linux:** The metadata is only applied on Linux
410486
///
411-
About(String),
487+
About(String, AboutMetadata),
412488

413489
/// A standard "hide the app" menu item.
414490
///

core/tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub use {
197197
pub use {
198198
self::app::WindowMenuEvent,
199199
self::event::{Event, EventHandler},
200-
self::runtime::menu::{CustomMenuItem, Menu, MenuEntry, MenuItem, Submenu},
200+
self::runtime::menu::{AboutMetadata, CustomMenuItem, Menu, MenuEntry, MenuItem, Submenu},
201201
self::window::menu::MenuEvent,
202202
};
203203
pub use {

0 commit comments

Comments
 (0)