1 /*
2 * Xiphos Bible Study Tool
3 * menu_popup.c - main window panes and dialogs popup menus
4 *
5 * Copyright (C) 2000-2020 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
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <gtk/gtk.h>
27
28 #ifndef USE_GTKBUILDER
29 #include <glade/glade-xml.h>
30 #endif
31
32 #include <glib.h>
33 #include <glib/gstdio.h>
34 #include <errno.h>
35 #include <unistd.h>
36 #include <ctype.h>
37
38 #include "xiphos_html/xiphos_html.h"
39
40 #include "gui/menu_popup.h"
41 #include "gui/cipher_key_dialog.h"
42 #include "gui/dialog.h"
43 #include "gui/utilities.h"
44 #include "gui/widgets.h"
45 #include "gui/bookmark_dialog.h"
46 #include "gui/export_dialog.h"
47 #include "gui/find_dialog.h"
48 #include "gui/font_dialog.h"
49 #include "gui/about_modules.h"
50
51 #include "main/module_dialogs.h"
52 #include "main/sword.h"
53 #include "main/settings.h"
54 #include "main/lists.h"
55 #include "main/display.hh"
56 #include "main/search_sidebar.h"
57 #include "main/mod_mgr.h"
58 #include "main/url.hh"
59
60 #ifdef USE_WEBKIT_EDITOR
61 #include "editor/webkit_editor.h"
62 #else
63 #include "editor/slib-editor.h"
64 #endif
65
66 #include "gui/debug_glib_null.h"
67
68 static gchar *menu_mod_name = NULL;
69 static DIALOG_DATA *dialog = NULL;
70 static int is_dialog = 0;
71
72 /******************************************************************************
73 * Name
74 *
75 *
76 * Synopsis
77 * #include "gui/menu_popup.h"
78 *
79 *
80 *
81 * Description
82 *
83 *
84 * Return value
85 *
86 */
87
_get_type_mod_list(void)88 gint _get_type_mod_list(void)
89 {
90 switch (main_get_mod_type(menu_mod_name)) {
91 case TEXT_TYPE:
92 return TEXT_DESC_LIST;
93 break;
94 case COMMENTARY_TYPE:
95 case PERCOM_TYPE:
96 return COMM_DESC_LIST;
97 break;
98 case DICTIONARY_TYPE:
99 return DICT_DESC_LIST;
100 break;
101 case BOOK_TYPE:
102 return GBS_DESC_LIST;
103 break;
104 default:
105 return -1;
106 break;
107 }
108 }
109
110 /******************************************************************************
111 * Name
112 *
113 *
114 * Synopsis
115 * #include "gui/menu_popup.h"
116 *
117 *
118 *
119 * Description
120 *
121 *
122 * Return value
123 *
124 */
125
_get_key(gchar * mod_name)126 gchar *_get_key(gchar *mod_name)
127 {
128 gchar *key = NULL;
129
130 if (is_dialog)
131 return g_strdup(dialog->key);
132
133 switch (main_get_mod_type(mod_name)) {
134 case TEXT_TYPE:
135 case COMMENTARY_TYPE:
136 case PERCOM_TYPE:
137 key = g_strdup(settings.currentverse);
138 break;
139 case DICTIONARY_TYPE:
140 key = g_strdup(settings.dictkey);
141 break;
142 case BOOK_TYPE:
143 case PRAYERLIST_TYPE:
144 key = g_strdup(settings.book_key);
145 break;
146 }
147 return key;
148 }
149
150 /******************************************************************************
151 * Name
152 *
153 *
154 * Synopsis
155 * #include "gui/menu_popup.h"
156 *
157 *
158 *
159 * Description
160 *
161 *
162 * Return value
163 *
164 */
165
_get_html(void)166 GtkWidget *_get_html(void)
167 {
168 if (is_dialog)
169 return dialog->html;
170 else
171 switch (main_get_mod_type(menu_mod_name)) {
172 case TEXT_TYPE:
173 return widgets.html_text;
174 break;
175 case COMMENTARY_TYPE:
176 case PERCOM_TYPE:
177 return widgets.html_comm;
178 break;
179 case DICTIONARY_TYPE:
180 return widgets.html_dict;
181 break;
182 case BOOK_TYPE:
183 case PRAYERLIST_TYPE:
184 return widgets.html_book;
185 break;
186 }
187 return NULL;
188 }
189
190 /******************************************************************************
191 * Name
192 * _global_option_main_pane
193 *
194 * Synopsis
195 * #include "gui/menu_popup.h"
196 *
197 * void _global_option_main_pane(GtkMenuItem * menuitem,
198 GBS_DATA * g)
199 *
200 * Description
201 *
202 *
203 * Return value
204 * void
205 */
206
_global_option_main_pane(GtkMenuItem * menuitem,const gchar * option)207 static void _global_option_main_pane(GtkMenuItem *menuitem, const gchar *option)
208 {
209 gchar *key = _get_key(menu_mod_name);
210 gchar *mod =
211 (gchar *)(is_dialog ? dialog->mod_name : menu_mod_name);
212 XI_message(("module option = %s", option));
213 if (key) {
214 gchar *url = g_strdup_printf("sword://%s/%s",
215 mod,
216 key);
217 main_save_module_options(mod, (gchar *)option,
218 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)));
219 if (is_dialog) {
220 /* show the change */
221 main_dialogs_url_handler(dialog, url, TRUE);
222 } else {
223 /* show the change */
224 main_url_handler(url, TRUE);
225 }
226
227 g_free(url);
228 g_free(key);
229 }
230 }
231
232 /******************************************************************************
233 * Name
234 *
235 *
236 * Synopsis
237 * #include "gui/menu_popup.h"
238 *
239 *
240 *
241 * Description
242 *
243 *
244 * Return value
245 *
246 */
247
on_edit_percomm_activate(GtkMenuItem * menuitem,gpointer user_data)248 static void on_edit_percomm_activate(GtkMenuItem *menuitem,
249 gpointer user_data)
250 {
251 gchar *key;
252
253 if (is_dialog)
254 key = g_strdup(dialog->key);
255 else
256 key = _get_key(menu_mod_name);
257 if (key) {
258 XI_message(("\n\npercomm key: %s\n\n", key));
259 editor_create_new((gchar *)user_data, (gchar *)key,
260 NOTE_EDITOR);
261 g_free(key);
262 }
263 }
264
265 /******************************************************************************
266 * Name
267 *
268 *
269 * Synopsis
270 * #include "gui/menu_popup.h"
271 *
272 *
273 *
274 * Description
275 *
276 *
277 * Return value
278 *
279 */
280
on_edit_prayerlist_activate(GtkMenuItem * menuitem,gpointer user_data)281 static void on_edit_prayerlist_activate(GtkMenuItem *menuitem,
282 gpointer user_data)
283 {
284 XI_message(("settings.book_key: %s", (char *)(is_dialog ? dialog->key : settings.book_key)));
285 editor_create_new((gchar *)user_data,
286 (gchar *)(is_dialog ? dialog->key : settings.book_key), BOOK_EDITOR);
287 }
288
289 /******************************************************************************
290 * Name
291 *
292 *
293 * Synopsis
294 * #include "gui/menu_popup.h"
295 *
296 *
297 *
298 * Description
299 *
300 *
301 * Return value
302 *
303 */
304
on_popup_about_activate(GtkMenuItem * menuitem,gpointer user_data)305 G_MODULE_EXPORT void on_popup_about_activate(GtkMenuItem *menuitem,
306 gpointer user_data)
307 {
308 gui_display_about_module_dialog((is_dialog ? dialog->mod_name : menu_mod_name));
309 }
310
311 /******************************************************************************
312 * Name
313 *
314 *
315 * Synopsis
316 * #include "gui/menu_popup.h"
317 *
318 *
319 *
320 * Description
321 *
322 *
323 * Return value
324 *
325 */
326
on_popup_bookmark_activate(GtkMenuItem * menuitem,gpointer user_data)327 G_MODULE_EXPORT void on_popup_bookmark_activate(GtkMenuItem *menuitem,
328 gpointer user_data)
329 {
330 gchar *key;
331
332 if (is_dialog)
333 return;
334
335 if ((key = _get_key(menu_mod_name))) {
336 gchar *label = g_strdup_printf("%s, %s",
337 key,
338 menu_mod_name);
339 gui_bookmark_dialog(label, menu_mod_name, key);
340 g_free(label);
341 g_free(key);
342 }
343 }
344
345 /******************************************************************************
346 * Name
347 *
348 *
349 * Synopsis
350 * #include "gui/menu_popup.h"
351 *
352 *
353 *
354 * Description
355 *
356 *
357 * Return value
358 *
359 */
360
on_popup_export_passage_activate(GtkMenuItem * menuitem,gpointer user_data)361 G_MODULE_EXPORT void on_popup_export_passage_activate(GtkMenuItem *
362 menuitem,
363 gpointer user_data)
364 {
365 if (is_dialog)
366 return;
367
368 gui_export_dialog();
369 }
370
371 /******************************************************************************
372 * Name
373 *
374 *
375 * Synopsis
376 * #include "gui/menu_popup.h"
377 *
378 *
379 *
380 * Description
381 *
382 *
383 * Return value
384 *
385 */
386
on_popup_print_activate(GtkMenuItem * menuitem,gpointer user_data)387 G_MODULE_EXPORT void on_popup_print_activate(GtkMenuItem *menuitem,
388 gpointer user_data)
389 {
390 /* there is some weirdness here, from having eliminated gtkhtml3.
391 * we must understand why this is an interesting conditional. */
392 if (is_dialog) {
393 XIPHOS_HTML_PRINT_DOCUMENT((XiphosHtml *)user_data);
394 } else {
395 XIPHOS_HTML_PRINT_DOCUMENT((XiphosHtml *)user_data);
396 }
397 }
398
399 /******************************************************************************
400 * Name
401 *
402 *
403 * Synopsis
404 * #include "gui/menu_popup.h"
405 *
406 *
407 *
408 * Description
409 *
410 *
411 * Return value
412 *
413 */
414
on_close_activate(GtkMenuItem * menuitem,gpointer user_data)415 G_MODULE_EXPORT void on_close_activate(GtkMenuItem *menuitem,
416 gpointer user_data)
417 {
418 /* FIXME */
419 }
420
421 /******************************************************************************
422 * Name
423 *
424 *
425 * Synopsis
426 * #include "gui/menu_popup.h"
427 *
428 *
429 *
430 * Description
431 *
432 *
433 * Return value
434 *
435 */
436
on_popup_copy_activate(GtkMenuItem * menuitem,gpointer user_data)437 G_MODULE_EXPORT void on_popup_copy_activate(GtkMenuItem *menuitem,
438 gpointer user_data)
439 {
440 /* ditto above comment re: printing */
441 if (is_dialog) {
442 XIPHOS_HTML_COPY_SELECTION(dialog->html);
443 } else {
444 XIPHOS_HTML_COPY_SELECTION(_get_html());
445 }
446 }
447
448 /******************************************************************************
449 * Name
450 *
451 *
452 * Synopsis
453 * #include "gui/menu_popup.h"
454 *
455 *
456 *
457 * Description
458 *
459 *
460 * Return value
461 *
462 */
463
on_popup_find_activate(GtkMenuItem * menuitem,gpointer user_data)464 G_MODULE_EXPORT void on_popup_find_activate(GtkMenuItem *menuitem,
465 gpointer user_data)
466 {
467 if (is_dialog)
468 gui_find_dlg(dialog->html, dialog->mod_name, FALSE, NULL);
469 else
470 gui_find_dlg(_get_html(), menu_mod_name, FALSE, NULL);
471 }
472
473 /******************************************************************************
474 * Name
475 *
476 *
477 * Synopsis
478 * #include "gui/menu_popup.h"
479 *
480 *
481 *
482 * Description
483 *
484 *
485 * Return value
486 *
487 */
488
on_popup_font_activate(GtkMenuItem * menuitem,gpointer user_data)489 G_MODULE_EXPORT void on_popup_font_activate(GtkMenuItem *menuitem,
490 gpointer user_data)
491 {
492 if (is_dialog) {
493 gchar *url = g_strdup_printf("sword://%s/%s",
494 dialog->mod_name,
495 dialog->key);
496 gui_set_module_font(dialog->mod_name);
497 /* show the change */
498 main_dialogs_url_handler(dialog, url, TRUE);
499 g_free(url);
500 } else {
501 gchar *key = _get_key(menu_mod_name);
502 if (key) {
503 gchar *url = g_strdup_printf("sword://%s/%s",
504 menu_mod_name,
505 key);
506 gui_set_module_font(menu_mod_name);
507 /* show the change */
508 main_url_handler(url, TRUE);
509 g_free(url);
510 g_free(key);
511 }
512 }
513 }
514
515 /******************************************************************************
516 * Name
517 *
518 *
519 * Synopsis
520 * #include "gui/menu_popup.h"
521 *
522 *
523 *
524 * Description
525 *
526 *
527 * Return value
528 *
529 */
530
on_verse_per_line_activate(GtkCheckMenuItem * menuitem,gpointer user_data)531 G_MODULE_EXPORT void on_verse_per_line_activate(GtkCheckMenuItem *
532 menuitem,
533 gpointer user_data)
534 {
535 gchar *file = g_strdup_printf("%s/modops.conf",
536 settings.gSwordDir);
537
538 gchar *url = g_strdup_printf("sword://%s/%s",
539 (is_dialog ? dialog->mod_name : settings.MainWindowModule),
540 (is_dialog ? dialog->key : settings.currentverse));
541
542 save_conf_file_item(file, (is_dialog
543 ? dialog->mod_name
544 : settings.MainWindowModule),
545 "style",
546 (gtk_check_menu_item_get_active(menuitem)
547 ? "verse"
548 : "paragraph"));
549 if (settings.havebible) {
550 if (is_dialog) {
551 /* show the change */
552 main_dialogs_url_handler(dialog, url, TRUE);
553 } else {
554 settings.versestyle =
555 gtk_check_menu_item_get_active(menuitem);
556 main_url_handler(url, TRUE);
557 }
558 }
559 g_free(url);
560 g_free(file);
561 }
562
563 /******************************************************************************
564 * Name
565 *
566 *
567 * Synopsis
568 * #include "gui/menu_popup.h"
569 *
570 *
571 *
572 * Description
573 *
574 *
575 * Return value
576 *
577 */
578
on_words_of_christ_in_red_activate(GtkCheckMenuItem * menuitem,gpointer user_data)579 G_MODULE_EXPORT void on_words_of_christ_in_red_activate(GtkCheckMenuItem *
580 menuitem,
581 gpointer user_data)
582 {
583 _global_option_main_pane((GtkMenuItem *)menuitem, "Words of Christ in Red"); /* string not seen by user */
584 }
585
586 /******************************************************************************
587 * Name
588 *
589 *
590 * Synopsis
591 * #include "gui/menu_popup.h"
592 *
593 *
594 *
595 * Description
596 *
597 *
598 * Return value
599 *
600 */
601
on_strong_s_numbers_activate(GtkCheckMenuItem * menuitem,gpointer user_data)602 G_MODULE_EXPORT void on_strong_s_numbers_activate(GtkCheckMenuItem *
603 menuitem,
604 gpointer user_data)
605 {
606 _global_option_main_pane((GtkMenuItem *)menuitem, "Strong's Numbers"); /* string not seen by user */
607 }
608
609 /******************************************************************************
610 * Name
611 *
612 *
613 * Synopsis
614 * #include "gui/menu_popup.h"
615 *
616 *
617 *
618 * Description
619 *
620 *
621 * Return value
622 *
623 */
624
on_morphological_tags_activate(GtkCheckMenuItem * menuitem,gpointer user_data)625 G_MODULE_EXPORT void on_morphological_tags_activate(GtkCheckMenuItem *
626 menuitem,
627 gpointer user_data)
628 {
629 _global_option_main_pane((GtkMenuItem *)menuitem, "Morphological Tags"); /* string not seen by user */
630 }
631
632 /******************************************************************************
633 * Name
634 *
635 *
636 * Synopsis
637 * #include "gui/menu_popup.h"
638 *
639 *
640 *
641 * Description
642 *
643 *
644 * Return value
645 *
646 */
647
on_footnotes_activate(GtkCheckMenuItem * menuitem,gpointer user_data)648 G_MODULE_EXPORT void on_footnotes_activate(GtkCheckMenuItem *menuitem,
649 gpointer user_data)
650 {
651 _global_option_main_pane((GtkMenuItem *)menuitem, "Footnotes"); /* string not seen by user */
652 }
653
654 /******************************************************************************
655 * Name
656 *
657 *
658 * Synopsis
659 * #include "gui/menu_popup.h"
660 *
661 *
662 *
663 * Description
664 *
665 *
666 * Return value
667 *
668 */
669
on_greek_accents_activate(GtkCheckMenuItem * menuitem,gpointer user_data)670 G_MODULE_EXPORT void on_greek_accents_activate(GtkCheckMenuItem *menuitem,
671 gpointer user_data)
672 {
673 _global_option_main_pane((GtkMenuItem *)menuitem, "Greek Accents"); /* string not seen by user */
674 }
675
676 /******************************************************************************
677 * Name
678 *
679 *
680 * Synopsis
681 * #include "gui/menu_popup.h"
682 *
683 *
684 *
685 * Description
686 *
687 *
688 * Return value
689 *
690 */
691
on_lemmas_activate(GtkCheckMenuItem * menuitem,gpointer user_data)692 G_MODULE_EXPORT void on_lemmas_activate(GtkCheckMenuItem *menuitem,
693 gpointer user_data)
694 {
695 _global_option_main_pane((GtkMenuItem *)menuitem, "Lemmas"); /* string not seen by user */
696 }
697
698 /******************************************************************************
699 * Name
700 *
701 *
702 * Synopsis
703 * #include "gui/menu_popup.h"
704 *
705 *
706 *
707 * Description
708 *
709 *
710 * Return value
711 *
712 */
713
714 G_MODULE_EXPORT void
on_scripture_cross_references_activate(GtkCheckMenuItem * menuitem,gpointer user_data)715 on_scripture_cross_references_activate(GtkCheckMenuItem *menuitem,
716 gpointer user_data)
717 {
718 _global_option_main_pane((GtkMenuItem *)menuitem, "Cross-references"); /* string not seen by user */
719 }
720
721 /******************************************************************************
722 * Name
723 *
724 *
725 * Synopsis
726 * #include "gui/menu_popup.h"
727 *
728 *
729 *
730 * Description
731 *
732 *
733 * Return value
734 *
735 */
736
on_hebrew_vowel_points_activate(GtkCheckMenuItem * menuitem,gpointer user_data)737 G_MODULE_EXPORT void on_hebrew_vowel_points_activate(GtkCheckMenuItem *
738 menuitem,
739 gpointer user_data)
740 {
741 _global_option_main_pane((GtkMenuItem *)menuitem, "Hebrew Vowel Points"); /* string not seen by user */
742 }
743
744 /******************************************************************************
745 * Name
746 *
747 *
748 * Synopsis
749 * #include "gui/menu_popup.h"
750 *
751 *
752 *
753 * Description
754 *
755 *
756 * Return value
757 *
758 */
759
on_hebrew_cantillation_activate(GtkCheckMenuItem * menuitem,gpointer user_data)760 G_MODULE_EXPORT void on_hebrew_cantillation_activate(GtkCheckMenuItem *
761 menuitem,
762 gpointer user_data)
763 {
764 _global_option_main_pane((GtkMenuItem *)menuitem, "Hebrew Cantillation"); /* string not seen by user */
765 }
766
767 /******************************************************************************
768 * Name
769 *
770 *
771 * Synopsis
772 * #include "gui/menu_popup.h"
773 *
774 *
775 *
776 * Description
777 *
778 *
779 * Return value
780 *
781 */
782
on_headings_activate(GtkCheckMenuItem * menuitem,gpointer user_data)783 G_MODULE_EXPORT void on_headings_activate(GtkCheckMenuItem *menuitem,
784 gpointer user_data)
785 {
786 _global_option_main_pane((GtkMenuItem *)menuitem, "Headings"); /* string not seen by user */
787 }
788
789 /******************************************************************************
790 * Name
791 *
792 *
793 * Synopsis
794 * #include "gui/menu_popup.h"
795 *
796 *
797 *
798 * Description
799 *
800 *
801 * Return value
802 *
803 */
804
on_transliteration_activate(GtkCheckMenuItem * menuitem,gpointer user_data)805 G_MODULE_EXPORT void on_transliteration_activate(GtkCheckMenuItem *
806 menuitem,
807 gpointer user_data)
808 {
809 _global_option_main_pane((GtkMenuItem *)menuitem, "Transliteration"); /* string not seen by user */
810 }
811
812 /******************************************************************************
813 * Name
814 *
815 *
816 * Synopsis
817 * #include "gui/menu_popup.h"
818 *
819 *
820 *
821 * Description
822 *
823 *
824 * Return value
825 *
826 */
827
on_commentary_by_chapter_activate(GtkCheckMenuItem * menuitem,gpointer user_data)828 G_MODULE_EXPORT void on_commentary_by_chapter_activate(GtkCheckMenuItem *
829 menuitem,
830 gpointer user_data)
831 {
832 _global_option_main_pane((GtkMenuItem *)menuitem, "Commentary by Chapter"); /* string not seen by user */
833 }
834
835 /******************************************************************************
836 * Name
837 *
838 *
839 * Synopsis
840 * #include "gui/menu_popup.h"
841 *
842 *
843 *
844 * Description
845 *
846 *
847 * Return value
848 *
849 */
850
on_doublespace_activate(GtkCheckMenuItem * menuitem,gpointer user_data)851 G_MODULE_EXPORT void on_doublespace_activate(GtkCheckMenuItem *menuitem,
852 gpointer user_data)
853 {
854 _global_option_main_pane((GtkMenuItem *)menuitem, "Doublespace"); /* string not seen by user */
855 }
856
857 /******************************************************************************
858 * Name
859 *
860 *
861 * Synopsis
862 * #include "gui/menu_popup.h"
863 *
864 *
865 *
866 * Description
867 *
868 *
869 * Return value
870 *
871 */
872
on_xrefnotenumbers_activate(GtkCheckMenuItem * menuitem,gpointer user_data)873 G_MODULE_EXPORT void on_xrefnotenumbers_activate(GtkCheckMenuItem *
874 menuitem,
875 gpointer user_data)
876 {
877 _global_option_main_pane((GtkMenuItem *)menuitem, "XrefNoteNumbers"); /* string not seen by user */
878 }
879
880 /******************************************************************************
881 * Name
882 *
883 *
884 * Synopsis
885 * #include "gui/menu_popup.h"
886 *
887 *
888 *
889 * Description
890 *
891 *
892 * Return value
893 *
894 */
895
on_xlit_activate(GtkCheckMenuItem * menuitem,gpointer user_data)896 G_MODULE_EXPORT void on_xlit_activate(GtkCheckMenuItem *menuitem,
897 gpointer user_data)
898 {
899 _global_option_main_pane((GtkMenuItem *)menuitem, "Transliterated Forms"); /* string not seen by user */
900 }
901
902 /******************************************************************************
903 * Name
904 *
905 *
906 * Synopsis
907 * #include "gui/menu_popup.h"
908 *
909 *
910 *
911 * Description
912 *
913 *
914 * Return value
915 *
916 */
917
on_enumerated_activate(GtkCheckMenuItem * menuitem,gpointer user_data)918 G_MODULE_EXPORT void on_enumerated_activate(GtkCheckMenuItem *menuitem,
919 gpointer user_data)
920 {
921 _global_option_main_pane((GtkMenuItem *)menuitem, "Enumerations"); /* string not seen by user */
922 }
923
924 /******************************************************************************
925 * Name
926 *
927 *
928 * Synopsis
929 * #include "gui/menu_popup.h"
930 *
931 *
932 *
933 * Description
934 *
935 *
936 * Return value
937 *
938 */
939
on_glosses_activate(GtkCheckMenuItem * menuitem,gpointer user_data)940 G_MODULE_EXPORT void on_glosses_activate(GtkCheckMenuItem *menuitem,
941 gpointer user_data)
942 {
943 _global_option_main_pane((GtkMenuItem *)menuitem, "Glosses"); /* string not seen by user */
944 }
945
946 /******************************************************************************
947 * Name
948 *
949 *
950 * Synopsis
951 * #include "gui/menu_popup.h"
952 *
953 *
954 *
955 * Description
956 *
957 *
958 * Return value
959 *
960 */
961
on_morphseg_activate(GtkCheckMenuItem * menuitem,gpointer user_data)962 G_MODULE_EXPORT void on_morphseg_activate(GtkCheckMenuItem *menuitem,
963 gpointer user_data)
964 {
965 _global_option_main_pane((GtkMenuItem *)menuitem, "Morpheme Segmentation"); /* string not seen by user */
966 }
967
968 /******************************************************************************
969 * Name
970 *
971 *
972 * Synopsis
973 * #include "gui/menu_popup.h"
974 *
975 *
976 *
977 * Description
978 *
979 *
980 * Return value
981 *
982 */
983
on_primary_reading_activate(GtkCheckMenuItem * menuitem,gpointer user_data)984 G_MODULE_EXPORT void on_primary_reading_activate(GtkCheckMenuItem *
985 menuitem,
986 gpointer user_data)
987 {
988 gchar *key = NULL;
989
990 if (is_dialog) {
991 reading_selector(dialog->mod_name,
992 dialog->key,
993 dialog,
994 (GtkMenuItem *)menuitem,
995 GINT_TO_POINTER(0));
996 } else {
997 if ((key = _get_key(menu_mod_name))) {
998 reading_selector(menu_mod_name,
999 key,
1000 NULL,
1001 (GtkMenuItem *)menuitem,
1002 GINT_TO_POINTER(0));
1003 g_free(key);
1004 }
1005 }
1006 }
1007
1008 /******************************************************************************
1009 * Name
1010 *
1011 *
1012 * Synopsis
1013 * #include "gui/menu_popup.h"
1014 *
1015 *
1016 *
1017 * Description
1018 *
1019 *
1020 * Return value
1021 *
1022 */
1023
on_secondary_reading_activate(GtkCheckMenuItem * menuitem,gpointer user_data)1024 G_MODULE_EXPORT void on_secondary_reading_activate(GtkCheckMenuItem *
1025 menuitem,
1026 gpointer user_data)
1027 {
1028 gchar *key = NULL;
1029
1030 if (is_dialog) {
1031 reading_selector(dialog->mod_name,
1032 dialog->key,
1033 dialog,
1034 (GtkMenuItem *)menuitem,
1035 GINT_TO_POINTER(1));
1036 } else {
1037 if ((key = _get_key(menu_mod_name))) {
1038 reading_selector(menu_mod_name,
1039 key,
1040 NULL,
1041 (GtkMenuItem *)menuitem,
1042 GINT_TO_POINTER(1));
1043 g_free(key);
1044 }
1045 }
1046 }
1047
1048 /******************************************************************************
1049 * Name
1050 *
1051 *
1052 * Synopsis
1053 * #include "gui/menu_popup.h"
1054 *
1055 *
1056 *
1057 * Description
1058 *
1059 *
1060 * Return value
1061 *
1062 */
1063
on_all_readings_activate(GtkCheckMenuItem * menuitem,gpointer user_data)1064 G_MODULE_EXPORT void on_all_readings_activate(GtkCheckMenuItem *menuitem,
1065 gpointer user_data)
1066 {
1067 gchar *key = NULL;
1068
1069 if (is_dialog) {
1070 reading_selector(dialog->mod_name,
1071 dialog->key,
1072 dialog,
1073 (GtkMenuItem *)menuitem,
1074 GINT_TO_POINTER(2));
1075 } else {
1076 if ((key = _get_key(menu_mod_name))) {
1077 reading_selector(menu_mod_name,
1078 key,
1079 NULL,
1080 (GtkMenuItem *)menuitem,
1081 GINT_TO_POINTER(2));
1082 g_free(key);
1083 }
1084 }
1085 }
1086
1087 /******************************************************************************
1088 * Name
1089 *
1090 *
1091 * Synopsis
1092 * #include "gui/menu_popup.h"
1093 *
1094 *
1095 *
1096 * Description
1097 *
1098 *
1099 * Return value
1100 *
1101 */
1102
on_image_content_activate(GtkCheckMenuItem * menuitem,gpointer user_data)1103 G_MODULE_EXPORT void on_image_content_activate(GtkCheckMenuItem *menuitem,
1104 gpointer user_data)
1105 {
1106 _global_option_main_pane((GtkMenuItem *)menuitem, "Image Content"); /* string not seen by user */
1107 }
1108
1109 /******************************************************************************
1110 * Name
1111 *
1112 *
1113 * Synopsis
1114 * #include "gui/menu_popup.h"
1115 *
1116 *
1117 *
1118 * Description
1119 *
1120 *
1121 * Return value
1122 *
1123 */
1124
on_respect_font_faces_activate(GtkCheckMenuItem * menuitem,gpointer user_data)1125 G_MODULE_EXPORT void on_respect_font_faces_activate(GtkCheckMenuItem *
1126 menuitem,
1127 gpointer user_data)
1128 {
1129 _global_option_main_pane((GtkMenuItem *)menuitem, "Respect Font Faces"); /* string not seen by user */
1130 }
1131
1132 /******************************************************************************
1133 * Name
1134 *
1135 *
1136 * Synopsis
1137 * #include "gui/menu_popup.h"
1138 *
1139 *
1140 *
1141 * Description
1142 *
1143 *
1144 * Return value
1145 *
1146 */
1147
on_unlock_this_module_activate(GtkMenuItem * menuitem,gpointer user_data)1148 G_MODULE_EXPORT void on_unlock_this_module_activate(GtkMenuItem *menuitem,
1149 gpointer user_data)
1150 {
1151 if (is_dialog)
1152 return;
1153 main_check_unlock(menu_mod_name, FALSE);
1154 }
1155
1156 /******************************************************************************
1157 * Name
1158 *
1159 *
1160 * Synopsis
1161 * #include "gui/menu_popup.h"
1162 *
1163 *
1164 *
1165 * Description
1166 *
1167 *
1168 * Return value
1169 *
1170 */
1171
on_display_book_heading_activate(GtkMenuItem * menuitem,gpointer user_data)1172 G_MODULE_EXPORT void on_display_book_heading_activate(GtkMenuItem *
1173 menuitem,
1174 gpointer user_data)
1175 {
1176 if (is_dialog)
1177 main_dialogs_book_heading(dialog);
1178 else
1179 main_book_heading(menu_mod_name);
1180 }
1181
1182 /******************************************************************************
1183 * Name
1184 *
1185 *
1186 * Synopsis
1187 * #include "gui/menu_popup.h"
1188 *
1189 *
1190 *
1191 * Description
1192 *
1193 *
1194 * Return value
1195 *
1196 */
1197
on_display_chapter_heading_activate(GtkMenuItem * menuitem,gpointer user_data)1198 G_MODULE_EXPORT void on_display_chapter_heading_activate(GtkMenuItem *
1199 menuitem,
1200 gpointer
1201 user_data)
1202 {
1203 if (is_dialog)
1204 main_dialogs_chapter_heading(dialog);
1205 else
1206 main_chapter_heading(menu_mod_name);
1207 }
1208
1209 /******************************************************************************
1210 * Name
1211 *
1212 *
1213 * Synopsis
1214 * #include "gui/menu_popup.h"
1215 *
1216 *
1217 *
1218 * Description
1219 *
1220 *
1221 * Return value
1222 *
1223 */
1224
on_use_current_dictionary_activate(GtkMenuItem * menuitem,gpointer user_data)1225 G_MODULE_EXPORT void on_use_current_dictionary_activate(GtkMenuItem *
1226 menuitem,
1227 gpointer user_data)
1228 {
1229 XIPHOS_HTML_COPY_SELECTION(_get_html());
1230 gtk_editable_select_region((GtkEditable *)widgets.entry_dict, 0,
1231 -1);
1232 gtk_editable_paste_clipboard((GtkEditable *)widgets.entry_dict);
1233 gtk_widget_activate(widgets.entry_dict);
1234 }
1235
1236 /******************************************************************************
1237 * Name
1238 * on_lookup_google_activate
1239 *
1240 * Synopsis
1241 * #include "gui/menu_popup.h"
1242 *
1243 * Description
1244 * offer mouse-swept selection as a google maps browser reference.
1245 *
1246 * Return value
1247 * void
1248 */
1249
on_lookup_google_activate(GtkMenuItem * menuitem,gpointer user_data)1250 G_MODULE_EXPORT void on_lookup_google_activate(GtkMenuItem *menuitem,
1251 gpointer user_data)
1252 {
1253 gchar *dict_key;
1254
1255 XIPHOS_HTML_COPY_SELECTION(_get_html());
1256 gtk_editable_select_region((GtkEditable *)widgets.entry_dict, 0,
1257 -1);
1258 gtk_editable_paste_clipboard((GtkEditable *)widgets.entry_dict);
1259 dict_key =
1260 g_strdup(gtk_editable_get_chars((GtkEditable *)widgets.entry_dict, 0, -1));
1261
1262 if ((dict_key == NULL) || (*dict_key == '\0')) {
1263 gui_generic_warning("No selection made");
1264 } else {
1265 gchar *showstr =
1266 g_strconcat("http://www.biblemap.org/#", dict_key, NULL);
1267 xiphos_open_default(showstr);
1268 g_free(showstr);
1269 }
1270 g_free(dict_key);
1271 }
1272
1273 /******************************************************************************
1274 * Name
1275 *
1276 *
1277 * Synopsis
1278 * #include "gui/menu_popup.h"
1279 *
1280 *
1281 *
1282 * Description
1283 *
1284 *
1285 * Return value
1286 *
1287 */
1288
on_rename_perscomm_activate(GtkMenuItem * menuitem,gpointer user_data)1289 G_MODULE_EXPORT void on_rename_perscomm_activate(GtkMenuItem *menuitem,
1290 gpointer user_data)
1291 {
1292 if (is_dialog)
1293 return;
1294
1295 #if defined(WIN32)
1296 gui_generic_warning(_("Renaming is not available in Windows.\n\n"
1297 "Xiphos is limited by Windows' filesystem,\n"
1298 "because it disallows the renaming of filename\n"
1299 "components of currently-open files,\n"
1300 "such as the contents of this commentary.\n"
1301 "Therefore, personal commentary renaming is\n"
1302 "not available in the Windows environment."));
1303 #else
1304 GS_DIALOG *info;
1305 GString *workstr;
1306 char *s;
1307 char *datapath_old, *datapath_new;
1308 const char *conf_old;
1309 char *conf_new;
1310 char *sworddir, *modsdir;
1311 FILE *result;
1312
1313 // get a new name for the module.
1314 info = gui_new_dialog();
1315 info->title = _("Rename Commentary");
1316 workstr = g_string_new("");
1317 g_string_printf(workstr, "<span weight=\"bold\">%s</span>",
1318 _("Choose Commentary Name"));
1319 info->label_top = workstr->str;
1320 info->text1 = g_strdup(_("New Name"));
1321 info->label1 = _("Name: ");
1322 info->ok = TRUE;
1323 info->cancel = TRUE;
1324
1325 if (gui_gs_dialog(info) != GS_OK)
1326 goto out1;
1327
1328 for (s = info->text1; *s; ++s) {
1329 if (!isalnum(*s) && (*s != '_')) {
1330 gui_generic_warning_modal(_("Module names must contain [A-Za-z0-9_] only."));
1331 goto out1;
1332 }
1333 }
1334
1335 if (main_is_module(info->text1)) {
1336 gui_generic_warning_modal(_("Xiphos already knows a module by that name."));
1337 goto out1;
1338 }
1339
1340 sworddir = g_strdup_printf("%s/" DOTSWORD, settings.homedir);
1341 modsdir = g_strdup_printf("%s/mods.d", sworddir);
1342
1343 conf_old =
1344 main_get_mod_config_file(settings.CommWindowModule, sworddir);
1345
1346 conf_new = g_strdup(info->text1); // dirname is lowercase.
1347 for (s = conf_new; *s; ++s)
1348 if (isupper(*s))
1349 *s = tolower(*s);
1350
1351 datapath_old =
1352 main_get_mod_config_entry(settings.CommWindowModule,
1353 "DataPath");
1354 datapath_new = g_strdup(datapath_old);
1355 if ((s = strstr(datapath_new, "rawfiles/")) == NULL) {
1356 gui_generic_warning_modal("Malformed datapath in old configuration!");
1357 goto out2;
1358 }
1359
1360 *(s + 9) = '\0'; // skip past "rawfiles/".
1361 s = g_strdup_printf("%s%s", datapath_new, conf_new);
1362 g_free(datapath_new); // out with the old...
1363 datapath_new = s; // ..and in with the new.
1364
1365 // move old data directory to new.
1366 if ((g_chdir(sworddir) != 0) ||
1367 (rename(datapath_old, datapath_new) != 0)) {
1368 gui_generic_warning_modal("Failed to rename directory.");
1369 goto out2;
1370 }
1371 // manufacture new .conf from old.
1372 g_string_printf(workstr,
1373 "( cd \"%s\" && sed -e '/^\\[/s|^.*$|[%s]|' -e '/^DataPath=/s|rawfiles/.*$|rawfiles/%s/|' < \"%s\" > \"%s.conf\" ) 2>&1",
1374 modsdir, info->text1, conf_new, conf_old,
1375 conf_new);
1376 if ((result = popen(workstr->str, "r")) == NULL) {
1377 g_string_printf(workstr,
1378 _("Failed to create new configuration:\n%s"),
1379 strerror(errno));
1380 gui_generic_warning_modal(workstr->str);
1381 goto out2;
1382 } else {
1383 gchar output[258];
1384 if (fgets(output, 256, result) != NULL) {
1385 g_string_truncate(workstr, 0);
1386 g_string_append(workstr,
1387 _("Configuration build error:\n\n"));
1388 g_string_append(workstr, output);
1389 gui_generic_warning_modal(workstr->str);
1390 goto out2; // necessary? advisable?
1391 }
1392 pclose(result);
1393 }
1394
1395 // unlink old conf.
1396 g_string_printf(workstr, "%s/%s", modsdir, conf_old);
1397 if (unlink(workstr->str) != 0) {
1398 g_string_printf(workstr,
1399 "Unlink of old configuration failed:\n%s",
1400 strerror(errno));
1401 gui_generic_warning_modal(workstr->str);
1402 goto out2;
1403 }
1404 main_update_module_lists();
1405 settings.CommWindowModule = g_strdup(info->text1);
1406 main_display_commentary(info->text1, settings.currentverse);
1407
1408 out2:
1409 g_free(conf_new);
1410 g_free((char *)conf_old);
1411 g_free(datapath_old);
1412 g_free(datapath_new);
1413 g_free(modsdir);
1414 g_free(sworddir);
1415 out1:
1416 g_free(info->text1);
1417 g_free(info);
1418 g_string_free(workstr, TRUE);
1419 #endif /* !WIN32 */
1420 }
1421
1422 /******************************************************************************
1423 * Name
1424 *
1425 *
1426 * Synopsis
1427 * #include "gui/menu_popup.h"
1428 *
1429 *
1430 *
1431 * Description
1432 *
1433 *
1434 * Return value
1435 *
1436 */
1437
on_dump_perscomm_activate(GtkMenuItem * menuitem,gpointer user_data)1438 G_MODULE_EXPORT void on_dump_perscomm_activate(GtkMenuItem *menuitem,
1439 gpointer user_data)
1440 {
1441 main_sidebar_perscomm_dump();
1442 }
1443
1444 /******************************************************************************
1445 * Name
1446 * on_read_selection_aloud_activate
1447 *
1448 * Synopsis
1449 * #include "gui/menu_popup.h"
1450 *
1451 * Description
1452 * takes mouse-swept text and funnels it through TTS.
1453 *
1454 * Return value
1455 * void
1456 */
1457
on_read_selection_aloud_activate(GtkMenuItem * menuitem,gpointer user_data)1458 G_MODULE_EXPORT void on_read_selection_aloud_activate(GtkMenuItem *
1459 menuitem,
1460 gpointer user_data)
1461 {
1462 gchar *dict_key;
1463 int len;
1464 GtkWidget *html_widget = _get_html();
1465
1466 XIPHOS_HTML_COPY_SELECTION(html_widget);
1467 gtk_editable_select_region((GtkEditable *)widgets.entry_dict, 0,
1468 -1);
1469 gtk_editable_paste_clipboard((GtkEditable *)widgets.entry_dict);
1470 dict_key =
1471 g_strdup(gtk_editable_get_chars((GtkEditable *)widgets.entry_dict, 0, -1));
1472 len = (dict_key ? strlen(dict_key) : 0);
1473
1474 if (dict_key && len && *dict_key) {
1475 ReadAloud(0, dict_key);
1476 g_free(dict_key);
1477 } else
1478 gui_generic_warning("No selection made");
1479 }
1480
1481 /******************************************************************************
1482 * Name
1483 * on_mark_verse_activate
1484 *
1485 * Synopsis
1486 * #include "gui/menu_popup.h"
1487 *
1488 * Description
1489 * mark/unmark a verse for highlighting and possible user comment.
1490 *
1491 * Return value
1492 * void
1493 */
1494
on_mark_verse_activate(GtkMenuItem * menuitem,gpointer user_data)1495 G_MODULE_EXPORT void on_mark_verse_activate(GtkMenuItem *menuitem,
1496 gpointer user_data)
1497 {
1498 gchar *key;
1499
1500 if (is_dialog)
1501 return;
1502
1503 if ((key = _get_key(menu_mod_name))) {
1504 gui_mark_verse_dialog(menu_mod_name, key);
1505 g_free(key);
1506 }
1507 }
1508
1509 /******************************************************************************
1510 * Name
1511 * _add_global_opts
1512 *
1513 * Synopsis
1514 * gui/menu_popup.h
1515 *
1516 * GtkWidget * _add_global_opts(const gcahr * module_name)
1517 *
1518 * Description
1519 *
1520 *
1521 * Return value
1522 * GtkWidget*
1523 */
1524
1525 #ifdef USE_GTKBUILDER
_add_and_check_global_opts(GtkBuilder * gxml,const gchar * mod_name,GtkWidget * submenu,DIALOG_DATA * d)1526 G_MODULE_EXPORT void _add_and_check_global_opts(GtkBuilder *gxml,
1527 #else
1528 G_MODULE_EXPORT void _add_and_check_global_opts(GladeXML *gxml,
1529 #endif
1530 const gchar *mod_name,
1531 GtkWidget *submenu,
1532 DIALOG_DATA *d)
1533 {
1534 GtkWidget *item;
1535 GLOBAL_OPS *ops = NULL;
1536 gint modtype =
1537 main_get_mod_type((gchar *)(is_dialog ? d->mod_name : mod_name));
1538
1539 ops = main_new_globals((gchar *)mod_name);
1540
1541 item = UI_GET_ITEM(gxml, "verse_per_line");
1542
1543 if (mod_name && (modtype == TEXT_TYPE)) {
1544 gtk_widget_show(item);
1545 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1546 ops->verse_per_line);
1547 }
1548
1549 item = UI_GET_ITEM(gxml, "words_of_christ_in_red");
1550
1551 if ((main_check_for_global_option((gchar *)mod_name, "GBFRedLetterWords")) ||
1552 (main_check_for_global_option((gchar *)mod_name, "OSISRedLetterWords"))) {
1553 gtk_widget_show(item);
1554 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1555 ops->words_in_red);
1556 }
1557
1558 item = UI_GET_ITEM(gxml, "strongs_numbers");
1559
1560 if ((main_check_for_global_option((gchar *)mod_name, "GBFStrongs")) ||
1561 (main_check_for_global_option((gchar *)mod_name, "ThMLStrongs")) ||
1562 (main_check_for_global_option((gchar *)mod_name, "OSISStrongs"))) {
1563 gtk_widget_show(item);
1564 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1565 ops->strongs);
1566 }
1567
1568 item = UI_GET_ITEM(gxml, "morphological_tags");
1569
1570 if (main_check_for_global_option((gchar *)mod_name, "GBFMorph") ||
1571 main_check_for_global_option((gchar *)mod_name, "ThMLMorph") || main_check_for_global_option((gchar *)mod_name,
1572 "OSISMorph")) {
1573 gtk_widget_show(item);
1574 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1575 ops->morphs);
1576 }
1577
1578 item = UI_GET_ITEM(gxml, "footnotes");
1579
1580 if (main_check_for_global_option((gchar *)mod_name, "GBFFootnotes") || main_check_for_global_option((gchar *)mod_name,
1581 "ThMLFootnotes") ||
1582 main_check_for_global_option((gchar *)mod_name,
1583 "OSISFootnotes")) {
1584 gtk_widget_show(item);
1585 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1586 ops->footnotes);
1587 }
1588
1589 item = UI_GET_ITEM(gxml, "greek_accents");
1590
1591 if (main_check_for_global_option((gchar *)mod_name, "UTF8GreekAccents")) {
1592 gtk_widget_show(item);
1593 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1594 ops->greekaccents);
1595 }
1596
1597 item = UI_GET_ITEM(gxml, "lemmas");
1598
1599 if (main_check_for_global_option((gchar *)mod_name, "ThMLLemma") || main_check_for_global_option((gchar *)mod_name,
1600 "OSISLemma")) {
1601 gtk_widget_show(item);
1602 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1603 ops->lemmas);
1604 }
1605
1606 item = UI_GET_ITEM(gxml, "cross-references");
1607
1608 if (main_check_for_global_option((gchar *)mod_name, "ThMLScripref") || main_check_for_global_option((gchar *)mod_name,
1609 "OSISScripref")) {
1610 gtk_widget_show(item);
1611 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1612 ops->scripturerefs);
1613 }
1614
1615 item = UI_GET_ITEM(gxml, "hebrew_vowel_points");
1616
1617 if (main_check_for_global_option((gchar *)mod_name, "UTF8HebrewPoints")) {
1618 gtk_widget_show(item);
1619 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1620 ops->hebrewpoints);
1621 }
1622
1623 item = UI_GET_ITEM(gxml, "hebrew_cantillation");
1624
1625 if (main_check_for_global_option((gchar *)mod_name, "UTF8Cantillation")) {
1626 gtk_widget_show(item);
1627 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1628 ops->hebrewcant);
1629 }
1630
1631 item = UI_GET_ITEM(gxml, "headings");
1632
1633 if (main_check_for_global_option((gchar *)mod_name, "ThMLHeadings") || main_check_for_global_option((gchar *)mod_name,
1634 "OSISHeadings")) {
1635 gtk_widget_show(item);
1636 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1637 ops->headings);
1638 }
1639
1640 item = UI_GET_ITEM(gxml, "transliteration");
1641 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1642 ops->transliteration);
1643
1644 item = UI_GET_ITEM(gxml, "variants");
1645
1646 if (main_check_for_global_option((gchar *)mod_name, "ThMLVariants") || main_check_for_global_option((gchar *)mod_name,
1647 "OSISVariants")) {
1648 gtk_widget_show(item);
1649
1650 item = UI_GET_ITEM(gxml, "primary_reading");
1651 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1652 ops->variants_primary);
1653
1654 item = UI_GET_ITEM(gxml, "secondary_reading");
1655 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1656 ops->variants_secondary);
1657
1658 item = UI_GET_ITEM(gxml, "all_readings");
1659 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1660 ops->variants_all);
1661 }
1662
1663 item = UI_GET_ITEM(gxml, "xlit");
1664
1665 if (main_check_for_global_option((gchar *)mod_name, "OSISXlit")) {
1666 gtk_widget_show(item);
1667 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1668 ops->xlit);
1669 }
1670
1671 item = UI_GET_ITEM(gxml, "enumerated");
1672
1673 if (main_check_for_global_option((gchar *)mod_name, "OSISEnum")) {
1674 gtk_widget_show(item);
1675 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1676 ops->enumerated);
1677 }
1678
1679 item = UI_GET_ITEM(gxml, "glosses");
1680
1681 if (main_check_for_global_option((gchar *)mod_name, "OSISGlosses") || main_check_for_global_option((gchar *)mod_name,
1682 "OSISRuby")) {
1683 gtk_widget_show(item);
1684 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1685 ops->glosses);
1686 }
1687
1688 item = UI_GET_ITEM(gxml, "morphseg");
1689
1690 if (main_check_for_global_option((gchar *)mod_name, "OSISMorphSegmentation")) {
1691 gtk_widget_show(item);
1692 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1693 ops->morphseg);
1694 }
1695
1696 item = UI_GET_ITEM(gxml, "image_content");
1697
1698 if (ops->image_content != -1) {
1699 gtk_widget_show(item);
1700 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1701 ops->image_content);
1702 }
1703
1704 item = UI_GET_ITEM(gxml, "respect_font_faces");
1705
1706 if (ops->respect_font_faces != -1) {
1707 gtk_widget_show(item);
1708 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1709 ops->respect_font_faces);
1710 }
1711
1712 item = UI_GET_ITEM(gxml, "commentary_by_chapter");
1713
1714 if ((modtype == COMMENTARY_TYPE) || (modtype == PERCOM_TYPE)) {
1715 gtk_widget_show(item);
1716 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1717 ops->commentary_by_chapter);
1718 }
1719
1720 item = UI_GET_ITEM(gxml, "doublespace");
1721 #ifdef USE_GTK_3
1722 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1723 ops->doublespace);
1724 #else
1725 GTK_CHECK_MENU_ITEM(item)->active = ops->doublespace;
1726 #endif
1727
1728 item = UI_GET_ITEM(gxml, "xrefnotenumbers");
1729
1730 if ((ops->scripturerefs &&
1731 (main_check_for_global_option((gchar *)mod_name, "ThMLScripref") || main_check_for_global_option((gchar *)mod_name,
1732 "OSISScripref"))) ||
1733 (ops->footnotes &&
1734 (main_check_for_global_option((gchar *)mod_name, "ThMLFootnotes") || main_check_for_global_option((gchar *)mod_name,
1735 "OSISFootnotes") ||
1736 main_check_for_global_option((gchar *)mod_name,
1737 "GBFFootnotes")))) {
1738 gtk_widget_show(item);
1739 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
1740 ops->xrefnotenumbers);
1741 } else {
1742 gtk_widget_hide(item);
1743 }
1744
1745 g_free(ops);
1746 }
1747
1748 /******************************************************************************
1749 * Name
1750 * on_view_mod_activate
1751 *
1752 * Synopsis
1753 * #include "gui/menu_popup.h"
1754 *
1755 * void on_view_mod_activate(GtkMenuItem * menuitem, gpointer user_data)
1756 *
1757 * Description
1758 * show a different module
1759 *
1760 * Return value
1761 * void
1762 */
1763
on_view_mod_activate(GtkMenuItem * menuitem,gpointer user_data)1764 static void on_view_mod_activate(GtkMenuItem *menuitem,
1765 gpointer user_data)
1766 {
1767 if (is_dialog)
1768 return;
1769
1770 gchar *module_name = main_module_name_from_description((gchar *)user_data);
1771 gchar *key;
1772
1773 if (module_name && (key = _get_key(menu_mod_name))) {
1774 gchar *url = g_strdup_printf("sword://%s/%s", module_name, key);
1775 main_url_handler(url, TRUE);
1776 g_free(url);
1777 }
1778 g_free(module_name);
1779 g_free(key);
1780 }
1781
1782 /******************************************************************************
1783 * Name
1784 * gui_lookup_bibletext_selection
1785 *
1786 * Synopsis
1787 * #include "gui/bibletext.h"
1788 *
1789 * void gui_lookup_bibletext_selection(GtkMenuItem * menuitem,
1790 gchar * dict_mod_description)
1791 *
1792 * Description
1793 * lookup selection in a dict/lex module
1794 *
1795 * Return value
1796 * void
1797 */
1798
_lookup_selection(GtkMenuItem * menuitem,gchar * dict_mod_description)1799 static void _lookup_selection(GtkMenuItem *menuitem,
1800 gchar *dict_mod_description)
1801 {
1802 gchar *dict_key = NULL;
1803 gchar *mod_name = NULL;
1804 GtkWidget *html = _get_html();
1805
1806 if (!html)
1807 return;
1808 mod_name = main_module_name_from_description(dict_mod_description);
1809 XIPHOS_HTML_COPY_SELECTION(html);
1810 gtk_editable_select_region((GtkEditable *)widgets.entry_dict, 0,
1811 -1);
1812 gtk_editable_paste_clipboard((GtkEditable *)widgets.entry_dict);
1813 gtk_widget_activate(widgets.entry_dict);
1814 dict_key =
1815 g_strdup(gtk_editable_get_chars((GtkEditable *)widgets.entry_dict, 0, -1));
1816
1817 if (dict_key && mod_name) {
1818 main_display_dictionary(mod_name, dict_key);
1819 }
1820 if (dict_key)
1821 g_free(dict_key);
1822 if (mod_name)
1823 g_free(mod_name);
1824 }
1825
1826 /******************************************************************************
1827 * Name
1828 * _create_popup_menu
1829 *
1830 * Synopsis
1831 * #include "gui/menu_popup.h"
1832 *
1833 * GtkWidget * _create_popup_menu ( const gchar * mod_name, DIALOG_DATA * d)
1834 *
1835 * Description
1836 * creates the needed popup and returns it to gui_menu_popup ()
1837 *
1838 * Return value
1839 * GtkWidget*
1840 */
1841
_create_popup_menu(XiphosHtml * html,const gchar * mod_name,DIALOG_DATA * d)1842 static GtkWidget *_create_popup_menu(XiphosHtml *html, const gchar *mod_name,
1843 DIALOG_DATA *d)
1844 {
1845 gchar *glade_file;
1846 #ifdef USE_GTKBUILDER
1847 GtkBuilder *gxml;
1848 #else
1849 GladeXML *gxml;
1850 #endif
1851 const gchar *mname = (is_dialog ? d->mod_name : mod_name);
1852 XI_message(("_create_popup_menu mod_name:%s", mod_name));
1853 if (!mname || !*mname)
1854 return NULL;
1855
1856 #ifdef USE_GTKBUILDER
1857 #if GTK_CHECK_VERSION(3, 14, 0)
1858 glade_file =
1859 gui_general_user_file("xi-menus-popup.gtkbuilder", FALSE);
1860 #else
1861 glade_file =
1862 gui_general_user_file("xi-menus-popup_old.gtkbuilder", FALSE);
1863 #endif
1864 #else
1865 glade_file = gui_general_user_file("xi-menus.glade", FALSE);
1866 #endif
1867 g_return_val_if_fail((glade_file != NULL), NULL);
1868
1869 #ifdef USE_GTKBUILDER
1870 gxml = gtk_builder_new();
1871 gtk_builder_add_from_file(gxml, glade_file, NULL);
1872 #else
1873 gxml = glade_xml_new(glade_file, "menu_popup", NULL);
1874 #endif
1875 g_free(glade_file);
1876 g_return_val_if_fail((gxml != NULL), NULL);
1877
1878 GtkWidget *menu = UI_GET_ITEM(gxml, "menu_popup");
1879 GtkWidget *bookmark = UI_GET_ITEM(gxml, "bookmark");
1880 GtkWidget *open = UI_GET_ITEM(gxml, "open_module2");
1881 GtkWidget *export_ = UI_GET_ITEM(gxml, "export_passage");
1882 GtkWidget *close = UI_GET_ITEM(gxml, "close");
1883 GtkWidget *note = UI_GET_ITEM(gxml, "note");
1884 GtkWidget *mark_verse = UI_GET_ITEM(gxml, "mark_verse");
1885 GtkWidget *open_edit = UI_GET_ITEM(gxml, "open_in_editor");
1886 GtkWidget *mod_opt_sub = UI_GET_ITEM(gxml, "module_options1_menu");
1887 GtkWidget *lookup = UI_GET_ITEM(gxml, "lookup_selection1");
1888 GtkWidget *lookup_sub =
1889 UI_GET_ITEM(gxml, "lookup_selection1_menu");
1890 GtkWidget *unlock = UI_GET_ITEM(gxml, "unlock_this_module");
1891 GtkWidget *book_heading =
1892 UI_GET_ITEM(gxml, "display_book_heading");
1893 GtkWidget *chapter_heading =
1894 UI_GET_ITEM(gxml, "display_chapter_heading");
1895 GtkWidget *rename_percomm = UI_GET_ITEM(gxml, "rename_perscomm");
1896 GtkWidget *dump_percomm = UI_GET_ITEM(gxml, "dump_perscomm");
1897
1898 GtkWidget *open_sub = gtk_menu_new();
1899 GtkWidget *note_sub = gtk_menu_new();
1900
1901 gtk_widget_hide(unlock);
1902 gtk_widget_hide(book_heading);
1903 gtk_widget_hide(export_);
1904 gtk_widget_hide(chapter_heading);
1905 gtk_widget_hide(rename_percomm);
1906 gtk_widget_hide(dump_percomm);
1907 gtk_widget_hide(note);
1908 gtk_widget_hide(open_edit);
1909 gtk_widget_hide(mark_verse);
1910 gtk_widget_hide(close); /* FIXME: hide until connected to dialog close */
1911
1912 if (is_dialog) {
1913 gtk_widget_hide(open);
1914 gtk_widget_hide(bookmark);
1915 gtk_widget_hide(export_);
1916 } else {
1917 gtk_widget_hide(close);
1918 gtk_menu_item_set_submenu(GTK_MENU_ITEM(open), open_sub);
1919 gui_add_mods_2_gtk_menu(_get_type_mod_list(), open_sub,
1920 (GCallback)on_view_mod_activate);
1921
1922 /* unlock from main window only */
1923 if (main_has_cipher_tag((gchar *)mod_name))
1924 gtk_widget_show(unlock);
1925 }
1926
1927 switch (main_get_mod_type((gchar *)mname)) {
1928 case TEXT_TYPE:
1929 gtk_widget_show(export_);
1930 if (is_dialog)
1931 break;
1932 gtk_widget_show(note);
1933 gtk_widget_show(mark_verse);
1934 gtk_menu_item_set_submenu(GTK_MENU_ITEM(note), note_sub);
1935 gui_add_mods_2_gtk_menu(PERCOMM_LIST, note_sub, (GCallback)
1936 on_edit_percomm_activate);
1937 break;
1938
1939 case COMMENTARY_TYPE:
1940 gtk_widget_show(export_);
1941 gtk_widget_show(book_heading);
1942 gtk_widget_show(chapter_heading);
1943 break;
1944
1945 case PERCOM_TYPE:
1946 gtk_widget_show(export_);
1947 gtk_widget_show(open_edit);
1948 g_signal_connect(G_OBJECT(open_edit),
1949 "activate",
1950 G_CALLBACK(on_edit_percomm_activate),
1951 (gchar *)(is_dialog ? d->mod_name : mod_name));
1952
1953 gtk_widget_show(rename_percomm);
1954 gtk_widget_show(dump_percomm);
1955 break;
1956
1957 case DICTIONARY_TYPE:
1958 break;
1959
1960 case BOOK_TYPE:
1961 break;
1962
1963 case PRAYERLIST_TYPE:
1964 gtk_widget_show(open_edit);
1965 g_signal_connect(G_OBJECT(open_edit),
1966 "activate",
1967 G_CALLBACK(on_edit_prayerlist_activate),
1968 (gchar *)(is_dialog ? d->mod_name : mod_name));
1969 break;
1970 }
1971
1972 gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup), lookup_sub);
1973
1974 gui_add_mods_2_gtk_menu(DICT_DESC_LIST, lookup_sub,
1975 (GCallback)_lookup_selection);
1976
1977 /* = glade_xml_get_widget (gxml, ""); */
1978 _add_and_check_global_opts(gxml,
1979 (char *)(is_dialog ? d->mod_name : mod_name), mod_opt_sub, d);
1980 /* connect signals and data */
1981 #ifdef USE_GTKBUILDER
1982 gtk_builder_connect_signals(gxml, html);
1983 /*gtk_builder_connect_signals_full
1984 (gxml, (GtkBuilderConnectFunc)gui_glade_signal_connect_func, html); */
1985 #else
1986 glade_xml_signal_autoconnect_full(gxml, (GladeXMLConnectFunc)gui_glade_signal_connect_func,
1987 html);
1988 #endif
1989
1990 return menu;
1991 }
1992
1993 /******************************************************************************
1994 * Name
1995 * gui_menu_popup
1996 *
1997 * Synopsis
1998 * #include "gui/menu_popup.h"
1999 *
2000 * void gui_menu_popup (const gchar * mod_name, DIALOG_DATA * d)
2001 *
2002 * Description
2003 * determens if a main window or dialog popup is needed
2004 * and calls _create_popup_menu() to create the menu and
2005 * then pops the menu up
2006 *
2007 * Return value
2008 * void
2009 */
2010
gui_menu_popup(XiphosHtml * html,const gchar * mod_name,DIALOG_DATA * d)2011 void gui_menu_popup(XiphosHtml *html, const gchar *mod_name,
2012 DIALOG_DATA *d)
2013 {
2014 GtkWidget *menu;
2015
2016 if (d) {
2017 dialog = d;
2018 menu_mod_name = NULL; //(gchar*) mod_name;
2019 is_dialog = TRUE;
2020 } else if (mod_name) {
2021 menu_mod_name = (gchar *)mod_name;
2022 dialog = NULL;
2023 is_dialog = FALSE;
2024 } else
2025 return;
2026
2027 menu = _create_popup_menu(html, mod_name, d);
2028 if (menu)
2029 #if GTK_CHECK_VERSION(3, 22, 0)
2030 gtk_menu_popup_at_pointer((GtkMenu *)menu, NULL);
2031 #else
2032 gtk_menu_popup((GtkMenu *)menu, NULL, NULL, NULL, NULL, 2,
2033 gtk_get_current_event_time());
2034 #endif
2035 else
2036 gui_generic_warning(_("No module in this pane."));
2037 }
2038