Minor cleanups.

This commit is contained in:
Jordan Petridis 2017-12-01 06:40:32 +02:00
parent 2d4acc3ba3
commit 91ac2c6445
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
4 changed files with 9 additions and 47 deletions

View File

@ -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,
}
}
}

View File

@ -53,9 +53,6 @@ impl Content {
} }
fn setup_stack(&self) { 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.widget.container, "widget");
self.stack.add_named(&self.podcasts.container, "podcasts"); self.stack.add_named(&self.podcasts.container, "podcasts");
self.stack.add_named(&self.empty.container, "empty"); self.stack.add_named(&self.empty.container, "empty");

View File

@ -65,12 +65,8 @@ fn refresh_podcasts_view() -> glib::Continue {
} }
pub fn get_pixbuf_from_path(pd: &Podcast) -> Option<Pixbuf> { pub fn get_pixbuf_from_path(pd: &Podcast) -> Option<Pixbuf> {
let img_path = downloader::cache_image(pd); let img_path = downloader::cache_image(pd)?;
if let Some(i) = img_path { Pixbuf::new_from_file_at_scale(&img_path, 256, 256, true).ok()
Pixbuf::new_from_file_at_scale(&i, 256, 256, true).ok()
} else {
None
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -40,6 +40,13 @@ impl PopulatedView {
} }
} }
#[allow(dead_code)]
pub fn new_initialized(stack: &gtk::Stack) -> PopulatedView {
let pop = PopulatedView::new();
pop.init(stack);
pop
}
pub fn init(&self, stack: &gtk::Stack) { pub fn init(&self, stack: &gtk::Stack) {
use gtk::WidgetExt; use gtk::WidgetExt;