mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-11 02:44:15 +00:00
init update action
This commit is contained in:
parent
68a97fdc88
commit
ae3cc7a7d5
@ -1,17 +1,19 @@
|
|||||||
mod subject;
|
mod subject;
|
||||||
mod tray;
|
mod tray;
|
||||||
|
|
||||||
use gtk::HeaderBar;
|
|
||||||
use subject::Subject;
|
use subject::Subject;
|
||||||
use tray::Tray;
|
use tray::Tray;
|
||||||
|
|
||||||
|
use gtk::HeaderBar;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
widget: HeaderBar,
|
widget: HeaderBar,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Header {
|
impl Header {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Header {
|
pub fn new() -> Arc<Header> {
|
||||||
let tray = Tray::new();
|
let tray = Tray::new();
|
||||||
let subject = Subject::new();
|
let subject = Subject::new();
|
||||||
|
|
||||||
@ -19,7 +21,7 @@ impl Header {
|
|||||||
widget.pack_start(tray.widget());
|
widget.pack_start(tray.widget());
|
||||||
widget.set_title_widget(Some(subject.widget()));
|
widget.set_title_widget(Some(subject.widget()));
|
||||||
|
|
||||||
Self { widget }
|
Arc::new(Self { widget })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -12,7 +12,7 @@ pub struct Main {
|
|||||||
|
|
||||||
impl Main {
|
impl Main {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Main {
|
pub fn new() -> Arc<Main> {
|
||||||
// Init components
|
// Init components
|
||||||
let tab = Tab::new();
|
let tab = Tab::new();
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ impl Main {
|
|||||||
widget.append(tab.widget());
|
widget.append(tab.widget());
|
||||||
|
|
||||||
// Init struct
|
// Init struct
|
||||||
Self { tab, widget }
|
Arc::new(Self { tab, widget })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
@ -42,6 +42,10 @@ impl Main {
|
|||||||
self.tab.pin();
|
self.tab.pin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update(&self) {
|
||||||
|
self.tab.update();
|
||||||
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &Box {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
|
@ -40,6 +40,11 @@ impl Label {
|
|||||||
Self { pin, title, widget }
|
Self { pin, title, widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
pub fn update(&self) {
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
pub fn pin(&self, is_pinned: bool) {
|
pub fn pin(&self, is_pinned: bool) {
|
||||||
self.pin.widget().set_visible(is_pinned);
|
self.pin.widget().set_visible(is_pinned);
|
||||||
|
@ -120,6 +120,27 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update(&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 widget ID
|
||||||
|
let id = &widget.widget_name();
|
||||||
|
|
||||||
|
// Get label by widget ID
|
||||||
|
if let Some(label) = self.labels.borrow().get(id) {
|
||||||
|
label.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get page by widget ID
|
||||||
|
if let Some(page) = self.pages.borrow().get(id) {
|
||||||
|
page.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &Notebook {
|
pub fn widget(&self) -> &Notebook {
|
||||||
self.widget.as_ref()
|
self.widget.as_ref()
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
mod content;
|
mod content;
|
||||||
mod navigation;
|
mod navigation;
|
||||||
|
|
||||||
|
use content::Content;
|
||||||
|
use navigation::Navigation;
|
||||||
|
|
||||||
use gtk::{glib::GString, prelude::BoxExt, Box, Orientation};
|
use gtk::{glib::GString, prelude::BoxExt, Box, Orientation};
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
widget: Box,
|
widget: Box,
|
||||||
|
navigation: Navigation,
|
||||||
|
content: Content,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
|
// Construct
|
||||||
pub fn new(name: GString) -> Page {
|
pub fn new(name: GString) -> Page {
|
||||||
// Init components
|
// Init components
|
||||||
let navigation = navigation::Navigation::new();
|
let content = Content::new();
|
||||||
let content = content::Content::new();
|
let navigation = Navigation::new();
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Box::builder()
|
let widget = Box::builder()
|
||||||
@ -23,7 +29,17 @@ impl Page {
|
|||||||
widget.append(content.widget());
|
widget.append(content.widget());
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Self { widget }
|
Self {
|
||||||
|
widget,
|
||||||
|
content,
|
||||||
|
navigation,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
pub fn update(&self) {
|
||||||
|
self.navigation.update();
|
||||||
|
// @TODO self.content.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -19,7 +19,7 @@ impl Base {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
todo!()
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -19,7 +19,7 @@ impl Bookmark {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
todo!()
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -19,7 +19,7 @@ impl Back {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
todo!()
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -18,7 +18,7 @@ impl Forward {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
todo!()
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -48,6 +48,9 @@ impl Navigation {
|
|||||||
widget.append(request.widget());
|
widget.append(request.widget());
|
||||||
widget.append(bookmark.widget());
|
widget.append(bookmark.widget());
|
||||||
|
|
||||||
|
// Connect events
|
||||||
|
// request.widget().connect_changed({ |_, _, _| {} });
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Self {
|
Self {
|
||||||
widget,
|
widget,
|
||||||
|
@ -19,7 +19,7 @@ impl Reload {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
todo!()
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -18,7 +18,7 @@ impl Request {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
todo!()
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -2,9 +2,14 @@ mod db;
|
|||||||
mod header;
|
mod header;
|
||||||
mod main;
|
mod main;
|
||||||
|
|
||||||
use gtk::gio::ActionEntry;
|
use header::Header;
|
||||||
use gtk::prelude::{ActionMapExtManual, GtkWindowExt};
|
use main::Main;
|
||||||
use gtk::{Application, ApplicationWindow};
|
|
||||||
|
use gtk::{
|
||||||
|
gio::ActionEntry,
|
||||||
|
prelude::{ActionMapExtManual, GtkWindowExt},
|
||||||
|
Application, ApplicationWindow,
|
||||||
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Browser {
|
pub struct Browser {
|
||||||
@ -12,8 +17,8 @@ pub struct Browser {
|
|||||||
// db: db::Browser,
|
// db: db::Browser,
|
||||||
widget: ApplicationWindow,
|
widget: ApplicationWindow,
|
||||||
// Components
|
// Components
|
||||||
// header: Arc<header::Header>,
|
header: Arc<Header>,
|
||||||
// main: main::Main,
|
main: Arc<Main>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Browser {
|
impl Browser {
|
||||||
@ -38,9 +43,16 @@ impl Browser {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Init actions
|
// Init actions
|
||||||
let main_ref = Arc::new(main); // @TODO
|
|
||||||
|
|
||||||
widget.add_action_entries([
|
widget.add_action_entries([
|
||||||
|
ActionEntry::builder("update")
|
||||||
|
.activate({
|
||||||
|
let main = main.clone();
|
||||||
|
move |this: &ApplicationWindow, _, _| {
|
||||||
|
// header.update(); @TODO
|
||||||
|
main.update();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
ActionEntry::builder("debug")
|
ActionEntry::builder("debug")
|
||||||
.activate(|this: &ApplicationWindow, _, _| {
|
.activate(|this: &ApplicationWindow, _, _| {
|
||||||
this.emit_enable_debugging(true);
|
this.emit_enable_debugging(true);
|
||||||
@ -53,7 +65,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_append")
|
ActionEntry::builder("tab_append")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main_ref.clone();
|
let main = main.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_append();
|
main.tab_append();
|
||||||
}
|
}
|
||||||
@ -61,7 +73,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_close")
|
ActionEntry::builder("tab_close")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main_ref.clone();
|
let main = main.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_close();
|
main.tab_close();
|
||||||
}
|
}
|
||||||
@ -69,7 +81,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_close_all")
|
ActionEntry::builder("tab_close_all")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main_ref.clone();
|
let main = main.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_close_all();
|
main.tab_close_all();
|
||||||
}
|
}
|
||||||
@ -77,7 +89,7 @@ impl Browser {
|
|||||||
.build(),
|
.build(),
|
||||||
ActionEntry::builder("tab_pin")
|
ActionEntry::builder("tab_pin")
|
||||||
.activate({
|
.activate({
|
||||||
let main = main_ref.clone();
|
let main = main.clone();
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
main.tab_pin();
|
main.tab_pin();
|
||||||
}
|
}
|
||||||
@ -89,8 +101,8 @@ impl Browser {
|
|||||||
Self {
|
Self {
|
||||||
// db,
|
// db,
|
||||||
widget,
|
widget,
|
||||||
// header,
|
header,
|
||||||
// main,
|
main,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ fn main() -> glib::ExitCode {
|
|||||||
app.set_accels_for_action("win.tab_page_reload", &["<Primary>r"]);
|
app.set_accels_for_action("win.tab_page_reload", &["<Primary>r"]);
|
||||||
app.set_accels_for_action("win.tab_page_bookmark", &["<Primary>b"]);
|
app.set_accels_for_action("win.tab_page_bookmark", &["<Primary>b"]);
|
||||||
app.set_accels_for_action("win.debug", &["<Primary>i"]);
|
app.set_accels_for_action("win.debug", &["<Primary>i"]);
|
||||||
|
app.set_accels_for_action("win.update", &["<Primary>u"]);
|
||||||
app.set_accels_for_action("win.quit", &["<Primary>Escape"]);
|
app.set_accels_for_action("win.quit", &["<Primary>Escape"]);
|
||||||
|
|
||||||
// Create new window
|
// Create new window
|
||||||
|
Loading…
x
Reference in New Issue
Block a user