aboutsummaryrefslogtreecommitdiffstats
path: root/apps/X11/cheatah/cheatah.cpp
blob: f01db1637e60d56a758f363a6edaf791ba40305b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/*  cheatah
 *  Copyright (C) 1999, CrossWire Bible Society
 *			P. O. Box 2528
 *			Tempe, AZ  85280-2528
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "cheatsig.h"
#include "cheatah.h"
#include <swmgr.h>
#include <versekey.h>
#include <regex.h>
#include <gbfplain.h>
#include <thmlplain.h>
#include <string.h>


MainWindow *cheatahWindow = NULL;

/*	I'm going to try commenting out get_widget() - it no longer seems to be used	*/
/*	Note: this doesn't seem to have caused any problems so far.			*/
/*
GtkWidget*
get_widget                             (GtkWidget       *widget,
                                        gchar           *widget_name)
{
  GtkWidget *found_widget;

  if (widget->parent)
    widget = gtk_widget_get_toplevel (widget);
  found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget),
                                                   widget_name);
  if (!found_widget)
    g_warning ("Widget not found: %s", widget_name);
  return found_widget;
}		
*/

/* This is an internally used function to set notebook tab widgets. */
void
set_notebook_tab                       (GtkWidget       *notebook,
                                        gint             page_num,
                                        GtkWidget       *widget)
{
  GtkNotebookPage *page;
  GtkWidget *notebook_page;

  page = (GtkNotebookPage*) g_list_nth (GTK_NOTEBOOK (notebook)->children, page_num)->data;
  notebook_page = page->child;
  gtk_widget_ref (notebook_page);
  gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), page_num);
  gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), notebook_page,
                            widget, page_num);
  gtk_widget_unref (notebook_page);
}



MainWindow::MainWindow() {
	searchType_group = NULL;
	mainMgr          = new SWMgr();
	curMod           = NULL;
	chapDisplay      = 0;	// set in create
	entryDisplay     = 0;	// set in create
}


MainWindow::~MainWindow() {
	delete mainMgr;
	if (chapDisplay)
		delete chapDisplay;
	if (entryDisplay)
		delete entryDisplay;
}


GtkWidget* create_mainWindow () {
	GtkWidget *retWidget;
	cheatahWindow = new MainWindow();
	retWidget = cheatahWindow->create();
	cheatahWindow->initSWORD();
	return retWidget;
}

/*								*/
/*	Note: this seems to be a poor choice of a name for this function .	*/
/*	When  I accidentally left off the  parenthesis when trying to call it,	*/
/*	the compiler didn't complain, but it didn't execute, either.		*/
/* 	Could there be a macro or something by the same name?		*/
/*	At any rate, be careful with it.				*/
/*								*/
void destroy_mainWindow () {
	delete cheatahWindow;
}

