From 14d4818867393037b9b1081b27c87f5abe2424a0 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sun, 19 Aug 2018 14:25:41 +0300 Subject: [PATCH] App: Disable refresh action while in empty state Close #71 --- podcasts-gtk/src/app.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index 0c6623e..4806a39 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -349,8 +349,24 @@ impl App { let menu = &s.get().container; self.headerbar.set_secondary_menu(menu); } - Action::EmptyState => self.content.switch_to_empty_views(), - Action::PopulatedState => self.content.switch_to_populated(), + Action::EmptyState => { + self.window + .lookup_action("refresh") + .and_then(|action| action.downcast::().ok()) + // Disable refresh action + .map(|action| action.set_enabled(false)); + + self.content.switch_to_empty_views(); + } + Action::PopulatedState => { + self.window + .lookup_action("refresh") + .and_then(|action| action.downcast::().ok()) + // Enable refresh action + .map(|action| action.set_enabled(true)); + + self.content.switch_to_populated(); + } } }