[gnome-control-center] display: Only show the sunset/sunrise icons when not manually specified
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] display: Only show the sunset/sunrise icons when not manually specified
- Date: Tue, 14 Feb 2017 11:21:01 +0000 (UTC)
commit 2f1af82a4ef46e838dd1d3691575d84f11452284
Author: Richard Hughes <richard hughsie com>
Date: Tue Feb 14 11:20:06 2017 +0000
display: Only show the sunset/sunrise icons when not manually specified
panels/display/cc-night-light-dialog.c | 5 ++++
panels/display/cc-night-light-widget.c | 36 ++++++++++++++++++++-----------
panels/display/cc-night-light-widget.h | 8 +++++++
3 files changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/panels/display/cc-night-light-dialog.c b/panels/display/cc-night-light-dialog.c
index d29b18a..66117ed 100644
--- a/panels/display/cc-night-light-dialog.c
+++ b/panels/display/cc-night-light-dialog.c
@@ -190,6 +190,11 @@ dialog_update_state (CcNightLightDialog *self)
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "box_manual"));
gtk_widget_set_sensitive (widget, enabled && !automatic);
+ /* show the sunset & sunrise icons when required */
+ cc_night_light_widget_set_mode (CC_NIGHT_LIGHT_WIDGET (self->night_light_widget),
+ automatic ? CC_NIGHT_LIGHT_WIDGET_MODE_AUTOMATIC :
+ CC_NIGHT_LIGHT_WIDGET_MODE_MANUAL);
+
/* set from */
if (automatic && self->proxy_color != NULL)
{
diff --git a/panels/display/cc-night-light-widget.c b/panels/display/cc-night-light-widget.c
index e1819c2..a7e646f 100644
--- a/panels/display/cc-night-light-widget.c
+++ b/panels/display/cc-night-light-widget.c
@@ -33,6 +33,7 @@ struct _CcNightLightWidget {
gdouble now;
cairo_surface_t *surface_sunrise;
cairo_surface_t *surface_sunset;
+ CcNightLightWidgetMode mode;
};
G_DEFINE_TYPE (CcNightLightWidget, cc_night_light_widget, GTK_TYPE_DRAWING_AREA);
@@ -60,6 +61,13 @@ cc_night_light_widget_set_now (CcNightLightWidget *self, gdouble now)
gtk_widget_queue_draw (GTK_WIDGET (self));
}
+void
+cc_night_light_widget_set_mode (CcNightLightWidget *self,
+ CcNightLightWidgetMode mode)
+{
+ self->mode = mode;
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
static void
cc_night_light_widget_finalize (GObject *object)
@@ -261,19 +269,21 @@ cc_night_light_widget_draw (GtkWidget *widget, cairo_t *cr)
cairo_fill (cr);
/* draw icons */
- if (self->to <= 0)
- line_x = rect.width - icon_sz;
- else
- line_x = MIN (MAX ((self->to / subsect) - (icon_sz / 2), 0), rect.width - icon_sz);
- cairo_set_source_surface (cr, self->surface_sunrise, line_x, 0);
- cairo_paint (cr);
- if (self->from <= 0)
- line_x = rect.width - icon_sz;
- else
- line_x = MIN (MAX ((self->from / subsect) - (icon_sz / 2), 0), rect.width - icon_sz);
- cairo_set_source_surface (cr, self->surface_sunset, line_x, 0);
- cairo_paint (cr);
-
+ if (self->mode == CC_NIGHT_LIGHT_WIDGET_MODE_AUTOMATIC)
+ {
+ if (self->to <= 0)
+ line_x = rect.width - icon_sz;
+ else
+ line_x = MIN (MAX ((self->to / subsect) - (icon_sz / 2), 0), rect.width - icon_sz);
+ cairo_set_source_surface (cr, self->surface_sunrise, line_x, 0);
+ cairo_paint (cr);
+ if (self->from <= 0)
+ line_x = rect.width - icon_sz;
+ else
+ line_x = MIN (MAX ((self->from / subsect) - (icon_sz / 2), 0), rect.width - icon_sz);
+ cairo_set_source_surface (cr, self->surface_sunset, line_x, 0);
+ cairo_paint (cr);
+ }
return FALSE;
}
diff --git a/panels/display/cc-night-light-widget.h b/panels/display/cc-night-light-widget.h
index dfdb847..979c20a 100644
--- a/panels/display/cc-night-light-widget.h
+++ b/panels/display/cc-night-light-widget.h
@@ -25,6 +25,12 @@
G_BEGIN_DECLS
+typedef enum {
+ CC_NIGHT_LIGHT_WIDGET_MODE_MANUAL,
+ CC_NIGHT_LIGHT_WIDGET_MODE_AUTOMATIC,
+ CC_NIGHT_LIGHT_WIDGET_MODE_LAST
+} CcNightLightWidgetMode;
+
#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)
@@ -35,6 +41,8 @@ void cc_night_light_widget_set_from (CcNightLightWidget *self,
gdouble from);
void cc_night_light_widget_set_now (CcNightLightWidget *self,
gdouble now);
+void cc_night_light_widget_set_mode (CcNightLightWidget *self,
+ CcNightLightWidgetMode mode);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]