GtkWidget *MainWindow::create() {
	mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_object_set_data (GTK_OBJECT (mainWindow), "mainWindow", mainWindow);
	gtk_window_set_title (GTK_WINDOW (mainWindow), "Cheatah - SWORD Quick Lookup / Search");
	gtk_window_set_policy (GTK_WINDOW (mainWindow), TRUE, TRUE, FALSE);
	gtk_widget_set_usize(GTK_WIDGET(mainWindow), 580, 360);
	gtk_signal_connect(GTK_OBJECT(mainWindow),
		       "destroy",
		       GTK_SIGNAL_FUNC(gtk_main_quit),
		       NULL);


	mainPanel = gtk_vbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "mainPanel", mainPanel);
  gtk_widget_show (mainPanel);
  gtk_container_add (GTK_CONTAINER (mainWindow), mainPanel);

  headerPanel = gtk_hbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "headerPanel", headerPanel);
  gtk_widget_show (headerPanel);
  gtk_box_pack_start (GTK_BOX (mainPanel), headerPanel, FALSE, TRUE, 0);

  handlebox3 = gtk_handle_box_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "handlebox3", handlebox3);
  gtk_widget_show (handlebox3);
  gtk_box_pack_start (GTK_BOX (headerPanel), handlebox3, TRUE, TRUE, 0);

  menubar4 = gtk_menu_bar_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "menubar4", menubar4);
  gtk_widget_show (menubar4);
  gtk_container_add (GTK_CONTAINER (handlebox3), menubar4);

  File = gtk_menu_item_new_with_label ("File");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "File", File);
  gtk_widget_show (File);
  gtk_container_add (GTK_CONTAINER (menubar4), File);

  menuFile = gtk_menu_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "menuFile", menuFile);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (File), menuFile);

  Exit3 = gtk_menu_item_new_with_label ("Exit");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "Exit3", Exit3);
  gtk_widget_show (Exit3);
  gtk_container_add (GTK_CONTAINER (menuFile), Exit3);
  gtk_signal_connect (GTK_OBJECT (Exit3), "activate",
                      GTK_SIGNAL_FUNC (gtk_main_quit),
                      NULL);

  
  View3 = gtk_menu_item_new_with_label ("View");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "View3", View3);
  gtk_widget_show (View3);
  gtk_container_add (GTK_CONTAINER (menubar4), View3);
  gtk_signal_connect (GTK_OBJECT (View3), "activate",
                      GTK_SIGNAL_FUNC (on_View3_activate),
                      NULL);

  menuView = gtk_menu_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "menuView", menuView);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (View3), menuView);

  commentaries = gtk_menu_item_new_with_label ("Commentaries");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "commentaries", commentaries);
  gtk_widget_show (commentaries);

  menuCommentaries = gtk_menu_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "menuCommentaries", menuCommentaries);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (commentaries), menuCommentaries);

  dictionaries = gtk_menu_item_new_with_label ("Dictionaries");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "Dictionaries", dictionaries);
  gtk_widget_show (dictionaries);

  menuDictionaries = gtk_menu_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "menuDictionaries", menuDictionaries);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (dictionaries), menuDictionaries);



  Help = gtk_menu_item_new_with_label ("Help");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "Help", Help);
  gtk_widget_show (Help);
  gtk_container_add (GTK_CONTAINER (menubar4), Help);
  gtk_signal_connect (GTK_OBJECT (Help), "activate",
                      GTK_SIGNAL_FUNC (on_Help_activate),
                      NULL);
  gtk_menu_item_right_justify (GTK_MENU_ITEM (Help));

  menuHelp = gtk_menu_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "menuHelp", menuHelp);
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (Help), menuHelp);

  About = gtk_menu_item_new_with_label ("About");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "About", About);
  gtk_widget_show (About);
  gtk_container_add (GTK_CONTAINER (menuHelp), About);
  gtk_signal_connect (GTK_OBJECT (About), "activate",
                      GTK_SIGNAL_FUNC (on_About_activate),
                      NULL);

  handlebox4 = gtk_handle_box_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "handlebox4", handlebox4);
  gtk_widget_show (handlebox4);
  gtk_box_pack_start (GTK_BOX (headerPanel), handlebox4, TRUE, TRUE, 0);

  hbox6 = gtk_hbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "hbox6", hbox6);
  gtk_widget_show (hbox6);
  gtk_container_add (GTK_CONTAINER (handlebox4), hbox6);

  label2 = gtk_label_new ("FreeForm Lookup:");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "label2", label2);
  gtk_widget_show (label2);
  gtk_box_pack_start (GTK_BOX (hbox6), label2, FALSE, TRUE, 0);
  gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_RIGHT);
  gtk_misc_set_padding (GTK_MISC (label2), 2, 0);

  lookupText = gtk_entry_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "lookupText", lookupText);
  gtk_widget_show (lookupText);
  gtk_box_pack_start (GTK_BOX (hbox6), lookupText, FALSE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT (lookupText), "changed",
                      GTK_SIGNAL_FUNC (on_lookupText_changed),
                      NULL);

  hbox2 = gtk_hbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "hbox2", hbox2);
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (mainPanel), hbox2, TRUE, TRUE, 0);


/*
  textScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "textScrolledWindow", textScrolledWindow);
  gtk_widget_show (textScrolledWindow);
  gtk_box_pack_start (GTK_BOX (hbox2), textScrolledWindow, FALSE, FALSE, 0);
*/

  moduleText = gtk_text_new (NULL, NULL);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "moduleText", moduleText);
  gtk_widget_show (moduleText);
