integrate source view feature

This commit is contained in:
yggverse 2025-01-21 19:49:43 +02:00
parent 88457b3fa0
commit 96f2edddfb
2 changed files with 15 additions and 14 deletions

View File

@ -219,7 +219,7 @@ impl Tab {
pub fn save_as(&self, page_position: Option<i32>) { pub fn save_as(&self, page_position: Option<i32>) {
if let Some(item) = self.item(page_position) { if let Some(item) = self.item(page_position) {
item.page.navigation.request.to_download(); item.page.navigation.request.to_download();
todo!() self.window_action.reload.activate();
} }
} }
@ -227,7 +227,7 @@ impl Tab {
pub fn source(&self, page_position: Option<i32>) { pub fn source(&self, page_position: Option<i32>) {
if let Some(item) = self.item(page_position) { if let Some(item) = self.item(page_position) {
item.page.navigation.request.to_source(); item.page.navigation.request.to_source();
todo!() self.window_action.reload.activate();
} }
} }

View File

@ -74,7 +74,13 @@ impl Gemini {
// Actions // Actions
pub fn handle(&self, uri: Uri, feature: Feature, cancellable: Cancellable, is_history: bool) { pub fn handle(
&self,
uri: Uri,
feature: Feature,
cancellable: Cancellable,
is_snap_history: bool,
) {
// Move focus out from navigation entry // Move focus out from navigation entry
self.page self.page
.browser_action .browser_action
@ -101,7 +107,7 @@ impl Gemini {
self.tab_page.set_loading(true); self.tab_page.set_loading(true);
if is_history { if is_snap_history {
snap_history(&self.page, None); snap_history(&self.page, None);
} }
@ -232,16 +238,11 @@ impl Gemini {
cancellable.clone(), cancellable.clone(),
move |result| match result { move |result| match result {
Ok(text) => { Ok(text) => {
/* @TODO refactor features let widget = if matches!(feature, Feature::Source) {
let widget = if is_source_request { page.content.to_text_source(&text.to_string())
page.content.to_text_source(&data)
} else { } else {
page.content.to_text_gemini(&uri, &data) page.content.to_text_gemini(&uri, &text.to_string())
};*/ };
let widget = page
.content
.to_text_gemini(&uri, &text.to_string());
// Connect `TextView` widget, update `search` model // Connect `TextView` widget, update `search` model
page.search.set(Some(widget.text_view)); page.search.set(Some(widget.text_view));
@ -371,7 +372,7 @@ impl Gemini {
.set_text(&uri.to_string()); .set_text(&uri.to_string());
} }
redirects.replace(total); redirects.replace(total);
page.tab_action.load.activate(Some(&target.to_string()), is_history); page.tab_action.load.activate(Some(&target.to_string()), is_snap_history);
} }
} }
Err(e) => { Err(e) => {