This file is indexed.

/usr/share/gnome-shell/extensions/TaskBar@zpydr/extension.js is in gnome-shell-extension-taskbar 57.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
//  GNOME Shell Extension TaskBar
//  Copyright (C) 2013-2018 zpydr
//
//  Version 57
//
//  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 3 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, see <https://www.gnu.org/licenses/>.
//
//  zpydr@openmailbox.org

const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;

const AppFavorites = imports.ui.appFavorites;
const Layout = imports.ui.layout;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const Panel = imports.ui.main.panel;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const RemoteMenu = imports.ui.remoteMenu;
const ThumbnailsSlider = imports.ui.overviewControls.ThumbnailsSlider.prototype;
const Tweener = imports.ui.tweener;

const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Lib = Extension.imports.lib;
const Prefs = Extension.imports.prefs;
const ShellVersion = imports.misc.config.PACKAGE_VERSION.split(".").map(function(x) {
	return +x;
});
const Windows = Extension.imports.windows;

const schema = "org.gnome.shell.extensions.TaskBar";

const RESETBOTTOMPANELCOLOR = 'rgba(0,0,0,1)';

const LEFTBUTTON = 1;
const MIDDLEBUTTON = 2;
const RIGHTBUTTON = 3;
const NOHOTCORNER = 54321;
const DESKTOPICON = Extension.path + '/images/desktop-button-default.png';
const APPVIEWICON = Extension.path + '/images/appview-button-default.svg';
const BPTRAYICON = Extension.path + '/images/bottom-panel-tray-button.svg';
const PREVIOUSKEY = 'key-previous-task';
const NEXTKEY = 'key-next-task';
const DESKTOPKEY = 'key-toggle-desktop';

function init(extensionMeta) {
	return new TaskBar(extensionMeta, schema);
}

function TaskBar(extensionMeta, schema) {
	this.init(extensionMeta, schema);
}

