From 2a9564bec6a308bf4af44894dd7342292368ae69 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 25 Oct 2024 18:16:15 +0300 Subject: [PATCH] fix external links handler on middle click --- .../item/page/content/text/gemini/reader.rs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs index f7d6db7b..2fb6cacd 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs @@ -264,7 +264,7 @@ impl Reader { } }, ), - }; + }; // @TODO common handler? } } } @@ -285,7 +285,24 @@ impl Reader { for tag in iter.tags() { // Tag is link if let Some(uri) = _links_.get(&tag) { - return action_tab_open.activate(Some(&uri.to_string().to_variant())); + // Select link handler by scheme + return match uri.scheme().as_str() { + "gemini" => { + // Open new page in browser + action_tab_open.activate(Some(&uri.to_string().to_variant())); + } + // Scheme not supported, delegate + _ => UriLauncher::new(&uri.to_str()).launch( + None::<&Window>, + None::<&Cancellable>, + |result| { + if let Err(error) = result { + // @TODO + println!("Could not delegate launch action: {error}") + } + }, + ), + }; // @TODO common handler? } } }