ShowsView/Stack: Add some assertions.

This commit is contained in:
Jordan Petridis 2018-07-21 10:39:42 +03:00
parent b9bcc28e0f
commit fc934ce8e1
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
4 changed files with 17 additions and 19 deletions

View File

@ -22,7 +22,7 @@ impl Content {
pub fn new(sender: &Sender<Action>) -> Result<Rc<Content>, Error> {
let stack = gtk::Stack::new();
let home = Rc::new(RefCell::new(HomeStack::new(sender.clone())?));
let shows = Rc::new(RefCell::new(ShowStack::new(sender.clone())?));
let shows = Rc::new(RefCell::new(ShowStack::new(sender.clone())));
stack.add_titled(&home.borrow().get_stack(), "home", "New");
stack.add_titled(&shows.borrow().get_stack(), "shows", "Shows");

View File

@ -31,10 +31,10 @@ pub struct PopulatedStack {
}
impl PopulatedStack {
pub fn new(sender: Sender<Action>) -> Result<PopulatedStack, Error> {
pub fn new(sender: Sender<Action>) -> PopulatedStack {
let stack = gtk::Stack::new();
let state = PopulatedState::View;
let populated = ShowsView::new(sender.clone())?;
let populated = ShowsView::new(sender.clone());
let show = Rc::new(ShowWidget::default());
let container = gtk::Box::new(gtk::Orientation::Horizontal, 0);
@ -43,16 +43,14 @@ impl PopulatedStack {
container.add(&stack);
container.show_all();
let show = PopulatedStack {
PopulatedStack {
container,
stack,
populated,
show,
state,
sender,
};
Ok(show)
}
}
pub fn update(&mut self) {
@ -80,7 +78,7 @@ impl PopulatedStack {
.map_err(|err| error!("Failed to set episodes_view allignment: {}", err))
.ok();
let pop = ShowsView::new(self.sender.clone())?;
let pop = ShowsView::new(self.sender.clone());
self.populated = pop;
self.stack.remove(old);
self.stack.add_named(&self.populated.container, "shows");

View File

@ -29,8 +29,8 @@ pub struct ShowStack {
}
impl ShowStack {
pub fn new(sender: Sender<Action>) -> Result<Self, Error> {
let populated = Rc::new(RefCell::new(PopulatedStack::new(sender.clone())?));
pub fn new(sender: Sender<Action>) -> Self {
let populated = Rc::new(RefCell::new(PopulatedStack::new(sender.clone())));
let empty = EmptyView::new();
let stack = gtk::Stack::new();
let state = ShowState::Empty;
@ -46,8 +46,9 @@ impl ShowStack {
sender,
};
show.determine_state()?;
Ok(show)
let res = show.determine_state();
debug_assert!(res.is_ok());
show
}
pub fn get_stack(&self) -> gtk::Stack {

View File

@ -43,24 +43,23 @@ impl Default for ShowsView {
}
impl ShowsView {
pub fn new(sender: Sender<Action>) -> Result<Rc<Self>, Error> {
pub fn new(sender: Sender<Action>) -> Rc<Self> {
let pop = Rc::new(ShowsView::default());
pop.init(sender);
// Populate the flowbox with the Shows.
populate_flowbox(&pop)?;
Ok(pop)
let res = populate_flowbox(&pop);
debug_assert!(res.is_ok());
pop
}
pub fn init(&self, sender: Sender<Action>) {
self.flowbox.connect_child_activated(move |_, child| {
on_child_activate(child, &sender)
.map_err(|err| error!("Error along flowbox child activation: {}", err))
.ok();
let res = on_child_activate(child, &sender);
debug_assert!(res.is_ok());
});
}
/// Set scrolled window vertical adjustment.
#[allow(unused)]
fn set_vadjustment(&self) -> Result<(), Error> {
let guard = SHOWS_VIEW_VALIGNMENT
.lock()