Skip to content

Commit 5bc31fa

Browse files
committed
#270: Add button for adding event
Addresses issue #270, Add button for adding event.
1 parent 87ba77e commit 5bc31fa

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/Indicator.vala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public class DateTime.Indicator : Wingpanel.Indicator {
110110
var settings_button = new Gtk.ModelButton ();
111111
settings_button.text = _("Date & Time Settings…");
112112

113+
var new_event_button = new Gtk.Button.from_icon_name ("appointment-new-symbolic");
114+
new_event_button.tooltip_text = _("New event");
115+
113116
var sep = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
114117
margin_bottom = 3,
115118
margin_top = 3

src/Widgets/calendar/CalendarView.vala

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)