Cleaned up unnecessary clone() calls.
This commit is contained in:
parent
64cd388aeb
commit
90c637ed53
@ -124,8 +124,9 @@ pub fn get_episode(connection: &SqliteConnection, ep: &mut Episode, dl_folder: &
|
||||
|
||||
let uri = ep.uri().to_owned();
|
||||
|
||||
// This would not be needed in general but I want to be able to block the
|
||||
// a higher order thread in src/widgets/episode.rs epsode.
|
||||
// This would not be needed in general but I want to be able to call
|
||||
// this function from the gtk client.
|
||||
// should get removed probably once custom callbacks are implemented.
|
||||
thread::spawn(move || {
|
||||
let res = download_to(&dlpath, uri.as_str());
|
||||
if let Err(err) = res {
|
||||
|
||||
@ -40,7 +40,7 @@ pub fn get_headerbar(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) -> g
|
||||
info!("{:?} feed added", url);
|
||||
if let Ok(mut source) = f {
|
||||
// update the db
|
||||
utils::refresh_feed(&db_clone.clone(), &stack_clone.clone(), &mut source);
|
||||
utils::refresh_feed(&db_clone, &stack_clone, &mut source);
|
||||
} else {
|
||||
error!("Expected Error, feed probably already exists.");
|
||||
error!("Error: {:?}", f.unwrap_err());
|
||||
@ -66,7 +66,7 @@ pub fn get_headerbar(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) -> g
|
||||
// FIXME: There appears to be a memmory leak here.
|
||||
refresh_button.connect_clicked(move |_| {
|
||||
// fsdaa, The things I do for the borrow checker.
|
||||
utils::refresh_db(&db_clone.clone(), &stack_clone.clone());
|
||||
utils::refresh_db(&db_clone, &stack_clone);
|
||||
});
|
||||
|
||||
header
|
||||
|
||||
@ -43,7 +43,7 @@ fn build_ui(app: >k::Application) {
|
||||
window.set_default_size(1050, 600);
|
||||
app.add_window(&window);
|
||||
// Setup the Stack that will magane the switche between podcasts_view and podcast_widget.
|
||||
let stack = podcasts_view::setup_stack(&db.clone());
|
||||
let stack = podcasts_view::setup_stack(&db);
|
||||
window.add(&stack);
|
||||
|
||||
// FIXME:
|
||||
@ -55,9 +55,9 @@ fn build_ui(app: >k::Application) {
|
||||
});
|
||||
|
||||
// Get the headerbar
|
||||
let header = headerbar::get_headerbar(&db.clone(), &stack.clone());
|
||||
let header = headerbar::get_headerbar(&db, &stack);
|
||||
// Uncomment this when etag implementation is fixed and refesh_db thread is non blocking.
|
||||
// utils::refresh_db(db.clone(), stack.clone());
|
||||
// utils::refresh_db(&db, &stack);
|
||||
window.set_titlebar(&header);
|
||||
|
||||
window.show_all();
|
||||
|
||||
@ -17,7 +17,7 @@ use views::podcasts_view;
|
||||
pub fn refresh_db(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) {
|
||||
let db_clone = db.clone();
|
||||
let handle = thread::spawn(move || {
|
||||
let t = hammond_data::index_feed::index_loop(&db_clone.clone(), false);
|
||||
let t = hammond_data::index_feed::index_loop(&db_clone, false);
|
||||
if t.is_err() {
|
||||
error!("Error While trying to update the database.");
|
||||
error!("Error msg: {}", t.unwrap_err());
|
||||
@ -28,24 +28,20 @@ pub fn refresh_db(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) {
|
||||
// TODO: emit a signal in order to update the podcast widget.
|
||||
let _ = handle.join();
|
||||
|
||||
podcasts_view::update_podcasts_view(&db.clone(), &stack.clone());
|
||||
podcasts_view::update_podcasts_view(&db, &stack);
|
||||
}
|
||||
|
||||
pub fn refresh_feed(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack, source: &mut Source) {
|
||||
let db_clone = db.clone();
|
||||
let source_ = source.clone();
|
||||
let mut source_ = source.clone();
|
||||
// TODO: add timeout option and error reporting.
|
||||
let handle = thread::spawn(move || {
|
||||
let db_ = db_clone.lock().unwrap();
|
||||
let foo_ = hammond_data::index_feed::refresh_source(&db_, &mut source_.clone(), false);
|
||||
let foo_ = hammond_data::index_feed::refresh_source(&db_, &mut source_, false);
|
||||
drop(db_);
|
||||
|
||||
if let Ok((mut req, s)) = foo_ {
|
||||
let s = hammond_data::index_feed::complete_index_from_source(
|
||||
&mut req,
|
||||
&s,
|
||||
&db_clone.clone(),
|
||||
);
|
||||
let s = hammond_data::index_feed::complete_index_from_source(&mut req, &s, &db_clone);
|
||||
if s.is_err() {
|
||||
error!("Error While trying to update the database.");
|
||||
error!("Error msg: {}", s.unwrap_err());
|
||||
@ -57,7 +53,7 @@ pub fn refresh_feed(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack, sourc
|
||||
// TODO: emit a signal in order to update the podcast widget.
|
||||
let _ = handle.join();
|
||||
|
||||
podcasts_view::update_podcasts_view(&db.clone(), &stack.clone());
|
||||
podcasts_view::update_podcasts_view(&db, &stack);
|
||||
}
|
||||
|
||||
// https://github.
|
||||
|
||||
@ -51,7 +51,7 @@ pub fn populate_podcasts_flowbox(
|
||||
f.connect_activate(move |_| {
|
||||
let old = stack_clone.get_child_by_name("pdw").unwrap();
|
||||
let pdw = podcast_widget(
|
||||
&db_clone.clone(),
|
||||
&db_clone,
|
||||
Some(title.as_str()),
|
||||
description.as_ref().map(|x| x.as_str()),
|
||||
pixbuf.clone(),
|
||||
@ -72,7 +72,7 @@ pub fn populate_podcasts_flowbox(
|
||||
}
|
||||
|
||||
fn setup_podcast_widget(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) {
|
||||
let pd_widget = podcast_widget(&db.clone(), None, None, None);
|
||||
let pd_widget = podcast_widget(&db, None, None, None);
|
||||
stack.add_named(&pd_widget, "pdw");
|
||||
}
|
||||
|
||||
@ -87,14 +87,14 @@ fn setup_podcasts_grid(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) {
|
||||
// FIXME: flowbox childs activate with space/enter but not with clicks.
|
||||
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
|
||||
// Populate the flowbox with the Podcasts.
|
||||
populate_podcasts_flowbox(&db.clone(), &stack.clone(), &flowbox.clone());
|
||||
populate_podcasts_flowbox(&db, &stack, &flowbox);
|
||||
}
|
||||
|
||||
pub fn setup_stack(db: &Arc<Mutex<SqliteConnection>>) -> gtk::Stack {
|
||||
let stack = gtk::Stack::new();
|
||||
let _st_clone = stack.clone();
|
||||
setup_podcast_widget(&db.clone(), &stack.clone());
|
||||
setup_podcasts_grid(&db.clone(), &stack.clone());
|
||||
// let _st_clone = stack.clone();
|
||||
setup_podcast_widget(&db, &stack);
|
||||
setup_podcasts_grid(&db, &stack);
|
||||
// stack.connect("foo", true, move |_| {
|
||||
// update_podcasts_view(db.clone(), st_clone.clone());
|
||||
// None
|
||||
@ -109,7 +109,7 @@ pub fn update_podcasts_view(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stac
|
||||
|
||||
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
|
||||
// Populate the flowbox with the Podcasts.
|
||||
populate_podcasts_flowbox(&db.clone(), &stack.clone(), &flowbox.clone());
|
||||
populate_podcasts_flowbox(&db, &stack, &flowbox);
|
||||
|
||||
let old = stack.get_child_by_name("pd_grid").unwrap();
|
||||
stack.remove(&old);
|
||||
|
||||
@ -84,7 +84,7 @@ fn epidose_widget(
|
||||
// TODO: emit a signal and show notification when dl is finished and block play_bttn till
|
||||
// then.
|
||||
thread::spawn(move || {
|
||||
let dl_fold = downloader::get_dl_folder(&pd_title.clone()).unwrap();
|
||||
let dl_fold = downloader::get_dl_folder(&pd_title).unwrap();
|
||||
let tempdb = db_clone.lock().unwrap();
|
||||
let e = downloader::get_episode(&tempdb, &mut ep_clone, dl_fold.as_str());
|
||||
drop(tempdb);
|
||||
@ -109,7 +109,7 @@ pub fn episodes_listbox(connection: &Arc<Mutex<SqliteConnection>>, pd_title: &st
|
||||
|
||||
let list = gtk::ListBox::new();
|
||||
episodes.iter_mut().for_each(|ep| {
|
||||
let w = epidose_widget(&connection.clone(), ep, pd_title);
|
||||
let w = epidose_widget(&connection, ep, pd_title);
|
||||
list.add(&w)
|
||||
});
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ pub fn podcast_liststore(connection: &SqliteConnection) -> gtk::ListStore {
|
||||
|
||||
pub fn pd_widget_from_diesel_model(db: &Arc<Mutex<SqliteConnection>>, pd: &Podcast) -> gtk::Box {
|
||||
let img = get_pixbuf_from_path(pd.image_uri(), pd.title());
|
||||
podcast_widget(&db.clone(), Some(pd.title()), Some(pd.description()), img)
|
||||
podcast_widget(&db, Some(pd.title()), Some(pd.description()), img)
|
||||
}
|
||||
|
||||
pub fn get_pixbuf_from_path(img_path: Option<&str>, pd_title: &str) -> Option<Pixbuf> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user