[epiphany] toolbar: Activate downloads popover only for active window



commit 3580f6dcfba2f65573ead2ce14c8650a9fdfad6f
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sun Jun 12 10:24:03 2016 -0500

    toolbar: Activate downloads popover only for active window
    
    We don't want to open the popover n times for n different windows, just
    once.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764303

 src/ephy-toolbar.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 7b21dd1..238cb2e 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -20,11 +20,12 @@
 #include "config.h"
 #include "ephy-toolbar.h"
 
+#include "ephy-downloads-popover.h"
+#include "ephy-downloads-progress-icon.h"
 #include "ephy-location-entry.h"
 #include "ephy-middle-clickable-button.h"
 #include "ephy-private.h"
-#include "ephy-downloads-popover.h"
-#include "ephy-downloads-progress-icon.h"
+#include "ephy-shell.h"
 
 enum {
   PROP_0,
@@ -50,6 +51,17 @@ struct _EphyToolbar {
 
 G_DEFINE_TYPE (EphyToolbar, ephy_toolbar, GTK_TYPE_HEADER_BAR)
 
+static gboolean
+toolbar_is_for_active_window (EphyToolbar *toolbar)
+{
+  EphyShell *shell = ephy_shell_get_default ();
+  GtkWindow *active_window;
+
+  active_window = gtk_application_get_active_window (GTK_APPLICATION (shell));
+
+  return active_window == GTK_WINDOW (toolbar->window);
+}
+
 static void
 download_added_cb (EphyDownloadsManager *manager,
                    EphyDownload         *download,
@@ -61,8 +73,10 @@ download_added_cb (EphyDownloadsManager *manager,
                                  toolbar->downloads_popover);
   }
 
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toolbar->downloads_button), TRUE);
   gtk_revealer_set_reveal_child (GTK_REVEALER (toolbar->downloads_revealer), TRUE);
+
+  if (toolbar_is_for_active_window (toolbar))
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toolbar->downloads_button), TRUE);
 }
 
 static void
@@ -70,7 +84,8 @@ download_completed_cb (EphyDownloadsManager *manager,
                        EphyDownload         *download,
                        EphyToolbar          *toolbar)
 {
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toolbar->downloads_button), TRUE);
+  if (toolbar_is_for_active_window (toolbar))
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toolbar->downloads_button), TRUE);
 }
 
 static void


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