Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Settings
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
671
Issues
671
List
Boards
Labels
Service Desk
Milestones
Merge Requests
51
Merge Requests
51
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
Settings
Commits
9039eb7b
Commit
9039eb7b
authored
Feb 15, 2017
by
Richard Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display: Tweak night light dialog UI to match latest mockups
parent
2f1af82a
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
358 additions
and
294 deletions
+358
-294
panels/display/cc-display-panel.c
panels/display/cc-display-panel.c
+3
-3
panels/display/cc-night-light-dialog.c
panels/display/cc-night-light-dialog.c
+23
-11
panels/display/cc-night-light-widget.c
panels/display/cc-night-light-widget.c
+79
-46
panels/display/display.ui
panels/display/display.ui
+253
-234
No files found.
panels/display/cc-display-panel.c
View file @
9039eb7b
...
...
@@ -2833,7 +2833,7 @@ cc_display_panel_init (CcDisplayPanel *self)
output_ids
=
g_hash_table_new
(
g_direct_hash
,
g_direct_equal
);
vbox
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
1
2
);
vbox
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
2
2
);
gtk_container_add
(
GTK_CONTAINER
(
self
),
vbox
);
frame
=
gtk_frame_new
(
NULL
);
...
...
@@ -2880,8 +2880,8 @@ cc_display_panel_init (CcDisplayPanel *self)
gtk_label_set_use_underline
(
GTK_LABEL
(
label
),
TRUE
);
gtk_widget_set_margin_start
(
label
,
20
);
gtk_widget_set_margin_end
(
label
,
20
);
gtk_widget_set_margin_top
(
label
,
6
);
gtk_widget_set_margin_bottom
(
label
,
6
);
gtk_widget_set_margin_top
(
label
,
12
);
gtk_widget_set_margin_bottom
(
label
,
12
);
gtk_box_pack_start
(
GTK_BOX
(
box
),
label
,
TRUE
,
TRUE
,
0
);
priv
->
night_light_filter_label
=
label
=
gtk_label_new
(
""
);
gtk_widget_set_halign
(
label
,
GTK_ALIGN_END
);
...
...
panels/display/cc-night-light-dialog.c
View file @
9039eb7b
...
...
@@ -181,12 +181,21 @@ dialog_update_state (CcNightLightDialog *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
,
"night-light-enabled"
);
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"radio_automatic"
));
enabled
=
g_settings_get_boolean
(
self
->
settings_display
,
"night-light-enabled"
);
automatic
=
g_settings_get_boolean
(
self
->
settings_display
,
"night-light-schedule-automatic"
);
gtk_widget_set_sensitive
(
self
->
night_light_widget
,
enabled
);
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"togglebutton_automatic"
));
gtk_widget_set_sensitive
(
widget
,
enabled
);
automatic
=
gtk_toggle_button_get_active
(
GTK_TOGGLE_BUTTON
(
widget
));
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"radio_manual"
));
self
->
ignore_value_changed
=
TRUE
;
gtk_toggle_button_set_active
(
GTK_TOGGLE_BUTTON
(
widget
),
automatic
);
self
->
ignore_value_changed
=
FALSE
;
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"togglebutton_manual"
));
gtk_widget_set_sensitive
(
widget
,
enabled
);
self
->
ignore_value_changed
=
TRUE
;
gtk_toggle_button_set_active
(
GTK_TOGGLE_BUTTON
(
widget
),
!
automatic
);
self
->
ignore_value_changed
=
FALSE
;
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"box_manual"
));
gtk_widget_set_sensitive
(
widget
,
enabled
&&
!
automatic
);
...
...
@@ -270,12 +279,15 @@ dialog_enabled_notify_cb (GtkSwitch *sw, GParamSpec *pspec, CcNightLightDialog *
static
void
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
,
"night-light-schedule-automatic"
,
ret
);
if
(
self
->
ignore_value_changed
)
return
;
if
(
!
gtk_toggle_button_get_active
(
togglebutton
))
return
;
ret
=
g_settings_get_boolean
(
self
->
settings_display
,
"night-light-schedule-automatic"
);
g_settings_set_boolean
(
self
->
settings_display
,
"night-light-schedule-automatic"
,
!
ret
);
}
static
void
...
...
@@ -583,10 +595,10 @@ cc_night_light_dialog_init (CcNightLightDialog *self)
g_settings_bind_writable
(
self
->
settings_display
,
"night-light-enabled"
,
sw
,
"sensitive"
,
FALSE
);
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"
radio
_automatic"
));
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"
togglebutton
_automatic"
));
g_signal_connect
(
widget
,
"toggled"
,
G_CALLBACK
(
dialog_mode_changed_cb
),
self
);
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"
radio
_manual"
));
widget
=
GTK_WIDGET
(
gtk_builder_get_object
(
self
->
builder
,
"
togglebutton
_manual"
));
g_signal_connect
(
widget
,
"toggled"
,
G_CALLBACK
(
dialog_mode_changed_cb
),
self
);
adj
=
GTK_ADJUSTMENT
(
gtk_builder_get_object
(
self
->
builder
,
"adjustment_from_hours"
));
...
...
@@ -657,7 +669,7 @@ cc_night_light_dialog_init (CcNightLightDialog *self)
/* add custom widget */
self
->
night_light_widget
=
cc_night_light_widget_new
();
gtk_widget_set_size_request
(
self
->
night_light_widget
,
-
1
,
34
);
gtk_widget_set_size_request
(
self
->
night_light_widget
,
-
1
,
40
);
box
=
GTK_BOX
(
gtk_builder_get_object
(
self
->
builder
,
"box_content"
));
gtk_box_pack_start
(
box
,
self
->
night_light_widget
,
FALSE
,
FALSE
,
0
);
gtk_widget_show
(
self
->
night_light_widget
);
...
...
panels/display/cc-night-light-widget.c
View file @
9039eb7b
...
...
@@ -192,8 +192,10 @@ cc_night_light_widget_draw (GtkWidget *widget, cairo_t *cr)
GtkAllocation
rect
;
const
guint
arrow_sz
=
5
;
/* px */
const
guint
icon_sz
=
16
;
/* px */
const
guint
pad_upper_sz
=
6
;
/* px */
const
guint
pad_lower_sz
=
4
;
/* px */
guint
line_x
=
0
;
/* px */
const
guint
bar_voffset
=
arrow_sz
+
icon
_sz
;
guint
bar
_sz
;
CcNightLightWidget
*
self
=
(
CcNightLightWidget
*
)
widget
;
g_return_val_if_fail
(
self
!=
NULL
,
FALSE
);
...
...
@@ -202,74 +204,104 @@ cc_night_light_widget_draw (GtkWidget *widget, cairo_t *cr)
cd_color_rgb_set
(
&
color_temperature
,
0
.
992
,
0
.
796
,
0
.
612
);
cd_color_rgb_set
(
&
color_unity
,
0
.
773
,
0
.
862
,
0
.
953
);
/*
* /
* | icon_sz
* \
* <- pad_upper_sz
* /
* | bar_sz (calculated)
* \
* <- pad_lower_sz
* /
* | arrow_sz
* \
*/
gtk_widget_get_allocation
(
widget
,
&
rect
);
bar_sz
=
rect
.
height
-
(
icon_sz
+
pad_upper_sz
+
pad_lower_sz
+
arrow_sz
);
/* clip to a rounded rectangle */
cairo_save
(
cr
);
cairo_set_line_width
(
cr
,
1
);
rounded_rectangle
(
cr
,
0
,
bar_voffset
,
6
,
rect
.
width
,
rect
.
height
-
bar_voffset
-
1
);
rounded_rectangle
(
cr
,
0
,
icon_sz
+
pad_upper_sz
,
6
,
rect
.
width
,
bar_sz
);
cairo_clip
(
cr
);
/* draw each color line */
cairo_set_line_width
(
cr
,
1
);
gdouble
subsect
=
24
.
f
/
(
gdouble
)
rect
.
width
;
for
(
guint
x
=
0
;
x
<
rect
.
width
;
x
+=
1
)
if
(
gtk_widget_is_sensitive
(
widget
)
)
{
gdouble
frac_hour
=
subsect
*
x
;
if
(
frac_hour
>
self
->
now
&&
line_x
==
0
)
{
cd_color_rgb_set
(
&
color
,
0
.
333
,
0
.
333
,
0
.
333
);
line_x
=
x
;
}
else
if
(
is_frac_day_between
(
frac_hour
,
self
->
to
-
1
,
self
->
to
))
{
gdouble
frac
=
1
.
f
-
(
self
->
to
-
frac_hour
);
cd_color_rgb_interpolate
(
&
color_temperature
,
&
color_unity
,
frac
,
&
color
);
}
else
if
(
is_frac_day_between
(
frac_hour
,
self
->
from
-
1
,
self
->
from
))
{
gdouble
frac
=
self
->
from
-
frac_hour
;
cd_color_rgb_interpolate
(
&
color_temperature
,
&
color_unity
,
frac
,
&
color
);
}
else
if
(
is_frac_day_between
(
frac_hour
,
self
->
to
,
self
->
from
))
{
cd_color_rgb_copy
(
&
color_unity
,
&
color
);
}
else
cairo_set_line_width
(
cr
,
1
);
for
(
guint
x
=
0
;
x
<
rect
.
width
;
x
+=
1
)
{
cd_color_rgb_copy
(
&
color_temperature
,
&
color
);
gdouble
frac_hour
=
subsect
*
x
;
if
(
is_frac_day_between
(
frac_hour
,
self
->
to
-
1
,
self
->
to
))
{
gdouble
frac
=
1
.
f
-
(
self
->
to
-
frac_hour
);
cd_color_rgb_interpolate
(
&
color_temperature
,
&
color_unity
,
frac
,
&
color
);
}
else
if
(
is_frac_day_between
(
frac_hour
,
self
->
from
-
1
,
self
->
from
))
{
gdouble
frac
=
self
->
from
-
frac_hour
;
cd_color_rgb_interpolate
(
&
color_temperature
,
&
color_unity
,
frac
,
&
color
);
}
else
if
(
is_frac_day_between
(
frac_hour
,
self
->
to
,
self
->
from
))
{
cd_color_rgb_copy
(
&
color_unity
,
&
color
);
}
else
{
cd_color_rgb_copy
(
&
color_temperature
,
&
color
);
}
cairo_set_source_rgb
(
cr
,
color
.
R
,
color
.
G
,
color
.
B
);
cairo_move_to
(
cr
,
x
+
0
.
5
,
icon_sz
+
pad_upper_sz
);
cairo_line_to
(
cr
,
x
+
0
.
5
,
icon_sz
+
pad_upper_sz
+
bar_sz
);
cairo_stroke
(
cr
);
}
cairo_set_source_rgb
(
cr
,
color
.
R
,
color
.
G
,
color
.
B
);
cairo_move_to
(
cr
,
x
+
0
.
5
,
bar_voffset
);
cairo_line_to
(
cr
,
x
+
0
.
5
,
bar_voffset
+
rect
.
height
);
cairo_stroke
(
cr
);
}
else
{
rounded_rectangle
(
cr
,
0
,
icon_sz
+
pad_upper_sz
,
6
,
rect
.
width
,
bar_sz
);
cairo_set_source_rgb
(
cr
,
0
.
95
f
,
0
.
95
f
,
0
.
95
f
);
cairo_fill
(
cr
);
}
/* apply border */
rounded_rectangle
(
cr
,
0
,
bar_voffset
,
6
,
rect
.
width
,
rect
.
height
-
bar_voffset
-
1
);
rounded_rectangle
(
cr
,
0
,
icon_sz
+
pad_upper_sz
,
6
,
rect
.
width
,
bar_sz
);
cairo_set_source_rgb
(
cr
,
0
.
65
,
0
.
65
,
0
.
65
);
cairo_set_line_width
(
cr
,
1
);
cairo_stroke
(
cr
);
cairo_restore
(
cr
);
/* apply arrow */
cairo_move_to
(
cr
,
line_x
-
arrow_sz
+
0
.
5
,
bar_voffset
-
arrow_sz
);
cairo_line_to
(
cr
,
line_x
+
arrow_sz
+
0
.
5
,
bar_voffset
-
arrow_sz
);
cairo_line_to
(
cr
,
line_x
+
0
.
5
,
arrow_sz
+
bar_voffset
-
arrow_sz
);
cairo_close_path
(
cr
);
cairo_set_source_rgb
(
cr
,
0
.
333
,
0
.
333
,
0
.
333
);
cairo_fill
(
cr
);
if
(
gtk_widget_is_sensitive
(
widget
))
{
line_x
=
self
->
now
/
subsect
;
cairo_move_to
(
cr
,
line_x
-
arrow_sz
+
0
.
5
,
icon_sz
+
pad_upper_sz
+
bar_sz
+
pad_lower_sz
+
arrow_sz
);
cairo_line_to
(
cr
,
line_x
+
arrow_sz
+
0
.
5
,
icon_sz
+
pad_upper_sz
+
bar_sz
+
pad_lower_sz
+
arrow_sz
);
cairo_line_to
(
cr
,
line_x
+
0
.
5
,
icon_sz
+
pad_upper_sz
+
bar_sz
+
pad_lower_sz
);
cairo_close_path
(
cr
);
cairo_set_source_rgb
(
cr
,
0
.
333
,
0
.
333
,
0
.
333
);
cairo_fill
(
cr
);
}
/* draw icons */
if
(
self
->
mode
==
CC_NIGHT_LIGHT_WIDGET_MODE_AUTOMATIC
)
if
(
gtk_widget_is_sensitive
(
widget
)
&&
self
->
mode
==
CC_NIGHT_LIGHT_WIDGET_MODE_AUTOMATIC
)
{
if
(
self
->
to
<=
0
)
line_x
=
rect
.
width
-
icon_sz
;
...
...
@@ -284,6 +316,7 @@ cc_night_light_widget_draw (GtkWidget *widget, cairo_t *cr)
cairo_set_source_surface
(
cr
,
self
->
surface_sunset
,
line_x
,
0
);
cairo_paint
(
cr
);
}
return
FALSE
;
}
...
...
panels/display/display.ui
View file @
9039eb7b
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment