~pkgcrosswire/xiphos/main

« back to all changes in this revision

Viewing changes to src/main/sidebar.cc

  • Committer: Dmitrijs Ledkovs
  • Date: 2010-11-14 00:38:52 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: dmitrij.ledkov@ubuntu.com-20101114003852-sjt227lz4qqi85xj
New upstream release 3.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Xiphos Bible Study Tool
3
3
 * utilities.c - support functions
4
4
 *
5
 
 * Copyright (C) 2000-2009 Xiphos Developer Team
 
5
 * Copyright (C) 2000-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
137
137
                                        gchar * verse_list)
138
138
{
139
139
        GList *tmp = NULL;
140
 
        gint i = 0;
141
140
        GtkTreeModel *model;
142
141
        GtkListStore *list_store;
143
142
        GtkTreeSelection *selection;
172
171
 
173
172
        strcpy(sidebar.mod_name, module_name);
174
173
 
175
 
        if (verse_list[0] == 'S' && verse_list[1] == 'e'
176
 
            && verse_list[2] == 'e') {
 
174
        if (!strncmp(verse_list, "See ", 4))
177
175
                verse_list += 4;
178
 
        }
179
 
        i = 0;
180
 
        tmp = backend->parse_verse_list(verse_list, key);
181
 
        while (tmp != NULL) {
 
176
        
 
177
        if ((*verse_list != '/') &&
 
178
            ((tmp = backend->parse_verse_list(verse_list, key)) != NULL)) {
 
179
                // normal verse list.
 
180
                while (tmp != NULL) {
 
181
                        gtk_list_store_append(list_store, &iter);
 
182
                        gtk_list_store_set(list_store, &iter, 0,
 
183
                                           (const char *) tmp->data, -1);
 
184
 
 
185
                        list_item = g_new(RESULTS, 1);
 
186
                        list_item->module = g_strdup(module_name);
 
187
                        list_item->key = g_strdup((const char *) tmp->data);
 
188
                        list_of_verses = g_list_append(list_of_verses,
 
189
                                                       (RESULTS *) list_item);
 
190
 
 
191
                        tmp = g_list_next(tmp);
 
192
                }
 
193
        } else {
 
194
                // not normal verse list.  probably a genbook or dict key.
182
195
                gtk_list_store_append(list_store, &iter);
183
 
                gtk_list_store_set(list_store, &iter, 0,
184
 
                                   (const char *) tmp->data, -1);
185
 
                ++i;
 
196
                gtk_list_store_set(list_store, &iter, 0, verse_list, -1);
186
197
 
187
 
                list_item = g_new(RESULTS,1);
 
198
                list_item = g_new(RESULTS, 1);
188
199
                list_item->module = g_strdup(module_name);
189
 
                list_item->key = g_strdup((const char *) tmp->data);
 
200
                list_item->key = g_strdup((const char *) verse_list);
190
201
                list_of_verses = g_list_append(list_of_verses,
191
202
                                               (RESULTS *) list_item);
192
 
 
193
 
                tmp = g_list_next(tmp);
194
203
        }
195
204
 
196
205
        selection = gtk_tree_view_get_selection
356
365
}
357
366
 
358
367
 
 
368
#ifdef ALLOW_BIBLE_NAVIGATION_FROM_SIDEBAR_TREE
 
369
 
359
370
/******************************************************************************
360
371
 * Name
361
372
 *  main_add_verses_to_chapter
372
383
 * Return value
373
384
 *   void
374
385
 */
375
 
#if 0
376
386
static void add_verses_to_chapter(GtkTreeModel * model,
377
387
                                  GtkTreeIter iter, const gchar * key)
378
388
{
419
429
}
420
430
 
421
431
 
422
 
 
423
432
/******************************************************************************
424
433
 * Name
425
434
 *  main_add_chapters_to_book
510
519
                           COL_OPEN_PIXBUF, pixbufs->pixbuf_opened, -1);
511
520
        if (backend->module_has_testament(mod_name, 1)) {
512
521
                while (j < key.BMAX[0]) {
513
 
#ifdef SWORD_MULTIVERSE
514
522
                        key.Testament(1);
515
523
                        key.Book(j+1);
516
524
                        buf = strdup((gchar *) key.getBookName());
517
 
#else
518
 
                        buf = strdup((gchar *) key.books[0][j].name);
519
 
#endif
520
525
                        gchar *key = g_strdup_printf("book://%s/%s 1:1",
521
526
                                                     mod_name, buf);
522
527
                        gtk_tree_store_append(GTK_TREE_STORE(model),
539
544
        j = 0;
540
545
        if (backend->module_has_testament(mod_name, 2)) {
541
546
                while (j < key.BMAX[1]) {
542
 
#ifdef SWORD_MULTIVERSE
543
547
                        key.Testament(2);
544
548
                        key.Book(j+1);
545
549
                        buf = strdup((gchar *) key.getBookName());
546
 
#else
547
 
                        buf = strdup((gchar *) key.books[1][j].name);
548
 
#endif
549
550
                        gchar *key = g_strdup_printf("book://%s/%s 1:1",
550
551
                                                     mod_name, buf);
551
552
                        gtk_tree_store_append(GTK_TREE_STORE(model),
566
567
                }
567
568
        }
568
569
}
569
 
#endif
 
570
#endif /* ALLOW_BIBLE_NAVIGATION_FROM_SIDEBAR_TREE */
570
571
 
571
572
#ifdef USE_TREEVIEW_PATH
572
573
gboolean main_expand_treeview_to_path (GtkTreeModel *model, GtkTreeIter iter)
633
634
        gchar *mod = NULL;
634
635
        gchar *key = NULL;
635
636
        GtkTreePath *path;
636
 
        /*  *** until after 3.1 ***
637
 
        gchar *path_str = NULL;
638
 
        */
639
637
 
640
638
        static int old_page = 0;
641
639
 
643
641
                           &mod, 4, &key, -1);
