[california] Don't adjust event duration in date/time editor while typing



commit 4f1d57554f6ba32f79702f35db8102a7b59ae6c4
Author: Jim Nelson <jim yorba org>
Date:   Tue Aug 12 17:41:39 2014 -0700

    Don't adjust event duration in date/time editor while typing
    
    Last commit had one serious shortcoming: if the user was typing a
    multidigit hour, the maintained duration could swing wildly.  (For
    example, typing a "1" then a "2" for 12 could make a 1-hour duration
    become a 12-hour duration.)  This corrects that by only adjusting the
    duration if the focus has left the GtkEntry.

 src/host/host-date-time-widget.vala    |    6 ++++++
 src/host/host-event-time-settings.vala |    5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/host/host-date-time-widget.vala b/src/host/host-date-time-widget.vala
index 42942d2..4b2a804 100644
--- a/src/host/host-date-time-widget.vala
+++ b/src/host/host-date-time-widget.vala
@@ -10,6 +10,7 @@ namespace California.Host {
 public class DateTimeWidget : Gtk.Box {
     public const string PROP_ENABLE_TIME = "enable-time";
     public const string PROP_ENABLE_DATE = "enable-date";
+    public const string PROP_IN_TIME_EDIT = "in-time-edit";
     public const string PROP_DATE = "date";
     public const string PROP_WALL_TIME = "wall-time";
     public const string PROP_FLOOR = "floor";
@@ -20,6 +21,8 @@ public class DateTimeWidget : Gtk.Box {
     
     public bool enable_date { get; set; default = true; }
     
+    public bool in_time_edit { get; protected set; default = false; }
+    
     public Calendar.Date date { get; set; default = Calendar.System.today; }
     
     public Calendar.WallTime wall_time { get; set; default = Calendar.System.now.to_wall_time(); }
@@ -86,6 +89,9 @@ public class DateTimeWidget : Gtk.Box {
             hour_up, hour_down, minutes_up, minutes_down, meridiem_up, meridiem_down,
             hour_entry, colon_label, minutes_entry, meridiem_label));
         
+        hour_entry.bind_property("has-focus", this, PROP_IN_TIME_EDIT, BindingFlags.SYNC_CREATE);
+        minutes_entry.bind_property("has-focus", this, PROP_IN_TIME_EDIT, BindingFlags.SYNC_CREATE);
+        
         // set sensitivities for up/down widgets
         foreach (Gtk.Widget widget in
             iterate<Gtk.Widget>(hour_up, hour_down, minutes_up, minutes_down, meridiem_up, meridiem_down)) {
diff --git a/src/host/host-event-time-settings.vala b/src/host/host-event-time-settings.vala
index 0b58e84..ee30a08 100644
--- a/src/host/host-event-time-settings.vala
+++ b/src/host/host-event-time-settings.vala
@@ -214,8 +214,9 @@ public class EventTimeSettings : Gtk.Box, Toolkit.Card {
             other.date = new Calendar.Date.from_exact_time(adjusted);
             other.wall_time = adjusted.to_wall_time();
             thaw_widget_notifications();
-        } else {
-            // otherwise, this is the new duration to be maintained
+        } else if (!source.in_time_edit) {
+            // otherwise, this is the new duration to be maintained (but only adjust if not editing
+            // a time field ... typing numbers can lead to wild fluctuations in duration otherwise)
             duration = new Calendar.Duration(0, 0, 0, to_exact_time.difference(from_exact_time));
         }
         


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