mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-10 10:24:13 +00:00
draft page reload action
This commit is contained in:
parent
4e0ec422ca
commit
fd73dc3d7c
@ -30,6 +30,10 @@ impl Main {
|
||||
self.tab.append(true);
|
||||
}
|
||||
|
||||
pub fn tab_page_reload(&self) {
|
||||
self.tab.page_reload();
|
||||
}
|
||||
|
||||
pub fn tab_close(&self) {
|
||||
self.tab.close();
|
||||
}
|
||||
|
@ -120,6 +120,19 @@ impl Tab {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn page_reload(&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.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&self) {
|
||||
// Get current page
|
||||
if let Some(page_number) = self.widget.current_page() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use gtk::{Box, Orientation};
|
||||
use gtk::{glib::GString, Box, Orientation};
|
||||
|
||||
pub struct Content {
|
||||
widget: Box,
|
||||
@ -12,6 +12,11 @@ impl Content {
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn reload(&self, request_text: GString) {
|
||||
// @TODO
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
|
@ -37,6 +37,10 @@ impl Page {
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn reload(&self) {
|
||||
self.content.reload(self.navigation.request_text());
|
||||
}
|
||||
|
||||
pub fn update(&self) {
|
||||
self.navigation.update();
|
||||
// @TODO self.content.update();
|
||||
|
@ -10,7 +10,7 @@ use history::History;
|
||||
use reload::Reload;
|
||||
use request::Request;
|
||||
|
||||
use gtk::{prelude::BoxExt, Box, Orientation};
|
||||
use gtk::{glib::GString, prelude::BoxExt, Box, Orientation};
|
||||
|
||||
pub struct Navigation {
|
||||
// GTK
|
||||
@ -72,4 +72,8 @@ impl Navigation {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
|
||||
pub fn request_text(&self) -> GString {
|
||||
self.request.text()
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
use gtk::{
|
||||
glib::GString,
|
||||
prelude::{EditableExt, EntryExt, WidgetExt},
|
||||
Entry,
|
||||
};
|
||||
@ -44,4 +45,8 @@ impl Request {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
0 == self.widget.text_length()
|
||||
}
|
||||
|
||||
pub fn text(&self) -> GString {
|
||||
self.widget.text()
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,14 @@ impl Browser {
|
||||
}
|
||||
})
|
||||
.build(),
|
||||
ActionEntry::builder("tab_page_reload")
|
||||
.activate({
|
||||
let main = main.clone();
|
||||
move |_, _, _| {
|
||||
main.tab_page_reload();
|
||||
}
|
||||
})
|
||||
.build(),
|
||||
ActionEntry::builder("tab_close")
|
||||
.activate({
|
||||
let main = main.clone();
|
||||
|
Loading…
x
Reference in New Issue
Block a user