diff --git a/src/app/browser/window/header/bar/menu.rs b/src/app/browser/window/header/bar/menu.rs index 162a11ae..868857fc 100644 --- a/src/app/browser/window/header/bar/menu.rs +++ b/src/app/browser/window/header/bar/menu.rs @@ -2,7 +2,7 @@ use super::{BrowserAction, Profile, WindowAction}; use gtk::{ gio::{self}, glib::{gformat, GString, Uri}, - prelude::{ActionExt, EditableExt, ToVariant}, + prelude::{ActionExt, ToVariant}, Align, MenuButton, }; use indexmap::IndexMap; @@ -210,7 +210,7 @@ impl Menu for MenuButton { // Recently closed history main_history_tab.remove_all(); for item in profile.history.memory.tab.recent() { - let item_request = item.page.navigation.request.text(); // @TODO restore entire `Item` + let item_request = item.page.navigation.request(); // @TODO restore entire `Item` let menu_item = gio::MenuItem::new(Some(&ellipsize(&item_request, LABEL_MAX_LENGTH)), None); menu_item.set_action_and_target_value(Some(&format!( "{}.{}", diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index 40be75aa..2cc5d540 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -12,7 +12,7 @@ use error::Error; use gtk::{ gio::Icon, glib::{DateTime, Propagation}, - prelude::{ActionExt, EditableExt}, + prelude::ActionExt, }; pub use item::Item; use menu::Menu; @@ -235,7 +235,7 @@ impl Tab { if let Some(item) = self.item(tab_page_position) { if let Some(home) = item.page.navigation.home() { let home = home.to_string(); - item.page.navigation.request.set_text(&home); + item.page.navigation.set_request(&home); item.client.handle(&home, true); } } diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index a3af7a4f..cae68073 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -10,7 +10,7 @@ use crate::Profile; use action::Action; use adw::TabView; use client::Client; -use gtk::prelude::{ActionMapExt, Cast, EditableExt}; +use gtk::prelude::{ActionMapExt, Cast}; use page::Page; use sqlite::Transaction; use std::rc::Rc; @@ -84,7 +84,7 @@ impl Item { this.set_enabled(false); if let Some(uri) = page.navigation.home() { let request = uri.to_string(); - page.navigation.request.set_text(&request); + page.navigation.set_request(&request); client.handle(&request, true); } } @@ -112,7 +112,7 @@ impl Item { let client = client.clone(); move |request, is_history| { if let Some(text) = request { - page.navigation.request.set_text(&text); + page.navigation.set_request(&text); client.handle(&text, is_history); } } @@ -122,13 +122,13 @@ impl Item { let page = page.clone(); let client = client.clone(); move |_, _| { - client.handle(&page.navigation.request.text(), false); + client.handle(&page.navigation.request(), false); } }); // Handle immediately on request if let Some(text) = request { - page.navigation.request.set_text(text); + page.navigation.set_request(text); if is_load { client.handle(text, true); } diff --git a/src/app/browser/window/tab/item/client.rs b/src/app/browser/window/tab/item/client.rs index 2253e88d..faa496ed 100644 --- a/src/app/browser/window/tab/item/client.rs +++ b/src/app/browser/window/tab/item/client.rs @@ -9,7 +9,7 @@ use feature::Feature; use gtk::{ gio::Cancellable, glib::{Uri, UriFlags}, - prelude::{ActionExt, CancellableExt, EntryExt}, + prelude::{ActionExt, CancellableExt}, }; use std::{cell::Cell, rc::Rc}; use subject::Subject; @@ -58,11 +58,7 @@ impl Client { self.subject.page.search.unset(); self.subject.page.input.unset(); self.subject.tab_page.set_title("Loading.."); - self.subject - .page - .navigation - .request - .set_progress_fraction(0.1); + self.subject.page.navigation.set_progress_fraction(0.1); self.subject.tab_page.set_loading(true); @@ -86,7 +82,7 @@ impl Client { "Scheme `{scheme}` yet not supported" ))); subject.tab_page.set_title(&status.title()); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); } }, diff --git a/src/app/browser/window/tab/item/client/driver/gemini.rs b/src/app/browser/window/tab/item/client/driver/gemini.rs index f87701c0..ef3a90c2 100644 --- a/src/app/browser/window/tab/item/client/driver/gemini.rs +++ b/src/app/browser/window/tab/item/client/driver/gemini.rs @@ -9,12 +9,9 @@ use gtk::{ gdk_pixbuf::Pixbuf, gio::{Cancellable, SocketClientEvent}, glib::{Priority, Uri}, - prelude::{EntryExt, SocketClientExt}, -}; -use gtk::{ - glib::Bytes, - prelude::{EditableExt, FileExt}, + prelude::SocketClientExt, }; +use gtk::{glib::Bytes, prelude::FileExt}; use std::{cell::Cell, path::MAIN_SEPARATOR, rc::Rc, time::Duration}; /// Multi-protocol client API for `Page` object @@ -59,7 +56,6 @@ impl Gemini { subject .page .navigation - .request .set_progress_fraction(progress_fraction); } }); @@ -129,11 +125,7 @@ impl Gemini { } }); self.subject.tab_page.set_title("Titan input"); - self.subject - .page - .navigation - .request - .set_progress_fraction(0.0); + self.subject.page.navigation.set_progress_fraction(0.0); self.subject.tab_page.set_loading(false); } _ => panic!(), // unexpected @@ -201,7 +193,7 @@ fn handle( Some(1024), ); } - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&title); redirects.replace(0); // reset @@ -273,7 +265,7 @@ fn handle( } }, ); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -296,7 +288,7 @@ fn handle( Some(title) => title.into(), // @TODO None => uri_to_title(&uri), }); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.page.window_action .find @@ -307,7 +299,7 @@ fn handle( Err(e) => { let status = subject.page.content.to_status_failure(); status.set_description(Some(&e.to_string())); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -351,7 +343,7 @@ fn handle( subject.tab_page.set_title(&status.title()); } } - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); redirects.replace(0); // reset }, @@ -360,7 +352,7 @@ fn handle( Err(e) => { let status = subject.page.content.to_status_failure(); status.set_description(Some(&e.to_string())); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -374,7 +366,7 @@ fn handle( .content .to_status_mime(mime, Some((&subject.page.item_action, &uri))); status.set_description(Some(&format!("Content type `{mime}` yet not supported"))); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -383,7 +375,7 @@ fn handle( None => { let status = subject.page.content.to_status_failure(); status.set_description(Some("MIME type not found")); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -421,7 +413,7 @@ fn handle( if total > 5 { let status = subject.page.content.to_status_failure(); status.set_description(Some("Redirection limit reached")); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -432,7 +424,7 @@ fn handle( || uri.host() != target.host() { let status = subject.page.content.to_status_failure(); status.set_description(Some("External redirects not allowed by protocol specification")); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -440,8 +432,7 @@ fn handle( } else { if matches!(response.meta.status, Status::PermanentRedirect) { subject.page.navigation - .request - .set_text(&uri.to_string()); + .set_request(&uri.to_string()); } redirects.replace(total); subject.page.item_action.load.activate(Some(&target.to_string()), false); @@ -450,7 +441,7 @@ fn handle( Err(e) => { let status = subject.page.content.to_status_failure(); status.set_description(Some(&e.to_string())); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -459,7 +450,7 @@ fn handle( None => { let status = subject.page.content.to_status_failure(); status.set_description(Some("Redirection target not found")); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -478,7 +469,7 @@ fn handle( None => response.meta.status.to_string(), })); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -486,7 +477,7 @@ fn handle( error => { let status = subject.page.content.to_status_failure(); status.set_description(Some(&error.to_string())); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset @@ -496,7 +487,7 @@ fn handle( Err(e) => { let status = subject.page.content.to_status_failure(); status.set_description(Some(&e.to_string())); - subject.page.navigation.request.set_progress_fraction(0.0); + subject.page.navigation.set_progress_fraction(0.0); subject.tab_page.set_loading(false); subject.tab_page.set_title(&status.title()); redirects.replace(0); // reset diff --git a/src/app/browser/window/tab/item/page/navigation.rs b/src/app/browser/window/tab/item/page/navigation.rs index d4460049..9ce67044 100644 --- a/src/app/browser/window/tab/item/page/navigation.rs +++ b/src/app/browser/window/tab/item/page/navigation.rs @@ -9,7 +9,7 @@ use super::{ItemAction, Profile, TabAction, WindowAction}; use bookmark::Bookmark; use gtk::{ glib::{GString, Uri}, - prelude::{BoxExt, EditableExt, WidgetExt}, + prelude::{BoxExt, EditableExt, EntryExt, WidgetExt}, Box, Button, Entry, Orientation, }; use history::History; @@ -23,10 +23,10 @@ const MARGIN: i32 = 6; const SPACING: i32 = 6; pub struct Navigation { - pub home: Button, - pub reload: Button, - pub bookmark: Button, - pub request: Entry, + //home: Button, + //reload: Button, + //bookmark: Button, + request: Entry, pub g_box: Box, } @@ -62,10 +62,10 @@ impl Navigation { g_box.append(&bookmark); Self { - home, + //home, request, - reload, - bookmark, + //reload, + //bookmark, g_box, } } @@ -135,6 +135,16 @@ impl Navigation { self.request.grab_focus() } + // Setters + + pub fn set_request(&self, value: &str) { + self.request.set_text(value); + } + + pub fn set_progress_fraction(&self, fraction: f64) { + self.request.set_progress_fraction(fraction); + } + pub fn to_download(&self) { self.request.to_download(); }