Skip to content

Commit 65f8b8c

Browse files
committed
Tidy up upon quitting
1 parent 97578f1 commit 65f8b8c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Application.vala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
public class Badger.Application : Gtk.Application {
2222
public bool headless = false;
2323
public bool ask_autostart = false;
24+
public Reminder[] reminders;
2425

2526
private Badger.MainWindow window;
2627

@@ -40,7 +41,7 @@ public class Badger.Application : Gtk.Application {
4041
var quit_action = new SimpleAction ("quit", null);
4142
add_action (quit_action);
4243
set_accels_for_action ("app.quit", {"<Control>q"});
43-
quit_action.activate.connect (quit);
44+
quit_action.activate.connect (tidy_up);
4445
}
4546

4647
protected override void activate () {
@@ -76,7 +77,7 @@ public class Badger.Application : Gtk.Application {
7677
}
7778

7879
if (window == null) {
79-
var reminders = set_up_reminders ();
80+
reminders = set_up_reminders ();
8081
var main = new MainGrid (reminders);
8182
window = new MainWindow (this, main);
8283

@@ -214,4 +215,11 @@ public class Badger.Application : Gtk.Application {
214215
);
215216
return reminders;
216217
}
218+
219+
public void tidy_up () {
220+
foreach (var reminder in reminders) {
221+
withdraw_notification (reminder.name);
222+
};
223+
quit ();
224+
}
217225
}

src/MainWindow.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public class Badger.MainWindow : Gtk.Window {
8989

9090
if (!settings.get_boolean ("all")) {
9191
debug ("All reminders are disabled, Badger will now go to sleep");
92-
application.quit ();
93-
};
92+
((Badger.Application)this.application).tidy_up ();
93+
}
9494

9595
return false;
9696
}

0 commit comments

Comments
 (0)