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); } }
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]); } }