//  gtk_container_add (GTK_CONTAINER (textScrolledWindow), moduleText);
  gtk_box_pack_start (GTK_BOX (hbox2), moduleText, TRUE, TRUE, 0);
  gtk_text_set_editable (GTK_TEXT (moduleText), FALSE);
  gtk_text_set_word_wrap (GTK_TEXT (moduleText), TRUE);
  gtk_widget_realize (moduleText);

	/* Add a vertical scrollbar to the GtkText widget */
	textScrollbar = gtk_vscrollbar_new (GTK_TEXT (moduleText)->vadj);
	gtk_box_pack_start (GTK_BOX (hbox2), textScrollbar, FALSE, FALSE, 0);
	gtk_widget_show (textScrollbar);


/*
  handlebox5 = gtk_handle_box_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "handlebox5", handlebox5);
  gtk_widget_show (handlebox5);
  gtk_box_pack_start (GTK_BOX (hbox2), handlebox5, FALSE, FALSE, 0);
  gtk_container_border_width (GTK_CONTAINER (handlebox5), 5);
*/

  searchPanel = gtk_vbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "searchPanel", searchPanel);
  gtk_widget_show (searchPanel);
  gtk_box_pack_start (GTK_BOX (hbox2), searchPanel, FALSE, FALSE, 0);
//  gtk_container_add (GTK_CONTAINER (handlebox5), searchPanel);

  hbox4 = gtk_hbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "hbox4", hbox4);
  gtk_widget_show (hbox4);
  gtk_box_pack_start (GTK_BOX (searchPanel), hbox4, FALSE, FALSE, 0);

  searchText = gtk_entry_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "searchText", searchText);
  gtk_widget_show (searchText);
  gtk_box_pack_start (GTK_BOX (hbox4), searchText, TRUE, TRUE, 0);

  searchButton = gtk_button_new_with_label ("Search");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "searchButton", searchButton);
  gtk_widget_show (searchButton);
  gtk_box_pack_start (GTK_BOX (hbox4), searchButton, FALSE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT (searchButton), "clicked",
                      GTK_SIGNAL_FUNC (on_searchButton_clicked),
                      NULL);

  searchSettingsPanel = gtk_hbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "searchSettingsPanel", searchSettingsPanel);
  gtk_widget_show (searchSettingsPanel);
  gtk_box_pack_start (GTK_BOX (searchPanel), searchSettingsPanel, FALSE, FALSE, 0);

  searchTypePanel = gtk_vbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "searchTypePanel", searchTypePanel);
  gtk_widget_show (searchTypePanel);
  gtk_box_pack_start (GTK_BOX (searchSettingsPanel), searchTypePanel, FALSE, FALSE, 0);

  multiWordSearch = gtk_radio_button_new_with_label (searchType_group, "Multi Word");
  searchType_group = gtk_radio_button_group (GTK_RADIO_BUTTON (multiWordSearch));
  gtk_object_set_data (GTK_OBJECT (mainWindow), "multiWordSearch", multiWordSearch);
  gtk_widget_show (multiWordSearch);
  gtk_box_pack_start (GTK_BOX (searchTypePanel), multiWordSearch, FALSE, FALSE, 0);

  phraseSearch = gtk_radio_button_new_with_label (searchType_group, "Exact Phrase");
  searchType_group = gtk_radio_button_group (GTK_RADIO_BUTTON (phraseSearch));
  gtk_object_set_data (GTK_OBJECT (mainWindow), "phraseSearch", phraseSearch);
  gtk_widget_show (phraseSearch);
  gtk_box_pack_start (GTK_BOX (searchTypePanel), phraseSearch, FALSE, FALSE, 0);

  regexSearch = gtk_radio_button_new_with_label (searchType_group, "Regular Expression");
  searchType_group = gtk_radio_button_group (GTK_RADIO_BUTTON (regexSearch));
  gtk_object_set_data (GTK_OBJECT (mainWindow), "regexSearch", regexSearch);
  gtk_widget_show (regexSearch);
  gtk_box_pack_start (GTK_BOX (searchTypePanel), regexSearch, FALSE, FALSE, 0);


  searchOptionsPanel = gtk_vbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "searchOptionsPanel", searchOptionsPanel);
  gtk_widget_show (searchOptionsPanel);
  gtk_box_pack_start (GTK_BOX (searchSettingsPanel), searchOptionsPanel, FALSE, FALSE, 0);

  caseSensitive = gtk_check_button_new_with_label ("Case Sensitive");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "caseSensitive", caseSensitive);
  gtk_widget_show (caseSensitive);
  gtk_box_pack_start (GTK_BOX (searchOptionsPanel), caseSensitive, FALSE, FALSE, 0);

  GtkWidget *resultPanel = gtk_hbox_new (FALSE, 0);
  gtk_object_set_data (GTK_OBJECT (mainWindow), "resultPanel", resultPanel);
  gtk_widget_show (resultPanel);
  gtk_box_pack_start (GTK_BOX (searchPanel), resultPanel, TRUE, TRUE, 0);
  resultList = gtk_clist_new(1);
  gtk_object_set_data(GTK_OBJECT (mainWindow), "resultList", resultList);
