Browse Source

implement objective actions

master
yggverse 2 months ago
parent
commit
a6559a289f
  1. 42
      src/browser/main/tab/page.rs

42
src/browser/main/tab/page.rs

@ -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
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 // Return activated structure
Self { Self {
// GTK // GTK
widget, widget,

Loading…
Cancel
Save