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 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()
),
&["<Primary>Escape"],
),
(
format!(
"{}.{}",
browser.action().id(),
browser.action().debug().id()
browser.action.id,
browser.action.debug.gobject.name()
),
&["<Primary>i"],
),
(
format!(
"{}.{}",
browser.action().id(),
browser.action().update().id()
browser.action.id,
browser.action.update.gobject.name()
),
&["<Primary>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()
),
&["<Primary>t"],
),
(
format!(
"{}.{}",
browser.window().action().id(),
browser.window().action().bookmark().id()
browser.window.action.id,
browser.window.action.bookmark.gobject.name()
),
&["<Primary>b"],
),
(
format!(
"{}.{}",
browser.window().action().id(),
browser.window().action().pin().id()
browser.window.action.id,
browser.window.action.pin.gobject.name()
),
&["<Primary>p"],
),
(
format!(
"{}.{}",
browser.window().action().id(),
browser.window().action().reload().id()
browser.window.action.id,
browser.window.action.reload.gobject.name()
),
&["<Primary>r"],
),
(
format!(
"{}.{}",
browser.window().action().id(),
browser.window().action().home().id()
browser.window.action.id,
browser.window.action.home.gobject.name()
),
&["<Primary>h"],
),
(
format!(
"{}.{}",
browser.window().action().id(),
browser.window().action().history_back().id()
browser.window.action.id,
browser.window.action.history_back.gobject.name()
),
&["<Primary>Left"],
),
(
format!(
"{}.{}",
browser.window().action().id(),
browser.window().action().history_forward().id()
browser.window.action.id,
browser.window.action.history_forward.gobject.name()
),
&["<Primary>Right"],
),
(
format!(
"{}.{}",
browser.window().action().id(),
browser.window().action().close().id()
browser.window.action.id,
browser.window.action.close.gobject.name()
),
&["<Primary>q"],
),

View File

@ -19,9 +19,9 @@ use sqlite::Transaction;
use std::rc::Rc;
pub struct Browser {
action: Rc<Action>,
widget: Rc<Widget>,
window: Rc<Window>,
pub action: Rc<Action>,
pub widget: Rc<Widget>,
pub window: Rc<Window>,
}
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<Action> {
&self.action
}
pub fn window(&self) -> &Rc<Window> {
&self.window
}
}
// Tools

View File

@ -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<About>,
close: Rc<Close>,
debug: Rc<Debug>,
profile: Rc<Profile>,
update: Rc<Update>,
pub about: Rc<About>,
pub close: Rc<Close>,
pub debug: Rc<Debug>,
pub profile: Rc<Profile>,
pub update: Rc<Update>,
// 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<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::{
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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -16,9 +16,9 @@ use gtk::glib::GString;
use std::rc::Rc;
pub struct Window {
action: Rc<Action>,
tab: Rc<Tab>,
widget: Rc<Widget>,
pub action: Rc<Action>,
pub tab: Rc<Tab>,
pub widget: Rc<Widget>,
}
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<Action> {
&self.action
}
pub fn widget(&self) -> &Rc<Widget> {
&self.widget
}
}
// 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
pub struct Action {
// Actions
append: Rc<Append>,
bookmark: Rc<Bookmark>,
close_all: Rc<CloseAll>,
close: Rc<Close>,
history_back: Rc<HistoryBack>,
history_forward: Rc<HistoryForward>,
home: Rc<Home>,
pin: Rc<Pin>,
reload: Rc<Reload>,
pub append: Rc<Append>,
pub bookmark: Rc<Bookmark>,
pub close_all: Rc<CloseAll>,
pub close: Rc<Close>,
pub history_back: Rc<HistoryBack>,
pub history_forward: Rc<HistoryForward>,
pub home: Rc<Home>,
pub pin: Rc<Pin>,
pub reload: Rc<Reload>,
// 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<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::{
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

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -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<Widget>,
pub widget: Rc<Widget>,
}
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()
}
}

View File

@ -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<Widget>,
pub widget: Rc<Widget>,
}
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()
}
}

View File

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

View File

@ -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
}
}

View File

@ -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<Widget>,
pub widget: Rc<Widget>,
}
#[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()
}
}

View File

@ -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
}
}

View File

@ -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<Widget>,
pub widget: Rc<Widget>,
}
impl Tab {
// Construct
pub fn new(window_action: Rc<WindowAction>, 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()
}
}

View File

@ -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()
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -26,7 +26,7 @@ pub struct Tab {
profile: Rc<Profile>,
actions: (Rc<BrowserAction>, Rc<WindowAction>),
index: Rc<RefCell<HashMap<GString, Rc<Item>>>>,
widget: Rc<Widget>,
pub widget: Rc<Widget>,
}
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<Item> {
// 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<Widget> {
&self.widget
}
}
// Tools

View File

@ -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(

View File

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

View File

@ -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();

View File

@ -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,

View File

@ -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

View File

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

View File

@ -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
}
}

View File

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

View File

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

View File

@ -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
}
}

View File

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

View File

@ -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
}
}

View File

@ -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
}
}

View File

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

View File

@ -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
}
}

View File

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

View File

@ -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
}
}

View File

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

View File

@ -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
}
}

View File

@ -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| {

View File

@ -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

View File

@ -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) -> &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
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
}
}

View File

@ -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
}
}