mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
remove extra methods
This commit is contained in:
parent
41ccee209f
commit
12fa47f8f9
@ -13,7 +13,10 @@ use widget::Widget;
|
|||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
use crate::app::browser::window::action::Action as WindowAction;
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::glib::{GString, Propagation};
|
use gtk::{
|
||||||
|
glib::{GString, Propagation},
|
||||||
|
prelude::WidgetExt,
|
||||||
|
};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
||||||
|
|
||||||
@ -104,7 +107,7 @@ impl Tab {
|
|||||||
if let Some(id) = page.keyword() {
|
if let Some(id) = page.keyword() {
|
||||||
if let Some(item) = index.borrow().get(&id) {
|
if let Some(item) = index.borrow().get(&id) {
|
||||||
item.set_page_navigation_request_text(value.as_str());
|
item.set_page_navigation_request_text(value.as_str());
|
||||||
item.page_reload();
|
item.page().reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,7 +142,13 @@ impl Tab {
|
|||||||
// Register dynamically created tab components in the HashMap index
|
// Register dynamically created tab components in the HashMap index
|
||||||
self.index.borrow_mut().insert(item.id(), item.clone());
|
self.index.borrow_mut().insert(item.id(), item.clone());
|
||||||
|
|
||||||
item.page_navigation_request_grab_focus(); // @TODO
|
item.page()
|
||||||
|
.navigation()
|
||||||
|
.request()
|
||||||
|
.widget()
|
||||||
|
.gobject()
|
||||||
|
.grab_focus();
|
||||||
|
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +171,7 @@ impl Tab {
|
|||||||
if let Some(page) = self.widget.page(page_position) {
|
if let Some(page) = self.widget.page(page_position) {
|
||||||
if let Some(id) = page.keyword() {
|
if let Some(id) = page.keyword() {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
item.page_home();
|
item.page().home();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,7 +181,7 @@ impl Tab {
|
|||||||
if let Some(page) = self.widget.page(page_position) {
|
if let Some(page) = self.widget.page(page_position) {
|
||||||
if let Some(id) = page.keyword() {
|
if let Some(id) = page.keyword() {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
item.page_history_back();
|
item.page().history_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,7 +191,7 @@ impl Tab {
|
|||||||
if let Some(page) = self.widget.page(page_position) {
|
if let Some(page) = self.widget.page(page_position) {
|
||||||
if let Some(id) = page.keyword() {
|
if let Some(id) = page.keyword() {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
item.page_history_forward();
|
item.page().history_forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,7 +202,7 @@ impl Tab {
|
|||||||
if let Some(page) = self.widget.page(page_position) {
|
if let Some(page) = self.widget.page(page_position) {
|
||||||
if let Some(id) = page.keyword() {
|
if let Some(id) = page.keyword() {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
item.page_reload();
|
item.page().reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,10 @@ use crate::app::browser::action::Action as BrowserAction;
|
|||||||
use crate::app::browser::window::action::Action as WindowAction;
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use crate::app::browser::window::tab::action::Action as TabAction;
|
use crate::app::browser::window::tab::action::Action as TabAction;
|
||||||
use adw::{TabPage, TabView};
|
use adw::{TabPage, TabView};
|
||||||
use gtk::glib::{uuid_string_random, GString};
|
use gtk::{
|
||||||
|
glib::{uuid_string_random, GString},
|
||||||
|
prelude::EditableExt,
|
||||||
|
};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
@ -63,26 +66,6 @@ impl Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn page_home(&self) {
|
|
||||||
self.page.home()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn page_history_back(&self) {
|
|
||||||
self.page.history_back()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn page_history_forward(&self) {
|
|
||||||
self.page.history_forward()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn page_reload(&self) {
|
|
||||||
self.page.reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn page_navigation_request_grab_focus(&self) {
|
|
||||||
self.page.navigation_request_grab_focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
// Update child components
|
// Update child components
|
||||||
self.page.update();
|
self.page.update();
|
||||||
@ -188,14 +171,24 @@ impl Item {
|
|||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
pub fn set_page_navigation_request_text(&self, value: &str) {
|
pub fn set_page_navigation_request_text(&self, value: &str) {
|
||||||
self.page.set_navigation_request_text(value);
|
self.page
|
||||||
|
.navigation()
|
||||||
|
.request()
|
||||||
|
.widget()
|
||||||
|
.gobject()
|
||||||
|
.set_text(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
pub fn id(&self) -> GString {
|
pub fn id(&self) -> GString {
|
||||||
self.id.clone()
|
self.id.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn page(&self) -> &Rc<Page> {
|
||||||
|
&self.page
|
||||||
|
}
|
||||||
|
|
||||||
pub fn page_is_loading(&self) -> bool {
|
pub fn page_is_loading(&self) -> bool {
|
||||||
self.page.is_loading()
|
self.page.is_loading()
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ use gtk::{
|
|||||||
RegexMatchFlags, Uri, UriFlags, UriHideFlags,
|
RegexMatchFlags, Uri, UriFlags, UriHideFlags,
|
||||||
},
|
},
|
||||||
prelude::{
|
prelude::{
|
||||||
ActionExt, CancellableExt, IOStreamExt, OutputStreamExt, SocketClientExt, StaticVariantType,
|
ActionExt, CancellableExt, EditableExt, IOStreamExt, OutputStreamExt, SocketClientExt,
|
||||||
|
StaticVariantType,
|
||||||
},
|
},
|
||||||
Box,
|
Box,
|
||||||
};
|
};
|
||||||
@ -79,7 +80,7 @@ impl Page {
|
|||||||
let widget = Widget::new_rc(
|
let widget = Widget::new_rc(
|
||||||
&id,
|
&id,
|
||||||
action_page_open.clone(),
|
action_page_open.clone(),
|
||||||
navigation.gobject(),
|
navigation.widget().gobject(),
|
||||||
content.gobject(),
|
content.gobject(),
|
||||||
input.gobject(),
|
input.gobject(),
|
||||||
);
|
);
|
||||||
@ -114,7 +115,7 @@ impl Page {
|
|||||||
let this = this.clone();
|
let this = this.clone();
|
||||||
move |_, request| {
|
move |_, request| {
|
||||||
// Set request value from action parameter
|
// Set request value from action parameter
|
||||||
this.navigation.set_request_text(
|
this.navigation().request().widget().gobject().set_text(
|
||||||
&request
|
&request
|
||||||
.expect("Parameter required for this action")
|
.expect("Parameter required for this action")
|
||||||
.get::<String>()
|
.get::<String>()
|
||||||
@ -135,7 +136,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.open().activate(Some(&url));
|
self.tab_action.open().activate(Some(&url));
|
||||||
}
|
}
|
||||||
@ -144,9 +145,13 @@ 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.set_request_text(&request);
|
self.navigation
|
||||||
|
.request()
|
||||||
|
.widget()
|
||||||
|
.gobject()
|
||||||
|
.set_text(&request);
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -156,9 +161,13 @@ 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.set_request_text(&request);
|
self.navigation
|
||||||
|
.request()
|
||||||
|
.widget()
|
||||||
|
.gobject()
|
||||||
|
.set_text(&request);
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -213,7 +222,10 @@ 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
|
||||||
.set_request_text(redirect.request().as_str());
|
.request()
|
||||||
|
.widget()
|
||||||
|
.gobject()
|
||||||
|
.set_text(redirect.request().as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return value from redirection holder
|
// Return value from redirection holder
|
||||||
@ -223,18 +235,18 @@ 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_text()
|
self.navigation.request().widget().gobject().text()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add history record
|
// Add history record
|
||||||
if history {
|
if history {
|
||||||
match self.navigation.history_current() {
|
match self.navigation.history().current() {
|
||||||
Some(current) => {
|
Some(current) => {
|
||||||
if current != request {
|
if current != request {
|
||||||
self.navigation.history_add(request.clone());
|
self.navigation.history().add(request.clone(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => self.navigation.history_add(request.clone()),
|
None => self.navigation.history().add(request.clone(), true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +296,11 @@ impl Page {
|
|||||||
match Uri::parse(&request, UriFlags::NONE) {
|
match Uri::parse(&request, UriFlags::NONE) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Update navigation entry
|
// Update navigation entry
|
||||||
self.navigation.set_request_text(&request);
|
self.navigation
|
||||||
|
.request()
|
||||||
|
.widget()
|
||||||
|
.gobject()
|
||||||
|
.set_text(&request);
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -301,7 +317,11 @@ impl Page {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update navigation entry
|
// Update navigation entry
|
||||||
self.navigation.set_request_text(&request);
|
self.navigation
|
||||||
|
.request()
|
||||||
|
.widget()
|
||||||
|
.gobject()
|
||||||
|
.set_text(&request);
|
||||||
|
|
||||||
// Load page (without history record)
|
// Load page (without history record)
|
||||||
self.load(false);
|
self.load(false);
|
||||||
@ -385,16 +405,6 @@ impl Page {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn navigation_request_grab_focus(&self) {
|
|
||||||
self.navigation.request_grab_focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setters
|
|
||||||
|
|
||||||
pub fn set_navigation_request_text(&self, value: &str) {
|
|
||||||
self.navigation.set_request_text(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
pub fn progress_fraction(&self) -> Option<f64> {
|
pub fn progress_fraction(&self) -> Option<f64> {
|
||||||
@ -426,6 +436,15 @@ impl Page {
|
|||||||
self.meta.title()
|
self.meta.title()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
pub fn meta(&self) -> &Rc<Meta> {
|
||||||
|
&self.meta
|
||||||
|
} */
|
||||||
|
|
||||||
|
pub fn navigation(&self) -> &Rc<Navigation> {
|
||||||
|
&self.navigation
|
||||||
|
}
|
||||||
|
|
||||||
pub fn gobject(&self) -> &Box {
|
pub fn gobject(&self) -> &Box {
|
||||||
self.widget.gobject()
|
self.widget.gobject()
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use widget::Widget;
|
|||||||
|
|
||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
use crate::app::browser::window::action::Action as WindowAction;
|
use crate::app::browser::window::action::Action as WindowAction;
|
||||||
use gtk::{gio::SimpleAction, glib::GString, prelude::WidgetExt, Box};
|
use gtk::{gio::SimpleAction, prelude::EditableExt};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
@ -63,30 +63,12 @@ impl Navigation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn request_grab_focus(&self) {
|
|
||||||
self.request.gobject().grab_focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn history_add(&self, request: GString) {
|
|
||||||
self.history.add(request, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn history_back(&self, follow_to_index: bool) -> Option<GString> {
|
|
||||||
self.history.back(follow_to_index)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn history_current(&self) -> Option<GString> {
|
|
||||||
self.history.current()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn history_forward(&self, follow_to_index: bool) -> Option<GString> {
|
|
||||||
self.history.forward(follow_to_index)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update(&self, progress_fraction: Option<f64>) {
|
pub fn update(&self, progress_fraction: Option<f64>) {
|
||||||
self.home.update(self.request.uri());
|
self.home.update(self.request.uri());
|
||||||
self.history.update();
|
self.history.update();
|
||||||
self.reload.update(!self.request.text().is_empty());
|
self.reload
|
||||||
|
.update(!self.request.widget().gobject().text().is_empty());
|
||||||
self.request.update(progress_fraction);
|
self.request.update(progress_fraction);
|
||||||
self.bookmark.update();
|
self.bookmark.update();
|
||||||
}
|
}
|
||||||
@ -150,22 +132,32 @@ impl Navigation {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters
|
|
||||||
pub fn set_request_text(&self, value: &str) {
|
|
||||||
self.request.set_text(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn gobject(&self) -> &Box {
|
|
||||||
self.widget.gobject()
|
pub fn home(&self) -> &Rc<Home> {
|
||||||
|
&self.home
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn home_url(&self) -> Option<GString> {
|
pub fn history(&self) -> &Rc<History> {
|
||||||
self.home.url()
|
&self.history
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_text(&self) -> GString {
|
/*
|
||||||
self.request.text()
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ use widget::Widget;
|
|||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
glib::{GString, Uri, UriFlags},
|
glib::{Uri, UriFlags},
|
||||||
|
prelude::EditableExt,
|
||||||
Entry,
|
Entry,
|
||||||
};
|
};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
@ -94,22 +95,17 @@ impl Request {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters
|
|
||||||
pub fn set_text(&self, value: &str) {
|
|
||||||
self.widget.set_text(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn gobject(&self) -> &Entry {
|
pub fn gobject(&self) -> &Entry {
|
||||||
self.widget.gobject()
|
self.widget.gobject()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text(&self) -> GString {
|
pub fn widget(&self) -> &Rc<Widget> {
|
||||||
self.widget.text()
|
&self.widget
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uri(&self) -> Option<Uri> {
|
pub fn uri(&self) -> Option<Uri> {
|
||||||
match Uri::parse(&self.widget.text(), UriFlags::NONE) {
|
match Uri::parse(&self.widget.gobject().text(), UriFlags::NONE) {
|
||||||
Ok(uri) => Some(uri),
|
Ok(uri) => Some(uri),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use database::Database;
|
|||||||
use crate::app::browser::action::Action as BrowserAction;
|
use crate::app::browser::action::Action as BrowserAction;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
glib::{timeout_add_local, ControlFlow, GString, SourceId},
|
glib::{timeout_add_local, ControlFlow, SourceId},
|
||||||
prelude::{ActionExt, EditableExt, EntryExt, ToVariant, WidgetExt},
|
prelude::{ActionExt, EditableExt, EntryExt, ToVariant, WidgetExt},
|
||||||
Entry, StateFlags,
|
Entry, StateFlags,
|
||||||
};
|
};
|
||||||
@ -202,19 +202,11 @@ impl Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters
|
|
||||||
pub fn set_text(&self, value: &str) {
|
|
||||||
self.gobject.set_text(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
pub fn gobject(&self) -> &Entry {
|
pub fn gobject(&self) -> &Entry {
|
||||||
&self.gobject
|
&self.gobject
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text(&self) -> GString {
|
|
||||||
self.gobject.text()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
Loading…
x
Reference in New Issue
Block a user