remove extra getters

This commit is contained in:
yggverse 2024-11-28 01:35:48 +02:00
parent 3ce272cd70
commit 0af69d99f6
56 changed files with 240 additions and 710 deletions

View File

@ -7,7 +7,7 @@ use crate::profile::Profile;
use adw::Application; use adw::Application;
use gtk::{ use gtk::{
glib::ExitCode, glib::ExitCode,
prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt}, prelude::{ActionExt, ApplicationExt, ApplicationExtManual, GtkApplicationExt},
}; };
use sqlite::Transaction; use sqlite::Transaction;
use std::rc::Rc; use std::rc::Rc;
@ -135,24 +135,24 @@ impl App {
( (
format!( format!(
"{}.{}", "{}.{}",
browser.action().id(), browser.action.id,
browser.action().close().id() browser.action.close.gobject.name()
), ),
&["<Primary>Escape"], &["<Primary>Escape"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.action().id(), browser.action.id,
browser.action().debug().id() browser.action.debug.gobject.name()
), ),
&["<Primary>i"], &["<Primary>i"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.action().id(), browser.action.id,
browser.action().update().id() browser.action.update.gobject.name()
), ),
&["<Primary>u"], &["<Primary>u"],
), ),
@ -160,64 +160,64 @@ impl App {
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().append().id() browser.window.action.append.gobject.name()
), ),
&["<Primary>t"], &["<Primary>t"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().bookmark().id() browser.window.action.bookmark.gobject.name()
), ),
&["<Primary>b"], &["<Primary>b"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().pin().id() browser.window.action.pin.gobject.name()
), ),
&["<Primary>p"], &["<Primary>p"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().reload().id() browser.window.action.reload.gobject.name()
), ),
&["<Primary>r"], &["<Primary>r"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().home().id() browser.window.action.home.gobject.name()
), ),
&["<Primary>h"], &["<Primary>h"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().history_back().id() browser.window.action.history_back.gobject.name()
), ),
&["<Primary>Left"], &["<Primary>Left"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().history_forward().id() browser.window.action.history_forward.gobject.name()
), ),
&["<Primary>Right"], &["<Primary>Right"],
), ),
( (
format!( format!(
"{}.{}", "{}.{}",
browser.window().action().id(), browser.window.action.id,
browser.window().action().close().id() browser.window.action.close.gobject.name()
), ),
&["<Primary>q"], &["<Primary>q"],
), ),

View File

