[california/wip/725786-edit-recurring] Allow moving back and forth between editors and not lose information



commit 42b6cd424d27441fb4502872dd3e9c0c9827e849
Author: Jim Nelson <jim yorba org>
Date:   Wed Jul 16 14:10:50 2014 -0700

    Allow moving back and forth between editors and not lose information

 src/host/host-create-update-event.vala |   48 ++++++++++++++++++++------------
 1 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/src/host/host-create-update-event.vala b/src/host/host-create-update-event.vala
index 9de97b8..69d6731 100644
--- a/src/host/host-create-update-event.vala
+++ b/src/host/host-create-update-event.vala
@@ -281,6 +281,10 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
     
     [GtkCallback]
     private void on_recurring_button_clicked() {
+        // update the component with what's in the controls now
+        update_component(event, true);
+        
+        // send off to recurring editor
         jump_to_card_by_name(CreateUpdateRecurring.ID, event);
     }
     
@@ -299,30 +303,38 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
         create_update_event(event, true);
     }
     
-    private void create_update_event(Component.Event target, bool update_dtstart) {
+    // TODO: Now that a clone is being used for editing, can directly bind controls properties to
+    // Event's properties and update that way ... doesn't quite work when updating the master event,
+    // however
+    private void update_component(Component.Event target, bool update_dtstart) {
         target.calendar_source = calendar_model.active;
         target.summary = summary_entry.text;
         target.location = location_entry.text;
         target.description = description_textview.buffer.text;
         
-        if (update_dtstart) {
-            if (all_day_toggle.active) {
-                target.set_event_date_span(selected_date_span);
-            } else {
-                // use existing timezone unless not specified in original event
-                Calendar.Timezone tz = (target.exact_time_span != null)
-                    ? target.exact_time_span.start_exact_time.tz
-                    : Calendar.Timezone.local;
-                target.set_event_exact_time_span(
-                    new Calendar.ExactTimeSpan(
-                        new Calendar.ExactTime(tz, selected_date_span.start_date,
-                            time_map.get(dtstart_time_combo.get_active_text())),
-                        new Calendar.ExactTime(tz, selected_date_span.end_date,
-                            time_map.get(dtend_time_combo.get_active_text()))
-                    )
-                );
-            }
+        if (!update_dtstart)
+            return;
+        
+        if (all_day_toggle.active) {
+            target.set_event_date_span(selected_date_span);
+        } else {
+            // use existing timezone unless not specified in original event
+            Calendar.Timezone tz = (target.exact_time_span != null)
+                ? target.exact_time_span.start_exact_time.tz
+                : Calendar.Timezone.local;
+            target.set_event_exact_time_span(
+                new Calendar.ExactTimeSpan(
+                    new Calendar.ExactTime(tz, selected_date_span.start_date,
+                        time_map.get(dtstart_time_combo.get_active_text())),
+                    new Calendar.ExactTime(tz, selected_date_span.end_date,
+                        time_map.get(dtend_time_combo.get_active_text()))
+                )
+            );
         }
+    }
+    
+    private void create_update_event(Component.Event target, bool update_dtstart) {
+        update_component(target, update_dtstart);
         
         if (is_update)
             update_event_async.begin(target, null);


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