diff options
Diffstat (limited to 'src/ui')
-rwxr-xr-x | src/ui/history_box.rs | 16 | ||||
-rwxr-xr-x | src/ui/preferences_window.rs | 95 | ||||
-rwxr-xr-x | src/ui/task_details.rs | 15 | ||||
-rwxr-xr-x | src/ui/task_row.rs | 24 | ||||
-rwxr-xr-x | src/ui/tasks_group.rs | 10 |
5 files changed, 56 insertions, 104 deletions
diff --git a/src/ui/history_box.rs b/src/ui/history_box.rs index 73ca077..9d2f59f 100755 --- a/src/ui/history_box.rs +++ b/src/ui/history_box.rs @@ -14,15 +14,15 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +use glib::subclass; use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::{glib, CompositeTemplate}; -use glib::subclass; -use crate::ui::{FurtheranceWindow, FurTasksPage}; -use crate::FurtheranceApplication; -use crate::database; use crate::config; +use crate::database; +use crate::ui::{FurTasksPage, FurtheranceWindow}; +use crate::FurtheranceApplication; enum View { Loading, @@ -60,7 +60,6 @@ mod imp { fn instance_init(obj: &subclass::InitializingObject<Self>) { obj.init_template(); } - } impl ObjectImpl for FurHistoryBox { @@ -68,7 +67,6 @@ mod imp { obj.setup_widgets(); self.parent_constructed(obj); } - } impl WidgetImpl for FurHistoryBox {} impl BoxImpl for FurHistoryBox {} @@ -80,7 +78,6 @@ glib::wrapper! { @extends gtk::Widget, gtk::Box; } - impl FurHistoryBox { fn setup_widgets(&self) { self.set_view(View::Loading); @@ -97,9 +94,9 @@ impl FurHistoryBox { // 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")); + imp.welcome_page + .set_icon_name(Some("com.lakoliu.Furtherance.Devel")); } - } fn set_view(&self, view: View) { @@ -147,5 +144,4 @@ impl FurHistoryBox { let window = FurtheranceWindow::default(); window.set_height_request(390); } - } diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs index d9495fd..188a478 100755 --- a/src/ui/preferences_window.rs +++ b/src/ui/preferences_window.rs @@ -87,7 +87,6 @@ mod imp { } impl ObjectImpl for FurPreferencesWindow { - fn constructed(&self, obj: &Self::Type) { let window = FurtheranceWindow::default(); obj.set_transient_for(Some(&window)); @@ -133,11 +132,7 @@ impl FurPreferencesWindow { fn setup_signals(&self) { let imp = imp::FurPreferencesWindow::from_instance(self); - settings_manager::bind_property( - "dark-mode", - &*imp.dark_theme_switch, - "active" - ); + settings_manager::bind_property("dark-mode", &*imp.dark_theme_switch, "active"); settings_manager::bind_property( "notify-of-idle", @@ -145,11 +140,7 @@ impl FurPreferencesWindow { "enable-expansion", ); - settings_manager::bind_property( - "idle-time", - &*imp.notify_of_idle_spin, - "value", - ); + settings_manager::bind_property("idle-time", &*imp.notify_of_idle_spin, "value"); settings_manager::bind_property( "limit-tasks", @@ -157,100 +148,68 @@ impl FurPreferencesWindow { "enable-expansion", ); - settings_manager::bind_property( - "limit-days", - &*imp.limit_days_spin, - "value", - ); + settings_manager::bind_property("limit-days", &*imp.limit_days_spin, "value"); settings_manager::bind_property( "delete-confirmation", &*imp.delete_confirmation_switch, - "active" + "active", ); - settings_manager::bind_property( - "show-seconds", - &*imp.show_seconds_switch, - "active" - ); + settings_manager::bind_property("show-seconds", &*imp.show_seconds_switch, "active"); - settings_manager::bind_property( - "show-daily-sums", - &*imp.show_daily_sums_switch, - "active" - ); + settings_manager::bind_property("show-daily-sums", &*imp.show_daily_sums_switch, "active"); - settings_manager::bind_property( - "show-tags", - &*imp.show_tags_switch, - "active" - ); + settings_manager::bind_property("show-tags", &*imp.show_tags_switch, "active"); - settings_manager::bind_property( - "pomodoro", - &*imp.pomodoro_expander, - "enable-expansion" - ); + settings_manager::bind_property("pomodoro", &*imp.pomodoro_expander, "enable-expansion"); - settings_manager::bind_property( - "pomodoro-time", - &*imp.pomodoro_spin, - "value" - ); + settings_manager::bind_property("pomodoro-time", &*imp.pomodoro_spin, "value"); - settings_manager::bind_property( - "autosave", - &*imp.autosave_expander, - "enable-expansion" - ); + settings_manager::bind_property("autosave", &*imp.autosave_expander, "enable-expansion"); - settings_manager::bind_property( - "autosave-time", - &*imp.autosave_spin, - "value" - ); + settings_manager::bind_property("autosave-time", &*imp.autosave_spin, "value"); - imp.dark_theme_switch.connect_active_notify(move |_|{ + imp.dark_theme_switch.connect_active_notify(move |_| { let app = FurtheranceApplication::default(); app.update_light_dark(); }); - imp.limit_tasks_expander.connect_enable_expansion_notify(move |_|{ - let window = FurtheranceWindow::default(); - window.reset_history_box(); - }); + imp.limit_tasks_expander + .connect_enable_expansion_notify(move |_| { + let window = FurtheranceWindow::default(); + window.reset_history_box(); + }); - imp.limit_days_spin.connect_value_changed(move |_|{ + imp.limit_days_spin.connect_value_changed(move |_| { let window = FurtheranceWindow::default(); window.reset_history_box(); }); - imp.show_seconds_switch.connect_active_notify(move |_|{ + imp.show_seconds_switch.connect_active_notify(move |_| { let window = FurtheranceWindow::default(); window.reset_history_box(); }); - imp.show_daily_sums_switch.connect_active_notify(move |_|{ + imp.show_daily_sums_switch.connect_active_notify(move |_| { let window = FurtheranceWindow::default(); window.reset_history_box(); }); - imp.show_tags_switch.connect_active_notify(move |_|{ + imp.show_tags_switch.connect_active_notify(move |_| { let window = FurtheranceWindow::default(); window.reset_history_box(); }); - imp.pomodoro_expander.connect_enable_expansion_notify(move |_|{ - let window = FurtheranceWindow::default(); - window.refresh_timer(); - }); + imp.pomodoro_expander + .connect_enable_expansion_notify(move |_| { + let window = FurtheranceWindow::default(); + window.refresh_timer(); + }); - imp.pomodoro_spin.connect_value_changed(move |_|{ + imp.pomodoro_spin.connect_value_changed(move |_| { let window = FurtheranceWindow::default(); window.refresh_timer(); }); } } - - diff --git a/src/ui/task_details.rs b/src/ui/task_details.rs index 37eced3..b8771ac 100755 --- a/src/ui/task_details.rs +++ b/src/ui/task_details.rs @@ -15,17 +15,17 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. use adw::subclass::prelude::*; +use chrono::{offset::TimeZone, DateTime, Local, NaiveDateTime, ParseError}; use gettextrs::*; use glib::clone; use gtk::subclass::prelude::*; use gtk::{glib, prelude::*, CompositeTemplate}; -use chrono::{DateTime, NaiveDateTime, Local, ParseError, offset::TimeZone}; use itertools::Itertools; -use crate::FurtheranceApplication; -use crate::ui::FurtheranceWindow; use crate::database; use crate::settings_manager; +use crate::ui::FurtheranceWindow; +use crate::FurtheranceApplication; mod imp { use super::*; @@ -75,7 +75,6 @@ mod imp { } impl ObjectImpl for FurTaskDetails { - fn constructed(&self, obj: &Self::Type) { obj.setup_signals(); obj.setup_delete_all(); @@ -413,7 +412,7 @@ impl FurTaskDetails { dialog.show(); })); - stop.connect_clicked(move |_|{ + stop.connect_clicked(move |_| { start.emit_clicked(); }); } @@ -438,7 +437,8 @@ impl FurTaskDetails { let start_time_str = start_time.format("%x").to_string(); if imp.this_day.borrow().to_string() != start_time_str || imp.task_name_label.text() != task.task_name - || imp.orig_tags.borrow().to_string() != task.tags { + || imp.orig_tags.borrow().to_string() != task.tags + { false } else { true @@ -590,13 +590,10 @@ impl FurTaskDetails { } })); - } fn delete_all(&self) { let imp = imp::FurTaskDetails::from_instance(self); let _ = database::delete_by_ids(imp.all_task_ids.borrow().to_vec()); } - } - diff --git a/src/ui/task_row.rs b/src/ui/task_row.rs index cccc827..810d12e 100755 --- a/src/ui/task_row.rs +++ b/src/ui/task_row.rs @@ -14,17 +14,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -use gtk::subclass::prelude::*; -use gtk::{glib, gio, prelude::*, CompositeTemplate}; use chrono::DateTime; -use std::sync::Mutex; -use once_cell::sync::Lazy; use glib::clone; +use gtk::subclass::prelude::*; +use gtk::{gio, glib, prelude::*, CompositeTemplate}; +use once_cell::sync::Lazy; +use std::sync::Mutex; use crate::database::Task; -use crate::ui::{FurTaskDetails, FurtheranceWindow}; use crate::settings_manager; - +use crate::ui::{FurTaskDetails, FurtheranceWindow}; mod imp { use super::*; @@ -110,7 +109,8 @@ impl FurTaskRow { } // Display task's name - imp.task_name_label.set_text(&imp.tasks.lock().unwrap()[0].task_name); + imp.task_name_label + .set_text(&imp.tasks.lock().unwrap()[0].task_name); // Display task's tags if task_list[0].tags.trim().is_empty() || !settings_manager::get_bool("show-tags") { @@ -131,10 +131,11 @@ impl FurTaskRow { self.add_controller(&gesture); - imp.restart_task_btn.connect_clicked(clone!(@strong task_list => move |_| { - let window = FurtheranceWindow::default(); - window.duplicate_task(task_list[0].clone()); - })); + imp.restart_task_btn + .connect_clicked(clone!(@strong task_list => move |_| { + let window = FurtheranceWindow::default(); + window.duplicate_task(task_list[0].clone()); + })); // Add up all durations for task of said name to create total_time for task in &task_list { @@ -169,4 +170,3 @@ impl FurTaskRow { *imp.total_time.borrow() } } - diff --git a/src/ui/tasks_group.rs b/src/ui/tasks_group.rs index bd55c36..f53b13f 100755 --- a/src/ui/tasks_group.rs +++ b/src/ui/tasks_group.rs @@ -18,9 +18,9 @@ use adw::subclass::prelude::*; use gtk::subclass::prelude::*; use gtk::{glib, prelude::*}; -use crate::ui::FurTaskRow; use crate::database; use crate::settings_manager; +use crate::ui::FurTaskRow; mod imp { use super::*; @@ -86,9 +86,10 @@ impl FurTasksGroup { let mut unique = true; for i in 0..tasks_by_name.len() { if tasks_by_name[i][0].task_name == task.task_name - && ( ( settings_manager::get_bool("show-tags") - && tasks_by_name[i][0].tags == task.tags ) || - !settings_manager::get_bool("show-tags") ) { + && ((settings_manager::get_bool("show-tags") + && tasks_by_name[i][0].tags == task.tags) + || !settings_manager::get_bool("show-tags")) + { tasks_by_name[i].push(task.clone()); unique = false; } @@ -118,4 +119,3 @@ impl FurTasksGroup { *imp.day_total_time.borrow() } } - |