]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/webview_webkit.cpp
Overhaul wxWebHandler naming to try and make it consistent with the rest of wxWidgets...
[wxWidgets.git] / src / gtk / webview_webkit.cpp
index 6e6096bf378061f2d79587854b01a2dc7f20b58c..c1493d21e6b1c51cc0490f8f07c1d438c23240a4 100644 (file)
@@ -26,8 +26,9 @@ extern "C"
 {
 
 static void
-wxgtk_webkitctrl_load_status_callback(GtkWidget* widget, GParamSpec*,
-                                      wxWebViewWebKit *webKitCtrl)
+wxgtk_webview_webkit_load_status(GtkWidget* widget, 
+                                 GParamSpec*,
+                                 wxWebViewWebKit *webKitCtrl)
 {
     if (!webKitCtrl->m_ready) return;
 
@@ -64,7 +65,7 @@ static gboolean
 wxgtk_webview_webkit_navigation(WebKitWebView*,
                                 WebKitWebFrame *frame,
                                 WebKitNetworkRequest *request,
-                                WebKitWebNavigationAction*,
+                                WebKitWebNavigationAction *,
                                 WebKitWebPolicyDecision *policy_decision,
                                 wxWebViewWebKit *webKitCtrl)
 {
@@ -95,11 +96,11 @@ wxgtk_webview_webkit_navigation(WebKitWebView*,
 }
 
 static gboolean
-wxgtk_webkitctrl_error (WebKitWebView*,
-                        WebKitWebFrame*,
-                        gchar          *uri,
-                        gpointer        web_error,
-                        wxWebViewWebKit* webKitWindow)
+wxgtk_webview_webkit_error(WebKitWebView*,
+                           WebKitWebFrame*,
+                           gchar *uri,
+                           gpointer web_error,
+                           wxWebViewWebKit* webKitWindow)
 {
     webKitWindow->m_busy = false;
     wxWebNavigationError type = wxWEB_NAV_ERR_OTHER;
@@ -238,12 +239,12 @@ wxgtk_webkitctrl_error (WebKitWebView*,
 }
 
 static gboolean
-wxgtk_webkitctrl_new_window(WebKitWebView*,
-                            WebKitWebFrame *frame,
-                            WebKitNetworkRequest *request,
-                            WebKitWebNavigationAction*,
-                            WebKitWebPolicyDecision *policy_decision,
-                    wxWebViewWebKit *webKitCtrl)
+wxgtk_webview_webkit_new_window(WebKitWebView*,
+                                WebKitWebFrame *frame,
+                                WebKitNetworkRequest *request,
+                                WebKitWebNavigationAction*,
+                                WebKitWebPolicyDecision *policy_decision,
+                                wxWebViewWebKit *webKitCtrl)
 {
     const gchar* uri = webkit_network_request_get_uri(request);
 
@@ -257,17 +258,29 @@ wxgtk_webkitctrl_new_window(WebKitWebView*,
     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);
-    }
+    //We always want the user to handle this themselves
+    webkit_web_policy_decision_ignore(policy_decision);
     return TRUE;
 }
 
+static void
+wxgtk_webview_webkit_title_changed(WebKitWebView *webView,
+                                   WebKitWebFrame *frame,
+                                   gchar *title,
+                                   wxWebViewWebKit *webKitCtrl)
+{
+    wxWebNavigationEvent thisEvent(wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED,
+                                   webKitCtrl->GetId(),
+                                   webKitCtrl->GetCurrentURL(),
+                                   "",
+                                   true);
+    thisEvent.SetString(wxString(title, wxConvUTF8));
+
+    if (webKitCtrl && webKitCtrl->GetEventHandler())
+        webKitCtrl->GetEventHandler()->ProcessEvent(thisEvent);
+
+}
+
 } // extern "C"
 
 //-----------------------------------------------------------------------------
@@ -307,17 +320,20 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
     gtk_widget_show(web_view);
 
     g_signal_connect_after(web_view, "notify::load-status",
-                           G_CALLBACK(wxgtk_webkitctrl_load_status_callback),
+                           G_CALLBACK(wxgtk_webview_webkit_load_status),
                            this);
     g_signal_connect_after(web_view, "navigation-policy-decision-requested",
                            G_CALLBACK(wxgtk_webview_webkit_navigation),
                            this);
     g_signal_connect_after(web_view, "load-error", 
-                           G_CALLBACK(wxgtk_webkitctrl_error),
+                           G_CALLBACK(wxgtk_webview_webkit_error),
                            this);
 
     g_signal_connect_after(web_view, "new-window-policy-decision-requested",
-                           G_CALLBACK(wxgtk_webkitctrl_new_window), this);
+                           G_CALLBACK(wxgtk_webview_webkit_new_window), this);
+
+    g_signal_connect_after(web_view, "title-changed",
+                           G_CALLBACK(wxgtk_webview_webkit_title_changed), this);
 
     m_parent->DoAddChild( this );