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({
|
action_page_history_back.connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |_, _| {
|
move |this, _| {
|
||||||
window.tab_page_navigation_history_back();
|
window.tab_page_navigation_history_back(page_position_from_action_state(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
action_page_history_forward.connect_activate({
|
action_page_history_forward.connect_activate({
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
move |_, _| {
|
move |this, _| {
|
||||||
window.tab_page_navigation_history_forward();
|
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);
|
self.tab.page_navigation_home(page_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_page_navigation_history_back(&self) {
|
pub fn tab_page_navigation_history_back(&self, page_position: Option<i32>) {
|
||||||
self.tab.page_navigation_history_back();
|
self.tab.page_navigation_history_back(page_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_page_navigation_history_forward(&self) {
|
pub fn tab_page_navigation_history_forward(&self, page_position: Option<i32>) {
|
||||||
self.tab.page_navigation_history_forward();
|
self.tab.page_navigation_history_forward(page_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reload page at given position or selected page on `None` given
|
/// Reload page at given position or selected page on `None` given
|
||||||
|
@ -72,6 +72,20 @@ impl Tab {
|
|||||||
|
|
||||||
menu.append_section(None, &navigation);
|
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();
|
let close = Menu::new();
|
||||||
|
|
||||||
close.append(
|
close.append(
|
||||||
@ -94,6 +108,8 @@ impl Tab {
|
|||||||
widget.gobject().connect_setup_menu({
|
widget.gobject().connect_setup_menu({
|
||||||
// Clone actions to update
|
// Clone actions to update
|
||||||
let action_page_close = action_page_close.clone();
|
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_home = action_page_home.clone();
|
||||||
let action_page_pin = action_page_pin.clone();
|
let action_page_pin = action_page_pin.clone();
|
||||||
let action_page_reload = action_page_reload.clone();
|
let action_page_reload = action_page_reload.clone();
|
||||||
@ -108,6 +124,8 @@ impl Tab {
|
|||||||
|
|
||||||
// Update actions
|
// Update actions
|
||||||
action_page_close.change_state(&state);
|
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_home.change_state(&state);
|
||||||
action_page_pin.change_state(&state);
|
action_page_pin.change_state(&state);
|
||||||
action_page_reload.change_state(&state);
|
action_page_reload.change_state(&state);
|
||||||
@ -236,34 +254,42 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_navigation_home(&self, page_position: Option<i32>) {
|
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(item) = self.index.borrow().get(&id) {
|
if let Some(id) = page.keyword() {
|
||||||
item.page_navigation_home();
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
|
item.page_navigation_home();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_navigation_history_back(&self) {
|
pub fn page_navigation_history_back(&self, page_position: Option<i32>) {
|
||||||
if let Some(id) = self.widget.current_page_keyword() {
|
if let Some(page) = self.widget.page(page_position) {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(id) = page.keyword() {
|
||||||
item.page_navigation_history_back();
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
|
item.page_navigation_history_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_navigation_history_forward(&self) {
|
pub fn page_navigation_history_forward(&self, page_position: Option<i32>) {
|
||||||
if let Some(id) = self.widget.current_page_keyword() {
|
if let Some(page) = self.widget.page(page_position) {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(id) = page.keyword() {
|
||||||
item.page_navigation_history_forward();
|
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
|
/// Reload page at `i32` position or selected page on `None` given
|
||||||
pub fn page_navigation_reload(&self, position: Option<i32>) {
|
pub fn page_navigation_reload(&self, page_position: Option<i32>) {
|
||||||
if let Some(id) = self.widget.page_keyword(position) {
|
if let Some(page) = self.widget.page(page_position) {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
if let Some(id) = page.keyword() {
|
||||||
item.page_navigation_reload();
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
|
item.page_navigation_reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use adw::{TabPage, TabView};
|
use adw::{TabPage, TabView};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
gio::{Icon, MenuModel},
|
gio::{Icon, MenuModel},
|
||||||
glib::GString,
|
|
||||||
prelude::IsA,
|
prelude::IsA,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,18 +64,6 @@ impl Widget {
|
|||||||
|
|
||||||
// Getters
|
// 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
|
/// Get tab page by position, `None` for selected page
|
||||||
/// * return `None` if requested or selected page not found
|
/// * return `None` if requested or selected page not found
|
||||||
pub fn page(&self, position: Option<i32>) -> Option<TabPage> {
|
pub fn page(&self, position: Option<i32>) -> Option<TabPage> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user