//  gtk_clist_set_policy(GTK_CLIST(resultList), GTK_POLICY_AUTOMATIC, 0);
//  gtk_clist_set_border(GTK_CLIST(resultList), GTK_SHADOW_ETCHED_IN);
  gtk_widget_show (resultList);
  gtk_box_pack_start (GTK_BOX (resultPanel), resultList, TRUE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT (resultList), "select_row",
                      GTK_SIGNAL_FUNC (on_resultList_selection_changed),
                      NULL);
	/* Add a vertical scrollbar to the GtkCList widget */
	textScrollbar = gtk_vscrollbar_new (NULL);
	gtk_clist_set_vadjustment (GTK_CLIST(resultList), gtk_range_get_adjustment(GTK_RANGE(textScrollbar)));
	gtk_box_pack_start (GTK_BOX (resultPanel), textScrollbar, FALSE, FALSE, 0);
	gtk_widget_show (textScrollbar);


/*
  statusbar1 = gtk_statusbar_new ();
  gtk_object_set_data (GTK_OBJECT (mainWindow), "statusbar1", statusbar1);
  gtk_widget_show (statusbar1);
  gtk_box_pack_start (GTK_BOX (mainPanel), statusbar1, FALSE, TRUE, 0);
*/

  arrow1 = gtk_button_new_with_label ("[<]");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "arrow1", arrow1);
  gtk_widget_show (arrow1);
  gtk_box_pack_start (GTK_BOX (headerPanel), arrow1, FALSE, FALSE, 0);
  gtk_signal_connect (GTK_OBJECT (arrow1), "clicked",
                      GTK_SIGNAL_FUNC (on_arrow1_button_press_event),
                      NULL);

  arrow2 = gtk_button_new_with_label ("[>]");
  gtk_object_set_data (GTK_OBJECT (mainWindow), "arrow2", arrow2);
  gtk_widget_show (arrow2);
  gtk_box_pack_start (GTK_BOX (headerPanel), arrow2, FALSE, FALSE, 0);
  gtk_signal_connect (GTK_OBJECT (arrow2), "clicked",
                      GTK_SIGNAL_FUNC (on_arrow2_button_press_event),
                      NULL);


	statusbar1 = gtk_label_new ("");
	gtk_object_set_data (GTK_OBJECT (mainWindow), "statusbar1", statusbar1);
	gtk_widget_show (statusbar1);
	gtk_box_pack_start (GTK_BOX (mainPanel), statusbar1, FALSE, FALSE, 0);
	gtk_label_set_justify (GTK_LABEL (statusbar1), GTK_JUSTIFY_LEFT);
	gtk_misc_set_padding (GTK_MISC (statusbar1), 2, 0);


	GTKEntryDisp::__initialize();
	chapDisplay = new GTKChapDisp(moduleText);
	entryDisplay = new GTKEntryDisp(moduleText);

	return mainWindow;
}

