[gnome-clocks/wip/exalm/libhandy-1: 10/10] alarm: Use actions for alarm ringing buttons



commit cf752ab8042c78c99f18d5d3ab752d2628f95d8e
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Jun 3 19:40:13 2020 +0500

    alarm: Use actions for alarm ringing buttons

 data/ui/alarmringing.ui |  2 --
 src/alarm.vala          | 25 ++++++++++---------------
 2 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/data/ui/alarmringing.ui b/data/ui/alarmringing.ui
index 7697377..69c088f 100644
--- a/data/ui/alarmringing.ui
+++ b/data/ui/alarmringing.ui
@@ -35,7 +35,6 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <signal name="clicked" handler="stop_clicked" swapped="no"/>
                     <style>
                       <class name="clocks-button"/>
                       <class name="clocks-stop"/>
@@ -55,7 +54,6 @@
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="relief">none</property>
-                    <signal name="clicked" handler="snooze_clicked" swapped="no"/>
                     <style>
                       <class name="clocks-button"/>
                       <class name="clocks-snooze"/>
diff --git a/src/alarm.vala b/src/alarm.vala
index b650179..0d763ce 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -735,6 +735,12 @@ private class RingingPanel : Gtk.Bin {
                         dismiss ();
                     }
                 });
+
+                stop_button.action_target = ((Item) _alarm).id;
+                stop_button.action_name = "app.stop-alarm";
+
+                snooze_button.action_target = ((Item) _alarm).id;
+                snooze_button.action_name = "app.snooze-alarm";
             }
 
             update ();
@@ -747,27 +753,16 @@ private class RingingPanel : Gtk.Bin {
     private Gtk.Label title_label;
     [GtkChild]
     private Gtk.Label time_label;
+    [GtkChild]
+    private Gtk.Button stop_button;
+    [GtkChild]
+    private Gtk.Button snooze_button;
 
     construct {
         // Start ticking...
         Utils.WallClock.get_default ().tick.connect (update);
     }
 
-    [GtkCallback]
-    private void stop_clicked () requires (alarm != null) {
-        ((Item) alarm).stop ();
-    }
-
-    [GtkCallback]
-    private void snooze_clicked () requires (alarm != null) {
-        if (((Item) alarm).state != Item.State.SNOOZING) {
-            ((Item) alarm).snooze ();
-        } else {
-            // The alarm is already snoozed, simply dismiss the panel.
-            dismiss ();
-        }
-    }
-
     public virtual signal void dismiss () {
         alarm = null;
     }


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