HomeView: make base view field publick

There is no point to re-export BaseView's methods.
This commit is contained in:
Jordan Petridis 2018-08-09 09:47:54 +03:00
parent 17d36370b7
commit e1aba32b9a
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 7 additions and 14 deletions

View File

@ -34,7 +34,7 @@ impl HomeStack {
let stack = gtk::Stack::new(); let stack = gtk::Stack::new();
let state = State::Empty; let state = State::Empty;
stack.add_named(episodes.container(), "home"); stack.add_named(episodes.view.container(), "home");
stack.add_named(&empty.container, "empty"); stack.add_named(&empty.container, "empty");
let mut home = HomeStack { let mut home = HomeStack {
@ -67,14 +67,14 @@ impl HomeStack {
fn replace_view(&mut self) -> Result<(), Error> { fn replace_view(&mut self) -> Result<(), Error> {
// Get the container of the view // Get the container of the view
let old = &self.episodes.container().clone(); let old = &self.episodes.view.container().clone();
let eps = HomeView::new(self.sender.clone())?; let eps = HomeView::new(self.sender.clone())?;
// Remove the old widget and add the new one // Remove the old widget and add the new one
// during this the previous view is removed, // during this the previous view is removed,
// and the visibile child fallsback to empty view. // and the visibile child fallsback to empty view.
self.stack.remove(old); self.stack.remove(old);
self.stack.add_named(eps.container(), "home"); self.stack.add_named(eps.view.container(), "home");
// Keep the previous state. // Keep the previous state.
let s = self.state; let s = self.state;
// Set the visible child back to the previous one to avoid // Set the visible child back to the previous one to avoid

View File

@ -34,7 +34,7 @@ enum ListSplit {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct HomeView { pub(crate) struct HomeView {
view: BaseView, pub(crate) view: BaseView,
frame_parent: gtk::Box, frame_parent: gtk::Box,
today_box: gtk::Box, today_box: gtk::Box,
yday_box: gtk::Box, yday_box: gtk::Box,
@ -125,18 +125,10 @@ impl HomeView {
}; };
lazy_load_full(episodes, func, callback); lazy_load_full(episodes, func, callback);
view.container().show_all(); view.view.container().show_all();
Ok(view) Ok(view)
} }
pub(crate) fn container(&self) -> &gtk::Box {
self.view.container()
}
pub(crate) fn scrolled_window(&self) -> &gtk::ScrolledWindow {
self.view.scrolled_window()
}
/// Set scrolled window vertical adjustment. /// Set scrolled window vertical adjustment.
fn set_vadjustment(&self) -> Result<(), Error> { fn set_vadjustment(&self) -> Result<(), Error> {
let guard = EPISODES_VIEW_VALIGNMENT let guard = EPISODES_VIEW_VALIGNMENT
@ -147,7 +139,7 @@ impl HomeView {
// Copy the vertical scrollbar adjustment from the old view into the new one. // Copy the vertical scrollbar adjustment from the old view into the new one.
let res = fragile let res = fragile
.try_get() .try_get()
.map(|x| utils::smooth_scroll_to(self.scrolled_window(), &x)) .map(|x| utils::smooth_scroll_to(self.view.scrolled_window(), &x))
.map_err(From::from); .map_err(From::from);
debug_assert!(res.is_ok()); debug_assert!(res.is_ok());
@ -161,6 +153,7 @@ impl HomeView {
pub(crate) fn save_alignment(&self) -> Result<(), Error> { pub(crate) fn save_alignment(&self) -> Result<(), Error> {
if let Ok(mut guard) = EPISODES_VIEW_VALIGNMENT.lock() { if let Ok(mut guard) = EPISODES_VIEW_VALIGNMENT.lock() {
let adj = self let adj = self
.view
.scrolled_window() .scrolled_window()
.get_vadjustment() .get_vadjustment()
.ok_or_else(|| format_err!("Could not get the adjustment"))?; .ok_or_else(|| format_err!("Could not get the adjustment"))?;