...
 
Commits (1)
......@@ -129,6 +129,18 @@ pub fn get_episode_local_uri_from_id(ep_id: i32) -> Result<Option<String>, DataE
.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(
filter_ids: &[i32],
limit: u32,
......@@ -360,7 +372,18 @@ pub(crate) fn episode_exists(title_: &str, podcast_id_: i32) -> Result<bool, Dat
.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.
pub fn is_episodes_populated() -> Result<bool, DataError> {
......
......@@ -207,67 +207,89 @@ Tobias Bernard
<property name="can_focus">False</property>
<property name="layout_style">center</property>
<child>
<object class="GtkButton" id="cancel_button">
<property name="label" translatable="yes">Cancel</property>
<object class="GtkButton" id="desc_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-paged-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="download_button">
<property name="visible">True</property>
<object class="GtkButton" id="play_button">
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Download this episode</property>
<property name="no_show_all">True</property>
<property name="tooltip_text" translatable="yes">Play 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>
<property name="icon_name">media-playback-start-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">2</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="play_button">
<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="no_show_all">True</property>
<property name="tooltip_text" translatable="yes">Play this episode</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">media-playback-start-symbolic</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">2</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>
<packing>
<property name="expand">False</property>
......
......@@ -10,7 +10,7 @@ use gtk::prelude::*;
use gtk::SettingsExt as GtkSettingsExt;
use crossbeam_channel::{unbounded, Sender};
use hammond_data::Podcast;
use hammond_data::{Podcast, dbqueries};
use headerbar::Header;
use settings::{self, WindowGeometry};
......@@ -53,6 +53,7 @@ pub enum Action {
MarkAllPlayerNotification(Arc<Podcast>),
RemoveShow(Arc<Podcast>),
ErrorNotification(String),
AboutWidget(i32),
}
#[derive(Debug)]
......@@ -179,6 +180,13 @@ impl App {
|| {}, UndoState::Hidden);
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(_) => (),
}
......
......@@ -85,4 +85,8 @@ impl Content {
pub fn get_shows(&self) -> Rc<RefCell<ShowStack>> {
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,
download: gtk::Button,
cancel: gtk::Button,
desc: gtk::Button,
}
impl InfoLabels {
......@@ -168,6 +169,7 @@ impl Default for EpisodeWidget {
let download = builder.get_object("download_button").unwrap();
let play = builder.get_object("play_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 title = builder.get_object("title_label").unwrap();
......@@ -198,6 +200,7 @@ impl Default for EpisodeWidget {
play,
download,
cancel,
desc: desc_button,
},
progressbar,
container,
......@@ -213,6 +216,32 @@ impl EpisodeWidget {
.map_err(|err| error!("Error: {}", err))
.ok();
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>) {}
......