[gnome-break-timer] Set colours for CircleCounter in CSS.



commit 8f7399f859847ce0a2cf00bfc8c4aaa1b7af71b6
Author: Dylan McCall <dylanmccall ubuntu com>
Date:   Thu Sep 12 16:26:06 2013 -0700

    Set colours for CircleCounter in CSS.
    
    Snap CircleCounter's progress indicator to exact increments, for consistency.

 settings/CircleCounter.vala       |   10 +++++++---
 settings/SettingsApplication.vala |    5 +++--
 settings/TimerBreakType.vala      |    1 -
 3 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/settings/CircleCounter.vala b/settings/CircleCounter.vala
index cee813b..c8001a9 100644
--- a/settings/CircleCounter.vala
+++ b/settings/CircleCounter.vala
@@ -26,6 +26,8 @@ public class CircleCounter : Gtk.Widget {
        protected const double LINE_WIDTH = 5.0;
        protected const int DEFAULT_RADIUS = 48;
 
+       private const double SNAP_INCREMENT = (Math.PI * 2) / 60.0;
+
        public enum Direction {
                COUNT_DOWN,
                COUNT_UP
@@ -48,6 +50,8 @@ public class CircleCounter : Gtk.Widget {
                Object ();
                this.set_has_window (false);
 
+               this.get_style_context ().add_class ("_circle-counter");
+
                this.notify["progress"].connect((s, p) => {
                        this.queue_draw ();
                });
@@ -64,9 +68,7 @@ public class CircleCounter : Gtk.Widget {
                int radius = int.min(center_x, center_y);
                double arc_radius = radius - LINE_WIDTH / 2;
 
-               // FIXME: Get some nicer colours from CSS?
-               Gdk.RGBA trough_color = style_context.get_color (state);
-               trough_color.alpha = trough_color.alpha / 5;
+               Gdk.RGBA trough_color = style_context.get_background_color (state);
                Gdk.RGBA base_color = style_context.get_color (state);
 
                Gdk.cairo_set_source_rgba (cr, trough_color);
@@ -76,6 +78,8 @@ public class CircleCounter : Gtk.Widget {
 
                double start_angle = 1.5 * Math.PI;
                double progress_angle = this.progress * Math.PI * 2.0;
+               progress_angle = (int)(progress_angle / SNAP_INCREMENT) * SNAP_INCREMENT;
+
                if (this.direction == Direction.COUNT_DOWN) {
                        if (progress_angle > 0) {
                                cr.arc (center_x, center_y, arc_radius, start_angle, start_angle - 
progress_angle);
diff --git a/settings/SettingsApplication.vala b/settings/SettingsApplication.vala
index 0ae9a6e..e2a3e88 100644
--- a/settings/SettingsApplication.vala
+++ b/settings/SettingsApplication.vala
@@ -42,8 +42,9 @@ public class SettingsApplication : Gtk.Application {
                        font-size: small;
                }
 
-               ._break-status-icon {
-                       opacity: 0.2;
+               ._circle-counter {
+                       color: @scrollbar_slider_prelight;
+                       background-color: @scrollbar_trough;
                }
                """;
 
diff --git a/settings/TimerBreakType.vala b/settings/TimerBreakType.vala
index 24794ea..c612a7a 100644
--- a/settings/TimerBreakType.vala
+++ b/settings/TimerBreakType.vala
@@ -117,7 +117,6 @@ public abstract class TimerBreakStatusPanel : BreakStatusPanel {
                // FIXME: This is an application icon. It doesn't make sense here.
                this.circle_counter = new CircleCounter ();
                this.attach (this.circle_counter, 0, 0, 1, 1);
-               this.circle_counter.get_style_context ().add_class ("_break-status-icon");
 
                var labels_grid = new Gtk.Grid ();
                this.attach (labels_grid, 1, 0, 1, 1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]