diff --git a/core/Utils.vala b/core/Utils.vala index d3dcb2a83..b7b94e345 100644 --- a/core/Utils.vala +++ b/core/Utils.vala @@ -60,30 +60,6 @@ namespace Maya.Util { return _("On this computer"); } - /* - * ical Exportation - */ - - public void save_temp_selected_calendars () { - var calmodel = Calendar.EventStore.get_default (); - var events = calmodel.get_events (); - var builder = new StringBuilder (); - builder.append ("BEGIN:VCALENDAR\n"); - builder.append ("VERSION:2.0\n"); - foreach (ECal.Component event in events) { - builder.append (event.get_as_string ()); - } - builder.append ("END:VCALENDAR"); - - string file_path = GLib.Environment.get_tmp_dir () + "/calendar.ics"; - try { - var file = File.new_for_path (file_path); - file.replace_contents (builder.data, null, false, FileCreateFlags.REPLACE_DESTINATION, null); - } catch (Error e) { - warning ("%s\n", e.message); - } - } - public ECal.Component? copy_ecal_component (ECal.Component? original) { if (original == null) { return null; diff --git a/src/Grid/CalendarView.vala b/src/Grid/CalendarView.vala index 270fad5ec..582f05222 100644 --- a/src/Grid/CalendarView.vala +++ b/src/Grid/CalendarView.vala @@ -196,9 +196,6 @@ public class Maya.View.CalendarView : Gtk.Box { } private void action_export () { - /* creates a .ics file */ - Util.save_temp_selected_calendars (); - var filter = new Gtk.FileFilter (); filter.add_mime_type ("text/calendar"); @@ -214,16 +211,19 @@ public class Maya.View.CalendarView : Gtk.Box { filechooser.set_current_name (_("calendar.ics")); if (filechooser.run () == Gtk.ResponseType.ACCEPT) { - var destination = filechooser.get_filename (); - if (destination == null) { - destination = filechooser.get_current_folder (); - } else if (!destination.has_suffix (".ics")) { - destination += ".ics"; + var events = Calendar.EventStore.get_default ().get_events (); + var builder = new StringBuilder (); + builder.append ("BEGIN:VCALENDAR\n"); + foreach (ECal.Component event in events) { + builder.append (event.get_as_string ()); } + builder.append ("END:VCALENDAR"); + + var file = filechooser.get_file (); try { - GLib.Process.spawn_command_line_async ("mv " + GLib.Environment.get_tmp_dir () + "/calendar.ics " + destination); - } catch (SpawnError e) { - warning (e.message); + file.replace_contents (builder.data, null, false, FileCreateFlags.REPLACE_DESTINATION, null); + } catch (Error e) { + warning ("%s\n", e.message); } }