replace arc with rc

This commit is contained in:
yggverse 2024-11-08 05:21:08 +02:00
parent a0e923eb7d
commit c843e5b7c0
62 changed files with 317 additions and 334 deletions

View file

@ -14,32 +14,32 @@ use gtk::{
prelude::{ActionExt, ToVariant, WidgetExt},
Box,
};
use std::sync::Arc;
use std::rc::Rc;
pub struct Response {
// Components
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Response {
// Construct
pub fn new_arc(
pub fn new_rc(
action_page_open: SimpleAction,
base: Uri,
title: Option<&str>,
size_limit: Option<usize>,
) -> Arc<Self> {
) -> Rc<Self> {
// Init local actions
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());
let form = Form::new_arc(action_update.clone());
let title = Title::new_arc(title);
let control = Control::new_rc(action_send.clone());
let form = Form::new_rc(action_update.clone());
let title = Title::new_rc(title);
// Init widget
let widget = Widget::new_arc(title.gobject(), form.gobject(), control.gobject());
let widget = Widget::new_rc(title.gobject(), form.gobject(), control.gobject());
// Init events
action_update.connect_activate({
@ -76,7 +76,7 @@ impl Response {
widget.gobject().connect_realize(move |_| form.focus());
// Return activated struct
Arc::new(Self { widget })
Rc::new(Self { widget })
}
// Getters

View file

@ -7,26 +7,26 @@ use send::Send;
use widget::Widget;
use gtk::{gio::SimpleAction, Box};
use std::sync::Arc;
use std::rc::Rc;
pub struct Control {
counter: Arc<Counter>,
send: Arc<Send>,
widget: Arc<Widget>,
counter: Rc<Counter>,
send: Rc<Send>,
widget: Rc<Widget>,
}
impl Control {
// Construct
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_send: SimpleAction) -> Rc<Self> {
// Init components
let counter = Counter::new_arc();
let send = Send::new_arc(action_send);
let counter = Counter::new_rc();
let send = Send::new_rc(action_send);
// Init widget
let widget = Widget::new_arc(counter.gobject(), send.gobject());
let widget = Widget::new_rc(counter.gobject(), send.gobject());
// Return activated struct
Arc::new(Self {
Rc::new(Self {
counter,
send,
widget,

View file

@ -3,20 +3,20 @@ mod widget;
use widget::Widget;
use gtk::Label;
use std::sync::Arc;
use std::rc::Rc;
pub struct Counter {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Counter {
// Construct
pub fn new_arc() -> Arc<Self> {
pub fn new_rc() -> Rc<Self> {
// Init widget
let widget = Widget::new_arc();
let widget = Widget::new_rc();
// Result
Arc::new(Self { widget })
Rc::new(Self { widget })
}
// Actions

View file

@ -1,5 +1,5 @@
use gtk::{prelude::WidgetExt, Label};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Label,
@ -7,10 +7,10 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc() -> Arc<Self> {
pub fn new_rc() -> Rc<Self> {
let gobject = Label::builder().build();
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -3,20 +3,20 @@ mod widget;
use widget::Widget;
use gtk::{gio::SimpleAction, Button};
use std::sync::Arc;
use std::rc::Rc;
pub struct Send {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Send {
// Construct
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_send: SimpleAction) -> Rc<Self> {
// Init widget
let widget = Widget::new_arc(action_send);
let widget = Widget::new_rc(action_send);
// Result
Arc::new(Self { widget })
Rc::new(Self { widget })
}
// Actions

View file

@ -3,7 +3,7 @@ use gtk::{
prelude::{ActionExt, ButtonExt, WidgetExt},
Button,
};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_send: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_send: SimpleAction) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
//.css_classes(["accent"])
@ -26,7 +26,7 @@ impl Widget {
});
// Return activated struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -1,5 +1,5 @@
use gtk::{prelude::BoxExt, Align, Box, Button, Label, Orientation};
use std::sync::Arc;
use std::rc::Rc;
const SPACING: i32 = 8;
@ -9,7 +9,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(limit: &Label, send: &Button) -> Arc<Self> {
pub fn new_rc(limit: &Label, send: &Button) -> Rc<Self> {
// Init gobject
let gobject = Box::builder()
.halign(Align::End)
@ -21,7 +21,7 @@ impl Widget {
gobject.append(send);
// Return new struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -3,20 +3,20 @@ mod widget;
use widget::Widget;
use gtk::{gio::SimpleAction, glib::GString, TextView};
use std::sync::Arc;
use std::rc::Rc;
pub struct Form {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Form {
// Construct
pub fn new_arc(action_update: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_update: SimpleAction) -> Rc<Self> {
// Init widget
let widget = Widget::new_arc(action_update);
let widget = Widget::new_rc(action_update);
// Result
Arc::new(Self { widget })
Rc::new(Self { widget })
}
// Actions

View file

@ -4,7 +4,7 @@ use gtk::{
prelude::{ActionExt, TextBufferExt, TextViewExt, WidgetExt},
TextView, WrapMode,
};
use std::sync::Arc;
use std::rc::Rc;
const MARGIN: i32 = 8;
@ -14,7 +14,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(action_update: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_update: SimpleAction) -> Rc<Self> {
// Init gobject
let gobject = TextView::builder()
.bottom_margin(MARGIN)
@ -30,7 +30,7 @@ impl Widget {
});
// Return activated struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -3,20 +3,20 @@ mod widget;
use widget::Widget;
use gtk::Label;
use std::sync::Arc;
use std::rc::Rc;
pub struct Title {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Title {
// Construct
pub fn new_arc(title: Option<&str>) -> Arc<Self> {
pub fn new_rc(title: Option<&str>) -> Rc<Self> {
// Init widget
let widget = Widget::new_arc(title);
let widget = Widget::new_rc(title);
// Result
Arc::new(Self { widget })
Rc::new(Self { widget })
}
// Getters

View file

@ -1,5 +1,5 @@
use gtk::{prelude::WidgetExt, Align, Label};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Label,
@ -7,7 +7,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(title: Option<&str>) -> Arc<Self> {
pub fn new_rc(title: Option<&str>) -> Rc<Self> {
let gobject = Label::builder()
.css_classes(["heading"])
.halign(Align::Start)
@ -23,7 +23,7 @@ impl Widget {
}
}
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -1,5 +1,5 @@
use gtk::{prelude::BoxExt, Box, Label, Orientation, TextView};
use std::sync::Arc;
use std::rc::Rc;
const MARGIN: i32 = 6;
const SPACING: i32 = 8;
@ -10,7 +10,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(title: &Label, response: &TextView, control: &Box) -> Arc<Self> {
pub fn new_rc(title: &Label, response: &TextView, control: &Box) -> Rc<Self> {
let gobject = Box::builder()
.margin_bottom(MARGIN)
.margin_end(MARGIN)
@ -24,7 +24,7 @@ impl Widget {
gobject.append(response);
gobject.append(control);
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -10,26 +10,26 @@ use gtk::{
prelude::{ActionExt, ToVariant, WidgetExt},
Box,
};
use std::sync::Arc;
use std::rc::Rc;
pub struct Sensitive {
// Components
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Sensitive {
// Construct
pub fn new_arc(
pub fn new_rc(
action_page_open: SimpleAction,
base: Uri,
title: Option<&str>,
max_length: Option<i32>,
) -> Arc<Self> {
) -> Rc<Self> {
// Init local actions
let action_send = SimpleAction::new(&uuid_string_random(), None);
// Init components
let form = Form::new_arc(
let form = Form::new_rc(
action_send.clone(),
title,
match max_length {
@ -41,7 +41,7 @@ impl Sensitive {
);
// Init widget
let widget = Widget::new_arc(form.gobject());
let widget = Widget::new_rc(form.gobject());
// Init events
action_send.connect_activate({
@ -61,7 +61,7 @@ impl Sensitive {
widget.gobject().connect_realize(move |_| form.focus());
// Return activated struct
Arc::new(Self { widget })
Rc::new(Self { widget })
}
// Getters

View file

@ -4,24 +4,24 @@ use widget::Widget;
use adw::PasswordEntryRow;
use gtk::{gio::SimpleAction, glib::GString};
use std::sync::Arc;
use std::rc::Rc;
pub struct Form {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Form {
// Construct
pub fn new_arc(
pub fn new_rc(
action_send: SimpleAction,
title: Option<&str>,
max_length: Option<i32>,
) -> Arc<Self> {
) -> Rc<Self> {
// Init widget
let widget = Widget::new_arc(action_send, title, max_length);
let widget = Widget::new_rc(action_send, title, max_length);
// Result
Arc::new(Self { widget })
Rc::new(Self { widget })
}
// Actions

View file

@ -7,7 +7,7 @@ use gtk::{
glib::GString,
prelude::{ActionExt, EditableExt, WidgetExt},
};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: PasswordEntryRow,
@ -15,11 +15,11 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
pub fn new_rc(
action_send: SimpleAction,
title: Option<&str>,
max_length: Option<i32>,
) -> Arc<Self> {
) -> Rc<Self> {
// Init gobject
let gobject = PasswordEntryRow::builder().show_apply_button(true).build();
@ -37,7 +37,7 @@ impl Widget {
});
// Return activated struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -1,6 +1,6 @@
use adw::PasswordEntryRow;
use gtk::{prelude::BoxExt, Box, Orientation};
use std::sync::Arc;
use std::rc::Rc;
const MARGIN: i32 = 6;
const SPACING: i32 = 8;
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(response: &PasswordEntryRow) -> Arc<Self> {
pub fn new_rc(response: &PasswordEntryRow) -> Rc<Self> {
let gobject = Box::builder()
.margin_bottom(MARGIN)
.margin_end(MARGIN)
@ -23,7 +23,7 @@ impl Widget {
gobject.append(response);
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -1,6 +1,6 @@
use adw::Clamp;
use gtk::{prelude::WidgetExt, Box};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Clamp,
@ -8,14 +8,14 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc() -> Arc<Self> {
pub fn new_rc() -> Rc<Self> {
let gobject = Clamp::builder()
.css_classes(["app-notification"])
.maximum_size(800)
.visible(false)
.build();
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions