~ubuntu-branches/ubuntu/trusty/xiphos/trusty

« back to all changes in this revision

Viewing changes to src/main/parallel_view.cc

  • Committer: Bazaar Package Importer
  • Author(s): Dmitrijs Ledkovs, Jonathan Marsden, Dmitrijs Ledkovs
  • Date: 2010-11-25 21:26:48 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20101125212648-mc64wvs0nw3xp7bx
Tags: 3.1.4-1
[ Jonathan Marsden ]
* New upstream release 3.1.4
* Removed debian/patch/* since the one patch was included upstream.
* Bumped Standards-Version to 3.9.1 (no changes required).
* debian/README.Debian: Corrected spelling and reworded for clarity.
* debian/control: Add Jonathan Marsden back into Uploaders.

[ Dmitrijs Ledkovs ]
* Added local options dpkg-source to unapply patches and fail on
  upstream source changes (ignoring false positives).
* Added bzr-builddeb hook to generate source-format before build. If you
  are not using bzr-builddeb, you must run "./debian/rules clean" before
  building.
* patches/xul-2.0.patch: bump UPPER_RANGE to allow running against xul20.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Xiphos Bible Study Tool
3
3
 * parallel_view.cc - support for displaying multiple modules
4
4
 *
5
 
 * Copyright (C) 2004-2009 Xiphos Developer Team
 
5
 * Copyright (C) 2004-2010 Xiphos Developer Team
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
25
25
 
26
26
#include <gtk/gtk.h>
27
27
 
28
 
#ifdef USE_GTKMOZEMBED
29
 
#ifdef WIN32
30
 
#include "geckowin/gecko-html.h"
31
 
#else
32
 
#include "gecko/gecko-html.h"
33
 
#endif
34
 
#else
35
 
#ifdef __cplusplus
36
 
extern "C" {
37
 
#include <gtkhtml/gtkhtml.h>
38
 
}
39
 
#endif  /* __cplusplus */
40
 
#include "gui/html.h"
41
 
#endif  /* USE_GTKMOZEMBED */
42
 
 
43
28
#include "backend/sword_main.hh"
44
29
 
45
30
#include "gui/parallel_view.h"
59
44
 
60
45
#include "gui/debug_glib_null.h"
61
46
 
62
 
#define HTML_START "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"><STYLE type=\"text/css\"><!--A { text-decoration:none }--></STYLE></head>"
 
47
#define HTML_START "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\"><!--A { text-decoration:none }--></style></head>"
63
48
 
64
49
extern GtkWidget *entrycbIntBook;
65
50
extern GtkWidget *sbIntChapter;
69
54
/******************************************************************************
70
55
 * static
71
56
 */
72
 
#ifndef USE_GTKMOZEMBED
73
 
static GtkHTMLStreamStatus status1;
74
 
static GtkHTMLStream *htmlstream;
75
 
#endif
76
 
static gboolean parallel1;
77
 
static gboolean parallel2;
78
 
static gboolean parallel3;
79
 
static gboolean parallel4;
80
 
static gboolean parallel5;
81
57
 
82
58
BackEnd *backend_p;
83
59
 
492
468
 
493
469
 
494
470
        item = gtk_check_menu_item_new_with_label(_("Morpheme Segmentation"));
 
471
#if 0
495
472
        gtk_widget_show(item);
 
473
#else
 
474
        gtk_widget_hide(item);
 
475
#endif
496
476
        gtk_container_add(GTK_CONTAINER(menu), item);
497
477
 
498
478
        GTK_CHECK_MENU_ITEM(item)->active = settings.parallel_segmentation;
579
559
 
580
560
void main_check_parallel_modules(void)
581
561
{
582
 
        if (settings.parallel1Module)
583
 
                parallel1 =
584
 
                    main_is_module(settings.parallel1Module);
585
 
        else
586
 
                parallel1 = FALSE;
587
 
 
588
 
        if (settings.parallel2Module)
589
 
                parallel2 =
590
 
                    main_is_module(settings.parallel2Module);
591
 
        else
592
 
                parallel2 = FALSE;
593
 
 
594
 
        if (settings.parallel3Module)
595
 
                parallel3 =
596
 
                    main_is_module(settings.parallel3Module);
597
 
        else
598
 
                parallel3 = FALSE;
599
 
 
600
 
        if (settings.parallel4Module)
601
 
                parallel4 =
602
 
                    main_is_module(settings.parallel4Module);
603
 
        else
604
 
                parallel4 = FALSE;
605
 
 
606
 
        if (settings.parallel5Module)
607
 
                parallel5 =
608
 
                    main_is_module(settings.parallel5Module);
609
 
        else
610
 
                parallel5 = FALSE;
611
 
 
 
562
        /* i don't know what it's good for, but we'll keep it for now. */
 
563
        return;
612
564
}
613
565
 
614
566
 
615
 
/******************************************************************************
616
 
 * Name
617
 
 *   gui_change_int1_mod
618
 
 *
619
 
 * Synopsis
620
 
 *   #include "main/parallel_view.h
621
 
 *
622
 
 *   void gui_changeint1_mod(gchar * mod_name)
623
 
 *
624
 
 * Description
625
 
 *
626
 
 *
627
 
 * Return value
628
 
 *   void
629
 
 */
630
 
 
631
 
void main_change_parallel_module(GSParallel parallel, gchar * mod_name)
 
