[gnome-software] Only show the 'Foo is now installed' notification if the window is not active



commit b1df1eadc659fdca09335df624c073f4819d2d20
Author: Richard Hughes <richard hughsie com>
Date:   Wed Nov 13 08:59:18 2013 +0000

    Only show the 'Foo is now installed' notification if the window is not active

 src/gs-shell-details.c |    4 +++-
 src/gs-shell-search.c  |    4 +++-
 src/gs-shell.c         |   12 ++++++++++++
 src/gs-shell.h         |    2 +-
 4 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 57d1a0d..80d296f 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -745,7 +745,9 @@ gs_shell_details_app_installed_cb (GObject *source,
                return;
        }
 
-       if (gs_app_get_state (helper->app) != GS_APP_STATE_QUEUED)
+       /* only show this if the window is not active */
+       if (gs_app_get_state (helper->app) != GS_APP_STATE_QUEUED &&
+           !gs_shell_is_active (helper->shell_details->priv->shell))
                gs_app_notify_installed (helper->app);
        gs_shell_details_refresh_all (helper->shell_details);
        g_object_unref (helper->shell_details);
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 2cbcf9c..b08c46b 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -90,7 +90,9 @@ gs_shell_search_app_installed_cb (GObject *source,
                                            error);
                g_error_free (error);
        } else {
-               gs_app_notify_installed (helper->app);
+               /* only show this if the window is not active */
+               if (!gs_shell_is_active (helper->shell_search->priv->shell))
+                       gs_app_notify_installed (helper->app);
        }
        g_object_unref (helper->app);
        g_object_unref (helper->shell_search);
diff --git a/src/gs-shell.c b/src/gs-shell.c
index b060fcd..d364a57 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -80,6 +80,18 @@ enum {
 static guint signals [SIGNAL_LAST] = { 0 };
 
 /**
+ * gs_shell_is_active:
+ **/
+gboolean
+gs_shell_is_active (GsShell *shell)
+{
+       GtkWindow *window;
+       window = GTK_WINDOW (gtk_builder_get_object (shell->priv->builder,
+                                                    "window_software"));
+       return gtk_window_is_active (window);
+}
+
+/**
  * gs_shell_activate:
  **/
 void
diff --git a/src/gs-shell.h b/src/gs-shell.h
index 98119cf..3bef5ca 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -86,7 +86,7 @@ GtkWindow     *gs_shell_setup                 (GsShell        *shell,
                                                 GsPluginLoader *plugin_loader,
                                                 GCancellable   *cancellable);
 void            gs_shell_invalidate            (GsShell        *shell);
-gboolean        gs_shell_is_cache_valid        (GsShell        *shell);
+gboolean        gs_shell_is_active             (GsShell        *shell);
 
 G_END_DECLS
 


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