~ubuntu-branches/debian/jessie/xiphos/jessie

« back to all changes in this revision

Viewing changes to src/gnome2/tabbed_browser.c

  • Committer: Bazaar Package Importer
  • Author(s): Dmitrijs Ledkovs
  • Date: 2010-03-22 18:15:54 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100322181554-qlqchymwhcw28c0c
* New upstream release:
  + Bugfix only
  + Compatible with xulrunner 1.9.2
  + Update translations

* Revert changes introduced in 3.1.2-1ubuntu1. Thank you Chris Coulson
  for temporary fix.
* debian/xiphos.1 - spelling mistake
* waf is now default buildsystem
* help is now licensed under GPL
* Bumped standards version no changes required
* Changed email to @ubuntu.com

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <libxml/tree.h>
31
31
#include <libxml/parser.h>
32
32
 
33
 
#ifdef USE_GTKHTML3_14_23
34
33
#include "editor/slib-editor.h"
35
 
#else
36
 
#include "editor/bonobo-editor.h"
37
 
#endif
38
34
 
39
35
#include "gui/xiphos.h"
40
36
#include "gui/tabbed_browser.h"
65
61
#include <glib/gstdio.h>
66
62
 
67
63
#include "gui/debug_glib_null.h"
68
 
        
 
64
 
69
65
static GtkWidget* tab_widget_new(PASSAGE_TAB_INFO *tbinf,
70
66
                                        const gchar *label_text);
71
67
void notebook_main_add_page(PASSAGE_TAB_INFO *tbinf);
85
81
PASSAGE_TAB_INFO *cur_passage_tab;
86
82
 
87
83
/******************************************************************************
88
 
 * globals to this file only 
 
84
 * globals to this file only
89
85
 */
90
86
static gboolean page_change = FALSE;
91
87
static gint removed_page;
110
106
 * Synopsis
111
107
 *   #include "tabbed_browser.h"
112
108
 *
113
 
 *   void gui_recompute_shows(void)     
 
109
 *   void gui_recompute_shows(void)
114
110
 *
115
111
 * Description
116
112
 *   a new set of text/preview/comm/dict showings has been selected.
126
122
        stop_refresh = TRUE;
127
123
 
128
124
        main_flush_widgets_content();
129
 
        
 
125
 
130
126
        if (cur_passage_tab)
131
127
                gui_reassign_strdup(&settings.currentverse,
132
128
                                    cur_passage_tab->text_commentary_key);
137
133
        gui_show_hide_comms(settings.showcomms);
138
134
        gui_set_bible_comm_layout();
139
135
 
140
 
        while (gtk_events_pending())
141
 
                gtk_main_iteration();
 
136
        sync_windows();
142
137
 
143
138
        stop_refresh = FALSE;
144
139
}
150
145
 * Synopsis
151
146
 *   #include "tabbed_browser.h"
152
147
 *
153
 
 *   void gui_recompute_view_menu_choices(void) 
 
148
 *   void gui_recompute_view_menu_choices(void)
154
149
 *
155
150
 * Description
156
151
 *   formerly part of gui_recompute_shows, but moved here to keep from
157
 
 *   triggering toggled signals on these items before new content is 
 
152
 *   triggering toggled signals on these items before new content is
158
153
 *   ready to be displayed
159
154
 *
160
155
 * Return value
184
179
{
185
180
        /*pt->editor = editor_create_new_book_editor(pt->book_mod, PRAYERLIST_TYPE);
186
181
        gtk_widget_show(GTK_WIDGET(pt->editor));
187
 
        
188
 
        gtk_box_pack_start (GTK_BOX (widgets.vboxMain), GTK_WIDGET(pt->editor), 
 
182
 
 
183
        gtk_box_pack_start (GTK_BOX (widgets.vboxMain), GTK_WIDGET(pt->editor),
189
184
                                TRUE, TRUE, 0);*/
190
185
}
191
186
 
196
191
 * Synopsis
197
192
 *   #include "tabbed_browser.h"
198
193
 *
199
 
 *   void set_current_tab (PASSAGE_TAB_INFO *pt)        
 
194
 *   void set_current_tab (PASSAGE_TAB_INFO *pt)
200
195
 *
201
196
 * Description
202
 
 *   point cur_passage_tab to the current tab and turns the close button on 
 
197
 *   point cur_passage_tab to the current tab and turns the close button on
203
198
 *   and off
204
199
 *
205
200
 * Return value
206
201
 *   void
207
202
 */
208
 
 
 
203
 