@ -19,9 +19,9 @@ use sqlite::Transaction;
use std::rc::Rc; use std::rc::Rc;
pub struct Browser { pub struct Browser {
action: Rc<Action>, pub action: Rc<Action>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
window: Rc<Window>, pub window: Rc<Window>,
} }
impl Browser { impl Browser {
@ -33,43 +33,43 @@ impl Browser {
// Init widget // Init widget
let widget = Rc::new(Widget::new( let widget = Rc::new(Widget::new(
window.widget().gobject(), &window.widget.gobject,
&[ &[
// Connect action groups (to apply accels) // Connect action groups (to apply accels)
( (
// Browser // Browser
action.id(), &action.id,
action.gobject().clone(), action.gobject.clone(),
), ),
( (
// Window // Window
window.action().id(), &window.action.id,
window.action().gobject().clone(), window.action.gobject.clone(),
), ),
], ],
)); ));
// Connect events // Connect events
action.about().connect_activate({ action.about.connect_activate({
let window = window.clone(); let window = window.clone();
move || { 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(); let widget = widget.clone();
move || widget.gobject().close() move || widget.gobject().close()
}); });
action.debug().connect_activate({ action.debug.connect_activate({
let widget = widget.clone(); let widget = widget.clone();
move || { move || {
widget.gobject().emit_enable_debugging(true); widget.gobject().emit_enable_debugging(true);
} }
}); });
action.profile().connect_activate({ action.profile.connect_activate({
let profile = profile.clone(); let profile = profile.clone();
move || { move || {
FileLauncher::new(Some(&File::for_path(profile.config_path.as_path()))).launch( 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(); let window = window.clone();
move |tab_item_id| window.update(tab_item_id) move |tab_item_id| window.update(tab_item_id)
}); });
@ -175,16 +175,6 @@ impl Browser {
pub fn update(&self) { pub fn update(&self) {
self.window.update(None); self.window.update(None);
} }
// Getters
pub fn action(&self) -> &Rc<Action> {
&self.action
}
pub fn window(&self) -> &Rc<Window> {
&self.window
}
} }
// Tools // Tools

View File

@ -20,14 +20,14 @@ use std::rc::Rc;
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions /// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
pub struct Action { pub struct Action {
// Actions // Actions
about: Rc<About>, pub about: Rc<About>,
close: Rc<Close>, pub close: Rc<Close>,
debug: Rc<Debug>, pub debug: Rc<Debug>,
profile: Rc<Profile>, pub profile: Rc<Profile>,
update: Rc<Update>, pub update: Rc<Update>,
// Group // Group
id: GString, pub id: GString,
gobject: SimpleActionGroup, pub gobject: SimpleActionGroup,
} }
impl Action { impl Action {
@ -49,11 +49,11 @@ impl Action {
let gobject = SimpleActionGroup::new(); let gobject = SimpleActionGroup::new();
// Add action to given group // Add action to given group
gobject.add_action(about.gobject()); gobject.add_action(&about.gobject);
gobject.add_action(close.gobject()); gobject.add_action(&close.gobject);
gobject.add_action(debug.gobject()); gobject.add_action(&debug.gobject);
gobject.add_action(profile.gobject()); gobject.add_action(&profile.gobject);
gobject.add_action(update.gobject()); gobject.add_action(&update.gobject);
// Done // Done
Self { Self {
@ -66,44 +66,4 @@ impl Action {
gobject, gobject,
} }
} }
// Getters
/// Get reference to `About` action
pub fn about(&self) -> &Rc<About> {
&self.about
}
/// Get reference to `Close` action
pub fn close(&self) -> &Rc<Close> {
&self.close
}
/// Get reference to `Debug` action
pub fn debug(&self) -> &Rc<Debug> {
&self.debug
}
/// Get reference to `Profile` action
pub fn profile(&self) -> &Rc<Profile> {
&self.profile
}
/// Get reference to `Update` action
pub fn update(&self) -> &Rc<Update> {
&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
}
} }

View File

@ -1,12 +1,8 @@
use gtk::{ use gtk::{gio::SimpleAction, glib::uuid_string_random};
gio::SimpleAction,
glib::{uuid_string_random, GString},
prelude::ActionExt,
};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `About` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `About` action of `Browser` group
pub struct About { pub struct About {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl About { impl About {
@ -26,16 +22,4 @@ impl About {
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); 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()
}
} }

View File

@ -1,12 +1,8 @@
use gtk::{ use gtk::{gio::SimpleAction, glib::uuid_string_random};
gio::SimpleAction,
glib::{uuid_string_random, GString},
prelude::ActionExt,
};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Browser` group
pub struct Close { pub struct Close {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Close { impl Close {
@ -26,16 +22,4 @@ impl Close {
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); 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()
}
} }

View File

@ -1,12 +1,8 @@
use gtk::{ use gtk::{gio::SimpleAction, glib::uuid_string_random};
gio::SimpleAction,
glib::{uuid_string_random, GString},
prelude::ActionExt,
};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Debug` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Debug` action of `Browser` group
pub struct Debug { pub struct Debug {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Debug { impl Debug {
@ -26,16 +22,4 @@ impl Debug {
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); 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()
}
} }

View File

@ -1,12 +1,8 @@
use gtk::{ use gtk::{gio::SimpleAction, glib::uuid_string_random};
gio::SimpleAction,
glib::{uuid_string_random, GString},
prelude::ActionExt,
};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Profile` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Profile` action of `Browser` group
pub struct Profile { pub struct Profile {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Profile { impl Profile {
@ -26,16 +22,4 @@ impl Profile {
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); 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()
}
} }

View File

@ -6,7 +6,7 @@ use gtk::{
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Update` action of `Browser` group /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Update` action of `Browser` group
pub struct Update { pub struct Update {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Update { 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()
}
} }

View File

@ -16,9 +16,9 @@ use gtk::glib::GString;
use std::rc::Rc; use std::rc::Rc;
pub struct Window { pub struct Window {
action: Rc<Action>, pub action: Rc<Action>,
tab: Rc<Tab>, pub tab: Rc<Tab>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Window { impl Window {
@ -29,11 +29,11 @@ impl Window {
// Init components // Init components
let tab = Rc::new(Tab::new(profile, (browser_action.clone(), action.clone()))); let tab = Rc::new(Tab::new(profile, (browser_action.clone(), action.clone())));
let header = Header::new(browser_action, action.clone(), tab.widget().gobject()); let header = Header::new(browser_action, action.clone(), &tab.widget.gobject);
let widget = Rc::new(Widget::new(header.gobject(), tab.widget().gobject())); let widget = Rc::new(Widget::new(&header.widget.gobject, &tab.widget.gobject));
// Init events // Init events
action.append().connect_activate({ action.append.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position, request, is_pinned, is_selected, is_attention, is_load| { move |position, request, is_pinned, is_selected, is_attention, is_load| {
tab.append( tab.append(
@ -47,7 +47,7 @@ impl Window {
} }
}); });
action.bookmark().connect_activate({ action.bookmark.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position| { move |position| {
if tab.bookmark(position).is_err() { if tab.bookmark(position).is_err() {
@ -56,39 +56,39 @@ impl Window {
} }
}); });
action.pin().connect_activate({ action.pin.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position| tab.pin(position) move |position| tab.pin(position)
}); });
action.reload().connect_activate({ action.reload.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position| tab.page_reload(position) move |position| tab.page_reload(position)
}); });
action.home().connect_activate({ action.home.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position| tab.page_home(position) move |position| tab.page_home(position)
}); });
action.close().connect_activate({ action.close.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position| tab.close(position) move |position| tab.close(position)
}); });
action.close_all().connect_activate({ action.close_all.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |_| tab.close_all() move |_| tab.close_all()
}); });
action.history_back().connect_activate({ action.history_back.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position| { move |position| {
tab.page_history_back(position); tab.page_history_back(position);
} // @TODO rename destination method } // @TODO rename destination method
}); });
action.history_forward().connect_activate({ action.history_forward.connect_activate({
let tab = tab.clone(); let tab = tab.clone();
move |position| { move |position| {
tab.page_history_forward(position); tab.page_history_forward(position);
@ -161,16 +161,6 @@ impl Window {
pub fn init(&self) { pub fn init(&self) {
self.tab.init(); self.tab.init();
} }
// Getters
pub fn action(&self) -> &Rc<Action> {
&self.action
}
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }
// Tools // Tools

View File

@ -30,18 +30,18 @@ pub use append::Position; // public enum
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions /// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
pub struct Action { pub struct Action {
// Actions // Actions
append: Rc<Append>, pub append: Rc<Append>,
bookmark: Rc<Bookmark>, pub bookmark: Rc<Bookmark>,
close_all: Rc<CloseAll>, pub close_all: Rc<CloseAll>,
close: Rc<Close>, pub close: Rc<Close>,
history_back: Rc<HistoryBack>, pub history_back: Rc<HistoryBack>,
history_forward: Rc<HistoryForward>, pub history_forward: Rc<HistoryForward>,
home: Rc<Home>, pub home: Rc<Home>,
pin: Rc<Pin>, pub pin: Rc<Pin>,
reload: Rc<Reload>, pub reload: Rc<Reload>,
// Group // Group
id: GString, pub id: GString,
gobject: SimpleActionGroup, pub gobject: SimpleActionGroup,
} }
impl Action { impl Action {
@ -67,15 +67,15 @@ impl Action {
let gobject = SimpleActionGroup::new(); let gobject = SimpleActionGroup::new();
// Add action to given group // Add action to given group
gobject.add_action(append.gobject()); gobject.add_action(&append.gobject);
gobject.add_action(bookmark.gobject()); gobject.add_action(&bookmark.gobject);
gobject.add_action(close_all.gobject()); gobject.add_action(&close_all.gobject);
gobject.add_action(close.gobject()); gobject.add_action(&close.gobject);
gobject.add_action(history_back.gobject()); gobject.add_action(&history_back.gobject);
gobject.add_action(history_forward.gobject()); gobject.add_action(&history_forward.gobject);
gobject.add_action(home.gobject()); gobject.add_action(&home.gobject);
gobject.add_action(pin.gobject()); gobject.add_action(&pin.gobject);
gobject.add_action(reload.gobject()); gobject.add_action(&reload.gobject);
// Done // Done
Self { Self {
@ -92,64 +92,4 @@ impl Action {
gobject, gobject,
} }
} }
// Getters
/// Get reference to `Append` action
pub fn append(&self) -> &Rc<Append> {
&self.append
}
/// Get reference to `Bookmark` action
pub fn bookmark(&self) -> &Rc<Bookmark> {
&self.bookmark
}
/// Get reference to `CloseAll` action
pub fn close_all(&self) -> &Rc<CloseAll> {
&self.close_all
}
/// Get reference to `Close` action
pub fn close(&self) -> &Rc<Close> {
&self.close
}
/// Get reference to `HistoryBack` action
pub fn history_back(&self) -> &Rc<HistoryBack> {
&self.history_back
}
/// Get reference to `HistoryForward` action
pub fn history_forward(&self) -> &Rc<HistoryForward> {
&self.history_forward
}
/// Get reference to `Home` action
pub fn home(&self) -> &Rc<Home> {
&self.home
}
/// Get reference to `Pin` action
pub fn pin(&self) -> &Rc<Pin> {
&self.pin
}
/// Get reference to `Reload` action
pub fn reload(&self) -> &Rc<Reload> {
&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
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString, Variant}, glib::{uuid_string_random, Variant},
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Append` action of `Window` group
pub struct Append { pub struct Append {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Append { 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 /// Shared helper to get C-based action state in Optional format

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
pub struct Bookmark { pub struct Bookmark {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Bookmark { 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()
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Close` action of `Window` group
pub struct Close { pub struct Close {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Close { 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()
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `CloseAll` action of `Window` group
pub struct CloseAll { pub struct CloseAll {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl CloseAll { 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()
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryBack` action of `Window` group
pub struct HistoryBack { pub struct HistoryBack {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl HistoryBack { 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()
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `HistoryForward` action of `Window` group
pub struct HistoryForward { pub struct HistoryForward {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl HistoryForward { 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()
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Home` action of `Window` group
pub struct Home { pub struct Home {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Home { 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()
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Pin` action of `Window` group
pub struct Pin { pub struct Pin {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Pin { 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()
}
} }

View File

@ -1,6 +1,6 @@
use gtk::{ use gtk::{
gio::SimpleAction, gio::SimpleAction,
glib::{uuid_string_random, GString}, glib::uuid_string_random,
prelude::{ActionExt, ToVariant}, 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 /// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Reload` action of `Window` group
pub struct Reload { pub struct Reload {
gobject: SimpleAction, pub gobject: SimpleAction,
} }
impl Reload { 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()
}
} }

View File

@ -6,11 +6,11 @@ use widget::Widget;
use crate::app::browser::action::Action as BrowserAction; use crate::app::browser::action::Action as BrowserAction;
use crate::app::browser::window::action::Action as WindowAction; use crate::app::browser::window::action::Action as WindowAction;
use adw::{TabView, ToolbarView}; use adw::TabView;
use std::rc::Rc; use std::rc::Rc;
pub struct Header { pub struct Header {
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Header { impl Header {
@ -27,12 +27,7 @@ impl Header {
// Return new struct // Return new struct
Self { 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()
}
} }

View File

@ -11,11 +11,10 @@ use widget::Widget;
use crate::app::browser::action::Action as BrowserAction; use crate::app::browser::action::Action as BrowserAction;
use crate::app::browser::window::action::Action as WindowAction; use crate::app::browser::window::action::Action as WindowAction;
use adw::TabView; use adw::TabView;
use gtk::Box;
use std::rc::Rc; use std::rc::Rc;
pub struct Bar { pub struct Bar {
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Bar { impl Bar {
@ -31,16 +30,10 @@ impl Bar {
let menu = Menu::new(browser_action, window_action); let menu = Menu::new(browser_action, window_action);
Self { Self {
widget: Rc::new(Widget::new( widget: Rc::new(Widget::new(
control.gobject(), &control.widget.gobject,
menu.gobject(), &menu.widget.gobject,
tab.gobject(), &tab.widget.gobject,
)), )),
} }
} }
// Getters
pub fn gobject(&self) -> &Box {
self.widget.gobject()
}
} }

View File

@ -1,12 +1,10 @@
mod widget; mod widget;
use widget::Widget; use widget::Widget;
use gtk::WindowControls;
use std::rc::Rc; use std::rc::Rc;
pub struct Control { pub struct Control {
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Control { impl Control {
@ -16,9 +14,4 @@ impl Control {
widget: Rc::new(Widget::new()), widget: Rc::new(Widget::new()),
} }
} }
// Getters
pub fn gobject(&self) -> &WindowControls {
self.widget.gobject()
}
} }

View File

@ -1,7 +1,7 @@
use gtk::{PackType, WindowControls}; use gtk::{PackType, WindowControls};
pub struct Widget { pub struct Widget {
gobject: WindowControls, pub gobject: WindowControls,
} }
impl Widget { impl Widget {
@ -14,9 +14,4 @@ impl Widget {
.build(), .build(),
} }
} }
// Getters
pub fn gobject(&self) -> &WindowControls {
&self.gobject
}
} }

View File

@ -6,12 +6,12 @@ use crate::app::browser::action::Action as BrowserAction;
use crate::app::browser::window::action::Action as WindowAction; use crate::app::browser::window::action::Action as WindowAction;
use gtk::{ use gtk::{
gio::{self}, gio::{self},
MenuButton, prelude::ActionExt,
}; };
use std::rc::Rc; use std::rc::Rc;
pub struct Menu { pub struct Menu {
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
#[rustfmt::skip] // @TODO template builder? #[rustfmt::skip] // @TODO template builder?
impl Menu { impl Menu {
@ -26,14 +26,14 @@ impl Menu {
let main_page = gio::Menu::new(); let main_page = gio::Menu::new();
main_page.append(Some("New"), Some(&format!( main_page.append(Some("New"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.append().id() window_action.append.gobject.name()
))); )));
main_page.append(Some("Reload"), Some(&format!( main_page.append(Some("Reload"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.reload().id() window_action.reload.gobject.name()
))); )));
// Main > Page > Mark // Main > Page > Mark
@ -41,14 +41,14 @@ impl Menu {
main_page_mark.append(Some("Bookmark"), Some(&format!( main_page_mark.append(Some("Bookmark"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.bookmark().id() window_action.bookmark.gobject.name()
))); )));
main_page_mark.append(Some("Pin"), Some(&format!( main_page_mark.append(Some("Pin"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.pin().id() window_action.pin.gobject.name()
))); )));
main_page.append_section(None, &main_page_mark); main_page.append_section(None, &main_page_mark);
@ -58,8 +58,8 @@ impl Menu {
main_page_navigation.append(Some("Home"), Some(&format!( main_page_navigation.append(Some("Home"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.home().id() window_action.home.gobject.name()
))); )));
// Main > Page > Navigation > History // Main > Page > Navigation > History
@ -67,14 +67,14 @@ impl Menu {
main_page_navigation_history.append(Some("Back"), Some(&format!( main_page_navigation_history.append(Some("Back"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.history_back().id() window_action.history_back.gobject.name()
))); )));
main_page_navigation_history.append(Some("Forward"), Some(&format!( main_page_navigation_history.append(Some("Forward"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.history_forward().id() window_action.history_forward.gobject.name()
))); )));
main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history); 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!( main_page_close.append(Some("Current"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.close().id() window_action.close.gobject.name()
))); )));
main_page_close.append(Some("All"), Some(&format!( main_page_close.append(Some("All"), Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.close_all().id() window_action.close_all.gobject.name()
))); )));
main_page.append_submenu(Some("Close"), &main_page_close); main_page.append_submenu(Some("Close"), &main_page_close);
@ -106,36 +106,31 @@ impl Menu {
// Debug // Debug
main_tool.append(Some("Debug"), Some(&format!( main_tool.append(Some("Debug"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id(), browser_action.id,
browser_action.debug().id() browser_action.debug.gobject.name()
))); )));
main_tool.append(Some("Profile"), Some(&format!( main_tool.append(Some("Profile"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id(), browser_action.id,
browser_action.profile().id() browser_action.profile.gobject.name()
))); )));
main_tool.append(Some("About"), Some(&format!( main_tool.append(Some("About"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id(), browser_action.id,
browser_action.about().id() browser_action.about.gobject.name()
))); )));
main.append_submenu(Some("Tool"), &main_tool); main.append_submenu(Some("Tool"), &main_tool);
main.append(Some("Quit"), Some(&format!( main.append(Some("Quit"), Some(&format!(
"{}.{}", "{}.{}",
browser_action.id(), browser_action.id,
browser_action.close().id() browser_action.close.gobject.name()
))); )));
// Result // Result
Self { widget:Rc::new(Widget::new(&main)) } Self { widget:Rc::new(Widget::new(&main)) }
} }
// Getters
pub fn gobject(&self) -> &MenuButton {
self.widget.gobject()
}
} }

View File

@ -1,7 +1,7 @@
use gtk::{gio::Menu, Align, MenuButton}; use gtk::{gio::Menu, Align, MenuButton};
pub struct Widget { pub struct Widget {
gobject: MenuButton, pub gobject: MenuButton,
} }
impl Widget { impl Widget {
@ -17,9 +17,4 @@ impl Widget {
.build(), .build(),
} }
} }
// Getters
pub fn gobject(&self) -> &MenuButton {
&self.gobject
}
} }

View File

@ -5,23 +5,21 @@ use append::Append;
use widget::Widget; use widget::Widget;
use crate::app::browser::window::action::Action as WindowAction; use crate::app::browser::window::action::Action as WindowAction;
use adw::{TabBar, TabView}; use adw::TabView;
use std::rc::Rc; use std::rc::Rc;
pub struct Tab { pub struct Tab {
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Tab { impl Tab {
// Construct // Construct
pub fn new(window_action: Rc<WindowAction>, view: &TabView) -> Self { pub fn new(window_action: Rc<WindowAction>, view: &TabView) -> Self {
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()
}
} }

View File

@ -3,7 +3,6 @@ mod widget;
use widget::Widget; use widget::Widget;
use crate::app::browser::window::action::Action as WindowAction; use crate::app::browser::window::action::Action as WindowAction;
use gtk::Button;
use std::rc::Rc; use std::rc::Rc;
pub struct Append { pub struct Append {
@ -17,9 +16,4 @@ impl Append {
widget: Rc::new(Widget::new(window_action)), widget: Rc::new(Widget::new(window_action)),
} }
} }
// Getters
pub fn gobject(&self) -> &Button {
self.widget.gobject()
}
} }

View File

@ -3,7 +3,7 @@ use gtk::{prelude::ButtonExt, Align, Button};
use std::rc::Rc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, pub gobject: Button,
} }
impl Widget { impl Widget {
@ -18,13 +18,8 @@ impl Widget {
.build(); .build();
// Init events // Init events
gobject.connect_clicked(move |_| window_action.append().activate_default_once()); gobject.connect_clicked(move |_| window_action.append.activate_default_once());
Self { gobject } Self { gobject }
} }
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
} }

View File

@ -2,7 +2,7 @@ use adw::{TabBar, TabView};
use gtk::prelude::IsA; use gtk::prelude::IsA;
pub struct Widget { pub struct Widget {
gobject: TabBar, pub gobject: TabBar,
} }
impl Widget { impl Widget {
@ -17,9 +17,4 @@ impl Widget {
.build(), .build(),
} }
} }
// Getters
pub fn gobject(&self) -> &TabBar {
&self.gobject
}
} }

