mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
remove extra getters
This commit is contained in:
parent
649d8f92f6
commit
3ce272cd70
@ -137,12 +137,7 @@ impl Tab {
|
|||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(item.id.clone(), item.clone());
|
.insert(item.id.clone(), item.clone());
|
||||||
|
|
||||||
item.page
|
item.page.navigation.request.widget.entry.grab_focus();
|
||||||
.navigation
|
|
||||||
.request()
|
|
||||||
.widget()
|
|
||||||
.gobject()
|
|
||||||
.grab_focus();
|
|
||||||
|
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ impl Item {
|
|||||||
// Init events
|
// Init events
|
||||||
|
|
||||||
if let Some(text) = request {
|
if let Some(text) = request {
|
||||||
page.navigation.request().widget().gobject().set_text(&text);
|
page.navigation.request.widget.entry.set_text(&text);
|
||||||
|
|
||||||
if is_load {
|
if is_load {
|
||||||
page.load(true);
|
page.load(true);
|
||||||
@ -79,7 +79,7 @@ impl Item {
|
|||||||
let parent = tab_view.clone().upcast::<gtk::Widget>();
|
let parent = tab_view.clone().upcast::<gtk::Widget>();
|
||||||
move || {
|
move || {
|
||||||
// Request should match valid URI for all drivers supported
|
// Request should match valid URI for all drivers supported
|
||||||
if let Some(uri) = page.navigation.request().uri() {
|
if let Some(uri) = page.navigation.request.uri() {
|
||||||
// Rout by scheme
|
// Rout by scheme
|
||||||
if uri.scheme().to_lowercase() == "gemini" {
|
if uri.scheme().to_lowercase() == "gemini" {
|
||||||
return identity::new_gemini(profile.clone(), actions.1.clone(), uri)
|
return identity::new_gemini(profile.clone(), actions.1.clone(), uri)
|
||||||
@ -96,7 +96,7 @@ impl Item {
|
|||||||
let page = page.clone();
|
let page = page.clone();
|
||||||
move |request, is_history| {
|
move |request, is_history| {
|
||||||
if let Some(text) = request {
|
if let Some(text) = request {
|
||||||
page.navigation.request().widget().gobject().set_text(&text);
|
page.navigation.request.widget.entry.set_text(&text);
|
||||||
}
|
}
|
||||||
page.load(is_history);
|
page.load(is_history);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ impl Page {
|
|||||||
|
|
||||||
let widget = Rc::new(Widget::new(
|
let widget = Rc::new(Widget::new(
|
||||||
&id,
|
&id,
|
||||||
navigation.widget().gobject(),
|
&navigation.widget.gobject,
|
||||||
content.gobject(),
|
content.gobject(),
|
||||||
input.gobject(),
|
input.gobject(),
|
||||||
));
|
));
|
||||||
@ -102,7 +102,7 @@ impl Page {
|
|||||||
let result = match self
|
let result = match self
|
||||||
.profile
|
.profile
|
||||||
.bookmark
|
.bookmark
|
||||||
.toggle(self.navigation.request().widget().gobject().text().as_str())
|
.toggle(self.navigation.request.widget.entry.text().as_str())
|
||||||
{
|
{
|
||||||
Ok(result) => Ok(result),
|
Ok(result) => Ok(result),
|
||||||
Err(_) => Err(Error::Bookmark), // @TODO
|
Err(_) => Err(Error::Bookmark), // @TODO
|
||||||
@ -114,7 +114,7 @@ impl Page {
|
|||||||
/// Navigate home URL (parsed from current navigation entry)
|
/// Navigate home URL (parsed from current navigation entry)
|
||||||
/// * this method create new history record in memory as defined in `action_page_open` action
|
/// * this method create new history record in memory as defined in `action_page_open` action
|
||||||
pub fn home(&self) {
|
pub fn home(&self) {
|
||||||
if let Some(url) = self.navigation.home().url() {
|
if let Some(url) = self.navigation.home.url() {
|
||||||
// Update with history record
|
// Update with history record
|
||||||
self.tab_action.load().activate(Some(&url), true);
|
self.tab_action.load().activate(Some(&url), true);
|
||||||
}
|
}
|
||||||
@ -123,13 +123,9 @@ impl Page {
|
|||||||
/// Navigate back in history
|
/// Navigate back in history
|
||||||
/// * this method does not create new history record in memory
|
/// * this method does not create new history record in memory
|
||||||
pub fn history_back(&self) {
|
pub fn history_back(&self) {
|
||||||
if let Some(request) = self.navigation.history().back(true) {
|
if let Some(request) = self.navigation.history.back(true) {
|
||||||
// Update navigation entry
|
// Update navigation entry
|
||||||
self.navigation
|
self.navigation.request.widget.entry.set_text(&request);
|
||||||
.request()
|
|
||||||
.widget()
|
|
||||||
.gobject()
|
|
||||||
.set_text(&request);
|
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -139,13 +135,9 @@ impl Page {
|
|||||||
/// Navigate forward in history
|
/// Navigate forward in history
|
||||||
/// * this method does not create new history record in memory
|
/// * this method does not create new history record in memory
|
||||||
pub fn history_forward(&self) {
|
pub fn history_forward(&self) {
|
||||||
if let Some(request) = self.navigation.history().forward(true) {
|
if let Some(request) = self.navigation.history.forward(true) {
|
||||||
// Update navigation entry
|
// Update navigation entry
|
||||||
self.navigation
|
self.navigation.request.widget.entry.set_text(&request);
|
||||||
.request()
|
|
||||||
.widget()
|
|
||||||
.gobject()
|
|
||||||
.set_text(&request);
|
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -200,9 +192,9 @@ impl Page {
|
|||||||
// Update navigation on redirect `is_foreground`
|
// Update navigation on redirect `is_foreground`
|
||||||
if redirect.is_foreground() {
|
if redirect.is_foreground() {
|
||||||
self.navigation
|
self.navigation
|
||||||
.request()
|
.request
|
||||||
.widget()
|
.widget
|
||||||
.gobject()
|
.entry
|
||||||
.set_text(redirect.request().as_str());
|
.set_text(redirect.request().as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +205,7 @@ impl Page {
|
|||||||
self.meta.unset_redirect_count();
|
self.meta.unset_redirect_count();
|
||||||
|
|
||||||
// Return value from navigation entry
|
// Return value from navigation entry
|
||||||
self.navigation.request().widget().gobject().text()
|
self.navigation.request.widget.entry.text()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
@ -267,11 +259,7 @@ impl Page {
|
|||||||
match Uri::parse(&request, UriFlags::NONE) {
|
match Uri::parse(&request, UriFlags::NONE) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Update navigation entry
|
// Update navigation entry
|
||||||
self.navigation
|
self.navigation.request.widget.entry.set_text(&request);
|
||||||
.request()
|
|
||||||
.widget()
|
|
||||||
.gobject()
|
|
||||||
.set_text(&request);
|
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -288,11 +276,7 @@ impl Page {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update navigation entry
|
// Update navigation entry
|
||||||
self.navigation
|
self.navigation.request.widget.entry.set_text(&request);
|
||||||
.request()
|
|
||||||
.widget()
|
|
||||||
.gobject()
|
|
||||||
.set_text(&request);
|
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -422,7 +406,7 @@ impl Page {
|
|||||||
.profile
|
.profile
|
||||||
.identity
|
.identity
|
||||||
.gemini
|
.gemini
|
||||||
.match_priority(&self.navigation.request().widget().gobject().text())
|
.match_priority(&self.navigation.request.widget.entry.text())
|
||||||
{
|
{
|
||||||
Some(identity) => {
|
Some(identity) => {
|
||||||
match gemini::client::Certificate::from_pem(&identity.pem, &identity.scope) {
|
match gemini::client::Certificate::from_pem(&identity.pem, &identity.scope) {
|
||||||
@ -929,14 +913,14 @@ fn is_external_uri(subject: &Uri, base: &Uri) -> bool {
|
|||||||
/// Make new history record for given `navigation` object
|
/// Make new history record for given `navigation` object
|
||||||
/// * applies on shared conditions match only
|
/// * applies on shared conditions match only
|
||||||
fn snap_history(navigation: Rc<Navigation>) {
|
fn snap_history(navigation: Rc<Navigation>) {
|
||||||
let request = navigation.request().widget().gobject().text();
|
let request = navigation.request.widget.entry.text();
|
||||||
|
|
||||||
// Apply additional filters
|
// Apply additional filters
|
||||||
if match navigation.history().current() {
|
if match navigation.history.current() {
|
||||||
Some(current) => current != request,
|
Some(current) => current != request,
|
||||||
None => true,
|
None => true,
|
||||||
} {
|
} {
|
||||||
// Add new record match conditions
|
// Add new record match conditions
|
||||||
navigation.history().add(request, true)
|
navigation.history.add(request, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,14 @@ use sqlite::Transaction;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Navigation {
|
pub struct Navigation {
|
||||||
bookmark: Rc<Bookmark>,
|
pub bookmark: Rc<Bookmark>,
|
||||||
history: Rc<History>,
|
pub history: Rc<History>,
|
||||||
home: Rc<Home>,
|
pub home: Rc<Home>,
|
||||||
identity: Rc<Identity>,
|
pub identity: Rc<Identity>,
|
||||||
profile: Rc<Profile>,
|
pub profile: Rc<Profile>,
|
||||||
reload: Rc<Reload>,
|
pub reload: Rc<Reload>,
|
||||||
request: Rc<Request>,
|
pub request: Rc<Request>,
|
||||||
widget: Rc<Widget>,
|
pub widget: Rc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Navigation {
|
impl Navigation {
|
||||||
@ -53,7 +53,7 @@ impl Navigation {
|
|||||||
home.widget().gobject(),
|
home.widget().gobject(),
|
||||||
history.widget().gobject(),
|
history.widget().gobject(),
|
||||||
reload.widget().gobject(),
|
reload.widget().gobject(),
|
||||||
request.widget().gobject(),
|
&request.widget.entry, // @TODO remove extra getters from other components
|
||||||
bookmark.widget().gobject(),
|
bookmark.widget().gobject(),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ impl Navigation {
|
|||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
pub fn update(&self, progress_fraction: Option<f64>) {
|
pub fn update(&self, progress_fraction: Option<f64>) {
|
||||||
let request_text = self.request.widget().gobject().text();
|
let request_text = self.request.widget.entry.text();
|
||||||
|
|
||||||
self.identity.update(
|
self.identity.update(
|
||||||
self.profile
|
self.profile
|
||||||
@ -151,34 +151,6 @@ impl Navigation {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
|
||||||
|
|
||||||
pub fn home(&self) -> &Rc<Home> {
|
|
||||||
&self.home
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn history(&self) -> &Rc<History> {
|
|
||||||
&self.history
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
pub fn reload(&self) -> &Rc<Reload> {
|
|
||||||
&self.reload
|
|
||||||
} */
|
|
||||||
|
|
||||||
pub fn request(&self) -> &Rc<Request> {
|
|
||||||
&self.request
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
pub fn bookmark(&self) -> &Rc<Bookmark> {
|
|
||||||
&self.bookmark
|
|
||||||
} */
|
|
||||||
|
|
||||||
pub fn widget(&self) -> &Rc<Widget> {
|
|
||||||
&self.widget
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
@ -13,7 +13,7 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
// Main
|
// Main
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
widget: Rc<Widget>,
|
pub widget: Rc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
@ -90,12 +90,8 @@ impl Request {
|
|||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
pub fn widget(&self) -> &Rc<Widget> {
|
|
||||||
&self.widget
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn uri(&self) -> Option<Uri> {
|
pub fn uri(&self) -> Option<Uri> {
|
||||||
match Uri::parse(&self.widget.gobject().text(), UriFlags::NONE) {
|
match Uri::parse(&self.widget.entry.text(), UriFlags::NONE) {
|
||||||
Ok(uri) => Some(uri),
|
Ok(uri) => Some(uri),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ struct Progress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Widget {
|
pub struct Widget {
|
||||||
gobject: Entry,
|
pub entry: Entry,
|
||||||
progress: Rc<Progress>,
|
progress: Rc<Progress>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,21 +35,21 @@ impl Widget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
let gobject = Entry::builder()
|
let entry = Entry::builder()
|
||||||
.placeholder_text(PLACEHOLDER_TEXT)
|
.placeholder_text(PLACEHOLDER_TEXT)
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
gobject.connect_changed(move |_| {
|
entry.connect_changed(move |_| {
|
||||||
action.0.update().activate(None);
|
action.0.update().activate(None);
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_activate(move |this| {
|
entry.connect_activate(move |this| {
|
||||||
action.1.load().activate(Some(&this.text()), true);
|
action.1.load().activate(Some(&this.text()), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_state_flags_changed({
|
entry.connect_state_flags_changed({
|
||||||
// Define last focus state container
|
// Define last focus state container
|
||||||
let has_focus = RefCell::new(false);
|
let has_focus = RefCell::new(false);
|
||||||
move |this, state| {
|
move |this, state| {
|
||||||
@ -71,7 +71,7 @@ impl Widget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Return activated `Self`
|
// Return activated `Self`
|
||||||
Self { gobject, progress }
|
Self { entry, progress }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
@ -113,7 +113,7 @@ impl Widget {
|
|||||||
Ok(records) => {
|
Ok(records) => {
|
||||||
for record in records {
|
for record in records {
|
||||||
if let Some(text) = record.text {
|
if let Some(text) = record.text {
|
||||||
self.gobject.set_text(&text);
|
self.entry.set_text(&text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate restore action to the item childs
|
// Delegate restore action to the item childs
|
||||||
@ -132,7 +132,7 @@ impl Widget {
|
|||||||
app_browser_window_tab_item_page_navigation_request_id: &i64,
|
app_browser_window_tab_item_page_navigation_request_id: &i64,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
// Keep value in memory until operation complete
|
// Keep value in memory until operation complete
|
||||||
let text = self.gobject.text();
|
let text = self.entry.text();
|
||||||
|
|
||||||
match database::insert(
|
match database::insert(
|
||||||
transaction,
|
transaction,
|
||||||
@ -167,16 +167,16 @@ impl Widget {
|
|||||||
Duration::from_millis(PROGRESS_ANIMATION_TIME),
|
Duration::from_millis(PROGRESS_ANIMATION_TIME),
|
||||||
{
|
{
|
||||||
// Clone async pointers dependency
|
// Clone async pointers dependency
|
||||||
let gobject = self.gobject.clone();
|
let entry = self.entry.clone();
|
||||||
let progress = self.progress.clone();
|
let progress = self.progress.clone();
|
||||||
|
|
||||||
// Frame
|
// Frame
|
||||||
move || {
|
move || {
|
||||||
// Animate
|
// Animate
|
||||||
if *progress.fraction.borrow() > gobject.progress_fraction() {
|
if *progress.fraction.borrow() > entry.progress_fraction() {
|
||||||
gobject.set_progress_fraction(
|
entry.set_progress_fraction(
|
||||||
// Currently, here is no outrange validation, seems that wrapper make this work @TODO
|
// Currently, here is no outrange validation, seems that wrapper make this work @TODO
|
||||||
gobject.progress_fraction() + PROGRESS_ANIMATION_STEP,
|
entry.progress_fraction() + PROGRESS_ANIMATION_STEP,
|
||||||
);
|
);
|
||||||
return ControlFlow::Continue;
|
return ControlFlow::Continue;
|
||||||
}
|
}
|
||||||
@ -185,8 +185,8 @@ impl Widget {
|
|||||||
|
|
||||||
// Reset on 100% (to hide progress bar)
|
// Reset on 100% (to hide progress bar)
|
||||||
// or, just await for new value request
|
// or, just await for new value request
|
||||||
if gobject.progress_fraction() == 1.0 {
|
if entry.progress_fraction() == 1.0 {
|
||||||
gobject.set_progress_fraction(0.0);
|
entry.set_progress_fraction(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop iteration
|
// Stop iteration
|
||||||
@ -198,12 +198,6 @@ impl Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
|
||||||
|
|
||||||
pub fn gobject(&self) -> &Entry {
|
|
||||||
&self.gobject
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
@ -7,7 +7,7 @@ const MARGIN: i32 = 6;
|
|||||||
const SPACING: i32 = 6;
|
const SPACING: i32 = 6;
|
||||||
|
|
||||||
pub struct Widget {
|
pub struct Widget {
|
||||||
gobject: Box,
|
pub gobject: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
@ -37,9 +37,4 @@ impl Widget {
|
|||||||
|
|
||||||
Self { gobject }
|
Self { gobject }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
|
||||||
pub fn gobject(&self) -> &Box {
|
|
||||||
&self.gobject
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user