gchar * html_get_location(Html *html) { g_return_val_if_fail(IS_HTML (html), NULL); WebKitWebFrame *web_frame; web_frame = webkit_web_view_get_main_frame (html->webview); gchar *uri = g_strdup(webkit_web_frame_get_uri(web_frame)); return uri; }
static void notifyLoadStatusCb(WebKitWebView* webView, GParamSpec* pspec, GtkWidget* uriEntry) { if (webkit_web_view_get_load_status(webView) == WEBKIT_LOAD_COMMITTED) { WebKitWebFrame *frame = webkit_web_view_get_main_frame(webView); const gchar *uri = webkit_web_frame_get_uri(frame); if (uri) gtk_entry_set_text(GTK_ENTRY(uriEntry), uri); } }
JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1webkit_1web_1view_1get_1main_1frame) (JNIEnv *env, jclass that, jintLong arg0) { jintLong rc = 0; WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1web_1view_1get_1main_1frame_FUNC); rc = (jintLong)webkit_web_view_get_main_frame((WebKitWebView *)arg0); WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1web_1view_1get_1main_1frame_FUNC); return rc; }
/* ghtml_get_title */ char const * ghtml_get_title(GtkWidget * widget) { GHtml * ghtml; WebKitWebFrame * frame; ghtml = g_object_get_data(G_OBJECT(widget), "ghtml"); frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(ghtml->view)); return webkit_web_frame_get_title(frame); }
int main (int argc, gchar* argv[]) { GtkWidget* window; GtkWidget* vbox; GtkWidget* scrolled; GtkWidget* web_view; GtkWidget* button_box; WebKitWebFrame* web_frame; JSGlobalContextRef js_context; JSObjectRef js_global; JSStringRef js_function_name; JSObjectRef js_set_can_register; if (!g_thread_supported ()) g_thread_init (NULL); gtk_init_check (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "WebKitGTK+ API Demo"); gtk_window_set_default_size (GTK_WINDOW (window), 640, 240); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); vbox = gtk_vbox_new (FALSE, 4); gtk_container_add (GTK_CONTAINER (window), vbox); scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0); web_view = webkit_web_view_new (); gtk_container_add (GTK_CONTAINER (scrolled), web_view); webkit_web_view_load_string (WEBKIT_WEB_VIEW (web_view), form_markup, "text/html", "UTF-8", ""); g_signal_connect (web_view, "create-plugin-widget", G_CALLBACK (web_view_create_plugin_widget_cb), NULL); button_box = gtk_hbutton_box_new (); gtk_box_pack_start (GTK_BOX (vbox), button_box, FALSE, FALSE, 0); register_button = gtk_button_new_with_mnemonic ("Send _Registration"); gtk_widget_set_sensitive (register_button, FALSE); gtk_box_pack_start (GTK_BOX (button_box), register_button, FALSE, FALSE, 0); web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)); js_context = webkit_web_frame_get_global_context (web_frame); js_global = JSContextGetGlobalObject (js_context); js_function_name = JSStringCreateWithUTF8CString ("setCanRegister"); js_set_can_register = JSObjectMakeFunctionWithCallback (js_context, js_function_name, (JSObjectCallAsFunctionCallback)set_can_register_cb); JSObjectSetProperty (js_context, js_global, js_function_name, js_set_can_register, 0, NULL); JSStringRelease (js_function_name); gtk_widget_show_all (window); gtk_main (); return 0; }
void FrameLoaderClient::dispatchDidChangeLocationWithinPage() { WebKitWebFramePrivate* priv = m_frame->priv; g_free(priv->uri); priv->uri = g_strdup(core(m_frame)->loader()->url().prettyURL().utf8().data()); g_object_notify(G_OBJECT(m_frame), "uri"); WebKitWebView* webView = getViewFromFrame(m_frame); if (m_frame == webkit_web_view_get_main_frame(webView)) g_object_notify(G_OBJECT(webView), "uri"); }
wxString wxWebViewWebKit::GetPageSource() const { WebKitWebFrame* frame = webkit_web_view_get_main_frame(m_web_view); WebKitWebDataSource* src = webkit_web_frame_get_data_source (frame); // TODO: check encoding with // const gchar* // webkit_web_data_source_get_encoding(WebKitWebDataSource *data_source); return wxString(webkit_web_data_source_get_data (src)->str, wxConvUTF8); }
void sc_print(Browser *b, const Arg *arg) { WebKitWebFrame *frame = webkit_web_view_get_main_frame(b->UI.view); if (!frame) { return; } webkit_web_frame_print(frame); }
static gboolean verify_contents(gpointer data) { KeyEventFixture* fixture = (KeyEventFixture*)data; JSGlobalContextRef context = webkit_web_frame_get_global_context( webkit_web_view_get_main_frame(fixture->webView)); g_assert(context); g_assert(element_text_equal_to(context, fixture->info->text)); g_main_loop_quit(fixture->loop); return FALSE; }
static gint luaH_webview_load_string(lua_State *L) { widget_t *w = luaH_checkwidget(L, 1); WebKitWebView *view = WEBKIT_WEB_VIEW(g_object_get_data(G_OBJECT(w->widget), "webview")); const gchar *string = luaL_checkstring(L, 2); const gchar *base_uri = luaL_checkstring(L, 3); WebKitWebFrame *frame = webkit_web_view_get_main_frame(view); webkit_web_frame_load_alternate_string(frame, string, base_uri, base_uri); return 0; }
/* ghtml_print */ void ghtml_print(GtkWidget * widget) { #if WEBKIT_CHECK_VERSION(1, 1, 0) /* XXX may not be accurate */ GHtml * ghtml; WebKitWebFrame * frame; ghtml = g_object_get_data(G_OBJECT(widget), "ghtml"); frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(ghtml->view)); webkit_web_frame_print(frame); #endif }
void wk_html_print(WkHtml *html) { #ifdef USE_WEBKIT2 WebKitPrintOperation *print_operation; print_operation = webkit_print_operation_new(WEBKIT_WEB_VIEW(html)); webkit_print_operation_run_dialog(print_operation, NULL); #else webkit_web_frame_print(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(html))); webkit_web_view_execute_script(WEBKIT_WEB_VIEW(html), "print();"); #endif }
static void notifyStatus(WebKitWebFrame* frame, WebKitLoadStatus loadStatus) { frame->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(frame), "load-status"); WebKitWebView* webView = getViewFromFrame(frame); if (frame == webkit_web_view_get_main_frame(webView)) { webView->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(webView), "load-status"); } }
static VALUE WebView_main_frame(VALUE self) { VALUE __p_retval = Qnil; WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self)); #line 271 "/home/ngl/Progetti/gtk-webkit-ruby/ext/webkit/webkit.cr" do { __p_retval = GOBJ2RVAL(webkit_web_view_get_main_frame(_self)); goto out; } while(0); out: return __p_retval; }
void wxWebViewWebKit::Print() { WebKitWebFrame* frame = webkit_web_view_get_main_frame(m_web_view); webkit_web_frame_print (frame); // GtkPrintOperationResult webkit_web_frame_print_full // (WebKitWebFrame *frame, // GtkPrintOperation *operation, // GtkPrintOperationAction action, // GError **error); }
gchar * html_get_title(Html *html) { g_return_val_if_fail(IS_HTML (html), NULL); WebKitWebFrame *web_frame; web_frame = webkit_web_view_get_main_frame (html->webview); gchar *web_view_title=NULL; if(web_frame) web_view_title = g_strdup(webkit_web_frame_get_title (web_frame)); return web_view_title; }
/* on_load_committed */ static void _on_load_committed(WebKitWebView * view, WebKitWebFrame * frame, gpointer data) { GHtml * ghtml; char const * location; ghtml = g_object_get_data(G_OBJECT(data), "ghtml"); if(frame == webkit_web_view_get_main_frame(view) && (location = webkit_web_frame_get_uri(frame)) != NULL) surfer_set_location(ghtml->surfer, location); surfer_set_security(ghtml->surfer, ghtml_get_security(ghtml->widget)); }
static void notifyStatus(WebKitWebFrame* frame, WebKitLoadStatus loadStatus) { frame->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(frame), "load-status"); WebKitWebView* webView = getViewFromFrame(frame); if (frame == webkit_web_view_get_main_frame(webView)) { webView->priv->loadStatus = loadStatus; g_object_notify(G_OBJECT(webView), "load-status"); if (AXObjectCache::accessibilityEnabled()) notifyAccessibilityStatus(frame, loadStatus); } }
static void notify_load_status_lifetime_cb(WebKitWebView* view, GParamSpec* pspec, GMainLoop* loop) { WebKitLoadStatus status = webkit_web_view_get_load_status (view); WebKitWebFrame* frame = webkit_web_view_get_main_frame(view); WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(frame); if (status == WEBKIT_LOAD_COMMITTED) { g_assert(webkit_web_data_source_is_loading(dataSource)); return; } else if (status != WEBKIT_LOAD_FINISHED) return; g_main_loop_quit(loop); }
void FrameLoaderClient::dispatchDidReceiveTitle(const String& title) { WebKitWebFramePrivate* priv = m_frame->priv; g_free(priv->title); priv->title = g_strdup(title.utf8().data()); g_signal_emit_by_name(m_frame, "title-changed", priv->title); g_object_notify(G_OBJECT(m_frame), "title"); WebKitWebView* webView = getViewFromFrame(m_frame); if (m_frame == webkit_web_view_get_main_frame(webView)) { g_signal_emit_by_name(webView, "title-changed", m_frame, title.utf8().data()); g_object_notify(G_OBJECT(webView), "title"); } }
void mk_zs__(WebKitWebView* wwv){ WebKitWebFrame* web_frame; JSGlobalContextRef js_context; JSObjectRef js_global; JSStringRef js_function_name; JSObjectRef js_function; web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (wwv)); js_context = webkit_web_frame_get_global_context (web_frame); js_global = JSContextGetGlobalObject (js_context); js_function_name = JSStringCreateWithUTF8CString (s1_[zs_].c_str()); js_function = JSObjectMakeFunctionWithCallback (js_context, js_function_name, zs__); JSObjectSetProperty (js_context, js_global, js_function_name, js_function, kJSPropertyAttributeNone, NULL); JSStringRelease (js_function_name); }
void* plat_create_window(void* tag, int w, int h) { struct gtk_state* state = malloc(sizeof(struct gtk_state)); state->tag = tag; GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "WebUI"); state->window = window; gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(close_window), state); GtkWidget* scroll = gtk_scrolled_window_new(NULL, NULL); state->web_view = webkit_web_view_new(); gtk_container_add(GTK_CONTAINER(scroll), state->web_view); gtk_container_add(GTK_CONTAINER(window), scroll); WebKitWebFrame* web_frame = webkit_web_view_get_main_frame( WEBKIT_WEB_VIEW(state->web_view)); gtk_window_set_default_size(GTK_WINDOW(window), w, h); gtk_widget_show_all(window); JSGlobalContextRef jsctx = webkit_web_frame_get_global_context(web_frame); state->jsctx = jsctx; JSClassDefinition system_def = kJSClassDefinitionEmpty; system_def.className = "ruby"; system_def.getProperty = ruby_getprop; JSClassRef system_class = JSClassCreate(&system_def); JSObjectRef o = JSObjectMake(jsctx, system_class, NULL); if(!JSObjectSetPrivate(o, tag)) { printf("WebKit is busted.\n"); abort(); } JSStringRef name = JSStringCreateWithUTF8CString("ruby"); JSObjectSetProperty(jsctx, JSContextGetGlobalObject(jsctx), name, o, kJSPropertyAttributeDontDelete, NULL); JSStringRelease(name); return state; }
/* ghtml_get_favicon */ GdkPixbuf * ghtml_get_favicon(GtkWidget * widget) { GHtml * ghtml; WebKitWebFrame * frame; ghtml = g_object_get_data(G_OBJECT(widget), "ghtml"); #if WEBKIT_CHECK_VERSION(1, 8, 0) if((frame = webkit_web_view_get_main_frame( WEBKIT_WEB_VIEW(ghtml->view))) != NULL && webkit_web_frame_get_uri(frame) != NULL) return webkit_web_view_try_get_favicon_pixbuf( WEBKIT_WEB_VIEW(ghtml->view), 16, 16); #else /* FIXME implement */ #endif return NULL; }
static void notify_load_status_unreachable_cb(WebKitWebView* view, GParamSpec* pspec, GMainLoop* loop) { WebKitLoadStatus status = webkit_web_view_get_load_status (view); WebKitWebFrame* frame = webkit_web_view_get_main_frame(view); g_assert(status != WEBKIT_LOAD_FINISHED); if (status != WEBKIT_LOAD_FAILED) return; WebKitWebDataSource* datasource = webkit_web_frame_get_data_source(frame); g_assert_cmpstr("http://this.host.does.not.exist/doireallyexist.html", ==, webkit_web_data_source_get_unreachable_uri(datasource)); g_main_loop_quit(loop); }
void browser_apply_settings(Browser *b) { WebKitWebFrame *frame; /* view */ if (show_scrollbars) { gtk_scrolled_window_set_policy(b->UI.scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); } else { frame = webkit_web_view_get_main_frame(b->UI.view); g_signal_connect(G_OBJECT(frame), "scrollbars-policy-changed", G_CALLBACK(gtk_true), NULL); gtk_scrolled_window_set_policy(b->UI.scrolled_window, GTK_POLICY_NEVER, GTK_POLICY_NEVER); } /* apply browser settings */ webkit_web_view_set_settings(b->UI.view, ripcurl->Global.webkit_settings); /* statusbar */ gtk_misc_set_alignment(GTK_MISC(b->Statusbar.text), 0.0, 0.0); gtk_misc_set_alignment(GTK_MISC(b->Statusbar.buffer), 1.0, 0.0); gtk_misc_set_alignment(GTK_MISC(b->Statusbar.position), 1.0, 0.0); gtk_misc_set_padding(GTK_MISC(b->Statusbar.text), 1.0, 2.0); gtk_misc_set_padding(GTK_MISC(b->Statusbar.buffer), 1.0, 2.0); gtk_misc_set_padding(GTK_MISC(b->Statusbar.position), 1.0, 2.0); gtk_widget_modify_bg(GTK_WIDGET(b->UI.statusbar), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_bg)); gtk_widget_modify_fg(GTK_WIDGET(b->Statusbar.text), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_fg)); gtk_widget_modify_fg(GTK_WIDGET(b->Statusbar.buffer), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_fg)); gtk_widget_modify_fg(GTK_WIDGET(b->Statusbar.position), GTK_STATE_NORMAL, &(ripcurl->Style.statusbar_fg)); gtk_widget_modify_font(GTK_WIDGET(b->Statusbar.text), ripcurl->Style.font); gtk_widget_modify_font(GTK_WIDGET(b->Statusbar.buffer), ripcurl->Style.font); gtk_widget_modify_font(GTK_WIDGET(b->Statusbar.position), ripcurl->Style.font); /* inputbar settings */ gtk_entry_set_inner_border(b->UI.inputbar, NULL); gtk_entry_set_has_frame(b->UI.inputbar, FALSE); gtk_editable_set_editable(GTK_EDITABLE(b->UI.inputbar), TRUE); gtk_widget_modify_base(GTK_WIDGET(b->UI.inputbar), GTK_STATE_NORMAL, &(ripcurl->Style.inputbar_bg)); gtk_widget_modify_text(GTK_WIDGET(b->UI.inputbar), GTK_STATE_NORMAL, &(ripcurl->Style.inputbar_fg)); gtk_widget_modify_font(GTK_WIDGET(b->UI.inputbar), ripcurl->Style.font); }
/* ghtml_get_source */ char const * ghtml_get_source(GtkWidget * widget) { #if WEBKIT_CHECK_VERSION(1, 1, 0) GHtml * ghtml; WebKitWebFrame * frame; WebKitWebDataSource * source; GString * str; ghtml = g_object_get_data(G_OBJECT(widget), "ghtml"); frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(ghtml->view)); source = webkit_web_frame_get_data_source(frame); if((str = webkit_web_data_source_get_data(source)) == NULL) return NULL; return str->str; #else return NULL; #endif }
void FrameLoaderClient::dispatchDidReceiveIcon() { if (m_loadingErrorPage) return; const gchar* frameURI = webkit_web_frame_get_uri(m_frame); WebKitIconDatabase* database = webkit_get_icon_database(); g_signal_emit_by_name(database, "icon-loaded", m_frame, frameURI); WebKitWebView* webView = getViewFromFrame(m_frame); // Avoid reporting favicons for non-main frames. if (m_frame != webkit_web_view_get_main_frame(webView)) return; g_object_notify(G_OBJECT(webView), "icon-uri"); g_signal_emit_by_name(webView, "icon-loaded", webkit_web_view_get_icon_uri(webView)); }
static GtkPrintOperationResult print(WebKitWebView *html, GtkPrintOperationAction action) { GtkPrintOperation *operation; GtkPrintOperationResult result; GError *error = NULL; WebKitWebFrame *frame; frame = webkit_web_view_get_main_frame(html); operation = gtk_print_operation_new(); result = webkit_web_frame_print_full(frame, operation, action, &error); g_object_unref(operation); handle_error(&error); return result; }
void show_scrollbars(widget_t *w, gboolean show) { GtkWidget *view = g_object_get_data(G_OBJECT(w->widget), "webview"); WebKitWebFrame *mf = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(view)); gulong id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(view), "hide_handler_id")); if (show) { if (id) g_signal_handler_disconnect((gpointer) mf, id); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w->widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); id = 0; } else if (!id) { gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w->widget), GTK_POLICY_NEVER, GTK_POLICY_NEVER); id = g_signal_connect(G_OBJECT(mf), "scrollbars-policy-changed", G_CALLBACK(true_cb), NULL); } g_object_set_data(G_OBJECT(view), "hide_handler_id", GINT_TO_POINTER(id)); }
static void copy_location_callback (GtkAction *action, gpointer data) { WebKitWebFrame *frame; const gchar *uri; frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)); uri = webkit_web_frame_get_uri (frame); if (uri) { GtkClipboard *clipboard; clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (view), GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text (clipboard, uri, -1); } }