Skip to content

Commit ca3c056

Browse files
authored
GridDay: add event, not button (#897)
DRY and make Grid more agnostic of widget creation
1 parent 1941d52 commit ca3c056

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/Grid/Grid.vala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ public class Grid : Gtk.Grid {
216216
public void add_event (ECal.Component event) {
217217
foreach (var grid_day in data.values) {
218218
if (Calendar.Util.ecalcomponent_is_on_day (event, grid_day.date)) {
219-
var button = new EventButton (event);
220-
grid_day.add_event_button (button);
219+
grid_day.add_event (event);
221220
}
222221
}
223222
}
@@ -239,8 +238,7 @@ public class Grid : Gtk.Grid {
239238
foreach (var grid_day in data.values) {
240239
if (Calendar.Util.ecalcomponent_is_on_day (event, grid_day.date)) {
241240
if (!grid_day.update_event (event)) {
242-
var button = new EventButton (event);
243-
grid_day.add_event_button (button);
241+
grid_day.add_event (event);
244242
}
245243
} else {
246244
grid_day.remove_event (event);

src/Grid/GridDay.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public class Maya.View.GridDay : Gtk.EventBox {
109109
calmodel.update_event (src, comp, ECal.ObjModType.ALL);
110110
}
111111

112-
public void add_event_button (EventButton button) {
112+
public void add_event (ECal.Component component) {
113+
var button = new EventButton (component);
114+
113115
string uid = button.get_uid ();
114116
lock (event_buttons) {
115117
event_buttons.remove (uid);

0 commit comments

Comments
 (0)