App: Disable refresh action while in empty state

Close #71
This commit is contained in:
Jordan Petridis 2018-08-19 14:25:41 +03:00
parent 9f42e91088
commit 14d4818867
No known key found for this signature in database
GPG Key ID: E8523968931763BE

View File

@ -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::<gio::SimpleAction>().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::<gio::SimpleAction>().ok())
// Enable refresh action
.map(|action| action.set_enabled(true));
self.content.switch_to_populated();
}
}
}