begin window actions group implementation

This commit is contained in:
yggverse 2024-11-10 08:51:08 +02:00
parent 5f280efaf3
commit 36b86ef5cf
15 changed files with 145 additions and 63 deletions

View file

@ -3,6 +3,7 @@ mod widget;
use widget::Widget;
use crate::app::browser::action::Action as BrowserAction;
use crate::app::browser::window::action::Action as WindowAction;
use gtk::{
gio::{self, SimpleAction},
glib::{gformat, GString},
@ -18,7 +19,7 @@ pub struct Menu {
impl Menu {
pub fn new_rc(
browser_action: Rc<BrowserAction>,
action_page_new: SimpleAction,
window_action: Rc<WindowAction>,
action_page_close: SimpleAction,
action_page_close_all: SimpleAction,
action_page_home: SimpleAction,
@ -32,7 +33,12 @@ impl Menu {
// Main > Page
let main_page = gio::Menu::new();
main_page.append(Some("New"), Some(&detailed_action_name(&action_page_new)));
main_page.append(Some("New"), Some(&gformat!(
"{}.{}",
window_action.id(),
window_action.append().id()
)));
main_page.append(Some("Reload"), Some(&detailed_action_name(&action_page_reload)));
main_page.append(Some("Pin"), Some(&detailed_action_name(&action_page_pin)));

View file

@ -4,8 +4,8 @@ mod widget;
use append::Append;
use widget::Widget;
use crate::app::browser::window::action::Action as WindowAction;
use adw::{TabBar, TabView};
use gtk::gio::SimpleAction;
use std::rc::Rc;
pub struct Tab {
@ -14,9 +14,9 @@ pub struct Tab {
impl Tab {
// Construct
pub fn new_rc(action_page_new: SimpleAction, view: &TabView) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>, view: &TabView) -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(view, Append::new_rc(action_page_new).gobject()),
widget: Widget::new_rc(view, Append::new_rc(window_action).gobject()),
})
}

View file

@ -2,7 +2,8 @@ mod widget;
use widget::Widget;
use gtk::{gio::SimpleAction, Button};
use crate::app::browser::window::action::Action as WindowAction;
use gtk::Button;
use std::rc::Rc;
pub struct Append {
@ -11,9 +12,9 @@ pub struct Append {
impl Append {
// Construct
pub fn new_rc(action_page_new: SimpleAction) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(action_page_new),
widget: Widget::new_rc(window_action),
})
}

View file

@ -1,8 +1,5 @@
use gtk::{
gio::SimpleAction,
prelude::{ActionExt, ButtonExt},
Align, Button,
};
use crate::app::browser::window::action::Action as WindowAction;
use gtk::{prelude::ButtonExt, Align, Button};
use std::rc::Rc;
pub struct Widget {
@ -11,7 +8,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(action_page_new: SimpleAction) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("tab-new-symbolic")
@ -21,9 +18,7 @@ impl Widget {
.build();
// Init events
gobject.connect_clicked(move |_| {
action_page_new.activate(None);
});
gobject.connect_clicked(move |_| window_action.append().activate());
Rc::new(Self { gobject })
}