void wxWebViewWebKit::DoSetPage(const wxString& html, const wxString& baseUri) { webkit_web_view_load_string (m_web_view, html.mb_str(wxConvUTF8), "text/html", "UTF-8", baseUri.mb_str(wxConvUTF8)); }
void wqq_qqchat_set_base_uri(WqqQQChat * chat, const gchar * base) { g_return_if_fail(WQQ_IS_QQCHAT(chat)); webkit_web_view_load_string(WEBKIT_WEB_VIEW(chat->webview), "<html><body></body></html>", "text/html", "UTF-8", base); chat->loading = TRUE; }
gboolean map_event_cb(GtkWidget *widget, GdkEvent* event, gpointer data) { gtk_widget_grab_focus(widget); CopyAndPasteFixture* fixture = (CopyAndPasteFixture*)data; webkit_web_view_load_string(fixture->webView, fixture->info->page, "text/html", "utf-8", "file://"); return FALSE; }
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; }
static void library_view_process_lyric(char* lyric, void* data) { struct lyric_cb* cb = (struct lyric_cb*) data; char* t_id = cb->track_id; library_view_t* view = cb->view; mc_free(cb); if (view->current_lyric_track_id != NULL) { mc_free(view->current_lyric_track_id); } view->current_lyric_track_id = t_id; track_t* t = library_get(view->library, t_id); if (t != NULL) { if (strcmp(lyric, "") != 0) { track_set_lyric(t, lyric); } char *artist = text_to_html(track_get_artist(t)); char *title = text_to_html(track_get_title(t)); char* s = (char*) mc_malloc(strlen(artist)+sizeof(", ")+strlen(title)+200); sprintf(s,"<span size=\"x-small\"><i><b>%s\n%s</b></i></span>", artist, title); gtk_label_set_markup(view->lbl_lyric_track,s); mc_free(s); mc_free(title); mc_free(artist); char* html = lyric_text_to_html(lyric); write_lyric(t, lyric, el_false); // write but don't overwrite webkit_web_view_load_string(view->lyric_view, html, NULL, NULL, ""); mc_free(html); } else { char* html = "<html><head></head><body></body></html>"; gtk_label_set_markup(view->lbl_lyric_track, ""); webkit_web_view_load_string(view->lyric_view, html, NULL, NULL, ""); } mc_free(lyric); }
void set_html (MuMsgBodyView *self, const char* html) { g_return_if_fail (MU_IS_MSG_BODY_VIEW(self)); webkit_web_view_load_string (WEBKIT_WEB_VIEW(self), html ? html : "", "text/html", "utf-8", ""); }
static void set_text (MuMsgBodyView *self, const char* txt) { g_return_if_fail (MU_IS_MSG_BODY_VIEW(self)); webkit_web_view_load_string (WEBKIT_WEB_VIEW(self), txt ? txt : "", "text/plain", "utf-8", ""); }
void ygtk_html_wrap_set_text (GtkWidget *widget, const gchar *text, gboolean plain_mode) { WebKitWebView *view = WEBKIT_WEB_VIEW (widget); // webkit prepends base-uri to non-uri hrefs if (plain_mode) webkit_web_view_load_string (view, text, "text/plain", "UTF-8", "/"); else { GString *str = NULL; int i, last_i = 0; for (i = 0; text[i]; i++) { if (!strncmp (text+i, "href=", 5)) { i += 5; if (text[i] == '"') i++; int j; for (j = i; text[j] && text[j] != ':'; j++) if (text[j] == '"' || g_ascii_isspace (text[j])) { if (!str) str = g_string_new (""); str = g_string_append_len (str, text+last_i, i-last_i); last_i = i; str = g_string_append (str, "label:/"); break; } } } if (str) { str = g_string_append (str, text+last_i); text = g_string_free (str, FALSE); } const gchar *extra_css = g_object_get_data (G_OBJECT (widget), "extra-css"); if (!extra_css) extra_css = ""; gchar *html = g_strdup_printf ("%s\n%s\n%s", CSS, extra_css, text); if (str) g_free ((gchar *) text); webkit_web_view_load_string (view, html, "text/html", "UTF-8", "/"); g_free (html); } }
static void dom_document_fixture_setup(DomDocumentFixture* fixture, gconstpointer data) { fixture->loop = g_main_loop_new(NULL, TRUE); fixture->webView = webkit_web_view_new(); g_object_ref_sink(fixture->webView); if (data != NULL) webkit_web_view_load_string(WEBKIT_WEB_VIEW (fixture->webView), (const char*) data, NULL, NULL, NULL); g_idle_add((GSourceFunc)finish_loading, fixture); g_main_loop_run(fixture->loop); }
void editor_load_note(EDITOR *e, const gchar *module_name, const gchar *key) { gchar *title = NULL, *text = NULL; if (e->is_changed) _save_note(e); if (module_name) { if (e->module) g_free(e->module); e->module = g_strdup(module_name); } if (key) { if (e->key) g_free(e->key); e->key = g_strdup(key); } text = main_get_raw_text((gchar *)e->module, (gchar *)e->key); if ((text == NULL) || strlen(text) == 0) { if (text) g_free(text); /* new empty document from template */ gchar *fname = g_build_filename(settings.gSwordDir, "studypad.spt", NULL); XI_message(("editor load NOTE [%s]", fname)); text = inhale_text_from_file(fname); g_free(fname); } if (text && strlen(text)) { webkit_web_view_load_string((WebKitWebView *) e->html_widget, text, "text/html", "utf_8", "file://"); } e->is_changed = FALSE; if (e->type == NOTE_EDITOR) { e->navbar.valid_key = TRUE; main_navbar_versekey_set(e->navbar, e->key); } if (text) g_free(text); title = g_strdup_printf("%s - %s", e->module, e->key); change_window_title(e->window, title); g_free(title); }
StatusWidget::StatusWidget(Statusnet::Status status) { GtkWidget *webkit = webkit_web_view_new(); //std::cout<<"creating statuswidget with text: "<<status.text<<std::endl; WebKitWebView *view = WEBKIT_WEB_VIEW(webkit); Gtk::Widget *webkit_mm = Glib::wrap(webkit); WebKitWebSettings *webkitsettings = webkit_web_settings_new(); g_object_set(G_OBJECT(webkitsettings), "enable-default-context-menu", FALSE, NULL); webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webkit), webkitsettings); webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), this->parse(status).c_str(), NULL, NULL, ""); g_signal_connect(view, "navigation-policy-decision-requested", G_CALLBACK(&StatusWidget::navigation_policy_decision_requested_cb), view); webkit_mm->set_size_request(10, 100); this->add(*webkit_mm); }
static void test_webkit_hit_test_result(HitTestResultFixture* fixture, gconstpointer data) { TestInfo* info = (TestInfo*)data; GtkAllocation allocation = { 0, 0, 50, 50 }; webkit_web_view_load_string(fixture->webView, info->data, "text/html", "utf-8", "file://"); gtk_widget_size_allocate(GTK_WIDGET(fixture->webView), &allocation); g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_status_cb), info); g_main_loop_run(loop); }
static void atk_roles_fixture_setup(AtkRolesFixture* fixture, gconstpointer data) { fixture->loop = g_main_loop_new(NULL, TRUE); fixture->alloc = (GtkAllocation) { 0, 0, 800, 600 }; fixture->webView = webkit_web_view_new(); g_object_ref_sink(fixture->webView); gtk_widget_size_allocate(fixture->webView, &fixture->alloc); if (data != NULL) webkit_web_view_load_string(WEBKIT_WEB_VIEW (fixture->webView), (const char*) data, NULL, NULL, NULL); g_idle_add((GSourceFunc) finish_loading, fixture); g_main_loop_run(fixture->loop); }
static VALUE WebView_load_string(VALUE self, VALUE __v_content, VALUE __v_mime_type, VALUE __v_encoding, VALUE __v_base_uri) { char * content; char * __orig_content; char * mime_type; char * __orig_mime_type; char * encoding; char * __orig_encoding; char * base_uri; char * __orig_base_uri; WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self)); __orig_content = content = ( NIL_P(__v_content) ? NULL : StringValuePtr(__v_content) ); __orig_mime_type = mime_type = ( NIL_P(__v_mime_type) ? NULL : StringValuePtr(__v_mime_type) ); __orig_encoding = encoding = ( NIL_P(__v_encoding) ? NULL : StringValuePtr(__v_encoding) ); __orig_base_uri = base_uri = ( NIL_P(__v_base_uri) ? NULL : StringValuePtr(__v_base_uri) ); #line 265 "/home/ngl/Progetti/gtk-webkit-ruby/ext/webkit/webkit.cr" webkit_web_view_load_string(_self, content, mime_type, encoding, base_uri); return Qnil; }
gboolean map_event_cb(GtkWidget *widget, GdkEvent* event, gpointer data) { gtk_widget_grab_focus(widget); KeyEventFixture* fixture = (KeyEventFixture*)data; g_signal_connect(fixture->webView, "key-press-event", G_CALLBACK(key_press_event_cb), fixture); g_signal_connect(fixture->webView, "key-release-event", G_CALLBACK(key_release_event_cb), fixture); g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_status_cb), fixture); webkit_web_view_load_string(fixture->webView, fixture->info->page, "text/html", "utf-8", "file://"); return FALSE; }
static void testWebkitAtkGetTextInParagraphAndBodyModerate(void) { WebKitWebView* webView; AtkObject* obj; AtkObject* obj1; AtkObject* obj2; GMainLoop* loop; AtkText* textObj1; AtkText* textObj2; webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); g_object_ref_sink(webView); GtkAllocation alloc = { 0, 0, 800, 600 }; gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); webkit_web_view_load_string(webView, contentsInParagraphAndBodyModerate, NULL, NULL, NULL); loop = g_main_loop_new(NULL, TRUE); g_timeout_add(100, (GSourceFunc)bail_out, loop); g_main_loop_run(loop); /* Get to the inner AtkText object */ obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); g_assert(obj); obj1 = atk_object_ref_accessible_child(obj, 0); g_assert(obj1); obj2 = atk_object_ref_accessible_child(obj, 1); g_assert(obj2); textObj1 = ATK_TEXT(obj1); g_assert(ATK_IS_TEXT(textObj1)); textObj2 = ATK_TEXT(obj2); g_assert(ATK_IS_TEXT(textObj2)); char *text = atk_text_get_text(textObj1, 0, -1); g_assert_cmpstr(text, ==, "This is a test."); text = atk_text_get_text(textObj2, 0, 53); g_assert_cmpstr(text, ==, "Hello world.\nThis sentence is green.\nThis one is not."); g_object_unref(obj1); g_object_unref(obj2); g_object_unref(webView); }
/* return the path to the output file, or NULL in case of error */ static gboolean generate_pdf (MuMsg *msg, const char *str, GError **err) { GtkWidget *view; WebKitWebFrame *frame; WebKitWebSettings *settings; WebKitLoadStatus status; time_t started; const int max_time = 3; /* max 3 seconds to download stuff */ settings = webkit_web_settings_new (); g_object_set (G_OBJECT(settings), "enable-scripts", FALSE, "auto-load-images", TRUE, "enable-plugins", FALSE, NULL); view = webkit_web_view_new (); /* to support cid: */ g_signal_connect (G_OBJECT(view), "resource-request-starting", G_CALLBACK (on_resource_request_starting), msg); webkit_web_view_set_settings (WEBKIT_WEB_VIEW(view), settings); webkit_web_view_load_string (WEBKIT_WEB_VIEW(view), str, "text/html", "utf-8", ""); g_object_unref (settings); frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW(view)); if (!frame) { g_set_error (err, 0, MU_ERROR, "cannot get web frame"); return FALSE; } started = time (NULL); do { status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW(view)); gtk_main_iteration_do (FALSE); } while (status != WEBKIT_LOAD_FINISHED && (time(NULL) - started) <= max_time); return print_to_pdf (frame, err); }
/* save if needed is done in treeky-editor.c before calling editor_load_book() */ void editor_load_book(EDITOR *e) { gchar *title = NULL, *text = NULL; if (!g_ascii_isdigit(e->key[0])) return; /* make sure is a number (offset) */ XI_message(("book: %s\noffset :%s", e->module, e->key)); if (atol(e->key) != 0) text = main_get_book_raw_text(e->module, e->key); else text = g_strdup(e->module); if ((text == NULL) || strlen(text) == 0) { if (text) g_free(text); /* new empty document from template */ gchar *fname = g_build_filename(settings.gSwordDir, "studypad.spt", NULL); XI_message(("editor load BOOK [%s]", fname)); text = inhale_text_from_file(fname); g_free(fname); } if (text && strlen(text)) { webkit_web_view_load_string((WebKitWebView *) e->html_widget, text, "text/html", "utf_8", "file://"); } if (text) g_free(text); title = g_strdup_printf("%s", e->module); change_window_title(e->window, title); g_free(title); e->is_changed = FALSE; }
/** * Load HTML string into the rendering scrollpane * * Load an HTML string into the web view. This is used to render * HTML documents created internally. */ static void liferea_webkit_write_html ( GtkWidget *scrollpane, const gchar *string, const guint length, const gchar *base, const gchar *content_type ) { GtkWidget *htmlwidget; htmlwidget = gtk_bin_get_child (GTK_BIN (scrollpane)); /* Note: we explicitely ignore the passed base URL because we don't need it as Webkit supports <div href=""> and throws a security exception when accessing file:// with a non-file:// base URL */ webkit_web_view_load_string (WEBKIT_WEB_VIEW (htmlwidget), string, content_type, "UTF-8", "file://"); }
JNIEXPORT void JNICALL WebKitGTK_NATIVE(_1webkit_1web_1view_1load_1string) (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4) { jbyte *lparg1=NULL; jbyte *lparg2=NULL; jbyte *lparg3=NULL; jbyte *lparg4=NULL; WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1web_1view_1load_1string_FUNC); if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail; if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail; if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail; webkit_web_view_load_string((WebKitWebView *)arg0, (const gchar *)lparg1, (const gchar *)lparg2, (const gchar *)lparg3, (const gchar *)lparg4); fail: if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0); if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0); if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1web_1view_1load_1string_FUNC); }
G_MODULE_EXPORT void action_delete_item_activate_cb(GtkWidget *widget, EDITOR *e) { if (e->studypad) return; gchar *buf = g_strdup_printf("<span weight=\"bold\" size=\"larger\">%s %s?</span>", _("Are you sure you want to delete the note for"), e->key); if (gui_yes_no_dialog(buf, #ifdef HAVE_GTK_310 "dialog-warning" #else GTK_STOCK_DIALOG_WARNING #endif )) { main_delete_note(e->module, e->key); /* new empty document from template */ gchar *fname = g_build_filename(settings.gSwordDir, "studypad.spt", NULL); XI_message(("action delete item [%s]", fname)); gchar *text = inhale_text_from_file(fname); g_free(fname); if (text && strlen(text)) { webkit_web_view_load_string((WebKitWebView *) e->html_widget, text, "text/html", "utf_8", "file://"); } if (text) g_free(text); } g_free(buf); e->is_changed = FALSE; }
void webview_load(WebView *webview, const gchar *url, const gchar *content, gboolean wholePageEditable) { WebKitWebView *widget = WEBKIT_WEB_VIEW(webview->widget); // Clean up from last time if (webview->link_blocker) { g_signal_handler_disconnect(widget, webview->link_blocker); webview->link_blocker = 0; // or is zero a valid handler? } GObject *settings = G_OBJECT(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(widget))); g_object_set(settings, "enable-scripts", FALSE, NULL); webview->common.wholePageEditable = wholePageEditable; // Load file webkit_web_view_load_string(widget, content, "text/html", NULL, url); // Disable links webview->link_blocker = g_signal_connect(widget, "navigation-policy-decision-requested", G_CALLBACK(block_navigation), NULL); }
void library_view_edit_lyric(GtkToolButton *btn, GObject *lview) { library_view_t* view = (library_view_t*) g_object_get_data(lview, "library_view_t"); if (view->current_lyric_track_id != NULL) { track_t* t = library_get(view->library, view->current_lyric_track_id); if (t != NULL) { GtkLabel* lbl = GTK_LABEL(gtk_builder_get_object(view->builder, "lbl_lyr_edit_track")); char* s = (char*) mc_malloc(strlen(track_get_artist(t))+sizeof(", ")+strlen(track_get_title(t))+200); sprintf(s,"<span size=\"x-small\"><i><b>%s\n%s</b></i></span>", track_get_artist(t), track_get_title(t)); gtk_label_set_markup(lbl,s); mc_free(s); GtkDialog* dlg = GTK_DIALOG(gtk_builder_get_object(view->builder, "dlg_edit_lyric")); g_object_set_data(G_OBJECT(dlg), "track", (gpointer) t ); GtkTextView* tv = GTK_TEXT_VIEW(gtk_builder_get_object(view->builder, "txt_lyric_edit")); GtkTextBuffer* buf = gtk_text_view_get_buffer(tv); const char* lyric = track_get_lyric(t); gtk_text_buffer_set_text(buf, lyric, -1); int response = gtk_dialog_run(dlg); if (response) { GtkTextIter start, end; gtk_text_buffer_get_iter_at_offset(buf, &start, 0); gtk_text_buffer_get_iter_at_offset(buf, &end, -1); char* txt = gtk_text_buffer_get_text(buf, &start, &end, FALSE); write_lyric(t, txt, el_true); track_set_lyric(t, txt); char* html = lyric_text_to_html(txt); webkit_web_view_load_string(view->lyric_view, html, NULL, NULL, ""); mc_free(html); g_free(txt); } gtk_widget_hide(GTK_WIDGET(dlg)); } } }
void DisplayProjectNotes::show_buffer () { // Displays the notes text buffer. webkit_web_view_load_string (WEBKIT_WEB_VIEW (webview), note_buffer.c_str(), NULL, NULL, NULL); }
void WindowShowRelatedVerses::load_webview (const gchar * url) { // New url. active_url = url; // Start writing a html page. HtmlWriter2 htmlwriter (""); bool display_another_page = true; if (active_url.find ("keyterm ") == 0) { item_type = ritKeytermId; item_id = active_url.substr (8, 100); gtk_button_clicked (GTK_BUTTON (button_item)); display_another_page = false; } else if (active_url.find ("strong ") == 0) { item_type = ritStrongNumber; item_id = active_url.substr (7, 100); gtk_button_clicked (GTK_BUTTON (button_item)); display_another_page = false; } else if (active_url.find ("parallels") == 0) { item_type = ritParallels; gtk_button_clicked (GTK_BUTTON (button_item)); display_another_page = false; } else { // Display the keyterms in the verse, and their renderings. htmlwriter.heading_open (3); htmlwriter.text_add (_("Keyterms in verse ") + myreference.verse); htmlwriter.heading_close (); vector <int> keyterms = keyterms_get_terms_in_verse(myreference); for (unsigned int i = 0; i < keyterms.size(); i++) { htmlwriter.paragraph_open(); // Display the keyterm. ustring term; keyterms_get_term(keyterms[i], term); htmlwriter.text_add ("* "); ustring url = "keyterm " + convert_to_string (keyterms[i]); htmlwriter.hyperlink_add (url, term); htmlwriter.text_add (": "); // Display the renderings. vector <ustring> renderings; vector <bool> wholewords; vector <bool> casesensitives; ustring category; { ustring dummy1; vector < Reference > dummy2; keyterms_get_data(keyterms[i], category, dummy1, dummy2); } keyterms_retrieve_renderings(myproject, term, category, renderings, wholewords, casesensitives); for (unsigned int i2 = 0; i2 < renderings.size(); i2++) { if (i2) htmlwriter.text_add (", "); htmlwriter.text_add (renderings[i2]); } htmlwriter.paragraph_close(); } // If there are no keyterms, mention this. if (keyterms.empty()) { htmlwriter.paragraph_open (); htmlwriter.text_add ("none"); htmlwriter.paragraph_close (); } // Terms derived from the Strong's numbers in this verse. htmlwriter.heading_open (3); htmlwriter.text_add (_("Similar words in other verses")); htmlwriter.heading_close (); // Get the data. vector <ustring> strongs; vector <ustring> words; kjv_get_strongs_data (myreference, strongs, words); // Display the data. for (unsigned int i = 0; i < strongs.size(); i++) { htmlwriter.paragraph_open (); Parse parse (strongs[i]); for (unsigned int i2 = 0; i2 < parse.words.size (); i2++) { htmlwriter.text_add (words[i]); htmlwriter.text_add (" "); ustring url = "strong " + parse.words[i2]; htmlwriter.hyperlink_add (url, parse.words[i2]); } htmlwriter.paragraph_close (); } // Parallel passages. vector <Reference> parallel_references; vector <ustring> parallel_comments; parallel_passages_retrieve (myreference, parallel_references, parallel_comments); if (!parallel_references.empty()) { extern Settings *settings; ProjectConfiguration *projectconfig = settings->projectconfig(myproject); ustring language = projectconfig->language_get(); htmlwriter.heading_open (3); htmlwriter.text_add (_("Parallel passages")); htmlwriter.heading_close (); for (unsigned int i = 0; i < parallel_references.size(); i++) { htmlwriter.paragraph_open (); htmlwriter.text_add (parallel_references[i].human_readable (language) + " " + parallel_comments[i]); htmlwriter.paragraph_close (); } htmlwriter.paragraph_open (); htmlwriter.hyperlink_add ("parallels", _("Send to references window")); htmlwriter.paragraph_close (); } } htmlwriter.finish(); if (display_another_page) { // Load the page. webkit_web_view_load_string (WEBKIT_WEB_VIEW (webview), htmlwriter.html.c_str(), NULL, NULL, NULL); // Scroll to the position that possibly was stored while this url was last active. GtkAdjustment * adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolledwindow)); gtk_adjustment_set_value (adjustment, scrolling_position[active_url]); } }
static void messageview_show_cb(GObject *obj, gpointer msgview, MsgInfo *msginfo, gboolean all_headers) { MessageView *messageview = NULL; MimeInfo *mimeinfo, *partial; FILE *msg_file, *input = NULL; gchar *html_buf = NULL; size_t n_size; #if defined(USE_WEBKITGTK) WebKitWebSettings *settings = NULL; #elif defined(USE_GTKHTML) #else #error "Not Implemented" #endif SYLPF_START_FUNC; g_return_if_fail(msgview != NULL); messageview = (MessageView*)msgview; g_return_if_fail(messageview != NULL); SYLPF_OPTION.is_show_attach_tab = SYLPF_GET_RC_SHOW_ATTACH_TAB; if (SYLPF_OPTION.is_show_attach_tab == 0) { gtk_notebook_set_current_page(GTK_NOTEBOOK(messageview->notebook), 0); SYLPF_RETURN; } if (SYLPF_OPTION.html_view == NULL) { #if defined(USE_WEBKITGTK) SYLPF_OPTION.html_view = (WebKitWebView*)create_htmlview(GTK_NOTEBOOK(messageview->notebook)); #elif defined(USE_GTKHTML) SYLPF_OPTION.html_view = create_htmlview(GTK_NOTEBOOK(messageview->notebook)); #endif } mimeinfo = procmime_scan_message(msginfo); msg_file = procmsg_open_message(msginfo); partial = mimeinfo; while (partial && partial->mime_type != MIME_TEXT_HTML) { partial = procmime_mimeinfo_next(partial); } if (partial && partial->mime_type == MIME_TEXT_HTML) { partial->mime_type = MIME_TEXT; input = procmime_get_text_content(partial, msg_file, NULL); html_buf = calloc(partial->size+1, 1); n_size = fread(html_buf, partial->size, 1, input); #if defined(USE_WEBKITGTK) settings = webkit_web_view_get_settings(SYLPF_OPTION.html_view); g_object_set(G_OBJECT(settings), ENABLE_IMAGES, SYLPF_OPTION.image_flag, NULL); g_object_set(G_OBJECT(settings), ENABLE_SCRIPTS, SYLPF_OPTION.script_flag, NULL); g_object_set(G_OBJECT(settings), ENABLE_PRIVATE_BROWSING, SYLPF_OPTION.private_flag, NULL); g_object_set(G_OBJECT(settings), DEFAULT_FONT_SIZE, SYLPF_OPTION.font_size, NULL); webkit_web_view_set_settings(SYLPF_OPTION.html_view, settings); webkit_web_view_load_string(SYLPF_OPTION.html_view, html_buf, NULL, NULL, ""); #elif defined(USE_GTKHTML) gtk_html_load_from_string(GTK_HTML(SYLPF_OPTION.html_view), html_buf, -1); #endif if (SYLPF_OPTION.switch_tab_flag != FALSE) { gtk_notebook_set_current_page(GTK_NOTEBOOK(messageview->notebook), 2); } fclose(input); free(html_buf); } else { gtk_notebook_set_current_page(GTK_NOTEBOOK(messageview->notebook), 0); } SYLPF_END_FUNC; }
static int gtkWebBrowserSetHTMLAttrib(Ihandle* ih, const char* value) { if (value) webkit_web_view_load_string((WebKitWebView*)ih->handle, iupgtkStrConvertToUTF8(value), "text/html", "UTF-8", ""); return 0; /* do not store value in hash table */ }
void WindowCheckKeyterms::html_link_clicked (const gchar * url) { // Store scrolling position for the now active url. GtkAdjustment * adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolledwindow_terms)); scrolling_position[active_url] = gtk_adjustment_get_value (adjustment); // New url. active_url = url; // Whether to show some widgets. bool show_collections = false; bool show_renderings = false; // Start writing a html page. HtmlWriter2 htmlwriter (""); bool display_another_page = false; if (active_url.find (_("keyterm ")) == 0) { // Store url of this keyterm. last_keyword_url = active_url; // Get the keyterm identifier. ustring url = active_url; url.erase (0, 8); keyword_id = convert_to_int (url); // Load the renderings. // To be done before displaying the verses themselves since the latter depends on the former. load_renderings (); // Write extra bits. html_write_keyterms (htmlwriter, keyword_id); show_renderings = true; display_another_page = true; } else if (active_url.find (_("goto ")) == 0) { // Signal the editors to go to a reference. ustring url = active_url; url.erase (0, 5); myreference.assign (get_reference (url)); new_reference_showing = &myreference; gtk_button_clicked(GTK_BUTTON(signal)); } else if (active_url.find (_("send")) == 0) { // Send the references to the references window. ustring url = active_url; new_reference_showing = NULL; gtk_button_clicked(GTK_BUTTON(signal)); } else { // Give the starting page with all keyterms of the active selection. show_collections = true; if (collection().find (_("Biblical")) != string::npos) { if (collection().find (_("Hebrew")) != string::npos) { htmlwriter.paragraph_open (); htmlwriter.text_add (_("Key Terms in Biblical Hebrew: The entries are an experimental sample set, not yet fully reviewed and approved. The KTBH team would welcome feed-back to [email protected].")); htmlwriter.paragraph_close (); } } vector <ustring> terms; vector <unsigned int> ids; keyterms_get_terms("", collection(), terms, ids); for (unsigned int i = 0; i < terms.size(); i++) { htmlwriter.paragraph_open(); htmlwriter.hyperlink_add (_("keyterm ") + convert_to_string (ids[i]), terms[i]); htmlwriter.paragraph_close(); } display_another_page = true; // No renderings. clear_renderings (); } htmlwriter.finish(); if (display_another_page) { // Load the page. webkit_web_view_load_string (WEBKIT_WEB_VIEW (webview_terms), htmlwriter.html.c_str(), NULL, NULL, NULL); // Scroll to the position that possibly was stored while this url was last active. GtkAdjustment * adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolledwindow_terms)); gtk_adjustment_set_value (adjustment, scrolling_position[active_url]); // Whether to show collections. if (show_collections) gtk_widget_show (hbox_collection); else gtk_widget_hide (hbox_collection); if (show_renderings) gtk_widget_show (treeview_renderings); else gtk_widget_hide (treeview_renderings); } }
gboolean map_event_cb(GtkWidget *widget, GdkEvent* event, DomDomviewFixture* fixture) { webkit_web_view_load_string(WEBKIT_WEB_VIEW (fixture->webView), (const char*)fixture->data, NULL, NULL, NULL); return FALSE; }
static void test_dom_document_garbage_collection(DomDocumentFixture* fixture, gconstpointer data) { guint count = 0; g_assert(fixture); WebKitWebView* view = (WebKitWebView*)fixture->webView; g_assert(view); WebKitDOMDocument* document = webkit_web_view_get_dom_document(view); g_assert(document); g_object_weak_ref(G_OBJECT(document), (GWeakNotify)weak_notify, &count); WebKitDOMHTMLHeadElement* head = webkit_dom_document_get_head(document); g_assert(head); g_object_weak_ref(G_OBJECT(head), (GWeakNotify)weak_notify, &count); WebKitDOMHTMLElement* body = webkit_dom_document_get_body(document); g_assert(body); g_object_weak_ref(G_OBJECT(body), (GWeakNotify)weak_notify, &count); WebKitDOMHTMLCollection *collection = webkit_dom_document_get_links(document); g_assert(collection); g_object_weak_ref(G_OBJECT(collection), (GWeakNotify)weak_notify, &count); webkit_web_view_load_string(WEBKIT_WEB_VIEW(view), HTML_DOCUMENT_LINKS, NULL, NULL, NULL); while (g_main_context_pending(NULL)) g_main_context_iteration(NULL, FALSE); g_assert_cmpuint(count, ==, 3); g_object_unref(collection); g_assert_cmpuint(count, ==, 4); count = 0; document = webkit_web_view_get_dom_document(view); g_assert(document); g_object_weak_ref(G_OBJECT(document), (GWeakNotify)weak_notify, &count); head = webkit_dom_document_get_head(document); g_assert(head); g_object_weak_ref(G_OBJECT(head), (GWeakNotify)weak_notify, &count); body = webkit_dom_document_get_body(document); g_assert(body); g_object_weak_ref(G_OBJECT(body), (GWeakNotify)weak_notify, &count); collection = webkit_dom_document_get_links(document); g_assert(collection); g_object_weak_ref(G_OBJECT(collection), (GWeakNotify)weak_notify, &count); /* Ask twice for the same object */ WebKitDOMHTMLCollection* collection2 = webkit_dom_document_get_links(document); g_assert(collection2); g_object_weak_ref(G_OBJECT(collection2), (GWeakNotify)weak_notify, &count); g_object_unref(document); g_object_unref(head); g_object_unref(body); g_object_unref(collection); g_object_unref(collection2); g_assert_cmpuint(count, ==, 5); webkit_web_view_load_string(WEBKIT_WEB_VIEW(view), HTML_DOCUMENT_IFRAME, NULL, NULL, NULL); while (g_main_context_pending(NULL)) g_main_context_iteration(NULL, FALSE); count = 0; document = webkit_web_view_get_dom_document(view); WebKitDOMElement* div = webkit_dom_document_get_element_by_id(document, "test"); g_assert(div); g_object_weak_ref(G_OBJECT(div), (GWeakNotify)weak_notify, &count); WebKitDOMElement* iframe = webkit_dom_document_get_element_by_id(document, "iframe"); g_assert(iframe); webkit_dom_element_set_attribute(iframe, "src", "data:<html><head></head></html>", NULL); while (g_main_context_pending(NULL)) g_main_context_iteration(NULL, FALSE); WebKitDOMDocument* iframeDocument = webkit_dom_html_iframe_element_get_content_document(WEBKIT_DOM_HTML_IFRAME_ELEMENT(iframe)); g_assert(iframeDocument); head = webkit_dom_document_get_head(iframeDocument); g_assert(head); g_object_weak_ref(G_OBJECT(head), (GWeakNotify)weak_notify, &count); webkit_dom_element_set_attribute(iframe, "src", "about:blank", NULL); while (g_main_context_pending(NULL)) g_main_context_iteration(NULL, FALSE); g_assert_cmpuint(count, ==, 1); webkit_web_view_load_string(WEBKIT_WEB_VIEW(view), HTML_DOCUMENT_LINKS, NULL, NULL, NULL); while (g_main_context_pending(NULL)) g_main_context_iteration(NULL, FALSE); g_assert_cmpuint(count, ==, 2); count = 0; document = webkit_web_view_get_dom_document(view); g_assert(document); g_object_weak_ref(G_OBJECT(document), (GWeakNotify)weak_notify, &count); /* Ask twice for the Document */ WebKitDOMDocument* document2 = webkit_web_view_get_dom_document(view); g_assert(document2); g_object_weak_ref(G_OBJECT(document2), (GWeakNotify)weak_notify, &count); head = webkit_dom_document_get_head(document); g_assert(head); g_object_weak_ref(G_OBJECT(head), (GWeakNotify)weak_notify, &count); body = webkit_dom_document_get_body(document); g_assert(body); g_object_weak_ref(G_OBJECT(body), (GWeakNotify)weak_notify, &count); collection = webkit_dom_document_get_links(document); g_assert(collection); g_object_weak_ref(G_OBJECT(collection), (GWeakNotify)weak_notify, &count); gtk_widget_destroy(fixture->webView); fixture->webView = NULL; g_assert_cmpuint(count, ==, 4); g_object_unref(collection); g_assert_cmpuint(count, ==, 5); }