[california] Export (save) recurring event's master as iCalendar: Bug #739373



commit 72d595303db91fd0ad4f81c847c9359626543118
Author: Jim Nelson <jim yorba org>
Date:   Tue Nov 4 15:21:35 2014 -0800

    Export (save) recurring event's master as iCalendar: Bug #739373
    
    Checkbox in file chooser dialog allows user to specify saving master
    instead of generated instance, off by default.

 src/host/host-show-event.vala |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index 76de1d1..640c72d 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -248,11 +248,6 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
     }
     
     private void on_export_button_clicked() {
-        // Export as a self-contained iCalendar
-        Component.iCalendar icalendar = new Component.iCalendar(iCal.icalproperty_method.PUBLISH,
-            Component.ICAL_PRODID, Component.ICAL_VERSION, null,
-            iterate<Component.Instance>(event).to_array_list());
-        
         Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog(_("Export event as .ics"),
             Application.instance.main_window, Gtk.FileChooserAction.SAVE,
             _("_Cancel"), Gtk.ResponseType.CANCEL,
@@ -263,6 +258,15 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
         dialog.set_current_name(_("event.ics"));
         dialog.do_overwrite_confirmation = true;
         
+        // if a generated instance of a recurring event, offer to export the master event rather
+        // than this instance of it
+        Gtk.CheckButton? export_master_checkbutton = null;
+        if (event.is_generated_instance) {
+            export_master_checkbutton = new Gtk.CheckButton.with_mnemonic(_("Export _master event"));
+            export_master_checkbutton.active = false;
+            dialog.extra_widget = export_master_checkbutton;
+        }
+        
         dialog.show_all();
         int response = dialog.run();
         string filename = dialog.get_filename();
@@ -271,6 +275,16 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
         if (response != Gtk.ResponseType.ACCEPT)
             return;
         
+        // if switch available and active, export master not the generated instance
+        Component.Instance to_export = (export_master_checkbutton != null && 
export_master_checkbutton.active)
+            ? event.master
+            : event;
+        
+        // Export as a self-contained iCalendar
+        Component.iCalendar icalendar = new Component.iCalendar(iCal.icalproperty_method.PUBLISH,
+            Component.ICAL_PRODID, Component.ICAL_VERSION, null,
+            iterate<Component.Instance>(to_export).to_array_list());
+        
         try {
             FileUtils.set_contents(filename, icalendar.source);
         } catch (Error err) {


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