-
Notifications
You must be signed in to change notification settings - Fork 2
/
gtk_settings.c
1271 lines (1041 loc) · 50.9 KB
/
gtk_settings.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "gtk_settings.h"
/** static globals to eliminate tracking unnecessary variables in mainwin_t */
static GtkWidget *settingswin; /* settings window */
/** settings keypress handler */
static gboolean on_settings_keypress (GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
switch (event->keyval)
{
case GDK_KEY_Escape: /* close dialog if user presses ESC */
settings_btncancel (widget, data);
break;
}
return FALSE; /* TRUE - no further processing */
}
/** settings window create */
GtkWidget *create_settings_dlg (gpointer data)
{
mainwin_t *app = data;
einst_t *einst = app->einst[app->focused];
kinst_t *inst = einst->inst;
/* variables */
GtkWidget *vbox; /* vbox - main container */
GtkWidget *notebook; /* notebook in vbox */
GtkWidget *vboxnb; /* vboxnb - vbox in each notebook page */
GtkWidget *frame; /* frames to section vboxnb */
GtkWidget *table; /* table for each frame */
GtkWidget *hbtweak; /* hbox to left-justify table element */
GtkWidget *label; /* generic label */
GtkWidget *toplabel; /* label above settings */
GtkWidget *hbox; /* hbox container */
GtkWidget *btnok; /* button OK */
GtkWidget *btncancel; /* button Cancel */
GtkWidget *fontbtn; /* Font Button */
GtkWidget *chkdynwrap; /* checkbox - dynamic word wrap */
GtkWidget *chkshowdwrap; /* checkbox - show wrap markers */
GtkWidget *chksmarthe; /* checkbox - smart home/end */
GtkWidget *chkwraptxtcsr; /* checkbox - wrap text cursor */
GtkWidget *chkpgudmvscsr; /* checkbox - PgUp/PgDn moves cursor */
GtkWidget *chkcsrtarrow; /* checkbox - use ctrl_shift_right_fix */
GtkWidget *chkwinrestore; /* checkbox - restore window size */
GtkWidget *chkexpandtab; /* checkbox - insert spaces for tab */
GtkWidget *chksmartbs; /* checkbox - smart backspace */
GtkWidget *chkshowtabs; /* checkbox - show tab markers */
GtkWidget *spintab; /* spinbutton - tabstop */
GtkWidget *chkindentwspc; /* checkbox - indent with spaces not tab */
GtkWidget *chkindentauto; /* checkbox - auto-indent new line */
GtkWidget *chkindentmixd; /* checkbox - Emacs mode mixed spaces/tabs */
GtkWidget *spinindent; /* spinbutton - indent width (softtab) */
GtkWidget *chkposcurend; /* checkbox - cursor position on open */
GtkWidget *chkcmtusesngl; /* checkbox - use single-line comment */
// GtkWidget *commentbox; /* combobox - holds single-line comment string */
GtkWidget *cmbeoldefault; /* combobox - set default EOL handling */
GtkWidget *chkunsaved; /* checkbox - prompt for unsaved on close */
GtkWidget *chktrimendws; /* checkbox - remove trailing whitespace */
GtkWidget *chkposixeof; /* checkbox - require POSIX end of file */
GtkWidget *spinrecent; /* spinbutton - no. files in recent chooser */
GtkWidget *chklinehghlt; /* checkbox - show current line highlight */
GtkWidget *chkshowmargin; /* checkbox - show right margin guide */
GtkObject *adjmarginwidth; /* adjustment - right marginwidth */
GtkWidget *spinmarginwidth; /* spinbutton - right marginwidth */
GtkWidget *chkenablecmplt; /* checkbox - enable word completion */
GtkObject *adjwordsize; /* adjustment - right marginwidth */
GtkWidget *spinwordsize; /* spinbutton - right marginwidth */
GtkObject *adjtab; /* adjustment - tab spinbutton */
GtkObject *adjind; /* adjustment - indent spinbutton */
GtkObject *adjrec; /* adjustment - recent spinbutton */
gint wnwidth = 500; /* initial dialog width and height */
gint wnheight = 520; /* maintian wnwidth - pgwidth = 80 */
gint pgwidth = 420; /* initial notebook page width and height */
gint pgheight = 440; /* (enforced by vboxnb width/height) */
/* MS Windows required additional space. */
/* create toplevel window */
if (!(settingswin = gtk_window_new (GTK_WINDOW_TOPLEVEL))) {
err_dialog ("create_settings_dlg() gtk_window_new failure.");
return NULL;
}
gtk_window_set_position (GTK_WINDOW (settingswin), GTK_WIN_POS_CENTER);
gtk_window_set_default_size (GTK_WINDOW (settingswin), wnwidth, wnheight);
gtk_window_set_title (GTK_WINDOW (settingswin), "GtkWrite Settings");
/* for inclusion in main app set modal and transient_for (to keep on top)
* gtk_window_set_modal (GtkWindow *window, gboolean modal);
* gtk_window_set_transient_for(GtkWindow *window, GtkWindow *parent)
*/
gtk_window_set_modal (GTK_WINDOW(settingswin), TRUE);
gtk_window_set_transient_for (GTK_WINDOW(settingswin),
GTK_WINDOW(app->window));
gtk_container_set_border_width (GTK_CONTAINER (settingswin), 5);
g_signal_connect (settingswin, "destroy",
G_CALLBACK (settings_btncancel), app);
/* main vbox container */
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (settingswin), vbox);
/* title over notebook, TODO: save label and change on page sel */
// toplabel = gtk_label_new ("Checkboxes - immediate effect, Entries - on Ok");
toplabel = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (toplabel),
"<b>Checkboxes - immediate effect, Entries - on Ok</b>");
gtk_misc_set_padding (GTK_MISC(toplabel), 0, 5);
gtk_box_pack_start (GTK_BOX (vbox), toplabel, FALSE, FALSE, 0);
gtk_widget_show (toplabel);
/* Create a new notebook, place the position of the tabs left,
* set tab-hborder and tab-vborder independently, kwinst menu
* of tabs currently not currently enabled. (see notes below)
*/
notebook = gtk_notebook_new ();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_LEFT);
/* set notebook tab border with g_object_set
* (gtk_notebook_set_tab_[hv]border is deprecated)
*
* set both h & v borders to a single value:
* g_object_set (GTK_NOTEBOOK (notebook), "tab-border", 4, NULL);
*
* set hborder and vborder independently:
*/
g_object_set (GTK_NOTEBOOK (notebook), "tab-vborder", 5,
"tab-hborder", 4, NULL);
/* enable kwinst menu showing all tabs if user rt-clicks on tab
* (not currently needed)
*
* gtk_notebook_popup_enable (GTK_NOTEBOOK (notebook));
*
* if enabled, you must replace:
* gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vboxnb, label);
* with:
* gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook), vboxnb, label, NULL);
* (already commented in code below)
*/
gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
// gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0);
/* appearance - setting page */
vboxnb = gtk_vbox_new (FALSE, 0);
gtk_widget_set_size_request (vboxnb, pgwidth, pgheight);
/* frame within page - font */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Font Selection");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame - font */
table = gtk_table_new (1, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* select font label is element 1 */
label = gtk_label_new ("Select Font:");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 1, 0, 1);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
/* font button calling font selection dialog */
fontbtn = gtk_font_button_new_with_font (app->fontname);
gtk_font_button_set_show_style (GTK_FONT_BUTTON(fontbtn), TRUE);
gtk_font_button_set_show_size (GTK_FONT_BUTTON(fontbtn), TRUE);
gtk_font_button_set_title (GTK_FONT_BUTTON(fontbtn),
"Select Editor Font & Size");
gtk_table_attach_defaults (GTK_TABLE (table), fontbtn, 1, 2, 0, 1);
gtk_widget_show (fontbtn);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page - word wrap */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Word Wrap");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (2, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chkdynwrap = gtk_check_button_new_with_mnemonic ("_Dynamic word wrap");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkdynwrap), app->dynwrap);
gtk_table_attach_defaults (GTK_TABLE (table), chkdynwrap, 0, 1, 0, 1);
gtk_widget_show (chkdynwrap);
chkshowdwrap = gtk_check_button_new_with_mnemonic ("Show _word wrap indicators");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkshowdwrap), app->showdwrap);
gtk_table_attach_defaults (GTK_TABLE (table), chkshowdwrap, 0, 1, 1, 2);
/* disable checkboxs until implemented? */
// gtk_widget_set_sensitive (chkshowdwrap, FALSE);
gtk_widget_show (chkshowdwrap);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page - cursor & selection */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Cursor & Selection");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (4, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chksmarthe = gtk_check_button_new_with_mnemonic ("_Smart home & end movement");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chksmarthe), app->smarthe);
gtk_table_attach_defaults (GTK_TABLE (table), chksmarthe, 0, 1, 0, 1);
gtk_widget_show (chksmarthe);
chkwraptxtcsr = gtk_check_button_new_with_mnemonic ("Wrap _cursor to next line");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkwraptxtcsr), app->wraptxtcsr);
gtk_table_attach_defaults (GTK_TABLE (table), chkwraptxtcsr, 0, 1, 1, 2);
gtk_widget_show (chkwraptxtcsr);
chkpgudmvscsr = gtk_check_button_new_with_mnemonic ("PgUp/PgDn _moves text cursor");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkpgudmvscsr), app->pgudmvscsr);
gtk_table_attach_defaults (GTK_TABLE (table), chkpgudmvscsr, 0, 1, 2, 3);
gtk_widget_show (chkpgudmvscsr);
chkcsrtarrow = gtk_check_button_new_with_mnemonic ("Ctrl + Shift + _Right-Arrow fix");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkcsrtarrow),
app->ctrl_shift_right_fix);
gtk_table_attach_defaults (GTK_TABLE (table), chkcsrtarrow, 0, 1, 3, 4);
gtk_widget_show (chkcsrtarrow);
/* pack frame into notebook vbox */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page - cursor & selection */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Visual Aids");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (2, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chklinehghlt = gtk_check_button_new_with_mnemonic ("_Highlight current line");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chklinehghlt), app->linehghlt);
gtk_table_attach_defaults (GTK_TABLE (table), chklinehghlt, 0, 1, 0, 1);
gtk_widget_show (chklinehghlt);
chkshowmargin = gtk_check_button_new_with_mnemonic ("Show right _margin");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkshowmargin), app->showmargin);
gtk_table_attach_defaults (GTK_TABLE (table), chkshowmargin, 0, 1, 1, 2);
gtk_widget_show (chkshowmargin);
/* value, lower, upper, step_increment, page_increment, page_size
* (as with statusbar, the value is line + 1)
*/
adjmarginwidth = gtk_adjustment_new (app->marginwidth, 1.0, 120.0, 1.0, 4.0, 0.0);
spinmarginwidth = gtk_spin_button_new (GTK_ADJUSTMENT(adjmarginwidth), 1.0, 0);
gtk_table_attach_defaults (GTK_TABLE (table), spinmarginwidth, 1, 2, 1, 2);
gtk_widget_show (spinmarginwidth);
/* pack frame into notebook vbox */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page - cursor & selection */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Window Size");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (1, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chkwinrestore = gtk_check_button_new_with_mnemonic ("_Restore window size at start");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkwinrestore), app->winrestore);
gtk_table_attach_defaults (GTK_TABLE (table), chkwinrestore, 0, 1, 0, 1);
gtk_widget_show (chkwinrestore);
/* save window size button */
GtkWidget *btn_savesize;
if (app->winszsaved)
btn_savesize = gtk_button_new_with_mnemonic ("Save Si_ze on Exit");
else
btn_savesize = gtk_button_new_with_mnemonic ("Save Current Si_ze");
gtk_widget_set_size_request (btn_savesize, 80, 24);
gtk_table_attach_defaults (GTK_TABLE (table), btn_savesize, 1, 2, 0, 1);
gtk_widget_show (btn_savesize);
/* pack frame into notebook vbox */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* label for tab */
/* TODO: set tab borders (hborder/vborder, etc..) */
label = gtk_label_new ("Appearance");
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vboxnb, label);
/* use if gtk_notebook_popup_enable () set above */
// gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook), vboxnb, label, NULL);
gtk_widget_show (vboxnb);
/* editing - setting page */
vboxnb = gtk_vbox_new (FALSE, 0);
gtk_widget_set_size_request (vboxnb, pgwidth, pgheight);
/* frame within page */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Tabulators");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (4, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chkexpandtab = gtk_check_button_new_with_mnemonic ("_Insert spaces instead of tab");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkexpandtab), app->expandtab);
gtk_table_attach_defaults (GTK_TABLE (table), chkexpandtab, 0, 1, 0, 1);
gtk_widget_show (chkexpandtab);
chksmartbs = gtk_check_button_new_with_mnemonic ("Smart _backspace (to tab)");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chksmartbs), app->smartbs);
gtk_table_attach_defaults (GTK_TABLE (table), chksmartbs, 0, 1, 1, 2);
gtk_widget_show (chksmartbs);
chkshowtabs = gtk_check_button_new_with_mnemonic ("_Show tab markers");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkshowtabs), app->showtabs);
gtk_table_attach_defaults (GTK_TABLE (table), chkshowtabs, 0, 1, 2, 3);
gtk_widget_show (chkshowtabs);
label = gtk_label_new ("Set tab size (spaces):");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 1, 3, 4);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
/* value, lower, upper, step_increment, page_increment, page_size
* (as with statusbar, the value is line + 1)
*/
adjtab = gtk_adjustment_new (app->tabstop, 1.0, 80.0, 1.0, 4.0, 0.0);
spintab = gtk_spin_button_new (GTK_ADJUSTMENT(adjtab), 1.0, 0);
gtk_table_attach_defaults (GTK_TABLE (table), spintab, 1, 2, 3, 4);
gtk_widget_show (spintab);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Indentation Rules");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (4, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chkindentwspc = gtk_check_button_new_with_mnemonic ("_Use spaces to indent");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkindentwspc), app->indentwspc);
gtk_table_attach_defaults (GTK_TABLE (table), chkindentwspc, 0, 1, 0, 1);
gtk_widget_show (chkindentwspc);
chkindentauto = gtk_check_button_new_with_mnemonic ("_Auto-indent new lines");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkindentauto), app->indentauto);
gtk_table_attach_defaults (GTK_TABLE (table), chkindentauto, 0, 1, 1, 2);
gtk_widget_show (chkindentauto);
chkindentmixd = gtk_check_button_new_with_mnemonic ("_Emacs style mixed mode");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkindentmixd), app->indentmixd);
gtk_table_attach_defaults (GTK_TABLE (table), chkindentmixd, 0, 1, 2, 3);
gtk_widget_show (chkindentmixd);
label = gtk_label_new ("Set indent size (spaces):");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 1, 3, 4);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
/* value, lower, upper, step_increment, page_increment, page_size
* (page_size other than 0.0 is deprecated)
*/
adjind = gtk_adjustment_new (app->softtab, 1.0, 80.0, 1.0, 2.0, 0.0);
spinindent = gtk_spin_button_new (GTK_ADJUSTMENT(adjind), 1.0, 0);
gtk_table_attach_defaults (GTK_TABLE (table), spinindent, 1, 2, 3, 4);
gtk_widget_show (spinindent);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Comment Settings");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (2, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs (with description) */
chkcmtusesngl = gtk_check_button_new_with_mnemonic ("Use single-line _comment");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkcmtusesngl), app->cmtusesingle);
gtk_table_attach_defaults (GTK_TABLE (table), chkcmtusesngl, 0, 1, 0, 1);
gtk_widget_show (chkcmtusesngl);
label = gtk_label_new ("(overrides auto-block comment use)");
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1);
gtk_widget_show (label);
/* add single-line comment entry to be used no sourceview or to override */
label = gtk_label_new ("Single-line Comment String:");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 1, 1, 2);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
app->cmtentry = gtk_entry_new();
const GtkBorder brd = { 2, 2, 2, 2 }; /* left, right, top, bottom */
gtk_entry_set_max_length (GTK_ENTRY(app->cmtentry), 8);
gtk_entry_set_has_frame (GTK_ENTRY(app->cmtentry), TRUE);
gtk_entry_set_inner_border (GTK_ENTRY(app->cmtentry), &brd);
if (inst->language && inst->comment_single)
gtk_entry_set_text (GTK_ENTRY(app->cmtentry), inst->comment_single);
else {
gchar *comment = app->comment ? app->comment : "<unset>";
gtk_entry_set_text (GTK_ENTRY(app->cmtentry), comment);
}
gtk_table_attach_defaults (GTK_TABLE (table), app->cmtentry, 1, 2, 1, 2);
gtk_widget_show (app->cmtentry);
/* show language and auto-lookup of comment-syntax */
gtk_table_resize (GTK_TABLE (table), 4, 2);
if (inst->language) {
const gchar *lang = gtk_source_language_get_name (inst->language);
gchar *msg;
label = gtk_label_new ("GTK SourceView Comment Auto-detect/Lookup");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 2, 2, 3);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
if ((inst->comment_blk_beg && inst->comment_blk_end)) {
if (inst->comment_single)
msg = g_markup_printf_escaped ("<tt> </tt>language:<tt><b> %s </b></tt>"
"single-line:<tt><b> '%s' </b></tt>"
"block:<tt><b> '%s...%s'</b></tt>",
lang, inst->comment_single,
inst->comment_blk_beg, inst->comment_blk_end);
else
msg = g_markup_printf_escaped ("<tt> </tt>language:<tt><b> N/A </b></tt>"
"single-line:<tt><b> '%s' </b></tt>"
"block:<tt><b> '%s...%s'</b></tt>",
lang,
inst->comment_blk_beg, inst->comment_blk_end);
}
else if (inst->comment_single)
msg = g_markup_printf_escaped ("<tt> </tt>language:<tt><b> %s </b></tt>"
"single-line:<tt><b> '%s' </b></tt>"
"block:<tt><b> 'none ... none'</b></tt>",
lang, inst->comment_single);
else {
msg = g_markup_printf_escaped ("<tt> </tt>language:<tt><b> %s </b></tt>"
"(comment syntax not implemented)", lang);
}
label = gtk_label_new (NULL);
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_label_set_markup (GTK_LABEL(label), msg);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 2, 3, 4);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
g_free (msg);
}
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* label for tab */
/* TODO: set tab borders (hborder/vborder, etc..) */
label = gtk_label_new ("Editing");
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vboxnb, label);
/* use if gtk_notebook_popup_enable () set above */
// gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook), vboxnb, label, NULL);
gtk_widget_show (vboxnb);
/* File Load/Save - setting page */
vboxnb = gtk_vbox_new (FALSE, 0);
gtk_widget_set_size_request (vboxnb, pgwidth, pgheight);
/* frame within page - cursor positon on open */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Position Cursor on Open");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (1, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chkposcurend = gtk_check_button_new_with_mnemonic ("Positon cursor at _end");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkposcurend), app->poscurend);
gtk_table_attach_defaults (GTK_TABLE (table), chkposcurend, 0, 1, 0, 1);
gtk_widget_show (chkposcurend);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page - cursor positon on open */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Word Completion");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (2, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chkenablecmplt = gtk_check_button_new_with_mnemonic ("Enable _Word Completion");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkenablecmplt),
app->enablecmplt);
gtk_table_attach_defaults (GTK_TABLE (table), chkenablecmplt, 0, 1, 0, 1);
gtk_widget_show (chkenablecmplt);
label = gtk_label_new ("(enabled/disabled on next editor use)");
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1);
gtk_widget_show (label);
label = gtk_label_new ("Minimum completion characters:");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 1, 1, 2);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
/* value, lower, upper, step_increment, page_increment, page_size
* (as with statusbar, the value is line + 1)
*/
adjwordsize = gtk_adjustment_new (app->cmplwordsz, 2.0, 12.0, 1.0, 2.0, 0.0);
spinwordsize = gtk_spin_button_new (GTK_ADJUSTMENT(adjwordsize), 1.0, 0);
gtk_table_attach_defaults (GTK_TABLE (table), spinwordsize, 1, 2, 1, 2);
gtk_widget_show (spinwordsize);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "End-of-Line Handling/Selection");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
// table = gtk_table_new (2, 2, TRUE);
table = gtk_table_new (1, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* label left of combobox */
label = gtk_label_new ("Select Global EOL Handling:");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 1, 0, 1);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
/* end-of-line combobox */
cmbeoldefault = gtk_combo_box_text_new ();
// g_object_set (GTK_COMBO_BOX(cmbeoldefault), "xalign", 0.5, NULL);
/* no property, must gtk_container_get_children (), find label */
for (gint i = 0; i < EOLTXT_NO; i++)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(cmbeoldefault), app->eoltxt[i]);
gtk_combo_box_set_active (GTK_COMBO_BOX(cmbeoldefault), app->eoldefault);
gtk_table_attach_defaults (GTK_TABLE (table), cmbeoldefault, 1, 2, 0, 1);
gtk_widget_show (cmbeoldefault);
/* label below combobox - TODO update on "changed" signal */
// label = gtk_label_new (app->eoltxt[app->eoldefault]);
// hbtweak = gtk_hbox_new (FALSE, 0);
// gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
// gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 1, 2, 1, 2);
// gtk_widget_show (hbtweak);
// gtk_widget_show (label);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "User Notifications");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (1, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chkunsaved = gtk_check_button_new_with_mnemonic ("Warn of _unsaved on close");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkunsaved), app->warnunsaved);
gtk_table_attach_defaults (GTK_TABLE (table), chkunsaved, 0, 1, 0, 1);
gtk_widget_show (chkunsaved);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "Automatic Cleanups on Load/Save");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (2, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
/* options checkboxs */
chktrimendws = gtk_check_button_new_with_mnemonic ("_Remove trailing whitespace");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chktrimendws), app->trimendws);
gtk_table_attach_defaults (GTK_TABLE (table), chktrimendws, 0, 1, 0, 1);
gtk_widget_show (chktrimendws);
chkposixeof = gtk_check_button_new_with_mnemonic ("Require _POSIX end-of-file");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkposixeof), app->posixeof);
gtk_table_attach_defaults (GTK_TABLE (table), chkposixeof, 0, 1, 1, 2);
gtk_widget_show (chkposixeof);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* frame within page */
frame = gtk_frame_new (NULL);
gtk_frame_set_label (GTK_FRAME (frame), "File Chooser Settings");
gtk_frame_set_label_align (GTK_FRAME (frame), 0.0, 0.5);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
gtk_widget_show (frame);
/* table inside frame */
table = gtk_table_new (1, 2, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 3);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
label = gtk_label_new ("No. Files in Recent Chooser:");
hbtweak = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbtweak), label, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), hbtweak, 0, 1, 0, 1);
gtk_widget_show (hbtweak);
gtk_widget_show (label);
/* value, lower, upper, step_increment, page_increment, page_size
* (page_size other than 0.0 is deprecated)
*/
adjrec = gtk_adjustment_new (app->nrecent, 1.0, 80.0, 1.0, 2.0, 0.0);
spinrecent = gtk_spin_button_new (GTK_ADJUSTMENT(adjrec), 1.0, 0);
gtk_table_attach_defaults (GTK_TABLE (table), spinrecent, 1, 2, 0, 1);
gtk_widget_show (spinrecent);
/* pack frame into notebook vboxnb */
gtk_box_pack_start (GTK_BOX (vboxnb), frame, FALSE, FALSE, 0);
/* label for tab */
/* TODO: set tab borders (hborder/vborder, etc..) */
label = gtk_label_new ("File Load/Save");
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vboxnb, label);
/* use if gtk_notebook_popup_enable () set above */
// gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook), vboxnb, label, NULL);
gtk_widget_show (vboxnb);
gtk_widget_show (notebook); /* show the notebook within vbox */
/* hbox (replacing table) button spacing */
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_set_spacing (GTK_BOX (hbox), 5);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
/* button sizes 80 x 24 */
btnok = gtk_button_new_with_mnemonic ("_Ok");
gtk_widget_set_size_request (btnok, 80, 24);
gtk_widget_show (btnok);
btncancel = gtk_button_new_with_mnemonic ("_Cancel");
gtk_widget_set_size_request (btncancel, 80, 24);
gtk_box_pack_end (GTK_BOX (hbox), btncancel, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (hbox), btnok, FALSE, FALSE, 0); // pack on rt-side.
gtk_widget_show (btncancel);
gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
gtk_widget_show (vbox); /* make all widgets visible */
/* settings callbacks - TODO: add remaining callbacks */
g_signal_connect (btncancel, "clicked",
G_CALLBACK (settings_btncancel), data);
g_signal_connect (btnok, "clicked",
G_CALLBACK (settings_btnok), data);
g_signal_connect (fontbtn, "font-set",
G_CALLBACK (settings_fontbtn), data);
g_signal_connect (chkdynwrap, "toggled",
G_CALLBACK (chkdynwrap_toggled), data);
g_signal_connect (chkshowdwrap, "toggled",
G_CALLBACK (chkshowdwrap_toggled), data);
g_signal_connect (chksmarthe, "toggled",
G_CALLBACK (chksmarthe_toggled), data);
g_signal_connect (chkwraptxtcsr, "toggled",
G_CALLBACK (chkwraptxtcsr_toggled), data);
g_signal_connect (chkpgudmvscsr, "toggled",
G_CALLBACK (chkpgudmvscsr_toggled), data);
g_signal_connect (chkcsrtarrow, "toggled",
G_CALLBACK (chkcsrtarrow_toggled), data);
g_signal_connect (chklinehghlt, "toggled",
G_CALLBACK (chklinehghlt_toggled), data);
g_signal_connect (chkshowmargin, "toggled",
G_CALLBACK (chkshowmargin_toggled), data);
g_signal_connect (spinmarginwidth, "value-changed",
G_CALLBACK (spinmarginwidth_changed), data);
g_signal_connect (chkenablecmplt, "toggled",
G_CALLBACK (chkenablecmplt_toggled), data);
g_signal_connect (spinwordsize, "value-changed",
G_CALLBACK (spinwordsize_changed), data);
g_signal_connect (chkwinrestore, "toggled",
G_CALLBACK (chkwinrestore_toggled), data);
g_signal_connect (btn_savesize, "clicked",
G_CALLBACK (btnwinsavesize), data);
g_signal_connect (chkexpandtab, "toggled",
G_CALLBACK (chkexpandtab_toggled), data);
g_signal_connect (chksmartbs, "toggled",
G_CALLBACK (chksmartbs_toggled), data);
g_signal_connect (chkshowtabs, "toggled",
G_CALLBACK (chkshowtabs_toggled), data);
g_signal_connect (spintab, "value-changed",
G_CALLBACK (spintab_changed), data);
g_signal_connect (chkindentwspc, "toggled",
G_CALLBACK (chkindentwspc_toggled), data);
g_signal_connect (chkindentauto, "toggled",
G_CALLBACK (chkindentauto_toggled), data);
g_signal_connect (chkindentmixd, "toggled",
G_CALLBACK (chkindentmixd_toggled), data);
g_signal_connect (spinindent, "value-changed",
G_CALLBACK (spinindent_changed), data);
g_signal_connect (chkcmtusesngl, "toggled",
G_CALLBACK (chkcmtusesngl_toggled), data);
g_signal_connect (app->cmtentry, "activate",
G_CALLBACK (entry_comment_activate), data);
g_signal_connect (chkposcurend, "toggled",
G_CALLBACK (chkposcurend_toggled), data);
g_signal_connect (cmbeoldefault, "changed",
G_CALLBACK (cmbeoldefault_changed), data);
g_signal_connect (chkunsaved, "toggled",
G_CALLBACK (chkunsaved_toggled), data);
g_signal_connect (chktrimendws, "toggled",
G_CALLBACK (chktrimendws_toggled), data);
g_signal_connect (chkposixeof, "toggled",
G_CALLBACK (chkposixeof_toggled), data);
g_signal_connect (settingswin, "key_press_event",
G_CALLBACK (on_settings_keypress), data);
g_signal_connect (spinrecent, "value-changed",
G_CALLBACK (spinrecent_changed), data);
gtk_widget_show (settingswin); /* show the window */
return (settingswin);
}
void settings_btncancel (GtkWidget *widget, gpointer data)
{
gtk_widget_destroy (settingswin);
if (widget || data) {}
}
void settings_btnok (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
einst_t *einst = app->einst[app->focused];
GtkWidget *view = einst->view;
entry_comment_activate (app->cmtentry, app);
if (app->showmargin)
gtk_source_view_set_right_margin_position (GTK_SOURCE_VIEW(view),
app->marginwidth);
gtk_widget_destroy (settingswin);
if (widget) {}
}
void settings_fontbtn (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
einst_t *einst = app->einst[app->focused];
GtkWidget *view = einst->view;
const gchar *newfont = gtk_font_button_get_font_name (GTK_FONT_BUTTON(widget));
PangoFontDescription *font_desc;
if (!newfont) {
err_dialog ("error: invalid font returned.");
return;
}
if (app->fontname)
g_free (app->fontname);
if (!(app->fontname = g_strdup (newfont))) {
err_dialog ("error:\ncopy of newfont to app->fontname failed.");
return;
}
font_desc = pango_font_description_from_string (app->fontname);
gtk_widget_modify_font (view, font_desc);
pango_font_description_free (font_desc);
}
void chkdynwrap_toggled (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
GtkWidget *view = app->einst[app->focused]->view;
app->dynwrap = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
app->dynwrap ? GTK_WRAP_WORD : GTK_WRAP_NONE);
}
void chkshowdwrap_toggled (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
app->showdwrap = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
}
void chksmarthe_toggled (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
app->smarthe = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
for (gint i = 0; i < app->nview; i++) {
GtkWidget *view = app->einst[i]->view;
if (app->smarthe)
gtk_source_view_set_smart_home_end (GTK_SOURCE_VIEW(view),
GTK_SOURCE_SMART_HOME_END_BEFORE);
else
gtk_source_view_set_smart_home_end (GTK_SOURCE_VIEW(view),
GTK_SOURCE_SMART_HOME_END_DISABLED);
}
}
void chkwraptxtcsr_toggled (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
app->wraptxtcsr = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
}
void chkpgudmvscsr_toggled (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
app->pgudmvscsr = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
}
void chkcsrtarrow_toggled (GtkWidget *widget, gpointer data)
{
mainwin_t *app = data;
app->ctrl_shift_right_fix =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
}
void chklinehghlt_toggled (GtkWidget *widget, gpointer data)
{