]> git.saurik.com Git - wxWidgets.git/commitdiff
Add support for new window events in gtk
authorSteve Lamerton <steve.lamerton@gmail.com>
Wed, 29 Jun 2011 08:09:47 +0000 (08:09 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Wed, 29 Jun 2011 08:09:47 +0000 (08:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/webview_webkit.cpp

index b838f79d9dc13566cb9a4d064f2518220a2b14f6..3f4c7c69bdf0b2b806365f9cbd23d6c5673d51d4 100644 (file)
@@ -234,6 +234,36 @@ wxgtk_webkitctrl_error (WebKitWebView  *web_view,
     return FALSE;
 }
 
+static gboolean
+wxgtk_webkitctrl_new_window(WebKitWebView *webView,
+                            WebKitWebFrame *frame,
+                            WebKitNetworkRequest *request,
+                            WebKitWebNavigationAction *navigation_action,
+                            WebKitWebPolicyDecision *policy_decision,
+                    wxWebViewWebKit *webKitCtrl)
+{
+    const gchar* uri = webkit_network_request_get_uri(request);
+
+    wxString target = webkit_web_frame_get_name (frame);
+    wxWebNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW,
+                                   webKitCtrl->GetId(),
+                                   wxString( uri, wxConvUTF8 ),
+                                   target,
+                                   true);
+
+    if (webKitCtrl && webKitCtrl->GetEventHandler())
+        webKitCtrl->GetEventHandler()->ProcessEvent(thisEvent);
+
+    if (thisEvent.IsVetoed())
+    {
+        webkit_web_policy_decision_ignore(policy_decision);
+    }
+    else
+    {
+        webkit_web_policy_decision_use(policy_decision);
+    }
+    return TRUE;
+}
 
 } // extern "C"
 
@@ -283,9 +313,8 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
                            G_CALLBACK(wxgtk_webkitctrl_error),
                            this);
 
-    // this signal can be added if we care about new frames open requests
-    //g_signal_connect_after(web_view, "new-window-policy-decision-requested",
-    //                       G_CALLBACK(...), this);
+    g_signal_connect_after(web_view, "new-window-policy-decision-requested",
+                           G_CALLBACK(wxgtk_webkitctrl_new_window), this);
 
     m_parent->DoAddChild( this );