[gnome-software/wip/temp/ubuntu-xenial-rebased: 240/326] Show ask for refresh dialog only when visible



commit 2ba523b67eee8241b0d49da2a31dd92efdda7419
Author: William Hua <william hua canonical com>
Date:   Thu Apr 14 20:23:12 2016 -0400

    Show ask for refresh dialog only when visible

 src/plugins/gs-plugin-appstream.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index e028e25..eb7fba3 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -209,17 +209,19 @@ ask_refresh (gpointer user_data)
 
        parent = gtk_application_get_active_window (GTK_APPLICATION (application));
 
-       dialog = gtk_message_dialog_new (parent,
-                                        GTK_DIALOG_MODAL |
-                                        GTK_DIALOG_DESTROY_WITH_PARENT,
-                                        GTK_MESSAGE_QUESTION,
-                                        GTK_BUTTONS_YES_NO,
-                                        _("An update is needed to show all installable apps. Download 
now?"));
-
-       if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
-               start_refresh (user_data);
-
-       gtk_widget_destroy (dialog);
+       if (gtk_widget_is_visible (GTK_WIDGET (parent))) {
+               dialog = gtk_message_dialog_new (parent,
+                                                GTK_DIALOG_MODAL |
+                                                GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                GTK_MESSAGE_QUESTION,
+                                                GTK_BUTTONS_YES_NO,
+                                                _("An update is needed to show all installable apps. 
Download now?"));
+
+               if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
+                       start_refresh (user_data);
+
+               gtk_widget_destroy (dialog);
+       }
 
        return G_SOURCE_REMOVE;
 }


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