mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
connect bookmark action
This commit is contained in:
parent
7b9bd95c09
commit
d0a7c3079d
12 changed files with 76 additions and 64 deletions
|
|
@ -15,6 +15,7 @@ use crate::app::browser::{
|
|||
window::{tab::item::Action as TabAction, Action as WindowAction},
|
||||
Action as BrowserAction,
|
||||
};
|
||||
use crate::Profile;
|
||||
use gtk::{
|
||||
gdk_pixbuf::Pixbuf,
|
||||
gio::{Cancellable, SocketClient, SocketClientEvent, SocketProtocol, TlsCertificateFlags},
|
||||
|
|
@ -44,15 +45,18 @@ pub struct Page {
|
|||
impl Page {
|
||||
// Constructors
|
||||
|
||||
pub fn new(id: GString, action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>)) -> Self {
|
||||
pub fn new(
|
||||
id: GString,
|
||||
profile: Rc<Profile>,
|
||||
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>),
|
||||
) -> Self {
|
||||
// Init components
|
||||
let content = Rc::new(Content::new((action.1.clone(), action.2.clone())));
|
||||
|
||||
let navigation = Rc::new(Navigation::new((
|
||||
action.0.clone(),
|
||||
action.1.clone(),
|
||||
action.2.clone(),
|
||||
)));
|
||||
let navigation = Rc::new(Navigation::new(
|
||||
profile,
|
||||
(action.0.clone(), action.1.clone(), action.2.clone()),
|
||||
));
|
||||
|
||||
let input = Rc::new(Input::new());
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ use widget::Widget;
|
|||
use crate::app::browser::window::tab::item::Action as TabAction;
|
||||
use crate::app::browser::window::Action as WindowAction;
|
||||
use crate::app::browser::Action as BrowserAction;
|
||||
use crate::Profile;
|
||||
use gtk::prelude::EditableExt;
|
||||
use sqlite::Transaction;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Navigation {
|
||||
profile: Rc<Profile>,
|
||||
bookmark: Rc<Bookmark>,
|
||||
history: Rc<History>,
|
||||
home: Rc<Home>,
|
||||
|
|
@ -30,7 +32,10 @@ pub struct Navigation {
|
|||
}
|
||||
|
||||
impl Navigation {
|
||||
pub fn new(action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>)) -> Self {
|
||||
pub fn new(
|
||||
profile: Rc<Profile>,
|
||||
action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>),
|
||||
) -> Self {
|
||||
// Init components
|
||||
let home = Rc::new(Home::new(action.1.clone()));
|
||||
let history = Rc::new(History::new(action.1.clone()));
|
||||
|
|
@ -49,6 +54,7 @@ impl Navigation {
|
|||
|
||||
// Done
|
||||
Self {
|
||||
profile,
|
||||
bookmark,
|
||||
history,
|
||||
home,
|
||||
|
|
@ -61,11 +67,13 @@ impl Navigation {
|
|||
// Actions
|
||||
|
||||
pub fn update(&self, progress_fraction: Option<f64>) {
|
||||
self.bookmark.update(false); // @TODO DB from request
|
||||
let request = self.request.widget().gobject().text();
|
||||
|
||||
self.bookmark
|
||||
.update(!self.profile.bookmark.has_request(&request, true));
|
||||
self.history.update();
|
||||
self.home.update(self.request.uri());
|
||||
self.reload
|
||||
.update(!self.request.widget().gobject().text().is_empty());
|
||||
self.reload.update(!request.is_empty());
|
||||
self.request.update(progress_fraction);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,26 +6,23 @@ use crate::app::browser::window::action::Action as WindowAction;
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Bookmark {
|
||||
window_action: Rc<WindowAction>,
|
||||
action: Rc<WindowAction>,
|
||||
widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
// Construct
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(window_action.clone())),
|
||||
window_action,
|
||||
widget: Rc::new(Widget::new(action.clone())),
|
||||
action,
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, is_enabled: bool) {
|
||||
// Update actions
|
||||
self.window_action
|
||||
.bookmark()
|
||||
.gobject()
|
||||
.set_enabled(is_enabled);
|
||||
self.action.bookmark().gobject().set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub struct Widget {
|
|||
impl Widget {
|
||||
// Constructors
|
||||
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
.icon_name("starred-symbolic")
|
||||
|
|
@ -22,7 +22,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| window_action.home().activate());
|
||||
gobject.connect_clicked(move |_| action.home().activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
|
|||
|
|
@ -7,18 +7,18 @@ use gtk::glib::{gformat, GString, Uri};
|
|||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub struct Home {
|
||||
window_action: Rc<WindowAction>,
|
||||
action: Rc<WindowAction>,
|
||||
uri: RefCell<Option<Uri>>,
|
||||
widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Home {
|
||||
// Construct
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
window_action: window_action.clone(),
|
||||
action: action.clone(),
|
||||
uri: RefCell::new(None),
|
||||
widget: Rc::new(Widget::new(window_action)),
|
||||
widget: Rc::new(Widget::new(action)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ impl Home {
|
|||
self.uri.replace(uri);
|
||||
|
||||
// Update action status
|
||||
self.window_action.home().gobject().set_enabled(status);
|
||||
self.action.home().gobject().set_enabled(status);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(status);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
.icon_name("go-home-symbolic")
|
||||
|
|
@ -20,7 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| window_action.home().activate());
|
||||
gobject.connect_clicked(move |_| action.home().activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ use crate::app::browser::window::action::Action as WindowAction;
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Reload {
|
||||
window_action: Rc<WindowAction>,
|
||||
action: Rc<WindowAction>,
|
||||
widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
// Construct
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
window_action: window_action.clone(),
|
||||
widget: Rc::new(Widget::new(window_action)),
|
||||
action: action.clone(),
|
||||
widget: Rc::new(Widget::new(action)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -23,10 +23,7 @@ impl Reload {
|
|||
|
||||
pub fn update(&self, is_enabled: bool) {
|
||||
// Update actions
|
||||
self.window_action
|
||||
.reload()
|
||||
.gobject()
|
||||
.set_enabled(is_enabled);
|
||||
self.action.reload().gobject().set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
|
|
@ -20,7 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| window_action.reload().activate());
|
||||
gobject.connect_clicked(move |_| action.reload().activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue