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

@ -176,7 +176,7 @@ Quick start guide and maintenance protocol
* implementable `struct` is public, where it members - private
* contain main `struct` implementation:
* at least one constructor that must:
* have common for application names: `from`, `new` or/and `new_arc`, `new_mutex`, etc - on return object in container
* have common for application names: `from`, `new` or/and `new_rc`, `new_mutex`, etc - on return object in container
* grant ownership for new `Self` object created
* public `activate` action if the new object can not be activated on construct
* public `link` getter for GTK `widget` (parental composition)

View file

@ -15,30 +15,18 @@ use gtk::{
};
use sqlite::{Connection, Transaction};
use std::{
path::PathBuf,
sync::{Arc, RwLock},
};
use std::{path::PathBuf, rc::Rc, sync::RwLock};
const APPLICATION_ID: &str = "io.github.yggverse.Yoda";
pub struct App {
profile_database_connection: Arc<RwLock<Connection>>,
// database: Arc<Database>,
// Actions
// action_update: SimpleAction,
// Components
// browser: Arc<Browser>,
// GTK
profile_database_connection: Rc<RwLock<Connection>>,
gobject: Application,
}
impl App {
// Construct
pub fn new(
profile_database_connection: Arc<RwLock<Connection>>,
profile_path: PathBuf,
) -> Self {
pub fn new(profile_database_connection: Rc<RwLock<Connection>>, profile_path: PathBuf) -> Self {
// Init defaults
let default_state = (-1).to_variant();
@ -100,7 +88,7 @@ impl App {
}
// Init components
let browser = Arc::new(Browser::new(
let browser = Rc::new(Browser::new(
profile_path,
action_about.clone(),
action_debug.clone(),

View file

@ -16,13 +16,13 @@ use gtk::{
FileLauncher,
};
use sqlite::Transaction;
use std::{path::PathBuf, sync::Arc};
use std::{path::PathBuf, rc::Rc};
pub struct Browser {
// Components
// header: Arc<Header>,
window: Arc<Window>,
widget: Arc<Widget>,
// header: Rc<Header>,
window: Rc<Window>,
widget: Rc<Widget>,
}
impl Browser {
@ -46,7 +46,7 @@ impl Browser {
action_page_pin: SimpleAction,
) -> Browser {
// Init components
let window = Arc::new(Window::new(
let window = Rc::new(Window::new(
action_about.clone(),
action_debug.clone(),
action_profile.clone(),
@ -63,7 +63,7 @@ impl Browser {
));
// Init widget
let widget = Arc::new(Widget::new(
let widget = Rc::new(Widget::new(
window.gobject(),
&[
action_about.clone(),

View file

@ -9,14 +9,14 @@ use sqlite::Transaction;
use tab::Tab;
use widget::Widget;
use std::sync::Arc;
use std::rc::Rc;
use gtk::{gio::SimpleAction, Box};
pub struct Window {
//header: Arc<Header>,
tab: Arc<Tab>,
widget: Arc<Widget>,
//header: Rc<Header>,
tab: Rc<Tab>,
widget: Rc<Widget>,
}
impl Window {
@ -38,7 +38,7 @@ impl Window {
action_page_pin: SimpleAction,
) -> Self {
// Init components
let tab = Tab::new_arc(
let tab = Tab::new_rc(
action_page_close.clone(),
action_page_close_all.clone(),
action_page_home.clone(),
@ -49,7 +49,7 @@ impl Window {
action_update.clone(),
);
let header = Header::new_arc(
let header = Header::new_rc(
// Actions
action_about,
action_debug,
@ -68,7 +68,7 @@ impl Window {
);
// GTK
let widget = Arc::new(Widget::new(header.gobject(), tab.gobject()));
let widget = Rc::new(Widget::new(header.gobject(), tab.gobject()));
// Init struct
Self {

View file

@ -6,15 +6,15 @@ use widget::Widget;
use adw::{TabView, ToolbarView};
use gtk::gio::SimpleAction;
use std::sync::Arc;
use std::rc::Rc;
pub struct Header {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Header {
// Construct
pub fn new_arc(
pub fn new_rc(
// Actions
action_about: SimpleAction,
action_debug: SimpleAction,
@ -30,9 +30,9 @@ impl Header {
action_page_pin: SimpleAction,
// Widgets
tab_view: &TabView,
) -> Arc<Self> {
) -> Rc<Self> {
// Init components
let bar = Bar::new_arc(
let bar = Bar::new_rc(
action_about,
action_debug,
action_profile,
@ -49,8 +49,8 @@ impl Header {
);
// Return new struct
Arc::new(Self {
widget: Widget::new_arc(bar.gobject()),
Rc::new(Self {
widget: Widget::new_rc(bar.gobject()),
})
}

View file

@ -10,15 +10,15 @@ use widget::Widget;
use adw::TabView;
use gtk::{gio::SimpleAction, Box};
use std::sync::Arc;
use std::rc::Rc;
pub struct Bar {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Bar {
// Construct
pub fn new_arc(
pub fn new_rc(
action_about: SimpleAction,
action_debug: SimpleAction,
action_profile: SimpleAction,
@ -32,11 +32,11 @@ impl Bar {
action_page_reload: SimpleAction,
action_page_pin: SimpleAction,
view: &TabView,
) -> Arc<Self> {
) -> Rc<Self> {
// Init components
let control = Control::new_arc();
let tab = Tab::new_arc(action_page_new.clone(), view);
let menu = Menu::new_arc(
let control = Control::new_rc();
let tab = Tab::new_rc(action_page_new.clone(), view);
let menu = Menu::new_rc(
action_about,
action_debug,
action_profile,
@ -52,8 +52,8 @@ impl Bar {
);
// Build result
Arc::new(Self {
widget: Widget::new_arc(control.gobject(), menu.gobject(), tab.gobject()),
Rc::new(Self {
widget: Widget::new_rc(control.gobject(), menu.gobject(), tab.gobject()),
})
}

View file

@ -3,17 +3,17 @@ mod widget;
use widget::Widget;
use gtk::WindowControls;
use std::sync::Arc;
use std::rc::Rc;
pub struct Control {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Control {
// 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::{PackType, WindowControls};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: WindowControls,
@ -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: WindowControls::builder()
.side(PackType::End)
.margin_end(4)

View file

@ -9,14 +9,14 @@ use gtk::{
MenuButton,
};
use std::sync::Arc;
use std::rc::Rc;
pub struct Menu {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
#[rustfmt::skip] // @TODO template builder?
impl Menu {
pub fn new_arc(
pub fn new_rc(
action_about: SimpleAction,
action_debug: SimpleAction,
action_profile: SimpleAction,
@ -29,7 +29,7 @@ impl Menu {
action_page_history_forward: SimpleAction,
action_page_reload: SimpleAction,
action_page_pin: SimpleAction,
) -> Arc<Self> {
) -> Rc<Self> {
// Main
let main = gio::Menu::new();
@ -72,7 +72,7 @@ impl Menu {
main.append(Some("Quit"), Some(&detailed_action_name(action_quit)));
// Result
Arc::new(Self { widget:Widget::new_arc(&main) })
Rc::new(Self { widget:Widget::new_rc(&main) })
}
// Getters

View file

@ -1,5 +1,5 @@
use gtk::{gio::Menu, Align, MenuButton};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: MenuButton,
@ -7,8 +7,8 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(model: &Menu) -> Arc<Self> {
Arc::new(Self {
pub fn new_rc(model: &Menu) -> Rc<Self> {
Rc::new(Self {
gobject: MenuButton::builder()
.css_classes(["flat"])
.icon_name("open-menu-symbolic")

View file

@ -6,17 +6,17 @@ use widget::Widget;
use adw::{TabBar, TabView};
use gtk::gio::SimpleAction;
use std::sync::Arc;
use std::rc::Rc;
pub struct Tab {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Tab {
// Construct
pub fn new_arc(action_page_new: SimpleAction, view: &TabView) -> Arc<Self> {
Arc::new(Self {
widget: Widget::new_arc(view, Append::new_arc(action_page_new).gobject()),
pub fn new_rc(action_page_new: SimpleAction, view: &TabView) -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(view, Append::new_rc(action_page_new).gobject()),
})
}

View file

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

View file

@ -3,7 +3,7 @@ use gtk::{
prelude::{ActionExt, ButtonExt},
Align, 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_new: SimpleAction) -> Arc<Self> {
pub fn new_rc(action_page_new: SimpleAction) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("tab-new-symbolic")
@ -25,7 +25,7 @@ impl Widget {
action_page_new.activate(None);
});
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -1,6 +1,6 @@
use adw::{TabBar, TabView};
use gtk::prelude::IsA;
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: TabBar,
@ -8,8 +8,8 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Arc<Self> {
Arc::new(Self {
pub fn new_rc(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Rc<Self> {
Rc::new(Self {
gobject: TabBar::builder()
.autohide(false)
.expand_tabs(false)

View file

@ -1,6 +1,6 @@
use adw::TabBar;
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Box,
@ -8,7 +8,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Arc<Self> {
pub fn new_rc(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Rc<Self> {
let gobject = Box::builder()
.orientation(Orientation::Horizontal)
.spacing(8)
@ -18,7 +18,7 @@ impl Widget {
gobject.append(menu);
gobject.append(control);
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -1,6 +1,6 @@
use adw::ToolbarView;
use gtk::Box;
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: ToolbarView,
@ -8,12 +8,12 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(top_bar: &Box) -> Arc<Self> {
pub fn new_rc(top_bar: &Box) -> Rc<Self> {
let gobject = ToolbarView::builder().build();
gobject.add_top_bar(top_bar);
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -15,7 +15,7 @@ use gtk::{
prelude::{ActionExt, StaticVariantType, ToVariant},
};
use sqlite::Transaction;
use std::{cell::RefCell, collections::HashMap, sync::Arc};
use std::{cell::RefCell, collections::HashMap, rc::Rc};
// Main
pub struct Tab {
@ -28,14 +28,14 @@ pub struct Tab {
action_page_reload: SimpleAction,
action_update: SimpleAction,
// Dynamically allocated reference index
index: Arc<RefCell<HashMap<GString, Arc<Item>>>>,
index: Rc<RefCell<HashMap<GString, Rc<Item>>>>,
// GTK
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Tab {
// Construct
pub fn new_arc(
pub fn new_rc(
action_page_close: SimpleAction,
action_page_close_all: SimpleAction,
action_page_home: SimpleAction,
@ -44,13 +44,13 @@ impl Tab {
action_page_pin: SimpleAction,
action_page_reload: SimpleAction,
action_update: SimpleAction,
) -> Arc<Self> {
) -> Rc<Self> {
// Init local actions
let action_tab_open =
SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type()));
// Init empty HashMap index as no tabs appended yet
let index = Arc::new(RefCell::new(HashMap::new()));
let index = Rc::new(RefCell::new(HashMap::new()));
// Init context menu
let menu = Menu::new(
@ -64,7 +64,7 @@ impl Tab {
);
// Init widget
let widget = Arc::new(Widget::new(menu.gobject()));
let widget = Rc::new(Widget::new(menu.gobject()));
// Init events
@ -80,7 +80,7 @@ impl Tab {
let action_update = action_update.clone();
move |_, request| {
// Init new tab item
let item = Item::new_arc(
let item = Item::new_rc(
&gobject,
// Local actions
action_tab_open.clone(),
@ -172,7 +172,7 @@ impl Tab {
});
// Return activated struct
Arc::new(Self {
Rc::new(Self {
// Local actions
action_tab_open,
// Global actions
@ -189,9 +189,9 @@ impl Tab {
}
// Actions
pub fn append(&self, position: Option<i32>) -> Arc<Item> {
pub fn append(&self, position: Option<i32>) -> Rc<Item> {
// Init new tab item
let item = Item::new_arc(
let item = Item::new_rc(
self.gobject(),
// Local actions
self.action_tab_open.clone(),

View file

@ -12,20 +12,20 @@ use gtk::{
glib::{uuid_string_random, GString},
};
use sqlite::Transaction;
use std::sync::Arc;
use std::rc::Rc;
pub struct Item {
// Auto-generated unique item ID
// useful as widget name in GTK actions callback
id: GString,
// Components
page: Arc<Page>,
widget: Arc<Widget>,
page: Rc<Page>,
widget: Rc<Widget>,
}
impl Item {
// Construct
pub fn new_arc(
pub fn new_rc(
tab_view: &TabView,
// Actions
action_tab_open: SimpleAction,
@ -38,12 +38,12 @@ impl Item {
position: Option<i32>,
is_pinned: bool,
is_selected: bool,
) -> Arc<Self> {
) -> Rc<Self> {
// Generate unique ID for new page components
let id = uuid_string_random();
// Init components
let page = Page::new_arc(
let page = Page::new_rc(
id.clone(),
// Actions
action_tab_open.clone(),
@ -54,7 +54,7 @@ impl Item {
action_update.clone(),
);
let widget = Widget::new_arc(
let widget = Widget::new_rc(
id.as_str(),
tab_view,
page.gobject(),
@ -65,7 +65,7 @@ impl Item {
); // @TODO
// Return struct
Arc::new(Self { id, page, widget })
Rc::new(Self { id, page, widget })
}
// Actions
@ -134,14 +134,14 @@ impl Item {
action_page_history_forward: SimpleAction,
action_page_reload: SimpleAction,
action_update: SimpleAction,
) -> Result<Vec<Arc<Item>>, String> {
) -> Result<Vec<Rc<Item>>, String> {
let mut items = Vec::new();
match Database::records(transaction, app_browser_window_tab_id) {
Ok(records) => {
for record in records {
// Construct new item object
let item = Item::new_arc(
let item = Item::new_rc(
tab_view,
// Actions
action_tab_open.clone(),

View file

@ -29,7 +29,7 @@ use gtk::{
Box,
};
use sqlite::Transaction;
use std::{sync::Arc, time::Duration};
use std::{rc::Rc, time::Duration};
pub struct Page {
id: GString,
@ -38,20 +38,20 @@ pub struct Page {
action_page_open: SimpleAction,
action_update: SimpleAction,
// Components
navigation: Arc<Navigation>,
content: Arc<Content>,
input: Arc<Input>,
navigation: Rc<Navigation>,
content: Rc<Content>,
input: Rc<Input>,
// Extras
meta: Arc<Meta>,
meta: Rc<Meta>,
// GTK
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Page {
// Constructors
/// Create new activated `Arc<Self>`
pub fn new_arc(
/// Create new activated `Rc<Self>`
pub fn new_rc(
id: GString,
action_tab_open: SimpleAction,
action_page_home: SimpleAction,
@ -59,16 +59,16 @@ impl Page {
action_page_history_forward: SimpleAction,
action_page_reload: SimpleAction,
action_update: SimpleAction,
) -> Arc<Self> {
) -> Rc<Self> {
// Init local actions
let action_page_load = SimpleAction::new(&uuid_string_random(), None);
let action_page_open =
SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type()));
// Init components
let content = Content::new_arc(action_tab_open.clone(), action_page_open.clone());
let content = Content::new_rc(action_tab_open.clone(), action_page_open.clone());
let navigation = Navigation::new_arc(
let navigation = Navigation::new_rc(
action_page_home.clone(),
action_page_history_back.clone(),
action_page_history_forward.clone(),
@ -77,9 +77,9 @@ impl Page {
action_update.clone(),
);
let input = Input::new_arc();
let input = Input::new_rc();
let widget = Widget::new_arc(
let widget = Widget::new_rc(
&id,
action_page_open.clone(),
navigation.gobject(),
@ -87,10 +87,10 @@ impl Page {
input.gobject(),
);
let meta = Meta::new_arc(Status::New, gformat!("New page"));
let meta = Meta::new_rc(Status::New, gformat!("New page"));
// Init `Self`
let this = Arc::new(Self {
let this = Rc::new(Self {
id,
// Actions
action_page_load: action_page_load.clone(),
@ -287,9 +287,9 @@ impl Page {
}
}
} else {
// Plain text given, make search request to default provider
// Plain text given, make seRch request to default provider
let request = gformat!(
"gemini://tlgs.one/search?{}",
"gemini://tlgs.one/seRch?{}",
Uri::escape_string(&request, None, false)
);

View file

@ -13,7 +13,7 @@ use gtk::{
prelude::{BoxExt, WidgetExt},
Box, Orientation,
};
use std::{sync::Arc, time::Duration};
use std::{rc::Rc, time::Duration};
pub struct Content {
// GTK
@ -27,8 +27,8 @@ impl Content {
// Construct
/// Create new container for different components
pub fn new_arc(action_tab_open: SimpleAction, action_page_open: SimpleAction) -> Arc<Self> {
Arc::new(Self {
pub fn new_rc(action_tab_open: SimpleAction, action_page_open: SimpleAction) -> Rc<Self> {
Rc::new(Self {
gobject: Box::builder().orientation(Orientation::Vertical).build(),
action_tab_open,
action_page_open,

View file

@ -11,11 +11,11 @@ use gtk::{
use adw::ClampScrollable;
use std::sync::Arc;
use std::rc::Rc;
pub struct Gemini {
reader: Arc<Reader>,
widget: Arc<Widget>,
reader: Rc<Reader>,
widget: Rc<Widget>,
}
impl Gemini {
@ -27,9 +27,9 @@ impl Gemini {
action_page_open: SimpleAction,
) -> Self {
// Init components
let reader = Reader::new_arc(gemtext, base, action_tab_open, action_page_open);
let reader = Reader::new_rc(gemtext, base, action_tab_open, action_page_open);
let widget = Widget::new_arc(&reader.gobject());
let widget = Widget::new_rc(&reader.gobject());
// Result
Self { reader, widget }

View file

@ -21,21 +21,21 @@ use gtk::{
UriLauncher, Window, WrapMode,
};
use std::{collections::HashMap, sync::Arc};
use std::{collections::HashMap, rc::Rc};
pub struct Reader {
title: Option<GString>,
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Reader {
// Construct
pub fn new_arc(
pub fn new_rc(
gemtext: &str,
base: &Uri,
action_tab_open: SimpleAction,
action_page_open: SimpleAction,
) -> Arc<Self> {
) -> Rc<Self> {
// Init default values
let mut title = None;
@ -223,7 +223,7 @@ impl Reader {
let motion_controller = EventControllerMotion::new();
// Init widget
let widget = Widget::new_arc(
let widget = Widget::new_rc(
&buffer,
primary_button_controller.clone(),
middle_button_controller.clone(),
@ -346,7 +346,7 @@ impl Reader {
}); // @TODO may be expensive for CPU, add timeout?
// Result
Arc::new(Self { title, widget })
Rc::new(Self { title, widget })
}
// Getters

View file

@ -1,7 +1,7 @@
use gtk::{
prelude::WidgetExt, EventControllerMotion, GestureClick, TextBuffer, TextView, WrapMode,
};
use std::sync::Arc;
use std::rc::Rc;
const MARGIN: i32 = 8;
@ -11,12 +11,12 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
pub fn new_rc(
buffer: &TextBuffer,
primary_button_controller: GestureClick,
middle_button_controller: GestureClick,
motion_controller: EventControllerMotion,
) -> Arc<Self> {
) -> Rc<Self> {
let gobject = TextView::builder()
.bottom_margin(MARGIN)
.buffer(buffer)
@ -33,7 +33,7 @@ impl Widget {
gobject.add_controller(middle_button_controller);
gobject.add_controller(motion_controller);
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -1,6 +1,6 @@
use adw::ClampScrollable;
use gtk::TextView;
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: ClampScrollable,
@ -8,8 +8,8 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(child: &TextView) -> Arc<Self> {
Arc::new(Self {
pub fn new_rc(child: &TextView) -> Rc<Self> {
Rc::new(Self {
gobject: ClampScrollable::builder()
.child(child)
.css_classes(["view"])

View file

@ -8,20 +8,20 @@ use sensitive::Sensitive;
use widget::Widget;
use adw::Clamp;
use std::sync::Arc;
use std::rc::Rc;
pub struct Input {
widget: Arc<Widget>,
widget: Rc<Widget>,
}
impl Input {
// 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
@ -38,7 +38,7 @@ impl Input {
size_limit: Option<usize>,
) {
self.widget.update(Some(
&Response::new_arc(action_page_open, base, title, size_limit).gobject(),
&Response::new_rc(action_page_open, base, title, size_limit).gobject(),
));
}
@ -50,7 +50,7 @@ impl Input {
max_length: Option<i32>,
) {
self.widget.update(Some(
&Sensitive::new_arc(action_page_open, base, title, max_length).gobject(),
&Sensitive::new_rc(action_page_open, base, title, max_length).gobject(),
));
}

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

View file

@ -6,7 +6,7 @@ use redirect::Redirect;
use gtk::glib::GString;
use sqlite::Transaction;
use std::{cell::RefCell, sync::Arc};
use std::{cell::RefCell, rc::Rc};
#[derive(Debug, Clone)]
pub enum Status {
@ -39,8 +39,8 @@ pub struct Meta {
impl Meta {
// Constructors
pub fn new_arc(status: Status, title: GString) -> Arc<Self> {
Arc::new(Self {
pub fn new_rc(status: Status, title: GString) -> Rc<Self> {
Rc::new(Self {
status: RefCell::new(status),
title: RefCell::new(title),
redirect: RefCell::new(None),

View file

@ -17,35 +17,35 @@ use widget::Widget;
use gtk::{gio::SimpleAction, glib::GString, prelude::WidgetExt, Box};
use sqlite::Transaction;
use std::sync::Arc;
use std::rc::Rc;
pub struct Navigation {
home: Arc<Home>,
bookmark: Arc<Bookmark>,
history: Arc<History>,
reload: Arc<Reload>,
request: Arc<Request>,
widget: Arc<Widget>,
home: Rc<Home>,
bookmark: Rc<Bookmark>,
history: Rc<History>,
reload: Rc<Reload>,
request: Rc<Request>,
widget: Rc<Widget>,
}
impl Navigation {
pub fn new_arc(
pub fn new_rc(
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,
) -> Arc<Self> {
) -> Rc<Self> {
// Init components
let home = Home::new_arc(action_page_home);
let history = History::new_arc(action_page_history_back, action_page_history_forward);
let reload = Reload::new_arc(action_page_reload.clone());
let request = Request::new_arc(action_update.clone(), action_page_open.clone());
let bookmark = Bookmark::new_arc();
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 bookmark = Bookmark::new_rc();
// Init widget
let widget = Widget::new_arc(
let widget = Widget::new_rc(
home.gobject(),
history.gobject(),
reload.gobject(),
@ -54,7 +54,7 @@ impl Navigation {
);
// Result
Arc::new(Self {
Rc::new(Self {
widget,
home,
history,

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

View file

@ -4,7 +4,7 @@ use gtk::{
prelude::{ActionMapExt, BoxExt, IsA, WidgetExt},
Box, Orientation,
};
use std::sync::Arc;
use std::rc::Rc;
pub struct Widget {
gobject: Box,
@ -12,7 +12,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
pub fn new_rc(
name: &str,
// Actions
action_page_open: SimpleAction,
@ -20,7 +20,7 @@ impl Widget {
navigation: &impl IsA<gtk::Widget>,
content: &impl IsA<gtk::Widget>,
input: &impl IsA<gtk::Widget>,
) -> Arc<Self> {
) -> Rc<Self> {
// Init additional action group
let action_group = SimpleActionGroup::new();
action_group.add_action(&action_page_open);
@ -37,7 +37,7 @@ impl Widget {
gobject.insert_action_group(&uuid_string_random(), Some(&action_group));
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Getters

View file

@ -5,7 +5,7 @@ use database::Database;
use adw::{TabPage, TabView};
use gtk::prelude::IsA;
use sqlite::Transaction;
use std::sync::Arc;
use std::rc::Rc;
const DEFAULT_TITLE: &str = "New page";
@ -15,7 +15,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_arc(
pub fn new_rc(
keyword: &str, // ID
tab_view: &TabView,
child: &impl IsA<gtk::Widget>,
@ -23,7 +23,7 @@ impl Widget {
position: Option<i32>,
is_pinned: bool,
is_selected: bool,
) -> Arc<Self> {
) -> Rc<Self> {
let gobject = match position {
Some(value) => {
// If given `position` match pinned tab, GTK will panic with notice:
@ -51,7 +51,7 @@ impl Widget {
tab_view.set_selected_page(&gobject);
}
Arc::new(Self { gobject })
Rc::new(Self { gobject })
}
// Actions

View file

@ -3,10 +3,7 @@ mod app;
use app::App;
use gtk::glib::{user_config_dir, ExitCode};
use sqlite::Connection;
use std::{
fs::create_dir_all,
sync::{Arc, RwLock},
};
use std::{fs::create_dir_all, rc::Rc, sync::RwLock};
const VENDOR: &str = "YGGverse";
const APP_ID: &str = "Yoda"; // env!("CARGO_PKG_NAME");
@ -36,7 +33,7 @@ fn main() -> ExitCode {
// Init database connection
let profile_database_connection = match Connection::open(profile_database_path) {
Ok(connection) => Arc::new(RwLock::new(connection)),
Ok(connection) => Rc::new(RwLock::new(connection)),
Err(e) => panic!("Failed to connect profile database: {e}"),
};