diff --git a/src/Widgets/calendar/CalendarView.vala b/src/Widgets/calendar/CalendarView.vala index 5bb077ec..d2e19f53 100644 --- a/src/Widgets/calendar/CalendarView.vala +++ b/src/Widgets/calendar/CalendarView.vala @@ -66,6 +66,9 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { box_buttons.add (center_button); box_buttons.add (right_button); + var new_event_button = new Gtk.Button.from_icon_name ("appointment-new-symbolic"); + new_event_button.tooltip_text = _("New event"); + events_model = CalendarModel.get_default (ECal.ClientSourceType.EVENTS); tasks_model = CalendarModel.get_default (ECal.ClientSourceType.TASKS); start_month = Util.get_start_of_month (); @@ -111,7 +114,8 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { margin_start = margin_end = 10; attach (label, 0, 0); attach (box_buttons, 1, 0); - attach (carousel, 0, 1, 2); + attach (new_event_button, 2, 0); + attach (carousel, 0, 1, 3); left_button.clicked.connect (() => { carousel.switch_child ((int) carousel.get_position () - 1, carousel.get_animation_duration ()); @@ -125,6 +129,10 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { show_today (); }); + new_event_button.clicked.connect (() => { + open_maya_with_options (selected_date, true); + }); + carousel.page_changed.connect ((index) => { events_model.change_month (-rel_postion); tasks_model.change_month (-rel_postion); @@ -244,8 +252,11 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { } // TODO: As far as maya supports it use the Dbus Activation feature to run the calendar-app. - public void show_date_in_maya (GLib.DateTime date) { - var command = "io.elementary.calendar --show-day %s".printf (date.format ("%F")); + private void open_maya_with_options (GLib.DateTime? day_to_show, bool add_event = false) { + day_to_show = day_to_show ?? new GLib.DateTime.now_local (); + var command = "io.elementary.calendar"; + command += add_event ? " --add-event" : ""; + command += " --show-day %s".printf (day_to_show.format ("%F")); try { var appinfo = AppInfo.create_from_commandline (command, null, AppInfoCreateFlags.NONE); @@ -262,6 +273,10 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { } } + public void show_date_in_maya (GLib.DateTime date) { + open_maya_with_options (date); + } + public void refresh () { show_today (true); }