From a7e3b1b99e9b0ecaa6c4f17d2b7a44281f167c79 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 26 Jan 2018 19:05:19 +0200 Subject: [PATCH] GtkApplication: Headbar and Content constructors now return Self instead of Arc. --- hammond-gtk/src/app.rs | 4 ++-- hammond-gtk/src/content.rs | 6 +++--- hammond-gtk/src/headerbar.rs | 6 ++---- hammond-gtk/src/widgets/episode.rs | 1 - 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index 4f4e341..5bd083c 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -66,10 +66,10 @@ impl App { let (sender, receiver) = channel(); // Create a content instance - let content = Content::new(sender.clone()); + let content = Arc::new(Content::new(sender.clone())); // Create the headerbar - let header = Header::new(content.clone(), sender.clone()); + let header = Arc::new(Header::new(content.clone(), sender.clone())); // Add the Headerbar to the window. window.set_titlebar(&header.container); diff --git a/hammond-gtk/src/content.rs b/hammond-gtk/src/content.rs index a83a4b1..400659b 100644 --- a/hammond-gtk/src/content.rs +++ b/hammond-gtk/src/content.rs @@ -24,7 +24,7 @@ pub struct Content { } impl Content { - pub fn new(sender: Sender) -> Arc { + pub fn new(sender: Sender) -> Content { let stack = gtk::Stack::new(); let episodes = Arc::new(EpisodeStack::new(sender.clone())); let shows = Arc::new(ShowStack::new(sender.clone())); @@ -32,12 +32,12 @@ impl Content { stack.add_titled(&episodes.stack, "episodes", "Episodes"); stack.add_titled(&shows.stack, "shows", "Shows"); - Arc::new(Content { + Content { stack, shows, episodes, sender, - }) + } } pub fn update(&self) { diff --git a/hammond-gtk/src/headerbar.rs b/hammond-gtk/src/headerbar.rs index db6a27c..3f36f80 100644 --- a/hammond-gtk/src/headerbar.rs +++ b/hammond-gtk/src/headerbar.rs @@ -51,12 +51,10 @@ impl Default for Header { } impl Header { - #[allow(dead_code)] - // FIXME: should not return arc and stuff - pub fn new(content: Arc, sender: Sender) -> Arc
{ + pub fn new(content: Arc, sender: Sender) -> Header { let h = Header::default(); h.init(content, sender); - Arc::new(h) + h } pub fn init(&self, content: Arc, sender: Sender) { diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index d4da92e..7042216 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -104,7 +104,6 @@ impl EpisodeWidget { widget } - // TODO: wire the cancel button. fn init(&self, episode: &mut EpisodeWidgetQuery, sender: Sender) { WidgetExt::set_name(&self.container, &episode.rowid().to_string());