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