mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
rename components
This commit is contained in:
parent
cf86cc2a14
commit
06f2e0e499
14 changed files with 18 additions and 18 deletions
|
|
@ -284,7 +284,7 @@ impl Page {
|
||||||
let description = gformat!("{placeholder}");
|
let description = gformat!("{placeholder}");
|
||||||
|
|
||||||
// Make input form
|
// Make input form
|
||||||
input.set_default(action_page_open, uri, Some(&description), Some(1024));
|
input.use_response(action_page_open, uri, Some(&description), Some(1024));
|
||||||
input.show();
|
input.show();
|
||||||
|
|
||||||
// Update meta
|
// Update meta
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
mod default;
|
mod response;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
use default::Default;
|
|
||||||
use gtk::{gio::SimpleAction, glib::Uri};
|
use gtk::{gio::SimpleAction, glib::Uri};
|
||||||
|
use response::Response;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
use adw::Clamp;
|
use adw::Clamp;
|
||||||
|
|
@ -31,7 +31,7 @@ impl Input {
|
||||||
self.widget.hide()
|
self.widget.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_default(
|
pub fn use_response(
|
||||||
&self,
|
&self,
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: Arc<SimpleAction>,
|
||||||
base: Uri,
|
base: Uri,
|
||||||
|
|
@ -39,7 +39,7 @@ impl Input {
|
||||||
size_limit: Option<usize>,
|
size_limit: Option<usize>,
|
||||||
) {
|
) {
|
||||||
self.widget.set_child(Some(
|
self.widget.set_child(Some(
|
||||||
&Default::new_arc(action_page_open, base, title, size_limit).gobject(),
|
&Response::new_arc(action_page_open, base, title, size_limit).gobject(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
mod control;
|
mod control;
|
||||||
mod response;
|
mod form;
|
||||||
mod title;
|
mod title;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
use control::Control;
|
use control::Control;
|
||||||
use response::Response;
|
use form::Form;
|
||||||
use title::Title;
|
use title::Title;
|
||||||
use widget::Widget;
|
use widget::Widget;
|
||||||
|
|
||||||
|
|
@ -16,12 +16,12 @@ use gtk::{
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Default {
|
pub struct Response {
|
||||||
// Components
|
// Components
|
||||||
widget: Arc<Widget>,
|
widget: Arc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default {
|
impl Response {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(
|
||||||
action_page_open: Arc<SimpleAction>,
|
action_page_open: Arc<SimpleAction>,
|
||||||
|
|
@ -35,23 +35,23 @@ impl Default {
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let control = Control::new_arc(action_send.clone());
|
let control = Control::new_arc(action_send.clone());
|
||||||
let response = Response::new_arc(action_update.clone());
|
let form = Form::new_arc(action_update.clone());
|
||||||
let title = Title::new_arc(title);
|
let title = Title::new_arc(title);
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Widget::new_arc(title.gobject(), response.gobject(), control.gobject());
|
let widget = Widget::new_arc(title.gobject(), form.gobject(), control.gobject());
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
action_update.connect_activate({
|
action_update.connect_activate({
|
||||||
let base = base.clone();
|
let base = base.clone();
|
||||||
let control = control.clone();
|
let control = control.clone();
|
||||||
let response = response.clone();
|
let form = form.clone();
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
control.update(match size_limit {
|
control.update(match size_limit {
|
||||||
Some(limit) => Some(
|
Some(limit) => Some(
|
||||||
limit as i32
|
limit as i32
|
||||||
- (base.to_string_partial(UriHideFlags::QUERY).len() as i32
|
- (base.to_string_partial(UriHideFlags::QUERY).len() as i32
|
||||||
+ Uri::escape_string(response.text().as_str(), None, false).len()
|
+ Uri::escape_string(form.text().as_str(), None, false).len()
|
||||||
as i32),
|
as i32),
|
||||||
),
|
),
|
||||||
None => None,
|
None => None,
|
||||||
|
|
@ -60,20 +60,20 @@ impl Default {
|
||||||
});
|
});
|
||||||
|
|
||||||
action_send.connect_activate({
|
action_send.connect_activate({
|
||||||
let response = response.clone();
|
let form = form.clone();
|
||||||
move |_, _| {
|
move |_, _| {
|
||||||
action_page_open.activate(Some(
|
action_page_open.activate(Some(
|
||||||
&format!(
|
&format!(
|
||||||
"{}?{}",
|
"{}?{}",
|
||||||
base.to_string_partial(UriHideFlags::QUERY),
|
base.to_string_partial(UriHideFlags::QUERY),
|
||||||
Uri::escape_string(response.text().as_str(), None, false),
|
Uri::escape_string(form.text().as_str(), None, false),
|
||||||
)
|
)
|
||||||
.to_variant(),
|
.to_variant(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.gobject().connect_realize(move |_| response.focus());
|
widget.gobject().connect_realize(move |_| form.focus());
|
||||||
|
|
||||||
// Return activated struct
|
// Return activated struct
|
||||||
Arc::new(Self { widget })
|
Arc::new(Self { widget })
|
||||||
|
|
@ -5,11 +5,11 @@ use widget::Widget;
|
||||||
use gtk::{gio::SimpleAction, glib::GString, TextView};
|
use gtk::{gio::SimpleAction, glib::GString, TextView};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Response {
|
pub struct Form {
|
||||||
widget: Arc<Widget>,
|
widget: Arc<Widget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Response {
|
impl Form {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(action_update: Arc<SimpleAction>) -> Arc<Self> {
|
pub fn new_arc(action_update: Arc<SimpleAction>) -> Arc<Self> {
|
||||||
// Init widget
|
// Init widget
|
||||||
Loading…
Add table
Add a link
Reference in a new issue