From 9c032a7f179ac2dedba05ec2c14e11671cb24e54 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 28 Oct 2017 09:08:18 +0300 Subject: [PATCH] On download completion also show the delete button for the episode widget. --- README.md | 4 ++-- hammond-gtk/src/widgets/episode.rs | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 855163c..bfac4ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Hammond -## Prototype of a multithreaded, safe, and reliable Gtk+ Podcast client. -Description... +## Multithreaded, safe, and reliable Gtk+ Podcast client. +This is a prototype of a podcast client written in Rust. ![podcasts_view](./assets/podcasts_view.png) ![podcast_widget](./assets/podcast_widget.png) diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index d816e55..b5eb350 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -39,9 +39,9 @@ macro_rules! clone { } thread_local!( - static GLOBAL: RefCell))>> = RefCell::new(None)); + static GLOBAL: RefCell, + ))>> = RefCell::new(None)); fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::Box { // This is just a prototype and will be reworked probably. @@ -96,15 +96,18 @@ fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk:: ); let pd_title = pd_title.to_owned(); - download_button.connect_clicked(clone!(db, play_button, episode => move |dl| { + download_button.connect_clicked( + clone!(db, play_button, delete_button, episode => move |dl| { on_download_clicked( &db, &pd_title, &mut episode.clone(), dl, &play_button, + &delete_button, ); - })); + }), + ); ep } @@ -116,13 +119,14 @@ fn on_download_clicked( ep: &mut Episode, download_bttn: >k::Button, play_bttn: >k::Button, + del_bttn: >k::Button, ) { // Create a async channel. let (sender, receiver) = channel(); // Pass the desired arguments into the Local Thread Storage. - GLOBAL.with(clone!(download_bttn, play_bttn => move |global| { - *global.borrow_mut() = Some((download_bttn, play_bttn, receiver)); + GLOBAL.with(clone!(download_bttn, play_bttn, del_bttn => move |global| { + *global.borrow_mut() = Some((download_bttn, play_bttn, del_bttn, receiver)); })); let pd_title = pd_title.to_owned(); @@ -177,10 +181,13 @@ fn on_delete_bttn_clicked(db: &Database, episode_id: i32) { fn receive() -> glib::Continue { GLOBAL.with(|global| { - if let Some((ref download_bttn, ref play_bttn, ref reciever)) = *global.borrow() { + if let Some((ref download_bttn, ref play_bttn, ref del_bttn, ref reciever)) = + *global.borrow() + { if reciever.try_recv().is_ok() { download_bttn.hide(); play_bttn.show(); + del_bttn.show(); } } });