void MainWindow::initSWORD() {

	GtkWidget *menuChoice;
	int viewNumber = 1;
	char menuName[64];
	ModMap::iterator it;
	SectionMap::iterator sit;
	ConfigEntMap::iterator eit;
	char *font;
	SWModule *curMod;

/*	First, check and see whether SWMgr found any installed books.  If not, tell the user what the problem is.	*/
/*	Print a short notice to stderr, for use when the program is invoked from the command line,		*/
/*	and also put  a bit longer message into the spot where bible text would otherwise show up. 		*/
/*	Then, return out of this function, because there's nothing left to do.					*/

	if (mainMgr->Modules.empty()==TRUE) {
		fprintf(stderr,"SWMgr: Can't find 'mods.conf' or 'mods.d'.  Try setting:\n\tSWORD_PATH=<directory containing mods.conf>\n\tOr see the README file for a full description of setup options.\n\t");

		gtk_text_set_point(GTK_TEXT(moduleText), 0);
		gtk_text_forward_delete (GTK_TEXT (moduleText), gtk_text_get_length((GTK_TEXT(moduleText))));
		int curPos = 0;
		gtk_text_freeze (GTK_TEXT(moduleText));
		gtk_text_insert(GTK_TEXT(moduleText), NULL, &moduleText->style->black, NULL, "\nCheatah was unable to find any books installed!\n\n", -1);
		gtk_text_insert(GTK_TEXT(moduleText), NULL, &moduleText->style->black, NULL, "They should be listed in a configuration file named either: ", -1);
		gtk_text_insert(GTK_TEXT(moduleText), NULL, &moduleText->style->black, NULL, "'mods.conf' or 'mods.d'. \n\n", -1);
		gtk_text_insert(GTK_TEXT(moduleText), NULL, &moduleText->style->black, NULL, "Try setting:\n\tSWORD_PATH=<directory containing mods.conf>\n\t",-1);
		gtk_text_insert(GTK_TEXT(moduleText), NULL, &moduleText->style->black, NULL, "Or see the README file for a full description of setup options.\n", -1);
		gtk_text_set_point(GTK_TEXT(moduleText), curPos);
		gtk_text_thaw(GTK_TEXT(moduleText));
						
		return;
	}

/*
* Create filters to use, depending on the needs of the installed modules.
* Right now, basically just handling GBF files and converting them to plain
* text for display.  So far, I haven't found any modules that specify
* anything other than GBF, but I've dropped in code to 
* install the thtml to plain filter just in case, since it's available.
* Question: I'm installing this as a display filter - would it make more
* sense to install it is a raw filter, so that I could use "plain" as the
* base for any strip filters we may need?  Or is that used for something else,
* like compression or decyphering locked books?
*/

	gbftoplain = new GBFPlain();
	thmlplain = new ThMLPlain();

/*
*	Next, if SWMgr did find  some book modules installed , hook them up to any filters needed
*	and set up the menues to reflect them.
*	Pick a default module to show on startup.
*/
		
	for (it = mainMgr->Modules.begin(); it != mainMgr->Modules.end(); it++) {
		curMod = (*it).second;
		menuChoice = gtk_menu_item_new_with_label (curMod->Name());
		sprintf(menuName, "viewMod%d", viewNumber++);
		gtk_object_set_data (GTK_OBJECT (mainWindow), menuName, menuChoice);
		gtk_widget_show (menuChoice);
		gtk_signal_connect(GTK_OBJECT (menuChoice), "activate",
			      GTK_SIGNAL_FUNC (on_viewMod_activate),
			      g_strdup(curMod->Name()));

		if ((sit = mainMgr->config->Sections.find(curMod->Name())) != mainMgr->config->Sections.end()) {
			if ((eit = (*sit).second.find("SourceType")) != (*sit).second.end()) {
				if (!strcasecmp((*eit).second.c_str(), "GBF")) {
					curMod->AddRenderFilter(gbftoplain);
				}
				else if (!strcasecmp((*eit).second.c_str(), "ThML")) {
					curMod->AddRenderFilter(thmlplain);
				}
			}
		}

		if (!strcmp((*it).second->Type(), "Biblical Texts")) {
			gtk_container_add (GTK_CONTAINER (menuView), menuChoice);
			font = 0;
			if ((sit = mainMgr->config->Sections.find(curMod->Name())) != mainMgr->config->Sections.end()) {
				if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) {
					font = (char *)(*eit).second.c_str();
				}
			}
//			CreateTextPane((*it).second, font);
			curMod->Disp(chapDisplay);	// set our GTKChapDisp object up for the diplayer of each Biblical Text module
			if (!this->curMod) 	// set currently selected module for app to first module from SWMgr (Bible Texts get first preference
				this->curMod = curMod;
		}
		else	{
			curMod->Disp(entryDisplay);	// set our GTKEntryDisp object up for the diplayer of each module other than Biblical Texts
			if (!strcmp(curMod->Type(), "Commentaries")) {
				gtk_container_add (GTK_CONTAINER (menuCommentaries), menuChoice);
	//			CreateCommentPane((*it).second);
			}
			if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
				gtk_container_add (GTK_CONTAINER (menuDictionaries), menuChoice);
	//			CreateLDPane((*it).second);
			}
		}


	}
	gtk_container_add (GTK_CONTAINER (menuView), commentaries);
	gtk_container_add (GTK_CONTAINER (menuView), dictionaries);

	if (!this->curMod)			// We didn't find a bible text, so set currently selected module for app to first module from SWMgr
		this->curMod = curMod;	// Should be o.k. to do this, because we've already tested to see if SWMgr thinks it found something
	assert(this->curMod!=NULL);
	if(this->curMod!=NULL)		// Go ahead and display default module
		lookupTextChanged();
}


