[epiphany] downloads: Create the download with the window of the web view that initiated the download



commit cf825ce1926ffb3890ebfd4f0094a97b2158f314
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Thu Oct 25 17:47:17 2012 +0200

    downloads: Create the download with the window of the web view that initiated the download
    
    Using webkit_download_get_web_view() and falling back to the active
    window if the download was not initiated by a web view.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686467

 src/ephy-shell.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 6afb298..1ae07ac 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -596,7 +596,9 @@ download_started_cb (WebKitWebContext *web_context,
                      EphyShell *shell)
 {
   EphyDownload *ed;
-  EphyWindow *window;
+  GtkWindow *window = NULL;
+  WebKitWebView *web_view;
+  GtkWidget *toplevel;
 
   /* Is download locked down? */
   if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
@@ -605,8 +607,19 @@ download_started_cb (WebKitWebContext *web_context,
     return;
   }
 
-  window = gtk_application_get_active_window (GTK_APPLICATION (shell));
-  ed = ephy_download_new_for_download (download, GTK_WINDOW (window));
+  web_view = webkit_download_get_web_view (download);
+  if (web_view) {
+    GtkWidget *toplevel;
+
+    toplevel = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+    if (GTK_IS_WINDOW (toplevel))
+      window = GTK_WINDOW (toplevel);
+  }
+
+  if (!window)
+    window = gtk_application_get_active_window (GTK_APPLICATION (shell));
+
+  ed = ephy_download_new_for_download (download, window);
 }
 #endif
 



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