mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
create separated wrappers for history, close action group
This commit is contained in:
parent
4afa2c204c
commit
8113022cd4
22 changed files with 557 additions and 335 deletions
|
|
@ -11,7 +11,7 @@ use widget::Widget;
|
|||
use crate::app::browser::action::Action as BrowserAction;
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use adw::TabView;
|
||||
use gtk::{gio::SimpleAction, Box};
|
||||
use gtk::Box;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Bar {
|
||||
|
|
@ -23,23 +23,12 @@ impl Bar {
|
|||
pub fn new_rc(
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
action_page_close: SimpleAction,
|
||||
action_page_close_all: SimpleAction,
|
||||
action_page_history_back: SimpleAction,
|
||||
action_page_history_forward: SimpleAction,
|
||||
view: &TabView,
|
||||
) -> Rc<Self> {
|
||||
// Init components
|
||||
let control = Control::new_rc();
|
||||
let tab = Tab::new_rc(window_action.clone(), view);
|
||||
let menu = Menu::new_rc(
|
||||
browser_action,
|
||||
window_action,
|
||||
action_page_close,
|
||||
action_page_close_all,
|
||||
action_page_history_back,
|
||||
action_page_history_forward,
|
||||
);
|
||||
let menu = Menu::new_rc(browser_action, window_action);
|
||||
|
||||
// Build result
|
||||
Rc::new(Self {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ 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},
|
||||
prelude::ActionExt,
|
||||
gio::{self},
|
||||
MenuButton,
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
|
@ -19,10 +18,6 @@ impl Menu {
|
|||
pub fn new_rc(
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
action_page_close: SimpleAction,
|
||||
action_page_close_all: SimpleAction,
|
||||
action_page_history_back: SimpleAction,
|
||||
action_page_history_forward: SimpleAction,
|
||||
) -> Rc<Self> {
|
||||
// Main
|
||||
let main = gio::Menu::new();
|
||||
|
|
@ -58,8 +53,18 @@ impl Menu {
|
|||
|
||||
// Main > Page > Navigation > History
|
||||
let main_page_navigation_history = gio::Menu::new();
|
||||
main_page_navigation_history.append(Some("Back"), Some(&detailed_action_name(&action_page_history_back)));
|
||||
main_page_navigation_history.append(Some("Forward"), Some(&detailed_action_name(&action_page_history_forward)));
|
||||
|
||||
main_page_navigation_history.append(Some("Back"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.history_back().id()
|
||||
)));
|
||||
|
||||
main_page_navigation_history.append(Some("Forward"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.history_forward().id()
|
||||
)));
|
||||
|
||||
main_page_navigation.append_submenu(Some("History"), &main_page_navigation_history);
|
||||
|
||||
|
|
@ -67,8 +72,18 @@ impl Menu {
|
|||
|
||||
// Main > Page > Close
|
||||
let main_page_close = gio::Menu::new();
|
||||
main_page_close.append(Some("Current"), Some(&detailed_action_name(&action_page_close)));
|
||||
main_page_close.append(Some("All"), Some(&detailed_action_name(&action_page_close_all)));
|
||||
|
||||
main_page_close.append(Some("Current"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.close().id()
|
||||
)));
|
||||
|
||||
main_page_close.append(Some("All"), Some(&format!(
|
||||
"{}.{}",
|
||||
window_action.id(),
|
||||
window_action.close_all().id()
|
||||
)));
|
||||
|
||||
main_page.append_submenu(Some("Close"), &main_page_close);
|
||||
|
||||
|
|
@ -113,10 +128,3 @@ impl Menu {
|
|||
self.widget.gobject()
|
||||
}
|
||||
}
|
||||
|
||||
// Private helpers
|
||||
fn detailed_action_name(action: &SimpleAction) -> String {
|
||||
format!("win.{}", action.name()) // @TODO find the way to ident parent group
|
||||
// without application-wide dependencies import
|
||||
// see also src/app/action.rs
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue