[geary/wip/766133-gnotification: 11/18] Allow Notifications.Desktop to cancel its async tasks
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/766133-gnotification: 11/18] Allow Notifications.Desktop to cancel its async tasks
- Date: Tue, 16 Apr 2019 13:17:39 +0000 (UTC)
commit e95c08c59686b0f5a1e8462b75af59308052275c
Author: Michael Gratton <mike vee net>
Date: Sat Apr 13 11:45:02 2019 +1000
Allow Notifications.Desktop to cancel its async tasks
Pass a cancellable when constructed and use that for async tasks.
src/client/application/geary-controller.vala | 3 ++-
src/client/notification/notification-desktop.vala | 20 +++++++++++++-------
2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 7ff8f29b..cf75af46 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -331,7 +331,8 @@ public class GearyController : Geary.BaseObject {
this.notifications = new Notification.Desktop(
this.new_messages_monitor,
- this.application
+ this.application,
+ this.open_cancellable
);
this.main_window.conversation_list_view.grab_focus();
diff --git a/src/client/notification/notification-desktop.vala
b/src/client/notification/notification-desktop.vala
index fa8580d7..1dfc9713 100644
--- a/src/client/notification/notification-desktop.vala
+++ b/src/client/notification/notification-desktop.vala
@@ -31,12 +31,15 @@ public class Notification.Desktop : Geary.BaseObject {
private GLib.Notification? error_notification = null;
private Geary.Folder? folder = null;
private Geary.Email? email = null;
+ private GLib.Cancellable load_cancellable;
public Desktop(NewMessagesMonitor monitor,
- GearyApplication application) {
+ GearyApplication application,
+ GLib.Cancellable load_cancellable) {
this.monitor = monitor;
this.application = application;
+ this.load_cancellable = load_cancellable;
init_sound();
this.monitor.add_required_fields(REQUIRED_FIELDS);
@@ -44,6 +47,7 @@ public class Notification.Desktop : Geary.BaseObject {
}
~Desktop() {
+ this.load_cancellable.cancel();
this.monitor.new_messages_arrived.disconnect(on_new_messages_arrived);
}
@@ -79,12 +83,13 @@ public class Notification.Desktop : Geary.BaseObject {
private void on_new_messages_arrived(Geary.Folder folder,
int total,
int added) {
- if (added == 1 && monitor.last_new_message_folder != null &&
+ if (added == 1 &&
+ monitor.last_new_message_folder != null &&
monitor.last_new_message != null) {
- notify_one_message_async.begin(
+ this.notify_one_message.begin(
monitor.last_new_message_folder,
monitor.last_new_message,
- null
+ this.load_cancellable
);
} else if (added > 0) {
notify_new_mail(folder, added);
@@ -120,9 +125,10 @@ public class Notification.Desktop : Geary.BaseObject {
}
}
- private async void notify_one_message_async(Geary.Folder folder,
- Geary.Email email,
- GLib.Cancellable? cancellable) throws GLib.Error {
+ private async void notify_one_message(Geary.Folder folder,
+ Geary.Email email,
+ GLib.Cancellable? cancellable)
+ throws GLib.Error {
// used if notification is invoked
this.folder = folder;
this.email = email;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]