From 91ac2c64458cda31b7d9c77a43ff23e0b066a01f Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 1 Dec 2017 06:40:32 +0200 Subject: [PATCH] Minor cleanups. --- hammond-gtk/src/app.rs | 38 ------------------------------- hammond-gtk/src/content.rs | 3 --- hammond-gtk/src/utils.rs | 8 ++----- hammond-gtk/src/views/podcasts.rs | 7 ++++++ 4 files changed, 9 insertions(+), 47 deletions(-) delete mode 100644 hammond-gtk/src/app.rs diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs deleted file mode 100644 index eab786a..0000000 --- a/hammond-gtk/src/app.rs +++ /dev/null @@ -1,38 +0,0 @@ -use gtk::prelude::*; -use gtk::{Window, WindowType}; - -use headerbar::Header; -use content::Content; - -#[derive(Debug)] -pub struct App<'a> { - window: Window, - header: Header, - content: Content<'a>, -} - -impl <'a>App<'a> { - pub fn new() -> App<'a> { - let window = Window::new(WindowType::Toplevel); - let content = Content::new(); - let header = Header::new(content.stack.clone()); - - window.set_default_size(1150, 650); - window.connect_delete_event(|w, _| { - w.destroy(); - Inhibit(false) - }); - - window.set_titlebar(&header.container); - window.add(&content.stack); - - window.show_all(); - window.activate(); - - App { - window, - header, - content, - } - } -} diff --git a/hammond-gtk/src/content.rs b/hammond-gtk/src/content.rs index 6a38fae..00677ba 100644 --- a/hammond-gtk/src/content.rs +++ b/hammond-gtk/src/content.rs @@ -53,9 +53,6 @@ impl Content { } fn setup_stack(&self) { - // self.stack - // .set_transition_type(gtk::StackTransitionType::SlideLeftRight); - self.stack.add_named(&self.widget.container, "widget"); self.stack.add_named(&self.podcasts.container, "podcasts"); self.stack.add_named(&self.empty.container, "empty"); diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs index 794765c..ca8db76 100644 --- a/hammond-gtk/src/utils.rs +++ b/hammond-gtk/src/utils.rs @@ -65,12 +65,8 @@ fn refresh_podcasts_view() -> glib::Continue { } pub fn get_pixbuf_from_path(pd: &Podcast) -> Option { - let img_path = downloader::cache_image(pd); - if let Some(i) = img_path { - Pixbuf::new_from_file_at_scale(&i, 256, 256, true).ok() - } else { - None - } + let img_path = downloader::cache_image(pd)?; + Pixbuf::new_from_file_at_scale(&img_path, 256, 256, true).ok() } #[cfg(test)] diff --git a/hammond-gtk/src/views/podcasts.rs b/hammond-gtk/src/views/podcasts.rs index 1b6cc8f..0d906a4 100644 --- a/hammond-gtk/src/views/podcasts.rs +++ b/hammond-gtk/src/views/podcasts.rs @@ -40,6 +40,13 @@ impl PopulatedView { } } + #[allow(dead_code)] + pub fn new_initialized(stack: >k::Stack) -> PopulatedView { + let pop = PopulatedView::new(); + pop.init(stack); + pop + } + pub fn init(&self, stack: >k::Stack) { use gtk::WidgetExt;