mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-28 12:04:13 +00:00
remove extra getters, give names to gobjects
This commit is contained in:
parent
ccbc82d2f5
commit
ff3f064534
@ -74,7 +74,7 @@ impl Item {
|
||||
}
|
||||
|
||||
// Show identity selection for item
|
||||
action.ident().connect_activate({
|
||||
action.ident.connect_activate({
|
||||
let browser_action = actions.0.clone();
|
||||
let window_action = actions.1.clone();
|
||||
let page = page.clone();
|
||||
@ -98,7 +98,7 @@ impl Item {
|
||||
});
|
||||
|
||||
// Load new request for item
|
||||
action.load().connect_activate({
|
||||
action.load.connect_activate({
|
||||
let page = page.clone();
|
||||
move |request, is_history| {
|
||||
if let Some(text) = request {
|
||||
|
@ -8,8 +8,8 @@ use std::rc::Rc;
|
||||
|
||||
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
|
||||
pub struct Action {
|
||||
ident: Rc<Ident>,
|
||||
load: Rc<Load>,
|
||||
pub ident: Rc<Ident>,
|
||||
pub load: Rc<Load>,
|
||||
}
|
||||
|
||||
impl Action {
|
||||
@ -22,16 +22,4 @@ impl Action {
|
||||
load: Rc::new(Load::new()),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get reference to `Ident` action
|
||||
pub fn ident(&self) -> &Rc<Ident> {
|
||||
&self.ident
|
||||
}
|
||||
|
||||
/// Get reference to `Load` action
|
||||
pub fn load(&self) -> &Rc<Load> {
|
||||
&self.load
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use gtk::{gio::SimpleAction, glib::uuid_string_random, prelude::ActionExt};
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Ident` action of `Item` group
|
||||
pub struct Ident {
|
||||
gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Ident {
|
||||
@ -11,7 +11,7 @@ impl Ident {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), None),
|
||||
simple_action: SimpleAction::new(&uuid_string_random(), None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ impl Ident {
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
/// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
|
||||
pub fn activate(&self) {
|
||||
self.gobject.activate(None);
|
||||
self.simple_action.activate(None);
|
||||
}
|
||||
|
||||
// Events
|
||||
@ -28,12 +28,6 @@ impl Ident {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn() + 'static) {
|
||||
self.gobject.connect_activate(move |_, _| callback());
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn gobject(&self) -> &SimpleAction {
|
||||
&self.gobject
|
||||
self.simple_action.connect_activate(move |_, _| callback());
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use gtk::{
|
||||
|
||||
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Load` action of `Item` group
|
||||
pub struct Load {
|
||||
gobject: SimpleAction,
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Load {
|
||||
@ -15,7 +15,7 @@ impl Load {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(
|
||||
simple_action: SimpleAction::new(
|
||||
&uuid_string_random(),
|
||||
Some(&<(String, bool)>::static_variant_type()),
|
||||
),
|
||||
@ -27,7 +27,7 @@ impl Load {
|
||||
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
/// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
|
||||
pub fn activate(&self, request: Option<&str>, is_history: bool) {
|
||||
self.gobject.activate(Some(
|
||||
self.simple_action.activate(Some(
|
||||
&(
|
||||
match request {
|
||||
Some(value) => String::from(value),
|
||||
@ -44,7 +44,7 @@ impl Load {
|
||||
/// Define callback function for
|
||||
/// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<GString>, bool) + 'static) {
|
||||
self.gobject.connect_activate(move |_, this| {
|
||||
self.simple_action.connect_activate(move |_, this| {
|
||||
let (request, is_history) = this
|
||||
.expect("Expected (`request`,`is_history`) variant")
|
||||
.get::<(String, bool)>()
|
||||
|
@ -116,7 +116,7 @@ impl Page {
|
||||
pub fn home(&self) {
|
||||
if let Some(url) = self.navigation.home.url() {
|
||||
// Update with history record
|
||||
self.tab_action.load().activate(Some(&url), true);
|
||||
self.tab_action.load.activate(Some(&url), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -802,7 +802,7 @@ impl Page {
|
||||
.set_title("Redirect");
|
||||
|
||||
// Reload page to apply redirection (without history record request)
|
||||
tab_action.load().activate(None, false);
|
||||
tab_action.load.activate(None, false);
|
||||
}
|
||||
},
|
||||
Err(reason) => {
|
||||
|
@ -24,7 +24,7 @@ pub fn new_gobject(action: Rc<Action>) -> StatusPage {
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
button.connect_clicked(move |_| action.ident().activate());
|
||||
button.connect_clicked(move |_| action.ident.activate());
|
||||
|
||||
// Init status page
|
||||
StatusPage::builder()
|
||||
|
@ -346,7 +346,7 @@ impl Reader {
|
||||
return match uri.scheme().as_str() {
|
||||
"gemini" => {
|
||||
// Open new page in browser
|
||||
actions.1.load().activate(Some(&uri.to_str()), true);
|
||||
actions.1.load.activate(Some(&uri.to_str()), true);
|
||||
}
|
||||
// Scheme not supported, delegate
|
||||
_ => UriLauncher::new(&uri.to_str()).launch(
|
||||
|
@ -62,7 +62,7 @@ impl Response {
|
||||
action_send.connect_activate({
|
||||
let form = form.clone();
|
||||
move |_, _| {
|
||||
tab_action.load().activate(
|
||||
tab_action.load.activate(
|
||||
Some(&format!(
|
||||
"{}?{}",
|
||||
base.to_string_partial(UriHideFlags::QUERY),
|
||||
|
@ -44,7 +44,7 @@ impl Sensitive {
|
||||
action_send.connect_activate({
|
||||
let form = form.clone();
|
||||
move |_, _| {
|
||||
tab_action.load().activate(
|
||||
tab_action.load.activate(
|
||||
Some(&format!(
|
||||
"{}?{}",
|
||||
base.to_string_partial(UriHideFlags::QUERY),
|
||||
|
@ -21,7 +21,7 @@ impl Identity {
|
||||
// Actions
|
||||
pub fn update(&self, is_auth: bool, is_enabled: bool) {
|
||||
// Update action status
|
||||
self.action.ident().gobject().set_enabled(is_enabled);
|
||||
self.action.ident.simple_action.set_enabled(is_enabled);
|
||||
|
||||
// Update widget
|
||||
self.widget.update(is_auth, is_enabled)
|
||||
|
@ -20,7 +20,7 @@ impl Widget {
|
||||
.build();
|
||||
|
||||
// Init events @TODO dialog window required
|
||||
gobject.connect_clicked(move |_| action.ident().activate());
|
||||
gobject.connect_clicked(move |_| action.ident.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
|
@ -70,7 +70,7 @@ impl Widget {
|
||||
EntryIconPosition::Primary => todo!(),
|
||||
EntryIconPosition::Secondary => {
|
||||
if go.is_some() {
|
||||
tab_action.load().activate(Some(&this.text()), true);
|
||||
tab_action.load.activate(Some(&this.text()), true);
|
||||
}
|
||||
}
|
||||
_ => println!("Undefined icon position"), // drop notice @TODO
|
||||
@ -82,7 +82,7 @@ impl Widget {
|
||||
});
|
||||
|
||||
entry.connect_activate(move |entry| {
|
||||
tab_action.load().activate(Some(&entry.text()), true);
|
||||
tab_action.load.activate(Some(&entry.text()), true);
|
||||
});
|
||||
|
||||
entry.connect_state_flags_changed({
|
||||
|
Loading…
x
Reference in New Issue
Block a user