diff --git a/podcasts-gtk/po/POTFILES.in b/podcasts-gtk/po/POTFILES.in index 07950b5..5a8a86d 100644 --- a/podcasts-gtk/po/POTFILES.in +++ b/podcasts-gtk/po/POTFILES.in @@ -5,7 +5,6 @@ podcasts-gtk/resources/org.gnome.Podcasts.desktop podcasts-gtk/resources/org.gnome.Podcasts.appdata.xml # ui files -podcasts-gtk/resources/gtk/empty_show.ui podcasts-gtk/resources/gtk/empty_view.ui podcasts-gtk/resources/gtk/episode_widget.ui podcasts-gtk/resources/gtk/hamburger.ui diff --git a/podcasts-gtk/resources/gtk/empty_show.ui b/podcasts-gtk/resources/gtk/empty_show.ui deleted file mode 100644 index b4c094a..0000000 --- a/podcasts-gtk/resources/gtk/empty_show.ui +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - True - False - center - center - True - True - vertical - 12 - - - True - False - 128 - application-rss+xml-symbolic - True - - - - False - True - 0 - - - - - True - False - This show does not have any episodes - - - - - - - False - True - 1 - - - - - True - False - If you think this is an error, please consider opening a bug report. - - - - False - True - 2 - - - - diff --git a/podcasts-gtk/resources/gtk/empty_view.ui b/podcasts-gtk/resources/gtk/empty_view.ui index c7ce40b..b616c47 100644 --- a/podcasts-gtk/resources/gtk/empty_view.ui +++ b/podcasts-gtk/resources/gtk/empty_view.ui @@ -30,6 +30,47 @@ Tobias Bernard + + True + False + center + center + True + True + vertical + 12 + + + True + False + This show does not have episodes yet + + + + + + + False + True + 1 + + + + + True + False + If you think this is an error, please consider writting a bug report. + + + + False + True + 2 + + + True False diff --git a/podcasts-gtk/resources/resources.xml b/podcasts-gtk/resources/resources.xml index e04850a..0ba1f91 100644 --- a/podcasts-gtk/resources/resources.xml +++ b/podcasts-gtk/resources/resources.xml @@ -4,7 +4,6 @@ gtk/episode_widget.ui gtk/show_widget.ui gtk/empty_view.ui - gtk/empty_show.ui gtk/home_view.ui gtk/home_episode.ui gtk/headerbar.ui diff --git a/podcasts-gtk/src/stacks/home.rs b/podcasts-gtk/src/stacks/home.rs index 252bd59..cccad87 100644 --- a/podcasts-gtk/src/stacks/home.rs +++ b/podcasts-gtk/src/stacks/home.rs @@ -10,6 +10,7 @@ use podcasts_data::errors::DataError; use app::Action; use widgets::{EmptyView, HomeView}; +use std::ops::Deref; use std::rc::Rc; #[derive(Debug, Clone, Copy)] @@ -30,12 +31,12 @@ pub(crate) struct HomeStack { impl HomeStack { pub(crate) fn new(sender: Sender) -> Result { let episodes = HomeView::new(sender.clone(), None)?; - let empty = EmptyView::new(); + let empty = EmptyView::default(); let stack = gtk::Stack::new(); let state = State::Empty; stack.add_named(episodes.view.container(), "home"); - stack.add_named(&empty.container, "empty"); + stack.add_named(empty.deref(), "empty"); let mut home = HomeStack { empty, diff --git a/podcasts-gtk/src/stacks/show.rs b/podcasts-gtk/src/stacks/show.rs index cb2076b..73244a7 100644 --- a/podcasts-gtk/src/stacks/show.rs +++ b/podcasts-gtk/src/stacks/show.rs @@ -11,6 +11,7 @@ use utils::get_ignored_shows; use widgets::EmptyView; use std::cell::RefCell; +use std::ops::Deref; use std::rc::Rc; #[derive(Debug, Clone, Copy)] @@ -31,12 +32,12 @@ pub(crate) struct ShowStack { impl ShowStack { pub(crate) fn new(sender: Sender) -> Self { let populated = Rc::new(RefCell::new(PopulatedStack::new(sender.clone()))); - let empty = EmptyView::new(); + let empty = EmptyView::default(); let stack = gtk::Stack::new(); let state = ShowState::Empty; stack.add_named(&populated.borrow().container(), "populated"); - stack.add_named(&empty.container, "empty"); + stack.add_named(empty.deref(), "empty"); let mut show = ShowStack { empty, diff --git a/podcasts-gtk/src/widgets/empty.rs b/podcasts-gtk/src/widgets/empty.rs index 186d875..64ed885 100644 --- a/podcasts-gtk/src/widgets/empty.rs +++ b/podcasts-gtk/src/widgets/empty.rs @@ -1,21 +1,38 @@ use gtk; +use std::ops::Deref; -#[derive(Debug, Clone)] -pub(crate) struct EmptyView { - pub(crate) container: gtk::Box, +#[derive(Clone, Debug)] +pub(crate) struct EmptyView(gtk::Box); + +impl Deref for EmptyView { + type Target = gtk::Box; + fn deref(&self) -> &Self::Target { + &self.0 + } } impl Default for EmptyView { fn default() -> Self { let builder = gtk::Builder::new_from_resource("/org/gnome/Podcasts/gtk/empty_view.ui"); let view: gtk::Box = builder.get_object("empty_view").unwrap(); - - EmptyView { container: view } + EmptyView(view) } } -impl EmptyView { - pub(crate) fn new() -> EmptyView { - EmptyView::default() +#[derive(Clone, Debug)] +pub(crate) struct EmptyShow(gtk::Box); + +impl Deref for EmptyShow { + type Target = gtk::Box; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl Default for EmptyShow { + fn default() -> Self { + let builder = gtk::Builder::new_from_resource("/org/gnome/Podcasts/gtk/empty_view.ui"); + let box_: gtk::Box = builder.get_object("empty_show").unwrap(); + EmptyShow(box_) } } diff --git a/podcasts-gtk/src/widgets/mod.rs b/podcasts-gtk/src/widgets/mod.rs index 85aae87..50b3f83 100644 --- a/podcasts-gtk/src/widgets/mod.rs +++ b/podcasts-gtk/src/widgets/mod.rs @@ -11,7 +11,7 @@ mod shows_view; pub(crate) use self::aboutdialog::about_dialog; pub(crate) use self::base_view::BaseView; -pub(crate) use self::empty::EmptyView; +pub(crate) use self::empty::{EmptyShow, EmptyView}; pub(crate) use self::episode::EpisodeWidget; pub(crate) use self::home_view::HomeView; pub(crate) use self::show::ShowWidget; diff --git a/podcasts-gtk/src/widgets/show.rs b/podcasts-gtk/src/widgets/show.rs index acdd588..cf3440d 100644 --- a/podcasts-gtk/src/widgets/show.rs +++ b/podcasts-gtk/src/widgets/show.rs @@ -13,8 +13,9 @@ use podcasts_data::Show; use app::Action; use utils::{self, lazy_load}; -use widgets::{BaseView, EpisodeWidget, ShowMenu}; +use widgets::{BaseView, EmptyShow, EpisodeWidget, ShowMenu}; +use std::ops::Deref; use std::rc::Rc; use std::sync::Arc; @@ -122,11 +123,8 @@ fn populate_listbox( })); if count == 0 { - let builder = gtk::Builder::new_from_resource("/org/gnome/Podcasts/gtk/empty_show.ui"); - let container: gtk::Box = builder - .get_object("empty_show") - .ok_or_else(|| format_err!("FOO"))?; - show.episodes.add(&container); + let empty = EmptyShow::default(); + show.episodes.add(empty.deref()); return Ok(()); }