|
|
@ -1,5 +1,5 @@ |
|
|
|
use gtk::{ |
|
|
|
use gtk::{ |
|
|
|
gio::{self, MenuItem, SimpleAction}, |
|
|
|
gio::{self, SimpleAction}, |
|
|
|
glib::{gformat, GString}, |
|
|
|
glib::{gformat, GString}, |
|
|
|
prelude::ActionExt, |
|
|
|
prelude::ActionExt, |
|
|
|
MenuButton, |
|
|
|
MenuButton, |
|
|
@ -10,28 +10,45 @@ pub struct Menu { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl 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
|
|
|
|
// Init model
|
|
|
|
let model_tab = gio::Menu::new(); |
|
|
|
let model_tab = gio::Menu::new(); |
|
|
|
model_tab.append(Some("New"), Some("win.tab_append")); |
|
|
|
model_tab.append(Some("New"), Some(&detailed_action_name(action_tab_append))); |
|
|
|
model_tab.append(Some("Pin"), Some("win.tab_pin")); |
|
|
|
model_tab.append(Some("Pin"), Some(&detailed_action_name(action_tab_pin))); |
|
|
|
|
|
|
|
|
|
|
|
let model_tab_page = gio::Menu::new(); |
|
|
|
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(); |
|
|
|
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("Back"), Some("win.tab_page_history_back")); // @TODO
|
|
|
|
model_tab_page_history.append(Some("Forward"), Some("win.tab_page_history_forward")); |
|
|
|
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_submenu(Some("History"), &model_tab_page_history); |
|
|
|
|
|
|
|
|
|
|
|
model_tab_page.append(Some("Reload"), Some("win.tab_page_reload")); |
|
|
|
model_tab_page.append( |
|
|
|
model_tab_page.append(Some("Bookmark"), Some("win.tab_page_bookmark")); |
|
|
|
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); |
|
|
|
model_tab.append_submenu(Some("Page"), &model_tab_page); |
|
|
|
|
|
|
|
|
|
|
|
let model_tab_close = gio::Menu::new(); |
|
|
|
let model_tab_close = gio::Menu::new(); |
|
|
|
model_tab_close.append(Some("Current"), Some("win.tab_close")); |
|
|
|
model_tab_close.append( |
|
|
|
model_tab_close.append(Some("All"), Some("win.tab_close_all")); |
|
|
|
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); |
|
|
|
model_tab.append_submenu(Some("Close"), &model_tab_close); |
|
|
|
|
|
|
|
|
|
|
|
let model = gio::Menu::new(); |
|
|
|
let model = gio::Menu::new(); |
|
|
@ -56,5 +73,6 @@ impl Menu { |
|
|
|
|
|
|
|
|
|
|
|
// Private helpers
|
|
|
|
// Private helpers
|
|
|
|
fn detailed_action_name(action: &SimpleAction) -> GString { |
|
|
|
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
|
|
|
|
} |
|
|
|
} |
|
|
|