Add support for new window events in gtk

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton 2011-06-29 08:09:47 +00:00
parent b5374b5cfa
commit 0016bf1df1

View 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 );