drop Arc from SimpleAction #1

This commit is contained in:
yggverse 2024-10-27 12:50:36 +02:00
parent 08ad677ba4
commit 920721412e
40 changed files with 162 additions and 175 deletions

View file

@ -35,9 +35,9 @@ use std::{cell::RefCell, sync::Arc};
pub struct Page {
id: GString,
// Actions
action_page_open: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
action_page_open: SimpleAction,
action_tab_page_navigation_reload: SimpleAction,
action_update: SimpleAction,
// Components
navigation: Arc<Navigation>,
content: Arc<Content>,
@ -52,18 +52,16 @@ impl Page {
// Construct
pub fn new_arc(
id: GString,
action_tab_open: Arc<SimpleAction>,
action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
action_tab_open: SimpleAction,
action_tab_page_navigation_base: SimpleAction,
action_tab_page_navigation_history_back: SimpleAction,
action_tab_page_navigation_history_forward: SimpleAction,
action_tab_page_navigation_reload: SimpleAction,
action_update: SimpleAction,
) -> Arc<Self> {
// Init local actions
let action_page_open = Arc::new(SimpleAction::new(
&uuid_string_random(),
Some(&String::static_variant_type()),
));
let action_page_open =
SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type()));
// Init components
let content = Arc::new(Content::new(

View file

@ -13,20 +13,17 @@ use gtk::{
prelude::{BoxExt, WidgetExt},
Box, Orientation,
};
use std::sync::Arc;
pub struct Content {
// GTK
gobject: Box,
// Actions
action_tab_open: Arc<SimpleAction>,
action_page_open: Arc<SimpleAction>,
action_tab_open: SimpleAction,
action_page_open: SimpleAction,
}
impl Content {
// Construct
pub fn new(action_tab_open: Arc<SimpleAction>, action_page_open: Arc<SimpleAction>) -> Self {
pub fn new(action_tab_open: SimpleAction, action_page_open: SimpleAction) -> Self {
Self {
gobject: Box::builder().orientation(Orientation::Vertical).build(),
action_tab_open,

View file

@ -8,8 +8,6 @@ use gtk::{
ScrolledWindow,
};
use std::sync::Arc;
pub struct Meta {
title: Option<GString>,
}
@ -24,8 +22,8 @@ impl Text {
pub fn gemini(
gemtext: &str,
base: &Uri,
action_tab_append: Arc<SimpleAction>,
action_page_open: Arc<SimpleAction>,
action_tab_append: SimpleAction,
action_page_open: SimpleAction,
) -> Self {
// Init components
let gemini = Gemini::new(gemtext, base, action_tab_append, action_page_open);

View file

@ -23,8 +23,8 @@ impl Gemini {
pub fn new(
gemtext: &str,
base: &Uri,
action_tab_open: Arc<SimpleAction>,
action_page_open: Arc<SimpleAction>,
action_tab_open: SimpleAction,
action_page_open: SimpleAction,
) -> Self {
// Init components
let reader = Reader::new_arc(gemtext, base, action_tab_open, action_page_open);

View file

@ -33,8 +33,8 @@ impl Reader {
pub fn new_arc(
gemtext: &str,
base: &Uri,
action_tab_open: Arc<SimpleAction>,
action_page_open: Arc<SimpleAction>,
action_tab_open: SimpleAction,
action_page_open: SimpleAction,
) -> Arc<Self> {
// Init default values
let mut title = None;

View file

@ -32,7 +32,7 @@ impl Input {
// Setters
pub fn set_new_response(
&self,
action_page_open: Arc<SimpleAction>,
action_page_open: SimpleAction,
base: Uri,
title: Option<&str>,
size_limit: Option<usize>,
@ -44,7 +44,7 @@ impl Input {
pub fn set_new_sensitive(
&self,
action_page_open: Arc<SimpleAction>,
action_page_open: SimpleAction,
base: Uri,
title: Option<&str>,
max_length: Option<i32>,

View file

@ -24,14 +24,14 @@ pub struct Response {
impl Response {
// Construct
pub fn new_arc(
action_page_open: Arc<SimpleAction>,
action_page_open: SimpleAction,
base: Uri,
title: Option<&str>,
size_limit: Option<usize>,
) -> Arc<Self> {
// Init local actions
let action_update = Arc::new(SimpleAction::new(&uuid_string_random(), None));
let action_send = Arc::new(SimpleAction::new(&uuid_string_random(), None));
let action_update = SimpleAction::new(&uuid_string_random(), None);
let action_send = SimpleAction::new(&uuid_string_random(), None);
// Init components
let control = Control::new_arc(action_send.clone());

View file

@ -17,7 +17,7 @@ pub struct Control {
impl Control {
// Construct
pub fn new_arc(action_send: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
// Init components
let counter = Counter::new_arc();
let send = Send::new_arc(action_send);

View file

@ -11,7 +11,7 @@ pub struct Send {
impl Send {
// Construct
pub fn new_arc(action_send: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
// Init widget
let widget = Widget::new_arc(action_send);

View file

@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_send: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
// Init gobject
let gobject = Button::builder()
//.css_classes(["accent"])

View file

@ -11,7 +11,7 @@ pub struct Form {
impl Form {
// Construct
pub fn new_arc(action_update: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_update: SimpleAction) -> Arc<Self> {
// Init widget
let widget = Widget::new_arc(action_update);

View file

@ -14,7 +14,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_update: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_update: SimpleAction) -> Arc<Self> {
// Init gobject
let gobject = TextView::builder()
.bottom_margin(MARGIN)

View file

@ -20,13 +20,13 @@ pub struct Sensitive {
impl Sensitive {
// Construct
pub fn new_arc(
action_page_open: Arc<SimpleAction>,
action_page_open: SimpleAction,
base: Uri,
title: Option<&str>,
max_length: Option<i32>,
) -> Arc<Self> {
// Init local actions
let action_send = Arc::new(SimpleAction::new(&uuid_string_random(), None));
let action_send = SimpleAction::new(&uuid_string_random(), None);
// Init components
let form = Form::new_arc(

View file

@ -13,7 +13,7 @@ pub struct Form {
impl Form {
// Construct
pub fn new_arc(
action_send: Arc<SimpleAction>,
action_send: SimpleAction,
title: Option<&str>,
max_length: Option<i32>,
) -> Arc<Self> {

View file

@ -16,7 +16,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
action_send: Arc<SimpleAction>,
action_send: SimpleAction,
title: Option<&str>,
max_length: Option<i32>,
) -> Arc<Self> {

View file

@ -30,11 +30,11 @@ pub struct Navigation {
impl Navigation {
pub fn new_arc(
action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>,
action_tab_page_navigation_base: SimpleAction,
action_tab_page_navigation_history_back: SimpleAction,
action_tab_page_navigation_history_forward: SimpleAction,
action_tab_page_navigation_reload: SimpleAction,
action_update: SimpleAction,
) -> Arc<Self> {
// Init components
let base = Base::new_arc(action_tab_page_navigation_base);

View file

@ -10,14 +10,14 @@ use gtk::{
use std::{cell::RefCell, sync::Arc};
pub struct Base {
action_tab_page_navigation_base: Arc<SimpleAction>,
action_tab_page_navigation_base: SimpleAction,
uri: RefCell<Option<Uri>>,
widget: Arc<Widget>,
}
impl Base {
// Construct
pub fn new_arc(action_tab_page_navigation_base: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_base: SimpleAction) -> Arc<Self> {
Arc::new(Self {
action_tab_page_navigation_base: action_tab_page_navigation_base.clone(),
uri: RefCell::new(None),

View file

@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_tab_page_navigation_base: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_base: SimpleAction) -> Arc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-home-symbolic")

View file

@ -28,8 +28,8 @@ pub struct History {
impl History {
// Construct
pub fn new_arc(
action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
action_tab_page_navigation_history_back: SimpleAction,
action_tab_page_navigation_history_forward: SimpleAction,
) -> Arc<Self> {
// init components
let back = Back::new_arc(action_tab_page_navigation_history_back);

View file

@ -6,13 +6,13 @@ use gtk::{gio::SimpleAction, Button};
use std::sync::Arc;
pub struct Back {
action_tab_page_navigation_history_back: Arc<SimpleAction>,
action_tab_page_navigation_history_back: SimpleAction,
widget: Arc<Widget>,
}
impl Back {
// Construct
pub fn new_arc(action_tab_page_navigation_history_back: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_history_back: SimpleAction) -> Arc<Self> {
// Return activated struct
Arc::new(Self {
action_tab_page_navigation_history_back: action_tab_page_navigation_history_back

View file

@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_tab_page_navigation_history_back: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_history_back: SimpleAction) -> Arc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-previous-symbolic")

View file

@ -6,13 +6,13 @@ use gtk::{gio::SimpleAction, Button};
use std::sync::Arc;
pub struct Forward {
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
action_tab_page_navigation_history_forward: SimpleAction,
widget: Arc<Widget>,
}
impl Forward {
// Construct
pub fn new_arc(action_tab_page_navigation_history_forward: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_history_forward: SimpleAction) -> Arc<Self> {
// Return activated struct
Arc::new(Self {
action_tab_page_navigation_history_forward: action_tab_page_navigation_history_forward

View file

@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_tab_page_navigation_history_forward: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_history_forward: SimpleAction) -> Arc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-next-symbolic")

View file

@ -6,13 +6,13 @@ use gtk::{gio::SimpleAction, Button};
use std::sync::Arc;
pub struct Reload {
action_tab_page_navigation_reload: Arc<SimpleAction>,
action_tab_page_navigation_reload: SimpleAction,
widget: Arc<Widget>,
}
impl Reload {
// Construct
pub fn new_arc(action_tab_page_navigation_reload: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_reload: SimpleAction) -> Arc<Self> {
Arc::new(Self {
action_tab_page_navigation_reload: action_tab_page_navigation_reload.clone(),
widget: Widget::new_arc(action_tab_page_navigation_reload),

View file

@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_tab_page_navigation_reload: Arc<SimpleAction>) -> Arc<Self> {
pub fn new_arc(action_tab_page_navigation_reload: SimpleAction) -> Arc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("view-refresh-symbolic")

View file

@ -21,8 +21,8 @@ impl Request {
// Construct
pub fn new_arc(
// Actions
action_update: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>, // @TODO local `action_page_open`?
action_update: SimpleAction,
action_tab_page_navigation_reload: SimpleAction, // @TODO local `action_page_open`?
) -> Arc<Self> {
Arc::new(Self {
widget: Widget::new_arc(action_update, action_tab_page_navigation_reload),

View file

@ -30,8 +30,8 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
action_update: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>, // @TODO local `action_page_open`?
action_update: SimpleAction,
action_tab_page_navigation_reload: SimpleAction, // @TODO local `action_page_open`?
) -> Arc<Self> {
// Init animated progress bar state
let progress = Arc::new(Progress {

View file

@ -16,7 +16,7 @@ impl Widget {
pub fn new_arc(
name: &str,
// Actions
action_page_open: Arc<SimpleAction>,
action_page_open: SimpleAction,
// Components
navigation: &Box,
content: &Box,
@ -24,7 +24,7 @@ impl Widget {
) -> Arc<Self> {
// Init additional action group
let action_group = SimpleActionGroup::new();
action_group.add_action(action_page_open.as_ref());
action_group.add_action(&action_page_open);
// Init self
let gobject = Box::builder()