mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
add history submenu
This commit is contained in:
parent
7ebcbde01b
commit
2d81cf7954
@ -154,15 +154,15 @@ impl Browser {
|
||||
|
||||
action_page_history_back.connect_activate({
|
||||
let window = window.clone();
|
||||
move |_, _| {
|
||||
window.tab_page_navigation_history_back();
|
||||
move |this, _| {
|
||||
window.tab_page_navigation_history_back(page_position_from_action_state(this));
|
||||
}
|
||||
});
|
||||
|
||||
action_page_history_forward.connect_activate({
|
||||
let window = window.clone();
|
||||
move |_, _| {
|
||||
window.tab_page_navigation_history_forward();
|
||||
move |this, _| {
|
||||
window.tab_page_navigation_history_forward(page_position_from_action_state(this));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -87,12 +87,12 @@ impl Window {
|
||||
self.tab.page_navigation_home(page_position);
|
||||
}
|
||||
|
||||
pub fn tab_page_navigation_history_back(&self) {
|
||||
self.tab.page_navigation_history_back();
|
||||
pub fn tab_page_navigation_history_back(&self, page_position: Option<i32>) {
|
||||
self.tab.page_navigation_history_back(page_position);
|
||||
}
|
||||
|
||||
pub fn tab_page_navigation_history_forward(&self) {
|
||||
self.tab.page_navigation_history_forward();
|
||||
pub fn tab_page_navigation_history_forward(&self, page_position: Option<i32>) {
|
||||
self.tab.page_navigation_history_forward(page_position);
|
||||
}
|
||||
|
||||
/// Reload page at given position or selected page on `None` given
|
||||
|
@ -72,6 +72,20 @@ impl Tab {
|
||||
|
||||
menu.append_section(None, &navigation);
|
||||
|
||||
let history = Menu::new();
|
||||
|
||||
history.append(
|
||||
Some("Back"),
|
||||
Some(&gformat!("win.{}", action_page_history_back.name())),
|
||||
);
|
||||
|
||||
history.append(
|
||||
Some("Forward"),
|
||||
Some(&gformat!("win.{}", action_page_history_forward.name())),
|
||||
);
|
||||
|
||||
menu.append_submenu(Some("History"), &history);
|
||||
|
||||
let close = Menu::new();
|
||||
|
||||
close.append(
|
||||
@ -94,6 +108,8 @@ impl Tab {
|
||||
widget.gobject().connect_setup_menu({
|
||||
// Clone actions to update
|
||||
let action_page_close = action_page_close.clone();
|
||||
let action_page_history_back = action_page_history_back.clone();
|
||||
let action_page_history_forward = action_page_history_forward.clone();
|
||||
let action_page_home = action_page_home.clone();
|
||||
let action_page_pin = action_page_pin.clone();
|
||||
let action_page_reload = action_page_reload.clone();
|
||||
@ -108,6 +124,8 @@ impl Tab {
|
||||
|
||||
// Update actions
|
||||
action_page_close.change_state(&state);
|
||||
action_page_history_back.change_state(&state);
|
||||
action_page_history_forward.change_state(&state);
|
||||
action_page_home.change_state(&state);
|
||||
action_page_pin.change_state(&state);
|
||||
action_page_reload.change_state(&state);
|
||||
@ -236,37 +254,45 @@ impl Tab {
|
||||
}
|
||||
|
||||
pub fn page_navigation_home(&self, page_position: Option<i32>) {
|
||||
if let Some(id) = self.widget.page_keyword(page_position) {
|
||||
if let Some(page) = self.widget.page(page_position) {
|
||||
if let Some(id) = page.keyword() {
|
||||
if let Some(item) = self.index.borrow().get(&id) {
|
||||
item.page_navigation_home();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn page_navigation_history_back(&self) {
|
||||
if let Some(id) = self.widget.current_page_keyword() {
|
||||
pub fn page_navigation_history_back(&self, page_position: Option<i32>) {
|
||||
if let Some(page) = self.widget.page(page_position) {
|
||||
if let Some(id) = page.keyword() {
|
||||
if let Some(item) = self.index.borrow().get(&id) {
|
||||
item.page_navigation_history_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn page_navigation_history_forward(&self) {
|
||||
if let Some(id) = self.widget.current_page_keyword() {
|
||||
pub fn page_navigation_history_forward(&self, page_position: Option<i32>) {
|
||||
if let Some(page) = self.widget.page(page_position) {
|
||||
if let Some(id) = page.keyword() {
|
||||
if let Some(item) = self.index.borrow().get(&id) {
|
||||
item.page_navigation_history_forward();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Reload page at `i32` position or selected page on `None` given
|
||||
pub fn page_navigation_reload(&self, position: Option<i32>) {
|
||||
if let Some(id) = self.widget.page_keyword(position) {
|
||||
pub fn page_navigation_reload(&self, page_position: Option<i32>) {
|
||||
if let Some(page) = self.widget.page(page_position) {
|
||||
if let Some(id) = page.keyword() {
|
||||
if let Some(item) = self.index.borrow().get(&id) {
|
||||
item.page_navigation_reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&self, id: &str) {
|
||||
match self.index.borrow().get(id) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
use adw::{TabPage, TabView};
|
||||
use gtk::{
|
||||
gio::{Icon, MenuModel},
|
||||
glib::GString,
|
||||
prelude::IsA,
|
||||
};
|
||||
|
||||
@ -65,18 +64,6 @@ impl Widget {
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn current_page_keyword(&self) -> Option<GString> {
|
||||
let page = self.gobject.selected_page()?;
|
||||
let id = page.keyword()?;
|
||||
Some(id)
|
||||
} // @TODO remove as deprecated
|
||||
|
||||
/// Get **keyword** for page at given position, `None` for selected page
|
||||
/// * return `None` if requested page or selected not found
|
||||
pub fn page_keyword(&self, position: Option<i32>) -> Option<GString> {
|
||||
self.page(position)?.keyword()
|
||||
}
|
||||
|
||||
/// Get tab page by position, `None` for selected page
|
||||
/// * return `None` if requested or selected page not found
|
||||
pub fn page(&self, position: Option<i32>) -> Option<TabPage> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user