WebKitTools/GtkLauncher/main.c

106106 webkit_web_view_go_forward (web_view);
107107}
108108
 109static void
 110allow_navigation_cb (GtkWidget* entry, gpointer data)
 111{
 112 webkit_web_policy_decision_use(data);
 113 GdkWindow* window = gtk_widget_get_parent_window(entry);
 114 gdk_window_hide(window);
 115}
 116
 117static void
 118disallow_navigation_cb (GtkWidget* entry, gpointer data)
 119{
 120 webkit_web_policy_decision_download(data);
 121 GdkWindow* window = gtk_widget_get_parent_window(entry);
 122 g_object_unref(data);
 123 gdk_window_hide(window);
 124}
 125
 126
 127static gboolean
 128navigation_requested_cb (WebKitWebView* page, WebKitWebFrame* frame, WebKitNetworkRequest* network, GHashTable* action_information, WebKitWebPolicyDecision* policyDecision, gpointer data)
 129{
 130 g_object_ref(policyDecision);
 131
 132 g_print("++++ Navigation requested for %s\n", webkit_network_request_get_uri(network));
 133 GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 134 gtk_window_set_title (window, "Allow navigation?");
 135 g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL);
 136
 137 GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
 138
 139 GtkWidget* widget = gtk_label_new(g_strconcat("Allow navigation to ", webkit_network_request_get_uri(network), NULL));
 140 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 10);
 141
 142 widget = gtk_button_new_from_stock(GTK_STOCK_YES);
 143 g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (allow_navigation_cb), policyDecision);
 144 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
 145 widget = gtk_button_new_from_stock(GTK_STOCK_NO);
 146 g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (disallow_navigation_cb), policyDecision);
 147 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
 148
 149 gtk_container_add (GTK_CONTAINER (window), vbox);
 150 gtk_window_set_transient_for(window, main_window);
 151 gtk_widget_show_all (window);
 152
 153 return TRUE;
 154}
 155static gboolean
 156mime_type_requested_cb (WebKitWebView* page, WebKitWebFrame* frame, WebKitNetworkRequest* network, const gchar* mime, WebKitWebPolicyDecision* policyDecision, gpointer data)
 157{
 158 g_object_ref(policyDecision);
 159
 160 g_print("++++ download requested for %s\n", webkit_network_request_get_uri(network));
 161 GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 162 gtk_window_set_title (window, "Allow navigation?");
 163 g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL);
 164
 165 GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
 166
 167 GtkWidget* widget = gtk_label_new(g_strconcat("Allow download to ", webkit_network_request_get_uri(network), "\n Mime: ", mime, NULL));
 168 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 10);
 169
 170 widget = gtk_button_new_from_stock(GTK_STOCK_YES);
 171 g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (allow_navigation_cb), policyDecision);
 172 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
 173 widget = gtk_button_new_from_stock(GTK_STOCK_NO);
 174 g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (disallow_navigation_cb), policyDecision);
 175 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
 176
 177 gtk_container_add (GTK_CONTAINER (window), vbox);
 178 gtk_window_set_transient_for(window, main_window);
 179 gtk_widget_show_all (window);
 180
 181 return TRUE;
 182}
 183
 184static gboolean
 185new_window_requested_cb (WebKitWebView* view, WebKitWebFrame* frame, WebKitNetworkRequest* network, GHashTable* action_information, WebKitWebPolicyDecision* policyDecision, gpointer data)
 186{
 187 g_object_ref(policyDecision);
 188 //webkit_web_policy_decision_use(policyDecision);
 189
 190 g_print("++++ new_window requested for %s\n", webkit_network_request_get_uri(network));
 191 GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 192 gtk_window_set_title (window, "Allow navigation?");
 193 g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL);
 194
 195 GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
 196
 197 GtkWidget* widget = gtk_label_new(g_strconcat("Allow navigation to ", webkit_network_request_get_uri(network), NULL));
 198 gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 10);
 199
 200 widget = gtk_button_new_from_stock(GTK_STOCK_YES);
 201 g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (allow_navigation_cb), policyDecision);
 202 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
 203 widget = gtk_button_new_from_stock(GTK_STOCK_NO);
 204 g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (disallow_navigation_cb), policyDecision);
 205 gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
 206
 207 gtk_container_add (GTK_CONTAINER (window), vbox);
 208 gtk_window_set_transient_for(window, main_window);
 209 gtk_widget_show_all (window);
 210
 211 return TRUE;
 212}
 213
109214static GtkWidget*
110215create_browser ()
111216{

119224 g_signal_connect (G_OBJECT (web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), web_view);
120225 g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (load_commit_cb), web_view);
121226 g_signal_connect (G_OBJECT (web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), web_view);
 227 //g_signal_connect (G_OBJECT (web_view), "navigation-requested", G_CALLBACK (navigation_requested_cb), web_view);
 228 //g_signal_connect (G_OBJECT (web_view), "new-window-requested", G_CALLBACK (new_window_requested_cb), web_view);
 229 g_signal_connect (G_OBJECT (web_view), "mime-type-policy-decision-requested", G_CALLBACK (mime_type_requested_cb), web_view);
122230
123231 return scrolled_window;
124232}
révision 30014