mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
create local actions group
This commit is contained in:
parent
1f44715ed7
commit
28fcf247b2
@ -9,7 +9,8 @@ use widget::Widget;
|
|||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::SimpleAction,
|
gio::SimpleAction,
|
||||||
glib::{GString, Propagation},
|
glib::{uuid_string_random, GString, Propagation},
|
||||||
|
prelude::StaticVariantType,
|
||||||
};
|
};
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use std::{cell::RefCell, collections::HashMap, sync::Arc};
|
use std::{cell::RefCell, collections::HashMap, sync::Arc};
|
||||||
@ -40,11 +41,17 @@ impl Tab {
|
|||||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
||||||
action_update: Arc<SimpleAction>,
|
action_update: Arc<SimpleAction>,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
|
// Init local actions
|
||||||
|
let action_tab_open = Arc::new(SimpleAction::new(
|
||||||
|
&uuid_string_random(),
|
||||||
|
Some(&String::static_variant_type()),
|
||||||
|
));
|
||||||
|
|
||||||
// Init empty HashMap index as no tabs appended yet
|
// Init empty HashMap index as no tabs appended yet
|
||||||
let index = Arc::new(RefCell::new(HashMap::new()));
|
let index = Arc::new(RefCell::new(HashMap::new()));
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Arc::new(Widget::new());
|
let widget = Arc::new(Widget::new(action_tab_open.clone()));
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
widget.gobject().connect_close_page({
|
widget.gobject().connect_close_page({
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
use gtk::glib::GString;
|
use gtk::{
|
||||||
|
gio::{SimpleAction, SimpleActionGroup},
|
||||||
|
glib::{uuid_string_random, GString},
|
||||||
|
prelude::{ActionMapExt, WidgetExt},
|
||||||
|
};
|
||||||
|
|
||||||
pub struct Widget {
|
pub struct Widget {
|
||||||
gobject: TabView,
|
gobject: TabView,
|
||||||
@ -7,10 +13,17 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Self {
|
pub fn new(action_tab_append: Arc<SimpleAction>) -> Self {
|
||||||
Self {
|
// Init additional action group
|
||||||
gobject: TabView::builder().build(),
|
let action_group = SimpleActionGroup::new();
|
||||||
}
|
action_group.add_action(action_tab_append.as_ref());
|
||||||
|
|
||||||
|
// Init gobject
|
||||||
|
let gobject = TabView::builder().build();
|
||||||
|
|
||||||
|
gobject.insert_action_group(&uuid_string_random(), Some(&action_group));
|
||||||
|
|
||||||
|
Self { gobject }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user