Fixed Another play button fuckup.
This commit is contained in:
parent
f9c5ff5e8c
commit
b2a8091f05
@ -1,5 +1,6 @@
|
|||||||
#![recursion_limit = "1024"]
|
#![recursion_limit = "1024"]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))]
|
#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate error_chain;
|
extern crate error_chain;
|
||||||
@ -55,14 +56,10 @@ lazy_static!{
|
|||||||
};
|
};
|
||||||
|
|
||||||
static ref DB_PATH: PathBuf = {
|
static ref DB_PATH: PathBuf = {
|
||||||
// Ensure that xdg_data is created.
|
|
||||||
&HAMMOND_DATA;
|
|
||||||
|
|
||||||
HAMMOND_XDG.place_data_file("hammond.db").unwrap()
|
HAMMOND_XDG.place_data_file("hammond.db").unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static ref DL_DIR: PathBuf = {
|
pub static ref DL_DIR: PathBuf = {
|
||||||
&HAMMOND_DATA;
|
|
||||||
HAMMOND_XDG.create_data_directory("Downloads").unwrap()
|
HAMMOND_XDG.create_data_directory("Downloads").unwrap()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,17 +58,17 @@ fn epidose_widget(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if episode.local_uri().is_some() {
|
// Show play button upon widget initialization.
|
||||||
|
let local_uri = episode.local_uri();
|
||||||
|
if local_uri.is_some() && Path::new(local_uri.unwrap()).exists() {
|
||||||
dl_button.hide();
|
dl_button.hide();
|
||||||
play_button.show();
|
play_button.show();
|
||||||
};
|
}
|
||||||
|
|
||||||
let ep_clone = episode.clone();
|
let ep_clone = episode.clone();
|
||||||
let db = connection.clone();
|
let db = connection.clone();
|
||||||
let play_button_clone = play_button.clone();
|
|
||||||
play_button.connect_clicked(move |_| {
|
play_button.connect_clicked(move |_| {
|
||||||
// info!("I RUN");
|
on_play_bttn_clicked(&db, ep_clone.id());
|
||||||
on_play_bttn_clicked(&db, ep_clone.id(), &play_button_clone);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: figure out how to use the gtk-clone macro,
|
// TODO: figure out how to use the gtk-clone macro,
|
||||||
@ -77,13 +77,12 @@ fn epidose_widget(
|
|||||||
let db = connection.clone();
|
let db = connection.clone();
|
||||||
let ep_clone = episode.clone();
|
let ep_clone = episode.clone();
|
||||||
let play_button_clone = play_button.clone();
|
let play_button_clone = play_button.clone();
|
||||||
let dl_button_clone = dl_button.clone();
|
dl_button.connect_clicked(move |dl| {
|
||||||
dl_button.connect_clicked(move |_| {
|
|
||||||
on_dl_clicked(
|
on_dl_clicked(
|
||||||
&db,
|
&db,
|
||||||
&pd_title_clone,
|
&pd_title_clone,
|
||||||
&mut ep_clone.clone(),
|
&mut ep_clone.clone(),
|
||||||
&dl_button_clone,
|
dl,
|
||||||
&play_button_clone,
|
&play_button_clone,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -122,31 +121,28 @@ fn on_dl_clicked(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_play_bttn_clicked(
|
fn on_play_bttn_clicked(db: &Arc<Mutex<SqliteConnection>>, episode_id: i32) {
|
||||||
db: &Arc<Mutex<SqliteConnection>>,
|
|
||||||
episode_id: i32,
|
|
||||||
play_button: >k::Button,
|
|
||||||
) {
|
|
||||||
let local_uri = {
|
let local_uri = {
|
||||||
let tempdb = db.lock().unwrap();
|
let tempdb = db.lock().unwrap();
|
||||||
dbqueries::get_episode_local_uri(&tempdb, episode_id).unwrap()
|
dbqueries::get_episode_local_uri(&tempdb, episode_id).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Local_uri: {:?}", local_uri);
|
|
||||||
if local_uri.is_some() {
|
if local_uri.is_some() {
|
||||||
let uri = local_uri.unwrap().to_owned();
|
let uri = local_uri.unwrap().to_owned();
|
||||||
|
|
||||||
if Path::new(&uri).exists() {
|
if Path::new(&uri).exists() {
|
||||||
play_button.show();
|
info!("Opening {}", uri);
|
||||||
play_button.connect_clicked(move |_| {
|
let e = open::that(&uri);
|
||||||
let e = open::that(&uri);
|
if let Err(err) = e {
|
||||||
if e.is_err() {
|
error!("Error while trying to open file: {}", uri);
|
||||||
error!("Error while trying to open: {}", uri);
|
error!("Error: {}", err);
|
||||||
}
|
};
|
||||||
});
|
|
||||||
} else {
|
|
||||||
()
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
error!(
|
||||||
|
"Something went wrong evaluating the following path: {:?}",
|
||||||
|
local_uri
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user