567
void get_heading(SWBuf &text, BackEnd *p, gint modidx)
632
568
{
633
 
        if (!mod_name)
634
 
                return;
635
 
        switch (parallel) {
636
 
        case PARALLEL1:
637
 
                xml_set_value("Xiphos", "modules", "int1",
638
 
                              mod_name);
639
 
                settings.parallel1Module =
640
 
                    xml_get_value("modules", "int1");
641
 
                parallel1 =
642
 
                    main_is_module(settings.parallel1Module);
643
 
                break;
644
 
        case PARALLEL2:
645
 
                xml_set_value("Xiphos", "modules", "int2",
646
 
                              mod_name);
647
 
                settings.parallel2Module =
648
 
                    xml_get_value("modules", "int2");
649
 
                parallel2 =
650
 
                    main_is_module(settings.parallel2Module);
651
 
                break;
652
 
        case PARALLEL3:
653
 
                xml_set_value("Xiphos", "modules", "int3",
654
 
                              mod_name);
655
 
                settings.parallel3Module =
656
 
                    xml_get_value("modules", "int3");
657
 
                parallel3 =
658
 
                    main_is_module(settings.parallel3Module);
659
 
                break;
660
 
        case PARALLEL4:
661
 
                xml_set_value("Xiphos", "modules", "int4",
662
 
                              mod_name);
663
 
                settings.parallel4Module =
664
 
                    xml_get_value("modules", "int4");
665
 
                parallel4 =
666
 
                    main_is_module(settings.parallel4Module);
667
 
                break;
668
 
        case PARALLEL5:
669
 
                xml_set_value("Xiphos", "modules", "int5",
670
 
                              mod_name);
671
 
                settings.parallel5Module =
672
 
                    xml_get_value("modules", "int5");
673
 
                parallel5 =
674
 
                    main_is_module(settings.parallel5Module);
675
 
                break;
676
 
        default:
677
 
                return;
678
 
                break;
 
569
        const gchar *preverse, *preverse2, *buf;
 
570
        gchar heading[8];
 
571
 
 
572
        int x = 0;
 
573
        sprintf(heading, "%d", x);
 
574
        while ((preverse = p->get_entry_attribute("Heading", "Preverse",
 
575
                                                  heading)) != NULL) {
 
576
                preverse2 = p->render_this_text(
 
577
                               settings.parallel_list[modidx], preverse);
 
578
                buf = g_strdup_printf("<br/><b>%s</b><br/><br/>", preverse2);
 
579
 
 
580
                text += buf;
 
581
 
 
582
                g_free((gchar *)preverse2); 
 
583
                g_free((gchar *)preverse);
 
584
                g_free((gchar *)buf);
 
585
                ++x;
 
586
                sprintf(heading, "%d", x);
679
587
        }
680
 
        if (settings.dockedInt)
681
 
                main_update_parallel_page();
682
 
        else
683
 
                main_update_parallel_page_detached();
684
588
}
685
589
 
686
 
#ifdef USE_GTKMOZEMBED
687
590
/******************************************************************************
688
591
 * Name
689
592
 *   gui_update_parallel_page
704
607
{
705
608
        gchar tmpBuf[256];
706
609
        const gchar *rowcolor;
707
 
        gchar *font_size_tmp = NULL, *font_size = NULL;
708
 
        gchar *utf8str, *mod_name, *font_name = NULL;
709
 
        gint utf8len, i, j;
710
 
        gboolean use_gtkhtml_font;
 
610
        gchar *utf8str, *mod_name;
 
611
        gint modidx;
711
612
        gboolean is_rtol = FALSE;
712
 
        gchar *buf;
713
 
        gchar *file = NULL;
714
 
        gchar *data = NULL;
715
 
 
716
 
 
717
 
        if (!GTK_WIDGET_REALIZED(GTK_WIDGET(widgets.html_parallel))) return ;
718
 
        GeckoHtml *html = GECKO_HTML(widgets.html_parallel);
719
 
        gecko_html_open_stream(html,"text/html");
 
613
        GString *data;
 
614
        MOD_FONT *mf;
 
615
        SWBuf text;
720
616
 
721
617
        settings.cvparallel = settings.currentverse;
722
618
 
723
 
        if (settings.havebible) {
724
 
                sprintf(tmpBuf, HTML_START
725
 
                        "<body bgcolor=\"%s\" text=\"%s\" link=\"%s\"><table>",
726
 
                        settings.bible_bg_color,
727
 
                        settings.bible_text_color, settings.link_color);
728
 
 
729
 
                utf8len = strlen(tmpBuf);
730
 
                if (utf8len) {
731
 
                        data = g_strconcat(tmpBuf,NULL);
732
 
                }
733
 
 
734
 
                for (i = 0, j = 0; i < 5; i++) {
735
 
                        mod_name = NULL;
736
 
                        switch (i) {
737
 
                        case 0:
738
 
                                if (parallel1)
739
 
                                        mod_name =
740
 
                                            settings.parallel1Module;
741
 
                                else
742
 
                                        mod_name = NULL;
743
 
                                break;
744
 
                        case 1:
745
 
                                if (parallel2)
746
 
                                        mod_name =
747
 
                                            settings.parallel2Module;
748
 
                                else
749
 
                                        mod_name = NULL;
750
 
                                break;
751
 
                        case 2:
752
 
                                if (parallel3)
753
 
                                        mod_name =
754
 
                                            settings.parallel3Module;
755
 
                                else
756
 
                                        mod_name = NULL;
757
 
                                break;
758
 
                        case 3:
759
 
                                if (parallel4)
760
 
                                        mod_name =
761
 
                                            settings.parallel4Module;
762
 
                                else
763
 
                                        mod_name = NULL;
764
 
                                break;
765
 
                        case 4:
766
 
                                if (parallel5)
767
 
                                        mod_name =
768
 
                                            settings.parallel5Module;
769
 
                                else
770
 
                                        mod_name = NULL;
771
 
                                break;
772
 
                        }
773
 
                        GS_message(("mod_name = %s",mod_name));
774
 
                        if (!mod_name)
775
 
                                continue;
776
 
 
777
 
                        ++j;
 
619
        sprintf(tmpBuf, HTML_START
 
620
                "<body bgcolor=\"%s\" text=\"%s\" link=\"%s\"><table>",
 
621
                settings.bible_bg_color,
 
622
                settings.bible_text_color, settings.link_color);
 
623
        data = g_string_new(tmpBuf);
 
624
 
 
625
        if (settings.parallel_list) {
 
626
                for (modidx = 0;
 
627
                     (mod_name = settings.parallel_list[modidx]);
 
628
                     modidx++) {
 
629
                        mf = get_font(mod_name);
 
630
 
778
631
                        is_rtol = main_is_mod_rtol(mod_name);
779
632
 
780
 
                        file = g_strdup_printf("%s/fonts.conf", settings.gSwordDir);
781
 
                        font_name = get_conf_file_item(file, mod_name, "Font");
782
 
                        if (!font_name || !strcmp(font_name, "none")) {
783
 
                                font_name =
784
 
                                    main_get_mod_config_entry(mod_name, "Font");
785
 
                                if (!font_name)
786
 
                                        font_name = g_strdup("none");
787
 
                        }
788
 
                        if (strlen(font_name) < 2) {
789
 
                                use_gtkhtml_font = TRUE;
790
 
                        } else {
791
 
                                if (!strncmp(font_name, "none", 4)) {
792
 
                                        use_gtkhtml_font = TRUE;
793
 
                                } else {
794
 
                                        use_gtkhtml_font = FALSE;
795
 
                                }
796
 
                        }
797
 
 
798
 
                        font_size_tmp = get_conf_file_item(file, mod_name, "Fontsize");
799
 
                        g_free(file);
800
 
                        if (!font_size_tmp) {
801
 
                                font_size_tmp =
802
 
                                    main_get_mod_config_entry(mod_name, "Fontsize");
803
 
                        }
804
 
 
805
 
                        font_size =
806
 
                            g_strdup_printf("%+d",
807
 
                                            (font_size_tmp ? atoi(font_size_tmp) : 0)
808
 
                                             + settings.base_font_size);
809
 
 
810
 
                        if (j == 0 || j == 2 || j == 4)
 
633
                        if (modidx % 2 == 1)    /* alternating background color */
811
634
                                rowcolor = "#F1F1F1";
812
635
                        else
813
636
                                rowcolor = settings.bible_bg_color;
814
637
 
815
 
                        if (j == 0) {
 
638
                        if (modidx == 0) {
816
639
                                sprintf(tmpBuf,
817
640
                                        "<tr><td><i><font color=\"%s\" size=\"%d\">[%s]</font></i></td></tr>",
818
641
                                        settings.bible_verse_num_color,
819
642
                                        settings.verse_num_font_size + settings.base_font_size,
820
643
                                        settings.currentverse);
821
 
 
822
 
                                utf8len = strlen(tmpBuf);
823
 
                                if (utf8len) {
824
 
                                        data = g_strconcat(data, tmpBuf, NULL);
825
 
                                }
 
644
                                g_string_append(data, tmpBuf);
826
645
                        }
827
646
 
828
647
                        sprintf(tmpBuf,
829
 
                                "<tr bgcolor=\"%s\"><td><b><a href=\"xiphos.url?action=showModInfo&value=%s&module=%s\"><font color=\"%s\" size=\"%+d\"> [%s]</font></a></b>",
 
648
                                "<tr bgcolor=\"%s\"><td><b><a href=\"passagestudy.jsp?action=showModInfo&value=%s&module=%s\"><font color=\"%s\" size=\"%+d\"> [%s]</font></a></b>",
830
649
                                rowcolor,
831
650
                                main_get_module_description(mod_name),
832
651
                                mod_name,
833
652
                                settings.bible_verse_num_color,
834
653
                                settings.verse_num_font_size + settings.base_font_size,
835
654
                                mod_name);
836
 
 
837
 
                        utf8len = strlen(tmpBuf);
838
 
                        if (utf8len) {
839
 
                                        data = g_strconcat(data, tmpBuf, NULL);
840
 
                        }
841
 
 
842
 
                        if (use_gtkhtml_font)
 
655
                        g_string_append(data, tmpBuf);
 
656
 
 
657
                        if ((strlen(mf->old_font) < 2) ||
 
658
                            !strncmp(mf->old_font, "none", 4))
843
659
                                sprintf(tmpBuf, "<font size=\"%s\">",
844
 
                                        font_size);
 
660
                                        mf->old_font_size);
845
661
                        else
846
662
                                sprintf(tmpBuf,
847
663
                                        "<font face=\"%s\" size=\"%s\">",
848
 
                                        font_name, font_size);
849
 
 
850
 
 
851
 
                        utf8len = strlen(tmpBuf);
852
 
                        if (utf8len) {
853
 
                                data = g_strconcat(data, tmpBuf, NULL);
854
 
                        }
855
 
 
856
 
                        utf8str =
857
 
                            backend_p->get_render_text(mod_name,
858
 
                                                        settings.
859
 
                                                        currentverse);
860
 
                        if (is_rtol) {
861
 
                                buf = g_strdup_printf(
862
 
                                        "%s","<br><DIV ALIGN=right>");
863
 
                                if (strlen(buf)) {
864
 
                                        data = g_strconcat(data, buf, NULL);
865
 
                                        free(buf);
866
 
                                }
867
 
                        }
868
 
                        if (strlen(utf8str)) {
869
 
                                data = g_strconcat(data, utf8str, NULL);
870
 
                                free(utf8str);
871
 
                        }
872
 
 
873
 
                        if (is_rtol) {
874
 
                                buf = g_strdup_printf(
875
 
                                        "%s","</DIV><br>");
876
 
                                if (strlen(buf)) {
877
 
                                        data = g_strconcat(data, buf, NULL);
878
 
                                        free(buf);
879
 
                                }
880
 
                        }
881
 
                        sprintf(tmpBuf,
882
 
                                "</font><small>[<a href=\"xiphos.url?action=showParallel&"
883
 
                                "type=swap&value=%s\">%s</a>]</small></td></tr>",
884
 
                                mod_name,_("view context"));
885
 
 
886
 
                        utf8len = strlen(tmpBuf);
887
 
                        if (utf8len) {
888
 
                                data = g_strconcat(data, tmpBuf, NULL);
889
 
                        }
890
 
                }
