diff --git a/src/app/browser/window.rs b/src/app/browser/window.rs index 800d9bd0..98ca7662 100644 --- a/src/app/browser/window.rs +++ b/src/app/browser/window.rs @@ -32,8 +32,8 @@ impl Window { let action = Rc::new(Action::new()); // Init components - let tab = Tab::new_rc(browser_action.clone(), action.clone()); - let header = Header::new_rc(browser_action, action.clone(), tab.gobject()); + let tab = Rc::new(Tab::new(browser_action.clone(), action.clone())); + let header = Header::new(browser_action, action.clone(), tab.gobject()); // GTK let widget = Rc::new(Widget::new(header.gobject(), tab.gobject())); diff --git a/src/app/browser/window/header.rs b/src/app/browser/window/header.rs index e683c528..656ea47b 100644 --- a/src/app/browser/window/header.rs +++ b/src/app/browser/window/header.rs @@ -15,20 +15,20 @@ pub struct Header { impl Header { // Construct - pub fn new_rc( + pub fn new( // Actions browser_action: Rc, window_action: Rc, // Widgets tab_view: &TabView, - ) -> Rc { + ) -> Self { // Init components - let bar = Bar::new_rc(browser_action, window_action, tab_view); + let bar = Bar::new(browser_action, window_action, tab_view); // Return new struct - Rc::new(Self { - widget: Widget::new_rc(bar.gobject()), - }) + Self { + widget: Rc::new(Widget::new(bar.gobject())), + } } // Getters diff --git a/src/app/browser/window/header/bar.rs b/src/app/browser/window/header/bar.rs index 8c4c3582..d7cbce79 100644 --- a/src/app/browser/window/header/bar.rs +++ b/src/app/browser/window/header/bar.rs @@ -19,24 +19,27 @@ pub struct Bar { } impl Bar { - // Construct - pub fn new_rc( + // Constructors + + pub fn new( browser_action: Rc, window_action: Rc, view: &TabView, - ) -> Rc { - // Init components - let control = Control::new_rc(); - let tab = Tab::new_rc(window_action.clone(), view); - let menu = Menu::new_rc(browser_action, window_action); - - // Build result - Rc::new(Self { - widget: Widget::new_rc(control.gobject(), menu.gobject(), tab.gobject()), - }) + ) -> Self { + let control = Control::new(); + let tab = Tab::new(window_action.clone(), view); + let menu = Menu::new(browser_action, window_action); + Self { + widget: Rc::new(Widget::new( + control.gobject(), + menu.gobject(), + tab.gobject(), + )), + } } // Getters + pub fn gobject(&self) -> &Box { self.widget.gobject() } diff --git a/src/app/browser/window/header/bar/control.rs b/src/app/browser/window/header/bar/control.rs index ddda9117..a03881f4 100644 --- a/src/app/browser/window/header/bar/control.rs +++ b/src/app/browser/window/header/bar/control.rs @@ -11,10 +11,10 @@ pub struct Control { impl Control { // Construct - pub fn new_rc() -> Rc { - Rc::new(Self { - widget: Widget::new_rc(), - }) + pub fn new() -> Self { + Self { + widget: Rc::new(Widget::new()), + } } // Getters diff --git a/src/app/browser/window/header/bar/control/widget.rs b/src/app/browser/window/header/bar/control/widget.rs index 85164384..af0f2f44 100644 --- a/src/app/browser/window/header/bar/control/widget.rs +++ b/src/app/browser/window/header/bar/control/widget.rs @@ -1,5 +1,4 @@ use gtk::{PackType, WindowControls}; -use std::rc::Rc; pub struct Widget { gobject: WindowControls, @@ -7,13 +6,13 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc() -> Rc { - Rc::new(Self { + pub fn new() -> Self { + Self { gobject: WindowControls::builder() .side(PackType::End) .margin_end(4) .build(), - }) + } } // Getters diff --git a/src/app/browser/window/header/bar/menu.rs b/src/app/browser/window/header/bar/menu.rs index 51beb995..6ba6c58b 100644 --- a/src/app/browser/window/header/bar/menu.rs +++ b/src/app/browser/window/header/bar/menu.rs @@ -15,10 +15,10 @@ pub struct Menu { } #[rustfmt::skip] // @TODO template builder? impl Menu { - pub fn new_rc( + pub fn new( browser_action: Rc, window_action: Rc, - ) -> Rc { + ) -> Self { // Main let main = gio::Menu::new(); @@ -120,7 +120,7 @@ impl Menu { ))); // Result - Rc::new(Self { widget:Widget::new_rc(&main) }) + Self { widget:Rc::new(Widget::new(&main)) } } // Getters diff --git a/src/app/browser/window/header/bar/menu/widget.rs b/src/app/browser/window/header/bar/menu/widget.rs index 54cf2385..672fec55 100644 --- a/src/app/browser/window/header/bar/menu/widget.rs +++ b/src/app/browser/window/header/bar/menu/widget.rs @@ -1,5 +1,4 @@ use gtk::{gio::Menu, Align, MenuButton}; -use std::rc::Rc; pub struct Widget { gobject: MenuButton, @@ -7,8 +6,8 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(model: &Menu) -> Rc { - Rc::new(Self { + pub fn new(model: &Menu) -> Self { + Self { gobject: MenuButton::builder() .css_classes(["flat"]) .icon_name("open-menu-symbolic") @@ -16,7 +15,7 @@ impl Widget { .tooltip_text("Menu") .valign(Align::Center) .build(), - }) + } } // Getters diff --git a/src/app/browser/window/header/bar/tab.rs b/src/app/browser/window/header/bar/tab.rs index f976e4b4..c5cedbec 100644 --- a/src/app/browser/window/header/bar/tab.rs +++ b/src/app/browser/window/header/bar/tab.rs @@ -14,10 +14,10 @@ pub struct Tab { impl Tab { // Construct - pub fn new_rc(window_action: Rc, view: &TabView) -> Rc { - Rc::new(Self { - widget: Widget::new_rc(view, Append::new_rc(window_action).gobject()), - }) + pub fn new(window_action: Rc, view: &TabView) -> Self { + Self { + widget: Rc::new(Widget::new(view, Append::new(window_action).gobject())), + } } // Getters diff --git a/src/app/browser/window/header/bar/tab/append.rs b/src/app/browser/window/header/bar/tab/append.rs index fa697c2f..eda2a8f3 100644 --- a/src/app/browser/window/header/bar/tab/append.rs +++ b/src/app/browser/window/header/bar/tab/append.rs @@ -12,10 +12,10 @@ pub struct Append { impl Append { // Construct - pub fn new_rc(window_action: Rc) -> Rc { - Rc::new(Self { - widget: Widget::new_rc(window_action), - }) + pub fn new(window_action: Rc) -> Self { + Self { + widget: Rc::new(Widget::new(window_action)), + } } // Getters diff --git a/src/app/browser/window/header/bar/tab/append/widget.rs b/src/app/browser/window/header/bar/tab/append/widget.rs index e4aeb74e..368675ce 100644 --- a/src/app/browser/window/header/bar/tab/append/widget.rs +++ b/src/app/browser/window/header/bar/tab/append/widget.rs @@ -8,7 +8,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(window_action: Rc) -> Rc { + pub fn new(window_action: Rc) -> Self { // Init gobject let gobject = Button::builder() .icon_name("tab-new-symbolic") @@ -20,7 +20,7 @@ impl Widget { // Init events gobject.connect_clicked(move |_| window_action.append().activate()); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/header/bar/tab/widget.rs b/src/app/browser/window/header/bar/tab/widget.rs index 1fbc05cf..7c359d61 100644 --- a/src/app/browser/window/header/bar/tab/widget.rs +++ b/src/app/browser/window/header/bar/tab/widget.rs @@ -1,6 +1,5 @@ use adw::{TabBar, TabView}; use gtk::prelude::IsA; -use std::rc::Rc; pub struct Widget { gobject: TabBar, @@ -8,15 +7,15 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(view: &TabView, start_action_widget: &impl IsA) -> Rc { - Rc::new(Self { + pub fn new(view: &TabView, start_action_widget: &impl IsA) -> Self { + Self { gobject: TabBar::builder() .autohide(false) .expand_tabs(false) .end_action_widget(start_action_widget) // @TODO find solution to append after tabs .view(view) .build(), - }) + } } // Getters diff --git a/src/app/browser/window/header/bar/widget.rs b/src/app/browser/window/header/bar/widget.rs index 527eb135..86754b44 100644 --- a/src/app/browser/window/header/bar/widget.rs +++ b/src/app/browser/window/header/bar/widget.rs @@ -1,6 +1,5 @@ use adw::TabBar; use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls}; -use std::rc::Rc; pub struct Widget { gobject: Box, @@ -8,7 +7,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Rc { + pub fn new(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Self { let gobject = Box::builder() .orientation(Orientation::Horizontal) .spacing(8) @@ -18,7 +17,7 @@ impl Widget { gobject.append(menu); gobject.append(control); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/header/widget.rs b/src/app/browser/window/header/widget.rs index 6f6d26fc..d4c7a7b9 100644 --- a/src/app/browser/window/header/widget.rs +++ b/src/app/browser/window/header/widget.rs @@ -1,6 +1,5 @@ use adw::ToolbarView; use gtk::Box; -use std::rc::Rc; pub struct Widget { gobject: ToolbarView, @@ -8,12 +7,12 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(top_bar: &Box) -> Rc { + pub fn new(top_bar: &Box) -> Self { let gobject = ToolbarView::builder().build(); gobject.add_top_bar(top_bar); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index 6d39fbbf..6f8e7bd3 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -33,7 +33,7 @@ pub struct Tab { impl Tab { // Construct - pub fn new_rc(browser_action: Rc, window_action: Rc) -> Rc { + pub fn new(browser_action: Rc, window_action: Rc) -> Self { // Init local actions let action = Rc::new(Action::new()); @@ -115,14 +115,14 @@ impl Tab { } }); // @TODO fix new item on middle click - // Return activated struct - Rc::new(Self { + // Return activated `Self` + Self { browser_action, window_action, index, action, widget, - }) + } } // Actions diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 30b2f40c..fc296b66 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -51,7 +51,7 @@ impl Item { tab_action, ); - let widget = Widget::new_rc( + let widget = Rc::new(Widget::new( id.as_str(), tab_view, page.gobject(), @@ -59,7 +59,7 @@ impl Item { position, is_pinned, is_selected, - ); // @TODO + )); // @TODO // Return struct Rc::new(Self { id, page, widget }) diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 4d291cac..01e37130 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -67,25 +67,25 @@ impl Page { SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type())); // Init components - let content = Content::new_rc(tab_action.clone(), action_page_open.clone()); + let content = Rc::new(Content::new(tab_action.clone(), action_page_open.clone())); - let navigation = Navigation::new_rc( + let navigation = Rc::new(Navigation::new( browser_action.clone(), window_action.clone(), action_page_open.clone(), - ); + )); - let input = Input::new_rc(); + let input = Rc::new(Input::new()); - let widget = Widget::new_rc( + let widget = Rc::new(Widget::new( &id, action_page_open.clone(), navigation.widget().gobject(), content.gobject(), input.gobject(), - ); + )); - let meta = Meta::new_rc(Status::New, gformat!("New page")); + let meta = Rc::new(Meta::new(Status::New, gformat!("New page"))); // Init `Self` let this = Rc::new(Self { diff --git a/src/app/browser/window/tab/item/page/content.rs b/src/app/browser/window/tab/item/page/content.rs index 281efca6..2b4d4977 100644 --- a/src/app/browser/window/tab/item/page/content.rs +++ b/src/app/browser/window/tab/item/page/content.rs @@ -28,12 +28,12 @@ impl Content { // Construct /// Create new container for different components - pub fn new_rc(tab_action: Rc, action_page_open: SimpleAction) -> Rc { - Rc::new(Self { + pub fn new(tab_action: Rc, action_page_open: SimpleAction) -> Self { + Self { gobject: Box::builder().orientation(Orientation::Vertical).build(), tab_action, action_page_open, - }) + } } // Actions diff --git a/src/app/browser/window/tab/item/page/content/text/gemini.rs b/src/app/browser/window/tab/item/page/content/text/gemini.rs index 9af567e3..14e32cc2 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini.rs @@ -26,9 +26,8 @@ impl Gemini { action_page_open: SimpleAction, ) -> Self { // Init components - let reader = Reader::new_rc(gemtext, base, tab_action, action_page_open); - - let widget = Widget::new_rc(reader.gobject()); + let reader = Rc::new(Reader::new(gemtext, base, tab_action, action_page_open)); + let widget = Rc::new(Widget::new(reader.gobject())); // Result Self { reader, widget } diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs index 720ddb05..ccc54954 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader.rs @@ -30,12 +30,12 @@ pub struct Reader { impl Reader { // Construct - pub fn new_rc( + pub fn new( gemtext: &str, base: &Uri, tab_action: Rc, action_page_open: SimpleAction, - ) -> Rc { + ) -> Self { // Init default values let mut title = None; @@ -223,12 +223,12 @@ impl Reader { let motion_controller = EventControllerMotion::new(); // Init widget - let widget = Widget::new_rc( + let widget = Rc::new(Widget::new( &buffer, primary_button_controller.clone(), middle_button_controller.clone(), motion_controller.clone(), - ); + )); // Init events primary_button_controller.connect_released({ @@ -346,7 +346,7 @@ impl Reader { }); // @TODO may be expensive for CPU, add timeout? // Result - Rc::new(Self { title, widget }) + Self { title, widget } } // Getters diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/widget.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/widget.rs index 17e878c1..9b635e60 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/widget.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/widget.rs @@ -1,7 +1,6 @@ use gtk::{ prelude::WidgetExt, EventControllerMotion, GestureClick, TextBuffer, TextView, WrapMode, }; -use std::rc::Rc; const MARGIN: i32 = 8; @@ -11,12 +10,12 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc( + pub fn new( buffer: &TextBuffer, primary_button_controller: GestureClick, middle_button_controller: GestureClick, motion_controller: EventControllerMotion, - ) -> Rc { + ) -> Self { let gobject = TextView::builder() .bottom_margin(MARGIN) .buffer(buffer) @@ -33,7 +32,7 @@ impl Widget { gobject.add_controller(middle_button_controller); gobject.add_controller(motion_controller); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/widget.rs b/src/app/browser/window/tab/item/page/content/text/gemini/widget.rs index daf8ebf6..3e55a854 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/widget.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/widget.rs @@ -1,6 +1,5 @@ use adw::ClampScrollable; use gtk::TextView; -use std::rc::Rc; pub struct Widget { gobject: ClampScrollable, @@ -8,14 +7,14 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(child: &TextView) -> Rc { - Rc::new(Self { + pub fn new(child: &TextView) -> Self { + Self { gobject: ClampScrollable::builder() .child(child) .css_classes(["view"]) .maximum_size(800) .build(), - }) + } } // Getters diff --git a/src/app/browser/window/tab/item/page/input.rs b/src/app/browser/window/tab/item/page/input.rs index d7ceb214..32b46a17 100644 --- a/src/app/browser/window/tab/item/page/input.rs +++ b/src/app/browser/window/tab/item/page/input.rs @@ -17,12 +17,12 @@ pub struct Input { impl Input { // Construct - pub fn new_rc() -> Rc { + pub fn new() -> Self { // Init widget - let widget = Widget::new_rc(); + let widget = Rc::new(Widget::new()); // Result - Rc::new(Self { widget }) + Self { widget } } // Actions @@ -39,7 +39,7 @@ impl Input { size_limit: Option, ) { self.widget.update(Some( - Response::new_rc(action, base, title, size_limit).gobject(), + Response::new(action, base, title, size_limit).gobject(), )); } @@ -51,7 +51,7 @@ impl Input { max_length: Option, ) { self.widget.update(Some( - Sensitive::new_rc(action, base, title, max_length).gobject(), + Sensitive::new(action, base, title, max_length).gobject(), )); } diff --git a/src/app/browser/window/tab/item/page/input/response.rs b/src/app/browser/window/tab/item/page/input/response.rs index 7c877c1f..79d513a3 100644 --- a/src/app/browser/window/tab/item/page/input/response.rs +++ b/src/app/browser/window/tab/item/page/input/response.rs @@ -24,23 +24,27 @@ pub struct Response { impl Response { // Construct - pub fn new_rc( + pub fn new( tab_action: Rc, base: Uri, title: Option<&str>, size_limit: Option, - ) -> 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_rc(action_send.clone()); - let form = Form::new_rc(action_update.clone()); - let title = Title::new_rc(title); + let control = Rc::new(Control::new(action_send.clone())); + let form = Rc::new(Form::new(action_update.clone())); + let title = Rc::new(Title::new(title)); // Init widget - let widget = Widget::new_rc(title.gobject(), form.gobject(), control.gobject()); + let widget = Rc::new(Widget::new( + title.gobject(), + form.gobject(), + control.gobject(), + )); // Init events action_update.connect_activate({ @@ -70,7 +74,7 @@ impl Response { widget.gobject().connect_realize(move |_| form.focus()); // Return activated struct - Rc::new(Self { widget }) + Self { widget } } // Getters diff --git a/src/app/browser/window/tab/item/page/input/response/control.rs b/src/app/browser/window/tab/item/page/input/response/control.rs index a23c3df6..9b9ea7ab 100644 --- a/src/app/browser/window/tab/item/page/input/response/control.rs +++ b/src/app/browser/window/tab/item/page/input/response/control.rs @@ -17,20 +17,20 @@ pub struct Control { impl Control { // Construct - pub fn new_rc(action_send: SimpleAction) -> Rc { + pub fn new(action_send: SimpleAction) -> Self { // Init components - let counter = Counter::new_rc(); - let send = Send::new_rc(action_send); + let counter = Rc::new(Counter::new()); + let send = Rc::new(Send::new(action_send)); // Init widget - let widget = Widget::new_rc(counter.gobject(), send.gobject()); + let widget = Rc::new(Widget::new(counter.gobject(), send.gobject())); // Return activated struct - Rc::new(Self { + Self { counter, send, widget, - }) + } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/response/control/counter.rs b/src/app/browser/window/tab/item/page/input/response/control/counter.rs index b950eae0..ae62ff24 100644 --- a/src/app/browser/window/tab/item/page/input/response/control/counter.rs +++ b/src/app/browser/window/tab/item/page/input/response/control/counter.rs @@ -11,12 +11,10 @@ pub struct Counter { impl Counter { // Construct - pub fn new_rc() -> Rc { - // Init widget - let widget = Widget::new_rc(); - - // Result - Rc::new(Self { widget }) + pub fn new() -> Self { + Self { + widget: Rc::new(Widget::new()), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/response/control/counter/widget.rs b/src/app/browser/window/tab/item/page/input/response/control/counter/widget.rs index 91da73de..ab58a5dd 100644 --- a/src/app/browser/window/tab/item/page/input/response/control/counter/widget.rs +++ b/src/app/browser/window/tab/item/page/input/response/control/counter/widget.rs @@ -1,5 +1,4 @@ use gtk::{prelude::WidgetExt, Label}; -use std::rc::Rc; pub struct Widget { gobject: Label, @@ -7,10 +6,10 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc() -> Rc { - let gobject = Label::builder().build(); - - Rc::new(Self { gobject }) + pub fn new() -> Self { + Self { + gobject: Label::builder().build(), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/response/control/send.rs b/src/app/browser/window/tab/item/page/input/response/control/send.rs index a255c798..21d4514a 100644 --- a/src/app/browser/window/tab/item/page/input/response/control/send.rs +++ b/src/app/browser/window/tab/item/page/input/response/control/send.rs @@ -1,5 +1,4 @@ mod widget; - use widget::Widget; use gtk::{gio::SimpleAction, Button}; @@ -11,12 +10,12 @@ pub struct Send { impl Send { // Construct - pub fn new_rc(action_send: SimpleAction) -> Rc { + pub fn new(action_send: SimpleAction) -> Self { // Init widget - let widget = Widget::new_rc(action_send); + let widget = Rc::new(Widget::new(action_send)); // Result - Rc::new(Self { widget }) + Self { widget } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/response/control/send/widget.rs b/src/app/browser/window/tab/item/page/input/response/control/send/widget.rs index 2b06b120..d3706868 100644 --- a/src/app/browser/window/tab/item/page/input/response/control/send/widget.rs +++ b/src/app/browser/window/tab/item/page/input/response/control/send/widget.rs @@ -3,7 +3,6 @@ use gtk::{ prelude::{ActionExt, ButtonExt, WidgetExt}, Button, }; -use std::rc::Rc; pub struct Widget { gobject: Button, @@ -11,7 +10,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(action_send: SimpleAction) -> Rc { + pub fn new(action_send: SimpleAction) -> Self { // Init gobject let gobject = Button::builder() //.css_classes(["accent"]) @@ -25,8 +24,8 @@ impl Widget { } }); - // Return activated struct - Rc::new(Self { gobject }) + // Return activated `Self` + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/response/control/widget.rs b/src/app/browser/window/tab/item/page/input/response/control/widget.rs index 79d94f74..1fec9bb4 100644 --- a/src/app/browser/window/tab/item/page/input/response/control/widget.rs +++ b/src/app/browser/window/tab/item/page/input/response/control/widget.rs @@ -1,5 +1,4 @@ use gtk::{prelude::BoxExt, Align, Box, Button, Label, Orientation}; -use std::rc::Rc; const SPACING: i32 = 8; @@ -9,7 +8,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(limit: &Label, send: &Button) -> Rc { + pub fn new(limit: &Label, send: &Button) -> Self { // Init gobject let gobject = Box::builder() .halign(Align::End) @@ -20,8 +19,8 @@ impl Widget { gobject.append(limit); gobject.append(send); - // Return new struct - Rc::new(Self { gobject }) + // Return new `Self` + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/page/input/response/form.rs b/src/app/browser/window/tab/item/page/input/response/form.rs index 47a03dd6..ee67e718 100644 --- a/src/app/browser/window/tab/item/page/input/response/form.rs +++ b/src/app/browser/window/tab/item/page/input/response/form.rs @@ -11,12 +11,10 @@ pub struct Form { impl Form { // Construct - pub fn new_rc(action_update: SimpleAction) -> Rc { - // Init widget - let widget = Widget::new_rc(action_update); - - // Result - Rc::new(Self { widget }) + pub fn new(action_update: SimpleAction) -> Self { + Self { + widget: Rc::new(Widget::new(action_update)), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/response/form/widget.rs b/src/app/browser/window/tab/item/page/input/response/form/widget.rs index e37a892b..fa3d7d97 100644 --- a/src/app/browser/window/tab/item/page/input/response/form/widget.rs +++ b/src/app/browser/window/tab/item/page/input/response/form/widget.rs @@ -4,7 +4,6 @@ use gtk::{ prelude::{ActionExt, TextBufferExt, TextViewExt, WidgetExt}, TextView, WrapMode, }; -use std::rc::Rc; const MARGIN: i32 = 8; @@ -14,7 +13,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(action_update: SimpleAction) -> Rc { + pub fn new(action_update: SimpleAction) -> Self { // Init gobject let gobject = TextView::builder() .bottom_margin(MARGIN) @@ -29,8 +28,8 @@ impl Widget { action_update.activate(None); }); - // Return activated struct - Rc::new(Self { gobject }) + // Return activated `Self` + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/response/title.rs b/src/app/browser/window/tab/item/page/input/response/title.rs index 9f4e2ade..73e713ab 100644 --- a/src/app/browser/window/tab/item/page/input/response/title.rs +++ b/src/app/browser/window/tab/item/page/input/response/title.rs @@ -11,12 +11,10 @@ pub struct Title { impl Title { // Construct - pub fn new_rc(title: Option<&str>) -> Rc { - // Init widget - let widget = Widget::new_rc(title); - - // Result - Rc::new(Self { widget }) + pub fn new(title: Option<&str>) -> Self { + Self { + widget: Rc::new(Widget::new(title)), + } } // Getters diff --git a/src/app/browser/window/tab/item/page/input/response/title/widget.rs b/src/app/browser/window/tab/item/page/input/response/title/widget.rs index 45f56521..54881031 100644 --- a/src/app/browser/window/tab/item/page/input/response/title/widget.rs +++ b/src/app/browser/window/tab/item/page/input/response/title/widget.rs @@ -1,5 +1,4 @@ use gtk::{prelude::WidgetExt, Align, Label}; -use std::rc::Rc; pub struct Widget { gobject: Label, @@ -7,7 +6,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(title: Option<&str>) -> Rc { + pub fn new(title: Option<&str>) -> Self { let gobject = Label::builder() .css_classes(["heading"]) .halign(Align::Start) @@ -23,7 +22,7 @@ impl Widget { } } - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/page/input/response/widget.rs b/src/app/browser/window/tab/item/page/input/response/widget.rs index cb42204a..ad3587ba 100644 --- a/src/app/browser/window/tab/item/page/input/response/widget.rs +++ b/src/app/browser/window/tab/item/page/input/response/widget.rs @@ -1,5 +1,4 @@ use gtk::{prelude::BoxExt, Box, Label, Orientation, TextView}; -use std::rc::Rc; const MARGIN: i32 = 6; const SPACING: i32 = 8; @@ -10,7 +9,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(title: &Label, response: &TextView, control: &Box) -> Rc { + pub fn new(title: &Label, response: &TextView, control: &Box) -> Self { let gobject = Box::builder() .margin_bottom(MARGIN) .margin_end(MARGIN) @@ -24,7 +23,7 @@ impl Widget { gobject.append(response); gobject.append(control); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/page/input/sensitive.rs b/src/app/browser/window/tab/item/page/input/sensitive.rs index f927ba13..75c418aa 100644 --- a/src/app/browser/window/tab/item/page/input/sensitive.rs +++ b/src/app/browser/window/tab/item/page/input/sensitive.rs @@ -20,25 +20,25 @@ pub struct Sensitive { impl Sensitive { // Construct - pub fn new_rc( + pub fn new( tab_action: Rc, base: Uri, title: Option<&str>, max_length: Option, - ) -> Rc { + ) -> Self { // Init local actions let action_send = SimpleAction::new(&uuid_string_random(), None); // Init components - let form = Form::new_rc( + let form = Rc::new(Form::new( action_send.clone(), title, max_length .map(|value| value - base.to_string_partial(UriHideFlags::QUERY).len() as i32), - ); + )); // Init widget - let widget = Widget::new_rc(form.gobject()); + let widget = Rc::new(Widget::new(form.gobject())); // Init events action_send.connect_activate({ @@ -55,7 +55,7 @@ impl Sensitive { widget.gobject().connect_realize(move |_| form.focus()); // Return activated struct - Rc::new(Self { widget }) + Self { widget } } // Getters diff --git a/src/app/browser/window/tab/item/page/input/sensitive/form.rs b/src/app/browser/window/tab/item/page/input/sensitive/form.rs index fc29ec90..4978a271 100644 --- a/src/app/browser/window/tab/item/page/input/sensitive/form.rs +++ b/src/app/browser/window/tab/item/page/input/sensitive/form.rs @@ -12,16 +12,12 @@ pub struct Form { impl Form { // Construct - pub fn new_rc( - action_send: SimpleAction, - title: Option<&str>, - max_length: Option, - ) -> Rc { + pub fn new(action_send: SimpleAction, title: Option<&str>, max_length: Option) -> Self { // Init widget - let widget = Widget::new_rc(action_send, title, max_length); + let widget = Rc::new(Widget::new(action_send, title, max_length)); // Result - Rc::new(Self { widget }) + Self { widget } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/sensitive/form/widget.rs b/src/app/browser/window/tab/item/page/input/sensitive/form/widget.rs index f122a3e5..123abbac 100644 --- a/src/app/browser/window/tab/item/page/input/sensitive/form/widget.rs +++ b/src/app/browser/window/tab/item/page/input/sensitive/form/widget.rs @@ -7,7 +7,6 @@ use gtk::{ glib::GString, prelude::{ActionExt, EditableExt, WidgetExt}, }; -use std::rc::Rc; pub struct Widget { gobject: PasswordEntryRow, @@ -15,11 +14,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc( - action_send: SimpleAction, - title: Option<&str>, - max_length: Option, - ) -> Rc { + pub fn new(action_send: SimpleAction, title: Option<&str>, max_length: Option) -> Self { // Init gobject let gobject = PasswordEntryRow::builder().show_apply_button(true).build(); @@ -37,7 +32,7 @@ impl Widget { }); // Return activated struct - Rc::new(Self { gobject }) + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/input/sensitive/widget.rs b/src/app/browser/window/tab/item/page/input/sensitive/widget.rs index 62301dc4..0629fd1d 100644 --- a/src/app/browser/window/tab/item/page/input/sensitive/widget.rs +++ b/src/app/browser/window/tab/item/page/input/sensitive/widget.rs @@ -1,6 +1,5 @@ use adw::PasswordEntryRow; use gtk::{prelude::BoxExt, Box, Orientation}; -use std::rc::Rc; const MARGIN: i32 = 6; const SPACING: i32 = 8; @@ -11,7 +10,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(response: &PasswordEntryRow) -> Rc { + pub fn new(response: &PasswordEntryRow) -> Self { let gobject = Box::builder() .margin_bottom(MARGIN) .margin_end(MARGIN) @@ -23,7 +22,7 @@ impl Widget { gobject.append(response); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/page/input/widget.rs b/src/app/browser/window/tab/item/page/input/widget.rs index be2494f9..ac782711 100644 --- a/src/app/browser/window/tab/item/page/input/widget.rs +++ b/src/app/browser/window/tab/item/page/input/widget.rs @@ -1,6 +1,5 @@ use adw::Clamp; use gtk::{prelude::WidgetExt, Box}; -use std::rc::Rc; pub struct Widget { gobject: Clamp, @@ -8,14 +7,14 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc() -> Rc { + pub fn new() -> Self { let gobject = Clamp::builder() .css_classes(["app-notification"]) .maximum_size(800) .visible(false) .build(); - Rc::new(Self { gobject }) + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/meta.rs b/src/app/browser/window/tab/item/page/meta.rs index ad214289..953b683f 100644 --- a/src/app/browser/window/tab/item/page/meta.rs +++ b/src/app/browser/window/tab/item/page/meta.rs @@ -6,7 +6,7 @@ use redirect::Redirect; use gtk::glib::GString; use sqlite::Transaction; -use std::{cell::RefCell, rc::Rc}; +use std::cell::RefCell; #[derive(Debug, Clone)] pub enum Status { @@ -39,13 +39,13 @@ pub struct Meta { impl Meta { // Constructors - pub fn new_rc(status: Status, title: GString) -> Rc { - Rc::new(Self { + pub fn new(status: Status, title: GString) -> Self { + Self { status: RefCell::new(status), title: RefCell::new(title), redirect: RefCell::new(None), redirect_count: RefCell::new(None), - }) + } } // Setters diff --git a/src/app/browser/window/tab/item/page/navigation.rs b/src/app/browser/window/tab/item/page/navigation.rs index 5437dbaa..036273cb 100644 --- a/src/app/browser/window/tab/item/page/navigation.rs +++ b/src/app/browser/window/tab/item/page/navigation.rs @@ -30,36 +30,36 @@ pub struct Navigation { } impl Navigation { - pub fn new_rc( + pub fn new( browser_action: Rc, window_action: Rc, action_page_open: SimpleAction, - ) -> Rc { + ) -> Self { // Init components - let home = Home::new_rc(window_action.clone()); - let history = History::new_rc(window_action.clone()); - let reload = Reload::new_rc(window_action); - let request = Request::new_rc(browser_action, action_page_open.clone()); - let bookmark = Bookmark::new_rc(); + let home = Rc::new(Home::new(window_action.clone())); + let history = Rc::new(History::new(window_action.clone())); + let reload = Rc::new(Reload::new(window_action)); + let request = Rc::new(Request::new(browser_action, action_page_open.clone())); + let bookmark = Rc::new(Bookmark::new()); // Init widget - let widget = Widget::new_rc( + let widget = Rc::new(Widget::new( home.gobject(), history.gobject(), reload.gobject(), request.widget().gobject(), bookmark.gobject(), - ); + )); - // Result - Rc::new(Self { + // Done + Self { widget, home, history, reload, request, bookmark, - }) + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/bookmark.rs b/src/app/browser/window/tab/item/page/navigation/bookmark.rs index ff099eca..8e4ec699 100644 --- a/src/app/browser/window/tab/item/page/navigation/bookmark.rs +++ b/src/app/browser/window/tab/item/page/navigation/bookmark.rs @@ -11,10 +11,10 @@ pub struct Bookmark { impl Bookmark { // Construct - pub fn new_rc() -> Rc { - Rc::new(Self { - widget: Widget::new_rc(), - }) + pub fn new() -> Self { + Self { + widget: Rc::new(Widget::new()), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs b/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs index 2a110328..d0e904d1 100644 --- a/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs @@ -1,5 +1,4 @@ use gtk::Button; -use std::rc::Rc; pub struct Widget { gobject: Button, @@ -7,14 +6,14 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc() -> Rc { - Rc::new(Self { + pub fn new() -> Self { + Self { gobject: Button::builder() .icon_name("starred-symbolic") .tooltip_text("Bookmark") .sensitive(false) .build(), - }) + } } // Getters diff --git a/src/app/browser/window/tab/item/page/navigation/history.rs b/src/app/browser/window/tab/item/page/navigation/history.rs index d0642d6c..620e8627 100644 --- a/src/app/browser/window/tab/item/page/navigation/history.rs +++ b/src/app/browser/window/tab/item/page/navigation/history.rs @@ -28,13 +28,13 @@ pub struct History { impl History { // Construct - pub fn new_rc(window_action: Rc) -> Rc { + pub fn new(window_action: Rc) -> Self { // init components - let back = Back::new_rc(window_action.clone()); - let forward = Forward::new_rc(window_action); + let back = Rc::new(Back::new(window_action.clone())); + let forward = Rc::new(Forward::new(window_action)); // Init widget - let widget = Widget::new_rc(back.gobject(), forward.gobject()); + let widget = Rc::new(Widget::new(back.gobject(), forward.gobject())); // Init memory let memory = RefCell::new(Vec::new()); @@ -42,13 +42,13 @@ impl History { // Init index let index = RefCell::new(None); - Rc::new(Self { + Self { back, forward, memory, index, widget, - }) + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/history/back.rs b/src/app/browser/window/tab/item/page/navigation/history/back.rs index a6d567f0..565e3f02 100644 --- a/src/app/browser/window/tab/item/page/navigation/history/back.rs +++ b/src/app/browser/window/tab/item/page/navigation/history/back.rs @@ -13,12 +13,11 @@ pub struct Back { impl Back { // Construct - pub fn new_rc(window_action: Rc) -> Rc { - // Return activated struct - Rc::new(Self { + pub fn new(window_action: Rc) -> Self { + Self { window_action: window_action.clone(), - widget: Widget::new_rc(window_action), - }) + widget: Rc::new(Widget::new(window_action)), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/history/back/widget.rs b/src/app/browser/window/tab/item/page/navigation/history/back/widget.rs index 2fcbf0ce..5d817b9d 100644 --- a/src/app/browser/window/tab/item/page/navigation/history/back/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/history/back/widget.rs @@ -11,7 +11,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(window_action: Rc) -> Rc { + pub fn new(window_action: Rc) -> Self { // Init gobject let gobject = Button::builder() .icon_name("go-previous-symbolic") @@ -20,15 +20,10 @@ impl Widget { .build(); // Init events - gobject.connect_clicked({ - let window_action = window_action.clone(); - move |_| { - window_action.history_back().activate(); - } - }); + gobject.connect_clicked(move |_| window_action.history_back().activate()); - // Return activated struct - Rc::new(Self { gobject }) + // Return activated `Self` + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/history/forward.rs b/src/app/browser/window/tab/item/page/navigation/history/forward.rs index 9dedf143..e772eae8 100644 --- a/src/app/browser/window/tab/item/page/navigation/history/forward.rs +++ b/src/app/browser/window/tab/item/page/navigation/history/forward.rs @@ -13,12 +13,11 @@ pub struct Forward { impl Forward { // Construct - pub fn new_rc(window_action: Rc) -> Rc { - // Return activated struct - Rc::new(Self { + pub fn new(window_action: Rc) -> Self { + Self { window_action: window_action.clone(), - widget: Widget::new_rc(window_action), - }) + widget: Rc::new(Widget::new(window_action)), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs b/src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs index 1ea539e1..79afe85e 100644 --- a/src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/history/forward/widget.rs @@ -11,7 +11,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(window_action: Rc) -> Rc { + pub fn new(window_action: Rc) -> Self { // Init gobject let gobject = Button::builder() .icon_name("go-next-symbolic") @@ -20,15 +20,10 @@ impl Widget { .build(); // Init events - gobject.connect_clicked({ - let window_action = window_action.clone(); - move |_| { - window_action.history_forward().activate(); - } - }); + gobject.connect_clicked(move |_| window_action.history_forward().activate()); - // Return activated struct - Rc::new(Self { gobject }) + // Return activated `Self` + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/history/widget.rs b/src/app/browser/window/tab/item/page/navigation/history/widget.rs index 7241d674..888e5bfc 100644 --- a/src/app/browser/window/tab/item/page/navigation/history/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/history/widget.rs @@ -2,7 +2,6 @@ use gtk::{ prelude::{BoxExt, IsA}, Box, Orientation, }; -use std::rc::Rc; pub struct Widget { gobject: Box, @@ -10,7 +9,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(back: &impl IsA, forward: &impl IsA) -> Rc { + pub fn new(back: &impl IsA, forward: &impl IsA) -> Self { // Init widget let gobject = Box::builder() .orientation(Orientation::Horizontal) @@ -23,8 +22,8 @@ impl Widget { gobject.append(back); gobject.append(forward); - // Return activated struct - Rc::new(Self { gobject }) + // Return activated `Self` + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/page/navigation/home.rs b/src/app/browser/window/tab/item/page/navigation/home.rs index 54efeda0..9fc5be59 100644 --- a/src/app/browser/window/tab/item/page/navigation/home.rs +++ b/src/app/browser/window/tab/item/page/navigation/home.rs @@ -17,12 +17,12 @@ pub struct Home { impl Home { // Construct - pub fn new_rc(window_action: Rc) -> Rc { - Rc::new(Self { + pub fn new(window_action: Rc) -> Self { + Self { window_action: window_action.clone(), uri: RefCell::new(None), - widget: Widget::new_rc(window_action), - }) + widget: Rc::new(Widget::new(window_action)), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/home/widget.rs b/src/app/browser/window/tab/item/page/navigation/home/widget.rs index 1eadfb64..2b494818 100644 --- a/src/app/browser/window/tab/item/page/navigation/home/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/home/widget.rs @@ -11,7 +11,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(window_action: Rc) -> Rc { + pub fn new(window_action: Rc) -> Self { // Init gobject let gobject = Button::builder() .icon_name("go-home-symbolic") @@ -22,8 +22,8 @@ impl Widget { // Init events gobject.connect_clicked(move |_| window_action.home().activate()); - // Return activated struct - Rc::new(Self { gobject }) + // Return activated `Self` + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/reload.rs b/src/app/browser/window/tab/item/page/navigation/reload.rs index 71887ff5..58088b70 100644 --- a/src/app/browser/window/tab/item/page/navigation/reload.rs +++ b/src/app/browser/window/tab/item/page/navigation/reload.rs @@ -13,11 +13,11 @@ pub struct Reload { impl Reload { // Construct - pub fn new_rc(window_action: Rc) -> Rc { - Rc::new(Self { + pub fn new(window_action: Rc) -> Self { + Self { window_action: window_action.clone(), - widget: Widget::new_rc(window_action), - }) + widget: Rc::new(Widget::new(window_action)), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/reload/widget.rs b/src/app/browser/window/tab/item/page/navigation/reload/widget.rs index c15b071c..ec167e11 100644 --- a/src/app/browser/window/tab/item/page/navigation/reload/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/reload/widget.rs @@ -11,7 +11,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(window_action: Rc) -> Rc { + pub fn new(window_action: Rc) -> Self { // Init gobject let gobject = Button::builder() .icon_name("view-refresh-symbolic") @@ -22,8 +22,8 @@ impl Widget { // Init events gobject.connect_clicked(move |_| window_action.reload().activate()); - // Return activated struct - Rc::new(Self { gobject }) + // Return activated `Self` + Self { gobject } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/request.rs b/src/app/browser/window/tab/item/page/navigation/request.rs index 16ac0f76..d20837ba 100644 --- a/src/app/browser/window/tab/item/page/navigation/request.rs +++ b/src/app/browser/window/tab/item/page/navigation/request.rs @@ -20,14 +20,14 @@ pub struct Request { impl Request { // Construct - pub fn new_rc( + pub fn new( // Actions browser_action: Rc, action_page_reload: SimpleAction, // @TODO local `action_page_open`? - ) -> Rc { - Rc::new(Self { - widget: Widget::new_rc(browser_action, action_page_reload), - }) + ) -> Self { + Self { + widget: Rc::new(Widget::new(browser_action, action_page_reload)), + } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/request/widget.rs b/src/app/browser/window/tab/item/page/navigation/request/widget.rs index 6735eb67..b5d87a2f 100644 --- a/src/app/browser/window/tab/item/page/navigation/request/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/request/widget.rs @@ -30,7 +30,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc(browser_action: Rc, action_page_open: SimpleAction) -> Rc { + pub fn new(browser_action: Rc, action_page_open: SimpleAction) -> Self { // Init animated progress bar state let progress = Rc::new(Progress { fraction: RefCell::new(0.0), @@ -73,8 +73,8 @@ impl Widget { } }); - // Return activated struct - Rc::new(Self { gobject, progress }) + // Return activated `Self` + Self { gobject, progress } } // Actions diff --git a/src/app/browser/window/tab/item/page/navigation/widget.rs b/src/app/browser/window/tab/item/page/navigation/widget.rs index 5d29ba27..220b79e5 100644 --- a/src/app/browser/window/tab/item/page/navigation/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/widget.rs @@ -2,7 +2,6 @@ use gtk::{ prelude::{BoxExt, IsA}, Box, Orientation, }; -use std::rc::Rc; const MARGIN: i32 = 6; const SPACING: i32 = 6; @@ -13,13 +12,13 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc( + pub fn new( base: &impl IsA, history: &impl IsA, reload: &impl IsA, request: &impl IsA, bookmark: &impl IsA, - ) -> Rc { + ) -> Self { let gobject = Box::builder() .orientation(Orientation::Horizontal) .spacing(SPACING) @@ -34,7 +33,7 @@ impl Widget { gobject.append(request); gobject.append(bookmark); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/page/widget.rs b/src/app/browser/window/tab/item/page/widget.rs index 7fb279cd..8c2e79e3 100644 --- a/src/app/browser/window/tab/item/page/widget.rs +++ b/src/app/browser/window/tab/item/page/widget.rs @@ -4,7 +4,6 @@ use gtk::{ prelude::{ActionMapExt, BoxExt, IsA, WidgetExt}, Box, Orientation, }; -use std::rc::Rc; pub struct Widget { gobject: Box, @@ -12,7 +11,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc( + pub fn new( name: &str, // Actions action_page_open: SimpleAction, @@ -20,7 +19,7 @@ impl Widget { navigation: &impl IsA, content: &impl IsA, input: &impl IsA, - ) -> Rc { + ) -> Self { // Init additional action group let action_group = SimpleActionGroup::new(); action_group.add_action(&action_page_open); @@ -37,7 +36,7 @@ impl Widget { gobject.insert_action_group(&uuid_string_random(), Some(&action_group)); - Rc::new(Self { gobject }) + Self { gobject } } // Getters diff --git a/src/app/browser/window/tab/item/widget.rs b/src/app/browser/window/tab/item/widget.rs index 0c927bad..52253be7 100644 --- a/src/app/browser/window/tab/item/widget.rs +++ b/src/app/browser/window/tab/item/widget.rs @@ -5,7 +5,6 @@ use database::Database; use adw::{TabPage, TabView}; use gtk::prelude::IsA; use sqlite::Transaction; -use std::rc::Rc; const DEFAULT_TITLE: &str = "New page"; @@ -15,7 +14,7 @@ pub struct Widget { impl Widget { // Construct - pub fn new_rc( + pub fn new( keyword: &str, // ID tab_view: &TabView, child: &impl IsA, @@ -23,7 +22,7 @@ impl Widget { position: Option, is_pinned: bool, is_selected: bool, - ) -> Rc { + ) -> Self { let gobject = match position { Some(value) => { // If given `position` match pinned tab, GTK will panic with notice: @@ -51,7 +50,7 @@ impl Widget { tab_view.set_selected_page(&gobject); } - Rc::new(Self { gobject }) + Self { gobject } } // Actions