@@ -196,9 +196,6 @@ public class Maya.View.CalendarView : Gtk.Box {
196196 }
197197
198198 private void action_export () {
199- /* creates a .ics file */
200- Util . save_temp_selected_calendars ();
201-
202199 var filter = new Gtk .FileFilter ();
203200 filter. add_mime_type (" text/calendar" );
204201
@@ -214,16 +211,19 @@ public class Maya.View.CalendarView : Gtk.Box {
214211 filechooser. set_current_name (_(" calendar.ics" ));
215212
216213 if (filechooser. run () == Gtk . ResponseType . ACCEPT ) {
217- var destination = filechooser . get_filename ();
218- if (destination == null ) {
219- destination = filechooser . get_current_folder ( );
220- } else if ( ! destination . has_suffix ( " .ics " ) ) {
221- destination + = " .ics " ;
214+ var events = Calendar . EventStore . get_default () . get_events ();
215+ var builder = new StringBuilder ();
216+ builder . append ( " BEGIN:VCALENDAR \n " );
217+ foreach ( ECal . Component event in events ) {
218+ builder . append (event . get_as_string ()) ;
222219 }
220+ builder. append (" END:VCALENDAR" );
221+
222+ var file = filechooser. get_file ();
223223 try {
224- GLib . Process . spawn_command_line_async ( " mv " + GLib . Environment . get_tmp_dir () + " /calendar.ics " + destination );
225- } catch (SpawnError e) {
226- warning (e. message);
224+ file . replace_contents (builder . data, null , false , FileCreateFlags . REPLACE_DESTINATION , null );
225+ } catch (Error e) {
226+ warning (" %s\n " , e. message);
227227 }
228228 }
229229
0 commit comments