PageRenderTime 33ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/xiphos-3.1.5/src/gnome2/search_dialog.c

#
C | 1750 lines | 828 code | 248 blank | 674 comment | 38 complexity | 28bb95c85064bbfacb633c0a6a6fd54c MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. * Xiphos Bible Study Tool
  3. * search_dialog.c - gui for searching Sword modules
  4. *
  5. * Copyright (C) 2000-2011 Xiphos Developer Team
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <gtk/gtk.h>
  25. #ifdef GTKHTML
  26. #include <gtkhtml/gtkhtml.h>
  27. #include "gui/html.h"
  28. #endif
  29. #ifndef USE_GTKBUILDER
  30. #include <glade/glade-xml.h>
  31. #endif
  32. #include "../xiphos_html/xiphos_html.h"
  33. #include <regex.h>
  34. #include <string.h>
  35. #include <glib.h>
  36. #include "gui/search_dialog.h"
  37. #include "gui/main_window.h"
  38. #include "gui/dialog.h"
  39. #include "gui/utilities.h"
  40. #include "gui/widgets.h"
  41. #include "gtk/gtk.h"
  42. #include "gui/export_bookmarks.h"
  43. #include "main/search_dialog.h"
  44. #include "main/configs.h"
  45. #include "main/lists.h"
  46. #include "main/previewer.h"
  47. #include "main/settings.h"
  48. #include "main/sword.h"
  49. #include "main/url.hh"
  50. #include "main/xml.h"
  51. #include "gui/debug_glib_null.h"
  52. /******************************************************************************/
  53. #define _BYTE 8
  54. #define _WORD 16
  55. #define _DWORD 32
  56. #define SEARCHING N_("Searching the ")
  57. #define SMODULE N_(" Module")
  58. #define FINDS N_("found in ")
  59. #define HTML_START "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\"><!-- A { text-decoration:none } *[dir=rtl] { text-align: right; } --></style></head>"
  60. SEARCH_DIALOG1 search1;
  61. static gboolean _preview_on;
  62. static gchar *module_selected;
  63. gchar *verse_selected;
  64. GtkWidget *remember_search; /* needed to change button in search stop */
  65. /* click on treeview folder to expand or collapse it */
  66. static gboolean button_release_event(GtkWidget * widget,
  67. GdkEventButton * event,
  68. gpointer data)
  69. {
  70. GtkTreeSelection *selection = NULL;
  71. GtkTreeIter selected;
  72. GtkTreeModel *model;
  73. GtkTreePath *path;
  74. selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
  75. if (!gtk_tree_selection_get_selected(selection, &model, &selected))
  76. return FALSE;
  77. if (!gtk_tree_model_iter_has_child(model, &selected))
  78. return FALSE;
  79. path = gtk_tree_model_get_path(model, &selected);
  80. if (gtk_tree_view_row_expanded (GTK_TREE_VIEW(widget), path))
  81. gtk_tree_view_collapse_row ( GTK_TREE_VIEW(widget), path );
  82. else
  83. gtk_tree_view_expand_row ( GTK_TREE_VIEW(widget), path, FALSE );
  84. gtk_tree_path_free ( path );
  85. return FALSE;
  86. }
  87. void on_comboboxentry2_changed(GtkComboBox * combobox,
  88. gpointer user_data)
  89. {
  90. main_comboboxentry2_changed(combobox, user_data);
  91. }
  92. /******************************************************************************
  93. * Name
  94. * button_clean
  95. *
  96. * Synopsis
  97. * #include "gui/search_dialog.h"
  98. *
  99. * void button_clean(GtkButton * button, gpointer user_data)
  100. *
  101. * Description
  102. * user pressed clear button - clears search results page
  103. *
  104. * Return value
  105. * void
  106. */
  107. void button_clean(GtkButton * button, gpointer user_data)
  108. {
  109. GtkTreeModel *model;
  110. GtkListStore *list_store;
  111. #ifdef USE_XIPHOS_HTML
  112. GString *html_text = g_string_new("");
  113. #endif
  114. GS_message(("button_clean"));
  115. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.listview_results));
  116. list_store = GTK_LIST_STORE(model);
  117. gtk_list_store_clear(list_store);
  118. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.listview_verses));
  119. list_store = GTK_LIST_STORE(model);
  120. gtk_list_store_clear(list_store);
  121. #ifdef USE_XIPHOS_HTML
  122. g_string_printf(html_text, HTML_START "<body text=\"%s\" bgcolor=\"%s\"> </body></html>",
  123. settings.bible_text_color, settings.bible_bg_color);
  124. XIPHOS_HTML_OPEN_STREAM(search1.preview_html,"text/html");
  125. XIPHOS_HTML_WRITE(search1.preview_html,html_text->str,html_text->len);
  126. XIPHOS_HTML_CLOSE(search1.preview_html);
  127. g_string_free(html_text,TRUE);
  128. #else
  129. gtk_html_load_from_string(GTK_HTML(search1.preview_html), " ", 1);
  130. #endif
  131. }
  132. /******************************************************************************
  133. * Name
  134. * button_save
  135. *
  136. * Synopsis
  137. * #include "gui/search_dialog.h"
  138. *
  139. * void button_save(GtkButton * button, gpointer user_data)
  140. *
  141. * Description
  142. * calls main_save_current_adv_search_as_bookmarks() in main/search_dialog.cc
  143. * to do the work of saving current search as bookmarks
  144. *
  145. * Return value
  146. * void
  147. */
  148. void button_save(GtkButton * button, gpointer user_data)
  149. {
  150. main_save_current_adv_search_as_bookmarks ();
  151. }
  152. /******************************************************************************
  153. * Name
  154. * button_export
  155. *
  156. * Synopsis
  157. * #include "gui/search_dialog.h"
  158. *
  159. * void button_export(GtkButton * button, gpointer user_data)
  160. *
  161. * Description
  162. * calls main_save_current_adv_search_as_bookmarks() in main/search_dialog.cc
  163. * to do the work of saving current search as bookmarks
  164. *
  165. * Return value
  166. * void
  167. */
  168. void button_export(GtkButton * button, gpointer user_data)
  169. {
  170. gui_export_bookmarks_dialog(ADV_SEARCH_RESULTS_EXPORT, NULL);
  171. }
  172. /******************************************************************************
  173. * Name
  174. * on_destroy
  175. *
  176. * Synopsis
  177. * #include "gui/search_dialog.h"
  178. *
  179. * void on_destroy(GtkWidget * dialog, gpointer user_data)
  180. *
  181. * Description
  182. * destroy the search dialog
  183. *
  184. * Return value
  185. * void
  186. */
  187. void _on_destroy(GtkWidget * dialog, gpointer user_data)
  188. {
  189. /* main_do_dialog_search() initializes these as search starts */
  190. if (search_active) {
  191. terminate_search = TRUE;
  192. sync_windows();
  193. } else {
  194. main_close_search_dialog();
  195. if (module_selected) {
  196. g_free(module_selected);
  197. module_selected = NULL;
  198. }
  199. if (verse_selected) {
  200. g_free(verse_selected);
  201. verse_selected = NULL;
  202. }
  203. }
  204. }
  205. /******************************************************************************
  206. * Name
  207. * on_button_begin_search
  208. *
  209. * Synopsis
  210. * #include "gui/search_dialog.h"
  211. *
  212. * void on_button_begin_search(GtkButton * button, gpointer user_data)
  213. *
  214. * Description
  215. * starts the search
  216. *
  217. * Return value
  218. * void
  219. */
  220. void on_button_begin_search(GtkButton * button, gpointer user_data)
  221. {
  222. if (search_active) {
  223. terminate_search = TRUE;
  224. gtk_button_set_label((GtkButton *)remember_search, "gtk-find");
  225. gtk_button_set_use_stock((GtkButton *)remember_search, TRUE);
  226. sync_windows();
  227. } else {
  228. gtk_button_set_label((GtkButton *)remember_search, "gtk-stop");
  229. gtk_button_set_use_stock((GtkButton *)remember_search, TRUE);
  230. main_do_dialog_search();
  231. gtk_button_set_label((GtkButton *)remember_search, "gtk-find");
  232. gtk_button_set_use_stock((GtkButton *)remember_search, TRUE);
  233. }
  234. }
  235. /******************************************************************************
  236. * Name
  237. * list_name_changed
  238. *
  239. * Synopsis
  240. * #include "gui/search_dialog.h"
  241. *
  242. * void list_name_changed(GtkEditable * editable,
  243. * gpointer user_data)
  244. *
  245. * Description
  246. * text in the range name entry has changed
  247. * name text in the clist_range is updated to match
  248. *
  249. * Return value
  250. * void
  251. */
  252. void list_name_changed(GtkEditable * editable, gpointer user_data)
  253. {
  254. const gchar *text;
  255. GtkTreeModel *model;
  256. GtkListStore *list_store;
  257. GtkTreeSelection *selection;
  258. GtkTreeIter selected;
  259. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.module_lists));
  260. list_store = GTK_LIST_STORE(model);
  261. selection = gtk_tree_view_get_selection
  262. (GTK_TREE_VIEW(search1.module_lists));
  263. if (!gtk_tree_selection_get_selected(selection, NULL, &selected))
  264. return;
  265. text = gtk_entry_get_text(GTK_ENTRY(editable));
  266. gtk_list_store_set(list_store, &selected, 0, text, -1);
  267. }
  268. /******************************************************************************
  269. * Name
  270. * range_name_changed
  271. *
  272. * Synopsis
  273. * #include "gui/search_dialog.h"
  274. *
  275. * void range_name_changed(GtkEditable * editable,
  276. * gpointer user_data)
  277. *
  278. * Description
  279. * text in the range name entry has changed
  280. * name text in the clist_range is updated to match
  281. *
  282. * Return value
  283. * void
  284. */
  285. void range_name_changed(GtkEditable * editable, gpointer user_data)
  286. {
  287. const gchar *text;
  288. GtkTreeModel *model;
  289. GtkListStore *list_store;
  290. GtkTreeSelection *selection;
  291. GtkTreeIter selected;
  292. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.list_range_name));
  293. list_store = GTK_LIST_STORE(model);
  294. selection = gtk_tree_view_get_selection
  295. (GTK_TREE_VIEW(search1.list_range_name));
  296. if (!gtk_tree_selection_get_selected
  297. (selection, NULL, &selected))
  298. return;
  299. text = gtk_entry_get_text(GTK_ENTRY(editable));
  300. gtk_list_store_set(list_store, &selected, 0, text, -1);
  301. }
  302. /******************************************************************************
  303. * Name
  304. * range_text_changed
  305. *
  306. * Synopsis
  307. * #include "gui/search_dialog.h"
  308. *
  309. * void range_text_changed(GtkEditable * editable,
  310. * gpointer user_data)
  311. *
  312. * Description
  313. * text in the range text entry has changed
  314. *
  315. * Return value
  316. * void
  317. */
  318. void range_text_changed(GtkEditable * editable, gpointer user_data)
  319. {
  320. main_range_text_changed(editable);
  321. }
  322. /******************************************************************************
  323. * Name
  324. * new_modlist
  325. *
  326. * Synopsis
  327. * #include "gui/search_dialog.h"
  328. *
  329. * void new_modlist(GtkButton * button, gpointer user_data)
  330. *
  331. * Description
  332. * adds a new custom module list to the
  333. *
  334. * Return value
  335. * void
  336. */
  337. void new_modlist(GtkButton * button, gpointer user_data)
  338. {
  339. gchar buf[80];
  340. GtkTreeModel *model;
  341. GtkListStore *list_store;
  342. GtkTreeModel *model2;
  343. GtkListStore *list_store2;
  344. GtkTreeIter iter;
  345. GtkTreeSelection *selection;
  346. GtkTreePath *path;
  347. selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(search1.module_lists));
  348. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.listview_modules));
  349. list_store = GTK_LIST_STORE(model);
  350. model2 = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.module_lists));
  351. list_store2 = GTK_LIST_STORE(model2);
  352. {
  353. // must encode locale-sensitively
  354. char *num = main_format_number(search1.list_rows);
  355. sprintf(buf, _("New List %s"), num);
  356. g_free(num);
  357. }
  358. search1.module_count = 0;
  359. gtk_list_store_clear(list_store);
  360. gtk_list_store_append(list_store2, &iter);
  361. gtk_list_store_set(list_store2, &iter, 0, buf, -1);
  362. path = gtk_tree_model_get_path(model2, &iter);
  363. gtk_tree_selection_select_path(selection, path);
  364. gtk_entry_set_text(GTK_ENTRY(search1.entry_list_name), buf);
  365. gtk_tree_path_free(path);
  366. }
  367. /******************************************************************************
  368. * Name
  369. *
  370. *
  371. * Synopsis
  372. * #include "gui/search_dialog.h"
  373. *
  374. *
  375. *
  376. * Description
  377. *
  378. *
  379. * Return value
  380. * void
  381. */
  382. void clear_modules(GtkButton * button, gpointer user_data)
  383. {
  384. GtkTreeModel *model;
  385. GtkListStore *list_store;
  386. GtkTreeSelection *selection;
  387. GtkTreeIter selected;
  388. gchar *str;
  389. str = g_strdup_printf("<span weight=\"bold\">%s</span>\n\n%s",
  390. _("Clear List?"),
  391. _("Are you sure you want to clear the module list?"));
  392. if (gui_yes_no_dialog(str, GTK_STOCK_DIALOG_WARNING)) {
  393. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.listview_modules));
  394. list_store = GTK_LIST_STORE(model);
  395. gtk_list_store_clear(list_store);
  396. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.module_lists));
  397. list_store = GTK_LIST_STORE(model);
  398. selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(search1.module_lists));
  399. if (gtk_tree_selection_get_selected(selection, NULL, &selected))
  400. gtk_list_store_set(list_store, &selected, 1, "", -1);
  401. }
  402. g_free(str);
  403. }
  404. /******************************************************************************
  405. * Name
  406. *
  407. *
  408. * Synopsis
  409. * #include "gui/search_dialog.h"
  410. *
  411. *
  412. *
  413. * Description
  414. *
  415. *
  416. * Return value
  417. * void
  418. */
  419. void delete_module(GtkButton * button, gpointer user_data)
  420. {
  421. main_delete_module(GTK_TREE_VIEW(search1.listview_modules));
  422. }
  423. /******************************************************************************
  424. * Name
  425. * save_modlist
  426. *
  427. * Synopsis
  428. * #include "gui/search_dialog.h"
  429. *
  430. * void save_modlist(GtkButton * button, gpointer user_data)
  431. *
  432. * Description
  433. * saves the custom module list
  434. *
  435. * Return value
  436. * void
  437. */
  438. void save_modlist(GtkButton * button, gpointer user_data)
  439. {
  440. main_save_modlist();
  441. }
  442. /******************************************************************************
  443. * Name
  444. * new_range
  445. *
  446. * Synopsis
  447. * #include "gui/search_dialog.h"
  448. *
  449. * void new_range(GtkButton * button, gpointer user_data)
  450. *
  451. * Description
  452. * adds a new custom range to the clist_range
  453. *
  454. * Return value
  455. * void
  456. */
  457. void new_range(GtkButton * button, gpointer user_data)
  458. {
  459. gchar *text[2];
  460. GtkTreeModel *model;
  461. GtkListStore *list_store;
  462. GtkTreeSelection *selection;
  463. GtkTreeIter iter;
  464. GtkTreePath *path;
  465. model =
  466. gtk_tree_view_get_model(GTK_TREE_VIEW
  467. (search1.list_range_name));
  468. list_store = GTK_LIST_STORE(model);
  469. selection = gtk_tree_view_get_selection
  470. (GTK_TREE_VIEW(search1.list_range_name));
  471. text[0] = "[New Range]";
  472. text[1] = "";
  473. gtk_list_store_append(list_store, &iter);
  474. gtk_list_store_set(list_store, &iter,
  475. 0, text[0], 1, text[1], -1);
  476. path = gtk_tree_model_get_path(model, &iter);
  477. gtk_tree_selection_select_path(selection, path);
  478. gtk_tree_path_free(path);
  479. gtk_entry_set_text(GTK_ENTRY(search1.entry_range_name),
  480. text[0]);
  481. gtk_entry_set_text(GTK_ENTRY(search1.entry_range_text), "");
  482. }
  483. /******************************************************************************
  484. * Name
  485. * save_range
  486. *
  487. * Synopsis
  488. * #include "gui/search_dialog.h"
  489. *
  490. * void save_range(GtkButton * button, gpointer user_data)
  491. *
  492. * Description
  493. * saves the custom range list
  494. *
  495. * Return value
  496. * void
  497. */
  498. void save_range(GtkButton * button, gpointer user_data)
  499. {
  500. main_save_range();
  501. }
  502. /******************************************************************************
  503. * Name
  504. * delete_range
  505. *
  506. * Synopsis
  507. * #include "gui/search_dialog.h"
  508. *
  509. * void delete_range(GtkButton * button, gpointer user_data)
  510. *
  511. * Description
  512. * delete the selected custom range
  513. *
  514. * Return value
  515. * void
  516. */
  517. void delete_range(GtkButton * button, gpointer user_data)
  518. {
  519. main_delete_range();
  520. }
  521. /******************************************************************************
  522. * Name
  523. * delete_list
  524. *
  525. * Synopsis
  526. * #include "gui/search_dialog.h"
  527. *
  528. * void delete_list(GtkButton * button, gpointer user_data)
  529. *
  530. * Description
  531. *
  532. *
  533. * Return value
  534. * void
  535. */
  536. void delete_list(GtkButton * button, gpointer user_data)
  537. {
  538. gchar *name_string = NULL;
  539. GtkTreeModel *model;
  540. GtkListStore *list_store;
  541. GtkTreeSelection *selection;
  542. GtkTreeIter selected;
  543. gchar *str;
  544. #if 0
  545. // #if 0'd until list_rows is properly managed.
  546. if (search1.list_rows < 2) {
  547. gui_generic_warning(_("The last module list may not be deleted"));
  548. return;
  549. }
  550. #endif
  551. model =
  552. gtk_tree_view_get_model(GTK_TREE_VIEW
  553. (search1.module_lists));
  554. list_store = GTK_LIST_STORE(model);
  555. selection = gtk_tree_view_get_selection
  556. (GTK_TREE_VIEW(search1.module_lists));
  557. if (!gtk_tree_selection_get_selected
  558. (selection, NULL, &selected))
  559. return;
  560. gtk_tree_model_get(model, &selected, 0, &name_string, -1);
  561. str = g_strdup_printf("<span weight=\"bold\">%s</span>\n\n%s %s",
  562. _("Delete list?"),
  563. _("Are you sure you want to delete:"),
  564. name_string);
  565. if (!gui_yes_no_dialog(str, GTK_STOCK_DIALOG_WARNING)) {
  566. g_free(name_string);
  567. g_free(str);
  568. return;
  569. }
  570. gtk_list_store_remove(list_store, &selected);
  571. xml_remove_node("modlists", "modlist", name_string);
  572. --search1.list_rows;
  573. save_modlist(NULL, NULL);
  574. g_free(name_string);
  575. g_free(str);
  576. }
  577. /******************************************************************************
  578. * Name
  579. * scope_toggled
  580. *
  581. * Synopsis
  582. * #include "gui/search_dialog.h"
  583. *
  584. * void scope_toggled(GtkToggleButton *togglebutton,
  585. gpointer user_data)
  586. *
  587. * Description
  588. * remember which scope button was pressed last
  589. * does not remember rb_last
  590. *
  591. * Return value
  592. * void
  593. */
  594. void scope_toggled(GtkToggleButton * togglebutton, gpointer user_data)
  595. {
  596. search1.which_scope = togglebutton;
  597. if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(search1.rb_custom_range)))
  598. gtk_widget_set_sensitive(search1.combo_range,TRUE);
  599. else
  600. gtk_widget_set_sensitive(search1.combo_range,FALSE);
  601. }
  602. /******************************************************************************
  603. * Name
  604. * mod_list_toggled
  605. *
  606. * Synopsis
  607. * #include "gui/search_dialog.h"
  608. *
  609. * void mod_list_toggled(GtkToggleButton *togglebutton,
  610. * gpointer user_data)
  611. *
  612. * Description
  613. *
  614. *
  615. * Return value
  616. * void
  617. */
  618. void mod_list_toggled(GtkToggleButton * togglebutton,
  619. gpointer user_data)
  620. {
  621. if (gtk_toggle_button_get_active (togglebutton)) {
  622. main_comboboxentry2_changed((GtkComboBox *) search1.
  623. combo_list, user_data);
  624. }
  625. if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(search1.rb_custom_list)))
  626. gtk_widget_set_sensitive(search1.combo_list,TRUE);
  627. else
  628. gtk_widget_set_sensitive(search1.combo_list,FALSE);
  629. }
  630. /******************************************************************************
  631. * Name
  632. * optimized_toggled
  633. *
  634. * Synopsis
  635. * #include "gui/search_dialog.h"
  636. *
  637. * void optimized_toggled(GtkToggleButton *togglebutton,
  638. * gpointer user_data)
  639. *
  640. * Description
  641. *
  642. *
  643. * Return value
  644. * void
  645. */
  646. void optimized_toggled(GtkToggleButton * togglebutton,
  647. gpointer user_data)
  648. {
  649. if (gtk_toggle_button_get_active (togglebutton))
  650. gtk_widget_show(search1.button_intro_lucene);
  651. else
  652. gtk_widget_hide(search1.button_intro_lucene);
  653. }
  654. /******************************************************************************
  655. * Name
  656. * on_lucene_intro_clicked
  657. *
  658. * Synopsis
  659. * #include "gui/search_dialog.h"
  660. *
  661. * void on_lucene_intro_clicked(GtkToggleButton *button,
  662. * gpointer user_data)
  663. *
  664. * Description
  665. *
  666. *
  667. * Return value
  668. * void
  669. */
  670. #define LUCENE_INTRO \
  671. _("<b>Syntax overview for optimized \"lucene\" searches</b>\nSearch for verses that contain...\n\nloved one\n\t \"loved\" or \"one\"\n\tThis is the same as searching for loved OR one\n\"loved one\"\n\tThe phrase \"loved one\"\nlove*\n\tA word starting with \"love\"\n\t(love OR loves OR loved OR etc...)\nloved AND one\n\tThe word \"loved\" and the word \"one\"\n\t&amp;&amp; can be used in place of AND\n+loved one\n\tVerses that <b>must</b> contain \"loved\" and <b>may</b> contain \"one\"\nloved NOT one\n\t\"loved\" but not \"one\"\n(loved one) AND God\n\t\"loved\" or \"one\" and \"God\"\nlemma:G2316\n\tSearch for the Strong's Greek (\"G\") word number 2316.\n\tAlso, select Strong's display on the <i>Attribute Search</i> tab.\n\nFor complete details, search the web for \"lucene search syntax\".")
  672. void
  673. on_lucene_intro_clicked(GtkButton * button, gpointer user_data)
  674. {
  675. GtkWidget *dialog;
  676. dialog = gtk_message_dialog_new_with_markup
  677. (NULL, /* no need for a parent window */
  678. GTK_DIALOG_DESTROY_WITH_PARENT,
  679. GTK_MESSAGE_INFO,
  680. GTK_BUTTONS_OK,
  681. LUCENE_INTRO);
  682. g_signal_connect_swapped (dialog, "response",
  683. G_CALLBACK (gtk_widget_destroy),
  684. dialog);
  685. gtk_widget_show(dialog);
  686. }
  687. /******************************************************************************
  688. * Name
  689. * attributes_toggled
  690. *
  691. * Synopsis
  692. * #include "gui/search_dialog.h"
  693. *
  694. * void attributes_toggled(GtkToggleButton *togglebutton,
  695. * gpointer user_data)
  696. *
  697. * Description
  698. *
  699. *
  700. * Return value
  701. * void
  702. */
  703. void attributes_toggled(GtkToggleButton * togglebutton,
  704. gpointer user_data)
  705. {
  706. if (gtk_toggle_button_get_active (togglebutton))
  707. gtk_widget_show(search1.button_intro_attributes);
  708. else
  709. gtk_widget_hide(search1.button_intro_attributes);
  710. }
  711. /******************************************************************************
  712. * Name
  713. * on_attributes_intro_clicked
  714. *
  715. * Synopsis
  716. * #include "gui/search_dialog.h"
  717. *
  718. * void on_attributes_intro_clicked(GtkToggleButton *button,
  719. * gpointer user_data)
  720. *
  721. * Description
  722. *
  723. *
  724. * Return value
  725. * void
  726. */
  727. #define ATTRIBUTES_INTRO \
  728. _("<b>Attribute-based searches</b>\nSearches for content contained in markup outside the main text. Attributes are footnotes, Strong's numbers, and morphological symbols.\n\nBe aware that most such searches can now be done faster via optimized \"lucene\" searches using keyword qualifiers.\n\nTo use attribute searches, you must select the appropriate button on the <i>Attribute Search</i> tab.\n* Footnote text is searched just like regular text.\n* Strong's words are specified as a prefix letter H or G (Hebrew or Greek) and the numeric word identifier, e.g. G2316 to find \"????\" (\"God\").\n* Morphological tags are identified literally, e.g. N-ASF for \"noun, accusative singular feminine\" -- see the Robinson module for details.")
  729. void
  730. on_attributes_intro_clicked(GtkButton * button, gpointer user_data)
  731. {
  732. GtkWidget *dialog;
  733. dialog = gtk_message_dialog_new_with_markup
  734. (NULL, /* no need for a parent window */
  735. GTK_DIALOG_DESTROY_WITH_PARENT,
  736. GTK_MESSAGE_INFO,
  737. GTK_BUTTONS_OK,
  738. ATTRIBUTES_INTRO);
  739. g_signal_connect_swapped (dialog, "response",
  740. G_CALLBACK (gtk_widget_destroy),
  741. dialog);
  742. gtk_widget_show(dialog);
  743. }
  744. /******************************************************************************
  745. * Name
  746. * current_module_toggled
  747. *
  748. * Synopsis
  749. * #include "gui/search_dialog.h"
  750. *
  751. * void current_module_toggled(GtkToggleButton *togglebutton,
  752. gpointer user_data)
  753. *
  754. * Description
  755. * sets rb_last to insensitive if either use module list
  756. * or use custom list is clicked
  757. * also set scope button to last one used before rb_last
  758. *
  759. * Return value
  760. * void
  761. */
  762. void current_module_toggled(GtkToggleButton * togglebutton,
  763. gpointer user_data)
  764. {
  765. if (gtk_toggle_button_get_active (togglebutton)) {
  766. main_change_mods_select_label(search1.search_mod);
  767. gtk_widget_set_sensitive(search1.rb_last, TRUE);
  768. gtk_widget_set_sensitive(search1.combo_list,FALSE);
  769. } else {
  770. gtk_widget_set_sensitive(search1.rb_last, FALSE);
  771. gtk_toggle_button_set_active(search1.which_scope, TRUE);
  772. }
  773. }
  774. /******************************************************************************
  775. * Name
  776. * mod_selection_changed
  777. *
  778. * Synopsis
  779. * #include "gui/search_dialog.h"
  780. *
  781. * void mod_selection_changed(GtkTreeSelection * selection,
  782. * GtkWidget * tree_widget)
  783. *
  784. * Description
  785. *
  786. *
  787. * Return value
  788. * void
  789. */
  790. static void mod_selection_changed(GtkTreeSelection * selection,
  791. GtkWidget * tree_widget)
  792. {
  793. main_mod_selection_changed(selection, tree_widget);
  794. }
  795. /******************************************************************************
  796. * Name
  797. *
  798. *
  799. * Synopsis
  800. * #include "gui/search_dialog.h"
  801. *
  802. * void (GtkTreeSelection * selection,
  803. * gpointer data)
  804. *
  805. * Description
  806. *
  807. *
  808. * Return value
  809. * void
  810. */
  811. static void _selection_finds_list_changed(GtkTreeSelection *
  812. selection, gpointer data)
  813. {
  814. main_selection_finds_list_changed(selection, data);
  815. }
  816. /******************************************************************************
  817. * Name
  818. * selection_modules_lists_changed
  819. *
  820. * Synopsis
  821. * #include "gui/search_dialog.h"
  822. *
  823. * void selection_modules_lists_changed(GtkTreeSelection * selection,
  824. * gpointer data)
  825. *
  826. * Description
  827. *
  828. *
  829. * Return value
  830. * void
  831. */
  832. static void _selection_modules_lists_changed(GtkTreeSelection *
  833. selection, gpointer data)
  834. {
  835. main_selection_modules_lists_changed(selection, data);
  836. }
  837. /******************************************************************************
  838. * Name
  839. * _modules_lists_changed
  840. *
  841. * Synopsis
  842. * #include "gui/search_dialog.h"
  843. *
  844. * void _modules_lists_changed(GtkTreeSelection * selection,
  845. * gpointer data)
  846. *
  847. * Description
  848. *
  849. *
  850. * Return value
  851. * void
  852. */
  853. static void _modules_lists_changed(GtkTreeSelection *
  854. selection, GtkTreeView * tree_widget)
  855. {
  856. gchar *mod = NULL;
  857. GtkTreeIter selected;
  858. GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_widget));
  859. if (!gtk_tree_selection_get_selected(selection, NULL, &selected))
  860. return;
  861. if (gtk_tree_model_iter_has_child(model, &selected)) {
  862. g_free(module_selected);
  863. module_selected = NULL;
  864. return;
  865. }
  866. gtk_tree_model_get(model, &selected, UTIL_COL_MODULE, &mod, -1);
  867. if (mod) {
  868. g_free(module_selected);
  869. module_selected = mod;
  870. }
  871. }
  872. /******************************************************************************
  873. * Name
  874. *
  875. *
  876. * Synopsis
  877. * #include "gui/search_dialog.h"
  878. *
  879. * void (GtkTreeSelection * selection,
  880. * gpointer data)
  881. *
  882. * Description
  883. *
  884. *
  885. * Return value
  886. * void
  887. */
  888. static void _finds_verselist_selection_changed(GtkWidget * widget,
  889. GdkEventButton * event,
  890. gpointer data)
  891. {
  892. GtkTreeSelection *selection;
  893. GtkTreeModel *model;
  894. GtkTreeIter selected;
  895. gchar *key = NULL;
  896. selection =
  897. gtk_tree_view_get_selection((GtkTreeView *) search1.listview_verses);
  898. model = gtk_tree_view_get_model(GTK_TREE_VIEW(search1.listview_verses));
  899. if (!gtk_tree_selection_get_selected(selection, NULL, &selected))
  900. return;
  901. gtk_tree_model_get(GTK_TREE_MODEL(model), &selected, 0, &key, -1);
  902. main_finds_verselist_selection_changed(selection, model, event->type == GDK_2BUTTON_PRESS);
  903. }
  904. /******************************************************************************
  905. * Name
  906. * selection_range_lists_changed
  907. *
  908. * Synopsis
  909. * #include "gui/search_dialog.h"
  910. *
  911. * void selection_range_lists_changed(GtkTreeSelection * selection,
  912. * gpointer data)
  913. *
  914. * Description
  915. *
  916. *
  917. * Return value
  918. * void
  919. */
  920. static void selection_range_lists_changed(GtkTreeSelection * selection,
  921. gpointer data)
  922. {
  923. gchar *name = NULL;
  924. gchar *range = NULL;
  925. GtkTreeModel *model;
  926. GtkTreeIter selected;
  927. if (!gtk_tree_selection_get_selected
  928. (selection, NULL, &selected))
  929. return;
  930. model =
  931. gtk_tree_view_get_model(GTK_TREE_VIEW
  932. (search1.list_range_name));
  933. gtk_tree_model_get(model, &selected, 0, &name, 1, &range, -1);
  934. gtk_entry_set_text(GTK_ENTRY(search1.entry_range_name), name);
  935. gtk_entry_set_text(GTK_ENTRY(search1.entry_range_text), range);
  936. g_free(name);
  937. g_free(range);
  938. }
  939. /******************************************************************************
  940. * Name
  941. *
  942. *
  943. * Synopsis
  944. * #include "gui/search_dialog.h"
  945. *
  946. * void (GtkTreeSelection * selection,
  947. * gpointer data)
  948. *
  949. * Description
  950. *
  951. *
  952. * Return value
  953. * void
  954. */
  955. static void selection_verselist_changed(GtkTreeSelection * selection,
  956. gpointer data)
  957. {
  958. GtkTreeModel *model;
  959. GtkTreeIter selected;
  960. if (!gtk_tree_selection_get_selected
  961. (selection, NULL, &selected))
  962. return;
  963. model =
  964. gtk_tree_view_get_model(GTK_TREE_VIEW
  965. (search1.list_range_name));
  966. main_finds_verselist_selection_changed(selection,
  967. model,
  968. FALSE);
  969. }
  970. /******************************************************************************
  971. * Name
  972. * add_two_text_columns
  973. *
  974. * Synopsis
  975. * #include "gui/search_dialog.h"
  976. *
  977. * void add_two_text_columns(GtkTreeView * treeview)
  978. *
  979. * Description
  980. *
  981. *
  982. * Return value
  983. * void
  984. */
  985. static void _add_two_text_columns(GtkTreeView * treeview)
  986. {
  987. GtkCellRenderer *renderer;
  988. GtkTreeViewColumn *column;
  989. renderer = gtk_cell_renderer_text_new();
  990. column = gtk_tree_view_column_new_with_attributes("Module",
  991. renderer,
  992. "text", 0,
  993. NULL);
  994. gtk_tree_view_append_column(treeview, column);
  995. renderer = gtk_cell_renderer_text_new();
  996. column = gtk_tree_view_column_new_with_attributes("Module",
  997. renderer,
  998. "text", 1,
  999. NULL);
  1000. gtk_tree_view_append_column(treeview, column);
  1001. gtk_tree_view_column_set_sort_column_id(column, 0);
  1002. }
  1003. /******************************************************************************
  1004. * Name
  1005. *
  1006. *
  1007. * Synopsis
  1008. * #include "gui/search_dialog.h"
  1009. *
  1010. *
  1011. *
  1012. * Description
  1013. *
  1014. *
  1015. * Return value
  1016. *
  1017. */
  1018. static
  1019. void _setup_combobox(GtkComboBox * combo)
  1020. {
  1021. GtkListStore *store;
  1022. store = gtk_list_store_new(1, G_TYPE_STRING);
  1023. gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store));
  1024. #ifdef USE_GTK_3
  1025. gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(combo), 0);
  1026. #else
  1027. gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo), 0);
  1028. #endif
  1029. }
  1030. /******************************************************************************
  1031. * Name
  1032. *
  1033. *
  1034. * Synopsis
  1035. * #include "gui/search_dialog.h"
  1036. *
  1037. *
  1038. *
  1039. * Description
  1040. *
  1041. *
  1042. * Return value
  1043. *
  1044. */
  1045. static
  1046. void _setup_listviews(GtkWidget * listview, GCallback callback)
  1047. {
  1048. GtkListStore *model;
  1049. GObject *selection;
  1050. model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
  1051. gtk_tree_view_set_model(GTK_TREE_VIEW(listview), GTK_TREE_MODEL(model));
  1052. _add_two_text_columns(GTK_TREE_VIEW(listview));
  1053. if (!callback)
  1054. return;
  1055. selection = G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(listview)));
  1056. g_signal_connect(selection, "changed", G_CALLBACK(callback), NULL);
  1057. }
  1058. static
  1059. void _setup_listviews2(GtkWidget * listview, GCallback callback)
  1060. {
  1061. GtkListStore *model;
  1062. GObject *selection;
  1063. model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
  1064. gtk_tree_view_set_model(GTK_TREE_VIEW(listview), GTK_TREE_MODEL(model));
  1065. _add_two_text_columns(GTK_TREE_VIEW(listview));
  1066. if (!callback)
  1067. return;
  1068. g_signal_connect((gpointer) listview,
  1069. "button_press_event",
  1070. G_CALLBACK(callback), NULL);
  1071. g_signal_connect((gpointer) listview,
  1072. "button_release_event",
  1073. G_CALLBACK(callback), NULL);
  1074. selection = G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(listview)));
  1075. g_signal_connect(selection, "changed", G_CALLBACK(selection_verselist_changed),
  1076. NULL);
  1077. }
  1078. /******************************************************************************
  1079. * Name
  1080. *
  1081. *
  1082. * Synopsis
  1083. * #include "gui/search_dialog.h"
  1084. *
  1085. *
  1086. *
  1087. * Description
  1088. *
  1089. *
  1090. * Return value
  1091. *
  1092. */
  1093. static
  1094. void _setup_treeview(GtkWidget * treeview)
  1095. {
  1096. GtkCellRenderer *renderer;
  1097. GtkTreeViewColumn *column;
  1098. GObject *selection;
  1099. renderer = gtk_cell_renderer_text_new();
  1100. column = gtk_tree_view_column_new_with_attributes("Found",
  1101. renderer,
  1102. "text",
  1103. 0, NULL);
  1104. gtk_tree_view_column_set_sort_column_id(column, 0);
  1105. gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
  1106. gui_load_module_tree(treeview, FALSE);
  1107. selection = G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)));
  1108. g_signal_connect(selection, "changed",
  1109. G_CALLBACK(mod_selection_changed), treeview);
  1110. g_signal_connect_after(G_OBJECT(treeview),
  1111. "button_release_event",
  1112. G_CALLBACK(button_release_event),
  1113. GINT_TO_POINTER(0));
  1114. }
  1115. static
  1116. void _setup_treeview2(GtkWidget * treeview)
  1117. {
  1118. GtkCellRenderer *renderer;
  1119. GtkTreeViewColumn *column;
  1120. GObject *selection;
  1121. renderer = gtk_cell_renderer_text_new();
  1122. column = gtk_tree_view_column_new_with_attributes("Found",
  1123. renderer,
  1124. "text",
  1125. 0, NULL);
  1126. gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
  1127. gtk_tree_view_column_set_sort_column_id(column, 0);
  1128. gui_load_module_tree(treeview, FALSE);
  1129. selection = G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)));
  1130. g_signal_connect(selection, "changed", G_CALLBACK(_modules_lists_changed), treeview);
  1131. }
  1132. void on_closebutton2_clicked(GtkButton * button, gpointer user_data)
  1133. {
  1134. gtk_widget_hide(search1.mod_sel_dialog);
  1135. }
  1136. /******************************************************************************
  1137. * Name
  1138. *
  1139. *
  1140. * Synopsis
  1141. * #include "gui/search_dialog.h"
  1142. *
  1143. *
  1144. *
  1145. * Description
  1146. *
  1147. *
  1148. * Return value
  1149. *
  1150. */
  1151. void _on_dialog2_response(GtkDialog * dialog, gint response_id,
  1152. gpointer user_data)
  1153. {
  1154. switch (response_id) {
  1155. case GTK_RESPONSE_CLOSE:
  1156. gtk_widget_hide(GTK_WIDGET(dialog));
  1157. break;
  1158. case GTK_RESPONSE_APPLY:
  1159. main_add_mod_to_list(search1.listview_modules, module_selected);
  1160. break;
  1161. }
  1162. }
  1163. /******************************************************************************
  1164. * Name
  1165. *
  1166. *
  1167. * Synopsis
  1168. * #include "gui/search_dialog.h"
  1169. *
  1170. *
  1171. *
  1172. * Description
  1173. * Creates the module selection dialog
  1174. *
  1175. * Return value
  1176. * void
  1177. */
  1178. #ifndef USE_GTKBUILDER
  1179. static
  1180. void _create_mod_sel_dialog(void)
  1181. {
  1182. gchar *glade_file;
  1183. GladeXML *gxml2;
  1184. glade_file = gui_general_user_file("search-dialog.glade", FALSE);
  1185. g_return_if_fail(glade_file != NULL);
  1186. GS_message(("%s",glade_file));
  1187. gxml2 = glade_xml_new(glade_file, "dialog2", NULL);
  1188. search1.mod_sel_dialog = glade_xml_get_widget(gxml2, "dialog2");
  1189. g_signal_connect((gpointer)search1.mod_sel_dialog, "response",
  1190. G_CALLBACK(_on_dialog2_response), NULL);
  1191. search1.mod_sel_dlg_treeview = glade_xml_get_widget(gxml2, "treeview8");
  1192. _setup_treeview2(search1.mod_sel_dlg_treeview);
  1193. gtk_widget_hide(search1.mod_sel_dialog);
  1194. g_free(glade_file);
  1195. }
  1196. #endif
  1197. /******************************************************************************
  1198. * Name
  1199. *
  1200. *
  1201. * Synopsis
  1202. * #include "gui/search_dialog.h"
  1203. *
  1204. *
  1205. *
  1206. * Description
  1207. * Shows the module selection dialog
  1208. *
  1209. * Return value
  1210. * void
  1211. */
  1212. void
  1213. on_toolbutton12_clicked(GtkToolButton * toolbutton, gpointer user_data)
  1214. {
  1215. #ifndef USE_GTKBUILDER
  1216. _create_mod_sel_dialog();
  1217. #endif
  1218. gtk_widget_show(search1.mod_sel_dialog);
  1219. }
  1220. /******************************************************************************
  1221. * Name
  1222. *
  1223. *
  1224. * Synopsis
  1225. * #include "gui/search_dialog.h"
  1226. *
  1227. *
  1228. *
  1229. * Description
  1230. *
  1231. *
  1232. * Return value
  1233. *
  1234. */
  1235. /* add html widgets */
  1236. static
  1237. void _add_html_widget(GtkWidget * vbox)
  1238. {
  1239. GtkWidget *scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  1240. gtk_widget_show(scrolledwindow);
  1241. gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
  1242. gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
  1243. (scrolledwindow),
  1244. GTK_POLICY_NEVER,
  1245. GTK_POLICY_AUTOMATIC);
  1246. gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)
  1247. scrolledwindow,
  1248. settings.shadow_type);
  1249. #ifdef USE_XIPHOS_HTML
  1250. search1.preview_html = GTK_WIDGET(XIPHOS_HTML_NEW(NULL, FALSE, DIALOG_SEARCH_PREVIEW_TYPE));
  1251. #else
  1252. search1.preview_html = gtk_html_new();
  1253. #endif
  1254. gtk_container_add(GTK_CONTAINER(scrolledwindow), search1.preview_html);
  1255. gtk_box_pack_start(GTK_BOX(scrolledwindow), search1.preview_html, TRUE, TRUE, 0);
  1256. gtk_widget_show(search1.preview_html);
  1257. }
  1258. /******************************************************************************
  1259. * Name
  1260. *
  1261. *
  1262. * Synopsis
  1263. * #include "gui/search_dialog.h"
  1264. *
  1265. *
  1266. *
  1267. * Description
  1268. *
  1269. *
  1270. * Return value
  1271. *
  1272. */
  1273. void _on_dialog_response(GtkDialog * dialog, gint response_id,
  1274. gpointer user_data)
  1275. {
  1276. switch (response_id) {
  1277. case GTK_RESPONSE_CLOSE:
  1278. if (search1.mod_sel_dialog) {
  1279. gtk_widget_destroy(GTK_WIDGET(search1.mod_sel_dialog));
  1280. search1.mod_sel_dialog = NULL;
  1281. }
  1282. gtk_widget_destroy(GTK_WIDGET(dialog));
  1283. break;
  1284. }
  1285. }
  1286. /******************************************************************************
  1287. * Name
  1288. * _create_search_dialog
  1289. *
  1290. * Synopsis
  1291. * #include "gui/search_dialog.h"
  1292. *
  1293. * void _create_search_dialog(void)
  1294. *
  1295. * Description
  1296. *
  1297. *
  1298. * Return value
  1299. * void
  1300. */
  1301. static
  1302. void _create_search_dialog(void)
  1303. {
  1304. gchar *glade_file;
  1305. #ifdef USE_GTKBUILDER
  1306. GtkBuilder *gxml;
  1307. #else
  1308. GladeXML *gxml;
  1309. #endif
  1310. GtkWidget *toolbutton1;
  1311. GtkWidget *toolbutton2;
  1312. GtkWidget *toolbutton3;
  1313. GtkWidget *toolbutton4;
  1314. GtkWidget *toolbutton5;
  1315. GtkWidget *toolbutton6;
  1316. GtkWidget *toolbutton7;
  1317. GtkWidget *toolbutton8;
  1318. GtkWidget *toolbutton10;
  1319. GtkWidget *toolbutton11;
  1320. GtkWidget *toolbutton12;
  1321. GtkWidget *toolbutton13;
  1322. module_selected = NULL;
  1323. verse_selected = NULL;
  1324. _preview_on = TRUE;
  1325. glade_file = gui_general_user_file("search-dialog" UI_SUFFIX, FALSE);
  1326. g_return_if_fail(glade_file != NULL);
  1327. GS_message(("%s",glade_file));
  1328. /* build the widget */
  1329. #ifdef USE_GTKBUILDER
  1330. gxml = gtk_builder_new ();
  1331. gtk_builder_add_from_file (gxml, glade_file, NULL);
  1332. #else
  1333. gxml = glade_xml_new(glade_file, "dialog", NULL);
  1334. #endif
  1335. g_return_if_fail(gxml != NULL);
  1336. /* lookup the root widget */
  1337. search1.dialog = UI_GET_ITEM(gxml, "dialog");
  1338. g_signal_connect(search1.dialog, "response",
  1339. G_CALLBACK(_on_dialog_response), NULL);
  1340. g_signal_connect(search1.dialog, "destroy",
  1341. G_CALLBACK(_on_destroy), NULL);
  1342. remember_search = UI_GET_ITEM(gxml, "button1");
  1343. g_signal_connect(remember_search, "clicked",
  1344. G_CALLBACK(on_button_begin_search), NULL);
  1345. search1.label_search_module = UI_GET_ITEM(gxml, "label5");
  1346. search1.search_entry = UI_GET_ITEM(gxml, "entry1");
  1347. g_signal_connect(search1.search_entry, "activate",
  1348. G_CALLBACK(on_button_begin_search), NULL);
  1349. search1.notebook = UI_GET_ITEM(gxml, "notebook1");
  1350. search1.treeview = UI_GET_ITEM(gxml, "treeview1");
  1351. _setup_treeview(search1.treeview);
  1352. search1.list_range_name = UI_GET_ITEM(gxml, "treeview4");
  1353. _setup_listviews(search1.list_range_name,
  1354. (GCallback) selection_range_lists_changed);
  1355. search1.list_ranges = UI_GET_ITEM(gxml, "treeview5");
  1356. _setup_listviews(search1.list_ranges, NULL);
  1357. search1.module_lists = UI_GET_ITEM(gxml, "treeview6");
  1358. _setup_listviews(search1.module_lists,
  1359. (GCallback) _selection_modules_lists_changed);
  1360. search1.listview_modules = UI_GET_ITEM(gxml, "treeview7");
  1361. _setup_listviews(search1.listview_modules, NULL);
  1362. /* scope radio buttons */
  1363. search1.rb_no_scope = UI_GET_ITEM(gxml, "radiobutton1");
  1364. g_signal_connect(search1.rb_no_scope, "toggled",
  1365. G_CALLBACK(scope_toggled), NULL);
  1366. search1.rb_last = UI_GET_ITEM(gxml, "radiobutton2");
  1367. search1.which_scope = GTK_TOGGLE_BUTTON(search1.rb_no_scope);
  1368. search1.rb_custom_range = UI_GET_ITEM(gxml, "radiobutton3");
  1369. g_signal_connect(search1.rb_custom_range, "toggled",
  1370. G_CALLBACK(scope_toggled), NULL);
  1371. /* modules radio buttons */
  1372. search1.rb_current_module = UI_GET_ITEM(gxml, "radiobutton4");
  1373. g_signal_connect(search1.rb_current_module, "toggled",
  1374. G_CALLBACK(current_module_toggled), NULL);
  1375. search1.rb_mod_list = UI_GET_ITEM(gxml, "radiobutton5");
  1376. g_signal_connect(search1.rb_mod_list, "toggled",
  1377. G_CALLBACK(mod_list_toggled), NULL);
  1378. search1.rb_custom_list = UI_GET_ITEM(gxml, "radiobutton6");
  1379. g_signal_connect(search1.rb_custom_list, "toggled",
  1380. G_CALLBACK(mod_list_toggled), NULL);
  1381. /* search type selection */
  1382. search1.rb_words = UI_GET_ITEM(gxml, "radiobutton9");
  1383. search1.rb_regexp = UI_GET_ITEM(gxml, "radiobutton10");
  1384. search1.rb_exact_phrase = UI_GET_ITEM(gxml, "radiobutton11");
  1385. search1.rb_optimized = UI_GET_ITEM(gxml, "radiobutton16");
  1386. g_signal_connect(search1.rb_optimized, "toggled",
  1387. G_CALLBACK(optimized_toggled), NULL);
  1388. search1.button_intro_lucene = UI_GET_ITEM(gxml, "button_intro_lucene");
  1389. g_signal_connect(search1.button_intro_lucene, "clicked",
  1390. G_CALLBACK(on_lucene_intro_clicked), NULL);
  1391. gtk_widget_show(search1.button_intro_lucene);
  1392. search1.rb_attributes = UI_GET_ITEM(gxml, "radiobutton12");
  1393. g_signal_connect(search1.rb_attributes, "toggled",
  1394. G_CALLBACK(attributes_toggled), NULL);
  1395. search1.button_intro_attributes = UI_GET_ITEM(gxml, "button_intro_attributes");
  1396. g_signal_connect(search1.button_intro_attributes, "clicked",
  1397. G_CALLBACK(on_attributes_intro_clicked), NULL);
  1398. gtk_widget_hide(search1.button_intro_attributes);
  1399. /* attributes radio buttons */
  1400. search1.rb_strongs = UI_GET_ITEM(gxml, "radiobutton13");
  1401. search1.rb_morphs = UI_GET_ITEM(gxml, "radiobutton15");
  1402. search1.rb_footnotes = UI_GET_ITEM(gxml, "radiobutton14");
  1403. /* */
  1404. search1.cb_case_sensitive = UI_GET_ITEM(gxml, "checkbutton1");
  1405. /* display options check buttons */
  1406. search1.cb_include_strongs = UI_GET_ITEM(gxml, "checkbutton2");
  1407. search1.cb_include_morphs = UI_GET_ITEM(gxml, "checkbutton3");
  1408. search1.cb_include_footnotes = UI_GET_ITEM(gxml, "checkbutton4");
  1409. toolbutton1 = UI_GET_ITEM(gxml, "toolbutton1");
  1410. toolbutton2 = UI_GET_ITEM(gxml, "toolbutton2");
  1411. toolbutton3 = UI_GET_ITEM(gxml, "toolbutton3");
  1412. toolbutton4 = UI_GET_ITEM(gxml, "toolbutton4");
  1413. toolbutton5 = UI_GET_ITEM(gxml, "toolbutton5");
  1414. toolbutton6 = UI_GET_ITEM(gxml, "toolbutton6");
  1415. toolbutton7 = UI_GET_ITEM(gxml, "toolbutton7");
  1416. toolbutton8 = UI_GET_ITEM(gxml, "toolbutton8");
  1417. toolbutton10 = UI_GET_ITEM(gxml, "toolbutton10");
  1418. toolbutton11 = UI_GET_ITEM(gxml, "toolbutton11");
  1419. toolbutton12 = UI_GET_ITEM(gxml, "toolbutton12");
  1420. toolbutton13 = UI_GET_ITEM(gxml, "toolbutton_export");
  1421. search1.combo_list = UI_GET_ITEM(gxml, "comboboxentry2");
  1422. g_signal_connect(toolbutton1, "clicked",
  1423. G_CALLBACK(button_save), NULL);
  1424. g_signal_connect(toolbutton2, "clicked",
  1425. G_CALLBACK(button_clean), NULL);
  1426. g_signal_connect(toolbutton3, "clicked",
  1427. G_CALLBACK(new_range), NULL);
  1428. g_signal_connect(toolbutton4, "clicked",
  1429. G_CALLBACK(save_range), NULL);
  1430. g_signal_connect(toolbutton5, "clicked",
  1431. G_CALLBACK(delete_range), NULL);
  1432. g_signal_connect(toolbutton6, "clicked",
  1433. G_CALLBACK(new_modlist), NULL);
  1434. g_signal_connect(toolbutton7, "clicked",
  1435. G_CALLBACK(save_modlist), NULL);
  1436. g_signal_connect(toolbutton8, "clicked",
  1437. G_CALLBACK(delete_list), NULL);
  1438. g_signal_connect(toolbutton10, "clicked",
  1439. G_CALLBACK(clear_modules), NULL);
  1440. g_signal_connect(toolbutton11, "clicked",
  1441. G_CALLBACK(delete_module), NULL);
  1442. g_signal_connect(toolbutton12, "clicked",
  1443. G_CALLBACK(on_toolbutton12_clicked), NULL);
  1444. g_signal_connect(toolbutton13, "clicked",
  1445. G_CALLBACK(button_export), NULL);
  1446. _setup_combobox(GTK_COMBO_BOX(search1.combo_list));
  1447. g_signal_connect(search1.combo_list, "changed",
  1448. G_CALLBACK(on_comboboxentry2_changed), NULL);
  1449. search1.entry_list_name = UI_GET_ITEM(gxml, "entry4");
  1450. g_signal_connect(search1.entry_list_name, "changed",
  1451. G_CALLBACK(list_name_changed), NULL);
  1452. search1.combo_range = UI_GET_ITEM(gxml, "comboboxentry1");
  1453. _setup_combobox(GTK_COMBO_BOX(search1.combo_range));
  1454. search1.entry_range_name = UI_GET_ITEM(gxml, "entry2");
  1455. g_signal_connect(search1.entry_range_name, "changed",
  1456. G_CALLBACK(range_name_changed), NULL);
  1457. search1.entry_range_text = UI_GET_ITEM(gxml, "entry3");
  1458. g_signal_connect(search1.entry_range_text, "changed",
  1459. G_CALLBACK(range_text_changed), NULL);
  1460. search1.progressbar = UI_GET_ITEM(gxml, "progressbar1");
  1461. #ifdef USE_GTKBUILDER
  1462. gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(search1.progressbar),TRUE);
  1463. #endif
  1464. search1.label_mod_select = UI_GET_ITEM(gxml, "label5");
  1465. search1.listview_results = UI_GET_ITEM(gxml, "treeview9");
  1466. #ifdef USE_GTKBUILDER
  1467. /* setup module select dialog */
  1468. search1.mod_sel_dialog = UI_GET_ITEM(gxml, "dialog2");
  1469. g_signal_connect((gpointer)search1.mod_sel_dialog, "response",
  1470. G_CALLBACK(_on_dialog2_response), NULL);
  1471. search1.mod_sel_dlg_treeview = UI_GET_ITEM(gxml, "treeview8");
  1472. _setup_treeview2(search1.mod_sel_dlg_treeview);
  1473. gtk_widget_hide(search1.mod_sel_dialog);
  1474. #endif
  1475. _setup_listviews(search1.listview_results, (GCallback) _selection_finds_list_changed);
  1476. search1.listview_verses = UI_GET_ITEM(gxml, "treeview10");
  1477. _setup_listviews2(search1.listview_verses, (GCallback) _finds_verselist_selection_changed);
  1478. #ifdef USE_GTKBUILDER
  1479. _add_html_widget(GTK_WIDGET (gtk_builder_get_object (gxml, "vbox12")));
  1480. #else
  1481. _add_html_widget(glade_xml_get_widget(gxml, "vbox12"));
  1482. #endif
  1483. }
  1484. /******************************************************************************
  1485. * Name
  1486. * gui_create_search_dialog
  1487. *
  1488. * Synopsis
  1489. * #include "gui/search_dialog.h"
  1490. *
  1491. * void gui_create_search_dialog(void)
  1492. *
  1493. * Description
  1494. * calls _create_search_dialog() to create the search dialog
  1495. *
  1496. * Return value
  1497. * void
  1498. */
  1499. void gui_create_search_dialog(void)
  1500. {
  1501. _create_search_dialog();
  1502. }