Fix all the clippy warnings!
This commit is contained in:
parent
d4d89a56e9
commit
c96b39d597
@ -1,3 +1,4 @@
|
|||||||
|
#![cfg_attr(feature = "cargo-clippy", allow(unit_arg))]
|
||||||
//! Index Feeds.
|
//! Index Feeds.
|
||||||
|
|
||||||
use futures::future::*;
|
use futures::future::*;
|
||||||
@ -53,7 +54,7 @@ impl Feed {
|
|||||||
// Filter errors, Index updatable episodes, return insertables.
|
// Filter errors, Index updatable episodes, return insertables.
|
||||||
let insertables = filter_episodes(episodes);
|
let insertables = filter_episodes(episodes);
|
||||||
// Batch index insertable episodes.
|
// Batch index insertable episodes.
|
||||||
let idx = insertables.and_then(|eps| ok(batch_insert_episodes(eps)));
|
let idx = insertables.and_then(|eps| ok(batch_insert_episodes(&eps)));
|
||||||
|
|
||||||
Box::new(idx)
|
Box::new(idx)
|
||||||
}
|
}
|
||||||
@ -109,13 +110,13 @@ where
|
|||||||
Box::new(list)
|
Box::new(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn batch_insert_episodes(episodes: Vec<NewEpisode>) {
|
fn batch_insert_episodes(episodes: &[NewEpisode]) {
|
||||||
if episodes.is_empty() {
|
if episodes.is_empty() {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Indexing {} episodes.", episodes.len());
|
info!("Indexing {} episodes.", episodes.len());
|
||||||
dbqueries::index_new_episodes(episodes.as_slice())
|
dbqueries::index_new_episodes(episodes)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
error!("Failed batch indexng: {}", err);
|
error!("Failed batch indexng: {}", err);
|
||||||
info!("Fallign back to individual indexing.");
|
info!("Fallign back to individual indexing.");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#![recursion_limit = "1024"]
|
#![recursion_limit = "1024"]
|
||||||
#![cfg_attr(all(test, feature = "clippy"), allow(option_unwrap_used, result_unwrap_used))]
|
#![cfg_attr(all(test, feature = "clippy"), allow(option_unwrap_used, result_unwrap_used))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))]
|
#![cfg_attr(feature = "cargo-clippy", allow(option_map_unit_fn))]
|
||||||
# Paths.
|
/// [XDG Base Direcotory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths.
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
|
|||||||
@ -181,7 +181,7 @@ impl Source {
|
|||||||
let id = self.id();
|
let id = self.id();
|
||||||
let response = loop_fn(self, move |source| {
|
let response = loop_fn(self, move |source| {
|
||||||
source
|
source
|
||||||
.request_constructor(client.clone(), ignore_etags)
|
.request_constructor(&client.clone(), ignore_etags)
|
||||||
.then(|res| match res {
|
.then(|res| match res {
|
||||||
Ok(response) => Ok(Loop::Break(response)),
|
Ok(response) => Ok(Loop::Break(response)),
|
||||||
Err(err) => match err {
|
Err(err) => match err {
|
||||||
@ -195,7 +195,7 @@ impl Source {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let feed = response
|
let feed = response
|
||||||
.and_then(|res| response_to_channel(res))
|
.and_then(response_to_channel)
|
||||||
.and_then(move |chan| {
|
.and_then(move |chan| {
|
||||||
FeedBuilder::default()
|
FeedBuilder::default()
|
||||||
.channel(chan)
|
.channel(chan)
|
||||||
@ -211,7 +211,7 @@ impl Source {
|
|||||||
// #bools_are_just_2variant_enmus
|
// #bools_are_just_2variant_enmus
|
||||||
fn request_constructor(
|
fn request_constructor(
|
||||||
self,
|
self,
|
||||||
client: Client<HttpsConnector<HttpConnector>>,
|
client: &Client<HttpsConnector<HttpConnector>>,
|
||||||
ignore_etags: bool,
|
ignore_etags: bool,
|
||||||
) -> Box<Future<Item = Response, Error = DataError>> {
|
) -> Box<Future<Item = Response, Error = DataError>> {
|
||||||
// FIXME: remove unwrap somehow
|
// FIXME: remove unwrap somehow
|
||||||
|
|||||||
@ -49,7 +49,7 @@ type HttpsClient = Client<HttpsConnector<HttpConnector>>;
|
|||||||
pub fn pipeline<'a, S>(
|
pub fn pipeline<'a, S>(
|
||||||
sources: S,
|
sources: S,
|
||||||
ignore_etags: bool,
|
ignore_etags: bool,
|
||||||
client: HttpsClient,
|
client: &HttpsClient,
|
||||||
) -> Box<Future<Item = Vec<()>, Error = DataError> + 'a>
|
) -> Box<Future<Item = Vec<()>, Error = DataError> + 'a>
|
||||||
where
|
where
|
||||||
S: Stream<Item = Source, Error = DataError> + 'a,
|
S: Stream<Item = Source, Error = DataError> + 'a,
|
||||||
@ -79,7 +79,7 @@ where
|
|||||||
.build(&handle);
|
.build(&handle);
|
||||||
|
|
||||||
let stream = iter_ok::<_, DataError>(sources);
|
let stream = iter_ok::<_, DataError>(sources);
|
||||||
let p = pipeline(stream, ignore_etags, client);
|
let p = pipeline(stream, ignore_etags, &client);
|
||||||
core.run(p).map(|_| ())
|
core.run(p).map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#![recursion_limit = "1024"]
|
#![recursion_limit = "1024"]
|
||||||
#![deny(unused_extern_crates, unused)]
|
#![deny(unused_extern_crates, unused)]
|
||||||
#![allow(unknown_lints)]
|
#![allow(unknown_lints)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))]
|
#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name, option_map_unit_fn))]
|
||||||
|
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|||||||
@ -82,7 +82,7 @@ impl App {
|
|||||||
Rc::new(Content::new(sender.clone()).expect("Content Initialization failed."));
|
Rc::new(Content::new(sender.clone()).expect("Content Initialization failed."));
|
||||||
|
|
||||||
// Create the headerbar
|
// Create the headerbar
|
||||||
let header = Rc::new(Header::new(&content, &window, sender.clone()));
|
let header = Rc::new(Header::new(&content, &window, &sender));
|
||||||
|
|
||||||
// Add the content main stack to the overlay.
|
// Add the content main stack to the overlay.
|
||||||
let overlay = gtk::Overlay::new();
|
let overlay = gtk::Overlay::new();
|
||||||
@ -194,7 +194,7 @@ impl App {
|
|||||||
Ok(Action::HeaderBarShowUpdateIndicator) => headerbar.show_update_notification(),
|
Ok(Action::HeaderBarShowUpdateIndicator) => headerbar.show_update_notification(),
|
||||||
Ok(Action::HeaderBarHideUpdateIndicator) => headerbar.hide_update_notification(),
|
Ok(Action::HeaderBarHideUpdateIndicator) => headerbar.hide_update_notification(),
|
||||||
Ok(Action::MarkAllPlayerNotification(pd)) => {
|
Ok(Action::MarkAllPlayerNotification(pd)) => {
|
||||||
let notif = mark_all_notif(pd, sender.clone());
|
let notif = mark_all_notif(pd, &sender);
|
||||||
notif.show(&overlay);
|
notif.show(&overlay);
|
||||||
}
|
}
|
||||||
Ok(Action::RemoveShow(pd)) => {
|
Ok(Action::RemoveShow(pd)) => {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ impl Default for InAppNotification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl InAppNotification {
|
impl InAppNotification {
|
||||||
pub fn new<F, U>(text: String, mut callback: F, undo_callback: U) -> Self
|
pub fn new<F, U>(text: &str, mut callback: F, undo_callback: U) -> Self
|
||||||
where
|
where
|
||||||
F: FnMut() -> glib::Continue + 'static,
|
F: FnMut() -> glib::Continue + 'static,
|
||||||
U: Fn() + 'static,
|
U: Fn() + 'static,
|
||||||
|
|||||||
@ -61,13 +61,13 @@ impl Default for Header {
|
|||||||
|
|
||||||
// TODO: Refactor components into smaller state machines
|
// TODO: Refactor components into smaller state machines
|
||||||
impl Header {
|
impl Header {
|
||||||
pub fn new(content: &Content, window: >k::Window, sender: Sender<Action>) -> Header {
|
pub fn new(content: &Content, window: >k::Window, sender: &Sender<Action>) -> Header {
|
||||||
let h = Header::default();
|
let h = Header::default();
|
||||||
h.init(content, window, sender);
|
h.init(content, window, &sender);
|
||||||
h
|
h
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self, content: &Content, window: >k::Window, sender: Sender<Action>) {
|
pub fn init(&self, content: &Content, window: >k::Window, sender: &Sender<Action>) {
|
||||||
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/headerbar.ui");
|
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/headerbar.ui");
|
||||||
|
|
||||||
let add_popover: gtk::Popover = builder.get_object("add_popover").unwrap();
|
let add_popover: gtk::Popover = builder.get_object("add_popover").unwrap();
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
allow(
|
allow(clone_on_ref_ptr, blacklisted_name, match_same_arms, option_map_unit_fn)
|
||||||
clone_on_ref_ptr, needless_pass_by_value, useless_format, blacklisted_name, match_same_arms
|
|
||||||
)
|
|
||||||
)]
|
)]
|
||||||
#![allow(unknown_lints)]
|
#![allow(unknown_lints)]
|
||||||
#![deny(unused_extern_crates, unused)]
|
#![deny(unused_extern_crates, unused)]
|
||||||
|
|||||||
@ -71,14 +71,14 @@ impl WindowGeometry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_refresh_interval(settings: &Settings) -> Duration {
|
pub fn get_refresh_interval(settings: &Settings) -> Duration {
|
||||||
let time = settings.get_int("refresh-interval-time") as i64;
|
let time = i64::from(settings.get_int("refresh-interval-time"));
|
||||||
let period = settings.get_string("refresh-interval-period").unwrap();
|
let period = settings.get_string("refresh-interval-period").unwrap();
|
||||||
|
|
||||||
time_period_to_duration(time, period.as_str())
|
time_period_to_duration(time, period.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_cleanup_date(settings: &Settings) -> DateTime<Utc> {
|
pub fn get_cleanup_date(settings: &Settings) -> DateTime<Utc> {
|
||||||
let time = settings.get_int("cleanup-age-time") as i64;
|
let time = i64::from(settings.get_int("cleanup-age-time"));
|
||||||
let period = settings.get_string("cleanup-age-period").unwrap();
|
let period = settings.get_string("cleanup-age-period").unwrap();
|
||||||
let duration = time_period_to_duration(time, period.as_str());
|
let duration = time_period_to_duration(time, period.as_str());
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use widgets::{EmptyView, HomeView};
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
enum State {
|
enum State {
|
||||||
Home,
|
Home,
|
||||||
Empty,
|
Empty,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use std::rc::Rc;
|
|||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum PopulatedState {
|
pub enum PopulatedState {
|
||||||
View,
|
View,
|
||||||
Widget,
|
Widget,
|
||||||
@ -71,7 +71,7 @@ impl PopulatedStack {
|
|||||||
// The current visible child might change depending on
|
// The current visible child might change depending on
|
||||||
// removal and insertion in the gtk::Stack, so we have
|
// removal and insertion in the gtk::Stack, so we have
|
||||||
// to make sure it will stay the same.
|
// to make sure it will stay the same.
|
||||||
let s = self.state.clone();
|
let s = self.state;
|
||||||
self.switch_visible(s);
|
self.switch_visible(s);
|
||||||
|
|
||||||
old.destroy();
|
old.destroy();
|
||||||
@ -94,7 +94,7 @@ impl PopulatedStack {
|
|||||||
// The current visible child might change depending on
|
// The current visible child might change depending on
|
||||||
// removal and insertion in the gtk::Stack, so we have
|
// removal and insertion in the gtk::Stack, so we have
|
||||||
// to make sure it will stay the same.
|
// to make sure it will stay the same.
|
||||||
let s = self.state.clone();
|
let s = self.state;
|
||||||
self.switch_visible(s);
|
self.switch_visible(s);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -113,7 +113,7 @@ impl PopulatedStack {
|
|||||||
// The current visible child might change depending on
|
// The current visible child might change depending on
|
||||||
// removal and insertion in the gtk::Stack, so we have
|
// removal and insertion in the gtk::Stack, so we have
|
||||||
// to make sure it will stay the same.
|
// to make sure it will stay the same.
|
||||||
let s = self.state.clone();
|
let s = self.state;
|
||||||
self.switch_visible(s);
|
self.switch_visible(s);
|
||||||
|
|
||||||
old.destroy();
|
old.destroy();
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use std::cell::RefCell;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum ShowState {
|
pub enum ShowState {
|
||||||
Populated,
|
Populated,
|
||||||
Empty,
|
Empty,
|
||||||
|
|||||||
@ -83,6 +83,7 @@ where
|
|||||||
/// If you just want to lazy add `widgets` to a `container` check if
|
/// If you just want to lazy add `widgets` to a `container` check if
|
||||||
/// `lazy_load` fits your needs first.
|
/// `lazy_load` fits your needs first.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(redundant_closure))]
|
||||||
pub fn lazy_load_full<T, F, U>(data: T, mut func: F, finish_callback: U)
|
pub fn lazy_load_full<T, F, U>(data: T, mut func: F, finish_callback: U)
|
||||||
where
|
where
|
||||||
T: IntoIterator + 'static,
|
T: IntoIterator + 'static,
|
||||||
@ -104,6 +105,7 @@ where
|
|||||||
|
|
||||||
// Kudos to Julian Sparber
|
// Kudos to Julian Sparber
|
||||||
// https://blogs.gnome.org/jsparber/2018/04/29/animate-a-scrolledwindow/
|
// https://blogs.gnome.org/jsparber/2018/04/29/animate-a-scrolledwindow/
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
|
||||||
pub fn smooth_scroll_to(view: >k::ScrolledWindow, target: >k::Adjustment) {
|
pub fn smooth_scroll_to(view: >k::ScrolledWindow, target: >k::Adjustment) {
|
||||||
if let Some(adj) = view.get_vadjustment() {
|
if let Some(adj) = view.get_vadjustment() {
|
||||||
if let Some(clock) = view.get_frame_clock() {
|
if let Some(clock) = view.get_frame_clock() {
|
||||||
@ -115,7 +117,8 @@ pub fn smooth_scroll_to(view: >k::ScrolledWindow, target: >k::Adjustment) {
|
|||||||
|
|
||||||
view.add_tick_callback(move |_, clock| {
|
view.add_tick_callback(move |_, clock| {
|
||||||
let now = clock.get_frame_time();
|
let now = clock.get_frame_time();
|
||||||
if now < end_time && adj.get_value() != end {
|
// FIXME: `adj.get_value != end` is a float comparison...
|
||||||
|
if now < end_time && adj.get_value().abs() != end.abs() {
|
||||||
let mut t = (now - start_time) as f64 / (end_time - start_time) as f64;
|
let mut t = (now - start_time) as f64 / (end_time - start_time) as f64;
|
||||||
t = ease_out_cubic(t);
|
t = ease_out_cubic(t);
|
||||||
adj.set_value(start + t * (end - start));
|
adj.set_value(start + t * (end - start));
|
||||||
@ -133,7 +136,7 @@ pub fn smooth_scroll_to(view: >k::ScrolledWindow, target: >k::Adjustment) {
|
|||||||
// infamous easing equations, MIT license.
|
// infamous easing equations, MIT license.
|
||||||
fn ease_out_cubic(t: f64) -> f64 {
|
fn ease_out_cubic(t: f64) -> f64 {
|
||||||
let p = t - 1f64;
|
let p = t - 1f64;
|
||||||
return p * p * p + 1f64;
|
p * p * p + 1f64
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|||||||
@ -80,14 +80,14 @@ impl Default for EpisodeWidget {
|
|||||||
|
|
||||||
impl EpisodeWidget {
|
impl EpisodeWidget {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(episode: EpisodeWidgetQuery, sender: Sender<Action>) -> EpisodeWidget {
|
pub fn new(episode: EpisodeWidgetQuery, sender: &Sender<Action>) -> EpisodeWidget {
|
||||||
let mut widget = EpisodeWidget::default();
|
let mut widget = EpisodeWidget::default();
|
||||||
widget.init(episode, sender);
|
widget.init(episode, sender);
|
||||||
widget
|
widget
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn init(&mut self, episode: EpisodeWidgetQuery, sender: Sender<Action>) {
|
fn init(&mut self, episode: EpisodeWidgetQuery, sender: &Sender<Action>) {
|
||||||
// Set the date label.
|
// Set the date label.
|
||||||
self.set_date(episode.epoch());
|
self.set_date(episode.epoch());
|
||||||
|
|
||||||
@ -98,22 +98,22 @@ impl EpisodeWidget {
|
|||||||
self.set_duration(episode.duration());
|
self.set_duration(episode.duration());
|
||||||
|
|
||||||
// Determine what the state of the media widgets should be.
|
// Determine what the state of the media widgets should be.
|
||||||
determine_media_state(self.media.clone(), &episode)
|
determine_media_state(&self.media, &episode)
|
||||||
.map_err(|err| error!("Error: {}", err))
|
.map_err(|err| error!("Error: {}", err))
|
||||||
.map_err(|_| error!("Could not determine Media State"))
|
.map_err(|_| error!("Could not determine Media State"))
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let episode = Arc::new(Mutex::new(episode));
|
let episode = Arc::new(Mutex::new(episode));
|
||||||
self.connect_buttons(episode, sender);
|
self.connect_buttons(&episode, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn connect_buttons(&self, episode: Arc<Mutex<EpisodeWidgetQuery>>, sender: Sender<Action>) {
|
fn connect_buttons(&self, episode: &Arc<Mutex<EpisodeWidgetQuery>>, sender: &Sender<Action>) {
|
||||||
let title = self.title.clone();
|
let title = self.title.clone();
|
||||||
if let Ok(media) = self.media.try_borrow_mut() {
|
if let Ok(media) = self.media.try_borrow_mut() {
|
||||||
media.play_connect_clicked(clone!(episode, sender => move |_| {
|
media.play_connect_clicked(clone!(episode, sender => move |_| {
|
||||||
if let Ok(mut ep) = episode.lock() {
|
if let Ok(mut ep) = episode.lock() {
|
||||||
on_play_bttn_clicked(&mut ep, title.clone(), sender.clone())
|
on_play_bttn_clicked(&mut ep, &title, &sender)
|
||||||
.map_err(|err| error!("Error: {}", err))
|
.map_err(|err| error!("Error: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@ -124,10 +124,10 @@ impl EpisodeWidget {
|
|||||||
// Make the button insensitive so it won't be pressed twice
|
// Make the button insensitive so it won't be pressed twice
|
||||||
dl.set_sensitive(false);
|
dl.set_sensitive(false);
|
||||||
if let Ok(ep) = episode.lock() {
|
if let Ok(ep) = episode.lock() {
|
||||||
on_download_clicked(&ep, sender.clone())
|
on_download_clicked(&ep, &sender)
|
||||||
.and_then(|_| {
|
.and_then(|_| {
|
||||||
info!("Donwload started succesfully.");
|
info!("Donwload started succesfully.");
|
||||||
determine_media_state(media_machine.clone(), &ep)
|
determine_media_state(&media_machine, &ep)
|
||||||
})
|
})
|
||||||
.map_err(|err| error!("Error: {}", err))
|
.map_err(|err| error!("Error: {}", err))
|
||||||
.map_err(|_| error!("Could not determine Media State"))
|
.map_err(|_| error!("Could not determine Media State"))
|
||||||
@ -167,7 +167,7 @@ impl EpisodeWidget {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn determine_media_state(
|
fn determine_media_state(
|
||||||
media_machine: Rc<RefCell<MediaMachine>>,
|
media_machine: &Rc<RefCell<MediaMachine>>,
|
||||||
episode: &EpisodeWidgetQuery,
|
episode: &EpisodeWidgetQuery,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let id = episode.rowid();
|
let id = episode.rowid();
|
||||||
@ -196,7 +196,7 @@ fn determine_media_state(
|
|||||||
if let Ok(guard) = manager::ACTIVE_DOWNLOADS.read() {
|
if let Ok(guard) = manager::ACTIVE_DOWNLOADS.read() {
|
||||||
if !guard.contains_key(&id) {
|
if !guard.contains_key(&id) {
|
||||||
if let Ok(ep) = dbqueries::get_episode_widget_from_rowid(id) {
|
if let Ok(ep) = dbqueries::get_episode_widget_from_rowid(id) {
|
||||||
determine_media_state(media_machine.clone(), &ep)
|
determine_media_state(&media_machine, &ep)
|
||||||
.map_err(|err| error!("Error: {}", err))
|
.map_err(|err| error!("Error: {}", err))
|
||||||
.map_err(|_| error!("Could not determine Media State"))
|
.map_err(|_| error!("Could not determine Media State"))
|
||||||
.ok();
|
.ok();
|
||||||
@ -230,19 +230,19 @@ fn determine_media_state(
|
|||||||
drop(lock);
|
drop(lock);
|
||||||
|
|
||||||
// Setup a callback that will update the progress bar.
|
// Setup a callback that will update the progress bar.
|
||||||
update_progressbar_callback(prog.clone(), media_machine.clone(), id);
|
update_progressbar_callback(&prog, &media_machine, id);
|
||||||
|
|
||||||
// Setup a callback that will update the total_size label
|
// Setup a callback that will update the total_size label
|
||||||
// with the http ContentLength header number rather than
|
// with the http ContentLength header number rather than
|
||||||
// relying to the RSS feed.
|
// relying to the RSS feed.
|
||||||
update_total_size_callback(prog.clone(), media_machine.clone());
|
update_total_size_callback(&prog, &media_machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn on_download_clicked(ep: &EpisodeWidgetQuery, sender: Sender<Action>) -> Result<(), Error> {
|
fn on_download_clicked(ep: &EpisodeWidgetQuery, sender: &Sender<Action>) -> Result<(), Error> {
|
||||||
let pd = dbqueries::get_podcast_from_id(ep.podcast_id())?;
|
let pd = dbqueries::get_podcast_from_id(ep.podcast_id())?;
|
||||||
let download_fold = get_download_folder(&pd.title())?;
|
let download_fold = get_download_folder(&pd.title())?;
|
||||||
|
|
||||||
@ -258,8 +258,8 @@ fn on_download_clicked(ep: &EpisodeWidgetQuery, sender: Sender<Action>) -> Resul
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn on_play_bttn_clicked(
|
fn on_play_bttn_clicked(
|
||||||
episode: &mut EpisodeWidgetQuery,
|
episode: &mut EpisodeWidgetQuery,
|
||||||
title: Rc<RefCell<TitleMachine>>,
|
title: &Rc<RefCell<TitleMachine>>,
|
||||||
sender: Sender<Action>,
|
sender: &Sender<Action>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
open_uri(episode.rowid())?;
|
open_uri(episode.rowid())?;
|
||||||
episode.set_played_now()?;
|
episode.set_played_now()?;
|
||||||
@ -292,12 +292,12 @@ fn open_uri(rowid: i32) -> Result<(), Error> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(if_same_then_else))]
|
#[cfg_attr(feature = "cargo-clippy", allow(if_same_then_else))]
|
||||||
fn update_progressbar_callback(
|
fn update_progressbar_callback(
|
||||||
prog: Arc<Mutex<manager::Progress>>,
|
prog: &Arc<Mutex<manager::Progress>>,
|
||||||
media: Rc<RefCell<MediaMachine>>,
|
media: &Rc<RefCell<MediaMachine>>,
|
||||||
episode_rowid: i32,
|
episode_rowid: i32,
|
||||||
) {
|
) {
|
||||||
let callback = clone!(prog, media => move || {
|
let callback = clone!(prog, media => move || {
|
||||||
progress_bar_helper(prog.clone(), media.clone(), episode_rowid)
|
progress_bar_helper(&prog, &media, episode_rowid)
|
||||||
.unwrap_or(glib::Continue(false))
|
.unwrap_or(glib::Continue(false))
|
||||||
});
|
});
|
||||||
timeout_add(300, callback);
|
timeout_add(300, callback);
|
||||||
@ -306,8 +306,8 @@ fn update_progressbar_callback(
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[allow(if_same_then_else)]
|
#[allow(if_same_then_else)]
|
||||||
fn progress_bar_helper(
|
fn progress_bar_helper(
|
||||||
prog: Arc<Mutex<manager::Progress>>,
|
prog: &Arc<Mutex<manager::Progress>>,
|
||||||
media: Rc<RefCell<MediaMachine>>,
|
media: &Rc<RefCell<MediaMachine>>,
|
||||||
episode_rowid: i32,
|
episode_rowid: i32,
|
||||||
) -> Result<glib::Continue, Error> {
|
) -> Result<glib::Continue, Error> {
|
||||||
let (fraction, downloaded) = {
|
let (fraction, downloaded) = {
|
||||||
@ -354,19 +354,19 @@ fn progress_bar_helper(
|
|||||||
// relying to the RSS feed.
|
// relying to the RSS feed.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn update_total_size_callback(
|
fn update_total_size_callback(
|
||||||
prog: Arc<Mutex<manager::Progress>>,
|
prog: &Arc<Mutex<manager::Progress>>,
|
||||||
media: Rc<RefCell<MediaMachine>>,
|
media: &Rc<RefCell<MediaMachine>>,
|
||||||
) {
|
) {
|
||||||
let callback = clone!(prog, media => move || {
|
let callback = clone!(prog, media => move || {
|
||||||
total_size_helper(prog.clone(), media.clone()).unwrap_or(glib::Continue(true))
|
total_size_helper(&prog, &media).unwrap_or(glib::Continue(true))
|
||||||
});
|
});
|
||||||
timeout_add(500, callback);
|
timeout_add(500, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn total_size_helper(
|
fn total_size_helper(
|
||||||
prog: Arc<Mutex<manager::Progress>>,
|
prog: &Arc<Mutex<manager::Progress>>,
|
||||||
media: Rc<RefCell<MediaMachine>>,
|
media: &Rc<RefCell<MediaMachine>>,
|
||||||
) -> Result<glib::Continue, Error> {
|
) -> Result<glib::Continue, Error> {
|
||||||
// Get the total_bytes.
|
// Get the total_bytes.
|
||||||
let total_bytes = {
|
let total_bytes = {
|
||||||
|
|||||||
@ -214,7 +214,7 @@ impl DateMachine {
|
|||||||
use self::DateMachine::*;
|
use self::DateMachine::*;
|
||||||
|
|
||||||
let ts = Utc.timestamp(epoch, 0);
|
let ts = Utc.timestamp(epoch, 0);
|
||||||
let is_old = !(NOW.year() == ts.year());
|
let is_old = NOW.year() != ts.year();
|
||||||
|
|
||||||
match (self, is_old) {
|
match (self, is_old) {
|
||||||
// Into Usual
|
// Into Usual
|
||||||
|
|||||||
@ -97,7 +97,7 @@ impl HomeView {
|
|||||||
let view_ = view.clone();
|
let view_ = view.clone();
|
||||||
let func = move |ep: EpisodeWidgetQuery| {
|
let func = move |ep: EpisodeWidgetQuery| {
|
||||||
let epoch = ep.epoch();
|
let epoch = ep.epoch();
|
||||||
let widget = EpisodesViewWidget::new(ep, sender.clone());
|
let widget = EpisodesViewWidget::new(ep, &sender);
|
||||||
|
|
||||||
match split(&now_utc, i64::from(epoch)) {
|
match split(&now_utc, i64::from(epoch)) {
|
||||||
Today => add_to_box(&widget, &view_.today_list, &view_.today_box),
|
Today => add_to_box(&widget, &view_.today_list, &view_.today_box),
|
||||||
@ -202,13 +202,13 @@ impl Default for EpisodesViewWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EpisodesViewWidget {
|
impl EpisodesViewWidget {
|
||||||
fn new(episode: EpisodeWidgetQuery, sender: Sender<Action>) -> EpisodesViewWidget {
|
fn new(episode: EpisodeWidgetQuery, sender: &Sender<Action>) -> EpisodesViewWidget {
|
||||||
let builder =
|
let builder =
|
||||||
gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/episodes_view_widget.ui");
|
gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/episodes_view_widget.ui");
|
||||||
let container: gtk::Box = builder.get_object("container").unwrap();
|
let container: gtk::Box = builder.get_object("container").unwrap();
|
||||||
let image: gtk::Image = builder.get_object("cover").unwrap();
|
let image: gtk::Image = builder.get_object("cover").unwrap();
|
||||||
let pid = episode.podcast_id();
|
let pid = episode.podcast_id();
|
||||||
let ep = EpisodeWidget::new(episode, sender.clone());
|
let ep = EpisodeWidget::new(episode, sender);
|
||||||
|
|
||||||
let view = EpisodesViewWidget {
|
let view = EpisodesViewWidget {
|
||||||
container,
|
container,
|
||||||
|
|||||||
@ -71,7 +71,7 @@ impl ShowWidget {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(pd: Arc<Podcast>, sender: Sender<Action>) -> Rc<ShowWidget> {
|
pub fn new(pd: Arc<Podcast>, sender: Sender<Action>) -> Rc<ShowWidget> {
|
||||||
let mut pdw = ShowWidget::default();
|
let mut pdw = ShowWidget::default();
|
||||||
pdw.init(pd.clone(), sender.clone());
|
pdw.init(&pd, &sender);
|
||||||
let pdw = Rc::new(pdw);
|
let pdw = Rc::new(pdw);
|
||||||
populate_listbox(&pdw, pd, sender)
|
populate_listbox(&pdw, pd, sender)
|
||||||
.map_err(|err| error!("Failed to populate the listbox: {}", err))
|
.map_err(|err| error!("Failed to populate the listbox: {}", err))
|
||||||
@ -81,18 +81,18 @@ impl ShowWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn init(&mut self, pd: Arc<Podcast>, sender: Sender<Action>) {
|
pub fn init(&mut self, pd: &Arc<Podcast>, sender: &Sender<Action>) {
|
||||||
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/show_widget.ui");
|
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/show_widget.ui");
|
||||||
|
|
||||||
self.unsub
|
self.unsub
|
||||||
.connect_clicked(clone!(pd, sender => move |bttn| {
|
.connect_clicked(clone!(pd, sender => move |bttn| {
|
||||||
on_unsub_button_clicked(pd.clone(), bttn, sender.clone());
|
on_unsub_button_clicked(pd.clone(), bttn, &sender);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
self.set_description(pd.description());
|
self.set_description(pd.description());
|
||||||
self.podcast_id = Some(pd.id());
|
self.podcast_id = Some(pd.id());
|
||||||
|
|
||||||
self.set_cover(pd.clone())
|
self.set_cover(&pd)
|
||||||
.map_err(|err| error!("Failed to set a cover: {}", err))
|
.map_err(|err| error!("Failed to set a cover: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ impl ShowWidget {
|
|||||||
on_played_button_clicked(
|
on_played_button_clicked(
|
||||||
pd.clone(),
|
pd.clone(),
|
||||||
&episodes,
|
&episodes,
|
||||||
sender.clone()
|
&sender
|
||||||
)
|
)
|
||||||
}));
|
}));
|
||||||
self.settings.set_popover(&show_menu);
|
self.settings.set_popover(&show_menu);
|
||||||
@ -122,7 +122,7 @@ impl ShowWidget {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Set the show cover.
|
/// Set the show cover.
|
||||||
fn set_cover(&self, pd: Arc<Podcast>) -> Result<(), Error> {
|
fn set_cover(&self, pd: &Arc<Podcast>) -> Result<(), Error> {
|
||||||
utils::set_image_from_path(&self.cover, pd.id(), 256)
|
utils::set_image_from_path(&self.cover, pd.id(), 256)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ impl ShowWidget {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Set scrolled window vertical adjustment.
|
/// Set scrolled window vertical adjustment.
|
||||||
fn set_vadjustment(&self, pd: Arc<Podcast>) -> Result<(), Error> {
|
fn set_vadjustment(&self, pd: &Arc<Podcast>) -> Result<(), Error> {
|
||||||
let guard = SHOW_WIDGET_VALIGNMENT
|
let guard = SHOW_WIDGET_VALIGNMENT
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?;
|
.map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?;
|
||||||
@ -214,11 +214,11 @@ fn populate_listbox(
|
|||||||
let list = show_.episodes.clone();
|
let list = show_.episodes.clone();
|
||||||
|
|
||||||
let constructor = clone!(sender => move |ep| {
|
let constructor = clone!(sender => move |ep| {
|
||||||
EpisodeWidget::new(ep, sender.clone()).container
|
EpisodeWidget::new(ep, &sender).container
|
||||||
});
|
});
|
||||||
|
|
||||||
let callback = clone!(pd, show_ => move || {
|
let callback = clone!(pd, show_ => move || {
|
||||||
show_.set_vadjustment(pd.clone())
|
show_.set_vadjustment(&pd)
|
||||||
.map_err(|err| error!("Failed to set ShowWidget Alignment: {}", err))
|
.map_err(|err| error!("Failed to set ShowWidget Alignment: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
});
|
});
|
||||||
@ -232,7 +232,7 @@ fn populate_listbox(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn on_unsub_button_clicked(pd: Arc<Podcast>, unsub_button: >k::Button, sender: Sender<Action>) {
|
fn on_unsub_button_clicked(pd: Arc<Podcast>, unsub_button: >k::Button, sender: &Sender<Action>) {
|
||||||
// hack to get away without properly checking for none.
|
// hack to get away without properly checking for none.
|
||||||
// if pressed twice would panic.
|
// if pressed twice would panic.
|
||||||
unsub_button.set_sensitive(false);
|
unsub_button.set_sensitive(false);
|
||||||
@ -253,7 +253,7 @@ fn on_unsub_button_clicked(pd: Arc<Podcast>, unsub_button: >k::Button, sender:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn on_played_button_clicked(pd: Arc<Podcast>, episodes: >k::ListBox, sender: Sender<Action>) {
|
fn on_played_button_clicked(pd: Arc<Podcast>, episodes: >k::ListBox, sender: &Sender<Action>) {
|
||||||
if dim_titles(episodes).is_none() {
|
if dim_titles(episodes).is_none() {
|
||||||
error!("Something went horribly wrong when dimming the titles.");
|
error!("Something went horribly wrong when dimming the titles.");
|
||||||
warn!("RUN WHILE YOU STILL CAN!");
|
warn!("RUN WHILE YOU STILL CAN!");
|
||||||
@ -266,7 +266,7 @@ fn on_played_button_clicked(pd: Arc<Podcast>, episodes: >k::ListBox, sender: S
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mark_all_watched(pd: &Podcast, sender: Sender<Action>) -> Result<(), Error> {
|
fn mark_all_watched(pd: &Podcast, sender: &Sender<Action>) -> Result<(), Error> {
|
||||||
dbqueries::update_none_to_played_now(pd)?;
|
dbqueries::update_none_to_played_now(pd)?;
|
||||||
// Not all widgets migth have been loaded when the mark_all is hit
|
// Not all widgets migth have been loaded when the mark_all is hit
|
||||||
// So we will need to refresh again after it's done.
|
// So we will need to refresh again after it's done.
|
||||||
@ -275,10 +275,10 @@ fn mark_all_watched(pd: &Podcast, sender: Sender<Action>) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mark_all_notif(pd: Arc<Podcast>, sender: Sender<Action>) -> InAppNotification {
|
pub fn mark_all_notif(pd: Arc<Podcast>, sender: &Sender<Action>) -> InAppNotification {
|
||||||
let id = pd.id();
|
let id = pd.id();
|
||||||
let callback = clone!(sender => move || {
|
let callback = clone!(sender => move || {
|
||||||
mark_all_watched(&pd, sender.clone())
|
mark_all_watched(&pd, &sender)
|
||||||
.map_err(|err| error!("Notif Callback Error: {}", err))
|
.map_err(|err| error!("Notif Callback Error: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
glib::Continue(false)
|
glib::Continue(false)
|
||||||
@ -290,7 +290,7 @@ pub fn mark_all_notif(pd: Arc<Podcast>, sender: Sender<Action>) -> InAppNotifica
|
|||||||
.ok();
|
.ok();
|
||||||
});
|
});
|
||||||
|
|
||||||
let text = "Marked all episodes as listened".into();
|
let text = "Marked all episodes as listened";
|
||||||
InAppNotification::new(text, callback, undo_callback)
|
InAppNotification::new(text, callback, undo_callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ pub fn remove_show_notif(pd: Arc<Podcast>, sender: Sender<Action>) -> InAppNotif
|
|||||||
undo_wrap().map_err(|err| error!("{}", err)).ok();
|
undo_wrap().map_err(|err| error!("{}", err)).ok();
|
||||||
};
|
};
|
||||||
|
|
||||||
InAppNotification::new(text, callback, undo_callback)
|
InAppNotification::new(&text, callback, undo_callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@ -46,7 +46,7 @@ impl ShowsView {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn init(&self, sender: Sender<Action>) -> Result<(), Error> {
|
pub fn init(&self, sender: Sender<Action>) -> Result<(), Error> {
|
||||||
self.flowbox.connect_child_activated(move |_, child| {
|
self.flowbox.connect_child_activated(move |_, child| {
|
||||||
on_child_activate(child, sender.clone())
|
on_child_activate(child, &sender)
|
||||||
.map_err(|err| error!("Error along flowbox child activation: {}", err))
|
.map_err(|err| error!("Error along flowbox child activation: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
});
|
});
|
||||||
@ -71,7 +71,7 @@ impl ShowsView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn on_child_activate(child: >k::FlowBoxChild, sender: Sender<Action>) -> Result<(), Error> {
|
fn on_child_activate(child: >k::FlowBoxChild, sender: &Sender<Action>) -> Result<(), Error> {
|
||||||
use gtk::WidgetExt;
|
use gtk::WidgetExt;
|
||||||
|
|
||||||
// This is such an ugly hack...
|
// This is such an ugly hack...
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user