void MainWindow::lookupTextChanged() {
	string keyText;
	gchar *entryText;
	char tmpBuf[255];

	entryText = gtk_entry_get_text(GTK_ENTRY(lookupText));
	keyText = entryText;

	if (curMod) {
		SWKey *key = curMod->CreateKey();
		VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
		key->Persist(1);
		if (vkey) {
			vkey->Headings(1);
			vkey->AutoNormalize(0);
		}
		*key = keyText.c_str();
		curMod->setKey(*key);
		curMod->Display();
		sprintf(tmpBuf, "%s (%s)", curMod->KeyText(), curMod->Name());
		gtk_label_set(GTK_LABEL(statusbar1), tmpBuf);
		curMod->setKey(keyText.c_str());
		delete key;
	}
}

void MainWindow::viewModActivate(GtkMenuItem *sender, gchar *modName) {
	ModMap::iterator it;

	it = mainMgr->Modules.find(modName);
	if (it != mainMgr->Modules.end()) {
		curMod = (*it).second;
		lookupTextChanged();
	}
	else	curMod = 0;
}


void MainWindow::navigateButtonClicked(int direction) {
	if (curMod) {
		if (direction)
			(*curMod)++;
		else	(*curMod)--;
		(const char *)*curMod;  // snap to closest locations
		const gchar *text = curMod->KeyText();
		gtk_entry_set_text(GTK_ENTRY(lookupText), text);
//		curMod->Display();
	}
}


void MainWindow::searchButtonClicked() {
	string srchText;
	gchar *entryText;
	const gchar *resultText;
	gchar **clistText = (gchar **)&resultText;


	gtk_clist_clear(GTK_CLIST(resultList));

	entryText = gtk_entry_get_text(GTK_ENTRY(searchText));
	srchText = entryText;

	if (curMod) {
		int searchType = GTK_TOGGLE_BUTTON(regexSearch)->active ? 0 : GTK_TOGGLE_BUTTON(phraseSearch)->active ? -1 : -2;
		int searchParams = GTK_TOGGLE_BUTTON(caseSensitive)->active ? 0 : REG_ICASE;
		gtk_clist_freeze(GTK_CLIST(resultList));
		for (ListKey searchResults = curMod->Search(srchText.c_str(), searchType, searchParams); !searchResults.Error(); searchResults++) {
			resultText = (const char *)searchResults;
			gtk_clist_append(GTK_CLIST(resultList), clistText);
		}
		gtk_clist_thaw(GTK_CLIST(resultList));
	}
}


void MainWindow::resultListSelectionChanged(GtkWidget *clist, gint row, gint column, GdkEventButton *event, gpointer data) {
	gchar *text;

	gtk_clist_get_text(GTK_CLIST(resultList), row, column, &text);

	if (text) {
		gtk_entry_set_text(GTK_ENTRY(lookupText), text);
	}
}

