From 707e8ed72d248bcc80a19c9220c1cc6de4dba28d Mon Sep 17 00:00:00 2001 From: Ricky Kresslein Date: Fri, 8 Apr 2022 13:01:33 +0300 Subject: Minimum height changes for task list or empty views (Issue #16) --- src/application.rs | 1 - src/ui/history_box.rs | 7 ++++++- src/ui/window.rs | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/application.rs b/src/application.rs index e3b4cc3..e5153da 100755 --- a/src/application.rs +++ b/src/application.rs @@ -64,7 +64,6 @@ mod imp { let window = FurtheranceWindow::new(application); window.set_default_size(400, 600); window.set_title(Some("Furtherance")); - window.set_height_request(300); window.upcast() }; diff --git a/src/ui/history_box.rs b/src/ui/history_box.rs index 459c751..73ca077 100755 --- a/src/ui/history_box.rs +++ b/src/ui/history_box.rs @@ -19,7 +19,7 @@ use gtk::subclass::prelude::*; use gtk::{glib, CompositeTemplate}; use glib::subclass; -use crate::ui::FurTasksPage; +use crate::ui::{FurtheranceWindow, FurTasksPage}; use crate::FurtheranceApplication; use crate::database; use crate::config; @@ -125,6 +125,7 @@ impl FurHistoryBox { pub fn create_tasks_page(&self) { let imp = imp::FurHistoryBox::from_instance(self); + let window = FurtheranceWindow::default(); imp.tasks_page.clear_task_list(); let is_saved_task: bool = match database::check_for_tasks() { Ok(_) => true, @@ -134,13 +135,17 @@ impl FurHistoryBox { self.set_view(View::Loading); imp.tasks_page.build_task_list(); self.set_view(View::Tasks); + window.set_height_request(300); } else { self.set_view(View::Empty); + window.set_height_request(390); } } pub fn empty_view(&self) { self.set_view(View::Empty); + let window = FurtheranceWindow::default(); + window.set_height_request(390); } } diff --git a/src/ui/window.rs b/src/ui/window.rs index c955451..a9b43bd 100755 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -153,6 +153,17 @@ impl FurtheranceWindow { fn setup_widgets(&self) { let imp = imp::FurtheranceWindow::from_instance(self); + // Set initial minimum height + let is_saved_task: bool = match database::check_for_tasks() { + Ok(_) => true, + Err(_) => false, + }; + if is_saved_task { + self.set_height_request(300); + } else { + self.set_height_request(390); + } + // Development mode if config::PROFILE == "development" { self.add_css_class("devel"); -- cgit 1.4.1