View File

@ -2,7 +2,7 @@ use adw::TabBar;
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls}; use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls};
pub struct Widget { pub struct Widget {
gobject: Box, pub gobject: Box,
} }
impl Widget { impl Widget {
@ -19,9 +19,4 @@ impl Widget {
Self { gobject } Self { gobject }
} }
// Getters
pub fn gobject(&self) -> &Box {
&self.gobject
}
} }

View File

@ -2,7 +2,7 @@ use adw::ToolbarView;
use gtk::Box; use gtk::Box;
pub struct Widget { pub struct Widget {
gobject: ToolbarView, pub gobject: ToolbarView,
} }
impl Widget { impl Widget {
@ -14,9 +14,4 @@ impl Widget {
Self { gobject } Self { gobject }
} }
// Getters
pub fn gobject(&self) -> &ToolbarView {
&self.gobject
}
} }

View File

@ -26,7 +26,7 @@ pub struct Tab {
profile: Rc<Profile>, profile: Rc<Profile>,
actions: (Rc<BrowserAction>, Rc<WindowAction>), actions: (Rc<BrowserAction>, Rc<WindowAction>),
index: Rc<RefCell<HashMap<GString, Rc<Item>>>>, index: Rc<RefCell<HashMap<GString, Rc<Item>>>>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Tab { impl Tab {
@ -39,11 +39,11 @@ impl Tab {
let menu = Menu::new(action.1.clone()); let menu = Menu::new(action.1.clone());
// Init widget // Init widget
let widget = Rc::new(Widget::new(menu.gobject())); let widget = Rc::new(Widget::new(&menu.gobject));
// Init events // Init events
widget.gobject().connect_setup_menu({ widget.gobject.connect_setup_menu({
let action = action.1.clone(); let action = action.1.clone();
move |tab_view, tab_page| { move |tab_view, tab_page| {
// Set new state for page selected on menu open // 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)); let state = tab_page.map(|this| tab_view.page_position(this));
// Update actions with new state value // Update actions with new state value
action.bookmark().change_state(state); action.bookmark.change_state(state);
action.close_all().change_state(state); action.close_all.change_state(state);
action.close().change_state(state); action.close.change_state(state);
action.history_back().change_state(state); action.history_back.change_state(state);
action.history_forward().change_state(state); action.history_forward.change_state(state);
action.home().change_state(state); action.home.change_state(state);
action.pin().change_state(state); action.pin.change_state(state);
action.reload().change_state(state); action.reload.change_state(state);
} }
}); });
widget.gobject().connect_close_page({ widget.gobject.connect_close_page({
let index = index.clone(); let index = index.clone();
move |_, item| { move |_, item| {
// Get index ID by keyword saved // 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(); let index = index.clone();
move |this| { move |this| {
if let Some(page) = this.selected_page() { if let Some(page) = this.selected_page() {
@ -117,7 +117,7 @@ impl Tab {
) -> Rc<Item> { ) -> Rc<Item> {
// Init new tab item // Init new tab item
let item = Rc::new(Item::new( let item = Rc::new(Item::new(
self.widget.gobject(), &self.widget.gobject,
self.profile.clone(), self.profile.clone(),
// Actions // Actions
(self.actions.0.clone(), self.actions.1.clone()), (self.actions.0.clone(), self.actions.1.clone()),
@ -228,7 +228,7 @@ impl Tab {
// Update tab title on loading indicator inactive // Update tab title on loading indicator inactive
if !item.page.is_loading() { if !item.page.is_loading() {
item.widget item.widget
.gobject() .gobject
.set_title(item.page.meta.title().as_str()) .set_title(item.page.meta.title().as_str())
} }
} }
@ -241,7 +241,7 @@ impl Tab {
// Update tab title on loading indicator inactive // Update tab title on loading indicator inactive
if !item.page.is_loading() { if !item.page.is_loading() {
item.widget item.widget
.gobject() .gobject
.set_title(item.page.meta.title().as_str()) .set_title(item.page.meta.title().as_str())
} }
} }
@ -283,7 +283,7 @@ impl Tab {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
match Item::restore( match Item::restore(
self.widget.gobject(), &self.widget.gobject,
transaction, transaction,
&record.id, &record.id,
self.profile.clone(), self.profile.clone(),
@ -322,10 +322,10 @@ impl Tab {
item.save( item.save(
transaction, transaction,
&id, &id,
&self.widget.gobject().page_position(item.widget.gobject()), &self.widget.gobject.page_position(&item.widget.gobject),
&item.widget.gobject().is_pinned(), &item.widget.gobject.is_pinned(),
&item.widget.gobject().is_selected(), &item.widget.gobject.is_selected(),
&item.widget.gobject().needs_attention(), &item.widget.gobject.needs_attention(),
)?; )?;
} }
} }
@ -343,12 +343,6 @@ impl Tab {
// @TODO other/child features.. // @TODO other/child features..
} }
// Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }
// Tools // Tools

View File

@ -112,7 +112,7 @@ impl Item {
self.page.update(); self.page.update();
// Update tab loading indicator // 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( pub fn clean(

View File

@ -163,7 +163,7 @@ impl Gemini {
} }
// Reload page to apply changes // Reload page to apply changes
action.reload().activate(); action.reload.activate();
} }
}); });

View File

@ -210,7 +210,7 @@ impl Page {
// Update // Update
self.meta.set_status(Status::Reload).set_title("Loading.."); 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 // Route by request
match Uri::parse(&request, UriFlags::NONE) { match Uri::parse(&request, UriFlags::NONE) {
@ -241,7 +241,7 @@ impl Page {
self.meta.set_status(status).set_title(title); self.meta.set_status(status).set_title(title);
// Update window // 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) { fn load_gemini(&self, uri: Uri, is_history: bool) {
// Init shared clones // Init shared clones
let cancellable = self.cancellable.borrow().clone(); 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 tab_action = self.tab_action.clone();
let navigation = self.navigation.clone(); let navigation = self.navigation.clone();
let content = self.content.clone(); let content = self.content.clone();

View File

@ -284,7 +284,7 @@ impl Reader {
return match uri.scheme().as_str() { return match uri.scheme().as_str() {
"gemini" => { "gemini" => {
// Open new page in browser // Open new page in browser
actions.0.append().activate_stateful_once( actions.0.append.activate_stateful_once(
Position::After, Position::After,
Some(uri.to_string()), Some(uri.to_string()),
false, false,

View File

@ -49,12 +49,12 @@ impl Navigation {
// Init widget // Init widget
let widget = Rc::new(Widget::new( let widget = Rc::new(Widget::new(
identity.widget().gobject(), &identity.widget.gobject,
home.widget().gobject(), &home.widget.gobject,
history.widget().gobject(), &history.widget.gobject,
reload.widget().gobject(), &reload.widget.gobject,
&request.widget.entry, // @TODO remove extra getters from other components &request.widget.entry,
bookmark.widget().gobject(), &bookmark.widget.gobject,
)); ));
// Done // Done

View File

@ -6,7 +6,7 @@ use crate::app::browser::window::action::Action as WindowAction;
use std::rc::Rc; use std::rc::Rc;
pub struct Bookmark { pub struct Bookmark {
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Bookmark { impl Bookmark {
@ -21,10 +21,4 @@ impl Bookmark {
pub fn update(&self, has_bookmark: bool) { pub fn update(&self, has_bookmark: bool) {
self.widget.update(has_bookmark); self.widget.update(has_bookmark);
} }
// Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }

View File

@ -7,7 +7,7 @@ const ICON_YES: &str = "starred-symbolic";
const ICON_NON: &str = "non-starred-symbolic"; const ICON_NON: &str = "non-starred-symbolic";
pub struct Widget { pub struct Widget {
gobject: Button, pub gobject: Button,
} }
impl Widget { impl Widget {
@ -21,7 +21,7 @@ impl Widget {
.build(); .build();
// Init events // Init events
gobject.connect_clicked(move |_| action.bookmark().activate()); gobject.connect_clicked(move |_| action.bookmark.activate());
// Return activated `Self` // Return activated `Self`
Self { gobject } Self { gobject }
@ -33,10 +33,4 @@ impl Widget {
self.gobject self.gobject
.set_icon_name(if has_bookmark { ICON_YES } else { ICON_NON }); .set_icon_name(if has_bookmark { ICON_YES } else { ICON_NON });
} }
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
} }

View File

@ -23,7 +23,7 @@ pub struct History {
memory: RefCell<Vec<Memory>>, memory: RefCell<Vec<Memory>>,
index: RefCell<Option<usize>>, index: RefCell<Option<usize>>,
// GTK // GTK
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl History { impl History {
@ -34,10 +34,7 @@ impl History {
let forward = Rc::new(Forward::new(window_action)); let forward = Rc::new(Forward::new(window_action));
// Init widget // Init widget
let widget = Rc::new(Widget::new( let widget = Rc::new(Widget::new(&back.widget.gobject, &forward.widget.gobject));
back.widget().gobject(),
forward.widget().gobject(),
));
// Init memory // Init memory
let memory = RefCell::new(Vec::new()); let memory = RefCell::new(Vec::new());
@ -123,10 +120,4 @@ impl History {
None => self.forward.update(false), None => self.forward.update(false),
}; };
} }
// Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }

View File

@ -6,8 +6,8 @@ use crate::app::browser::window::Action;
use std::rc::Rc; use std::rc::Rc;
pub struct Back { pub struct Back {
action: Rc<Action>, pub action: Rc<Action>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Back { impl Back {
@ -24,15 +24,9 @@ impl Back {
pub fn update(&self, status: bool) { pub fn update(&self, status: bool) {
// Update actions // Update actions
self.action.history_back().gobject().set_enabled(status); self.action.history_back.gobject.set_enabled(status);
// Update child components // Update child components
self.widget.update(status); self.widget.update(status);
} }
// Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }

View File

@ -6,7 +6,7 @@ use gtk::{
use std::rc::Rc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, pub gobject: Button,
} }
impl Widget { impl Widget {
@ -20,7 +20,7 @@ impl Widget {
.build(); .build();
// Init events // Init events
gobject.connect_clicked(move |_| action.history_back().activate()); gobject.connect_clicked(move |_| action.history_back.activate());
// Return activated `Self` // Return activated `Self`
Self { gobject } Self { gobject }
@ -30,9 +30,4 @@ impl Widget {
pub fn update(&self, is_sensitive: bool) { pub fn update(&self, is_sensitive: bool) {
self.gobject.set_sensitive(is_sensitive); self.gobject.set_sensitive(is_sensitive);
} }
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
} }

View File

@ -6,8 +6,8 @@ use crate::app::browser::window::Action;
use std::rc::Rc; use std::rc::Rc;
pub struct Forward { pub struct Forward {
action: Rc<Action>, pub action: Rc<Action>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Forward { impl Forward {
@ -22,15 +22,9 @@ impl Forward {
// Actions // Actions
pub fn update(&self, status: bool) { pub fn update(&self, status: bool) {
// Update actions // Update actions
self.action.history_forward().gobject().set_enabled(status); self.action.history_forward.gobject.set_enabled(status);
// Update child components // Update child components
self.widget.update(status); self.widget.update(status);
} }
// Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }

View File

@ -6,7 +6,7 @@ use gtk::{
use std::rc::Rc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, pub gobject: Button,
} }
impl Widget { impl Widget {
@ -20,7 +20,7 @@ impl Widget {
.build(); .build();
// Init events // Init events
gobject.connect_clicked(move |_| action.history_forward().activate()); gobject.connect_clicked(move |_| action.history_forward.activate());
// Return activated `Self` // Return activated `Self`
Self { gobject } Self { gobject }
@ -30,9 +30,4 @@ impl Widget {
pub fn update(&self, is_sensitive: bool) { pub fn update(&self, is_sensitive: bool) {
self.gobject.set_sensitive(is_sensitive); self.gobject.set_sensitive(is_sensitive);
} }
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
} }

View File

@ -4,7 +4,7 @@ use gtk::{
}; };
pub struct Widget { pub struct Widget {
gobject: Box, pub gobject: Box,
} }
impl Widget { impl Widget {
@ -25,9 +25,4 @@ impl Widget {
// Return activated `Self` // Return activated `Self`
Self { gobject } Self { gobject }
} }
// Getters
pub fn gobject(&self) -> &Box {
&self.gobject
}
} }

View File

@ -9,7 +9,7 @@ use std::{cell::RefCell, rc::Rc};
pub struct Home { pub struct Home {
action: Rc<WindowAction>, action: Rc<WindowAction>,
uri: RefCell<Option<Uri>>, uri: RefCell<Option<Uri>>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Home { impl Home {
@ -34,16 +34,13 @@ impl Home {
self.uri.replace(uri); self.uri.replace(uri);
// Update action status // Update action status
self.action.home().gobject().set_enabled(status); self.action.home.gobject.set_enabled(status);
// Update child components // Update child components
self.widget.update(status); self.widget.update(status);
} }
// Getters // Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
pub fn url(&self) -> Option<GString> { pub fn url(&self) -> Option<GString> {
// Build URL from parsed URI cache // Build URL from parsed URI cache

View File

@ -6,7 +6,7 @@ use gtk::{
use std::rc::Rc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, pub gobject: Button,
} }
impl Widget { impl Widget {
@ -20,7 +20,7 @@ impl Widget {
.build(); .build();
// Init events // Init events
gobject.connect_clicked(move |_| action.home().activate()); gobject.connect_clicked(move |_| action.home.activate());
// Return activated `Self` // Return activated `Self`
Self { gobject } Self { gobject }
@ -30,9 +30,4 @@ impl Widget {
pub fn update(&self, is_sensitive: bool) { pub fn update(&self, is_sensitive: bool) {
self.gobject.set_sensitive(is_sensitive); self.gobject.set_sensitive(is_sensitive);
} }
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
} }

View File

@ -6,7 +6,7 @@ use std::rc::Rc;
pub struct Identity { pub struct Identity {
action: Rc<Action>, action: Rc<Action>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Identity { impl Identity {
@ -26,10 +26,4 @@ impl Identity {
// Update widget // Update widget
self.widget.update(is_auth, is_enabled) self.widget.update(is_auth, is_enabled)
} }
// Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }

View File

@ -6,7 +6,7 @@ use gtk::{
use std::rc::Rc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, pub gobject: Button,
} }
impl Widget { impl Widget {
@ -32,9 +32,4 @@ impl Widget {
self.gobject self.gobject
.set_css_classes(if is_auth { &["success"] } else { &[] }); .set_css_classes(if is_auth { &["success"] } else { &[] });
} }
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
} }

View File

@ -7,7 +7,7 @@ use std::rc::Rc;
pub struct Reload { pub struct Reload {
action: Rc<WindowAction>, action: Rc<WindowAction>,
widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
impl Reload { impl Reload {
@ -23,15 +23,9 @@ impl Reload {
pub fn update(&self, is_enabled: bool) { pub fn update(&self, is_enabled: bool) {
// Update actions // Update actions
self.action.reload().gobject().set_enabled(is_enabled); self.action.reload.gobject.set_enabled(is_enabled);
// Update child components // Update child components
self.widget.update(is_enabled); self.widget.update(is_enabled);
} }
// Getters
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
} }

View File

@ -6,7 +6,7 @@ use gtk::{
use std::rc::Rc; use std::rc::Rc;
pub struct Widget { pub struct Widget {
gobject: Button, pub gobject: Button,
} }
impl Widget { impl Widget {
@ -20,7 +20,7 @@ impl Widget {
.build(); .build();
// Init events // Init events
gobject.connect_clicked(move |_| action.reload().activate()); gobject.connect_clicked(move |_| action.reload.activate());
// Return activated `Self` // Return activated `Self`
Self { gobject } Self { gobject }
@ -30,9 +30,4 @@ impl Widget {
pub fn update(&self, is_sensitive: bool) { pub fn update(&self, is_sensitive: bool) {
self.gobject.set_sensitive(is_sensitive); self.gobject.set_sensitive(is_sensitive);
} }
// Getters
pub fn gobject(&self) -> &Button {
&self.gobject
}
} }

View File

@ -42,7 +42,7 @@ impl Widget {
// Connect events // Connect events
entry.connect_changed(move |_| { entry.connect_changed(move |_| {
action.0.update().activate(None); action.0.update.activate(None);
}); });
entry.connect_activate(move |this| { entry.connect_activate(move |this| {

View File

@ -8,7 +8,7 @@ use sqlite::Transaction;
const DEFAULT_TITLE: &str = "New page"; const DEFAULT_TITLE: &str = "New page";
pub struct Widget { pub struct Widget {
gobject: TabPage, pub gobject: TabPage,
} }
impl Widget { impl Widget {
@ -128,12 +128,6 @@ impl Widget {
Ok(()) Ok(())
} }
// Getters
pub fn gobject(&self) -> &TabPage {
&self.gobject
}
} }
// Tools // Tools

View File

@ -1,11 +1,12 @@
use crate::app::browser::window::action::Action as WindowAction; use crate::app::browser::window::action::Action as WindowAction;
use gtk::prelude::ActionExt;
use std::rc::Rc; use std::rc::Rc;
/// Context menu wrapper /// Context menu wrapper
/// ///
/// https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.TabView.get_menu_model.html /// https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.TabView.get_menu_model.html
pub struct Menu { pub struct Menu {
gobject: gtk::gio::Menu, pub gobject: gtk::gio::Menu,
} }
impl Menu { impl Menu {
@ -19,8 +20,8 @@ impl Menu {
Some("Reload"), Some("Reload"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.reload().id() window_action.reload.gobject.name()
)), )),
); );
@ -30,8 +31,8 @@ impl Menu {
Some("Bookmark"), Some("Bookmark"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.bookmark().id() window_action.bookmark.gobject.name()
)), )),
); );
@ -39,8 +40,8 @@ impl Menu {
Some("Pin"), Some("Pin"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.pin().id() window_action.pin.gobject.name()
)), )),
); );
@ -52,8 +53,8 @@ impl Menu {
Some("Home"), Some("Home"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.home().id() window_action.home.gobject.name()
)), )),
); );
@ -65,8 +66,8 @@ impl Menu {
Some("Back"), Some("Back"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.history_back().id() window_action.history_back.gobject.name()
)), )),
); );
@ -74,8 +75,8 @@ impl Menu {
Some("Forward"), Some("Forward"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.history_forward().id() window_action.history_forward.gobject.name()
)), )),
); );
@ -87,8 +88,8 @@ impl Menu {
Some("Current"), Some("Current"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.close().id() window_action.close.gobject.name()
)), )),
); );
@ -96,8 +97,8 @@ impl Menu {
Some("All"), Some("All"),
Some(&format!( Some(&format!(
"{}.{}", "{}.{}",
window_action.id(), window_action.id,
window_action.close_all().id() window_action.close_all.gobject.name()
)), )),
); );
@ -105,9 +106,4 @@ impl Menu {
Self { gobject: main } Self { gobject: main }
} }
/// Get reference to [Menu](https://docs.gtk.org/gio/class.Menu.html) `GObject`
pub fn gobject(&self) -> &gtk::gio::Menu {
&self.gobject
}
} }

View File

@ -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 /// Wrapper for [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) GObject
pub struct Widget { pub struct Widget {
gobject: TabView, pub gobject: TabView,
} }
impl Widget { impl Widget {
@ -72,9 +72,4 @@ impl Widget {
None => self.gobject.selected_page(), 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
}
} }

View File

@ -2,7 +2,7 @@ use adw::{TabView, ToolbarView};
use gtk::{prelude::BoxExt, Box, Orientation}; use gtk::{prelude::BoxExt, Box, Orientation};
pub struct Widget { pub struct Widget {
gobject: Box, pub gobject: Box,
} }
impl Widget { impl Widget {
@ -14,9 +14,4 @@ impl Widget {
Self { gobject } Self { gobject }
} }
// Getters
pub fn gobject(&self) -> &Box {
&self.gobject
}
} }