46
46
#include "main/previewer.h"
47
47
#include "main/search_dialog.h"
48
48
#include "main/settings.h"
49
49
#include "main/sword.h"
50
50
#include "main/xml.h"
51
51
#include "main/url.hh"
53
53
#include "gui/search_dialog.h"
54
54
#include "gui/bookmark_dialog.h"
55
55
#include "gui/bookmarks_treeview.h"
66
66
#define SEARCHING _("Searching the ")
67
67
#define SMODULE _(" Module")
68
#define FINDS _("found in ")
68
#define FINDS _("found in ")
69
69
#define HTML_START "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"></head>"
71
71
static BackEnd *backendSearch = NULL;
101
101
* exports search results to html or plain text
108
108
gboolean main_export_current_adv_search (GString * str, gboolean html, gboolean with_scripture)
110
110
GList *verses = NULL;
111
111
GList *tmp = NULL;
112
112
RESULTS *list_item;
113
113
gboolean ret = FALSE;
116
116
tmp = g_list_first(list_for_bookmarking);
118
118
str = g_string_append(str, "<html><body>");
120
120
verses = (GList*) tmp->data;
122
122
GString *verse_string = g_string_new("");
123
123
gboolean first_entry = TRUE;
126
126
list_item = (RESULTS *) verses->data;
127
127
if (main_is_Bible_key(list_item->key)) {
131
131
g_string_printf(verse_string, "<ul><b>%s</b>", list_item->module);
137
137
desc = g_strdup_printf("%s %s",
139
139
list_item->module);
141
141
gui_set_html_item ( str,
147
gui_set_plain_text_item ( str,
147
gui_set_plain_text_item ( str,
155
155
verses = g_list_next(verses);
176
176
* saves search results as bookmarks - single bookmark per module
183
183
void main_save_current_adv_search_as_bookmarks (void)
185
185
GList *verses = NULL;
186
186
RESULTS *list_item;
187
187
gchar *module_name = NULL;
189
189
list_for_bookmarking = g_list_first(list_for_bookmarking);
190
190
while (list_for_bookmarking) {
191
191
verses = (GList*) list_for_bookmarking->data;
193
193
GString *name = g_string_new(NULL);
194
194
GString *verse_string = g_string_new("");
195
195
gboolean first_entry = TRUE;
489
489
gtk_list_store_clear(list_store);
492
492
buf = (char*) tmp->data;
493
493
gtk_list_store_append(list_store, &iter);
494
gtk_list_store_set(list_store,
494
gtk_list_store_set(list_store,
498
498
tmp = g_list_next(tmp);
536
536
buf[1] = xml_get_list();
538
538
gtk_list_store_append(list_store, &iter);
539
gtk_list_store_set(list_store,
539
gtk_list_store_set(list_store,
548
548
gui_clear_combo(search1.combo_range);
549
549
while (xml_next_item()) {
550
550
if (xml_get_label()) {
552
552
buf[1] = xml_get_list();
554
554
gtk_list_store_append(list_store, &iter);
555
gtk_list_store_set(list_store,
555
gtk_list_store_set(list_store,
560
560
gui_add_item_to_combo(search1.combo_range,
602
602
buf[1] = xml_get_list();
604
604
gtk_list_store_append(list_store, &iter);
605
gtk_list_store_set(list_store,
605
gtk_list_store_set(list_store,
618
618
buf[1] = xml_get_list();
620
620
gtk_list_store_append(list_store, &iter);
621
gtk_list_store_set(list_store,
621
gtk_list_store_set(list_store,
626
626
gui_add_item_to_combo(search1.combo_list,
654
654
void main_change_mods_select_label(char *mod_name)
658
658
if (GTK_TOGGLE_BUTTON(search1.rb_current_module)->active) {
659
659
str = g_strdup_printf("<b>%s</b>%s",Q_("Search: "),mod_name);
660
660
gtk_label_set_markup(GTK_LABEL(search1.label_mod_select), str);
740
740
gchar *mod_list = NULL;
741
741
GList *mods = NULL;
742
742
GtkTreeSelection *selection_modules_lists;
744
744
model_modules_lists =
745
745
gtk_tree_view_get_model(GTK_TREE_VIEW(search1.module_lists));
746
746
store_modules_lists = GTK_LIST_STORE(model_modules_lists);
748
748
selection_modules_lists = gtk_tree_view_get_selection
749
749
(GTK_TREE_VIEW(search1.module_lists));
752
752
gtk_tree_view_get_model(GTK_TREE_VIEW(tree_widget));
753
753
list_store = GTK_LIST_STORE(model_mods);
764
764
gtk_tree_selection_get_selected
765
(selection_modules_lists, NULL,
765
(selection_modules_lists, NULL,
766
766
&selected_modules_lists);
768
768
gtk_list_store_set(store_modules_lists,
769
769
&selected_modules_lists,
770
770
1, mod_list, -1);
833
833
selection_modules_lists = gtk_tree_view_get_selection
834
834
(GTK_TREE_VIEW(search1.module_lists));
836
if (gtk_tree_model_iter_has_child(model, &selected))
836
if (gtk_tree_model_iter_has_child(model, &selected))
839
839
gtk_tree_model_get(model, &selected, 0, &mod, -1);
842
842
backendSearch->module_description(mod);
844
844
if (GTK_TOGGLE_BUTTON(search1.rb_current_module)->active) {
856
856
gtk_tree_selection_get_selected
857
(selection_modules_lists, NULL,
857
(selection_modules_lists, NULL,
858
858
&selected_modules_lists);
860
860
gtk_list_store_set(store_modules_lists,
861
861
&selected_modules_lists,
862
862
1, mod_list, -1);
895
895
GtkTreeModel *model;
896
896
GtkTreeIter selected;
897
897
GtkTreePath *path;
899
899
if (!gtk_tree_selection_get_selected (selection,&model,&selected))
901
901
gtk_tree_model_get(model, &selected, 0, &text, -1);
935
935
void main_finds_verselist_selection_changed(GtkTreeSelection * selection,
936
GtkTreeModel * model,
936
GtkTreeModel * model,
937
937
gboolean is_double_click)
939
939
gchar *text, *buf, *module, *key;
977
977
#ifdef USE_GTKMOZEMBED
978
978
GString *html_text = g_string_new(HTML_START);
979
979
g_string_append(html_text, text_str->str);
980
g_string_append(html_text, "</html>");
980
g_string_append(html_text, "</html>");
981
981
gecko_html_open_stream(GECKO_HTML(search1.preview_html), "text/html");
982
982
gecko_html_write(GECKO_HTML(search1.preview_html),
983
983
html_text->str, html_text->len);
1144
1144
gchar *str = NULL;
1145
1145
gchar *mod_list_str = NULL;
1146
1146
const gchar *name = NULL;
1148
1148
if (!GTK_TOGGLE_BUTTON(search1.rb_custom_list)->active)
1150
name = gtk_entry_get_text(GTK_ENTRY(GTK_BIN(combobox)->child));
1150
name = gtk_entry_get_text(GTK_ENTRY(GTK_BIN(combobox)->child));
1151
1151
mod_list = get_custom_list_from_name(name);
1152
1152
mod_list_str = get_modlist_string(mod_list);
1153
1153
if (strlen(mod_list_str) > 60)
1474
1474
(search1.listview_verses));
1475
1475
list_store2 = GTK_LIST_STORE(model2);
1476
1476
gtk_list_store_clear(list_store2);
1478
1478
search_string =
1479
1479
gtk_entry_get_text(GTK_ENTRY(search1.search_entry));
1481
1481
if (strlen(search_string) < 1)
1483
1483
str = g_string_new("");
1485
1485
gtk_notebook_set_current_page(GTK_NOTEBOOK(search1.notebook), 1);
1487
1487
GTK_TOGGLE_BUTTON(search1.rb_regexp)->active ? 0 :
1488
1488
GTK_TOGGLE_BUTTON(search1.rb_exact_phrase)->active ? -1 :
1489
1489
GTK_TOGGLE_BUTTON(search1.rb_words)->active ? -2 :
1496
1496
// For attribute-based searches, e.g. "Word//Lemma/G140",
1497
1497
// we must constrain the match to whole words. Otherwise,
1498
// we will inadvertently return e.g. 140 plus 1401 and 1404.
1499
if(search_type == -3) {
1500
if(GTK_TOGGLE_BUTTON(search1.rb_strongs)->active) {
1498
// we will inadvertently return e.g. 140 plus 1401 and 1404.
1499
if (search_type == -3) {
1500
if (GTK_TOGGLE_BUTTON(search1.rb_strongs)->active) {
1501
1501
search_params |= SEARCHFLAG_MATCHWHOLEENTRY;
1502
1502
attribute_search_string = g_strdup_printf(
1503
1503
#ifdef SWORD_MULTIVERSE
1506
1506
"Word//Lemma/%s",
1508
1508
search_string);
1509
} else if(GTK_TOGGLE_BUTTON(search1.rb_morphs)->active) {
1509
} else if (GTK_TOGGLE_BUTTON(search1.rb_morphs)->active) {
1510
1510
search_params |= SEARCHFLAG_MATCHWHOLEENTRY;
1511
1511
attribute_search_string = g_strdup_printf(
1512
1512
"Word//Morph/%s",
1513
1513
search_string);
1514
} else if(GTK_TOGGLE_BUTTON(search1.rb_footnotes)->active) {
1514
} else if (GTK_TOGGLE_BUTTON(search1.rb_footnotes)->active) {
1515
1515
attribute_search_string = g_strdup_printf(
1516
1516
"Footnote//body/%s",
1517
1517
search_string);
1585
1585
GS_message(("search_type = %d",search_type));
1587
finds = backendSearch->do_module_search(module,
1587
finds = backendSearch->do_module_search(module,
1588
1588
(attribute_search_string
1589
1589
? mgr->getModule(module)->
1590
1590
StripText(attribute_search_string)
1591
1591
: mgr->getModule(module)->
1592
1592
StripText(search_string)),
1597
1597
tmp_list = g_list_first(tmp_list);
1598
1598
tmp_list = NULL;
1599
1599
tmp_bookmark_list = g_list_first(tmp_bookmark_list);
1600
1600
tmp_bookmark_list = NULL;
1602
mod_type = backendSearch->module_type(module);
1602
mod_type = backendSearch->module_type(module);
1603
1603
while ((key_buf = backendSearch->get_next_listkey()) != NULL) {
1604
if (mod_type == TEXT_TYPE)
1604
if (mod_type == TEXT_TYPE)
1605
1605
g_string_printf(str, "%s: %s %s", module, key_buf, backendSearch->get_strip_text(module, key_buf));
1607
g_string_printf(str, "%s: %s", module, key_buf);
1607
g_string_printf(str, "%s: %s", module, key_buf);
1608
1608
tmp_list = g_list_append(tmp_list, (char*) g_strdup(str->str));
1610
1610
results = g_new(RESULTS,1);
1611
1611
results->module = g_strdup(module);
1612
1612
results->key = g_strdup(key_buf);
1613
tmp_bookmark_list = g_list_append(tmp_bookmark_list,
1613
tmp_bookmark_list = g_list_append(tmp_bookmark_list,
1614
1614
(RESULTS*) results);
1616
1616
list_of_finds = g_list_append(list_of_finds, (GList*)tmp_list);
1622
1622
num, FINDS, module);
1624
1624
gtk_list_store_append(list_store, &iter);
1625
gtk_list_store_set(list_store,
1625
gtk_list_store_set(list_store,
1630
1630
if (x == 1) { // add verse list for hits in first module to verse listview
1639
1639
search_active = FALSE;
1641
if(attribute_search_string)
1641
if (attribute_search_string)
1642
1642
g_free((gchar*)attribute_search_string);
1643
1643
g_list_free(search_mods);
1644
1644
gui_set_progressbar_text(search1.progressbar, _("Search finished"));
1671
1671
delete backendSearch;
1673
1673
backendSearch = new BackEnd();
1675
1675
/* create and show search dialog */
1676
1676
gui_create_search_dialog();
1677
1677
backendSearch->init_SWORD(2);
1680
1680
/* initiate module count to 0 */
1681
1681
search1.module_count = 0;
1715
1715
* #include "main/search.h"
1717
* void search_percent_update(char percent, void *userData)
1717
* void search_percent_update(char percent, void *userData)
1720
1720
* updates the progress bar during shortcut bar search
1726
1726
void main_dialog_search_percent_update(char percent, void *userData)
1728
1728
char maxHashes = *((char *) userData);
1730
1730
static char printed = 0;
1732
1732
if (terminate_search) {
1733
1733
backendSearch->terminate_search();
1734
1734
// this is WAY WRONG but at least it cleans up the dying window. */