mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
remove extra getters
This commit is contained in:
parent
3ce272cd70
commit
0af69d99f6
56 changed files with 240 additions and 710 deletions
|
|
@ -112,7 +112,7 @@ impl Item {
|
|||
self.page.update();
|
||||
|
||||
// Update tab loading indicator
|
||||
self.widget.gobject().set_loading(self.page.is_loading());
|
||||
self.widget.gobject.set_loading(self.page.is_loading());
|
||||
}
|
||||
|
||||
pub fn clean(
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ impl Gemini {
|
|||
}
|
||||
|
||||
// Reload page to apply changes
|
||||
action.reload().activate();
|
||||
action.reload.activate();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ impl Page {
|
|||
|
||||
// Update
|
||||
self.meta.set_status(Status::Reload).set_title("Loading..");
|
||||
self.browser_action.update().activate(Some(&id));
|
||||
self.browser_action.update.activate(Some(&id));
|
||||
|
||||
// Route by request
|
||||
match Uri::parse(&request, UriFlags::NONE) {
|
||||
|
|
@ -241,7 +241,7 @@ impl Page {
|
|||
self.meta.set_status(status).set_title(title);
|
||||
|
||||
// Update window
|
||||
self.browser_action.update().activate(Some(&id));
|
||||
self.browser_action.update.activate(Some(&id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ impl Page {
|
|||
fn load_gemini(&self, uri: Uri, is_history: bool) {
|
||||
// Init shared clones
|
||||
let cancellable = self.cancellable.borrow().clone();
|
||||
let update = self.browser_action.update().clone();
|
||||
let update = self.browser_action.update.clone();
|
||||
let tab_action = self.tab_action.clone();
|
||||
let navigation = self.navigation.clone();
|
||||
let content = self.content.clone();
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ impl Reader {
|
|||
return match uri.scheme().as_str() {
|
||||
"gemini" => {
|
||||
// Open new page in browser
|
||||
actions.0.append().activate_stateful_once(
|
||||
actions.0.append.activate_stateful_once(
|
||||
Position::After,
|
||||
Some(uri.to_string()),
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ impl Navigation {
|
|||
|
||||
// Init widget
|
||||
let widget = Rc::new(Widget::new(
|
||||
identity.widget().gobject(),
|
||||
home.widget().gobject(),
|
||||
history.widget().gobject(),
|
||||
reload.widget().gobject(),
|
||||
&request.widget.entry, // @TODO remove extra getters from other components
|
||||
bookmark.widget().gobject(),
|
||||
&identity.widget.gobject,
|
||||
&home.widget.gobject,
|
||||
&history.widget.gobject,
|
||||
&reload.widget.gobject,
|
||||
&request.widget.entry,
|
||||
&bookmark.widget.gobject,
|
||||
));
|
||||
|
||||
// Done
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::app::browser::window::action::Action as WindowAction;
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Bookmark {
|
||||
widget: Rc<Widget>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
|
|
@ -21,10 +21,4 @@ impl Bookmark {
|
|||
pub fn update(&self, has_bookmark: bool) {
|
||||
self.widget.update(has_bookmark);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn widget(&self) -> &Rc<Widget> {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const ICON_YES: &str = "starred-symbolic";
|
|||
const ICON_NON: &str = "non-starred-symbolic";
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
pub gobject: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -21,7 +21,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| action.bookmark().activate());
|
||||
gobject.connect_clicked(move |_| action.bookmark.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
@ -33,10 +33,4 @@ impl Widget {
|
|||
self.gobject
|
||||
.set_icon_name(if has_bookmark { ICON_YES } else { ICON_NON });
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn gobject(&self) -> &Button {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ pub struct History {
|
|||
memory: RefCell<Vec<Memory>>,
|
||||
index: RefCell<Option<usize>>,
|
||||
// GTK
|
||||
widget: Rc<Widget>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl History {
|
||||
|
|
@ -34,10 +34,7 @@ impl History {
|
|||
let forward = Rc::new(Forward::new(window_action));
|
||||
|
||||
// Init widget
|
||||
let widget = Rc::new(Widget::new(
|
||||
back.widget().gobject(),
|
||||
forward.widget().gobject(),
|
||||
));
|
||||
let widget = Rc::new(Widget::new(&back.widget.gobject, &forward.widget.gobject));
|
||||
|
||||
// Init memory
|
||||
let memory = RefCell::new(Vec::new());
|
||||
|
|
@ -123,10 +120,4 @@ impl History {
|
|||
None => self.forward.update(false),
|
||||
};
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn widget(&self) -> &Rc<Widget> {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use crate::app::browser::window::Action;
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Back {
|
||||
action: Rc<Action>,
|
||||
widget: Rc<Widget>,
|
||||
pub action: Rc<Action>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Back {
|
||||
|
|
@ -24,15 +24,9 @@ impl Back {
|
|||
|
||||
pub fn update(&self, status: bool) {
|
||||
// Update actions
|
||||
self.action.history_back().gobject().set_enabled(status);
|
||||
self.action.history_back.gobject.set_enabled(status);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(status);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn widget(&self) -> &Rc<Widget> {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use gtk::{
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
pub gobject: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -20,7 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| action.history_back().activate());
|
||||
gobject.connect_clicked(move |_| action.history_back.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
@ -30,9 +30,4 @@ impl Widget {
|
|||
pub fn update(&self, is_sensitive: bool) {
|
||||
self.gobject.set_sensitive(is_sensitive);
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Button {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use crate::app::browser::window::Action;
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Forward {
|
||||
action: Rc<Action>,
|
||||
widget: Rc<Widget>,
|
||||
pub action: Rc<Action>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Forward {
|
||||
|
|
@ -22,15 +22,9 @@ impl Forward {
|
|||
// Actions
|
||||
pub fn update(&self, status: bool) {
|
||||
// Update actions
|
||||
self.action.history_forward().gobject().set_enabled(status);
|
||||
self.action.history_forward.gobject.set_enabled(status);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(status);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn widget(&self) -> &Rc<Widget> {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use gtk::{
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
pub gobject: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -20,7 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| action.history_forward().activate());
|
||||
gobject.connect_clicked(move |_| action.history_forward.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
@ -30,9 +30,4 @@ impl Widget {
|
|||
pub fn update(&self, is_sensitive: bool) {
|
||||
self.gobject.set_sensitive(is_sensitive);
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Button {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use gtk::{
|
|||
};
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Box,
|
||||
pub gobject: Box,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -25,9 +25,4 @@ impl Widget {
|
|||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Box {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::{cell::RefCell, rc::Rc};
|
|||
pub struct Home {
|
||||
action: Rc<WindowAction>,
|
||||
uri: RefCell<Option<Uri>>,
|
||||
widget: Rc<Widget>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Home {
|
||||
|
|
@ -34,16 +34,13 @@ impl Home {
|
|||
self.uri.replace(uri);
|
||||
|
||||
// Update action status
|
||||
self.action.home().gobject().set_enabled(status);
|
||||
self.action.home.gobject.set_enabled(status);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(status);
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &Rc<Widget> {
|
||||
&self.widget
|
||||
}
|
||||
|
||||
pub fn url(&self) -> Option<GString> {
|
||||
// Build URL from parsed URI cache
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use gtk::{
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
pub gobject: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -20,7 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| action.home().activate());
|
||||
gobject.connect_clicked(move |_| action.home.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
@ -30,9 +30,4 @@ impl Widget {
|
|||
pub fn update(&self, is_sensitive: bool) {
|
||||
self.gobject.set_sensitive(is_sensitive);
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Button {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::rc::Rc;
|
|||
|
||||
pub struct Identity {
|
||||
action: Rc<Action>,
|
||||
widget: Rc<Widget>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Identity {
|
||||
|
|
@ -26,10 +26,4 @@ impl Identity {
|
|||
// Update widget
|
||||
self.widget.update(is_auth, is_enabled)
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn widget(&self) -> &Rc<Widget> {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use gtk::{
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
pub gobject: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -32,9 +32,4 @@ impl Widget {
|
|||
self.gobject
|
||||
.set_css_classes(if is_auth { &["success"] } else { &[] });
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Button {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use std::rc::Rc;
|
|||
|
||||
pub struct Reload {
|
||||
action: Rc<WindowAction>,
|
||||
widget: Rc<Widget>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
|
|
@ -23,15 +23,9 @@ impl Reload {
|
|||
|
||||
pub fn update(&self, is_enabled: bool) {
|
||||
// Update actions
|
||||
self.action.reload().gobject().set_enabled(is_enabled);
|
||||
self.action.reload.gobject.set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn widget(&self) -> &Rc<Widget> {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use gtk::{
|
|||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
pub gobject: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -20,7 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| action.reload().activate());
|
||||
gobject.connect_clicked(move |_| action.reload.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
|
@ -30,9 +30,4 @@ impl Widget {
|
|||
pub fn update(&self, is_sensitive: bool) {
|
||||
self.gobject.set_sensitive(is_sensitive);
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Button {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ impl Widget {
|
|||
|
||||
// Connect events
|
||||
entry.connect_changed(move |_| {
|
||||
action.0.update().activate(None);
|
||||
action.0.update.activate(None);
|
||||
});
|
||||
|
||||
entry.connect_activate(move |this| {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use sqlite::Transaction;
|
|||
const DEFAULT_TITLE: &str = "New page";
|
||||
|
||||
pub struct Widget {
|
||||
gobject: TabPage,
|
||||
pub gobject: TabPage,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -128,12 +128,6 @@ impl Widget {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn gobject(&self) -> &TabPage {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use gtk::prelude::ActionExt;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// Context menu wrapper
|
||||
///
|
||||
/// https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.TabView.get_menu_model.html
|
||||
pub struct Menu {
|
||||
gobject: gtk::gio::Menu,
|
||||
pub gobject: gtk::gio::Menu,
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
|
|
@ -19,8 +20,8 @@ impl Menu {
|
|||
Some("Reload"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.reload().id()
|
||||
window_action.id,
|
||||
window_action.reload.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -30,8 +31,8 @@ impl Menu {
|
|||
Some("Bookmark"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.bookmark().id()
|
||||
window_action.id,
|
||||
window_action.bookmark.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -39,8 +40,8 @@ impl Menu {
|
|||
Some("Pin"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.pin().id()
|
||||
window_action.id,
|
||||
window_action.pin.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -52,8 +53,8 @@ impl Menu {
|
|||
Some("Home"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.home().id()
|
||||
window_action.id,
|
||||
window_action.home.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -65,8 +66,8 @@ impl Menu {
|
|||
Some("Back"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.history_back().id()
|
||||
window_action.id,
|
||||
window_action.history_back.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -74,8 +75,8 @@ impl Menu {
|
|||
Some("Forward"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.history_forward().id()
|
||||
window_action.id,
|
||||
window_action.history_forward.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -87,8 +88,8 @@ impl Menu {
|
|||
Some("Current"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.close().id()
|
||||
window_action.id,
|
||||
window_action.close.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -96,8 +97,8 @@ impl Menu {
|
|||
Some("All"),
|
||||
Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.close_all().id()
|
||||
window_action.id,
|
||||
window_action.close_all.gobject.name()
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -105,9 +106,4 @@ impl Menu {
|
|||
|
||||
Self { gobject: main }
|
||||
}
|
||||
|
||||
/// Get reference to [Menu](https://docs.gtk.org/gio/class.Menu.html) `GObject`
|
||||
pub fn gobject(&self) -> >k::gio::Menu {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const DEFAULT_TAB_ICON: &str = "view-pin-symbolic";
|
|||
|
||||
/// Wrapper for [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) GObject
|
||||
pub struct Widget {
|
||||
gobject: TabView,
|
||||
pub gobject: TabView,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
|
|
@ -72,9 +72,4 @@ impl Widget {
|
|||
None => self.gobject.selected_page(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get reference of [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) `GObject`
|
||||
pub fn gobject(&self) -> &TabView {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue