On download completion also show the delete button for the episode widget.
This commit is contained in:
parent
1cdae2b8b0
commit
9c032a7f17
@ -1,6 +1,6 @@
|
|||||||
# Hammond
|
# Hammond
|
||||||
## Prototype of a multithreaded, safe, and reliable Gtk+ Podcast client.
|
## Multithreaded, safe, and reliable Gtk+ Podcast client.
|
||||||
Description...
|
This is a prototype of a podcast client written in Rust.
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|||||||
@ -39,9 +39,9 @@ macro_rules! clone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
thread_local!(
|
thread_local!(
|
||||||
static GLOBAL: RefCell<Option<((gtk::Button,
|
static GLOBAL: RefCell<Option<((
|
||||||
gtk::Button,
|
gtk::Button, gtk::Button, gtk::Button, Receiver<bool>,
|
||||||
Receiver<bool>))>> = RefCell::new(None));
|
))>> = RefCell::new(None));
|
||||||
|
|
||||||
fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::Box {
|
fn epidose_widget(db: &Database, episode: &mut Episode, pd_title: &str) -> gtk::Box {
|
||||||
// This is just a prototype and will be reworked probably.
|
// 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();
|
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(
|
on_download_clicked(
|
||||||
&db,
|
&db,
|
||||||
&pd_title,
|
&pd_title,
|
||||||
&mut episode.clone(),
|
&mut episode.clone(),
|
||||||
dl,
|
dl,
|
||||||
&play_button,
|
&play_button,
|
||||||
|
&delete_button,
|
||||||
);
|
);
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
ep
|
ep
|
||||||
}
|
}
|
||||||
@ -116,13 +119,14 @@ fn on_download_clicked(
|
|||||||
ep: &mut Episode,
|
ep: &mut Episode,
|
||||||
download_bttn: >k::Button,
|
download_bttn: >k::Button,
|
||||||
play_bttn: >k::Button,
|
play_bttn: >k::Button,
|
||||||
|
del_bttn: >k::Button,
|
||||||
) {
|
) {
|
||||||
// Create a async channel.
|
// Create a async channel.
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
// Pass the desired arguments into the Local Thread Storage.
|
// Pass the desired arguments into the Local Thread Storage.
|
||||||
GLOBAL.with(clone!(download_bttn, play_bttn => move |global| {
|
GLOBAL.with(clone!(download_bttn, play_bttn, del_bttn => move |global| {
|
||||||
*global.borrow_mut() = Some((download_bttn, play_bttn, receiver));
|
*global.borrow_mut() = Some((download_bttn, play_bttn, del_bttn, receiver));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let pd_title = pd_title.to_owned();
|
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 {
|
fn receive() -> glib::Continue {
|
||||||
GLOBAL.with(|global| {
|
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() {
|
if reciever.try_recv().is_ok() {
|
||||||
download_bttn.hide();
|
download_bttn.hide();
|
||||||
play_bttn.show();
|
play_bttn.show();
|
||||||
|
del_bttn.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user