mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
replace static action names with objects
This commit is contained in:
parent
76d0c6014c
commit
12f5146468
4 changed files with 120 additions and 65 deletions
|
|
@ -13,9 +13,25 @@ pub struct Header {
|
|||
|
||||
impl Header {
|
||||
// Construct
|
||||
pub fn new(action_debug: &SimpleAction, action_quit: &SimpleAction) -> Self {
|
||||
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,
|
||||
) -> Self {
|
||||
// Init components
|
||||
let tray = Tray::new(action_debug, action_quit);
|
||||
let tray = Tray::new(
|
||||
action_debug,
|
||||
action_quit,
|
||||
action_tab_append,
|
||||
action_tab_close,
|
||||
action_tab_close_all,
|
||||
action_tab_page_reload,
|
||||
action_tab_pin,
|
||||
);
|
||||
|
||||
let subject = Subject::new();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,25 @@ pub struct Tray {
|
|||
}
|
||||
|
||||
impl Tray {
|
||||
pub fn new(action_debug: &SimpleAction, action_quit: &SimpleAction) -> Self {
|
||||
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,
|
||||
) -> Self {
|
||||
// Init components
|
||||
let menu = Menu::new(action_debug, action_quit);
|
||||
let menu = Menu::new(
|
||||
action_debug,
|
||||
action_quit,
|
||||
action_tab_append,
|
||||
action_tab_close,
|
||||
action_tab_close_all,
|
||||
action_tab_page_reload,
|
||||
action_tab_pin,
|
||||
);
|
||||
let tab = Tab::new();
|
||||
|
||||
// Init widget
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use gtk::{
|
||||
gio::{self, MenuItem, SimpleAction},
|
||||
gio::{self, SimpleAction},
|
||||
glib::{gformat, GString},
|
||||
prelude::ActionExt,
|
||||
MenuButton,
|
||||
|
|
@ -10,28 +10,45 @@ pub struct Menu {
|
|||
}
|
||||
|
||||
impl Menu {
|
||||
pub fn new(action_debug: &SimpleAction, action_quit: &SimpleAction) -> Self {
|
||||
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,
|
||||
) -> Self {
|
||||
// Init model
|
||||
let model_tab = gio::Menu::new();
|
||||
model_tab.append(Some("New"), Some("win.tab_append"));
|
||||
model_tab.append(Some("Pin"), Some("win.tab_pin"));
|
||||
model_tab.append(Some("New"), Some(&detailed_action_name(action_tab_append)));
|
||||
model_tab.append(Some("Pin"), Some(&detailed_action_name(action_tab_pin)));
|
||||
|
||||
let model_tab_page = gio::Menu::new();
|
||||
model_tab_page.append(Some("Base"), Some("win.tab_page_base"));
|
||||
model_tab_page.append(Some("Base"), Some("win.tab_page_base")); // @TODO
|
||||
|
||||
let model_tab_page_history = gio::Menu::new();
|
||||
model_tab_page_history.append(Some("Back"), Some("win.tab_page_history_back"));
|
||||
model_tab_page_history.append(Some("Forward"), Some("win.tab_page_history_forward"));
|
||||
model_tab_page_history.append(Some("Back"), Some("win.tab_page_history_back")); // @TODO
|
||||
model_tab_page_history.append(Some("Forward"), Some("win.tab_page_history_forward")); // @TODO
|
||||
model_tab_page.append_submenu(Some("History"), &model_tab_page_history);
|
||||
|
||||
model_tab_page.append(Some("Reload"), Some("win.tab_page_reload"));
|
||||
model_tab_page.append(Some("Bookmark"), Some("win.tab_page_bookmark"));
|
||||
model_tab_page.append(
|
||||
Some("Reload"),
|
||||
Some(&detailed_action_name(action_tab_page_reload)),
|
||||
);
|
||||
model_tab_page.append(Some("Bookmark"), Some("win.tab_page_bookmark")); // @TODO
|
||||
|
||||
model_tab.append_submenu(Some("Page"), &model_tab_page);
|
||||
|
||||
let model_tab_close = gio::Menu::new();
|
||||
model_tab_close.append(Some("Current"), Some("win.tab_close"));
|
||||
model_tab_close.append(Some("All"), Some("win.tab_close_all"));
|
||||
model_tab_close.append(
|
||||
Some("Current"),
|
||||
Some(&detailed_action_name(action_tab_close)),
|
||||
);
|
||||
model_tab_close.append(
|
||||
Some("All"),
|
||||
Some(&detailed_action_name(action_tab_close_all)),
|
||||
);
|
||||
model_tab.append_submenu(Some("Close"), &model_tab_close);
|
||||
|
||||
let model = gio::Menu::new();
|
||||
|
|
@ -56,5 +73,6 @@ impl Menu {
|
|||
|
||||
// Private helpers
|
||||
fn detailed_action_name(action: &SimpleAction) -> GString {
|
||||
gformat!("win.{}", action.name()) // @TODO
|
||||
gformat!("win.{}", action.name()) // @TODO find the way to ident parent group
|
||||
// without application-wide dependencies import
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue