ShowWidget: Add a proggress_bar to indicate loading status of episode widgets

parent 9f841781
Pipeline #9033 passed with stages
in 10 minutes and 48 seconds
......@@ -34,6 +34,18 @@ Tobias Bernard
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkProgressBar" id="progress_bar">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="name">scrolled_window</property>
......@@ -277,7 +289,7 @@ Tobias Bernard
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">2</property>
</packing>
</child>
</object>
......
......@@ -151,7 +151,6 @@ impl App {
WindowGeometry::from_settings(&self.settings).apply(&self.window);
let window = self.window.clone();
self.app_instance.connect_startup(move |app| {
build_ui(&window, app);
});
......@@ -175,8 +174,8 @@ impl App {
content
.get_shows()
.replace_widget(pd.clone())
.map_err(|err| error!("Failed to update ShowWidget: {}", err))
.map_err(|_| error!("Failed ot update ShowWidget {}", pd.title()))
.map_err(|err| error!("Error: {}", err))
.map_err(|_| error!("Failed to update ShowWidget of {}", pd.title()))
.ok();
}
Ok(Action::ShowWidgetAnimated) => content.get_shows().switch_widget_animated(),
......
......@@ -69,7 +69,6 @@ impl ShowStack {
.downcast::<gtk::Box>()
.map_err(|_| format_err!("Failed to downcast stack child to a Box."))?;
debug!("Name: {:?}", WidgetExt::get_name(&old));
let scrolled_window = old.get_children()
.first()
.ok_or_else(|| format_err!("Box container has no childs."))?
......
......@@ -29,6 +29,7 @@ pub struct ShowWidget {
settings: gtk::MenuButton,
unsub: gtk::Button,
episodes: gtk::ListBox,
progress_bar: gtk::ProgressBar,
}
impl Default for ShowWidget {
......@@ -43,6 +44,7 @@ impl Default for ShowWidget {
let unsub: gtk::Button = builder.get_object("unsub_button").unwrap();
let link: gtk::Button = builder.get_object("link_button").unwrap();
let settings: gtk::MenuButton = builder.get_object("settings_button").unwrap();
let progress_bar = builder.get_object("progress_bar").unwrap();
ShowWidget {
container,
......@@ -53,6 +55,7 @@ impl Default for ShowWidget {
link,
settings,
episodes,
progress_bar,
}
}
}
......@@ -147,6 +150,7 @@ impl ShowWidget {
}
let list = self.episodes.clone();
let bar = self.progress_bar.clone();
gtk::idle_add(move || {
let episodes = match receiver.try_recv() {
Ok(e) => e,
......@@ -154,7 +158,16 @@ impl ShowWidget {
Err(Disconnected) => return glib::Continue(false),
};
let constructor = clone!(sender => move |ep| {
let mut done = 0;
let constructor = clone!(sender, bar => move |ep| {
done += 1;
if done >= count {
bar.hide()
}
let fraction = done as f64 / count as f64;
bar.set_fraction(fraction);
EpisodeWidget::new(ep, sender.clone()).container
});
......@@ -164,6 +177,7 @@ impl ShowWidget {
.ok();
});
bar.show();
lazy_load(episodes, list.clone(), constructor, callback);
glib::Continue(false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment