Wired playbutton to use xdg-open for the files.
This commit is contained in:
parent
e3c1464a67
commit
80f0f138f3
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -12,6 +12,7 @@ dependencies = [
|
||||
"hammond-downloader 0.1.0",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"loggerv 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -940,6 +941,11 @@ dependencies = [
|
||||
"libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "open"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.9.20"
|
||||
@ -1703,6 +1709,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01"
|
||||
"checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0"
|
||||
"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d"
|
||||
"checksum open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113"
|
||||
"checksum openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf434ff6117485dc16478d77a4f5c84eccc9c3645c4da8323b287ad6a15a638"
|
||||
"checksum openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad395f1cee51b64a8d07cc8063498dc7554db62d5f3ca87a67f4eed2791d0c8"
|
||||
"checksum pango 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5afa4b4c5380315b12075e7767d9bdd62d53beeb6087d9287ef6990e57a6b643"
|
||||
|
||||
@ -14,6 +14,7 @@ gdk-pixbuf = "0.2"
|
||||
diesel = { version = "0.16", features = ["sqlite"] }
|
||||
loggerv = "0.3"
|
||||
log = "0.3"
|
||||
open = "1.2"
|
||||
|
||||
hammond-data = {path = "../hammond-data"}
|
||||
hammond-downloader = {path = "../hammond-downloader"}
|
||||
|
||||
@ -83,7 +83,6 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="play_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="valign">center</property>
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
// extern crate glib;
|
||||
extern crate diesel;
|
||||
|
||||
extern crate gdk;
|
||||
extern crate gdk_pixbuf;
|
||||
extern crate gio;
|
||||
extern crate gtk;
|
||||
|
||||
extern crate diesel;
|
||||
extern crate hammond_data;
|
||||
extern crate hammond_downloader;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate loggerv;
|
||||
extern crate open;
|
||||
|
||||
use log::LogLevel;
|
||||
use diesel::prelude::*;
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::models::Episode;
|
||||
|
||||
use std::rc;
|
||||
use std::thread;
|
||||
@ -109,14 +111,14 @@ fn podcast_widget(
|
||||
pd_widget
|
||||
}
|
||||
|
||||
fn epidose_widget(title: Option<&str>, description: Option<&str>) -> gtk::Box {
|
||||
fn epidose_widget(episode: &Episode) -> gtk::Box {
|
||||
// This is just a prototype and will be reworked probably.
|
||||
let builder = include_str!("../gtk/EpisodeWidget.ui");
|
||||
let builder = gtk::Builder::new_from_string(builder);
|
||||
|
||||
let ep: gtk::Box = builder.get_object("episode_box").unwrap();
|
||||
let _dl_button: gtk::Button = builder.get_object("download_button").unwrap();
|
||||
let _play_button: gtk::Button = builder.get_object("play_button").unwrap();
|
||||
let dl_button: gtk::Button = builder.get_object("download_button").unwrap();
|
||||
let play_button: gtk::Button = builder.get_object("play_button").unwrap();
|
||||
|
||||
let title_label: gtk::Label = builder.get_object("title_label").unwrap();
|
||||
let desc_label: gtk::Label = builder.get_object("desc_label").unwrap();
|
||||
@ -124,14 +126,26 @@ fn epidose_widget(title: Option<&str>, description: Option<&str>) -> gtk::Box {
|
||||
title_label.set_xalign(0.0);
|
||||
desc_label.set_xalign(0.0);
|
||||
|
||||
if let Some(t) = title {
|
||||
if let Some(t) = episode.title() {
|
||||
title_label.set_text(t);
|
||||
}
|
||||
|
||||
if let Some(d) = description {
|
||||
if let Some(d) = episode.description() {
|
||||
desc_label.set_text(d);
|
||||
}
|
||||
|
||||
if let Some(_) = episode.local_uri() {
|
||||
dl_button.hide();
|
||||
play_button.show();
|
||||
let uri = episode.local_uri().unwrap().to_owned();
|
||||
play_button.connect_clicked(move |_| {
|
||||
let e = open::that(&uri);
|
||||
if e.is_err() {
|
||||
error!("Error while trying to open: {}", uri);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ep
|
||||
}
|
||||
|
||||
@ -141,7 +155,7 @@ fn episodes_listbox(connection: &SqliteConnection, pd_title: &str) -> gtk::ListB
|
||||
|
||||
let list = gtk::ListBox::new();
|
||||
episodes.iter().for_each(|ep| {
|
||||
let w = epidose_widget(ep.title(), ep.description());
|
||||
let w = epidose_widget(ep);
|
||||
list.add(&w)
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user