644
642
        if (!cap)
645
643
                return;
 
644
 
646
645
        if (!g_utf8_collate(cap, _("Parallel View"))) {
647
646
                if (settings.dockedInt) {
648
 
                        gtk_notebook_set_current_page (GTK_NOTEBOOK
 
647
                        gtk_notebook_set_current_page(GTK_NOTEBOOK
649
648
                                              (widgets.
650
649
                                               notebook_bible_parallel),
651
650
                                              1);
660
659
                                GTK_NOTEBOOK (widgets.notebook_main),
661
660
                                widgets.parallel_tab));
662
661
                }
663
 
 
664
662
        }
665
663
 
666
664
        if (!g_utf8_collate(cap, _("Standard View"))) {
706
704
                                               notebook_bible_parallel),
707
705
                                              0);
708
706
                // MainWindowModule is set in main_bible_display(), not here.
709
 
                /*if (!gtk_tree_model_iter_has_child
 
707
 
 
708
#ifdef ALLOW_BIBLE_NAVIGATION_FROM_SIDEBAR_TREE
 
709
                if (!gtk_tree_model_iter_has_child
710
710
                    (GTK_TREE_MODEL(model), &selected)
711
711
                    && !key)
712
712
                        add_books_to_bible(model, selected, mod);
718
718
                    (GTK_TREE_MODEL(model), &selected)
719
719
                    && strstr(key, "chapter:"))
720
720
                        add_verses_to_chapter(model, selected, key);
721
 
                */
 
721
#endif
722
722
 
723
723
                if (!GTK_CHECK_MENU_ITEM(widgets.viewtexts_item)->active) {
724
724
                        GTK_CHECK_MENU_ITEM(widgets.viewtexts_item)->active = 1;
730
730
                        main_url_handler(key, TRUE);
731
731
                else
732
732
                        main_display_bible(mod, settings.currentverse);
 
733
                break;
733
734
 
734
 
                break;
735
735
        case COMMENTARY_TYPE:
736
736
        case PERCOM_TYPE:
737
737
                gtk_notebook_set_current_page(GTK_NOTEBOOK
745
745
                        on_show_commentary_activate
746
746
                            (GTK_MENU_ITEM(widgets.viewcomms_item), NULL);
747
747
                }
748
 
 
749
748
                main_display_commentary(mod, settings.currentverse);
750
749
                break;
 
750
 
751
751
        case DICTIONARY_TYPE:
752
752
                if (!GTK_CHECK_MENU_ITEM(widgets.viewdicts_item)->active) {
753
753
                        GTK_CHECK_MENU_ITEM(widgets.viewdicts_item)->active = 1;
754
754
                        on_show_dictionary_lexicon_activate
755
755
                            (GTK_MENU_ITEM(widgets.viewcomms_item), NULL);
756
756
                }
757
 
 
758
757
                main_display_dictionary(mod, settings.dictkey);
759
758
                break;
 
759
 
760
760
        case BOOK_TYPE:
761
761
        case PRAYERLIST_TYPE:
762
762
                GS_message(("key %s", (key ? key : "-null-")));
770
770
                if (!gtk_tree_model_iter_has_child
771
771
                    (GTK_TREE_MODEL(model), &selected)
772
772
                    && !key) {
773
 
                        add_children_to_tree(model,
774
 
                                             selected,
775
 
                                             mod,
776
 
                                             0);
 
773
                        add_children_to_tree(model, selected, mod, 0);
777
774
                }
778
775
                if (!gtk_tree_model_iter_has_child
779
776
                    (GTK_TREE_MODEL(model), &selected)
780
777
                    && backend->treekey_has_children(key ? atoi(key) : 0)) {
781
 
                        add_children_to_tree(model,
782
 
                                             selected, mod, atol(key));
 
778
                        add_children_to_tree(model, selected, mod, atol(key));
783
779
                }
784
780
 
785
 
                /*  *** until after 3.1 ***
786
 
                path_str = gtk_tree_path_to_string (path);
787
 
                //GS_message (("path: %s", path_str));
 
781
#ifdef USE_TREEVIEW_PATH
 
782
                gchar *path_str = gtk_tree_path_to_string (path);
 
783
                GS_message (("path: %s", path_str));
788
784
                gui_save_treeview_path_string (path_str, mod);
789
785
                g_free (path_str);
790
 
                */
 
786
#endif /* USE_TREEVIEW_PATH */
 
787
 
791
788
                gtk_tree_view_expand_row(GTK_TREE_VIEW
792
789
                                         (sidebar.module_list), path,
793
790
                                         FALSE);
804
801
                main_setup_navbar_book(mod, (key ? atoi(key) : 0));
805
802
                break;
806
803
        }