891
 
 
892
 
                sprintf(tmpBuf, "</table></body></html>");
893
 
 
894
 
                utf8len = strlen(tmpBuf);
895
 
                if (utf8len) {
896
 
                        data = g_strconcat(data, tmpBuf, NULL);
897
 
                        gecko_html_write(html,data,-1);
898
 
                }
899
 
        }
900
 
        gecko_html_close(html);
901
 
        if (data)
902
 
                g_free(data);
903
 
        if (font_name)
904
 
                free(font_name);
905
 
        if (font_size)
906
 
                free(font_size);
907
 
        if (font_size_tmp)
908
 
                free(font_size_tmp);
909
 
}
910
 
 
911
 
#else
912
 
/******************************************************************************
913
 
 * Name
914
 
 *   gui_update_parallel_page
915
 
 *
916
 
 * Synopsis
917
 
 *   #include "main/parallel_view.h
918
 
 *
919
 
 *   void gui_update_parallel_page(void)
920
 
 *
921
 
 * Description
922
 
 *
923
 
 *
924
 
 * Return value
925
 
 *   void
926
 
 */
927
 
 
928
 
void main_update_parallel_page(void)
929
 
{
930
 
        gchar tmpBuf[256], *rowcolor;
931
 
        gchar *font_size_tmp = NULL, *font_size = NULL;
932
 
        gchar *utf8str, *mod_name, *font_name = NULL;
933
 
        gint utf8len, i, j;
934
 
        gboolean was_editable, use_gtkhtml_font;
935
 
        gboolean is_rtol = FALSE;
936
 
        gchar *buf;
937
 
        gchar *file = NULL;
938
 
 
939
 
        settings.cvparallel = settings.currentverse;
940
 
 
941
 
        if (settings.havebible) {
942
 
                /* setup gtkhtml widget */
943
 
                GtkHTML *html = GTK_HTML(widgets.html_parallel);
944
 
                was_editable = gtk_html_get_editable(html);
945
 
                if (was_editable)
946
 
                        gtk_html_set_editable(html, FALSE);
947
 
                htmlstream =
948
 
                    gtk_html_begin_content(html,
949
 
                                           (gchar *)"text/html; charset=utf-8");
950
 
                sprintf(tmpBuf,
951
 
                        "<html><body bgcolor=\"%s\" text=\"%s\" link=\"%s\"><table>",
952
 
                        settings.bible_bg_color,
953
 
                        settings.bible_text_color, settings.link_color);
954
 
                /*utf8str =
955
 
                    e_utf8_from_gtk_string(widgets.html_parallel,
956
 
                                           tmpBuf);*/
957
 
                utf8len = strlen(tmpBuf);
958
 
                if (utf8len) {
959
 
                        gtk_html_write(GTK_HTML(html), htmlstream,
960
 
                                       tmpBuf, utf8len);
961
 
                }
962
 
 
963
 
                for (i = 0, j = 0; i < 5; i++) {
964
 
                        mod_name = NULL;
965
 
                        switch (i) {
966
 
                        case 0:
967
 
                                if (parallel1)
968
 
                                        mod_name =
969
 
                                            settings.parallel1Module;
970
 
                                else
971
 
                                        mod_name = NULL;
972
 
                                break;
973
 
                        case 1:
974
 
                                if (parallel2)
975
 
                                        mod_name =
976
 
                                            settings.parallel2Module;
977
 
                                else
978
 
                                        mod_name = NULL;
979
 
                                break;
980
 
                        case 2:
981
 
                                if (parallel3)
982
 
                                        mod_name =
983
 
                                            settings.parallel3Module;
984
 
                                else
985
 
                                        mod_name = NULL;
986
 
                                break;
987
 
                        case 3:
988
 
                                if (parallel4)
989
 
                                        mod_name =
990
 
                                            settings.parallel4Module;
991
 
                                else
992
 
                                        mod_name = NULL;
993
 
                                break;
994
 
                        case 4:
995
 
                                if (parallel5)
996
 
                                        mod_name =
997
 
                                            settings.parallel5Module;
998
 
                                else
999
 
                                        mod_name = NULL;
1000
 
                                break;
1001
 
                        }
1002
 
                        if (!mod_name)
1003
 
                                continue;
1004
 
                        GS_message(("mod_name = %s", mod_name));
1005
 
 
1006
 
                        ++j;
1007
 
                        is_rtol = main_is_mod_rtol(mod_name);
1008
 
                        //font_name = get_module_font_name(mod_name);
1009
 
                        file = g_strdup_printf("%s/fonts.conf", settings.gSwordDir);
1010
 
                        font_name = get_conf_file_item(file, mod_name, "Font");
1011
 
                        if (!font_name || !strcmp(font_name, "none")) {
1012
 
                                font_name =
1013
 
                                    main_get_mod_config_entry(mod_name, "Font");
1014
 
                                if (!font_name)
1015
 
                                        font_name = g_strdup("none");
1016
 
                        }
1017
 
                        if (strlen(font_name) < 2) {
1018
 
                                use_gtkhtml_font = TRUE;
1019
 
                                GS_message(("use_gtkhtml_font = TRUE"));
1020
 
                        } else {
1021
 
                                if (!strncmp(font_name, "none", 4)) {
1022
 
                                        use_gtkhtml_font = TRUE;
1023
 
                                        GS_message(("use_gtkhtml_font = TRUE"));
1024
 
                                } else {
1025
 
                                        use_gtkhtml_font = FALSE;
1026
 
                                        GS_message(("use_gtkhtml_font = FALSE"));
1027
 
                                }
1028
 
                        }
1029
 
 
1030
 
                        font_size_tmp = get_conf_file_item(file, mod_name, "Fontsize");
1031
 
                        g_free(file);
1032
 
                        if (!font_size_tmp) {
1033
 
                                font_size_tmp =
1034
 
                                    main_get_mod_config_entry(mod_name, "Fontsize");
1035
 
                        }
1036
 
 
1037
 
                        font_size =
1038
 
                            g_strdup_printf("%+d",
1039
 
                                            (font_size_tmp ? atoi(font_size_tmp) : 0)
1040
 
                                             + settings.base_font_size);
1041
 
 
1042
 
                        if (j == 0 || j == 2 || j == 4)
1043
 
                                rowcolor = (gchar *)"#F1F1F1";
1044
 
                        else
1045
 
                                rowcolor = settings.bible_bg_color;
1046
 
 
1047
 
                        if (j == 0) {
1048
 
                                sprintf(tmpBuf,
1049
 
                                        "<tr><td><i><font color=\"%s\" size=\"%d\">[%s]</font></i></td></tr>",
1050
 
                                        settings.bible_verse_num_color,
1051
 
                                        settings.verse_num_font_size + settings.base_font_size,
1052
 
                                        settings.currentverse);
1053
 
 
1054
 
                                utf8len = strlen(tmpBuf);
1055
 
                                if (utf8len) {
1056
 
                                        gtk_html_write(GTK_HTML(html),
1057
 
                                                       htmlstream,
1058
 
                                                       tmpBuf,
1059
 
                                                       utf8len);
1060
 
                                }
1061
 
                        }
1062
 
 
1063
 
                        sprintf(tmpBuf,
1064
 
                                "<tr bgcolor=\"%s\"><td><b><a href=\"xiphos.url?action=showModInfo&value=%s&module=%s\"><font color=\"%s\" size=\"%+d\"> [%s]</font></a></b>",
1065
 
                                rowcolor,
1066
 
                                main_get_module_description(mod_name),
1067
 
                                mod_name,
1068
 
                                settings.bible_verse_num_color,
1069
 
                                settings.verse_num_font_size + settings.base_font_size,
1070
 
                                mod_name);
1071
 
 
1072
 
                        utf8len = strlen(tmpBuf);
1073
 
                        if (utf8len) {
1074
 
                                gtk_html_write(GTK_HTML(html),
1075
 
                                               htmlstream, tmpBuf,
1076
 
                                               utf8len);
1077
 
                        }
1078
 
 
1079
 
                        if (use_gtkhtml_font)
1080
 
                                sprintf(tmpBuf, "<font size=\"%s\">",
1081
 
                                        font_size);
1082
 
                        else
1083
 
                                sprintf(tmpBuf,
1084
 
                                        "<font face=\"%s\"size=\"%s\">",
1085
 
                                        font_name, font_size);
1086
 
 
1087
 
 
1088
 
                        utf8len = strlen(tmpBuf);
1089
 
                        if (utf8len) {
1090
 
                                gtk_html_write(GTK_HTML(html),
1091
 
                                               htmlstream, tmpBuf,
1092
 
                                               utf8len);
1093
 
                        }
1094
 
 
1095
 
                        utf8str =
1096
 
                            backend_p->get_render_text(mod_name,
1097
 
                                                        settings.
1098
 
                                                        currentverse);
1099
 
/*#ifdef  DEBUG
1100
 
                        if (!strcmp(mod_name,"KJV2006"))
1101
 
                                g_message("\nmod: %s\nRAW: %s\nRENDERED: %s", mod_name,
1102
 
                                                backend_p->get_raw_text(mod_name,
1103
 
                                                                settings.currentverse),utf8str);
1104
 
#endif
1105
 
*/
1106
 
                        if (is_rtol) {
1107
 
                                buf = g_strdup_printf(
1108
 
                                        "%s","<br><DIV ALIGN=right>");
1109
 
                                if (strlen(buf)) {
1110
 
                                        gtk_html_write(GTK_HTML(html),
1111
 
                                                       htmlstream, buf,
1112
 
                                                       strlen(buf));
1113
 
                                        free(buf);
1114
 
                                }
1115
 
                        }
1116
 
                        if (strlen(utf8str)) {
1117
 
                                gtk_html_write(GTK_HTML(html),
1118
 
                                               htmlstream, utf8str,
1119
 
                                               strlen(utf8str));
1120
 
                                free(utf8str);
1121
 
                        }
1122
 
 
1123
 
                        if (is_rtol) {
1124
 
                                buf = g_strdup_printf(
1125
 
                                        "%s","</DIV><br>");
1126
 
                                if (strlen(buf)) {
1127
 
                                        gtk_html_write(GTK_HTML(html),
1128
 
                                                       htmlstream, buf,
1129
 
                                                       strlen(buf));
1130
 
                                        free(buf);
1131
 
                                }
1132
 
                        }
1133
 
                        sprintf(tmpBuf,
1134
 
                                "</font><small>[<a href=\"xiphos.url?action=showParallel&"
1135
 
                                "type=swap&value=%s\">%s</a>]</small></td></tr>",
1136
 
                                mod_name,_("view context"));
1137
 
 
1138
 
                        utf8len = strlen(tmpBuf);
1139
 
                        if (utf8len) {
1140
 
                                gtk_html_write(GTK_HTML(html),
1141
 
                                               htmlstream, tmpBuf,
1142
 
                                               utf8len);
1143
 
                        }
1144
 
                        if (font_name)
1145
 
                                free(font_name);
1146
 
                        if (font_size)
1147
 
                                free(font_size);
1148
 
                        if (font_size_tmp)
1149
 
                                free(font_size_tmp);
1150
 
 
1151
 
                }
1152
 
 
1153
 
                sprintf(tmpBuf, "</table></body></html>");
1154
 
 
1155
 
                utf8len = strlen(tmpBuf);
1156
 
                if (utf8len) {
1157
 
                        gtk_html_write(GTK_HTML(html), htmlstream,
1158
 
                                       tmpBuf, utf8len);
1159
 
                }
1160
 
 
1161
 
                gtk_html_end(GTK_HTML(html), htmlstream, status1);
1162
 
                gtk_html_set_editable(html, was_editable);
1163
 
        }
1164
 
}
1165
 
 
1166
 
