GtkApplication: Change the action channel polling interval.
This commit is contained in:
parent
f873278a96
commit
750abb519b
@ -13,7 +13,6 @@ use utils;
|
|||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
@ -124,15 +123,15 @@ impl App {
|
|||||||
self.setup_timed_callbacks();
|
self.setup_timed_callbacks();
|
||||||
self.setup_actions();
|
self.setup_actions();
|
||||||
|
|
||||||
let receiver = self.receiver;
|
|
||||||
let content = self.content.clone();
|
let content = self.content.clone();
|
||||||
let headerbar = self.header.clone();
|
let headerbar = self.header.clone();
|
||||||
let sender = self.sender.clone();
|
let sender = self.sender.clone();
|
||||||
gtk::idle_add(clone!(content, headerbar => move || {
|
let receiver = self.receiver;
|
||||||
match receiver.recv_timeout(Duration::from_millis(5)) {
|
gtk::timeout_add(250, move || {
|
||||||
|
match receiver.try_recv() {
|
||||||
Ok(Action::UpdateSources(source)) => {
|
Ok(Action::UpdateSources(source)) => {
|
||||||
if let Some(s) = source {
|
if let Some(s) = source {
|
||||||
utils::refresh_feed(headerbar.clone(), Some(vec!(s)), sender.clone())
|
utils::refresh_feed(headerbar.clone(), Some(vec![s]), sender.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Action::RefreshViews) => {
|
Ok(Action::RefreshViews) => {
|
||||||
@ -141,20 +140,14 @@ impl App {
|
|||||||
Ok(Action::RefreshEpisodesViewBGR) => {
|
Ok(Action::RefreshEpisodesViewBGR) => {
|
||||||
content.update_episode_view_if_baground();
|
content.update_episode_view_if_baground();
|
||||||
}
|
}
|
||||||
Ok(Action::HeaderBarShowTile(title)) => {
|
Ok(Action::HeaderBarShowTile(title)) => headerbar.switch_to_back(&title),
|
||||||
headerbar.switch_to_back(&title)
|
Ok(Action::HeaderBarNormal) => headerbar.switch_to_normal(),
|
||||||
}
|
Ok(Action::HeaderBarHideUpdateIndicator) => headerbar.hide_update_notification(),
|
||||||
Ok(Action::HeaderBarNormal) => {
|
|
||||||
headerbar.switch_to_normal()
|
|
||||||
}
|
|
||||||
Ok(Action::HeaderBarHideUpdateIndicator) => {
|
|
||||||
headerbar.hide_update_notification()
|
|
||||||
}
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
Continue(true)
|
Continue(true)
|
||||||
}));
|
});
|
||||||
|
|
||||||
ApplicationExtManual::run(&self.app_instance, &[]);
|
ApplicationExtManual::run(&self.app_instance, &[]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,7 @@ impl Default for EpisodesView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: REFACTOR ME
|
||||||
impl EpisodesView {
|
impl EpisodesView {
|
||||||
pub fn new(sender: Sender<Action>) -> Rc<EpisodesView> {
|
pub fn new(sender: Sender<Action>) -> Rc<EpisodesView> {
|
||||||
let view = EpisodesView::default();
|
let view = EpisodesView::default();
|
||||||
|
|||||||
@ -107,7 +107,7 @@ impl EpisodeWidget {
|
|||||||
title
|
title
|
||||||
.get_style_context()
|
.get_style_context()
|
||||||
.map(|c| c.add_class("dim-label"));
|
.map(|c| c.add_class("dim-label"));
|
||||||
sender.clone().send(Action::RefreshEpisodesViewBGR).unwrap();
|
sender.send(Action::RefreshEpisodesViewBGR).unwrap();
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -261,12 +261,12 @@ fn on_play_bttn_clicked(episode_id: i32) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn episodes_listbox(pd: &Podcast, sender: Sender<Action>) -> Result<gtk::ListBox> {
|
pub fn episodes_listbox(pd: &Podcast, sender: Sender<Action>) -> Result<gtk::ListBox> {
|
||||||
let episodes = dbqueries::get_pd_episodeswidgets(pd)?;
|
let mut episodes = dbqueries::get_pd_episodeswidgets(pd)?;
|
||||||
|
|
||||||
let list = gtk::ListBox::new();
|
let list = gtk::ListBox::new();
|
||||||
|
|
||||||
episodes.into_iter().for_each(|mut ep| {
|
episodes.iter_mut().for_each(|ep| {
|
||||||
let widget = EpisodeWidget::new(&mut ep, sender.clone());
|
let widget = EpisodeWidget::new(ep, sender.clone());
|
||||||
list.add(&widget.container);
|
list.add(&widget.container);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user