From 301ebdbcd81c27f60b9eed70b4cf9685ec06426d Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 27 Jun 2018 18:18:11 +0300 Subject: [PATCH] Content: ::new() method now returns Rc. --- hammond-gtk/src/app.rs | 3 +-- hammond-gtk/src/stacks/content.rs | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index eff7553..a4b922a 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -85,8 +85,7 @@ impl App { })); // Create a content instance - let content = - Rc::new(Content::new(sender.clone()).expect("Content Initialization failed.")); + let content = Content::new(&sender).expect("Content Initialization failed."); // Create the headerbar let header = Rc::new(Header::new(&content, &window, &sender)); diff --git a/hammond-gtk/src/stacks/content.rs b/hammond-gtk/src/stacks/content.rs index e45c541..6ac8189 100644 --- a/hammond-gtk/src/stacks/content.rs +++ b/hammond-gtk/src/stacks/content.rs @@ -19,7 +19,7 @@ pub struct Content { } impl Content { - pub fn new(sender: Sender) -> Result { + pub fn new(sender: &Sender) -> Result, 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())?)); @@ -27,12 +27,13 @@ impl Content { stack.add_titled(&home.borrow().get_stack(), "home", "New"); stack.add_titled(&shows.borrow().get_stack(), "shows", "Shows"); - Ok(Content { + let con = Content { stack, shows, home, - sender, - }) + sender: sender.clone(), + }; + Ok(Rc::new(con)) } pub fn update(&self) {