Save the views as their original widgets #132
|
@ -87,7 +87,7 @@ impl AppWindow {
|
|||
let initial_view = View::Placeholder(PlaceholderView::new().upcast());
|
||||
|
||||
layout.append(&header);
|
||||
layout.append(initial_view.widget());
|
||||
layout.append(&initial_view.widget());
|
||||
|
||||
window.set_content(Some(&layout));
|
||||
window.present();
|
||||
|
@ -130,9 +130,9 @@ impl AppWindow {
|
|||
// position.
|
||||
fn swap_main(&self, view: View) {
|
||||
let mut current_widget = self.current_view.borrow_mut();
|
||||
self.layout.remove(&*current_widget.widget());
|
||||
self.layout.remove(¤t_widget.widget());
|
||||
*current_widget = view;
|
||||
self.layout.append(&*current_widget.widget());
|
||||
self.layout.append(¤t_widget.widget());
|
||||
}
|
||||
|
||||
fn construct_view(&self, view: ViewName) -> View {
|
||||
|
|
|
@ -14,6 +14,8 @@ General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use gtk::prelude::*;
|
||||
|
||||
mod historical_view;
|
||||
pub use historical_view::HistoricalView;
|
||||
|
||||
|
@ -30,17 +32,17 @@ pub enum ViewName {
|
|||
}
|
||||
|
||||
pub enum View {
|
||||
Placeholder(gtk::Widget),
|
||||
Welcome(gtk::Widget),
|
||||
Historical(gtk::Widget),
|
||||
Placeholder(PlaceholderView),
|
||||
Welcome(WelcomeView),
|
||||
Historical(HistoricalView),
|
||||
}
|
||||
|
||||
impl View {
|
||||
pub fn widget<'a>(&'a self) -> &'a gtk::Widget {
|
||||
pub fn widget(&self) -> gtk::Widget {
|
||||
match self {
|
||||
View::Placeholder(widget) => widget,
|
||||
View::Welcome(widget) => widget,
|
||||
View::Historical(widget) => widget,
|
||||
View::Placeholder(widget) => widget.clone().upcast::<gtk::Widget>(),
|
||||
View::Welcome(widget) => widget.clone().upcast::<gtk::Widget>(),
|
||||
View::Historical(widget) => widget.clone().upcast::<gtk::Widget>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue