From 63b5123edfe07fbf47b97d221dc824eeb529e218 Mon Sep 17 00:00:00 2001
From: guinux <nuxgui@gmail.com>
Date: Sat, 31 Mar 2018 16:13:37 +0200
Subject: [PATCH] display a notification when transaction is finished

---
 src/meson.build      |  2 +-
 src/transaction.vala | 29 +++++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/meson.build b/src/meson.build
index 9fadcc64..7ebe4c46 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -73,7 +73,7 @@ executable('pamac-system-daemon',
 
 libpamac = library('pamac',
 	sources: [common_sources, transaction_sources, preferences_sources, transaction_resources],
-	dependencies: [gtk3, gdk3, vte3, posix, math],
+	dependencies: [gtk3, gdk3, vte3, libnotify, posix, math],
 	vala_args: common_vala_args,
 	c_args: common_c_args,
 	install: true,
diff --git a/src/transaction.vala b/src/transaction.vala
index 21d8edce..315a4834 100644
--- a/src/transaction.vala
+++ b/src/transaction.vala
@@ -241,6 +241,8 @@ namespace Pamac {
 			timer = new Timer ();
 			success = false;
 			warning_textbuffer = new StringBuilder ();
+			// notify
+			Notify.init (dgettext (null, "Package Manager"));
 		}
 
 		public void run_preferences_dialog () {
@@ -1619,8 +1621,21 @@ namespace Pamac {
 			box.add (scrolledwindow);
 			dialog.default_width = 600;
 			dialog.default_height = 300;
-			dialog.run ();
-			dialog.destroy ();
+			dialog.show ();
+			dialog.response.connect (() => {
+				dialog.destroy ();
+			});
+			Timeout.add (1000, () => {
+				try {
+					var notification = new Notify.Notification (dgettext (null, "Package Manager"),
+																message,
+																"system-software-update");
+					notification.show ();
+				} catch (Error e) {
+					stderr.printf ("Notify Error: %s", e.message);
+				}
+				return false;
+			});
 		}
 
 		void handle_error (ErrorInfos error) {
@@ -1635,6 +1650,16 @@ namespace Pamac {
 			disconnecting_dbus_signals ();
 			transaction_summary.remove_all ();
 			reset_progress_box ("");
+			if (success) {
+				try {
+					var notification = new Notify.Notification (dgettext (null, "Package Manager"),
+																dgettext (null, "Transaction successfully finished"),
+																"system-software-update");
+					notification.show ();
+				} catch (Error e) {
+					stderr.printf ("Notify Error: %s", e.message);
+				}
+			}
 			finished (success);
 			success = false;
 		}
-- 
GitLab