mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
use tuple for actions
This commit is contained in:
parent
b70a5a7867
commit
61010e0a42
@ -50,9 +50,7 @@ impl Item {
|
|||||||
|
|
||||||
let page = Rc::new(Page::new(
|
let page = Rc::new(Page::new(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
browser_action,
|
(browser_action, window_action, action.clone()),
|
||||||
window_action,
|
|
||||||
action.clone(),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
let widget = Rc::new(Widget::new(
|
let widget = Rc::new(Widget::new(
|
||||||
|
@ -44,20 +44,15 @@ pub struct Page {
|
|||||||
impl Page {
|
impl Page {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(id: GString, action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>)) -> Self {
|
||||||
id: GString,
|
|
||||||
browser_action: Rc<BrowserAction>,
|
|
||||||
window_action: Rc<WindowAction>,
|
|
||||||
tab_action: Rc<TabAction>,
|
|
||||||
) -> Self {
|
|
||||||
// Init components
|
// Init components
|
||||||
let content = Rc::new(Content::new(window_action.clone(), tab_action.clone()));
|
let content = Rc::new(Content::new((action.1.clone(), action.2.clone())));
|
||||||
|
|
||||||
let navigation = Rc::new(Navigation::new(
|
let navigation = Rc::new(Navigation::new((
|
||||||
browser_action.clone(),
|
action.0.clone(),
|
||||||
window_action.clone(),
|
action.1.clone(),
|
||||||
tab_action.clone(),
|
action.2.clone(),
|
||||||
));
|
)));
|
||||||
|
|
||||||
let input = Rc::new(Input::new());
|
let input = Rc::new(Input::new());
|
||||||
|
|
||||||
@ -75,8 +70,8 @@ impl Page {
|
|||||||
cancellable: RefCell::new(Cancellable::new()),
|
cancellable: RefCell::new(Cancellable::new()),
|
||||||
id,
|
id,
|
||||||
// Actions
|
// Actions
|
||||||
browser_action,
|
browser_action: action.0,
|
||||||
tab_action,
|
tab_action: action.2,
|
||||||
// Components
|
// Components
|
||||||
content,
|
content,
|
||||||
navigation,
|
navigation,
|
||||||
|
@ -25,11 +25,11 @@ impl Content {
|
|||||||
// Construct
|
// Construct
|
||||||
|
|
||||||
/// Create new container for different components
|
/// Create new container for different components
|
||||||
pub fn new(window_action: Rc<WindowAction>, tab_action: Rc<TabAction>) -> Self {
|
pub fn new(action: (Rc<WindowAction>, Rc<TabAction>)) -> Self {
|
||||||
Self {
|
Self {
|
||||||
gobject: Box::builder().orientation(Orientation::Vertical).build(),
|
gobject: Box::builder().orientation(Orientation::Vertical).build(),
|
||||||
window_action,
|
window_action: action.0,
|
||||||
tab_action,
|
tab_action: action.1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,17 +30,13 @@ pub struct Navigation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Navigation {
|
impl Navigation {
|
||||||
pub fn new(
|
pub fn new(action: (Rc<BrowserAction>, Rc<WindowAction>, Rc<TabAction>)) -> Self {
|
||||||
browser_action: Rc<BrowserAction>,
|
|
||||||
window_action: Rc<WindowAction>,
|
|
||||||
tab_action: Rc<TabAction>,
|
|
||||||
) -> Self {
|
|
||||||
// Init components
|
// Init components
|
||||||
let home = Rc::new(Home::new(window_action.clone()));
|
let home = Rc::new(Home::new(action.1.clone()));
|
||||||
let history = Rc::new(History::new(window_action.clone()));
|
let history = Rc::new(History::new(action.1.clone()));
|
||||||
let reload = Rc::new(Reload::new(window_action.clone()));
|
let reload = Rc::new(Reload::new(action.1.clone()));
|
||||||
let request = Rc::new(Request::new(browser_action, tab_action));
|
let request = Rc::new(Request::new((action.0, action.2)));
|
||||||
let bookmark = Rc::new(Bookmark::new(window_action));
|
let bookmark = Rc::new(Bookmark::new(action.1));
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Rc::new(Widget::new(
|
let widget = Rc::new(Widget::new(
|
||||||
|
@ -18,13 +18,9 @@ pub struct Request {
|
|||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(
|
pub fn new(action: (Rc<BrowserAction>, Rc<TabAction>)) -> Self {
|
||||||
// Actions
|
|
||||||
browser_action: Rc<BrowserAction>,
|
|
||||||
tab_action: Rc<TabAction>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
widget: Rc::new(Widget::new(browser_action, tab_action)),
|
widget: Rc::new(Widget::new(action)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(browser_action: Rc<BrowserAction>, tab_action: Rc<TabAction>) -> Self {
|
pub fn new(action: (Rc<BrowserAction>, Rc<TabAction>)) -> Self {
|
||||||
// Init animated progress bar state
|
// Init animated progress bar state
|
||||||
let progress = Rc::new(Progress {
|
let progress = Rc::new(Progress {
|
||||||
fraction: RefCell::new(0.0),
|
fraction: RefCell::new(0.0),
|
||||||
@ -42,11 +42,11 @@ impl Widget {
|
|||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
gobject.connect_changed(move |_| {
|
gobject.connect_changed(move |_| {
|
||||||
browser_action.update().activate(None);
|
action.0.update().activate(None);
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_activate(move |this| {
|
gobject.connect_activate(move |this| {
|
||||||
tab_action.load().activate(Some(&this.text()), true);
|
action.1.load().activate(Some(&this.text()), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_state_flags_changed({
|
gobject.connect_state_flags_changed({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user