Move and rename stuff.

This commit is contained in:
Jordan Petridis 2017-12-13 11:35:17 +02:00
parent d5d55d4ef3
commit 5defb5867a
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
7 changed files with 30 additions and 29 deletions

View File

@ -4,9 +4,10 @@ use gtk::prelude::*;
use hammond_data::Podcast;
use hammond_data::dbqueries;
use views::podcasts::PopulatedView;
use views::shows::ShowsPopulated;
use views::empty::EmptyView;
use widgets::podcast::PodcastWidget;
use widgets::show::ShowWidget;
use std::rc::Rc;
@ -50,8 +51,8 @@ impl ShowStack {
let show = Rc::new(ShowStack { stack });
let pop = PopulatedView::new_initialized(show.clone());
let widget = PodcastWidget::new();
let pop = ShowsPopulated::new_initialized(show.clone());
let widget = ShowWidget::new();
let empty = EmptyView::new();
show.stack.add_named(&pop.container, "podcasts");
@ -80,7 +81,7 @@ impl ShowStack {
let vis = self.stack.get_visible_child_name().unwrap();
let old = self.stack.get_child_by_name("podcasts").unwrap();
let pop = PopulatedView::new();
let pop = ShowsPopulated::new();
pop.init(Rc::new(self.clone()));
self.stack.remove(&old);
@ -99,7 +100,7 @@ impl ShowStack {
pub fn replace_widget(&self, pd: &Podcast) {
let old = self.stack.get_child_by_name("widget").unwrap();
let new = PodcastWidget::new_initialized(Rc::new(self.clone()), pd);
let new = ShowWidget::new_initialized(Rc::new(self.clone()), pd);
self.stack.remove(&old);
self.stack.add_named(&new.container, "widget");

View File

@ -0,0 +1 @@

View File

@ -1,2 +1,3 @@
pub mod podcasts;
pub mod shows;
pub mod episodes;
pub mod empty;

View File

@ -12,14 +12,14 @@ use content::ShowStack;
use std::rc::Rc;
#[derive(Debug, Clone)]
pub struct PopulatedView {
pub struct ShowsPopulated {
pub container: gtk::Box,
pub flowbox: gtk::FlowBox,
viewport: gtk::Viewport,
}
#[derive(Debug)]
struct PodcastChild {
struct ShowsChild {
container: gtk::Box,
title: gtk::Label,
cover: gtk::Image,
@ -28,14 +28,14 @@ struct PodcastChild {
child: gtk::FlowBoxChild,
}
impl PopulatedView {
pub fn new() -> PopulatedView {
impl ShowsPopulated {
pub fn new() -> ShowsPopulated {
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/podcasts_view.ui");
let container: gtk::Box = builder.get_object("fb_parent").unwrap();
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
let viewport: gtk::Viewport = builder.get_object("viewport").unwrap();
PopulatedView {
ShowsPopulated {
container,
flowbox,
viewport,
@ -43,8 +43,8 @@ impl PopulatedView {
}
#[allow(dead_code)]
pub fn new_initialized(show: Rc<ShowStack>) -> PopulatedView {
let pop = PopulatedView::new();
pub fn new_initialized(show: Rc<ShowStack>) -> ShowsPopulated {
let pop = ShowsPopulated::new();
pop.init(show);
pop
}
@ -75,7 +75,7 @@ impl PopulatedView {
if let Ok(pds) = podcasts {
pds.iter().for_each(|parent| {
let flowbox_child = PodcastChild::new_initialized(parent);
let flowbox_child = ShowsChild::new_initialized(parent);
self.flowbox.add(&flowbox_child.child);
});
self.flowbox.show_all();
@ -87,8 +87,8 @@ impl PopulatedView {
}
}
impl PodcastChild {
fn new() -> PodcastChild {
impl ShowsChild {
fn new() -> ShowsChild {
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/podcasts_child.ui");
// Copy of gnome-music AlbumWidget
@ -101,7 +101,7 @@ impl PodcastChild {
let child = gtk::FlowBoxChild::new();
child.add(&container);
PodcastChild {
ShowsChild {
container,
title,
cover,
@ -123,8 +123,8 @@ impl PodcastChild {
self.configure_banner(pd);
}
pub fn new_initialized(pd: &Podcast) -> PodcastChild {
let child = PodcastChild::new();
pub fn new_initialized(pd: &Podcast) -> ShowsChild {
let child = ShowsChild::new();
child.init(pd);
child

View File

@ -13,8 +13,6 @@ use hammond_data::utils::*;
use hammond_data::errors::*;
use hammond_data::utils::replace_extra_spaces;
// use utils::html_to_markup;
use std::thread;
use std::cell::RefCell;
use std::sync::mpsc::{channel, Receiver};

View File

@ -1,2 +1,2 @@
pub mod podcast;
pub mod show;
pub mod episode;

View File

@ -14,7 +14,7 @@ use content::ShowStack;
use std::rc::Rc;
#[derive(Debug, Clone)]
pub struct PodcastWidget {
pub struct ShowWidget {
pub container: gtk::Box,
cover: gtk::Image,
title: gtk::Label,
@ -24,8 +24,8 @@ pub struct PodcastWidget {
played: gtk::Button,
}
impl PodcastWidget {
pub fn new() -> PodcastWidget {
impl ShowWidget {
pub fn new() -> ShowWidget {
// Adapted from gnome-music AlbumWidget
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/podcast_widget.ui");
let container: gtk::Box = builder.get_object("podcast_widget").unwrap();
@ -37,7 +37,7 @@ impl PodcastWidget {
let unsub: gtk::Button = builder.get_object("unsub_button").unwrap();
let played: gtk::Button = builder.get_object("mark_all_played_button").unwrap();
PodcastWidget {
ShowWidget {
container,
cover,
title,
@ -48,8 +48,8 @@ impl PodcastWidget {
}
}
pub fn new_initialized(shows: Rc<ShowStack>, pd: &Podcast) -> PodcastWidget {
let pdw = PodcastWidget::new();
pub fn new_initialized(shows: Rc<ShowStack>, pd: &Podcast) -> ShowWidget {
let pdw = ShowWidget::new();
pdw.init(shows, pd);
pdw
}