GtkApplication: Add an action for showing the headerbar_update_indicator.
This commit is contained in:
parent
a7e3b1b99e
commit
5e1d1e557f
@ -30,6 +30,7 @@ pub enum Action {
|
||||
ShowShowsAnimated,
|
||||
HeaderBarShowTile(String),
|
||||
HeaderBarNormal,
|
||||
HeaderBarShowUpdateIndicator,
|
||||
HeaderBarHideUpdateIndicator,
|
||||
}
|
||||
|
||||
@ -87,21 +88,19 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn setup_timed_callbacks(&self) {
|
||||
let header = self.header.clone();
|
||||
let sender = self.sender.clone();
|
||||
// Update the feeds right after the Application is initialized.
|
||||
gtk::timeout_add_seconds(2, move || {
|
||||
utils::refresh_feed(header.clone(), None, sender.clone());
|
||||
utils::refresh_feed(None, sender.clone());
|
||||
glib::Continue(false)
|
||||
});
|
||||
|
||||
let header = self.header.clone();
|
||||
let sender = self.sender.clone();
|
||||
// Auto-updater, runs every hour.
|
||||
// TODO: expose the interval in which it run to a user setting.
|
||||
// TODO: show notifications.
|
||||
gtk::timeout_add_seconds(3600, move || {
|
||||
utils::refresh_feed(header.clone(), None, sender.clone());
|
||||
utils::refresh_feed(None, sender.clone());
|
||||
glib::Continue(true)
|
||||
});
|
||||
|
||||
@ -128,9 +127,9 @@ impl App {
|
||||
match receiver.recv_timeout(Duration::from_millis(10)) {
|
||||
Ok(Action::UpdateSources(source)) => {
|
||||
if let Some(s) = source {
|
||||
utils::refresh_feed(headerbar.clone(), Some(vec![s]), sender.clone())
|
||||
utils::refresh_feed(Some(vec![s]), sender.clone())
|
||||
} else {
|
||||
utils::refresh_feed(headerbar.clone(), None, sender.clone())
|
||||
utils::refresh_feed(None, sender.clone())
|
||||
}
|
||||
}
|
||||
Ok(Action::RefreshAllViews) => content.update(),
|
||||
@ -145,6 +144,7 @@ impl App {
|
||||
Ok(Action::ShowShowsAnimated) => content.get_shows().switch_podcasts_animated(),
|
||||
Ok(Action::HeaderBarShowTile(title)) => headerbar.switch_to_back(&title),
|
||||
Ok(Action::HeaderBarNormal) => headerbar.switch_to_normal(),
|
||||
Ok(Action::HeaderBarShowUpdateIndicator) => headerbar.show_update_notification(),
|
||||
Ok(Action::HeaderBarHideUpdateIndicator) => headerbar.hide_update_notification(),
|
||||
Err(_) => (),
|
||||
}
|
||||
|
||||
@ -8,25 +8,21 @@ use hammond_data::pipeline;
|
||||
use hammond_downloader::downloader;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use std::sync::{Mutex, RwLock};
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thread;
|
||||
|
||||
use app::Action;
|
||||
use headerbar::Header;
|
||||
|
||||
/// Update the rss feed(s) originating from `source`.
|
||||
/// If `source` is None, Fetches all the `Source` entries in the database and updates them.
|
||||
/// When It's done,it queues up a `RefreshViews` action.
|
||||
pub fn refresh_feed(headerbar: Arc<Header>, source: Option<Vec<Source>>, sender: Sender<Action>) {
|
||||
// TODO: make it an application channel action.
|
||||
// I missed it before apparently.
|
||||
headerbar.show_update_notification();
|
||||
pub fn refresh_feed(source: Option<Vec<Source>>, sender: Sender<Action>) {
|
||||
sender.send(Action::HeaderBarShowUpdateIndicator).unwrap();
|
||||
|
||||
thread::spawn(move || {
|
||||
// FIXME: This is messy at best.
|
||||
if let Some(s) = source {
|
||||
// feed::index_loop(s);
|
||||
// TODO: determine if it needs to ignore_etags.
|
||||
if let Err(err) = pipeline::run(s, true) {
|
||||
error!("Error While trying to update the database.");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user