[gnome-settings-daemon] color: Rename 'Natural Light Filter' to 'Night Light'
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] color: Rename 'Natural Light Filter' to 'Night Light'
- Date: Fri, 10 Feb 2017 16:35:34 +0000 (UTC)
commit 5237382507944b5e5731b38781f09062ef8a7e5a
Author: Richard Hughes <richard hughsie com>
Date: Fri Feb 10 16:28:33 2017 +0000
color: Rename 'Natural Light Filter' to 'Night Light'
...settings-daemon.plugins.color.gschema.xml.in.in | 22 +-
plugins/color/Makefile.am | 16 +-
plugins/color/gcm-self-test.c | 108 +++++-----
plugins/color/gsd-color-manager.c | 52 +++---
plugins/color/gsd-natural-light.h | 52 -----
...ral-light-common.c => gsd-night-light-common.c} | 12 +-
...ral-light-common.h => gsd-night-light-common.h} | 24 ++--
.../{gsd-natural-light.c => gsd-night-light.c} | 210 ++++++++++----------
plugins/color/gsd-night-light.h | 52 +++++
9 files changed, 274 insertions(+), 274 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in
b/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in
index e1a0828..0f72f37 100644
--- a/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in
@@ -10,32 +10,32 @@
<_summary>The duration a printer profile is valid</_summary>
<_description>This is the number of days after which the printer color profile is considered
invalid.</_description>
</key>
- <key name="natural-light-enabled" type="b">
+ <key name="night-light-enabled" type="b">
<default>false</default>
- <_summary>If the natural night mode is enabled</_summary>
- <_description>Natural light mode changes the color temperature of your display when the sun has gone
down or at present times.</_description>
+ <_summary>If the night night mode is enabled</_summary>
+ <_description>Night light mode changes the color temperature of your display when the sun has gone
down or at present times.</_description>
</key>
- <key name="natural-light-temperature" type="u">
+ <key name="night-light-temperature" type="u">
<default>4000</default>
<_summary>Temperature of the display when enabled</_summary>
- <_description>This temperature in Kelvin is used to modify the screen tones when natural light mode is
enabled. Higher values are bluer, lower redder.</_description>
+ <_description>This temperature in Kelvin is used to modify the screen tones when night light mode is
enabled. Higher values are bluer, lower redder.</_description>
</key>
- <key name="natural-light-schedule-automatic" type="b">
+ <key name="night-light-schedule-automatic" type="b">
<default>true</default>
<_summary>Use the sunrise and sunset</_summary>
<_description>Calculate the sunrise and sunset times automatically, from the current
location.</_description>
</key>
- <key name="natural-light-schedule-from" type="d">
+ <key name="night-light-schedule-from" type="d">
<default>16.00</default>
<_summary>The start time</_summary>
- <_description>When “natural-light-schedule-automatic” is disabled, use this start time in hours from
midnight.</_description>
+ <_description>When “night-light-schedule-automatic” is disabled, use this start time in hours from
midnight.</_description>
</key>
- <key name="natural-light-schedule-to" type="d">
+ <key name="night-light-schedule-to" type="d">
<default>8.00</default>
<_summary>The end time</_summary>
- <_description>When “natural-light-schedule-automatic” is disabled, use this end time in hours from
midnight.</_description>
+ <_description>When “night-light-schedule-automatic” is disabled, use this end time in hours from
midnight.</_description>
</key>
- <key name="natural-light-last-coordinates" type="(dd)">
+ <key name="night-light-last-coordinates" type="(dd)">
<default>(91,181)</default>
<_summary>The last detected position</_summary>
<_description>When location services are available this represents the last detected location. The
default value is an invalid value to ensure it is always updated at startup.</_description>
diff --git a/plugins/color/Makefile.am b/plugins/color/Makefile.am
index 042b245..a280ba8 100644
--- a/plugins/color/Makefile.am
+++ b/plugins/color/Makefile.am
@@ -15,10 +15,10 @@ gcm_self_test_CFLAGS = \
gcm_self_test_SOURCES = \
gcm-edid.c \
gcm-edid.h \
- gsd-natural-light.c \
- gsd-natural-light.h \
- gsd-natural-light-common.c \
- gsd-natural-light-common.h \
+ gsd-night-light.c \
+ gsd-night-light.h \
+ gsd-night-light-common.c \
+ gsd-night-light-common.h \
gnome-datetime-source.c \
gnome-datetime-source.h \
gcm-self-test.c
@@ -45,10 +45,10 @@ gsd_color_SOURCES = \
gsd-color-profiles.h \
gsd-color-state.c \
gsd-color-state.h \
- gsd-natural-light.c \
- gsd-natural-light.h \
- gsd-natural-light-common.c \
- gsd-natural-light-common.h \
+ gsd-night-light.c \
+ gsd-night-light.h \
+ gsd-night-light-common.c \
+ gsd-night-light-common.h \
$(NULL)
gsd_color_CFLAGS = \
diff --git a/plugins/color/gcm-self-test.c b/plugins/color/gcm-self-test.c
index 695754e..37ec133 100644
--- a/plugins/color/gcm-self-test.c
+++ b/plugins/color/gcm-self-test.c
@@ -27,11 +27,11 @@
#include "gcm-edid.h"
#include "gsd-color-state.h"
-#include "gsd-natural-light.h"
-#include "gsd-natural-light-common.h"
+#include "gsd-night-light.h"
+#include "gsd-night-light-common.h"
static void
-on_notify (GsdNaturalLight *nlight,
+on_notify (GsdNightLight *nlight,
GParamSpec *pspec,
gpointer user_data)
{
@@ -40,7 +40,7 @@ on_notify (GsdNaturalLight *nlight,
}
static void
-gcm_test_natural_light (void)
+gcm_test_night_light (void)
{
gboolean ret;
guint active_cnt = 0;
@@ -50,11 +50,11 @@ gcm_test_natural_light (void)
guint temperature_cnt = 0;
g_autoptr(GDateTime) datetime_override = NULL;
g_autoptr(GError) error = NULL;
- g_autoptr(GsdNaturalLight) nlight = NULL;
+ g_autoptr(GsdNightLight) nlight = NULL;
g_autoptr(GSettings) settings = NULL;
- nlight = gsd_natural_light_new ();
- g_assert (GSD_IS_NATURAL_LIGHT (nlight));
+ nlight = gsd_night_light_new ();
+ g_assert (GSD_IS_NIGHT_LIGHT (nlight));
g_signal_connect (nlight, "notify::active",
G_CALLBACK (on_notify), &active_cnt);
g_signal_connect (nlight, "notify::sunset",
@@ -68,27 +68,27 @@ gcm_test_natural_light (void)
/* hardcode a specific date and time */
datetime_override = g_date_time_new_utc (2017, 2, 8, 20, 0, 0);
- gsd_natural_light_set_date_time_now (nlight, datetime_override);
+ gsd_night_light_set_date_time_now (nlight, datetime_override);
/* do not start geoclue */
- gsd_natural_light_set_geoclue_enabled (nlight, FALSE);
+ gsd_night_light_set_geoclue_enabled (nlight, FALSE);
/* switch off */
settings = g_settings_new ("org.gnome.settings-daemon.plugins.color");
- g_settings_set_boolean (settings, "natural-light-enabled", FALSE);
+ g_settings_set_boolean (settings, "night-light-enabled", FALSE);
/* check default values */
- g_assert (!gsd_natural_light_get_active (nlight));
- g_assert_cmpint ((gint) gsd_natural_light_get_sunrise (nlight), ==, -1);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunset (nlight), ==, -1);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ g_assert (!gsd_night_light_get_active (nlight));
+ g_assert_cmpint ((gint) gsd_night_light_get_sunrise (nlight), ==, -1);
+ g_assert_cmpint ((gint) gsd_night_light_get_sunset (nlight), ==, -1);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
/* start module, disabled */
- ret = gsd_natural_light_start (nlight, &error);
+ ret = gsd_night_light_start (nlight, &error);
g_assert_no_error (error);
g_assert (ret);
- g_assert (!gsd_natural_light_get_active (nlight));
+ g_assert (!gsd_night_light_get_active (nlight));
g_assert_cmpint (active_cnt, ==, 0);
g_assert_cmpint (sunset_cnt, ==, 0);
g_assert_cmpint (sunrise_cnt, ==, 0);
@@ -96,57 +96,57 @@ gcm_test_natural_light (void)
g_assert_cmpint (disabled_until_tmw_cnt, ==, 0);
/* enable automatic mode */
- g_settings_set_value (settings, "natural-light-last-coordinates",
+ g_settings_set_value (settings, "night-light-last-coordinates",
g_variant_new ("(dd)", 51.5, -0.1278));
- g_settings_set_boolean (settings, "natural-light-schedule-automatic", TRUE);
- g_settings_set_boolean (settings, "natural-light-enabled", TRUE);
- g_assert (gsd_natural_light_get_active (nlight));
+ g_settings_set_boolean (settings, "night-light-schedule-automatic", TRUE);
+ g_settings_set_boolean (settings, "night-light-enabled", TRUE);
+ g_assert (gsd_night_light_get_active (nlight));
g_assert_cmpint (active_cnt, ==, 1);
g_assert_cmpint (sunset_cnt, ==, 1);
g_assert_cmpint (sunrise_cnt, ==, 1);
g_assert_cmpint (temperature_cnt, ==, 1);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 0);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunrise (nlight), ==, 7);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunset (nlight), ==, 17);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, 4000);
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ g_assert_cmpint ((gint) gsd_night_light_get_sunrise (nlight), ==, 7);
+ g_assert_cmpint ((gint) gsd_night_light_get_sunset (nlight), ==, 17);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, 4000);
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
/* disable for one day */
- gsd_natural_light_set_disabled_until_tmw (nlight, TRUE);
- gsd_natural_light_set_disabled_until_tmw (nlight, TRUE);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
- g_assert (gsd_natural_light_get_active (nlight));
- g_assert (gsd_natural_light_get_disabled_until_tmw (nlight));
+ gsd_night_light_set_disabled_until_tmw (nlight, TRUE);
+ gsd_night_light_set_disabled_until_tmw (nlight, TRUE);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+ g_assert (gsd_night_light_get_active (nlight));
+ g_assert (gsd_night_light_get_disabled_until_tmw (nlight));
g_assert_cmpint (temperature_cnt, ==, 2);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 1);
/* change our mind */
- gsd_natural_light_set_disabled_until_tmw (nlight, FALSE);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, 4000);
- g_assert (gsd_natural_light_get_active (nlight));
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ gsd_night_light_set_disabled_until_tmw (nlight, FALSE);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, 4000);
+ g_assert (gsd_night_light_get_active (nlight));
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
g_assert_cmpint (active_cnt, ==, 1);
g_assert_cmpint (temperature_cnt, ==, 3);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 2);
/* enabled manual mode (night shift) */
- g_settings_set_double (settings, "natural-light-schedule-from", 4.0);
- g_settings_set_double (settings, "natural-light-schedule-to", 16.f);
- g_settings_set_boolean (settings, "natural-light-schedule-automatic", FALSE);
+ g_settings_set_double (settings, "night-light-schedule-from", 4.0);
+ g_settings_set_double (settings, "night-light-schedule-to", 16.f);
+ g_settings_set_boolean (settings, "night-light-schedule-automatic", FALSE);
g_assert_cmpint (active_cnt, ==, 2);
g_assert_cmpint (sunset_cnt, ==, 1);
g_assert_cmpint (sunrise_cnt, ==, 1);
g_assert_cmpint (temperature_cnt, ==, 4);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 2);
- g_assert (!gsd_natural_light_get_active (nlight));
- g_assert_cmpint ((gint) gsd_natural_light_get_sunrise (nlight), ==, 7);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunset (nlight), ==, 17);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ g_assert (!gsd_night_light_get_active (nlight));
+ g_assert_cmpint ((gint) gsd_night_light_get_sunrise (nlight), ==, 7);
+ g_assert_cmpint ((gint) gsd_night_light_get_sunset (nlight), ==, 17);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
/* finally disable, with no changes */
- g_settings_set_boolean (settings, "natural-light-enabled", FALSE);
- g_assert (!gsd_natural_light_get_active (nlight));
+ g_settings_set_boolean (settings, "night-light-enabled", FALSE);
+ g_assert (!gsd_night_light_get_active (nlight));
g_assert_cmpint (active_cnt, ==, 2);
g_assert_cmpint (sunset_cnt, ==, 1);
g_assert_cmpint (sunrise_cnt, ==, 1);
@@ -221,7 +221,7 @@ gcm_test_sunset_sunrise (void)
g_autoptr(GDateTime) dt = g_date_time_new_utc (2007, 2, 1, 0, 0, 0);
/* get for London, today */
- gsd_natural_light_get_sunrise_sunset (dt, 51.5, -0.1278, &sunrise, &sunset);
+ gsd_night_light_get_sunrise_sunset (dt, 51.5, -0.1278, &sunrise, &sunset);
g_assert_cmpfloat (sunrise, <, sunrise_actual + 0.1);
g_assert_cmpfloat (sunrise, >, sunrise_actual - 0.1);
g_assert_cmpfloat (sunset, <, sunset_actual + 0.1);
@@ -236,22 +236,22 @@ gcm_test_frac_day (void)
gdouble fd_actual = 12.99;
/* test for 12:59:59 */
- fd = gsd_natural_light_frac_day_from_dt (dt);
+ fd = gsd_night_light_frac_day_from_dt (dt);
g_assert_cmpfloat (fd, >, fd_actual - 0.01);
g_assert_cmpfloat (fd, <, fd_actual + 0.01);
/* test same day */
- g_assert (gsd_natural_light_frac_day_is_between (12, 6, 20));
- g_assert (!gsd_natural_light_frac_day_is_between (5, 6, 20));
- g_assert (gsd_natural_light_frac_day_is_between (12, 0, 24));
- g_assert (gsd_natural_light_frac_day_is_between (12, -1, 25));
+ g_assert (gsd_night_light_frac_day_is_between (12, 6, 20));
+ g_assert (!gsd_night_light_frac_day_is_between (5, 6, 20));
+ g_assert (gsd_night_light_frac_day_is_between (12, 0, 24));
+ g_assert (gsd_night_light_frac_day_is_between (12, -1, 25));
/* test rollover to next day */
- g_assert (gsd_natural_light_frac_day_is_between (23, 20, 6));
- g_assert (!gsd_natural_light_frac_day_is_between (12, 20, 6));
+ g_assert (gsd_night_light_frac_day_is_between (23, 20, 6));
+ g_assert (!gsd_night_light_frac_day_is_between (12, 20, 6));
/* test rollover to the previous day */
- g_assert (gsd_natural_light_frac_day_is_between (5, 16, 8));
+ g_assert (gsd_night_light_frac_day_is_between (5, 16, 8));
}
int
@@ -265,7 +265,7 @@ main (int argc, char **argv)
g_test_add_func ("/color/edid", gcm_test_edid_func);
g_test_add_func ("/color/sunset-sunrise", gcm_test_sunset_sunrise);
g_test_add_func ("/color/fractional-day", gcm_test_frac_day);
- g_test_add_func ("/color/natural-light", gcm_test_natural_light);
+ g_test_add_func ("/color/night-light", gcm_test_night_light);
return g_test_run ();
}
diff --git a/plugins/color/gsd-color-manager.c b/plugins/color/gsd-color-manager.c
index 58676ad..c8bcf32 100644
--- a/plugins/color/gsd-color-manager.c
+++ b/plugins/color/gsd-color-manager.c
@@ -29,7 +29,7 @@
#include "gsd-color-manager.h"
#include "gsd-color-profiles.h"
#include "gsd-color-state.h"
-#include "gsd-natural-light.h"
+#include "gsd-night-light.h"
#define GSD_DBUS_NAME "org.gnome.SettingsDaemon"
#define GSD_DBUS_PATH "/org/gnome/SettingsDaemon"
@@ -42,7 +42,7 @@
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.gnome.SettingsDaemon.Color'>"
-" <property name='NaturalLightActive' type='b' access='read'/>"
+" <property name='NightLightActive' type='b' access='read'/>"
" <property name='Temperature' type='u' access='readwrite'/>"
" <property name='DisabledUntilTomorrow' type='b' access='readwrite'/>"
" <property name='Sunrise' type='d' access='read'/>"
@@ -63,7 +63,7 @@ struct GsdColorManagerPrivate
GsdColorCalibrate *calibrate;
GsdColorProfiles *profiles;
GsdColorState *state;
- GsdNaturalLight *nlight;
+ GsdNightLight *nlight;
};
enum {
@@ -163,57 +163,57 @@ emit_property_changed (GsdColorManager *manager,
}
static void
-on_active_notify (GsdNaturalLight *nlight,
+on_active_notify (GsdNightLight *nlight,
GParamSpec *pspec,
gpointer user_data)
{
GsdColorManager *manager = GSD_COLOR_MANAGER (user_data);
GsdColorManagerPrivate *priv = manager->priv;
- emit_property_changed (manager, "NaturalLightActive",
- g_variant_new_boolean (gsd_natural_light_get_active (priv->nlight)));
+ emit_property_changed (manager, "NightLightActive",
+ g_variant_new_boolean (gsd_night_light_get_active (priv->nlight)));
}
static void
-on_sunset_notify (GsdNaturalLight *nlight,
+on_sunset_notify (GsdNightLight *nlight,
GParamSpec *pspec,
gpointer user_data)
{
GsdColorManager *manager = GSD_COLOR_MANAGER (user_data);
GsdColorManagerPrivate *priv = manager->priv;
emit_property_changed (manager, "Sunset",
- g_variant_new_double (gsd_natural_light_get_sunset (priv->nlight)));
+ g_variant_new_double (gsd_night_light_get_sunset (priv->nlight)));
}
static void
-on_sunrise_notify (GsdNaturalLight *nlight,
+on_sunrise_notify (GsdNightLight *nlight,
GParamSpec *pspec,
gpointer user_data)
{
GsdColorManager *manager = GSD_COLOR_MANAGER (user_data);
GsdColorManagerPrivate *priv = manager->priv;
emit_property_changed (manager, "Sunrise",
- g_variant_new_double (gsd_natural_light_get_sunrise (priv->nlight)));
+ g_variant_new_double (gsd_night_light_get_sunrise (priv->nlight)));
}
static void
-on_disabled_until_tmw_notify (GsdNaturalLight *nlight,
+on_disabled_until_tmw_notify (GsdNightLight *nlight,
GParamSpec *pspec,
gpointer user_data)
{
GsdColorManager *manager = GSD_COLOR_MANAGER (user_data);
GsdColorManagerPrivate *priv = manager->priv;
emit_property_changed (manager, "DisabledUntilTomorrow",
- g_variant_new_boolean (gsd_natural_light_get_disabled_until_tmw
(priv->nlight)));
+ g_variant_new_boolean (gsd_night_light_get_disabled_until_tmw
(priv->nlight)));
}
static void
-on_tempertature_notify (GsdNaturalLight *nlight,
+on_tempertature_notify (GsdNightLight *nlight,
GParamSpec *pspec,
gpointer user_data)
{
GsdColorManager *manager = GSD_COLOR_MANAGER (user_data);
GsdColorManagerPrivate *priv = manager->priv;
- gdouble temperature = gsd_natural_light_get_temperature (priv->nlight);
+ gdouble temperature = gsd_night_light_get_temperature (priv->nlight);
gsd_color_state_set_temperature (priv->state, temperature);
emit_property_changed (manager, "Temperature",
g_variant_new_double (temperature));
@@ -230,8 +230,8 @@ gsd_color_manager_init (GsdColorManager *manager)
priv->profiles = gsd_color_profiles_new ();
priv->state = gsd_color_state_new ();
- /* natural light features */
- priv->nlight = gsd_natural_light_new ();
+ /* night light features */
+ priv->nlight = gsd_night_light_new ();
g_signal_connect (priv->nlight, "notify::active",
G_CALLBACK (on_active_notify), manager);
g_signal_connect (priv->nlight, "notify::sunset",
@@ -294,8 +294,8 @@ handle_get_property (GDBusConnection *connection,
return NULL;
}
- if (g_strcmp0 (property_name, "NaturalLightActive") == 0)
- return g_variant_new_boolean (gsd_natural_light_get_active (priv->nlight));
+ if (g_strcmp0 (property_name, "NightLightActive") == 0)
+ return g_variant_new_boolean (gsd_night_light_get_active (priv->nlight));
if (g_strcmp0 (property_name, "Temperature") == 0) {
guint temperature;
@@ -304,13 +304,13 @@ handle_get_property (GDBusConnection *connection,
}
if (g_strcmp0 (property_name, "DisabledUntilTomorrow") == 0)
- return g_variant_new_boolean (gsd_natural_light_get_disabled_until_tmw (priv->nlight));
+ return g_variant_new_boolean (gsd_night_light_get_disabled_until_tmw (priv->nlight));
if (g_strcmp0 (property_name, "Sunrise") == 0)
- return g_variant_new_double (gsd_natural_light_get_sunrise (priv->nlight));
+ return g_variant_new_double (gsd_night_light_get_sunrise (priv->nlight));
if (g_strcmp0 (property_name, "Sunset") == 0)
- return g_variant_new_double (gsd_natural_light_get_sunset (priv->nlight));
+ return g_variant_new_double (gsd_night_light_get_sunset (priv->nlight));
g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
"Failed to get property: %s", property_name);
@@ -359,8 +359,8 @@ handle_set_property (GDBusConnection *connection,
}
if (g_strcmp0 (property_name, "DisabledUntilTomorrow") == 0) {
- gsd_natural_light_set_disabled_until_tmw (priv->nlight,
- g_variant_get_boolean (value));
+ gsd_night_light_set_disabled_until_tmw (priv->nlight,
+ g_variant_get_boolean (value));
return TRUE;
}
@@ -418,9 +418,9 @@ on_bus_gotten (GObject *source_object,
manager,
NULL);
- /* setup natural light module */
- if (!gsd_natural_light_start (priv->nlight, &error)) {
- g_warning ("Could not start natural light module: %s", error->message);
+ /* setup night light module */
+ if (!gsd_night_light_start (priv->nlight, &error)) {
+ g_warning ("Could not start night light module: %s", error->message);
g_error_free (error);
}
}
diff --git a/plugins/color/gsd-natural-light-common.c b/plugins/color/gsd-night-light-common.c
similarity index 93%
rename from plugins/color/gsd-natural-light-common.c
rename to plugins/color/gsd-night-light-common.c
index c0853ab..9f786e9 100644
--- a/plugins/color/gsd-natural-light-common.c
+++ b/plugins/color/gsd-night-light-common.c
@@ -22,7 +22,7 @@
#include <glib.h>
#include <math.h>
-#include "gsd-natural-light-common.h"
+#include "gsd-night-light-common.h"
static gdouble
deg2rad (gdouble degrees)
@@ -47,9 +47,9 @@ rad2deg (gdouble radians)
* a sunrise at all.
*/
gboolean
-gsd_natural_light_get_sunrise_sunset (GDateTime *dt,
- gdouble pos_lat, gdouble pos_long,
- gdouble *sunrise, gdouble *sunset)
+gsd_night_light_get_sunrise_sunset (GDateTime *dt,
+ gdouble pos_lat, gdouble pos_long,
+ gdouble *sunrise, gdouble *sunset)
{
g_autoptr(GDateTime) dt_zero = g_date_time_new_utc (1900, 1, 1, 0, 0, 0);
GTimeSpan ts = g_date_time_difference (dt, dt_zero);
@@ -107,7 +107,7 @@ gsd_natural_light_get_sunrise_sunset (GDateTime *dt,
}
gdouble
-gsd_natural_light_frac_day_from_dt (GDateTime *dt)
+gsd_night_light_frac_day_from_dt (GDateTime *dt)
{
return g_date_time_get_hour (dt) +
(gdouble) g_date_time_get_minute (dt) / 60.f +
@@ -115,7 +115,7 @@ gsd_natural_light_frac_day_from_dt (GDateTime *dt)
}
gboolean
-gsd_natural_light_frac_day_is_between (gdouble value, gdouble start, gdouble end)
+gsd_night_light_frac_day_is_between (gdouble value, gdouble start, gdouble end)
{
/* wraparound to the next day */
if (end < start)
diff --git a/plugins/color/gsd-natural-light-common.h b/plugins/color/gsd-night-light-common.h
similarity index 50%
rename from plugins/color/gsd-natural-light-common.h
rename to plugins/color/gsd-night-light-common.h
index dd04ffd..4995da5 100644
--- a/plugins/color/gsd-natural-light-common.h
+++ b/plugins/color/gsd-night-light-common.h
@@ -17,23 +17,23 @@
*
*/
-#ifndef __GSD_NATURAL_LIGHT_COMMON_H
-#define __GSD_NATURAL_LIGHT_COMMON_H
+#ifndef __GSD_NIGHT_LIGHT_COMMON_H
+#define __GSD_NIGHT_LIGHT_COMMON_H
#include <glib-object.h>
G_BEGIN_DECLS
-gboolean gsd_natural_light_get_sunrise_sunset (GDateTime *dt,
- gdouble pos_lat,
- gdouble pos_long,
- gdouble *sunrise,
- gdouble *sunset);
-gdouble gsd_natural_light_frac_day_from_dt (GDateTime *dt);
-gboolean gsd_natural_light_frac_day_is_between (gdouble value,
- gdouble start,
- gdouble end);
+gboolean gsd_night_light_get_sunrise_sunset (GDateTime *dt,
+ gdouble pos_lat,
+ gdouble pos_long,
+ gdouble *sunrise,
+ gdouble *sunset);
+gdouble gsd_night_light_frac_day_from_dt (GDateTime *dt);
+gboolean gsd_night_light_frac_day_is_between (gdouble value,
+ gdouble start,
+ gdouble end);
G_END_DECLS
-#endif /* __GSD_NATURAL_LIGHT_COMMON_H */
+#endif /* __GSD_NIGHT_LIGHT_COMMON_H */
diff --git a/plugins/color/gsd-natural-light.c b/plugins/color/gsd-night-light.c
similarity index 72%
rename from plugins/color/gsd-natural-light.c
rename to plugins/color/gsd-night-light.c
index 181011a..5d90376 100644
--- a/plugins/color/gsd-natural-light.c
+++ b/plugins/color/gsd-night-light.c
@@ -27,16 +27,16 @@
#include "gsd-color-state.h"
-#include "gsd-natural-light.h"
-#include "gsd-natural-light-common.h"
+#include "gsd-night-light.h"
+#include "gsd-night-light-common.h"
-struct _GsdNaturalLight {
+struct _GsdNightLight {
GObject parent;
GSettings *settings;
gboolean disabled_until_tmw;
gboolean geoclue_enabled;
- GSource *natural_light_source;
- guint natural_light_validate_id;
+ GSource *source;
+ guint validate_id;
gint disabled_day_of_month;
GClueClient *geoclue_client;
GClueSimple *geoclue_simple;
@@ -58,22 +58,22 @@ enum {
PROP_LAST
};
-#define GSD_NATURAL_LIGHT_SCHEDULE_TIMEOUT 5 /* seconds */
-#define GSD_NATURAL_LIGHT_POLL_TIMEOUT 60 /* seconds */
-#define GSD_NATURAL_LIGHT_POLL_SMEAR 1 /* hours */
+#define GSD_NIGHT_LIGHT_SCHEDULE_TIMEOUT 5 /* seconds */
+#define GSD_NIGHT_LIGHT_POLL_TIMEOUT 60 /* seconds */
+#define GSD_NIGHT_LIGHT_POLL_SMEAR 1 /* hours */
#define GSD_FRAC_DAY_MAX_DELTA (1.f/60.f) /* 1 minute */
#define GSD_TEMPERATURE_MAX_DELTA (10.f) /* Kelvin */
#define DESKTOP_ID "gnome-color-panel"
-static void poll_timeout_destroy (GsdNaturalLight *self);
-static void poll_timeout_create (GsdNaturalLight *self);
+static void poll_timeout_destroy (GsdNightLight *self);
+static void poll_timeout_create (GsdNightLight *self);
-G_DEFINE_TYPE (GsdNaturalLight, gsd_natural_light, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GsdNightLight, gsd_night_light, G_TYPE_OBJECT);
static GDateTime *
-gsd_natural_light_get_date_time_now (GsdNaturalLight *self)
+gsd_night_light_get_date_time_now (GsdNightLight *self)
{
if (self->datetime_override != NULL)
return g_date_time_ref (self->datetime_override);
@@ -81,7 +81,7 @@ gsd_natural_light_get_date_time_now (GsdNaturalLight *self)
}
void
-gsd_natural_light_set_date_time_now (GsdNaturalLight *self, GDateTime *datetime)
+gsd_night_light_set_date_time_now (GsdNightLight *self, GDateTime *datetime)
{
if (self->datetime_override != NULL)
g_date_time_unref (self->datetime_override);
@@ -97,7 +97,7 @@ linear_interpolate (gdouble val1, gdouble val2, gdouble factor)
}
static gboolean
-update_cached_sunrise_sunset (GsdNaturalLight *self)
+update_cached_sunrise_sunset (GsdNightLight *self)
{
gboolean ret = FALSE;
gdouble latitude;
@@ -105,16 +105,16 @@ update_cached_sunrise_sunset (GsdNaturalLight *self)
gdouble sunrise;
gdouble sunset;
g_autoptr(GVariant) tmp = NULL;
- g_autoptr(GDateTime) dt_now = gsd_natural_light_get_date_time_now (self);
+ g_autoptr(GDateTime) dt_now = gsd_night_light_get_date_time_now (self);
/* calculate the sunrise/sunset for the location */
- tmp = g_settings_get_value (self->settings, "natural-light-last-coordinates");
+ tmp = g_settings_get_value (self->settings, "night-light-last-coordinates");
g_variant_get (tmp, "(dd)", &latitude, &longitude);
if (latitude > 90.f || latitude < -90.f)
return FALSE;
if (longitude > 180.f || longitude < -180.f)
return FALSE;
- if (!gsd_natural_light_get_sunrise_sunset (dt_now, latitude, longitude,
+ if (!gsd_night_light_get_sunrise_sunset (dt_now, latitude, longitude,
&sunrise, &sunset)) {
g_warning ("failed to get sunset/sunrise for %.3f,%.3f",
longitude, longitude);
@@ -136,7 +136,7 @@ update_cached_sunrise_sunset (GsdNaturalLight *self)
}
static void
-gsd_natural_light_set_temperature (GsdNaturalLight *self, gdouble temperature)
+gsd_night_light_set_temperature (GsdNightLight *self, gdouble temperature)
{
if (ABS (self->cached_temperature - temperature) > GSD_TEMPERATURE_MAX_DELTA) {
self->cached_temperature = temperature;
@@ -145,7 +145,7 @@ gsd_natural_light_set_temperature (GsdNaturalLight *self, gdouble temperature)
}
static void
-gsd_natural_light_set_active (GsdNaturalLight *self, gboolean active)
+gsd_night_light_set_active (GsdNightLight *self, gboolean active)
{
if (self->cached_active == active)
return;
@@ -153,26 +153,26 @@ gsd_natural_light_set_active (GsdNaturalLight *self, gboolean active)
/* ensure set to unity temperature */
if (!active)
- gsd_natural_light_set_temperature (self, GSD_COLOR_TEMPERATURE_DEFAULT);
+ gsd_night_light_set_temperature (self, GSD_COLOR_TEMPERATURE_DEFAULT);
g_object_notify (G_OBJECT (self), "active");
}
static void
-natural_light_recheck (GsdNaturalLight *self)
+night_light_recheck (GsdNightLight *self)
{
gdouble frac_day;
gdouble schedule_from = -1.f;
gdouble schedule_to = -1.f;
- gdouble smear = GSD_NATURAL_LIGHT_POLL_SMEAR; /* hours */
+ gdouble smear = GSD_NIGHT_LIGHT_POLL_SMEAR; /* hours */
guint temperature;
guint temp_smeared;
- g_autoptr(GDateTime) dt_now = gsd_natural_light_get_date_time_now (self);
+ g_autoptr(GDateTime) dt_now = gsd_night_light_get_date_time_now (self);
/* enabled */
- if (!g_settings_get_boolean (self->settings, "natural-light-enabled")) {
- g_debug ("natural light disabled, resetting");
- gsd_natural_light_set_active (self, FALSE);
+ if (!g_settings_get_boolean (self->settings, "night-light-enabled")) {
+ g_debug ("night light disabled, resetting");
+ gsd_night_light_set_active (self, FALSE);
return;
}
@@ -180,8 +180,8 @@ natural_light_recheck (GsdNaturalLight *self)
if (self->disabled_until_tmw) {
gint tmp_day_of_month = g_date_time_get_day_of_month (dt_now);
if (tmp_day_of_month == self->disabled_day_of_month) {
- g_debug ("natural light still day-disabled, resetting");
- gsd_natural_light_set_temperature (self,
+ g_debug ("night light still day-disabled, resetting");
+ gsd_night_light_set_temperature (self,
GSD_COLOR_TEMPERATURE_DEFAULT);
return;
}
@@ -193,7 +193,7 @@ natural_light_recheck (GsdNaturalLight *self)
}
/* calculate the position of the sun */
- if (g_settings_get_boolean (self->settings, "natural-light-schedule-automatic")) {
+ if (g_settings_get_boolean (self->settings, "night-light-schedule-automatic")) {
update_cached_sunrise_sunset (self);
if (self->cached_sunrise > 0.f && self->cached_sunset > 0.f) {
schedule_to = self->cached_sunrise;
@@ -204,20 +204,20 @@ natural_light_recheck (GsdNaturalLight *self)
/* fall back to manual settings */
if (schedule_to <= 0.f || schedule_from <= 0.f) {
schedule_from = g_settings_get_double (self->settings,
- "natural-light-schedule-from");
+ "night-light-schedule-from");
schedule_to = g_settings_get_double (self->settings,
- "natural-light-schedule-to");
+ "night-light-schedule-to");
}
/* get the current hour of a day as a fraction */
- frac_day = gsd_natural_light_frac_day_from_dt (dt_now);
+ frac_day = gsd_night_light_frac_day_from_dt (dt_now);
g_debug ("fractional day = %.3f, limits = %.3f->%.3f",
frac_day, schedule_from, schedule_to);
- if (!gsd_natural_light_frac_day_is_between (frac_day,
+ if (!gsd_night_light_frac_day_is_between (frac_day,
schedule_from - smear,
schedule_to)) {
- g_debug ("not time for natural-light");
- gsd_natural_light_set_active (self, FALSE);
+ g_debug ("not time for night-light");
+ gsd_night_light_set_active (self, FALSE);
return;
}
@@ -231,14 +231,14 @@ natural_light_recheck (GsdNaturalLight *self)
* \ /
* \--------------------/
*/
- temperature = g_settings_get_uint (self->settings, "natural-light-temperature");
- if (gsd_natural_light_frac_day_is_between (frac_day,
+ temperature = g_settings_get_uint (self->settings, "night-light-temperature");
+ if (gsd_night_light_frac_day_is_between (frac_day,
schedule_from - smear,
schedule_from)) {
gdouble factor = 1.f - ((frac_day - (schedule_from - smear)) / smear);
temp_smeared = linear_interpolate (GSD_COLOR_TEMPERATURE_DEFAULT,
temperature, factor);
- } else if (gsd_natural_light_frac_day_is_between (frac_day,
+ } else if (gsd_night_light_frac_day_is_between (frac_day,
schedule_to - smear,
schedule_to)) {
gdouble factor = ((schedule_to - smear) - frac_day) / smear;
@@ -247,41 +247,41 @@ natural_light_recheck (GsdNaturalLight *self)
} else {
temp_smeared = temperature;
}
- g_debug ("natural light mode on, using temperature of %uK (aiming for %uK)",
+ g_debug ("night light mode on, using temperature of %uK (aiming for %uK)",
temp_smeared, temperature);
- gsd_natural_light_set_active (self, TRUE);
- gsd_natural_light_set_temperature (self, temp_smeared);
+ gsd_night_light_set_active (self, TRUE);
+ gsd_night_light_set_temperature (self, temp_smeared);
}
static gboolean
-natural_light_recheck_schedule_cb (gpointer user_data)
+night_light_recheck_schedule_cb (gpointer user_data)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (user_data);
- natural_light_recheck (self);
- self->natural_light_validate_id = 0;
+ GsdNightLight *self = GSD_NIGHT_LIGHT (user_data);
+ night_light_recheck (self);
+ self->validate_id = 0;
return G_SOURCE_REMOVE;
}
/* called when something changed */
static void
-natural_light_recheck_schedule (GsdNaturalLight *self)
+night_light_recheck_schedule (GsdNightLight *self)
{
- if (self->natural_light_validate_id != 0)
- g_source_remove (self->natural_light_validate_id);
- self->natural_light_validate_id =
- g_timeout_add_seconds (GSD_NATURAL_LIGHT_SCHEDULE_TIMEOUT,
- natural_light_recheck_schedule_cb,
+ if (self->validate_id != 0)
+ g_source_remove (self->validate_id);
+ self->validate_id =
+ g_timeout_add_seconds (GSD_NIGHT_LIGHT_SCHEDULE_TIMEOUT,
+ night_light_recheck_schedule_cb,
self);
}
/* called when the time may have changed */
static gboolean
-natural_light_recheck_cb (gpointer user_data)
+night_light_recheck_cb (gpointer user_data)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (user_data);
+ GsdNightLight *self = GSD_NIGHT_LIGHT (user_data);
/* recheck parameters, then reschedule a new timeout */
- natural_light_recheck (self);
+ night_light_recheck (self);
poll_timeout_destroy (self);
poll_timeout_create (self);
@@ -290,42 +290,42 @@ natural_light_recheck_cb (gpointer user_data)
}
static void
-poll_timeout_create (GsdNaturalLight *self)
+poll_timeout_create (GsdNightLight *self)
{
g_autoptr(GDateTime) dt_now = NULL;
g_autoptr(GDateTime) dt_expiry = NULL;
- if (self->natural_light_source != NULL)
+ if (self->source != NULL)
return;
- dt_now = gsd_natural_light_get_date_time_now (self);
- dt_expiry = g_date_time_add_seconds (dt_now, GSD_NATURAL_LIGHT_POLL_TIMEOUT);
- self->natural_light_source = _gnome_datetime_source_new (dt_now,
+ dt_now = gsd_night_light_get_date_time_now (self);
+ dt_expiry = g_date_time_add_seconds (dt_now, GSD_NIGHT_LIGHT_POLL_TIMEOUT);
+ self->source = _gnome_datetime_source_new (dt_now,
dt_expiry,
FALSE);
- g_source_set_callback (self->natural_light_source,
- natural_light_recheck_cb,
+ g_source_set_callback (self->source,
+ night_light_recheck_cb,
self, NULL);
- g_source_attach (self->natural_light_source, NULL);
+ g_source_attach (self->source, NULL);
}
static void
-poll_timeout_destroy (GsdNaturalLight *self)
+poll_timeout_destroy (GsdNightLight *self)
{
- if (self->natural_light_source == NULL)
+ if (self->source == NULL)
return;
- g_source_destroy (self->natural_light_source);
- self->natural_light_source = NULL;
+ g_source_destroy (self->source);
+ self->source = NULL;
}
static void
settings_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (user_data);
+ GsdNightLight *self = GSD_NIGHT_LIGHT (user_data);
g_debug ("settings changed");
- natural_light_recheck (self);
+ night_light_recheck (self);
}
static void
@@ -333,7 +333,7 @@ on_location_notify (GClueSimple *simple,
GParamSpec *pspec,
gpointer user_data)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (user_data);
+ GsdNightLight *self = GSD_NIGHT_LIGHT (user_data);
GClueLocation *location;
gdouble latitude, longitude;
@@ -342,14 +342,14 @@ on_location_notify (GClueSimple *simple,
longitude = gclue_location_get_longitude (location);
g_settings_set_value (self->settings,
- "natural-light-last-coordinates",
+ "night-light-last-coordinates",
g_variant_new ("(dd)", latitude, longitude));
g_debug ("got geoclue latitude %f, longitude %f", latitude, longitude);
/* recheck the levels if the location changed significantly */
if (update_cached_sunrise_sunset (self))
- natural_light_recheck_schedule (self);
+ night_light_recheck_schedule (self);
}
static void
@@ -357,7 +357,7 @@ on_geoclue_simple_ready (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (user_data);
+ GsdNightLight *self = GSD_NIGHT_LIGHT (user_data);
GClueSimple *geoclue_simple;
g_autoptr(GError) error = NULL;
@@ -378,7 +378,7 @@ on_geoclue_simple_ready (GObject *source_object,
}
static void
-register_geoclue (GsdNaturalLight *self)
+register_geoclue (GsdNightLight *self)
{
gclue_simple_new (DESKTOP_ID,
GCLUE_ACCURACY_LEVEL_CITY,
@@ -389,63 +389,63 @@ register_geoclue (GsdNaturalLight *self)
}
void
-gsd_natural_light_set_disabled_until_tmw (GsdNaturalLight *self, gboolean value)
+gsd_night_light_set_disabled_until_tmw (GsdNightLight *self, gboolean value)
{
- g_autoptr(GDateTime) dt = gsd_natural_light_get_date_time_now (self);
+ g_autoptr(GDateTime) dt = gsd_night_light_get_date_time_now (self);
if (self->disabled_until_tmw == value)
return;
self->disabled_until_tmw = value;
self->disabled_day_of_month = g_date_time_get_day_of_month (dt);
- natural_light_recheck (self);
+ night_light_recheck (self);
g_object_notify (G_OBJECT (self), "disabled-until-tmw");
}
gboolean
-gsd_natural_light_get_disabled_until_tmw (GsdNaturalLight *self)
+gsd_night_light_get_disabled_until_tmw (GsdNightLight *self)
{
return self->disabled_until_tmw;
}
gboolean
-gsd_natural_light_get_active (GsdNaturalLight *self)
+gsd_night_light_get_active (GsdNightLight *self)
{
return self->cached_active;
}
gdouble
-gsd_natural_light_get_sunrise (GsdNaturalLight *self)
+gsd_night_light_get_sunrise (GsdNightLight *self)
{
return self->cached_sunrise;
}
gdouble
-gsd_natural_light_get_sunset (GsdNaturalLight *self)
+gsd_night_light_get_sunset (GsdNightLight *self)
{
return self->cached_sunset;
}
gdouble
-gsd_natural_light_get_temperature (GsdNaturalLight *self)
+gsd_night_light_get_temperature (GsdNightLight *self)
{
return self->cached_temperature;
}
void
-gsd_natural_light_set_geoclue_enabled (GsdNaturalLight *self, gboolean enabled)
+gsd_night_light_set_geoclue_enabled (GsdNightLight *self, gboolean enabled)
{
self->geoclue_enabled = enabled;
}
gboolean
-gsd_natural_light_start (GsdNaturalLight *self, GError **error)
+gsd_night_light_start (GsdNightLight *self, GError **error)
{
if (self->geoclue_enabled)
register_geoclue (self);
- natural_light_recheck (self);
+ night_light_recheck (self);
poll_timeout_create (self);
/* care about changes */
@@ -455,9 +455,9 @@ gsd_natural_light_start (GsdNaturalLight *self, GError **error)
}
static void
-gsd_natural_light_finalize (GObject *object)
+gsd_night_light_finalize (GObject *object)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (object);
+ GsdNightLight *self = GSD_NIGHT_LIGHT (object);
poll_timeout_destroy (self);
@@ -469,24 +469,24 @@ gsd_natural_light_finalize (GObject *object)
g_clear_object (&self->cancellable);
}
- if (self->natural_light_validate_id > 0) {
- g_source_remove (self->natural_light_validate_id);
- self->natural_light_validate_id = 0;
+ if (self->validate_id > 0) {
+ g_source_remove (self->validate_id);
+ self->validate_id = 0;
}
if (self->geoclue_client != NULL)
gclue_client_call_stop (self->geoclue_client, NULL, NULL, NULL);
g_clear_object (&self->geoclue_simple);
- G_OBJECT_CLASS (gsd_natural_light_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gsd_night_light_parent_class)->finalize (object);
}
static void
-gsd_natural_light_set_property (GObject *object,
+gsd_night_light_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (object);
+ GsdNightLight *self = GSD_NIGHT_LIGHT (object);
switch (prop_id) {
case PROP_SUNRISE:
@@ -507,12 +507,12 @@ gsd_natural_light_set_property (GObject *object,
}
static void
-gsd_natural_light_get_property (GObject *object,
+gsd_night_light_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- GsdNaturalLight *self = GSD_NATURAL_LIGHT (object);
+ GsdNightLight *self = GSD_NIGHT_LIGHT (object);
switch (prop_id) {
case PROP_ACTIVE:
@@ -528,7 +528,7 @@ gsd_natural_light_get_property (GObject *object,
g_value_set_double (value, self->cached_sunrise);
break;
case PROP_DISABLED_UNTIL_TMW:
- g_value_set_boolean (value, gsd_natural_light_get_disabled_until_tmw (self));
+ g_value_set_boolean (value, gsd_night_light_get_disabled_until_tmw (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -536,19 +536,19 @@ gsd_natural_light_get_property (GObject *object,
}
static void
-gsd_natural_light_class_init (GsdNaturalLightClass *klass)
+gsd_night_light_class_init (GsdNightLightClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gsd_natural_light_finalize;
+ object_class->finalize = gsd_night_light_finalize;
- object_class->set_property = gsd_natural_light_set_property;
- object_class->get_property = gsd_natural_light_get_property;
+ object_class->set_property = gsd_night_light_set_property;
+ object_class->get_property = gsd_night_light_get_property;
g_object_class_install_property (object_class,
PROP_ACTIVE,
g_param_spec_boolean ("active",
"Active",
- "If natural light functionality is active
right now",
+ "If night light functionality is active right
now",
FALSE,
G_PARAM_READABLE));
@@ -586,14 +586,14 @@ gsd_natural_light_class_init (GsdNaturalLightClass *klass)
PROP_DISABLED_UNTIL_TMW,
g_param_spec_boolean ("disabled-until-tmw",
"Disabled until tomorrow",
- "If the natural light is disabled until the
next day",
+ "If the night light is disabled until the
next day",
FALSE,
G_PARAM_READWRITE));
}
static void
-gsd_natural_light_init (GsdNaturalLight *self)
+gsd_night_light_init (GsdNightLight *self)
{
self->cached_sunrise = -1.f;
self->cached_sunset = -1.f;
@@ -602,8 +602,8 @@ gsd_natural_light_init (GsdNaturalLight *self)
self->settings = g_settings_new ("org.gnome.settings-daemon.plugins.color");
}
-GsdNaturalLight *
-gsd_natural_light_new (void)
+GsdNightLight *
+gsd_night_light_new (void)
{
- return g_object_new (GSD_TYPE_NATURAL_LIGHT, NULL);
+ return g_object_new (GSD_TYPE_NIGHT_LIGHT, NULL);
}
diff --git a/plugins/color/gsd-night-light.h b/plugins/color/gsd-night-light.h
new file mode 100644
index 0000000..2403307
--- /dev/null
+++ b/plugins/color/gsd-night-light.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2017 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GSD_NIGHT_LIGHT_H__
+#define __GSD_NIGHT_LIGHT_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_NIGHT_LIGHT (gsd_night_light_get_type ())
+G_DECLARE_FINAL_TYPE (GsdNightLight, gsd_night_light, GSD, NIGHT_LIGHT, GObject)
+
+GsdNightLight *gsd_night_light_new (void);
+gboolean gsd_night_light_start (GsdNightLight *self,
+ GError **error);
+
+gboolean gsd_night_light_get_active (GsdNightLight *self);
+gdouble gsd_night_light_get_sunrise (GsdNightLight *self);
+gdouble gsd_night_light_get_sunset (GsdNightLight *self);
+gdouble gsd_night_light_get_temperature (GsdNightLight *self);
+
+gboolean gsd_night_light_get_disabled_until_tmw (GsdNightLight *self);
+void gsd_night_light_set_disabled_until_tmw (GsdNightLight *self,
+ gboolean value);
+
+/* only for the self test program */
+void gsd_night_light_set_geoclue_enabled (GsdNightLight *self,
+ gboolean enabled);
+void gsd_night_light_set_date_time_now (GsdNightLight *self,
+ GDateTime *datetime);
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]