El jue, 11-09-2014 a las 09:03 +0200, Adrien Schwartzentruber escribió: > Hello guys, > > > I'm using Webkit2Gtk and i'm facing a difficult that I can't open a > javascript popup. > > > This is my WebkitView initialization code : > > > WebKitWebContext* context = webkit_web_context_get_default(); > WebKitSettings* settings = > webkit_web_view_get_settings(WEBKIT_WEB_VIEW(self->content_web)); > g_object_set(settings, "javascript-can-open-windows-automatically", > TRUE, "allow-modal-dialogs", TRUE, NULL); > webkit_settings_set_sans_serif_font_family(settings, "Helvetica > Neue"); > webkit_settings_set_enable_javascript(settings, TRUE); > webkit_settings_set_javascript_can_open_windows_automatically(settings, TRUE); > webkit_settings_set_allow_modal_dialogs(settings, TRUE); > webkit_web_context_set_cache_model(context, > WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); > webkit_web_context_clear_cache (context); > webkit_web_view_load_uri(WEBKIT_WEB_VIEW(self->content_web), > "http://localhost/index.php?logout=true"); > webkit_settings_set_enable_page_cache(settings, FALSE); > webkit_web_view_set_settings(WEBKIT_WEB_VIEW(self->content_web), > settings); > g_signal_connect(self->content_web, "decide-policy", > G_CALLBACK(decide_policy_cb), self); > g_signal_connect(self->content_web, "create", G_CALLBACK(create), > self); > g_signal_connect(self->content_web, "ready-to-show", > G_CALLBACK(read_to_show), self); > g_signal_connect(self->content_web, "run-as-modal", > G_CALLBACK(run_as_modal), self); > > > The observed behavior is that "create" signal is called but nothing > else. (I return NULL in the callback, and I also tried to create a > GtkWindow, if a WebKitView inside and return the WebKitView).
Returning NULL from the create callback is the way to prevent the popup window to be created. So, first of all you should create a web view in the create callback and return it. Also creating a GtkWindow and adding the view to the window, of course. The other problem is that you are connecting to the ready-to-show and run-as-modal signals on the existing web view instead of the newly created one. These signals are emitted after "create" on the new web view, so you should connect to them in the create callback right after creating the view. You should also connect to close, to destroy the popup when the view is closed. In the ready-to-show callback you can get the window properties with webkit_web_view_get_window_properties() to etup your window and then call gtk_widget_show() on your window. > > I probably just miss something obvious, Thx in adavance for your > help. > > > > > _______________________________________________ > webkit-gtk mailing list > [email protected] > https://lists.webkit.org/mailman/listinfo/webkit-gtk -- Carlos Garcia Campos http://pgp.rediris.es:11371/pks/lookup?op=get&search=0xF3D322D0EC4582C3
signature.asc
Description: This is a digitally signed message part
_______________________________________________ webkit-gtk mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-gtk
