mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
define actions in arc container
This commit is contained in:
parent
7c78396328
commit
9a3ad366af
10 changed files with 138 additions and 77 deletions
|
|
@ -5,19 +5,21 @@ use gtk::{
|
|||
MenuButton,
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct Menu {
|
||||
widget: MenuButton,
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
pub fn new(
|
||||
action_debug: &SimpleAction,
|
||||
action_quit: &SimpleAction,
|
||||
action_tab_append: &SimpleAction,
|
||||
action_tab_close: &SimpleAction,
|
||||
action_tab_close_all: &SimpleAction,
|
||||
action_tab_page_reload: &SimpleAction,
|
||||
action_tab_pin: &SimpleAction,
|
||||
action_debug: Arc<SimpleAction>,
|
||||
action_quit: Arc<SimpleAction>,
|
||||
action_tab_append: Arc<SimpleAction>,
|
||||
action_tab_close: Arc<SimpleAction>,
|
||||
action_tab_close_all: Arc<SimpleAction>,
|
||||
action_tab_page_reload: Arc<SimpleAction>,
|
||||
action_tab_pin: Arc<SimpleAction>,
|
||||
) -> Self {
|
||||
// Init model
|
||||
let model_tab = gio::Menu::new();
|
||||
|
|
@ -72,7 +74,7 @@ impl Menu {
|
|||
}
|
||||
|
||||
// Private helpers
|
||||
fn detailed_action_name(action: &SimpleAction) -> GString {
|
||||
fn detailed_action_name(action: Arc<SimpleAction>) -> GString {
|
||||
gformat!("win.{}", action.name()) // @TODO find the way to ident parent group
|
||||
// without application-wide dependencies import
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use gtk::{gio::SimpleAction, prelude::ActionExt, prelude::ButtonExt, Button};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct Tab {
|
||||
pub widget: Button,
|
||||
|
|
@ -6,7 +7,7 @@ pub struct Tab {
|
|||
|
||||
impl Tab {
|
||||
// Construct
|
||||
pub fn new(action_tab_append: &SimpleAction) -> Self {
|
||||
pub fn new(action_tab_append: Arc<SimpleAction>) -> Self {
|
||||
// Init widget
|
||||
let widget = Button::builder()
|
||||
.icon_name("tab-new-symbolic")
|
||||
|
|
@ -14,11 +15,8 @@ impl Tab {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
widget.connect_clicked({
|
||||
let action_tab_append = action_tab_append.clone();
|
||||
move |_| {
|
||||
action_tab_append.activate(None);
|
||||
}
|
||||
widget.connect_clicked(move |_| {
|
||||
action_tab_append.activate(None);
|
||||
});
|
||||
|
||||
// Return activated struct
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue