[gnome-software] Don't notify for available updates if we have a window open and active



commit 62610d8f35437d3acd30490287f4402cc7a609f4
Author: Richard Hughes <richard hughsie com>
Date:   Tue Nov 12 09:29:23 2013 +0000

    Don't notify for available updates if we have a window open and active
    
    Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=710880

 src/gs-application.c    |   14 ++++++++++++++
 src/gs-application.h    |    2 ++
 src/gs-update-monitor.c |    3 +++
 3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 53e3026..200946d 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -60,6 +60,20 @@ struct _GsApplicationClass {
 
 G_DEFINE_TYPE (GsApplication, gs_application, GTK_TYPE_APPLICATION);
 
+gboolean
+gs_application_has_active_window (GsApplication *application)
+{
+       GList *windows;
+       GList *l;
+
+       windows = gtk_application_get_windows (GTK_APPLICATION (application));
+       for (l = windows; l != NULL; l = l->next) {
+               if (gtk_window_is_active (GTK_WINDOW (l->data)))
+                       return TRUE;
+       }
+       return FALSE;
+}
+
 static void
 gs_application_init (GsApplication *application)
 {
diff --git a/src/gs-application.h b/src/gs-application.h
index b0875c5..7343c38 100644
--- a/src/gs-application.h
+++ b/src/gs-application.h
@@ -33,6 +33,8 @@ typedef struct _GsApplicationClass    GsApplicationClass;
 GType           gs_application_get_type        (void);
 GsApplication  *gs_application_new             (void);
 
+gboolean        gs_application_has_active_window       (GsApplication *application);
+
 #endif  /* __GS_APPLICATION_H */
 
 /* vim: set noexpandtab: */
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 4380b9b..b51b5d9 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -90,6 +90,9 @@ notify_offline_update_available (GsUpdateMonitor *monitor)
        if (monitor->offline_update_notified)
                return;
 
+       if (gs_application_has_active_window (GS_APPLICATION (monitor->application)))
+               return;
+
        monitor->offline_update_notified = TRUE;
 
        /* don't notify more often than once every hour */


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