From b9453ffad7590080ed67898062babd97bbea46af Mon Sep 17 00:00:00 2001 From: Ricky Kresslein Date: Fri, 10 Jun 2022 15:35:12 +0300 Subject: Center timer on empty (Issue #1) --- src/gtk/history_box.ui | 68 +----------------------------------- src/gtk/window.ui | 95 +++++++++++++++++++++++++------------------------- src/ui/history_box.rs | 17 +++------ src/ui/window.rs | 15 +++++--- 4 files changed, 64 insertions(+), 131 deletions(-) diff --git a/src/gtk/history_box.ui b/src/gtk/history_box.ui index b5c9a34..89a44a7 100755 --- a/src/gtk/history_box.ui +++ b/src/gtk/history_box.ui @@ -21,73 +21,7 @@ empty - - Start Tracking - com.lakoliu.Furtherance - - - center - 12 - 12 - - - input-keyboard-symbolic - - 0 - 0 - - - - - - start - Type your task and press start - - 1 - 0 - - - - - - accessories-text-editor-symbolic - - 0 - 1 - - - - - - start - Prior tasks will show up here - - 1 - 1 - - - - - - input-mouse-symbolic - - 0 - 2 - - - - - - start - Right-click a task to duplicate it - - 1 - 2 - - - - - + diff --git a/src/gtk/window.ui b/src/gtk/window.ui index 25b81ca..20ac46e 100755 --- a/src/gtk/window.ui +++ b/src/gtk/window.ui @@ -34,53 +34,54 @@ - - vertical - 10 - center - 400 - True - - - 00:00:00 - 12 - 12 - - - - - - - - - - 5 - 12 - 8 - - - Task Name #tags - True - True - - - - - media-playback-start-symbolic - - - - - - - - - - + + vertical + 10 + center + center + 400 + True + + + 00:00:00 + 12 + 12 + + + + + + + + + + 5 + 12 + 8 + + + Task Name #tags + True + True + + + + + media-playback-start-symbolic + + + + + + + + + + diff --git a/src/ui/history_box.rs b/src/ui/history_box.rs index 9d2f59f..445d796 100755 --- a/src/ui/history_box.rs +++ b/src/ui/history_box.rs @@ -19,7 +19,6 @@ use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::{glib, CompositeTemplate}; -use crate::config; use crate::database; use crate::ui::{FurTasksPage, FurtheranceWindow}; use crate::FurtheranceApplication; @@ -42,8 +41,6 @@ mod imp { #[template_child] pub spinner: TemplateChild, #[template_child] - pub welcome_page: TemplateChild, - #[template_child] pub tasks_page: TemplateChild, } @@ -90,13 +87,6 @@ impl FurHistoryBox { } else { self.set_view(View::Empty); } - - // Change "empty" page icon for development mode - let imp = imp::FurHistoryBox::from_instance(self); - if config::PROFILE == "development" { - imp.welcome_page - .set_icon_name(Some("com.lakoliu.Furtherance.Devel")); - } } fn set_view(&self, view: View) { @@ -129,19 +119,20 @@ impl FurHistoryBox { Err(_) => false, }; if is_saved_task { + window.vertical_align(gtk::Align::Start); 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); + window.vertical_align(gtk::Align::Center); } } pub fn empty_view(&self) { self.set_view(View::Empty); let window = FurtheranceWindow::default(); - window.set_height_request(390); + window.vertical_align(gtk::Align::Center); } } + diff --git a/src/ui/window.rs b/src/ui/window.rs index d02d1b5..5670696 100755 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -52,6 +52,9 @@ mod imp { pub header_bar: TemplateChild, #[template_child] pub add_task: TemplateChild, + + #[template_child] + pub win_box: TemplateChild, #[template_child] pub watch: TemplateChild, #[template_child] @@ -162,15 +165,13 @@ impl FurtheranceWindow { fn setup_widgets(&self) { let imp = imp::FurtheranceWindow::from_instance(self); - // Set initial minimum height + // Set initial minimum height and alignment 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); + self.vertical_align(gtk::Align::Start); } // Development mode @@ -910,6 +911,12 @@ impl FurtheranceWindow { dialog.show() } + + pub fn vertical_align(&self, align: gtk::Align) { + let imp = imp::FurtheranceWindow::from_instance(self); + imp.win_box.set_valign(align); + } + } impl Default for FurtheranceWindow { -- cgit 1.4.1