mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-10 20:51:45 +00:00
use actionable object
This commit is contained in:
parent
2d160b5a49
commit
01307f4925
@ -40,7 +40,7 @@ impl Navigation {
|
|||||||
let base = Base::new();
|
let base = Base::new();
|
||||||
let history = History::new();
|
let history = History::new();
|
||||||
let reload = Reload::new(action_tab_page_reload);
|
let reload = Reload::new(action_tab_page_reload);
|
||||||
let request = Request::new(request_text);
|
let request = Request::new(request_text, action_update);
|
||||||
let bookmark = Bookmark::new();
|
let bookmark = Bookmark::new();
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
use gtk::{
|
use gtk::{
|
||||||
|
gio::SimpleAction,
|
||||||
glib::{GString, Uri, UriFlags},
|
glib::{GString, Uri, UriFlags},
|
||||||
prelude::{EditableExt, EntryExt, WidgetExt},
|
prelude::{ActionExt, EditableExt, EntryExt, WidgetExt},
|
||||||
Entry,
|
Entry,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
widget: Entry,
|
widget: Entry,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(text: Option<GString>) -> Self {
|
pub fn new(text: Option<GString>, action_update: Arc<SimpleAction>) -> Self {
|
||||||
// GTK
|
// GTK
|
||||||
let widget = Entry::builder()
|
let widget = Entry::builder()
|
||||||
.placeholder_text("URL or search term...")
|
.placeholder_text("URL or search term...")
|
||||||
@ -24,15 +27,13 @@ impl Request {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
widget.connect_changed(|entry| {
|
widget.connect_changed(move |_| {
|
||||||
entry
|
action_update.activate(None);
|
||||||
.activate_action("win.update", None)
|
|
||||||
.expect("Action `win.update` not found")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.connect_activate(|entry| {
|
widget.connect_activate(|entry| {
|
||||||
entry
|
entry
|
||||||
.activate_action("win.tab_page_reload", None)
|
.activate_action("win.tab_page_reload", None) // @TODO
|
||||||
.expect("Action `win.tab_page_reload` not found")
|
.expect("Action `win.tab_page_reload` not found")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user