mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-05 07:54:14 +00:00
draft history navigation actions
This commit is contained in:
parent
356972ae39
commit
28684b8ef9
@ -142,16 +142,16 @@ impl Browser {
|
||||
});
|
||||
|
||||
action_tab_page_navigation_history_back.connect_activate({
|
||||
// let main = main.clone();
|
||||
let main = main.clone();
|
||||
move |_, _| {
|
||||
// @TODO
|
||||
main.tab_page_navigation_history_back();
|
||||
}
|
||||
});
|
||||
|
||||
action_tab_page_navigation_history_forward.connect_activate({
|
||||
// let main = main.clone();
|
||||
let main = main.clone();
|
||||
move |_, _| {
|
||||
// @TODO
|
||||
main.tab_page_navigation_history_forward();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -49,6 +49,14 @@ impl Main {
|
||||
self.tab.page_navigation_base();
|
||||
}
|
||||
|
||||
pub fn tab_page_navigation_history_back(&self) {
|
||||
self.tab.page_navigation_history_back();
|
||||
}
|
||||
|
||||
pub fn tab_page_navigation_history_forward(&self) {
|
||||
self.tab.page_navigation_history_forward();
|
||||
}
|
||||
|
||||
pub fn tab_page_navigation_reload(&self) {
|
||||
self.tab.page_navigation_reload();
|
||||
}
|
||||
|
@ -169,6 +169,32 @@ impl Tab {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn page_navigation_history_back(&self) {
|
||||
// Get current page
|
||||
if let Some(page_number) = self.widget.current_page() {
|
||||
// Get default widget to extract it name as the ID for childs
|
||||
if let Some(widget) = self.widget.nth_page(Some(page_number)) {
|
||||
// Get page by widget ID
|
||||
if let Some(page) = self.pages.borrow().get(&widget.widget_name()) {
|
||||
page.navigation_history_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn page_navigation_history_forward(&self) {
|
||||
// Get current page
|
||||
if let Some(page_number) = self.widget.current_page() {
|
||||
// Get default widget to extract it name as the ID for childs
|
||||
if let Some(widget) = self.widget.nth_page(Some(page_number)) {
|
||||
// Get page by widget ID
|
||||
if let Some(page) = self.pages.borrow().get(&widget.widget_name()) {
|
||||
page.navigation_history_forward();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn page_navigation_reload(&self) {
|
||||
// Get current page
|
||||
if let Some(page_number) = self.widget.current_page() {
|
||||
|
@ -95,7 +95,7 @@ impl Page {
|
||||
&request, true, // activate (page reload)
|
||||
);
|
||||
|
||||
navigation.add_history(request);
|
||||
navigation.history_add(request);
|
||||
}
|
||||
});
|
||||
|
||||
@ -126,6 +126,18 @@ impl Page {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn navigation_history_back(&self) {
|
||||
if let Some(url) = self.navigation.history_try_back() {
|
||||
self.action_page_open.activate(Some(&url.to_variant()));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn navigation_history_forward(&self) {
|
||||
if let Some(url) = self.navigation.history_try_forward() {
|
||||
self.action_page_open.activate(Some(&url.to_variant()));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn navigation_reload(&self) {
|
||||
// Init globals
|
||||
let request_text = self.navigation.request_text();
|
||||
|
@ -85,10 +85,18 @@ impl Navigation {
|
||||
self.request.widget().grab_focus();
|
||||
}
|
||||
|
||||
pub fn add_history(&self, request: GString) {
|
||||
pub fn history_add(&self, request: GString) {
|
||||
self.history.add(request, true);
|
||||
}
|
||||
|
||||
pub fn history_try_back(&self) -> Option<GString> {
|
||||
self.history.try_back(true)
|
||||
}
|
||||
|
||||
pub fn history_try_forward(&self) -> Option<GString> {
|
||||
self.history.try_forward(true)
|
||||
}
|
||||
|
||||
pub fn update(&self, progress_fraction: Option<f64>) {
|
||||
self.base.update(self.request.uri());
|
||||
self.history.update();
|
||||
|
@ -5,11 +5,11 @@ use back::Back;
|
||||
use forward::Forward;
|
||||
|
||||
use gtk::{gio::SimpleAction, glib::GString, prelude::BoxExt, Box, Orientation};
|
||||
use std::{cell::RefCell, sync::Arc, time::SystemTime};
|
||||
use std::{cell::RefCell, sync::Arc};
|
||||
|
||||
struct Memory {
|
||||
request: GString,
|
||||
time: SystemTime,
|
||||
// time: SystemTime,
|
||||
}
|
||||
|
||||
pub struct History {
|
||||
@ -67,7 +67,7 @@ impl History {
|
||||
// Append new Memory record
|
||||
self.memory.borrow_mut().push(Memory {
|
||||
request,
|
||||
time: SystemTime::now(),
|
||||
//time: SystemTime::now(),
|
||||
});
|
||||
|
||||
if follow_to_index {
|
||||
@ -88,11 +88,6 @@ impl History {
|
||||
None
|
||||
}
|
||||
|
||||
/* @TODO
|
||||
pub fn try_current(&self) -> bool {
|
||||
true
|
||||
} */
|
||||
|
||||
pub fn try_forward(&self, follow_to_index: bool) -> Option<GString> {
|
||||
if let Some(index) = self.index.borrow().as_ref() {
|
||||
if let Some(memory) = self.memory.borrow().get(index + 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user