-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathaltyo_settings.vala
1876 lines (1729 loc) · 65.5 KB
/
altyo_settings.vala
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
using Gtk;
//vala bug, without CCode will generate AY_SETTINGS_terminal_palettes[5] = {{{
//https://bugzilla.gnome.org/show_bug.cgi?id=604371
//[CCode (cname = "AY_SETTINGS_terminal_palettes[5][16]",array_length_cname = "5",array_length= false)]
//[CCode (cname = "AY_SETTINGS_terminal_palettes[16]",array_length= false)]
/* Tango palette */
const Gdk.RGBA terminal_palettes_tango[16] = {
{ 0, 0, 0, 1 },
{ 0.8, 0, 0, 1 },
{ 0.305882, 0.603922, 0.0235294, 1 },
{ 0.768627, 0.627451, 0, 1 },
{ 0.203922, 0.396078, 0.643137, 1 },
{ 0.458824, 0.313725, 0.482353, 1 },
{ 0.0235294, 0.596078, 0.603922, 1 },
{ 0.827451, 0.843137, 0.811765, 1 },
{ 0.333333, 0.341176, 0.32549, 1 },
{ 0.937255, 0.160784, 0.160784, 1 },
{ 0.541176, 0.886275, 0.203922, 1 },
{ 0.988235, 0.913725, 0.309804, 1 },
{ 0.447059, 0.623529, 0.811765, 1 },
{ 0.678431, 0.498039, 0.658824, 1 },
{ 0.203922, 0.886275, 0.886275, 1 },
{ 0.933333, 0.933333, 0.92549, 1 }
};
/* Linux palette */
public const Gdk.RGBA terminal_palettes_linux[16] = {
{ 0, 0, 0, 1 },
{ 0.666667, 0, 0, 1 },
{ 0, 0.666667, 0, 1 },
{ 0.666667, 0.333333, 0, 1 },
{ 0, 0, 0.666667, 1 },
{ 0.666667, 0, 0.666667, 1 },
{ 0, 0.666667, 0.666667, 1 },
{ 0.666667, 0.666667, 0.666667, 1 },
{ 0.333333, 0.333333, 0.333333, 1 },
{ 1, 0.333333, 0.333333, 1 },
{ 0.333333, 1, 0.333333, 1 },
{ 1, 1, 0.333333, 1 },
{ 0.333333, 0.333333, 1, 1 },
{ 1, 0.333333, 1, 1 },
{ 0.333333, 1, 1, 1 },
{ 1, 1, 1, 1 }
};
/* XTerm palette */
const Gdk.RGBA terminal_palettes_xterm[16] = {
{ 0, 0, 0, 1 },
{ 0.803922, 0, 0, 1 },
{ 0, 0.803922, 0, 1 },
{ 0.803922, 0.803922, 0, 1 },
{ 0.117647, 0.564706, 1, 1 },
{ 0.803922, 0, 0.803922, 1 },
{ 0, 0.803922, 0.803922, 1 },
{ 0.898039, 0.898039, 0.898039, 1 },
{ 0.298039, 0.298039, 0.298039, 1 },
{ 1, 0, 0, 1 },
{ 0, 1, 0, 1 },
{ 1, 1, 0, 1 },
{ 0.27451, 0.509804, 0.705882, 1 },
{ 1, 0, 1, 1 },
{ 0, 1, 1, 1 },
{ 1, 1, 1, 1 }
};
/* RXVT palette */
const Gdk.RGBA terminal_palettes_rxvt[16] = {
{ 0, 0, 0, 1 },
{ 0.803922, 0, 0, 1 },
{ 0, 0.803922, 0, 1 },
{ 0.803922, 0.803922, 0, 1 },
{ 0, 0, 0.803922, 1 },
{ 0.803922, 0, 0.803922, 1 },
{ 0, 0.803922, 0.803922, 1 },
{ 0.980392, 0.921569, 0.843137, 1 },
{ 0.25098, 0.25098, 0.25098, 1 },
{ 1, 0, 0, 1 },
{ 0, 1, 0, 1 },
{ 1, 1, 0, 1 },
{ 0, 0, 1, 1 },
{ 1, 0, 1, 1 },
{ 0, 1, 1, 1 },
{ 1, 1, 1, 1 }
};
/* Solarized palette (1.0.0beta2): http://ethanschoonover.com/solarized */
const Gdk.RGBA terminal_palettes_solarized[16] = {
{ 0.02745, 0.211764, 0.258823, 1 },
{ 0.862745, 0.196078, 0.184313, 1 },
{ 0.521568, 0.6, 0, 1 },
{ 0.709803, 0.537254, 0, 1 },
{ 0.149019, 0.545098, 0.823529, 1 },
{ 0.82745, 0.211764, 0.509803, 1 },
{ 0.164705, 0.631372, 0.596078, 1 },
{ 0.933333, 0.909803, 0.835294, 1 },
{ 0, 0.168627, 0.211764, 1 },
{ 0.796078, 0.294117, 0.086274, 1 },
{ 0.345098, 0.431372, 0.458823, 1 },
{ 0.396078, 0.482352, 0.513725, 1 },
{ 0.513725, 0.580392, 0.588235, 1 },
{ 0.423529, 0.443137, 0.768627, 1 },
{ 0.57647, 0.631372, 0.631372, 1 },
{ 0.992156, 0.964705, 0.890196, 1 }
};
const string settings_base_css = """
vte-terminal,AYTerm {
-AYTerm-bg-color: @ayterm-bg-color;
-AYTerm-fg-color: @ayterm-fg-color;
-AYTerm-palette-0 : @ayterm-palette-0;
-AYTerm-palette-1 : @ayterm-palette-1;
-AYTerm-palette-2 : @ayterm-palette-2;
-AYTerm-palette-3 : @ayterm-palette-3;
-AYTerm-palette-4 : @ayterm-palette-4;
-AYTerm-palette-5 : @ayterm-palette-5;
-AYTerm-palette-6 : @ayterm-palette-6;
-AYTerm-palette-7 : @ayterm-palette-7;
-AYTerm-palette-8 : @ayterm-palette-8;
-AYTerm-palette-9 : @ayterm-palette-9;
-AYTerm-palette-10 : @ayterm-palette-10;
-AYTerm-palette-11 : @ayterm-palette-11;
-AYTerm-palette-12 : @ayterm-palette-12;
-AYTerm-palette-13 : @ayterm-palette-13;
-AYTerm-palette-14 : @ayterm-palette-14;
-AYTerm-palette-15 : @ayterm-palette-15;
}
#VTToggleButton .label {
/*font: 'Mono' 10px;*/
outline-width: 0px;
border-width:0px;
-outer-stroke-width: 0px;
margin:0px;
padding:0px;
}
#VTToggleButton {
outline-width: 0px;
border-color:alpha(#000000,0.0);
border-width: 0px;
border-image-width: 0px;
-outer-stroke-width: 0px;
border-radius: 3px;
border-style: solid;
background-image: none;
margin:0px;
padding:0px 0px 0px 0px;
}
#VTToggleButton:active {
text-shadow: none;
}
.window_multitabs {
border-width: 2px 2px 0px 2px;
border-color: #3C3B37;
border-style: solid;
padding:0px;
margin:0;
}
#terms_notebook {
border-width: 0px;
border-style: solid;
padding:0px;
margin:0;
}
#search_hbox .label:active {
border-color: @fg_color;
color: #FF0000;
}
#search_hbox .label:hover {
background-color: @ayterm-bg-color;
border-color: @fg_color;
color: #FF0000;
}
#search_hbox {
border-width: 0px 0px 0px 0px;
-outer-stroke-width: 0px;
border-radius: 0px 0px 0px 0px;
border-style: solid;
background-image: none;
margin:0px;
padding:0px 0px 1px 0px;
}
#HVBox {
border-width: 0px 2px 2px 2px;
border-style: solid;
}
#OffscreenWindow, #VTMainWindow,#HVBox_dnd_window {
border-width: 0px;
border-style: solid;
background-color: alpha(@ayterm-bg-color,0.0);
}
#HVBox,#quick_options_notebook{
background-color: @ayterm-bg-color;
}
#settings-scrolledwindow{
background-color: @bg_color;
}
#VTToggleButton{
box-shadow: none;
}
.window_single_tab {
border-width: 2px 2px 2px 2px;
border-style: solid;
}
""";
const string settings_css_solarized_dark="""
@define-color ayterm-bg-color alpha(#063541,1.00);
@define-color ayterm-fg-color #EDE7D4;
@define-color ayterm-palette-15 #FCF5E2;
@define-color ayterm-palette-14 #92A0A0;
@define-color ayterm-palette-13 #6B70C3;
@define-color ayterm-palette-12 #829395;
@define-color ayterm-palette-11 #647A82;
@define-color ayterm-palette-10 #576D74;
@define-color ayterm-palette-9 #CA4A15;
@define-color ayterm-palette-8 #002A35;
@define-color ayterm-palette-7 #EDE7D4;
@define-color ayterm-palette-6 #29A097;
@define-color ayterm-palette-5 #D23581;
@define-color ayterm-palette-4 #258AD1;
@define-color ayterm-palette-3 #B48800;
@define-color ayterm-palette-2 #849900;
@define-color ayterm-palette-1 #DB312E;
@define-color ayterm-palette-0 #063541;
@define-color tab-index-color @ayterm-palette-11;
@define-color username-color @ayterm-palette-2;
@define-color hostname-color @ayterm-palette-9;
#VTToggleButton {
-VTToggleButton-tab-index-color:@ayterm-palette-11;
-VTToggleButton-username-color:@ayterm-palette-2;
-VTToggleButton-hostname-color:@ayterm-palette-9;
background-color: alpha(@ayterm-bg-color,0.0);
color: @ayterm-fg-color;
}
#VTToggleButton:active{
background-color: @ayterm-palette-15;
background-image: none;
color: @ayterm-palette-11;
}
#VTToggleButton:hover {
background-color: @ayterm-palette-7;
background-image:none;
color: @ayterm-bg-color;
}
#VTToggleButton:active:hover{
background-color:@ayterm-palette-7;
background-image: none;
color: @ayterm-palette-0;
}
.window_multitabs {
border-color: #3C3B37;
border-style: solid;
}
#search_hbox .label:active {
border-color: @fg_color;
color: #FF0000;
}
#search_hbox .label:hover {
background-color: @ayterm-bg-color;
border-color: @fg_color;
color: #FF0000;
}
#search_hbox , #search_hbox .entry{
background-color: @ayterm-bg-color;
border-color: @bg_color;
color: #00FFAA;
background-image: none;
}
#HVBox , #main_vbox{
border-color: #3C3B37;
border-style: solid;
background-color: @ayterm-bg-color;
}
#OffscreenWindow, #VTMainWindow,#HVBox_dnd_window {
border-style: solid;
background-color: alpha(@ayterm-bg-color,0.0);
}
#HVBox,#quick_options_notebook{
background-color: @ayterm-bg-color;
}
#settings-scrolledwindow{
background-color: @bg_color;
}
#settings-scrolledwindow{
background-color: @bg_color;
}
#VTToggleButton{
box-shadow: none;
}
.window_single_tab {
border-color: #3C3B37;
border-style: solid;
}
.window_maximized{}
.window_multitabs{}
""";
const string settings_css_linux = """
@define-color ayterm-bg-color alpha(#000000,1.00);
@define-color ayterm-fg-color #AAAAAA;
@define-color ayterm-palette-15 #FFFFFF;
@define-color ayterm-palette-14 #54FFFF;
@define-color ayterm-palette-13 #FF54FF;
@define-color ayterm-palette-12 #5454FF;
@define-color ayterm-palette-11 #FFFF54;
@define-color ayterm-palette-10 #54FF54;
@define-color ayterm-palette-9 #FF5454;
@define-color ayterm-palette-8 #545454;
@define-color ayterm-palette-7 #AAAAAA;
@define-color ayterm-palette-6 #00AAAA;
@define-color ayterm-palette-5 #AA00AA;
@define-color ayterm-palette-4 #0000AA;
@define-color ayterm-palette-3 #AA5400;
@define-color ayterm-palette-2 #00AA00;
@define-color ayterm-palette-1 #AA0000;
@define-color ayterm-palette-0 #000000;
@define-color tab-index-color @ayterm-palette-11;
@define-color username-color @ayterm-palette-15;
@define-color hostname-color @ayterm-palette-11;
#VTToggleButton {
-VTToggleButton-tab-index-color:@ayterm-palette-11;
-VTToggleButton-username-color:@ayterm-palette-15;
-VTToggleButton-hostname-color:@ayterm-palette-11;
border-color:alpha(#000000,0.0);
background-color: alpha(#000000,0.0);
color: #AAAAAA;
box-shadow: none;
}
#VTToggleButton:active{
background-color: #00AAAA;
background-image: -gtk-gradient(radial,center center, 0,center center, 1, from (#00BBBB),to (#008888) );
color: #000000;
}
#VTToggleButton:hover {
background-color: #AAAAAA;
background-image: -gtk-gradient(radial,center center, 0,center center, 1, from (#AAAAAA),to (#777777) );
color: #000000;
}
#VTToggleButton:active:hover{
background-color: #00AAAA;
background-image: -gtk-gradient(radial,center center, 0,center center, 1, from (lighter(#00BBBB)),to (#008888) );
color: #000000;
}
.window_multitabs {
border-color: #3C3B37;
border-style: solid;
}
#search_hbox .label:active {
border-color: @fg_color;
color: #FF0000;
}
#search_hbox .label:hover {
background-color: @ayterm-bg-color;
border-color: @fg_color;
color: #FF0000;
}
#search_hbox {
background-color: @ayterm-bg-color;
border-color: @bg_color;
color: #00FFAA;
}
#HVBox {
border-color: #3C3B37;
border-style: solid;
background-color: @ayterm-bg-color;
}
#OffscreenWindow, #VTMainWindow,#HVBox_dnd_window {
border-style: solid;
background-color: alpha(@ayterm-bg-color,0.0);
}
#HVBox,#quick_options_notebook{
background-color: @ayterm-bg-color;
}
#settings-scrolledwindow{
background-color: @bg_color;
}
#settings-scrolledwindow{
background-color: @bg_color;
}
#VTToggleButton{
box-shadow: none;
}
.window_single_tab {
border-color: #3C3B37;
border-style: solid;
}
.window_maximized{}
.window_multitabs{}
""";
//terminal_palettes_rxvt;
public class point_ActionGroup_store {
public unowned Gtk.ActionGroup action_group;
public unowned Gtk.ListStore store;
public unowned AYSettings yasettings;
public point_ActionGroup_store(Gtk.ActionGroup ag,Gtk.ListStore st,AYSettings yas) {
this.action_group=ag;
this.store=st;
this.yasettings=yas;
}
}
public class AYSettings : AYTab{
private Gtk.Builder builder;
public AYObject ayobject {get;set;default=null;}
private Gtk.ListStore keybindings_store;
private string autorun_file;
private string monitor_name;/*save monitor name on which settings was opened*/
private bool ignore_on_loading;/*ignore some events when loading settings from ini file*/
private VTToggleButton vttbut;
public AYSettings(MySettings my_conf,Notebook notebook, int tab_index,AYObject ayo) {
base(my_conf, notebook, tab_index);
this.hbox.show();
this.hbox.check_resize();
this.tbutton.set_title(tab_index, _("AYsettings") );
this.ayobject=ayo;
if(this.ayobject.main_window.application.application_id!=null)
this.autorun_file = GLib.Environment.get_user_config_dir()+"/autostart"+"/"+this.ayobject.main_window.application.application_id+".desktop";
else{
if(my_conf.standalone_mode)
this.autorun_file = GLib.Environment.get_user_config_dir()+"/autostart"+"/altyo.standalone.desktop";
else
this.autorun_file = GLib.Environment.get_user_config_dir()+"/autostart"+"/altyo.none.desktop";
}
this.builder = new Gtk.Builder ();
try {
this.builder.add_from_resource ("/org/gnome/altyo/preferences.glade");
this.builder.add_from_resource("/org/gnome/altyo/encodings_list.glade");
this.keybindings_store = builder.get_object ("keybindings_store") as Gtk.ListStore;
var encodings_combo = builder.get_object ("terminal_default_encoding") as Gtk.ComboBox;
var encodinsg_store = this.builder.get_object ("encodings_liststore") as Gtk.ListStore;
encodinsg_store.set_sort_column_id(1,Gtk.SortType.ASCENDING);
encodings_combo.model=encodinsg_store;
//connect model from encodings_list.glade to preferences.glade
var del_combo = builder.get_object ("terminal_delete_binding") as Gtk.ComboBox;
del_combo.model= this.builder.get_object ("terminal_delete_binding_liststore") as Gtk.ListStore;
var bps_combo = builder.get_object ("terminal_backspace_binding") as Gtk.ComboBox;
bps_combo.model= this.builder.get_object ("terminal_delete_binding_liststore") as Gtk.ListStore;
this.builder.connect_signals(this);
var B = builder.get_object ("settings-scrolledwindow") as Gtk.Widget;
B.name="settings-scrolledwindow";
B.destroy.connect(()=>{debug("~settings-scrolledwindow");});
this.hbox.add(B);
var L = builder.get_object ("config_path_linkbutton") as Gtk.LinkButton;
L.label=my_conf.conf_file;
L.uri="file://"+my_conf.conf_file;
#if VTE_2_91
/*hide unavailable options*/
Gtk.Grid grid;
int r = 0;
Gtk.Widget? child;
grid = (builder.get_object ("grid9") as Gtk.Grid);
while( (child=grid.get_child_at(1,r)) != null){
switch(child.get_name()){
case "terminal_background_image_file":
case "terminal_background_fake_transparent":
case "terminal_background_fake_transparent_scroll":
case "terminal_tint_color":
case "terminal_background_saturation":
grid.remove_row(r);
break;
default:
r++;
break;
}
}
grid = (builder.get_object ("grid1") as Gtk.Grid);
while( (child=grid.get_child_at(1,r)) != null){
switch(child.get_name()){
case "terminal_visible_bell":
case "terminal_set_alternate_screen_scroll":
grid.remove_row(r);
break;
default:
r++;
break;
}
}
grid = (builder.get_object ("grid5") as Gtk.Grid);
r = 0;
while( (child=grid.get_child_at(1,r)) != null){
switch(child.get_name()){
case "terminal_word_chars":
grid.remove_row(r);
break;
default:
r++;
break;
}
}
#endif
this.vttbut = new VTToggleButton();
this.get_from_conf();
var font_button = (builder.get_object ("terminal_font") as Gtk.FontButton);
font_button.set_filter_func((family, face)=>{
//show only monospace fonts
bool ret = !face.is_synthesized() && family.is_monospace();
//~ debug("system_font=%d %s %s",(int)ret, family.get_name(), face.get_face_name());
return ret;
});
} catch (Error e) {
error ("loading menu builder file: %s", e.message);
}
if(my_conf.readonly){
var A = builder.get_object ("apply_button") as Gtk.Button;
A.sensitive=false;
var R = builder.get_object ("restore_button") as Gtk.Button;
R.sensitive=false;
R.tooltip_text=A.tooltip_text=_("Config is read only!");
}
}
~AYSettings(){
debug("~AYSettings");
}
[CCode (instance_pos = -1)]
public void on_font_set (Gtk.FontButton w) {
debug("New font is: %s",w.get_font_name());
}
[CCode (instance_pos = -1)]
public void on_animation_enabled_toggled (Gtk.CheckButton w) {
var B = builder.get_object ("animation_pull_steps") as Gtk.SpinButton;
if(B!=null){
B.sensitive=w.active;
}
}
[CCode (instance_pos = -1)]
public void on_workaround_if_focuslost_toggled (Gtk.CheckButton w) {
if(!this.ignore_on_loading && w.active){
string title=_("AltYo attention");
string msg=_("You must restart altyo for the workaround to take effect.");
this.ayobject.main_window.show_message_box(title,msg);
}
}
[CCode (instance_pos = -1)]
public void on_size_changed (Gtk.SpinButton w,Gtk.Label L) {
if(L!=null){
if(w.value>100){
L.label=_("px");
}else
if(w.value==100){
L.label=_("maximize");
}else{
L.label=_("%");
}
}
}
[CCode (instance_pos = -1)]
public void on_reset_terminal_background_image_file (Gtk.Button w,Gtk.FileChooserButton F) {
if(F!=null){
F.unselect_all();
}
}
[CCode (instance_pos = -1)]
public void on_apply(Gtk.Button w) {
this.apply();
}
[CCode (instance_pos = -1)]
public void on_close(Gtk.Button w) {
this.ayobject.action_group.set_sensitive(true);//activate
this.ayobject.action_group.get_action("open_settings").activate();
}
[CCode (instance_pos = -1)]
public void on_reset_to_defaults(Gtk.Button w) {
GLib.Timeout.add(50,()=>{this.ayobject.show_reset_to_defaults_dialog();return false;});//async call
}
[CCode (instance_pos = -1)]
public void accel_edited_cb (Gtk.CellRendererAccel cell, string path_string, uint accel_key, Gdk.ModifierType accel_mods, uint hardware_keycode){
debug("accel_edited_cb start");
this.ayobject.action_group.set_sensitive(true);
var path = new Gtk.TreePath.from_string (path_string);
if (path == null)
return;
Gtk.TreeIter iter;
if (!this.keybindings_store.get_iter (out iter, path))
return;
string? accel_path = null;
this.keybindings_store.get (iter, 0, out accel_path);
if (accel_path == null)
return;
Gtk.Action action=this.ayobject.action_group.get_action(this.get_name_from_path(accel_path));
if(this.ayobject.update_action_keybinding(action,accel_key,accel_mods)){
debug("accel_edited_cb name:%s ",accel_path);
string? name = this.get_name_from_path(accel_path);
if(name!=null){
var parsed_name=Gtk.accelerator_name (accel_key, accel_mods);
this.my_conf.set_accel_string(name,parsed_name);
if(name=="main_hotkey"){
this.ayobject.main_window.reconfigure();//check is it was correct, and not busy
var saved_key = this.my_conf.get_accel_string(name,"");
if(parsed_name != saved_key){
//some thing was wrong,update key value
uint accelerator_key;
Gdk.ModifierType accelerator_mods;
Gtk.accelerator_parse(saved_key,out accelerator_key,out accelerator_mods);
accel_key=accelerator_key;
accel_mods=accelerator_mods;
}
}
this.keybindings_store.set (iter, 2, accel_key);
this.keybindings_store.set (iter, 3, accel_mods);
this.my_conf.save();
}
}
}
[CCode (instance_pos = -1)]
public void accel_cleared_cb (Gtk.CellRendererAccel cell,string path_string){
debug("accel_cleared_cb start");
this.ayobject.action_group.set_sensitive(true);
var path = new Gtk.TreePath.from_string (path_string);
if (path == null)
return;
Gtk.TreeIter iter;
if (!this.keybindings_store.get_iter (out iter, path))
return;
string? accel_path = null;
this.keybindings_store.get (iter, 0, out accel_path);
if (accel_path == null)
return;
if(Gtk.AccelMap.change_entry(accel_path,0,0,false)){
string? name = get_name_from_path(accel_path);
if(name!=null){
this.my_conf.set_accel_string(name,"");//clear in config
this.keybindings_store.set (iter, 2, 0);
this.my_conf.save();
}
}
//~ settings.set_int (key, 0);
}
[CCode (instance_pos = -1)]
public void accel_editing_started_cb (Gtk.CellRenderer cell,
Gtk.CellEditable editable,
string path_string){
debug("accel_editing_started_cb");
this.ayobject.action_group.set_sensitive(false);
var tree = builder.get_object ("keybindings_treeview") as Gtk.TreeView;
tree.grab_focus();//so Gtk.CellRendererAccel will have a focus
}
[CCode (instance_pos = -1)]
public bool on_list_button_press_event(Gtk.Widget w,Gdk.EventButton event){
debug("command_list_button_press_event %s",w.name);
if((int)event.button == 3){//right mouse button
if(((Gtk.Buildable)w).get_name()=="terminal_autostart_session_treeview"){
var popup_menu = builder.get_object ("popup_command_list") as Gtk.Menu;
popup_menu.popup(null, null, null, event.button, event.time);
}else
if(((Gtk.Buildable)w).get_name()=="tab_title_format_regex_treeview"){
var popup_menu = builder.get_object ("popup_tab_title_format_regex") as Gtk.Menu;
popup_menu.popup(null, null, null, event.button, event.time);
}else
if(((Gtk.Buildable)w).get_name()=="terminal_url_regexps_treeview"){
var popup_menu = builder.get_object ("popup_terminal_url_regexps") as Gtk.Menu;
popup_menu.popup(null, null, null, event.button, event.time);
}
return true;
}
return false;
}
[CCode (instance_pos = -1)]
public void on_popup_command_list_add(Gtk.MenuItem item){
var store = builder.get_object ("terminal_autostart_session") as Gtk.ListStore;
TreeIter? data_iter = this.list_store_add_after_selected("terminal_autostart_session_treeview",store);
if(data_iter!=null){
store.set (data_iter,
0, "/bin/sh",
-1);
}
}
[CCode (instance_pos = -1)]
public void on_popup_command_list_remove(Gtk.MenuItem item){
var store = builder.get_object ("terminal_autostart_session") as Gtk.ListStore;
var view = builder.get_object ("terminal_autostart_session_treeview") as Gtk.TreeView;
if(store!=null && view!=null){
TreePath path;
TreeViewColumn s_column;
TreeIter? iter=null;
view.get_cursor(out path,out s_column);
if(store.get_iter(out iter,path))
if(!store.iter_has_child(iter)){
#if VALA_0_36
store.remove(ref iter);
#else
store.remove(iter);
#endif
if(store.get_iter(out iter,path))
view.set_cursor(path,null,false);
else if(path.prev())
view.set_cursor(path,null,false);
else if(path.up())
view.set_cursor(path,null,false);
}
}
}
[CCode (instance_pos = -1)]
public void on_popup_tab_title_format_regex_add(Gtk.MenuItem item){
var store = builder.get_object ("tab_title_format_regex") as Gtk.ListStore;
TreeIter? data_iter = this.list_store_add_after_selected("tab_title_format_regex_treeview",store);
if(data_iter!=null){
store.set (data_iter,
0, "",
1, "",
-1);
}
}
[CCode (instance_pos = -1)]
public void on_popup_tab_title_format_regex_remove(Gtk.MenuItem item){
var store = builder.get_object ("tab_title_format_regex") as Gtk.ListStore;
var view = builder.get_object ("tab_title_format_regex_treeview") as Gtk.TreeView;
if(store!=null && view!=null){
TreePath path;
TreeViewColumn s_column;
TreeIter? iter=null;
view.get_cursor(out path,out s_column);
if(store.get_iter(out iter,path))
if(!store.iter_has_child(iter)){
#if VALA_0_36
store.remove(ref iter);
#else
store.remove(iter);
#endif
if(store.get_iter(out iter,path))
view.set_cursor(path,null,false);
else if(path.prev())
view.set_cursor(path,null,false);
else if(path.up())
view.set_cursor(path,null,false);
}
}
}
[CCode (instance_pos = -1)]
public void on_popup_terminal_url_regexps_add(Gtk.MenuItem item){
var store = builder.get_object ("terminal_url_regexps") as Gtk.ListStore;
TreeIter? data_iter = this.list_store_add_after_selected("terminal_url_regexps_treeview",store);
if(data_iter!=null){
store.set (data_iter,
0, "",
1, "",
-1);
}
}
[CCode (instance_pos = -1)]
public void on_popup_terminal_url_regexps_remove(Gtk.MenuItem item){
var store = builder.get_object ("terminal_url_regexps") as Gtk.ListStore;
var view = builder.get_object ("terminal_url_regexps_treeview") as Gtk.TreeView;
if(store!=null && view!=null){
TreePath path;
TreeViewColumn s_column;
TreeIter? iter=null;
view.get_cursor(out path,out s_column);
if(store.get_iter(out iter,path))
if(!store.iter_has_child(iter)){
#if VALA_0_36
store.remove(ref iter);
#else
store.remove(iter);
#endif
if(store.get_iter(out iter,path))
view.set_cursor(path,null,false);
else if(path.prev())
view.set_cursor(path,null,false);
else if(path.up())
view.set_cursor(path,null,false);
}
}
}
[CCode (instance_pos = -1)]
public void on_terminal_autostart_session_cellrenderertext_edited (Gtk.CellRendererText renderer, string path_string, string new_text){
debug("on_terminal_autostart_session_cellrenderertext_edited start %s",path_string);
Gtk.ListStore? store=null;
store = builder.get_object("terminal_autostart_session") as Gtk.ListStore;
if(store == null) return;
var path = new Gtk.TreePath.from_string (path_string);
if (path == null) return;
Gtk.TreeIter iter;
if (!store.get_iter (out iter, path)) return;
store.set (iter,
0, new_text,
-1);
}
[CCode (instance_pos = -1)]
public void on_tab_title_format_regex_cellrenderertext_pattern_edited (Gtk.CellRendererText renderer, string path_string, string new_text){
debug("on_tab_title_format_regex_cellrenderertext_pattern_edited start %s",path_string);
Gtk.ListStore? store=null;
store = builder.get_object ("tab_title_format_regex") as Gtk.ListStore;
if(store == null) return;
var path = new Gtk.TreePath.from_string (path_string);
if (path == null) return;
Gtk.TreeIter iter;
if (!store.get_iter (out iter, path)) return;
string err;
if(!this.my_conf.check_regex(new_text,out err)){
var bg=new Gdk.RGBA();
bg.parse("#FF0000");
store.set (iter,
0, new_text,
2, GLib.Markup.escape_text(err,-1), /*tooltip*/
3, bg,
5, true,/*strikethrough*/
-1);
}else{
store.set (iter,
0, new_text,
2, null,
3, null,
5, false,/*strikethrough*/
-1);
}
}
[CCode (instance_pos = -1)]
public void on_tab_title_format_regex_cellrenderertext_replace_edited (Gtk.CellRendererText renderer, string path_string, string new_text){
debug("on_tab_title_format_regex_cellrenderertext_replace_edited start %s",path_string);
Gtk.ListStore? store=null;
store = builder.get_object ("tab_title_format_regex") as Gtk.ListStore;
if(store == null) return;
var path = new Gtk.TreePath.from_string (path_string);
if (path == null) return;
Gtk.TreeIter iter;
if (!store.get_iter (out iter, path)) return;
string err;
var s = replace_color_in_markup(this.vttbut,new_text);
if(!this.my_conf.check_markup(s,out err)){
var bg=new Gdk.RGBA();
bg.parse("#FF0000");
store.set (iter,
1, new_text,
2, GLib.Markup.escape_text(err,-1), /*tooltip*/
4, bg,
6, true,/*strikethrough*/
-1);
}else{
store.set (iter,
1, new_text,
2, null,
4, null,
6, false,/*strikethrough*/
-1);
}
}
[CCode (instance_pos = -1)]
public void on_terminal_url_regexps_match_cellrenderertext_pattern_edited (Gtk.CellRendererText renderer, string path_string, string new_text){
debug("on_terminal_url_regexps_match_cellrenderertext_pattern_edited start %s",path_string);
Gtk.ListStore? store=null;
store = builder.get_object ("terminal_url_regexps") as Gtk.ListStore;
if(store == null) return;
var path = new Gtk.TreePath.from_string (path_string);
if (path == null) return;
Gtk.TreeIter iter;
if (!store.get_iter (out iter, path)) return;
string err;
if(!this.my_conf.check_regex(new_text,out err)){
var bg=new Gdk.RGBA();
bg.parse("#FF0000");
store.set (iter,
0, new_text,
2, GLib.Markup.escape_text(err,-1), /*tooltip*/
3, bg,
4, true,/*strikethrough*/
-1);
}else{
store.set (iter,
0, new_text,
2, null,
3, null,
4, false,/*strikethrough*/
-1);
}
}
[CCode (instance_pos = -1)]
public void on_terminal_url_regexps_run_cellrenderertext_pattern_edited (Gtk.CellRendererText renderer, string path_string, string new_text){
debug("on_terminal_url_regexps_run_cellrenderertext_pattern_edited start %s",path_string);
Gtk.ListStore? store=null;
store = builder.get_object ("terminal_url_regexps") as Gtk.ListStore;
if(store == null) return;
var path = new Gtk.TreePath.from_string (path_string);
if (path == null) return;
Gtk.TreeIter iter;
if (!store.get_iter (out iter, path)) return;
store.set (iter,
1, new_text,
-1);
}
private string? get_name_from_path(string accel_path){
string[] regs;
regs=GLib.Regex.split_simple("^.*/(.*)$",accel_path,RegexCompileFlags.CASELESS,0);
if(regs!=null && regs[1]!=null){
return regs[1];
}
return null;
}
[CCode (instance_pos = -1)]
public void on_check_css_button_activate(Gtk.Button w) {
debug("on_check_css_button_activate");
var B = builder.get_object ("program_style") as Gtk.TextView;
var L = builder.get_object ("check_css_label") as Gtk.Label;
string S="";
string msg="";
uint line,pos;
if(!this.check_css(B.buffer.text,ref S,out line,out pos)){
msg=_("in line %d at position %d error:%s").printf((int)line,(int)pos,S);
debug("on_check_css_button_activate %s",msg);
TextIter where;
B.buffer.get_iter_at_line_offset(out where,(int)line,(int)pos);
B.buffer.place_cursor(where);
B.grab_focus();
}else
msg=_("Looks good");
L.label=msg;
}
private bool check_css(string css_text,ref string msg,out uint line,out uint pos){
bool ret=true;
string S="";
uint L=0,P=0;
var css_main = new CssProvider ();
css_main.parsing_error.connect((section,error)=>{
if(ret){
debug("css_main.parsing_error %s",error.message);
L=section.get_end_line();
P=section.get_end_position();