TaskBar.prototype = {
	active: null,
	activeTask: null,
	activeWorkspaceIndex: null,
	activeWorkspace: null,
	activitiesStyle: null,
	activitiesContainer: null,
	alwaysZoomOut: null,
	app: null,
	appearance: null,
	appearances: [],
	appMenuColor: null,
	appMenuContainer: null,
	appMenuStyle: null,
	appname: null,
	attentionStyle: null,
	attentionStyleChanged: null,
	attentionStyleChangeTimeout: null,
	backgroundColor: null,
	backgroundStyleColor: null,
	barriers: null,
	blacklist: [],
	blacklistapp: null,
	bottomPanelActor: null,
	bottomPanelBackgroundColor: null,
	bottomPanelBackgroundStyle: null,
	bottomPanelEndIndicator: null,
	bottomPanelHeight: null,
	bottomPanelVertical: null,
	boxBottomPanelTrayButton: null,
	boxDesktop: null,
	boxMainDesktopButton: null,
	boxMainFavorites: null,
	boxMain: null,
	boxMainShowAppsButton: null,
	boxMainTasksId: null,
	boxMainTasks: null,
	boxMainWorkspaceButton: null,
	boxShowApps: null,
	boxTray: null,
	boxWorkspace: null,
	buttonDesktop: null,
	buttonfavorite: null,
	button: null,
	buttonShowApps: null,
	buttonTask: null,
	buttonTaskLayout: null,
	buttonTaskWidth: null,
	buttonTray: null,
	buttonWorkspace: null,
	changedId: null,
	countTasks: null,
	dash: null,
	dashHeight: null,
	dashWidth: null,
	dateMenuColor: null,
	dateMenuContainer: null,
	dateMenuStyle: null,
	desktopButtonIcon: null,
	desktopView: null,
	favoriteappName: null,
	favoriteapp: null,
	favorites: null,
	favoritesPreview: null,
	focusWindow: null,
	globalThemeChangedId: null,
	height: null,
	hidingId2: null,
	hidingId: null,
	hoverComponent: null,
	hoverStyle: null,
	iconDesktop: null,
	iconPath: null,
	iconShowApps: null,
	panelSize: null,
	iconTask: null,
	iconThemeChangedId: null,
	iconTray: null,
	inactiveBackgroundStyleColor: null,
	inactiveTask: null,
	index: null,
	indicatorCount: null,
	installedChangedId: null,
	i: null,
	itemHeight: null,
	itemWidth: null,
	j: null,
	k: null,
	key: null,
	labelHeight: null,
	labelNamePreview: null,
	labelTask: null,
	labelTitlePreview: null,
	labelTotalWorkspace: null,
	labelTray: null,
	labelWidth: null,
	labelWorkspaceIndex: null,
	labelWorkspace: null,
	lastFocusedWindow: null,
	lastFocusedWindowUserTime: null,
	leftbutton: null,
	mainBox: null,
	maxWindows: null,
	menuQuit: null,
	messageTrayCountAddedId: null,
	messageTrayCountRemovedId: null,
	messageTrayHidingId: null,
	messageTrayShowingId: null,
	monitorChangedId: null,
	mutterWindow: null,
	newActiveWorkspace: null,
	newBox: null,
	newShowTray: null,
	newTasksContainerWidth: null,
	newWidth: null,
	nextTask: null,
	node: null,
	nonExpandedWidth: null,
	numButton: null,
	nWorkspacesId: null,
	originalLeftPanelCornerStyle: null,
	originalRightPanelCornerStyle: null,
	originalTopPanelStyle: null,
	overviewHidingId: null,
	overviewShowingId: null,
	panelBox: null,
	panelIconSize: null,
	panelPosition: null,
	panelSet: null,
	fontSize: null,
	panelStyleChangedId: null,
	pbchildren: null,
	positionAppearance: null,
	positionBoxBottomEnd: null,
	positionBoxBottomMiddle: null,
	positionBoxBottomSettings: null,
	positionBoxBottomStart: null,
	positionMaxRight: null,
	posparent: null,
	posparentWidth: null,
	preview: null,
	previewTimer2: null,
	previewTimer: null,
	previousTask: null,
	primary: null,
	resetHover: null,
	rightbutton: null,
	scale: null,
	screenShieldLockId: null,
	scrollDirection: null,
	separatorAppview: null,
	separatorBoxMain: null,
	separatorDesktop: null,
	separatorFavorites: null,
	separatorLeftAppview: null,
	separatorLeftBoxMain: null,
	separatorLeftDesktop: null,
	separatorLeftFavorites: null,
	separatorLeftTasks: null,
	separatorLeftWorkspaces: null,
	separatorRightAppview: null,
	separatorRightBoxMain: null,
	separatorRightDesktop: null,
	separatorRightFavorites: null,
	separatorRightTasks: null,
	separatorRightWorkspaces: null,
	separatorTasks: null,
	separatorWorkspaces: null,
	setAnchorPoint: null,
	setTaskBar: null,
	settingSignals: [],
	settings: null,
	showAppsIcon: null,
	showTray: null,
	signalDesktop: null,
	signalShowApps: null,
	signalsTask: [],
	signalTray: null,
	spaces: null,
	stageX: null,
	stageY: null,
	systemMenuColor: null,
	systemMenuContainer: null,
	systemMenuStyle: null,
	taskMenu: null,
	taskMenuIsOpen: null,
	taskMenuManager: null,
	taskMenuUp: null,
	tasksContainerWidth: null,
	tasksLabelColor: null,
	tasksLabelStyle: null,
	tasksList: [],
	tasksWidth: null,
	tbp: null,
	threshold: null,
	thumbnail: null,
	title: null,
	toggleOverview: null,
	topPanelBackgroundColor: null,
	topPanelBackgroundStyle: null,
	topPanelOriginalBackgroundColor: null,
	totalWidth: null,
	totalWorkspace: null,
	tpobc: null,
	trayIcon: null,
	type: null,
	userTime: null,
	variant: null,
	width: null,
	windowDemandsAttentionId: null,
	windows: null,
	windowsList: [],
	windowTask: null,
	windowTexture: null,
	windowWorkspace: null,
	workspace: null,
	workspaceButtonColor: null,
	workspaceButtonStyle: null,
	workspaceSwitchedId: null,
	workspaceTask: null,
	x: null,
	xsettings: null,
	y: null,
	yOffset: null,

	init: function(extensionMeta, schema) {
		this.extensionMeta = extensionMeta;
		this.schema = schema;
	},

	onParamChanged: function() {
		if (!this.settings.get_boolean("reset-flag")) {
			this.disable();
			this.enable();
		}
	},

	enable: function() {
		let settings = new Lib.Settings(this.schema);
		this.settings = settings.getSettings();

		//Top Panel Background Color
		this.changeTopPanelBackgroundColor();

		//First Start
		this.firstStart();

		//Verify other Extensions
		this.otherExtensions();

		//Add TaskBar
		this.addTaskBar();

		//Add Separators
		this.addSeparators();

		//Set TaskBar Position
		this.onPositionChanged();

		//Add Favorites
		this.addFavorites();

		//Add Appview Button
		this.addShowAppsButton();

		//Add Workspace Button
		this.addWorkspaceButton();

		//Add Desktop Button
		this.addDesktopButton();

		//Add Tray Button
		this.addTrayButton();

		//Activities Button
		this.initDisplayActivitiesButton();

		//Hot Corner
		this.initEnableHotCorner();

		//Application Menu
		this.initDisplayApplicationMenu();

		//Date Menu
		this.initDisplayDateMenu();

		//System Menu
		this.initDisplaySystemMenu();

		//Dash
		this.initDisplayDash();

		//Workspace Selector
		this.initDisplayWorkspaceSelector();

		//Init Windows Manage Callbacks
		this.initWindows();

		//Order of Appearance
		this.appearanceOrder();

		//Preferences Hover Event
		this.hoverEvent();

		//Top Panel
		this.initDisplayTopPanel();

		//Reinit Extension on Param Change
		this.setSignals();
		this.setSystemSignals();

		//Keybindings
		this.keybindings();
	},

	disable: function() {
		//Disconnect Overview Signals
		if (this.overviewHidingId !== null) {
			Main.overview.disconnect(this.overviewHidingId);
			this.overviewHidingId = null;
		}
		if (this.overviewShowingId !== null) {
			Main.overview.disconnect(this.overviewShowingId);
			this.overviewShowingId = null;
		}

		//Show Activities if hidden
		if (!this.settings.get_boolean("activities-button"))
			this.activitiesContainer.show();

		//Reset Activities Button Color if changed
		if (this.settings.get_string("activities-button-color") !== "unset")
			Main.panel.statusArea.activities.actor.set_style("None");

		//Enable Hot Corner if disabled
		if ((!this.settings.get_boolean("hot-corner")) && (ShellVersion[1] < 26))
			Main.layoutManager._updateHotCorners();

		//Show and disconnect Application Menu if hidden
		if (!this.settings.get_boolean("application-menu")) {
			this.appMenuContainer.show();
			Shell.WindowTracker.get_default().disconnect(this.hidingId2);
			Main.overview.disconnect(this.hidingId);
		}

		//Reset Application Menu Color if changed
		if (this.settings.get_string("application-menu-color") !== "unset")
			Main.panel.statusArea.appMenu.actor.set_style("None");

		//Show Date Menu if hidden
		if (!this.settings.get_boolean("date-menu"))
			this.dateMenuContainer.show();

		//Reset Date Menu Color if changed
		if (this.settings.get_string("date-menu-color") !== "unset")
			Main.panel.statusArea.dateMenu.actor.set_style("None");

		//Show System Menu if hidden
		if (!this.settings.get_boolean("system-menu"))
			this.systemMenuContainer.show();

		//Reset System Menu Color if changed
		if (this.settings.get_string("system-menu-color") !== "unset")
			Main.panel.statusArea.aggregateMenu.actor.set_style("None");

		//Show Dash if hidden
		if (!this.settings.get_boolean("dash")) {
			this.dash.set_height(this.dashHeight);
			this.dash.set_width(this.dashWidth);
		}

		//Show Workspace Selector if hidden
		if (!this.settings.get_boolean("workspace-selector")) {
			ThumbnailsSlider._getAlwaysZoomOut = this.alwaysZoomOut;
			ThumbnailsSlider.getNonExpandedWidth = this.nonExpandedWidth;
		}

		//Disconnect Workspace Signals
		if (this.workspaceSwitchedId !== null) {
			global.screen.disconnect(this.workspaceSwitchedId);
			this.workspaceSwitchedId = null;
		}
		if (this.nWorkspacesId !== null) {
			global.screen.disconnect(this.nWorkspacesId);
			this.nWorkspacesId = null;
		}

		//Disconnect Favorites Signals
		if (this.installedChangedId !== null) {
			Shell.AppSystem.get_default().disconnect(this.installedChangedId);
			this.installedChangedId = null;
		}
		if (this.changedId !== null) {
			AppFavorites.getAppFavorites().disconnect(this.changedId);
			this.changedId = null;
		}

		//Disconnect Message Tray Sources Added Signal
		if (this.messageTrayCountAddedId !== null) {
			if (ShellVersion[1] <= 14)
				Main.messageTray.disconnect(this.messageTrayCountAddedId);
			this.messageTrayCountAddedId = null;
		}

		//Disconnect Message Tray Sources Removed Signal
		if (this.messageTrayCountRemovedId !== null) {
			if (ShellVersion[1] <= 14)
				Main.messageTray.disconnect(this.messageTrayCountRemovedId);
			this.messageTrayCountRemovedId = null;
		}

		//Disconnect Message Tray Showing Signal
		if (this.messageTrayShowingId !== null) {
			if (ShellVersion[1] <= 14)
				Main.messageTray.disconnect(this.messageTrayShowingId);
			this.messageTrayShowingId = null;
		}

		//Disconnect Message Tray Hiding Signal
		if (this.messageTrayHidingId !== null) {
			if (ShellVersion[1] <= 14)
				Main.messageTray.disconnect(this.messageTrayHidingId);
			this.messageTrayHidingId = null;
		}

		//Reset Message Tray
		if (this.showTray !== null) {
			if (ShellVersion[1] <= 14)
				MessageTray.MessageTray.prototype._showTray = this.showTray;
			this.showTray = null;
		}

		//Disconnect Setting Signals
		if (this.settingSignals !== null) {
			this.settingSignals.forEach(
				function(signal) {
					this.settings.disconnect(signal);
				},
				this
			);
			this.settingSignals = null;
		}

		//Disconnect Monitor Change Signals
		if (this.monitorChangedId !== null) {
			Main.layoutManager.disconnect(this.monitorChangedId);
			this.monitorChangedId = null;
		}

		//Disconnect Texture Cache Signals
		if (this.iconThemeChangedId !== null) {
			St.TextureCache.get_default().disconnect(this.iconThemeChangedId);
			this.iconThemeChangedId = null;
		}

		//Disconnect Global Theme Signals
		if (this.globalThemeChangedId !== null) {
			St.ThemeContext.get_for_stage(global.stage).disconnect(this.globalThemeChangedId);
			this.globalThemeChangedId = null;
		}

		//Disconnect Window Demands Attention Signals
		if (this.windowDemandsAttentionId !== null) {
			global.display.disconnect(this.windowDemandsAttentionId);
			this.windowDemandsAttentionId = null;
		}

		//Disconnect Lock Screen Signals
		if (this.screenShieldLockId !== null) {
			Main.screenShield.disconnect(this.screenShieldLockId);
			this.screenShieldLockId = null;
		}

		//Hide current preview if necessary
		this.hidePreview();

		//Disconnect Tasks Container Scroll Signals
		if (this.boxMainTasksId !== null) {
			this.boxMainTasks.disconnect(this.boxMainTasksId);
			this.boxMainTasksId = null;
		}

		//Remove Keybindings
		if (Main.wm.removeKeybinding) {
			Main.wm.removeKeybinding(PREVIOUSKEY);
			Main.wm.removeKeybinding(NEXTKEY);
			Main.wm.removeKeybinding(DESKTOPKEY);
		} else {
			global.display.remove_keybinding(PREVIOUSKEY);
			global.display.remove_keybinding(NEXTKEY);
			global.display.remove_keybinding(DESKTOPKEY);
		}

		//Remove TaskBar
		if (this.windows !== null) {
			this.windows.destruct();
			this.windows = null;
		}
		if (this.bottomPanelActor !== null) {
			this.bottomPanelActor.destroy();
			this.bottomPanelActor = null;
		}
		if ((this.setAnchorPoint) && (ShellVersion[1] <= 14)) {
			Main.messageTray.actor.set_anchor_point(0, 0);
			Main.messageTray._notificationWidget.set_anchor_point(0, 0);
			this.setAnchorPoint = false;
		}
		if (this.newBox !== null) {
			this.newBox.remove_child(this.boxMain);
			this.newBox = null;
		}
		if (this.boxMain !== null)
			this.boxMain = null;
		if (this.mainBox !== null)
			this.mainBox = null;
		this.cleanTasksList();
		if (this.topPanelBackgroundColor !== 'unset') {
			if (ShellVersion[1] <= 16) {
				Main.panel._leftCorner.actor.show();
				Main.panel._rightCorner.actor.show();
			}
			Main.panel._leftCorner.actor.set_style(this.originalLeftPanelCornerStyle);
			Main.panel._rightCorner.actor.set_style(this.originalRightPanelCornerStyle);
		}
		if ((this.topPanelBackgroundColor !== 'unset') || (this.panelSet))
			Main.panel.actor.set_style(this.originalTopPanelStyle);
		if (!this.settings.get_boolean("top-panel")) {
			Main.layoutManager.removeChrome(Main.layoutManager.panelBox);
			Main.layoutManager.addChrome(Main.layoutManager.panelBox, {
				affectsStruts: true
			});
			Main.panel._leftCorner.actor.show();
			Main.panel._rightCorner.actor.show();
			Main.panel.actor.show();
		}
	},

	setSignals: function() {
		//Reinit Extension on Param Change
		this.settingSignals = [
			this.settings.connect("changed::panel-size", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::panel-size-bottom", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tb-icon-size", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tb-icon-size-bottom", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tb-label-size", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tb-label-size-bottom", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::content-size", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::font-size-bottom", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::panel-box", Lang.bind(this, this.onBoxChanged)),
			this.settings.connect("changed::panel-position", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-favorites", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-showapps-button", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-workspace-button", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::workspace-button-index", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::workspace-button-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-workspace-button-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::workspace-button-width", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-desktop-button", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::overview", Lang.bind(this, this.setOverview)),
			this.settings.connect("changed::tray-button", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tray-button-empty", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::desktop-button-icon", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::appview-button-icon", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tray-button-icon", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::sort-tasks", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::active-task-frame", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::inactive-task-frame", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::active-task-background-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::active-task-background-color-set", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::inactive-task-background-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::inactive-task-background-color-set", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tasks-label", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tasks-label-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-tasks-label-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::inactive-tasks-label-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-inactive-tasks-label-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tasks-frame-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-tasks-frame-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::inactive-tasks-frame-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-inactive-tasks-frame-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tasks-width", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tasks-spaces", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::blink-tasks", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::blacklist-set", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::top-panel-background-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::top-panel-background-alpha", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::bottom-panel-background-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-tasks", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-left-box-main", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-right-box-main", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-left-tasks", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-right-tasks", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-left-desktop", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-right-desktop", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-left-workspaces", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-right-workspaces", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-left-appview", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-right-appview", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-left-favorites", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::separator-right-favorites", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::top-panel", Lang.bind(this, this.displayTopPanel)),
			this.settings.connect("changed::activities-button", Lang.bind(this, this.displayActivities)),
			this.settings.connect("changed::activities-button-color", Lang.bind(this, this.colorActivities)),
			this.settings.connect("changed::hot-corner", Lang.bind(this, this.enableHotCorner)),
			this.settings.connect("changed::application-menu", Lang.bind(this, this.displayApplicationMenu)),
			this.settings.connect("changed::application-menu-color", Lang.bind(this, this.colorApplicationMenu)),
			this.settings.connect("changed::date-menu", Lang.bind(this, this.displayDateMenu)),
			this.settings.connect("changed::date-menu-color", Lang.bind(this, this.colorDateMenu)),
			this.settings.connect("changed::system-menu", Lang.bind(this, this.displaySystemMenu)),
			this.settings.connect("changed::system-menu-color", Lang.bind(this, this.colorSystemMenu)),
			this.settings.connect("changed::dash", Lang.bind(this, this.displayDash)),
			this.settings.connect("changed::workspace-selector", Lang.bind(this, this.displayWorkspaceSelector)),
			this.settings.connect("changed::position-changed", Lang.bind(this, this.appearancePositionChange)),
			this.settings.connect("changed::bottom-panel", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::bottom-panel-vertical", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::position-bottom-box", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tasks-all-workspaces", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::tasks-container-width-new", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::hover-event", Lang.bind(this, this.hoverEvent)),
			this.settings.connect("changed::blacklist", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::find-apps", Lang.bind(this, this.findApps)),
			this.settings.connect("changed::display-preview-background-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::display-preview-label-color", Lang.bind(this, this.onParamChanged)),
			this.settings.connect("changed::export-settings", Lang.bind(this, this.exportSettings)),
			this.settings.connect("changed::import-settings", Lang.bind(this, this.importSettings)),
			this.settings.connect("changed::reset-all", Lang.bind(this, this.resetAll)),
			this.settings.connect("changed::reset-flag", Lang.bind(this, this.onParamChanged))
		];
	},

	//Monitor Change, Icon and Global Theme Change
	setSystemSignals: function() {
		this.monitorChangedId = null;
		this.iconThemeChangedId = null;
		this.globalThemeChangedId = null;
		this.windowDemandsAttentionId = null;
		this.screenShieldLockId = null;
		this.panelStyleChangedId = null;
		this.mainBox = null;
		this.overviewHidingId = null;
		this.overviewShowingId = null;
		this.monitorChangedId = Main.layoutManager.connect('monitors-changed', Lang.bind(this, this.onParamChanged));
		this.iconThemeChangedId = St.TextureCache.get_default().connect('icon-theme-changed', Lang.bind(this, this.onParamChanged));
		this.globalThemeChangedId = St.ThemeContext.get_for_stage(global.stage).connect('changed', Lang.bind(this, this.onParamChanged));
		if ((this.settings.get_boolean("display-tasks")) && (this.settings.get_boolean("blink-tasks")))
			this.windowDemandsAttentionId = global.display.connect('window-demands-attention', Lang.bind(this, this.onWindowDemandsAttention));
		//        if (Main.screenShield !== null)
		//            this.screenShieldLockId = Main.screenShield.connect('lock-status-changed', Lang.bind(this, this.onParamChanged));
		this.setOverview();
	},

	//TaskBar in Overview Mode
	setOverview: function() {
		if (!this.settings.get_boolean("overview")) {
			this.mainBox = this.boxMain;
			this.overviewHidingId = Main.overview.connect('hiding', Lang.bind(this, this.showMainBox));
			this.overviewShowingId = Main.overview.connect('showing', Lang.bind(this, this.hideMainBox));
		} else {
			//Disconnect Overview Signals
			if (this.overviewHidingId !== null) {
				Main.overview.disconnect(this.overviewHidingId);
				this.overviewHidingId = null;
			}
			if (this.overviewShowingId !== null) {
				Main.overview.disconnect(this.overviewShowingId);
				this.overviewShowingId = null;
			}
		}
	},

	//First Start
	firstStart: function() {
		if ((this.settings.get_string("extension-path") === 'unset') || (this.settings.get_string("extension-path") !== Extension.path)) {
			this.settings.set_string("extension-path", Extension.path);
			this.settings.set_string("desktop-button-icon", DESKTOPICON);
			this.settings.set_string("appview-button-icon", APPVIEWICON);
			this.settings.set_string("tray-button-icon", BPTRAYICON);
		}
		if ((this.settings.get_boolean("first-start")) && (Main.sessionMode.currentMode === 'user')) {
			//Comment out the next line to disable the preferences window from opening at the first start
			Main.Util.trySpawnCommandLine('gnome-shell-extension-prefs ' + Extension.metadata.uuid);
			this.settings.set_boolean("first-start", false);
		}
	},

	//Verify other Extensions
	otherExtensions: function() {
		//Find out if the bottom panel extension is enabled
		this.tbp = false;
		let schemaSettings = new Gio.Settings({
			schema: 'org.gnome.shell'
		});
		let enabled_extensions = schemaSettings.get_strv('enabled-extensions');
		if (enabled_extensions.indexOf("bottompanel@tmoer93") !== -1)
			this.tbp = true;
	},

	//Add TaskBar
	addTaskBar: function() {
		this.setTaskBar = false;
		if ((this.settings.get_boolean("display-tasks")) ||
			(this.settings.get_boolean("display-desktop-button")) ||
			(this.settings.get_boolean("display-workspace-button")) ||
			(this.settings.get_boolean("display-showapps-button")) ||
			(this.settings.get_boolean("display-favorites"))) {
			this.setTaskBar = true;
			this.boxMain = new St.BoxLayout({
				style_class: "tkb-box"
			});
			if (this.settings.get_boolean("display-favorites"))
				this.boxMainFavorites = new St.BoxLayout({
					style_class: "tkb-box"
				});
			if (this.settings.get_boolean("display-showapps-button"))
				this.boxMainShowAppsButton = new St.BoxLayout({
					style_class: "tkb-box"
				});
			if (this.settings.get_boolean("display-workspace-button"))
				this.boxMainWorkspaceButton = new St.BoxLayout({
					style_class: "tkb-box"
				});
			if (this.settings.get_boolean("display-desktop-button"))
				this.boxMainDesktopButton = new St.BoxLayout({
					style_class: "tkb-box"
				});
			if (this.settings.get_boolean("display-tasks")) {
				this.boxMainTasks = new St.BoxLayout({
					style_class: "tkb-box",
					reactive: true
				});
				this.tasksContainerWidth = this.settings.get_int("tasks-container-width-new");
				this.boxMainTasksId = this.boxMainTasks.connect("scroll-event", Lang.bind(this, this.onScrollTaskButton));
			}
			if ((this.settings.get_enum("tray-button") !== 0) && (this.settings.get_boolean("bottom-panel")) && (ShellVersion[1] <= 14))
				this.boxBottomPanelTrayButton = new St.BoxLayout({
					style_class: "tkb-box"
				});
		}
	},

	//Add Separators
	addSeparators: function() {
		if (this.setTaskBar) {
			let separatorLeftBoxMain = this.settings.get_int('separator-left-box-main');
			let separatorRightBoxMain = this.settings.get_int('separator-right-box-main');
			this.separatorBoxMain = 'padding-left: ' + separatorLeftBoxMain + 'px; padding-right: ' + separatorRightBoxMain + 'px; ';
			this.boxMain.set_style(this.separatorBoxMain);
			if (this.settings.get_boolean("display-favorites")) {
				let separatorLeftFavorites = this.settings.get_int('separator-left-favorites');
				let separatorRightFavorites = this.settings.get_int('separator-right-favorites');
				this.separatorFavorites = 'padding-left: ' + separatorLeftFavorites + 'px; padding-right: ' + separatorRightFavorites + 'px; ';
				this.boxMainFavorites.set_style(this.separatorFavorites);
			}
			if (this.settings.get_boolean("display-showapps-button")) {
				let separatorLeftAppview = this.settings.get_int('separator-left-appview');
				let separatorRightAppview = this.settings.get_int('separator-right-appview');
				this.separatorAppview = 'padding-left: ' + separatorLeftAppview + 'px; padding-right: ' + separatorRightAppview + 'px; ';
				this.boxMainShowAppsButton.set_style(this.separatorAppview);
			}
			if (this.settings.get_boolean("display-workspace-button")) {
				let separatorLeftWorkspaces = this.settings.get_int('separator-left-workspaces');
				let separatorRightWorkspaces = this.settings.get_int('separator-right-workspaces');
				this.separatorWorkspaces = 'padding-left: ' + separatorLeftWorkspaces + 'px; padding-right: ' + separatorRightWorkspaces + 'px; ';
				this.boxMainWorkspaceButton.set_style(this.separatorWorkspaces);
			}
			if (this.settings.get_boolean("display-desktop-button")) {
				let separatorLeftDesktop = this.settings.get_int('separator-left-desktop');
				let separatorRightDesktop = this.settings.get_int('separator-right-desktop');
				this.separatorDesktop = 'padding-left: ' + separatorLeftDesktop + 'px; padding-right: ' + separatorRightDesktop + 'px; ';
				this.boxMainDesktopButton.set_style(this.separatorDesktop);
			}
			if (this.settings.get_boolean("display-tasks")) {
				let separatorLeftTasks = this.settings.get_int('separator-left-tasks');
				let separatorRightTasks = this.settings.get_int('separator-right-tasks');
				this.separatorTasks = 'padding-left: ' + separatorLeftTasks + 'px; padding-right: ' + separatorRightTasks + 'px; ';
				this.boxMainTasks.set_style(this.separatorTasks);
			}
		}
	},

	//Export Settings
	exportSettings: function() {
		if (this.settings.get_boolean("export-settings")) {
			Main.Util.trySpawnCommandLine('sh ' + Extension.path + '/scripts/export.sh');
			this.settings.set_boolean("export-settings", false);
		}
	},

	//Import Settings
	importSettings: function() {
		if (this.settings.get_boolean("import-settings")) {
			Main.Util.trySpawnCommandLine('sh ' + Extension.path + '/scripts/import.sh');
			this.settings.set_boolean("import-settings", false);
		}
	},

	//Reset All !
	resetAll: function() {
		if (this.settings.get_boolean("reset-all")) {
			Main.Util.trySpawnCommandLine('dconf reset -f /org/gnome/shell/extensions/TaskBar/');
		}
	},

	//Find Apps
	findApps: function() {
		if (this.settings.get_boolean("find-apps")) {
			Main.overview.show();
			Main.overview.viewSelector._showAppsButton.checked = true;
			this.settings.set_boolean("find-apps", false);
		}
	},

	//Keybindings
	keybindings: function() {
		if (Main.wm.addKeybinding && Shell.ActionMode) //3.16
			Main.wm.addKeybinding(PREVIOUSKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Shell.ActionMode.NORMAL,
				Lang.bind(this, this.keyPreviousTask));
		else if (Main.wm.addKeybinding && Shell.KeyBindingMode) //3.8
			Main.wm.addKeybinding(PREVIOUSKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
				Lang.bind(this, this.keyPreviousTask));
		else
			global.display.add_keybinding(PREVIOUSKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Lang.bind(this, this.keyPreviousTask));
		if (Main.wm.addKeybinding && Shell.ActionMode) //3.16
			Main.wm.addKeybinding(NEXTKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Shell.ActionMode.NORMAL,
				Lang.bind(this, this.keyNextTask));
		else if (Main.wm.addKeybinding && Shell.KeyBindingMode) //3.8
			Main.wm.addKeybinding(NEXTKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
				Lang.bind(this, this.keyNextTask));
		else
			global.display.add_keybinding(NEXTKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Lang.bind(this, this.keyNextTask));
		if (Main.wm.addKeybinding && Shell.ActionMode) //3.16
			Main.wm.addKeybinding(DESKTOPKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Shell.ActionMode.NORMAL,
				Lang.bind(this, this.keyToggleDesktop));
		else if (Main.wm.addKeybinding && Shell.KeyBindingMode) //3.8
			Main.wm.addKeybinding(DESKTOPKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
				Lang.bind(this, this.keyToggleDesktop));
		else
			global.display.add_keybinding(DESKTOPKEY, this.settings, Meta.KeyBindingFlags.NONE,
				Lang.bind(this, this.keyToggleDesktop));
	},

	//Keybinding Activate Previous Task
	keyPreviousTask: function() {
		this.previousTask = null;
		let focusWindow = global.display.focus_window;
		let activeWorkspace = global.screen.get_active_workspace();
		this.tasksList.forEach(
			function(task) {
				let [windowTask, buttonTask, signalsTask] = task;
				if ((windowTask === focusWindow) && (this.previousTask !== null)) {
					let [windowTask, buttonTask, signalsTask] = this.previousTask;
					let windowWorkspace = windowTask.get_workspace();
					if (windowWorkspace !== activeWorkspace)
						windowWorkspace.activate(global.get_current_time());
					windowTask.activate(global.get_current_time());
				}
				this.previousTask = task;
			},
			this
		);
		if (Main.overview.visible)
			Main.overview.hide();
	},

	//Keybinding Activate Next Task
	keyNextTask: function() {
		this.nextTask = false;
		let focusWindow = global.display.focus_window;
		let activeWorkspace = global.screen.get_active_workspace();
		this.tasksList.forEach(
			function(task) {
				let [windowTask, buttonTask, signalsTask] = task;
				let windowWorkspace = windowTask.get_workspace();
				if (this.nextTask) {
					if (windowWorkspace !== activeWorkspace)
						windowWorkspace.activate(global.get_current_time());
					windowTask.activate(global.get_current_time());
					this.nextTask = false;
				}
				if (windowTask === focusWindow)
					this.nextTask = true;
			},
			this
		);
		if (Main.overview.visible)
			Main.overview.hide();
	},

	//Keybinding Toggle Desktop
	keyToggleDesktop: function() {
		let maxWindows = false;
		let userTime = null;
		let activeWorkspace = global.screen.get_active_workspace();
		let windows = activeWorkspace.list_windows().filter(function(w) {
			return w.get_window_type() !== Meta.WindowType.DESKTOP;
		});
		for (let i = 0; i < windows.length; ++i) {
			if ((this.desktopView) && (!Main.overview.visible)) {
				userTime = windows[i].user_time;
				if (userTime > this.lastFocusedWindowUserTime) {
					this.lastFocusedWindowUserTime = userTime;
					this.lastFocusedWindow = windows[i];
				}
				windows[i].unminimize();
				maxWindows = true;
			} else {
				windows[i].minimize();
			}
		}
		if (maxWindows) {
			this.lastFocusedWindow.activate(global.get_current_time());
		}
		this.desktopView = !this.desktopView;
		if (Main.overview.visible)
			Main.overview.hide();
	},

	//Align Position
	onPositionChanged: function() {
		this.showTray = null;
		this.messageTrayShowingId = null;
		this.messageTrayHidingId = null;
		this.setAnchorPoint = false;
		this.bottomPanelEndIndicator = false;
		if (this.setTaskBar) {
			if (this.settings.get_boolean("bottom-panel"))
				this.bottomPanel();
			else {
				this.defineBoxChanged();
				this.panelPosition = this.settings.get_int('panel-position');
				if (this.panelPosition > this.pbchildren)
					this.settings.set_int("panel-position", this.pbchildren);
				this.newBox.insert_child_at_index(this.boxMain, this.panelPosition);
			}
		}
	},

	defineBoxChanged: function() {
		this.panelBox = this.settings.get_int('panel-box');
		if (this.panelBox === 1)
			this.newBox = Main.panel._leftBox;
		else if (this.panelBox === 2)
			this.newBox = Main.panel._centerBox;
		else if (this.panelBox === 3)
			this.newBox = Main.panel._rightBox;
		this.pbchildren = this.newBox.get_children().length;
		let positionMaxRight = this.settings.get_int("position-max-right");
		if (positionMaxRight !== this.pbchildren)
			this.settings.set_int("position-max-right", this.pbchildren);
	},

	onBoxChanged: function() {
		this.newBox.remove_child(this.boxMain);
		this.defineBoxChanged();
	},

	appearanceOrder: function() {
		if (this.setTaskBar) {
			this.appearances = [
				("position-tasks"),
				("position-desktop-button"),
				("position-workspace-button"),
				("position-appview-button"),
				("position-favorites")
			];
			for (let i = 0; i <= 4; i++) {
				this.appearances.forEach(
					function(appearance) {
						let positionAppearance = this.settings.get_int(appearance);
						if (positionAppearance === i) {
							if ((appearance === "position-tasks") && (this.settings.get_boolean("display-tasks")))
								this.boxMain.add_actor(this.boxMainTasks);
							else if ((appearance === "position-desktop-button") && (this.settings.get_boolean("display-desktop-button")))
								this.boxMain.add_actor(this.boxMainDesktopButton);
							else if ((appearance === "position-workspace-button") && (this.settings.get_boolean("display-workspace-button")))
								this.boxMain.add_actor(this.boxMainWorkspaceButton);
							else if ((appearance === "position-appview-button") && (this.settings.get_boolean("display-showapps-button")))
								this.boxMain.add_actor(this.boxMainShowAppsButton);
							else if ((appearance === "position-favorites") && (this.settings.get_boolean("display-favorites")))
								this.boxMain.add_actor(this.boxMainFavorites);
						}
					},
					this
				);
			}
			if ((this.settings.get_enum("tray-button") !== 0) && (this.bottomPanelEndIndicator) && (ShellVersion[1] <= 14))
				this.boxMain.add_actor(this.boxBottomPanelTrayButton);
		}
	},

	//Appearance Position changed
	appearancePositionChange: function() {
		if (this.settings.get_boolean("position-changed")) {
			this.settings.set_boolean("position-changed", false);
			this.onParamChanged();
		}
	},

	//Hide TaskBar in Overview
	showMainBox: function() {
		this.mainBox.show();
		if ((this.settings.get_enum("tray-button") !== 0) && (!this.bottomPanelEndIndicator) && (this.settings.get_boolean("bottom-panel")) && (ShellVersion[1] <= 14))
			this.boxBottomPanelTrayButton.show();
	},

	hideMainBox: function() {
		this.mainBox.hide();
		if ((this.settings.get_enum("tray-button") !== 0) && (!this.bottomPanelEndIndicator) && (this.settings.get_boolean("bottom-panel")) && (ShellVersion[1] <= 14))
			this.boxBottomPanelTrayButton.hide();
	},

	//Add Favorites
	addFavorites: function(buttonfavorite, favoriteapp) {
		this.installedChangedId = null;
		this.changedId = null;
		if (this.settings.get_boolean("display-favorites")) {
			//Connect Favorites Changes
			this.installedChangedId = Shell.AppSystem.get_default().connect('installed-changed', Lang.bind(this, this.onParamChanged));
			this.changedId = AppFavorites.getAppFavorites().connect('changed', Lang.bind(this, this.onParamChanged));

			let favorites = global.settings.get_strv(AppFavorites.getAppFavorites().FAVORITE_APPS_KEY);
			for (let i = 0; i < favorites.length; ++i) {
				let favoriteapp = Shell.AppSystem.get_default().lookup_app(favorites[i]);
				if (favoriteapp === null) {
					continue;
				}
				let buttonfavorite = new St.Button({
					style_class: "tkb-task-button",
					child: favoriteapp.create_icon_texture(this.panelSize)
				});
				buttonfavorite.connect('clicked', Lang.bind(this, function() {
					favoriteapp.open_new_window(-1);
				}, favoriteapp));
				buttonfavorite.connect("enter-event", Lang.bind(this, function() {
					//Hide current preview if necessary
					this.hidePreview();
					if (this.settings.get_enum("display-favorites-label") !== 0) {
						if (this.settings.get_int("preview-delay") === 0)
							this.showFavoritesPreview(buttonfavorite, favoriteapp);
						else
							this.previewTimer = Mainloop.timeout_add(this.settings.get_int("preview-delay"),
								Lang.bind(this, this.showFavoritesPreview, buttonfavorite, favoriteapp));
					}
				}, buttonfavorite, favoriteapp));
				buttonfavorite.connect("leave-event", Lang.bind(this, this.hidePreview));
				this.boxMainFavorites.add_actor(buttonfavorite);
			}
		}
	},

	//Add Appview Button
	addShowAppsButton: function() {
		if (this.settings.get_boolean("display-showapps-button")) {
			let iconPath = this.settings.get_string("appview-button-icon");
			if (iconPath === 'unset')
				iconPath = APPVIEWICON;
			this.showAppsIcon = Gio.icon_new_for_string(iconPath);
			this.iconShowApps = new St.Icon({
				gicon: this.showAppsIcon,
				icon_size: (this.panelSize),
				style_class: "tkb-desktop-icon"
			});
			this.buttonShowApps = new St.Button({
				style_class: "tkb-task-button"
			});
			this.signalShowApps = this.buttonShowApps.connect("button-press-event", Lang.bind(this, this.onClickShowAppsButton));
			this.buttonShowApps.set_child(this.iconShowApps);
			this.boxShowApps = new St.BoxLayout({
				style_class: "tkb-desktop-box"
			});
			this.boxShowApps.add_actor(this.buttonShowApps);
			this.boxMainShowAppsButton.add_actor(this.boxShowApps);
		}
	},

	//Add Workspace Button
	addWorkspaceButton: function() {
		this.workspaceSwitchedId = null;
		this.nWorkspacesId = null;
		if (this.settings.get_boolean("display-workspace-button")) {
			//Connect Workspace Changes
			this.workspaceSwitchedId = global.screen.connect('workspace-switched', Lang.bind(this, this.updateWorkspaces));
			this.nWorkspacesId = global.screen.connect('notify::n-workspaces', Lang.bind(this, this.updateWorkspaces));
			this.buttonWorkspace = new St.Button({
				style_class: "tkb-task-button"
			});
			this.buttonWorkspace.connect("button-press-event", Lang.bind(this, this.onClickWorkspaceButton));
			this.buttonWorkspace.connect("scroll-event", Lang.bind(this, this.onScrollWorkspaceButton));
			this.workspaceButtonColor = this.settings.get_string("workspace-button-color");
			this.displayWorkspaceButtonColor = this.settings.get_boolean("display-workspace-button-color");
			if ((this.workspaceButtonColor !== "unset") && (this.displayWorkspaceButtonColor)) {
				this.workspaceButtonStyle = "color: " + this.workspaceButtonColor + ";";
				this.buttonWorkspace.set_style(this.workspaceButtonStyle);
			}
			this.updateWorkspaces();
			this.boxWorkspace = new St.BoxLayout({
				style_class: "tkb-desktop-box"
			});
			this.boxWorkspace.add_actor(this.buttonWorkspace);
			this.boxMainWorkspaceButton.add_actor(this.boxWorkspace);
		}
	},

	updateWorkspaces: function() {
		this.activeWorkspaceIndex = global.screen.get_active_workspace().index();
		let workspaceButtonWidth = this.settings.get_int("workspace-button-width");
		this.totalWorkspace = global.screen.n_workspaces - 1;
		let labelWorkspaceIndex = this.activeWorkspaceIndex + 1;
		let labelTotalWorkspace = this.totalWorkspace + 1;
		if (this.settings.get_enum("workspace-button-index") === 1) {
			this.labelWorkspace = new St.Label({
				text: (labelWorkspaceIndex + "/" + labelTotalWorkspace)
			});
			this.labelWorkspace.set_width((this.panelSize * 2) + 2 + this.adjustTBLabelSize - this.adjustTBIconSize + workspaceButtonWidth);
		} else if (this.settings.get_enum("workspace-button-index") === 0) {
			this.labelWorkspace = new St.Label({
				text: (labelWorkspaceIndex + "")
			});
			this.labelWorkspace.set_width(this.panelSize - 2 + this.adjustTBLabelSize - this.adjustTBIconSize + workspaceButtonWidth);
		}
		this.labelWorkspace.style = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px' + '; text-align: center;';
		this.buttonWorkspace.set_child(this.labelWorkspace);
	},

	//Add Desktop Button
	addDesktopButton: function() {
		if (this.settings.get_boolean("display-desktop-button")) {
			let iconPath = this.settings.get_string("desktop-button-icon");
			if (iconPath === 'unset')
				iconPath = DESKTOPICON;
			this.desktopButtonIcon = Gio.icon_new_for_string(iconPath);
			let iconDesktop = new St.Icon({
				gicon: this.desktopButtonIcon,
				icon_size: (this.panelSize),
				style_class: "tkb-desktop-icon"
			});
			let buttonDesktop = new St.Button({
				style_class: "tkb-task-button"
			});
			let signalDesktop = buttonDesktop.connect("button-press-event", Lang.bind(this, this.onClickDesktopButton));
			buttonDesktop.set_child(iconDesktop);
			let boxDesktop = new St.BoxLayout({
				style_class: "tkb-desktop-box"
			});
			boxDesktop.add_actor(buttonDesktop);
			this.boxMainDesktopButton.add_actor(boxDesktop);
		}
	},

	//Add Tray Button
	addTrayButton: function() {
		this.messageTrayCountAddedId = null;
		this.messageTrayCountRemovedId = null;
		if ((this.settings.get_boolean("bottom-panel")) && (this.settings.get_enum("tray-button") !== 0) && (ShellVersion[1] <= 14)) {
			this.buttonTray = new St.Button({
				style_class: "tkb-task-button"
			});
			this.signalTray = [
				this.buttonTray.connect("button-press-event", Lang.bind(this, this.onClickTrayButton)),
				this.buttonTray.connect("enter-event", Lang.bind(this, this.onHoverTrayButton))
			];
			if ((this.settings.get_enum("tray-button") === 1) && (this.settings.get_enum("tray-button-empty") === 0))
				this.messageTrayIcon();
			else {
				this.messageTrayCountAddedId = Main.messageTray.connect('source-added', Lang.bind(this, this.messageTrayCount));
				this.messageTrayCountRemovedId = Main.messageTray.connect('source-removed', Lang.bind(this, this.messageTrayCount));
				this.messageTrayCount();
			}
		}
	},

	messageTrayCount: function() {
		let indicatorCount = 0;
		indicatorCount = Main.messageTray.getSources().length;
		if (((indicatorCount === 0) && (this.settings.get_enum("tray-button-empty") === 0)) ||
			((indicatorCount !== 0) && (this.settings.get_enum("tray-button-empty") === 1) && (this.settings.get_enum("tray-button") !== 2)) ||
			((indicatorCount !== 0) && (this.settings.get_enum("tray-button") === 1)))
			this.messageTrayIcon();
		else {
			if ((indicatorCount === 0) && (this.settings.get_enum("tray-button-empty") === 2))
				this.labelTray = new St.Label();
			else
				this.labelTray = new St.Label({
					text: (indicatorCount + '')
				});
			this.buttonTray.set_child(this.labelTray);
			this.boxTray = new St.BoxLayout({
				style_class: "tkb-desktop-box"
			});
			this.boxTray.add_actor(this.buttonTray);
			this.boxBottomPanelTrayButton.add_actor(this.boxTray);
		}
	},

	messageTrayIcon: function() {
		let iconPath = this.settings.get_string("tray-button-icon");
		if (iconPath === 'unset')
			iconPath = BPTRAYICON;
		this.trayIcon = Gio.icon_new_for_string(iconPath);
		this.iconTray = new St.Icon({
			gicon: this.trayIcon,
			icon_size: (this.panelSize),
			style_class: "tkb-desktop-icon"
		});
		this.buttonTray.set_child(this.iconTray);
		this.boxTray = new St.BoxLayout({
			style_class: "tkb-desktop-box"
		});
		this.boxTray.add_actor(this.buttonTray);
		this.boxBottomPanelTrayButton.add_actor(this.boxTray);
	},

	//Activities Button
	displayActivities: function() {
		this.initDisplayActivitiesButton();
		if (this.settings.get_boolean("activities-button"))
			this.activitiesContainer.show();
	},

	initDisplayActivitiesButton: function() {
		if (!this.settings.get_boolean("activities-button")) {
			this.activitiesContainer = Main.panel.statusArea.activities.container;
			this.activitiesContainer.hide();
		}
		this.activitiesColor = this.settings.get_string("activities-button-color");
		if (this.activitiesColor !== "unset")
			this.colorActivities();
	},

	colorActivities: function() {
		this.activitiesColor = this.settings.get_string("activities-button-color");
		if (this.activitiesColor !== "unset") {
			this.activitiesStyle = "color: " + this.activitiesColor + ";";
			Main.panel.statusArea.activities.actor.set_style(this.activitiesStyle);
		} else
			Main.panel.statusArea.activities.actor.set_style("None");
	},

	//Top Panel
	displayTopPanel: function() {
		this.initDisplayTopPanel();
		if (this.settings.get_boolean("top-panel")) {
			Main.layoutManager.removeChrome(Main.layoutManager.panelBox);
			Main.layoutManager.addChrome(Main.layoutManager.panelBox, {
				affectsStruts: true
			});
			Main.panel.actor.show();
			Main.panel._leftCorner.actor.show();
			Main.panel._rightCorner.actor.show();
			this.onParamChanged();
		}
	},

	initDisplayTopPanel: function() {
		if (!this.settings.get_boolean("top-panel")) {
			Main.layoutManager.removeChrome(Main.layoutManager.panelBox);
			Main.layoutManager.addChrome(Main.layoutManager.panelBox, {
				affectsStruts: false
			});
			Main.panel.actor.hide();
			Main.panel._leftCorner.actor.hide();
			Main.panel._rightCorner.actor.hide();
		}
	},

	//Hot Corner
	enableHotCorner: function() {
        if (ShellVersion[1] < 26) {
		    this.initEnableHotCorner();
		    if (this.settings.get_boolean("hot-corner")) {
			    Main.layoutManager._updateHotCorners();
		    }
        }
	},

	initEnableHotCorner: function() {
		if ((!this.settings.get_boolean("hot-corner")) && (ShellVersion[1] < 26)) {
			Main.layoutManager.hotCorners[Main.layoutManager.primaryIndex]._toggleOverview = function() {};
			Main.layoutManager.hotCorners[Main.layoutManager.primaryIndex]._pressureBarrier._trigger = function() {};
		}
	},

	//Application Menu
	displayApplicationMenu: function() {
		this.initDisplayApplicationMenu();
		if (this.settings.get_boolean("application-menu")) {
			let variant = GLib.Variant.new('a{sv}', {
				'Gtk/ShellShowsAppMenu': GLib.Variant.new('i', 1)
			});
			let xsettings = new Gio.Settings({
				schema: 'org.gnome.settings-daemon.plugins.xsettings'
			});
			xsettings.set_value('overrides', variant);
			this.appMenuContainer.show();
			Shell.WindowTracker.get_default().disconnect(this.hidingId2);
			Main.overview.disconnect(this.hidingId);
		}
	},

	initDisplayApplicationMenu: function() {
		this.appMenuContainer = Main.panel.statusArea.appMenu.container;
		if (!this.settings.get_boolean("application-menu")) {
			this.appMenuContainer.hide();
			this.hidingId = Main.overview.connect('hiding', function() {
				Main.panel.statusArea.appMenu.container.hide();
			});
			this.hidingId2 = Shell.WindowTracker.get_default().connect('notify::focus-app', function() {
				Main.panel.statusArea.appMenu.container.hide();
			});
		}
		this.appMenuColor = this.settings.get_string("application-menu-color");
		if (this.appMenuColor !== "unset")
			this.colorApplicationMenu();
	},

	colorApplicationMenu: function() {
		this.appMenuColor = this.settings.get_string("application-menu-color");
		if (this.appMenuColor !== "unset") {
			this.appMenuStyle = "color: " + this.appMenuColor + ";";
			Main.panel.statusArea.appMenu.actor.set_style(this.appMenuStyle);
		} else
			Main.panel.statusArea.appMenu.actor.set_style("None");
	},


	//Date Menu
	displayDateMenu: function() {
		this.initDisplayDateMenu();
		if (this.settings.get_boolean("date-menu"))
			this.dateMenuContainer.show();
	},

	initDisplayDateMenu: function() {
		if (!this.settings.get_boolean("date-menu")) {
			this.dateMenuContainer = Main.panel.statusArea.dateMenu.container;
			this.dateMenuContainer.hide();
		}
		this.dateMenuColor = this.settings.get_string("date-menu-color");
		if (this.dateMenuColor !== "unset")
			this.colorDateMenu();
	},

	colorDateMenu: function() {
		this.dateMenuColor = this.settings.get_string("date-menu-color");
		if (this.dateMenuColor !== "unset") {
			this.dateMenuStyle = "color: " + this.dateMenuColor + ";";
			Main.panel.statusArea.dateMenu.actor.set_style(this.dateMenuStyle);
		} else
			Main.panel.statusArea.dateMenu.actor.set_style("None");
	},

	//System Menu
	displaySystemMenu: function() {
		this.initDisplaySystemMenu();
		if (this.settings.get_boolean("system-menu"))
			this.systemMenuContainer.show();
	},

	initDisplaySystemMenu: function() {
		if (!this.settings.get_boolean("system-menu")) {
			this.systemMenuContainer = Main.panel.statusArea.aggregateMenu.container;
			this.systemMenuContainer.hide();
		}
		this.systemMenuColor = this.settings.get_string("system-menu-color");
		if (this.systemMenuColor !== "unset")
			this.colorSystemMenu();
	},

	colorSystemMenu: function() {
		this.systemMenuColor = this.settings.get_string("system-menu-color");
		if (this.systemMenuColor !== "unset") {
			this.systemMenuStyle = "color: " + this.systemMenuColor + ";";
			Main.panel.statusArea.aggregateMenu.actor.set_style(this.systemMenuStyle);
		} else
			Main.panel.statusArea.aggregateMenu.actor.set_style("None");
	},

	//Dash
	displayDash: function() {
		this.initDisplayDash();
		if (this.settings.get_boolean("dash")) {
			this.dash.set_height(this.dashHeight);
			this.dash.set_width(this.dashWidth);
		}
	},

	initDisplayDash: function() {
		if (!this.settings.get_boolean("dash")) {
			this.dash = Main.overview._dash.actor;
			this.dashHeight = this.dash.get_height();
			this.dashWidth = this.dash.get_width();
			this.dash.set_height(0);
			this.dash.set_width(0);
		}
	},

	//Workspace Selector
	displayWorkspaceSelector: function() {
		this.initDisplayWorkspaceSelector();
		if (this.settings.get_boolean("workspace-selector")) {
			ThumbnailsSlider._getAlwaysZoomOut = this.alwaysZoomOut;
			ThumbnailsSlider.getNonExpandedWidth = this.nonExpandedWidth;
		}
	},

	initDisplayWorkspaceSelector: function() {
		if (!this.settings.get_boolean("workspace-selector")) {
			this.alwaysZoomOut = ThumbnailsSlider._getAlwaysZoomOut;
			this.nonExpandedWidth = ThumbnailsSlider.getNonExpandedWidth;
			ThumbnailsSlider._getAlwaysZoomOut = function() {
				return false;
			}
			ThumbnailsSlider.getNonExpandedWidth = function() {
				return 0;
			}
		}
	},


	//Preferences Hover Component Event
	hoverEvent: function() {
		this.hoverComponent = this.settings.get_int("hover-event");
		this.hoverStyle = "background-color: red; border-radius: 5px";
		if ((this.hoverComponent === 1) && (this.settings.get_boolean("display-tasks")))
			this.boxMainTasks.set_style(this.separatorTasks + this.hoverStyle);
		else if ((this.hoverComponent === 2) && (this.settings.get_boolean("display-desktop-button")))
			this.boxMainDesktopButton.set_style(this.separatorDesktop + this.hoverStyle);
		else if ((this.hoverComponent === 3) && (this.settings.get_boolean("display-workspace-button")))
			this.boxMainWorkspaceButton.set_style(this.separatorWorkspaces + this.hoverStyle);
		else if ((this.hoverComponent === 4) && (this.settings.get_boolean("display-showapps-button")))
			this.boxMainShowAppsButton.set_style(this.separatorAppview + this.hoverStyle);
		else if ((this.hoverComponent === 5) && (this.settings.get_boolean("display-favorites")))
			this.boxMainFavorites.set_style(this.separatorFavorites + this.hoverStyle);
		else if (this.hoverComponent === 0) {
			if (this.settings.get_boolean("display-tasks"))
				this.boxMainTasks.set_style(this.separatorTasks);
			if (this.settings.get_boolean("display-desktop-button"))
				this.boxMainDesktopButton.set_style(this.separatorDesktop);
			if (this.settings.get_boolean("display-workspace-button"))
				this.boxMainWorkspaceButton.set_style(this.separatorWorkspaces);
			if (this.settings.get_boolean("display-showapps-button"))
				this.boxMainShowAppsButton.set_style(this.separatorAppview);
			if (this.settings.get_boolean("display-favorites"))
				this.boxMainFavorites.set_style(this.separatorFavorites);
		}
	},

	//Active Task Frame / Background Color
	activeTaskFrame: function() {
		this.backgroundColor = this.settings.get_string("active-task-background-color");
		this.activeTasksFrameColor = this.settings.get_string("tasks-frame-color");
		this.margin = this.settings.get_int("tasks-spaces");
		this.backgroundStyleColor = "border-radius: 5px;";
		if (this.settings.get_boolean("active-task-background-color-set"))
			this.backgroundStyleColor += "background-color: " + this.backgroundColor + "; ";
		if ((this.settings.get_boolean("active-task-frame")) && (this.settings.get_boolean("display-tasks-frame-color")))
			this.backgroundStyleColor += "border: 1px " + this.activeTasksFrameColor + "; background-image: url('" + Extension.path + "/images/active-task-background.svg'); ";
		else if ((this.settings.get_boolean("active-task-frame")) && (!this.settings.get_boolean("display-tasks-frame-color")))
			this.backgroundStyleColor += "border: 1px solid gray; background-image: url('" + Extension.path + "/images/active-task-background.svg'); ";
		if (this.settings.get_int("tasks-spaces") !== 0)
			this.backgroundStyleColor += "margin-right: " + this.margin + "px;";
	},

	//Inactive Task Frame / Background Color
	inactiveTaskFrame: function() {
		this.inactiveBackgroundColor = this.settings.get_string("inactive-task-background-color");
		this.inactiveTasksFrameColor = this.settings.get_string("inactive-tasks-frame-color");
		this.inactiveMargin = this.settings.get_int("tasks-spaces");
		this.inactiveBackgroundStyleColor = "border-radius: 5px; ";
		if (this.settings.get_boolean("inactive-task-background-color-set"))
			this.inactiveBackgroundStyleColor += "background-color: " + this.inactiveBackgroundColor + "; ";
		if ((this.settings.get_boolean("inactive-task-frame")) && (this.settings.get_boolean("display-inactive-tasks-frame-color")))
			this.inactiveBackgroundStyleColor += "border: 1px " + this.inactiveTasksFrameColor + "; background-image: url('" + Extension.path + "/images/active-task-background.svg'); ";
		else if ((this.settings.get_boolean("inactive-task-frame")) && (!this.settings.get_boolean("display-inactive-tasks-frame-color")))
			this.inactiveBackgroundStyleColor += "border: 1px solid gray; background-image: url('" + Extension.path + "/images/active-task-background.svg'); ";
		if (this.settings.get_int("tasks-spaces") !== 0)
			this.inactiveBackgroundStyleColor += "margin-right: " + this.inactiveMargin + "px;";
	},

	//Top Panel Background Color and (Font) Size
	changeTopPanelBackgroundColor: function() {
		this.panelSize = this.settings.get_int('panel-size');
		this.adjustTBIconSize = this.settings.get_int('tb-icon-size');
		this.adjustTBLabelSize = this.settings.get_int('tb-label-size');
		this.adjustContentSize = this.settings.get_int('content-size');
		this.panelSet = false;
		this.originalTopPanelStyle = Main.panel.actor.get_style();
		this.originalLeftPanelCornerStyle = Main.panel._leftCorner.actor.get_style();
		this.originalRightPanelCornerStyle = Main.panel._rightCorner.actor.get_style();
		//Get Native Panel Background Color
		let tpobc = Main.panel.actor.get_theme_node().get_background_color();
		let topPanelOriginalBackgroundColor = 'rgba(%d, %d, %d, %d)'.format(tpobc.red, tpobc.green, tpobc.blue, tpobc.alpha);
		this.settings.set_string("top-panel-original-background-color", topPanelOriginalBackgroundColor);
		this.bottomPanelBackgroundColor = this.settings.get_string("bottom-panel-background-color");
		if (this.bottomPanelBackgroundColor === 'unset') {
			this.settings.set_string("bottom-panel-original-background-color", topPanelOriginalBackgroundColor);
		}
		if ((this.panelSize !== 27) || (this.adjustContentSize !== 0)) {
			//Set Font Size
			this.panelLabelSize = (this.panelSize - 12 + this.adjustContentSize);
			this.fontSize = 'font-size: ' + this.panelLabelSize + 'px; height: ' + this.panelSize + 'px;';
			Main.panel.actor.set_style(this.fontSize);
			this.panelSet = true;
		}
		this.topPanelBackgroundColor = this.settings.get_string("top-panel-background-color");
		if (this.topPanelBackgroundColor !== 'unset') {
			this.topPanelBackgroundStyle = "background-color: " + this.topPanelBackgroundColor + ";";
			this.panelLabelSize = (this.panelSize - 12 + this.adjustContentSize);
			this.fontSize = 'font-size: ' + this.panelLabelSize + 'px; height: ' + this.panelSize + 'px;';
			Main.panel.actor.set_style(this.fontSize + ' ' + this.topPanelBackgroundStyle);
			if ((this.settings.get_boolean("top-panel-background-alpha")) && (ShellVersion[1] <= 16)) {
				Main.panel._leftCorner.actor.hide();
				Main.panel._rightCorner.actor.hide();
			} else {
				if (ShellVersion[1] <= 16) {
					Main.panel._leftCorner.actor.show();
					Main.panel._rightCorner.actor.show();
				}
				Main.panel._leftCorner.actor.set_style('-panel-corner-background-color: ' + this.topPanelBackgroundColor + ';');
				Main.panel._rightCorner.actor.set_style('-panel-corner-background-color: ' + this.topPanelBackgroundColor + ';');
			}
			this.panelSet = true;
		}
		this.panelSize = ((this.settings.get_int('panel-size')) - 6 + (this.settings.get_int('tb-icon-size')));
	},

	//Bottom Panel
	bottomPanel: function() {
		this.adjustTBIconSize = this.settings.get_int('tb-icon-size-bottom');
		this.adjustTBLabelSize = this.settings.get_int('tb-label-size-bottom');
		this.adjustContentSize = 0;
		let bottomPanelHeight = null;
		let newShowTray = null;
		this.panelSize = this.settings.get_int('panel-size-bottom');
		this.panelLabelSize = (this.panelSize - 12 + this.adjustTBLabelSize);
		this.fontSize = 'font-size: ' + this.panelLabelSize + 'px; height: ' + this.panelSize + 'px;';
		this.bottomPanelVertical = this.settings.get_int('bottom-panel-vertical');
		this.bottomPanelBackgroundColor = this.settings.get_string("bottom-panel-background-color");
		if (this.bottomPanelBackgroundColor === "unset")
			this.bottomPanelBackgroundColor = this.settings.get_string("bottom-panel-original-background-color");
		this.bottomPanelBackgroundStyle = "background-color: " + this.bottomPanelBackgroundColor + ";";
		this.bottomPanelActor = new St.BoxLayout({
			name: 'bottomPanel'
		});
		this.bottomPanelActor.set_style(this.fontSize + ' ' + this.bottomPanelBackgroundStyle);
		this.bottomPanelActor.set_reactive(false);
		this.positionBoxBottomStart = new St.Bin({
			x_fill: false,
			x_expand: true,
			x_align: St.Align.START
		});
		this.positionBoxBottomMiddle = new St.Bin({
			x_fill: false,
			x_expand: true,
			x_align: St.Align.MIDDLE
		});
		this.positionBoxBottomEnd = new St.Bin({
			x_fill: false,
			x_expand: true,
			x_align: St.Align.END
		});
		this.positionBoxBottomSettings = this.settings.get_int("position-bottom-box");
		if (this.positionBoxBottomSettings === 0)
			this.positionBoxBottomStart.add_actor(this.boxMain);
		else if (this.positionBoxBottomSettings === 1)
			this.positionBoxBottomMiddle.add_actor(this.boxMain);
		else if (this.positionBoxBottomSettings === 2) {
			this.positionBoxBottomEnd.add_actor(this.boxMain);
			this.bottomPanelEndIndicator = true;
		}
		if ((this.settings.get_enum("tray-button") !== 0) && (!this.bottomPanelEndIndicator) && (ShellVersion[1] <= 14))
			this.positionBoxBottomEnd.add_actor(this.boxBottomPanelTrayButton);
		Main.layoutManager.addChrome(this.bottomPanelActor, {
			affectsStruts: true,
			trackFullscreen: true
		});
		this.bottomPanelActor.add_actor(this.positionBoxBottomStart);
		this.bottomPanelActor.add_actor(this.positionBoxBottomMiddle);
		this.bottomPanelActor.add_actor(this.positionBoxBottomEnd);
		let primary = Main.layoutManager.primaryMonitor;
		this.height = (this.panelSize + this.bottomPanelVertical);
		this.bottomPanelActor.set_position(primary.x, primary.y + primary.height - this.height);
		this.bottomPanelActor.set_size(primary.width, -1);
		if (ShellVersion[1] <= 14) {
			Main.messageTray._notificationWidget.set_anchor_point(0, this.height);
			this.setAnchorPoint = true;
			this.messageTrayShowingId = Main.messageTray.connect('showing', Lang.bind(this, function() {
				Main.messageTray.actor.set_anchor_point(0, this.height);
				this.setAnchorPoint = true;
			}));
			this.messageTrayHidingId = Main.messageTray.connect('hiding', Lang.bind(this, function() {
				Main.messageTray.actor.set_anchor_point(0, 0);
				this.setAnchorPoint = true;
			}));
		}
		this.panelSize = ((this.settings.get_int('panel-size-bottom')) - 6 + (this.settings.get_int('tb-icon-size-bottom')));
	},

	//Click Events
	onClickShowAppsButton: function(button, pspec) {
		let numButton = pspec.get_button();
		this.leftbutton = LEFTBUTTON;
		this.rightbutton = RIGHTBUTTON;
		if (this.settings.get_enum("showapps-button-toggle") === 1) {
			this.leftbutton = RIGHTBUTTON;
			this.rightbutton = LEFTBUTTON;
		}
		if (numButton === this.leftbutton) //Left Button
		{
			if (!Main.overview.visible)
				Main.overview.show();
			if (!Main.overview.viewSelector._showAppsButton.checked)
				Main.overview.viewSelector._showAppsButton.checked = true;
			else
				Main.overview.hide();
		} else if (numButton === this.rightbutton) //Right Button
		{
			if (!Main.overview.visible)
				Main.overview.show();
			else if (Main.overview.viewSelector._showAppsButton.checked)
				Main.overview.viewSelector._showAppsButton.checked = false;
			else
				Main.overview.hide();
		}
	},

	onClickWorkspaceButton: function(button, pspec) {
		let numButton = pspec.get_button();
		if (numButton === LEFTBUTTON) //Left Button
		{
			if (this.activeWorkspaceIndex === this.totalWorkspace)
				this.activeWorkspaceIndex = -1;
			let newActiveWorkspace = global.screen.get_workspace_by_index(this.activeWorkspaceIndex + 1);
			newActiveWorkspace.activate(global.get_current_time());
		} else if (numButton === RIGHTBUTTON) //Right Button
		{
			if (this.activeWorkspaceIndex === 0)
				this.activeWorkspaceIndex = this.totalWorkspace + 1;
			let newActiveWorkspace = global.screen.get_workspace_by_index(this.activeWorkspaceIndex - 1);
			newActiveWorkspace.activate(global.get_current_time());
		}
	},

	onClickDesktopButton: function(button, pspec) {
		let maxWindows = false;
		let userTime = null;
		let activeWorkspace = global.screen.get_active_workspace();
		let windows = activeWorkspace.list_windows().filter(function(w) {
			return w.get_window_type() !== Meta.WindowType.DESKTOP;
		});
		let numButton = pspec.get_button();
		if (numButton === LEFTBUTTON) //Left Button
		{
			for (let i = 0; i < windows.length; ++i) {
				if ((this.desktopView) && (!Main.overview.visible)) {
					userTime = windows[i].user_time;
					if (userTime > this.lastFocusedWindowUserTime) {
						this.lastFocusedWindowUserTime = userTime;
						this.lastFocusedWindow = windows[i];
					}
					windows[i].unminimize();
					maxWindows = true;
				} else {
					windows[i].minimize();
				}
			}
			if (maxWindows) {
				this.lastFocusedWindow.activate(global.get_current_time());
			}
			this.desktopView = !this.desktopView;
			if (Main.overview.visible)
				Main.overview.hide();
		} else if ((numButton === RIGHTBUTTON) && (this.settings.get_boolean("desktop-button-right-click"))) //Right Button
			Main.Util.trySpawnCommandLine('gnome-shell-extension-prefs ' + Extension.metadata.uuid);
	},

	onClickTaskButton: function(button, pspec, window) {
	    if (this.taskMenuUp && this.taskMenu.isOpen) {
	        this.taskMenu.close();
	        return;
	    }

		let numButton = pspec.get_button();
		let buttonAction = 0;

	    if (numButton === LEFTBUTTON)
	        buttonAction = this.settings.get_enum("tasks-left-click");
	    else if (numButton === MIDDLEBUTTON)
	        buttonAction = this.settings.get_enum("tasks-middle-click");
	    else if (numButton === RIGHTBUTTON)
	        buttonAction = this.settings.get_enum("tasks-right-click");

		let app = Shell.WindowTracker.get_default().get_window_app(window);
		let appname = app.get_name();
		let index = this.searchTaskInList(window);

	    switch (buttonAction)
	    {
	        case 0: //Action === 'none'
	            return;
	        case 1: //Action === 'minmax'
	            this.clickActionMinMax(window, appname, index);
	            break;
	        case 2: //Action === 'openmenu'
	            this.clickActionOpenMenu(window, appname, button);
	            break;
	        case 3: //Action === 'close'
	            window.delete(global.get_current_time());
	            break;
            case 4: //Action === 'new_instance'
                app.open_new_window(-1);
                break;
	        default: //Same as 'none'
	            return;
	    }
	},

	onClickTrayButton: function(button, pspec) {
		let numButton = pspec.get_button();
		if (numButton === LEFTBUTTON) //Left Button
		{
			Main.messageTray.toggle();
		}
	},

	//Actions executed depending on button click on Task
	clickActionMinMax: function(window, appname, index) {
	    let activeWorkspace = global.screen.get_active_workspace();
	    let focusWindow = global.display.focus_window;
	    let nextApp = false;

	    this.tasksList.forEach(
	        function(task) {
	            let [windowTask, buttonTask, signalsTask] = task;
	            let windowWorkspace = windowTask.get_workspace();

	            if (windowTask === window) {
	                if (windowWorkspace !== activeWorkspace) {
	                    windowWorkspace.activate(global.get_current_time());
	                    windowTask.activate(global.get_current_time());
	                }
	                else if (!windowTask.has_focus()) {
	                    windowTask.activate(global.get_current_time());
	                }
	                else if ((!Main.overview.visible) && ((this.settings.get_enum("sort-tasks") === 3) || (this.settings.get_enum("sort-tasks") === 4))) {
	                    for (let i = index - 1; i >= 0; i--) {
	                        let sameWorkspace = true;
	                        let [_windowTask, _buttonTask, _signalsTask] = this.tasksList[i];
	                        let _appname = Shell.WindowTracker.get_default().get_window_app(_windowTask).get_name();
	                        let _windowWorkspace = _windowTask.get_workspace();

	                        if ((appname === _appname) && (_windowTask !== focusWindow)) {
	                            if (_windowWorkspace !== activeWorkspace) {
	                                if (this.settings.get_enum("sort-tasks") === 4) continue;
	                                else _windowWorkspace.activate(global.get_current_time());
	                            }
	                            _windowTask.activate(global.get_current_time());
	                            nextApp = true;
	                            break;
	                        }
	                    }

	                    if (!nextApp) {
	                        for (let k = this.tasksList.length - 1; k >= index; k--) {
	                            let [_windowTask2, _buttonTask2, _signalsTask2] = this.tasksList[k];
	                            let _appname2 = Shell.WindowTracker.get_default().get_window_app(_windowTask2).get_name();
	                            let _windowWorkspace2 = _windowTask2.get_workspace();

	                            if ((appname === _appname2) && (_windowTask2 !== focusWindow)) {
	                                if (_windowWorkspace2 !== activeWorkspace) {
	                                    if (this.settings.get_enum("sort-tasks") === 4)
	                                        continue;
	                                    else
	                                        _windowWorkspace2.activate(global.get_current_time());
	                                }
	                                _windowTask2.activate(global.get_current_time());
	                                nextApp = true;
	                                break;
	                            }
	                        }
	                        windowTask.minimize();
	                    }
	                }
	                else if (!Main.overview.visible)
	                    windowTask.minimize();
	            }
	        },
	        this
	    );

	    if (Main.overview.visible)
	        Main.overview.hide();
	},

	clickActionOpenMenu: function(window, appname, button) {
	    this.taskMenu = null;
	    let app = Shell.WindowTracker.get_default().get_window_app(window);
	    let taskMenuManager = new PopupMenu.PopupMenuManager({
	        actor: button
	    });

	    if (app.action_group && app.menu) {
	        this.taskMenu = new RemoteMenu.RemoteMenu(button, app.menu, app.action_group);
	    }
	    else {
	        this.taskMenu = new PopupMenu.PopupMenu(button, 0.0, St.Side.TOP);
	        let menuQuit = new PopupMenu.PopupMenuItem("Quit");

	        menuQuit.connect('activate', Lang.bind(this, function() {
	            window.delete(global.get_current_time());
	        }));
	        this.taskMenu.addMenuItem(menuQuit);
	    }

	    if ((this.settings.get_enum("sort-tasks") === 3) || (this.settings.get_enum("sort-tasks") === 4)) {
	        let counter = 1;
	        let windowsList = null;
	        let title = null;

	        this.tasksList.forEach(
	            function(task) {
	                let [windowTask, buttonTask, signalsTask] = task;
	                let _appname = Shell.WindowTracker.get_default().get_window_app(windowTask).get_name();
	                let windowWorkspace = windowTask.get_workspace();

	                if ((appname === _appname) && (windowTask !== window)) {
	                    if ((windowWorkspace !== window.get_workspace()) && (this.settings.get_enum("sort-tasks") === 4))
	                        return;

	                    windowsList = null;
	                    title = windowTask.get_title();

	                    if (title.length > 50)
	                        title = title.substr(0, 47) + "...";

	                    windowsList = new PopupMenu.PopupMenuItem(title);
	                    windowsList.connect('activate', Lang.bind(this, function() {
	                        if (windowWorkspace !== global.screen.get_active_workspace())
	                            windowWorkspace.activate(global.get_current_time());
	                        windowTask.activate(global.get_current_time());
	                    }));

	                    this.taskMenu.addMenuItem(windowsList, 0);
	                    counter++;
	                }
	            },
	            this
	        );

	        if (counter > 1) {
	            windowsList = null;
	            title = null;
	            title = window.get_title();
	            if (title.length > 50)
	                title = title.substr(0, 47) + "...";
	            windowsList = new PopupMenu.PopupMenuItem(title);
	            let _windowWorkspace = window.get_workspace();
	            windowsList.connect('activate', Lang.bind(this, function() {
	                window.activate(global.get_current_time());
	            }));
	            this.taskMenu.addMenuItem(windowsList, 0);
	        }
	        else {
	            counter--;
	        }

	        if (counter > 1) {
	            let mini = new PopupMenu.PopupMenuItem("Minimize Window");
	            mini.connect('activate', Lang.bind(this, function() {
	                window.minimize();
	            }));
	            this.taskMenu.addMenuItem(mini, counter);
	            let separator = new PopupMenu.PopupSeparatorMenuItem();
	            this.taskMenu.addMenuItem(separator, counter);
	        }
	    }

	    this.taskMenu.actor.hide();
	    taskMenuManager.addMenu(this.taskMenu);
	    Main.uiGroup.add_actor(this.taskMenu.actor);
	    this.taskMenuUp = true;
	    this.hidePreview();
	    this.taskMenu.open();
	},

	//Scroll Events
	onScrollWorkspaceButton: function(button, event) {
		if ((this.settings.get_enum("scroll-workspaces") === 1) || (this.settings.get_enum("scroll-workspaces") === 2)) {
			let scrollDirection = event.get_scroll_direction();
			if (((scrollDirection === Clutter.ScrollDirection.UP) && (this.settings.get_enum("scroll-workspaces") === 1)) ||
				((scrollDirection === Clutter.ScrollDirection.DOWN) && (this.settings.get_enum("scroll-workspaces") === 2))) {
				if (this.activeWorkspaceIndex === this.totalWorkspace)
					this.activeWorkspaceIndex = -1;
				let newActiveWorkspace = global.screen.get_workspace_by_index(this.activeWorkspaceIndex + 1);
				newActiveWorkspace.activate(global.get_current_time());
			} else if (((scrollDirection === Clutter.ScrollDirection.DOWN) && (this.settings.get_enum("scroll-workspaces") === 1)) ||
				((scrollDirection === Clutter.ScrollDirection.UP) && (this.settings.get_enum("scroll-workspaces") === 2))) {
				if (this.activeWorkspaceIndex === 0)
					this.activeWorkspaceIndex = this.totalWorkspace + 1;
				let newActiveWorkspace = global.screen.get_workspace_by_index(this.activeWorkspaceIndex - 1);
				newActiveWorkspace.activate(global.get_current_time());
			}
		}
	},

	onScrollTaskButton: function(button, event) {
		if ((this.settings.get_enum("scroll-tasks") === 1) || (this.settings.get_enum("scroll-tasks") === 2)) {
			this.nextTask = false;
			this.previousTask = null;
			let focusWindow = global.display.focus_window;
			let activeWorkspace = global.screen.get_active_workspace();
			let scrollDirection = event.get_scroll_direction();
			if (((scrollDirection === Clutter.ScrollDirection.UP) && (this.settings.get_enum("scroll-tasks") === 1)) ||
				((scrollDirection === Clutter.ScrollDirection.DOWN) && (this.settings.get_enum("scroll-tasks") === 2))) {
				this.tasksList.forEach(
					function(task) {
						let [windowTask, buttonTask, signalsTask] = task;
						let windowWorkspace = windowTask.get_workspace();
						if (this.nextTask) {
							if (windowWorkspace !== activeWorkspace)
								windowWorkspace.activate(global.get_current_time());
							windowTask.activate(global.get_current_time());
							this.nextTask = false;
						}
						if (windowTask === focusWindow)
							this.nextTask = true;
					},
					this
				);
				if (Main.overview.visible)
					Main.overview.hide();
			} else if (((scrollDirection === Clutter.ScrollDirection.DOWN) && (this.settings.get_enum("scroll-tasks") === 1)) ||
				((scrollDirection === Clutter.ScrollDirection.UP) && (this.settings.get_enum("scroll-tasks") === 2))) {
				this.tasksList.forEach(
					function(task) {
						let [windowTask, buttonTask, signalsTask] = task;
						if ((windowTask === focusWindow) && (this.previousTask !== null)) {
							let [windowTask, buttonTask, signalsTask] = this.previousTask;
							let windowWorkspace = windowTask.get_workspace();
							if (windowWorkspace !== activeWorkspace)
								windowWorkspace.activate(global.get_current_time());
							windowTask.activate(global.get_current_time());
						}
						this.previousTask = task;
					},
					this
				);
				if (Main.overview.visible)
					Main.overview.hide();
			}
		}
	},

	//Open Tray on Tray Button Hover
	onHoverTrayButton: function() {
		if (this.settings.get_boolean("hover-tray-button"))
			Main.messageTray.toggle();
	},

	//Switch Task on Hover
	onHoverSwitchTask: function(button, window) {
		if (!this.resetHover) {
			let focusWindow = global.display.focus_window;
			let appname = Shell.WindowTracker.get_default().get_window_app(focusWindow).get_name();
			let activeWorkspace = global.screen.get_active_workspace();
			this.tasksList.forEach(
				function(task) {
					let [windowTask, buttonTask, signalsTask] = task;
					let windowWorkspace = windowTask.get_workspace();
					let _app_name = Shell.WindowTracker.get_default().get_window_app(windowTask).get_name();
					if ((windowTask === window) && (((appname !== _app_name) && ((this.settings.get_enum("sort-tasks") === 3) || (this.settings.get_enum("sort-tasks") === 4))) || ((this.settings.get_enum("sort-tasks") !== 3) && (this.settings.get_enum("sort-tasks") !== 4)))) {
						if (windowWorkspace !== activeWorkspace) {
							windowWorkspace.activate(global.get_current_time());
							windowTask.activate(global.get_current_time());
						} else if (!windowTask.has_focus())
							windowTask.activate(global.get_current_time());
					}
				},
				this
			);
			if (Main.overview.visible)
				Main.overview.hide();
		}
		if (this.previewTimer2 !== null) {
			Mainloop.source_remove(this.previewTimer2);
			this.previewTimer2 = null;
		}
	},

	//Window Demands Attention
	onWindowDemandsAttention: function(display, window) {
		if ((this.settings.get_boolean("display-tasks")) && (this.settings.get_boolean("blink-tasks"))) {
			this.tasksList.forEach(
				function(task) {
					let [windowTask, buttonTask, signalsTask] = task;
					if ((windowTask === window) && (!windowTask.has_focus())) {
						this.attentionStyleChanged = false;
						this.attentionStyle = "background-color: " + this.settings.get_string("blink-color") + "; margin-right: " + this.inactiveMargin + "px;";
						this.attentionStyleChangeTimeout = Mainloop.timeout_add(this.settings.get_int("blink-rate"), Lang.bind(this, this.changeAttentionStyle, windowTask, buttonTask));
					}
				},
				this
			);
		}
	},

	changeAttentionStyle: function(windowTask, buttonTask) {
		if ((!this.attentionStyleChanged) && (!windowTask.has_focus())) {
			buttonTask.set_style(this.attentionStyle);
			this.attentionStyleChanged = true;
			return true;
		} else if ((this.attentionStyleChanged) && (!windowTask.has_focus())) {
			buttonTask.set_style(this.inactiveBackgroundStyleColor);
			this.attentionStyleChanged = false;
			return true;
		} else
			return false;
	},

	//Init Windows Manage Callbacks
	initWindows: function(windowsList, type, window) {
		if (this.settings.get_boolean("display-tasks")) {
			//Active Task Frame / Background Color
			this.activeTaskFrame();
			//Inactive Task Frame / Background Color
			this.inactiveTaskFrame();
			//Task Menu
			this.taskMenu = null;
			this.taskMenuUp = false;
			this.tasksContainerSize();
			this.windows = new Windows.Windows(this, this.onWindowsListChanged, this.onWindowChanged);
		}
	},

    //Taskslist
    onWindowsListChanged: function(windowsList, type, window) {
        this.cleanTasksList();
        windowsList.forEach(
            function(window) {
                this.addTaskInList(window);
            },
            this
        );
        this.hidePreview();
        this.tasksContainer();
        this.iconGeometry();
        this.updateIcon();
    },

	//Tasks Container
	tasksContainer: function(window) {
		if ((this.tasksContainerWidth > 0) && (this.countTasks > 0) && (this.countTasks > this.tasksContainerWidth)) {
			let buttonTaskWidth;
			if (this.settings.get_enum("tasks-label") !== 0)
				buttonTaskWidth = this.settings.get_int("tasks-width");
			else
				buttonTaskWidth = (this.panelSize + 8);
			let totalWidth = this.boxMainTasks.get_width();
			let spaces = this.settings.get_int("tasks-spaces");
			let counter = 0;
			this.tasksList.forEach(
				function(task) {
					let [windowTask, buttonTask, signalsTask] = task;
					if (buttonTask.visible)
						counter++;
				},
				this
			);
			let newWidth = ((totalWidth - (spaces * counter)) / counter);
			if (newWidth > buttonTaskWidth) {
				newWidth = buttonTaskWidth;
			}
			this.tasksList.forEach(
				function(_task) {
					let [_windowTask, _buttonTask, _signalsTask] = _task;
					_buttonTask.set_width(newWidth);
				},
				this
			);
		}
	},

	//Tasks Container Size
	tasksContainerSize: function() {
		if (this.tasksContainerWidth > 0) {
			let spaces = this.settings.get_int("tasks-spaces");
			let buttonTaskWidth = 0;
			this.tasksWidth = this.settings.get_int("tasks-width");
			if (this.settings.get_enum("tasks-label") !== 0)
				buttonTaskWidth = this.tasksWidth;
			else
				buttonTaskWidth = (this.panelSize + 8);
			this.newTasksContainerWidth = (this.tasksContainerWidth * (buttonTaskWidth + spaces));
			this.boxMainTasks.set_width(this.newTasksContainerWidth);
		}
	},

    //Icon Geometry
	iconGeometry: function() {
		for (let i = this.tasksList.length - 1; i >= 0; i--) {
			let [windowTask, buttonTask, signalsTask, labelTask, iconTask] = this.tasksList[i];
			let rect = new Meta.Rectangle();
			[rect.x, rect.y] = buttonTask.get_transformed_position();
            [rect.width, rect.height] = buttonTask.get_transformed_size();
			windowTask.set_icon_geometry(rect);
		}
	},

    //Icons
    updateIcon: function() {
		this.tasksList.forEach(
			function(task) {
				let [windowTask, buttonTask, signalsTask, labelTask, iconTask] = task;
                let app = Shell.WindowTracker.get_default().get_window_app(windowTask);
                iconTask.child = app.create_icon_texture(this.panelSize);
			},
			this
		);
    },

    updateTasks: function() {
        this.iconGeometry();
        this.updateIcon();
    },

	//Active Tasks
	activeTasks: function(window) {
		let active = false;
		let activeWorkspace = global.screen.get_active_workspace();
		this.tasksList.forEach(
			function(task) {
				let [windowTask, buttonTask, signalsTask] = task;
				let workspaceTask = windowTask.get_workspace();
				if ((!windowTask.minimized) && (workspaceTask === activeWorkspace))
					active = true;
			},
			this
		);
		if (active === true)
			this.desktopView = false;
		else
			this.desktopView = true;
	},

	//Task Style
	onWindowChanged: function(window, type) {
		if (type === 0) //Focus
		{
			this.tasksList.forEach(
				function(task) {
					let [windowTask, buttonTask, signalsTask, labelTask] = task;
					if (windowTask === window) {
						buttonTask.set_style(this.backgroundStyleColor);
						buttonTask.show();
						if ((this.settings.get_enum("tasks-label") !== 0) && (this.settings.get_boolean("display-tasks-label-color"))) {
							this.tasksLabelColor = this.settings.get_string("tasks-label-color");
							if (this.tasksLabelColor !== "unset") {
								this.tasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; padding-top: ' + ((this.panelSize - 5 - (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize)) / 2) + 'px; color: ' + this.tasksLabelColor + ';';
								labelTask.set_style(this.tasksLabelStyle);
							} else
								labelTask.set_style("None");
						} else if (this.settings.get_enum("tasks-label") !== 0) {
							this.tasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; padding-top: ' + ((this.panelSize - 5 - (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize)) / 2) + 'px;';
							labelTask.set_style(this.tasksLabelStyle);
						}
					} else {
						buttonTask.set_style(this.inactiveBackgroundStyleColor);
						if ((this.settings.get_enum("sort-tasks") === 3) || (this.settings.get_enum("sort-tasks") === 4)) {
							let _app_name = Shell.WindowTracker.get_default().get_window_app(window).get_name();
							let appname = Shell.WindowTracker.get_default().get_window_app(windowTask).get_name();
							let workspaceTask = windowTask.get_workspace();
							let activeWorkspace = global.screen.get_active_workspace();
							if ((_app_name === appname) && ((workspaceTask === activeWorkspace) || (this.settings.get_enum("sort-tasks") === 3)))
								buttonTask.hide();
						}
						if ((this.settings.get_enum("tasks-label") !== 0) && (this.settings.get_boolean("display-inactive-tasks-label-color"))) {
							this.inactiveTasksLabelColor = this.settings.get_string("inactive-tasks-label-color");
							if (this.inactiveTasksLabelColor !== "unset") {
								this.inactiveTasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; color: ' + this.inactiveTasksLabelColor + ';';
								labelTask.set_style(this.inactiveTasksLabelStyle);
							} else
								labelTask.set_style("None");
						} else if (this.settings.get_enum("tasks-label") !== 0) {
							this.tasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; padding-top: ' + ((this.panelSize - 5 - (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize)) / 2) + 'px;';
							labelTask.set_style(this.tasksLabelStyle);
						}
					}
				},
				this
			);
		} else if ((type === 1) && (this.settings.get_enum("tasks-label") === 1)) //Title Change
		{
			this.tasksList.forEach(
				function(task) {
					let [windowTask, buttonTask, signalsTask, labelTask] = task;
					if (windowTask === window) {
						labelTask.text = " " + window.get_title() + " ";
					}
				},
				this
			);
		} else if (type === 2) //Minimized
		{
			this.tasksList.forEach(
				function(task) {
					let [windowTask, buttonTask, signalsTask, labelTask] = task;
					if (windowTask === window) {
						buttonTask.set_style(this.inactiveBackgroundStyleColor);
						if ((this.settings.get_enum("tasks-label") !== 0) && (this.settings.get_boolean("display-inactive-tasks-label-color"))) {
							this.inactiveTasksLabelColor = this.settings.get_string("inactive-tasks-label-color");
							if (this.inactiveTasksLabelColor !== "unset") {
								this.inactiveTasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; color: ' + this.inactiveTasksLabelColor + ';';
								labelTask.set_style(this.inactiveTasksLabelStyle);
							} else
								labelTask.set_style("None");
						} else if (this.settings.get_enum("tasks-label") !== 0) {
							this.tasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; padding-top: ' + ((this.panelSize - 5 - (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize)) / 2) + 'px;';
							labelTask.set_style(this.tasksLabelStyle);
						}
					}
				},
				this
			);
		} else if ((type === 3) || (type === 4)) {
              this.updateIcon();
        }
	},

	//Task Index
	searchTaskInList: function(window) {
		let index = null;
		for (let indexTask in this.tasksList) {
			let [windowTask, buttonTask, signalsTask] = this.tasksList[indexTask];
			if (windowTask === window) {
				index = indexTask;
				break;
			}
		}
		return index;
	},

	//Add Tasks
	addTaskInList: function(window) {
		let app = Shell.WindowTracker.get_default().get_window_app(window);
		let buttonTask = null;
        let iconTask = new St.Bin();
		let labelTask = null;
		if (app !== null) {
			let appname = app.get_name();
			//Check Blacklisted Apps
			if (this.settings.get_boolean("blacklist-set")) {
				let blacklist = this.settings.get_strv("blacklist");
				if (blacklist.length > 0) {
					for (let j = 0; j < blacklist.length; j++) {
						let blacklistapp = blacklist[j];
						if (appname === blacklistapp) {
							return;
                        }
					}
				}
			}
			//Tasks Label
			if (this.settings.get_enum("tasks-label") !== 0) {
				let buttonTaskLayout = null;
				if (this.settings.get_boolean("bottom-panel")) {
					buttonTaskLayout = new St.BoxLayout({
						style_class: "tkb-task-button-bottom-label"
					});
                } else {
					buttonTaskLayout = new St.BoxLayout({
						style_class: "tkb-task-button"
					});
                }
				buttonTaskLayout.add_actor(iconTask);
				if (this.settings.get_enum("tasks-label") === 1) {
					labelTask = new St.Label({
						text: (" " + window.get_title() + " ")
					});
                } else {
					labelTask = new St.Label({
						text: (" " + appname + " ")
					});
                }
				labelTask.set_style('font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; padding-top: ' + ((this.panelSize - 5 - (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize)) / 2) + 'px;');
				buttonTaskLayout.add_actor(labelTask);
				buttonTask = new St.Button({
					style_class: "tkb-task-button",
					child: buttonTaskLayout,
					x_align: St.Align.START
				});
				this.tasksWidth = this.settings.get_int("tasks-width");
				buttonTask.set_width(this.tasksWidth);
			} else {
				if (this.settings.get_boolean("bottom-panel")) {
					buttonTask = new St.Button({
						style_class: "tkb-task-button-bottom"
					});
                } else {
					buttonTask = new St.Button({
						style_class: "tkb-task-button"
					});
                }
                buttonTask.add_actor(iconTask);
			}
			//Signals
			let signalsTask = [
				buttonTask.connect("button-press-event", Lang.bind(this, this.onClickTaskButton, window)),
				buttonTask.connect("enter-event", Lang.bind(this, this.showPreview, window)),
				buttonTask.connect("leave-event", Lang.bind(this, this.resetPreview, window)),
				buttonTask.connect("allocation-changed", Lang.bind(this, this.updateTasks))
			];
			//Display Tasks of All Workspaces
			if (!this.settings.get_boolean("tasks-all-workspaces")) {
				let workspace = global.screen.get_active_workspace();
				if (!this.settings.get_boolean("tasks-all-workspaces")) {
					buttonTask.visible = window.located_on_workspace(workspace);
                }
			}
			if (window.has_focus()) {
				buttonTask.set_style(this.backgroundStyleColor);
				if ((this.settings.get_enum("tasks-label") !== 0) && (this.settings.get_boolean("display-tasks-label-color"))) {
					this.tasksLabelColor = this.settings.get_string("tasks-label-color");
					if (this.tasksLabelColor !== "unset") {
						this.tasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; padding-top: ' + ((this.panelSize - 5 - (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize)) / 2) + 'px; color: ' + this.tasksLabelColor + ';';
						labelTask.set_style(this.tasksLabelStyle);
					} else
						labelTask.set_style("None");
				}
			} else {
				buttonTask.set_style(this.inactiveBackgroundStyleColor);
				if ((this.settings.get_enum("tasks-label") !== 0) && (this.settings.get_boolean("display-inactive-tasks-label-color"))) {
					this.inactiveTasksLabelColor = this.settings.get_string("inactive-tasks-label-color");
					if (this.inactiveTasksLabelColor !== "unset") {
						this.inactiveTasksLabelStyle = 'font-size: ' + (this.panelSize - 5 + this.adjustTBLabelSize - this.adjustTBIconSize) + 'px; color: ' + this.inactiveTasksLabelColor + ';';
						labelTask.set_style(this.inactiveTasksLabelStyle);
					} else {
						labelTask.set_style("None");
                    }
				}
			}
			//Sort Tasks
			let inserted = false;
			if (this.settings.get_enum("sort-tasks") !== 0) {
				for (let i = this.tasksList.length - 1; i >= 0; i--) {
					let [_windowTask, _buttonTask, _signalsTask] = this.tasksList[i];
					let _app_name = Shell.WindowTracker.get_default().get_window_app(_windowTask).get_name();
					if (appname === _app_name) {
						if ((this.settings.get_enum("sort-tasks") === 2) || (this.settings.get_enum("sort-tasks") === 4)) {
							let _workspaceTask = _windowTask.get_workspace();
							let workspaceTask = window.get_workspace();
							if (workspaceTask !== _workspaceTask) {
								break;
							}
						}
						this.boxMainTasks.insert_child_above(buttonTask, _buttonTask);
						if ((this.settings.get_enum("sort-tasks") === 3) || (this.settings.get_enum("sort-tasks") === 4)) {
							buttonTask.hide();
                        }
						this.tasksList.splice(i + 1, 0, [window, buttonTask, signalsTask, labelTask, iconTask]);
						inserted = true;
						break;
					}
				}
			}
			if (!inserted) {
				this.boxMainTasks.add_child(buttonTask);
				this.tasksList.push([window, buttonTask, signalsTask, labelTask, iconTask]);
			}
			this.countTasks++;
		}
	},

	//Remove Tasks
	removeTaskInList: function(window) {
		let index = this.searchTaskInList(window);
		if (index !== null) {
			let [windowTask, buttonTask, signalsTask] = this.tasksList[index];
			signalsTask.forEach(
				function(signal) {
					buttonTask.disconnect(signal);
				},
				this
			);
			buttonTask.destroy();
			this.tasksList.splice(index, 1);
			this.countTasks--;
			if (this.countTasks < 0)
				this.countTasks = 0;
			if (this.countTasks === 0)
				this.cleanTasksList();
			return true;
		} else
			return false;
	},

	//Reset Taskslist
	cleanTasksList: function() {
		for (let i = this.tasksList.length - 1; i >= 0; i--) {
			let [windowTask, buttonTask, signalsTask] = this.tasksList[i];
			signalsTask.forEach(
				function(signal) {
					buttonTask.disconnect(signal);
				},
				this
			);
			buttonTask.destroy();
			this.tasksList.splice(i, 1);
		}
		this.tasksList = [];
		this.countTasks = 0;
	},

    //Preview
	getThumbnail: function(window, size) {
		let thumbnail = null;
		let mutterWindow = window.get_compositor_private();
		if (mutterWindow) {
			let windowTexture = mutterWindow.get_texture();
			let [width, height] = windowTexture.get_size();
			let scale = Math.min(1.0, size / width, size / height);
			thumbnail = new Clutter.Clone({
				source: windowTexture,
				reactive: true,
				width: width * scale,
				height: height * scale
			});
		}
		return thumbnail;
	},

	showPreview: function(button, pspec, window) {
		//Switch Task on Hover
		this.resetHover = false;
		if (this.settings.get_boolean("hover-switch-task")) {
			if (this.settings.get_int("hover-delay") === 0)
				this.onHoverSwitchTask(button, window);
			else
				this.previewTimer2 = Mainloop.timeout_add(this.settings.get_int("hover-delay"),
					Lang.bind(this, this.onHoverSwitchTask, button, window));
		}
		//Hide current preview if necessary
		this.hidePreview();
		this.grouped = false;
		if ((this.settings.get_enum("display-label") !== 0) || (this.settings.get_boolean("display-thumbnail"))) {
			if ((this.settings.get_enum("sort-tasks") === 3) || (this.settings.get_enum("sort-tasks") === 4)) {
				let appname = Shell.WindowTracker.get_default().get_window_app(window).get_name();
				let focuswindow = global.display.focus_window;
				let focusappname = Shell.WindowTracker.get_default().get_window_app(focuswindow).get_name();
				for (let i = this.tasksList.length - 1; i >= 0; i--) {
					let [_windowTask, _buttonTask, _signalsTask] = this.tasksList[i];
					let _app_name = Shell.WindowTracker.get_default().get_window_app(_windowTask).get_name();
					if ((appname === _app_name) && (_windowTask !== window)) {
						this.grouped = true;
						if (appname === focusappname) {
							window = global.display.focus_window;
							break;
						}
					}
				}
			}
			if (this.settings.get_int("preview-delay") === 0)
				this.showPreview2(button, window);
			else
				this.previewTimer = Mainloop.timeout_add(this.settings.get_int("preview-delay"),
					Lang.bind(this, this.showPreview2, button, window));
		}
	},

	showPreview2: function(button, window) {
		//Hide current preview if necessary
		this.hidePreview();
		let app = Shell.WindowTracker.get_default().get_window_app(window);
		this.previewFontSize = this.settings.get_int("preview-font-size");
		this.preview = new St.BoxLayout({
			vertical: true
		});
		if (this.settings.get_enum("display-label") !== 0) {
			if (this.settings.get_enum("display-label") !== 2) {
				let labelNamePreview;
				if (this.grouped) {
					labelNamePreview = new St.Label({
						text: ' ' + app.get_name() + ' (Group) '
					});
				} else {
					labelNamePreview = new St.Label({
						text: ' ' + app.get_name() + ' '
					});
				}
				if ((this.settings.get_string("preview-label-color") !== 'unset') && (this.settings.get_boolean("display-preview-label-color"))) {
					this.previewLabelColor = this.settings.get_string("preview-label-color");
					this.labelNamePreviewStyle = "color: " + this.previewLabelColor + "; font-weight: bold; font-size: " + this.previewFontSize + "pt; text-align: center;";
					labelNamePreview.set_style(this.labelNamePreviewStyle);
				} else {
					this.labelNamePreviewStyle = "color: rgba(255,255,255,1); font-weight: bold; font-size: " + this.previewFontSize + "pt; text-align: center;";
					labelNamePreview.set_style(this.labelNamePreviewStyle);
				}
				this.preview.add_actor(labelNamePreview);
			}
			if (this.settings.get_enum("display-label") !== 1) {
				let title = window.get_title();
				if ((title.length > 50) && (this.settings.get_boolean("display-thumbnail")))
					title = title.substr(0, 47) + "...";
				let labelTitlePreview = new St.Label({
					text: ' ' + title + ' '
				});
				if ((this.settings.get_string("preview-label-color") !== 'unset') && (this.settings.get_boolean("display-preview-label-color"))) {
					this.previewLabelColor = this.settings.get_string("preview-label-color");
					this.labelTitlePreviewStyle = "color: " + this.previewLabelColor + "; font-weight: bold; font-size: " + this.previewFontSize + "pt; text-align: center;";
					labelTitlePreview.set_style(this.labelTitlePreviewStyle);
				} else {
					this.labelTitlePreviewStyle = "color: rgba(255,255,255,1.0); font-weight: bold; font-size: " + this.previewFontSize + "pt; text-align: center;";
					labelTitlePreview.set_style(this.labelTitlePreviewStyle);
				}
				this.preview.add_actor(labelTitlePreview);
			}
		}
		if (this.settings.get_boolean("display-thumbnail")) {
			let thumbnail = this.getThumbnail(window, this.settings.get_int("preview-size"));
			this.preview.add_actor(thumbnail);
		}
		if ((this.settings.get_string("preview-background-color") !== 'unset') && (this.settings.get_boolean("display-preview-background-color"))) {
			this.previewBackgroundColor = this.settings.get_string("preview-background-color");
			this.previewStyle = "background-color: " + this.previewBackgroundColor + "; padding: 5px; border-radius: 8px; -y-offset: 6px;";
			this.preview.set_style(this.previewStyle);
		} else {
			this.previewStyle = "background-color: rgba(0,0,0,0.9); padding: 5px; border-radius: 8px; -y-offset: 6px;";
			this.preview.set_style(this.previewStyle);
		}
		global.stage.add_actor(this.preview);
		this.button = button;
		this.setPreviewPosition();
	},

	showFavoritesPreview: function(buttonfavorite, favoriteapp) {
		//Hide current preview if necessary
		this.hidePreview();
		this.previewFontSize = this.settings.get_int("preview-font-size");
		this.favoritesPreview = new St.BoxLayout({
			vertical: true
		});
		let favoriteappName = favoriteapp.get_name();
		if (favoriteapp.get_description()) {
			if (this.settings.get_enum("display-favorites-label") === 2)
				favoriteappName = favoriteapp.get_description();
			if (this.settings.get_enum("display-favorites-label") === 3)
				favoriteappName += '\n' + favoriteapp.get_description();
		}
		let labelNamePreview = new St.Label({
			text: favoriteappName
		});
		if ((this.settings.get_string("preview-label-color") !== 'unset') && (this.settings.get_boolean("display-preview-label-color"))) {
			this.previewLabelColor = this.settings.get_string("preview-label-color");
			this.labelNamePreviewStyle = "color: " + this.previewLabelColor + "; font-weight: bold; font-size: " + this.previewFontSize + "pt; text-align: center;";
			labelNamePreview.set_style(this.labelNamePreviewStyle);
		} else {
			this.labelNamePreviewStyle = "color: rgba(255,255,255,1.0); font-weight: bold; font-size: " + this.previewFontSize + "pt; text-align: center;";
			labelNamePreview.set_style(this.labelNamePreviewStyle);
		}
		this.favoritesPreview.add_actor(labelNamePreview);
		if ((this.settings.get_string("preview-background-color") !== 'unset') && (this.settings.get_boolean("display-preview-background-color"))) {
			this.previewBackgroundColor = this.settings.get_string("preview-background-color");
			this.favoritesPreviewStyle = "background-color: " + this.previewBackgroundColor + "; padding: 5px; border-radius: 8px; -y-offset: 6px;";
			this.favoritesPreview.set_style(this.favoritesPreviewStyle);
		} else {
			this.favoritesPreviewStyle = "background-color: rgba(0,0,0,0.9); padding: 5px; border-radius: 8px; -y-offset: 6px;";
			this.favoritesPreview.set_style(this.favoritesPreviewStyle);
		}
		global.stage.add_actor(this.favoritesPreview);
		this.button = buttonfavorite;
		this.preview = this.favoritesPreview;
		this.setPreviewPosition();
	},

	setPreviewPosition: function() {
		let [stageX, stageY] = this.button.get_transformed_position();
		let itemHeight = this.button.allocation.y2 - this.button.allocation.y1;
		let itemWidth = this.button.allocation.x2 - this.button.allocation.x1;
		let labelWidth = this.preview.get_width();
		let labelHeight = this.preview.get_height();
		let node = this.preview.get_theme_node();
		let yOffset = node.get_length('-y-offset');
		let y = null;
		if ((this.settings.get_boolean("bottom-panel")) || (this.tbp))
			y = stageY - labelHeight - yOffset;
		else
			y = stageY + itemHeight + yOffset;
		let x = Math.floor(stageX + itemWidth / 2 - labelWidth / 2);
		let posparent = this.preview.get_parent();
		let posparentWidth = posparent.allocation.x2 - posparent.allocation.x1;
		if (Clutter.get_default_text_direction() === Clutter.TextDirection.LTR) {
			x = Math.min(x, posparentWidth - labelWidth - 6);
			x = Math.max(x, 6);
		} else {
			x = Math.max(x, 6);
			x = Math.min(x, posparentWidth - labelWidth - 6);
		}
		this.preview.set_position(x, y);
	},

	resetPreview: function(button, window) {
		//Reset Hover
		this.resetHover = true;
		if (this.previewTimer2 !== null) {
			Mainloop.source_remove(this.previewTimer2);
			this.previewTimer2 = null;
		}
		this.hidePreview();
	},

	hidePreview: function() {
		//Remove preview programmed if necessary
		if (this.previewTimer !== null) {
			Mainloop.source_remove(this.previewTimer);
			this.previewTimer = null;
		}

		//Destroy Preview if displaying
		if (this.preview !== null) {
			this.preview.destroy();
			this.preview = null;
		}

		//Destroy Favorites Preview if displaying
		if (this.favoritesPreview !== null) {
			this.favoritesPreview.destroy();
			this.favoritesPreview = null;
		}
	}
};