mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
define ptr container outside
This commit is contained in:
parent
7b2c07ac45
commit
a5fc2a7475
@ -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()));
|
||||
|
@ -15,20 +15,20 @@ pub struct Header {
|
||||
|
||||
impl Header {
|
||||
// Construct
|
||||
pub fn new_rc(
|
||||
pub fn new(
|
||||
// Actions
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
// Widgets
|
||||
tab_view: &TabView,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -19,24 +19,27 @@ pub struct Bar {
|
||||
}
|
||||
|
||||
impl Bar {
|
||||
// Construct
|
||||
pub fn new_rc(
|
||||
// Constructors
|
||||
|
||||
pub fn new(
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
view: &TabView,
|
||||
) -> Rc<Self> {
|
||||
// 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()
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ pub struct Control {
|
||||
|
||||
impl Control {
|
||||
// Construct
|
||||
pub fn new_rc() -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
widget: Widget::new_rc(),
|
||||
})
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new()),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -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<Self> {
|
||||
Rc::new(Self {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: WindowControls::builder()
|
||||
.side(PackType::End)
|
||||
.margin_end(4)
|
||||
.build(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -15,10 +15,10 @@ pub struct Menu {
|
||||
}
|
||||
#[rustfmt::skip] // @TODO template builder?
|
||||
impl Menu {
|
||||
pub fn new_rc(
|
||||
pub fn new(
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -14,10 +14,10 @@ pub struct Tab {
|
||||
|
||||
impl Tab {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>, view: &TabView) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
widget: Widget::new_rc(view, Append::new_rc(window_action).gobject()),
|
||||
})
|
||||
pub fn new(window_action: Rc<WindowAction>, view: &TabView) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(view, Append::new(window_action).gobject())),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -12,10 +12,10 @@ pub struct Append {
|
||||
|
||||
impl Append {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
widget: Widget::new_rc(window_action),
|
||||
})
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(window_action)),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -8,7 +8,7 @@ pub struct Widget {
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -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<gtk::Widget>) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
pub fn new(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> 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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -33,7 +33,7 @@ pub struct Tab {
|
||||
|
||||
impl Tab {
|
||||
// Construct
|
||||
pub fn new_rc(browser_action: Rc<BrowserAction>, window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
pub fn new(browser_action: Rc<BrowserAction>, window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -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 })
|
||||
|
@ -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 {
|
||||
|
@ -28,12 +28,12 @@ impl Content {
|
||||
// Construct
|
||||
|
||||
/// Create new container for different components
|
||||
pub fn new_rc(tab_action: Rc<TabAction>, action_page_open: SimpleAction) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
pub fn new(tab_action: Rc<TabAction>, action_page_open: SimpleAction) -> Self {
|
||||
Self {
|
||||
gobject: Box::builder().orientation(Orientation::Vertical).build(),
|
||||
tab_action,
|
||||
action_page_open,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
@ -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 }
|
||||
|
@ -30,12 +30,12 @@ pub struct Reader {
|
||||
|
||||
impl Reader {
|
||||
// Construct
|
||||
pub fn new_rc(
|
||||
pub fn new(
|
||||
gemtext: &str,
|
||||
base: &Uri,
|
||||
tab_action: Rc<TabAction>,
|
||||
action_page_open: SimpleAction,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -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> {
|
||||
) -> 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
|
||||
|
@ -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<Self> {
|
||||
Rc::new(Self {
|
||||
pub fn new(child: &TextView) -> Self {
|
||||
Self {
|
||||
gobject: ClampScrollable::builder()
|
||||
.child(child)
|
||||
.css_classes(["view"])
|
||||
.maximum_size(800)
|
||||
.build(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -17,12 +17,12 @@ pub struct Input {
|
||||
|
||||
impl Input {
|
||||
// Construct
|
||||
pub fn new_rc() -> Rc<Self> {
|
||||
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<usize>,
|
||||
) {
|
||||
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<i32>,
|
||||
) {
|
||||
self.widget.update(Some(
|
||||
Sensitive::new_rc(action, base, title, max_length).gobject(),
|
||||
Sensitive::new(action, base, title, max_length).gobject(),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -24,23 +24,27 @@ pub struct Response {
|
||||
|
||||
impl Response {
|
||||
// Construct
|
||||
pub fn new_rc(
|
||||
pub fn new(
|
||||
tab_action: Rc<TabAction>,
|
||||
base: Uri,
|
||||
title: Option<&str>,
|
||||
size_limit: Option<usize>,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -17,20 +17,20 @@ pub struct Control {
|
||||
|
||||
impl Control {
|
||||
// Construct
|
||||
pub fn new_rc(action_send: SimpleAction) -> Rc<Self> {
|
||||
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
|
||||
|
@ -11,12 +11,10 @@ pub struct Counter {
|
||||
|
||||
impl Counter {
|
||||
// Construct
|
||||
pub fn new_rc() -> Rc<Self> {
|
||||
// Init widget
|
||||
let widget = Widget::new_rc();
|
||||
|
||||
// Result
|
||||
Rc::new(Self { widget })
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new()),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
@ -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<Self> {
|
||||
let gobject = Label::builder().build();
|
||||
|
||||
Rc::new(Self { gobject })
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: Label::builder().build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -11,12 +11,10 @@ pub struct Form {
|
||||
|
||||
impl Form {
|
||||
// Construct
|
||||
pub fn new_rc(action_update: SimpleAction) -> Rc<Self> {
|
||||
// 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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -11,12 +11,10 @@ pub struct Title {
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new_rc(title: Option<&str>) -> Rc<Self> {
|
||||
// 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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -20,25 +20,25 @@ pub struct Sensitive {
|
||||
|
||||
impl Sensitive {
|
||||
// Construct
|
||||
pub fn new_rc(
|
||||
pub fn new(
|
||||
tab_action: Rc<TabAction>,
|
||||
base: Uri,
|
||||
title: Option<&str>,
|
||||
max_length: Option<i32>,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -12,16 +12,12 @@ pub struct Form {
|
||||
|
||||
impl Form {
|
||||
// Construct
|
||||
pub fn new_rc(
|
||||
action_send: SimpleAction,
|
||||
title: Option<&str>,
|
||||
max_length: Option<i32>,
|
||||
) -> Rc<Self> {
|
||||
pub fn new(action_send: SimpleAction, title: Option<&str>, max_length: Option<i32>) -> 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
|
||||
|
@ -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<i32>,
|
||||
) -> Rc<Self> {
|
||||
pub fn new(action_send: SimpleAction, title: Option<&str>, max_length: Option<i32>) -> 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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -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<Self> {
|
||||
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
|
||||
|
@ -30,36 +30,36 @@ pub struct Navigation {
|
||||
}
|
||||
|
||||
impl Navigation {
|
||||
pub fn new_rc(
|
||||
pub fn new(
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
action_page_open: SimpleAction,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -11,10 +11,10 @@ pub struct Bookmark {
|
||||
|
||||
impl Bookmark {
|
||||
// Construct
|
||||
pub fn new_rc() -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
widget: Widget::new_rc(),
|
||||
})
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new()),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
@ -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<Self> {
|
||||
Rc::new(Self {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: Button::builder()
|
||||
.icon_name("starred-symbolic")
|
||||
.tooltip_text("Bookmark")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -28,13 +28,13 @@ pub struct History {
|
||||
|
||||
impl History {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -13,12 +13,11 @@ pub struct Back {
|
||||
|
||||
impl Back {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
// Return activated struct
|
||||
Rc::new(Self {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
window_action: window_action.clone(),
|
||||
widget: Widget::new_rc(window_action),
|
||||
})
|
||||
widget: Rc::new(Widget::new(window_action)),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -13,12 +13,11 @@ pub struct Forward {
|
||||
|
||||
impl Forward {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
// Return activated struct
|
||||
Rc::new(Self {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
window_action: window_action.clone(),
|
||||
widget: Widget::new_rc(window_action),
|
||||
})
|
||||
widget: Rc::new(Widget::new(window_action)),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -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<gtk::Widget>, forward: &impl IsA<gtk::Widget>) -> Rc<Self> {
|
||||
pub fn new(back: &impl IsA<gtk::Widget>, forward: &impl IsA<gtk::Widget>) -> 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
|
||||
|
@ -17,12 +17,12 @@ pub struct Home {
|
||||
|
||||
impl Home {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -13,11 +13,11 @@ pub struct Reload {
|
||||
|
||||
impl Reload {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
window_action: window_action.clone(),
|
||||
widget: Widget::new_rc(window_action),
|
||||
})
|
||||
widget: Rc::new(Widget::new(window_action)),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
@ -11,7 +11,7 @@ pub struct Widget {
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> 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
|
||||
|
@ -20,14 +20,14 @@ pub struct Request {
|
||||
|
||||
impl Request {
|
||||
// Construct
|
||||
pub fn new_rc(
|
||||
pub fn new(
|
||||
// Actions
|
||||
browser_action: Rc<BrowserAction>,
|
||||
action_page_reload: SimpleAction, // @TODO local `action_page_open`?
|
||||
) -> Rc<Self> {
|
||||
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
|
||||
|
@ -30,7 +30,7 @@ pub struct Widget {
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(browser_action: Rc<BrowserAction>, action_page_open: SimpleAction) -> Rc<Self> {
|
||||
pub fn new(browser_action: Rc<BrowserAction>, 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
|
||||
|
@ -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<gtk::Widget>,
|
||||
history: &impl IsA<gtk::Widget>,
|
||||
reload: &impl IsA<gtk::Widget>,
|
||||
request: &impl IsA<gtk::Widget>,
|
||||
bookmark: &impl IsA<gtk::Widget>,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -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<gtk::Widget>,
|
||||
content: &impl IsA<gtk::Widget>,
|
||||
input: &impl IsA<gtk::Widget>,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
@ -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<gtk::Widget>,
|
||||
@ -23,7 +22,7 @@ impl Widget {
|
||||
position: Option<i32>,
|
||||
is_pinned: bool,
|
||||
is_selected: bool,
|
||||
) -> Rc<Self> {
|
||||
) -> 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user