(&self, app: AppHandle, preference: State<PreferenceConfig>)
| 74 | |
| 75 | #[tracing::instrument(level = "debug", skip(self, app, preference))] |
| 76 | pub fn update_zoom(&self, app: AppHandle, preference: State<PreferenceConfig>) -> Result<()> { |
| 77 | let scale_factor: f64 = preference.load_selective("zoomFactor".into())?; |
| 78 | let windows = app.webview_windows(); |
| 79 | for window in windows.values() { |
| 80 | window.with_webview(move |webview| { |
| 81 | #[cfg(target_os = "linux")] |
| 82 | { |
| 83 | // see https://docs.rs/webkit2gtk/0.18.2/webkit2gtk/struct.WebView.html |
| 84 | // and https://docs.rs/webkit2gtk/0.18.2/webkit2gtk/trait.WebViewExt.html |
| 85 | use webkit2gtk::WebViewExt; |
| 86 | webview.inner().set_zoom_level(scale_factor); |
| 87 | } |
| 88 | |
| 89 | #[cfg(windows)] |
| 90 | unsafe { |
| 91 | // see https://docs.rs/webview2-com/0.19.1/webview2_com/Microsoft/Web/WebView2/Win32/struct.ICoreWebView2Controller.html |
| 92 | webview.controller().SetZoomFactor(scale_factor).unwrap(); |
| 93 | } |
| 94 | |
| 95 | // #[cfg(target_os = "macos")] |
| 96 | // unsafe { |
| 97 | // use objc::{sel, sel_impl}; |
| 98 | // let () = objc::msg_send![webview.inner(), setPageZoom: scale_factor]; |
| 99 | // } |
| 100 | })?; |
| 101 | } |
| 102 | |
| 103 | Ok(()) |
| 104 | } |
| 105 | |
| 106 | #[tracing::instrument(level = "debug", skip(self, url))] |
| 107 | pub fn open_external(&self, app: AppHandle, url: String) -> Result<()> { |
nothing calls this directly
no test coverage detected