807
 
        if (cap)
808
 
                g_free(cap);
809
 
        if (mod)
810
 
                g_free(mod);
811
 
        if (key)
812
 
                g_free(key);
813
 
 
814
 
 
 
804
        g_free(cap);
 
805
        g_free(mod);
 
806
        g_free(key);
815
807
}
816
808
 
817
809
 
974
966
        GtkTreeIter text;
975
967
        GtkTreeIter commentary;
976
968
        GtkTreeIter dictionary;
 
969
        GtkTreeIter glossary;
977
970
        GtkTreeIter devotional;
978
971
        GtkTreeIter book;
979
972
        GtkTreeIter map;
980
973
        GtkTreeIter image;
 
974
        GtkTreeIter cult;
981
975
        GtkTreeIter prayerlist;
982
976
        GtkTreeIter child_iter;
983
977
        GList *tmp = NULL;
1034
1028
                           COL_MODULE, NULL,
1035
1029
                           COL_OFFSET, _("Dictionaries"), -1);
1036
1030
 
 
1031
        /*  Glossaries folders */
 
1032
        gtk_tree_store_append(store, &glossary, NULL);
 
1033
        gtk_tree_store_set(store, &glossary,
 
1034
                           COL_OPEN_PIXBUF, pixbufs->pixbuf_opened,
 
1035
                           COL_CLOSED_PIXBUF, pixbufs->pixbuf_closed,
 
1036
                           COL_CAPTION, _("Glossaries"),
 
1037
                           COL_MODULE, NULL,
 
1038
                           COL_OFFSET, _("Glossaries"), -1);
 
1039
 
1037
1040
        /*  Devotionals folders */
1038
1041
        gtk_tree_store_append(store, &devotional, NULL);
1039
1042
        gtk_tree_store_set(store, &devotional,
1070
1073
                           COL_MODULE, NULL,
1071
1074
                           COL_OFFSET, _("Images"), -1);
1072
1075
 
 
1076
        /*  Cult/Unorthodox/Questionable folders */
 
1077
        gtk_tree_store_append(store, &cult, NULL);
 
1078
        gtk_tree_store_set(store, &cult,
 
1079
                           COL_OPEN_PIXBUF, pixbufs->pixbuf_opened,
 
1080
                           COL_CLOSED_PIXBUF, pixbufs->pixbuf_closed,
 
1081
                           COL_CAPTION, _("Cult/Unorthodox"),
 
1082
                           COL_MODULE, NULL,
 
1083
                           COL_OFFSET, _("Cult/Unorthodox"), -1);
 
1084
 
1073
1085
        /*  Prayer lists folder */
1074
1086
        if (settings.prayerlist) {
1075
1087
                gtk_tree_store_append(store, &prayerlist, NULL);
1085
1097
 
1086
1098
        language_make_list(tmp, store,
1087
1099
                           text, commentary, map, image,
1088
 
                           devotional, dictionary, book,
 
1100
                           devotional, dictionary, glossary, book, cult,
1089
1101
                           NULL, NULL,
1090
 
                           language_add_folders);
 
1102
                           language_add_folders, FALSE);
1091
1103
 
1092
1104
        // fast-n-loose w/known string values to avoid pointless strcmp costs.
1093
1105
        // TEXT_MODS => 'B' ("Biblical Texts")
1102
1114
        while (tmp2 != NULL) {
1103
1115
                info = (MOD_MGR *) tmp2->data;
1104
1116
 
1105
 
                if (info->type[0] == 'B') {
 
1117
                if (info->is_cult) {
 
1118
                        add_module_to_language_folder(GTK_TREE_MODEL(store),
 
1119
                                                      cult, info->language,
 
1120
                                                      info->name);
 
1121
                }
 
1122
                else if (info->type[0] == 'B') {
1106
1123
                        add_module_to_language_folder(GTK_TREE_MODEL(store),
1107
1124
                                                      text, info->language,
1108
1125
                                                      info->name);
1127
1144
                                                      devotional, info->language,
1128
1145
                                                      info->name);
1129
1146
                }
 
1147
                else if (info->is_glossary) {
 
1148
                        add_module_to_language_folder(GTK_TREE_MODEL(store),
 
1149
                                                      glossary, info->language,
 
1150
                                                      info->name);
 
1151
                }
1130
1152
                else if (info->type[0] == 'L') {
1131
1153
                        add_module_to_language_folder(GTK_TREE_MODEL(store),
1132
1154
                                                      dictionary, info->language,