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 * implementable `struct` is public, where it members - private
* contain main `struct` implementation: * contain main `struct` implementation:
* at least one constructor that must: * 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 * grant ownership for new `Self` object created
* public `activate` action if the new object can not be activated on construct * public `activate` action if the new object can not be activated on construct
* public `link` getter for GTK `widget` (parental composition) * public `link` getter for GTK `widget` (parental composition)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
use gtk::{PackType, WindowControls}; use gtk::{PackType, WindowControls};
use std::sync::Arc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: WindowControls, gobject: WindowControls,
@ -7,8 +7,8 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // Construct
pub fn new_arc() -> Arc<Self> { pub fn new_rc() -> Rc<Self> {
Arc::new(Self { Rc::new(Self {
gobject: WindowControls::builder() gobject: WindowControls::builder()
.side(PackType::End) .side(PackType::End)
.margin_end(4) .margin_end(4)

View file

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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,7 @@ use gtk::{
prelude::{ActionExt, ButtonExt}, prelude::{ActionExt, ButtonExt},
Align, Button, Align, Button,
}; };
use std::sync::Arc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, gobject: Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // Construct
pub fn new_arc(action_page_new: SimpleAction) -> Arc<Self> { pub fn new_rc(action_page_new: SimpleAction) -> Rc<Self> {
// Init gobject // Init gobject
let gobject = Button::builder() let gobject = Button::builder()
.icon_name("tab-new-symbolic") .icon_name("tab-new-symbolic")
@ -25,7 +25,7 @@ impl Widget {
action_page_new.activate(None); action_page_new.activate(None);
}); });
Arc::new(Self { gobject }) Rc::new(Self { gobject })
} }
// Getters // Getters

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,11 +11,11 @@ use gtk::{
use adw::ClampScrollable; use adw::ClampScrollable;
use std::sync::Arc; use std::rc::Rc;
pub struct Gemini { pub struct Gemini {
reader: Arc<Reader>, reader: Rc<Reader>,
widget: Arc<Widget>, widget: Rc<Widget>,
} }
impl Gemini { impl Gemini {
@ -27,9 +27,9 @@ impl Gemini {
action_page_open: SimpleAction, action_page_open: SimpleAction,
) -> Self { ) -> Self {
// Init components // 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 // Result
Self { reader, widget } Self { reader, widget }

View file

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

View file

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

View file

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

View file

@ -8,20 +8,20 @@ use sensitive::Sensitive;
use widget::Widget; use widget::Widget;
use adw::Clamp; use adw::Clamp;
use std::sync::Arc; use std::rc::Rc;
pub struct Input { pub struct Input {
widget: Arc<Widget>, widget: Rc<Widget>,
} }
impl Input { impl Input {
// Construct // Construct
pub fn new_arc() -> Arc<Self> { pub fn new_rc() -> Rc<Self> {
// Init widget // Init widget
let widget = Widget::new_arc(); let widget = Widget::new_rc();
// Result // Result
Arc::new(Self { widget }) Rc::new(Self { widget })
} }
// Actions // Actions
@ -38,7 +38,7 @@ impl Input {
size_limit: Option<usize>, size_limit: Option<usize>,
) { ) {
self.widget.update(Some( 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>, max_length: Option<i32>,
) { ) {
self.widget.update(Some( 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}, prelude::{ActionExt, ToVariant, WidgetExt},
Box, Box,
}; };
use std::sync::Arc; use std::rc::Rc;
pub struct Response { pub struct Response {
// Components // Components
widget: Arc<Widget>, widget: Rc<Widget>,
} }
impl Response { impl Response {
// Construct // Construct
pub fn new_arc( pub fn new_rc(
action_page_open: SimpleAction, action_page_open: SimpleAction,
base: Uri, base: Uri,
title: Option<&str>, title: Option<&str>,
size_limit: Option<usize>, size_limit: Option<usize>,
) -> Arc<Self> { ) -> Rc<Self> {
// Init local actions // Init local actions
let action_update = SimpleAction::new(&uuid_string_random(), None); let action_update = SimpleAction::new(&uuid_string_random(), None);
let action_send = SimpleAction::new(&uuid_string_random(), None); let action_send = SimpleAction::new(&uuid_string_random(), None);
// Init components // Init components
let control = Control::new_arc(action_send.clone()); let control = Control::new_rc(action_send.clone());
let form = Form::new_arc(action_update.clone()); let form = Form::new_rc(action_update.clone());
let title = Title::new_arc(title); let title = Title::new_rc(title);
// Init widget // 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 // Init events
action_update.connect_activate({ action_update.connect_activate({
@ -76,7 +76,7 @@ impl Response {
widget.gobject().connect_realize(move |_| form.focus()); widget.gobject().connect_realize(move |_| form.focus());
// Return activated struct // Return activated struct
Arc::new(Self { widget }) Rc::new(Self { widget })
} }
// Getters // Getters

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,20 +3,20 @@ mod widget;
use widget::Widget; use widget::Widget;
use gtk::{gio::SimpleAction, Button}; use gtk::{gio::SimpleAction, Button};
use std::sync::Arc; use std::rc::Rc;
pub struct Back { pub struct Back {
action_page_history_back: SimpleAction, action_page_history_back: SimpleAction,
widget: Arc<Widget>, widget: Rc<Widget>,
} }
impl Back { impl Back {
// Construct // 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 // Return activated struct
Arc::new(Self { Rc::new(Self {
action_page_history_back: action_page_history_back.clone(), 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}, prelude::{ActionExt, ButtonExt, WidgetExt},
Button, Button,
}; };
use std::sync::Arc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, gobject: Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // 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 // Init gobject
let gobject = Button::builder() let gobject = Button::builder()
.icon_name("go-previous-symbolic") .icon_name("go-previous-symbolic")
@ -21,15 +21,14 @@ impl Widget {
// Init events // Init events
gobject.connect_clicked({ gobject.connect_clicked({
let action_page_history_back = let action_page_history_back = action_page_history_back.clone();
action_page_history_back.clone();
move |_| { move |_| {
action_page_history_back.activate(None); action_page_history_back.activate(None);
} }
}); });
// Return activated struct // Return activated struct
Arc::new(Self { gobject }) Rc::new(Self { gobject })
} }
// Actions // Actions

View file

@ -3,20 +3,20 @@ mod widget;
use widget::Widget; use widget::Widget;
use gtk::{gio::SimpleAction, Button}; use gtk::{gio::SimpleAction, Button};
use std::sync::Arc; use std::rc::Rc;
pub struct Forward { pub struct Forward {
action_page_history_forward: SimpleAction, action_page_history_forward: SimpleAction,
widget: Arc<Widget>, widget: Rc<Widget>,
} }
impl Forward { impl Forward {
// Construct // 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 // Return activated struct
Arc::new(Self { Rc::new(Self {
action_page_history_forward: action_page_history_forward.clone(), 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}, prelude::{ActionExt, ButtonExt, WidgetExt},
Button, Button,
}; };
use std::sync::Arc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, gobject: Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // 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 // Init gobject
let gobject = Button::builder() let gobject = Button::builder()
.icon_name("go-next-symbolic") .icon_name("go-next-symbolic")
@ -21,15 +21,14 @@ impl Widget {
// Init events // Init events
gobject.connect_clicked({ gobject.connect_clicked({
let action_page_history_forward = let action_page_history_forward = action_page_history_forward.clone();
action_page_history_forward.clone();
move |_| { move |_| {
action_page_history_forward.activate(None); action_page_history_forward.activate(None);
} }
}); });
// Return activated struct // Return activated struct
Arc::new(Self { gobject }) Rc::new(Self { gobject })
} }
// Actions // Actions

View file

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

View file

@ -7,21 +7,21 @@ use gtk::{
glib::{gformat, GString, Uri}, glib::{gformat, GString, Uri},
Button, Button,
}; };
use std::{cell::RefCell, sync::Arc}; use std::{cell::RefCell, rc::Rc};
pub struct Home { pub struct Home {
action_page_home: SimpleAction, action_page_home: SimpleAction,
uri: RefCell<Option<Uri>>, uri: RefCell<Option<Uri>>,
widget: Arc<Widget>, widget: Rc<Widget>,
} }
impl Home { impl Home {
// Construct // Construct
pub fn new_arc(action_page_home: SimpleAction) -> Arc<Self> { pub fn new_rc(action_page_home: SimpleAction) -> Rc<Self> {
Arc::new(Self { Rc::new(Self {
action_page_home: action_page_home.clone(), action_page_home: action_page_home.clone(),
uri: RefCell::new(None), 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}, prelude::{ActionExt, ButtonExt, WidgetExt},
Button, Button,
}; };
use std::sync::Arc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, gobject: Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // Construct
pub fn new_arc(action_page_home: SimpleAction) -> Arc<Self> { pub fn new_rc(action_page_home: SimpleAction) -> Rc<Self> {
// Init gobject // Init gobject
let gobject = Button::builder() let gobject = Button::builder()
.icon_name("go-home-symbolic") .icon_name("go-home-symbolic")
@ -28,7 +28,7 @@ impl Widget {
}); });
// Return activated struct // Return activated struct
Arc::new(Self { gobject }) Rc::new(Self { gobject })
} }
// Actions // Actions

View file

@ -3,19 +3,19 @@ mod widget;
use widget::Widget; use widget::Widget;
use gtk::{gio::SimpleAction, Button}; use gtk::{gio::SimpleAction, Button};
use std::sync::Arc; use std::rc::Rc;
pub struct Reload { pub struct Reload {
action_page_reload: SimpleAction, action_page_reload: SimpleAction,
widget: Arc<Widget>, widget: Rc<Widget>,
} }
impl Reload { impl Reload {
// Construct // Construct
pub fn new_arc(action_page_reload: SimpleAction) -> Arc<Self> { pub fn new_rc(action_page_reload: SimpleAction) -> Rc<Self> {
Arc::new(Self { Rc::new(Self {
action_page_reload: action_page_reload.clone(), 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}, prelude::{ActionExt, ButtonExt, WidgetExt},
Button, Button,
}; };
use std::sync::Arc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, gobject: Button,
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // Construct
pub fn new_arc(action_page_reload: SimpleAction) -> Arc<Self> { pub fn new_rc(action_page_reload: SimpleAction) -> Rc<Self> {
// Init gobject // Init gobject
let gobject = Button::builder() let gobject = Button::builder()
.icon_name("view-refresh-symbolic") .icon_name("view-refresh-symbolic")
@ -28,7 +28,7 @@ impl Widget {
}); });
// Return activated struct // Return activated struct
Arc::new(Self { gobject }) Rc::new(Self { gobject })
} }
// Actions // Actions

View file

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

View file

@ -9,9 +9,9 @@ use gtk::{
Entry, StateFlags, Entry, StateFlags,
}; };
use sqlite::Transaction; 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 // Progress bar animation setup
const PROGRESS_ANIMATION_STEP: f64 = 0.05; const PROGRESS_ANIMATION_STEP: f64 = 0.05;
@ -24,14 +24,14 @@ struct Progress {
pub struct Widget { pub struct Widget {
gobject: Entry, gobject: Entry,
progress: Arc<Progress>, progress: Rc<Progress>,
} }
impl Widget { impl Widget {
// Construct // 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 // Init animated progress bar state
let progress = Arc::new(Progress { let progress = Rc::new(Progress {
fraction: RefCell::new(0.0), fraction: RefCell::new(0.0),
source_id: RefCell::new(None), source_id: RefCell::new(None),
}); });
@ -73,7 +73,7 @@ impl Widget {
}); });
// Return activated struct // Return activated struct
Arc::new(Self { gobject, progress }) Rc::new(Self { gobject, progress })
} }
// Actions // Actions

View file

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

View file

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

View file

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

View file

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