209
204
void set_current_tab (PASSAGE_TAB_INFO *pt)
210
205
{
211
206
        PASSAGE_TAB_INFO *ot = cur_passage_tab;
212
 
        
 
207
 
213
208
        if (stop_refresh)
214
209
                return;
215
210
 
252
247
 *   GString *
253
248
 *   ** caller must free it **
254
249
 */
255
 
 
 
250
 
256
251
GString *
257
252
pick_tab_label(PASSAGE_TAB_INFO *pt)
258
253
{
259
254
        GString *str = g_string_new(NULL);
260
 
        
261
 
        if (pt->showparallel) { 
 
255
 
 
256
        if (pt->showparallel) {
262
257
                g_string_printf(str, "%s", _("Parallel View"));
263
258
                return str;
264
259
        }
265
 
        
 
260
 
266
261
        if (pt->showtexts || (pt->showcomms && pt->comm_showing)) {
267
262
                g_string_printf(str, "%s: %s",
268
263
                                (pt->showtexts
308
303
 
309
304
        str = pick_tab_label(tbinf);
310
305
        tbinf->page_widget = gtk_vbox_new (FALSE, 0);
311
 
        if(tbinf->showparallel)
 
306
        if (tbinf->showparallel)
312
307
                widgets.parallel_tab = tbinf->page_widget;
313
308
        gtk_widget_show(tbinf->page_widget);
314
309
 
315
310
        tab_widget = tab_widget_new(tbinf, str->str);
316
311
        /*gtk_notebook_insert_page(GTK_NOTEBOOK(widgets.notebook_main),
317
 
                                 tbinf->page_widget, 
 
312
                                 tbinf->page_widget,
318
313
                                 tab_widget,
319
314
                                 tbinf->showparallel ? 1 : -1);*/
320
315
        gtk_notebook_append_page(GTK_NOTEBOOK(widgets.notebook_main),
342
337
 *   Saves the information for the current set of tabs.
343
338
 *
344
339
 * Return value
345
 
 *   
 
340
 *
346
341
 */
347
342
 
348
343
void gui_save_tabs(const gchar *filename)
360
355
 
361
356
        if (NULL == filename)
362
357
                filename = default_tab_filename;
363
 
        
 
358
 
364
359
        tabs_dir = g_strdup_printf("%s/tabs/",settings.gSwordDir);
365
 
        
 
360
 
366
361
        if (g_access(tabs_dir, F_OK) == -1) {
367
362
                if ((g_mkdir(tabs_dir, S_IRWXU)) == -1) {
368
363
                        gui_generic_warning("Can't create tabs dir.");
372
367
        file = g_strdup_printf("%s%s",tabs_dir,filename);
373
368
        g_free(tabs_dir);
374
369
        //xml_filename = (const xmlChar *) file;
375
 
        
 
370
 
376
371
        xml_doc = xmlNewDoc((const xmlChar *) "1.0");
377
372
 
378
373
        if (xml_doc == NULL) {
383
378
        root_node = xmlNewNode(NULL, (const xmlChar *) "Xiphos_Tabs");
384
379
        xml_attr = xmlNewProp(root_node, (const xmlChar *)"Version", (const xmlChar *) VERSION);
385
380
        xmlDocSetRootElement(xml_doc, root_node);
386
 
        
 
381
 
387
382
        section_node = xmlNewChild(root_node, NULL,
388
383
                                   (const xmlChar *) "tabs", NULL);
389
 
        
 
384
 
390
385
        for (tmp = g_list_first(passage_list); tmp != NULL; tmp = g_list_next(tmp)) {
391
386
 
392
387
                pt = (PASSAGE_TAB_INFO*) tmp->data;
393
 
                
 
388
 
394
389
                cur_node = xmlNewChild(section_node,
395
390
                                NULL, (const xmlChar *) "tab", NULL);
396
391
                xmlNewProp(cur_node,(const xmlChar *)"text_mod",
428
423
 
429
424
/******************************************************************************
430
425
 * Name
431
 
 *   
 
426
 *
432
427
 *
433
428
 * Synopsis
434
429
 *   #include "tabbed_browser.h"
439
434
 *   Saves the information for the current set of tabs.
440
435
 *
441
436
 * Return value
442
 
 *   
 
437
 *
443
438
 */
444
439
 
445
440
static
452
447
        xmlAttrPtr xml_attr;
453
448
        gchar *tabs_dir;
454
449
        gchar *file;
455
 
    
 
450
 
456
451
        if (NULL == filename)
457
452
                filename = no_tab_filename;
458
 
        
 
453
 
459
454
        tabs_dir = g_strdup_printf("%s/tabs/",settings.gSwordDir);
460
 
        
 
455
 
461
456
        if (g_access(tabs_dir, F_OK) == -1) {
462
457
                if ((g_mkdir(tabs_dir, S_IRWXU)) == -1) {
463
458
                        gui_generic_warning("Can't create tabs dir.");
466
461
        }
467
462
        file = g_strdup_printf("%s%s",tabs_dir,filename);
468
463
        g_free(tabs_dir);
469
 
        
 
464
 
470
465
        xml_doc = xmlNewDoc((const xmlChar *) "1.0");
471
466
 
472
467
        if (xml_doc == NULL) {
477
472
        root_node = xmlNewNode(NULL, (const xmlChar *) "Xiphos_Tabs");
478
473
        xml_attr = xmlNewProp(root_node, (const xmlChar *)"Version", (const xmlChar *) VERSION);
479
474
        xmlDocSetRootElement(xml_doc, root_node);
480
 
        
 
475
 
481
476
        section_node = xmlNewChild(root_node, NULL,
482
477
                                   (const xmlChar *) "tabs", NULL);
483
 
                
 
478
 
484
479
        cur_node = xmlNewChild(section_node,
485
480
                        NULL, (const xmlChar *) "tab", NULL);
486
481
        xmlNewProp(cur_node,(const xmlChar *)"text_mod",
527
522
 *   Load the tabs from the given file.
528
523
 *
529
524
 * Return value
530
 
 *   
 
525
 *
531
526
 */
532
527
 
533
528
void gui_load_tabs(const gchar *filename)
554
549
                        GS_message(("Creating new tabs directory\n"));
555
550
                        gui_save_tabs (filename);
556
551
                        //return;
557
 
                }       
 
552
                }
558
553
                file = g_strdup_printf("%s%s",tabs_dir,filename);
559
554
                g_free(tabs_dir);
560
 
                
 
555
 
561
556
                /* we need this for first time non tabbed browsing */
562
557
                if (!settings.browsing && g_access(file, F_OK) == -1) {
563
558
                        _save_off_tab (filename);
583
578
                                error = TRUE;
584
579
                        }
585
580
                }
586
 
                
 
581
 
587
582
                if (error == FALSE)
588
583
                {
589
584
                        for (childnode = tmp_node->children; childnode != NULL; childnode = childnode->next)
598
593
                                                        pt = g_new0(PASSAGE_TAB_INFO, 1);
599
594
                                                        if (pt_first == NULL)
600
595
                                                                pt_first = pt;
601
 
                                                        
 
596
 
602
597
                                                        /* load per-tab module information. */
603
598
                                                        val = (gchar*)xmlGetProp(tmp_node, (const xmlChar *)"text_mod");
604
599
                                                        pt->text_mod = g_strdup(val);
620
615
                                                        xmlFree(val);
621
616
                                                        val = (gchar*)xmlGetProp(tmp_node, (const xmlChar *)"book_offset");
622
617
                                                        pt->book_offset = g_strdup(val);
623
 
                                                        xmlFree(val);                                   
 
618
                                                        xmlFree(val);
624
619
                                                        val = (gchar*)xmlGetProp(tmp_node, (const xmlChar *)"comm_showing");
625
620
                                                        pt->comm_showing = yes_no2true_false(val);
626
621
                                                        xmlFree(val);
627
622
                                                        val = (gchar*)xmlGetProp(tmp_node, (const xmlChar *)"showparallel");
628
623
                                                        pt->showparallel = yes_no2true_false(val);
629
624
                                                        xmlFree(val);
630
 
                                                        if(pt->showparallel) {
 
625
                                                        if (pt->showparallel) {
631
626
                                                                settings.showparatab = TRUE;
632
627
                                                                pt->paratab = gui_create_parallel_tab();
633
628
                                                                gtk_box_pack_start(GTK_BOX(widgets.page), pt->paratab, TRUE, TRUE,
657
652
                                                                val = (gchar*)xmlGetProp(tmp_node, (const xmlChar *)"showdicts");
658
653
                                                                pt->showdicts = yes_no2true_false(val);
659
654
                                                                xmlFree(val);
660
 
                                                                
 
655
 
661
656
                                                        } else {
662
657
                                                                pt->showtexts   = settings.showtexts;
663
658
                                                                pt->showpreview = settings.showpreview;
666
661
                                                                back_compat_need_save = TRUE;
667
662
                                                        }
668
663
 
669
 
                                                        pt->history_items = 0;  
 
664
                                                        pt->history_items = 0;
670
665
                                                        pt->current_history_item = 0;
671
666
                                                        pt->first_back_click = TRUE;
672
667
                                                        main_add_tab_history_item((PASSAGE_TAB_INFO*)pt);
686
681
                /* backward compatibility completion. */
687
682
                if (back_compat_need_save)
688
683
                        gui_save_tabs(filename);
689
 
        
 
684
 
690
685
                if (error == TRUE || pt == NULL) {
691
686
                        pt = g_new0(PASSAGE_TAB_INFO, 1);
692
687
                        pt->text_mod = g_strdup(settings.MainWindowModule);
696
691
                        pt->text_commentary_key = g_strdup(settings.currentverse);
697
692
                        pt->dictlex_key = g_strdup(settings.dictkey);
698
693
                        pt->book_offset = NULL; //settings.book_offset = atol(xml_get_value( "keys", "offset"));
699
 
                        
 
694
 
700
695
                        pt->paratab = NULL;
701
 
                        
 
696
 
702
697
                        pt->showtexts   = settings.showtexts;
703
698
                        pt->showpreview = settings.showpreview;
704
699
                        pt->showcomms   = settings.showcomms;
705
700
                        pt->showdicts   = settings.showdicts;
706
701
 
707
 
                        pt->history_items = 0;  
 
702
                        pt->history_items = 0;
708
703
                        pt->current_history_item = 0;
709
704
                        pt->first_back_click = TRUE;
710
705
//                      main_add_tab_history_item((PASSAGE_TAB_INFO*)pt);
715
710
                {
716
711
                        // first passage is current/displayed.
717
712
                        pt = pt_first;
718
 
                        
 
713
 
719
714
                        pt->paratab = NULL;
720
715
                        // This is a hack to keep gs from loading the settings
721
716
                        // from the last session into the last tab loaded here.
742
737
 * Synopsis
743
738
 *   #include "tabbed_browser.h"
744
739
 *
745
 
 *   void on_notebook_main_close_page(GtkButton * button, gpointer user_data)   
 
740
 *   void on_notebook_main_close_page(GtkButton * button, gpointer user_data)
746
741
 *
747
742
 * Description
748
 
 *   
 
743
 *
749
744
 *
750
745
 * Return value
751
746
 *   void
752
747
 */
753
 
 
 
748
 
754
749
static void on_notebook_main_close_page(GtkButton * button, gpointer user_data)
755
750
{
756
751
        PASSAGE_TAB_INFO *pt = (PASSAGE_TAB_INFO*)user_data;
767
762
 * Synopsis
768
763
 *   #include "tabbed_browser.h"
769
764
 *
770
 
 *   GtkWidget* tab_widget_new(PASSAGE_TAB_INFO *tbinf,const gchar *label_text) 
 
765
 *   GtkWidget* tab_widget_new(PASSAGE_TAB_INFO *tbinf,const gchar *label_text)
771
766
 *
772
767
 * Description
773
768
 *   creates a tab widget that contains a label and a close button
775
770
 * Return value
776
771
 *   GtkWidget*
777
772
 */
778
 
 
 
773
 
779
774
static GtkWidget* tab_widget_new(PASSAGE_TAB_INFO *tbinf, const gchar *label_text)
780
775
{
781
776
        GtkWidget *tmp_toolbar_icon;
791
786
        tbinf->button_close = gtk_button_new();
792
787
        gtk_container_add(GTK_CONTAINER(tbinf->button_close), tmp_toolbar_icon);
793
788
        gtk_button_set_relief(GTK_BUTTON(tbinf->button_close), GTK_RELIEF_NONE);
794
 
        gtk_widget_set_usize (tbinf->button_close, 18, 16);
 
789
        gtk_widget_set_size_request(tbinf->button_close, 18, 16);
795
790
 
796
791
        tbinf->close_pixmap = pixmap_finder("window-close.png");
797
 
        gtk_widget_size_request (tbinf->button_close, &r);
798
 
        gtk_widget_set_usize (tbinf->close_pixmap, r.width, r.height);
 
792
        gtk_widget_size_request(tbinf->button_close, &r);
 
793
        gtk_widget_set_size_request(tbinf->close_pixmap, r.width, r.height);
799
794
        gtk_widget_set_sensitive(tbinf->close_pixmap, FALSE);
800
795
        gtk_widget_show(tbinf->close_pixmap);
801
796
 
836
831
 *
837
832
 *   void gui_notebook_main_switch_page(GtkNotebook * notebook,
838
833
 *                                GtkNotebookPage * page,
839
 
 *                                gint page_num, GList * tl)    
 
834
 *                                gint page_num, GList * tl)
840
835
 *
841
836
 * Description
842
837
 *   sets gui to new passage
847
842
void gui_notebook_main_switch_page(GtkNotebook * notebook,
848
843
                                         GtkNotebookPage * page,
849
844
                                         gint page_num, GList **tl)
850
 
 
845
{
851
846
        gboolean comm_showing;
852
847
        gint number_of_pages = gtk_notebook_get_n_pages(notebook);
853
848
        PASSAGE_TAB_INFO *pt;
861
856
        /*
862
857
         * this is needed to stop seg fault if the left tab is closed when
863
858
         * there are only two tabs - because number_of_pages equals 2 even
864
 
         * thought there is only 1. 
 
859
         * thought there is only 1.
865
860
         */
866
 
        if(number_of_pages == 2 && removed_page == 0)
 
861
        if (number_of_pages == 2 && removed_page == 0)
867
862
                pt = (PASSAGE_TAB_INFO*)g_list_nth_data(*tl, 0);
868
863
        else
869
864
                pt = (PASSAGE_TAB_INFO*)g_list_nth_data(*tl, page_num);
870
865
        removed_page = 1;
871
866
        //cur_passage_tab = pt;
872
867
 
873
 
#ifdef USE_TREEVIEW_PATH        
874
 
        if(cur_passage_tab && cur_passage_tab->book_mod)
875
 
                gui_collapse_treeview_to_book (GTK_TREE_VIEW (sidebar.module_list), 
 
868
#ifdef USE_TREEVIEW_PATH
 
869
        if (cur_passage_tab && cur_passage_tab->book_mod)
 
870
                gui_collapse_treeview_to_book (GTK_TREE_VIEW (sidebar.module_list),
876
871
                                               cur_passage_tab->book_mod);
877
872
#endif /* USE_TREEVIEW_PATH */
878
 
        
879
 
        if(!pt->showparallel) { 
880
 
                if(cur_passage_tab && cur_passage_tab->paratab)
 
873
 
 
874
        if (!pt->showparallel) {
 
875
                if (cur_passage_tab && cur_passage_tab->paratab)
881
876
                        gtk_widget_hide(cur_passage_tab->paratab);
882
877
                gtk_widget_show(widgets.hpaned);
883
878
        }
884
 
        
 
879
 
885
880
        set_current_tab (pt);
886
881
 
887
882
        companion_activity = TRUE;
888
 
        if(pt->showparallel) {
 
883
        if (pt->showparallel) {
889
884
                gtk_widget_hide(widgets.hpaned);
890
 
                if(pt->paratab)
891
 
                        gtk_widget_show(pt->paratab);           
 
885
                if (pt->paratab)
 
886
                        gtk_widget_show(pt->paratab);
892
887
                companion_activity = FALSE;
893
888
                page_change = FALSE;
894
889
                settings.paratab_showing = TRUE;
895
890
                return;
896
891
        } else
897
892
                settings.paratab_showing = FALSE;
898
 
                
899
 
        
 
893
 
 
894
 
900
895
        //sets the book mod and key
901
896
        main_display_book(pt->book_mod, pt->book_offset);
902
 
        
 
897
 
903
898
#ifdef USE_TREEVIEW_PATH
904
899
        if (pt->showcomms && pt->book_mod)
905
 
                gui_expand_treeview_to_path (GTK_TREE_VIEW (sidebar.module_list), 
 
900
                gui_expand_treeview_to_path (GTK_TREE_VIEW (sidebar.module_list),
906
901
                                             pt->book_mod);
907
902
#endif /* USE_TREEVIEW_PATH */
908
 
        
 
903
 
909
904
        comm_showing = settings.comm_showing;
910
905
        settings.comm_showing = 1;
911
906
        //sets the commentary mod and key
912
907
        main_display_commentary(pt->commentary_mod, pt->text_commentary_key);
913
 
        settings.comm_showing = comm_showing; 
 
908
        settings.comm_showing = comm_showing;
914
909
        //sets the text mod and key
915
910
        main_display_bible(pt->text_mod, pt->text_commentary_key);
916
 
        
 
911
 
917
912
        navbar_versekey.module_name = g_string_assign(navbar_versekey.module_name,pt->text_mod);
918
913
        navbar_versekey.key = g_string_assign(navbar_versekey.key,pt->text_commentary_key);
919
914
        main_update_nav_controls(pt->text_commentary_key);
920
 
        
 
915
 
921
916
        //sets the dictionary mod and key
922
917
        main_display_dictionary(pt->dictlex_mod, pt->dictlex_key);
923
918
 
939
934
 * Synopsis
940
935
 *   #include "tabbed_browser.h"
941
936
 *
942
 
 *   void gui_set_tab_label(const char *key, gboolean one_tab)  
 
937
 *   void gui_set_tab_label(const char *key, gboolean one_tab)
943
938
 *
944
939
 * Description
945
940
 *   sets tab label(s) to current verse.
949
944
 * Return value
950
945
 *   void
951
946
 */
952
 
 
 
947
 
953
948
void gui_set_tab_label(const gchar * key, gboolean one_tab)
954
949
{
955
950
        if (stop_refresh)
976
971
 * Synopsis
977
972
 *   #include "tabbed_browser.h"
978
973
 *
979
 
 *   void gui_set_named_tab_label(const char *key, PASSAGE_TAB_INFO *pt)        
 
974
 *   void gui_set_named_tab_label(const char *key, PASSAGE_TAB_INFO *pt)
980
975
 *
981
976
 * Description
982
977
 *   sets specified tab label to current verse
984
979
 * Return value
985
980
 *   void
986
981
 */
987
 
 
 
982
 
988
983
void gui_set_named_tab_label(const gchar * key, PASSAGE_TAB_INFO *pt, gboolean update)
989
984
{
990
985
        GString *str;
991
 
        
 
986
 
992
987
        if (stop_refresh)
993
988
                return;
994
989
 
995
990
        gui_reassign_strdup(&pt->text_commentary_key, (char *)key);
996
991
        str = pick_tab_label(pt);
997
 
                
 
992
 
998
993
        gtk_label_set_text(pt->tab_label, str->str);
999
994
        GS_message(("label = %s", str->str));
1000
995
        gtk_notebook_set_menu_label_text(
1007
1002
 
1008
1003
/******************************************************************************
1009
1004
 * Name
1010
 
 *  
 
1005
 *
1011
1006
 *
1012
1007
 * Synopsis
1013
1008
 *   #include "tabbed_browser.h"
1014
1009
 *
1015
 
 *      
 
1010
 *
1016
1011
 *
1017
1012
 * Description
1018
 
 *   
 
1013
 *
1019
1014
 *
1020
1015
 * Return value
1021
1016
 *   void
1022
1017
 */
1023
 
 
1024
 
void gui_update_tab_struct(const gchar * text_mod, 
1025
 
                           const gchar * commentary_mod, 
1026
 
                           const gchar * dictlex_mod, 
1027
 
                           const gchar * book_mod, 
 
1018
 
 
1019
void gui_update_tab_struct(const gchar * text_mod,
 
1020
                           const gchar * commentary_mod,
 
1021
                           const gchar * dictlex_mod,
 
1022
                           const gchar * book_mod,
1028
1023
                           const gchar * dictlex_key,
1029
1024
                           const gchar * book_offset,
1030
1025
                           gboolean comm_showing,
1032
1027
                           gboolean showpreview,
1033
1028
                           gboolean showcomms,
1034
1029
                           gboolean showdicts)
1035
 
{       
 
1030
{
1036
1031
        if (stop_refresh)
1037
1032
                return;
1038
1033
 
1039
 
/*      if(!settings.browsing)
 
1034
/*      if (!settings.browsing)
1040
1035
                return;
1041
1036
*/
1042
 
        
1043
 
        if(page_change)
 
1037
 
 
1038
        if (page_change)
1044
1039
                return;
1045
1040
        if (!cur_passage_tab)
1046
1041
                return;
1049
1044
        cur_passage_tab->showcomms   = showcomms;
1050
1045
        cur_passage_tab->showdicts   = showdicts;
1051
1046
 
1052
 
        if(text_mod) {
 
1047
        if (text_mod) {
1053
1048
                gui_reassign_strdup(&cur_passage_tab->text_mod, (char *)text_mod);
1054
1049
        }
1055
 
        if(commentary_mod) {
 
1050
        if (commentary_mod) {
1056
1051
                cur_passage_tab->comm_showing = comm_showing;
1057
1052
                gui_reassign_strdup(&cur_passage_tab->commentary_mod, (char *)commentary_mod);
1058
 
        } 
1059
 
        if(dictlex_mod) {
 
1053
        }
 
1054
        if (dictlex_mod) {
1060
1055
                gui_reassign_strdup(&cur_passage_tab->dictlex_mod, (char *)dictlex_mod);
1061
 
        } 
1062
 
        if(book_mod) {
 
1056
        }
 
1057
        if (book_mod) {
1063
1058
                cur_passage_tab->comm_showing = comm_showing;
1064
1059
                gui_reassign_strdup(&cur_passage_tab->book_mod, (char *)book_mod);
1065
1060
        }
1066
 
        if(book_offset) {
 
1061
        if (book_offset) {
1067
1062
                gui_reassign_strdup(&cur_passage_tab->book_offset, (char *)book_offset);
1068
1063
        }
1069
 
        if(dictlex_key) {
 
1064
        if (dictlex_key) {
1070
1065
                gui_reassign_strdup(&cur_passage_tab->dictlex_key, (char *)dictlex_key);
1071
1066
        }
1072
1067
}
1089
1084
void gui_open_passage_in_new_tab(gchar *verse_key)
1090
1085
{
1091
1086
        PASSAGE_TAB_INFO *pt;
1092
 
        
 
1087
 
1093
1088
        if (stop_refresh)
1094
1089
                return;
1095
1090
 
1096
 
        if(!settings.browsing)
 
1091
        if (!settings.browsing)
1097
1092
                return;
1098
1093
 
1099
1094
        if ((pt = g_new0(PASSAGE_TAB_INFO, 1)) == NULL) {
1110
1105
        pt->dictlex_key = g_strdup(settings.dictkey);
1111
1106
        pt->book_offset = g_strdup_printf("%ld",settings.book_offset);
1112
1107
        pt->comm_showing = settings.comm_showing;
1113
 
        
1114
 
        if(cur_passage_tab && cur_passage_tab->showparallel) {
 
1108
 
 
1109
        if (cur_passage_tab && cur_passage_tab->showparallel) {
1115
1110
                pt->showtexts   = 1;
1116
1111
                pt->showcomms   = 1;
1117
1112
                pt->showdicts   = 1;
1120
1115
                pt->showcomms   = settings.showcomms;
1121
1116
                pt->showdicts   = settings.showdicts;
1122
1117
        }
1123
 
        
 
1118
 
1124
1119
        pt->showpreview = settings.showpreview;
1125
1120
        pt->showparallel        = FALSE;
1126
1121
 
1127
 
        pt->history_items = 0;  
 
1122
        pt->history_items = 0;
1128
1123
        pt->current_history_item = 0;
1129
1124
        pt->first_back_click = TRUE;
1130
1125
        main_add_tab_history_item((PASSAGE_TAB_INFO*)pt);
1131
 
        
1132
 
        passage_list = g_list_append(passage_list, (PASSAGE_TAB_INFO*)pt);      
 
1126
 
 
1127
        passage_list = g_list_append(passage_list, (PASSAGE_TAB_INFO*)pt);
1133
1128
        //set_current_tab(pt);
1134
1129
        notebook_main_add_page(pt);
1135
 
        
 
1130
 
1136
1131
        gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_main),
1137
1132
                                gtk_notebook_page_num
1138
1133
                                (GTK_NOTEBOOK(widgets.notebook_main),
1159
1154
void gui_open_parallel_view_in_new_tab(void)
1160
1155
{
1161
1156
        PASSAGE_TAB_INFO *pt;
1162
 
        
 
1157
 
1163
1158
        if (stop_refresh)
1164
1159
                return;
1165
1160
 
1166
 
        if(!settings.browsing)
 
1161
        if (!settings.browsing)
1167
1162
                return;
1168
 
        
 
1163
 
1169
1164
        if ((pt = g_new0(PASSAGE_TAB_INFO, 1)) == NULL) {
1170
1165
                gui_generic_warning("Could not allocate a new tab");
1171
1166
                return;
1184
1179
        pt->comm_showing = FALSE;
1185
1180
 
1186
1181
        pt->text_commentary_key = g_strdup(settings.currentverse);
1187
 
        pt->dictlex_key = g_strdup(settings.dictkey);   
 
1182
        pt->dictlex_key = g_strdup(settings.dictkey);
1188
1183
        pt->book_offset = g_strdup_printf("%ld",settings.book_offset);
1189
 
        
 
1184
 
1190
1185
        passage_list = g_list_append(passage_list, (PASSAGE_TAB_INFO*)pt);
1191
1186
        set_current_tab(pt);
1192
1187
        gui_recompute_view_menu_choices();
1222
1217
{
1223
1218
        PASSAGE_TAB_INFO *pt;
1224
1219
        gint module_type;
1225
 
        
 
1220
 
1226
1221
        if (stop_refresh)
1227
1222
                return;
1228
1223
 
1229
 
        if(!settings.browsing)
 
1224
        if (!settings.browsing)
1230
1225
                return;
1231
 
        
 
1226
 
1232
1227
        if ((pt = g_new0(PASSAGE_TAB_INFO, 1)) == NULL) {
1233
1228
                gui_generic_warning("Could not allocate a new tab");
1234
1229
                return;
1288
1283
        }
1289
1284
 
1290
1285
        pt->text_commentary_key = g_strdup(settings.currentverse);
1291
 
        pt->dictlex_key = g_strdup(settings.dictkey);   
 
1286
        pt->dictlex_key = g_strdup(settings.dictkey);
1292
1287
        pt->book_offset = g_strdup_printf("%ld",settings.book_offset);
1293
 
        
 
1288
 
1294
1289
        passage_list = g_list_append(passage_list, (PASSAGE_TAB_INFO*)pt);
1295
1290
        //set_current_tab(pt);
1296
1291
        notebook_main_add_page(pt);
1297
 
        
 
1292
 
1298
1293
        gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets.notebook_main),
1299
1294
                                gtk_notebook_page_num
1300
1295
                                (GTK_NOTEBOOK(widgets.notebook_main),
1321
1316
void gui_close_all_tabs(void)
1322
1317
{
1323
1318
        gint i;
1324
 
        gint number_of_pages = 
 
1319
        gint number_of_pages =
1325
1320
                gtk_notebook_get_n_pages(GTK_NOTEBOOK(widgets.notebook_main));
1326
1321
 
1327
1322
        if (stop_refresh)
1328
1323
                return;
1329
1324
 
1330
1325
        for(i = number_of_pages - 1; i > -1; i--) {
1331
 
                PASSAGE_TAB_INFO *pt = 
 
1326
                PASSAGE_TAB_INFO *pt =
1332
1327
                        (PASSAGE_TAB_INFO*)g_list_nth_data(passage_list, (guint)i);
1333
1328
                passage_list = g_list_remove(passage_list, pt);
1334
1329
                g_free(pt->text_mod);
1341
1336
                g_free(pt);
1342
1337
                gtk_notebook_remove_page(GTK_NOTEBOOK(widgets.notebook_main), i);
1343
1338
        }
1344
 
        
 
1339
 
1345
1340
        g_list_free(passage_list);
1346
1341
        passage_list = NULL;
1347
1342
        cur_passage_tab = NULL;
1410
1405
                if (pagenum > 0){
1411
1406
                        gtk_notebook_set_current_page(
1412
1407
                                GTK_NOTEBOOK(widgets.notebook_main), 0);
1413
 
                        cur_passage_tab = (PASSAGE_TAB_INFO*)           
 
1408
                        cur_passage_tab = (PASSAGE_TAB_INFO*)
1414
1409
                                g_list_nth_data(passage_list, (guint)0);
1415
1410
                }
1416
1411
        }
1417
 
        
 
1412
 
1418
1413
        stop_refresh = TRUE;
1419
 
        while (gtk_events_pending())
1420
 
                gtk_main_iteration();
 
1414
        sync_windows();
1421
1415
        stop_refresh = FALSE;
1422
 
        
 
1416
 
1423
1417
        passage_list = g_list_remove(passage_list, pt);
1424
 
        if(pt->text_mod) g_free(pt->text_mod);
1425
 
        if(pt->commentary_mod) g_free(pt->commentary_mod);
1426
 
        if(pt->dictlex_mod) g_free(pt->dictlex_mod);
1427
 
        if(pt->book_mod) g_free(pt->book_mod);
1428
 
        if(pt->text_commentary_key) g_free(pt->text_commentary_key);
1429
 
        if(pt->dictlex_key) g_free(pt->dictlex_key);
1430
 
        if(pt->book_offset) g_free(pt->book_offset);
1431
 
        if(pt->showparallel) {
 
1418
        if (pt->text_mod) g_free(pt->text_mod);
 
1419
        if (pt->commentary_mod) g_free(pt->commentary_mod);
 
1420
        if (pt->dictlex_mod) g_free(pt->dictlex_mod);
 
1421
        if (pt->book_mod) g_free(pt->book_mod);
 
1422
        if (pt->text_commentary_key) g_free(pt->text_commentary_key);
 
1423
        if (pt->dictlex_key) g_free(pt->dictlex_key);
 
1424
        if (pt->book_offset) g_free(pt->book_offset);
 
1425
        if (pt->showparallel) {
1432
1426
                gtk_widget_hide(pt->paratab);
1433
1427
                gui_destroy_parallel_tab();
1434
1428
                settings.showparatab = FALSE;
1470
1464
        removed_page = 1;
1471
1465
        cur_passage_tab = NULL;
1472
1466
        passage_list = NULL;
1473
 
        
 
1467
 
1474
1468
        gui_load_tabs(tabs ? default_tab_filename : no_tab_filename);
1475
1469
 
1476
1470
        g_signal_connect(GTK_OBJECT(widgets.notebook_main),
1479
1473
                           (gui_notebook_main_switch_page), &passage_list);
1480
1474
        g_signal_connect(GTK_OBJECT(widgets.button_new_tab), "clicked",
1481
1475
                           G_CALLBACK(on_notebook_main_new_tab_clicked), NULL);
1482
 
                
 
1476
 
1483
1477
        //show the new tab button here instead of in main_window.c so it
1484
1478
        //doesn't get shown if !settings.browsing
1485
1479
        gtk_widget_show(widgets.button_new_tab);
1486
1480
        gui_notebook_main_switch_page(GTK_NOTEBOOK(widgets.notebook_main),
1487
1481
                                         NULL,
1488
 
                                         settings.tab_page, 
 
1482
                                         settings.tab_page,
1489
1483
                                        &passage_list);
1490
1484
}
1491
1485
 
1496
1490
 * Synopsis
1497
1491
 *   #include "tabbed_browser.h"
1498
1492
 *
1499
 
 *  void gui_notebook_main_shutdown(int tabs)   
 
1493
 *  void gui_notebook_main_shutdown(int tabs)
1500
1494
 *
1501
1495
 * Description
1502
1496
 *   shut down main notebook and clean mem
1505
1499
 *   void
1506
1500
 */
1507
1501
void gui_notebook_main_shutdown(int tabs)
1508
 
{       
 
1502
{
1509
1503
        if (stop_refresh)
1510
1504
                return;
1511
1505
 
1554
1548
static
1555
1549
int _is_paratab_showing (void)
1556
1550
{
1557
 
        if(settings.paratab_showing)
 
1551
        if (settings.paratab_showing)
1558
1552
                return 1;
1559
1553
        return 0;
1560
1554
}
1594
1588
{
1595
1589
        if (on)
1596
1590
                _tabs_on ();
1597
 
        else 
1598
 
                _tabs_off ();   
 
1591
        else
 
1592
                _tabs_off ();
1599
1593
}