mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
delegate non-supported links handler to the external app
This commit is contained in:
parent
918838fe96
commit
bb9ddda109
@ -10,7 +10,7 @@ use widget::Widget;
|
||||
use adw::StyleManager;
|
||||
use gtk::{
|
||||
gdk::{BUTTON_MIDDLE, BUTTON_PRIMARY},
|
||||
gio::SimpleAction,
|
||||
gio::{AppInfo, AppLaunchContext, SimpleAction},
|
||||
glib::{GString, TimeZone, Uri},
|
||||
pango::Style,
|
||||
prelude::{ActionExt, TextBufferExt, TextBufferExtManual, TextViewExt, ToVariant, WidgetExt},
|
||||
@ -216,13 +216,20 @@ impl Reader {
|
||||
for tag in iter.tags() {
|
||||
// Tag is link
|
||||
if let Some(uri) = _links_.get(&tag) {
|
||||
// Select handler by scheme
|
||||
// Select link handler by scheme
|
||||
return match uri.scheme().as_str() {
|
||||
"gemini" => {
|
||||
// Open new page
|
||||
// Open new page in browser
|
||||
action_page_open.activate(Some(&uri.to_str().to_variant()));
|
||||
}
|
||||
_ => (), // Protocol not supported, delegate to the external app @TODO
|
||||
// Scheme not supported, delegate link to the external app
|
||||
_ => match AppInfo::launch_default_for_uri(
|
||||
&uri.to_str(),
|
||||
Some(&AppLaunchContext::new()),
|
||||
) {
|
||||
Ok(_) => (),
|
||||
Err(e) => todo!("{e}"),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user