[baobab/add-notification: 3/3] Show a Notification when the scan is completed



commit 9fe0fb06f94fbbc3f467c5585fa00a35e5d35966
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Wed Oct 10 15:55:52 2018 +0200

    Show a Notification when the scan is completed
    
    https://gitlab.gnome.org/GNOME/baobab/issues/3

 src/baobab-application.vala | 5 +++++
 src/baobab-window.vala      | 6 ++++++
 2 files changed, 11 insertions(+)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index 5fb6d24..05523e7 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -48,6 +48,11 @@ namespace Baobab {
         void ensure_window () {
             if (window == null) {
                 window = new Window (this);
+
+                window.focus_in_event.connect (() => {
+                    withdraw_notification ("scan-completed");
+                    return false;
+                });
             }
         }
 
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 74de8f2..cc2df0d 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -588,6 +588,12 @@ namespace Baobab {
                 if (!show_allocated_size) {
                     message (_("Could not detect occupied disk sizes."), _("Apparent sizes are shown 
instead."), Gtk.MessageType.INFO);
                 }
+
+                if (!is_active) {
+                    var notification = new Notification(_("Scan completed"));
+                    notification.set_body (_("Completed scan of ā€œ%sā€").printf 
(scanner.directory.get_parse_name ()));
+                    get_application ().send_notification ("scan-completed", notification);
+                }
             });
 
             clear_message ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]