[california/wip/729221-quick-add] Allow user to go straight to Create/Update dialog



commit 1655bf3b1a63f1f6af3cf5f5a642a079e942ec85
Author: Jim Nelson <jim yorba org>
Date:   Tue Jun 3 16:39:45 2014 -0700

    Allow user to go straight to Create/Update dialog
    
    Also, Cancel in Create/Update dialog will close Deck.

 src/host/host-quick-create-event.vala |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/src/host/host-quick-create-event.vala b/src/host/host-quick-create-event.vala
index 609d490..be3e33b 100644
--- a/src/host/host-quick-create-event.vala
+++ b/src/host/host-quick-create-event.vala
@@ -74,16 +74,6 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
         
         // make first item active
         calendar_combo_box.active = 0;
-        
-        // enable create button only when the user has typed something
-        details_entry.bind_property("text-length", create_button, "sensitive", BindingFlags.SYNC_CREATE,
-            xform_text_length_to_sensitive);
-    }
-    
-    private bool xform_text_length_to_sensitive(Binding binding, Value source_value, ref Value target_value) 
{
-        target_value = !String.is_empty(details_entry.text);
-        
-        return true;
     }
     
     public void jumped_to(Toolkit.Card? from, Value? message) {
@@ -104,14 +94,30 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
     
     [GtkCallback]
     private void on_create_button_clicked() {
-        Component.DetailsParser parser = new Component.DetailsParser(details_entry.text, model.active,
+        string details = details_entry.text.strip();
+        
+        if (String.is_empty(details)) {
+            // jump to Create/Update dialog and remove this Card from the Deck ... this ensures
+            // that if the user presses Cancel in the Create/Update dialog the Deck exits rather
+            // than returns here (via jump_home_or_user_closed())
+            jump_to_card_by_name(CreateUpdateEvent.ID, null);
+            deck.remove_cards(iterate<Toolkit.Card>(this).to_array_list());
+            
+            return;
+        }
+        
+        Component.DetailsParser parser = new Component.DetailsParser(details, model.active,
             event);
         event = parser.event;
         
-        if (event.is_valid())
+        if (event.is_valid()) {
             create_event_async.begin(null);
-        else
+        } else {
+            // see note above about why the Deck jumps to Create/Update and then this Card is
+            // removed
             jump_to_card_by_name(CreateUpdateEvent.ID, event);
+            deck.remove_cards(iterate<Toolkit.Card>(this).to_array_list());
+        }
     }
     
     private async void create_event_async(Cancellable? cancellable) {


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