mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
follow new construction protocol
This commit is contained in:
parent
c03bef9f15
commit
1db706aa5b
@ -5,7 +5,6 @@ use subject::Subject;
|
|||||||
use tray::Tray;
|
use tray::Tray;
|
||||||
|
|
||||||
use gtk::{glib::GString, HeaderBar};
|
use gtk::{glib::GString, HeaderBar};
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
widget: HeaderBar,
|
widget: HeaderBar,
|
||||||
@ -14,7 +13,7 @@ pub struct Header {
|
|||||||
|
|
||||||
impl Header {
|
impl Header {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Header> {
|
pub fn new() -> Header {
|
||||||
let tray = Tray::new();
|
let tray = Tray::new();
|
||||||
let subject = Subject::new();
|
let subject = Subject::new();
|
||||||
|
|
||||||
@ -22,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()));
|
||||||
|
|
||||||
Arc::new(Self { widget, subject })
|
Self { widget, subject }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
@ -3,16 +3,15 @@ mod tab;
|
|||||||
use tab::Tab;
|
use tab::Tab;
|
||||||
|
|
||||||
use gtk::{glib::GString, prelude::BoxExt, Box, Orientation};
|
use gtk::{glib::GString, prelude::BoxExt, Box, Orientation};
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct Main {
|
pub struct Main {
|
||||||
tab: Arc<Tab>,
|
tab: Tab,
|
||||||
widget: Box,
|
widget: Box,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Main {
|
impl Main {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Main> {
|
pub fn new() -> Main {
|
||||||
// Init components
|
// Init components
|
||||||
let tab = Tab::new();
|
let tab = Tab::new();
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ impl Main {
|
|||||||
widget.append(tab.widget());
|
widget.append(tab.widget());
|
||||||
|
|
||||||
// Init struct
|
// Init struct
|
||||||
Arc::new(Self { tab, widget })
|
Self { tab, widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
@ -10,8 +10,6 @@ use gtk::{
|
|||||||
Align, Box, Orientation,
|
Align, Box, Orientation,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct Label {
|
pub struct Label {
|
||||||
// Components
|
// Components
|
||||||
pin: Pin,
|
pin: Pin,
|
||||||
@ -23,7 +21,7 @@ pub struct Label {
|
|||||||
|
|
||||||
impl Label {
|
impl Label {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(name: GString, is_pinned: bool) -> Arc<Label> {
|
pub fn new(name: GString, is_pinned: bool) -> Label {
|
||||||
// Components
|
// Components
|
||||||
let pin = Pin::new(is_pinned);
|
let pin = Pin::new(is_pinned);
|
||||||
let title = Title::new();
|
let title = Title::new();
|
||||||
@ -39,7 +37,7 @@ impl Label {
|
|||||||
widget.append(title.widget());
|
widget.append(title.widget());
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Arc::new(Self { pin, title, widget })
|
Self { pin, title, widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
@ -22,20 +22,21 @@ pub struct Tab {
|
|||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Tab> {
|
pub fn new() -> Tab {
|
||||||
// Init GTK component
|
// Init GTK component
|
||||||
let notebook = Arc::new(Notebook::builder().scrollable(true).build());
|
let notebook = Arc::new(Notebook::builder().scrollable(true).build());
|
||||||
|
|
||||||
// Init new Tab struct
|
// Init new Tab struct
|
||||||
let tab = Arc::new(Self {
|
let tab = Self {
|
||||||
// Reference wanted for async events, create new smart pointer
|
// Reference wanted for async events, create new smart pointer
|
||||||
widget: notebook.clone(),
|
widget: notebook.clone(),
|
||||||
// Init empty HashMap index as no tabs appended yet
|
// Init empty HashMap index as no tabs appended yet
|
||||||
labels: RefCell::new(HashMap::new()),
|
labels: RefCell::new(HashMap::new()),
|
||||||
pages: RefCell::new(HashMap::new()),
|
pages: RefCell::new(HashMap::new()),
|
||||||
});
|
};
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
|
/* @TODO move outside
|
||||||
notebook.connect_page_removed({
|
notebook.connect_page_removed({
|
||||||
// Make new local ref
|
// Make new local ref
|
||||||
let tab = tab.clone();
|
let tab = tab.clone();
|
||||||
@ -46,7 +47,7 @@ impl Tab {
|
|||||||
tab.labels.borrow_mut().remove(id);
|
tab.labels.borrow_mut().remove(id);
|
||||||
tab.pages.borrow_mut().remove(id);
|
tab.pages.borrow_mut().remove(id);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
|
|
||||||
tab // return Arc pointer to the new Tab constructed
|
tab // return Arc pointer to the new Tab constructed
|
||||||
}
|
}
|
||||||
@ -57,8 +58,8 @@ impl Tab {
|
|||||||
let id = uuid_string_random();
|
let id = uuid_string_random();
|
||||||
|
|
||||||
// Init new tab components
|
// Init new tab components
|
||||||
let label = Label::new(id.clone(), false);
|
let label = Arc::new(Label::new(id.clone(), false));
|
||||||
let page = Page::new(id.clone());
|
let page = Arc::new(Page::new(id.clone()));
|
||||||
|
|
||||||
// Register dynamically created tab components in the HashMap index
|
// Register dynamically created tab components in the HashMap index
|
||||||
self.labels.borrow_mut().insert(id.clone(), label.clone());
|
self.labels.borrow_mut().insert(id.clone(), label.clone());
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gtk::{Box, Orientation};
|
use gtk::{Box, Orientation};
|
||||||
|
|
||||||
pub struct Content {
|
pub struct Content {
|
||||||
@ -8,10 +6,10 @@ pub struct Content {
|
|||||||
|
|
||||||
impl Content {
|
impl Content {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new() -> Arc<Content> {
|
pub fn new() -> Content {
|
||||||
Arc::new(Self {
|
Self {
|
||||||
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
widget: Box::builder().orientation(Orientation::Vertical).build(),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
@ -21,7 +21,7 @@ pub struct Page {
|
|||||||
// GTK
|
// GTK
|
||||||
widget: Box,
|
widget: Box,
|
||||||
// Components
|
// Components
|
||||||
navigation: Navigation,
|
navigation: Arc<Navigation>,
|
||||||
content: Arc<Content>,
|
content: Arc<Content>,
|
||||||
// Extras
|
// Extras
|
||||||
meta: Arc<RefCell<Meta>>,
|
meta: Arc<RefCell<Meta>>,
|
||||||
@ -29,10 +29,10 @@ pub struct Page {
|
|||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new(name: GString) -> Arc<Page> {
|
pub fn new(name: GString) -> Page {
|
||||||
// Init components
|
// Init components
|
||||||
let content = Content::new();
|
let content = Arc::new(Content::new());
|
||||||
let navigation = Navigation::new();
|
let navigation = Arc::new(Navigation::new());
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
let widget = Box::builder()
|
let widget = Box::builder()
|
||||||
@ -47,12 +47,12 @@ impl Page {
|
|||||||
let meta = Arc::new(RefCell::new(Meta::new()));
|
let meta = Arc::new(RefCell::new(Meta::new()));
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
Arc::new(Self {
|
Self {
|
||||||
widget,
|
widget,
|
||||||
content,
|
content,
|
||||||
navigation,
|
navigation,
|
||||||
meta,
|
meta,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
@ -31,8 +31,8 @@ impl Browser {
|
|||||||
) -> Browser {
|
) -> Browser {
|
||||||
// Init components
|
// Init components
|
||||||
// let db = db::Browser::new(connection);
|
// let db = db::Browser::new(connection);
|
||||||
let header = header::Header::new();
|
let header = Arc::new(header::Header::new());
|
||||||
let main = main::Main::new();
|
let main = Arc::new(main::Main::new());
|
||||||
|
|
||||||
let widget = ApplicationWindow::builder()
|
let widget = ApplicationWindow::builder()
|
||||||
.application(app)
|
.application(app)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user