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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
|
(*
Tux Commander - UMain - Main form and window-related functions
Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
Check for updates on tuxcmd.sourceforge.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
unit UMain;
interface
uses
StrUtils, SysUtils, Types, Classes, DateUtils,
lazglib2, lazgobject2, lazgdk3, lazgtk3,
GTKForms, GTKControls, GTKMenus, GTKStdCtrls, GTKExtCtrls, GTKView, GTKConsts, GTKUtils,
GTKClasses, GTKPixbuf, UEngines, UConfig, UGnome, UVFSCore, UCoreClasses;
type
TFMain = class(TGTKForm)
MainVBox : TGTKVBox;
MainMenu : TGTKMenuBar;
LeftPanelBox, RightPanelBox : TGTKVBox;
PanelSeparator : TGTKHPaned;
LeftStatusBox, RightStatusBox, LeftPathLabelHBox, RightPathLabelHBox : TGTKHBox;
LeftPathLabel, RightPathLabel : TGTKLabel;
LeftPathLabelEventBox, RightPathLabelEventBox : TGTKEventBox;
LeftScrolledWindow, RightScrolledWindow : TGTKScrolledWindow;
LeftListView, RightListView: TGTKListView;
LeftStatusLine, RightStatusLine : TGTKLabel;
LeftUpButton, LeftRootButton, LeftHomeButton, RightUpButton, RightRootButton, RightHomeButton,
LeftBookmarkButton, RightBookmarkButton : TGTKButton;
LeftEqualButton, RightEqualButton : TGTKButton;
LeftDiskInfoLabel, RightDiskInfoLabel : TGTKLabel;
ButtonsBox : TGTKHBox;
F2Button, F3Button, F4Button, F5Button, F6Button, F7Button, F8Button : TGTKButton;
mnuFile, mnuMark, mnuCommands, mnuShow, mnuSettings, mnuHelp : TGTKMenuItem;
miExit : TGTKMenuItem;
miSelectGroup, miUnselectGroup, miSelectAll, miUnselectAll, miInvertSelection : TGTKMenuItem;
miRefresh : TGTKMenuItem;
miShowDotFiles : TGTKMenuItem;
miFileTypes: TGTKMenuItem;
miAbout : TGTKMenuItem;
miVerifyChecksums, miCreateChecksums : TGTKMenuItem;
miSplitFile, miMergeFiles : TGTKMenuItem;
miChangePermissions, miChangeOwner: TGTKMenuItem;
miCreateSymlink, miEditSymlink: TGTKMenuItem;
LeftQuickFindVBox, RightQuickFindVBox: TGTKVBox;
LeftQuickFindHBox, RightQuickFindHBox: TGTKHBox;
LeftQuickFindLabel, RightQuickFindLabel: TGTKLabel;
LeftQuickFindEntry, RightQuickFindEntry: TGTKEntry;
LeftQuickFindSeparator, RightQuickFindSeparator, ButtonBoxSeparator: TGTKHSeparator;
CommandLineHBox: TGTKHBox;
CommandLineCombo: TGTKComboBoxEntry;
CommandLineLabel: TGTKLabel;
SplitterPopupMenu: TGTKMenuItem;
FilePopupMenu: TGTKMenuItem;
miPreferences: TGTKMenuItem;
mnuBookmarks, miAddBookmark, miEditBookmarks, BookmarkPopup, BookmarkPopupDelete, miBookmarksSeparator: TGTKMenuItem;
miShowDirectorySizes, miTargetSource: TGTKMenuItem;
miCopyNames, miCopyFullPaths: TGTKMenuItem;
ButtonBoxSpace: TGTKEventBox;
MounterBarBox, LeftMounterBarBox, RightMounterBarBox: TGTKHBox;
MounterButtonPopupMenu, miMount, miUmount, miEject: TGTKMenuItem;
miMounterSettings, miNoMounterBar, miShowOneMounterBar, miShowTwoMounterBar: TGTKMenuItem;
miColumns: TGTKMenuItem;
mnuPlugins, miTestPlugin: TGTKMenuItem;
miSavePosition: TGTKMenuItem;
LeftPanelNotebook, RightPanelNotebook: TEphyNotebook;
LeftListBox, RightListBox: TGTKVBox;
TabPopupMenu, miDuplicateTab, miCloseTab, miCloseAllTabs: TGTKMenuItem;
mnuNetwork, miConnections, miOpenConnection, miQuickConnect, miDisconnect: TGTKMenuItem;
miSearch: TGTKMenuItem;
LeftDisconnectButton, RightDisconnectButton, LeftLeaveArchiveButton, RightLeaveArchiveButton: TGTKButton;
OpenTerminalButton: TGTKButton;
miNewTab: TGTKMenuItem;
LeftPasswordButton, RightPasswordButton: TGTKButton;
PathBoxPopupMenu: TGTKMenuItem;
miPathBoxRefresh, miPathBoxCopyPath: TGTKMenuItem;
miDiff, miSynchronizeDirs: TGTKMenuItem;
procedure FormCreate(Sender: TObject); override;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure PanelSeparatorPositionChanged(Sender: TObject);
procedure PanelSeparatorRealize(Sender: TObject);
procedure miExitClick(Sender: TObject);
procedure miAboutClick(Sender: TObject);
procedure miRefreshClick(Sender: TObject);
procedure mnuMarkClick(Sender: TObject);
procedure ListViewKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
procedure ListViewEnter(Sender: TObject; var Accept: boolean);
procedure PathLabelMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
procedure PathButtonClick(Sender: TObject);
function CompareFunc(Sender: TObject; var model: PGtkTreeModel; var a, b: PGtkTreeIter): integer;
procedure F5ButtonClick(Sender: TObject);
procedure F6ButtonClick(Sender: TObject);
procedure F7ButtonClick(Sender: TObject);
procedure F8ButtonClick(Sender: TObject);
procedure ListViewDblClick(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
procedure ListViewMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
procedure ListViewMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
procedure ListViewMouseMove(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
procedure InplaceEditTimerTimer(Sender: TObject);
procedure ListViewEdited(Sender: TObject; Column: TGTKTreeViewColumn; Item: TGTKListItem; var NewText: string; var AllowChange: boolean; var DataColumn: integer);
procedure ListViewSelectionChanged(Sender: TObject);
procedure QuickFindEntryEnter(Sender: TObject; var Accept: boolean);
procedure miVerifyChecksumsClick(Sender: TObject);
procedure miCreateChecksumsClick(Sender: TObject);
procedure miMergeFilesClick(Sender: TObject);
procedure miSplitFileClick(Sender: TObject);
procedure miShowDotFilesClick(Sender: TObject);
procedure F3F4ButtonClick(Sender: TObject);
procedure miFileTypesClick(Sender: TObject);
procedure CommandLineComboKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
procedure SplitterPopupMenuClick(Sender: TObject);
procedure miChangePermissionsClick(Sender: TObject);
procedure miChangeOwnerClick(Sender: TObject);
procedure miCreateSymlinkClick(Sender: TObject);
procedure miEditSymlinkClick(Sender: TObject);
procedure FilePopupMenuPopup(Sender: TObject);
procedure FilePopupMenuItemClick(Sender: TObject);
procedure miPreferencesClick(Sender: TObject);
procedure miAddBookmarkClick(Sender: TObject);
procedure miBookmarkClick(Sender: TObject);
procedure BookmarkPopupDeleteClick(Sender: TObject);
procedure BookmarkItemMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
procedure BookmarkButtonClick(Sender: TObject);
procedure mnuBookmarksPopup(Sender: TObject);
procedure miShowDirectorySizesClick(Sender: TObject);
procedure miTargetSourceClick(Sender: TObject);
procedure MounterButtonClick(Sender: TObject);
procedure MounterButtonPopupMenuPopup(Sender: TObject);
procedure MounterButtonMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
procedure miMountClick(Sender: TObject);
procedure miUmountClick(Sender: TObject);
procedure miEjectClick(Sender: TObject);
procedure miMounterSettingsClick(Sender: TObject);
procedure miShowMounterBarClick(Sender: TObject);
procedure miColumnsClick(Sender: TObject);
procedure ListViewColumnsChanged(Sender: TObject);
procedure RebuildListViewsTimerTimer(Sender: TObject);
procedure miTestPluginClick(Sender: TObject);
procedure miPluginAboutClick(Sender: TObject);
procedure miSavePositionClick(Sender: TObject);
procedure TabNotebookSwitchPage(Sender: TObject; const NewTabNum: integer; const ShouldFocus: boolean);
procedure miDuplicateTabClick(Sender: TObject);
procedure miCloseTabClick(Sender: TObject);
procedure miCloseAllTabsClick(Sender: TObject);
procedure TabPopupMenuPopup(Sender: TObject);
procedure miOpenConnectionClick(Sender: TObject);
procedure miSearchClick(Sender: TObject);
procedure miDisconnectClick(Sender: TObject);
procedure DisconnectButtonClick(Sender: TObject);
procedure LeaveArchiveButtonClick(Sender: TObject);
procedure OpenTerminalButtonClick(Sender: TObject);
procedure ListViewColumnClicked(Sender: TObject);
procedure NotebookReordered(Sender: TObject; const Source, Dest: integer);
procedure NotebookTabClosed(Sender: TObject; const TabNum: integer; var CanClose: boolean);
procedure NotebookTabDoubleClick(Sender: TObject; const TabNum: integer);
function NotebookFindNotebookAtPointerEvent(Sender: TObject; const AbsX, AbsY: integer): TEphyNotebook;
function NotebookMoveTabToAnotherNotebook(Sender: TObject; Destination: TEphyNotebook; const SourceTabNo, DestTabNo: integer): boolean;
procedure NotebookTabFocusOnlyEvent(Sender: TObject; const TabNum: integer);
procedure PasswordButtonClick(Sender: TObject);
procedure miPathBoxCopyPathClick(Sender: TObject);
procedure miCopyNamesClick(Sender: TObject);
procedure RightMouseSelectPopupTimerTimer(Sender: TObject);
procedure miQuickConnectClick(Sender: TObject);
procedure miDiffClick(Sender: TObject);
procedure miSynchronizeDirsClick(Sender: TObject);
private
LeftLastFocused, Editing, QuickFind, RedrawLeftInactive, RedrawRightInactive, StartUp, LeftTabPopup: boolean;
RunningEscSensitive: integer;
InplaceEditTimer, RebuildListViewsTimer, RightMouseSelectPopupTimer: TGTKTimer;
InplaceEditItem: TGTKListItem;
SavedCmdLine: string;
LastMounterButton: TGTKButton;
MounterBarBoxList, MounterBarBoxListLeft, MounterBarBoxListRight: TList;
LeftNotebookBoxList, RightNotebookBoxList: TList;
LeftPathsHighlight, RightPathsHighlight: TStringList;
LeftTabEngines, RightTabEngines: TList;
LastUsedFilter: string;
PanelRightMouseSelMode, PanelRightMouseInProgress: boolean;
procedure ConstructPanels;
procedure ConstructMenu;
procedure ConstructColumns(ListView: TGTKListView);
procedure AfterStart;
procedure ActivateItem(const ItemIndex: longint);
procedure UpdatePanelInfo;
procedure UpdatePanelInfoDown(LeftPanel: boolean);
procedure UpdateCaption;
function FormatPathString(Engine: TPanelEngine): string;
procedure ChangingDir(LeftPanel: boolean; NewPath: string; HiliString1: string = ''; HiliString2: string = ''; const PreserveSelection: boolean = False; const AutoFallback: boolean = False; Plugin: TVFSPlugin = nil);
procedure DoSelect(SelectType: integer);
procedure ListViewCellDataFunc(Sender: TObject; tree_view: PGtkTreeView; tree_column : PGtkTreeViewColumn; cell : PGtkCellRenderer; tree_model : PGtkTreeModel; iter : PGtkTreeIter);
procedure DoGetDirSize(AllItems: boolean);
procedure DoDelete(LeftPanel: boolean; ListView: TGTKListView; Engine: TPanelEngine; DataList: TList);
procedure DoCopyMove(LeftPanel, CopyMode, ShiftPressed: boolean; ListView: TGTKListView; Engine: TPanelEngine; DataList: TList);
procedure DoRefresh(LeftPanel, StaySame, AutoFallback: boolean);
procedure DoQuickRename(LeftPanel: boolean; ListView: TGTKListView; const CalledFromKey: boolean);
procedure ActivateQuickFind(LeftPanel: boolean);
procedure DeactivateQuickFind(LeftPanel: boolean);
function QuickFindSendKey(LeftPanel: boolean; Key: word): boolean;
procedure ProcessMarkKey(KeyType, Key: integer);
procedure SwitchOtherPanel(LeftPanel, RequestNewAltO: boolean);
procedure EditViewFile(LeftPanel: boolean; AListView: TGTKListView; View, NewFile: boolean);
procedure RunFile(Path: string; Engine: TPanelEngine; CustomAction: integer);
function ActivateCommandLine(Key: word; const ActualPosition: boolean = False): boolean;
procedure ApplySettings(RebuildListViews, RebuildIcons, AStartup: boolean);
procedure RefreshBookmarksMenu;
procedure PopupFileMenuPos;
procedure HandleFormFocusIn;
procedure SwitchPanelCtrlLeftRight(LeftPanel, LeftArrowPressed: boolean);
procedure FillMounterBar;
procedure RebuildListViews(ADoRefresh: boolean);
procedure FillPluginMenu;
procedure NewTab(LeftPanel, SendSelectedDirToBg: boolean; CustomPath: string = '');
procedure SwitchTab(TabNo: integer; LeftPanel, ASetFocus: boolean);
procedure CloseTab(TabNo: integer; LeftPanel, CloseVFSEngine: boolean);
procedure AddTabs(LeftPanel: boolean; TabList: TStringList; TabSortIDs, TabSortTypes: TList; SetTabActive: integer);
function HandleVFSArchive(LeftPanel: boolean; const FullPath, HighlightItem, TargetPath: string): boolean;
function CloseVFS(LeftPanel, SuppressRefresh: boolean): string;
procedure ShowBookmarkQuick(LeftPanel: boolean);
procedure SetTabLabel(Notebook: TEphyNotebook; PageIndex: integer; ALabel, ATooltip: string);
procedure NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer; SwitchToNewTab: boolean);
procedure CopyFilenamesToClipboard(FullPaths, LeftPanel: boolean);
function HandleRunFromArchive(var APath: string; Engine: TPanelEngine; Command, FileTypeDesc: string; BypassDialog: boolean): boolean;
function ExtractFromArchive(var NewPath: string; Engine: TPanelEngine; const FileToExtract: string; ExtractAll: boolean): boolean;
function HandleKey(Key: Word; Shift: TShiftState; LeftPanel: boolean): boolean;
function IsEditing(AListView: TGTKListView): boolean;
function PanelFindEditableWidget(AListView: TGTKListView): PGtkEditable;
function CheckForUnsavedConnection(Engine: TVFSEngine; AllowCancel: boolean): boolean; // Returns False to Cancel
procedure SaveCursorPositionTabbed(LeftPanel: boolean);
public
LeftPanelEngine, RightPanelEngine : TPanelEngine;
ColumnSortIDs: array[1..ConstNumPanelColumns] of integer;
LastClick: TDateTime;
procedure EditViewFileInternal(Filename: string; Engine: TPanelEngine; View, NewFile: boolean);
end;
var
FMain: TFMain;
implementation
uses ULibc,
UCore, UCoreWorkers, USelect, UNewDir, UCopyMove,
UCoreUtils, ULocale, UChecksum, UChecksumDruid, USplitFile,
UFileTypeSettings, UFileAssoc, UChmod, UChown, USymlink,
UPreferences, UViewer, UToolTips, UMounterPrefs, UColumns,
UTestPlugin, UConnectionManager, USearch,
URunFromVFS, uVFSprototypes, UQuickConnect,
UConnectionProperties, UError;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
(********************************************************************************************************************************)
(********************************************************************************************************************************)
function form_event_handler(widget: PGtkWidget; event: PGdkEvent; user_data: gpointer): gboolean; cdecl; forward;
procedure TFMain.FormCreate(Sender: TObject);
begin
SetupAppIcon;
StartUp := True;
RunningEscSensitive := 0;
Editing := False;
QuickFind := False;
LeftTabPopup := True;
LastClick := 0;
PanelRightMouseSelMode := True;
PanelRightMouseInProgress := False;
LastUsedFilter := '*.*';
RedrawLeftInactive := False;
RedrawRightInactive := False;
MounterBarBoxList := TList.Create;
MounterBarBoxListLeft := TList.Create;
MounterBarBoxListRight := TList.Create;
LeftNotebookBoxList := TList.Create;
RightNotebookBoxList := TList.Create;
LeftPathsHighlight := TStringList.Create;
RightPathsHighlight := TStringList.Create;
LeftTabEngines := TList.Create;
RightTabEngines := TList.Create;
Caption := ConstAppTitle;
WindowPosition := wpCenter;
MainVBox := TGTKVBox.Create(Self);
AddControl(MainVBox);
MainMenu := TGTKMenuBar.Create(Self);
MainVBox.AddControlEx(MainMenu, False, False, 0);
ConstructMenu;
InplaceEditTimer := TGTKTimer.Create(Self);
InplaceEditTimer.Enabled := False;
InplaceEditTimer.OnTimer := @InplaceEditTimerTimer;
RebuildListViewsTimer := TGTKTimer.Create(Self);
RebuildListViewsTimer.Enabled := False;
RebuildListViewsTimer.OnTimer := @RebuildListViewsTimerTimer;
RightMouseSelectPopupTimer := TGTKTimer.Create(Self);
RightMouseSelectPopupTimer.Enabled := False;
RightMouseSelectPopupTimer.OnTimer := @RightMouseSelectPopupTimerTimer;
MounterBarBox := TGTKHBox.Create(Self);
MainVBox.AddControlEx(MounterBarBox, False, False, 0);
LeftPanelBox := TGTKVBox.Create(Self);
RightPanelBox := TGTKVBox.Create(Self);
PanelSeparator := TGTKHPaned.Create(Self);
ConstructPanels;
MainVBox.AddControlEx(PanelSeparator, True, True, 0);
CommandLineHBox := TGTKHBox.Create(Self);
CommandLineHBox.Homogeneous := False;
CommandLineCombo := TGTKComboBoxEntry.Create(Self);
// CommandLineCombo.Entry.OnKeyDown := CommandLineComboKeyDown;
CommandLineLabel := TGTKLabel.Create(Self);
CommandLineLabel.Alignment := taRightJustify;
CommandLineLabel.XAlign := 1;
CommandLineLabel.YAlign := 0.5;
CommandLineLabel.SetSizeRequest(300, -1);
OpenTerminalButton := TGTKButton.Create(Self);
OpenTerminalButton.Caption := LANGOpenTerminalButton_Caption;
OpenTerminalButton.BorderStyle := bsNone;
OpenTerminalButton.CanFocus := False;
OpenTerminalButton.Tooltip := LANGOpenTerminalButton_Tooltip;
OpenTerminalButton.OnClick := @OpenTerminalButtonClick;
CommandLineHBox.AddControlEx(CommandLineLabel, False, False, 0);
CommandLineHBox.AddControlEx(CommandLineCombo, True, True, 5);
CommandLineHBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2);
CommandLineHBox.AddControlEx(OpenTerminalButton, False, False, 2);
MainVBox.AddControlEx(TGTKHSeparator.Create(Self), False, False, 2);
MainVBox.AddControlEx(CommandLineHBox, False, False, 0);
ButtonsBox := TGTKHBox.Create(Self);
F2Button := TGTKButton.Create(Self);
F3Button := TGTKButton.Create(Self);
F4Button := TGTKButton.Create(Self);
F5Button := TGTKButton.Create(Self);
F6Button := TGTKButton.Create(Self);
F7Button := TGTKButton.Create(Self);
F8Button := TGTKButton.Create(Self);
ButtonsBox.AddControlEx(F2Button, True, True, 0);
// TODO: ypadding = 4
ButtonsBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2);
ButtonsBox.AddControlEx(F3Button, True, True, 0);
ButtonsBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2);
ButtonsBox.AddControlEx(F4Button, True, True, 0);
ButtonsBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2);
ButtonsBox.AddControlEx(F5Button, True, True, 0);
ButtonsBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2);
ButtonsBox.AddControlEx(F6Button, True, True, 0);
ButtonsBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2);
ButtonsBox.AddControlEx(F7Button, True, True, 0);
ButtonsBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2);
ButtonsBox.AddControlEx(F8Button, True, True, 0);
ButtonBoxSeparator := TGTKHSeparator.Create(Self);
ButtonBoxSpace := TGTKEventBox.Create(Self);
MainVBox.AddControlEx(ButtonBoxSpace, False, False, 2);
MainVBox.AddControlEx(ButtonBoxSeparator, False, False, 2);
MainVBox.AddControlEx(ButtonsBox, False, False, 0);
F2Button.BorderStyle := bsNone;
F3Button.BorderStyle := bsNone;
F4Button.BorderStyle := bsNone;
F5Button.BorderStyle := bsNone;
F6Button.BorderStyle := bsNone;
F7Button.BorderStyle := bsNone;
F8Button.BorderStyle := bsNone;
F2Button.Caption := LANGF2Button_Caption;
F3Button.Caption := LANGF3Button_Caption;
F4Button.Caption := LANGF4Button_Caption;
F5Button.Caption := LANGF5Button_Caption;
F6Button.Caption := LANGF6Button_Caption;
F7Button.Caption := LANGF7Button_Caption;
F8Button.Caption := LANGF8Button_Caption;
F2Button.OnClick := @F6ButtonClick;
F3Button.OnClick := @F3F4ButtonClick;
F4Button.OnClick := @F3F4ButtonClick;
F5Button.OnClick := @F5ButtonClick;
F6Button.OnClick := @F6ButtonClick;
F7Button.OnClick := @F7ButtonClick;
F8Button.OnClick := @F8ButtonClick;
F2Button.CanFocus := False;
F3Button.CanFocus := False;
F4Button.CanFocus := False;
F5Button.CanFocus := False;
F6Button.CanFocus := False;
F7Button.CanFocus := False;
F8Button.CanFocus := False;
// Events
OnDestroy := @FormDestroy;
OnKeyDown := @FormKeyDown;
OnClose := @FormClose;
g_signal_connect_data(PGObject(FWidget), 'event-after', TGCallback(@form_event_handler), nil, nil, [G_CONNECT_AFTER]);
PanelSeparator.OnPositionChanged := @PanelSeparatorPositionChanged;
PanelSeparator.OnRealize := @PanelSeparatorRealize;
PanelSeparator.HandlePopupMenu := SplitterPopupMenu;
LeftListView.OnKeyDown := @ListViewKeyDown;
RightListView.OnKeyDown := @ListViewKeyDown;
LeftListView.OnEnter := @ListViewEnter;
RightListView.OnEnter := @ListViewEnter;
LeftPathLabelEventBox.OnMouseDown := @PathLabelMouseDown;
RightPathLabelEventBox.OnMouseDown := @PathLabelMouseDown;
LeftUpButton.OnClick := @PathButtonClick;
LeftRootButton.OnClick := @PathButtonClick;
LeftHomeButton.OnClick := @PathButtonClick;
RightUpButton.OnClick := @PathButtonClick;
RightRootButton.OnClick := @PathButtonClick;
RightHomeButton.OnClick := @PathButtonClick;
LeftEqualButton.OnClick := @miTargetSourceClick;
RightEqualButton.OnClick := @miTargetSourceClick;
LeftDisconnectButton.OnClick := @DisconnectButtonClick;
RightDisconnectButton.OnClick := @DisconnectButtonClick;
LeftLeaveArchiveButton.OnClick := @LeaveArchiveButtonClick;
RightLeaveArchiveButton.OnClick := @LeaveArchiveButtonClick;
LeftListView.CompareFunc := @CompareFunc;
RightListView.CompareFunc := @CompareFunc;
LeftListView.CellDataFunc := @ListViewCellDataFunc;
RightListView.CellDataFunc := @ListViewCellDataFunc;
LeftListView.OnMouseDown := @ListViewMouseDown;
RightListView.OnMouseDown := @ListViewMouseDown;
LeftListView.OnMouseUp := @ListViewMouseUp;
RightListView.OnMouseUp := @ListViewMouseUp;
LeftListView.OnDblClick := @ListViewDblClick;
RightListView.OnDblClick := @ListViewDblClick;
LeftListView.OnSelectionChanged := @ListViewSelectionChanged;
RightListView.OnSelectionChanged := @ListViewSelectionChanged;
LeftListView.OnMouseMove := @ListViewMouseMove;
RightListView.OnMouseMove := @ListViewMouseMove;
LeftQuickFindEntry.OnEnter := @QuickFindEntryEnter;
RightQuickFindEntry.OnEnter := @QuickFindEntryEnter;
LeftPanelNotebook.OnTabSwitched := @TabNotebookSwitchPage;
RightPanelNotebook.OnTabSwitched := @TabNotebookSwitchPage;
LeftPanelNotebook.PopupMenu := TabPopupMenu;
RightPanelNotebook.PopupMenu := TabPopupMenu;
AfterStart;
end;
procedure TFMain.ConstructPanels;
begin
LeftMounterBarBox := TGTKHBox.Create(Self);
// LeftMounterBarBox.SetSizeRequest(10, -1);
RightMounterBarBox := TGTKHBox.Create(Self);
// RightMounterBarBox.SetSizeRequest(10, -1);
LeftMounterBarBox.BorderWidth := 2;
RightMounterBarBox.BorderWidth := 2;
LeftPanelBox.AddControlEx(LeftMounterBarBox, False, False, 0);
RightPanelBox.AddControlEx(RightMounterBarBox, False, False, 0);
LeftStatusBox := TGTKHBox.Create(Self);
RightStatusBox := TGTKHBox.Create(Self);
LeftStatusBox.Homogeneous := False;
RightStatusBox.Homogeneous := False;
LeftPathLabel := TGTKLabel.Create(Self);
RightPathLabel := TGTKLabel.Create(Self);
// LeftPathLabel.SetSizeRequest(10, -1);
// RightPathLabel.SetSizeRequest(10, -1);
LeftPathLabelEventBox := TGTKEventBox.Create(Self);
RightPathLabelEventBox := TGTKEventBox.Create(Self);
LeftPathLabelHBox := TGTKHBox.Create(Self);
RightPathLabelHBox := TGTKHBox.Create(Self);
LeftPathLabelHBox.Homogeneous := False;
RightPathLabelHBox.Homogeneous := False;
LeftBookmarkButton := TGTKButton.Create(Self); LeftBookmarkButton.Caption := '❇';
RightBookmarkButton := TGTKButton.Create(Self); RightBookmarkButton.Caption := '❇';
LeftPasswordButton := TGTKButton.CreateFromIconName(Self, 'lock');
RightPasswordButton := TGTKButton.CreateFromIconName(Self, 'lock');
LeftPasswordButton.BorderStyle := bsNone;
RightPasswordButton.BorderStyle := bsNone;
LeftBookmarkButton.SetSizeRequest(22, 22); LeftBookmarkButton.Tooltip := LANGBookmarkButton_Tooltip + ' (Ctrl+D)';
RightBookmarkButton.SetSizeRequest(22, 22); RightBookmarkButton.Tooltip := LANGBookmarkButton_Tooltip + ' (Ctrl+D)';
LeftPasswordButton.SetSizeRequest(28, 22); LeftPasswordButton.Tooltip := LANGPasswordButton_Tooltip;
RightPasswordButton.SetSizeRequest(28, 22); RightPasswordButton.Tooltip := LANGPasswordButton_Tooltip;
LeftPasswordButton.Visible := False;
RightPasswordButton.Visible := False;
LeftBookmarkButton.CanFocus := False;
RightBookmarkButton.CanFocus := False;
LeftPasswordButton.CanFocus := False;
RightPasswordButton.CanFocus := False;
LeftBookmarkButton.OnClick := @BookmarkButtonClick;
RightBookmarkButton.OnClick := @BookmarkButtonClick;
LeftPasswordButton.OnClick := @PasswordButtonClick;
RightPasswordButton.OnClick := @PasswordButtonClick;
LeftScrolledWindow := TGTKScrolledWindow.Create(Self);
RightScrolledWindow := TGTKScrolledWindow.Create(Self);
LeftListView := TGTKListView.CreateTyped(Self, True, [lcPointer]);
RightListView := TGTKListView.CreateTyped(Self, True, [lcPointer]);
LeftStatusLine := TGTKLabel.Create(Self);
RightStatusLine := TGTKLabel.Create(Self);
LeftQuickFindVBox := TGTKVBox.Create(Self);
LeftQuickFindHBox := TGTKHBox.Create(Self);
LeftQuickFindLabel := TGTKLabel.Create(Self);
LeftQuickFindEntry := TGTKEntry.Create(Self);
LeftQuickFindEntry.CanFocus := False;
LeftQuickFindSeparator := TGTKHSeparator.Create(Self);
LeftQuickFindHBox.AddControlEx(LeftQuickFindLabel, False, False, 0);
LeftQuickFindHBox.AddControlEx(LeftQuickFindEntry, True, True, 5);
LeftQuickFindHBox.Homogeneous := False;
LeftQuickFindVBox.AddControlEx(LeftQuickFindHBox, False, False, 5);
LeftQuickFindVBox.AddControlEx(LeftQuickFindSeparator, False, False, 0);
LeftQuickFindLabel.Caption := LANGQuickFind;
LeftQuickFindVBox.Hide;
RightQuickFindVBox := TGTKVBox.Create(Self);
RightQuickFindHBox := TGTKHBox.Create(Self);
RightQuickFindLabel := TGTKLabel.Create(Self);
RightQuickFindEntry := TGTKEntry.Create(Self);
RightQuickFindEntry.CanFocus := False;
RightQuickFindSeparator := TGTKHSeparator.Create(Self);
RightQuickFindHBox.AddControlEx(RightQuickFindLabel, False, False, 0);
RightQuickFindHBox.AddControlEx(RightQuickFindEntry, True, True, 5);
RightQuickFindHBox.Homogeneous := False;
RightQuickFindVBox.AddControlEx(RightQuickFindHBox, False, False, 5);
RightQuickFindVBox.AddControlEx(RightQuickFindSeparator, False, False, 0);
RightQuickFindLabel.Caption := LANGQuickFind;
RightQuickFindVBox.Hide;
LeftDisconnectButton := TGTKButton.Create(Self);
LeftDisconnectButton.Caption := '✖';
LeftDisconnectButton.CanFocus := False;
LeftDisconnectButton.SetSizeRequest(22, 22);
LeftDisconnectButton.Tooltip := LANGDisconnectButton_Tooltip + ' (Shift+Ctrl+F)';
LeftDisconnectButton.Visible := False;
RightDisconnectButton := TGTKButton.Create(Self);
RightDisconnectButton.Caption := '✖';
RightDisconnectButton.CanFocus := False;
RightDisconnectButton.SetSizeRequest(22, 22);
RightDisconnectButton.Tooltip := LANGDisconnectButton_Tooltip + ' (Shift+Ctrl+F)';
RightDisconnectButton.Visible := False;
LeftLeaveArchiveButton := TGTKButton.Create(Self);
LeftLeaveArchiveButton.Caption := '⇚';
LeftLeaveArchiveButton.CanFocus := False;
LeftLeaveArchiveButton.SetSizeRequest(22, 22);
LeftLeaveArchiveButton.Tooltip := LANGLeaveArchiveButton_Tooltip;
LeftLeaveArchiveButton.Visible := False;
RightLeaveArchiveButton := TGTKButton.Create(Self);
RightLeaveArchiveButton.Caption := '⇚';
RightLeaveArchiveButton.CanFocus := False;
RightLeaveArchiveButton.SetSizeRequest(22, 22);
RightLeaveArchiveButton.Tooltip := LANGLeaveArchiveButton_Tooltip;
RightLeaveArchiveButton.Visible := False;
LeftPathLabelHBox.AddControlEx(LeftPathLabelEventBox, True, True, 0);
LeftPathLabelHBox.AddControlEx(LeftPasswordButton, False, False, 0);
LeftPathLabelHBox.AddControlEx(LeftDisconnectButton, False, True, 0);
LeftPathLabelHBox.AddControlEx(LeftLeaveArchiveButton, False, True, 0);
LeftPathLabelHBox.AddControlEx(LeftBookmarkButton, False, False, 0);
RightPathLabelHBox.AddControlEx(RightPathLabelEventBox, True, True, 0);
RightPathLabelHBox.AddControlEx(RightPasswordButton, False, False, 0);
RightPathLabelHBox.AddControlEx(RightDisconnectButton, False, True, 0);
RightPathLabelHBox.AddControlEx(RightLeaveArchiveButton, False, True, 0);
RightPathLabelHBox.AddControlEx(RightBookmarkButton, False, False, 0);
LeftPathLabelEventBox.AddControl(LeftPathLabel);
RightPathLabelEventBox.AddControl(RightPathLabel);
LeftPanelNotebook := TEphyNotebook.Create(Self);
LeftPanelNotebook.Visible := False;
// LeftPanelNotebook.SetSizeRequest(10, -1);
LeftPanelNotebook.Scrollable := True;
LeftPanelNotebook.ShowBorder := False;
LeftPanelNotebook.CanFocus := False; // Notebook should be focusable to allow scrolling when many tabs -- temporarily disabled
LeftPanelNotebook.ShowCloseButtons := True;
LeftPanelNotebook.AllowDragDrop := True;
LeftPanelNotebook.AllowDragOutside := True;
LeftPanelNotebook.OnNotebookReordered := @NotebookReordered;
LeftPanelNotebook.OnTabClose := @NotebookTabClosed;
LeftPanelNotebook.OnTabDoubleClick := @NotebookTabDoubleClick;
LeftPanelNotebook.OnFindNotebookAtPointer := @NotebookFindNotebookAtPointerEvent;
LeftPanelNotebook.OnMoveTabToAnotherNotebook := @NotebookMoveTabToAnotherNotebook;
LeftPanelNotebook.OnTabFocusOnlyEvent := @NotebookTabFocusOnlyEvent;
RightPanelNotebook := TEphyNotebook.Create(Self);
RightPanelNotebook.Visible := False;
// RightPanelNotebook.SetSizeRequest(10, -1);
RightPanelNotebook.Scrollable := True;
RightPanelNotebook.ShowBorder := False;
RightPanelNotebook.CanFocus := False;
RightPanelNotebook.ShowCloseButtons := True;
RightPanelNotebook.AllowDragDrop := True;
RightPanelNotebook.AllowDragOutside := True;
RightPanelNotebook.OnNotebookReordered := @NotebookReordered;
RightPanelNotebook.OnTabClose := @NotebookTabClosed;
RightPanelNotebook.OnTabDoubleClick := @NotebookTabDoubleClick;
RightPanelNotebook.OnFindNotebookAtPointer := @NotebookFindNotebookAtPointerEvent;
RightPanelNotebook.OnMoveTabToAnotherNotebook := @NotebookMoveTabToAnotherNotebook;
RightPanelNotebook.OnTabFocusOnlyEvent := @NotebookTabFocusOnlyEvent;
LeftListBox := TGTKVBox.Create(Self);
LeftListBox.AddControlEx(LeftScrolledWindow, True, True, 0);
RightListBox := TGTKVBox.Create(Self);
RightListBox.AddControlEx(RightScrolledWindow, True, True, 0);
LeftPanelBox.AddControlEx(LeftStatusBox, False, True, 0);
RightPanelBox.AddControlEx(RightStatusBox, False, True, 0);
LeftPanelBox.AddControlEx(LeftPathLabelHBox, False, False, 1);
RightPanelBox.AddControlEx(RightPathLabelHBox, False, False, 1);
LeftPanelBox.AddControlEx(LeftPanelNotebook, True, True, 0);
RightPanelBox.AddControlEx(RightPanelNotebook, True, True, 0);
LeftPanelBox.AddControlEx(LeftListBox, True, True, 0);
RightPanelBox.AddControlEx(RightListBox, True, True, 0);
LeftPanelBox.AddControlEx(LeftQuickFindVBox, False, True, 0);
RightPanelBox.AddControlEx(RightQuickFindVBox, False, True, 0);
LeftPanelBox.AddControlEx(LeftStatusLine, False, True, 0);
RightPanelBox.AddControlEx(RightStatusLine, False, True, 0);
LeftScrolledWindow.AddControl(LeftListView);
RightScrolledWindow.AddControl(RightListView);
LeftScrolledWindow.HorizScrollBarPolicy := sbAutomatic;
RightScrolledWindow.HorizScrollBarPolicy := sbAutomatic;
LeftScrolledWindow.VertScrollBarPolicy := sbAutomatic;
RightScrolledWindow.VertScrollBarPolicy := sbAutomatic;
LeftScrolledWindow.ShadowType := stShadowIn;
RightScrolledWindow.ShadowType := stShadowIn;
LeftUpButton := TGTKButton.Create(Self); LeftUpButton.Caption := '..';
LeftRootButton := TGTKButton.Create(Self); LeftRootButton.Caption := '/';
LeftHomeButton := TGTKButton.Create(Self); LeftHomeButton.Caption := '~';
LeftEqualButton := TGTKButton.Create(Self); LeftEqualButton.Caption := '=';
LeftUpButton.SetSizeRequest(22, 22); LeftUpButton.Tooltip := LANGUpButton_Tooltip;
LeftRootButton.SetSizeRequest(22, 22); LeftRootButton.Tooltip := LANGRootButton_Tooltip + #10'(Ctrl+/)';
LeftHomeButton.SetSizeRequest(22, 22); LeftHomeButton.Tooltip := LANGHomeButton_Tooltip + #10'(Ctrl+Home)';
LeftEqualButton.SetSizeRequest(22, 22); LeftEqualButton.Tooltip := LANGLeftEqualButton_Tooltip;
LeftDiskInfoLabel := TGTKLabel.Create(Self);
LeftStatusBox.AddControlEx(LeftDiskInfoLabel, True, True, 0);
LeftStatusBox.AddControlEndEx(LeftUpButton, False, False, 0);
LeftStatusBox.AddControlEndEx(LeftRootButton, False, False, 0);
LeftStatusBox.AddControlEndEx(LeftHomeButton, False, False, 0);
LeftStatusBox.AddControlEndEx(LeftEqualButton, False, False, 0);
RightUpButton := TGTKButton.Create(Self); RightUpButton.Caption := '..';
RightRootButton := TGTKButton.Create(Self); RightRootButton.Caption := '/';
RightHomeButton := TGTKButton.Create(Self); RightHomeButton.Caption := '~';
RightEqualButton := TGTKButton.Create(Self); RightEqualButton.Caption := '=';
RightUpButton.SetSizeRequest(22, 22); RightUpButton.Tooltip := LANGUpButton_Tooltip;
RightRootButton.SetSizeRequest(22, 22); RightRootButton.Tooltip := LANGRootButton_Tooltip + #10'(Ctrl+/)';
RightHomeButton.SetSizeRequest(22, 22); RightHomeButton.Tooltip := LANGHomeButton_Tooltip + #10'(Ctrl+Home)';
RightEqualButton.SetSizeRequest(22, 22); RightEqualButton.Tooltip := LANGRightEqualButton_Tooltip;
LeftUpButton.CanFocus := False;
LeftRootButton.CanFocus := False;
LeftHomeButton.CanFocus := False;
LeftEqualButton.CanFocus := False;
RightUpButton.CanFocus := False;
RightRootButton.CanFocus := False;
RightHomeButton.CanFocus := False;
RightEqualButton.CanFocus := False;
RightDiskInfoLabel := TGTKLabel.Create(Self);
RightStatusBox.AddControlEx(RightDiskInfoLabel, True, True, 0);
RightStatusBox.AddControlEndEx(RightUpButton, False, False, 0);
RightStatusBox.AddControlEndEx(RightRootButton, False, False, 0);
RightStatusBox.AddControlEndEx(RightHomeButton, False, False, 0);
RightStatusBox.AddControlEndEx(RightEqualButton, False, False, 0);
ConstructColumns(LeftListView);
ConstructColumns(RightListView);
LeftPathLabel.XAlign := 0;
LeftPathLabel.MarginStart := 5;
LeftPathLabel.MarginEnd := 5;
LeftPathLabel.MarginTop := 1;
LeftPathLabel.MarginBottom := 1;
RightPathLabel.XAlign := 0;
RightPathLabel.MarginStart := 5;
RightPathLabel.MarginEnd := 5;
RightPathLabel.MarginTop := 1;
RightPathLabel.MarginBottom := 1;
LeftDiskInfoLabel.XAlign := 0;
LeftDiskInfoLabel.MarginStart := 5;
LeftDiskInfoLabel.MarginEnd := 5;
LeftDiskInfoLabel.YAlign := 0.5;
RightDiskInfoLabel.XAlign := 0;
RightDiskInfoLabel.MarginStart := 5;
RightDiskInfoLabel.MarginEnd := 5;
RightDiskInfoLabel.YAlign := 0.5;
LeftStatusLine.XAlign := 0;
LeftStatusLine.MarginStart := 5;
LeftStatusLine.MarginEnd := 5;
LeftStatusLine.YAlign := 0.5;
RightStatusLine.XAlign := 0;
RightStatusLine.MarginStart := 5;
RightStatusLine.MarginEnd := 5;
RightStatusLine.YAlign := 0.5;
{ LeftStatusBox.SetSizeRequest(1, 18);
RightStatusBox.SetSizeRequest(1, 18);
LeftStatusLine.SetSizeRequest(1, 18);
RightStatusLine.SetSizeRequest(1, 18);
LeftDiskInfoLabel.SetSizeRequest(1, -1);
RightDiskInfoLabel.SetSizeRequest(1, -1);
LeftQuickFindVBox.SetSizeRequest(1, -1);
RightQuickFindVBox.SetSizeRequest(1, -1); }
PanelSeparator.Child1 := LeftPanelBox;
PanelSeparator.Child2 := RightPanelBox;
end;
procedure TFMain.ConstructMenu;
const ShowDotFilesShortcut: TGDKShortCut = ( Key: 46; Locked: False; ModAlt: False; ModShift: False; ModCtrl: True);
var i: integer;
Item: TGTKMenuItem;
Group: TGTKMenuItemGroup;
begin
mnuFile := TGTKMenuItem.Create(Self);
mnuFile.Caption := LANGmnuFile_Caption;
MainMenu.Items.Add(mnuFile);
miChangePermissions := TGTKMenuItem.CreateTyped(Self, itImageText);
miChangePermissions.Caption := LANGmiChangePermissions_Caption;
miChangePermissions.IconName := 'gtk-convert';
miChangePermissions.OnClick := @miChangePermissionsClick;
mnuFile.Add(miChangePermissions);
miChangeOwner := TGTKMenuItem.Create(Self);
miChangeOwner.Caption := LANGmiChangeOwner_Caption;
miChangeOwner.OnClick := @miChangeOwnerClick;
mnuFile.Add(miChangeOwner);
mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miCreateSymlink := TGTKMenuItem.CreateTyped(Self, itImageText);
miCreateSymlink.Caption := LANGmiCreateSymlink_Caption;
miCreateSymlink.IconName := 'gtk-jump-to';
miCreateSymlink.OnClick := @miCreateSymlinkClick;
mnuFile.Add(miCreateSymlink);
miEditSymlink := TGTKMenuItem.Create(Self);
miEditSymlink.Caption := LANGmiEditSymlink_Caption;
miEditSymlink.OnClick := @miEditSymlinkClick;
mnuFile.Add(miEditSymlink);
mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miSplitFile := TGTKMenuItem.Create(Self);
miSplitFile.Caption := LANGmiSplitFileCaption;
miSplitFile.OnClick := @miSplitFileClick;
mnuFile.Add(miSplitFile);
miMergeFiles := TGTKMenuItem.Create(Self);
miMergeFiles.Caption := LANGmiMergeFilesCaption;
miMergeFiles.OnClick := @miMergeFilesClick;
mnuFile.Add(miMergeFiles);
mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miVerifyChecksums := TGTKMenuItem.Create(Self);
miVerifyChecksums.Caption := LANGmiVerifyChecksums;
miVerifyChecksums.OnClick := @miVerifyChecksumsClick;
mnuFile.Add(miVerifyChecksums);
miCreateChecksums := TGTKMenuItem.Create(Self);
miCreateChecksums.Caption := LANGmiCreateChecksumsCaption;
miCreateChecksums.OnClick := @miCreateChecksumsClick;
mnuFile.Add(miCreateChecksums);
mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miDiff := TGTKMenuItem.Create(Self);
miDiff.Caption := '_Diff';
miDiff.OnClick := @miDiffClick;
mnuFile.Add(miDiff);
miSynchronizeDirs := TGTKMenuItem.Create(Self);
miSynchronizeDirs.Caption := 'S_ynchronize directories';
miSynchronizeDirs.OnClick := @miSynchronizeDirsClick;
mnuFile.Add(miSynchronizeDirs);
mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miExit := TGTKMenuItem.CreateTyped(Self, itImageText);
miExit.Caption := LANGmiExit_Caption;
miExit.IconName := 'gtk-quit';
miExit.OnClick := @miExitClick;
mnuFile.Add(miExit);
mnuMark := TGTKMenuItem.Create(Self);
mnuMark.Caption := LANGmnuMark_Caption;
MainMenu.Items.Add(mnuMark);
miSelectGroup := TGTKMenuItem.CreateTyped(Self, itImageText);
miSelectGroup.Caption := LANGmiSelectGroup_Caption;
miSelectGroup.ShortCuts.Add(MakeGDKShortCut(GDK_KEY_plus, False, False, False, False));
miSelectGroup.IconName := 'gtk-add';
miSelectGroup.OnClick := @mnuMarkClick;
mnuMark.Add(miSelectGroup);
miUnselectGroup := TGTKMenuItem.CreateTyped(Self, itImageText);
miUnselectGroup.Caption := LANGmiUnselectGroup_Caption;
miUnselectGroup.ShortCuts.Add(MakeGDKShortCut(GDK_KEY_minus, False, False, False, False));
miUnselectGroup.IconName := 'gtk-remove';
miUnselectGroup.OnClick := @mnuMarkClick;
mnuMark.Add(miUnselectGroup);
miSelectAll := TGTKMenuItem.Create(Self);
miSelectAll.Caption := LANGmiSelectAll_Caption;
miSelectAll.ShortCuts.Add(MakeGDKShortCut(GDK_KEY_plus, False, False, False, True));
miSelectAll.OnClick := @mnuMarkClick;
mnuMark.Add(miSelectAll);
miUnselectAll := TGTKMenuItem.Create(Self);
miUnselectAll.Caption := LANGmiUnselectAll_Caption;
miUnselectAll.ShortCuts.Add(MakeGDKShortCut(GDK_KEY_minus, False, False, False, True));
miUnselectAll.OnClick := @mnuMarkClick;
mnuMark.Add(miUnselectAll);
miInvertSelection := TGTKMenuItem.Create(Self);
miInvertSelection.Caption := LANGmiInvertSelection_Caption;
miInvertSelection.ShortCuts.Add(MakeGDKShortCut(GDK_KEY_asterisk, False, False, False, False));
miInvertSelection.OnClick := @mnuMarkClick;
mnuMark.Add(miInvertSelection);
mnuCommands := TGTKMenuItem.Create(Self);
mnuCommands.Caption := LANGmnuCommands_Caption;
MainMenu.Items.Add(mnuCommands);
miSearch := TGTKMenuItem.CreateTyped(Self, itImageText);
miSearch.IconName := 'gtk-find';
miSearch.Caption := LANGmiSearchCaption2;
miSearch.ShortCuts.AddName('<Alt>F7');
miSearch.OnClick := @miSearchClick;
mnuCommands.Add(miSearch);
mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miRefresh := TGTKMenuItem.CreateTyped(Self, itImageText);
miRefresh.Caption := LANGmiRefresh_Caption;
miRefresh.IconName := 'gtk-refresh';
miRefresh.ShortCuts.AddName('<Control>R');
miRefresh.OnClick := @miRefreshClick;
mnuCommands.Add(miRefresh);
miShowDirectorySizes := TGTKMenuItem.CreateTyped(Self, itImageText);
miShowDirectorySizes.Caption := LANGmiShowDirectorySizes_Caption;
miShowDirectorySizes.OnClick := @miShowDirectorySizesClick;
mnuCommands.Add(miShowDirectorySizes);
mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miCopyNames := TGTKMenuItem.CreateTyped(Self, itImageText);
miCopyNames.Caption := LANGCopyFileNamesToClipboard;
miCopyNames.ShortCuts.AddName('<Shift>F2');
miCopyNames.OnClick := @miCopyNamesClick;
mnuCommands.Add(miCopyNames);
miCopyFullPaths := TGTKMenuItem.CreateTyped(Self, itImageText);
miCopyFullPaths.Caption := LANGCopyFullPathNamesToClipboard;
miCopyFullPaths.ShortCuts.AddName('<Control>F2');
miCopyFullPaths.IconName := 'gtk-copy';
miCopyFullPaths.OnClick := @miCopyNamesClick;
mnuCommands.Add(miCopyFullPaths);
mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miNewTab := TGTKMenuItem.CreateTyped(Self, itImageText);
miNewTab.Caption := LANGmiNewTab_Caption;
miNewTab.ShortCuts.AddName('<Control>T');
miNewTab.OnClick := @miDuplicateTabClick;
miNewTab.IconName := 'gtk-index';
mnuCommands.Add(miNewTab);
mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miTargetSource := TGTKMenuItem.CreateTyped(Self, itImageText);
miTargetSource.Caption := LANGmiTargetSource_Caption;
// miTargetSource.ShortCuts.AddName('<Alt>O');
miTargetSource.OnClick := @miTargetSourceClick;
mnuCommands.Add(miTargetSource);
mnuShow := TGTKMenuItem.Create(Self);
mnuShow.Caption := LANGmnuShow_Caption;
MainMenu.Items.Add(mnuShow);
miShowDotFiles := TGTKMenuItem.CreateTyped(Self, itCheck);
miShowDotFiles.Caption := LANGmiShowDotFiles_Caption;
miShowDotFiles.Checked := ConfShowDotFiles;
miShowDotFiles.OnClick := @miShowDotFilesClick;
miShowDotFiles.ShortCuts.Add(ShowDotFilesShortcut);
mnuShow.Add(miShowDotFiles);
mnuShow.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miNoMounterBar := TGTKMenuItem.CreateTyped(Self, itRadio, nil);
miNoMounterBar.Caption := LANGmiNoMounterBarCaption;
miNoMounterBar.Checked := ConfShowMounterBar = 0;
Group := miNoMounterBar.Group;
mnuShow.Add(miNoMounterBar);
miShowOneMounterBar := TGTKMenuItem.CreateTyped(Self, itRadio, Group);
miShowOneMounterBar.Caption := LANGmiShowOneMounterBarCaption;
miShowOneMounterBar.Checked := ConfShowMounterBar = 1;
Group := miShowOneMounterBar.Group;
mnuShow.Add(miShowOneMounterBar);
miShowTwoMounterBar := TGTKMenuItem.CreateTyped(Self, itRadio, Group);
miShowTwoMounterBar.Caption := LANGmiShowTwoMounterBarCaption;
miShowTwoMounterBar.Checked := ConfShowMounterBar = 2;
mnuShow.Add(miShowTwoMounterBar);
// Assign of the events has to be done after all radio items are created
miNoMounterBar.OnClick := @miShowMounterBarClick;
miShowOneMounterBar.OnClick := @miShowMounterBarClick;
miShowTwoMounterBar.OnClick := @miShowMounterBarClick;
mnuBookmarks := TGTKMenuItem.Create(Self);
mnuBookmarks.Caption := LANGmnuBookmarks_Caption;
mnuBookmarks.OnPopup := @mnuBookmarksPopup;
mnuBookmarks.OnClick := @mnuBookmarksPopup;
MainMenu.Items.Add(mnuBookmarks);
miAddBookmark := TGTKMenuItem.CreateTyped(Self, itImageText);
miAddBookmark.Caption := LANGmiAddBookmark_Caption;
miAddBookmark.IconName := 'gtk-add';
miAddBookmark.OnClick := @miAddBookmarkClick;
mnuBookmarks.Add(miAddBookmark);
miEditBookmarks := TGTKMenuItem.CreateTyped(Self, itImageText);
miEditBookmarks.Caption := LANGmiEditBookmarks_Caption;
miEditBookmarks.Enabled := False;
miEditBookmarks.Visible := False;
miEditBookmarks.Tooltip := 'Currently not implemented - use the popup menu';
mnuBookmarks.Add(miEditBookmarks);
miBookmarksSeparator := TGTKMenuItem.CreateTyped(Self, itSeparator);
mnuBookmarks.Add(miBookmarksSeparator);
BookmarkPopup := TGTKMenuItem.Create(Self);
BookmarkPopupDelete := TGTKMenuItem.Create(Self);
BookmarkPopupDelete.Caption := LANGBookmarkPopupDelete_Caption;
BookmarkPopupDelete.OnClick := @BookmarkPopupDeleteClick;
BookmarkPopup.Add(BookmarkPopupDelete);
mnuNetwork := TGTKMenuItem.Create(Self);
mnuNetwork.Caption := LANGmnuNetworkCaption;
MainMenu.Items.Add(mnuNetwork);
miConnections := TGTKMenuItem.CreateTyped(Self, itImageText);
miConnections.Caption := LANGmiConnectionsCaption;
miConnections.IconName := 'gtk-network';
miConnections.Enabled := False;
mnuNetwork.Add(miConnections);
mnuNetwork.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miOpenConnection := TGTKMenuItem.CreateTyped(Self, itImageText);
miOpenConnection.Caption := LANGmiOpenConnectionCaption;
miOpenConnection.OnClick := @miOpenConnectionClick;
miOpenConnection.IconName := 'gtk-connect';
miOpenConnection.ShortCuts.AddName('<Control>F');
mnuNetwork.Add(miOpenConnection);
miQuickConnect := TGTKMenuItem.CreateTyped(Self, itImageText);
miQuickConnect.Caption := LANGmiQuickConnectCaption;
miQuickConnect.OnClick := @miQuickConnectClick;
miQuickConnect.ShortCuts.AddName('<Control>N');
mnuNetwork.Add(miQuickConnect);
mnuNetwork.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miDisconnect := TGTKMenuItem.CreateTyped(Self, itImageText);
miDisconnect.Caption := LANGmiDisconnect_Caption;
miDisconnect.Enabled := False;
miDisconnect.ShortCuts.AddName('<Shift><Control>F');
miDisconnect.IconName := 'gtk-disconnect';
miDisconnect.OnClick := @miDisconnectClick;
mnuNetwork.Add(miDisconnect);
mnuPlugins := TGTKMenuItem.Create(Self);
mnuPlugins.Caption := LANGmnuPluginsCaption;
MainMenu.Items.Add(mnuPlugins);
miTestPlugin := TGTKMenuItem.CreateTyped(Self, itImageText);
miTestPlugin.Caption := LANGmiTestPluginCaption;
miTestPlugin.OnClick := @miTestPluginClick;
mnuPlugins.Add(miTestPlugin);
mnuPlugins.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
mnuSettings := TGTKMenuItem.Create(Self);
mnuSettings.Caption := LANGmnuSettings_Caption;
MainMenu.Items.Add(mnuSettings);
miPreferences := TGTKMenuItem.CreateTyped(Self, itImageText);
miPreferences.Caption := LANGmiPreferences_Caption;
miPreferences.IconName := 'gtk-preferences';
miPreferences.OnClick := @miPreferencesClick;
mnuSettings.Add(miPreferences);
miFileTypes := TGTKMenuItem.CreateTyped(Self, itImageText);
miFileTypes.Caption := LANGmiFileTypes_Caption;
miFileTypes.OnClick := @miFileTypesClick;
mnuSettings.Add(miFileTypes);
miMounterSettings := TGTKMenuItem.CreateTyped(Self, itImageText);
miMounterSettings.Caption := LANGmiMounterSettingsCaption;
miMounterSettings.OnClick := @miMounterSettingsClick;
mnuSettings.Add(miMounterSettings);
miColumns := TGTKMenuItem.CreateTyped(Self, itImageText);
miColumns.Caption := LANGmiColumnsCaption;
miColumns.OnClick := @miColumnsClick;
mnuSettings.Add(miColumns);
mnuSettings.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miSavePosition := TGTKMenuItem.CreateTyped(Self, itImageText);
miSavePosition.Caption := LANGmiSavePositionCaption;
miSavePosition.OnClick := @miSavePositionClick;
mnuSettings.Add(miSavePosition);
mnuHelp := TGTKMenuItem.Create(Self);
mnuHelp.Caption := LANGmnuHelp_Caption;
MainMenu.Items.Add(mnuHelp);
miAbout := TGTKMenuItem.CreateTyped(Self, itImageText);
miAbout.Caption := LANGmiAbout_Caption;
miAbout.IconName := 'gtk-about';
miAbout.OnClick := @miAboutClick;
mnuHelp.Add(miAbout);
// Splitter popup menu
SplitterPopupMenu := TGTKMenuItem.Create(Self);
for i := 2 to 8 do begin
Item := TGTKMenuItem.Create(Self);
Item.Caption := Format('%d - %d', [i * 10, (10 - i) * 10]);
Item.Data := Pointer(i * 10);
Item.OnClick := @SplitterPopupMenuClick;
SplitterPopupMenu.Add(Item);
end;
// Files popup menu
FilePopupMenu := TGTKMenuItem.Create(Self);
FilePopupMenu.OnPopup := @FilePopupMenuPopup;
// Mounter popup menu
MounterButtonPopupMenu := TGTKMenuItem.Create(Self);
MounterButtonPopupMenu.OnPopup := @MounterButtonPopupMenuPopup;
miMount := TGTKMenuItem.CreateTyped(Self, itImageText);
miMount.Caption := LANGmiMountCaption;
miMount.IconName := 'gtk-connect';
miMount.OnClick := @miMountClick;
MounterButtonPopupMenu.Add(miMount);
miUmount := TGTKMenuItem.CreateTyped(Self, itImageText);
miUmount.Caption := LANGmiUmountCaption;
miUmount.IconName := 'gtk-disconnect';
miUmount.OnClick := @miUmountClick;
MounterButtonPopupMenu.Add(miUmount);
miEject := TGTKMenuItem.CreateTyped(Self, itImageText);
miEject.Caption := LANGmiEjectCaption;
// miEject.IconName := 'gtk-cdrom';
miEject.OnClick := @miEjectClick;
MounterButtonPopupMenu.Add(miEject);
// Tab popup menu
TabPopupMenu := TGTKMenuItem.Create(Self);
TabPopupMenu.OnPopup := @TabPopupMenuPopup;
miDuplicateTab := TGTKMenuItem.CreateTyped(Self, itImageText);
miDuplicateTab.Caption := LANGmiDuplicateTabCaption;
miDuplicateTab.ShortCuts.AddName('<Control>T');
miDuplicateTab.OnClick := @miDuplicateTabClick;
miDuplicateTab.IconName := 'gtk-index';
TabPopupMenu.Add(miDuplicateTab);
TabPopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miCloseTab := TGTKMenuItem.CreateTyped(Self, itImageText);
miCloseTab.Caption := LANGmiCloseTabCaption;
miCloseTab.ShortCuts.AddName('<Control>W');
miCloseTab.OnClick := @miCloseTabClick;
miCloseTab.IconName := 'gtk-close';
TabPopupMenu.Add(miCloseTab);
miCloseAllTabs := TGTKMenuItem.CreateTyped(Self, itImageText);
miCloseAllTabs.Caption := LANGmiCloseAllTabsCaption;
miCloseAllTabs.OnClick := @miCloseAllTabsClick;
TabPopupMenu.Add(miCloseAllTabs);
// Path box popup menu
PathBoxPopupMenu := TGTKMenuItem.Create(Self);
miPathBoxRefresh := TGTKMenuItem.CreateTyped(Self, itImageText);
miPathBoxRefresh.Caption := LANGmiRefresh_Caption;
miPathBoxRefresh.IconName := 'gtk-refresh';
miPathBoxRefresh.ShortCuts.AddName('<Control>R');
miPathBoxRefresh.OnClick := @miRefreshClick;
PathBoxPopupMenu.Add(miPathBoxRefresh);
PathBoxPopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miPathBoxCopyPath := TGTKMenuItem.CreateTyped(Self, itImageText);
miPathBoxCopyPath.Caption := LANGCopyPathToClipboard;
miPathBoxCopyPath.IconName := 'gtk-copy';
miPathBoxCopyPath.OnClick := @miPathBoxCopyPathClick;
PathBoxPopupMenu.Add(miPathBoxCopyPath);
end;
procedure ListViewColumnResized(gobject: PGObject; pspec: PGParamSpec; user_data: gpointer); cdecl;
var AListView: TGTKListView;
i, FirstColumn, LastColumn: integer;
LeftLV: boolean;
HandlerID: gulong;
begin
AListView := TGTKListView(user_data);
LeftLV := AListView = FMain.LeftListView;
GetFirstLastPanelColumn(FirstColumn, LastColumn);
// Find which column trigerred the signal
for i := 0 to AListView.Columns.Count - 1 do
if (AListView.Columns[i].FColumn = PGtkTreeViewColumn(gobject)) and
// Last column will always change if other one is being resized
(AListView.Columns[i].Tag <> LastColumn) and (FirstColumn <> LastColumn) and
(ConfColumnSizes[AListView.Columns[i].Tag] <> AListView.Columns[i].Width) then
begin
DebugMsg(['LeftLV = ', LeftLV, ', i = ', i, ', Tag = ', AListView.Columns[i].Tag, ', Old size = ', ConfColumnSizes[AListView.Columns[i].Tag], ', New size = ', AListView.Columns[i].Width]);
ConfColumnSizes[AListView.Columns[i].Tag] := AListView.Columns[i].Width;
// Apply on the other side
if LeftLV then AListView := FMain.RightListView
else AListView := FMain.LeftListView;
HandlerID := gulong(g_object_get_data(PGObject(AListView.Columns[i].FColumn), 'Width_Notify_Handler'));
g_signal_handler_block(PGObject(AListView.Columns[i].FColumn), HandlerID);
AListView.Columns[i].FixedWidth := ConfColumnSizes[AListView.Columns[i].Tag];
g_signal_handler_unblock(PGObject(AListView.Columns[i].FColumn), HandlerID);
break;
end;
end;
procedure TFMain.ConstructColumns(ListView: TGTKListView);
var i, FirstColumn, LastColumn: integer;
HandlerID: gulong;
Column: TGTKTreeViewColumn;
begin
ListView.SelectionMode := smBrowse;
GetFirstLastPanelColumn(FirstColumn, LastColumn);
// Temporarily disable the fixed height mode to be able to add columns the Pascal way
ListView.FixedHeightMode := False;
for i := 1 to ConstNumPanelColumns do
if ConfColumnVisible[i] then begin
// First column should have filetype icon
if (i = FirstColumn) and ConfUseFileTypeIcons then begin
Column := ListView.Columns.AddTyped(ctImageText);
Column.SetImageProperty('ypad', 0);
Column.SetImageProperty('yalign', 0.5);
Column.SetImageProperty('xpad', 0);
Column.SetImageProperty('xalign', 0.5);
if (ConfRowHeight > 0) and ConfUseFileTypeIcons then begin
Column.SetImageProperty('width', ConfRowHeight);
Column.SetImageProperty('height', ConfRowHeight);
end;
end else Column := ListView.Columns.Add;
Column.Caption := ConfColumnTitlesShort[ConfColumnIDs[i]];
g_object_set(PGObject(Column.FColumn), 'sizing', [2, 'fixed-width', ConfColumnSizes[i], nil]);
gtk_tree_view_column_set_spacing(Column.FColumn, 1); // Bug with column spacing?
Column.Resizable := True;
Column.Reorderable := True;
Column.SetProperty('ypad', 0);
Column.SetProperty('yalign', 0.5);
Column.Tag := i;
g_object_set_data(PGObject(Column.FColumn), 'Column_ID', Pointer(i));
if ConfRowHeight > 0 then Column.SetProperty('height', ConfRowHeight);
Column.SortID := ListView.Columns.Count - 1;
ColumnSortIDs[Column.SortID + 1] := ConfColumnIDs[i];
if ConfRowHeight < 0 then gtk_cell_renderer_text_set_fixed_height_from_font(PGtkCellRendererText(Column.FRenderer), 1);
{ gtk_cell_renderer_text_set_fixed_height_from_font(PGtkCellRendererText(Column.FRenderer), 1);
gtk_cell_renderer_set_fixed_size(PGtkCellRenderer(Column.FRenderer), ConfColumnSizes[i], ConfRowHeight); }
if ConfColumnIDs[i] < 3 then begin // Filename column
Column.OnEdited := @ListViewEdited;
Column.SetProperty('ellipsize', 3);
end;
if ConfColumnIDs[i] in [4, 8, 9] then begin
Column.SetProperty('xalign', 1);
Column.Alignment := 1;
end;
Column.SetProperty('single-paragraph-mode', 1);
Column.OnClicked := @ListViewColumnClicked;
HandlerID := g_signal_connect_data(PGObject(Column.FColumn), 'notify::width', TGCallback(@ListViewColumnResized), ListView, nil, G_CONNECT_DEFAULT);
g_object_set_data(PGObject(Column.FColumn), 'Width_Notify_Handler', Pointer(HandlerID));
end;
ListView.FixedHeightMode := True;
end;
procedure TFMain.FormDestroy(Sender: TObject);
begin
LeftNotebookBoxList.Free;
RightNotebookBoxList.Free;
end;
procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction);
function InternalCloseEngine(Engine, FallbackEngine: TPanelEngine): TPanelEngine;
begin
Result := FallbackEngine;
if not Assigned(Engine.ParentEngine) or (not (Engine is TVFSEngine)) then Exit;
Result := Engine.ParentEngine;
CheckForUnsavedConnection(Engine as TVFSEngine, False);
if not TVFSEngine(Engine).VFSClose(nil) then
DebugMsg(['Error closing the engine...']);
Engine.Free;
end;
var i: integer;
b: boolean;
(* DontShowAgain: boolean;
res: TMessageButton; *)
s: string;
begin
// Find all opened connections and warn user
b := False;
if LeftPanelNotebook.Visible and Assigned(LeftTabEngines) and (LeftTabEngines.Count > 0) then
for i := 0 to LeftTabEngines.Count - 1 do
if TPanelEngine(LeftTabEngines[i]) is TVFSEngine then begin
b := True;
Break;
end;
if (not b) or (RightPanelNotebook.Visible and Assigned(RightTabEngines) and (RightTabEngines.Count > 0)) then
for i := 0 to RightTabEngines.Count - 1 do
if TPanelEngine(RightTabEngines[i]) is TVFSEngine then begin
b := True;
Break;
end;
b := b or (LeftPanelEngine is TVFSEngine) or (RightPanelEngine is TVFSEngine);
(* -- Disabled, makes users confused. We have that 'usaved connection' message now anyway
if b and ConfOpenConnectionsWarning then begin
res := MessageBoxShowOnce(PGtkWindow(FWidget), LANGOpenConnectionsWarning, LANGDontShowAgain, DontShowAgain, [mbYes, mbNo], mbWarning, mbYes, mbNo);
if DontShowAgain then begin
ConfOpenConnectionsWarning := False;
WriteMainGUISettings;
end;
if res = mbNo then begin
Action := caNone;
Exit;
end;
end;
*)
ApplicationShuttingDown := True; // Avoid emitting config files refresh event
// Close all active connections
if b then begin
if (not LeftPanelNotebook.Visible) and (LeftPanelEngine is TVFSEngine) then begin
while LeftPanelEngine is TVFSEngine do s := CloseVFS(True, True);
if LeftPanelEngine is TLocalTreeEngine then LeftPanelEngine.ChangeDir(s, nil);
end else
for i := 0 to LeftTabEngines.Count - 1 do
if (TPanelEngine(LeftTabEngines[i]) <> nil) and (TPanelEngine(LeftTabEngines[i]) is TVFSEngine) then
try
if LeftPanelNotebook.PageIndex = i then begin
while LeftPanelEngine is TVFSEngine do s := CloseVFS(True, True);
LeftPanelTabs[i] := s;
end else
while Assigned(LeftTabEngines[i]) and (TPanelEngine(LeftTabEngines[i]) is TVFSEngine) do begin
s := TPanelEngine(LeftTabEngines[i]).SavePath;
LeftTabEngines[i] := InternalCloseEngine(TPanelEngine(LeftTabEngines[i]), LeftLocalEngine);
if s <> '' then LeftPanelTabs[i] := s
else LeftPanelTabs[i] := TPanelEngine(LeftTabEngines[i]).Path;
end;
except end;
if (not RightPanelNotebook.Visible) and (RightPanelEngine is TVFSEngine) then begin
while RightPanelEngine is TVFSEngine do s := CloseVFS(False, True);
if RightPanelEngine is TLocalTreeEngine then RightPanelEngine.ChangeDir(s, nil);
end else
for i := 0 to RightTabEngines.Count - 1 do
if (TPanelEngine(RightTabEngines[i]) <> nil) and (TPanelEngine(RightTabEngines[i]) is TVFSEngine) then
try
if RightPanelNotebook.PageIndex = i then begin
while RightPanelEngine is TVFSEngine do s := CloseVFS(False, True);
RightPanelTabs[i] := s;
end else
while Assigned(RightTabEngines[i]) and (TPanelEngine(RightTabEngines[i]) is TVFSEngine) do begin
s := TPanelEngine(RightTabEngines[i]).SavePath;
RightTabEngines[i] := InternalCloseEngine(TPanelEngine(RightTabEngines[i]), RightLocalEngine);
if s <> '' then RightPanelTabs[i] := s
else RightPanelTabs[i] := TPanelEngine(RightTabEngines[i]).Path;
end;
except end;
end;
// Unset the columns changed signal because it's called on window close
LeftListView.OnColumnsChanged := nil;
RightListView.OnColumnsChanged := nil;
ConfMainWindowState := Integer(WindowState);
ConfMainWindowPosLeft := Left;
ConfMainWindowPosTop := Top;
ConfMainWindowWidth := Width;
ConfMainWindowHeight := Height;
for i := 0 to LeftListView.Columns.Count - 1 do
ConfColumnSizes[LeftListView.Columns[i].Tag] := LeftListView.Columns[i].Width;
ConfMainWindowLeftSortColumn := LeftListView.SortColumnID;
ConfMainWindowLeftSortType := Integer(LeftListView.SortOrder);
ConfMainWindowRightSortColumn := RightListView.SortColumnID;
ConfMainWindowRightSortType := Integer(RightListView.SortOrder);
ConfLeftTabBarTabIndex := LeftPanelNotebook.PageIndex;
ConfRightTabBarTabIndex := RightPanelNotebook.PageIndex;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.AfterStart;
var i: integer;
TmpList: TStringList;
TmpList2, TmpList3: TList;
begin
LeftPanelEngine := LeftLocalEngine;
RightPanelEngine := RightLocalEngine;
// Apply the settings
ApplySettings(False, False, True);
MounterBarBox.Visible := ConfShowMounterBar = 1;
LeftMounterBarBox.Visible := ConfShowMounterBar = 2;
RightMounterBarBox.Visible := ConfShowMounterBar = 2;
FillMounterBar;
LeftListView.SetFocus;
if CommandLineHistory.Count > 0 then
for i := 0 to CommandLineHistory.Count - 1 do
CommandLineCombo.AppendItem(CommandLineHistory[i]);
CommandLineCombo.ItemIndex := -1;
CommandLineCombo.Entry.Text := '';
RefreshBookmarksMenu;
ButtonsBox.Visible := ConfShowFuncButtons;
ButtonBoxSeparator.Visible := ConfShowFuncButtons;
ButtonBoxSpace.Visible := not ConfShowFuncButtons;
FillPluginMenu;
{ FileListTipsInstall(PGtkTreeView(LeftListView.FWidget));
FileListTipsInstall(PGtkTreeView(RightListView.FWidget));
FileListTipsEnable;
}
// Load and restore panel tabs
if ConfSavePanelTabs then try
TmpList := TStringList.Create;
TmpList2 := TList.Create;
TmpList3 := TList.Create;
ReadTabs(True, TmpList, TmpList2, TmpList3);
if (TmpList.Count > 0) and (TmpList2.Count > 0) and (TmpList3.Count > 0) then
AddTabs(True, TmpList, TmpList2, TmpList3, ConfLeftTabBarTabIndex);
TmpList.Clear;
TmpList2.Clear;
TmpList3.Clear;
ReadTabs(False, TmpList, TmpList2, TmpList3);
if (TmpList.Count > 0) and (TmpList2.Count > 0) and (TmpList3.Count > 0) then
AddTabs(False, TmpList, TmpList2, TmpList3, ConfRightTabBarTabIndex);
TmpList.Free;
TmpList2.Free;
TmpList3.Free;
except
on E: Exception do DebugMsg(['*** Exception raised in TFMain.AfterStart, loading tabs: (', E.ClassName, '): ', E.Message]);
end;
// Refresh the lists
if not (LeftPanelNotebook.Visible and (LeftTabEngines.Count > 0)) then begin
ChangingDir(True, ConfLeftPath, '', '', False, True); // AutoFallback
LeftListView.SetSortInfo(ConfMainWindowLeftSortColumn, TGTKTreeViewSortOrder(ConfMainWindowLeftSortType));
end;
if not (RightPanelNotebook.Visible and (RightTabEngines.Count > 0)) then begin
ChangingDir(False, ConfRightPath, '', '', False, True);
RightListView.SetSortInfo(ConfMainWindowRightSortColumn, TGTKTreeViewSortOrder(ConfMainWindowRightSortType));
end;
// Set window position and size
SetDefaultSize(ConfMainWindowWidth, ConfMainWindowHeight);
if (ConfMainWindowPosLeft > -1) and (ConfMainWindowPosTop > -1)
then WindowMove(ConfMainWindowPosLeft, ConfMainWindowPosTop);
if ConfWMCompatMode then Show;
case integer(ConfMainWindowState) of
Ord(wsMaximized) : Maximize;
Ord(wsMinimized) : Minimize;
end;
if not ConfWMCompatMode then Show;
StartUp := False; // Set the flag to process Splitter repositioning
Application.ProcessMessages; // Need to process all messages before unlocking
InternalLockInit(False);
LeftListView.OnColumnsChanged := @ListViewColumnsChanged;
RightListView.OnColumnsChanged := @ListViewColumnsChanged;
LeftListView.SetFocus;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.PanelSeparatorPositionChanged(Sender: TObject);
begin
if (not StartUp) and (PanelSeparator.Position > 0) then
ConfPanelSep := Round((PanelSeparator.Position / PanelSeparator.Width) * 100);
end;
procedure TFMain.PanelSeparatorRealize(Sender: TObject);
begin
PanelSeparator.Position := Round(PanelSeparator.Width * (ConfPanelSep / 100));
end;
procedure TFMain.SplitterPopupMenuClick(Sender: TObject);
begin
if not (Sender is TGTKMenuItem) then Exit;
ConfPanelSep := Integer((Sender as TGTKMenuItem).Data);
PanelSeparator.Position := Round(PanelSeparator.Width * (ConfPanelSep / 100));
end;
procedure TFMain.miExitClick(Sender: TObject);
begin
Close;
end;
procedure TFMain.miAboutClick(Sender: TObject);
begin
InternalLock;
ShowAbout;
Application.ProcessMessages;
InternalLockInit(False);
end;
procedure TFMain.ListViewKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
var AListView: TGTKListView;
ANotebook: TEphyNotebook;
LeftPanel, KeyHandled: boolean;
x: integer;
begin
if not Assigned(Sender) or not (Sender is TGTKListView) then DebugMsg(['**** ListViewKeyDown: Sender is not TGTKListView or not valid']);
AListView := Sender as TGTKListView;
if LeftListView.Focused then LeftPanel := True
else if RightListView.Focused then LeftPanel := False
else LeftPanel := LeftLastFocused;
if LeftPanel then ANotebook := LeftPanelNotebook
else ANotebook := RightPanelNotebook;
FileListTipsHide;
KeyHandled := False;
case Key of
GDK_KEY_Tab, GDK_KEY_ISO_Left_Tab : if (ssCtrl in Shift) and ANotebook.Visible then begin
Accept := False;
KeyHandled := True;
x := (ANotebook.PageIndex + 1 - 2*Ord(ssShift in Shift)) mod ANotebook.ChildrenCount;
if x < 0 then x := ANotebook.ChildrenCount - 1;
ANotebook.PageIndex := x;
end else begin
Accept := False;
KeyHandled := True;
DeactivateQuickFind(LeftPanel);
// Application.ProcessMessages;
if InternalLockUnlocked then // prevent changing focus when busy
if LeftPanel then RightListView.SetFocus
else LeftListView.SetFocus;
end;
GDK_KEY_Return, GDK_KEY_KP_Enter : begin
KeyHandled := True;
if {(Key = GDK_KEY_Return) and} (Shift = [ssAlt, ssShift]) then DoGetDirSize(True)
else
if ([ssAlt] = Shift) or ([ssCtrl] = Shift) then begin
CommandLineComboKeyDown(Sender, Key, Shift, Accept);
Accept := False;
CommandLineCombo.Entry.SetFocus;
CommandLineCombo.Entry.SelectRegion(Length(CommandLineCombo.Entry.Text), Length(CommandLineCombo.Entry.Text));
end else
if Length(Trim(CommandLineCombo.Entry.Text)) > 0 then CommandLineComboKeyDown(Sender, Key, Shift, Accept)
else if Assigned(AListView.Selected) then ActivateItem(AListView.Selected.Index);
end;
GDK_KEY_BackSpace : begin
KeyHandled := True;
if QuickFind then QuickFindSendKey(LeftPanel, Key)
else begin
if LeftPanel then PathButtonClick(LeftUpButton)
else PathButtonClick(RightUpButton);
end;
end;
GDK_KEY_Right : begin
if [ssCtrl] = Shift then SwitchPanelCtrlLeftRight(LeftPanel, False) else
if ConfLynxLikeMotion then begin
if Assigned(AListView.Selected) then ActivateItem(AListView.Selected.Index);
end;
Accept := False;
KeyHandled := True;
end;
GDK_KEY_Left : begin
if [ssCtrl] = Shift then SwitchPanelCtrlLeftRight(LeftPanel, True) else
if ConfLynxLikeMotion then
if LeftPanel then PathButtonClick(LeftUpButton)
else PathButtonClick(RightUpButton);
Accept := False;
KeyHandled := True;
end;
GDK_KEY_Insert : begin
KeyHandled := True;
DoSelect(5);
end;
GDK_KEY_space : if not QuickFind then begin
Accept := False;
KeyHandled := True;
if Length(CommandLineCombo.Entry.Text) > 0 then ActivateCommandLine(Key)
else begin
if not PDataItem(AListView.Selected.Data)^.Selected then DoGetDirSize(False);
DoSelect(8);
end;
end;
GDK_KEY_F1 : begin
KeyHandled := True;
if Shift = [ssAlt] then begin
ShowBookmarkQuick(True);
Accept := False;
end;
end;
GDK_KEY_F2 : begin
KeyHandled := True;
if Shift = [ssAlt] then begin
ShowBookmarkQuick(False);
Accept := False;
end else begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
F6ButtonClick(nil);
end;
end;
GDK_KEY_F3 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
KeyHandled := True;
F3F4ButtonClick(F3Button);
end;
GDK_KEY_F4 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
KeyHandled := True;
if ssShift in Shift then EditViewFile(LeftPanel, AListView, False, True)
else F3F4ButtonClick(F4Button);
end;
GDK_KEY_F5 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
KeyHandled := True;
if ssShift in Shift then F5ButtonClick(nil)
else F5ButtonClick(Sender);
end;
GDK_KEY_F6 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
KeyHandled := True;
if ssShift in Shift then begin
Editing := IsEditing(AListView);
DoQuickRename(LeftPanel, AListView, True);
end else F6ButtonClick(Sender);
end;
GDK_KEY_F7 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
KeyHandled := True;
if ssAlt in Shift then miSearchClick(Sender)
else F7ButtonClick(Sender);
end;
GDK_KEY_F8, GDK_KEY_Delete : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
KeyHandled := True;
F8ButtonClick(Sender);
end;
GDK_KEY_Escape : begin
if not QuickFind then CommandLineCombo.Entry.Text := '';
DeactivateQuickFind(LeftPanel);
KeyHandled := True;
if RunningEscSensitive > 0 then FMainEscPressed := True;
end;
{ GDK_WIN_POPUP : begin
Accept := False;
KeyHandled := True;
PopupFileMenuPos;
end; }
GDK_KEY_Home: begin
if Shift = [ssCtrl] then begin
if LeftPanel then PathButtonClick(LeftHomeButton)
else PathButtonClick(RightHomeButton);
Accept := False;
end else if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0) then Accept := False;
KeyHandled := True;
end;
GDK_KEY_End: begin
if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1)
then Accept := False;
KeyHandled := True;
end;
GDK_KEY_slash: begin
if Shift = [ssCtrl] then begin
if LeftPanel then PathButtonClick(LeftRootButton)
else PathButtonClick(RightRootButton);
Accept := False;
end else
if (Shift = []) then ActivateQuickFind(LeftPanel);
KeyHandled := True;
end;
{ GDK_0..GDK_9: if ConfBookmarkQuickJump and (Shift = [ssAlt]) then QuickJumpToBookmark(LeftPanel, Key - GDK_1)
else begin
Accept := False;
if QuickFind then QuickFindSendKey(LeftPanel, Key)
else ActivateCommandLine(Key);
end; }
GDK_KEY_Down : begin
KeyHandled := False;
if [ssCtrl] = Shift then begin
Accept := False;
CommandLineCombo.Entry.SetFocus;
CommandLineCombo.Entry.SelectAll;
KeyHandled := True;
end else begin
if QuickFind and (Shift = []) then begin
KeyHandled := QuickFindSendKey(LeftPanel, Key);
Accept := not KeyHandled;
end;
if not KeyHandled then begin
KeyHandled := True;
if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1) then Accept := False;
end;
end;
end;
GDK_KEY_Up : begin
KeyHandled := False;
if QuickFind and (Shift = []) then begin
KeyHandled := QuickFindSendKey(LeftPanel, Key);
Accept := not KeyHandled;
end;
if not KeyHandled then begin
KeyHandled := True;
if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0) then Accept := False;
end;
end;
GDK_KEY_Page_Up, GDK_KEY_Page_Down: begin
KeyHandled := True;
if (Shift = [ssCtrl]) and ANotebook.Visible then begin
Accept := False;
x := (ANotebook.PageIndex + 1 - 2*Ord(Key = GDK_KEY_Page_Up)) mod ANotebook.ChildrenCount;
if x < 0 then x := ANotebook.ChildrenCount - 1;
ANotebook.PageIndex := x;
end else begin
if Assigned(AListView.Selected) and
(((Key = GDK_KEY_Page_Up) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0)) or
((Key = GDK_KEY_Page_Down) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1)))
then Accept := False;
end;
end;
GDK_KEY_A: if ((Shift = [ssAlt]) and (ConfQuickSearchActivationKey <> 2)) or (Shift = [ssCtrl]) then begin
KeyHandled := True;
CommandLineComboKeyDown(Sender, Key, Shift, Accept);
end;
GDK_KEY_D: if Shift = [ssCtrl] then begin
Accept := False;
KeyHandled := True;
ShowBookmarkQuick(LeftPanel);
end;
GDK_KEY_O : if (Shift = [ssAlt]) and (ConfQuickSearchActivationKey <> 2) then begin
Accept := False;
KeyHandled := True;
SwitchOtherPanel(LeftPanel, False);
end;
GDK_KEY_P, GDK_KEY_N:
if (((Shift = [ssAlt]) and (ConfQuickSearchActivationKey <> 2)) or (Shift = [ssCtrl])) { and (CommandLineHistory.Count > 0) } then begin
KeyHandled := True;
CommandLineComboKeyDown(Sender, Key, Shift, Accept);
end;
GDK_KEY_S : if ((Shift = [ssAlt]) and (ConfQuickSearchActivationKey <> 2)) or (Shift = [ssCtrl]) then begin
KeyHandled := True;
ActivateQuickFind(LeftPanel);
end;
end;
if not KeyHandled then Accept := not HandleKey(Key, Shift, LeftPanel);
end;
function TFMain.HandleKey(Key: Word; Shift: TShiftState; LeftPanel: boolean): boolean;
var s: string;
b: boolean;
begin
Result := False;
if Key = 0 then Exit;
// Filter out all non-character keys
s := UTF8Encode(WideChar(KeyValToUnicode(Key)));
if (Length(s) = 0) or (s = #0) then begin
// DebugMsg(['HandleKey: not a character key. Ignoring.']);
Exit;
end;
// Triggers:
// 0 = Ctrl+S/Alt+S and "/" only
// 1 = Ctrl+Alt+letters
// 2 = Alt+letters
// 3 = letters directly
if QuickFind then Result := QuickFindSendKey(LeftPanel, Key) else begin
b := False;
case ConfQuickSearchActivationKey of
1: b := Shift = [ssCtrl, ssAlt];
2: b := Shift = [ssAlt];
3: b := Shift = [];
end;
if b then begin
ActivateQuickFind(LeftPanel);
Result := QuickFindSendKey(LeftPanel, Key);
end else Result := ActivateCommandLine(Key);
end;
end;
(******************************************************************************************************************************************)
procedure TFMain.ListViewEnter(Sender: TObject; var Accept: boolean);
var s: string;
begin
LeftLastFocused := Sender = LeftListView;
if LeftLastFocused then begin
LeftPathLabelEventBox.ControlState := csSelected;
RightPathLabelEventBox.ControlState := csActive;
s := LeftPathLabel.Caption;
end else begin
LeftPathLabelEventBox.ControlState := csActive;
RightPathLabelEventBox.ControlState := csSelected;
s := RightPathLabel.Caption;
end;
CommandLineLabel.Caption := Format('%s@%s:%s>', [GetUserName, GetHostName, s]);
UpdateCaption;
miDisconnect.Enabled := (LeftLastFocused and (LeftPanelEngine is TVFSEngine) and (not TVFSEngine(LeftPanelEngine).ArchiveMode)) or
((not LeftLastFocused) and (RightPanelEngine is TVFSEngine) and (not TVFSEngine(RightPanelEngine).ArchiveMode));
end;
procedure TFMain.PathLabelMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
begin
if Button in [mbLeft, mbRight] then begin
if Sender = LeftPathLabelEventBox then LeftListView.SetFocus
else if Sender = RightPathLabelEventBox then RightListView.SetFocus;
end;
if Button = mbRight then begin
Accept := False;
PathBoxPopupMenu.PopUp;
end;
end;
procedure TFMain.ActivateItem(const ItemIndex: longint);
var Data: PDataItem;
LeftPanel: boolean;
DataList: TList;
Engine: TPanelEngine;
Ext: string;
begin
if LeftListView.Focused then LeftPanel := True
else if RightListView.Focused then LeftPanel := False
else LeftPanel := LeftLastFocused;
if LeftPanel then begin
DataList := LeftPanelData;
Engine := LeftPanelEngine;
end else begin
DataList := RightPanelData;
Engine := RightPanelEngine;
end;
DeactivateQuickFind(LeftPanel);
Data := DataList[ItemIndex];
DebugMsg(['Selected:', Data^.FDisplayName]);
if not Assigned(Data) then Exit;
if Data^.UpDir then ChangingDir(LeftPanel, '..') else
if Data^.IsDir then ChangingDir(LeftPanel, Data^.FName)
else begin
Ext := WideUpperCase(Trim(Copy(String(Data^.FDisplayName), LastDelimiter('.', String(Data^.FDisplayName)) + 1, Length(String(Data^.FDisplayName)) - LastDelimiter('.', String(Data^.FDisplayName)))));
// Test for known internal functions
if ((Ext = 'SFV') or (Ext = 'MD5')) and (Engine is TLocalTreeEngine) then miVerifyChecksumsClick(Self) else
if ((Ext = 'CRC') or (Ext = '001')) and (Engine is TLocalTreeEngine) then miMergeFilesClick(Self) else
if not HandleVFSArchive(LeftPanel, IncludeTrailingPathDelimiter(Engine.Path) + String(Data^.FName), String(Data^.FName), '/') then
if (not ConfUseURI) or (not (Engine is TVFSEngine)) or ((Engine is TVFSEngine) and TVFSEngine(Engine).ArchiveMode)
then RunFile(IncludeTrailingPathDelimiter(Engine.Path) + String(Data^.FName), Engine, -1)
else RunFile(IncludeTrailingPathDelimiter((Engine as TVFSEngine).GetPathURI) + String(Data^.FName), Engine, -1);
end;
end;
procedure TFMain.ChangingDir(LeftPanel: boolean; NewPath: string; HiliString1: string = ''; HiliString2: string = ''; const PreserveSelection: boolean = False; const AutoFallback: boolean = False; Plugin: TVFSPlugin = nil);
var ListView: TGTKListView;
Engine: TPanelEngine;
s: string;
i, Sel: integer;
b: boolean;
DataList, DirList: TList;
SelectedFiles: TStringList;
ANotebook: TEphyNotebook;
ATabList: TStringList;
TabEngines: TList;
OpenDirThread: TOpenDirThread;
function LookupItem(const AName: string; const CaseSensitive: boolean): boolean;
var i: integer;
begin
Result := False;
for i := 0 to DataList.Count - 1 do
if (CaseSensitive and (WideCompareStr(string(PDataItem(DataList[i])^.FName), AName) = 0)) or
((not CaseSensitive) and (WideCompareText(string(PDataItem(DataList[i])^.FName), AName) = 0)) then
begin
Sel := i;
Result := True;
Break;
end;
end;
procedure DoThread;
begin
try
OpenDirThread.AEngine := Engine;
OpenDirThread.APath := NewPath;
OpenDirThread.ASelItem := '';
OpenDirThread.AAutoFallBack := AutoFallback;
OpenDirThread.ADirList := DirList;
OpenDirThread.DialogsParentWindow := Self;
if Plugin <> nil then begin
DebugMsg(['Plugin <> nil']);
OpenDirThread.APlugin := Plugin;
OpenDirThread.AFullPath := HiliString1;
OpenDirThread.AHighlightItem := HiliString2;
end;
DebugMsg(['(II) TFMain.ChangingDir: begin thread']);
OpenDirThread.Resume;
ProcessThreadEvents(OpenDirThread);
DebugMsg(['(II) TFMain.ChangingDir: end thread, running time = ', OpenDirThread.RunningTime, 'ms']);
except
on E: Exception do DebugMsg(['*** Exception raised in TFMain.ChangingDir:DoThread (', E.ClassName, '): ', E.Message]);
end;
end;
begin
DebugMsg(['*** Begin changing dir to ', NewPath]);
if LeftPanel then begin
ListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
ANotebook := LeftPanelNotebook;
ATabList := LeftPanelTabs;
TabEngines := LeftTabEngines;
end else begin
ListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
ANotebook := RightPanelNotebook;
ATabList := RightPanelTabs;
TabEngines := RightTabEngines;
end;
// try
if (NewPath = '..') and (Engine.ParentEngine <> nil) and (Engine.Path = '/') then begin
CloseVFS(LeftPanel, False);
Exit;
end;
InternalLock;
FileListTipsDisable;
SelectedFiles := nil;
if PreserveSelection then begin
SelectedFiles := TStringList.Create;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
if PDataItem(DataList[i])^.Selected and (not PDataItem(DataList[i])^.UpDir)
then SelectedFiles.Add(PDataItem(DataList[i])^.FName);
end;
Editing := False;
DeactivateQuickFind(LeftPanel);
DeactivateQuickFind(not LeftPanel);
DirList := TList.Create;
// Threading...
OpenDirThread := TOpenDirThread.Create;
// DebugMsg(['TFMain.ChangingDir: Creating thread...']);
DoThread;
if Plugin <> nil then begin
HiliString1 := '';
HiliString2 := '';
end;
if not OpenDirThread.VFSOpenResult then begin
// Silence the error if password dialog has been cancelled
if not OpenDirThread.VFSCallbackCancelled then
ShowError(Self, LANGCouldntOpenURIArchive, OpenDirThread.VFSOpenError);
// DebugMsg(['TFMain.ChangingDir: Freeing thread...']);
OpenDirThread.Free;
end else
if not OpenDirThread.ChDirResult then begin
// Drop the error message if one of the callback dialogs were cancelled
if not OpenDirThread.VFSCallbackCancelled then
ShowError(Self, 'Error changing directory', OpenDirThread.ChDirError);
// DebugMsg(['TFMain.ChangingDir: Freeing thread...']);
OpenDirThread.Free;
end else
if not OpenDirThread.ListingResult then begin
ShowError(Self, Format('Error getting listing for %s panel', [LANGPanelStrings[LeftPanel]]), OpenDirThread.ListingError);
// DebugMsg(['TFMain.ChangingDir: Freeing thread...']);
OpenDirThread.Free;
end else begin
s := OpenDirThread.ASelItem;
Engine := OpenDirThread.AEngine; // set current Engine from the thread (might have been modified due to VFS)
if LeftPanel then LeftPanelEngine := Engine
else RightPanelEngine := Engine;
// DebugMsg(['TFMain.ChangingDir: Freeing thread...']);
OpenDirThread.Free;
// Prevent GtkTreeView accessing invalid item memory
ListView.CellDataFunc := nil;
FillPanel(DirList, ListView, Engine, LeftPanel);
DirList.Free;
if DataList.Count > 0 then begin
if PreserveSelection and (SelectedFiles.Count > 0) and (DataList.Count > 0) then
for i := 0 to DataList.Count - 1 do
if (not PDataItem(DataList[i])^.UpDir) and (SelectedFiles.IndexOf(PDataItem(DataList[i])^.FName) >= 0)
then PDataItem(DataList[i])^.Selected := True;
Sel := 0;
b := (NewPath = '..') and (Length(Trim(s)) > 0) and LookupItem(StrToUTF8(s), True);
if not b then b := (HiliString1 <> '') and LookupItem(HiliString1, True);
if (not b) and (HiliString1 <> '') then b := LookupItem(HiliString1, False);
if (not b) and (HiliString2 <> '') then b := LookupItem(HiliString2, True);
if (not b) and (HiliString2 <> '') then b := LookupItem(HiliString2, False);
// DebugMsg(['TFMain.ChangingDir: Engine.Path = "', Engine.Path, '", NewPath = "', NewPath, '", HiliString1 = "', HiliString1, '", HiliString2 = "', HiliString2, '"']);
if (not b) and ((Engine.Path = '/') or (NewPath = '/')) and (HiliString1 = '') and (HiliString2 = '') then Sel := ListView.ConvertFromSorted(0);
ListView.Items[Sel].Selected := True;
ListView.Items[Sel].SetCursor(0, False, False, 0.5, 0);
end;
ListView.CellDataFunc := @ListViewCellDataFunc;
UpdatePanelInfo;
UpdatePanelInfoDown(LeftPanel);
UpdatePanelInfoDown(not LeftPanel);
if ANotebook.Visible then begin
ATabList[ANotebook.PageIndex] := Engine.Path;
TabEngines[ANotebook.PageIndex] := Engine;
s := ExtractFileName(ExcludeTrailingPathDelimiter(Engine.Path));
if s = '' then s := '/';
SetTabLabel(ANotebook, ANotebook.PageIndex, StrToUTF8(s), StrToUTF8(Engine.Path));
end;
end; // of Chdir, Listing, ...
libc_chdir('/');
Application.ProcessMessages;
InternalUnLock;
FileListTipsEnable;
{ except
on E: Exception do DebugMsg(['*** Exception raised in TFMain.ChangingDir (', E.ClassName, '): ', E.Message]);
end; }
end;
procedure TFMain.DoRefresh(LeftPanel, StaySame, AutoFallback: boolean);
var ListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
s1, s2: string;
begin
if LeftPanel then begin
ListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
ListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
s1 := ''; s2 := '';
FindNextSelected(ListView, DataList, s1, s2);
ChangingDir(LeftPanel, Engine.Path, s1, s2, StaySame, AutoFallback);
end;
function TFMain.FormatPathString(Engine: TPanelEngine): string;
begin
if not (Engine is TVFSEngine) then Result := Engine.Path else
if (Engine as TVFSEngine).ArchiveMode then Result := Format(ConstFullPathFormatStr, [(Engine as TVFSEngine).ArchivePath, Engine.Path])
else Result := (Engine as TVFSEngine).GetPathURI;
end;
procedure TFMain.UpdateCaption;
var LeftPanel: boolean;
Engine: TPanelEngine;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
Caption := Format('Tux Commander [%s]', [StrToUTF8(FormatPathString(Engine))]);
miVerifyChecksums.Enabled := Engine is TLocalTreeEngine;
miCreateChecksums.Enabled := Engine is TLocalTreeEngine;
miSplitFile.Enabled := Engine is TLocalTreeEngine;
miMergeFiles.Enabled := Engine is TLocalTreeEngine;
end;
procedure TFMain.UpdatePanelInfo;
var FSFree, FSSize: Int64;
FSName, s: string;
Time1, Time2: TDateTime;
begin
UpdateCaption;
Time1 := Now;
LeftPathLabel.Caption := StrToUTF8(FormatPathString(LeftPanelEngine));
RightPathLabel.Caption := StrToUTF8(FormatPathString(RightPanelEngine));
LeftPathLabel.UseMarkup := True;
RightPathLabel.UseMarkup := True;
if LeftLastFocused then s := LeftPathLabel.Caption
else s := RightPathLabel.Caption;
CommandLineLabel.Caption := Format('%s@%s:%s>', [GetUserName, GetHostName, s]);
LeftPanelEngine.GetFileSystemInfo(LeftPanelEngine.Path, FSSize, FSFree, FSName);
// *TODO: hide numbers if filesystem info cannot be determined
if FSSize < 0 then FSSize := 0;
if FSFree < 0 then FSFree := 0;
if FSName <> ''
then LeftDiskInfoLabel.Caption := Format(LANGDiskStatVolNameFmt, [FSName,
FormatSize(FSFree, 1024),
FormatSize(FSSize, 1024)])
else LeftDiskInfoLabel.Caption := Format(LANGDiskStatFmt,
[FormatSize(FSFree, 1024),
FormatSize(FSSize, 1024)]);
RightPanelEngine.GetFileSystemInfo(RightPanelEngine.Path, FSSize, FSFree, FSName);
if FSName <> ''
then RightDiskInfoLabel.Caption := Format(LANGDiskStatVolNameFmt, [FSName,
FormatSize(FSFree, 1024),
FormatSize(FSSize, 1024)])
else RightDiskInfoLabel.Caption := Format(LANGDiskStatFmt,
[FormatSize(FSFree, 1024),
FormatSize(FSSize, 1024)]);
LeftDiskInfoLabel.UseMarkup := True;
RightDiskInfoLabel.UseMarkup := True;
// Update visibility of VFS buttons
LeftDisconnectButton.Visible := (LeftPanelEngine is TVFSEngine) and (not TVFSEngine(LeftPanelEngine).ArchiveMode);
LeftLeaveArchiveButton.Visible := (LeftPanelEngine is TVFSEngine) and TVFSEngine(LeftPanelEngine).ArchiveMode;
RightDisconnectButton.Visible := (RightPanelEngine is TVFSEngine) and (not TVFSEngine(RightPanelEngine).ArchiveMode);
RightLeaveArchiveButton.Visible := (RightPanelEngine is TVFSEngine) and TVFSEngine(RightPanelEngine).ArchiveMode;
LeftPasswordButton.Visible := (LeftPanelEngine is TVFSEngine) and TVFSEngine(LeftPanelEngine).GetPasswordRequired;
RightPasswordButton.Visible := (RightPanelEngine is TVFSEngine) and TVFSEngine(RightPanelEngine).GetPasswordRequired;
miDisconnect.Enabled := (LeftLastFocused and (LeftPanelEngine is TVFSEngine) and (not TVFSEngine(LeftPanelEngine).ArchiveMode)) or
((not LeftLastFocused) and (RightPanelEngine is TVFSEngine) and (not TVFSEngine(RightPanelEngine).ArchiveMode));
Time2 := Now;
DebugMsg(['UpdatePanelInfo: ', SecondOf(Time2 - Time1), ':', MillisecondOf(Time2 - Time1)]);
end;
procedure TFMain.UpdatePanelInfoDown(LeftPanel: boolean);
var Size, TotalSize: Int64;
NumSel, TotalFiles: longint;
i: integer;
Data: PDataItem;
s: string;
DataList: TList;
begin
if LeftPanel then DataList := LeftPanelData
else DataList := RightPanelData;
Size := 0;
TotalSize := 0;
NumSel := 0;
TotalFiles := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do begin
Data := DataList[i];
if (not Data^.UpDir) and ((not Data^.IsDir) or (Data^.IsDir and (Data^.Size > 0))) then begin
TotalSize := TotalSize + Data^.Size;
if not Data^.IsDir then Inc(TotalFiles);
if Data^.Selected then begin
if not Data^.IsDir then Inc(NumSel);
Size := Size + Data^.Size;
end;
end;
end;
s := Format(LANGStatusLineFmt, [FormatSize(Size, 1024),
FormatSize(TotalSize, 1024), NumSel, TotalFiles]);
if LeftPanel then LeftStatusLine.Caption := s
else RightStatusLine.Caption := s;
end;
procedure TFMain.PathButtonClick(Sender: TObject);
var NewPath: string;
LeftPanel: boolean;
begin
LeftPanel := (Sender = LeftUpButton) or (Sender = LeftHomeButton) or (Sender = LeftRootButton);
if (Sender = LeftUpButton) or (Sender = RightUpButton) then NewPath := '..'
else if (Sender = LeftRootButton) or (Sender = RightRootButton) then NewPath := '/'
else if (Sender = LeftHomeButton) or (Sender = RightHomeButton) then NewPath := GetHomePath
else Exit;
// Close VFS connections
if (Sender = LeftHomeButton) and (not (LeftPanelEngine is TLocalTreeEngine)) then
while (LeftPanelEngine is TVFSEngine) do CloseVFS(LeftPanel, True);
if (Sender = RightHomeButton) and (not (RightPanelEngine is TLocalTreeEngine)) then
while (RightPanelEngine is TVFSEngine) do CloseVFS(LeftPanel, True);
if ((Sender = LeftUpButton) and (LeftPanelEngine is TVFSEngine) and (not (LeftPanelEngine as TVFSEngine).ArchiveMode) and (LeftPanelEngine.Path = '/')) or
((Sender = RightUpButton) and (RightPanelEngine is TVFSEngine) and (not (RightPanelEngine as TVFSEngine).ArchiveMode) and (RightPanelEngine.Path = '/'))
then NewPath := '/';
ChangingDir(LeftPanel, NewPath);
if LeftPanel then LeftListView.SetFocus
else RightListView.SetFocus;
end;
procedure TFMain.miRefreshClick(Sender: TObject);
begin
DoRefresh(LeftListView.Focused, True, True);
end;
function TFMain.CompareFunc(Sender: TObject; var model: PGtkTreeModel; var a, b: PGtkTreeIter): integer;
var Data1, Data2: PDataItem;
Path: PGtkTreePath;
DataList: TList;
begin
Result := 0;
if Sender = LeftListView then DataList := LeftPanelData
else DataList := RightPanelData;
Path := gtk_tree_model_get_path(model, a);
if not Assigned(Path) then Exit;
Data1 := DataList[gtk_tree_path_get_indices(Path)^];
gtk_tree_path_free(Path);
Path := gtk_tree_model_get_path(model, b);
if not Assigned(Path) then Exit;
Data2 := DataList[gtk_tree_path_get_indices(Path)^];
gtk_tree_path_free(Path);
Result := LVCompareItems(Data1, Data2, (Sender as TGTKView).SortOrder = soAscending, FMain.ColumnSortIDs[(Sender as TGTKView).SortColumnID + 1]);
end;
(********************************************************************************************************************************)
procedure TFMain.DoSelect(SelectType: integer);
var Filter, s: string;
LeftPanel, ExpandSel, b, Found: boolean;
ListView: TGTKListView;
Engine: TPanelEngine;
i, j: integer;
Item: TGTKListItem;
Data: PDataItem;
DataList: TList;
Wilds: array of string;
begin
try
InternalLock;
try
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else Exit;
if LeftPanel then begin
ListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
ListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
DeactivateQuickFind(LeftPanel);
ExpandSel := False;
if SelectType in [1, 2] then try
FSelect := TFSelect.Create(Self);
case SelectType of
1 : FSelect.Caption := LANGExpandSelection;
2 : FSelect.Caption := LANGShrinkSelection;
end;
{ FSelect.TitleLabel.Caption := Format('<span size="large" weight="ultrabold">%s</span>', [FSelect.Caption]);
FSelect.TitleLabel.UseMarkup := True; }
ExpandSel := SelectType = 1;
FSelect.ComboBox.Entry.Text := LastUsedFilter;
FSelect.ComboBox.Entry.SelectAll;
if FSelect.Run = mbOK
then begin
Filter := FSelect.ComboBox.Entry.Text;
LastUsedFilter := Filter;
if FSelect.ComboBox.Entry.Text <> '*.*' then
SaveItemToHistory(FSelect.ComboBox.Entry.Text, SelectHistory);
end else Exit;
finally
FSelect.Free;
end;
case SelectType of
1, 2 : if ListView.Items.Count > 1 then begin
SetLength(Wilds, 0);
while LastDelimiter(ConfSelItemsDelim, Filter) > 0 do begin
i := LastDelimiter(ConfSelItemsDelim, Filter);
if i < Length(Filter) then begin
s := Copy(Filter, i + 1, Length(Filter) - i);
Delete(Filter, i, Length(Filter) - i + 1);
SetLength(Wilds, Length(Wilds) + 1);
Wilds[Length(Wilds) - 1] := s;
end;
end;
if Length(Filter) > 0 then begin
SetLength(Wilds, Length(Wilds) + 1);
Wilds[Length(Wilds) - 1] := Filter;
end;
Found := False;
for i := 0 to DataList.Count - 1 do begin
Data := DataList[i];
if Assigned(Data) and (not Data^.UpDir) and (ConfSelectAllDirs or (not Data^.IsDir)) {and (Data^.Selected <> ExpandSel)} then begin
b := False;
for j := 0 to Length(Wilds) - 1 do
b := b or IsWild(String(Data^.FDisplayName), Wilds[j], True);
if b then begin
Data^.Selected := ExpandSel;
Found := True;
end;
end;
end;
SetLength(Wilds, 0);
if not Found then Application.MessageBox(LANGNoMatchesFound, [mbOK], mbWarning, mbNone, mbOK);
end;
3, 4 : if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
if (not PDataItem(DataList[i])^.UpDir) and (ConfSelectAllDirs or (not PDataItem(DataList[i])^.IsDir)) then
PDataItem(DataList[i])^.Selected := not PDataItem(DataList[i])^.Selected;
5, 8 : begin
Item := ListView.Selected;
if Assigned(Item) and Assigned(Item.Data) then begin
Data := PDataItem(Item.Data);
if (Engine.Path = '/') or (Item.Index > 0) then Data^.Selected := not Data^.Selected;
if (ListView.ConvertToSorted(Item.Index) < ListView.Items.Count - 1) and
(((SelectType = 5) and ConfInsMoveDown) or ((SelectType = 8) and ConfSpaceMovesDown)) then begin
ListView.Selected := ListView.Items[ListView.ConvertFromSorted(ListView.ConvertToSorted(Item.Index) + 1)];
ListView.Selected.SetCursor(0, False, False, 0, 0);
end else Item.RedrawRow; // Move to the next item will invalidate it automatically
end;
end;
6, 7: if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
if (not PDataItem(DataList[i])^.UpDir) and (ConfSelectAllDirs or (not PDataItem(DataList[i])^.IsDir)) then
PDataItem(DataList[i])^.Selected := SelectType = 6;
end;
if SelectType in [1..4, 6..7] then ListView.Invalidate; // Make changes appear
UpdatePanelInfoDown(LeftPanel);
Application.ProcessMessages;
except end;
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
function TFMain.IsEditing(AListView: TGTKListView): boolean;
var i: integer;
begin
Result := False;
// TODO
{ for i := 0 to AListView.Columns.Count - 1 do begin
if Assigned(AListView.Columns[i].FColumn^.editable_widget) then Result := True;
end; }
end;
function TFMain.PanelFindEditableWidget(AListView: TGTKListView): PGtkEditable;
var i: integer;
begin
Result := nil;
// TODO
{
for i := 0 to AListView.Columns.Count - 1 do
if Assigned(AListView.Columns[i].FColumn^.editable_widget) then begin
Result := AListView.Columns[i].FColumn^.editable_widget;
Break;
end;
}
end;
procedure TFMain.ProcessMarkKey(KeyType, Key: integer);
var LeftPanel: boolean;
ListView: TGTKListView;
Pos: integer;
editable: PGtkEditable;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then ListView := LeftListView
else ListView := RightListView;
editable := PanelFindEditableWidget(ListView);
if Editing and Assigned(editable) then begin
Pos := gtk_editable_get_position(editable);
gtk_editable_insert_text(editable, PChar(UTF8Encode(WideChar(KeyValToUnicode(Key)))), 1, @Pos);
gtk_editable_set_position(editable, Pos);
end;
if CommandLineCombo.Entry.Focused then ActivateCommandLine(Key, True) else
if QuickFind then QuickFindSendKey(LeftPanel, Key)
else DoSelect(KeyType);
end;
procedure TFMain.mnuMarkClick(Sender: TObject);
begin
if Sender = miSelectGroup then ProcessMarkKey(1, GDK_KEY_plus) else
if Sender = miUnselectGroup then ProcessMarkKey(2, GDK_KEY_minus) else
if Sender = miSelectAll then DoSelect(6) else
if Sender = miUnselectAll then DoSelect(7) else
if Sender = miInvertSelection then ProcessMarkKey(4, GDK_KEY_asterisk);
end;
(********************************************************************************************************************************)
function GTK_IS_CELL_RENDERER_PIXBUF(obj: pointer) : boolean;
begin
Result := g_type_check_instance_is_a(obj, gtk_cell_renderer_pixbuf_get_type());
end;
procedure TFMain.ListViewCellDataFunc(Sender: TObject; tree_view: PGtkTreeView; tree_column: PGtkTreeViewColumn; cell: PGtkCellRenderer; tree_model: PGtkTreeModel; iter: PGtkTreeIter);
var s: PChar;
Sel, ImageCol: boolean;
Data: PDataItem;
i, ColumnID, ColumnIdx: integer;
DataList: TList;
TreePath: PGtkTreePath;
AFGColor: PGdkRGBA;
begin
Data := nil;
ImageCol := False;
ColumnIdx := gtk_tree_view_column_get_sort_column_id(tree_column);
ColumnID := ColumnSortIDs[ColumnIdx + 1] - 1;
if ColumnIdx = 0 then ImageCol := Assigned(cell) and GTK_IS_CELL_RENDERER_PIXBUF(cell);
if Sender = LeftListView then DataList := LeftPanelData
else DataList := RightPanelData;
TreePath := gtk_tree_model_get_path(tree_model, iter);
if not Assigned(TreePath) then Exit;
(Sender as TGTKListView).ConvertPathToChild(TreePath);
Data := DataList[gtk_tree_path_get_indices(TreePath)^];
gtk_tree_path_free(TreePath);
if not Assigned(Data) then Exit;
Sel := gtk_tree_selection_iter_is_selected((Sender as TGTKView).FSelection, iter);
with Data^ do begin
// ################ Prepare colors
AFGColor := nil;
if Selected then AFGColor := SelectedItemGDKColor else begin
if Sel then begin
if (Sender as TGTKView).Focused
then AFGColor := ActiveItemGDKColor
else AFGColor := InactiveItemGDKColor;
end else AFGColor := ItemColor;
end;
// ################ Setting the properties
if not ImageCol then begin
if Editing and (InplaceEditItem.Data = Data) and (ColumnID < 3) and ((ColumnID = 0) or (ColumnID = 1) { TODO or Assigned(tree_column^.editable_widget)})
then begin
if (ColumnID = 0) or (ColumnID = 1) then s := FDisplayName else s := nil;
g_object_set(PGObject(cell), 'text', ['foreground-rgba', AFGColor, nil]);
end
else begin // not editing
if ConfDirsInBold then begin
if IsDir or UpDir then g_object_set(PGObject(cell), 'markup', [PChar(Format('<span weight="bold">%s</span>', [QuoteMarkupStr(ColumnData[ColumnID])])), nil])
else g_object_set(PGObject(cell), 'markup', [PChar(QuoteMarkupStr(ColumnData[ColumnID])), nil]);
end else g_object_set(PGObject(cell), 'text', [ColumnData[ColumnID], nil]);
g_object_set(PGObject(cell), 'foreground-rgba', [AFGColor, nil]);
end;
end else // this is an image column
if ConfUseFileTypeIcons then begin // Assign icons
if Sel and (not (Sender as TGTKView).Focused) then begin
if Sender = LeftListView then RedrawLeftInactive := True
else RedrawRightInactive := True;
end;
if Icon <> nil then g_object_set(PGObject(cell), 'pixbuf', [Icon, nil]);
end;
end;
end;
procedure TFMain.F7ButtonClick(Sender: TObject);
var LeftPanel: boolean;
ListView: TGTKListView;
Engine: TPanelEngine;
NewDir: string;
begin
try
InternalLock;
try
if Sender = F7Button then LeftPanel := LeftLastFocused else
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else Exit;
if LeftPanel then ListView := LeftListView
else ListView := RightListView;
if LeftPanel then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
try
FNewDir := TFNewDir.Create(Self);
if FNewDir.Run = mbOK
then NewDir := UTF8ToStr(FNewDir.Entry.Text)
else Exit;
finally
FNewDir.Free;
end;
if NewDir = '' then Exit;
if not MakeDirectory(ListView, Engine, LeftPanel, NewDir) then Exit;
if Pos('/', NewDir) > 0 then Delete(NewDir, Pos('/', NewDir), Length(NewDir) - Pos('/', NewDir) + 1);
ChangingDir(LeftPanel, Engine.Path, NewDir);
DoRefresh(not LeftPanel, True, True);
except end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.DoGetDirSize(AllItems: boolean);
var LeftPanel: boolean;
ListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else Exit;
if LeftPanel then begin
ListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
ListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
RunningEscSensitive := 1;
GetDirSize(ListView, Engine, DataList, AllItems);
if ConfSortDirectoriesLikeFiles and (ColumnSortIDs[ListView.SortColumnID + 1] = 4) then begin
if ListView.SortOrder = soAscending then begin
ListView.SetSortInfo(ListView.SortColumnID, soDescending);
ListView.SetSortInfo(ListView.SortColumnID, soAscending);
end else begin
ListView.SetSortInfo(ListView.SortColumnID, soAscending);
ListView.SetSortInfo(ListView.SortColumnID, soDescending);
end;
ListView.Selected.SetCursor(0, False, False, 0, 0);
end;
FMainEscPressed := False;
RunningEscSensitive := 0;
end;
procedure TFMain.DoDelete(LeftPanel: boolean; ListView: TGTKListView; Engine: TPanelEngine; DataList: TList);
var i, j : integer;
SelCount: longint;
s, s2, smsg, NextItem1, NextItem2: string;
Data: PDataItem;
AWorkingThread: TWorkerThread;
begin
try
InternalLock;
SelCount := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then Inc(SelCount);
if (SelCount = 0) and ((not Assigned(ListView.Selected)) or PDataItem(ListView.Selected.Data)^.UpDir) then begin
// WriteLn(integer(mbApply), ', ', integer(Application.MessageBox(LANGNoFilesSelected, [mbOK], mbInfo, mbNone, mbApply)));
Application.MessageBox(LANGNoFilesSelected, [mbOK], mbInfo, mbNone, mbOK);
Exit;
end;
Data := nil;
if Assigned(ListView.Selected) then Data := ListView.Selected.Data;
if SelCount > 0 then begin
j := 0;
s2 := '';
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then begin
s2 := s2 + #10 + FDisplayName;
Inc(j);
if j = 5 then Break;
end;
if SelCount > j then s2 := s2 + #10 + '...';
s := Format(LANGSelectedFilesDirectories, [SelCount]);
smsg := Format(LANGDoYouReallyWantToDeleteTheSS, [s, s2]);
end else begin
if Assigned(Data) then
if Data^.IsDir then s := Format(LANGDirectoryS, [string(Data^.FDisplayName)])
else s := Format(LANGFileS, [string(Data^.FDisplayName)]);
smsg := Format(LANGDoYouReallyWantToDeleteTheS, [s]);
end;
if Application.MessageBox(smsg, [mbYes, mbNo], mbQuestion, mbNone, mbNo) <> mbYes then Exit;
FindNextSelected(ListView, DataList, NextItem1, NextItem2);
AWorkingThread := TWorkerThread.Create;
DebugMsg(['TFMain.DoDelete: Creating thread...']);
try
AWorkingThread.DialogsParentWindow := Self;
if Assigned(ListView.Selected) then AWorkingThread.SelectedItem := ListView.Selected.Data;
AWorkingThread.AEngine := Engine;
AWorkingThread.DataList := DataList;
AWorkingThread.JobType := WORKER_JOB_DELETE;
AWorkingThread.Resume;
ProcessThreadEvents(AWorkingThread);
finally
AWorkingThread.Free;
DebugMsg(['TFMain.DoDelete: Freeing thread...']);
end;
ChangingDir(LeftPanel, Engine.Path, NextItem1, NextItem2);
DoRefresh(not LeftPanel, True, True);
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
procedure TFMain.F8ButtonClick(Sender: TObject);
var LeftPanel: boolean;
ListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
begin
try
if (Sender = F8Button) or (Sender is TGTKMenuItem)
then LeftPanel := LeftLastFocused else
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else Exit;
if LeftPanel then begin
ListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
ListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
DoDelete(LeftPanel, ListView, Engine, DataList);
except end;
end;
procedure TFMain.F5ButtonClick(Sender: TObject);
var LeftPanel: boolean;
ListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
begin
try
if Sender = F5Button then LeftPanel := LeftLastFocused else
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else Exit;
if LeftPanel then begin
ListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
ListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
DoCopyMove(LeftPanel, True, Sender = nil, ListView, Engine, DataList);
except end;
end;
procedure TFMain.F6ButtonClick(Sender: TObject);
var LeftPanel: boolean;
ListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
begin
try
if (Sender = F6Button) or (Sender = F2Button) or (Sender is TGTKMenuItem)
then LeftPanel := LeftLastFocused else
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else Exit;
if LeftPanel then begin
ListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
ListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
DoCopyMove(LeftPanel, False, (Sender = nil) or (Sender = F2Button) or (Sender is TGTKMenuItem), ListView, Engine, DataList);
except end;
end;
procedure TFMain.DoCopyMove(LeftPanel, CopyMode, ShiftPressed: boolean; ListView: TGTKListView; Engine: TPanelEngine; DataList: TList);
var i: integer;
SelCount: longint;
NewPath, SelSingle, NextItem1, NextItem2: string;
AWorkingThread: TWorkerThread;
OppositeEngine: TPanelEngine;
p: PChar;
BypassSelAll: boolean;
begin
try
InternalLock;
SelCount := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then Inc(SelCount);
if (SelCount = 0) and ((not Assigned(ListView.Selected)) or PDataItem(ListView.Selected.Data)^.UpDir) then begin
Application.MessageBox(LANGNoFilesSelected, [mbOK], mbInfo, mbNone, mbOK);
Exit;
end;
BypassSelAll := False;
SelSingle := '';
if SelCount = 0 then begin
SelCount := 1;
SelSingle := PDataItem(ListView.Selected.Data)^.FDisplayName;
end;
if LeftPanel then begin
OppositeEngine := RightPanelEngine;
end else begin
OppositeEngine := LeftPanelEngine;
end;
try
FCopyMove := TFCopyMove.Create(Self);
if CopyMode then begin
FCopyMove.Caption := LANGCopyFiles;
FCopyMove.Label1.Caption := Format(LANGCopyDFileDirectoriesTo, [SelCount]);
end else begin
FCopyMove.Caption := LANGMoveRenameFiles;
FCopyMove.Label1.Caption := Format(LANGMoveRenameDFileDirectoriesTo, [SelCount]);
end;
if ShiftPressed then begin
if SelSingle <> '' then begin
FCopyMove.Entry.Text := SelSingle;
if ConfQuickRenameSkipExt then begin
p := gtk_entry_get_text(PGtkEntry(FCopyMove.Entry.FWidget));
if (p <> nil) and (g_utf8_strlen(p, -1) > 0) then begin
// DebugMsg(['TFMain.DoCopyMove: p = "', p, '", g_utf8_strlen(p) = ', g_utf8_strlen(p, -1)]);
if AnsiPos('.', p) > 0 then begin
FCopyMove.Entry.SelectRegion(0, g_utf8_strlen(p, -1) - g_utf8_strlen(PChar(ExtractFileExt(p)), -1));
BypassSelAll := True;
end;
end;
end;
end else FCopyMove.Entry.Text := '*.*';
end else FCopyMove.Entry.Text := OppositeEngine.Path;
{ if OppositeEngine is TLocalTreeEngine then FCopyMove.Entry.Text := OppositeEngine.Path
else FCopyMove.Entry.Text := Format(ConstFullPathFormatStr, [OppositeEngine.GetPrefix, OppositeEngine.Path]); }
if not BypassSelAll then FCopyMove.Entry.SelectAll;
if FCopyMove.Run <> mbOK then Exit;
NewPath := UTF8ToStr(FCopyMove.Entry.Text);
finally
FCopyMove.Free;
end;
DebugMsg(['TFMain.DoCopyMove: NewPath = "', NewPath, '"']);
NextItem1 := ''; NextItem2 := '';
FindNextSelected(ListView, DataList, NextItem1, NextItem2);
DebugMsg(['TFMain.DoCopyMove: FindNextSelected, NextItem1 = "', NextItem1, '", NextItem2 = "', NextItem2, '"']);
if ShiftPressed then NextItem1 := NewPath;
AWorkingThread := TWorkerThread.Create;
DebugMsg(['TFMain.DoCopyMove: Creating thread...']);
try
AWorkingThread.DialogsParentWindow := Self;
if Assigned(ListView.Selected) then AWorkingThread.SelectedItem := ListView.Selected.Data;
// Determine target engine according to absolute/relative path
if (NewPath[1] = '/') or (NewPath[1] = '~') then AWorkingThread.DestEngine := OppositeEngine
else AWorkingThread.DestEngine := Engine;
AWorkingThread.SrcEngine := Engine;
// Determine on which engine the entered path is
{
if Pos(ConstPathDelim, NewPath) = 0 then begin
if OppositeEngine is TLocalTreeEngine then AWorkingThread.DestEngine := OppositeEngine else
if CurrentEngine is TLocalTreeEngine then AWorkingThread.DestEngine := CurrentEngine
else begin
Application.MessageBox(LANGCannotDetermineDestinationEngine, [mbOK], mbError, mbOK, mbOK);
Exit;
end;
end else begin
s := Copy(NewPath, 1, Pos(ConstPathDelim, NewPath) - 1);
if s = OppositeEngine.GetPrefix then AWorkingThread.DestEngine := OppositeEngine else
if s = CurrentEngine.GetPrefix then AWorkingThread.DestEngine := CurrentEngine
else begin
Application.MessageBox(LANGCannotDetermineDestinationEngine, [mbOK], mbError, mbOK, mbOK);
Exit;
end;
end;
}
// Strip the engine prefix
// if Pos(ConstPathDelim, NewPath) > 0 then Delete(NewPath, 1, Pos(ConstPathDelim, NewPath));
AWorkingThread.DataList := DataList;
if CopyMode then AWorkingThread.JobType := WORKER_JOB_COPY
else AWorkingThread.JobType := WORKER_JOB_MOVE;
AWorkingThread.CopyTargetPath := NewPath;
DebugMsg(['*** Copy: AWorkingThread.Resume']);
AWorkingThread.Resume;
DebugMsg(['*** Copy: AWorkingThread.Resumed.']);
ProcessThreadEvents(AWorkingThread);
finally
DebugMsg(['TFMain.DoCopyMove: Freeing thread...']);
AWorkingThread.Free;
end;
ChangingDir(LeftPanel, Engine.Path, NextItem1, NextItem2);
DoRefresh(not LeftPanel, True, False);
finally
DebugMsg(['** TFMain.DoCopyMove finished']);
Application.ProcessMessages;
InternalUnLock;
end;
end;
procedure TFMain.ListViewDblClick(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
begin
DebugMsg(['DblClick']);
Accept := True; // This causes selecting the item if clicked is different than selected
if (Sender as TGTKListView).GetItemAtPos(X, Y) <> (Sender as TGTKListView).Selected then Exit;
Accept := False;
DebugMsg(['DblClick OK']);
if not (Sender as TGTKListView).Focused then (Sender as TGTKListView).SetFocus;
if Assigned((Sender as TGTKListView).Selected) and Assigned((Sender as TGTKListView).Selected.Data)
then ActivateItem((Sender as TGTKListView).Selected.Index);
end;
procedure TFMain.ListViewMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
var Item: TGTKListItem;
Click: TDateTime;
Data: PDataItem;
AEngine: TPanelEngine;
begin
try
InternalLock;
PanelRightMouseInProgress := False;
// DebugMsg(['ListViewMouseDown, X = ', X, ', Y = ', Y]);
if Button = mbLeft then begin
Click := Now;
if LastClick + ConfDblClickDelay/MSecsPerDay > Click then begin
Accept := False;
InplaceEditTimer.Enabled := False;
LastClick := 0;
ListViewDblClick(Sender, Button, Shift, X, Y, Accept);
Exit;
end;
LastClick := Click;
DebugMsg(['Click, Focus = ', (Sender as TGTKControl).Focused]);
if not (Sender as TGTKListView).Focused then Exit; // (Sender as TGTKListView).SetFocus;
Item := (Sender as TGTKListView).GetItemAtPos(X, Y);
if (Item = (Sender as TGTKListView).Selected) and Assigned(Item) and Assigned((Sender as TGTKListView).Selected) and
Assigned(Item.Data) and (not PDataItem(Item.Data)^.UpDir) and (Sender as TGTKListView).Focused and (not ConfDisableMouseRename) then
begin
DebugMsg(['Quick-Rename']);
InplaceEditTimer.Interval := ConfQuickRenameDelay;
InplaceEditTimer.Enabled := True;
InplaceEditItem := Item;
end;
Accept := True;
end else
if Button = mbRight then begin
if not (Sender as TGTKListView).Focused then (Sender as TGTKListView).SetFocus;
Item := (Sender as TGTKListView).GetItemAtPos(X, Y);
if Assigned(Item) then begin
Item.Selected := True;
Item.SetCursor(0, False, False, 0.5, 0);
end;
// Show file popup menu or start selection mode, depending on ConfRightClickSelect
if ConfRightClickSelect then begin
if (Item <> nil) and (Item.Data <> nil) then begin
Data := PDataItem(Item.Data);
if not Data^.UpDir then begin
PanelRightMouseSelMode := not Data^.Selected;
Data^.Selected := PanelRightMouseSelMode;
Item.RedrawRow;
UpdatePanelInfoDown(Sender = LeftListView);
PanelRightMouseInProgress := True;
RightMouseSelectPopupTimer.Interval := ConfQuickRenameDelay;
RightMouseSelectPopupTimer.Enabled := True;
end;
end;
end else
if (Item <> nil) then FilePopupMenu.PopUp;
Accept := False;
end else
if Button = mbMiddle then begin
if not (Sender as TGTKListView).Focused then (Sender as TGTKListView).SetFocus;
Item := (Sender as TGTKListView).GetItemAtPos(X, Y);
if Assigned(Item) then begin
Item.Selected := True;
Item.SetCursor(0, False, False, 0.5, 0);
end;
// Open directory in background tab
if (Item <> nil) and (Item.Data <> nil) then begin
Data := PDataItem(Item.Data);
if Sender = LeftListView then AEngine := LeftPanelEngine
else AEngine := RightPanelEngine;
if (not Data^.UpDir) and (Data^.IsDir) then NewTab(Sender = LeftListView, True, IncludeTrailingPathDelimiter(AEngine.Path) + Data^.FName);
end;
Accept := False;
end;
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
procedure TFMain.ListViewMouseMove(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
var Item: TGTKListItem;
Data: PDataItem;
begin
Accept := True;
if not ((Sender is TGTKListView) and ConfRightClickSelect) then Exit;
if (Button = mbRight) and PanelRightMouseInProgress then begin
Item := (Sender as TGTKListView).GetItemAtPos(X, Y);
if (Item <> nil) and (Item.Data <> nil) and (not Item.Selected) then begin
Data := PDataItem(Item.Data);
if not Data^.UpDir then begin
RightMouseSelectPopupTimer.Enabled := False;
Data^.Selected := PanelRightMouseSelMode;
Item.Selected := True;
Item.SetCursor(0, False, False, 0.5, 0);
UpdatePanelInfoDown(Sender = LeftListView);
end;
end;
end else PanelRightMouseInProgress := False;
end;
procedure TFMain.RightMouseSelectPopupTimerTimer(Sender: TObject);
var AListView: TGTKListView;
Data: PDataItem;
begin
RightMouseSelectPopupTimer.Enabled := False;
if LeftListView.Focused then AListView := LeftListView else
if RightListView.Focused then AListView := RightListView else
Exit;
if (AListView.Selected <> nil) then begin
Data := AListView.Selected.Data;
// Explicitly select the item before showing the popup menu
if (Data <> nil) and (not Data^.UpDir) then begin
Data^.Selected := True;
AListView.Selected.RedrawRow;
UpdatePanelInfoDown(LeftListView.Focused);
FilePopupMenu.PopUp;
end;
end;
end;
procedure TFMain.InplaceEditTimerTimer(Sender: TObject);
var LeftPanel: boolean;
ListView: TGTKListView;
begin
InplaceEditTimer.Enabled := False;
try
LeftPanel := LeftLastFocused;
if LeftPanel then begin
ListView := LeftListView;
end else begin
ListView := RightListView;
end;
if ListView.Selected <> InplaceEditItem then Exit;
DoQuickRename(LeftPanel, ListView, False);
except end;
end;
procedure TFMain.DoQuickRename(LeftPanel: boolean; ListView: TGTKListView; const CalledFromKey: boolean);
var i: integer;
s: PChar;
begin
if (not Assigned(ListView.Selected)) or (not Assigned(ListView.Selected.Data)) or
PDataItem(ListView.Selected.Data)^.UpDir or Editing then Exit;
Editing := True;
if CalledFromKey then InplaceEditItem := ListView.Selected;
for i := 1 to ConstNumPanelColumns do
if ColumnSortIDs[i] in [1, 2] then begin
ListView.Columns[i - 1].SetProperty('editable', 1);
ListView.StartEditing(i - 1);
// TODO
(*
if ConfQuickRenameSkipExt { TODO and (ListView.Columns[i - 1].FColumn^.editable_widget <> nil) } then begin
s := gtk_entry_get_text(PGtkEntry(ListView.Columns[i - 1].FColumn^.editable_widget));
if (s <> nil) and (g_utf8_strlen(s, -1) > 0) then begin
// DebugMsg(['TFMain.DoQuickRename: s = "', s, '", g_utf8_strlen(s) = ', g_utf8_strlen(s, -1)]);
if AnsiPos('.', s) > 0 then
gtk_editable_select_region(PGtkEditable(ListView.Columns[i - 1].FColumn^.editable_widget), 0, g_utf8_strlen(s, -1) - g_utf8_strlen(PChar(ExtractFileExt(s)), -1));
end;
end; *)
Break;
end;
end;
procedure TFMain.ListViewEdited(Sender: TObject; Column: TGTKTreeViewColumn; Item: TGTKListItem; var NewText: string; var AllowChange: boolean; var DataColumn: integer);
var AListView: TGTKListView;
DataList: TList;
Engine: TPanelEngine;
AWorkingThread: TWorkerThread;
i: integer;
s1, s2: string;
begin
Exit;
try
InternalLock;
AListView := (((Sender as TGTKTreeViewColumn).Parent as TGTKTreeViewColumns).Parent as TGTKListView);
for i := 1 to ConstNumPanelColumns do
if ColumnSortIDs[i] in [1, 2] then begin
AListView.Columns[i - 1].SetProperty('editable', 0);
Break;
end;
if AListView = LeftListView then begin
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
Editing := False;
DebugMsg(['TFMain.ListViewEdited: FDisplayName = "', String(PDataItem(InplaceEditItem.Data)^.FDisplayName), '", NewText = "', NewText, '"']);
if (AListView.Selected = InplaceEditItem) and (AListView.Selected.Data = InplaceEditItem.Data) and
(String(PDataItem(InplaceEditItem.Data)^.FDisplayName) <> NewText) then
begin
AWorkingThread := TWorkerThread.Create;
DebugMsg(['TFMain.ListViewEdited: Creating thread...']);
try
AWorkingThread.DialogsParentWindow := Self;
if Assigned(AListView.Selected) then AWorkingThread.SelectedItem := AListView.Selected.Data;
AWorkingThread.SrcEngine := Engine;
AWorkingThread.DestEngine := Engine;
AWorkingThread.DataList := DataList;
AWorkingThread.JobType := WORKER_JOB_MOVE;
AWorkingThread.CopyTargetPath := UTF8ToStr(NewText);
AWorkingThread.QuickRenameDataItem := InplaceEditItem.Data;
AWorkingThread.Resume;
ProcessThreadEvents(AWorkingThread);
finally
DebugMsg(['TFMain.ListViewEdited: Freeing thread...']);
AWorkingThread.Free;
end;
s1 := ''; s2 := '';
FindNextSelected(AListView, DataList, s1, s2);
DebugMsg(['TFMain.ListViewEdited: FindNextSelected, s1 = "', s1, '", s2 = "', s2, '"']);
ChangingDir(AListView = LeftListView, Engine.Path, {String(PDataItem(InplaceEditItem.Data)^.AName),} NewText, s2);
DoRefresh(AListView <> LeftListView, True, True);
end;
AListView.SetFocus;
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
procedure TFMain.ListViewSelectionChanged(Sender: TObject);
var i: integer;
begin
if Editing and ((Sender as TGTKListView).Selected <> InplaceEditItem) then begin
Editing := False;
for i := 1 to ConstNumPanelColumns do
if ColumnSortIDs[i] in [1, 2] then begin
(Sender as TGTKListView).Columns[i - 1].SetProperty('editable', 0);
Break;
end;
end;
if QuickFind then DeactivateQuickFind(Sender = LeftListView);
SaveCursorPositionTabbed(Sender = LeftListView);
end;
procedure TFMain.SaveCursorPositionTabbed(LeftPanel: boolean);
begin
if LeftPanel then begin
if LeftPanelNotebook.Visible and (LeftPathsHighlight.Count > LeftPanelNotebook.PageIndex) and (LeftPanelNotebook.PageIndex >= 0) and
Assigned(LeftListView.Selected) and Assigned(LeftListView.Selected.Data)
then LeftPathsHighlight[LeftPanelNotebook.PageIndex] := PDataItem(LeftListView.Selected.Data)^.FName;
end else
if RightPanelNotebook.Visible and (RightPathsHighlight.Count > RightPanelNotebook.PageIndex) and (RightPanelNotebook.PageIndex >= 0) and
Assigned(RightListView.Selected) and Assigned(RightListView.Selected.Data)
then RightPathsHighlight[RightPanelNotebook.PageIndex] := PDataItem(RightListView.Selected.Data)^.FName;
end;
procedure TFMain.ActivateQuickFind(LeftPanel: boolean);
var Entry: TGTKEntry;
begin
QuickFind := True;
if LeftPanel then begin
Entry := LeftQuickFindEntry;
LeftQuickFindVBox.Show;
end else begin
Entry := RightQuickFindEntry;
RightQuickFindVBox.Show;
end;
Entry.Text := '';
end;
procedure TFMain.QuickFindEntryEnter(Sender: TObject; var Accept: boolean);
begin
Accept := False;
(Sender as TGTKControl).SetFocus;
end;
procedure TFMain.DeactivateQuickFind(LeftPanel: boolean);
begin
QuickFind := False;
if LeftPanel then LeftQuickFindVBox.Hide
else RightQuickFindVBox.Hide;
end;
function TFMain.QuickFindSendKey(LeftPanel: boolean; Key: word): boolean;
var Entry: TGTKEntry;
s, NewText: string;
i: integer;
AListView: TGTKListView;
DataList: TList;
Data: PDataItem;
OldSelectionChangedEvent: TNotifyEvent;
g: PChar;
NewIndex, StartIndex: Longint;
begin
Result := False;
if not QuickFind then Exit;
if LeftPanel then begin
Entry := LeftQuickFindEntry;
AListView := LeftListView;
DataList := LeftPanelData;
end else begin
Entry := RightQuickFindEntry;
AListView := RightListView;
DataList := RightPanelData;
end;
// DebugMsg(['TFMain.QuickFindSendKey: Key = ', Key, ', GDK_KEY_Down = ', GDK_KEY_Down, ', GDK_KEY_Up = ', GDK_KEY_Up]);
if Key = GDK_KEY_BackSpace then begin
if g_utf8_strlen(PChar(Entry.Text), -1) > 0 then begin
// DebugMsg(['TFMain.QuickFindSendKey: before delete: "', Entry.Text, '", ansi = "', UTF8ToStr(Entry.Text), '"']);
g := malloc(Length(Entry.Text));
memset(g, 0, Length(Entry.Text));
g_utf8_strncpy(g, PChar(Entry.Text), g_utf8_strlen(PChar(Entry.Text), -1) - 1);
// DebugMsg(['TFMain.QuickFindSendKey: after delete: "', g, '", ansi = "', UTF8ToStr(g), '"']);
Entry.Text := g;
libc_free(g);
end;
NewText := Entry.Text;
end else
if (Key = GDK_KEY_Down) or (Key = GDK_KEY_Up) then begin
if Length(Entry.Text) = 0 then begin
DeactivateQuickFind(LeftPanel);
Result := False;
Exit;
end else NewText := Entry.Text;
end else begin
s := UTF8Encode(WideChar(KeyValToUnicode(Key)));
if (Length(s) = 0) or (s = #0) then Exit;
NewText := Entry.Text + s;
end;
if (DataList.Count > 0) and (Length(NewText) > 0) then begin
NewIndex := -1;
StartIndex := (AListView.ConvertToSorted(AListView.Selected.Index) + Ord(Key = GDK_KEY_Down) - Ord(Key = GDK_KEY_Up)) mod DataList.Count;
if StartIndex < 0 then StartIndex := 0;
if StartIndex > DataList.Count - 1 then StartIndex := DataList.Count - 1;
// DebugMsg(['TFMain.QuickFindSendKey: StartIndex = ', StartIndex]);
if Key <> GDK_KEY_Up then begin
// Search down
for i := StartIndex to DataList.Count - 1 do begin
Data := DataList[AListView.ConvertFromSorted(i)];
if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
NewIndex := i;
Break;
end;
end;
if NewIndex < 0 then
for i := 0 to StartIndex do begin
Data := DataList[AListView.ConvertFromSorted(i)];
if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
NewIndex := i;
Break;
end;
end;
end else begin
// Search up
for i := StartIndex downto 0 do begin
Data := DataList[AListView.ConvertFromSorted(i)];
if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
NewIndex := i;
Break;
end;
end;
if NewIndex < 0 then
for i := DataList.Count - 1 downto StartIndex do begin
Data := DataList[AListView.ConvertFromSorted(i)];
if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
NewIndex := i;
Break;
end;
end;
end;
if NewIndex >= 0 then begin
OldSelectionChangedEvent := AListView.OnSelectionChanged;
AListView.OnSelectionChanged := nil;
AListView.Selected := AListView.Items[AListView.ConvertFromSorted(NewIndex)];
AListView.Items[AListView.ConvertFromSorted(NewIndex)].SetCursor(0, False, False, 0, 0);
SaveCursorPositionTabbed(LeftPanel);
AListView.OnSelectionChanged := OldSelectionChangedEvent;
Entry.Text := NewText;
end else Beep;
Result := True;
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.miVerifyChecksumsClick(Sender: TObject);
var i, SelCount: integer;
b, LeftPanel: boolean;
AListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
SelCount := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) and (not IsDir) then Inc(SelCount);
if (SelCount = 0) and ((not Assigned(AListView.Selected)) or PDataItem(AListView.Selected.Data)^.UpDir or PDataItem(AListView.Selected.Data)^.IsDir) then begin
Application.MessageBox(LANGYouMustSelectAValidFile, [mbOK], mbError, mbNone, mbOK);
Exit;
end;
try
FChecksum := TFChecksum.Create(Self);
FChecksum.Engine := Engine;
FChecksum.DataList := DataList;
FChecksum.AListView := AListView;
if SelCount = 0 then b := FChecksum.ProcessFile(IncludeTrailingPathDelimiter(Engine.Path) + string(PDataItem(AListView.Selected.Data)^.FName))
else begin
b := False;
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if (not UpDir) and (not IsDir) and Selected then
b := b or FChecksum.ProcessFile(IncludeTrailingPathDelimiter(Engine.Path) + string(FName));
end;
if b { and (FChecksum.List.Count > 0) } then FChecksum.Run;
finally
FChecksum.Free;
end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
(********************************************************************************************************************************)
procedure TFMain.miCreateChecksumsClick(Sender: TObject);
var i, SelCount: integer;
LeftPanel: boolean;
AListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
SelCount := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) and (not IsDir) then Inc(SelCount);
if (SelCount = 0) and ((not Assigned(AListView.Selected)) or PDataItem(AListView.Selected.Data)^.UpDir or PDataItem(AListView.Selected.Data)^.IsDir) then begin
Application.MessageBox(LANGYouMustSelectAtLeastOneFileToCalculateChecksum, [mbOK], mbError, mbNone, mbOK);
Exit;
end;
try
FChecksumDruid := TFChecksumDruid.Create(Self);
FChecksumDruid.Engine := Engine;
if Engine.Path = '/' then FChecksumDruid.DirName := 'root'
else FChecksumDruid.DirName := ExtractFileName(ExcludeTrailingPathDelimiter(Engine.Path));
if SelCount = 0 then FChecksumDruid.FileNames.Add(IncludeTrailingPathDelimiter(Engine.Path) + string(PDataItem(AListView.Selected.Data)^.FName))
else
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if (not UpDir) and (not IsDir) and Selected then
FChecksumDruid.FileNames.Add(IncludeTrailingPathDelimiter(Engine.Path) + string(FName));
FChecksumDruid.Run;
finally
if FChecksumDruid.SeparateFileCheckBox.Checked
then DoRefresh(AListView = LeftListView, True, True)
else ChangingDir(AListView = LeftListView, Engine.Path, FChecksumDruid.FileNameEntry.Text, PDataItem(AListView.Selected.Data)^.FName);
DoRefresh(AListView <> LeftListView, True, True);
FChecksumDruid.Free;
end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.miMergeFilesClick(Sender: TObject);
var LeftPanel, HasInitialCRC: boolean;
AListView: TGTKListView;
Engine: TPanelEngine;
FilePath, s, TargetName: string;
TargetCRC: Cardinal;
TargetSize: Int64;
AWorkingThread: TWorkerThread;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
end;
if (not Assigned(AListView.Selected)) or (not Assigned(AListView.Selected.Data)) or PDataItem(AListView.Selected.Data)^.IsDir or
PDataItem(AListView.Selected.Data)^.UpDir then
begin
Application.MessageBox(LANGYouMustSelectAValidFile, [mbOK], mbError, mbNone, mbOK);
Exit;
end;
FilePath := '';
try
FNewDir := TFNewDir.Create(Self);
FNewDir.Caption := LANGMergeCaption;
FNewDir.Label1.SetSizeRequest(500, -1);
FNewDir.Label1.Caption := Format(LANGMergeSAndAllFilesWithAscendingNamesToTheFollowingDirectory, [PDataItem(AListView.Selected.Data)^.FDisplayName]);
if LeftPanel then FNewDir.Entry.Text := StrToUTF8(RightPanelEngine.Path)
else FNewDir.Entry.Text := StrToUTF8(LeftPanelEngine.Path);
FNewDir.Entry.SelectAll;
if FNewDir.Run = mbOK
then FilePath := UTF8ToStr(FNewDir.Entry.Text)
else Exit;
finally
FNewDir.Free;
end;
if FilePath = '' then Exit;
AWorkingThread := TWorkerThread.Create;
DebugMsg(['TFMain.miMergeFilesClick: Creating thread...']);
try
AWorkingThread.DialogsParentWindow := Self;
AWorkingThread.MergeTargetPath := FilePath;
AWorkingThread.MergeSourceFile := IncludeTrailingPathDelimiter(Engine.Path) + PDataItem(AListView.Selected.Data)^.FName;
HasInitialCRC := CRCGetInfo(AWorkingThread.MergeSourceFile, Engine, TargetName, TargetCRC, TargetSize);
AWorkingThread.MergeTargetFinalName:= TargetName;
AWorkingThread.MergeHasInitialCRC := HasInitialCRC;
AWorkingThread.MergeTargetCRC := TargetCRC;
AWorkingThread.MergeTargetSize := TargetSize;
AWorkingThread.AEngine := Engine;
AWorkingThread.JobType := WORKER_JOB_MERGE;
AWorkingThread.Resume;
ProcessThreadEvents(AWorkingThread);
s := AWorkingThread.MergeTargetFinalName;
finally
DebugMsg(['TFMain.miMergeFilesClick: Freeing thread...']);
AWorkingThread.Free;
end;
ChangingDir(LeftPanel, Engine.Path, s, PDataItem(AListView.Selected.Data)^.FName);
DoRefresh(not LeftPanel, True, True);
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
(********************************************************************************************************************************)
procedure TFMain.miSplitFileClick(Sender: TObject);
var LeftPanel: boolean;
AListView: TGTKListView;
Engine: TPanelEngine;
FilePath: string;
DeleteTarget: boolean;
MaxSize: Int64;
i: integer;
AWorkingThread: TWorkerThread;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
end;
if (not Assigned(AListView.Selected)) or (not Assigned(AListView.Selected.Data)) or PDataItem(AListView.Selected.Data)^.IsDir or
PDataItem(AListView.Selected.Data)^.UpDir then
begin
Application.MessageBox(LANGYouMustSelectAValidFile, [mbOK], mbError, mbNone, mbOK);
Exit;
end;
FilePath := '';
try
FSplitFile := TFSplitFile.Create(Self);
FSplitFile.Label1.Caption := Format(LANGSplitTheFileSToDirectory, [PDataItem(AListView.Selected.Data)^.FDisplayName]);
FSplitFile.Label1.UseUnderline := True;
if LeftPanel then FSplitFile.Entry.Text := StrToUTF8(RightPanelEngine.Path)
else FSplitFile.Entry.Text := StrToUTF8(LeftPanelEngine.Path);
FSplitFile.Entry.SelectAll;
if FSplitFile.Run = mbOK
then FilePath := UTF8ToStr(FSplitFile.Entry.Text)
else Exit;
DeleteTarget := FSplitFile.DeleteTargetCheckBox.Checked;
MaxSize := 0;
for i := 1 to Length(SplitConsts) do
if Trim(WideUpperCase(SplitConsts[i].Title)) = Trim(WideUpperCase(FSplitFile.SizeCombo.Entry.Text)) then
begin
MaxSize := SplitConsts[i].PartSize;
Break;
end;
if MaxSize = 0 then MaxSize := GetStrSize(FSplitFile.SizeCombo.Entry.Text);
finally
FSplitFile.Free;
end;
if FilePath = '' then Exit;
AWorkingThread := TWorkerThread.Create;
DebugMsg(['TFMain.miSplitFileClick: Creating thread...']);
try
AWorkingThread.DialogsParentWindow := Self;
AWorkingThread.SplitSourceFile := IncludeTrailingPathDelimiter(Engine.Path) + PDataItem(AListView.Selected.Data)^.FName;
AWorkingThread.SplitTargetPath := FilePath;
AWorkingThread.SplitDeleteTarget := DeleteTarget;
AWorkingThread.SplitMaxSize := MaxSize;
AWorkingThread.AEngine := Engine;
AWorkingThread.JobType := WORKER_JOB_SPLIT;
AWorkingThread.Resume;
ProcessThreadEvents(AWorkingThread);
finally
DebugMsg(['TFMain.miSplitFileClick: Freeing thread...']);
AWorkingThread.Free;
end;
DoRefresh(LeftPanel, True, True);
DoRefresh(not LeftPanel, True, True);
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.SwitchOtherPanel(LeftPanel, RequestNewAltO: boolean);
var AListView: TGTKListView;
SrcEngine, OrigSrcEngine, TargetEngine: TPanelEngine;
s: string;
DontShowAgain: boolean;
begin
if LeftPanel then begin
AListView := LeftListView;
SrcEngine := LeftPanelEngine;
TargetEngine := RightPanelEngine;
end else begin
AListView := RightListView;
SrcEngine := RightPanelEngine;
TargetEngine := LeftPanelEngine;
end;
OrigSrcEngine := SrcEngine;
if not (SrcEngine is TLocalTreeEngine) then begin
if ConfSwitchOtherPanelBehaviour < 0 then begin
MessageBoxShowOnce(PGtkWindow(FWidget), LANGSwitchOtherPanelWarning, LANGDontShowAgain, DontShowAgain, [mbOK], mbWarning, mbOK, mbOK);
if DontShowAgain then begin
ConfSwitchOtherPanelBehaviour := 1;
WriteMainGUISettings;
end;
end;
// Exit;
end;
// don't change dir in VFS engines
while not (SrcEngine is TLocalTreeEngine) do SrcEngine := SrcEngine.ParentEngine;
while not (TargetEngine is TLocalTreeEngine) do TargetEngine := TargetEngine.ParentEngine;
if (not ConfNewStyleAltO) and (not RequestNewAltO) then begin
s := ExcludeTrailingPathDelimiter(SrcEngine.Path);
if OrigSrcEngine = SrcEngine then begin
if (not Assigned(AListView.Selected)) or (not Assigned(AListView.Selected.Data)) or PDataItem(AListView.Selected.Data)^.UpDir or
(not PDataItem(AListView.Selected.Data)^.IsDir)
then begin if Length(s) > 1 then s := IncludeTrailingPathDelimiter(Copy(s, 1, LastDelimiter(PathDelim, s))); end
else s := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(s) + PDataItem(AListView.Selected.Data)^.FName);
end;
if IncludeTrailingPathDelimiter(TargetEngine.Path) <> s then begin
if LeftPanel then RightPanelEngine := TargetEngine
else LeftPanelEngine := TargetEngine;
ChangingDir(not LeftPanel, s);
end;
// Move one item down
if (OrigSrcEngine = SrcEngine) and Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) < AListView.Items.Count - 1) then begin
AListView.Selected := AListView.Items[AListView.ConvertFromSorted(AListView.ConvertToSorted(AListView.Selected.Index) + 1)];
AListView.Selected.SetCursor(0, False, False, 0, 0);
end;
end else begin
if IncludeTrailingPathDelimiter(TargetEngine.Path) <> IncludeTrailingPathDelimiter(SrcEngine.Path) then begin
if LeftPanel then RightPanelEngine := TargetEngine
else LeftPanelEngine := TargetEngine;
ChangingDir(not LeftPanel, SrcEngine.Path);
end;
end;
end;
procedure TFMain.miShowDotFilesClick(Sender: TObject);
begin
ConfShowDotFiles := miShowDotFiles.Checked;
DoRefresh(True, True, True);
DoRefresh(False, True, True);
end;
procedure TFMain.F3F4ButtonClick(Sender: TObject);
var LeftPanel: boolean;
AListView: TGTKListView;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
end else begin
AListView := RightListView;
end;
if (not Assigned(AListView.Selected)) or (not Assigned(AListView.Selected.Data)) or PDataItem(AListView.Selected.Data)^.IsDir or
PDataItem(AListView.Selected.Data)^.UpDir then
begin
Application.MessageBox(LANGYouMustSelectAValidFile, [mbOK], mbError, mbNone, mbOK);
Exit;
end;
EditViewFile(LeftPanel, AListView, (Sender = F3Button) or ((Sender is TGTKMenuItem) and (Integer((Sender as TGTKMenuItem).Data) = 200)), False);
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.EditViewFile(LeftPanel: boolean; AListView: TGTKListView; View, NewFile: boolean);
var ANewDir: TFNewDir;
Engine: TPanelEngine;
AFile: string;
begin
try
InternalLock;
if LeftPanel then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
if NewFile then begin
ANewDir := TFNewDir.Create(Self);
try
ANewDir.Caption := LANGEdit;
ANewDir.Label1.Caption := LANGEnterFilenameToEdit;
ANewDir.Label1.UseUnderline := True;
ANewDir.Label1.FocusControl := ANewDir.Entry;
if Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and (not PDataItem(AListView.Selected.Data)^.IsDir) and
(not PDataItem(AListView.Selected.Data)^.UpDir)
then ANewDir.Entry.Text := PDataItem(AListView.Selected.Data)^.FDisplayName
else ANewDir.Entry.Text := '';
if Length(ANewDir.Entry.Text) > 0 then ANewDir.Entry.SelectAll;
if ANewDir.Run <> mbOK then Exit;
AFile := IncludeTrailingPathDelimiter(Engine.Path) + UTF8ToStr(ANewDir.Entry.Text);
finally
ANewDir.Free;
end;
end else AFile := IncludeTrailingPathDelimiter(Engine.Path) + PDataItem(AListView.Selected.Data)^.FName;
EditViewFileInternal(AFile, Engine, View, NewFile);
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
procedure TFMain.EditViewFileInternal(Filename: string; Engine: TPanelEngine; View, NewFile: boolean);
var s: string;
Stat: PDataItem;
Error, x: integer;
// AViewer: TViewerThread;
AViewer: TFViewer;
begin
Stat := Engine.GetFileInfo(Filename, True, True, nil);
if Assigned(Stat) and (Stat^.Size > ConfEditViewFileSizeLimit) and
(Application.MessageBox(LANGTheFileYouAreTryingToOpenIsQuiteBig, [mbYes, mbNo], mbWarning, mbNone, mbNo) = mbNo)
then begin
FreeDataItem(Stat);
Exit;
end;
FreeDataItem(Stat);
if View then s := ConfViewer
else s := ConfEditor;
if (Engine is TVFSEngine) and (not NewFile) then
if not HandleRunFromArchive(Filename, Engine, s, '', True) then Exit;
if ConfUseInternalViewer and View then begin
(* AViewer := TViewerThread.Create(Self);
if not AViewer.LoadFile(AFile) then begin
Application.MessageBox(Format('Cannot load file ''%s''. Please check the permissions.', [ANSIToUTF8(AFile)]), [mbOK], mbError);
AViewer.Free;
end else AViewer.Resume; *)
AViewer := TFViewer.Create(Self);
if not AViewer.LoadFile(Filename) then begin
Application.MessageBox(Format(LANGCannotLoadFile, [Filename]), [mbOK], mbError, mbNone, mbOK);
AViewer.Free;
end else begin
// gtk_window_set_transient_for(PGtkWindow(AViewer.FWidget), PGtkWindow(ParentWindow.FWidget));
AViewer.Show;
end;
end else begin
if View then x := ConfViewerTerminalBehaviour
else x := ConfEditorTerminalBehaviour;
if not ExecuteProgram(Format('%s %s', [s, QuoteStr(Filename)]), ExtractFilePath(Filename), x = 0, x = 1, Error) then
Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [s]), [mbOK], mbError, mbNone, mbOK);
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.miFileTypesClick(Sender: TObject);
var x: pointer;
begin
try
InternalLock;
FFileTypeSettings := TFFileTypeSettings.Create(Self);
ReadAssoc;
FFileTypeSettings.AssignAssocList(AssocList);
FFileTypeSettings.FillList;
if FFileTypeSettings.Run = mbOK then begin
RemoveIconRefs(FFileTypeSettings.IntAssocList, True);
RemoveIconRefs(AssocList, False);
FFileTypeSettings.CleanItems;
x := AssocList;
AssocList := FFileTypeSettings.IntAssocList;
FFileTypeSettings.IntAssocList := TList(x);
RecreateIcons(AssocList);
DoRefresh(True, True, True);
DoRefresh(False, True, True);
WriteAssoc;
end;
finally
FFileTypeSettings.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.RunFile(Path: string; Engine: TPanelEngine; CustomAction: integer);
var Command, FileTypeDesc: string;
i, ac: integer;
b, AutodetectGUI, RunInTerminal: boolean;
Stat: PDataItem;
s: string;
Assoc: TFileAssoc;
begin
try
InternalLock;
Command := '';
FileTypeDesc := '';
AutodetectGUI := True;
RunInTerminal := False;
Assoc := FindAssoc(ExtractFileName(Path));
if Assoc <> nil then begin
FileTypeDesc := Assoc.FileTypeName;
if (CustomAction > Assoc.ActionList.Count - 1) or (CustomAction = -1)
then ac := Assoc.DefaultAction
else ac := CustomAction;
if ac > Assoc.ActionList.Count - 1 then ac := 0;
if Assoc.ActionList.Count > ac then begin
Command := UTF8ToStr(Trim(TAssocAction(Assoc.ActionList[ac]).ActionCommand));
AutodetectGUI := TAssocAction(Assoc.ActionList[ac]).AutodetectGUI;
RunInTerminal := TAssocAction(Assoc.ActionList[ac]).RunInTerminal;
end;
end;
// Association not found, try to execute file itself
if Command = '' then begin
DebugMsg(['File association not found']);
if CustomAction > -1 then begin
DebugMsg(['Some strange error occured...']);
Exit;
end;
Stat := Engine.GetFileInfo(Path, True, True, nil);
if Assigned(Stat) and Stat^.IsExecutable then begin
b := True;
if Engine is TVFSEngine then b := HandleRunFromArchive(Path, Engine, Command, FileTypeDesc, False); // not a local engine, extract to local first
if b then begin
libc_chdir(PChar(ExtractFilePath(Path)));
b := ExecuteProgram(QuoteStr(Path), ExtractFilePath(Path), AutodetectGUI, RunInTerminal, i);
libc_chdir(PChar('/'));
end else b := True; // Mask cancelled extraction from VFS
FreeDataItem(Stat);
end else begin
if Engine is TVFSEngine then begin
HandleRunFromArchive(Path, Engine, Command, FileTypeDesc, False);
// b := True;
end else
if Application.MessageBox(Format(LANGThereIsNoApplicationAssociatedWithS, [StrToUTF8(ExtractFileName(Path))]), [mbYes, mbNo], mbQuestion, mbNone, mbNo) = mbYes
then miFileTypesClick(Self);
Exit;
end;
end else begin
DebugMsg(['File association found: ', Command]);
s := Command;
b := True;
if Engine is TVFSEngine then b := HandleRunFromArchive(Path, Engine, Command, FileTypeDesc, False); // not a local engine, extract to local first
if Pos('%s', s) > 0 then s := Format(s, ['''' + QuoteStr(Path) + ''''])
else s := Format('%s %s', [s, QuoteStr(Path)]);
// DebugMsg(['execute: ', s, ' , ', Command, ' , ', QuoteStr(Path)]);
if b then begin
libc_chdir(PChar(ExtractFilePath(Path)));
b := ExecuteProgram(s, ExtractFilePath(Path), AutodetectGUI, RunInTerminal, i);
libc_chdir(PChar('/'));
end else b := True; // Mask cancelled extraction from VFS
end;
if not b then Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [s]), [mbOK], mbError, mbNone, mbOK);
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
procedure TFMain.CommandLineComboKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
var Error, OldPos, i: integer;
AListView: TGTKListView;
Engine: TPanelEngine;
s, s2, Orig: string;
begin
try
InternalLock;
case Key of
GDK_KEY_Return, GDK_KEY_KP_Enter: begin
Accept := False;
if LeftLastFocused then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
// Insert filename
if (ssAlt in Shift) or (ssCtrl in Shift) then begin
if LeftLastFocused then AListView := LeftListView
else AListView := RightListView;
if Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and (not PDataItem(AListView.Selected.Data)^.UpDir) then begin
s2 := QuoteStr(String(PDataItem(AListView.Selected.Data)^.FDisplayName)) + ' ';
if Length(CommandLineCombo.Entry.Text) = 0 then begin
CommandLineCombo.Entry.Text := Format('./%s', [s2]);
CommandLineCombo.Entry.CursorPosition := Length(s2);
end else begin
OldPos := CommandLineCombo.Entry.CursorPosition;
s := CommandLineCombo.Entry.Text;
Insert(s2, s, OldPos + 1);
CommandLineCombo.Entry.Text := s;
CommandLineCombo.Entry.CursorPosition := OldPos + Length(s2);
end;
end;
Exit;
end;
Orig := Trim(CommandLineCombo.Entry.Text);
if Length(Orig) > 0 then begin
if WideUpperCase(Orig) = 'CD' then begin
if LeftLastFocused then PathButtonClick(LeftHomeButton)
else PathButtonClick(RightHomeButton);
end else
if (Length(Orig) > 3) and (WideUpperCase(Copy(Orig, 1, 3)) = 'CD ') then begin
ChangingDir(LeftLastFocused, ProcessPattern(Engine, UTF8ToStr(Copy(Orig, 4, Length(Orig) - 3)), Engine.Path, '', True));
end else begin
while not (Engine is TLocalTreeEngine) do Engine := Engine.ParentEngine;
libc_chdir(PChar(Engine.Path));
if not ExecuteProgram(UTF8ToStr(Orig), Engine.Path, ConfCmdLineTerminalBehaviour = 0 , ConfCmdLineTerminalBehaviour = 1, Error) then
Application.MessageBox(LANGErrorExecutingCommand, [mbOK], mbError, mbNone, mbOK);
libc_chdir('/');
end;
end;
CommandLineCombo.Entry.Text := '';
if LeftLastFocused then LeftListView.SetFocus
else RightListView.SetFocus;
if Length(Orig) > 0 then begin
SaveItemToHistory(Orig, CommandLineHistory);
CommandLineCombo.ClearItems();
if CommandLineHistory.Count > 0 then
for i := 0 to CommandLineHistory.Count - 1 do
CommandLineCombo.AppendItem(CommandLineHistory[i]);
CommandLineCombo.Entry.Text := '';
end;
end;
GDK_KEY_Down, GDK_KEY_Up:
begin
Accept := False;
if LeftLastFocused then AListView := LeftListView
else AListView := RightListView;
if (not (([ssCtrl] = Shift) and (Key = GDK_KEY_Up))) and (
((Key = GDK_KEY_Down) and (AListView.ConvertToSorted(AListView.Selected.Index) < AListView.Items.Count - 1)) or
((Key = GDK_KEY_Up) and (AListView.ConvertToSorted(AListView.Selected.Index) > 0))) then
begin
AListView.Selected := AListView.Items[AListView.ConvertFromSorted(AListView.ConvertToSorted(AListView.Selected.Index) + (Ord(Key = GDK_KEY_Down) * 2) - 1)];
AListView.Selected.SetCursor(0, False, False, 0, 0);
end;
AListView.SetFocus;
end;
GDK_KEY_Escape: begin
Accept := False;
CommandLineCombo.Entry.Text := '';
if LeftLastFocused then LeftListView.SetFocus
else RightListView.SetFocus;
end;
GDK_KEY_Tab: begin
Accept := False;
if LeftLastFocused then RightListView.SetFocus
else LeftListView.SetFocus;
end;
GDK_KEY_P: if ((Shift = [ssAlt]) or (Shift = [ssCtrl])) and (CommandLineHistory.Count > 0) then
begin
Accept := False;
Orig := Trim(CommandLineCombo.Entry.Text);
i := CommandLineHistory.IndexOf(Orig);
if i < 0 then begin
SavedCmdLine := Orig;
i := 0;
end else
if CommandLineHistory.Count > i + 1 then Inc(i);
CommandLineCombo.Entry.Text := CommandLineHistory[i];
CommandLineCombo.Entry.SetFocus;
CommandLineCombo.Entry.SelectRegion(Length(CommandLineCombo.Entry.Text), Length(CommandLineCombo.Entry.Text));
end else if not CommandLineCombo.Entry.Focused then ActivateCommandLine(Key);
GDK_KEY_N: if ((Shift = [ssAlt]) or (Shift = [ssCtrl])) and (CommandLineHistory.Count > 0) then
begin
Accept := False;
Orig := Trim(CommandLineCombo.Entry.Text);
i := CommandLineHistory.IndexOf(Orig);
if i < 0 then Exit else
if i = 0 then begin
s := SavedCmdLine;
SavedCmdLine := '';
end else
if CommandLineHistory.Count > i then s := CommandLineHistory[i - 1];
CommandLineCombo.Entry.Text := s;
CommandLineCombo.Entry.SetFocus;
CommandLineCombo.Entry.SelectRegion(Length(CommandLineCombo.Entry.Text), Length(CommandLineCombo.Entry.Text));
end else if not CommandLineCombo.Entry.Focused then ActivateCommandLine(Key);
GDK_KEY_A: if (Shift = [ssAlt]) or (Shift = [ssCtrl]) then
begin
Accept := False;
if LeftLastFocused then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
s2 := QuoteStr(IncludeTrailingPathDelimiter(Engine.Path));
OldPos := CommandLineCombo.Entry.CursorPosition;
s := CommandLineCombo.Entry.Text;
Insert(s2, s, OldPos + 1);
CommandLineCombo.Entry.SetFocus;
CommandLineCombo.Entry.Text := s;
CommandLineCombo.Entry.CursorPosition := OldPos + Length(s2);
end else if not CommandLineCombo.Entry.Focused then ActivateCommandLine(Key);
end;
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
function TFMain.ActivateCommandLine(Key: word; const ActualPosition: boolean = False): boolean;
var s, s2: string;
OldPos: integer;
begin
Result := False;
s := UTF8Encode(WideChar(KeyValToUnicode(Key)));
if (Length(s) = 0) or (s = #0) then Exit;
if ActualPosition and CommandLineCombo.Entry.Focused then begin
OldPos := CommandLineCombo.Entry.CursorPosition;
s2 := CommandLineCombo.Entry.Text;
Insert(s, s2, Length(LeftStr(s2, OldPos)) + 1);
CommandLineCombo.Entry.Text := s2;
CommandLineCombo.Entry.CursorPosition := OldPos + 1;
end else begin
CommandLineCombo.Entry.Text := CommandLineCombo.Entry.Text + s;
CommandLineCombo.Entry.SetFocus;
CommandLineCombo.Entry.SelectRegion(Length(CommandLineCombo.Entry.Text), Length(CommandLineCombo.Entry.Text));
end;
Result := True;
end;
procedure TFMain.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
var AListView: TGTKListView;
begin
if (ConfQuickSearchActivationKey = 2) and (Shift = [ssAlt]) and (LeftListView.Focused or RightListView.Focused) then begin
Accept := not HandleKey(Key, Shift, LeftListView.Focused);
if not Accept then Exit;
end;
if CommandLineCombo.Entry.Focused then CommandLineComboKeyDown(Sender, Key, Shift, Accept);
if Editing and (Key = GDK_KEY_Escape) then begin
Editing := False;
if LeftLastFocused then AListView := LeftListView
else AListView := RightListView;
AListView.Columns[0].SetProperty('editable', 0);
end;
end;
(********************************************************************************************************************************)
procedure TFMain.miChangePermissionsClick(Sender: TObject);
var LeftPanel: boolean;
AListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
i: longint;
SelCount: longint;
AFile, NextItem1, NextItem2: string;
Stat: PDataItem;
UsrManager: TUserManager;
AWorkingThread: TWorkerThread;
begin
try
InternalLock;
Stat := nil;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
SelCount := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then Inc(SelCount);
if (SelCount = 0) and ((not Assigned(AListView.Selected)) or PDataItem(AListView.Selected.Data)^.UpDir) then begin
Application.MessageBox(LANGNoFilesSelected, [mbOK], mbInfo, mbNone, mbOK);
Exit;
end;
AFile := '';
if SelCount = 0 then AFile := PDataItem(AListView.Selected.Data)^.FName else
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then begin
AFile := FName;
Break;
end;
if AFile <> '' then
try
FChmod := TFChmod.Create(Self);
Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True, nil);
if not Assigned(Stat) then Exit;
UsrManager := TUserManager.Create;
try
FChmod.AssignMode(Stat^.Mode, AFile, UsrManager.GetUserName(Stat^.UID), UsrManager.GetGroupName(Stat^.GID));
finally
UsrManager.Free;
end;
if FChmod.Run = mbOK then begin
FindNextSelected(AListView, DataList, NextItem1, NextItem2);
AWorkingThread := TWorkerThread.Create;
try
AWorkingThread.DialogsParentWindow := Self;
if Assigned(AListView.Selected) then AWorkingThread.SelectedItem := AListView.Selected.Data;
if not FChmod.RecursiveCheckButton.Checked
then AWorkingThread.ChmodRecurseType := -1
else AWorkingThread.ChmodRecurseType := FChmod.RecursiveComboBox.ItemIndex;
AWorkingThread.ChmodMode := FChmod.LastMode;
AWorkingThread.AEngine := Engine;
AWorkingThread.DataList := DataList;
AWorkingThread.JobType := WORKER_JOB_CHMOD;
AWorkingThread.Resume;
ProcessThreadEvents(AWorkingThread);
finally
AWorkingThread.Free;
end;
ChangingDir(LeftPanel, Engine.Path, NextItem1, NextItem2);
DoRefresh(not LeftPanel, True, True);
end;
finally
FreeDataItem(Stat);
FChmod.Free;
end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.miChangeOwnerClick(Sender: TObject);
var LeftPanel: boolean;
AListView: TGTKListView;
Engine: TPanelEngine;
DataList: TList;
i: integer;
SelCount: longint;
AFile, NextItem1, NextItem2: string;
Stat: PDataItem;
AWorkingThread: TWorkerThread;
begin
try
InternalLock;
Stat := nil;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
SelCount := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then Inc(SelCount);
if (SelCount = 0) and ((not Assigned(AListView.Selected)) or PDataItem(AListView.Selected.Data)^.UpDir) then begin
Application.MessageBox(LANGNoFilesSelected, [mbOK], mbInfo, mbNone, mbOK);
Exit;
end;
AFile := '';
if SelCount = 0 then AFile := PDataItem(AListView.Selected.Data)^.FName else
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then begin
AFile := FName;
Break;
end;
if AFile <> '' then
try
FChown := TFChown.Create(Self);
Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True, nil);
if not Assigned(Stat) then Exit;
FChown.AssignMode(Stat^.Mode, AFile, Stat^.UID, Stat^.GID);
if FChown.Run = mbOK then begin
FindNextSelected(AListView, DataList, NextItem1, NextItem2);
AWorkingThread := TWorkerThread.Create;
try
AWorkingThread.DialogsParentWindow := Self;
if Assigned(AListView.Selected) then AWorkingThread.SelectedItem := AListView.Selected.Data;
AWorkingThread.ChownRecursive := FChown.RecursiveCheckButton.Checked;
AWorkingThread.ChownUID := FChown.LastUID;
AWorkingThread.ChownGID := FChown.LastGID;
AWorkingThread.AEngine := Engine;
AWorkingThread.DataList := DataList;
AWorkingThread.JobType := WORKER_JOB_CHOWN;
AWorkingThread.Resume;
ProcessThreadEvents(AWorkingThread);
finally
AWorkingThread.Free;
end;
ChangingDir(LeftPanel, Engine.Path, NextItem1, NextItem2);
DoRefresh(not LeftPanel, True, True);
end;
finally
FreeDataItem(Stat);
FChown.Free;
end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
(********************************************************************************************************************************)
procedure TFMain.miCreateSymlinkClick(Sender: TObject);
var LeftPanel: boolean;
AListView: TGTKListView;
Engine, EngineOpposite: TPanelEngine;
s1, s2: string;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
EngineOpposite := RightPanelEngine;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
EngineOpposite := LeftPanelEngine;
end;
if (not Assigned(AListView.Selected)) or (not Assigned(AListView.Selected.Data)) or PDataItem(AListView.Selected.Data)^.UpDir
then s1 := ExcludeTrailingPathDelimiter(Engine.Path)
else s1 := IncludeTrailingPathDelimiter(Engine.Path) + PDataItem(AListView.Selected.Data)^.FName;
if Engine.Path <> EngineOpposite.Path
then s2 := IncludeTrailingPathDelimiter(EngineOpposite.Path) + PDataItem(AListView.Selected.Data)^.FName
else s2 := IncludeTrailingPathDelimiter(EngineOpposite.Path) + Format(LANGLinkToS, [PDataItem(AListView.Selected.Data)^.FName]);
if CreateSymlink(s1, s2, Engine) then begin
DoRefresh(LeftPanel, True, True);
DoRefresh(not LeftPanel, True, True);
end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.miEditSymlinkClick(Sender: TObject);
var LeftPanel: boolean;
AListView: TGTKListView;
Engine: TPanelEngine;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
end;
if (not Assigned(AListView.Selected)) or (not Assigned(AListView.Selected.Data)) or (not PDataItem(AListView.Selected.Data)^.IsLnk) or
PDataItem(AListView.Selected.Data)^.UpDir then
begin
Application.MessageBox(LANGYouMustSelectAValidSymbolicLink, [mbOK], mbError, mbNone, mbOK);
Exit;
end;
if EditSymlink(IncludeTrailingPathDelimiter(Engine.Path) + PDataItem(AListView.Selected.Data)^.FName, Engine) then begin
DoRefresh(LeftPanel, True, True);
DoRefresh(not LeftPanel, True, True);
end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
(********************************************************************************************************************************)
procedure TFMain.FilePopupMenuPopup(Sender: TObject);
procedure ClearPopupMenu(Popup: TGTKMenuItem);
var x: TGTKMenuItem;
begin
while Popup.Count > 0 do begin
if Popup.Items[0].Count > 0 then ClearPopupMenu(Popup.Items[0]);
x := Popup.Items[0];
Popup.Delete(0);
x.Free;
end;
end;
var Item: TGTKMenuItem;
DataItem: PDataItem;
Engine: TPanelEngine;
AListView: TGTKListView;
FileName, ShortFName: string;
UpDir, Found: boolean;
i, j: integer;
Assoc: TFileAssoc;
Error: PGError;
begin
ClearPopupMenu(FilePopupMenu);
if LeftLastFocused then begin
Engine := LeftPanelEngine;
AListView := LeftListView;
end else begin
Engine := RightPanelEngine;
AListView := RightListView;
end;
FileName := IncludeTrailingPathDelimiter(Engine.Path);
if Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and (not PDataItem(AListView.Selected.Data)^.UpDir)
then FileName := FileName + PDataItem(AListView.Selected.Data)^.FName;
ShortFName := ExtractFileName(ExcludeTrailingPathDelimiter(FileName));
Error := nil;
DataItem := Engine.GetFileInfo(FileName, True, True, @Error);
if not Assigned(DataItem) then begin
DebugMsg(['Error: File data not assigned. Bug ???! FileName = ', FileName, ', Error = ', Error^.message]);
g_error_free(Error);
Exit;
end;
UpDir := PDataItem(AListView.Selected.Data)^.UpDir;
if not DataItem^.IsDir then begin
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := Format(LANGPopupRunS, [QuoteMarkupStr(StrToUTF8(ShortFName), True)]);
Item.IconName := 'gtk-execute';
Item.Data := Pointer(1);
Item.OnClick := @FilePopupMenuItemClick;
Item.Enabled := Engine.FileCanRun(FileName);
FilePopupMenu.Add(Item);
end else begin
// Open directory
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
if UpDir then Item.Caption := LANGPopupGoUp
else Item.Caption := Format(LANGPopupOpenS, [QuoteMarkupStr(StrToUTF8(ShortFName), True)]);
Item.IconName := 'gtk-open';
Item.Data := Pointer(1);
Item.OnClick := @FilePopupMenuItemClick;
FilePopupMenu.Add(Item);
// Open directory in background tab
if not UpDir then begin
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGOpenDirectoryInBackgroundTab;
Item.Data := Pointer(3);
Item.OnClick := @FilePopupMenuItemClick;
FilePopupMenu.Add(Item);
end;
end;
// Find actions for meta-item
if AssocList.Count > 0 then
for i := 0 to AssocList.Count - 1 do
if ((DataItem^.IsDir and (TFileAssoc(AssocList[i]).FileTypeName = ConstFTAMetaDirectory)) or
((not DataItem^.IsDir) and (TFileAssoc(AssocList[i]).FileTypeName = ConstFTAMetaFile))) and
(TFileAssoc(AssocList[i]).ActionList.Count > 0) then
with TFileAssoc(AssocList[i]) do begin
FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
for j := 0 to ActionList.Count - 1 do begin
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := Format(LANGPopupOpenWithS, [TAssocAction(ActionList[j]).ActionName]);
Item.Data := ActionList[j];
Item.OnClick := @FilePopupMenuItemClick;
FilePopupMenu.Add(Item);
end;
Break;
end;
FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
// Find and add actions for this file type
Found := False;
Assoc := FindAssoc(ShortFName);
if (Assoc <> nil) and (Assoc.ActionList.Count > 0) then begin
Found := True;
for j := 0 to Assoc.ActionList.Count - 1 do begin
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := Format(LANGPopupOpenWithS, [TAssocAction(Assoc.ActionList[j]).ActionName]);
if ((j = 0) and (Assoc.DefaultAction > Assoc.ActionList.Count - 1)) or (j = Assoc.DefaultAction)
then Item.Caption := Item.Caption + LANGPopupDefault;
Item.Data := Assoc.ActionList[j];
Item.OnClick := @FilePopupMenuItemClick;
FilePopupMenu.Add(Item);
end;
end;
if (not Found) and (not DataItem^.IsDir) then begin
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGPopupOpenWith;
Item.Data := Pointer(2);
Item.OnClick := @FilePopupMenuItemClick;
FilePopupMenu.Add(Item);
end;
// Other items
if not DataItem^.IsDir then begin
FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGPopupViewFile;
Item.IconName := 'gtk-find';
Item.Data := Pointer(200); // This number HAVE to be here due to F3F4ButtonClick method using
Item.OnClick := @F3F4ButtonClick;
FilePopupMenu.Add(Item);
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGPopupEditFile;
Item.Data := Pointer(201); // Here too
Item.OnClick := @F3F4ButtonClick;
FilePopupMenu.Add(Item);
end;
if not DataItem^.IsDir then FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGPopupMakeSymlink;
Item.IconName := 'gtk-jump-to';
Item.OnClick := @miCreateSymlinkClick;
FilePopupMenu.Add(Item);
if DataItem^.IsLnk then begin
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGmiEditSymlink_Caption;
Item.OnClick := @miEditSymlinkClick;
FilePopupMenu.Add(Item);
end;
FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGmiChangePermissions_Caption;
Item.IconName := 'gtk-convert';
Item.OnClick := @miChangePermissionsClick;
Item.Enabled := not UpDir;
FilePopupMenu.Add(Item);
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGmiChangeOwner_Caption;
Item.OnClick := @miChangeOwnerClick;
Item.Enabled := not UpDir;
FilePopupMenu.Add(Item);
FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGPopupRename;
Item.OnClick := @F6ButtonClick;
Item.Enabled := not UpDir;
FilePopupMenu.Add(Item);
Item := TGTKMenuItem.CreateTyped(Self, itImageText);
Item.Caption := LANGPopupDelete;
Item.IconName := 'gtk-delete';
Item.OnClick := @F8ButtonClick;
Item.Enabled := not UpDir;
FilePopupMenu.Add(Item);
FreeDataItem(DataItem);
end;
procedure TFMain.FilePopupMenuItemClick(Sender: TObject);
var Engine: TPanelEngine;
DataItem: PDataItem;
AListView: TGTKListView;
FileName, ShortFName, s: string;
SpawnError: integer;
Error: PGError;
b: boolean;
begin
try
InternalLock;
if (not Assigned(Sender)) or (not (Sender is TGTKMenuItem)) then begin
DebugMsg(['Error: Popup menuitem is invalid']);
end;
if LeftLastFocused then begin
Engine := LeftPanelEngine;
AListView := LeftListView;
end else begin
Engine := RightPanelEngine;
AListView := RightListView;
end;
if ConfUseURI and (Engine is TVFSEngine) and (not (Engine as TVFSEngine).ArchiveMode)
then FileName := IncludeTrailingPathDelimiter((Engine as TVFSEngine).GetPathURI)
else FileName := IncludeTrailingPathDelimiter(Engine.Path);
if Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and (not PDataItem(AListView.Selected.Data)^.UpDir)
then FileName := FileName + PDataItem(AListView.Selected.Data)^.FName;
ShortFName := ExtractFileName(ExcludeTrailingPathDelimiter(FileName));
Error := nil;
DataItem := Engine.GetFileInfo(FileName, True, True, @Error);
if not Assigned(DataItem) then begin
DebugMsg(['Error: File data not assigned. Bug ???! FileName = ', FileName, ', Error = ', Error^.message]);
g_error_free(Error);
Exit;
end;
case Integer((Sender as TGTKMenuItem).Data) of
1: if DataItem^.IsDir then ActivateItem(AListView.Selected.Index)
else begin
b := True;
if Engine is TVFSEngine then b := HandleRunFromArchive(FileName, Engine, '', '', False); // not a local engine, extract to local first
if b then begin
libc_chdir(PChar(ExtractFilePath(FileName)));
b := ExecuteProgram(QuoteStr(FileName), ExtractFilePath(FileName), True, False, SpawnError);
libc_chdir(PChar('/'));
end else b := True; // Mask cancelled extraction from VFS
if not b then Application.MessageBox(LANGErrorExecutingCommand, [mbOK], mbError, mbNone, mbOK);
end;
2: if Application.MessageBox(Format(LANGThereIsNoApplicationAssociatedWithS, [ShortFName]), [mbYes, mbNo], mbQuestion, mbNone, mbNo) = mbYes
then miFileTypesClick(Self);
3: NewTab(LeftLastFocused, True, FileName);
else begin
b := True;
s := UTF8ToStr(Trim(TAssocAction((Sender as TGTKMenuItem).Data).ActionCommand));
if Engine is TVFSEngine then b := HandleRunFromArchive(FileName, Engine, s, '', False); // not a local engine, extract to local first
if Pos('%s', s) > 0 then s := Format(s, ['''' + QuoteStr(FileName) + ''''])
else s := Format('%s %s', [s, QuoteStr(FileName)]);
if b then begin
libc_chdir(PChar(ExtractFilePath(FileName)));
b := ExecuteProgram(s, ExtractFilePath(FileName), TAssocAction((Sender as TGTKMenuItem).Data).AutodetectGUI,
TAssocAction((Sender as TGTKMenuItem).Data).RunInTerminal, SpawnError);
libc_chdir(PChar('/'));
end else b := True; // Mask cancelled extraction from VFS
if not b then Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [FileName]), [mbOK], mbError, mbNone, mbOK);
end;
end;
FreeDataItem(DataItem);
finally
Application.ProcessMessages;
InternalUnLock;
end;
end;
(********************************************************************************************************************************)
procedure TFMain.ListViewMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
var AListView: TGTKListView;
i, FirstColumn, LastColumn: integer;
LeftLV, b: boolean;
begin
PanelRightMouseInProgress := False;
RightMouseSelectPopupTimer.Enabled := False;
if Button = mbRight then Accept := False;
end;
procedure TFMain.ListViewColumnClicked(Sender: TObject);
var ANotebook: TEphyNotebook;
AListView: TGTKListView;
LeftLV: boolean;
begin
AListView := ((Sender as TGTKTreeViewColumn).Parent as TGTKTreeViewColumns).Parent as TGTKListView;
LeftLV := AListView = LeftListView;
// Check for sort change
if LeftLV then ANotebook := LeftPanelNotebook
else ANotebook := RightPanelNotebook;
try
if ANotebook.Visible then begin
DebugMsg(['*** ListView Mouse Up -> saving sort info to tab ', ANotebook.PageIndex, ', SortColumnID = ', AListView.SortColumnID]);
if LeftLV then begin
LeftTabSortIDs[ANotebook.PageIndex] := Pointer(AListView.SortColumnID);
LeftTabSortTypes[ANotebook.PageIndex] := Pointer(Integer(AListView.SortOrder));
end else begin
RightTabSortIDs[ANotebook.PageIndex] := Pointer(AListView.SortColumnID);
RightTabSortTypes[ANotebook.PageIndex] := Pointer(Integer(AListView.SortOrder));
end;
end;
except
on E: Exception do DebugMsg(['*** Exception raised in TFMain.ListViewColumnClicked(', E.ClassName, '): ', E.Message]);
end;
end;
(********************************************************************************************************************************)
procedure TFMain.miPreferencesClick(Sender: TObject);
begin
try
InternalLock;
FPreferences := TFPreferences.Create(Self);
FPreferences.AssignDefaultValues;
if FPreferences.Run = mbOK then begin
FPreferences.SaveSettings;
WriteMainGUISettings;
ApplySettings(FPreferences.RebuildListViews, FPreferences.RebuildIcons, False);
end;
finally
FPreferences.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.ApplySettings(RebuildListViews, RebuildIcons, AStartup: boolean);
var i: integer;
CSS: string;
begin
ButtonsBox.Visible := ConfShowFuncButtons;
ButtonBoxSeparator.Visible := ConfShowFuncButtons;
ButtonBoxSpace.Visible := not ConfShowFuncButtons;
// Rebuild Icons
if RebuildIcons then begin
if ConfRowHeight > 0 then ConfRowHeightReal := ConfRowHeight
else ConfRowHeightReal := ConfDefaultRowHeight;
FolderIcon.Free;
FileIcon.Free;
UpDirIcon.Free;
SymLinkEmblem.Free;
FolderIconLnk.Free;
FileIconLnk.Free;
LoadIcons;
RecreateIcons(AssocList, False);
end;
// Rebuild ListViews
if RebuildListViews then FMain.RebuildListViews(False);
// Colors Section
SetupColors;
CSS := '';
// CSS := CSS + '* { all: unset; -gtk-outline-radius: 0px; outline-color: transparent; outline-style: none; outline-offset: 0px; outline-width: 0px; }'#10;
CSS := CSS + 'treeview.view:nth-child(2) {'#10;
CSS := CSS + ' -gtk-outline-radius: 0px;'#10' outline-color: transparent;'#10' outline-style: none;'#10' outline-offset: 0px;'#10' outline-width: 0px;'#10;
if not ConfUseSystemFont then CSS := CSS + ' ' + PangoFontDescToCSS(ConfPanelFont) + #10;
if Assigned(NormalItemGDKBackground) then CSS := CSS + ' background-color: ' + GDKRGBAToString(NormalItemGDKBackground) + ';'#10;
if Assigned(NormalItemGDKColor) then CSS := CSS + ' color: ' + GDKRGBAToString(NormalItemGDKColor) + ';'#10;
// CSS := CSS + ' -GtkTreeView-vertical-separator: 10px;'#10' -GtkTreeView-horizontal-separator: 10px;'#10;
CSS := CSS + '}'#10;
(* CSS := CSS + 'row, .row, .cell, treeview.cell, treeview.row, treeview cell, treeview row {'#10 +
' border-width: 0px; border-radius: 0px; border-image: none; border: none;'#10 +
' background-color:yellow; background-image: none;'#10 +
' padding: 0px; margin: 0px; box-shadow: none; '#10 +
' outline-style: none; outline-offset: 0px; outline-width: 0px; outline-color: yellow;'#10 +
'}'#10;
*)
if Assigned(ActiveItemGDKBackground) or Assigned(ActiveItemGDKColor) then begin
CSS := CSS + 'treeview.cell:selected:focus {'#10;
if Assigned(ActiveItemGDKColor) then CSS := CSS + ' color: ' + GDKRGBAToString(ActiveItemGDKColor) + ';'#10;
if Assigned(ActiveItemGDKBackground) then CSS := CSS + ' background-color: ' + GDKRGBAToString(ActiveItemGDKBackground) + ';'#10 +
' background-image: image(' + GDKRGBAToString(ActiveItemGDKBackground) + ');'#10 +
' border-style: none; border-width: 0;'#10;
CSS := CSS + '}'#10;
end;
if Assigned(InactiveItemGDKBackground) or Assigned(InactiveItemGDKColor) then begin
CSS := CSS + 'treeview.cell:selected {'#10;
if Assigned(InactiveItemGDKColor) then CSS := CSS + ' color: ' + GDKRGBAToString(InactiveItemGDKColor) + ';'#10;
if Assigned(InactiveItemGDKBackground) then CSS := CSS + ' background-color: ' + GDKRGBAToString(InactiveItemGDKBackground) + ';'#10 +
' background-image: image(' + GDKRGBAToString(InactiveItemGDKBackground) + ');'#10 +
' border-style: none; border-width: 0;'#10;
CSS := CSS + '}'#10;
end;
writeln(css);
LeftListView.ApplyCustomCSS(CSS);
RightListView.ApplyCustomCSS(CSS);
// Resize commandline history
if ConfNumHistoryItems < CommandLineHistory.Count then begin
try
for i := CommandLineHistory.Count downto ConfNumHistoryItems + 1 do
CommandLineHistory.Delete(i - 1);
CommandLineCombo.ClearItems();
if CommandLineHistory.Count > 0 then
for i := 0 to CommandLineHistory.Count - 1 do
CommandLineCombo.AppendItem(CommandLineHistory[i]);
except end;
CommandLineCombo.Entry.Text := '';
end;
// Refresh the lists
if not AStartup then begin
DoRefresh(True, True, True);
DoRefresh(False, True, True);
if RebuildListViews then begin
LeftListView.SetSortInfo(ConfMainWindowLeftSortColumn, TGTKTreeViewSortOrder(ConfMainWindowLeftSortType));
RightListView.SetSortInfo(ConfMainWindowRightSortColumn, TGTKTreeViewSortOrder(ConfMainWindowRightSortType));
end;
end;
end;
(********************************************************************************************************************************)
procedure TFMain.RefreshBookmarksMenu;
const ShortcutKeys = '1234567890';
var i: integer;
Item: TGTKMenuItem;
begin
if mnuBookmarks.Count > 3 then
for i := mnuBookmarks.Count - 1 downto 3 do begin
mnuBookmarks.Items[i].Free;
mnuBookmarks.Delete(i);
end;
miAddBookmark.Visible := True;
miEditBookmarks.Visible := False;
miBookmarksSeparator.Visible := False;
if Bookmarks.Count > 0 then begin
miBookmarksSeparator.Visible := True;
for i := 0 to Bookmarks.Count - 1 do begin
if Length(Trim(Bookmarks[i])) = 0 then Continue;
Item := TGTKMenuItem.CreateTyped(Self, itLabel);
Item.Caption := Format('_%s %s', [Chr(Ord('a') + i), StrToUTF8(QuoteMarkupStr(Bookmarks[i]))]);
Item.Data := Pointer(i);
Item.OnClick := @miBookmarkClick;
Item.OnMouseUp := @BookmarkItemMouseUp;
if i < Length(ShortcutKeys) - 1 then Item.ShortCuts.AddName(Format('<Alt>%s', [ShortcutKeys[i + 1]]));
mnuBookmarks.Add(Item);
end;
end;
end;
procedure TFMain.miAddBookmarkClick(Sender: TObject);
var LeftPanel: boolean;
s: string;
begin
try
InternalLock;
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then s := LeftPanelEngine.Path
else s := RightPanelEngine.Path;
s := ExcludeTrailingPathDelimiter(s);
if Bookmarks.IndexOf(s) > -1 then begin
Application.MessageBox(LANGTheCurrentDirectoryAlreadyExistsInTheBookmarksList, [mbOK], mbWarning);
Exit;
end;
Bookmarks.Add(s);
WriteBookmarks;
RefreshBookmarksMenu;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.miBookmarkClick(Sender: TObject);
var LeftPanel: boolean;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
// Close VFS connections
if LeftPanel then while (LeftPanelEngine is TVFSEngine) do CloseVFS(LeftPanel, True)
else while (RightPanelEngine is TVFSEngine) do CloseVFS(LeftPanel, True);
ChangingDir(LeftPanel, Bookmarks[Integer((Sender as TGTKMenuItem).Data)]);
end;
procedure TFMain.BookmarkPopupDeleteClick(Sender: TObject);
begin
try
Bookmarks.Delete(Integer((Sender as TGTKMenuItem).Data));
WriteBookmarks;
RefreshBookmarksMenu;
except
on E: Exception do
DebugMsg(['*** Error deleting item: ', E.Message]);
end;
end;
procedure TFMain.BookmarkItemMouseUp(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
begin
if Button = mbRight then begin
Accept := False;
BookmarkPopup.PopUp;
BookmarkPopupDelete.Data := (Sender as TGTKMenuItem).Data;
end;
end;
(********************************************************************************************************************************)
function form_event_handler(widget: PGtkWidget; event: PGdkEvent; user_data: gpointer): gboolean; cdecl;
begin
Result := False;
if event^.type_ = GDK_FOCUS_CHANGE then
if event^.focus_change.in_ = 1 then FMain.HandleFormFocusIn
else FileListTipsHide;
end;
procedure TFMain.HandleFormFocusIn;
var ChangedMainGUI, ChangedAssoc, ChangedBookmarks, ChangedMounter, ChangedConnMgr, APerformRefresh: boolean;
begin
ChangedMainGUI := False;
ChangedAssoc := False;
ChangedBookmarks := False;
ChangedMounter := False;
ChangedConnMgr := False;
try
if (csDestroying in ComponentState) or (not Assigned(FMain)) then Exit;
if ApplicationShuttingDown then begin
DebugMsg([' *** TFMain.HandleFormFocusIn called when ApplicationShuttingDown, possible bug caught ***']);
Exit;
end;
if InternalLockUnlocked then begin
APerformRefresh := ConfFocusRefresh;
if CheckConfFilesMod(ChangedMainGUI, ChangedAssoc, ChangedBookmarks, ChangedMounter, ChangedConnMgr) then begin
if ChangedBookmarks then begin
DebugMsg(['Bookmark file changed ---> performing refresh']);
ReadBookmarks;
RefreshBookmarksMenu;
end;
(* if ChangedConnMgr then begin
DebugMsg(['Connection manager file changed ---> performing refresh']);
ReadConnections;
end; *)
try
InternalLock;
if (ChangedMainGUI or ChangedAssoc or ChangedMounter) and (Application.MessageBox(LANGSomeOtherInstanceChanged,
[mbYes, mbNo], mbWarning) = mbNo) then Exit;
if ChangedMounter then begin
DebugMsg(['Mounter file changed ---> performing refresh']);
ReadMounter;
FillMounterBar;
end;
if ChangedMainGUI then begin
DebugMsg(['GUI file changed ---> performing refresh']);
ReadMainGUISettings;
ApplySettings(True, True, False);
APerformRefresh := True;
end;
if ChangedAssoc then begin
DebugMsg(['Assoc file changed ---> performing refresh']);
ReadAssoc;
LoadIcons;
RemoveIconRefs(AssocList, False);
RecreateIcons(AssocList);
APerformRefresh := True;
end;
finally
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
if APerformRefresh then begin
DebugMsg(['ANN: Form Focus ---> refresh']);
DoRefresh(True, True, True);
DoRefresh(False, True, True);
if ConfFocusRefresh and ParamDebug then Beep;
end;
end;
except
on E: Exception do DebugMsg(['*** Exception raised in TFMain.HandleFormFocusIn (', E.ClassName, '): ', E.Message]);
end;
end;
(********************************************************************************************************************************)
function Max(Int1, Int2: integer): integer;
begin
if Int1 > Int2 then Result := Int1
else Result := Int2;
end;
procedure menu_position_cb(menu: PGtkMenu; x, y: Pgint; push_in: pgboolean; user_data: gpointer); cdecl;
var menu_requisition: TGtkRequisition;
allocation: TGtkAllocation;
max_x, max_y: integer;
begin
(* Calculate our preferred position. *)
gdk_window_get_origin(PGtkWidget(user_data)^.Window, x, y);
gtk_widget_get_allocation(PGtkWidget(user_data), @allocation);
x^ := x^ + allocation.x + allocation.width;
y^ := y^ + allocation.y + allocation.height;
(* Now make sure we are on the screen. *)
gtk_widget_get_preferred_size(PGtkWidget(menu), @menu_requisition, nil);
max_x := Max(0, gdk_screen_width () - menu_requisition.width);
max_y := Max(0, gdk_screen_height () - menu_requisition.height);
x^ := x^ - menu_requisition.width;
x^ := CLAMP(x^, 0, max_x);
y^ := CLAMP(y^, 0, max_y);
end;
procedure TFMain.BookmarkButtonClick(Sender: TObject);
begin
miAddBookmark.Visible := True;
miEditBookmarks.Visible := False;
miBookmarksSeparator.Visible := mnuBookmarks.Count > 3;
gtk_menu_popup(PGtkMenu(mnuBookmarks.FMenu), nil, nil, @menu_position_cb, (Sender as TGTKControl).FWidget, 1, GDK_CURRENT_TIME);
if (Sender = LeftBookmarkButton) {and (not LeftLastFocused)} then LeftListView.SetFocus else
if (Sender = RightBookmarkButton) {and LeftLastFocused} then RightListView.SetFocus;
end;
(********************************************************************************************************************************)
procedure file_popup_position_cb(menu: PGtkMenu; x, y: Pgint; push_in: pgboolean; user_data: gpointer); cdecl;
var menu_requisition: TGtkRequisition;
max_x, max_y: integer;
TreePath: PGtkTreePath;
Iter: TGtkTreeIter;
Rect: TGdkRectangle;
TreeView: PGtkTreeView;
begin
TreeView := PGtkTreeView(TGTKListView(user_data).FWidget);
if not gtk_tree_selection_get_selected(gtk_tree_view_get_selection(TreeView), nil, @Iter) then Exit;
TreePath := gtk_tree_model_get_path(gtk_tree_view_get_model(TreeView), @iter);
if not Assigned(TreePath) then Exit;
gtk_tree_view_get_background_area(TreeView, TreePath, nil, @Rect);
gdk_window_get_origin(gtk_tree_view_get_bin_window(TreeView), x, y);
y^ := y^ + Rect.y + Rect.height;
gtk_widget_get_preferred_size(PGtkWidget(menu), @menu_requisition, nil);
if y^ > gdk_screen_height - menu_requisition.height then begin
gdk_window_get_origin(gtk_tree_view_get_bin_window(TreeView), x, y);
y^ := y^ + Rect.y - menu_requisition.height;
end;
max_x := Max(0, gdk_screen_width () - menu_requisition.width);
max_y := Max(0, gdk_screen_height () - menu_requisition.height);
x^ := CLAMP(x^, 0, max_x);
y^ := CLAMP(y^, 0, max_y);
end;
procedure TFMain.PopupFileMenuPos;
var AListView: TGTKListView;
LeftPanel: boolean;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then AListView := LeftListView
else AListView := RightListView;
FilePopupMenuPopup(AListView);
gtk_menu_popup(PGtkMenu(FilePopupMenu.FMenu), nil, nil, @file_popup_position_cb, AListView, 0, gtk_get_current_event_time());
end;
(********************************************************************************************************************************)
procedure TFMain.miShowDirectorySizesClick(Sender: TObject);
begin
DoGetDirSize(True);
end;
procedure TFMain.miTargetSourceClick(Sender: TObject);
begin
if Sender = LeftEqualButton then SwitchOtherPanel(True, True) else
if Sender = RightEqualButton then SwitchOtherPanel(False, True) else
SwitchOtherPanel(LeftLastFocused, True);
end;
procedure TFMain.SwitchPanelCtrlLeftRight(LeftPanel, LeftArrowPressed: boolean);
var AListView: TGTKListView;
SrcEngine, OrigSrcEngine, TargetEngine: TPanelEngine;
s: string;
DontShowAgain: boolean;
begin
DontShowAgain := False;
if LeftPanel then begin
AListView := LeftListView;
SrcEngine := LeftPanelEngine;
TargetEngine := RightPanelEngine;
end else begin
AListView := RightListView;
SrcEngine := RightPanelEngine;
TargetEngine := LeftPanelEngine;
end;
OrigSrcEngine := SrcEngine;
if ((not (SrcEngine is TLocalTreeEngine)) and (LeftPanel <> LeftArrowPressed)) or
((not (TargetEngine is TLocalTreeEngine)) and (LeftPanel = LeftArrowPressed)) then
begin
if ConfSwitchOtherPanelBehaviour < 0 then begin
MessageBoxShowOnce(PGtkWindow(FWidget), LANGSwitchOtherPanelWarning, LANGDontShowAgain, DontShowAgain, [mbOK], mbWarning, mbOK, mbOK);
if DontShowAgain then begin
ConfSwitchOtherPanelBehaviour := 1;
WriteMainGUISettings;
end;
end;
end;
// don't change dir in VFS engines
while not (SrcEngine is TLocalTreeEngine) do SrcEngine := SrcEngine.ParentEngine;
while not (TargetEngine is TLocalTreeEngine) do TargetEngine := TargetEngine.ParentEngine;
if LeftPanel <> LeftArrowPressed then begin
s := ExcludeTrailingPathDelimiter(SrcEngine.Path);
if (OrigSrcEngine = SrcEngine) and Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and
(not PDataItem(AListView.Selected.Data)^.UpDir) and PDataItem(AListView.Selected.Data)^.IsDir
then s := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(s) + PDataItem(AListView.Selected.Data)^.FName);
if IncludeTrailingPathDelimiter(TargetEngine.Path) <> s then begin
if LeftPanel then RightPanelEngine := TargetEngine
else LeftPanelEngine := TargetEngine;
ChangingDir(not LeftPanel, s);
end;
end else begin
// Close opened VFS engines
if LeftPanel then begin
while (LeftPanelEngine is TVFSEngine) do CloseVFS(LeftPanel, True);
end else
while (RightPanelEngine is TVFSEngine) do CloseVFS(LeftPanel, True);
ChangingDir(LeftPanel, TargetEngine.Path);
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.FillMounterBar;
procedure ClearButtons(List: TList; Table: TGTKHBox);
var i: integer;
begin
if List.Count > 0 then
for i := List.Count - 1 downto 0 do
Table.RemoveControl(TGTKControl(List[i]));
List.Clear;
end;
procedure FillTableButtons(List: TList; Box: TGTKHBox);
var i: integer;
Button: TGTKButton;
Pixmap: TGDKPixbuf;
b: boolean;
Sep: TGTKVSeparator;
begin
if MounterList.Count > 0 then
for i := 0 to MounterList.Count - 1 do
with TMounterItem(MounterList[i]) do begin
if ConfMounterPushDown then begin
Button := TGTKToggleButton.Create(Self);
if Length(DisplayText) > 0 then (Button as TGTKToggleButton).Caption := DisplayText else
(Button as TGTKToggleButton).Caption := Copy(MountPath, LastDelimiter(PathDelim, ExcludeTrailingPathDelimiter(MountPath)) + 1,
Length(ExcludeTrailingPathDelimiter(MountPath)) - LastDelimiter(PathDelim, ExcludeTrailingPathDelimiter(MountPath)));
end else begin
Button := TGTKButton.Create(Self);
if Length(DisplayText) > 0 then (Button as TGTKButton).Caption := DisplayText else
Button.Caption := Copy(MountPath, LastDelimiter(PathDelim, ExcludeTrailingPathDelimiter(MountPath)) + 1,
Length(ExcludeTrailingPathDelimiter(MountPath)) - LastDelimiter(PathDelim, ExcludeTrailingPathDelimiter(MountPath)));
end;
Button.CanFocus := False;
// DebugMsg(['Int64(MounterList[i]) = ', Int64(MounterList[i])]);
// DebugMsg(['Integer(MounterList[i]) = ', Integer(MounterList[i])]);
{$IFDEF CPU64}
Button.Tag := QWORD(MounterList[i]);
{$ELSE}
Button.Tag := Cardinal(MounterList[i]);
{$ENDIF}
Button.Tooltip := Format(LANGMountPointDevice, [StrToUTF8(MountPath), StrToUTF8(Device)]);
Button.BorderStyle := bsNone;
Button.PopupMenu := MounterButtonPopupMenu;
Button.OnMouseDown := @MounterButtonMouseDown;
// Check the icon
b := FileExists(IconPath);
Pixmap := nil;
if b then begin
Pixmap := TGDKPixbuf.Create(Self);
Pixmap.LoadFromFile(IconPath);
b := Pixmap.FPixbuf <> nil;
if b then Pixmap.ScaleSimple(16, 16);
end;
if not b then
case DeviceType of
0 : Pixmap := MounterHDD;
1 : Pixmap := MounterRemovable;
2 : Pixmap := MounterCD;
3 : Pixmap := MounterFloppy;
4 : Pixmap := MounterNetwork;
end;
if ConfMounterPushDown then begin
(Button as TGTKToggleButton).Icon := Pixmap;
(Button as TGTKToggleButton).Checked := Mounted;
end else Button.Icon := Pixmap;
Button.OnClick := @MounterButtonClick; // It has to be here because setting the Checked property causes the signal emitting
Button.MarginTop := 1;
Button.MarginBottom := 1;
Box.AddControlEx(Button, False, True, 0);
List.Add(Button);
if i < MounterList.Count - 1 then begin
Sep := TGTKVSeparator.Create(Self);
Sep.MarginTop := 6;
Sep.MarginBottom := 6;
Box.AddControlEx(Sep, False, True, 2);
List.Add(Sep);
end;
end;
end;
var Lab: TGTKLabel;
begin
if ConfMounterUseFSTab then FillDefaultFstabMounterItems;
// Clean all items
ClearButtons(MounterBarBoxList, MounterBarBox);
ClearButtons(MounterBarBoxListLeft, LeftMounterBarBox);
ClearButtons(MounterBarBoxListRight, RightMounterBarBox);
// Fill the new items
Lab := TGTKLabel.Create(Self);
Lab.Caption := Format('<span weight="bold">%s</span>', [LANGMountSC]);
Lab.UseMarkup := True;
Lab.MarginTop := 1;
Lab.MarginBottom := 1;
MounterBarBoxList.Add(Lab);
MounterBarBox.AddControlEx(Lab, False, True, 5);
case ConfShowMounterBar of
1: FillTableButtons(MounterBarBoxList, MounterBarBox);
2: begin
FillTableButtons(MounterBarBoxListLeft, LeftMounterBarBox);
FillTableButtons(MounterBarBoxListRight, RightMounterBarBox);
end;
end;
end;
procedure TFMain.MounterButtonClick(Sender: TObject);
var Item: TMounterItem;
LeftPanel, b: boolean;
Engine: TPanelEngine;
begin
if not (Sender is TGTKButton) then Exit;
try
Item := TMounterItem((Sender as TGTKButton).Tag);
if (not Assigned(Item)) or (Item.MountPath = '') then DebugMsg(['*** Error in mounter button: incorrect data']) else begin
if MounterBarBoxListLeft.IndexOf(Sender) > -1 then LeftPanel := True else
if MounterBarBoxListRight.IndexOf(Sender) > -1 then LeftPanel := False else LeftPanel := LeftLastFocused;
if LeftPanel then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
try
b := Item.Mounted;
except
b := False;
end;
if ConfMounterPushDown then begin
if not b then b := Item.Mount else
if Pos(Item.MountPath, Engine.Path) = 1 then b := Item.Eject;
(Sender as TGTKToggleButton).OnClick := nil;
(Sender as TGTKToggleButton).Checked := Item.Mounted;
(Sender as TGTKToggleButton).OnClick := @MounterButtonClick;
end else if not b then b := Item.Mount;
if b then begin
if Engine is TVFSEngine then CloseVFS(LeftPanel, True);
ChangingDir(LeftPanel, Item.MountPath);
DoRefresh(LeftPanel, True, True);
end;
if LeftPanel then LeftListView.SetFocus
else RightListView.SetFocus;
end;
except
on E: Exception do DebugMsg(['*** Exception raised in FMain.MounterButtonClick: (', E.ClassName, '): ', E.Message]);
end;
end;
procedure TFMain.MounterButtonPopupMenuPopup(Sender: TObject);
begin
// DebugMsg(['aaaa']);
try
// DebugMsg(['aaaa']);
if (not Assigned(LastMounterButton)) or (LastMounterButton.Tag = 0) then begin
// DebugMsg(['aaaa']);
MounterButtonPopupMenu.PopDown;
// DebugMsg(['aaaa']);
Exit;
end;
// DebugMsg(['aaaaX']);
// DebugMsg(['sizeof(LastMounterButton.Tag) = ', sizeof(LastMounterButton.Tag)]);
// DebugMsg(['LastMounterButton.Tag = ', Int64(LastMounterButton.Tag)]);
// DebugMsg(['TMounterItem(Pointer(QWord(LastMounterButton.Tag))).Device = ', TMounterItem(Pointer(QWord(LastMounterButton.Tag))).Device]);
// DebugMsg(['TMounterItem(LastMounterButton.Tag).ClassName = ', TMounterItem(LastMounterButton.Tag).ClassName]);
miMount.Enabled := not TMounterItem(LastMounterButton.Tag).Mounted;
// DebugMsg(['aaaaX']);
miUmount.Enabled := not miMount.Enabled;
// DebugMsg(['aaaaX']);
miEject.Enabled := not miMount.Enabled;
except
on E: Exception do begin
DebugMsg(['*** Exception raised in FMain.MounterButtonClick: (', E.ClassName, '): ', E.Message]);
MounterButtonPopupMenu.PopDown;
end;
end;
end;
procedure TFMain.MounterButtonMouseDown(Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean);
begin
LastMounterButton := nil;
if (not (Sender is TGTKButton)) or ((Sender as TGTKButton).Tag = 0) then Exit;
LastMounterButton := Sender as TGTKButton;
end;
procedure TFMain.miMountClick(Sender: TObject);
begin
if Assigned(LastMounterButton) then TMounterItem(LastMounterButton.Tag).Mount;
DoRefresh(LeftLastFocused, True, True);
DoRefresh(not LeftLastFocused, True, True);
if ConfMounterPushDown then begin
(LastMounterButton as TGTKToggleButton).OnClick := nil;
(LastMounterButton as TGTKToggleButton).Checked := TMounterItem(LastMounterButton.Tag).Mounted;
(LastMounterButton as TGTKToggleButton).OnClick := @MounterButtonClick;
end;
end;
procedure TFMain.miUmountClick(Sender: TObject);
begin
if Assigned(LastMounterButton) then TMounterItem(LastMounterButton.Tag).Umount;
DoRefresh(LeftLastFocused, True, True);
DoRefresh(not LeftLastFocused, True, True);
if ConfMounterPushDown then begin
(LastMounterButton as TGTKToggleButton).OnClick := nil;
(LastMounterButton as TGTKToggleButton).Checked := TMounterItem(LastMounterButton.Tag).Mounted;
(LastMounterButton as TGTKToggleButton).OnClick := @MounterButtonClick;
end;
end;
procedure TFMain.miEjectClick(Sender: TObject);
begin
if Assigned(LastMounterButton) then TMounterItem(LastMounterButton.Tag).Eject;
DoRefresh(LeftLastFocused, True, True);
DoRefresh(not LeftLastFocused, True, True);
if ConfMounterPushDown then begin
(LastMounterButton as TGTKToggleButton).OnClick := nil;
(LastMounterButton as TGTKToggleButton).Checked := TMounterItem(LastMounterButton.Tag).Mounted;
(LastMounterButton as TGTKToggleButton).OnClick := @MounterButtonClick;
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.miMounterSettingsClick(Sender: TObject);
var x: TList;
begin
try
InternalLock;
FMounterPrefs := TFMounterPrefs.Create(Self);
ReadMounter;
FMounterPrefs.AssignAssocList(MounterList);
FMounterPrefs.FillList;
if FMounterPrefs.Run = mbOK then begin
FMounterPrefs.CleanItems;
x := MounterList;
MounterList := FMounterPrefs.InternalMounterList;
FMounterPrefs.InternalMounterList := x;
ConfMounterUseFSTab := FMounterPrefs.UseFSTabDefaultsCheckBox.Checked;
ConfMounterPushDown := FMounterPrefs.ToggleModeCheckBox.Checked;
WriteMounter;
end;
FillMounterBar;
finally
FMounterPrefs.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.miShowMounterBarClick(Sender: TObject);
begin
if miShowOneMounterBar.Checked then ConfShowMounterBar := 1 else
if miShowTwoMounterBar.Checked then ConfShowMounterBar := 2 else ConfShowMounterBar := 0;
MounterBarBox.Visible := ConfShowMounterBar = 1;
LeftMounterBarBox.Visible := ConfShowMounterBar = 2;
RightMounterBarBox.Visible := ConfShowMounterBar = 2;
FillMounterBar;
end;
procedure TFMain.miColumnsClick(Sender: TObject);
begin
try
InternalLock;
FColumns := TFColumns.Create(Self);
if FColumns.Run = mbOK then begin
FColumns.ApplyColumnList;
RebuildListViews(True);
end;
finally
FColumns.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.ListViewColumnsChanged(Sender: TObject);
var SourceListView: TGTKListView;
i, j, k, ColIdx, ColumnID: integer;
Column: PGtkTreeViewColumn;
TempIDs, TempArrayI: array[1..ConstNumPanelColumns] of integer;
TempArrayB: array[1..ConstNumPanelColumns] of boolean;
begin
DebugMsg(['*** Columns reordered ---> performing listview rebuild']);
LeftListView.OnMouseUp := nil;
RightListView.OnMouseUp := nil;
LeftListView.OnColumnsChanged := nil;
RightListView.OnColumnsChanged := nil;
SourceListView := Sender as TGTKListView;
// Copy the old items
for i := 1 to ConstNumPanelColumns do begin
TempIDs[i] := ConfColumnIDs[i];
TempArrayI[i] := ConfColumnSizes[i];
TempArrayB[i] := ConfColumnVisible[i];
end;
ColIdx := 1;
// Search for moved columns
for i := 0 to SourceListView.Columns.Count - 1 do begin
Column := gtk_tree_view_get_column(PGtkTreeView(SourceListView.FWidget), i);
ColumnID := ColumnSortIDs[gtk_tree_view_column_get_sort_column_id(column) + 1];
for j := ColIdx to ConstNumPanelColumns do
if TempArrayB[j] then begin
for k := 1 to ConstNumPanelColumns do
if ColumnID = TempIDs[k] then begin
DebugMsg(['moving from ', k, ' to ', j]);
ConfColumnIDs[j] := TempIDs[k];
ConfColumnSizes[j] := TempArrayI[k];
ConfColumnVisible[j] := TempArrayB[k];
Break;
end;
ColIdx := j + 1;
Break;
end;
end;
Application.ProcessMessages;
RebuildListViewsTimer.Interval := 1;
RebuildListViewsTimer.Enabled := True;
gtk_tree_view_set_headers_visible(PGtkTreeView(SourceListView.FWidget), False);
gtk_tree_view_set_headers_visible(PGtkTreeView(SourceListView.FWidget), True);
end;
procedure TFMain.RebuildListViews(ADoRefresh: boolean);
begin
LeftListView.OnColumnsChanged := nil;
RightListView.OnColumnsChanged := nil;
ConfMainWindowLeftSortColumn := LeftListView.SortColumnID;
ConfMainWindowLeftSortType := Integer(LeftListView.SortOrder);
ConfMainWindowRightSortColumn := RightListView.SortColumnID;
ConfMainWindowRightSortType := Integer(RightListView.SortOrder);
LeftListView.Items.Clear;
RightListView.Items.Clear;
LeftListView.Columns.Clear;
RightListView.Columns.Clear;
ConstructColumns(LeftListView);
ConstructColumns(RightListView);
if ADoRefresh then begin
Application.ProcessMessages;
FMain.DoRefresh(True, True, True);
FMain.DoRefresh(False, True, True);
LeftListView.SetSortInfo(ConfMainWindowLeftSortColumn, TGTKTreeViewSortOrder(ConfMainWindowLeftSortType));
RightListView.SetSortInfo(ConfMainWindowRightSortColumn, TGTKTreeViewSortOrder(ConfMainWindowRightSortType));
end;
LeftListView.OnColumnsChanged := @ListViewColumnsChanged;
RightListView.OnColumnsChanged := @ListViewColumnsChanged;
end;
procedure TFMain.RebuildListViewsTimerTimer(Sender: TObject);
begin
RebuildListViewsTimer.Enabled := False;
RebuildListViews(True);
LeftListView.OnMouseUp := @ListViewMouseUp;
RightListView.OnMouseUp := @ListViewMouseUp;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.FillPluginMenu;
var i: integer;
MenuItem1, MenuItem2: TGTKMenuItem;
begin
if PluginList.Count = 0 then begin
MenuItem1 := TGTKMenuItem.CreateTyped(Self, itLabel);
MenuItem1.Caption := LANGNoPluginsFound;
MenuItem1.Enabled := False;
mnuPlugins.Add(MenuItem1);
end else
for i := 0 to PluginList.Count - 1 do begin
MenuItem1 := TGTKMenuItem.CreateTyped(Self, itImageText);
MenuItem1.Caption := TVFSPlugin(PluginList[i]).ModuleName;
MenuItem2 := TGTKMenuItem.CreateTyped(Self, itImageText);
MenuItem2.Caption := LANGPluginAbout;
MenuItem2.Tag := i;
MenuItem2.OnClick := @miPluginAboutClick;
mnuPlugins.Add(MenuItem1);
MenuItem1.Add(MenuItem2);
end;
end;
procedure TFMain.miTestPluginClick(Sender: TObject);
var Engine: TVFSEngine;
b: boolean;
begin
try
InternalLock;
FTestPlugin := TFTestPlugin.Create(Self);
if (FTestPlugin.Run = mbOK) and (PluginList.Count > 0) then begin
Engine := TVFSEngine.Create(LookupVFSPlugin(FTestPlugin.PluginComboBox.ItemID));
if not Engine.VFSOpenURI(FTestPlugin.CommandEntry.Text, nil, nil, nil, nil, nil) then begin
Application.MessageBox(LANGCouldntOpenURI, [mbOK], mbError, mbOK, mbOK);
Exit;
end;
b := True;
{ if not FTestPlugin.AnonymousCheckButton.Checked then
b := HandleLogin(FTestPlugin, Engine, FTestPlugin.UserEntry.Text, FTestPlugin.PasswordEntry.Text); }
if b then begin
if LeftLastFocused then LeftPanelEngine := Engine
else RightPanelEngine := Engine;
DoRefresh(LeftLastFocused, False, False);
end;
end;
finally
FTestPlugin.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.miPluginAboutClick(Sender: TObject);
var VFSItem: TVFSPlugin;
about_dialog: PGtkWidget;
begin
InternalLock;
VFSItem := TVFSPlugin(PluginList[(Sender as TGTKMenuItem).Tag]);
about_dialog := gtk_about_dialog_new();
gtk_about_dialog_set_program_name(PGtkAboutDialog(about_dialog), PChar(VFSItem.ModuleName));
gtk_about_dialog_set_version(PGtkAboutDialog(about_dialog), PChar(VFSItem.ModuleAbout));
gtk_about_dialog_set_copyright(PGtkAboutDialog(about_dialog), PChar(VFSItem.ModuleCopyright));
gtk_about_dialog_set_logo(PGtkAboutDialog(about_dialog), AppIcon64.FPixbuf);
gtk_window_set_transient_for(PGtkWindow(about_dialog), PGtkWindow(FMain.FWidget));
gtk_dialog_run(PGtkDialog(about_dialog));
gtk_widget_destroy(about_dialog);
InternalLockInit(False);
end;
procedure TFMain.miSavePositionClick(Sender: TObject);
begin
WriteMainSettings;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer; SwitchToNewTab: boolean);
var AListView: TGTKListView;
AEngine: TPanelEngine;
ANotebook: TEphyNotebook;
ATabList: TStringList;
AVBoxList: TList;
APath, APathSave: string;
VBox: TGTKVBox;
DockedToNotebook: boolean;
PathsHighlight: TStringList;
TabEngines: TList;
TabSortIDs: TList;
TabSortTypes: TList;
i, InsertPos: integer;
ForceReparent: boolean;
begin
if LeftPanel then begin
AListView := LeftListView;
AEngine := LeftPanelEngine;
ANotebook := LeftPanelNotebook;
ATabList := LeftPanelTabs;
AVBoxList := LeftNotebookBoxList;
PathsHighlight := LeftPathsHighlight;
TabEngines := LeftTabEngines;
TabSortIDs := LeftTabSortIDs;
TabSortTypes := LeftTabSortTypes;
end else begin
AListView := RightListView;
AEngine := RightPanelEngine;
ANotebook := RightPanelNotebook;
ATabList := RightPanelTabs;
AVBoxList := RightNotebookBoxList;
PathsHighlight := RightPathsHighlight;
TabEngines := RightTabEngines;
TabSortIDs := RightTabSortIDs;
TabSortTypes := RightTabSortTypes;
end;
DockedToNotebook := ANotebook.Visible;
VBox := nil;
for i := 0 to 0 + Ord(not DockedToNotebook) do begin
InsertPos := 0;
if (i = 1) or DockedToNotebook then begin
APath := _Path;
AEngine := _Engine;
InsertPos := NewTabPosition;
if (i = 1) and (InsertPos > 1) then InsertPos := 1;
end else APath := AEngine.Path;
ATabList.Insert(InsertPos, APath);
APath := ExtractFileName(ExcludeTrailingPathDelimiter(APath));
if APath = '' then APath := '/';
if i = 0 then APathSave := APath;
VBox := TGTKVBox.Create(Self);
AVBoxList.Insert(InsertPos, VBox);
PathsHighlight.Insert(InsertPos, PDataItem(AListView.Selected.Data)^.FName);
TabSortIDs.Insert(InsertPos, Pointer(AListView.SortColumnID));
TabSortTypes.Insert(InsertPos, Pointer(Integer(AListView.SortOrder)));
TabEngines.Insert(InsertPos, AEngine);
end;
if not DockedToNotebook then begin
ANotebook.InsertPage(0, TGTKControl(AVBoxList[0]), StrToUTF8(APathSave));
SetTabLabel(ANotebook, 0, StrToUTF8(APathSave), StrToUTF8(ATabList[0]));
end;
InsertPos := NewTabPosition;
if InsertPos > ATabList.Count then InsertPos := ATabList.Count;
ForceReparent := not ANotebook.Visible;
if not ANotebook.Visible then ANotebook.Visible := True;
i := ANotebook.InsertPage(InsertPos, VBox, StrToUTF8(APath));
SetTabLabel(ANotebook, i, StrToUTF8(APath), StrToUTF8(ATabList[InsertPos]));
if SwitchToNewTab then ANotebook.PageIndex := i else
if ForceReparent then SwitchTab(0, LeftPanel, True); // We use first page as there were no tabs before
end;
procedure TFMain.NewTab(LeftPanel, SendSelectedDirToBg: boolean; CustomPath: string = '');
var AEngine: TPanelEngine;
ATabList: TStringList;
ANotebook: TEphyNotebook;
APath: string;
DontShowAgain: boolean;
NewTabPosition: integer;
begin
DontShowAgain := False;
if LeftPanel then begin
AEngine := LeftPanelEngine;
ATabList := LeftPanelTabs;
ANotebook := LeftPanelNotebook;
end else begin
AEngine := RightPanelEngine;
ATabList := RightPanelTabs;
ANotebook := RightPanelNotebook;
end;
if Length(Trim(CustomPath)) > 0
then APath := CustomPath
else APath := AEngine.Path;
if AEngine is TVFSEngine then begin
while AEngine is TVFSEngine do begin
APath := AEngine.SavePath;
AEngine := AEngine.ParentEngine;
end;
// Show warning that we couldn't duplicate the VFS location
if ConfDuplicateTabWarning then begin
MessageBoxShowOnce(PGtkWindow(FWidget), LANGDuplicateTabWarning, LANGDontShowAgain, DontShowAgain, [mbOK], mbInfo, mbOK, mbOK);
if DontShowAgain then begin
ConfDuplicateTabWarning := False;
WriteMainGUISettings;
end;
end;
end;
NewTabPosition := ATabList.Count + Ord(ATabList.Count = 0); // Append to end by default
if SendSelectedDirToBg and ANotebook.Visible then NewTabPosition := ANotebook.PageIndex + 1;
NewTabInternal(LeftPanel, AEngine, APath, NewTabPosition, not SendSelectedDirToBg);
end;
procedure TFMain.SwitchTab(TabNo: integer; LeftPanel, ASetFocus: boolean);
var ANotebook: TEphyNotebook;
AListView: TGTKListView;
AVBoxList: TList;
ListBox: TGTKVBox;
AScrolledWindow: TGTKScrolledWindow;
i: integer;
begin
if LeftPanel then begin
ANotebook := LeftPanelNotebook;
AVBoxList := LeftNotebookBoxList;
ListBox := LeftListBox;
AScrolledWindow := LeftScrolledWindow;
AListView := LeftListView;
end else begin
ANotebook := RightPanelNotebook;
AVBoxList := RightNotebookBoxList;
ListBox := RightListBox;
AScrolledWindow := RightScrolledWindow;
AListView := RightListView;
end;
if (AVBoxList.Count < TabNo) or (TabNo < -1) then Exit;
// Remove any objects
g_object_ref(PGObject(AScrolledWindow.FWidget));
if ListBox.ChildrenCount > 0 then ListBox.RemoveControl(AScrolledWindow);
if AVBoxList.Count > 0 then
for i := 0 to AVBoxList.Count - 1 do
if TGTKVBox(AVBoxList[i]).ChildrenCount > 0 then TGTKVBox(AVBoxList[i]).RemoveControl(AScrolledWindow);
if TabNo >= 0 then begin // Reparent to the tab
TGTKVBox(AVBoxList[TabNo]).AddControlEx(AScrolledWindow, True, True, 0);
ListBox.Visible := False;
ANotebook.Visible := True;
end else begin // Reparent back to the panel
ListBox.AddControlEx(AScrolledWindow, True, True, 0);
ListBox.Visible := True;
ANotebook.Visible := False;
end;
g_object_unref(PGObject(AScrolledWindow.FWidget));
if ASetFocus then AListView.SetFocus;
end;
procedure TFMain.TabNotebookSwitchPage(Sender: TObject; const NewTabNum: integer; const ShouldFocus: boolean);
var LeftPanel: boolean;
ATabList: TStringList;
PathsHighlight: TStringList;
TabEngines: TList;
AListView: TGTKListView;
TabSortIDs: TList;
TabSortTypes: TList;
begin
DebugMsg(['Switch page']);
LeftPanel := (Sender as TEphyNotebook) = LeftPanelNotebook;
if LeftPanel then begin
ATabList := LeftPanelTabs;
PathsHighlight := LeftPathsHighlight;
TabEngines := LeftTabEngines;
TabSortIDs := LeftTabSortIDs;
TabSortTypes := LeftTabSortTypes;
AListView := LeftListView;
end else begin
ATabList := RightPanelTabs;
PathsHighlight := RightPathsHighlight;
TabEngines := RightTabEngines;
TabSortIDs := RightTabSortIDs;
TabSortTypes := RightTabSortTypes;
AListView := RightListView;
end;
SwitchTab(NewTabNum, LeftPanel, ShouldFocus);
if LeftPanel then LeftPanelEngine := TPanelEngine(TabEngines[NewTabNum])
else RightPanelEngine := TPanelEngine(TabEngines[NewTabNum]);
ChangingDir(LeftPanel, ATabList[NewTabNum], PathsHighlight[NewTabNum], '', False, True);
AListView.SetSortInfo(Integer(TabSortIDs[NewTabNum]),
TGTKTreeViewSortOrder(Integer(TabSortTypes[NewTabNum])));
end;
procedure TFMain.miDuplicateTabClick(Sender: TObject);
begin
if not CommandLineCombo.Entry.Focused then
if LeftListView.Focused then NewTab(True, False) else
if RightListView.Focused then NewTab(False, False) else
if (Sender is TGTKMenuItem) and LeftTabPopup then NewTab(True, False) else
if (Sender is TGTKMenuItem) and (not LeftTabPopup) then NewTab(False, False) else
DebugMsg(['Couldn''t duplicate tab: No listview focused.']);
end;
procedure TFMain.miCloseTabClick(Sender: TObject);
begin
if not CommandLineCombo.Entry.Focused then
if LeftListView.Focused then CloseTab(LeftPanelNotebook.PageIndex, True, True) else
if RightListView.Focused then CloseTab(RightPanelNotebook.PageIndex, False, True) else
if (Sender is TGTKMenuItem) and LeftTabPopup then CloseTab(LeftPanelNotebook.PageIndex, True, True) else
if (Sender is TGTKMenuItem) and (not LeftTabPopup) then CloseTab(RightPanelNotebook.PageIndex, False, True) else
DebugMsg(['Couldn''t close tab: No listview focused.']);
end;
procedure TFMain.miCloseAllTabsClick(Sender: TObject);
begin
if Application.MessageBox(LANGAreYouSureCloseAllTabs, [mbYes, mbNo], mbQuestion, mbYes, mbNo) = mbYes then
if (Sender is TGTKMenuItem) and LeftTabPopup then CloseTab(-1, True, True) else
if (Sender is TGTKMenuItem) and (not LeftTabPopup) then CloseTab(-1, False, True) else
DebugMsg(['Couldn''t close all tabs: No listview focused.']);
end;
procedure TFMain.CloseTab(TabNo: integer; LeftPanel, CloseVFSEngine: boolean);
var ATabList: TStringList;
PathsHighlight: TStringList;
ANotebook: TEphyNotebook;
AVBoxList: TList;
i, NewPageIndex: integer;
TabEngines: TList;
Engine, xEngine: TPanelEngine;
TabSortIDs: TList;
TabSortTypes: TList;
AListView: TGTKListView;
begin
if LeftPanel then begin
ATabList := LeftPanelTabs;
PathsHighlight := LeftPathsHighlight;
ANotebook := LeftPanelNotebook;
AVBoxList := LeftNotebookBoxList;
TabEngines := LeftTabEngines;
TabSortIDs := LeftTabSortIDs;
TabSortTypes := LeftTabSortTypes;
AListView := LeftListView;
end else begin
ATabList := RightPanelTabs;
PathsHighlight := RightPathsHighlight;
ANotebook := RightPanelNotebook;
AVBoxList := RightNotebookBoxList;
TabEngines := RightTabEngines;
TabSortIDs := RightTabSortIDs;
TabSortTypes := RightTabSortTypes;
AListView := RightListView;
end;
DebugMsg(['Close tab, TabNo = ', TabNo, ', PageIndex = ', ANotebook.PageIndex]);
if (ANotebook.ChildrenCount < TabNo) or (TabNo < -1) or (not ANotebook.Visible) then begin
DebugMsg(['Couldn''t close tab: wrong TabNo']);
Exit;
end;
if TabNo > 0 then begin
Engine := TPanelEngine(TabEngines[TabNo]);
if (Engine is TVFSEngine) and CloseVFSEngine and (not CheckForUnsavedConnection(Engine as TVFSEngine, True)) then Exit;
end;
if (ANotebook.ChildrenCount > 2) and (TabNo >= 0) then begin
// Close one tab, leave tab bar visible
Engine := TPanelEngine(TabEngines[TabNo]);
// !!!!!!!!
NewPageIndex := ANotebook.PageIndex - Ord((TabNo = ANotebook.PageIndex) and (TabNo = ANotebook.ChildrenCount - 1))
+ Ord((TabNo = ANotebook.PageIndex) and (ANotebook.ChildrenCount > TabNo + 1));
// if (ANotebook.PageIndex = 0) and (NewPageIndex = 0) then NewPageIndex := 1;
ANotebook.PageIndex := NewPageIndex;
// Before remove, ensure some other page is active
ANotebook.RemovePage(TabNo);
ATabList.Delete(TabNo);
PathsHighlight.Delete(TabNo);
TabEngines.Delete(TabNo);
// g_object_unref(TGTKVBox(AVBoxList[TabNo]).FWidget);
AVBoxList.Delete(TabNo);
TabSortIDs.Delete(TabNo);
TabSortTypes.Delete(TabNo);
// Try to close the VFS engine
if CloseVFSEngine then
while Engine is TVFSEngine do
try
xEngine := Engine;
Engine := xEngine.ParentEngine;
if not TVFSEngine(xEngine).VFSClose(nil) then
DebugMsg(['Error closing the engine...']);
xEngine.Free;
except end;
end else begin // Close last/all tabs, hide the tab bar
// Change dir to the opposite
if (TabNo >= 0) and (TabNo = ANotebook.PageIndex) then begin // we should not change directory while closing all tabs...
i := Ord(not Boolean(ANotebook.PageIndex));
if LeftPanel then LeftPanelEngine := TPanelEngine(TabEngines[i])
else RightPanelEngine := TPanelEngine(TabEngines[i]);
ChangingDir(LeftPanel, ATabList[i], PathsHighlight[i]);
AListView.SetSortInfo(Integer(TabSortIDs[i]), TGTKTreeViewSortOrder(Integer(TabSortTypes[i])));
end;
// Remove the tabs
SwitchTab(-1, LeftPanel, False);
for i := ANotebook.ChildrenCount - 1 downto 0 do ANotebook.RemovePage(i);
ATabList.Clear;
PathsHighlight.Clear;
for i := 0 to TabEngines.Count - 1 do
if (TPanelEngine(TabEngines[i]) is TVFSEngine) and CloseVFSEngine and ((LeftPanel and (LeftPanelEngine <> TPanelEngine(TabEngines[i]))) or
((not LeftPanel) and (RightPanelEngine <> TPanelEngine(TabEngines[i]))))
then begin
Engine := TPanelEngine(TabEngines[i]);
while Engine is TVFSEngine do
try
if (i <> TabNo) and (not CheckForUnsavedConnection(Engine as TVFSEngine, False)) then Exit;
xEngine := Engine;
Engine := xEngine.ParentEngine;
if not TVFSEngine(xEngine).VFSClose(nil) then
DebugMsg(['Error closing the engine...']);
xEngine.Free;
except end;
end;
TabEngines.Clear;
{ for i := 0 to AVBoxList.Count - 1 do
g_object_unref(TGTKVBox(AVBoxList[i]).FWidget); }
AVBoxList.Clear;
TabSortIDs.Clear;
TabSortTypes.Clear;
AListView.SetFocus;
end;
end;
procedure TFMain.TabPopupMenuPopup(Sender: TObject);
begin
LeftTabPopup := Sender = LeftPanelNotebook;
end;
procedure TFMain.AddTabs(LeftPanel: boolean; TabList: TStringList; TabSortIDs, TabSortTypes: TList; SetTabActive: integer);
var ANotebook: TEphyNotebook;
ATabList: TStringList;
AVBoxList: TList;
APath: string;
VBox: TGTKVBox;
PathsHighlight: TStringList;
TabEngines: TList;
i: integer;
ATabSortIDs: TList;
ATabSortTypes: TList;
OldEvent: TEphyNotebookTabSwitchedEvent;
begin
if LeftPanel then begin
ANotebook := LeftPanelNotebook;
ATabList := LeftPanelTabs;
AVBoxList := LeftNotebookBoxList;
PathsHighlight := LeftPathsHighlight;
TabEngines := LeftTabEngines;
ATabSortIDs := LeftTabSortIDs;
ATabSortTypes := LeftTabSortTypes;
end else begin
ANotebook := RightPanelNotebook;
ATabList := RightPanelTabs;
AVBoxList := RightNotebookBoxList;
PathsHighlight := RightPathsHighlight;
TabEngines := RightTabEngines;
ATabSortIDs := RightTabSortIDs;
ATabSortTypes := RightTabSortTypes;
end;
if (not Assigned(TabList)) or (TabList.Count < 1) or (not Assigned(TabSortIDs)) or (TabSortIDs.Count < 1) or
(not Assigned(TabSortTypes)) or (TabSortTypes.Count < 1) then Exit;
for i := 0 to TabList.Count - 1 do begin
ATabList.Add(TabList[i]);
APath := ExtractFileName(ExcludeTrailingPathDelimiter(TabList[i]));
if APath = '' then APath := '/';
VBox := TGTKVBox.Create(Self);
AVBoxList.Add(VBox);
PathsHighlight.Add('');
ATabSortIDs.Add(TabSortIDs[i]);
ATabSortTypes.Add(TabSortTypes[i]);
if LeftPanel then TabEngines.Add(LeftPanelEngine)
else TabEngines.Add(RightPanelEngine);
ANotebook.AppendPage(VBox, StrToUTF8(APath));
SetTabLabel(ANotebook, ANotebook.ChildrenCount - 1, StrToUTF8(APath), StrToUTF8(TabList[i]));
end;
if not ANotebook.Visible then ANotebook.Visible := True;
OldEvent := ANotebook.OnTabSwitched;
ANotebook.OnTabSwitched := nil;
ANotebook.PageIndex := SetTabActive;
ANotebook.OnTabSwitched := OldEvent;
TabNotebookSwitchPage(ANotebook, SetTabActive, True);
end;
procedure TFMain.SetTabLabel(Notebook: TEphyNotebook; PageIndex: integer; ALabel, ATooltip: string);
var g: PChar;
begin
if (ConfTabMaxLength > 0) and (g_utf8_strlen(PChar(ALabel), -1) > ConfTabMaxLength) then begin
g := malloc(Length(ALabel) + 4);
memset(g, 0, Length(ALabel) + 4);
g_utf8_strncpy(g, PChar(ALabel), ConfTabMaxLength);
ALabel := g + '...';
libc_free(g);
end;
Notebook.SetTabCaption(PageIndex, ALabel);
Notebook.SetTabTooltip(PageIndex, ATooltip);
end;
procedure TFMain.NotebookReordered(Sender: TObject; const Source, Dest: integer);
var ANotebook: TEphyNotebook;
ATabList: TStringList;
AVBoxList: TList;
PathsHighlight: TStringList;
TabEngines: TList;
ATabSortIDs: TList;
ATabSortTypes: TList;
begin
ANotebook := Sender as TEphyNotebook;
if ANotebook = LeftPanelNotebook then begin
ATabList := LeftPanelTabs;
AVBoxList := LeftNotebookBoxList;
PathsHighlight := LeftPathsHighlight;
TabEngines := LeftTabEngines;
ATabSortIDs := LeftTabSortIDs;
ATabSortTypes := LeftTabSortTypes;
end else begin
ATabList := RightPanelTabs;
AVBoxList := RightNotebookBoxList;
PathsHighlight := RightPathsHighlight;
TabEngines := RightTabEngines;
ATabSortIDs := RightTabSortIDs;
ATabSortTypes := RightTabSortTypes;
end;
ATabList.Move(Source, Dest);
AVBoxList.Move(Source, Dest);
PathsHighlight.Move(Source, Dest);
TabEngines.Move(Source, Dest);
ATabSortIDs.Move(Source, Dest);
ATabSortTypes.Move(Source, Dest);
end;
procedure TFMain.NotebookTabClosed(Sender: TObject; const TabNum: integer; var CanClose: boolean);
begin
CloseTab(TabNum, Sender = LeftPanelNotebook, True);
CanClose := False;
end;
procedure TFMain.NotebookTabDoubleClick(Sender: TObject; const TabNum: integer);
begin
CloseTab(TabNum, Sender = LeftPanelNotebook, True);
end;
function TFMain.NotebookFindNotebookAtPointerEvent(Sender: TObject; const AbsX, AbsY: integer): TEphyNotebook;
var wx, wy: Integer;
allocation: TGtkAllocation;
begin
// DebugMsg([' *** NotebookFindNotebookAtPointerEvent(AbsX = ', AbsX, ', AbsY = ', AbsY, ')']);
Result := nil;
// TODO
if LeftPanelNotebook.Visible then begin
gdk_window_get_device_position(gtk_widget_get_window(LeftPanelNotebook.FWidget), nil, @wx, @wy, nil);
// gtk_widget_get_pointer(LeftPanelNotebook.FWidget, @wx, @wy);
gtk_widget_get_allocation(LeftPanelNotebook.FWidget, @allocation);
if (wx > 0) and (wy > 0) and (wx < allocation.width) and
(wy < allocation.height) then Result := LeftPanelNotebook;
end else begin
gdk_window_get_device_position(gtk_widget_get_window(LeftScrolledWindow.FWidget), nil, @wx, @wy, nil);
// gtk_widget_get_pointer(LeftScrolledWindow.FWidget, @wx, @wy);
gtk_widget_get_allocation(LeftScrolledWindow.FWidget, @allocation);
if (wx > 0) and (wy > 0) and (wx < allocation.width) and
(wy < allocation.height) then Result := LeftPanelNotebook;
end;
if Result = nil then begin
if RightPanelNotebook.Visible then begin
gdk_window_get_device_position(gtk_widget_get_window(RightPanelNotebook.FWidget), nil, @wx, @wy, nil);
// gtk_widget_get_pointer(RightPanelNotebook.FWidget, @wx, @wy);
gtk_widget_get_allocation(RightPanelNotebook.FWidget, @allocation);
if (wx > 0) and (wy > 0) and (wx < allocation.width) and
(wy < allocation.height) then Result := RightPanelNotebook;
end else begin
gdk_window_get_device_position(gtk_widget_get_window(RightScrolledWindow.FWidget), nil, @wx, @wy, nil);
// gtk_widget_get_pointer(RightScrolledWindow.FWidget, @wx, @wy);
gtk_widget_get_allocation(RightScrolledWindow.FWidget, @allocation);
if (wx > 0) and (wy > 0) and (wx < allocation.width) and
(wy < allocation.height) then Result := RightPanelNotebook;
end;
end;
{
if Result = LeftPanelNotebook then DebugMsg([' *** NotebookFindNotebookAtPointerEvent: inside LeftPanelNotebook']) else
if Result = RightPanelNotebook then DebugMsg([' *** NotebookFindNotebookAtPointerEvent: inside RightPanelNotebook']);
}
end;
function TFMain.NotebookMoveTabToAnotherNotebook(Sender: TObject; Destination: TEphyNotebook; const SourceTabNo, DestTabNo: integer): boolean;
var LeftPanel: boolean;
ATargetEngine, ASrcEngine: TPanelEngine;
ATargetTabList, ASrcTabList: TStringList;
(* ATargetPathsHighlight, ASrcPathsHighlight: TStringList;
ATargetTabEngines, *) ASrcTabEngines: TList;
(* ATargetTabSortIDs, ASrcTabSortIDs: TList;
ATargetTabSortTypes, ASrcTabSortTypes: TList;
DontShowAgain: boolean; *)
APath: string;
dst_no: integer;
begin
Result := False;
(* DontShowAgain := False; *)
DebugMsg([' *** NotebookMoveTabToAnotherNotebook(SourceTabNo = ', SourceTabNo, ', DestTabNo = ', DestTabNo, ')']);
LeftPanel := Sender = LeftPanelNotebook;
if LeftPanel then begin
ATargetEngine := RightPanelEngine;
ATargetTabList := RightPanelTabs;
ASrcEngine := LeftPanelEngine;
ASrcTabList := LeftPanelTabs;
ASrcTabEngines := LeftTabEngines;
(* ATargetPathsHighlight := RightPathsHighlight;
ATargetTabEngines := RightTabEngines;
ATargetTabSortIDs := RightTabSortIDs;
ATargetTabSortTypes := RightTabSortTypes;
ASrcPathsHighlight := LeftPathsHighlight;
ASrcTabSortIDs := LeftTabSortIDs;
ASrcTabSortTypes := LeftTabSortTypes; *)
end else begin
ATargetEngine := LeftPanelEngine;
ATargetTabList := LeftPanelTabs;
ASrcEngine := RightPanelEngine;
ASrcTabList := RightPanelTabs;
ASrcTabEngines := RightTabEngines;
(* ATargetPathsHighlight := LeftPathsHighlight;
ATargetTabEngines := LeftTabEngines;
ATargetTabSortIDs := LeftTabSortIDs;
ATargetTabSortTypes := LeftTabSortTypes;
ASrcPathsHighlight := RightPathsHighlight;
ASrcTabSortIDs := RightTabSortIDs;
ASrcTabSortTypes := RightTabSortTypes; *)
end;
if (SourceTabNo < 0) or (SourceTabNo > ASrcTabList.Count - 1) then begin
DebugMsg([' *** NotebookMoveTabToAnotherNotebook: invalid SourceTabNo']);
Exit;
end;
APath := TPanelEngine(ASrcTabEngines[SourceTabNo]).Path;
(* -- disabled, we allow to _move_ (not duplicate) non-local engine
if TPanelEngine(ASrcTabEngines[SourceTabNo]) is TVFSEngine then begin
while TPanelEngine(ASrcTabEngines[SourceTabNo]) is TVFSEngine do begin
APath := TPanelEngine(ASrcTabEngines[SourceTabNo]).SavePath;
ASrcTabEngines[SourceTabNo] := TPanelEngine(ASrcTabEngines[SourceTabNo]).ParentEngine;
end;
// Show warning that we couldn't duplicate the VFS location
if ConfDuplicateTabWarning then begin
MessageBoxShowOnce(LANGDuplicateTabWarning, LANGDontShowAgain, DontShowAgain, [mbOK], mbInfo, mbOK, mbOK);
if DontShowAgain then begin
ConfDuplicateTabWarning := False;
WriteMainGUISettings;
end;
end;
end;
while ATargetEngine is TVFSEngine do
ATargetEngine := ATargetEngine.ParentEngine;
*)
dst_no := DestTabNo;
if dst_no < 0 then dst_no := ATargetTabList.Count + Ord(ATargetTabList.Count = 0);
CloseTab(SourceTabNo, LeftPanel, False);
if not (ASrcEngine is TLocalTreeEngine)
then NewTabInternal(not LeftPanel, ASrcEngine, APath, dst_no, True)
else NewTabInternal(not LeftPanel, ATargetEngine, APath, dst_no, True);
Result := True;
end;
procedure TFMain.NotebookTabFocusOnlyEvent(Sender: TObject; const TabNum: integer);
begin
if Sender = LeftPanelNotebook then LeftListView.SetFocus else
if Sender = RightPanelNotebook then RightListView.SetFocus
else Exit;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
function TFMain.HandleVFSArchive(LeftPanel: boolean; const FullPath, HighlightItem, TargetPath: string): boolean;
var Plugin: TVFSPlugin;
Engine, NewEngine: TPanelEngine;
NewPath: string;
begin
Plugin := FindVFSPlugin(ExtractFileName(FullPath));
Result := Plugin <> nil;
if Result then begin
if LeftPanel then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
if Engine is TLocalTreeEngine then begin
DebugMsg(['Found plugin ''', Plugin.ModuleID, ''', trying to open the file ''', FullPath, '''']);
ChangingDir(LeftPanel, TargetPath, FullPath, HighlightItem, False, False, Plugin);
end else begin
DebugMsg(['Found plugin ''', Plugin.ModuleID, ''', archive is nested in another archive, extracting first.']);
NewPath := '';
Result := ExtractFromArchive(NewPath, Engine, FullPath, False);
if Result then begin
DebugMsg(['Extract OK, trying to open the file ''', NewPath, '''']);
ChangingDir(LeftPanel, TargetPath, NewPath, HighlightItem, False, False, Plugin);
if LeftPanel then NewEngine := LeftPanelEngine
else NewEngine := RightPanelEngine;
if (NewEngine is TVFSEngine) and (NewEngine.ParentEngine = Engine) then
(NewEngine as TVFSEngine).RemoveFileOnClose := NewPath;
end;
end;
end;
end;
function TFMain.CloseVFS(LeftPanel, SuppressRefresh: boolean): string;
var Engine: TPanelEngine;
begin
if LeftPanel then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
if (not Assigned(Engine.ParentEngine)) or (not (Engine is TVFSEngine)) then begin
if LeftPanel then begin
LeftPanelEngine := LeftLocalEngine;
Result := LeftPanelEngine.Path;
end else begin
RightPanelEngine := RightLocalEngine;
Result := RightPanelEngine.Path;
end;
Exit;
end;
if not CheckForUnsavedConnection(Engine as TVFSEngine, (not SuppressRefresh) and (not ApplicationShuttingDown)) then Exit;
if LeftPanel then LeftPanelEngine := Engine.ParentEngine
else RightPanelEngine := Engine.ParentEngine;
Result := Engine.SavePath;
if not SuppressRefresh then
ChangingDir(LeftPanel, Engine.SavePath, Engine.ParentEngine.LastHighlightItem, Engine.ParentEngine.LastHighlightItem, False, True);
if not TVFSEngine(Engine).VFSClose(nil) then
DebugMsg(['Error closing the engine...']);
Engine.Free;
end;
function TFMain.CheckForUnsavedConnection(Engine: TVFSEngine; AllowCancel: boolean): boolean; // Returns False to Cancel
var Buttons: TMessageButtons;
CancelButton: TMessageButton;
AFConnectionProperties: TFConnectionProperties;
URI: string;
ConnMgrItem: TConnMgrItem;
i: integer;
DontShowAgain: boolean;
res: TMessageButton;
begin
Result := True;
URI := Engine.GetPathURI;
if Engine.OpenedFromQuickConnect and (Length(Trim(URI)) > 0) then begin
Buttons := [mbYes, mbNo];
CancelButton := mbNo;
if AllowCancel then begin
Include(Buttons, mbCancel);
CancelButton := mbCancel;
end;
if ConfWarnUnsavedConnection then begin
DontShowAgain := False;
res := MessageBoxShowOnce(PGtkWindow(FWidget), Format(LANGTheActiveConnectionHasNotBeenSaved, [Engine.GetPathURI]), LANGDontShowAgain, DontShowAgain, Buttons, mbWarning, mbNo, CancelButton);
if DontShowAgain then begin
ConfWarnUnsavedConnection := False;
WriteMainGUISettings;
end;
case res of
mbYes: begin
AFConnectionProperties := TFConnectionProperties.Create(Self);
try
AFConnectionProperties.URIEntry.Text := URI;
if (Engine.CustomPluginIDSave <> '') and (PluginList.Count > 0) then
AFConnectionProperties.PluginComboBox.ItemID := Engine.CustomPluginIDSave;
if AFConnectionProperties.Run = mbOK then begin
ReadConnections;
ConnMgrItem := TConnMgrItem.Create;
ConnMgrItem.ConnectionName := AFConnectionProperties.NameEntry.Text;
ConnMgrItem.ServiceType := AFConnectionProperties.GetService;
ConnMgrItem.Server := AFConnectionProperties.ServerEntry.Text;
ConnMgrItem.Username := AFConnectionProperties.UserNameEntry.Text;
ConnMgrItem.Password := AFConnectionProperties.PasswordEntry.Text;
ConnMgrItem.TargetDir := AFConnectionProperties.TargetDirEntry.Text;
ConnMgrItem.PluginID := AFConnectionProperties.PluginComboBox.ItemID;
ConfConnMgrActiveItem := ConnectionMgrList.Add(ConnMgrItem);
WriteConnections;
end;
finally
AFConnectionProperties.Free;
end;
Result := True;
end;
mbNo: Result := True;
mbCancel: Result := False;
else {Cancel?} Result := not AllowCancel;
end;
end else Result := True;
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.ShowBookmarkQuick(LeftPanel: boolean);
var SenderControl: TGTKControl;
begin
if LeftPanel then SenderControl := LeftBookmarkButton
else SenderControl := RightBookmarkButton;
miAddBookmark.Visible := False;
miEditBookmarks.Visible := False;
miBookmarksSeparator.Visible := False;
gtk_menu_popup(PGtkMenu(mnuBookmarks.FMenu), nil, nil, @menu_position_cb, SenderControl.FWidget, 1, GDK_CURRENT_TIME);
if LeftPanel then LeftListView.SetFocus else RightListView.SetFocus;
end;
procedure TFMain.mnuBookmarksPopup(Sender: TObject);
begin
miAddBookmark.Visible := True;
miEditBookmarks.Visible := False;
miBookmarksSeparator.Visible := mnuBookmarks.Count > 3;
end;
(********************************************************************************************************************************)
procedure TFMain.miSearchClick(Sender: TObject);
var Engine: TPanelEngine;
DataList: TList;
AListView: TGTKListView;
i: integer;
begin
if LeftLastFocused then Engine := LeftPanelEngine
else Engine := RightPanelEngine;
try
FSearch := TFSearch.Create(Self);
FSearch.ParentForm := FMain;
FSearch.Engine := Engine;
FSearch.SearchInEntry.Text := StrToUTF8(ExcludeTrailingPathDelimiter(Engine.Path));
if Length(FSearch.SearchInEntry.Text) < 1 then FSearch.SearchInEntry.Text := '/';
FSearch.CaseSensitiveMatchCheckButton.Checked := ConfSearchFilterCaseSensitive;
FSearch.StayCurrentFSCheckButton.Checked := ConfSearchOtherFS;
FSearch.SearchArchivesCheckButton.Checked := ConfSearchArchives;
FSearch.CaseSensitiveCheckButton.Checked := ConfSearchTextCaseSensitive;
case FSearch.Run of
mbOK: ;
mbApply: begin
DebugMsg(['TFMain.miSearchClick: FSearch.GoToFileArchive = "', FSearch.GoToFileArchive, '", FSearch.GoToFile = "', FSearch.GoToFile, '"']);
if Length(FSearch.GoToFileArchive) > 0 then begin
HandleVFSArchive(LeftLastFocused, FSearch.GoToFileArchive, ExtractFileName(FSearch.GoToFileArchive), ExtractFilePath(FSearch.GoToFile));
if LeftLastFocused then begin
Engine := LeftPanelEngine;
DataList := LeftPanelData;
AListView := LeftListView;
end else begin
Engine := RightPanelEngine;
DataList := RightPanelData;
AListView := RightListView;
end;
if Engine is TVFSEngine then begin
Engine.SavePath := ExtractFilePath(FSearch.GoToFileArchive);
// (Engine as TVFSEngine).ParentEngine.LastHighlightItem := ExtractFileName(FSearch.GoToFileArchive);
for i := 0 to DataList.Count - 1 do
if WideCompareText(string(PDataItem(DataList[i])^.FName), ExtractFileName(FSearch.GoToFile)) = 0 then begin
AListView.Items[i].Selected := True;
AListView.Items[i].SetCursor(0, False, False, 0.5, 0);
Break;
end;
end;
end else ChangingDir(LeftLastFocused, ExtractFilePath(FSearch.GoToFile), ExtractFileName(FSearch.GoToFile));
end;
end;
finally
ConfSearchFilterCaseSensitive := FSearch.CaseSensitiveMatchCheckButton.Checked;
ConfSearchOtherFS := FSearch.StayCurrentFSCheckButton.Checked;
ConfSearchArchives := FSearch.SearchArchivesCheckButton.Checked;
ConfSearchTextCaseSensitive := FSearch.CaseSensitiveCheckButton.Checked;
FSearch.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
procedure TFMain.miOpenConnectionClick(Sender: TObject);
var b: boolean;
begin
try
InternalLock;
ReadConnections;
FConnectionManager := TFConnectionManager.Create(Self);
if LeftLastFocused then FConnectionManager.SourcePanelEngine := LeftPanelEngine
else FConnectionManager.SourcePanelEngine := RightPanelEngine;
b := FConnectionManager.Run = mbOK;
WriteConnections; // Save connection manager data
if b and (FConnectionManager.ConnectedEngine <> nil) then begin
while FConnectionManager.ConnectedEngine.ParentEngine is TVFSEngine do
FConnectionManager.ConnectedEngine.ParentEngine := FConnectionManager.ConnectedEngine.ParentEngine.ParentEngine;
if FConnectionManager.SourcePanelEngine is TVFSEngine then CloseVFS(LeftLastFocused, True);
if LeftLastFocused then LeftPanelEngine := FConnectionManager.ConnectedEngine
else RightPanelEngine := FConnectionManager.ConnectedEngine;
DoRefresh(LeftLastFocused, False, False);
end;
finally
FConnectionManager.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.miQuickConnectClick(Sender: TObject);
var b: boolean;
begin
try
InternalLock;
ReadConnections;
FQuickConnect := TFQuickConnect.Create(Self);
if LeftLastFocused then FQuickConnect.SourcePanelEngine := LeftPanelEngine
else FQuickConnect.SourcePanelEngine := RightPanelEngine;
b := FQuickConnect.Run = mbOK;
WriteConnections; // Save connection manager data
if b and (FQuickConnect.ConnectedEngine <> nil) then begin
while FQuickConnect.ConnectedEngine.ParentEngine is TVFSEngine do
FQuickConnect.ConnectedEngine.ParentEngine := FQuickConnect.ConnectedEngine.ParentEngine.ParentEngine;
if FQuickConnect.SourcePanelEngine is TVFSEngine then CloseVFS(LeftLastFocused, True);
if LeftLastFocused then LeftPanelEngine := FQuickConnect.ConnectedEngine
else RightPanelEngine := FQuickConnect.ConnectedEngine;
DoRefresh(LeftLastFocused, False, False);
end;
finally
FQuickConnect.Free;
Application.ProcessMessages;
InternalLockInit(False);
end;
end;
procedure TFMain.miDisconnectClick(Sender: TObject);
begin
CloseVFS(LeftLastFocused, False);
end;
procedure TFMain.DisconnectButtonClick(Sender: TObject);
begin
CloseVFS(Sender = LeftDisconnectButton, False);
if (Sender = LeftDisconnectButton) and (not LeftListView.Focused) then LeftListView.SetFocus else
if (Sender = RightDisconnectButton) and (not RightListView.Focused) then RightListView.SetFocus;
end;
procedure TFMain.LeaveArchiveButtonClick(Sender: TObject);
begin
CloseVFS(Sender = LeftLeaveArchiveButton, False);
if (Sender = LeftLeaveArchiveButton) and (not LeftListView.Focused) then LeftListView.SetFocus else
if (Sender = RightLeaveArchiveButton) and (not RightListView.Focused) then RightListView.SetFocus;
end;
procedure TFMain.OpenTerminalButtonClick(Sender: TObject);
var CurrentPath: string;
AEngine: TPanelEngine;
Error: integer;
begin
Error := 0;
if LeftLastFocused then AEngine := LeftPanelEngine
else AEngine := RightPanelEngine;
while not (AEngine is TLocalTreeEngine) do AEngine := AEngine.ParentEngine;
CurrentPath := AEngine.Path;
libc_chdir(PChar(CurrentPath));
ExecuteProgram('bash', CurrentPath, False, True, Error);
libc_chdir('/');
end;
(********************************************************************************************************************************)
procedure TFMain.CopyFilenamesToClipboard(FullPaths, LeftPanel: boolean);
var DataList: TList;
Engine: TPanelEngine;
AListView: TGTKListView;
i, x: longint;
SelCount: longint;
clip: PGtkClipboard;
s: string;
begin
if LeftPanel then begin
AListView := LeftListView;
Engine := LeftPanelEngine;
DataList := LeftPanelData;
end else begin
AListView := RightListView;
Engine := RightPanelEngine;
DataList := RightPanelData;
end;
clip := gtk_clipboard_get(gdk_atom_intern('CLIPBOARD', False));
SelCount := 0;
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do
with PDataItem(DataList[i])^ do
if Selected and (not UpDir) then Inc(SelCount);
if (SelCount = 0) and ((not Assigned(AListView.Selected)) or PDataItem(AListView.Selected.Data)^.UpDir) then begin
// Empty the clipboard
gtk_clipboard_clear(clip);
Exit;
end;
if SelCount = 0 then begin
s := PDataItem(AListView.Selected.Data)^.FDisplayName;
if FullPaths then s := IncludeTrailingPathDelimiter(Engine.GetPath) + s;
end else begin
s := '';
if DataList.Count > 0 then
for i := 0 to DataList.Count - 1 do begin
x := AListView.ConvertFromSorted(i);
if (x >= 0) and (x < DataList.Count) and PDataItem(DataList[x])^.Selected then begin
if FullPaths then s := s + IncludeTrailingPathDelimiter(Engine.GetPath);
s := s + PDataItem(DataList[x])^.FDisplayName + #10;
end;
end;
end;
gtk_clipboard_set_text(clip, PChar(s), Length(s));
end;
procedure TFMain.miPathBoxCopyPathClick(Sender: TObject);
var clip: PGtkClipboard;
s: string;
begin
if LeftLastFocused then s := LeftPanelEngine.Path
else s := RightPanelEngine.Path;
clip := gtk_clipboard_get(gdk_atom_intern('CLIPBOARD', False));
gtk_clipboard_set_text(clip, PChar(StrToUTF8(s)), Length(StrToUTF8(s)));
end;
procedure TFMain.miCopyNamesClick(Sender: TObject);
begin
if LeftListView.Focused then CopyFilenamesToClipboard(Sender = miCopyFullPaths, True) else
if RightListView.Focused then CopyFilenamesToClipboard(Sender = miCopyFullPaths, False);
end;
(********************************************************************************************************************************)
(********************************************************************************************************************************)
function TFMain.HandleRunFromArchive(var APath: string; Engine: TPanelEngine; Command, FileTypeDesc: string; BypassDialog: boolean): boolean;
var Res: TMessageButton;
Stat: PDataItem;
s: string;
AListView: TGTKListView;
begin
Result := False;
try
if not BypassDialog then begin
Stat := Engine.GetFileInfo(APath, True, True, nil);
FRunFromVFS := TFRunFromVFS.Create(Self);
FRunFromVFS.FileNameLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [StrToUTF8(APath)]);
if FileTypeDesc = '' then FileTypeDesc := LANGHandleRunFromArchive_FileTypeDesc_Unknown;
FRunFromVFS.FileTypeLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [FileTypeDesc]);
if Assigned(Stat) then begin
if (ConfSizeFormat < 5) or (Stat^.Size < 1024) then s := Format(' %s', [LANGHandleRunFromArchive_Bytes]);
FRunFromVFS.SizeLabel2.Caption := Format('%s%s<span weight="ultrabold"> </span>', [FormatSize(Stat^.Size, 0), s]);
if (ConfSizeFormat < 5) or (Stat^.Size < 1024) then s := Format(' %s', [LANGHandleRunFromArchive_Bytes]);
if Stat^.PackedSize >= 0 then begin
FRunFromVFS.PackedSizeLabel2.Caption := Format('%s%s<span weight="ultrabold"> </span>', [FormatSize(Stat^.PackedSize, 0), s]);
end else begin
FRunFromVFS.PackedSizeLabel2.Visible := False;
FRunFromVFS.PackedSizeLabel.Visible := False;
end;
FRunFromVFS.DateLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [FormatDate(Stat^.mtime, True, True)]);
if (Command = '') and (not Stat^.IsExecutable) then begin
FRunFromVFS.OpensWithLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [LANGHandleRunFromArchive_NotAssociated]);
FRunFromVFS.ExecuteButton.Enabled := False;
FRunFromVFS.ExecuteAllButton.Enabled := False;
end else begin
if Command = '' then Command := LANGHandleRunFromArchive_SelfExecutable;
FRunFromVFS.OpensWithLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [Command]);
end;
FreeDataItem(Stat);
end else begin
FRunFromVFS.SizeLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', ['??']);
FRunFromVFS.PackedSizeLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', ['??']);
FRunFromVFS.DateLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', ['??']);
FRunFromVFS.OpensWithLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [Command]);
end;
FRunFromVFS.FileNameLabel2.UseMarkup := True;
FRunFromVFS.FileTypeLabel2.UseMarkup := True;
FRunFromVFS.SizeLabel2.UseMarkup := True;
FRunFromVFS.PackedSizeLabel2.UseMarkup := True;
FRunFromVFS.DateLabel2.UseMarkup := True;
FRunFromVFS.OpensWithLabel2.UseMarkup := True;
Res := FRunFromVFS.Run;
FRunFromVFS.Close;
FRunFromVFS.Free;
Application.ProcessMessages;
end else Res := mbYes;
if Res in [mbYes, mbNo] then begin
Result := False;
if Res = mbYes then DebugMsg(['(II) HandleRunFromArchive: Selected extract and execute single item'])
else DebugMsg(['(II) HandleRunFromArchive: Selected extract all and execute']);
if LeftLastFocused then AListView := LeftListView
else AListView := RightListView;
Engine.Path := ExtractFilePath(APath);
// Extract the files
Result := ExtractFromArchive(APath, Engine, APath, Res = mbNo);
end;
finally
Application.ProcessMessages;
end;
end;
function TFMain.ExtractFromArchive(var NewPath: string; Engine: TPanelEngine; const FileToExtract: string; ExtractAll: boolean): boolean;
var s: string;
AWorkingThread: TWorkerThread;
tmp: PChar;
LocalEngine: TLocalTreeEngine;
DataList: TList;
err: integer;
begin
s := IncludeTrailingPathDelimiter(ConfTempPath) + 'tuxcmd-XXXXXX';
tmp := strdup(PChar(s));
tmp := mkdtemp(tmp);
if tmp = nil then begin
err := errno;
DebugMsg(['(EE) ExtractFromArchive: Couldn''t create temporary directory: ', strerror(err)]);
Application.MessageBox(Format(LANGHandleRunFromArchive_CouldntCreateTemporaryDirectory, [s, string(strerror(err))]), [mbOK], mbError, mbOK, mbOK);
Result := False;
Exit;
end;
DebugMsg(['(II) ExtractFromArchive: Using temporary directory: ', tmp]);
UsedTempPaths.Add(string(tmp));
if LeftLastFocused then DataList := LeftPanelData
else DataList := RightPanelData;
LocalEngine := TLocalTreeEngine.Create;
AWorkingThread := TWorkerThread.Create;
try
DebugMsg(['TFMain.ExtractFromArchive: Creating thread...']);
LocalEngine.SetPath(tmp);
AWorkingThread.DialogsParentWindow := Self;
AWorkingThread.DestEngine := LocalEngine;
AWorkingThread.SrcEngine := Engine;
AWorkingThread.ExtractFromVFSAll := ExtractAll;
AWorkingThread.DataList := DataList;
AWorkingThread.JobType := WORKER_JOB_EXTRACT_TO_TEMP;
AWorkingThread.CopyTargetPath := string(tmp);
AWorkingThread.ExtractFile := FileToExtract;
DebugMsg(['*** Copy: AWorkingThread.Resume']);
AWorkingThread.Resume;
DebugMsg(['*** Copy: AWorkingThread.Resumed.']);
ProcessThreadEvents(AWorkingThread);
Result := (not AWorkingThread.FCancelled) and (not AWorkingThread.ErrorHappened);
finally
DebugMsg(['TFMain.ExtractFromArchive: Freeing thread...']);
LocalEngine.Free;
AWorkingThread.Free;
end;
DebugMsg(['(II) ExtractFromArchive: Old path = ', FileToExtract]);
if Result then begin
if not ExtractAll then NewPath := IncludeTrailingPathDelimiter(string(tmp)) + ExtractFileName(FileToExtract)
else NewPath := ExcludeTrailingPathDelimiter(string(tmp)) + FileToExtract;
DebugMsg(['(II) ExtractFromArchive: New path = ', NewPath]);
// Test for read access to the new file
if (not ExtractAll) and (access(PChar(NewPath), R_OK) <> 0) then begin
Result := False;
DebugMsg(['(EE) ExtractFromArchive: access test to the new file failed.']);
end;
end;
libc_free(tmp);
DebugMsg(['(II) ExtractFromArchive: Copy OK, Result = ', Result]);
end;
(********************************************************************************************************************************)
procedure TFMain.PasswordButtonClick(Sender: TObject);
var Engine: TPanelEngine;
Password: PChar;
begin
if Sender = LeftPasswordButton then Engine := LeftPanelEngine else
if Sender = RightPasswordButton then Engine := RightPanelEngine
else Exit;
if not (Engine is TVFSEngine) then Exit;
try
Password := nil;
if HandleVFSAskPasswordCallback(FWidget, PChar(LANGTheArchiveIsEncryptedAndRequiresPassword),
nil, nil, PChar(TVFSEngine(Engine).Password),
VFS_ASK_PASSWORD_NEED_PASSWORD or VFS_ASK_PASSWORD_ARCHIVE_MODE,
nil, @Password, nil, nil, nil) then
if Password <> nil then begin
TVFSEngine(Engine).Password := string(Password);
TVFSEngine(Engine).PasswordUsed := False;
TVFSEngine(Engine).ResetPassword;
g_free(Password);
end;
except
on E: Exception do DebugMsg(['*** Exception raised in FMain.HandleSetPassword: (', E.ClassName, '): ', E.Message]);
end;
end;
(********************************************************************************************************************************)
procedure TFMain.miDiffClick(Sender: TObject);
var LeftPanel: boolean;
SourceListView, TargetListView: TGTKListView;
SourceEngine, TargetEngine: TPanelEngine;
SourceFile, TargetFile: string;
Error: integer;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
SourceListView := LeftListView;
TargetListView := RightListView;
SourceEngine := LeftPanelEngine;
TargetEngine := RightPanelEngine;
end else begin
SourceListView := RightListView;
TargetListView := LeftListView;
SourceEngine := RightPanelEngine;
TargetEngine := LeftPanelEngine;
end;
if (not Assigned(SourceListView.Selected)) or (not Assigned(SourceListView.Selected.Data)) or PDataItem(SourceListView.Selected.Data)^.IsDir or
PDataItem(SourceListView.Selected.Data)^.UpDir then
begin
Application.MessageBox(LANGYouMustSelectAValidFile, [mbOK], mbError, mbNone, mbOK);
Exit;
end;
SourceFile := IncludeTrailingPathDelimiter(SourceEngine.Path) + PDataItem(SourceListView.Selected.Data)^.FName;
TargetFile := '';
if Assigned(TargetListView.Selected) and Assigned(TargetListView.Selected.Data) and
(not PDataItem(TargetListView.Selected.Data)^.IsDir) and (not PDataItem(TargetListView.Selected.Data)^.UpDir)
then TargetFile := IncludeTrailingPathDelimiter(TargetEngine.Path) + PDataItem(TargetListView.Selected.Data)^.FName;
if SourceEngine is TVFSEngine then
if not HandleRunFromArchive(SourceFile, SourceEngine, '', '', True) then Exit;
if (Length(TargetFile) > 0) and (TargetEngine is TVFSEngine) then
if not HandleRunFromArchive(TargetFile, TargetEngine, '', '', True) then Exit;
if not ExecuteProgram(Format('%s %s %s', [ConfDiffCommand, QuoteStr(SourceFile), QuoteStr(TargetFile)]), SourceEngine.Path, ConfDiffTerminalBehaviour = 0, ConfDiffTerminalBehaviour = 1, Error) then
Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [ConfDiffCommand]), [mbOK], mbError, mbNone, mbOK);
end;
procedure TFMain.miSynchronizeDirsClick(Sender: TObject);
var LeftPanel: boolean;
SourceListView, TargetListView: TGTKListView;
SourceEngine, TargetEngine: TPanelEngine;
SourceDir, TargetDir: string;
Error: integer;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then begin
SourceListView := LeftListView;
TargetListView := RightListView;
SourceEngine := LeftPanelEngine;
TargetEngine := RightPanelEngine;
end else begin
SourceListView := RightListView;
TargetListView := LeftListView;
SourceEngine := RightPanelEngine;
TargetEngine := LeftPanelEngine;
end;
if (not Assigned(SourceListView.Selected)) or (not Assigned(SourceListView.Selected.Data)) or
((not PDataItem(SourceListView.Selected.Data)^.IsDir) and (not PDataItem(SourceListView.Selected.Data)^.UpDir)) then
begin
Application.MessageBox('You must select directory!', [mbOK], mbError, mbNone, mbOK);
Exit;
end;
if PDataItem(SourceListView.Selected.Data)^.UpDir
then SourceDir := IncludeTrailingPathDelimiter(SourceEngine.Path)
else SourceDir := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(SourceEngine.Path) + PDataItem(SourceListView.Selected.Data)^.FName);
TargetDir := '';
if Assigned(TargetListView.Selected) and Assigned(TargetListView.Selected.Data) and
(PDataItem(TargetListView.Selected.Data)^.IsDir or PDataItem(TargetListView.Selected.Data)^.UpDir) then
begin
if PDataItem(TargetListView.Selected.Data)^.UpDir
then TargetDir := IncludeTrailingPathDelimiter(TargetEngine.Path)
else TargetDir := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(TargetEngine.Path) + PDataItem(TargetListView.Selected.Data)^.FName);
end;
//* TODO: extract only particular subtree, also use ExtractFromArchive directly instead
if SourceEngine is TVFSEngine then
if not HandleRunFromArchive(SourceDir, SourceEngine, '', '', True) then Exit;
if (Length(TargetDir) > 0) and (TargetEngine is TVFSEngine) then
if not HandleRunFromArchive(TargetDir, TargetEngine, '', '', True) then Exit;
if not ExecuteProgram(Format('%s %s %s', [ConfDiffDirCommand, QuoteStr(SourceDir), QuoteStr(TargetDir)]), SourceEngine.Path, ConfDiffDirTerminalBehaviour = 0, ConfDiffDirTerminalBehaviour = 1, Error) then
Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [ConfDiffDirCommand]), [mbOK], mbError, mbNone, mbOK);
end;
end.
|