Wire auxbutton and vibrator properly
[gregoa/zavai.git] / src / app_alarm.vala
index e09879f035921f6b1063f2d58c63ac740ec10231..2d2699bee642f76869118e1ecfae6942ec61284d 100644 (file)
@@ -72,7 +72,7 @@ protected class AlarmNotifierDialog : ui.notify.Notifier
     {
         var state = new zavai.led.LedState(notifier_name);
         state.set_blink(255);
-        zavai.led.aux.push_state(state);
+        zavai.led.vibrator.push_state(state);
         return true;
     }
 
@@ -103,6 +103,9 @@ public class AlarmNotifier : zavai.Resource, ui.notify.Notifier
         current = info;
         dialog = new AlarmNotifierDialog("Alarm", info.label);
 
+        if (zavai.led.auxbutton != null)
+            zavai.led.auxbutton.event += on_auxbutton;
+
         uint cancel_timeout = 0;
         cancel_timeout = Timeout.add(30 * 1000, () => {
             dialog.response(Gtk.ResponseType.CANCEL);
@@ -120,11 +123,22 @@ public class AlarmNotifier : zavai.Resource, ui.notify.Notifier
                 clock.alarm_trigger_queue.cancel(current);
                 break;
         }
+
+        if (zavai.led.auxbutton != null)
+            zavai.led.auxbutton.event -= on_auxbutton;
+
         dialog.destroy();
         dialog = null;
         current = null;
     }
 
+    protected bool on_auxbutton(ulong time, bool pressed)
+    {
+        if (dialog == null) return false;
+        dialog.response(Gtk.ResponseType.OK);
+        return true;
+    }
+
     public void on_done(clock.AlarmTriggerInfo info)
     {
         if (current == null || dialog == null || current != info) return;