#endif
1167
 
 
1168
 
/******************************************************************************
1169
 
 * Name
1170
 
 *   int_display
1171
 
 *
1172
 
 * Synopsis
1173
 
 *   #include "main/parallel_view.h
1174
 
 *
1175
 
 *   void int_display(SWBuf& text, gchar *key, char *mod_name[])
 
664
                                        mf->old_font, mf->old_font_size);
 
665
                        free_font(mf);
 
666
                        g_string_append(data, tmpBuf);
 
667
 
 
668
                        if (is_rtol)
 
669
                                g_string_append(data, "<br/><div align=right>");
 
670
 
 
671
                        backend_p->set_module_key(settings.parallel_list[modidx], settings.cvparallel);
 
672
                        text = "";
 
673
                        get_heading(text, backend_p, modidx);
 
674
                        g_string_append(data, text.c_str());
 
675
 
 
676
                        utf8str = backend_p->get_render_text(mod_name, settings.currentverse);
 
677
                        if (utf8str) {
 
678
                                g_string_append(data, utf8str);
 
679
                                g_free(utf8str);
 
680
                        }
 
681
 
 
682
                        if (is_rtol)
 
683
                                g_string_append(data, "</div><br/>");
 
684
 
 
685
                        sprintf(tmpBuf,
 
686
                                "</font><small>[<a href=\"passagestudy.jsp?action=showParallel&"
 
687
                                "type=swap&value=%s\">%s</a>]</small></td></tr>",
 
688
                                mod_name,_("view context"));
 
689
                        g_string_append(data, tmpBuf);
 
690
                }
 
691
        }
 
692
 
 
693
        g_string_append(data, "</table></body></html>");
 
694
        HtmlOutput(data->str, widgets.html_parallel, NULL, NULL);
 
695
        g_string_free(data, TRUE);
 
696
}
 
697
 
 
698
/******************************************************************************
 
699
 * Name
 
700
 *   interpolate_parallel_display
 
701
 *
 
702
 * Synopsis
 
703
 *   #include "main/parallel_view.h
 
704
 *
 
705
 *   void interpolate_parallel_display(SWBuf& text, gchar *key)
1176
706
 *
1177
707
 * Description
1178
708
 *   carry out the hard work of getting verses for parallel display.
1181
711
 *   void
1182
712
 */
