[california/wip/725787-remove-recurring] Done.



commit daf4035b04d79ec39cb5b97657477bd4b7dcce25
Author: Jim Nelson <jim yorba org>
Date:   Thu Jul 3 15:12:14 2014 -0700

    Done.

 src/host/host-show-event.vala |   78 ++++++------
 src/rc/show-event.ui          |  305 +++++++++++++++++++++++++++++------------
 2 files changed, 254 insertions(+), 129 deletions(-)
---
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index 11ff31d..c9f0780 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -45,8 +45,13 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
     [GtkChild]
     private Gtk.Button close_button;
     
+    [GtkChild]
+    private Gtk.Revealer button_box_revealer;
+    
+    [GtkChild]
+    private Gtk.Revealer remove_recurring_revealer;
+    
     private new Component.Event event;
-    private Gtk.Menu? remove_recurring_menu = null;
     
     public ShowEvent() {
         Calendar.System.instance.is_24hr_changed.connect(build_display);
@@ -69,8 +74,6 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
     }
     
     private void build_display() {
-        debug("%s\n", event.source);
-        
         // summary
         set_label(null, summary_text, event.summary);
         
@@ -83,25 +86,6 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
         // description
         set_label(null, description_text, Markup.linkify(escape(event.description), linkify_delegate));
         
-        // If recurring (and so this is a generated instance of the VEVENT, not the VEVENT itself),
-        // use a popup menu to ask how to remove this event
-        if (event.is_recurring) {
-            remove_recurring_menu = new Gtk.Menu();
-            
-            Gtk.MenuItem remove_all = new Gtk.MenuItem.with_mnemonic(_("Remove _All Events"));
-            remove_all.activate.connect(on_remove_recurring_all);
-            remove_recurring_menu.append(remove_all);
-            
-            Gtk.MenuItem remove_this = new Gtk.MenuItem.with_mnemonic(_("Remove Only _This Event"));
-            remove_this.activate.connect(on_remove_recurring_this);
-            remove_recurring_menu.append(remove_this);
-            
-            Gtk.MenuItem remove_following = new Gtk.MenuItem.with_mnemonic(
-                _("Remove This and All _Following Events"));
-            remove_following.activate.connect(on_remove_recurring_this_and_following);
-            remove_recurring_menu.append(remove_following);
-        }
-        
         // don't current support updating or removing recurring events properly; see
         // https://bugzilla.gnome.org/show_bug.cgi?id=725786
         bool read_only = event.calendar_source != null && event.calendar_source.read_only;
@@ -153,11 +137,14 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
     
     [GtkCallback]
     private void on_remove_button_clicked() {
+        // If recurring (and so this is a generated instance of the VEVENT, not the VEVENT itself),
+        // reveal additional remove buttons
+        //
+        // TODO: Gtk.Stack would be a better widget for this animation, but it's unavailable in
+        // Glade as of GTK+ 3.12.
         if (event.is_recurring) {
-            assert(remove_recurring_menu != null);
-            
-            remove_recurring_menu.popup(null, null, null, 0, Gtk.get_current_event_time());
-            remove_recurring_menu.show_all();
+            button_box_revealer.reveal_child = false;
+            remove_recurring_revealer.reveal_child = true;
             
             return;
         }
@@ -166,6 +153,27 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
     }
     
     [GtkCallback]
+    private void on_cancel_remove_recurring_button_clicked() {
+        button_box_revealer.reveal_child = true;
+        remove_recurring_revealer.reveal_child = false;
+    }
+    
+    [GtkCallback]
+    private void on_remove_this_button_clicked() {
+        remove_events_async.begin(event.rid, Backing.CalendarSource.AffectedInstances.THIS);
+    }
+    
+    [GtkCallback]
+    private void on_remove_future_button_clicked() {
+        remove_events_async.begin(event.rid, Backing.CalendarSource.AffectedInstances.THIS_AND_FUTURE);
+    }
+    
+    [GtkCallback]
+    private void on_remove_all_button_clicked() {
+        remove_events_async.begin(null, Backing.CalendarSource.AffectedInstances.ALL);
+    }
+    
+    [GtkCallback]
     private void on_update_button_clicked() {
         jump_to_card_by_name(CreateUpdateEvent.ID, event);
     }
@@ -194,22 +202,14 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
         if (remove_err == null) {
             notify_success();
         } else {
+            bool multiple = (rid != null) || (affected != Backing.CalendarSource.AffectedInstances.THIS);
+            
+            // No number is supplied because the number of events removed is indefinite in certain
+            // situations ... plural text should simply be for "more than one"
             notify_failure(ngettext("Unable to remove event: %s", "Unable to remove events: %s",
-                rid == null ? 1 : 2).printf(remove_err.message));
+                !multiple ? 1 : 2).printf(remove_err.message));
         }
     }
