diff --git a/src/browser/main/mod.rs b/src/browser/main/mod.rs index f6f6fcf0..af33aced 100644 --- a/src/browser/main/mod.rs +++ b/src/browser/main/mod.rs @@ -1,34 +1,31 @@ mod tab; - -use std::sync::Arc; - -use gtk::prelude::BoxExt; -use gtk::Box; +mod widget; pub struct Main { - pub widget: Arc, - pub tab: Arc, + widget: widget::Main, + tab: tab::Tab, } impl Main { + // Construct + pub fn new() -> Main { + // Init components + let tab = tab::new(); + + // Init struct + Self { + widget: widget::Main::new(tab.widget.as_ref()), // @TODO + tab, + } + } + + // Actions pub fn tab_append(&self) { self.tab.append(true); } -} -pub fn new() -> Main { - // Init components - let tab = Arc::new(tab::new()); - - // Init widget - let widget = Arc::new( - Box::builder() - .orientation(gtk::Orientation::Vertical) - .build(), - ); - - widget.append(tab.widget.as_ref()); - - // Init struct - Main { widget, tab } + // Getters + pub fn widget(&self) -> &widget::Main { + &self.widget + } } diff --git a/src/browser/main/widget.rs b/src/browser/main/widget.rs new file mode 100644 index 00000000..cb87ff4d --- /dev/null +++ b/src/browser/main/widget.rs @@ -0,0 +1,23 @@ +use gtk::prelude::BoxExt; + +pub struct Main { + gtk: gtk::Box, +} + +impl Main { + // Construct + pub fn new(tab: >k::Notebook) -> Main { + let gtk = gtk::Box::builder() + .orientation(gtk::Orientation::Vertical) + .build(); + + gtk.append(tab); + + Self { gtk } + } + + // Getters + pub fn gtk(&self) -> >k::Box { + &self.gtk + } +} diff --git a/src/browser/mod.rs b/src/browser/mod.rs index 46648836..cfd32f46 100644 --- a/src/browser/mod.rs +++ b/src/browser/mod.rs @@ -23,7 +23,7 @@ impl Browser { let widget = widget::Browser::new( app, header::Header::new().widget().gtk(), - main::new().widget.as_ref(), // @TODO + main::Main::new().widget().gtk(), default_width, default_height, );