1183
713
 
1184
 
static void int_display(SWBuf& text, gchar *key, char *mod_name[])
 
714
static void interpolate_parallel_display(SWBuf& text, gchar *key, gint parallel_count, gint fraction)
1185
715
{
1186
716
        gchar   *utf8str,
1187
717
                *textColor,
1188
718
                *tmpkey,
1189
 
                tmpbuf[256],
1190
 
                *use_font_size[5],
1191
 
                *font_size_tmp[5],
1192
 
                *use_font_name[5];
 
719
                tmpbuf[256];
1193
720
        const gchar *bgColor;
1194
721
        gchar str[500];
1195
 
        gboolean evenRow = FALSE;
1196
 
        gboolean is_rtol = FALSE;
1197
 
        gchar *file = NULL;
1198
 
        gint cur_verse, cur_chapter, i = 1, j;
 
722
        gint cur_verse, cur_chapter, verse, modidx;
1199
723
        char *cur_book;
1200
 
        gboolean is_module[5] = { FALSE, FALSE, FALSE, FALSE, FALSE };
 
724
        MOD_FONT **mf;
 
725
        gboolean *is_rtol, *is_module;
1201
726
 
1202
727
        if (!GTK_WIDGET_REALIZED(GTK_WIDGET(widgets.notebook_bible_parallel))) return;
1203
728
 
1204
 
        // need #verses to process in this book.
 
729
        is_module = g_new(gboolean, parallel_count);
 
730
        is_rtol   = g_new(gboolean, parallel_count);
 
731
        mf        = g_new(MOD_FONT *, parallel_count);
 
732
 
 
733
        // quick cache of fonts/rtol info.
 
734
        for (modidx = 0; modidx < parallel_count; ++modidx) {
 
735
                // determine module presence once each.
 
736
                is_module[modidx] = backend->is_module(settings.parallel_list[modidx]);
 
737
 
 
738
                if (is_module[modidx]) {
 
739
                        is_rtol[modidx] = main_is_mod_rtol(settings.parallel_list[modidx]);
 
740
                        mf[modidx] = get_font(settings.parallel_list[modidx]);
 
741
                }
 
742
        }
 
743
 
 
744
        // need #verses to process in this chapter.
1205
745
        VerseKey vkey;
1206
746
        int xverses;
1207
747
 
1208
748
        vkey.AutoNormalize(1);
1209
749
        vkey = key;
1210
 
 
1211
 
#ifdef SWORD_MULTIVERSE
1212
750
        xverses = (vkey.getVerseMax());
1213
 
#else
1214
 
        xverses = (vkey.books[vkey.Testament()-1]
1215
 
                                 [vkey.Book()-1].
1216
 
                                 versemax[vkey.Chapter()-1]);
1217
 
#endif
1218
 
 
1219
 
        // quick cache of fonts.  (mod_name was passed in.)
1220
 
        file = g_strdup_printf("%s/fonts.conf", settings.gSwordDir);
1221
 
        for (j = 0; j < 5; ++j) {
1222
 
                // determine module presence just once each for this routine.
1223
 
                is_module[j] = (mod_name[j] &&
1224
 
                                *(mod_name[j]) &&
1225
 
                                backend->is_module(mod_name[j]));
1226
 
 
1227
 
                // collect decorations.
1228
 
                font_size_tmp[j] = get_conf_file_item(file, mod_name[j], "Fontsize");
1229
 
                if ((font_size_tmp[j] == NULL) ||
1230
 
                    !strcmp(font_size_tmp[j], "+0")) {
1231
 
                        g_free(font_size_tmp[j]);
1232
 
                        font_size_tmp[j] =
1233
 
                            main_get_mod_config_entry(mod_name[j], "Fontsize");
1234
 
                        if ((font_size_tmp[j] == NULL) || (*font_size_tmp[j] == '\0'))
1235
 
                                font_size_tmp[j] = g_strdup("+0");
1236
 
                }
1237
 
 
1238
 
                use_font_size[j] =
1239
 
                    g_strdup_printf("%+d",
1240
 
                                    (font_size_tmp[j] ? atoi(font_size_tmp[j]) : 0)
1241
 
                                    + settings.base_font_size);
1242
 
 
1243
 
                use_font_name[j] = get_conf_file_item(file, mod_name[j], "Font");
1244
 
                if ((use_font_name[j] == NULL) ||
1245
 
                    !strcmp(use_font_name[j], "none")) {
1246
 
                        use_font_name[j] =
1247
 
                            main_get_mod_config_entry(mod_name[j], "Font");
1248
 
                        if (!use_font_name[j])
1249
 
                                use_font_name[j] = g_strdup("none");
1250
 
                }
1251
 
        }
1252
 
        g_free(file);
1253
 
 
1254
 
        bgColor = "#f1f1f1";
1255
751
 
1256
752
        tmpkey = backend_p->get_valid_key(key);
1257
753
        cur_verse = backend_p->key_get_verse(tmpkey);
1258
 
        settings.intCurVerse = cur_verse;
1259
754
        cur_chapter = backend_p->key_get_chapter(tmpkey);
1260
755
        cur_book = backend_p->key_get_book(tmpkey);
 
756
        settings.intCurVerse = cur_verse;
1261
757
 
1262
 
        for (i = 1; i <= xverses; ++i) {
1263
 
                snprintf(tmpbuf, 255, "%s %d:%d", cur_book, cur_chapter, i);
 
758
        for (verse = 1; verse <= xverses; ++verse) {
 
759
                snprintf(tmpbuf, 255, "%s %d:%d", cur_book, cur_chapter, verse);
1264
760
                free(tmpkey);
1265
761
                tmpkey = backend_p->get_valid_key(tmpbuf);
1266
762
 
1267
763
                text += "<tr valign=\"top\">";
1268
764
 
1269
765
                // mark current verse properly.
1270
 
                if (i == cur_verse)
 
766
                if (verse == cur_verse)
1271
767
                        textColor = settings.currentverse_color;
1272
768
                else
1273
769
                        textColor = settings.bible_text_color;
1274
770
 
1275
771
                // alternate background colors.
1276
 
                if (evenRow) {
1277
 
                        evenRow = FALSE;
 
772
                if (verse % 2 == 0)
1278
773
                        bgColor = "#f1f1f1";
1279
 
                } else {
1280
 
                        evenRow = TRUE;
 
774
                else
1281
775
                        bgColor = settings.bible_bg_color;
1282
 
                }
1283
 
 
1284
 
                for (j = 0; j < 5; j++) {
1285
 
                        is_rtol = main_is_mod_rtol(mod_name[j]);
1286
 
 
1287
 
                        char *num = main_format_number(i);
1288
 
                        snprintf(str, 499,
1289
 
                                "<td width=\"20%%\" bgcolor=\"%s\">"
1290
 
                                "<a href=\"xiphos.url?action=showParallel&"
1291
 
                                "type=verse&value=%s\" name=\"%d\">"
1292
 
                                "<font color=\"%s\">%s. </font></a>"
1293
 
                                "<font face=\"%s\" size=\"%s\" color=\"%s\">",
1294
 
                                bgColor,
1295
 
                                main_url_encode(tmpkey),
1296
 
                                i,
1297
 
                                settings.bible_verse_num_color,
1298
 
                                num,
1299
 
                                use_font_name[j],
1300
 
                                use_font_size[j],
1301
 
                                textColor);
1302
 
                        g_free(num);
1303
 
                        text += str;
1304
 
 
1305
 
                        if (is_module[j]) {
1306
 
                                if (is_rtol)
1307
 
                                        text += "<br><DIV ALIGN=right>";
1308
 
 
1309
 
                                utf8str = backend_p->get_render_text
1310
 
                                    (mod_name[j], tmpkey);
1311
 
                                if (strlen(utf8str)) {
 
776
 
 
777
                for (modidx = 0; modidx < parallel_count; modidx++) {
 
778
                        if (is_module[modidx]) {                
 
779
                                
 
780
                                const gchar *newurl = main_url_encode(tmpkey);
 
781
                                gchar *num = main_format_number(verse);
 
782
                                snprintf(str, 499,
 
783
                                         "<td width=\"%d%%\" bgcolor=\"%s\">"
 
784
                                         "<a href=\"passagestudy.jsp?action=showParallel&"
 
785
                                         "type=verse&value=%s\" name=\"%d\">"
 
786
                                         "<font color=\"%s\">%s. </font></a>"
 
787
                                         "<font face=\"%s\" size=\"%s\" color=\"%s\">",
 
788
                                         fraction,
 
789
                                         bgColor,
 
790
                                         newurl,
 
791
                                         verse,
 
792
                                         settings.bible_verse_num_color,
 
793
                                         num,
 
794
                                         mf[modidx]->old_font,
 
795
                                         mf[modidx]->old_font_size,
 
796
                                         textColor);
 
797
                                g_free((gchar*)newurl);
 
798
                                g_free(num);
 
799
                                text += str;
 
800
 
 
801
                                if (is_rtol[modidx])
 
802
                                        text += "<br/><div align=right>";
 
803
 
 
804
                                backend_p->set_module_key(settings.parallel_list[modidx], tmpkey);
 
805
                                get_heading(text, backend_p, modidx);
 
806
 
 
807
                                utf8str = backend_p->get_render_text(settings.parallel_list[modidx], tmpkey);
 
808
                                if (utf8str) {
1312
809
                                        text += utf8str;
1313
 
                                        free(utf8str);
 
810
                                        g_free(utf8str);
1314
811
                                }
1315
812
 
1316
 
                                if (is_rtol)
1317
 
                                        text += "</DIV>";
 
813
                                if (is_rtol[modidx])
 
814
                                        text += "</div>";
1318
815
                        }
1319
816
 
1320
817
                        text += "</font></td>";
1322
819
 
1323
820
                text += "</tr>";
1324
821
        }
1325
 
 
1326
 
        for (j = 0; j < 5; ++j) {
1327
 
                g_free(use_font_size[j]);
1328
 
                g_free(font_size_tmp[j]);
1329
 
                g_free(use_font_name[j]);
1330
 
        }
1331
822
        g_free(tmpkey);
1332
823
        g_free(cur_book);
 
824
 
 
825
        /* clear bookkeeping data */
 
826
        for (modidx = 0; modidx < parallel_count; ++modidx)
 
827
                if (is_module[modidx])
 
828
                        free_font(mf[modidx]);
 
829
        g_free(mf);
 
830
        g_free(is_rtol);
 
831
        g_free(is_module);
1333
832
}
1334
833
 
1335
834
 
1352
851
void main_update_parallel_page_detached(void)
1353
852
{
1354
853
        SWBuf text("");
1355
 
        gchar buf[500], *mod_name[5];
1356
 
        gint j;
1357
 
        gchar space[2];  //there is surely a better way?
1358
 
        space[0] = ' ';
1359
 
        space[1] = '\0';
1360
 
        mod_name[0] = (parallel1 ? settings.parallel1Module : space);
1361
 
        mod_name[1] = (parallel2 ? settings.parallel2Module : space);
1362
 
        mod_name[2] = (parallel3 ? settings.parallel3Module : space);
1363
 
        mod_name[3] = (parallel4 ? settings.parallel4Module : space);
1364
 
        mod_name[4] = (parallel5 ? settings.parallel5Module : space);
1365
 
 
1366
 
        snprintf(buf, 499, "<span color='blue' weight='bold'>%s</span>", mod_name[0]);
1367
 
        gtk_label_set_markup(GTK_LABEL(plabels.label_1), buf);
1368
 
 
1369
 
        snprintf(buf, 499, "<span color='blue' weight='bold'>%s</span>", mod_name[1]);
1370
 
        gtk_label_set_markup(GTK_LABEL(plabels.label_2), buf);
1371
 
 
1372
 
        snprintf(buf, 499, "<span color='blue' weight='bold'>%s</span>", mod_name[2]);
1373
 
        gtk_label_set_markup(GTK_LABEL(plabels.label_3), buf);
1374
 
 
1375
 
        snprintf(buf, 499, "<span color='blue' weight='bold'>%s</span>", mod_name[3]);
1376
 
        gtk_label_set_markup(GTK_LABEL(plabels.label_4), buf);
1377
 
 
1378
 
        snprintf(buf, 499, "<span color='blue' weight='bold'>%s</span>", mod_name[4]);
1379
 
        gtk_label_set_markup(GTK_LABEL(plabels.label_5), buf);
 
854
        gchar buf[500];
 
855
        gint modidx, parallel_count, fraction;
1380
856
 
1381
857
#ifdef USE_GTKMOZEMBED
1382
858
        if (!GTK_WIDGET_REALIZED(GTK_WIDGET(widgets.html_parallel_dialog))) return;
1383
859
#endif
1384
860
 
 
861
        /* how big a pile of parallels have we got? */
 
862
        if (settings.parallel_list == NULL)
 
863
                return;
 
864
        for (parallel_count = 0; settings.parallel_list[parallel_count]; ++parallel_count)
 
865
                /* just count non-null string ptrs */;
 
866
 
 
867
        /* get the per-column percentage width. */
 
868
        /* 2 => 50, 4 => 25, 5 => 20, 10 => 10, ... */
 
869
        fraction = (parallel_count ? (100/parallel_count) : 100);
 
870
 
1385
871
        snprintf(buf, 499, HTML_START
1386
872
                "<body bgcolor=\"%s\" text=\"%s\" link=\"%s\"><table align=\"left\" valign=\"top\"><tr valign=\"top\" >",
1387
873
                settings.bible_bg_color, settings.bible_text_color,
1388
874
                settings.link_color);
1389
875
        text += buf;
1390
876
 
1391
 
        for (j = 0; j < 5; ++j){
 
877
        for (modidx = 0; settings.parallel_list[modidx]; ++modidx) {
1392
878
                snprintf(buf, 499,
1393
 
                        "<td valign=\"top\" width=\"20%%\" bgcolor=\"#f1f1f1\"><font color=\"%s\" size=\"%+d\"><b>%s</b></td>",
1394
 
                        settings.bible_verse_num_color,
1395
 
                        settings.verse_num_font_size + settings.base_font_size,
1396
 
                        mod_name[j]);
 
879
                         "<td valign=\"top\" width=\"%d%%\" bgcolor=\"#f1f1f1\"><font color=\"%s\" size=\"%+d\"><b>%s</b></font></td>",
 
880
                         fraction,
 
881
                         settings.bible_verse_num_color,
 
882
                         settings.verse_num_font_size + settings.base_font_size,
 
883
                         settings.parallel_list[modidx]);
1397
884
                text += buf;
1398
885
        }
1399
886
 
1400
887
        text += "</tr>";
1401
 
        int_display(text, settings.cvparallel, mod_name);
 
888
        interpolate_parallel_display(text, settings.cvparallel, parallel_count, fraction);
1402
889
        text += "</table></body></html>";
1403
890
 
1404
891
        snprintf(buf, 499, "%d", ((settings.intCurVerse > 1)
1426
913
 
1427
914
void main_swap_parallel_with_main(char *intmod)
1428
915
{
1429
 
#if 0
1430
 
        if ((settings.parallel5Module) && !strcmp(settings.parallel5Module, intmod)) {
1431
 
                settings.parallel5Module = xml_get_value("modules", "bible");
1432
 
        }
1433
 
        if ((settings.parallel4Module) && !strcmp(settings.parallel4Module, intmod)) {
1434
 
                settings.parallel4Module = xml_get_value("modules", "bible");
1435
 
        }
1436
 
        if ((settings.parallel3Module) && !strcmp(settings.parallel3Module, intmod)) {
1437
 
                settings.parallel3Module = xml_get_value("modules", "bible");
1438
 
        }
1439
 
        if ((settings.parallel2Module) && !strcmp(settings.parallel2Module, intmod)) {
1440
 
                settings.parallel2Module = xml_get_value("modules", "bible");
1441
 
        }
1442
 
        if ((settings.parallel1Module) && !strcmp(settings.parallel1Module, intmod)) {
1443
 
                settings.parallel1Module = xml_get_value("modules", "bible");
1444
 
        }
1445
 
#endif
1446
916
        main_display_bible(intmod, settings.currentverse);
1447
917
        main_update_parallel_page();
1448
918
        gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_bible_parallel),
1522
992
void main_init_parallel_view(void)
1523
993
{
1524
994
        backend_p = new BackEnd();
1525
 
        gui_create_parallel_page();
1526
 
        gtk_widget_realize(widgets.html_parallel);
1527
 
        main_set_parallel_options_at_start();
1528
995
}
1529
996
 
1530
997