Overall impromvment into episode_widget.
Parse html into plain text for the episode widget. Implement on per episode/child description evaluation. Minor episode_widget tweaks.
This commit is contained in:
@@ -15,6 +15,7 @@ diesel = { version = "0.16", features = ["sqlite"] }
|
||||
loggerv = "0.3"
|
||||
log = "0.3"
|
||||
open = "1.2"
|
||||
dissolve = "0.1.3"
|
||||
|
||||
hammond-data = {path = "../hammond-data"}
|
||||
hammond-downloader = {path = "../hammond-downloader"}
|
||||
|
||||
@@ -33,26 +33,53 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="desc_label">
|
||||
<object class="GtkExpander" id="expand_desc">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="ellipsize">end</property>
|
||||
<property name="lines">3</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label_fill">True</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<property name="min_content_height">60</property>
|
||||
<property name="max_content_height">400</property>
|
||||
<property name="propagate_natural_height">True</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="desc_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="wrap">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Description:</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
|
||||
@@ -12,6 +12,7 @@ extern crate hammond_downloader;
|
||||
extern crate log;
|
||||
extern crate loggerv;
|
||||
extern crate open;
|
||||
extern crate dissolve;
|
||||
|
||||
use log::LogLevel;
|
||||
use hammond_data::index_feed;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// use glib;
|
||||
|
||||
use hammond_data;
|
||||
use diesel::prelude::SqliteConnection;
|
||||
|
||||
@@ -14,3 +16,23 @@ pub fn refresh_db(db: Arc<Mutex<SqliteConnection>>) {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// https://github.
|
||||
// com/needle-and-thread/vocal/blob/8b21f1c18c2be32921e84e289576a659ab3c8f2e/src/Utils/Utils.
|
||||
// vala#L136
|
||||
// TODO:
|
||||
// pub fn html_to_markup(s: String) -> String {
|
||||
// let markup = glib::uri_escape_string(s.as_str(), None, true);
|
||||
|
||||
// let markup = if let Some(m) = markup {
|
||||
// m
|
||||
// } else {
|
||||
// warn!("unable to unescape markup: {}", s);
|
||||
// s
|
||||
// };
|
||||
// // let markup = s;
|
||||
|
||||
|
||||
// info!("{}", markup);
|
||||
// markup
|
||||
// }
|
||||
|
||||
@@ -3,6 +3,10 @@ use diesel::prelude::SqliteConnection;
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::models::Episode;
|
||||
use hammond_downloader::downloader;
|
||||
// use html5ever::parse_document;
|
||||
// use html5ever::rcdom::RcDom;
|
||||
// use tendril::stream::TendrilSink;
|
||||
use dissolve::strip_html_tags;
|
||||
|
||||
use std::thread;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -10,6 +14,8 @@ use std::sync::{Arc, Mutex};
|
||||
use gtk;
|
||||
use gtk::prelude::*;
|
||||
|
||||
// use utils;
|
||||
|
||||
fn epidose_widget(
|
||||
connection: Arc<Mutex<SqliteConnection>>,
|
||||
episode: &mut Episode,
|
||||
@@ -25,6 +31,7 @@ fn epidose_widget(
|
||||
|
||||
let title_label: gtk::Label = builder.get_object("title_label").unwrap();
|
||||
let desc_label: gtk::Label = builder.get_object("desc_label").unwrap();
|
||||
let expander: gtk::Expander = builder.get_object("expand_desc").unwrap();
|
||||
|
||||
title_label.set_xalign(0.0);
|
||||
desc_label.set_xalign(0.0);
|
||||
@@ -33,8 +40,15 @@ fn epidose_widget(
|
||||
title_label.set_text(t);
|
||||
}
|
||||
|
||||
if let Some(d) = episode.description() {
|
||||
desc_label.set_text(d);
|
||||
if episode.description().is_some() {
|
||||
// let mk = utils::html_to_markup(d.to_string());
|
||||
// desc_label.set_markup(mk.as_str());
|
||||
let d = episode.description().unwrap().to_owned();
|
||||
|
||||
expander.connect_activate(move |_|{
|
||||
let plain_text = strip_html_tags(&d).join(" ");
|
||||
desc_label.set_text(&plain_text.trim())
|
||||
});
|
||||
}
|
||||
|
||||
if episode.local_uri().is_some() {
|
||||
|
||||
Reference in New Issue
Block a user