[gnome-clocks] Set "needs-attention" when the timer and stopwatcg are running



commit 4617f93ec81e5a5db04b70e6c45f86c959feb768
Author: Paolo Borelli <pborelli gnome org>
Date:   Fri Aug 30 22:37:10 2013 +0200

    Set "needs-attention" when the timer and stopwatcg are running
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707153

 src/stopwatch.vala |    5 +++--
 src/timer.vala     |    5 +++--
 src/window.vala    |   21 +++++++++++++++++----
 3 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/stopwatch.vala b/src/stopwatch.vala
index 27cdea5..969b299 100644
--- a/src/stopwatch.vala
+++ b/src/stopwatch.vala
@@ -91,7 +91,7 @@ private class LapsRow : Gtk.ListBoxRow {
 
 [GtkTemplate (ui = "/org/gnome/clocks/ui/stopwatch.ui")]
 public class MainPanel : Gtk.Box, Clocks.Clock {
-    private enum State {
+    public enum State {
         RESET,
         RUNNING,
         STOPPED
@@ -107,7 +107,8 @@ public class MainPanel : Gtk.Box, Clocks.Clock {
     public HeaderBar header_bar { get; construct set; }
     public PanelId panel_id { get; construct set; }
 
-    private State state;
+    public State state { get; private set; default = State.RESET; }
+
     private GLib.Timer timer;
     private uint tick_id;
     private int current_lap;
diff --git a/src/timer.vala b/src/timer.vala
index f7f88cc..c4c1c7b 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -66,7 +66,7 @@ public class CountdownFrame : AnalogFrame {
 
 [GtkTemplate (ui = "/org/gnome/clocks/ui/timer.ui")]
 public class MainPanel : Gtk.Stack, Clocks.Clock {
-    enum State {
+    public enum State {
         STOPPED,
         RUNNING,
         PAUSED
@@ -76,7 +76,8 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
     public HeaderBar header_bar { get; construct set; }
     public PanelId panel_id { get; construct set; }
 
-    private State state;
+    public State state { get; private set; default = State.STOPPED; }
+
     private GLib.Settings settings;
     private uint tick_id;
     private double span;
diff --git a/src/window.vala b/src/window.vala
index 2f9992d..38d0ca2 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -65,6 +65,11 @@ public class Window : Gtk.ApplicationWindow {
         panels[PanelId.STOPWATCH] = new Stopwatch.MainPanel (header_bar);
         panels[PanelId.TIMER] = new Timer.MainPanel (header_bar);
 
+        var world = (World.MainPanel)panels[PanelId.WORLD];
+        var alarm = (Alarm.MainPanel)panels[PanelId.ALARM];
+        var stopwatch = (Stopwatch.MainPanel)panels[PanelId.STOPWATCH];
+        var timer = (Timer.MainPanel)panels[PanelId.TIMER];
+
         foreach (var clock in panels) {
             stack.add_titled (clock, ((Clock)clock).label, ((Clock)clock).label);
         }
@@ -86,16 +91,24 @@ public class Window : Gtk.ApplicationWindow {
             stack_id = 0;
         });
 
-        ((Alarm.MainPanel)panels[PanelId.ALARM]).ring.connect ((w) => {
-            ((World.MainPanel)panels[PanelId.WORLD]).reset_view ();
+        alarm.ring.connect ((w) => {
+            world.reset_view ();
             stack.visible_child = w;
         });
 
-        ((Timer.MainPanel)panels[PanelId.TIMER]).ring.connect ((w) => {
-            ((World.MainPanel)panels[PanelId.WORLD]).reset_view ();
+        stopwatch.notify["state"].connect ((w) => {
+            stack.child_set_property (stopwatch, "needs-attention", stopwatch.state == 
Stopwatch.MainPanel.State.RUNNING);
+        });
+
+        timer.ring.connect ((w) => {
+            world.reset_view ();
             stack.visible_child = w;
         });
 
+        timer.notify["state"].connect ((w) => {
+            stack.child_set_property (timer, "needs-attention", timer.state == 
Timer.MainPanel.State.RUNNING);
+        });
+
         stack.visible_child = panels[settings.get_enum ("panel-id")];
 
         update_header_bar ();


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