GdkColor GTKEntryDisp::colourBlue;
GdkColor GTKEntryDisp::colourGreen;

/*										*/
/*	Note: we have a warning that should be fixed here.  GTKEntryDisp::Display() is defined	*/
/*	as returning char, but doesn't have a return statement				*/
/*	What was intended - a return code?  That doesn't seem right, because those are	*/
/*	usually int's.  But it isn't defined as returning a char*, so it doesn't seem		*/
/*	likely that it's intended to return the text involved.					*/
/*										*/
char GTKEntryDisp::Display(SWModule &imodule) {
	char tmpBuf[255];

	gtk_text_set_point(GTK_TEXT(gtkText), 0);
	gtk_text_forward_delete (GTK_TEXT (gtkText), gtk_text_get_length((GTK_TEXT(gtkText))));
	int curPos = 0;
	(const char *)imodule;	// snap to entry
	gtk_text_freeze (GTK_TEXT(gtkText));
	sprintf(tmpBuf, "[%s] ", imodule.KeyText());
	gtk_text_insert(GTK_TEXT(gtkText), NULL, &colourBlue, NULL, tmpBuf, -1);
	gtk_text_insert(GTK_TEXT(gtkText), NULL, &gtkText->style->black, NULL, (const char *)imodule, -1);
	gtk_text_set_point(GTK_TEXT(gtkText), curPos);
	gtk_text_thaw(GTK_TEXT(gtkText));
}

/*											*/
/*	Note: we have a warning that should be fixed here.  GTKChapDisp::Display() is defined		*/
/*	as returning char, but doesn't have a return statement.					*/
/*	What was intended - a return code?  That doesn't seem right, because those are		*/
/*	usually int's.  But it isn't defined as returning a char*, so it doesn't seem			*/
/*	likely that it's intended to return the text involved.						*/
/*											*/

char GTKChapDisp::Display(SWModule &imodule) {
	char tmpBuf[255];

	gtk_text_set_point(GTK_TEXT(gtkText), 0);
	gtk_text_forward_delete (GTK_TEXT (gtkText), gtk_text_get_length((GTK_TEXT(gtkText))));
	VerseKey *key = (VerseKey *)(SWKey *)imodule;
	int curVerse = key->Verse();
	int curChapter = key->Chapter();
	int curBook = key->Book();
	int curPos = 0;
	gfloat adjVal;
	gtk_text_freeze (GTK_TEXT(gtkText));
	for (key->Verse(1); (key->Book() == curBook && key->Chapter() == curChapter && !imodule.Error()); imodule++) {
		sprintf(tmpBuf, "%d. ", key->Verse());
		gtk_text_insert(GTK_TEXT(gtkText), NULL, &colourBlue, NULL, tmpBuf, -1);
		if (key->Verse() == curVerse) {
			gtk_text_thaw(GTK_TEXT(gtkText));
			adjVal = GTK_TEXT(gtkText)->vadj->upper;
			curPos = gtk_text_get_length(GTK_TEXT(gtkText));
			gtk_text_insert(GTK_TEXT(gtkText), NULL, &colourGreen, NULL, (const char *)imodule, -1);
			gtk_text_freeze (GTK_TEXT(gtkText));
		}
		else {
			gtk_text_insert(GTK_TEXT(gtkText), NULL, &gtkText->style->black, NULL, (const char *)imodule, -1);
		}
		gtk_text_insert(GTK_TEXT(gtkText), NULL, &gtkText->style->black, NULL, "  ", -1);
	}
	gtk_text_set_point(GTK_TEXT(gtkText), curPos);
	gtk_text_thaw(GTK_TEXT(gtkText));
	adjVal -= (GTK_TEXT(gtkText)->vadj->page_size / 2);
	gtk_adjustment_set_value(GTK_TEXT(gtkText)->vadj, (adjVal>0)?adjVal:0);
	key->Verse(1);
	key->Chapter(1);
	key->Book(curBook);
	key->Chapter(curChapter);
	key->Verse(curVerse);
}