Add file size indication based on rss item length.
This commit is contained in:
parent
a7208b0c61
commit
e3b540170a
@ -51,6 +51,18 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="size_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">42 mb</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="an_indicator">
|
||||
<property name="can_focus">False</property>
|
||||
@ -59,7 +71,7 @@
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@ -39,6 +39,7 @@ struct EpisodeWidget {
|
||||
cancel: gtk::Button,
|
||||
title: gtk::Label,
|
||||
duration: gtk::Label,
|
||||
size: gtk::Label,
|
||||
progress: gtk::ProgressBar,
|
||||
an_indicator: gtk::Image,
|
||||
}
|
||||
@ -59,6 +60,7 @@ impl EpisodeWidget {
|
||||
|
||||
let title: gtk::Label = builder.get_object("title_label").unwrap();
|
||||
let duration: gtk::Label = builder.get_object("duration_label").unwrap();
|
||||
let size: gtk::Label = builder.get_object("size_label").unwrap();
|
||||
|
||||
EpisodeWidget {
|
||||
container,
|
||||
@ -70,6 +72,7 @@ impl EpisodeWidget {
|
||||
delete,
|
||||
title,
|
||||
duration,
|
||||
size,
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,6 +86,7 @@ impl EpisodeWidget {
|
||||
// TODO: wire the progress_bar to the downloader.
|
||||
// TODO: wire the cancel button.
|
||||
fn init(&self, episode: &mut EpisodeWidgetQuery, pd: &Podcast) {
|
||||
self.duration.hide();
|
||||
self.title.set_xalign(0.0);
|
||||
self.title.set_text(episode.title());
|
||||
self.progress.set_pulse_step(0.1);
|
||||
@ -93,6 +97,11 @@ impl EpisodeWidget {
|
||||
glib::Continue(true)
|
||||
});
|
||||
|
||||
if let Some(size) = episode.length() {
|
||||
let megabytes: f32 = size as f32 / 1024.0 / 1024.0; // episode.length represents bytes
|
||||
self.size.set_text(&format!("{:.1} mb", megabytes))
|
||||
};
|
||||
|
||||
// Show or hide the play/delete/download buttons upon widget initialization.
|
||||
let local_uri = episode.local_uri();
|
||||
if local_uri.is_some() && Path::new(local_uri.unwrap()).exists() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user