ShowWidget: Update EpisodesView when unsub button is activated.
This commit is contained in:
parent
994ea5af22
commit
74a6e5814a
@ -23,8 +23,8 @@ pub struct Content {
|
|||||||
impl Content {
|
impl Content {
|
||||||
pub fn new(header: Rc<Header>) -> Rc<Content> {
|
pub fn new(header: Rc<Header>) -> Rc<Content> {
|
||||||
let stack = gtk::Stack::new();
|
let stack = gtk::Stack::new();
|
||||||
let shows = ShowStack::new(header);
|
|
||||||
let episodes = EpisodeStack::new();
|
let episodes = EpisodeStack::new();
|
||||||
|
let shows = ShowStack::new(header, episodes.clone());
|
||||||
|
|
||||||
stack.add_titled(&episodes.stack, "episodes", "Episodes");
|
stack.add_titled(&episodes.stack, "episodes", "Episodes");
|
||||||
stack.add_titled(&shows.stack, "shows", "Shows");
|
stack.add_titled(&shows.stack, "shows", "Shows");
|
||||||
@ -50,15 +50,17 @@ impl Content {
|
|||||||
pub struct ShowStack {
|
pub struct ShowStack {
|
||||||
pub stack: gtk::Stack,
|
pub stack: gtk::Stack,
|
||||||
header: Rc<Header>,
|
header: Rc<Header>,
|
||||||
|
epstack: Rc<EpisodeStack>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShowStack {
|
impl ShowStack {
|
||||||
fn new(header: Rc<Header>) -> Rc<ShowStack> {
|
fn new(header: Rc<Header>, epstack: Rc<EpisodeStack>) -> Rc<ShowStack> {
|
||||||
let stack = gtk::Stack::new();
|
let stack = gtk::Stack::new();
|
||||||
|
|
||||||
let show = Rc::new(ShowStack {
|
let show = Rc::new(ShowStack {
|
||||||
stack,
|
stack,
|
||||||
header: header.clone(),
|
header: header.clone(),
|
||||||
|
epstack,
|
||||||
});
|
});
|
||||||
|
|
||||||
let pop = ShowsPopulated::new(show.clone(), header);
|
let pop = ShowsPopulated::new(show.clone(), header);
|
||||||
@ -110,7 +112,12 @@ impl ShowStack {
|
|||||||
|
|
||||||
pub fn replace_widget(&self, pd: &Podcast) {
|
pub fn replace_widget(&self, pd: &Podcast) {
|
||||||
let old = self.stack.get_child_by_name("widget").unwrap();
|
let old = self.stack.get_child_by_name("widget").unwrap();
|
||||||
let new = ShowWidget::new(Rc::new(self.clone()), self.header.clone(), pd);
|
let new = ShowWidget::new(
|
||||||
|
Rc::new(self.clone()),
|
||||||
|
self.epstack.clone(),
|
||||||
|
self.header.clone(),
|
||||||
|
pd,
|
||||||
|
);
|
||||||
|
|
||||||
self.stack.remove(&old);
|
self.stack.remove(&old);
|
||||||
self.stack.add_named(&new.container, "widget");
|
self.stack.add_named(&new.container, "widget");
|
||||||
@ -145,10 +152,7 @@ impl ShowStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct RecentEpisodes;
|
pub struct EpisodeStack {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct EpisodeStack {
|
|
||||||
// populated: RecentEpisodes,
|
// populated: RecentEpisodes,
|
||||||
// empty: EmptyView,
|
// empty: EmptyView,
|
||||||
stack: gtk::Stack,
|
stack: gtk::Stack,
|
||||||
@ -172,7 +176,7 @@ impl EpisodeStack {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&self) {
|
pub fn update(&self) {
|
||||||
let old = self.stack.get_child_by_name("episodes").unwrap();
|
let old = self.stack.get_child_by_name("episodes").unwrap();
|
||||||
let eps = EpisodesView::new();
|
let eps = EpisodesView::new();
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use hammond_downloader::downloader;
|
|||||||
|
|
||||||
use widgets::episode::episodes_listbox;
|
use widgets::episode::episodes_listbox;
|
||||||
use utils::get_pixbuf_from_path;
|
use utils::get_pixbuf_from_path;
|
||||||
use content::ShowStack;
|
use content::{EpisodeStack, ShowStack};
|
||||||
use headerbar::Header;
|
use headerbar::Header;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -53,18 +53,30 @@ impl Default for ShowWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ShowWidget {
|
impl ShowWidget {
|
||||||
pub fn new(shows: Rc<ShowStack>, header: Rc<Header>, pd: &Podcast) -> ShowWidget {
|
pub fn new(
|
||||||
|
shows: Rc<ShowStack>,
|
||||||
|
epstack: Rc<EpisodeStack>,
|
||||||
|
header: Rc<Header>,
|
||||||
|
pd: &Podcast,
|
||||||
|
) -> ShowWidget {
|
||||||
let pdw = ShowWidget::default();
|
let pdw = ShowWidget::default();
|
||||||
pdw.init(shows, header, pd);
|
pdw.init(shows, epstack, header, pd);
|
||||||
pdw
|
pdw
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self, shows: Rc<ShowStack>, header: Rc<Header>, pd: &Podcast) {
|
pub fn init(
|
||||||
|
&self,
|
||||||
|
shows: Rc<ShowStack>,
|
||||||
|
epstack: Rc<EpisodeStack>,
|
||||||
|
header: Rc<Header>,
|
||||||
|
pd: &Podcast,
|
||||||
|
) {
|
||||||
WidgetExt::set_name(&self.container, &pd.id().to_string());
|
WidgetExt::set_name(&self.container, &pd.id().to_string());
|
||||||
|
|
||||||
// TODO: should spawn a thread to avoid locking the UI probably.
|
// TODO: should spawn a thread to avoid locking the UI probably.
|
||||||
self.unsub.connect_clicked(clone!(shows, pd => move |bttn| {
|
self.unsub
|
||||||
on_unsub_button_clicked(shows.clone(), &pd, bttn);
|
.connect_clicked(clone!(shows, epstack, pd => move |bttn| {
|
||||||
|
on_unsub_button_clicked(shows.clone(), epstack.clone(), &pd, bttn);
|
||||||
header.switch_to_normal();
|
header.switch_to_normal();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -94,7 +106,12 @@ impl ShowWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_unsub_button_clicked(shows: Rc<ShowStack>, pd: &Podcast, unsub_button: >k::Button) {
|
fn on_unsub_button_clicked(
|
||||||
|
shows: Rc<ShowStack>,
|
||||||
|
epstack: Rc<EpisodeStack>,
|
||||||
|
pd: &Podcast,
|
||||||
|
unsub_button: >k::Button,
|
||||||
|
) {
|
||||||
let res = dbqueries::remove_feed(pd);
|
let res = dbqueries::remove_feed(pd);
|
||||||
if res.is_ok() {
|
if res.is_ok() {
|
||||||
info!("{} was removed succesfully.", pd.title());
|
info!("{} was removed succesfully.", pd.title());
|
||||||
@ -112,6 +129,7 @@ fn on_unsub_button_clicked(shows: Rc<ShowStack>, pd: &Podcast, unsub_button: >
|
|||||||
}
|
}
|
||||||
shows.switch_podcasts_animated();
|
shows.switch_podcasts_animated();
|
||||||
shows.update_podcasts();
|
shows.update_podcasts();
|
||||||
|
epstack.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user