EpisodeWidget: Do not display size if it's 0 bytes.
This commit is contained in:
parent
37dbfff766
commit
2d6f02c407
@ -63,7 +63,7 @@ pub(crate) fn new_episode(item: &Item, parent_id: i32) -> Result<NewEpisode> {
|
||||
let pub_date = date.map(|x| x.to_rfc2822()).ok();
|
||||
let epoch = date.map(|x| x.timestamp() as i32).unwrap_or(0);
|
||||
|
||||
let length = item.enclosure().map(|x| x.length().parse().unwrap_or(0));
|
||||
let length = || -> Option<i32> { item.enclosure().map(|x| x.length().parse().ok())? }();
|
||||
let duration = parse_itunes_duration(item);
|
||||
|
||||
Ok(NewEpisodeBuilder::default()
|
||||
|
||||
@ -104,8 +104,8 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="separator2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="no_show_all">True</property>
|
||||
<property name="label" translatable="yes">·</property>
|
||||
<property name="track_visited_links">False</property>
|
||||
<style>
|
||||
@ -120,7 +120,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="size_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="no_show_all">True</property>
|
||||
<property name="label" translatable="yes">42 MB</property>
|
||||
|
||||
@ -47,6 +47,7 @@ pub struct EpisodeWidget {
|
||||
progress: gtk::ProgressBar,
|
||||
progress_label: gtk::Label,
|
||||
separator1: gtk::Label,
|
||||
separator2: gtk::Label,
|
||||
}
|
||||
|
||||
impl Default for EpisodeWidget {
|
||||
@ -68,6 +69,7 @@ impl Default for EpisodeWidget {
|
||||
let progress_label: gtk::Label = builder.get_object("progress_label").unwrap();
|
||||
|
||||
let separator1: gtk::Label = builder.get_object("separator1").unwrap();
|
||||
let separator2: gtk::Label = builder.get_object("separator2").unwrap();
|
||||
|
||||
EpisodeWidget {
|
||||
container,
|
||||
@ -82,6 +84,7 @@ impl Default for EpisodeWidget {
|
||||
date,
|
||||
progress_label,
|
||||
separator1,
|
||||
separator2,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,11 +123,13 @@ impl EpisodeWidget {
|
||||
};
|
||||
|
||||
if let Some(size) = episode.length() {
|
||||
if size != 0 {
|
||||
let s = size.file_size(custom_options);
|
||||
if let Ok(s) = s {
|
||||
self.size.set_text(&s);
|
||||
} else {
|
||||
self.size.hide();
|
||||
self.size.show();
|
||||
self.separator2.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user