[gnome-clocks] Fix a problem with duplicate alarms patch



commit 055aacd7d8811284469f0f2d21240b4c30c278db
Author: Saurabh_P <srp201201051 gmail com>
Date:   Thu Feb 13 23:32:53 2014 +0530

    Fix a problem with duplicate alarms patch
    
    We need to ensure GtkCallbacks have the proper signature and use the
    proper signal for GtkSwitch. We need to connect manually since
    notifi::active does not seem to work from the .ui file.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=697659

 data/ui/alarmsetupdialog.ui |    5 ++---
 src/alarm.vala              |   40 ++++++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/data/ui/alarmsetupdialog.ui b/data/ui/alarmsetupdialog.ui
index fd791fd..bb01be4 100644
--- a/data/ui/alarmsetupdialog.ui
+++ b/data/ui/alarmsetupdialog.ui
@@ -134,8 +134,8 @@
                     <property name="adjustment">m_adjustment</property>
                     <property name="numeric">True</property>
                     <property name="wrap">True</property>
+                    <signal name="value-changed" handler="spinbuttons_changed" 
object="ClocksAlarmSetupDialog" swapped="no"/>
                     <signal name="output" handler="show_leading_zeros" object="ClocksAlarmSetupDialog" 
swapped="no"/>
-                    <signal name="value-changed" handler="avert_duplicate_alarm" swapped="no"/>
                   </object>
                   <packing>
                     <property name="left_attach">3</property>
@@ -180,8 +180,8 @@
                     <property name="adjustment">h_adjustment</property>
                     <property name="numeric">True</property>
                     <property name="wrap">True</property>
+                    <signal name="value-changed" handler="spinbuttons_changed" 
object="ClocksAlarmSetupDialog" swapped="no"/>
                     <signal name="output" handler="show_leading_zeros" object="ClocksAlarmSetupDialog" 
swapped="no"/>
-                    <signal name="value-changed" handler="avert_duplicate_alarm" swapped="no"/>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
@@ -316,7 +316,6 @@
                     <property name="can_focus">True</property>
                     <property name="halign">start</property>
                     <property name="valign">center</property>
-                    <signal name="state-flags-changed" handler="avert_duplicate_alarm" swapped="no"/>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
diff --git a/src/alarm.vala b/src/alarm.vala
index bcab3f5..7bc03dd 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -180,7 +180,7 @@ private class Item : Object, ContentItem {
         state = State.READY;
     }
 
-    public bool compare_with_item (Item i) {
+    private bool compare_with_item (Item i) {
         return (this.alarm_time.compare (i.alarm_time) == 0 && this.active && i.active);
     }
 
@@ -335,7 +335,7 @@ private class SetupDialog : Gtk.Dialog {
             day_buttons[i] = button;
 
             day_buttons[i].toggled.connect (() => {
-                avert_duplicate_alarm ();
+                avoid_duplicate_alarm ();
             });
         }
 
@@ -347,21 +347,11 @@ private class SetupDialog : Gtk.Dialog {
             day_buttons_box.pack_start (day_buttons[day_number]);
         }
 
-        set_from_alarm (alarm);
-    }
-
-    [GtkCallback]
-    private void avert_duplicate_alarm () {
-        var alarm = new Item ();
-        apply_to_alarm (alarm);
+        active_switch.notify["active"].connect (() => {
+            avoid_duplicate_alarm ();
+        });
 
-        if (alarm.check_duplicate_alarm (alarms_list)) {
-            this.set_response_sensitive (1, false);
-            label_revealer.set_reveal_child (true);
-        } else {
-            this.set_response_sensitive (1, true);
-            label_revealer.set_reveal_child (false);
-        }
+        set_from_alarm (alarm);
     }
 
     // Sets up the dialog to show the values of alarm.
@@ -442,6 +432,24 @@ private class SetupDialog : Gtk.Dialog {
         }
     }
 
+    private void avoid_duplicate_alarm () {
+        var alarm = new Item ();
+        apply_to_alarm (alarm);
+
+        if (alarm.check_duplicate_alarm (alarms_list)) {
+            this.set_response_sensitive (1, false);
+            label_revealer.set_reveal_child (true);
+        } else {
+            this.set_response_sensitive (1, true);
+            label_revealer.set_reveal_child (false);
+        }
+    }
+
+    [GtkCallback]
+    private void spinbuttons_changed (Gtk.SpinButton spin_button) {
+        avoid_duplicate_alarm ();
+    }
+
     [GtkCallback]
     private bool show_leading_zeros (Gtk.SpinButton spin_button) {
         spin_button.set_text ("%02i".printf (spin_button.get_value_as_int ()));


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