EpisodeWidget: Remove delete button and hide cancel button till refactor.
This commit is contained in:
parent
bfb74c4dba
commit
0a7825dfff
@ -187,29 +187,6 @@
|
|||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="delete_button">
|
|
||||||
<property name="name">delete_button</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="no_show_all">True</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="icon_name">user-trash-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="download_button">
|
<object class="GtkButton" id="download_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use humansize::{file_size_opts as size_opts, FileSize};
|
|||||||
|
|
||||||
use hammond_data::dbqueries;
|
use hammond_data::dbqueries;
|
||||||
use hammond_data::{EpisodeWidgetQuery, Podcast};
|
use hammond_data::{EpisodeWidgetQuery, Podcast};
|
||||||
use hammond_data::utils::*;
|
// use hammond_data::utils::*;
|
||||||
use hammond_data::errors::*;
|
use hammond_data::errors::*;
|
||||||
use hammond_downloader::downloader;
|
use hammond_downloader::downloader;
|
||||||
|
|
||||||
@ -24,7 +24,6 @@ type Foo = RefCell<
|
|||||||
gtk::Button,
|
gtk::Button,
|
||||||
gtk::Button,
|
gtk::Button,
|
||||||
gtk::Button,
|
gtk::Button,
|
||||||
gtk::Button,
|
|
||||||
gtk::ProgressBar,
|
gtk::ProgressBar,
|
||||||
Receiver<bool>,
|
Receiver<bool>,
|
||||||
),
|
),
|
||||||
@ -37,7 +36,6 @@ thread_local!(static GLOBAL: Foo = RefCell::new(None));
|
|||||||
pub struct EpisodeWidget {
|
pub struct EpisodeWidget {
|
||||||
pub container: gtk::Box,
|
pub container: gtk::Box,
|
||||||
play: gtk::Button,
|
play: gtk::Button,
|
||||||
delete: gtk::Button,
|
|
||||||
download: gtk::Button,
|
download: gtk::Button,
|
||||||
cancel: gtk::Button,
|
cancel: gtk::Button,
|
||||||
title: gtk::Label,
|
title: gtk::Label,
|
||||||
@ -59,7 +57,6 @@ impl Default for EpisodeWidget {
|
|||||||
|
|
||||||
let download: gtk::Button = builder.get_object("download_button").unwrap();
|
let download: gtk::Button = builder.get_object("download_button").unwrap();
|
||||||
let play: gtk::Button = builder.get_object("play_button").unwrap();
|
let play: gtk::Button = builder.get_object("play_button").unwrap();
|
||||||
let delete: gtk::Button = builder.get_object("delete_button").unwrap();
|
|
||||||
let cancel: gtk::Button = builder.get_object("cancel_button").unwrap();
|
let cancel: gtk::Button = builder.get_object("cancel_button").unwrap();
|
||||||
|
|
||||||
let title: gtk::Label = builder.get_object("title_label").unwrap();
|
let title: gtk::Label = builder.get_object("title_label").unwrap();
|
||||||
@ -77,7 +74,6 @@ impl Default for EpisodeWidget {
|
|||||||
download,
|
download,
|
||||||
play,
|
play,
|
||||||
cancel,
|
cancel,
|
||||||
delete,
|
|
||||||
title,
|
title,
|
||||||
duration,
|
duration,
|
||||||
size,
|
size,
|
||||||
@ -152,7 +148,6 @@ impl EpisodeWidget {
|
|||||||
if local_uri.is_some() && Path::new(local_uri.unwrap()).exists() {
|
if local_uri.is_some() && Path::new(local_uri.unwrap()).exists() {
|
||||||
self.download.hide();
|
self.download.hide();
|
||||||
self.play.show();
|
self.play.show();
|
||||||
self.delete.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let title = &self.title;
|
let title = &self.title;
|
||||||
@ -168,31 +163,18 @@ impl EpisodeWidget {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
let play = &self.play;
|
let play = &self.play;
|
||||||
let download = &self.download;
|
|
||||||
self.delete
|
|
||||||
.connect_clicked(clone!(episode, play, download => move |del| {
|
|
||||||
on_delete_bttn_clicked(episode.rowid());
|
|
||||||
del.hide();
|
|
||||||
play.hide();
|
|
||||||
download.show();
|
|
||||||
}));
|
|
||||||
|
|
||||||
let play = &self.play;
|
|
||||||
let delete = &self.delete;
|
|
||||||
let cancel = &self.cancel;
|
let cancel = &self.cancel;
|
||||||
let progress = self.progress.clone();
|
let progress = self.progress.clone();
|
||||||
self.download.connect_clicked(
|
self.download
|
||||||
clone!(play, delete, episode, cancel, progress => move |dl| {
|
.connect_clicked(clone!(play, episode, cancel, progress => move |dl| {
|
||||||
on_download_clicked(
|
on_download_clicked(
|
||||||
&mut episode.clone(),
|
&mut episode.clone(),
|
||||||
dl,
|
dl,
|
||||||
&play,
|
&play,
|
||||||
&delete,
|
|
||||||
&cancel,
|
&cancel,
|
||||||
progress.clone()
|
progress.clone()
|
||||||
);
|
);
|
||||||
}),
|
}));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +183,6 @@ fn on_download_clicked(
|
|||||||
ep: &mut EpisodeWidgetQuery,
|
ep: &mut EpisodeWidgetQuery,
|
||||||
download_bttn: >k::Button,
|
download_bttn: >k::Button,
|
||||||
play_bttn: >k::Button,
|
play_bttn: >k::Button,
|
||||||
del_bttn: >k::Button,
|
|
||||||
cancel_bttn: >k::Button,
|
cancel_bttn: >k::Button,
|
||||||
progress_bar: gtk::ProgressBar,
|
progress_bar: gtk::ProgressBar,
|
||||||
) {
|
) {
|
||||||
@ -218,11 +199,10 @@ fn on_download_clicked(
|
|||||||
|
|
||||||
// Pass the desired arguments into the Local Thread Storage.
|
// Pass the desired arguments into the Local Thread Storage.
|
||||||
GLOBAL.with(
|
GLOBAL.with(
|
||||||
clone!(download_bttn, play_bttn, del_bttn, cancel_bttn, progress => move |global| {
|
clone!(download_bttn, play_bttn, cancel_bttn, progress => move |global| {
|
||||||
*global.borrow_mut() = Some((
|
*global.borrow_mut() = Some((
|
||||||
download_bttn,
|
download_bttn,
|
||||||
play_bttn,
|
play_bttn,
|
||||||
del_bttn,
|
|
||||||
cancel_bttn,
|
cancel_bttn,
|
||||||
progress,
|
progress,
|
||||||
receiver));
|
receiver));
|
||||||
@ -232,7 +212,7 @@ fn on_download_clicked(
|
|||||||
let pd = dbqueries::get_podcast_from_id(ep.podcast_id()).unwrap();
|
let pd = dbqueries::get_podcast_from_id(ep.podcast_id()).unwrap();
|
||||||
let pd_title = pd.title().to_owned();
|
let pd_title = pd.title().to_owned();
|
||||||
let mut ep = ep.clone();
|
let mut ep = ep.clone();
|
||||||
cancel_bttn.show();
|
// cancel_bttn.show();
|
||||||
progress.show();
|
progress.show();
|
||||||
download_bttn.hide();
|
download_bttn.hide();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@ -267,25 +247,24 @@ fn on_play_bttn_clicked(episode_id: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_delete_bttn_clicked(episode_id: i32) {
|
// fn on_delete_bttn_clicked(episode_id: i32) {
|
||||||
let mut ep = dbqueries::get_episode_from_rowid(episode_id)
|
// let mut ep = dbqueries::get_episode_from_rowid(episode_id)
|
||||||
.unwrap()
|
// .unwrap()
|
||||||
.into();
|
// .into();
|
||||||
|
|
||||||
let e = delete_local_content(&mut ep);
|
// let e = delete_local_content(&mut ep);
|
||||||
if let Err(err) = e {
|
// if let Err(err) = e {
|
||||||
error!("Error while trying to delete file: {:?}", ep.local_uri());
|
// error!("Error while trying to delete file: {:?}", ep.local_uri());
|
||||||
error!("Error: {}", err);
|
// error!("Error: {}", err);
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn receive() -> glib::Continue {
|
fn receive() -> glib::Continue {
|
||||||
GLOBAL.with(|global| {
|
GLOBAL.with(|global| {
|
||||||
if let Some((
|
if let Some((
|
||||||
ref download_bttn,
|
ref download_bttn,
|
||||||
ref play_bttn,
|
ref play_bttn,
|
||||||
ref del_bttn,
|
ref _cancel_bttn,
|
||||||
ref cancel_bttn,
|
|
||||||
ref progress_bar,
|
ref progress_bar,
|
||||||
ref reciever,
|
ref reciever,
|
||||||
)) = *global.borrow()
|
)) = *global.borrow()
|
||||||
@ -293,8 +272,7 @@ fn receive() -> glib::Continue {
|
|||||||
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();
|
// cancel_bttn.hide();
|
||||||
cancel_bttn.hide();
|
|
||||||
progress_bar.hide();
|
progress_bar.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user