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

@ -3,17 +3,17 @@ mod widget;
use widget::Widget;
use gtk::Button;
use std::sync::Arc;
use std::rc::Rc;
pub struct Bookmark {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Bookmark {
// Construct
pub fn new_arc() -> Arc<Self> {
Arc::new(Self {
widget: Widget::new_arc(),
pub fn new_rc() -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(),
})
}

View file

@ -1,5 +1,5 @@
use gtk::Button;
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Button,
@ -7,8 +7,8 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc() -> Arc<Self> {
Arc::new(Self {
pub fn new_rc() -> Rc<Self> {
Rc::new(Self {
gobject: Button::builder()
.icon_name("starred-symbolic")
.tooltip_text("Bookmark")

View file

@ -7,7 +7,7 @@ use forward::Forward;
use widget::Widget;
use gtk::{gio::SimpleAction, glib::GString, Box};
use std::{cell::RefCell, sync::Arc};
use std::{cell::RefCell, rc::Rc};
struct Memory {
request: GString,
@ -16,27 +16,27 @@ struct Memory {
pub struct History {
// Components
back: Arc<Back>,
forward: Arc<Forward>,
back: Rc<Back>,
forward: Rc<Forward>,
// Extras
memory: RefCell<Vec<Memory>>,
index: RefCell<Option<usize>>,
// GTK
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl History {
// Construct
pub fn new_arc(
pub fn new_rc(
action_page_history_back: SimpleAction,
action_page_history_forward: SimpleAction,
) -> Arc<Self> {
) -> Rc<Self> {
// init components
let back = Back::new_arc(action_page_history_back);
let forward = Forward::new_arc(action_page_history_forward);
let back = Back::new_rc(action_page_history_back);
let forward = Forward::new_rc(action_page_history_forward);
// Init widget
let widget = Widget::new_arc(back.gobject(), forward.gobject());
let widget = Widget::new_rc(back.gobject(), forward.gobject());
// Init memory
let memory = RefCell::new(Vec::new());
@ -44,7 +44,7 @@ impl History {
// Init index
let index = RefCell::new(None);
Arc::new(Self {
Rc::new(Self {
back,
forward,
memory,

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 Back {
action_page_history_back: SimpleAction,
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Back {
// Construct
pub fn new_arc(action_page_history_back: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_page_history_back: SimpleAction) -> Rc<Self> {
// Return activated struct
Arc::new(Self {
Rc::new(Self {
action_page_history_back: action_page_history_back.clone(),
widget: Widget::new_arc(action_page_history_back),
widget: Widget::new_rc(action_page_history_back),
})
}

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_page_history_back: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_page_history_back: SimpleAction) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-previous-symbolic")
@ -21,15 +21,14 @@ impl Widget {
// Init events
gobject.connect_clicked({
let action_page_history_back =
action_page_history_back.clone();
let action_page_history_back = action_page_history_back.clone();
move |_| {
action_page_history_back.activate(None);
}
});
// 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::{gio::SimpleAction, Button};
use std::sync::Arc;
use std::rc::Rc;
pub struct Forward {
action_page_history_forward: SimpleAction,
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Forward {
// Construct
pub fn new_arc(action_page_history_forward: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_page_history_forward: SimpleAction) -> Rc<Self> {
// Return activated struct
Arc::new(Self {
Rc::new(Self {
action_page_history_forward: action_page_history_forward.clone(),
widget: Widget::new_arc(action_page_history_forward),
widget: Widget::new_rc(action_page_history_forward),
})
}

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_page_history_forward: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_page_history_forward: SimpleAction) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-next-symbolic")
@ -21,15 +21,14 @@ impl Widget {
// Init events
gobject.connect_clicked({
let action_page_history_forward =
action_page_history_forward.clone();
let action_page_history_forward = action_page_history_forward.clone();
move |_| {
action_page_history_forward.activate(None);
}
});
// Return activated struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -2,7 +2,7 @@ use gtk::{
prelude::{BoxExt, IsA},
Box, Orientation,
};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Box,
@ -10,7 +10,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(back: &impl IsA<gtk::Widget>, forward: &impl IsA<gtk::Widget>) -> Arc<Self> {
pub fn new_rc(back: &impl IsA<gtk::Widget>, forward: &impl IsA<gtk::Widget>) -> Rc<Self> {
// Init widget
let gobject = Box::builder()
.orientation(Orientation::Horizontal)
@ -24,7 +24,7 @@ impl Widget {
gobject.append(forward);
// Return activated struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -7,21 +7,21 @@ use gtk::{
glib::{gformat, GString, Uri},
Button,
};
use std::{cell::RefCell, sync::Arc};
use std::{cell::RefCell, rc::Rc};
pub struct Home {
action_page_home: SimpleAction,
uri: RefCell<Option<Uri>>,
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Home {
// Construct
pub fn new_arc(action_page_home: SimpleAction) -> Arc<Self> {
Arc::new(Self {
pub fn new_rc(action_page_home: SimpleAction) -> Rc<Self> {
Rc::new(Self {
action_page_home: action_page_home.clone(),
uri: RefCell::new(None),
widget: Widget::new_arc(action_page_home),
widget: Widget::new_rc(action_page_home),
})
}

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_page_home: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_page_home: SimpleAction) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-home-symbolic")
@ -28,7 +28,7 @@ impl Widget {
});
// Return activated struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -3,19 +3,19 @@ mod widget;
use widget::Widget;
use gtk::{gio::SimpleAction, Button};
use std::sync::Arc;
use std::rc::Rc;
pub struct Reload {
action_page_reload: SimpleAction,
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Reload {
// Construct
pub fn new_arc(action_page_reload: SimpleAction) -> Arc<Self> {
Arc::new(Self {
pub fn new_rc(action_page_reload: SimpleAction) -> Rc<Self> {
Rc::new(Self {
action_page_reload: action_page_reload.clone(),
widget: Widget::new_arc(action_page_reload),
widget: Widget::new_rc(action_page_reload),
})
}

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_page_reload: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_page_reload: SimpleAction) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("view-refresh-symbolic")
@ -28,7 +28,7 @@ impl Widget {
});
// Return activated struct
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -10,22 +10,22 @@ use gtk::{
Entry,
};
use sqlite::Transaction;
use std::sync::Arc;
use std::rc::Rc;
// Main
pub struct Request {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Request {
// Construct
pub fn new_arc(
pub fn new_rc(
// Actions
action_update: SimpleAction,
action_page_reload: SimpleAction, // @TODO local `action_page_open`?
) -> Arc<Self> {
Arc::new(Self {
widget: Widget::new_arc(action_update, action_page_reload),
) -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(action_update, action_page_reload),
})
}

View file

@ -9,9 +9,9 @@ use gtk::{
Entry, StateFlags,
};
use sqlite::Transaction;
use std::{cell::RefCell, sync::Arc, time::Duration};
use std::{cell::RefCell, rc::Rc, time::Duration};
const PLACEHOLDER_TEXT: &str = "URL or search term...";
const PLACEHOLDER_TEXT: &str = "URL or seRch term...";
// Progress bar animation setup
const PROGRESS_ANIMATION_STEP: f64 = 0.05;
@ -24,14 +24,14 @@ struct Progress {
pub struct Widget {
gobject: Entry,
progress: Arc<Progress>,
progress: Rc<Progress>,
}
impl Widget {
// Construct
pub fn new_arc(action_update: SimpleAction, action_page_open: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_update: SimpleAction, action_page_open: SimpleAction) -> Rc<Self> {
// Init animated progress bar state
let progress = Arc::new(Progress {
let progress = Rc::new(Progress {
fraction: RefCell::new(0.0),
source_id: RefCell::new(None),
});
@ -73,7 +73,7 @@ impl Widget {
});
// Return activated struct
Arc::new(Self { gobject, progress })
Rc::new(Self { gobject, progress })
}
// Actions

View file

@ -2,7 +2,7 @@ use gtk::{
prelude::{BoxExt, IsA},
Box, Orientation,
};
use std::sync::Arc;
use std::rc::Rc;
const MARGIN: i32 = 6;
const SPACING: i32 = 6;
@ -13,13 +13,13 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
pub fn new_rc(
base: &impl IsA<gtk::Widget>,
history: &impl IsA<gtk::Widget>,
reload: &impl IsA<gtk::Widget>,
request: &impl IsA<gtk::Widget>,
bookmark: &impl IsA<gtk::Widget>,
) -> Arc<Self> {
) -> Rc<Self> {
let gobject = Box::builder()
.orientation(Orientation::Horizontal)
.spacing(SPACING)
@ -34,7 +34,7 @@ impl Widget {
gobject.append(request);
gobject.append(bookmark);
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters