AboutEpisode: Initial commit.
This commit is contained in:
parent
dea517c17c
commit
cd52c5afdf
@ -129,6 +129,18 @@ pub fn get_episode_local_uri_from_id(ep_id: i32) -> Result<Option<String>, DataE
|
|||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_episode_description(rowid_: i32) -> Result<Option<String>, DataError> {
|
||||||
|
use schema::episode::dsl::*;
|
||||||
|
let db = connection();
|
||||||
|
let con = db.get()?;
|
||||||
|
|
||||||
|
episode
|
||||||
|
.filter(rowid.eq(rowid_))
|
||||||
|
.select(description)
|
||||||
|
.get_result::<Option<String>>(&con)
|
||||||
|
.map_err(From::from)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_episodes_widgets_filter_limit(
|
pub fn get_episodes_widgets_filter_limit(
|
||||||
filter_ids: &[i32],
|
filter_ids: &[i32],
|
||||||
limit: u32,
|
limit: u32,
|
||||||
@ -360,7 +372,18 @@ pub(crate) fn episode_exists(title_: &str, podcast_id_: i32) -> Result<bool, Dat
|
|||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if the `episode table contains any rows
|
pub fn episode_had_description(rowid_: i32) -> Result<bool, DataError> {
|
||||||
|
use schema::episode::dsl::*;
|
||||||
|
|
||||||
|
let db = connection();
|
||||||
|
let con = db.get()?;
|
||||||
|
|
||||||
|
select(exists(episode.filter(rowid.eq(rowid_))))
|
||||||
|
.get_result(&con)
|
||||||
|
.map_err(From::from)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if the `episode` table contains any rows
|
||||||
///
|
///
|
||||||
/// Return true if `episode` table is populated.
|
/// Return true if `episode` table is populated.
|
||||||
pub fn is_episodes_populated() -> Result<bool, DataError> {
|
pub fn is_episodes_populated() -> Result<bool, DataError> {
|
||||||
|
|||||||
@ -207,41 +207,24 @@ Tobias Bernard
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="layout_style">center</property>
|
<property name="layout_style">center</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="cancel_button">
|
<object class="GtkButton" id="desc_button">
|
||||||
<property name="label" translatable="yes">Cancel</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">False</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">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="download_button">
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="tooltip_text" translatable="yes">Download this episode</property>
|
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="always_show_image">True</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="icon_name">document-save-symbolic</property>
|
<property name="icon_name">view-paged-symbolic</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">True</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">0</property>
|
||||||
<property name="non_homogeneous">True</property>
|
<property name="non_homogeneous">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@ -268,6 +251,45 @@ Tobias Bernard
|
|||||||
<property name="non_homogeneous">True</property>
|
<property name="non_homogeneous">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="download_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">Download this episode</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="always_show_image">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">document-save-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">3</property>
|
||||||
|
<property name="non_homogeneous">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="cancel_button">
|
||||||
|
<property name="label" translatable="yes">Cancel</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</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">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use gtk::prelude::*;
|
|||||||
use gtk::SettingsExt as GtkSettingsExt;
|
use gtk::SettingsExt as GtkSettingsExt;
|
||||||
|
|
||||||
use crossbeam_channel::{unbounded, Sender};
|
use crossbeam_channel::{unbounded, Sender};
|
||||||
use hammond_data::Podcast;
|
use hammond_data::{Podcast, dbqueries};
|
||||||
|
|
||||||
use headerbar::Header;
|
use headerbar::Header;
|
||||||
use settings::{self, WindowGeometry};
|
use settings::{self, WindowGeometry};
|
||||||
@ -53,6 +53,7 @@ pub enum Action {
|
|||||||
MarkAllPlayerNotification(Arc<Podcast>),
|
MarkAllPlayerNotification(Arc<Podcast>),
|
||||||
RemoveShow(Arc<Podcast>),
|
RemoveShow(Arc<Podcast>),
|
||||||
ErrorNotification(String),
|
ErrorNotification(String),
|
||||||
|
AboutWidget(i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -179,6 +180,13 @@ impl App {
|
|||||||
|| {}, UndoState::Hidden);
|
|| {}, UndoState::Hidden);
|
||||||
notif.show(&overlay);
|
notif.show(&overlay);
|
||||||
}
|
}
|
||||||
|
Ok(Action::AboutWidget(rowid)) => {
|
||||||
|
if let Ok(d) = dbqueries::get_episode_description(rowid) {
|
||||||
|
if let Some(_desc) = d {
|
||||||
|
let _stack = content.get_visible_stack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(_) => (),
|
Err(_) => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -85,4 +85,8 @@ impl Content {
|
|||||||
pub fn get_shows(&self) -> Rc<RefCell<ShowStack>> {
|
pub fn get_shows(&self) -> Rc<RefCell<ShowStack>> {
|
||||||
self.shows.clone()
|
self.shows.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_visible_stack(&self) -> Option<gtk::Stack> {
|
||||||
|
self.stack.get_visible_child().and_then(|w| w.downcast::<gtk::Stack>().ok())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,7 @@ struct Buttons {
|
|||||||
play: gtk::Button,
|
play: gtk::Button,
|
||||||
download: gtk::Button,
|
download: gtk::Button,
|
||||||
cancel: gtk::Button,
|
cancel: gtk::Button,
|
||||||
|
desc: gtk::Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InfoLabels {
|
impl InfoLabels {
|
||||||
@ -168,6 +169,7 @@ impl Default for EpisodeWidget {
|
|||||||
let download = builder.get_object("download_button").unwrap();
|
let download = builder.get_object("download_button").unwrap();
|
||||||
let play = builder.get_object("play_button").unwrap();
|
let play = builder.get_object("play_button").unwrap();
|
||||||
let cancel = builder.get_object("cancel_button").unwrap();
|
let cancel = builder.get_object("cancel_button").unwrap();
|
||||||
|
let desc_button = builder.get_object("desc_button").unwrap();
|
||||||
|
|
||||||
let info_container = builder.get_object("info_container").unwrap();
|
let info_container = builder.get_object("info_container").unwrap();
|
||||||
let title = builder.get_object("title_label").unwrap();
|
let title = builder.get_object("title_label").unwrap();
|
||||||
@ -198,6 +200,7 @@ impl Default for EpisodeWidget {
|
|||||||
play,
|
play,
|
||||||
download,
|
download,
|
||||||
cancel,
|
cancel,
|
||||||
|
desc: desc_button,
|
||||||
},
|
},
|
||||||
progressbar,
|
progressbar,
|
||||||
container,
|
container,
|
||||||
@ -213,6 +216,32 @@ impl EpisodeWidget {
|
|||||||
.map_err(|err| error!("Error: {}", err))
|
.map_err(|err| error!("Error: {}", err))
|
||||||
.ok();
|
.ok();
|
||||||
widget
|
widget
|
||||||
|
.on_desc_clicked(episode, sender)
|
||||||
|
.map_err(|err| error!("Error: {}", err))
|
||||||
|
.ok();
|
||||||
|
widget
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_desc_clicked(
|
||||||
|
&self,
|
||||||
|
episode: &EpisodeWidgetQuery,
|
||||||
|
sender: &Sender<Action>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let id = episode.rowid();
|
||||||
|
if dbqueries::episode_had_description(id)? {
|
||||||
|
self.buttons.desc.show();
|
||||||
|
self.buttons
|
||||||
|
.desc
|
||||||
|
.connect_clicked(clone!(sender => move |_| {
|
||||||
|
sender.send(Action::AboutWidget(id))
|
||||||
|
.map_err(|err| error!("Action Sender: {}", err))
|
||||||
|
.ok();
|
||||||
|
}));
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
self.buttons.desc.hide();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn init(widget: Rc<Self>, sender: &Sender<Action>) {}
|
// fn init(widget: Rc<Self>, sender: &Sender<Action>) {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user