[gnome-control-center] display: Fix night light minute selection
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] display: Fix night light minute selection
- Date: Tue, 30 Jan 2018 11:42:46 +0000 (UTC)
commit 77aaf3146bebde404bd22125e234c8bce85e608b
Author: danielps <d nielps me>
Date: Fri Jan 26 23:45:53 2018 +0100
display: Fix night light minute selection
The night light schedule dialog stores the time as a single floating
point value, which is then converted into hours and minutes for the
time selection fields.
Previously, the minutes were calculated using the remainder of the
stored value and the hours. This caused undesired behaviour when the
hour field was set to zero, as fmod(value, 0) returns NaN. As a result,
the user was not able to set the time between 00:00 and 00:59.
This patch rewrites the time retrieval logic using modf.
https://bugzilla.gnome.org/show_bug.cgi?id=792944
panels/display/cc-night-light-dialog.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
---
diff --git a/panels/display/cc-night-light-dialog.c b/panels/display/cc-night-light-dialog.c
index 2fb515b..a2bbc68 100644
--- a/panels/display/cc-night-light-dialog.c
+++ b/panels/display/cc-night-light-dialog.c
@@ -119,7 +119,7 @@ dialog_adjustments_set_frac_hours (CcNightLightDialog *self,
/* display the right thing for AM/PM */
is_24h = self->clock_format == G_DESKTOP_CLOCK_FORMAT_24H;
- hours = floor (value);
+ mins = modf (value, &hours) * 60.f;
if (!is_24h)
{
if (hours > 12)
@@ -137,11 +137,6 @@ dialog_adjustments_set_frac_hours (CcNightLightDialog *self,
is_pm = TRUE;
}
}
- if (value > 0.f)
- {
- mins = fmod (value, hours) * 60.f;
- mins = fmod (mins, 60.f);
- }
g_debug ("setting adjustment %.3f to %.0f:%02.0f", value, hours, mins);
self->ignore_value_changed = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]