Show next deadline
authorEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 17:02:11 +0000 (18:02 +0100)
committerEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 17:02:11 +0000 (18:02 +0100)
src/app_main.vala
src/clock.vala
src/zavai.vala

index 1d2882d93c9227b069062b9885c6e6991cea3617..fbe32a8f1b5974a0cb1f2ce29f2af9875a614651 100644 (file)
@@ -37,6 +37,7 @@ public class Clock : Gtk.VBox
 {
     protected Gtk.Label l_date;
     protected Gtk.Label l_time;
+    protected Gtk.Label l_deadline;
 
     public Clock()
     {
@@ -46,10 +47,29 @@ public class Clock : Gtk.VBox
         l_time = new Gtk.Label("--:--");
         l_time.modify_font(Pango.FontDescription.from_string("Sans 60"));
         pack_start(l_time, false, false, 0);
+        l_deadline = new Gtk.Label("");
+        l_deadline.modify_font(Pango.FontDescription.from_string("Sans 30"));
+        pack_start(l_deadline, false, false, 0);
 
         zavai.clock.clock.minute_changed += on_minute_changed;
+        zavai.clock.clock.schedule_changed += on_schedule_changed;
 
         zavai.clock.clock.request("ui.main.clock");
+
+        // Read the current schedule
+        on_schedule_changed();
+    }
+
+    private void on_schedule_changed()
+    {
+        zavai.clock.Alarm a = zavai.clock.clock.next_alarm();
+        if (a == null)
+            l_deadline.set_text("");
+        else
+        {
+            var t = Time.local(a.deadline);
+            l_deadline.set_text(a.label + ": " + t.format("%a %d %b %H:%M"));
+        }
     }
 
     private void on_minute_changed(long ts, zavai.clock.SourceType type)
index 3d97a901de39a1970952395a63fd434eed9c6000..394ff29e08e5622fe55859e394a526b52be3d138 100644 (file)
@@ -73,6 +73,7 @@ public class Clock: zavai.Service
 
     // Ticks once a minute
     public signal void minute_changed(long time, SourceType source);
+    public signal void schedule_changed();
 
        public Clock()
        {
@@ -107,6 +108,13 @@ public class Clock: zavai.Service
         //notification.Alarm += on_alarm;
        }
 
+    public Alarm? next_alarm()
+    {
+        if (alarms == null)
+            return null;
+        return alarms.data;
+    }
+
     public void schedule(Alarm a)
     {
         alarms.insert_sorted(a, alarm_compare);
@@ -131,6 +139,7 @@ public class Clock: zavai.Service
                 zavai.log.error("Cannot reschedule alarms: " + e.message);
             }
         }
+        schedule_changed();
     }
 
     public void check_alarms()
index 956d21213d2338cbceb7b9952029c7f4547422f6..29c92e005d372097fba924f5f4150865cd5f5b9c 100644 (file)
@@ -76,6 +76,7 @@ static int main (string[] args) {
 
        zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 10, "Test second"));
        zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 5, "Test first"));
+       zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 30, "Test third"));
 
        //zavai.ui.power.power_menu.toggle();