Completed functionality of the delete buttons.
This commit is contained in:
parent
0137e1e49b
commit
e6ceb86201
4
TODO.md
4
TODO.md
@ -35,9 +35,9 @@
|
|||||||
|
|
||||||
**DB changes:**
|
**DB changes:**
|
||||||
|
|
||||||
- [ ] Db episodes: add watched field
|
- [ ] episodes: add watched field
|
||||||
- [ ] Mark episodes/podcast for archival
|
- [ ] Mark episodes/podcast for archival
|
||||||
- [ ] Podcast deletion
|
- [x] Podcast deletion
|
||||||
- [ ] Download cleaner
|
- [ ] Download cleaner
|
||||||
- [ ] Mark stuff as Favorite. Maybe auto-archive favorites?
|
- [ ] Mark stuff as Favorite. Maybe auto-archive favorites?
|
||||||
- [ ] New episode notifier on podcast_flowbox_child, like the one vocal has
|
- [ ] New episode notifier on podcast_flowbox_child, like the one vocal has
|
||||||
|
|||||||
@ -172,11 +172,11 @@ mod tests {
|
|||||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||||
|
|
||||||
let firstitem = channel.items().first().unwrap();
|
let firstitem = channel.items().first().unwrap();
|
||||||
let descr = "NSA whistleblower Edward Snowden discusses the massive Equifax data \
|
let descr = "NSA whistleblower Edward Snowden discusses the massive Equifax data breach \
|
||||||
breach and allegations of Russian interference in the US election. \
|
and allegations of Russian interference in the US election. Commentator \
|
||||||
Commentator Shaun King explains his call for a boycott of the NFL and \
|
Shaun King explains his call for a boycott of the NFL and talks about his \
|
||||||
talks about his campaign to bring violent neo-Nazis to justice. Rapper \
|
campaign to bring violent neo-Nazis to justice. Rapper Open Mike Eagle \
|
||||||
Open Mike Eagle performs.";
|
performs.";
|
||||||
let i = parse_episode(&firstitem, 0);
|
let i = parse_episode(&firstitem, 0);
|
||||||
|
|
||||||
assert_eq!(i.title, Some("The Super Bowl of Racism"));
|
assert_eq!(i.title, Some("The Super Bowl of Racism"));
|
||||||
@ -251,9 +251,9 @@ mod tests {
|
|||||||
|
|
||||||
let second = channel.items().iter().nth(1).unwrap();
|
let second = channel.items().iter().nth(1).unwrap();
|
||||||
let i2 = parse_episode(&second, 0);
|
let i2 = parse_episode(&second, 0);
|
||||||
let descr2 = "<p>Jonathan Allen and Amie Parnes didn’t know their \
|
let descr2 = "<p>Jonathan Allen and Amie Parnes didn’t know their book would be called \
|
||||||
book would be called ‘Shattered,’ or that their extraordinary access would \
|
‘Shattered,’ or that their extraordinary access would let them chronicle \
|
||||||
let them chronicle the mounting signs of a doomed campaign.</p>";
|
the mounting signs of a doomed campaign.</p>";
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
i2.title,
|
i2.title,
|
||||||
@ -287,10 +287,10 @@ mod tests {
|
|||||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||||
|
|
||||||
let firstitem = channel.items().first().unwrap();
|
let firstitem = channel.items().first().unwrap();
|
||||||
let descr = "Audit your network with a couple of easy commands on Kali Linux. Chris \
|
let descr =
|
||||||
decides to blow off a little steam by attacking his IoT devices, Wes \
|
"Audit your network with a couple of easy commands on Kali Linux. Chris decides to \
|
||||||
has the scope on Equifax blaming open source & the Beard just saved \
|
blow off a little steam by attacking his IoT devices, Wes has the scope on Equifax \
|
||||||
the show. It’s a really packed episode!";
|
blaming open source & the Beard just saved the show. It’s a really packed episode!";
|
||||||
let i = parse_episode(&firstitem, 0);
|
let i = parse_episode(&firstitem, 0);
|
||||||
|
|
||||||
assert_eq!(i.title, Some("Hacking Devices with Kali Linux | LUP 214"));
|
assert_eq!(i.title, Some("Hacking Devices with Kali Linux | LUP 214"));
|
||||||
@ -313,8 +313,7 @@ mod tests {
|
|||||||
let descr2 = "<p>The Gnome project is about to solve one of our audience's biggest \
|
let descr2 = "<p>The Gnome project is about to solve one of our audience's biggest \
|
||||||
Wayland’s concerns. But as the project takes on a new level of relevance, \
|
Wayland’s concerns. But as the project takes on a new level of relevance, \
|
||||||
decisions for the next version of Gnome have us worried about the \
|
decisions for the next version of Gnome have us worried about the \
|
||||||
future.</p>\n\n\
|
future.</p>\n\n<p>Plus we chat with Wimpy about the Ubuntu Rally in NYC, \
|
||||||
<p>Plus we chat with Wimpy about the Ubuntu Rally in NYC, \
|
|
||||||
Microsoft’s sneaky move to turn Windows 10 into the “ULTIMATE LINUX \
|
Microsoft’s sneaky move to turn Windows 10 into the “ULTIMATE LINUX \
|
||||||
RUNTIME”, community news & more!</p>";
|
RUNTIME”, community news & more!</p>";
|
||||||
assert_eq!(i2.title, Some("Gnome Does it Again | LUP 213"));
|
assert_eq!(i2.title, Some("Gnome Does it Again | LUP 213"));
|
||||||
|
|||||||
@ -207,7 +207,7 @@ impl<'a> Source {
|
|||||||
{
|
{
|
||||||
self.http_etag = etag.map(|x| x.tag().to_string().to_owned());
|
self.http_etag = etag.map(|x| x.tag().to_string().to_owned());
|
||||||
self.last_modified = lmod.map(|x| format!("{}", x));
|
self.last_modified = lmod.map(|x| format!("{}", x));
|
||||||
self.save(&db)?;
|
self.save(db)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -59,7 +59,7 @@ fn populate_flowbox(db: &Database, stack: >k::Stack, flowbox: >k::FlowBox) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup_podcast_widget(db: &Database, stack: >k::Stack) {
|
fn setup_podcast_widget(db: &Database, stack: >k::Stack) {
|
||||||
let pd_widget = podcast_widget(db, None, None, None);
|
let pd_widget = podcast_widget(db, stack, None, None, None);
|
||||||
stack.add_named(&pd_widget, "pdw");
|
stack.add_named(&pd_widget, "pdw");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,15 @@ use gtk::prelude::*;
|
|||||||
use gtk;
|
use gtk;
|
||||||
use gdk_pixbuf::Pixbuf;
|
use gdk_pixbuf::Pixbuf;
|
||||||
|
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
use hammond_data::models::Podcast;
|
use hammond_data::models::Podcast;
|
||||||
use hammond_downloader::downloader;
|
use hammond_downloader::downloader;
|
||||||
use hammond_data::index_feed::Database;
|
use hammond_data::index_feed::Database;
|
||||||
use hammond_data::dbqueries::{load_podcast_from_title, remove_feed};
|
use hammond_data::dbqueries::{load_podcast_from_title, remove_feed};
|
||||||
|
|
||||||
use widgets::episode::episodes_listbox;
|
use widgets::episode::episodes_listbox;
|
||||||
|
use podcasts_view::update_podcasts_view;
|
||||||
|
|
||||||
// http://gtk-rs.org/tuto/closures
|
// http://gtk-rs.org/tuto/closures
|
||||||
macro_rules! clone {
|
macro_rules! clone {
|
||||||
@ -29,6 +32,7 @@ macro_rules! clone {
|
|||||||
|
|
||||||
pub fn podcast_widget(
|
pub fn podcast_widget(
|
||||||
db: &Database,
|
db: &Database,
|
||||||
|
stack: >k::Stack,
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
description: Option<&str>,
|
description: Option<&str>,
|
||||||
image: Option<Pixbuf>,
|
image: Option<Pixbuf>,
|
||||||
@ -44,22 +48,34 @@ pub fn podcast_widget(
|
|||||||
let view: gtk::Viewport = pd_widget_buidler.get_object("view").unwrap();
|
let view: gtk::Viewport = pd_widget_buidler.get_object("view").unwrap();
|
||||||
let unsub_button: gtk::Button = pd_widget_buidler.get_object("unsub_button").unwrap();
|
let unsub_button: gtk::Button = pd_widget_buidler.get_object("unsub_button").unwrap();
|
||||||
|
|
||||||
// TODO: handle unwraps properly.
|
// TODO: refactor, splitoff, spawn a thread probably.
|
||||||
// TODO: also remove the downloaded content.
|
|
||||||
if title.is_some() {
|
if title.is_some() {
|
||||||
let t = title.unwrap().to_owned();
|
let t = title.unwrap().to_owned();
|
||||||
// TODO: update the stack views after.
|
unsub_button.connect_clicked(clone!(db, stack, t => move |bttn| {
|
||||||
unsub_button.connect_clicked(clone!(db, t => move |bttn| {
|
|
||||||
let pd = {
|
let pd = {
|
||||||
let tempdb = db.lock().unwrap();
|
let tempdb = db.lock().unwrap();
|
||||||
load_podcast_from_title(&tempdb, &t).unwrap()};
|
load_podcast_from_title(&tempdb, &t)};
|
||||||
|
if let Ok(pd) = pd {
|
||||||
|
|
||||||
let res = remove_feed(&db, &pd);
|
let res = remove_feed(&db, &pd);
|
||||||
if res.is_ok(){
|
if res.is_ok(){
|
||||||
info!("{} was removed succesfully.", t);
|
info!("{} was removed succesfully.", &t);
|
||||||
// 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.
|
||||||
bttn.hide();
|
bttn.hide();
|
||||||
|
|
||||||
|
let dl_fold = downloader::get_download_folder(&t);
|
||||||
|
if let Ok(fold) = dl_fold{
|
||||||
|
let res3 = fs::remove_dir_all(&fold);
|
||||||
|
if res3.is_ok(){
|
||||||
|
info!("All the content at, {} was removed succesfully", &fold);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update_podcasts_view(&db, &stack);
|
||||||
|
stack.set_visible_child_name("pd_grid")
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +131,13 @@ pub fn on_flowbox_child_activate(
|
|||||||
pixbuf: Option<Pixbuf>,
|
pixbuf: Option<Pixbuf>,
|
||||||
) {
|
) {
|
||||||
let old = stack.get_child_by_name("pdw").unwrap();
|
let old = stack.get_child_by_name("pdw").unwrap();
|
||||||
let pdw = podcast_widget(db, Some(parent.title()), Some(parent.description()), pixbuf);
|
let pdw = podcast_widget(
|
||||||
|
db,
|
||||||
|
stack,
|
||||||
|
Some(parent.title()),
|
||||||
|
Some(parent.description()),
|
||||||
|
pixbuf,
|
||||||
|
);
|
||||||
|
|
||||||
stack.remove(&old);
|
stack.remove(&old);
|
||||||
stack.add_named(&pdw, "pdw");
|
stack.add_named(&pdw, "pdw");
|
||||||
|
|||||||
@ -20,7 +20,7 @@ spaces_within_parens = false
|
|||||||
write_mode = "Overwrite"
|
write_mode = "Overwrite"
|
||||||
merge_derives = true
|
merge_derives = true
|
||||||
condense_wildcard_suffixes = true
|
condense_wildcard_suffixes = true
|
||||||
# format_strings = true
|
format_strings = true
|
||||||
multiline_closure_forces_block = true
|
multiline_closure_forces_block = true
|
||||||
attributes_on_same_line_as_field = true
|
attributes_on_same_line_as_field = true
|
||||||
attributes_on_same_line_as_variant = true
|
attributes_on_same_line_as_variant = true
|
||||||
Loading…
Reference in New Issue
Block a user