mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement objective actions
This commit is contained in:
parent
5396c9a4a8
commit
a6559a289f
1 changed files with 31 additions and 27 deletions
|
|
@ -8,13 +8,13 @@ use navigation::Navigation;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::{
|
gio::{
|
||||||
ActionEntry, Cancellable, SimpleAction, SimpleActionGroup, SocketClient, SocketProtocol,
|
Cancellable, SimpleAction, SimpleActionGroup, SocketClient, SocketProtocol,
|
||||||
TlsCertificateFlags,
|
TlsCertificateFlags,
|
||||||
},
|
},
|
||||||
glib::{gformat, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
glib::{gformat, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
||||||
prelude::{
|
prelude::{
|
||||||
ActionExt, ActionMapExtManual, BoxExt, IOStreamExt, InputStreamExtManual,
|
ActionExt, ActionMapExt, BoxExt, IOStreamExt, InputStreamExtManual, OutputStreamExtManual,
|
||||||
OutputStreamExtManual, SocketClientExt, StaticVariantType, WidgetExt,
|
SocketClientExt, StaticVariantType, WidgetExt,
|
||||||
},
|
},
|
||||||
Box, Orientation,
|
Box, Orientation,
|
||||||
};
|
};
|
||||||
|
|
@ -41,6 +41,16 @@ impl Page {
|
||||||
action_tab_page_reload: Arc<SimpleAction>,
|
action_tab_page_reload: Arc<SimpleAction>,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: Arc<SimpleAction>,
|
||||||
) -> Page {
|
) -> Page {
|
||||||
|
// Init actions
|
||||||
|
let action_open = Arc::new(SimpleAction::new(
|
||||||
|
"open",
|
||||||
|
Some(&String::static_variant_type()),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Init action group
|
||||||
|
let action_group = SimpleActionGroup::new();
|
||||||
|
action_group.add_action(action_open.as_ref());
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let content = Arc::new(Content::new());
|
let content = Arc::new(Content::new());
|
||||||
let navigation = Arc::new(Navigation::new(
|
let navigation = Arc::new(Navigation::new(
|
||||||
|
|
@ -58,12 +68,15 @@ impl Page {
|
||||||
widget.append(navigation.widget());
|
widget.append(navigation.widget());
|
||||||
widget.append(content.widget());
|
widget.append(content.widget());
|
||||||
|
|
||||||
// Init actions @TODO use object container
|
widget.insert_action_group("page", Some(&action_group));
|
||||||
let action_open = ActionEntry::builder("open")
|
|
||||||
.parameter_type(Some(&String::static_variant_type()))
|
// Init async mutable Meta object
|
||||||
.activate({
|
let meta = Arc::new(RefCell::new(Meta::new()));
|
||||||
|
|
||||||
|
// Init events
|
||||||
|
action_open.connect_activate({
|
||||||
let navigation = navigation.clone();
|
let navigation = navigation.clone();
|
||||||
move |_, _, request| {
|
move |_, request| {
|
||||||
let uri = request
|
let uri = request
|
||||||
.expect("Parameter required for `page.open` action")
|
.expect("Parameter required for `page.open` action")
|
||||||
.get::<String>()
|
.get::<String>()
|
||||||
|
|
@ -74,18 +87,9 @@ impl Page {
|
||||||
true, // activate (page reload)
|
true, // activate (page reload)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.build();
|
|
||||||
|
|
||||||
// Init action group
|
// Return activated structure
|
||||||
let actions = SimpleActionGroup::new();
|
|
||||||
actions.add_action_entries([action_open]);
|
|
||||||
widget.insert_action_group("page", Some(&actions));
|
|
||||||
|
|
||||||
// Init async mutable Meta object
|
|
||||||
let meta = Arc::new(RefCell::new(Meta::new()));
|
|
||||||
|
|
||||||
// Result
|
|
||||||
Self {
|
Self {
|
||||||
// GTK
|
// GTK
|
||||||
widget,
|
widget,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue