ShowsView/Stack: Add some assertions.
This commit is contained in:
parent
b9bcc28e0f
commit
fc934ce8e1
@ -22,7 +22,7 @@ impl Content {
|
|||||||
pub fn new(sender: &Sender<Action>) -> Result<Rc<Content>, Error> {
|
pub fn new(sender: &Sender<Action>) -> Result<Rc<Content>, Error> {
|
||||||
let stack = gtk::Stack::new();
|
let stack = gtk::Stack::new();
|
||||||
let home = Rc::new(RefCell::new(HomeStack::new(sender.clone())?));
|
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(&home.borrow().get_stack(), "home", "New");
|
||||||
stack.add_titled(&shows.borrow().get_stack(), "shows", "Shows");
|
stack.add_titled(&shows.borrow().get_stack(), "shows", "Shows");
|
||||||
|
|||||||
@ -31,10 +31,10 @@ pub struct PopulatedStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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 stack = gtk::Stack::new();
|
||||||
let state = PopulatedState::View;
|
let state = PopulatedState::View;
|
||||||
let populated = ShowsView::new(sender.clone())?;
|
let populated = ShowsView::new(sender.clone());
|
||||||
let show = Rc::new(ShowWidget::default());
|
let show = Rc::new(ShowWidget::default());
|
||||||
let container = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
let container = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
||||||
|
|
||||||
@ -43,16 +43,14 @@ impl PopulatedStack {
|
|||||||
container.add(&stack);
|
container.add(&stack);
|
||||||
container.show_all();
|
container.show_all();
|
||||||
|
|
||||||
let show = PopulatedStack {
|
PopulatedStack {
|
||||||
container,
|
container,
|
||||||
stack,
|
stack,
|
||||||
populated,
|
populated,
|
||||||
show,
|
show,
|
||||||
state,
|
state,
|
||||||
sender,
|
sender,
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(show)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self) {
|
pub fn update(&mut self) {
|
||||||
@ -80,7 +78,7 @@ impl PopulatedStack {
|
|||||||
.map_err(|err| error!("Failed to set episodes_view allignment: {}", err))
|
.map_err(|err| error!("Failed to set episodes_view allignment: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let pop = ShowsView::new(self.sender.clone())?;
|
let pop = ShowsView::new(self.sender.clone());
|
||||||
self.populated = pop;
|
self.populated = pop;
|
||||||
self.stack.remove(old);
|
self.stack.remove(old);
|
||||||
self.stack.add_named(&self.populated.container, "shows");
|
self.stack.add_named(&self.populated.container, "shows");
|
||||||
|
|||||||
@ -29,8 +29,8 @@ pub struct ShowStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ShowStack {
|
impl ShowStack {
|
||||||
pub fn new(sender: Sender<Action>) -> Result<Self, Error> {
|
pub fn new(sender: Sender<Action>) -> Self {
|
||||||
let populated = Rc::new(RefCell::new(PopulatedStack::new(sender.clone())?));
|
let populated = Rc::new(RefCell::new(PopulatedStack::new(sender.clone())));
|
||||||
let empty = EmptyView::new();
|
let empty = EmptyView::new();
|
||||||
let stack = gtk::Stack::new();
|
let stack = gtk::Stack::new();
|
||||||
let state = ShowState::Empty;
|
let state = ShowState::Empty;
|
||||||
@ -46,8 +46,9 @@ impl ShowStack {
|
|||||||
sender,
|
sender,
|
||||||
};
|
};
|
||||||
|
|
||||||
show.determine_state()?;
|
let res = show.determine_state();
|
||||||
Ok(show)
|
debug_assert!(res.is_ok());
|
||||||
|
show
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_stack(&self) -> gtk::Stack {
|
pub fn get_stack(&self) -> gtk::Stack {
|
||||||
|
|||||||
@ -43,24 +43,23 @@ impl Default for ShowsView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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());
|
let pop = Rc::new(ShowsView::default());
|
||||||
pop.init(sender);
|
pop.init(sender);
|
||||||
// Populate the flowbox with the Shows.
|
// Populate the flowbox with the Shows.
|
||||||
populate_flowbox(&pop)?;
|
let res = populate_flowbox(&pop);
|
||||||
Ok(pop)
|
debug_assert!(res.is_ok());
|
||||||
|
pop
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self, sender: Sender<Action>) {
|
pub fn init(&self, sender: Sender<Action>) {
|
||||||
self.flowbox.connect_child_activated(move |_, child| {
|
self.flowbox.connect_child_activated(move |_, child| {
|
||||||
on_child_activate(child, &sender)
|
let res = on_child_activate(child, &sender);
|
||||||
.map_err(|err| error!("Error along flowbox child activation: {}", err))
|
debug_assert!(res.is_ok());
|
||||||
.ok();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set scrolled window vertical adjustment.
|
/// Set scrolled window vertical adjustment.
|
||||||
#[allow(unused)]
|
|
||||||
fn set_vadjustment(&self) -> Result<(), Error> {
|
fn set_vadjustment(&self) -> Result<(), Error> {
|
||||||
let guard = SHOWS_VIEW_VALIGNMENT
|
let guard = SHOWS_VIEW_VALIGNMENT
|
||||||
.lock()
|
.lock()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user