Content: ::new() method now returns Rc<Self>.

This commit is contained in:
Jordan Petridis 2018-06-27 18:18:11 +03:00
parent 49bcf46b4f
commit 301ebdbcd8
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 6 additions and 6 deletions

View File

@ -85,8 +85,7 @@ impl App {
})); }));
// Create a content instance // Create a content instance
let content = let content = Content::new(&sender).expect("Content Initialization failed.");
Rc::new(Content::new(sender.clone()).expect("Content Initialization failed."));
// Create the headerbar // Create the headerbar
let header = Rc::new(Header::new(&content, &window, &sender)); let header = Rc::new(Header::new(&content, &window, &sender));

View File

@ -19,7 +19,7 @@ pub struct Content {
} }
impl Content { impl Content {
pub fn new(sender: Sender<Action>) -> Result<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())?));
@ -27,12 +27,13 @@ impl Content {
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");
Ok(Content { let con = Content {
stack, stack,
shows, shows,
home, home,
sender, sender: sender.clone(),
}) };
Ok(Rc::new(con))
} }
pub fn update(&self) { pub fn update(&self) {