diff options
author | Ricky Kresslein <ricky@kressle.in> | 2022-02-23 22:54:50 +0100 |
---|---|---|
committer | Ricky Kresslein <ricky@kressle.in> | 2022-02-23 22:54:50 +0100 |
commit | de4ea78d38007a2efda4cbd03d0207fa27decbf4 (patch) | |
tree | 77f642be49be3656276628b8fc885a5f5d169c86 /src/ui | |
parent | 2a8e1c75863bc84c55eadcff1f3adb42d409d180 (diff) | |
download | Furtherance-de4ea78d38007a2efda4cbd03d0207fa27decbf4.tar.zst |
- Clearly states idle notify works in Gnome only
- Fixed bug idle preference only updated on start - Added dark theme switch
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/preferences_window.rs | 14 | ||||
-rw-r--r-- | src/ui/window.rs | 11 |
2 files changed, 17 insertions, 8 deletions
diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs index e9ef36e..b6088ec 100644 --- a/src/ui/preferences_window.rs +++ b/src/ui/preferences_window.rs @@ -31,6 +31,11 @@ mod imp { #[template(resource = "/com/lakoliu/Furtherance/gtk/preferences_window.ui")] pub struct FurPreferencesWindow { #[template_child] + pub appearance_group: TemplateChild<adw::PreferencesGroup>, + #[template_child] + pub dark_theme_switch: TemplateChild<gtk::Switch>, + + #[template_child] pub idle_group: TemplateChild<adw::PreferencesGroup>, #[template_child] pub notify_of_idle_expander: TemplateChild<adw::ExpanderRow>, @@ -88,13 +93,22 @@ impl FurPreferencesWindow { } fn setup_widgets(&self) { + let imp = imp::FurPreferencesWindow::from_instance(self); + let manager = adw::StyleManager::default(); + let support_darkmode = manager.system_supports_color_schemes(); + imp.appearance_group.set_visible(!support_darkmode); } 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( "notify-of-idle", &*imp.notify_of_idle_expander, "enable-expansion", diff --git a/src/ui/window.rs b/src/ui/window.rs index 92c8282..7c1e8cc 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -25,7 +25,6 @@ use std::rc::Rc; use std::cell::RefCell; use chrono::{DateTime, Local, Duration as ChronDur}; use dbus::blocking::Connection; -use once_cell::unsync::OnceCell; use crate::ui::FurHistoryBox; use crate::FurtheranceApplication; @@ -53,7 +52,6 @@ mod imp { #[template_child] pub toast_overlay: TemplateChild<adw::ToastOverlay>, - pub notify_of_idle: OnceCell<u64>, pub stored_idle: Mutex<u64>, pub idle_notified: Mutex<bool>, pub idle_time_reached: Mutex<bool>, @@ -220,9 +218,6 @@ impl FurtheranceWindow { fn setup_settings(&self) { let imp = imp::FurtheranceWindow::from_instance(self); - // Get user setting idle-time in minutes and convert it to seconds - imp.notify_of_idle.set((settings_manager::get_int("idle-time") * 60) as u64) - .expect("Failed to set notify_of_idle"); self.reset_vars(); // Enter starts timer @@ -249,7 +244,7 @@ impl FurtheranceWindow { let idle_time = self.get_idle_time().unwrap(); // If user was idle and has now returned... - if idle_time < *imp.notify_of_idle.get().unwrap() + if idle_time < (settings_manager::get_int("idle-time") * 60) as u64 && *imp.idle_time_reached.lock().unwrap() && !*imp.idle_notified.lock().unwrap() { @@ -259,12 +254,12 @@ impl FurtheranceWindow { *imp.stored_idle.lock().unwrap() = idle_time; // If user is idle but has not returned... - if *imp.stored_idle.lock().unwrap() >= *imp.notify_of_idle.get().unwrap() + if *imp.stored_idle.lock().unwrap() >= (settings_manager::get_int("idle-time") * 60) as u64 && !*imp.idle_time_reached.lock().unwrap() { *imp.idle_time_reached.lock().unwrap() = true; let true_idle_start_time = Local::now() - - ChronDur::seconds(*imp.notify_of_idle.get().unwrap() as i64); + ChronDur::seconds((settings_manager::get_int("idle-time") * 60) as i64); *imp.idle_start_time.lock().unwrap() = true_idle_start_time.to_rfc3339(); } } |