Merge branch '47-mark-all-played' into 'master'
Resolve "Mark all episodes of a Show Feed as played." Closes #47 See merge request alatiera/Hammond!19
This commit is contained in:
commit
abe7215bc0
@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
* Ability to mark all episodes of a Show as watched. (#47)[https://gitlab.gnome.org/alatiera/Hammond/issues/47]
|
||||||
|
|
||||||
## [0.3.0] - 2018-02-11
|
## [0.3.0] - 2018-02-11
|
||||||
|
|
||||||
* Tobias Bernard Redesigned the whole Gtk+ client.
|
* Tobias Bernard Redesigned the whole Gtk+ client.
|
||||||
|
|||||||
@ -348,3 +348,29 @@ pub fn update_none_to_played_now(parent: &Podcast) -> Result<usize, DataError> {
|
|||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use database::*;
|
||||||
|
use pipeline::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_update_none_to_played_now() {
|
||||||
|
truncate_db().unwrap();
|
||||||
|
|
||||||
|
let url = "https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
|
||||||
|
com/InterceptedWithJeremyScahill";
|
||||||
|
let source = Source::from_url(url).unwrap();
|
||||||
|
let id = source.id();
|
||||||
|
index_single_source(source, true).unwrap();
|
||||||
|
let pd = get_podcast_from_source_id(id).unwrap();
|
||||||
|
|
||||||
|
let eps_num = get_pd_unplayed_episodes(&pd).unwrap().len();
|
||||||
|
assert_ne!(eps_num, 0);
|
||||||
|
|
||||||
|
update_none_to_played_now(&pd).unwrap();
|
||||||
|
let eps_num2 = get_pd_unplayed_episodes(&pd).unwrap().len();
|
||||||
|
assert_eq!(eps_num2, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -68,167 +68,250 @@ Tobias Bernard
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkOverlay">
|
||||||
<property name="width_request">600</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="margin_left">32</property>
|
|
||||||
<property name="margin_right">32</property>
|
|
||||||
<property name="margin_top">32</property>
|
|
||||||
<property name="margin_bottom">32</property>
|
|
||||||
<property name="hexpand">False</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">24</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
|
<property name="width_request">600</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="valign">center</property>
|
<property name="margin_left">32</property>
|
||||||
<property name="spacing">12</property>
|
<property name="margin_right">32</property>
|
||||||
<child>
|
<property name="margin_top">32</property>
|
||||||
<object class="GtkImage" id="cover">
|
<property name="margin_bottom">32</property>
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">False</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="pixel_size">128</property>
|
<property name="spacing">24</property>
|
||||||
<property name="icon_name">image-x-generic-symbolic</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="valign">end</property>
|
<property name="valign">center</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="spacing">12</property>
|
||||||
<property name="orientation">vertical</property>
|
<child>
|
||||||
<property name="spacing">6</property>
|
<object class="GtkImage" id="cover">
|
||||||
<child type="center">
|
|
||||||
<object class="GtkLabel" id="description">
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="halign">start</property>
|
<property name="pixel_size">128</property>
|
||||||
<property name="valign">end</property>
|
<property name="icon_name">image-x-generic-symbolic</property>
|
||||||
<property name="label" translatable="yes">Show description</property>
|
|
||||||
<property name="wrap">True</property>
|
|
||||||
<property name="wrap_mode">word-char</property>
|
|
||||||
<property name="max_width_chars">100</property>
|
|
||||||
<attributes>
|
|
||||||
<attribute name="weight" value="medium"/>
|
|
||||||
</attributes>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="position">1</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="valign">end</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child type="center">
|
||||||
<object class="GtkMenuButton" id="settings_button">
|
<object class="GtkLabel" id="description">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="halign">start</property>
|
||||||
<child>
|
<property name="valign">end</property>
|
||||||
<object class="GtkImage">
|
<property name="label" translatable="yes">Show description</property>
|
||||||
<property name="visible">True</property>
|
<property name="wrap">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="wrap_mode">word-char</property>
|
||||||
<property name="halign">center</property>
|
<property name="max_width_chars">100</property>
|
||||||
<property name="valign">center</property>
|
<attributes>
|
||||||
<property name="icon_name">emblem-system-symbolic</property>
|
<attribute name="weight" value="medium"/>
|
||||||
</object>
|
</attributes>
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">False</property>
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="link_button">
|
|
||||||
<property name="label" translatable="yes">Website</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="halign">center</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="padding">5</property>
|
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="unsub_button">
|
<object class="GtkBox">
|
||||||
<property name="label" translatable="yes">Unsubscribe</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="spacing">6</property>
|
||||||
<property name="halign">center</property>
|
<child>
|
||||||
<property name="valign">center</property>
|
<object class="GtkMenuButton" id="settings_button">
|
||||||
<style>
|
<property name="visible">True</property>
|
||||||
<class name="destructive-action"/>
|
<property name="can_focus">True</property>
|
||||||
</style>
|
<property name="receives_default">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="icon_name">emblem-system-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="link_button">
|
||||||
|
<property name="label" translatable="yes">Website</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="padding">5</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="unsub_button">
|
||||||
|
<property name="label" translatable="yes">Unsubscribe</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<style>
|
||||||
|
<class name="destructive-action"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="padding">5</property>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">False</property>
|
||||||
<property name="padding">5</property>
|
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
<property name="position">2</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">True</property>
|
||||||
<property name="pack_type">end</property>
|
<property name="position">1</property>
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">False</property>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkFrame" id="episodes">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="label_xalign">0</property>
|
||||||
|
<property name="shadow_type">in</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child type="label_item">
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="index">-1</property>
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child type="overlay">
|
||||||
<object class="GtkFrame" id="episodes">
|
<object class="GtkOverlay" id="inapp_notif_overlay">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="halign">center</property>
|
||||||
<property name="label_xalign">0</property>
|
<property name="valign">start</property>
|
||||||
<property name="shadow_type">in</property>
|
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<object class="GtkRevealer" id="notif_revealer">
|
||||||
</child>
|
<property name="visible">True</property>
|
||||||
<child type="label_item">
|
<property name="can_focus">False</property>
|
||||||
<placeholder/>
|
<child>
|
||||||
|
<object class="GtkFrame">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="label_xalign">0</property>
|
||||||
|
<property name="shadow_type">none</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="margin_top">6</property>
|
||||||
|
<property name="margin_bottom">6</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="notif_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="label" translatable="yes">An in-app action notification</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="undo_button">
|
||||||
|
<property name="label" translatable="yes">Undo</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="label_item">
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<style>
|
||||||
|
<class name="app-notification"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="index">-1</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
@ -266,4 +349,29 @@ Tobias Bernard
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkPopover" id="show_menu">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="position">bottom</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkModelButton" id="mark_all_watched">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="text" translatable="yes">Mark all epiodes as Watched</property>
|
||||||
|
<property name="centered">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
use dissolve;
|
use dissolve;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use glib;
|
||||||
use gtk;
|
use gtk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use open;
|
use open;
|
||||||
@ -12,6 +13,8 @@ use app::Action;
|
|||||||
use utils::get_pixbuf_from_path;
|
use utils::get_pixbuf_from_path;
|
||||||
use widgets::episode::episodes_listbox;
|
use widgets::episode::episodes_listbox;
|
||||||
|
|
||||||
|
use std::cell::RefCell;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
@ -26,6 +29,9 @@ pub struct ShowWidget {
|
|||||||
settings: gtk::MenuButton,
|
settings: gtk::MenuButton,
|
||||||
unsub: gtk::Button,
|
unsub: gtk::Button,
|
||||||
episodes: gtk::Frame,
|
episodes: gtk::Frame,
|
||||||
|
notif: gtk::Revealer,
|
||||||
|
notif_label: gtk::Label,
|
||||||
|
notif_undo: gtk::Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ShowWidget {
|
impl Default for ShowWidget {
|
||||||
@ -41,6 +47,10 @@ impl Default for ShowWidget {
|
|||||||
let link: gtk::Button = builder.get_object("link_button").unwrap();
|
let link: gtk::Button = builder.get_object("link_button").unwrap();
|
||||||
let settings: gtk::MenuButton = builder.get_object("settings_button").unwrap();
|
let settings: gtk::MenuButton = builder.get_object("settings_button").unwrap();
|
||||||
|
|
||||||
|
let notif: gtk::Revealer = builder.get_object("notif_revealer").unwrap();
|
||||||
|
let notif_label: gtk::Label = builder.get_object("notif_label").unwrap();
|
||||||
|
let notif_undo: gtk::Button = builder.get_object("undo_button").unwrap();
|
||||||
|
|
||||||
ShowWidget {
|
ShowWidget {
|
||||||
container,
|
container,
|
||||||
scrolled_window,
|
scrolled_window,
|
||||||
@ -50,6 +60,9 @@ impl Default for ShowWidget {
|
|||||||
link,
|
link,
|
||||||
settings,
|
settings,
|
||||||
episodes,
|
episodes,
|
||||||
|
notif,
|
||||||
|
notif_label,
|
||||||
|
notif_undo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,6 +75,8 @@ impl ShowWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&self, pd: Arc<Podcast>, sender: Sender<Action>) {
|
pub fn init(&self, pd: Arc<Podcast>, sender: Sender<Action>) {
|
||||||
|
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/show_widget.ui");
|
||||||
|
|
||||||
// Hacky workaround so the pd.id() can be retrieved from the `ShowStack`.
|
// Hacky workaround so the pd.id() can be retrieved from the `ShowStack`.
|
||||||
WidgetExt::set_name(&self.container, &pd.id().to_string());
|
WidgetExt::set_name(&self.container, &pd.id().to_string());
|
||||||
|
|
||||||
@ -88,6 +103,25 @@ impl ShowWidget {
|
|||||||
error!("Error: {}", err);
|
error!("Error: {}", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let show_menu: gtk::Popover = builder.get_object("show_menu").unwrap();
|
||||||
|
let mark_all: gtk::ModelButton = builder.get_object("mark_all_watched").unwrap();
|
||||||
|
|
||||||
|
let notif = self.notif.clone();
|
||||||
|
let notif_label = self.notif_label.clone();
|
||||||
|
let notif_undo = self.notif_undo.clone();
|
||||||
|
let episodes = self.episodes.clone();
|
||||||
|
mark_all.connect_clicked(clone!(pd, sender => move |_| {
|
||||||
|
on_played_button_clicked(
|
||||||
|
pd.clone(),
|
||||||
|
¬if,
|
||||||
|
¬if_label,
|
||||||
|
¬if_undo,
|
||||||
|
&episodes,
|
||||||
|
sender.clone()
|
||||||
|
)
|
||||||
|
}));
|
||||||
|
self.settings.set_popover(&show_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Populate the listbox with the shows episodes.
|
/// Populate the listbox with the shows episodes.
|
||||||
@ -142,9 +176,83 @@ fn on_unsub_button_clicked(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
fn on_played_button_clicked(
|
||||||
fn on_played_button_clicked(pd: &Podcast, sender: Sender<Action>) -> Result<(), Error> {
|
pd: Arc<Podcast>,
|
||||||
|
notif: >k::Revealer,
|
||||||
|
label: >k::Label,
|
||||||
|
undo: >k::Button,
|
||||||
|
episodes: >k::Frame,
|
||||||
|
sender: Sender<Action>,
|
||||||
|
) {
|
||||||
|
if dim_titles(episodes).is_none() {
|
||||||
|
error!("Something went horribly wrong when dimming the titles.");
|
||||||
|
warn!("RUN WHILE YOU STILL CAN!");
|
||||||
|
}
|
||||||
|
|
||||||
|
label.set_text("All episodes where marked as watched.");
|
||||||
|
notif.set_reveal_child(true);
|
||||||
|
|
||||||
|
// Set up the callback
|
||||||
|
let id = timeout_add_seconds(
|
||||||
|
10,
|
||||||
|
clone!(sender => move || {
|
||||||
|
if let Err(err) = wrap(&pd, sender.clone()) {
|
||||||
|
error!(
|
||||||
|
"Something went horribly wrong with the notif callback: {}",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
glib::Continue(false)
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
let id = Rc::new(RefCell::new(Some(id)));
|
||||||
|
|
||||||
|
// Cancel the callback
|
||||||
|
undo.connect_clicked(clone!(id, notif, sender => move |_| {
|
||||||
|
let foo = id.borrow_mut().take();
|
||||||
|
if let Some(id) = foo {
|
||||||
|
glib::source::source_remove(id);
|
||||||
|
notif.set_reveal_child(false);
|
||||||
|
if let Err(err) = sender.send(Action::RefreshWidgetIfVis) {
|
||||||
|
error!("Something went horribly wrong with the Action channel: {}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wrap(pd: &Podcast, sender: Sender<Action>) -> Result<(), Error> {
|
||||||
dbqueries::update_none_to_played_now(pd)?;
|
dbqueries::update_none_to_played_now(pd)?;
|
||||||
sender.send(Action::RefreshWidget)?;
|
sender.send(Action::RefreshWidgetIfVis)?;
|
||||||
|
sender.send(Action::RefreshEpisodesView)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ideally if we had a custom widget this would have been as simple as:
|
||||||
|
// `for row in listbox { ep = row.get_episode(); ep.dim_title(); }`
|
||||||
|
// But now I can't think of a better way to do it than hardcoding the title
|
||||||
|
// position relative to the EpisodeWidget container gtk::Box.
|
||||||
|
fn dim_titles(episodes: >k::Frame) -> Option<()> {
|
||||||
|
let listbox = episodes
|
||||||
|
.get_children()
|
||||||
|
.remove(0)
|
||||||
|
.downcast::<gtk::ListBox>()
|
||||||
|
.ok()?;
|
||||||
|
let children = listbox.get_children();
|
||||||
|
|
||||||
|
for row in children {
|
||||||
|
let row = row.downcast::<gtk::ListBoxRow>().ok()?;
|
||||||
|
let container = row.get_children().remove(0).downcast::<gtk::Box>().ok()?;
|
||||||
|
let foo = container
|
||||||
|
.get_children()
|
||||||
|
.remove(0)
|
||||||
|
.downcast::<gtk::Box>()
|
||||||
|
.ok()?;
|
||||||
|
let bar = foo.get_children().remove(0).downcast::<gtk::Box>().ok()?;
|
||||||
|
let baz = bar.get_children().remove(0).downcast::<gtk::Box>().ok()?;
|
||||||
|
let title = baz.get_children().remove(0).downcast::<gtk::Label>().ok()?;
|
||||||
|
|
||||||
|
title.get_style_context().map(|c| c.add_class("dim-label"));
|
||||||
|
}
|
||||||
|
Some(())
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user