display: Rename 'Natural Light Filter' to 'Night Light'
This commit is contained in:
parent
8c93ec478f
commit
fdbd788b96
7 changed files with 131 additions and 131 deletions
|
@ -11,10 +11,10 @@ libdisplay_la_SOURCES = \
|
|||
$(BUILT_SOURCES) \
|
||||
cc-display-panel.c \
|
||||
cc-display-panel.h \
|
||||
cc-natural-light-dialog.c \
|
||||
cc-natural-light-dialog.h \
|
||||
cc-natural-light-widget.c \
|
||||
cc-natural-light-widget.h \
|
||||
cc-night-light-dialog.c \
|
||||
cc-night-light-dialog.h \
|
||||
cc-night-light-widget.c \
|
||||
cc-night-light-widget.h \
|
||||
scrollarea.c \
|
||||
scrollarea.h
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "shell/list-box-helper.h"
|
||||
#include <libupower-glib/upower.h>
|
||||
|
||||
#include "cc-natural-light-dialog.h"
|
||||
#include "cc-night-light-dialog.h"
|
||||
#include "cc-display-resources.h"
|
||||
|
||||
CC_PANEL_REGISTER (CcDisplayPanel, cc_display_panel)
|
||||
|
@ -87,8 +87,8 @@ struct _CcDisplayPanelPrivate
|
|||
GtkWidget *rotate_right_button;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *config_grid;
|
||||
GtkWidget *natural_light_filter_label;
|
||||
CcNaturalLightDialog *natural_light_dialog;
|
||||
GtkWidget *night_light_filter_label;
|
||||
CcNightLightDialog *night_light_dialog;
|
||||
|
||||
GSettings *settings_color;
|
||||
|
||||
|
@ -249,7 +249,7 @@ cc_display_panel_dispose (GObject *object)
|
|||
g_clear_object (&priv->background);
|
||||
g_clear_object (&priv->thumbnail_factory);
|
||||
g_clear_object (&priv->settings_color);
|
||||
g_clear_object (&priv->natural_light_dialog);
|
||||
g_clear_object (&priv->night_light_dialog);
|
||||
|
||||
if (priv->dialog)
|
||||
{
|
||||
|
@ -2613,14 +2613,14 @@ show_setup_dialog (CcDisplayPanel *panel)
|
|||
}
|
||||
|
||||
static void
|
||||
cc_display_panel_natural_light_activated (GtkListBox *listbox,
|
||||
cc_display_panel_night_light_activated (GtkListBox *listbox,
|
||||
GtkWidget *row,
|
||||
CcDisplayPanel *panel)
|
||||
{
|
||||
CcDisplayPanelPrivate *priv = panel->priv;
|
||||
GtkWindow *toplevel;
|
||||
toplevel = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel))));
|
||||
cc_natural_light_dialog_present (priv->natural_light_dialog, toplevel);
|
||||
cc_night_light_dialog_present (priv->night_light_dialog, toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2776,13 +2776,13 @@ sensor_proxy_vanished_cb (GDBusConnection *connection,
|
|||
}
|
||||
|
||||
static void
|
||||
natural_light_enabled_recheck (CcDisplayPanel *self)
|
||||
night_light_enabled_recheck (CcDisplayPanel *self)
|
||||
{
|
||||
CcDisplayPanelPrivate *priv = DISPLAY_PANEL_PRIVATE (self);
|
||||
gboolean ret = g_settings_get_boolean (priv->settings_color,
|
||||
"natural-light-enabled");
|
||||
gtk_label_set_label (GTK_LABEL (priv->natural_light_filter_label),
|
||||
/* TRANSLATORS: the state of the natural light setting */
|
||||
"night-light-enabled");
|
||||
gtk_label_set_label (GTK_LABEL (priv->night_light_filter_label),
|
||||
/* TRANSLATORS: the state of the night light setting */
|
||||
ret ? _("On") : _("Off"));
|
||||
}
|
||||
|
||||
|
@ -2790,8 +2790,8 @@ static void
|
|||
settings_color_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
|
||||
{
|
||||
CcDisplayPanel *self = CC_DISPLAY_PANEL (user_data);
|
||||
if (g_strcmp0 (key, "natural-light-enabled") == 0)
|
||||
natural_light_enabled_recheck (self);
|
||||
if (g_strcmp0 (key, "night-light-enabled") == 0)
|
||||
night_light_enabled_recheck (self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2802,7 +2802,7 @@ cc_display_panel_init (CcDisplayPanel *self)
|
|||
GtkListBoxRow *row;
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *natural_light_listbox;
|
||||
GtkWidget *night_light_listbox;
|
||||
GError *error = NULL;
|
||||
GSettings *settings;
|
||||
|
||||
|
@ -2817,7 +2817,7 @@ cc_display_panel_init (CcDisplayPanel *self)
|
|||
|
||||
priv->thumbnail_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
|
||||
priv->natural_light_dialog = cc_natural_light_dialog_new ();
|
||||
priv->night_light_dialog = cc_night_light_dialog_new ();
|
||||
|
||||
priv->screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
|
||||
if (!priv->screen)
|
||||
|
@ -2861,21 +2861,21 @@ cc_display_panel_init (CcDisplayPanel *self)
|
|||
|
||||
gtk_container_add (GTK_CONTAINER (vbox), priv->arrange_button);
|
||||
|
||||
/* natural light section */
|
||||
/* night light section */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
natural_light_listbox = gtk_list_box_new ();
|
||||
gtk_list_box_set_selection_mode (GTK_LIST_BOX (natural_light_listbox),
|
||||
night_light_listbox = gtk_list_box_new ();
|
||||
gtk_list_box_set_selection_mode (GTK_LIST_BOX (night_light_listbox),
|
||||
GTK_SELECTION_NONE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), natural_light_listbox);
|
||||
g_signal_connect (natural_light_listbox, "row-activated",
|
||||
G_CALLBACK (cc_display_panel_natural_light_activated),
|
||||
gtk_container_add (GTK_CONTAINER (frame), night_light_listbox);
|
||||
g_signal_connect (night_light_listbox, "row-activated",
|
||||
G_CALLBACK (cc_display_panel_night_light_activated),
|
||||
self);
|
||||
row = GTK_LIST_BOX_ROW (gtk_list_box_row_new ());
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 50);
|
||||
gtk_container_add (GTK_CONTAINER (row), box);
|
||||
gtk_container_add (GTK_CONTAINER (natural_light_listbox), GTK_WIDGET (row));
|
||||
label = gtk_label_new (_("_Natural Light Filter"));
|
||||
gtk_container_add (GTK_CONTAINER (night_light_listbox), GTK_WIDGET (row));
|
||||
label = gtk_label_new (_("_Night Light"));
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
|
||||
gtk_widget_set_margin_start (label, 20);
|
||||
|
@ -2883,7 +2883,7 @@ cc_display_panel_init (CcDisplayPanel *self)
|
|||
gtk_widget_set_margin_top (label, 6);
|
||||
gtk_widget_set_margin_bottom (label, 6);
|
||||
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
|
||||
priv->natural_light_filter_label = label = gtk_label_new ("");
|
||||
priv->night_light_filter_label = label = gtk_label_new ("");
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_END);
|
||||
gtk_widget_set_margin_start (label, 24);
|
||||
gtk_widget_set_margin_end (label, 24);
|
||||
|
@ -2917,7 +2917,7 @@ cc_display_panel_init (CcDisplayPanel *self)
|
|||
priv->settings_color = g_settings_new ("org.gnome.settings-daemon.plugins.color");
|
||||
g_signal_connect (priv->settings_color, "changed",
|
||||
G_CALLBACK (settings_color_changed_cb), self);
|
||||
natural_light_enabled_recheck (self);
|
||||
night_light_enabled_recheck (self);
|
||||
|
||||
g_signal_connect (self, "map", G_CALLBACK (mapped_cb), NULL);
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "cc-natural-light-dialog.h"
|
||||
#include "cc-natural-light-widget.h"
|
||||
#include "cc-night-light-dialog.h"
|
||||
#include "cc-night-light-widget.h"
|
||||
|
||||
struct _CcNaturalLightDialog {
|
||||
struct _CcNightLightDialog {
|
||||
GObject parent;
|
||||
GtkBuilder *builder;
|
||||
GSettings *settings_display;
|
||||
|
@ -35,21 +35,21 @@ struct _CcNaturalLightDialog {
|
|||
GDBusProxy *proxy_color;
|
||||
GDBusProxy *proxy_color_props;
|
||||
GCancellable *cancellable;
|
||||
GtkWidget *natural_light_widget;
|
||||
GtkWidget *night_light_widget;
|
||||
GtkWidget *main_window;
|
||||
gboolean ignore_value_changed;
|
||||
guint timer_id;
|
||||
GDesktopClockFormat clock_format;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (CcNaturalLightDialog, cc_natural_light_dialog, G_TYPE_OBJECT);
|
||||
G_DEFINE_TYPE (CcNightLightDialog, cc_night_light_dialog, G_TYPE_OBJECT);
|
||||
|
||||
#define CLOCK_SCHEMA "org.gnome.desktop.interface"
|
||||
#define DISPLAY_SCHEMA "org.gnome.settings-daemon.plugins.color"
|
||||
#define CLOCK_FORMAT_KEY "clock-format"
|
||||
|
||||
void
|
||||
cc_natural_light_dialog_present (CcNaturalLightDialog *self, GtkWindow *parent)
|
||||
cc_night_light_dialog_present (CcNightLightDialog *self, GtkWindow *parent)
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (self->main_window);
|
||||
if (parent != NULL)
|
||||
|
@ -61,9 +61,9 @@ cc_natural_light_dialog_present (CcNaturalLightDialog *self, GtkWindow *parent)
|
|||
}
|
||||
|
||||
static void
|
||||
cc_natural_light_dialog_finalize (GObject *object)
|
||||
cc_night_light_dialog_finalize (GObject *object)
|
||||
{
|
||||
CcNaturalLightDialog *self = CC_NATURAL_LIGHT_DIALOG (object);
|
||||
CcNightLightDialog *self = CC_NIGHT_LIGHT_DIALOG (object);
|
||||
|
||||
if (self->cancellable != NULL)
|
||||
{
|
||||
|
@ -85,14 +85,14 @@ cc_natural_light_dialog_finalize (GObject *object)
|
|||
if (self->timer_id > 0)
|
||||
g_source_remove (self->timer_id);
|
||||
|
||||
G_OBJECT_CLASS (cc_natural_light_dialog_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (cc_night_light_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
cc_natural_light_dialog_class_init (CcNaturalLightDialogClass *klass)
|
||||
cc_night_light_dialog_class_init (CcNightLightDialogClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = cc_natural_light_dialog_finalize;
|
||||
object_class->finalize = cc_night_light_dialog_finalize;
|
||||
}
|
||||
|
||||
static gdouble
|
||||
|
@ -104,11 +104,11 @@ frac_day_from_dt (GDateTime *dt)
|
|||
}
|
||||
|
||||
static void
|
||||
dialog_adjustments_set_frac_hours (CcNaturalLightDialog *self,
|
||||
gdouble value,
|
||||
const gchar *id_hours,
|
||||
const gchar *id_mins,
|
||||
const gchar *id_stack)
|
||||
dialog_adjustments_set_frac_hours (CcNightLightDialog *self,
|
||||
gdouble value,
|
||||
const gchar *id_hours,
|
||||
const gchar *id_mins,
|
||||
const gchar *id_stack)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
gdouble hours;
|
||||
|
@ -159,7 +159,7 @@ dialog_adjustments_set_frac_hours (CcNaturalLightDialog *self,
|
|||
}
|
||||
|
||||
static void
|
||||
dialog_update_state (CcNaturalLightDialog *self)
|
||||
dialog_update_state (CcNightLightDialog *self)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gboolean automatic;
|
||||
|
@ -181,7 +181,7 @@ dialog_update_state (CcNaturalLightDialog *self)
|
|||
gtk_widget_set_visible (widget, disabled_until_tomorrow);
|
||||
|
||||
/* make things insensitive if the switch is disabled */
|
||||
enabled = g_settings_get_boolean (self->settings_display, "natural-light-enabled");
|
||||
enabled = g_settings_get_boolean (self->settings_display, "night-light-enabled");
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "radio_automatic"));
|
||||
gtk_widget_set_sensitive (widget, enabled);
|
||||
automatic = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
|
||||
|
@ -207,14 +207,14 @@ dialog_update_state (CcNaturalLightDialog *self)
|
|||
}
|
||||
else
|
||||
{
|
||||
value = g_settings_get_double (self->settings_display, "natural-light-schedule-from");
|
||||
value = g_settings_get_double (self->settings_display, "night-light-schedule-from");
|
||||
value = fmod (value, 24.f);
|
||||
}
|
||||
dialog_adjustments_set_frac_hours (self, value,
|
||||
"adjustment_from_hours",
|
||||
"adjustment_from_minutes",
|
||||
"stack_from");
|
||||
cc_natural_light_widget_set_from (CC_NATURAL_LIGHT_WIDGET (self->natural_light_widget), value);
|
||||
cc_night_light_widget_set_from (CC_NIGHT_LIGHT_WIDGET (self->night_light_widget), value);
|
||||
|
||||
/* set to */
|
||||
if (automatic && self->proxy_color != NULL)
|
||||
|
@ -233,44 +233,44 @@ dialog_update_state (CcNaturalLightDialog *self)
|
|||
}
|
||||
else
|
||||
{
|
||||
value = g_settings_get_double (self->settings_display, "natural-light-schedule-to");
|
||||
value = g_settings_get_double (self->settings_display, "night-light-schedule-to");
|
||||
value = fmod (value, 24.f);
|
||||
}
|
||||
dialog_adjustments_set_frac_hours (self, value,
|
||||
"adjustment_to_hours",
|
||||
"adjustment_to_minutes",
|
||||
"stack_to");
|
||||
cc_natural_light_widget_set_to (CC_NATURAL_LIGHT_WIDGET (self->natural_light_widget), value);
|
||||
cc_night_light_widget_set_to (CC_NIGHT_LIGHT_WIDGET (self->night_light_widget), value);
|
||||
|
||||
/* set new time */
|
||||
cc_natural_light_widget_set_now (CC_NATURAL_LIGHT_WIDGET (self->natural_light_widget),
|
||||
cc_night_light_widget_set_now (CC_NIGHT_LIGHT_WIDGET (self->night_light_widget),
|
||||
frac_day_from_dt (dt));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dialog_tick_cb (gpointer user_data)
|
||||
{
|
||||
CcNaturalLightDialog *self = (CcNaturalLightDialog *) user_data;
|
||||
CcNightLightDialog *self = (CcNightLightDialog *) user_data;
|
||||
dialog_update_state (self);
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_enabled_notify_cb (GtkSwitch *sw, GParamSpec *pspec, CcNaturalLightDialog *self)
|
||||
dialog_enabled_notify_cb (GtkSwitch *sw, GParamSpec *pspec, CcNightLightDialog *self)
|
||||
{
|
||||
g_settings_set_boolean (self->settings_display, "natural-light-enabled",
|
||||
g_settings_set_boolean (self->settings_display, "night-light-enabled",
|
||||
gtk_switch_get_active (sw));
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_mode_changed_cb (GtkToggleButton *togglebutton, CcNaturalLightDialog *self)
|
||||
dialog_mode_changed_cb (GtkToggleButton *togglebutton, CcNightLightDialog *self)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gboolean ret;
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "radio_automatic"));
|
||||
ret = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
|
||||
g_settings_set_boolean (self->settings_display, "natural-light-schedule-automatic", ret);
|
||||
g_settings_set_boolean (self->settings_display, "night-light-schedule-automatic", ret);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -289,7 +289,7 @@ dialog_undisable_call_cb (GObject *source_object, GAsyncResult *res, gpointer us
|
|||
}
|
||||
|
||||
static void
|
||||
dialog_undisable_clicked_cb (GtkButton *button, CcNaturalLightDialog *self)
|
||||
dialog_undisable_clicked_cb (GtkButton *button, CcNightLightDialog *self)
|
||||
{
|
||||
g_dbus_proxy_call (self->proxy_color_props,
|
||||
"Set",
|
||||
|
@ -305,7 +305,7 @@ dialog_undisable_clicked_cb (GtkButton *button, CcNaturalLightDialog *self)
|
|||
}
|
||||
|
||||
static gdouble
|
||||
dialog_adjustments_get_frac_hours (CcNaturalLightDialog *self,
|
||||
dialog_adjustments_get_frac_hours (CcNightLightDialog *self,
|
||||
const gchar *id_hours,
|
||||
const gchar *id_mins,
|
||||
const gchar *id_stack)
|
||||
|
@ -324,7 +324,7 @@ dialog_adjustments_get_frac_hours (CcNaturalLightDialog *self,
|
|||
}
|
||||
|
||||
static void
|
||||
dialog_time_from_value_changed_cb (GtkAdjustment *adjustment, CcNaturalLightDialog *self)
|
||||
dialog_time_from_value_changed_cb (GtkAdjustment *adjustment, CcNightLightDialog *self)
|
||||
{
|
||||
gdouble value;
|
||||
|
||||
|
@ -332,17 +332,17 @@ dialog_time_from_value_changed_cb (GtkAdjustment *adjustment, CcNaturalLightDial
|
|||
return;
|
||||
|
||||
value = dialog_adjustments_get_frac_hours (self,
|
||||
"adjustment_from_hours",
|
||||
"adjustment_from_minutes",
|
||||
"stack_from");
|
||||
"adjustment_from_hours",
|
||||
"adjustment_from_minutes",
|
||||
"stack_from");
|
||||
if (value >= 24.f)
|
||||
value = fmod (value, 24);
|
||||
g_debug ("new value = %.3f", value);
|
||||
g_settings_set_double (self->settings_display, "natural-light-schedule-from", value);
|
||||
g_settings_set_double (self->settings_display, "night-light-schedule-from", value);
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_time_to_value_changed_cb (GtkAdjustment *adjustment, CcNaturalLightDialog *self)
|
||||
dialog_time_to_value_changed_cb (GtkAdjustment *adjustment, CcNightLightDialog *self)
|
||||
{
|
||||
gdouble value;
|
||||
|
||||
|
@ -356,14 +356,14 @@ dialog_time_to_value_changed_cb (GtkAdjustment *adjustment, CcNaturalLightDialog
|
|||
if (value >= 24.f)
|
||||
value = fmod (value, 24);
|
||||
g_debug ("new value = %.3f", value);
|
||||
g_settings_set_double (self->settings_display, "natural-light-schedule-to", value);
|
||||
g_settings_set_double (self->settings_display, "night-light-schedule-to", value);
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_color_properties_changed_cb (GDBusProxy *proxy,
|
||||
GVariant *changed_properties,
|
||||
GStrv invalidated_properties,
|
||||
CcNaturalLightDialog *self)
|
||||
CcNightLightDialog *self)
|
||||
{
|
||||
dialog_update_state (self);
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ dialog_color_properties_changed_cb (GDBusProxy *proxy,
|
|||
static void
|
||||
dialog_got_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
||||
{
|
||||
CcNaturalLightDialog *self = (CcNaturalLightDialog *) user_data;
|
||||
CcNightLightDialog *self = (CcNightLightDialog *) user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
self->proxy_color = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
if (self->proxy_color == NULL)
|
||||
|
@ -388,7 +388,7 @@ dialog_got_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_da
|
|||
static void
|
||||
dialog_got_proxy_props_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
||||
{
|
||||
CcNaturalLightDialog *self = (CcNaturalLightDialog *) user_data;
|
||||
CcNightLightDialog *self = (CcNightLightDialog *) user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
self->proxy_color_props = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
if (self->proxy_color_props == NULL)
|
||||
|
@ -399,7 +399,7 @@ dialog_got_proxy_props_cb (GObject *source_object, GAsyncResult *res, gpointer u
|
|||
}
|
||||
|
||||
static gboolean
|
||||
dialog_format_minutes_combobox (GtkSpinButton *spin, CcNaturalLightDialog *self)
|
||||
dialog_format_minutes_combobox (GtkSpinButton *spin, CcNightLightDialog *self)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
g_autofree gchar *text = NULL;
|
||||
|
@ -410,7 +410,7 @@ dialog_format_minutes_combobox (GtkSpinButton *spin, CcNaturalLightDialog *self)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
dialog_format_hours_combobox (GtkSpinButton *spin, CcNaturalLightDialog *self)
|
||||
dialog_format_hours_combobox (GtkSpinButton *spin, CcNightLightDialog *self)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
g_autofree gchar *text = NULL;
|
||||
|
@ -424,7 +424,7 @@ dialog_format_hours_combobox (GtkSpinButton *spin, CcNaturalLightDialog *self)
|
|||
}
|
||||
|
||||
static void
|
||||
dialog_update_adjustments (CcNaturalLightDialog *self)
|
||||
dialog_update_adjustments (CcNightLightDialog *self)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
GtkWidget *widget;
|
||||
|
@ -467,13 +467,13 @@ dialog_update_adjustments (CcNaturalLightDialog *self)
|
|||
}
|
||||
|
||||
static void
|
||||
dialog_settings_changed_cb (GSettings *settings_display, gchar *key, CcNaturalLightDialog *self)
|
||||
dialog_settings_changed_cb (GSettings *settings_display, gchar *key, CcNightLightDialog *self)
|
||||
{
|
||||
dialog_update_state (self);
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_clock_settings_changed_cb (GSettings *settings_display, gchar *key, CcNaturalLightDialog *self)
|
||||
dialog_clock_settings_changed_cb (GSettings *settings_display, gchar *key, CcNightLightDialog *self)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
GtkWidget *widget;
|
||||
|
@ -500,46 +500,46 @@ dialog_clock_settings_changed_cb (GSettings *settings_display, gchar *key, CcNat
|
|||
}
|
||||
|
||||
static void
|
||||
dialog_am_pm_from_button_clicked_cb (GtkButton *button, CcNaturalLightDialog *self)
|
||||
dialog_am_pm_from_button_clicked_cb (GtkButton *button, CcNightLightDialog *self)
|
||||
{
|
||||
gdouble value;
|
||||
value = g_settings_get_double (self->settings_display, "natural-light-schedule-from");
|
||||
value = g_settings_get_double (self->settings_display, "night-light-schedule-from");
|
||||
if (value > 12.f)
|
||||
value -= 12.f;
|
||||
else
|
||||
value += 12.f;
|
||||
if (value >= 24.f)
|
||||
value = fmod (value, 24);
|
||||
g_settings_set_double (self->settings_display, "natural-light-schedule-from", value);
|
||||
g_settings_set_double (self->settings_display, "night-light-schedule-from", value);
|
||||
g_debug ("new value = %.3f", value);
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_am_pm_to_button_clicked_cb (GtkButton *button, CcNaturalLightDialog *self)
|
||||
dialog_am_pm_to_button_clicked_cb (GtkButton *button, CcNightLightDialog *self)
|
||||
{
|
||||
gdouble value;
|
||||
value = g_settings_get_double (self->settings_display, "natural-light-schedule-to");
|
||||
value = g_settings_get_double (self->settings_display, "night-light-schedule-to");
|
||||
if (value > 12.f)
|
||||
value -= 12.f;
|
||||
else
|
||||
value += 12.f;
|
||||
if (value >= 24.f)
|
||||
value = fmod (value, 24);
|
||||
g_settings_set_double (self->settings_display, "natural-light-schedule-to", value);
|
||||
g_settings_set_double (self->settings_display, "night-light-schedule-to", value);
|
||||
g_debug ("new value = %.3f", value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dialog_delete_event_cb (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
CcNaturalLightDialog *self)
|
||||
CcNightLightDialog *self)
|
||||
{
|
||||
gtk_widget_hide (widget);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
cc_natural_light_dialog_init (CcNaturalLightDialog *self)
|
||||
cc_night_light_dialog_init (CcNightLightDialog *self)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GtkAdjustment *adj;
|
||||
|
@ -569,13 +569,13 @@ cc_natural_light_dialog_init (CcNaturalLightDialog *self)
|
|||
/* connect widgets */
|
||||
sw = GTK_WIDGET (gtk_builder_get_object (self->builder, "switch_enable"));
|
||||
g_settings_bind (self->settings_display,
|
||||
"natural-light-enabled",
|
||||
"night-light-enabled",
|
||||
GTK_SWITCH (sw),
|
||||
"active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_signal_connect (sw, "notify::active",
|
||||
G_CALLBACK (dialog_enabled_notify_cb), self);
|
||||
g_settings_bind_writable (self->settings_display, "natural-light-enabled",
|
||||
g_settings_bind_writable (self->settings_display, "night-light-enabled",
|
||||
sw, "sensitive",
|
||||
FALSE);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "radio_automatic"));
|
||||
|
@ -613,7 +613,7 @@ cc_natural_light_dialog_init (CcNaturalLightDialog *self)
|
|||
g_signal_connect (widget, "clicked",
|
||||
G_CALLBACK (dialog_am_pm_to_button_clicked_cb), self);
|
||||
|
||||
self->main_window = GTK_WIDGET (gtk_builder_get_object (self->builder, "window_natural_light"));
|
||||
self->main_window = GTK_WIDGET (gtk_builder_get_object (self->builder, "window_night_light"));
|
||||
g_signal_connect (self->main_window, "delete-event",
|
||||
G_CALLBACK (dialog_delete_event_cb), self);
|
||||
|
||||
|
@ -651,11 +651,11 @@ cc_natural_light_dialog_init (CcNaturalLightDialog *self)
|
|||
G_CALLBACK (dialog_format_minutes_combobox), self);
|
||||
|
||||
/* add custom widget */
|
||||
self->natural_light_widget = cc_natural_light_widget_new ();
|
||||
gtk_widget_set_size_request (self->natural_light_widget, -1, 34);
|
||||
self->night_light_widget = cc_night_light_widget_new ();
|
||||
gtk_widget_set_size_request (self->night_light_widget, -1, 34);
|
||||
box = GTK_BOX (gtk_builder_get_object (self->builder, "box_content"));
|
||||
gtk_box_pack_start (box, self->natural_light_widget, FALSE, FALSE, 0);
|
||||
gtk_widget_show (self->natural_light_widget);
|
||||
gtk_box_pack_start (box, self->night_light_widget, FALSE, FALSE, 0);
|
||||
gtk_widget_show (self->night_light_widget);
|
||||
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
|
@ -687,9 +687,9 @@ cc_natural_light_dialog_init (CcNaturalLightDialog *self)
|
|||
dialog_update_state (self);
|
||||
}
|
||||
|
||||
CcNaturalLightDialog *
|
||||
cc_natural_light_dialog_new (void)
|
||||
CcNightLightDialog *
|
||||
cc_night_light_dialog_new (void)
|
||||
{
|
||||
return g_object_new (CC_TYPE_NATURAL_LIGHT_DIALOG, NULL);
|
||||
return g_object_new (CC_TYPE_NIGHT_LIGHT_DIALOG, NULL);
|
||||
}
|
||||
|
|
@ -18,19 +18,19 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CC_NATURAL_LIGHT_DIALOG_H__
|
||||
#define __CC_NATURAL_LIGHT_DIALOG_H__
|
||||
#ifndef __CC_NIGHT_LIGHT_DIALOG_H__
|
||||
#define __CC_NIGHT_LIGHT_DIALOG_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CC_TYPE_NATURAL_LIGHT_DIALOG (cc_natural_light_dialog_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (CcNaturalLightDialog, cc_natural_light_dialog, CC, NATURAL_LIGHT_DIALOG, GObject)
|
||||
#define CC_TYPE_NIGHT_LIGHT_DIALOG (cc_night_light_dialog_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (CcNightLightDialog, cc_night_light_dialog, CC, NIGHT_LIGHT_DIALOG, GObject)
|
||||
|
||||
CcNaturalLightDialog *cc_natural_light_dialog_new (void);
|
||||
void cc_natural_light_dialog_present (CcNaturalLightDialog *self,
|
||||
GtkWindow *parent);
|
||||
CcNightLightDialog *cc_night_light_dialog_new (void);
|
||||
void cc_night_light_dialog_present (CcNightLightDialog *self,
|
||||
GtkWindow *parent);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
@ -23,10 +23,10 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <colord.h>
|
||||
|
||||
#include "cc-natural-light-widget.h"
|
||||
#include "cc-night-light-widget.h"
|
||||
#include "cc-display-resources.h"
|
||||
|
||||
struct _CcNaturalLightWidget {
|
||||
struct _CcNightLightWidget {
|
||||
GtkDrawingArea parent;
|
||||
gdouble to;
|
||||
gdouble from;
|
||||
|
@ -35,26 +35,26 @@ struct _CcNaturalLightWidget {
|
|||
cairo_surface_t *surface_sunset;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (CcNaturalLightWidget, cc_natural_light_widget, GTK_TYPE_DRAWING_AREA);
|
||||
G_DEFINE_TYPE (CcNightLightWidget, cc_night_light_widget, GTK_TYPE_DRAWING_AREA);
|
||||
|
||||
static gboolean cc_natural_light_widget_draw (GtkWidget *widget, cairo_t *cr);
|
||||
static gboolean cc_night_light_widget_draw (GtkWidget *widget, cairo_t *cr);
|
||||
|
||||
void
|
||||
cc_natural_light_widget_set_to (CcNaturalLightWidget *self, gdouble to)
|
||||
cc_night_light_widget_set_to (CcNightLightWidget *self, gdouble to)
|
||||
{
|
||||
self->to = to;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
void
|
||||
cc_natural_light_widget_set_from (CcNaturalLightWidget *self, gdouble from)
|
||||
cc_night_light_widget_set_from (CcNightLightWidget *self, gdouble from)
|
||||
{
|
||||
self->from = from;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
void
|
||||
cc_natural_light_widget_set_now (CcNaturalLightWidget *self, gdouble now)
|
||||
cc_night_light_widget_set_now (CcNightLightWidget *self, gdouble now)
|
||||
{
|
||||
self->now = now;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
@ -62,23 +62,23 @@ cc_natural_light_widget_set_now (CcNaturalLightWidget *self, gdouble now)
|
|||
|
||||
|
||||
static void
|
||||
cc_natural_light_widget_finalize (GObject *object)
|
||||
cc_night_light_widget_finalize (GObject *object)
|
||||
{
|
||||
CcNaturalLightWidget *self = CC_NATURAL_LIGHT_WIDGET (object);
|
||||
CcNightLightWidget *self = CC_NIGHT_LIGHT_WIDGET (object);
|
||||
|
||||
g_clear_pointer (&self->surface_sunrise, (GDestroyNotify) cairo_surface_destroy);
|
||||
g_clear_pointer (&self->surface_sunset, (GDestroyNotify) cairo_surface_destroy);
|
||||
|
||||
G_OBJECT_CLASS (cc_natural_light_widget_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (cc_night_light_widget_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
cc_natural_light_widget_class_init (CcNaturalLightWidgetClass *klass)
|
||||
cc_night_light_widget_class_init (CcNightLightWidgetClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
object_class->finalize = cc_natural_light_widget_finalize;
|
||||
widget_class->draw = cc_natural_light_widget_draw;
|
||||
object_class->finalize = cc_night_light_widget_finalize;
|
||||
widget_class->draw = cc_night_light_widget_draw;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
|
@ -112,7 +112,7 @@ read_surface_from_resource (const gchar *path)
|
|||
}
|
||||
|
||||
static void
|
||||
cc_natural_light_widget_init (CcNaturalLightWidget *self)
|
||||
cc_night_light_widget_init (CcNightLightWidget *self)
|
||||
{
|
||||
self->to = 8;
|
||||
self->from = 16;
|
||||
|
@ -176,7 +176,7 @@ rounded_rectangle (cairo_t *cr,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
cc_natural_light_widget_draw (GtkWidget *widget, cairo_t *cr)
|
||||
cc_night_light_widget_draw (GtkWidget *widget, cairo_t *cr)
|
||||
{
|
||||
CdColorRGB color;
|
||||
CdColorRGB color_temperature;
|
||||
|
@ -187,9 +187,9 @@ cc_natural_light_widget_draw (GtkWidget *widget, cairo_t *cr)
|
|||
guint line_x = 0; /* px */
|
||||
const guint bar_voffset = arrow_sz + icon_sz;
|
||||
|
||||
CcNaturalLightWidget *self = (CcNaturalLightWidget*) widget;
|
||||
CcNightLightWidget *self = (CcNightLightWidget*) widget;
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
g_return_val_if_fail (CC_IS_NATURAL_LIGHT_WIDGET (self), FALSE);
|
||||
g_return_val_if_fail (CC_IS_NIGHT_LIGHT_WIDGET (self), FALSE);
|
||||
|
||||
cd_color_rgb_set (&color_temperature, 0.992, 0.796, 0.612);
|
||||
cd_color_rgb_set (&color_unity, 0.773, 0.862, 0.953);
|
||||
|
@ -278,8 +278,8 @@ cc_natural_light_widget_draw (GtkWidget *widget, cairo_t *cr)
|
|||
}
|
||||
|
||||
GtkWidget *
|
||||
cc_natural_light_widget_new (void)
|
||||
cc_night_light_widget_new (void)
|
||||
{
|
||||
return g_object_new (CC_TYPE_NATURAL_LIGHT_WIDGET, NULL);
|
||||
return g_object_new (CC_TYPE_NIGHT_LIGHT_WIDGET, NULL);
|
||||
}
|
||||
|
|
@ -18,23 +18,23 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CC_NATURAL_LIGHT_WIDGET_H__
|
||||
#define __CC_NATURAL_LIGHT_WIDGET_H__
|
||||
#ifndef __CC_NIGHT_LIGHT_WIDGET_H__
|
||||
#define __CC_NIGHT_LIGHT_WIDGET_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CC_TYPE_NATURAL_LIGHT_WIDGET (cc_natural_light_widget_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (CcNaturalLightWidget, cc_natural_light_widget, CC, NATURAL_LIGHT_WIDGET, GtkDrawingArea)
|
||||
#define CC_TYPE_NIGHT_LIGHT_WIDGET (cc_night_light_widget_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (CcNightLightWidget, cc_night_light_widget, CC, NIGHT_LIGHT_WIDGET, GtkDrawingArea)
|
||||
|
||||
GtkWidget *cc_natural_light_widget_new (void);
|
||||
void cc_natural_light_widget_set_to (CcNaturalLightWidget *self,
|
||||
gdouble to);
|
||||
void cc_natural_light_widget_set_from (CcNaturalLightWidget *self,
|
||||
gdouble from);
|
||||
void cc_natural_light_widget_set_now (CcNaturalLightWidget *self,
|
||||
gdouble now);
|
||||
GtkWidget *cc_night_light_widget_new (void);
|
||||
void cc_night_light_widget_set_to (CcNightLightWidget *self,
|
||||
gdouble to);
|
||||
void cc_night_light_widget_set_from (CcNightLightWidget *self,
|
||||
gdouble from);
|
||||
void cc_night_light_widget_set_now (CcNightLightWidget *self,
|
||||
gdouble now);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkDialog" id="window_natural_light">
|
||||
<object class="GtkDialog" id="window_night_light">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes" comments="This is the redshift functionality where we suppress blue light when the sun has gone down">Natural Light Filter</property>
|
||||
<property name="title" translatable="yes" comments="This is the redshift functionality where we suppress blue light when the sun has gone down">Night Light</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
|
@ -142,7 +142,7 @@
|
|||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Natural Light Filter</property>
|
||||
<property name="label" translatable="yes">Night Light</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue