[california/wip/725786-edit-recurring: 2/2] Laying down the basics



commit 13523fc5a6dc27ae8c2bdc7bfef2d82c818469c6
Author: Jim Nelson <jim yorba org>
Date:   Tue Jul 8 18:52:37 2014 -0700

    Laying down the basics

 src/activator/activator-instance-list.vala         |    2 +-
 .../activator-google-authenticating-pane.vala      |    2 +-
 .../activator-google-calendar-list-pane.vala       |    2 +-
 .../google/activator-google-login-pane.vala        |    2 +-
 src/activator/webcal/activator-webcal-pane.vala    |    2 +-
 src/host/host-create-update-event.vala             |   15 +-
 src/host/host-create-update-recurring.vala         |   12 +-
 src/host/host-quick-create-event.vala              |    2 +-
 src/host/host-show-event.vala                      |    2 +-
 src/manager/manager-calendar-list.vala             |    2 +-
 src/rc/create-update-recurring.ui                  |  201 ++++++++++++++++++--
 src/toolkit/toolkit-card.vala                      |   31 +++-
 src/toolkit/toolkit-deck.vala                      |   24 ++-
 13 files changed, 259 insertions(+), 40 deletions(-)
---
diff --git a/src/activator/activator-instance-list.vala b/src/activator/activator-instance-list.vala
index c5d560a..324deed 100644
--- a/src/activator/activator-instance-list.vala
+++ b/src/activator/activator-instance-list.vala
@@ -43,7 +43,7 @@ public class InstanceList : Gtk.Grid, Toolkit.Card {
         return true;
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
     }
     
     private void on_item_activated(Instance activator) {
diff --git a/src/activator/google/activator-google-authenticating-pane.vala 
b/src/activator/google/activator-google-authenticating-pane.vala
index e950173..cc9fbcc 100644
--- a/src/activator/google/activator-google-authenticating-pane.vala
+++ b/src/activator/google/activator-google-authenticating-pane.vala
@@ -56,7 +56,7 @@ public class GoogleAuthenticatingPane : Gtk.Grid, Toolkit.Card {
             app_id = "yorba-california-%s".printf(Application.VERSION);
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
         Message? credentials = message as Message;
         assert(credentials != null);
         
diff --git a/src/activator/google/activator-google-calendar-list-pane.vala 
b/src/activator/google/activator-google-calendar-list-pane.vala
index 8d37d7a..6dc545f 100644
--- a/src/activator/google/activator-google-calendar-list-pane.vala
+++ b/src/activator/google/activator-google-calendar-list-pane.vala
@@ -67,7 +67,7 @@ public class GoogleCalendarListPane : Gtk.Grid, Toolkit.Card {
         return label;
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
         Message? feeds = message as Message;
         assert(feeds != null);
         
diff --git a/src/activator/google/activator-google-login-pane.vala 
b/src/activator/google/activator-google-login-pane.vala
index 856db52..15d66fc 100644
--- a/src/activator/google/activator-google-login-pane.vala
+++ b/src/activator/google/activator-google-login-pane.vala
@@ -34,7 +34,7 @@ internal class GoogleLoginPane : Gtk.Grid, Toolkit.Card {
             BindingFlags.SYNC_CREATE, on_entry_changed);
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? msg) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? msg) {
         password_entry.text = "";
     }
     
diff --git a/src/activator/webcal/activator-webcal-pane.vala b/src/activator/webcal/activator-webcal-pane.vala
index c66dc91..4d3b31e 100644
--- a/src/activator/webcal/activator-webcal-pane.vala
+++ b/src/activator/webcal/activator-webcal-pane.vala
@@ -46,7 +46,7 @@ internal class WebCalActivatorPane : Gtk.Grid, Toolkit.Card {
             BindingFlags.SYNC_CREATE, on_entry_changed);
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
     }
     
     private bool on_entry_changed(Binding binding, Value source_value, ref Value target_value) {
diff --git a/src/host/host-create-update-event.vala b/src/host/host-create-update-event.vala
index f3e8cfa..5989d2b 100644
--- a/src/host/host-create-update-event.vala
+++ b/src/host/host-create-update-event.vala
@@ -104,12 +104,15 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
         update_controls();
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
-        if (message != null) {
-            event = message as Component.Event;
-            assert(event != null);
-        } else {
-            event = new Component.Event.blank();
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
+        // if jumping back, message is null but want to keep using current Event
+        if (reason != Toolkit.Card.Jump.BACK) {
+            if (message != null) {
+                event = message as Component.Event;
+                assert(event != null);
+            } else {
+                event = new Component.Event.blank();
+            }
         }
         
         update_controls();
diff --git a/src/host/host-create-update-recurring.vala b/src/host/host-create-update-recurring.vala
index deb6c0a..2993c3d 100644
--- a/src/host/host-create-update-recurring.vala
+++ b/src/host/host-create-update-recurring.vala
@@ -21,7 +21,17 @@ public class CreateUpdateRecurring : Gtk.Grid, Toolkit.Card {
     public CreateUpdateRecurring() {
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
+    }
+    
+    [GtkCallback]
+    private void on_cancel_button_clicked() {
+        jump_back();
+    }
+    
+    [GtkCallback]
+    private void on_ok_button_clicked() {
+        jump_back();
     }
 }
 
diff --git a/src/host/host-quick-create-event.vala b/src/host/host-quick-create-event.vala
index 267a0b0..e4ca931 100644
--- a/src/host/host-quick-create-event.vala
+++ b/src/host/host-quick-create-event.vala
@@ -76,7 +76,7 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
         calendar_combo_box.active = 0;
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
     }
     
     [GtkCallback]
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index d16301f..af4da0e 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -63,7 +63,7 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
         Calendar.System.instance.today_changed.disconnect(build_display);
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
         if (message == null)
             return;
         
diff --git a/src/manager/manager-calendar-list.vala b/src/manager/manager-calendar-list.vala
index 8287e7d..be48193 100644
--- a/src/manager/manager-calendar-list.vala
+++ b/src/manager/manager-calendar-list.vala
@@ -53,7 +53,7 @@ internal class CalendarList : Gtk.Grid, Toolkit.Card {
         Backing.Manager.instance.notify[Backing.Manager.PROP_IS_OPEN].disconnect(on_manager_opened_closed);
     }
     
-    public void jumped_to(Toolkit.Card? from, Value? message) {
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
     }
     
     private void on_manager_opened_closed() {
diff --git a/src/rc/create-update-recurring.ui b/src/rc/create-update-recurring.ui
index 70536bf..3796e4b 100644
--- a/src/rc/create-update-recurring.ui
+++ b/src/rc/create-update-recurring.ui
@@ -9,24 +9,199 @@
     <property name="margin_right">8</property>
     <property name="margin_top">8</property>
     <property name="margin_bottom">8</property>
-    <property name="row_homogeneous">True</property>
+    <property name="row_spacing">6</property>
     <child>
-      <placeholder/>
+      <object class="GtkCheckButton" id="make_recurring_checkbutton">
+        <property name="label" translatable="yes">_Repeating event:</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="valign">start</property>
+        <property name="use_underline">True</property>
+        <property name="xalign">0</property>
+        <property name="draw_indicator">True</property>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+        <property name="width">2</property>
+        <property name="height">1</property>
+      </packing>
     </child>
     <child>
-      <placeholder/>
+      <object class="GtkGrid" id="child_grid">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="margin_left">16</property>
+        <property name="row_spacing">6</property>
+        <property name="column_spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">Re_peats:</property>
+            <property name="use_underline">True</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">_Every:</property>
+            <property name="use_underline">True</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">En_ds:</property>
+            <property name="use_underline">True</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">4</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">_Starts:</property>
+            <property name="use_underline">True</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">3</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">_On days:</property>
+            <property name="use_underline">True</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">1</property>
+        <property name="width">2</property>
+        <property name="height">1</property>
+      </packing>
     </child>
     <child>
-      <placeholder/>
-    </child>
-    <child>
-      <placeholder/>
-    </child>
-    <child>
-      <placeholder/>
-    </child>
-    <child>
-      <placeholder/>
+      <object class="GtkButtonBox" id="buttonbox1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">end</property>
+        <property name="valign">end</property>
+        <property name="margin_top">8</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="spacing">8</property>
+        <property name="homogeneous">True</property>
+        <property name="layout_style">start</property>
+        <child>
+          <object class="GtkButton" id="cancel_button">
+            <property name="label" translatable="yes">_Cancel</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_underline">True</property>
+            <signal name="clicked" handler="on_cancel_button_clicked" 
object="CaliforniaHostCreateUpdateRecurring" swapped="no"/>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="ok_button">
+            <property name="label" translatable="yes">_OK</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="can_default">True</property>
+            <property name="has_default">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_underline">True</property>
+            <signal name="clicked" handler="on_ok_button_clicked" 
object="CaliforniaHostCreateUpdateRecurring" swapped="no"/>
+            <style>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">2</property>
+        <property name="width">2</property>
+        <property name="height">1</property>
+      </packing>
     </child>
   </template>
 </interface>
diff --git a/src/toolkit/toolkit-card.vala b/src/toolkit/toolkit-card.vala
index ed7ef81..8e2daee 100644
--- a/src/toolkit/toolkit-card.vala
+++ b/src/toolkit/toolkit-card.vala
@@ -15,6 +15,30 @@ namespace California.Toolkit {
 
 public interface Card : Gtk.Widget {
     /**
+     * Enumerates the various reasons a { link Card} may be jumped to.
+     */
+    public enum Jump {
+        /**
+         * The { link Card} was jumped to because it's home and { link jump_home} was fired by
+         * another Card.
+         */
+        HOME,
+        /**
+         * The { link Card} was jumped to because another Card fired { link jump_back} and this is
+         * the previous Card in the { link Deck}.
+         */
+        BACK,
+        /**
+         * The { link Card} was jumped directly to by another Card, either by { link card_id} or
+         * by an object instance.
+         *
+         * @see jump_to_card
+         * @see jump_to_card_by_name
+         */
+        DIRECT
+    }
+    
+    /**
      * Each { link Card} has its own identifier that should be unique within the { link Deck}.
      *
      * In the Gtk.Stack, this is its name.
@@ -124,7 +148,9 @@ public interface Card : Gtk.Widget {
      * the Deck.
      *
      * message may be null even if the Card expects one; generally this means { link jump_back}
-     * or { link jump_home} was invoked, resulting in this Card being activated.
+     * or { link jump_home} was invoked, resulting in this Card being activated.  The supplied
+     * { link Jump} reason is useful for context.  There are code paths where { link Jump.HOME}
+     * accepts a message; { link Jump.BACK} will never supply a message.
      *
      * Due to some mechanism inside of GSignal or Vala, it's possible for a caller to pass null
      * that gets translated into a Value object holding a null pointer.  Deck will watch for this
@@ -137,7 +163,8 @@ public interface Card : Gtk.Widget {
      * This is called before dealing with { link default_widget} and { link initial_focus}, so
      * changes to those properties in this call, if need be.
      */
-    public abstract void jumped_to(Card? from, Value? message);
+    // TODO: Use a JumpContext object instead.
+    public abstract void jumped_to(Card? from, Jump reason, Value? message);
     
     /**
      * Dismiss the { link Deck} due to the user requesting it be closed or cancelled.
diff --git a/src/toolkit/toolkit-deck.vala b/src/toolkit/toolkit-deck.vala
index c738acf..6592690 100644
--- a/src/toolkit/toolkit-deck.vala
+++ b/src/toolkit/toolkit-deck.vala
@@ -80,7 +80,7 @@ public class Deck : Gtk.Stack {
     private void on_child_to_top() {
         // disconnect from previous top card and push onto nav stack
         if (top != null) {
-            top.jump_to_card.disconnect(on_jump_to_card);
+            top.jump_to_card.disconnect(on_jump_to_card_instance);
             top.jump_to_card_by_name.disconnect(on_jump_to_card_by_name);
             top.jump_back.disconnect(on_jump_back);
             top.jump_home.disconnect(on_jump_home);
@@ -95,7 +95,7 @@ public class Deck : Gtk.Stack {
         // make new visible child top Card and connect to its signals
         top = visible_child as Card;
         if (top != null) {
-            top.jump_to_card.connect(on_jump_to_card);
+            top.jump_to_card.connect(on_jump_to_card_instance);
             top.jump_to_card_by_name.connect(on_jump_to_card_by_name);
             top.jump_back.connect(on_jump_back);
             top.jump_home.connect(on_jump_home);
@@ -151,7 +151,7 @@ public class Deck : Gtk.Stack {
         
         if (set_home_visible && home != null) {
             set_visible_child(home);
-            home.jumped_to(null, null);
+            home.jumped_to(null, Card.Jump.HOME, null);
         }
     }
     
@@ -187,7 +187,7 @@ public class Deck : Gtk.Stack {
         if (displaying && top == null && home != null) {
             navigation_stack.clear();
             set_visible_child(home);
-            home.jumped_to(null, null);
+            home.jumped_to(null, Card.Jump.HOME, null);
         }
     }
     
@@ -223,10 +223,10 @@ public class Deck : Gtk.Stack {
         navigation_stack.clear();
         
         set_visible_child(home);
-        home.jumped_to(null, strip_null_value(message));
+        home.jumped_to(null, Card.Jump.HOME, strip_null_value(message));
     }
     
-    private void on_jump_to_card(Card card, Card next, Value? message) {
+    private void on_jump_to_card(Card card, Card next, Card.Jump reason, Value? message) {
         // do nothing if already visible
         if (get_visible_child() == next) {
             debug("Already showing card %s", next.card_id);
@@ -242,13 +242,17 @@ public class Deck : Gtk.Stack {
         }
         
         set_visible_child(next);
-        next.jumped_to(card, strip_null_value(message));
+        next.jumped_to(card, reason, strip_null_value(message));
+    }
+    
+    private void on_jump_to_card_instance(Card card, Card next, Value? message) {
+        on_jump_to_card(card, next, Card.Jump.DIRECT, message);
     }
     
     private void on_jump_to_card_by_name(Card card, string name, Value? message) {
         Card? next = names.get(name);
         if (next != null)
-            on_jump_to_card(card, next, message);
+            on_jump_to_card(card, next, Card.Jump.DIRECT, message);
         else
             GLib.message("Card %s not found in Deck", name);
     }
@@ -256,7 +260,7 @@ public class Deck : Gtk.Stack {
     private void on_jump_back(Card card) {
         // if still not empty, next card is "back", so pop that off and jump to it
         if (!navigation_stack.is_empty)
-            on_jump_to_card(card, navigation_stack.poll_head(), null);
+            on_jump_to_card(card, navigation_stack.poll_head(), Card.Jump.BACK, null);
     }
     
     private void on_jump_home(Card card) {
@@ -264,7 +268,7 @@ public class Deck : Gtk.Stack {
         navigation_stack.clear();
         
         if (home != null)
-            on_jump_to_card(card, home, null);
+            on_jump_to_card(card, home, Card.Jump.HOME, null);
         else
             message("No home card in Deck");
     }


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