From 0af69d99f6be70e45f94bd6e655b16d9d78027b5 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 28 Nov 2024 01:35:48 +0200 Subject: [PATCH] remove extra getters --- src/app.rs | 46 ++++---- src/app/browser.rs | 38 +++---- src/app/browser/action.rs | 64 +++-------- src/app/browser/action/about.rs | 20 +--- src/app/browser/action/close.rs | 20 +--- src/app/browser/action/debug.rs | 20 +--- src/app/browser/action/profile.rs | 20 +--- src/app/browser/action/update.rs | 14 +-- src/app/browser/window.rs | 38 +++---- src/app/browser/window/action.rs | 100 ++++-------------- src/app/browser/window/action/append.rs | 16 +-- src/app/browser/window/action/bookmark.rs | 16 +-- src/app/browser/window/action/close.rs | 16 +-- src/app/browser/window/action/close_all.rs | 16 +-- src/app/browser/window/action/history_back.rs | 16 +-- .../browser/window/action/history_forward.rs | 16 +-- src/app/browser/window/action/home.rs | 16 +-- src/app/browser/window/action/pin.rs | 16 +-- src/app/browser/window/action/reload.rs | 16 +-- src/app/browser/window/header.rs | 11 +- src/app/browser/window/header/bar.rs | 15 +-- src/app/browser/window/header/bar/control.rs | 9 +- .../window/header/bar/control/widget.rs | 7 +- src/app/browser/window/header/bar/menu.rs | 61 +++++------ .../browser/window/header/bar/menu/widget.rs | 7 +- src/app/browser/window/header/bar/tab.rs | 14 ++- .../browser/window/header/bar/tab/append.rs | 6 -- .../window/header/bar/tab/append/widget.rs | 9 +- .../browser/window/header/bar/tab/widget.rs | 7 +- src/app/browser/window/header/bar/widget.rs | 7 +- src/app/browser/window/header/widget.rs | 7 +- src/app/browser/window/tab.rs | 48 ++++----- src/app/browser/window/tab/item.rs | 2 +- .../window/tab/item/identity/gemini.rs | 2 +- src/app/browser/window/tab/item/page.rs | 6 +- .../item/page/content/text/gemini/reader.rs | 2 +- .../window/tab/item/page/navigation.rs | 12 +-- .../tab/item/page/navigation/bookmark.rs | 8 +- .../item/page/navigation/bookmark/widget.rs | 10 +- .../tab/item/page/navigation/history.rs | 13 +-- .../tab/item/page/navigation/history/back.rs | 12 +-- .../page/navigation/history/back/widget.rs | 9 +- .../item/page/navigation/history/forward.rs | 12 +-- .../page/navigation/history/forward/widget.rs | 9 +- .../item/page/navigation/history/widget.rs | 7 +- .../window/tab/item/page/navigation/home.rs | 7 +- .../tab/item/page/navigation/home/widget.rs | 9 +- .../tab/item/page/navigation/identity.rs | 8 +- .../item/page/navigation/identity/widget.rs | 7 +- .../window/tab/item/page/navigation/reload.rs | 10 +- .../tab/item/page/navigation/reload/widget.rs | 9 +- .../item/page/navigation/request/widget.rs | 2 +- src/app/browser/window/tab/item/widget.rs | 8 +- src/app/browser/window/tab/menu.rs | 40 ++++--- src/app/browser/window/tab/widget.rs | 7 +- src/app/browser/window/widget.rs | 7 +- 56 files changed, 240 insertions(+), 710 deletions(-) diff --git a/src/app.rs b/src/app.rs index 64c62143..f82f6fdf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -7,7 +7,7 @@ use crate::profile::Profile; use adw::Application; use gtk::{ glib::ExitCode, - prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt}, + prelude::{ActionExt, ApplicationExt, ApplicationExtManual, GtkApplicationExt}, }; use sqlite::Transaction; use std::rc::Rc; @@ -135,24 +135,24 @@ impl App { ( format!( "{}.{}", - browser.action().id(), - browser.action().close().id() + browser.action.id, + browser.action.close.gobject.name() ), &["Escape"], ), ( format!( "{}.{}", - browser.action().id(), - browser.action().debug().id() + browser.action.id, + browser.action.debug.gobject.name() ), &["i"], ), ( format!( "{}.{}", - browser.action().id(), - browser.action().update().id() + browser.action.id, + browser.action.update.gobject.name() ), &["u"], ), @@ -160,64 +160,64 @@ impl App { ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().append().id() + browser.window.action.id, + browser.window.action.append.gobject.name() ), &["t"], ), ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().bookmark().id() + browser.window.action.id, + browser.window.action.bookmark.gobject.name() ), &["b"], ), ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().pin().id() + browser.window.action.id, + browser.window.action.pin.gobject.name() ), &["p"], ), ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().reload().id() + browser.window.action.id, + browser.window.action.reload.gobject.name() ), &["r"], ), ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().home().id() + browser.window.action.id, + browser.window.action.home.gobject.name() ), &["h"], ), ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().history_back().id() + browser.window.action.id, + browser.window.action.history_back.gobject.name() ), &["Left"], ), ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().history_forward().id() + browser.window.action.id, + browser.window.action.history_forward.gobject.name() ), &["Right"], ), ( format!( "{}.{}", - browser.window().action().id(), - browser.window().action().close().id() + browser.window.action.id, + browser.window.action.close.gobject.name() ), &["q"], ), diff --git a/src/app/browser.rs b/src/app/browser.rs index 6dda47c7..c86d935d 100644 --- a/src/app/browser.rs +++ b/src/app/browser.rs @@ -19,9 +19,9 @@ use sqlite::Transaction; use std::rc::Rc; pub struct Browser { - action: Rc, - widget: Rc, - window: Rc, + pub action: Rc, + pub widget: Rc, + pub window: Rc, } impl Browser { @@ -33,43 +33,43 @@ impl Browser { // Init widget let widget = Rc::new(Widget::new( - window.widget().gobject(), + &window.widget.gobject, &[ // Connect action groups (to apply accels) ( // Browser - action.id(), - action.gobject().clone(), + &action.id, + action.gobject.clone(), ), ( // Window - window.action().id(), - window.action().gobject().clone(), + &window.action.id, + window.action.gobject.clone(), ), ], )); // Connect events - action.about().connect_activate({ + action.about.connect_activate({ let window = window.clone(); move || { - About::new().present(Some(window.widget().gobject())); + About::new().present(Some(&window.widget.gobject)); } }); - action.close().connect_activate({ + action.close.connect_activate({ let widget = widget.clone(); move || widget.gobject().close() }); - action.debug().connect_activate({ + action.debug.connect_activate({ let widget = widget.clone(); move || { widget.gobject().emit_enable_debugging(true); } }); - action.profile().connect_activate({ + action.profile.connect_activate({ let profile = profile.clone(); move || { FileLauncher::new(Some(&File::for_path(profile.config_path.as_path()))).launch( @@ -84,7 +84,7 @@ impl Browser { } }); - action.update().connect_activate({ + action.update.connect_activate({ let window = window.clone(); move |tab_item_id| window.update(tab_item_id) }); @@ -175,16 +175,6 @@ impl Browser { pub fn update(&self) { self.window.update(None); } - - // Getters - - pub fn action(&self) -> &Rc { - &self.action - } - - pub fn window(&self) -> &Rc { - &self.window - } } // Tools diff --git a/src/app/browser/action.rs b/src/app/browser/action.rs index bf9860de..dce9632c 100644 --- a/src/app/browser/action.rs +++ b/src/app/browser/action.rs @@ -20,14 +20,14 @@ use std::rc::Rc; /// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions pub struct Action { // Actions - about: Rc, - close: Rc, - debug: Rc, - profile: Rc, - update: Rc, + pub about: Rc, + pub close: Rc, + pub debug: Rc, + pub profile: Rc, + pub update: Rc, // Group - id: GString, - gobject: SimpleActionGroup, + pub id: GString, + pub gobject: SimpleActionGroup, } impl Action { @@ -49,11 +49,11 @@ impl Action { let gobject = SimpleActionGroup::new(); // Add action to given group - gobject.add_action(about.gobject()); - gobject.add_action(close.gobject()); - gobject.add_action(debug.gobject()); - gobject.add_action(profile.gobject()); - gobject.add_action(update.gobject()); + gobject.add_action(&about.gobject); + gobject.add_action(&close.gobject); + gobject.add_action(&debug.gobject); + gobject.add_action(&profile.gobject); + gobject.add_action(&update.gobject); // Done Self { @@ -66,44 +66,4 @@ impl Action { gobject, } } - - // Getters - - /// Get reference to `About` action - pub fn about(&self) -> &Rc { - &self.about - } - - /// Get reference to `Close` action - pub fn close(&self) -> &Rc { - &self.close - } - - /// Get reference to `Debug` action - pub fn debug(&self) -> &Rc { - &self.debug - } - - /// Get reference to `Profile` action - pub fn profile(&self) -> &Rc { - &self.profile - } - - /// Get reference to `Update` action - pub fn update(&self) -> &Rc { - &self.update - } - - /// Get auto-generated name for action group - /// * useful for manual relationship with GObjects or as the `detailed_name` - /// for [Accels](https://docs.gtk.org/gtk4/method.Application.set_accels_for_action.html) or - /// [Menu](https://docs.gtk.org/gio/class.Menu.html) builder - pub fn id(&self) -> &GString { - &self.id - } - - /// Get reference to [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) GObject - pub fn gobject(&self) -> &SimpleActionGroup { - &self.gobject - } } diff --git a/src/app/browser/action/about.rs b/src/app/browser/action/about.rs index 0eb033f0..8497ba07 100644 --- a/src/app/browser/action/about.rs +++ b/src/app/browser/action/about.rs @@ -1,12 +1,8 @@ -use gtk::{ - gio::SimpleAction, - glib::{uuid_string_random, GString}, - prelude::ActionExt, -}; +use gtk::{gio::SimpleAction, glib::uuid_string_random}; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `About` action of `Browser` group pub struct About { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl About { @@ -26,16 +22,4 @@ impl About { pub fn connect_activate(&self, callback: impl Fn() + 'static) { self.gobject.connect_activate(move |_, _| callback()); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/action/close.rs b/src/app/browser/action/close.rs index 4e79dace..40c7186f 100644 --- a/src/app/browser/action/close.rs +++ b/src/app/browser/action/close.rs @@ -1,12 +1,8 @@ -use gtk::{ - gio::SimpleAction, - glib::{uuid_string_random, GString}, - prelude::ActionExt, -}; +use gtk::{gio::SimpleAction, glib::uuid_string_random}; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Browser` group pub struct Close { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Close { @@ -26,16 +22,4 @@ impl Close { pub fn connect_activate(&self, callback: impl Fn() + 'static) { self.gobject.connect_activate(move |_, _| callback()); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/action/debug.rs b/src/app/browser/action/debug.rs index 295d104c..033b97ab 100644 --- a/src/app/browser/action/debug.rs +++ b/src/app/browser/action/debug.rs @@ -1,12 +1,8 @@ -use gtk::{ - gio::SimpleAction, - glib::{uuid_string_random, GString}, - prelude::ActionExt, -}; +use gtk::{gio::SimpleAction, glib::uuid_string_random}; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Debug` action of `Browser` group pub struct Debug { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Debug { @@ -26,16 +22,4 @@ impl Debug { pub fn connect_activate(&self, callback: impl Fn() + 'static) { self.gobject.connect_activate(move |_, _| callback()); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/action/profile.rs b/src/app/browser/action/profile.rs index ed1d195e..08bb5181 100644 --- a/src/app/browser/action/profile.rs +++ b/src/app/browser/action/profile.rs @@ -1,12 +1,8 @@ -use gtk::{ - gio::SimpleAction, - glib::{uuid_string_random, GString}, - prelude::ActionExt, -}; +use gtk::{gio::SimpleAction, glib::uuid_string_random}; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Profile` action of `Browser` group pub struct Profile { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Profile { @@ -26,16 +22,4 @@ impl Profile { pub fn connect_activate(&self, callback: impl Fn() + 'static) { self.gobject.connect_activate(move |_, _| callback()); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/action/update.rs b/src/app/browser/action/update.rs index 2dc25205..10314b1e 100644 --- a/src/app/browser/action/update.rs +++ b/src/app/browser/action/update.rs @@ -6,7 +6,7 @@ use gtk::{ /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Update` action of `Browser` group pub struct Update { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Update { @@ -50,16 +50,4 @@ impl Update { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window.rs b/src/app/browser/window.rs index 657b2acc..13f70ff7 100644 --- a/src/app/browser/window.rs +++ b/src/app/browser/window.rs @@ -16,9 +16,9 @@ use gtk::glib::GString; use std::rc::Rc; pub struct Window { - action: Rc, - tab: Rc, - widget: Rc, + pub action: Rc, + pub tab: Rc, + pub widget: Rc, } impl Window { @@ -29,11 +29,11 @@ impl Window { // Init components let tab = Rc::new(Tab::new(profile, (browser_action.clone(), action.clone()))); - let header = Header::new(browser_action, action.clone(), tab.widget().gobject()); - let widget = Rc::new(Widget::new(header.gobject(), tab.widget().gobject())); + let header = Header::new(browser_action, action.clone(), &tab.widget.gobject); + let widget = Rc::new(Widget::new(&header.widget.gobject, &tab.widget.gobject)); // Init events - action.append().connect_activate({ + action.append.connect_activate({ let tab = tab.clone(); move |position, request, is_pinned, is_selected, is_attention, is_load| { tab.append( @@ -47,7 +47,7 @@ impl Window { } }); - action.bookmark().connect_activate({ + action.bookmark.connect_activate({ let tab = tab.clone(); move |position| { if tab.bookmark(position).is_err() { @@ -56,39 +56,39 @@ impl Window { } }); - action.pin().connect_activate({ + action.pin.connect_activate({ let tab = tab.clone(); move |position| tab.pin(position) }); - action.reload().connect_activate({ + action.reload.connect_activate({ let tab = tab.clone(); move |position| tab.page_reload(position) }); - action.home().connect_activate({ + action.home.connect_activate({ let tab = tab.clone(); move |position| tab.page_home(position) }); - action.close().connect_activate({ + action.close.connect_activate({ let tab = tab.clone(); move |position| tab.close(position) }); - action.close_all().connect_activate({ + action.close_all.connect_activate({ let tab = tab.clone(); move |_| tab.close_all() }); - action.history_back().connect_activate({ + action.history_back.connect_activate({ let tab = tab.clone(); move |position| { tab.page_history_back(position); } // @TODO rename destination method }); - action.history_forward().connect_activate({ + action.history_forward.connect_activate({ let tab = tab.clone(); move |position| { tab.page_history_forward(position); @@ -161,16 +161,6 @@ impl Window { pub fn init(&self) { self.tab.init(); } - - // Getters - - pub fn action(&self) -> &Rc { - &self.action - } - - pub fn widget(&self) -> &Rc { - &self.widget - } } // Tools diff --git a/src/app/browser/window/action.rs b/src/app/browser/window/action.rs index 07afe663..47e5ae4e 100644 --- a/src/app/browser/window/action.rs +++ b/src/app/browser/window/action.rs @@ -30,18 +30,18 @@ pub use append::Position; // public enum /// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions pub struct Action { // Actions - append: Rc, - bookmark: Rc, - close_all: Rc, - close: Rc, - history_back: Rc, - history_forward: Rc, - home: Rc, - pin: Rc, - reload: Rc, + pub append: Rc, + pub bookmark: Rc, + pub close_all: Rc, + pub close: Rc, + pub history_back: Rc, + pub history_forward: Rc, + pub home: Rc, + pub pin: Rc, + pub reload: Rc, // Group - id: GString, - gobject: SimpleActionGroup, + pub id: GString, + pub gobject: SimpleActionGroup, } impl Action { @@ -67,15 +67,15 @@ impl Action { let gobject = SimpleActionGroup::new(); // Add action to given group - gobject.add_action(append.gobject()); - gobject.add_action(bookmark.gobject()); - gobject.add_action(close_all.gobject()); - gobject.add_action(close.gobject()); - gobject.add_action(history_back.gobject()); - gobject.add_action(history_forward.gobject()); - gobject.add_action(home.gobject()); - gobject.add_action(pin.gobject()); - gobject.add_action(reload.gobject()); + gobject.add_action(&append.gobject); + gobject.add_action(&bookmark.gobject); + gobject.add_action(&close_all.gobject); + gobject.add_action(&close.gobject); + gobject.add_action(&history_back.gobject); + gobject.add_action(&history_forward.gobject); + gobject.add_action(&home.gobject); + gobject.add_action(&pin.gobject); + gobject.add_action(&reload.gobject); // Done Self { @@ -92,64 +92,4 @@ impl Action { gobject, } } - - // Getters - - /// Get reference to `Append` action - pub fn append(&self) -> &Rc { - &self.append - } - - /// Get reference to `Bookmark` action - pub fn bookmark(&self) -> &Rc { - &self.bookmark - } - - /// Get reference to `CloseAll` action - pub fn close_all(&self) -> &Rc { - &self.close_all - } - - /// Get reference to `Close` action - pub fn close(&self) -> &Rc { - &self.close - } - - /// Get reference to `HistoryBack` action - pub fn history_back(&self) -> &Rc { - &self.history_back - } - - /// Get reference to `HistoryForward` action - pub fn history_forward(&self) -> &Rc { - &self.history_forward - } - - /// Get reference to `Home` action - pub fn home(&self) -> &Rc { - &self.home - } - - /// Get reference to `Pin` action - pub fn pin(&self) -> &Rc { - &self.pin - } - - /// Get reference to `Reload` action - pub fn reload(&self) -> &Rc { - &self.reload - } - - /// Get auto-generated name for action group - /// * useful for manual relationship with GObjects or as the `detailed_name` - /// for [Accels](https://docs.gtk.org/gtk4/method.Application.set_accels_for_action.html) or - /// [Menu](https://docs.gtk.org/gio/class.Menu.html) builder - pub fn id(&self) -> &GString { - &self.id - } - - /// Get reference to [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) GObject - pub fn gobject(&self) -> &SimpleActionGroup { - &self.gobject - } } diff --git a/src/app/browser/window/action/append.rs b/src/app/browser/window/action/append.rs index 9f75348b..114cce3b 100644 --- a/src/app/browser/window/action/append.rs +++ b/src/app/browser/window/action/append.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString, Variant}, + glib::{uuid_string_random, Variant}, prelude::{ActionExt, ToVariant}, }; @@ -37,7 +37,7 @@ const DEFAULT_IS_LOAD: bool = false; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Append` action of `Window` group pub struct Append { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Append { @@ -183,18 +183,6 @@ impl Append { ) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } /// Shared helper to get C-based action state in Optional format diff --git a/src/app/browser/window/action/bookmark.rs b/src/app/browser/window/action/bookmark.rs index 4524e60d..61d1933d 100644 --- a/src/app/browser/window/action/bookmark.rs +++ b/src/app/browser/window/action/bookmark.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group pub struct Bookmark { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Bookmark { @@ -66,16 +66,4 @@ impl Bookmark { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/action/close.rs b/src/app/browser/window/action/close.rs index 6c927bee..00d668a4 100644 --- a/src/app/browser/window/action/close.rs +++ b/src/app/browser/window/action/close.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Window` group pub struct Close { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Close { @@ -61,16 +61,4 @@ impl Close { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/action/close_all.rs b/src/app/browser/window/action/close_all.rs index 938d422e..e5d34e65 100644 --- a/src/app/browser/window/action/close_all.rs +++ b/src/app/browser/window/action/close_all.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `CloseAll` action of `Window` group pub struct CloseAll { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl CloseAll { @@ -61,16 +61,4 @@ impl CloseAll { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/action/history_back.rs b/src/app/browser/window/action/history_back.rs index cb7e3745..2e602539 100644 --- a/src/app/browser/window/action/history_back.rs +++ b/src/app/browser/window/action/history_back.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryBack` action of `Window` group pub struct HistoryBack { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl HistoryBack { @@ -66,16 +66,4 @@ impl HistoryBack { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/action/history_forward.rs b/src/app/browser/window/action/history_forward.rs index 9f6c99c0..22a54dcd 100644 --- a/src/app/browser/window/action/history_forward.rs +++ b/src/app/browser/window/action/history_forward.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryForward` action of `Window` group pub struct HistoryForward { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl HistoryForward { @@ -66,16 +66,4 @@ impl HistoryForward { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/action/home.rs b/src/app/browser/window/action/home.rs index 8c51520b..9b575f6c 100644 --- a/src/app/browser/window/action/home.rs +++ b/src/app/browser/window/action/home.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group pub struct Home { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Home { @@ -66,16 +66,4 @@ impl Home { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/action/pin.rs b/src/app/browser/window/action/pin.rs index 8ec61303..5ca612fd 100644 --- a/src/app/browser/window/action/pin.rs +++ b/src/app/browser/window/action/pin.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Pin` action of `Window` group pub struct Pin { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Pin { @@ -61,16 +61,4 @@ impl Pin { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/action/reload.rs b/src/app/browser/window/action/reload.rs index a1edce11..ab6a4763 100644 --- a/src/app/browser/window/action/reload.rs +++ b/src/app/browser/window/action/reload.rs @@ -1,6 +1,6 @@ use gtk::{ gio::SimpleAction, - glib::{uuid_string_random, GString}, + glib::uuid_string_random, prelude::{ActionExt, ToVariant}, }; @@ -11,7 +11,7 @@ const DEFAULT_STATE: i32 = -1; /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Reload` action of `Window` group pub struct Reload { - gobject: SimpleAction, + pub gobject: SimpleAction, } impl Reload { @@ -66,16 +66,4 @@ impl Reload { }) }); } - - // Getters - - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject - pub fn gobject(&self) -> &SimpleAction { - &self.gobject - } - - /// Get auto-generated [action name](https://docs.gtk.org/gio/property.SimpleAction.name.html) - pub fn id(&self) -> GString { - self.gobject.name() - } } diff --git a/src/app/browser/window/header.rs b/src/app/browser/window/header.rs index 656ea47b..77663e08 100644 --- a/src/app/browser/window/header.rs +++ b/src/app/browser/window/header.rs @@ -6,11 +6,11 @@ use widget::Widget; use crate::app::browser::action::Action as BrowserAction; use crate::app::browser::window::action::Action as WindowAction; -use adw::{TabView, ToolbarView}; +use adw::TabView; use std::rc::Rc; pub struct Header { - widget: Rc, + pub widget: Rc, } impl Header { @@ -27,12 +27,7 @@ impl Header { // Return new struct Self { - widget: Rc::new(Widget::new(bar.gobject())), + widget: Rc::new(Widget::new(&bar.widget.gobject)), } } - - // Getters - pub fn gobject(&self) -> &ToolbarView { - self.widget.gobject() - } } diff --git a/src/app/browser/window/header/bar.rs b/src/app/browser/window/header/bar.rs index d7cbce79..0be125fc 100644 --- a/src/app/browser/window/header/bar.rs +++ b/src/app/browser/window/header/bar.rs @@ -11,11 +11,10 @@ use widget::Widget; use crate::app::browser::action::Action as BrowserAction; use crate::app::browser::window::action::Action as WindowAction; use adw::TabView; -use gtk::Box; use std::rc::Rc; pub struct Bar { - widget: Rc, + pub widget: Rc, } impl Bar { @@ -31,16 +30,10 @@ impl Bar { let menu = Menu::new(browser_action, window_action); Self { widget: Rc::new(Widget::new( - control.gobject(), - menu.gobject(), - tab.gobject(), + &control.widget.gobject, + &menu.widget.gobject, + &tab.widget.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 a03881f4..f09dba04 100644 --- a/src/app/browser/window/header/bar/control.rs +++ b/src/app/browser/window/header/bar/control.rs @@ -1,12 +1,10 @@ mod widget; - use widget::Widget; -use gtk::WindowControls; use std::rc::Rc; pub struct Control { - widget: Rc, + pub widget: Rc, } impl Control { @@ -16,9 +14,4 @@ impl Control { widget: Rc::new(Widget::new()), } } - - // Getters - pub fn gobject(&self) -> &WindowControls { - self.widget.gobject() - } } diff --git a/src/app/browser/window/header/bar/control/widget.rs b/src/app/browser/window/header/bar/control/widget.rs index af0f2f44..4d5301af 100644 --- a/src/app/browser/window/header/bar/control/widget.rs +++ b/src/app/browser/window/header/bar/control/widget.rs @@ -1,7 +1,7 @@ use gtk::{PackType, WindowControls}; pub struct Widget { - gobject: WindowControls, + pub gobject: WindowControls, } impl Widget { @@ -14,9 +14,4 @@ impl Widget { .build(), } } - - // Getters - pub fn gobject(&self) -> &WindowControls { - &self.gobject - } } diff --git a/src/app/browser/window/header/bar/menu.rs b/src/app/browser/window/header/bar/menu.rs index 15ee9578..16b2ccaf 100644 --- a/src/app/browser/window/header/bar/menu.rs +++ b/src/app/browser/window/header/bar/menu.rs @@ -6,12 +6,12 @@ use crate::app::browser::action::Action as BrowserAction; use crate::app::browser::window::action::Action as WindowAction; use gtk::{ gio::{self}, - MenuButton, + prelude::ActionExt, }; use std::rc::Rc; pub struct Menu { - widget: Rc, + pub widget: Rc, } #[rustfmt::skip] // @TODO template builder? impl Menu { @@ -26,14 +26,14 @@ impl Menu { let main_page = gio::Menu::new(); main_page.append(Some("New"), Some(&format!( "{}.{}", - window_action.id(), - window_action.append().id() + window_action.id, + window_action.append.gobject.name() ))); main_page.append(Some("Reload"), Some(&format!( "{}.{}", - window_action.id(), - window_action.reload().id() + window_action.id, + window_action.reload.gobject.name() ))); // Main > Page > Mark @@ -41,14 +41,14 @@ impl Menu { main_page_mark.append(Some("Bookmark"), Some(&format!( "{}.{}", - window_action.id(), - window_action.bookmark().id() + window_action.id, + window_action.bookmark.gobject.name() ))); main_page_mark.append(Some("Pin"), Some(&format!( "{}.{}", - window_action.id(), - window_action.pin().id() + window_action.id, + window_action.pin.gobject.name() ))); main_page.append_section(None, &main_page_mark); @@ -58,8 +58,8 @@ impl Menu { main_page_navigation.append(Some("Home"), Some(&format!( "{}.{}", - window_action.id(), - window_action.home().id() + window_action.id, + window_action.home.gobject.name() ))); // Main > Page > Navigation > History @@ -67,14 +67,14 @@ impl Menu { main_page_navigation_history.append(Some("Back"), Some(&format!( "{}.{}", - window_action.id(), - window_action.history_back().id() + window_action.id, + window_action.history_back.gobject.name() ))); main_page_navigation_history.append(Some("Forward"), Some(&format!( "{}.{}", - window_action.id(), - window_action.history_forward().id() + window_action.id, + window_action.history_forward.gobject.name() ))); main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history); @@ -86,14 +86,14 @@ impl Menu { main_page_close.append(Some("Current"), Some(&format!( "{}.{}", - window_action.id(), - window_action.close().id() + window_action.id, + window_action.close.gobject.name() ))); main_page_close.append(Some("All"), Some(&format!( "{}.{}", - window_action.id(), - window_action.close_all().id() + window_action.id, + window_action.close_all.gobject.name() ))); main_page.append_submenu(Some("Close"), &main_page_close); @@ -106,36 +106,31 @@ impl Menu { // Debug main_tool.append(Some("Debug"), Some(&format!( "{}.{}", - browser_action.id(), - browser_action.debug().id() + browser_action.id, + browser_action.debug.gobject.name() ))); main_tool.append(Some("Profile"), Some(&format!( "{}.{}", - browser_action.id(), - browser_action.profile().id() + browser_action.id, + browser_action.profile.gobject.name() ))); main_tool.append(Some("About"), Some(&format!( "{}.{}", - browser_action.id(), - browser_action.about().id() + browser_action.id, + browser_action.about.gobject.name() ))); main.append_submenu(Some("Tool"), &main_tool); main.append(Some("Quit"), Some(&format!( "{}.{}", - browser_action.id(), - browser_action.close().id() + browser_action.id, + browser_action.close.gobject.name() ))); // Result Self { widget:Rc::new(Widget::new(&main)) } } - - // Getters - pub fn gobject(&self) -> &MenuButton { - self.widget.gobject() - } } diff --git a/src/app/browser/window/header/bar/menu/widget.rs b/src/app/browser/window/header/bar/menu/widget.rs index 672fec55..c940ca37 100644 --- a/src/app/browser/window/header/bar/menu/widget.rs +++ b/src/app/browser/window/header/bar/menu/widget.rs @@ -1,7 +1,7 @@ use gtk::{gio::Menu, Align, MenuButton}; pub struct Widget { - gobject: MenuButton, + pub gobject: MenuButton, } impl Widget { @@ -17,9 +17,4 @@ impl Widget { .build(), } } - - // Getters - pub fn gobject(&self) -> &MenuButton { - &self.gobject - } } diff --git a/src/app/browser/window/header/bar/tab.rs b/src/app/browser/window/header/bar/tab.rs index c5cedbec..4fb53f61 100644 --- a/src/app/browser/window/header/bar/tab.rs +++ b/src/app/browser/window/header/bar/tab.rs @@ -5,23 +5,21 @@ use append::Append; use widget::Widget; use crate::app::browser::window::action::Action as WindowAction; -use adw::{TabBar, TabView}; +use adw::TabView; use std::rc::Rc; pub struct Tab { - widget: Rc, + pub widget: Rc, } impl Tab { // Construct pub fn new(window_action: Rc, view: &TabView) -> Self { Self { - widget: Rc::new(Widget::new(view, Append::new(window_action).gobject())), + widget: Rc::new(Widget::new( + view, + &Append::new(window_action).widget.gobject, + )), } } - - // Getters - pub fn gobject(&self) -> &TabBar { - self.widget.gobject() - } } diff --git a/src/app/browser/window/header/bar/tab/append.rs b/src/app/browser/window/header/bar/tab/append.rs index eda2a8f3..8a5be285 100644 --- a/src/app/browser/window/header/bar/tab/append.rs +++ b/src/app/browser/window/header/bar/tab/append.rs @@ -3,7 +3,6 @@ mod widget; use widget::Widget; use crate::app::browser::window::action::Action as WindowAction; -use gtk::Button; use std::rc::Rc; pub struct Append { @@ -17,9 +16,4 @@ impl Append { widget: Rc::new(Widget::new(window_action)), } } - - // Getters - pub fn gobject(&self) -> &Button { - self.widget.gobject() - } } 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 886c5fcc..fd4340bd 100644 --- a/src/app/browser/window/header/bar/tab/append/widget.rs +++ b/src/app/browser/window/header/bar/tab/append/widget.rs @@ -3,7 +3,7 @@ use gtk::{prelude::ButtonExt, Align, Button}; use std::rc::Rc; pub struct Widget { - gobject: Button, + pub gobject: Button, } impl Widget { @@ -18,13 +18,8 @@ impl Widget { .build(); // Init events - gobject.connect_clicked(move |_| window_action.append().activate_default_once()); + gobject.connect_clicked(move |_| window_action.append.activate_default_once()); Self { gobject } } - - // Getters - pub fn gobject(&self) -> &Button { - &self.gobject - } } diff --git a/src/app/browser/window/header/bar/tab/widget.rs b/src/app/browser/window/header/bar/tab/widget.rs index 7c359d61..9ccc3aa0 100644 --- a/src/app/browser/window/header/bar/tab/widget.rs +++ b/src/app/browser/window/header/bar/tab/widget.rs @@ -2,7 +2,7 @@ use adw::{TabBar, TabView}; use gtk::prelude::IsA; pub struct Widget { - gobject: TabBar, + pub gobject: TabBar, } impl Widget { @@ -17,9 +17,4 @@ impl Widget { .build(), } } - - // Getters - pub fn gobject(&self) -> &TabBar { - &self.gobject - } } diff --git a/src/app/browser/window/header/bar/widget.rs b/src/app/browser/window/header/bar/widget.rs index 86754b44..5cf90835 100644 --- a/src/app/browser/window/header/bar/widget.rs +++ b/src/app/browser/window/header/bar/widget.rs @@ -2,7 +2,7 @@ use adw::TabBar; use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls}; pub struct Widget { - gobject: Box, + pub gobject: Box, } impl Widget { @@ -19,9 +19,4 @@ impl Widget { Self { gobject } } - - // Getters - pub fn gobject(&self) -> &Box { - &self.gobject - } } diff --git a/src/app/browser/window/header/widget.rs b/src/app/browser/window/header/widget.rs index d4c7a7b9..c03add89 100644 --- a/src/app/browser/window/header/widget.rs +++ b/src/app/browser/window/header/widget.rs @@ -2,7 +2,7 @@ use adw::ToolbarView; use gtk::Box; pub struct Widget { - gobject: ToolbarView, + pub gobject: ToolbarView, } impl Widget { @@ -14,9 +14,4 @@ impl Widget { Self { gobject } } - - // Getters - pub fn gobject(&self) -> &ToolbarView { - &self.gobject - } } diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index 0f8b5bcc..80e1ecf6 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -26,7 +26,7 @@ pub struct Tab { profile: Rc, actions: (Rc, Rc), index: Rc>>>, - widget: Rc, + pub widget: Rc, } impl Tab { @@ -39,11 +39,11 @@ impl Tab { let menu = Menu::new(action.1.clone()); // Init widget - let widget = Rc::new(Widget::new(menu.gobject())); + let widget = Rc::new(Widget::new(&menu.gobject)); // Init events - widget.gobject().connect_setup_menu({ + widget.gobject.connect_setup_menu({ let action = action.1.clone(); move |tab_view, tab_page| { // Set new state for page selected on menu open @@ -51,18 +51,18 @@ impl Tab { let state = tab_page.map(|this| tab_view.page_position(this)); // Update actions with new state value - action.bookmark().change_state(state); - action.close_all().change_state(state); - action.close().change_state(state); - action.history_back().change_state(state); - action.history_forward().change_state(state); - action.home().change_state(state); - action.pin().change_state(state); - action.reload().change_state(state); + action.bookmark.change_state(state); + action.close_all.change_state(state); + action.close.change_state(state); + action.history_back.change_state(state); + action.history_forward.change_state(state); + action.home.change_state(state); + action.pin.change_state(state); + action.reload.change_state(state); } }); - widget.gobject().connect_close_page({ + widget.gobject.connect_close_page({ let index = index.clone(); move |_, item| { // Get index ID by keyword saved @@ -81,7 +81,7 @@ impl Tab { } }); - widget.gobject().connect_selected_page_notify({ + widget.gobject.connect_selected_page_notify({ let index = index.clone(); move |this| { if let Some(page) = this.selected_page() { @@ -117,7 +117,7 @@ impl Tab { ) -> Rc { // Init new tab item let item = Rc::new(Item::new( - self.widget.gobject(), + &self.widget.gobject, self.profile.clone(), // Actions (self.actions.0.clone(), self.actions.1.clone()), @@ -228,7 +228,7 @@ impl Tab { // Update tab title on loading indicator inactive if !item.page.is_loading() { item.widget - .gobject() + .gobject .set_title(item.page.meta.title().as_str()) } } @@ -241,7 +241,7 @@ impl Tab { // Update tab title on loading indicator inactive if !item.page.is_loading() { item.widget - .gobject() + .gobject .set_title(item.page.meta.title().as_str()) } } @@ -283,7 +283,7 @@ impl Tab { Ok(records) => { for record in records { match Item::restore( - self.widget.gobject(), + &self.widget.gobject, transaction, &record.id, self.profile.clone(), @@ -322,10 +322,10 @@ impl Tab { item.save( transaction, &id, - &self.widget.gobject().page_position(item.widget.gobject()), - &item.widget.gobject().is_pinned(), - &item.widget.gobject().is_selected(), - &item.widget.gobject().needs_attention(), + &self.widget.gobject.page_position(&item.widget.gobject), + &item.widget.gobject.is_pinned(), + &item.widget.gobject.is_selected(), + &item.widget.gobject.needs_attention(), )?; } } @@ -343,12 +343,6 @@ impl Tab { // @TODO other/child features.. } - - // Getters - - pub fn widget(&self) -> &Rc { - &self.widget - } } // Tools diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 1752e84e..e853088c 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -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( diff --git a/src/app/browser/window/tab/item/identity/gemini.rs b/src/app/browser/window/tab/item/identity/gemini.rs index 5e2eea8f..dacf9ce3 100644 --- a/src/app/browser/window/tab/item/identity/gemini.rs +++ b/src/app/browser/window/tab/item/identity/gemini.rs @@ -163,7 +163,7 @@ impl Gemini { } // Reload page to apply changes - action.reload().activate(); + action.reload.activate(); } }); diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 664e087f..e71fb2a5 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -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(); 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 9f3f1f69..3339cf9a 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 @@ -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, diff --git a/src/app/browser/window/tab/item/page/navigation.rs b/src/app/browser/window/tab/item/page/navigation.rs index 8e9adc0e..e2ba86db 100644 --- a/src/app/browser/window/tab/item/page/navigation.rs +++ b/src/app/browser/window/tab/item/page/navigation.rs @@ -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 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 adac4a18..b911e4ac 100644 --- a/src/app/browser/window/tab/item/page/navigation/bookmark.rs +++ b/src/app/browser/window/tab/item/page/navigation/bookmark.rs @@ -6,7 +6,7 @@ use crate::app::browser::window::action::Action as WindowAction; use std::rc::Rc; pub struct Bookmark { - widget: Rc, + pub widget: Rc, } 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 { - &self.widget - } } 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 2f1a9398..06eb227c 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 @@ -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 - } } 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 30f4b120..97062d63 100644 --- a/src/app/browser/window/tab/item/page/navigation/history.rs +++ b/src/app/browser/window/tab/item/page/navigation/history.rs @@ -23,7 +23,7 @@ pub struct History { memory: RefCell>, index: RefCell>, // GTK - widget: Rc, + pub widget: Rc, } 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 { - &self.widget - } } 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 113e156b..edc25fab 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 @@ -6,8 +6,8 @@ use crate::app::browser::window::Action; use std::rc::Rc; pub struct Back { - action: Rc, - widget: Rc, + pub action: Rc, + pub widget: Rc, } 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 { - &self.widget - } } 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 3f35ec1d..9f67d840 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 @@ -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 - } } 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 61df4268..4e0cf894 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 @@ -6,8 +6,8 @@ use crate::app::browser::window::Action; use std::rc::Rc; pub struct Forward { - action: Rc, - widget: Rc, + pub action: Rc, + pub widget: Rc, } 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 { - &self.widget - } } 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 617a4476..aac2bf01 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 @@ -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 - } } 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 888e5bfc..ff00af9e 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 @@ -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 - } } 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 1a00e07c..39b9a41c 100644 --- a/src/app/browser/window/tab/item/page/navigation/home.rs +++ b/src/app/browser/window/tab/item/page/navigation/home.rs @@ -9,7 +9,7 @@ use std::{cell::RefCell, rc::Rc}; pub struct Home { action: Rc, uri: RefCell>, - widget: Rc, + pub widget: Rc, } 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 { - &self.widget - } pub fn url(&self) -> Option { // Build URL from parsed URI cache 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 224ae34c..8df4a6e1 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 @@ -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 - } } diff --git a/src/app/browser/window/tab/item/page/navigation/identity.rs b/src/app/browser/window/tab/item/page/navigation/identity.rs index 65e36377..52d8985b 100644 --- a/src/app/browser/window/tab/item/page/navigation/identity.rs +++ b/src/app/browser/window/tab/item/page/navigation/identity.rs @@ -6,7 +6,7 @@ use std::rc::Rc; pub struct Identity { action: Rc, - widget: Rc, + pub widget: Rc, } impl Identity { @@ -26,10 +26,4 @@ impl Identity { // Update widget self.widget.update(is_auth, is_enabled) } - - // Getters - - pub fn widget(&self) -> &Rc { - &self.widget - } } diff --git a/src/app/browser/window/tab/item/page/navigation/identity/widget.rs b/src/app/browser/window/tab/item/page/navigation/identity/widget.rs index b8bd3fc3..460861da 100644 --- a/src/app/browser/window/tab/item/page/navigation/identity/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/identity/widget.rs @@ -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 - } } 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 c44c9b8e..8a9d1d5f 100644 --- a/src/app/browser/window/tab/item/page/navigation/reload.rs +++ b/src/app/browser/window/tab/item/page/navigation/reload.rs @@ -7,7 +7,7 @@ use std::rc::Rc; pub struct Reload { action: Rc, - widget: Rc, + pub widget: Rc, } 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 { - &self.widget - } } 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 89f589c1..7bebeb35 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 @@ -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 - } } 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 b0adf17d..3c882ec4 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 @@ -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| { diff --git a/src/app/browser/window/tab/item/widget.rs b/src/app/browser/window/tab/item/widget.rs index e79b9d80..01996493 100644 --- a/src/app/browser/window/tab/item/widget.rs +++ b/src/app/browser/window/tab/item/widget.rs @@ -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 diff --git a/src/app/browser/window/tab/menu.rs b/src/app/browser/window/tab/menu.rs index 9a084975..4f9267ab 100644 --- a/src/app/browser/window/tab/menu.rs +++ b/src/app/browser/window/tab/menu.rs @@ -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 - } } diff --git a/src/app/browser/window/tab/widget.rs b/src/app/browser/window/tab/widget.rs index ab4ac889..7b33b71b 100644 --- a/src/app/browser/window/tab/widget.rs +++ b/src/app/browser/window/tab/widget.rs @@ -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 - } } diff --git a/src/app/browser/window/widget.rs b/src/app/browser/window/widget.rs index 801b17aa..ed84ca72 100644 --- a/src/app/browser/window/widget.rs +++ b/src/app/browser/window/widget.rs @@ -2,7 +2,7 @@ use adw::{TabView, ToolbarView}; use gtk::{prelude::BoxExt, Box, Orientation}; pub struct Widget { - gobject: Box, + pub gobject: Box, } impl Widget { @@ -14,9 +14,4 @@ impl Widget { Self { gobject } } - - // Getters - pub fn gobject(&self) -> &Box { - &self.gobject - } }