-    
-    private void on_remove_recurring_all() {
-        remove_events_async.begin(null, Backing.CalendarSource.AffectedInstances.ALL);
-    }
-    
-    private void on_remove_recurring_this() {
-        remove_events_async.begin(event.rid, Backing.CalendarSource.AffectedInstances.THIS);
-    }
-    
-    private void on_remove_recurring_this_and_following() {
-        remove_events_async.begin(event.rid, Backing.CalendarSource.AffectedInstances.THIS_AND_FUTURE);
-    }
 }
 
 }
diff --git a/src/rc/show-event.ui b/src/rc/show-event.ui
index 0763e8e..a164ec2 100644
--- a/src/rc/show-event.ui
+++ b/src/rc/show-event.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.18.3 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <template class="CaliforniaHostShowEvent" parent="GtkGrid">
@@ -26,8 +26,6 @@
       <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>
@@ -68,83 +66,6 @@
       <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>
-      <object class="GtkButtonBox" id="button_box">
-        <property name="visible">True</property>
-        <property name="can_focus">False</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="baseline_position">bottom</property>
-        <property name="layout_style">end</property>
-        <child>
-          <object class="GtkButton" id="remove_button">
-            <property name="label" translatable="yes">_Remove</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_underline">True</property>
-            <property name="image_position">bottom</property>
-            <signal name="clicked" handler="on_remove_button_clicked" object="CaliforniaHostShowEvent" 
swapped="no"/>
-            <style>
-              <class name="destructive-action"/>
-            </style>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="update_button">
-            <property name="label" translatable="yes">_Update</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="can_default">True</property>
-            <property name="receives_default">True</property>
-            <property name="use_underline">True</property>
-            <property name="image_position">bottom</property>
-            <signal name="clicked" handler="on_update_button_clicked" object="CaliforniaHostShowEvent" 
swapped="no"/>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="close_button">
-            <property name="label" translatable="yes">_Close</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>
-            <property name="image_position">bottom</property>
-            <signal name="clicked" handler="on_close_button_clicked" object="CaliforniaHostShowEvent" 
swapped="no"/>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </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>
@@ -167,8 +88,6 @@
           <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>
@@ -185,8 +104,6 @@
           <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>
@@ -201,8 +118,6 @@
           <packing>
             <property name="left_attach">1</property>
             <property name="top_attach">0</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -217,17 +132,227 @@
           <packing>
             <property name="left_attach">1</property>
             <property name="top_attach">1</property>
-            <property name="width">1</property>
-            <property name="height">1</property>
           </packing>
         </child>
       </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="GtkBox" id="box2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkRevealer" id="remove_recurring_revealer">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="transition_type">slide-right</property>
+            <property name="transition_duration">500</property>
+            <child>
+              <object class="GtkBox" id="box1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">4</property>
+                <child>
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Remove in this series:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButtonBox" id="remove_recurring_button_box">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">8</property>
+                    <property name="baseline_position">bottom</property>
+                    <property name="layout_style">end</property>
+                    <child>
+                      <object class="GtkButton" id="remove_this_button">
+                        <property name="label" translatable="yes">_This Event</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_remove_this_button_clicked" 
object="CaliforniaHostShowEvent" swapped="no"/>
+                        <style>
+                          <class name="destructive-action"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="remove_future_button">
+                        <property name="label" translatable="yes">This and _Future Events</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_remove_future_button_clicked" 
object="CaliforniaHostShowEvent" swapped="no"/>
+                        <style>
+                          <class name="destructive-action"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="remove_all_button">
+                        <property name="label" translatable="yes">_All Events</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0.56000000238418579</property>
+                        <property name="yalign">0.51999998092651367</property>
+                        <signal name="clicked" handler="on_remove_all_button_clicked" 
object="CaliforniaHostShowEvent" swapped="no"/>
+                        <style>
+                          <class name="destructive-action"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="cancel_remove_recurring_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_remove_recurring_button_clicked" 
object="CaliforniaHostShowEvent" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">4</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRevealer" id="button_box_revealer">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="transition_type">slide-left</property>
+            <property name="transition_duration">500</property>
+            <property name="reveal_child">True</property>
+            <child>
+              <object class="GtkButtonBox" id="button_box">
+                <property name="visible">True</property>
+                <property name="can_focus">False</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="baseline_position">bottom</property>
+                <property name="layout_style">end</property>
+                <child>
+                  <object class="GtkButton" id="remove_button">
+                    <property name="label" translatable="yes">_Remove</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="image_position">bottom</property>
+                    <signal name="clicked" handler="on_remove_button_clicked" 
object="CaliforniaHostShowEvent" swapped="no"/>
+                    <style>
+                      <class name="destructive-action"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="update_button">
+                    <property name="label" translatable="yes">_Update</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                    <property name="image_position">bottom</property>
+                    <signal name="clicked" handler="on_update_button_clicked" 
object="CaliforniaHostShowEvent" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="close_button">
+                    <property name="label" translatable="yes">_Close</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>
+                    <property name="image_position">bottom</property>
+                    <signal name="clicked" handler="on_close_button_clicked" 
object="CaliforniaHostShowEvent" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </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">3</property>
+      </packing>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
   </template>
 </interface>


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