@@ -64,6 +64,9 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid {
6464 box_buttons. add (center_button);
6565 box_buttons. add (right_button);
6666
67+ var new_event_button = new Gtk .Button .from_icon_name (" appointment-new-symbolic" );
68+ new_event_button. tooltip_text = _(" New event" );
69+
6770 events_model = CalendarModel . get_default (ECal . ClientSourceType . EVENTS );
6871 tasks_model = CalendarModel . get_default (ECal . ClientSourceType . TASKS );
6972 start_month = Util . get_start_of_month ();
@@ -108,7 +111,8 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid {
108111 margin_start = margin_end = 10 ;
109112 attach (label, 0 , 0 );
110113 attach (box_buttons, 1 , 0 );
111- attach (carousel, 0 , 1 , 2 );
114+ attach (new_event_button, 2 , 0 );
115+ attach (carousel, 0 , 1 , 3 );
112116
113117 left_button. clicked. connect (() = > {
114118 carousel. switch_child ((int ) carousel. get_position () - 1 , carousel. get_animation_duration ());
@@ -122,6 +126,10 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid {
122126 show_today ();
123127 });
124128
129+ new_event_button. clicked. connect (() = > {
130+ open_maya_with_options (selected_date, true );
131+ });
132+
125133 carousel. page_changed. connect ((index) = > {
126134 events_model. change_month (- rel_postion);
127135 tasks_model. change_month (- rel_postion);
@@ -241,8 +249,11 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid {
241249 }
242250
243251 // TODO: As far as maya supports it use the Dbus Activation feature to run the calendar-app.
244- public void show_date_in_maya (GLib .DateTime date ) {
245- var command = " io.elementary.calendar --show-day %s " . printf (date. format (" %F " ));
252+ private void open_maya_with_options (GLib .DateTime ? day_to_show , bool add_event = false ) {
253+ day_to_show = day_to_show ?? new GLib .DateTime .now_local ();
254+ var command = " io.elementary.calendar" ;
255+ command + = add_event ? " --add-event" : " " ;
256+ command + = " --show-day %s " . printf (day_to_show. format (" %F " ));
246257
247258 try {
248259 var appinfo = AppInfo . create_from_commandline (command, null , AppInfoCreateFlags . NONE );
@@ -259,6 +270,10 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid {
259270 }
260271 }
261272
273+ public void show_date_in_maya (GLib .DateTime date ) {
274+ open_maya_with_options (date);
275+ }
276+
262277 public void refresh () {
263278 show_today (true );
264279 }
0 commit comments