begin action collections implementation (to reduce argument size by clippy)

This commit is contained in:
yggverse 2024-11-08 06:47:58 +02:00
parent 7c7e91ca31
commit ec7a668cd9
15 changed files with 164 additions and 129 deletions

View file

@ -14,9 +14,9 @@ use reload::Reload;
use request::Request;
use widget::Widget;
use crate::action::Browser as BrowserAction;
use gtk::{gio::SimpleAction, glib::GString, prelude::WidgetExt, Box};
use sqlite::Transaction;
use std::rc::Rc;
pub struct Navigation {
@ -30,18 +30,18 @@ pub struct Navigation {
impl Navigation {
pub fn new_rc(
browser_action: Rc<BrowserAction>,
action_page_home: SimpleAction,
action_page_history_back: SimpleAction,
action_page_history_forward: SimpleAction,
action_page_reload: SimpleAction,
action_page_open: SimpleAction,
action_update: SimpleAction,
) -> Rc<Self> {
// Init components
let home = Home::new_rc(action_page_home);
let history = History::new_rc(action_page_history_back, action_page_history_forward);
let reload = Reload::new_rc(action_page_reload.clone());
let request = Request::new_rc(action_update.clone(), action_page_open.clone());
let request = Request::new_rc(browser_action, action_page_open.clone());
let bookmark = Bookmark::new_rc();
// Init widget

View file

@ -4,6 +4,7 @@ mod widget;
use database::Database;
use widget::Widget;
use crate::action::Browser as BrowserAction;
use gtk::{
gio::SimpleAction,
glib::{GString, Uri, UriFlags},
@ -21,11 +22,11 @@ impl Request {
// Construct
pub fn new_rc(
// Actions
action_update: SimpleAction,
browser_action: Rc<BrowserAction>,
action_page_reload: SimpleAction, // @TODO local `action_page_open`?
) -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(action_update, action_page_reload),
widget: Widget::new_rc(browser_action, action_page_reload),
})
}

View file

@ -2,6 +2,7 @@ mod database;
use database::Database;
use crate::action::Browser as BrowserAction;
use gtk::{
gio::SimpleAction,
glib::{timeout_add_local, ControlFlow, GString, SourceId},
@ -29,7 +30,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(action_update: SimpleAction, action_page_open: SimpleAction) -> Rc<Self> {
pub fn new_rc(browser_action: Rc<BrowserAction>, action_page_open: SimpleAction) -> Rc<Self> {
// Init animated progress bar state
let progress = Rc::new(Progress {
fraction: RefCell::new(0.0),
@ -44,7 +45,7 @@ impl Widget {
// Connect events
gobject.connect_changed(move |_| {
action_update.activate(Some(&"".to_variant())); // @TODO
browser_action.update().activate(Some(&"".to_variant())); // @TODO
});
gobject.connect_activate(move |this| {