1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT
use crate::{
ffi, AuthenticationRequest, AutomationBrowsingContextPresentation, BackForwardList,
BackForwardListItem, ColorChooserRequest, ContextMenu, Download, EditorState,
FileChooserRequest, FindController, FormSubmissionRequest, HitTestResult, InputMethodContext,
InsecureContentEvent, LoadEvent, MediaCaptureState, NavigationAction, NetworkSession,
Notification, OptionMenu, PermissionRequest, PermissionStateQuery, PolicyDecision,
PolicyDecisionType, PrintOperation, SaveMode, ScriptDialog, Settings, SnapshotOptions,
SnapshotRegion, URIRequest, UserContentManager, UserMessage, WebContext, WebExtensionMode,
WebInspector, WebProcessTerminationReason, WebResource, WebViewBase, WebViewSessionState,
WebsitePolicies, WindowProperties,
};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, pin::Pin};
glib::wrapper! {
/// The central class of the WPE WebKit and WebKitGTK APIs.
///
/// #WebKitWebView is the central class of the WPE WebKit and WebKitGTK
/// APIs. It is responsible for managing the drawing of the content and
/// forwarding of events. You can load any URI into the #WebKitWebView or
/// a data string. With #WebKitSettings you can control various aspects
/// of the rendering and loading of the content.
///
/// Note that in WebKitGTK, #WebKitWebView is scrollable by itself, so
/// you don't need to embed it in a #GtkScrolledWindow.
///
/// ## Properties
///
///
/// #### `automation-presentation-type`
/// The #WebKitAutomationBrowsingContextPresentation of #WebKitWebView. This should only be used when
/// creating a new #WebKitWebView as a response to #WebKitAutomationSession::create-web-view
/// signal request. If the new WebView was added to a new tab of current browsing context window
/// [`AutomationBrowsingContextPresentation::Tab`][crate::AutomationBrowsingContextPresentation::Tab] should be used.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `camera-capture-state`
/// Capture state of the camera device. Whenever the user grants a media-request sent by the web
/// page, requesting video capture capabilities (`navigator.mediaDevices.getUserMedia({video:
/// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
///
/// The application can monitor this property and provide a visual indicator allowing to optionally
/// deactivate or mute the capture device by setting this property respectively to
/// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
///
/// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
/// can still re-request the permission to the user. Permission desision caching is left to the
/// application.
///
/// Readable | Writeable
///
///
/// #### `default-content-security-policy`
/// The default Content-Security-Policy used by the webview as if it were set
/// by an HTTP header.
///
/// This applies to all content loaded including through navigation or via the various
/// webkit_web_view_load_\* APIs. However do note that many WebKit APIs bypass
/// Content-Security-Policy in general such as #WebKitUserContentManager and
/// webkit_web_view_run_javascript().
///
/// Policies are additive so if a website sets its own policy it still applies
/// on top of the policy set here.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `display-capture-state`
/// Capture state of the display device. Whenever the user grants a media-request sent by the web
/// page, requesting screencasting capabilities (`navigator.mediaDevices.getDisplayMedia() this
/// property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
///
/// The application can monitor this property and provide a visual indicator allowing to
/// optionally deactivate or mute the capture device by setting this property respectively to
/// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
///
/// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
/// can still re-request the permission to the user. Permission desision caching is left to the
/// application.
///
/// Readable | Writeable
///
///
/// #### `editable`
/// Whether the pages loaded inside #WebKitWebView are editable. For more
/// information see webkit_web_view_set_editable().
///
/// Readable | Writeable
///
///
/// #### `estimated-load-progress`
/// An estimate of the percent completion for the current loading operation.
/// This value will range from 0.0 to 1.0 and, once a load completes,
/// will remain at 1.0 until a new load starts, at which point it
/// will be reset to 0.0.
/// The value is an estimate based on the total number of bytes expected
/// to be received for a document, including all its possible subresources
/// and child documents.
///
/// Readable
///
///
/// #### `favicon`
/// The favicon currently associated to the #WebKitWebView.
/// See webkit_web_view_get_favicon() for more details.
///
/// Readable
///
///
/// #### `is-controlled-by-automation`
/// Whether the #WebKitWebView is controlled by automation. This should only be used when
/// creating a new #WebKitWebView as a response to #WebKitAutomationSession::create-web-view
/// signal request.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `is-loading`
/// Whether the #WebKitWebView is currently loading a page. This property becomes
/// [`true`] as soon as a new load operation is requested and before the
/// #WebKitWebView::load-changed signal is emitted with [`LoadEvent::Started`][crate::LoadEvent::Started] and
/// at that point the active URI is the requested one.
/// When the load operation finishes the property is set to [`false`] before
/// #WebKitWebView::load-changed is emitted with [`LoadEvent::Finished`][crate::LoadEvent::Finished].
///
/// Readable
///
///
/// #### `is-muted`
/// Whether the #WebKitWebView audio is muted. When [`true`], audio is silenced.
/// It may still be playing, i.e. #WebKitWebView:is-playing-audio may be [`true`].
///
/// Readable | Writeable
///
///
/// #### `is-playing-audio`
/// Whether the #WebKitWebView is currently playing audio from a page.
/// This property becomes [`true`] as soon as web content starts playing any
/// kind of audio. When a page is no longer playing any kind of sound,
/// the property is set back to [`false`].
///
/// Readable
///
///
/// #### `is-web-process-responsive`
/// Whether the web process currently associated to the #WebKitWebView is responsive.
///
/// Readable
///
///
/// #### `microphone-capture-state`
/// Capture state of the microphone device. Whenever the user grants a media-request sent by the web
/// page, requesting audio capture capabilities (`navigator.mediaDevices.getUserMedia({audio:
/// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
///
/// The application can monitor this property and provide a visual indicator allowing to
/// optionally deactivate or mute the capture device by setting this property respectively to
/// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
///
/// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
/// can still re-request the permission to the user. Permission desision caching is left to the
/// application.
///
/// Readable | Writeable
///
///
/// #### `network-session`
/// The #WebKitNetworkSession of the view
///
/// Readable | Writeable | Construct Only
///
///
/// #### `page-id`
/// The identifier of the #WebKitWebPage corresponding to the #WebKitWebView.
///
/// Readable
///
///
/// #### `related-view`
/// The related #WebKitWebView used when creating the view to share the
/// same web process and network session. This property is not readable
/// because the related web view is only valid during the object construction.
///
/// Writeable | Construct Only
///
///
/// #### `settings`
/// The #WebKitSettings of the view.
///
/// Writeable | Construct
///
///
/// #### `title`
/// The main frame document title of this #WebKitWebView. If
/// the title has not been received yet, it will be [`None`].
///
/// Readable
///
///
/// #### `uri`
/// The current active URI of the #WebKitWebView.
/// See webkit_web_view_get_uri() for more details.
///
/// Readable
///
///
/// #### `user-content-manager`
/// The #WebKitUserContentManager of the view.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `web-context`
/// The #WebKitWebContext of the view.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `web-extension-mode`
/// This configures @web_view to treat the content as a WebExtension.
///
/// Note that this refers to the web standard [WebExtensions](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions)
/// and not WebKitWebExtensions.
///
/// In practice this limits the Content-Security-Policies that are allowed to be set. Some details can be found in
/// [Chrome's documentation](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#content-security-policy).
///
/// Readable | Writeable | Construct Only
///
///
/// #### `website-policies`
/// The #WebKitWebsitePolicies for the view.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `zoom-level`
/// The zoom level of the #WebKitWebView content.
/// See webkit_web_view_set_zoom_level() for more details.
///
/// Readable | Writeable
/// <details><summary><h4>Widget</h4></summary>
///
///
/// #### `can-focus`
/// Whether the widget or any of its descendents can accept
/// the input focus.
///
/// This property is meant to be set by widget implementations,
/// typically in their instance init function.
///
/// Readable | Writeable
///
///
/// #### `can-target`
/// Whether the widget can receive pointer events.
///
/// Readable | Writeable
///
///
/// #### `css-classes`
/// A list of css classes applied to this widget.
///
/// Readable | Writeable
///
///
/// #### `css-name`
/// The name of this widget in the CSS tree.
///
/// This property is meant to be set by widget implementations,
/// typically in their instance init function.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `cursor`
/// The cursor used by @widget.
///
/// Readable | Writeable
///
///
/// #### `focus-on-click`
/// Whether the widget should grab focus when it is clicked with the mouse.
///
/// This property is only relevant for widgets that can take focus.
///
/// Readable | Writeable
///
///
/// #### `focusable`
/// Whether this widget itself will accept the input focus.
///
/// Readable | Writeable
///
///
/// #### `halign`
/// How to distribute horizontal space if widget gets extra space.
///
/// Readable | Writeable
///
///
/// #### `has-default`
/// Whether the widget is the default widget.
///
/// Readable
///
///
/// #### `has-focus`
/// Whether the widget has the input focus.
///
/// Readable
///
///
/// #### `has-tooltip`
/// Enables or disables the emission of the ::query-tooltip signal on @widget.
///
/// A value of [`true`] indicates that @widget can have a tooltip, in this case
/// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
/// determine whether it will provide a tooltip or not.
///
/// Readable | Writeable
///
///
/// #### `height-request`
/// Override for height request of the widget.
///
/// If this is -1, the natural request will be used.
///
/// Readable | Writeable
///
///
/// #### `hexpand`
/// Whether to expand horizontally.
///
/// Readable | Writeable
///
///
/// #### `hexpand-set`
/// Whether to use the `hexpand` property.
///
/// Readable | Writeable
///
///
/// #### `layout-manager`
/// The `GtkLayoutManager` instance to use to compute the preferred size
/// of the widget, and allocate its children.
///
/// This property is meant to be set by widget implementations,
/// typically in their instance init function.
///
/// Readable | Writeable
///
///
/// #### `margin-bottom`
/// Margin on bottom side of widget.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
///
/// Readable | Writeable
///
///
/// #### `margin-end`
/// Margin on end of widget, horizontally.
///
/// This property supports left-to-right and right-to-left text
/// directions.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
///
/// Readable | Writeable
///
///
/// #### `margin-start`
/// Margin on start of widget, horizontally.
///
/// This property supports left-to-right and right-to-left text
/// directions.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
///
/// Readable | Writeable
///
///
/// #### `margin-top`
/// Margin on top side of widget.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
///
/// Readable | Writeable
///
///
/// #### `name`
/// The name of the widget.
///
/// Readable | Writeable
///
///
/// #### `opacity`
/// The requested opacity of the widget.
///
/// Readable | Writeable
///
///
/// #### `overflow`
/// How content outside the widget's content area is treated.
///
/// This property is meant to be set by widget implementations,
/// typically in their instance init function.
///
/// Readable | Writeable
///
///
/// #### `parent`
/// The parent widget of this widget.
///
/// Readable
///
///
/// #### `receives-default`
/// Whether the widget will receive the default action when it is focused.
///
/// Readable | Writeable
///
///
/// #### `root`
/// The `GtkRoot` widget of the widget tree containing this widget.
///
/// This will be [`None`] if the widget is not contained in a root widget.
///
/// Readable
///
///
/// #### `scale-factor`
/// The scale factor of the widget.
///
/// Readable
///
///
/// #### `sensitive`
/// Whether the widget responds to input.
///
/// Readable | Writeable
///
///
/// #### `tooltip-markup`
/// Sets the text of tooltip to be the given string, which is marked up
/// with Pango markup.
///
/// Also see `Gtk::Tooltip::set_markup()`.
///
/// This is a convenience property which will take care of getting the
/// tooltip shown if the given string is not [`None`]:
/// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to [`true`]
/// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
/// the default signal handler.
///
/// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
/// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
///
/// Readable | Writeable
///
///
/// #### `tooltip-text`
/// Sets the text of tooltip to be the given string.
///
/// Also see `Gtk::Tooltip::set_text()`.
///
/// This is a convenience property which will take care of getting the
/// tooltip shown if the given string is not [`None`]:
/// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to [`true`]
/// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
/// the default signal handler.
///
/// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
/// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
///
/// Readable | Writeable
///
///
/// #### `valign`
/// How to distribute vertical space if widget gets extra space.
///
/// Readable | Writeable
///
///
/// #### `vexpand`
/// Whether to expand vertically.
///
/// Readable | Writeable
///
///
/// #### `vexpand-set`
/// Whether to use the `vexpand` property.
///
/// Readable | Writeable
///
///
/// #### `visible`
/// Whether the widget is visible.
///
/// Readable | Writeable
///
///
/// #### `width-request`
/// Override for width request of the widget.
///
/// If this is -1, the natural request will be used.
///
/// Readable | Writeable
/// </details>
/// <details><summary><h4>Accessible</h4></summary>
///
///
/// #### `accessible-role`
/// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
///
/// The accessible role cannot be changed once set.
///
/// Readable | Writeable
/// </details>
///
/// ## Signals
///
///
/// #### `authenticate`
/// This signal is emitted when the user is challenged with HTTP
/// authentication. To let the application access or supply
/// the credentials as well as to allow the client application
/// to either cancel the request or perform the authentication,
/// the signal will pass an instance of the
/// #WebKitAuthenticationRequest in the @request argument.
/// To handle this signal asynchronously you should keep a ref
/// of the request and return [`true`]. To disable HTTP authentication
/// entirely, connect to this signal and simply return [`true`].
///
/// The default signal handler will run a default authentication
/// dialog asynchronously for the user to interact with.
///
///
///
///
/// #### `close`
/// Emitted when closing a #WebKitWebView is requested. This occurs when a
/// call is made from JavaScript's <function>window.close</function> function or
/// after trying to close the @web_view with webkit_web_view_try_close().
/// It is the owner's responsibility to handle this signal to hide or
/// destroy the #WebKitWebView, if necessary.
///
///
///
///
/// #### `context-menu`
/// Emitted when a context menu is about to be displayed to give the application
/// a chance to customize the proposed menu, prevent the menu from being displayed,
/// or build its own context menu.
/// <itemizedlist>
/// <listitem><para>
/// To customize the proposed menu you can use webkit_context_menu_prepend(),
/// webkit_context_menu_append() or webkit_context_menu_insert() to add new
/// #WebKitContextMenuItem<!-- -->s to @context_menu, webkit_context_menu_move_item()
/// to reorder existing items, or webkit_context_menu_remove() to remove an
/// existing item. The signal handler should return [`false`], and the menu represented
/// by @context_menu will be shown.
/// </para></listitem>
/// <listitem><para>
/// To prevent the menu from being displayed you can just connect to this signal
/// and return [`true`] so that the proposed menu will not be shown.
/// </para></listitem>
/// <listitem><para>
/// To build your own menu, you can remove all items from the proposed menu with
/// webkit_context_menu_remove_all(), add your own items and return [`false`] so
/// that the menu will be shown. You can also ignore the proposed #WebKitContextMenu,
/// build your own #GtkMenu and return [`true`] to prevent the proposed menu from being shown.
/// </para></listitem>
/// <listitem><para>
/// If you just want the default menu to be shown always, simply don't connect to this
/// signal because showing the proposed context menu is the default behaviour.
/// </para></listitem>
/// </itemizedlist>
///
/// If the signal handler returns [`false`] the context menu represented by @context_menu
/// will be shown, if it return [`true`] the context menu will not be shown.
///
/// The proposed #WebKitContextMenu passed in @context_menu argument is only valid
/// during the signal emission.
///
///
///
///
/// #### `context-menu-dismissed`
/// Emitted after #WebKitWebView::context-menu signal, if the context menu is shown,
/// to notify that the context menu is dismissed.
///
///
///
///
/// #### `create`
/// Emitted when the creation of a new #WebKitWebView is requested.
/// If this signal is handled the signal handler should return the
/// newly created #WebKitWebView.
///
/// The #WebKitNavigationAction parameter contains information about the
/// navigation action that triggered this signal.
///
/// The new #WebKitWebView must be related to @web_view, see
/// #WebKitWebView:related-view for more details.
///
/// The new #WebKitWebView should not be displayed to the user
/// until the #WebKitWebView::ready-to-show signal is emitted.
///
///
///
///
/// #### `decide-policy`
/// This signal is emitted when WebKit is requesting the client to decide a policy
/// decision, such as whether to navigate to a page, open a new window or whether or
/// not to download a resource. The #WebKitNavigationPolicyDecision passed in the
/// @decision argument is a generic type, but should be casted to a more
/// specific type when making the decision. For example:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static gboolean
/// decide_policy_cb (WebKitWebView *web_view,
/// WebKitPolicyDecision *decision,
/// WebKitPolicyDecisionType type)
/// {
/// switch (type) {
/// case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
/// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
/// // Make a policy decision here
/// break;
/// }
/// case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: {
/// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
/// // Make a policy decision here
/// break;
/// }
/// case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
/// WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision);
/// // Make a policy decision here
/// break;
/// default:
/// // Making no decision results in webkit_policy_decision_use()
/// return FALSE;
/// }
/// return TRUE;
/// }
/// ```
///
/// It is possible to make policy decision asynchronously, by simply calling g_object_ref()
/// on the @decision argument and returning [`true`] to block the default signal handler.
/// If the last reference is removed on a #WebKitPolicyDecision and no decision has been
/// made explicitly, webkit_policy_decision_use() will be the default policy decision. The
/// default signal handler will simply call webkit_policy_decision_use(). Only the first
/// policy decision chosen for a given #WebKitPolicyDecision will have any affect.
///
///
///
///
/// #### `enter-fullscreen`
/// Emitted when JavaScript code calls
/// <function>element.webkitRequestFullScreen</function>. If the
/// signal is not handled the #WebKitWebView will proceed to full screen
/// its top level window. This signal can be used by client code to
/// request permission to the user prior doing the full screen
/// transition and eventually prepare the top-level window
/// (e.g. hide some widgets that would otherwise be part of the
/// full screen window).
///
///
///
///
/// #### `insecure-content-detected`
/// Prior to 2.46, this signal was emitted when insecure content was
/// loaded in a secure content. Since 2.46, this signal is generally
/// no longer emitted.
///
///
///
///
/// #### `leave-fullscreen`
/// Emitted when the #WebKitWebView is about to restore its top level
/// window out of its full screen state. This signal can be used by
/// client code to restore widgets hidden during the
/// #WebKitWebView::enter-fullscreen stage for instance.
///
///
///
///
/// #### `load-changed`
/// Emitted when a load operation in @web_view changes.
/// The signal is always emitted with [`LoadEvent::Started`][crate::LoadEvent::Started] when a
/// new load request is made and [`LoadEvent::Finished`][crate::LoadEvent::Finished] when the load
/// finishes successfully or due to an error. When the ongoing load
/// operation fails #WebKitWebView::load-failed signal is emitted
/// before #WebKitWebView::load-changed is emitted with
/// [`LoadEvent::Finished`][crate::LoadEvent::Finished].
/// If a redirection is received from the server, this signal is emitted
/// with [`LoadEvent::Redirected`][crate::LoadEvent::Redirected] after the initial emission with
/// [`LoadEvent::Started`][crate::LoadEvent::Started] and before [`LoadEvent::Committed`][crate::LoadEvent::Committed].
/// When the page content starts arriving the signal is emitted with
/// [`LoadEvent::Committed`][crate::LoadEvent::Committed] event.
///
/// You can handle this signal and use a switch to track any ongoing
/// load operation.
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void web_view_load_changed (WebKitWebView *web_view,
/// WebKitLoadEvent load_event,
/// gpointer user_data)
/// {
/// switch (load_event) {
/// case WEBKIT_LOAD_STARTED:
/// // New load, we have now a provisional URI
/// provisional_uri = webkit_web_view_get_uri (web_view);
/// // Here we could start a spinner or update the
/// // location bar with the provisional URI
/// break;
/// case WEBKIT_LOAD_REDIRECTED:
/// redirected_uri = webkit_web_view_get_uri (web_view);
/// break;
/// case WEBKIT_LOAD_COMMITTED:
/// // The load is being performed. Current URI is
/// // the final one and it won't change unless a new
/// // load is requested or a navigation within the
/// // same page is performed
/// uri = webkit_web_view_get_uri (web_view);
/// break;
/// case WEBKIT_LOAD_FINISHED:
/// // Load finished, we can now stop the spinner
/// break;
/// }
/// }
/// ```
///
///
///
///
/// #### `load-failed`
/// Emitted when an error occurs during a load operation.
/// If the error happened when starting to load data for a page
/// @load_event will be [`LoadEvent::Started`][crate::LoadEvent::Started]. If it happened while
/// loading a committed data source @load_event will be [`LoadEvent::Committed`][crate::LoadEvent::Committed].
/// Since a load error causes the load operation to finish, the signal
/// WebKitWebView::load-changed will always be emitted with
/// [`LoadEvent::Finished`][crate::LoadEvent::Finished] event right after this one.
///
/// By default, if the signal is not handled, a stock error page will be displayed.
/// You need to handle the signal if you want to provide your own error page.
///
///
///
///
/// #### `load-failed-with-tls-errors`
/// Emitted when a TLS error occurs during a load operation.
/// To allow an exception for this @certificate
/// and the host of @failing_uri use webkit_web_context_allow_tls_certificate_for_host().
///
/// To handle this signal asynchronously you should call g_object_ref() on @certificate
/// and return [`true`].
///
/// If [`false`] is returned, #WebKitWebView::load-failed will be emitted. The load
/// will finish regardless of the returned value.
///
///
///
///
/// #### `mouse-target-changed`
/// This signal is emitted when the mouse cursor moves over an
/// element such as a link, image or a media element. To determine
/// what type of element the mouse cursor is over, a Hit Test is performed
/// on the current mouse coordinates and the result is passed in the
/// @hit_test_result argument. The @modifiers argument is a bitmask of
/// #GdkModifierType flags indicating the state of modifier keys.
/// The signal is emitted again when the mouse is moved out of the
/// current element with a new @hit_test_result.
///
///
///
///
/// #### `permission-request`
/// This signal is emitted when WebKit is requesting the client to
/// decide about a permission request, such as allowing the browser
/// to switch to fullscreen mode, sharing its location or similar
/// operations.
///
/// A possible way to use this signal could be through a dialog
/// allowing the user decide what to do with the request:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static gboolean permission_request_cb (WebKitWebView *web_view,
/// WebKitPermissionRequest *request,
/// GtkWindow *parent_window)
/// {
/// GtkWidget *dialog = gtk_message_dialog_new (parent_window,
/// GTK_DIALOG_MODAL,
/// GTK_MESSAGE_QUESTION,
/// GTK_BUTTONS_YES_NO,
/// "Allow Permission Request?");
/// gtk_widget_show (dialog);
/// gint result = gtk_dialog_run (GTK_DIALOG (dialog));
///
/// switch (result) {
/// case GTK_RESPONSE_YES:
/// webkit_permission_request_allow (request);
/// break;
/// default:
/// webkit_permission_request_deny (request);
/// break;
/// }
/// gtk_widget_destroy (dialog);
///
/// return TRUE;
/// }
/// ```
///
/// It is possible to handle permission requests asynchronously, by
/// simply calling g_object_ref() on the @request argument and
/// returning [`true`] to block the default signal handler. If the
/// last reference is removed on a #WebKitPermissionRequest and the
/// request has not been handled, webkit_permission_request_deny()
/// will be the default action.
///
/// If the signal is not handled, the @request will be completed automatically
/// by the specific #WebKitPermissionRequest that could allow or deny it. Check the
/// documentation of classes implementing #WebKitPermissionRequest interface to know
/// their default action.
///
///
///
///
/// #### `print`
/// Emitted when printing is requested on @web_view, usually by a JavaScript call,
/// before the print dialog is shown. This signal can be used to set the initial
/// print settings and page setup of @print_operation to be used as default values in
/// the print dialog. You can call webkit_print_operation_set_print_settings() and
/// webkit_print_operation_set_page_setup() and then return [`false`] to propagate the
/// event so that the print dialog is shown.
///
/// You can connect to this signal and return [`true`] to cancel the print operation
/// or implement your own print dialog.
///
///
///
///
/// #### `query-permission-state`
/// This signal allows the User-Agent to respond to permission requests for powerful features, as
/// specified by the [Permissions W3C Specification](https://w3c.github.io/permissions/).
/// You can reply to the query using webkit_permission_state_query_finish().
///
/// You can handle the query asynchronously by calling webkit_permission_state_query_ref() on
/// @query and returning [`true`]. If the last reference of @query is removed and the query has not
/// been handled, the query result will be set to `WEBKIT_QUERY_PERMISSION_PROMPT`.
///
///
///
///
/// #### `ready-to-show`
/// Emitted after #WebKitWebView::create on the newly created #WebKitWebView
/// when it should be displayed to the user. When this signal is emitted
/// all the information about how the window should look, including
/// size, position, whether the location, status and scrollbars
/// should be displayed, is already set on the #WebKitWindowProperties
/// of @web_view. See also webkit_web_view_get_window_properties().
///
///
///
///
/// #### `resource-load-started`
/// Emitted when a new resource is going to be loaded. The @request parameter
/// contains the #WebKitURIRequest that will be sent to the server.
/// You can monitor the load operation by connecting to the different signals
/// of @resource.
///
///
///
///
/// #### `run-as-modal`
/// Emitted after #WebKitWebView::ready-to-show on the newly
/// created #WebKitWebView when JavaScript code calls
/// <function>window.showModalDialog</function>. The purpose of
/// this signal is to allow the client application to prepare the
/// new view to behave as modal. Once the signal is emitted a new
/// main loop will be run to block user interaction in the parent
/// #WebKitWebView until the new dialog is closed.
///
///
///
///
/// #### `run-color-chooser`
/// This signal is emitted when the user interacts with a <input
/// type='color' /> HTML element, requesting from WebKit to show
/// a dialog to select a color. To let the application know the details of
/// the color chooser, as well as to allow the client application to either
/// cancel the request or perform an actual color selection, the signal will
/// pass an instance of the #WebKitColorChooserRequest in the @request
/// argument.
///
/// It is possible to handle this request asynchronously by increasing the
/// reference count of the request.
///
/// The default signal handler will asynchronously run a regular
/// #GtkColorChooser for the user to interact with.
///
///
///
///
/// #### `run-file-chooser`
/// This signal is emitted when the user interacts with a <input
/// type='file' /> HTML element, requesting from WebKit to show
/// a dialog to select one or more files to be uploaded. To let the
/// application know the details of the file chooser, as well as to
/// allow the client application to either cancel the request or
/// perform an actual selection of files, the signal will pass an
/// instance of the #WebKitFileChooserRequest in the @request
/// argument.
///
/// The default signal handler will asynchronously run a regular
/// #GtkFileChooserDialog for the user to interact with.
///
///
///
///
/// #### `script-dialog`
/// Emitted when JavaScript code calls <function>window.alert</function>,
/// <function>window.confirm</function> or <function>window.prompt</function>,
/// or when <function>onbeforeunload</function> event is fired.
/// The @dialog parameter should be used to build the dialog.
/// If the signal is not handled a different dialog will be built and shown depending
/// on the dialog type:
/// <itemizedlist>
/// <listitem><para>
/// [`ScriptDialogType::Alert`][crate::ScriptDialogType::Alert]: message dialog with a single Close button.
/// </para></listitem>
/// <listitem><para>
/// [`ScriptDialogType::Confirm`][crate::ScriptDialogType::Confirm]: message dialog with OK and Cancel buttons.
/// </para></listitem>
/// <listitem><para>
/// [`ScriptDialogType::Prompt`][crate::ScriptDialogType::Prompt]: message dialog with OK and Cancel buttons and
/// a text entry with the default text.
/// </para></listitem>
/// <listitem><para>
/// [`ScriptDialogType::BeforeUnloadConfirm`][crate::ScriptDialogType::BeforeUnloadConfirm]: message dialog with Stay and Leave buttons.
/// </para></listitem>
/// </itemizedlist>
///
/// It is possible to handle the script dialog request asynchronously, by simply
/// caling webkit_script_dialog_ref() on the @dialog argument and calling
/// webkit_script_dialog_close() when done.
/// If the last reference is removed on a #WebKitScriptDialog and the dialog has not been
/// closed, webkit_script_dialog_close() will be called.
///
///
///
///
/// #### `show-notification`
/// This signal is emitted when a notification should be presented to the
/// user. The @notification is kept alive until either: 1) the web page cancels it
/// or 2) a navigation happens.
///
/// The default handler will emit a notification using libnotify, if built with
/// support for it.
///
///
///
///
/// #### `show-option-menu`
/// This signal is emitted when a select element in @web_view needs to display a
/// dropdown menu. This signal can be used to show a custom menu, using @menu to get
/// the details of all items that should be displayed. The area of the element in the
/// #WebKitWebView is given as @rectangle parameter, it can be used to position the
/// menu.
/// To handle this signal asynchronously you should keep a ref of the @menu.
///
/// The default signal handler will pop up a #GtkMenu.
///
///
///
///
/// #### `submit-form`
/// This signal is emitted when a form is about to be submitted. The @request
/// argument passed contains information about the text fields of the form. This
/// is typically used to store login information that can be used later to
/// pre-fill the form.
/// The form will not be submitted until webkit_form_submission_request_submit() is called.
///
/// It is possible to handle the form submission request asynchronously, by
/// simply calling g_object_ref() on the @request argument and calling
/// webkit_form_submission_request_submit() when done to continue with the form submission.
/// If the last reference is removed on a #WebKitFormSubmissionRequest and the
/// form has not been submitted, webkit_form_submission_request_submit() will be called.
///
///
///
///
/// #### `user-message-received`
/// This signal is emitted when a #WebKitUserMessage is received from the
/// #WebKitWebPage corresponding to @web_view. You can reply to the message
/// using webkit_user_message_send_reply().
///
/// You can handle the user message asynchronously by calling g_object_ref() on
/// @message and returning [`true`]. If the last reference of @message is removed
/// and the message has not been replied to, the operation in the #WebKitWebPage will
/// finish with error [`UserMessageError::Message`][crate::UserMessageError::Message].
///
///
///
///
/// #### `web-process-terminated`
/// This signal is emitted when the web process terminates abnormally due
/// to @reason.
///
///
/// <details><summary><h4>Widget</h4></summary>
///
///
/// #### `destroy`
/// Signals that all holders of a reference to the widget should release
/// the reference that they hold.
///
/// May result in finalization of the widget if all references are released.
///
/// This signal is not suitable for saving widget state.
///
///
///
///
/// #### `direction-changed`
/// Emitted when the text direction of a widget changes.
///
///
///
///
/// #### `hide`
/// Emitted when @widget is hidden.
///
///
///
///
/// #### `keynav-failed`
/// Emitted if keyboard navigation fails.
///
/// See [`WidgetExtManual::keynav_failed()`][crate::gtk::prelude::WidgetExtManual::keynav_failed()] for details.
///
///
///
///
/// #### `map`
/// Emitted when @widget is going to be mapped.
///
/// A widget is mapped when the widget is visible (which is controlled with
/// [`visible`][struct@crate::gtk::Widget#visible]) and all its parents up to the toplevel widget
/// are also visible.
///
/// The ::map signal can be used to determine whether a widget will be drawn,
/// for instance it can resume an animation that was stopped during the
/// emission of [`unmap`][struct@crate::gtk::Widget#unmap].
///
///
///
///
/// #### `mnemonic-activate`
/// Emitted when a widget is activated via a mnemonic.
///
/// The default handler for this signal activates @widget if @group_cycling
/// is [`false`], or just makes @widget grab focus if @group_cycling is [`true`].
///
///
///
///
/// #### `move-focus`
/// Emitted when the focus is moved.
///
/// The ::move-focus signal is a [keybinding signal](class.SignalAction.html).
///
/// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
/// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
///
/// Action
///
///
/// #### `query-tooltip`
/// Emitted when the widget’s tooltip is about to be shown.
///
/// This happens when the [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] property
/// is [`true`] and the hover timeout has expired with the cursor hovering
/// "above" @widget; or emitted when @widget got focus in keyboard mode.
///
/// Using the given coordinates, the signal handler should determine
/// whether a tooltip should be shown for @widget. If this is the case
/// [`true`] should be returned, [`false`] otherwise. Note that if
/// @keyboard_mode is [`true`], the values of @x and @y are undefined and
/// should not be used.
///
/// The signal handler is free to manipulate @tooltip with the therefore
/// destined function calls.
///
///
///
///
/// #### `realize`
/// Emitted when @widget is associated with a `GdkSurface`.
///
/// This means that [`WidgetExtManual::realize()`][crate::gtk::prelude::WidgetExtManual::realize()] has been called
/// or the widget has been mapped (that is, it is going to be drawn).
///
///
///
///
/// #### `show`
/// Emitted when @widget is shown.
///
///
///
///
/// #### `state-flags-changed`
/// Emitted when the widget state changes.
///
/// See [`WidgetExtManual::state_flags()`][crate::gtk::prelude::WidgetExtManual::state_flags()].
///
///
///
///
/// #### `unmap`
/// Emitted when @widget is going to be unmapped.
///
/// A widget is unmapped when either it or any of its parents up to the
/// toplevel widget have been set as hidden.
///
/// As ::unmap indicates that a widget will not be shown any longer,
/// it can be used to, for example, stop an animation on the widget.
///
///
///
///
/// #### `unrealize`
/// Emitted when the `GdkSurface` associated with @widget is destroyed.
///
/// This means that [`WidgetExtManual::unrealize()`][crate::gtk::prelude::WidgetExtManual::unrealize()] has been called
/// or the widget has been unmapped (that is, it is going to be hidden).
///
///
/// </details>
///
/// # Implements
///
/// [`WebViewExt`][trait@crate::prelude::WebViewExt], [`WebViewBaseExt`][trait@crate::prelude::WebViewBaseExt], [`trait@gtk::prelude::WidgetExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`]
#[doc(alias = "WebKitWebView")]
pub struct WebView(Object<ffi::WebKitWebView, ffi::WebKitWebViewClass>) @extends WebViewBase, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
match fn {
type_ => || ffi::webkit_web_view_get_type(),
}
}
impl WebView {
pub const NONE: Option<&'static WebView> = None;
/// Creates a new #WebKitWebView with the default #WebKitWebContext.
///
/// Creates a new #WebKitWebView with the default #WebKitWebContext and
/// no #WebKitUserContentManager associated with it.
/// See also webkit_web_view_new_with_context(),
/// webkit_web_view_new_with_user_content_manager(), and
/// webkit_web_view_new_with_settings().
///
/// # Returns
///
/// The newly created #WebKitWebView widget
#[doc(alias = "webkit_web_view_new")]
pub fn new() -> WebView {
assert_initialized_main_thread!();
unsafe { gtk::Widget::from_glib_none(ffi::webkit_web_view_new()).unsafe_cast() }
}
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`WebView`] objects.
///
/// This method returns an instance of [`WebViewBuilder`](crate::builders::WebViewBuilder) which can be used to create [`WebView`] objects.
pub fn builder() -> WebViewBuilder {
WebViewBuilder::new()
}
}
impl Default for WebView {
fn default() -> Self {
Self::new()
}
}
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`WebView`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct WebViewBuilder {
builder: glib::object::ObjectBuilder<'static, WebView>,
}
impl WebViewBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
/// The #WebKitAutomationBrowsingContextPresentation of #WebKitWebView. This should only be used when
/// creating a new #WebKitWebView as a response to #WebKitAutomationSession::create-web-view
/// signal request. If the new WebView was added to a new tab of current browsing context window
/// [`AutomationBrowsingContextPresentation::Tab`][crate::AutomationBrowsingContextPresentation::Tab] should be used.
pub fn automation_presentation_type(
self,
automation_presentation_type: AutomationBrowsingContextPresentation,
) -> Self {
Self {
builder: self
.builder
.property("automation-presentation-type", automation_presentation_type),
}
}
/// Capture state of the camera device. Whenever the user grants a media-request sent by the web
/// page, requesting video capture capabilities (`navigator.mediaDevices.getUserMedia({video:
/// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
///
/// The application can monitor this property and provide a visual indicator allowing to optionally
/// deactivate or mute the capture device by setting this property respectively to
/// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
///
/// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
/// can still re-request the permission to the user. Permission desision caching is left to the
/// application.
pub fn camera_capture_state(self, camera_capture_state: MediaCaptureState) -> Self {
Self {
builder: self
.builder
.property("camera-capture-state", camera_capture_state),
}
}
/// The default Content-Security-Policy used by the webview as if it were set
/// by an HTTP header.
///
/// This applies to all content loaded including through navigation or via the various
/// webkit_web_view_load_\* APIs. However do note that many WebKit APIs bypass
/// Content-Security-Policy in general such as #WebKitUserContentManager and
/// webkit_web_view_run_javascript().
///
/// Policies are additive so if a website sets its own policy it still applies
/// on top of the policy set here.
pub fn default_content_security_policy(
self,
default_content_security_policy: impl Into<glib::GString>,
) -> Self {
Self {
builder: self.builder.property(
"default-content-security-policy",
default_content_security_policy.into(),
),
}
}
/// Capture state of the display device. Whenever the user grants a media-request sent by the web
/// page, requesting screencasting capabilities (`navigator.mediaDevices.getDisplayMedia() this
/// property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
///
/// The application can monitor this property and provide a visual indicator allowing to
/// optionally deactivate or mute the capture device by setting this property respectively to
/// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
///
/// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
/// can still re-request the permission to the user. Permission desision caching is left to the
/// application.
pub fn display_capture_state(self, display_capture_state: MediaCaptureState) -> Self {
Self {
builder: self
.builder
.property("display-capture-state", display_capture_state),
}
}
/// Whether the pages loaded inside #WebKitWebView are editable. For more
/// information see webkit_web_view_set_editable().
pub fn editable(self, editable: bool) -> Self {
Self {
builder: self.builder.property("editable", editable),
}
}
/// Whether the #WebKitWebView is controlled by automation. This should only be used when
/// creating a new #WebKitWebView as a response to #WebKitAutomationSession::create-web-view
/// signal request.
pub fn is_controlled_by_automation(self, is_controlled_by_automation: bool) -> Self {
Self {
builder: self
.builder
.property("is-controlled-by-automation", is_controlled_by_automation),
}
}
/// Whether the #WebKitWebView audio is muted. When [`true`], audio is silenced.
/// It may still be playing, i.e. #WebKitWebView:is-playing-audio may be [`true`].
pub fn is_muted(self, is_muted: bool) -> Self {
Self {
builder: self.builder.property("is-muted", is_muted),
}
}
/// Capture state of the microphone device. Whenever the user grants a media-request sent by the web
/// page, requesting audio capture capabilities (`navigator.mediaDevices.getUserMedia({audio:
/// true})`) this property will be set to [`MediaCaptureState::Active`][crate::MediaCaptureState::Active].
///
/// The application can monitor this property and provide a visual indicator allowing to
/// optionally deactivate or mute the capture device by setting this property respectively to
/// [`MediaCaptureState::None`][crate::MediaCaptureState::None] or [`MediaCaptureState::Muted`][crate::MediaCaptureState::Muted].
///
/// If the capture state of the device is set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] the web-page
/// can still re-request the permission to the user. Permission desision caching is left to the
/// application.
pub fn microphone_capture_state(self, microphone_capture_state: MediaCaptureState) -> Self {
Self {
builder: self
.builder
.property("microphone-capture-state", microphone_capture_state),
}
}
/// The #WebKitNetworkSession of the view
pub fn network_session(self, network_session: &NetworkSession) -> Self {
Self {
builder: self
.builder
.property("network-session", network_session.clone()),
}
}
/// The related #WebKitWebView used when creating the view to share the
/// same web process and network session. This property is not readable
/// because the related web view is only valid during the object construction.
pub fn related_view(self, related_view: &impl IsA<WebView>) -> Self {
Self {
builder: self
.builder
.property("related-view", related_view.clone().upcast()),
}
}
/// The #WebKitSettings of the view.
pub fn settings(self, settings: &Settings) -> Self {
Self {
builder: self.builder.property("settings", settings.clone()),
}
}
/// The #WebKitUserContentManager of the view.
pub fn user_content_manager(self, user_content_manager: &UserContentManager) -> Self {
Self {
builder: self
.builder
.property("user-content-manager", user_content_manager.clone()),
}
}
/// The #WebKitWebContext of the view.
pub fn web_context(self, web_context: &WebContext) -> Self {
Self {
builder: self.builder.property("web-context", web_context.clone()),
}
}
/// This configures @web_view to treat the content as a WebExtension.
///
/// Note that this refers to the web standard [WebExtensions](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions)
/// and not WebKitWebExtensions.
///
/// In practice this limits the Content-Security-Policies that are allowed to be set. Some details can be found in
/// [Chrome's documentation](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#content-security-policy).
pub fn web_extension_mode(self, web_extension_mode: WebExtensionMode) -> Self {
Self {
builder: self
.builder
.property("web-extension-mode", web_extension_mode),
}
}
/// The #WebKitWebsitePolicies for the view.
pub fn website_policies(self, website_policies: &WebsitePolicies) -> Self {
Self {
builder: self
.builder
.property("website-policies", website_policies.clone()),
}
}
/// The zoom level of the #WebKitWebView content.
/// See webkit_web_view_set_zoom_level() for more details.
pub fn zoom_level(self, zoom_level: f64) -> Self {
Self {
builder: self.builder.property("zoom-level", zoom_level),
}
}
/// Whether the widget or any of its descendents can accept
/// the input focus.
///
/// This property is meant to be set by widget implementations,
/// typically in their instance init function.
pub fn can_focus(self, can_focus: bool) -> Self {
Self {
builder: self.builder.property("can-focus", can_focus),
}
}
/// Whether the widget can receive pointer events.
pub fn can_target(self, can_target: bool) -> Self {
Self {
builder: self.builder.property("can-target", can_target),
}
}
/// A list of css classes applied to this widget.
pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
Self {
builder: self.builder.property("css-classes", css_classes.into()),
}
}
/// The name of this widget in the CSS tree.
///
/// This property is meant to be set by widget implementations,
/// typically in their instance init function.
pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("css-name", css_name.into()),
}
}
//pub fn cursor(self, cursor: /*Ignored*/&gdk::Cursor) -> Self {
// Self { builder: self.builder.property("cursor", cursor), }
//}
/// Whether the widget should grab focus when it is clicked with the mouse.
///
/// This property is only relevant for widgets that can take focus.
pub fn focus_on_click(self, focus_on_click: bool) -> Self {
Self {
builder: self.builder.property("focus-on-click", focus_on_click),
}
}
/// Whether this widget itself will accept the input focus.
pub fn focusable(self, focusable: bool) -> Self {
Self {
builder: self.builder.property("focusable", focusable),
}
}
//pub fn halign(self, halign: /*Ignored*/gtk::Align) -> Self {
// Self { builder: self.builder.property("halign", halign), }
//}
/// Enables or disables the emission of the ::query-tooltip signal on @widget.
///
/// A value of [`true`] indicates that @widget can have a tooltip, in this case
/// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
/// determine whether it will provide a tooltip or not.
pub fn has_tooltip(self, has_tooltip: bool) -> Self {
Self {
builder: self.builder.property("has-tooltip", has_tooltip),
}
}
/// Override for height request of the widget.
///
/// If this is -1, the natural request will be used.
pub fn height_request(self, height_request: i32) -> Self {
Self {
builder: self.builder.property("height-request", height_request),
}
}
/// Whether to expand horizontally.
pub fn hexpand(self, hexpand: bool) -> Self {
Self {
builder: self.builder.property("hexpand", hexpand),
}
}
/// Whether to use the `hexpand` property.
pub fn hexpand_set(self, hexpand_set: bool) -> Self {
Self {
builder: self.builder.property("hexpand-set", hexpand_set),
}
}
//pub fn layout_manager(self, layout_manager: &impl IsA</*Ignored*/gtk::LayoutManager>) -> Self {
// Self { builder: self.builder.property("layout-manager", layout_manager.clone().upcast()), }
//}
/// Margin on bottom side of widget.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
pub fn margin_bottom(self, margin_bottom: i32) -> Self {
Self {
builder: self.builder.property("margin-bottom", margin_bottom),
}
}
/// Margin on end of widget, horizontally.
///
/// This property supports left-to-right and right-to-left text
/// directions.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
pub fn margin_end(self, margin_end: i32) -> Self {
Self {
builder: self.builder.property("margin-end", margin_end),
}
}
/// Margin on start of widget, horizontally.
///
/// This property supports left-to-right and right-to-left text
/// directions.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
pub fn margin_start(self, margin_start: i32) -> Self {
Self {
builder: self.builder.property("margin-start", margin_start),
}
}
/// Margin on top side of widget.
///
/// This property adds margin outside of the widget's normal size
/// request, the margin will be added in addition to the size from
/// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
pub fn margin_top(self, margin_top: i32) -> Self {
Self {
builder: self.builder.property("margin-top", margin_top),
}
}
/// The name of the widget.
pub fn name(self, name: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("name", name.into()),
}
}
/// The requested opacity of the widget.
pub fn opacity(self, opacity: f64) -> Self {
Self {
builder: self.builder.property("opacity", opacity),
}
}
//pub fn overflow(self, overflow: /*Ignored*/gtk::Overflow) -> Self {
// Self { builder: self.builder.property("overflow", overflow), }
//}
/// Whether the widget will receive the default action when it is focused.
pub fn receives_default(self, receives_default: bool) -> Self {
Self {
builder: self.builder.property("receives-default", receives_default),
}
}
/// Whether the widget responds to input.
pub fn sensitive(self, sensitive: bool) -> Self {
Self {
builder: self.builder.property("sensitive", sensitive),
}
}
/// Sets the text of tooltip to be the given string, which is marked up
/// with Pango markup.
///
/// Also see `Gtk::Tooltip::set_markup()`.
///
/// This is a convenience property which will take care of getting the
/// tooltip shown if the given string is not [`None`]:
/// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to [`true`]
/// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
/// the default signal handler.
///
/// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
/// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
Self {
builder: self
.builder
.property("tooltip-markup", tooltip_markup.into()),
}
}
/// Sets the text of tooltip to be the given string.
///
/// Also see `Gtk::Tooltip::set_text()`.
///
/// This is a convenience property which will take care of getting the
/// tooltip shown if the given string is not [`None`]:
/// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to [`true`]
/// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
/// the default signal handler.
///
/// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
/// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("tooltip-text", tooltip_text.into()),
}
}
//pub fn valign(self, valign: /*Ignored*/gtk::Align) -> Self {
// Self { builder: self.builder.property("valign", valign), }
//}
/// Whether to expand vertically.
pub fn vexpand(self, vexpand: bool) -> Self {
Self {
builder: self.builder.property("vexpand", vexpand),
}
}
/// Whether to use the `vexpand` property.
pub fn vexpand_set(self, vexpand_set: bool) -> Self {
Self {
builder: self.builder.property("vexpand-set", vexpand_set),
}
}
/// Whether the widget is visible.
pub fn visible(self, visible: bool) -> Self {
Self {
builder: self.builder.property("visible", visible),
}
}
/// Override for width request of the widget.
///
/// If this is -1, the natural request will be used.
pub fn width_request(self, width_request: i32) -> Self {
Self {
builder: self.builder.property("width-request", width_request),
}
}
//pub fn accessible_role(self, accessible_role: /*Ignored*/gtk::AccessibleRole) -> Self {
// Self { builder: self.builder.property("accessible-role", accessible_role), }
//}
// rustdoc-stripper-ignore-next
/// Build the [`WebView`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> WebView {
self.builder.build()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::WebView>> Sealed for T {}
}
/// Trait containing all [`struct@WebView`] methods.
///
/// # Implementors
///
/// [`WebView`][struct@crate::WebView]
pub trait WebViewExt: IsA<WebView> + sealed::Sealed + 'static {
/// Asynchronously call @body with @arguments in the script world with name @world_name of the main frame current context in @self.
/// The @arguments values must be one of the following types, or contain only the following GVariant types: number, string and dictionary.
/// The result of the operation can be a Promise that will be properly passed to the callback.
/// If @world_name is [`None`], the default world is used. Any value that is not [`None`] is a distin ct world.
/// The @source_uri will be shown in exceptions and doesn't affect the behavior of the script.
/// When not provided, the document URL is used.
///
/// Note that if #WebKitSettings:enable-javascript is [`false`], this method will do nothing.
/// If you want to use this method but still prevent web content from executing its own
/// JavaScript, then use #WebKitSettings:enable-javascript-markup.
///
/// When the operation is finished, @callback will be called. You can then call
/// webkit_web_view_call_async_javascript_function_finish() to get the result of the operation.
///
/// This is an example that shows how to pass arguments to a JS function that returns a Promise
/// that resolves with the passed argument:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void
/// web_view_javascript_finished (GObject *object,
/// GAsyncResult *result,
/// gpointer user_data)
/// {
/// JSCValue *value;
/// GError *error = NULL;
///
/// value = webkit_web_view_call_async_javascript_function_finish (WEBKIT_WEB_VIEW (object), result, &error);
/// if (!value) {
/// g_warning ("Error running javascript: %s", error->message);
/// g_error_free (error);
/// return;
/// }
///
/// if (jsc_value_is_number (value)) {
/// gint32 int_value = jsc_value_to_string (value);
/// JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
/// if (exception)
/// g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
/// else
/// g_print ("Script result: %d\n", int_value);
/// g_free (str_value);
/// } else {
/// g_warning ("Error running javascript: unexpected return value");
/// }
/// g_object_unref (value);
/// }
///
/// static void
/// web_view_evaluate_promise (WebKitWebView *web_view)
/// {
/// GVariantDict dict;
/// g_variant_dict_init (&dict, NULL);
/// g_variant_dict_insert (&dict, "count", "u", 42);
/// GVariant *args = g_variant_dict_end (&dict);
/// const gchar *body = "return new Promise((resolve) => { resolve(count); });";
/// webkit_web_view_call_async_javascript_function (web_view, body, -1, arguments, NULL, NULL, NULL, web_view_javascript_finished, NULL);
/// }
/// ```
/// ## `body`
/// the function body
/// ## `length`
/// length of @body, or -1 if @body is a nul-terminated string
/// ## `arguments`
/// a #GVariant with format `a{sv}` storing the function arguments, or [`None`]
/// ## `world_name`
/// the name of a #WebKitScriptWorld or [`None`] to use the default
/// ## `source_uri`
/// the source URI
/// ## `cancellable`
/// a #GCancellable or [`None`] to ignore
/// ## `callback`
/// a #GAsyncReadyCallback to call when the script finished
#[doc(alias = "webkit_web_view_call_async_javascript_function")]
fn call_async_javascript_function<
P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static,
>(
&self,
body: &str,
arguments: Option<&glib::Variant>,
world_name: Option<&str>,
source_uri: Option<&str>,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
let length = body.len() as _;
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn call_async_javascript_function_trampoline<
P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::ptr::null_mut();
let ret = ffi::webkit_web_view_call_async_javascript_function_finish(
_source_object as *mut _,
res,
&mut error,
);
let result = if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = call_async_javascript_function_trampoline::<P>;
unsafe {
ffi::webkit_web_view_call_async_javascript_function(
self.as_ref().to_glib_none().0,
body.to_glib_none().0,
length,
arguments.to_glib_none().0,
world_name.to_glib_none().0,
source_uri.to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box_::into_raw(user_data) as *mut _,
);
}
}
fn call_async_javascript_function_future(
&self,
body: &str,
arguments: Option<&glib::Variant>,
world_name: Option<&str>,
source_uri: Option<&str>,
) -> Pin<
Box_<
dyn std::future::Future<Output = Result<javascriptcore::Value, glib::Error>> + 'static,
>,
> {
let body = String::from(body);
let arguments = arguments.map(ToOwned::to_owned);
let world_name = world_name.map(ToOwned::to_owned);
let source_uri = source_uri.map(ToOwned::to_owned);
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.call_async_javascript_function(
&body,
arguments.as_ref().map(::std::borrow::Borrow::borrow),
world_name.as_ref().map(::std::borrow::Borrow::borrow),
source_uri.as_ref().map(::std::borrow::Borrow::borrow),
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
/// Asynchronously check if it is possible to execute the given editing command.
///
/// When the operation is finished, @callback will be called. You can then call
/// webkit_web_view_can_execute_editing_command_finish() to get the result of the operation.
/// ## `command`
/// the command to check
/// ## `cancellable`
/// a #GCancellable or [`None`] to ignore
/// ## `callback`
/// a #GAsyncReadyCallback to call when the request is satisfied
#[doc(alias = "webkit_web_view_can_execute_editing_command")]
fn can_execute_editing_command<P: FnOnce(Result<(), glib::Error>) + 'static>(
&self,
command: &str,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn can_execute_editing_command_trampoline<
P: FnOnce(Result<(), glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::ptr::null_mut();
let _ = ffi::webkit_web_view_can_execute_editing_command_finish(
_source_object as *mut _,
res,
&mut error,
);
let result = if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = can_execute_editing_command_trampoline::<P>;
unsafe {
ffi::webkit_web_view_can_execute_editing_command(
self.as_ref().to_glib_none().0,
command.to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box_::into_raw(user_data) as *mut _,
);
}
}
fn can_execute_editing_command_future(
&self,
command: &str,
) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
let command = String::from(command);
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.can_execute_editing_command(&command, Some(cancellable), move |res| {
send.resolve(res);
});
}))
}
/// Determines whether @self has a previous history item.
///
/// # Returns
///
/// [`true`] if able to move back or [`false`] otherwise.
#[doc(alias = "webkit_web_view_can_go_back")]
fn can_go_back(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_can_go_back(
self.as_ref().to_glib_none().0,
))
}
}
/// Determines whether @self has a next history item.
///
/// # Returns
///
/// [`true`] if able to move forward or [`false`] otherwise.
#[doc(alias = "webkit_web_view_can_go_forward")]
fn can_go_forward(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_can_go_forward(
self.as_ref().to_glib_none().0,
))
}
}
/// Whether or not a MIME type can be displayed in @self.
/// ## `mime_type`
/// a MIME type
///
/// # Returns
///
/// [`true`] if the MIME type @mime_type can be displayed or [`false`] otherwise
#[doc(alias = "webkit_web_view_can_show_mime_type")]
fn can_show_mime_type(&self, mime_type: &str) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_can_show_mime_type(
self.as_ref().to_glib_none().0,
mime_type.to_glib_none().0,
))
}
}
/// Requests downloading of the specified URI string for @self.
/// ## `uri`
/// the URI to download
///
/// # Returns
///
/// a new #WebKitDownload representing
/// the download operation.
#[doc(alias = "webkit_web_view_download_uri")]
fn download_uri(&self, uri: &str) -> Option<Download> {
unsafe {
from_glib_full(ffi::webkit_web_view_download_uri(
self.as_ref().to_glib_none().0,
uri.to_glib_none().0,
))
}
}
/// Asynchronously evaluate @script in the script world with name @world_name of the main frame current context in @self.
/// If @world_name is [`None`], the default world is used. Any value that is not [`None`] is a distinct world.
/// The @source_uri will be shown in exceptions and doesn't affect the behavior of the script.
/// When not provided, the document URL is used.
///
/// Note that if #WebKitSettings:enable-javascript is [`false`], this method will do nothing.
/// If you want to use this method but still prevent web content from executing its own
/// JavaScript, then use #WebKitSettings:enable-javascript-markup.
///
/// When the operation is finished, @callback will be called. You can then call
/// webkit_web_view_evaluate_javascript_finish() to get the result of the operation.
///
/// This is an example of using webkit_web_view_evaluate_javascript() with a script returning
/// a string:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void
/// web_view_javascript_finished (GObject *object,
/// GAsyncResult *result,
/// gpointer user_data)
/// {
/// JSCValue *value;
/// GError *error = NULL;
///
/// value = webkit_web_view_evaluate_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error);
/// if (!value) {
/// g_warning ("Error running javascript: %s", error->message);
/// g_error_free (error);
/// return;
/// }
///
/// if (jsc_value_is_string (value)) {
/// gchar *str_value = jsc_value_to_string (value);
/// JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
/// if (exception)
/// g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
/// else
/// g_print ("Script result: %s\n", str_value);
/// g_free (str_value);
/// } else {
/// g_warning ("Error running javascript: unexpected return value");
/// }
/// g_object_unref (value);
/// }
///
/// static void
/// web_view_get_link_url (WebKitWebView *web_view,
/// const gchar *link_id)
/// {
/// gchar *script = g_strdup_printf ("window.document.getElementById('%s').href;", link_id);
/// webkit_web_view_evaluate_javascript (web_view, script, -1, NULL, NULL, NULL, web_view_javascript_finished, NULL);
/// g_free (script);
/// }
/// ```
/// ## `script`
/// the script to evaluate
/// ## `length`
/// length of @script, or -1 if @script is a nul-terminated string
/// ## `world_name`
/// the name of a #WebKitScriptWorld or [`None`] to use the default
/// ## `source_uri`
/// the source URI
/// ## `cancellable`
/// a #GCancellable or [`None`] to ignore
/// ## `callback`
/// a #GAsyncReadyCallback to call when the script finished
#[doc(alias = "webkit_web_view_evaluate_javascript")]
fn evaluate_javascript<P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static>(
&self,
script: &str,
world_name: Option<&str>,
source_uri: Option<&str>,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
let length = script.len() as _;
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn evaluate_javascript_trampoline<
P: FnOnce(Result<javascriptcore::Value, glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::ptr::null_mut();
let ret = ffi::webkit_web_view_evaluate_javascript_finish(
_source_object as *mut _,
res,
&mut error,
);
let result = if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = evaluate_javascript_trampoline::<P>;
unsafe {
ffi::webkit_web_view_evaluate_javascript(
self.as_ref().to_glib_none().0,
script.to_glib_none().0,
length,
world_name.to_glib_none().0,
source_uri.to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box_::into_raw(user_data) as *mut _,
);
}
}
fn evaluate_javascript_future(
&self,
script: &str,
world_name: Option<&str>,
source_uri: Option<&str>,
) -> Pin<
Box_<
dyn std::future::Future<Output = Result<javascriptcore::Value, glib::Error>> + 'static,
>,
> {
let script = String::from(script);
let world_name = world_name.map(ToOwned::to_owned);
let source_uri = source_uri.map(ToOwned::to_owned);
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.evaluate_javascript(
&script,
world_name.as_ref().map(::std::borrow::Borrow::borrow),
source_uri.as_ref().map(::std::borrow::Borrow::borrow),
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
/// Request to execute the given @command for @self.
///
/// You can use webkit_web_view_can_execute_editing_command() to check whether
/// it's possible to execute the command.
/// ## `command`
/// the command to execute
#[doc(alias = "webkit_web_view_execute_editing_command")]
fn execute_editing_command(&self, command: &str) {
unsafe {
ffi::webkit_web_view_execute_editing_command(
self.as_ref().to_glib_none().0,
command.to_glib_none().0,
);
}
}
/// Request to execute the given @command with @argument for @self.
///
/// You can use
/// webkit_web_view_can_execute_editing_command() to check whether
/// it's possible to execute the command.
/// ## `command`
/// the command to execute
/// ## `argument`
/// the command argument
#[doc(alias = "webkit_web_view_execute_editing_command_with_argument")]
fn execute_editing_command_with_argument(&self, command: &str, argument: &str) {
unsafe {
ffi::webkit_web_view_execute_editing_command_with_argument(
self.as_ref().to_glib_none().0,
command.to_glib_none().0,
argument.to_glib_none().0,
);
}
}
/// Get the presentation type of #WebKitWebView when created for automation.
///
/// # Returns
///
/// a #WebKitAutomationBrowsingContextPresentation.
#[doc(alias = "webkit_web_view_get_automation_presentation_type")]
#[doc(alias = "get_automation_presentation_type")]
#[doc(alias = "automation-presentation-type")]
fn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation {
unsafe {
from_glib(ffi::webkit_web_view_get_automation_presentation_type(
self.as_ref().to_glib_none().0,
))
}
}
/// Obtains the #WebKitBackForwardList associated with the given #WebKitWebView.
///
/// The #WebKitBackForwardList is owned by the #WebKitWebView.
///
/// # Returns
///
/// the #WebKitBackForwardList
#[doc(alias = "webkit_web_view_get_back_forward_list")]
#[doc(alias = "get_back_forward_list")]
fn back_forward_list(&self) -> Option<BackForwardList> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_back_forward_list(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the color that is used to draw the @self background.
///
/// Gets the color that is used to draw the @self background before
/// the actual contents are rendered.
/// For more information see also webkit_web_view_set_background_color()
///
/// # Returns
///
///
/// ## `rgba`
/// a #GdkRGBA to fill in with the background color
#[doc(alias = "webkit_web_view_get_background_color")]
#[doc(alias = "get_background_color")]
fn background_color(&self) -> gdk::RGBA {
unsafe {
let mut rgba = gdk::RGBA::uninitialized();
ffi::webkit_web_view_get_background_color(
self.as_ref().to_glib_none().0,
rgba.to_glib_none_mut().0,
);
rgba
}
}
/// Get the camera capture state of a #WebKitWebView.
///
/// # Returns
///
/// The #WebKitMediaCaptureState of the camera device. If #WebKitSettings:enable-mediastream
/// is [`false`], this method will return [`MediaCaptureState::None`][crate::MediaCaptureState::None].
#[doc(alias = "webkit_web_view_get_camera_capture_state")]
#[doc(alias = "get_camera_capture_state")]
#[doc(alias = "camera-capture-state")]
fn camera_capture_state(&self) -> MediaCaptureState {
unsafe {
from_glib(ffi::webkit_web_view_get_camera_capture_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the web context of @self.
///
/// # Returns
///
/// the #WebKitWebContext of the view
#[doc(alias = "webkit_web_view_get_context")]
#[doc(alias = "get_context")]
fn context(&self) -> Option<WebContext> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_context(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the current custom character encoding name of @self.
///
/// # Returns
///
/// the current custom character encoding name or [`None`] if no
/// custom character encoding has been set.
#[doc(alias = "webkit_web_view_get_custom_charset")]
#[doc(alias = "get_custom_charset")]
fn custom_charset(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_custom_charset(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the configured default Content-Security-Policy.
///
/// # Returns
///
/// The default policy or [`None`]
#[doc(alias = "webkit_web_view_get_default_content_security_policy")]
#[doc(alias = "get_default_content_security_policy")]
#[doc(alias = "default-content-security-policy")]
fn default_content_security_policy(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_default_content_security_policy(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the display capture state of a #WebKitWebView.
///
/// # Returns
///
/// The #WebKitMediaCaptureState of the display device. If #WebKitSettings:enable-mediastream
/// is [`false`], this method will return [`MediaCaptureState::None`][crate::MediaCaptureState::None].
#[doc(alias = "webkit_web_view_get_display_capture_state")]
#[doc(alias = "get_display_capture_state")]
#[doc(alias = "display-capture-state")]
fn display_capture_state(&self) -> MediaCaptureState {
unsafe {
from_glib(ffi::webkit_web_view_get_display_capture_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the web editor state of @self.
///
/// # Returns
///
/// the #WebKitEditorState of the view
#[doc(alias = "webkit_web_view_get_editor_state")]
#[doc(alias = "get_editor_state")]
fn editor_state(&self) -> Option<EditorState> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_editor_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the value of the #WebKitWebView:estimated-load-progress property.
///
/// You can monitor the estimated progress of a load operation by
/// connecting to the notify::estimated-load-progress signal of @self.
///
/// # Returns
///
/// an estimate of the of the percent complete for a document
/// load as a range from 0.0 to 1.0.
#[doc(alias = "webkit_web_view_get_estimated_load_progress")]
#[doc(alias = "get_estimated_load_progress")]
#[doc(alias = "estimated-load-progress")]
fn estimated_load_progress(&self) -> f64 {
unsafe { ffi::webkit_web_view_get_estimated_load_progress(self.as_ref().to_glib_none().0) }
}
/// Returns favicon currently associated to @self.
///
/// Returns favicon currently associated to @self, if any. You can
/// connect to notify::favicon signal of @self to be notified when
/// the favicon is available.
///
/// # Returns
///
/// the favicon image or [`None`] if there's no
/// icon associated with @self.
#[doc(alias = "webkit_web_view_get_favicon")]
#[doc(alias = "get_favicon")]
fn favicon(&self) -> Option<gdk::Texture> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_favicon(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the #WebKitFindController.
///
/// Gets the #WebKitFindController that will allow the caller to query
/// the #WebKitWebView for the text to look for.
///
/// # Returns
///
/// the #WebKitFindController associated to
/// this particular #WebKitWebView.
#[doc(alias = "webkit_web_view_get_find_controller")]
#[doc(alias = "get_find_controller")]
fn find_controller(&self) -> Option<FindController> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_find_controller(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the #WebKitInputMethodContext currently in use by @self.
///
/// Get the #WebKitInputMethodContext currently in use by @self, or [`None`] if no input method is being used.
///
/// # Returns
///
/// a #WebKitInputMethodContext, or [`None`]
#[doc(alias = "webkit_web_view_get_input_method_context")]
#[doc(alias = "get_input_method_context")]
fn input_method_context(&self) -> Option<InputMethodContext> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_input_method_context(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the #WebKitWebInspector associated to @self
///
/// # Returns
///
/// the #WebKitWebInspector of @self
#[doc(alias = "webkit_web_view_get_inspector")]
#[doc(alias = "get_inspector")]
fn inspector(&self) -> Option<WebInspector> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_inspector(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the mute state of @self.
///
/// # Returns
///
/// [`true`] if @self audio is muted or [`false`] is audio is not muted.
#[doc(alias = "webkit_web_view_get_is_muted")]
#[doc(alias = "get_is_muted")]
#[doc(alias = "is-muted")]
fn is_muted(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_get_is_muted(
self.as_ref().to_glib_none().0,
))
}
}
/// Get whether the current web process of a #WebKitWebView is responsive.
///
/// # Returns
///
/// [`true`] if the web process attached to @self is responsive, or [`false`] otherwise.
#[doc(alias = "webkit_web_view_get_is_web_process_responsive")]
#[doc(alias = "get_is_web_process_responsive")]
#[doc(alias = "is-web-process-responsive")]
fn is_web_process_responsive(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_get_is_web_process_responsive(
self.as_ref().to_glib_none().0,
))
}
}
/// Return the main resource of @self.
///
/// # Returns
///
/// the main #WebKitWebResource of the view
/// or [`None`] if nothing has been loaded.
#[doc(alias = "webkit_web_view_get_main_resource")]
#[doc(alias = "get_main_resource")]
fn main_resource(&self) -> Option<WebResource> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_main_resource(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the microphone capture state of a #WebKitWebView.
///
/// # Returns
///
/// The #WebKitMediaCaptureState of the microphone device. If #WebKitSettings:enable-mediastream
/// is [`false`], this method will return [`MediaCaptureState::None`][crate::MediaCaptureState::None].
#[doc(alias = "webkit_web_view_get_microphone_capture_state")]
#[doc(alias = "get_microphone_capture_state")]
#[doc(alias = "microphone-capture-state")]
fn microphone_capture_state(&self) -> MediaCaptureState {
unsafe {
from_glib(ffi::webkit_web_view_get_microphone_capture_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the #WebKitNetworkSession associated to @self.
///
/// # Returns
///
/// a #WebKitNetworkSession
#[doc(alias = "webkit_web_view_get_network_session")]
#[doc(alias = "get_network_session")]
#[doc(alias = "network-session")]
fn network_session(&self) -> Option<NetworkSession> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_network_session(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the identifier of the #WebKitWebPage corresponding to
/// the #WebKitWebView
///
/// # Returns
///
/// the page ID of @self.
#[doc(alias = "webkit_web_view_get_page_id")]
#[doc(alias = "get_page_id")]
#[doc(alias = "page-id")]
fn page_id(&self) -> u64 {
unsafe { ffi::webkit_web_view_get_page_id(self.as_ref().to_glib_none().0) }
}
/// Gets the current session state of @self
///
/// # Returns
///
/// a #WebKitWebViewSessionState
#[doc(alias = "webkit_web_view_get_session_state")]
#[doc(alias = "get_session_state")]
fn session_state(&self) -> Option<WebViewSessionState> {
unsafe {
from_glib_full(ffi::webkit_web_view_get_session_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the #WebKitSettings currently applied to @self.
///
/// If no other #WebKitSettings have been explicitly applied to
/// @self with webkit_web_view_set_settings(), the default
/// #WebKitSettings will be returned. This method always returns
/// a valid #WebKitSettings object.
/// To modify any of the @self settings, you can either create
/// a new #WebKitSettings object with webkit_settings_new(), setting
/// the desired preferences, and then replace the existing @self
/// settings with webkit_web_view_set_settings() or get the existing
/// @self settings and update it directly. #WebKitSettings objects
/// can be shared by multiple #WebKitWebView<!-- -->s, so modifying
/// the settings of a #WebKitWebView would affect other
/// #WebKitWebView<!-- -->s using the same #WebKitSettings.
///
/// # Returns
///
/// the #WebKitSettings attached to @self
#[doc(alias = "webkit_web_view_get_settings")]
#[doc(alias = "get_settings")]
fn settings(&self) -> Option<Settings> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_settings(
self.as_ref().to_glib_none().0,
))
}
}
/// Asynchronously retrieves a snapshot of @self for @region.
///
/// @options specifies how the snapshot should be rendered.
///
/// When the operation is finished, @callback will be called. You must
/// call webkit_web_view_get_snapshot_finish() to get the result of the
/// operation.
/// ## `region`
/// the #WebKitSnapshotRegion for this snapshot
/// ## `options`
/// #WebKitSnapshotOptions for the snapshot
/// ## `cancellable`
/// a #GCancellable
/// ## `callback`
/// a #GAsyncReadyCallback
#[doc(alias = "webkit_web_view_get_snapshot")]
#[doc(alias = "get_snapshot")]
fn snapshot<P: FnOnce(Result<gdk::Texture, glib::Error>) + 'static>(
&self,
region: SnapshotRegion,
options: SnapshotOptions,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn snapshot_trampoline<
P: FnOnce(Result<gdk::Texture, glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::ptr::null_mut();
let ret =
ffi::webkit_web_view_get_snapshot_finish(_source_object as *mut _, res, &mut error);
let result = if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = snapshot_trampoline::<P>;
unsafe {
ffi::webkit_web_view_get_snapshot(
self.as_ref().to_glib_none().0,
region.into_glib(),
options.into_glib(),
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box_::into_raw(user_data) as *mut _,
);
}
}
fn snapshot_future(
&self,
region: SnapshotRegion,
options: SnapshotOptions,
) -> Pin<Box_<dyn std::future::Future<Output = Result<gdk::Texture, glib::Error>> + 'static>>
{
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.snapshot(region, options, Some(cancellable), move |res| {
send.resolve(res);
});
}))
}
/// Gets the value of the #WebKitWebView:title property.
///
/// You can connect to notify::title signal of @self to
/// be notified when the title has been received.
///
/// # Returns
///
/// The main frame document title of @self.
#[doc(alias = "webkit_web_view_get_title")]
#[doc(alias = "get_title")]
fn title(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_title(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the #GTlsCertificate associated with the main resource of @self.
///
/// Retrieves the #GTlsCertificate associated with the main resource of @self,
/// and the #GTlsCertificateFlags showing what problems, if any, have been found
/// with that certificate.
/// If the connection is not HTTPS, this function returns [`false`].
/// This function should be called after a response has been received from the
/// server, so you can connect to #WebKitWebView::load-changed and call this function
/// when it's emitted with [`LoadEvent::Committed`][crate::LoadEvent::Committed] event.
///
/// Note that this function provides no information about the security of the web
/// page if the current #WebKitTLSErrorsPolicy is [`TLSErrorsPolicy::Ignore`][crate::TLSErrorsPolicy::Ignore],
/// as subresources of the page may be controlled by an attacker. This function
/// may safely be used to determine the security status of the current page only
/// if the current #WebKitTLSErrorsPolicy is [`TLSErrorsPolicy::Fail`][crate::TLSErrorsPolicy::Fail], in
/// which case subresources that fail certificate verification will be blocked.
///
/// # Returns
///
/// [`true`] if the @self connection uses HTTPS and a response has been received
/// from the server, or [`false`] otherwise.
///
/// ## `certificate`
/// return location for a #GTlsCertificate
///
/// ## `errors`
/// return location for a #GTlsCertificateFlags the verification status of @certificate
#[doc(alias = "webkit_web_view_get_tls_info")]
#[doc(alias = "get_tls_info")]
fn tls_info(&self) -> Option<(gio::TlsCertificate, gio::TlsCertificateFlags)> {
unsafe {
let mut certificate = std::ptr::null_mut();
let mut errors = std::mem::MaybeUninit::uninit();
let ret = from_glib(ffi::webkit_web_view_get_tls_info(
self.as_ref().to_glib_none().0,
&mut certificate,
errors.as_mut_ptr(),
));
if ret {
Some((from_glib_none(certificate), from_glib(errors.assume_init())))
} else {
None
}
}
}
/// Returns the current active URI of @self.
///
/// The active URI might change during
/// a load operation:
///
/// <orderedlist>
/// <listitem><para>
/// When nothing has been loaded yet on @self the active URI is [`None`].
/// </para></listitem>
/// <listitem><para>
/// When a new load operation starts the active URI is the requested URI:
/// <itemizedlist>
/// <listitem><para>
/// If the load operation was started by webkit_web_view_load_uri(),
/// the requested URI is the given one.
/// </para></listitem>
/// <listitem><para>
/// If the load operation was started by webkit_web_view_load_html(),
/// the requested URI is "about:blank".
/// </para></listitem>
/// <listitem><para>
/// If the load operation was started by webkit_web_view_load_alternate_html(),
/// the requested URI is content URI provided.
/// </para></listitem>
/// <listitem><para>
/// If the load operation was started by webkit_web_view_go_back() or
/// webkit_web_view_go_forward(), the requested URI is the original URI
/// of the previous/next item in the #WebKitBackForwardList of @self.
/// </para></listitem>
/// <listitem><para>
/// If the load operation was started by
/// webkit_web_view_go_to_back_forward_list_item(), the requested URI
/// is the opriginal URI of the given #WebKitBackForwardListItem.
/// </para></listitem>
/// </itemizedlist>
/// </para></listitem>
/// <listitem><para>
/// If there is a server redirection during the load operation,
/// the active URI is the redirected URI. When the signal
/// #WebKitWebView::load-changed is emitted with [`LoadEvent::Redirected`][crate::LoadEvent::Redirected]
/// event, the active URI is already updated to the redirected URI.
/// </para></listitem>
/// <listitem><para>
/// When the signal #WebKitWebView::load-changed is emitted
/// with [`LoadEvent::Committed`][crate::LoadEvent::Committed] event, the active URI is the final
/// one and it will not change unless a new load operation is started
/// or a navigation action within the same page is performed.
/// </para></listitem>
/// </orderedlist>
///
/// You can monitor the active URI by connecting to the notify::uri
/// signal of @self.
///
/// # Returns
///
/// the current active URI of @self or [`None`]
/// if nothing has been loaded yet.
#[doc(alias = "webkit_web_view_get_uri")]
#[doc(alias = "get_uri")]
fn uri(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::webkit_web_view_get_uri(self.as_ref().to_glib_none().0)) }
}
/// Gets the user content manager associated to @self.
///
/// # Returns
///
/// the #WebKitUserContentManager associated with the view
#[doc(alias = "webkit_web_view_get_user_content_manager")]
#[doc(alias = "get_user_content_manager")]
#[doc(alias = "user-content-manager")]
fn user_content_manager(&self) -> Option<UserContentManager> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_user_content_manager(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the view's #WebKitWebExtensionMode.
///
/// # Returns
///
/// the #WebKitWebExtensionMode
#[doc(alias = "webkit_web_view_get_web_extension_mode")]
#[doc(alias = "get_web_extension_mode")]
#[doc(alias = "web-extension-mode")]
fn web_extension_mode(&self) -> WebExtensionMode {
unsafe {
from_glib(ffi::webkit_web_view_get_web_extension_mode(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the default website policies.
///
/// Gets the default website policies set on construction in the
/// @self. These can be overridden on a per-origin basis via the
/// #WebKitWebView::decide-policy signal handler.
///
/// See also webkit_policy_decision_use_with_policies().
///
/// # Returns
///
/// the default #WebKitWebsitePolicies
/// associated with the view.
#[doc(alias = "webkit_web_view_get_website_policies")]
#[doc(alias = "get_website_policies")]
#[doc(alias = "website-policies")]
fn website_policies(&self) -> Option<WebsitePolicies> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_website_policies(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the #WebKitWindowProperties object.
///
/// Get the #WebKitWindowProperties object containing the properties
/// that the window containing @self should have.
///
/// # Returns
///
/// the #WebKitWindowProperties of @self
#[doc(alias = "webkit_web_view_get_window_properties")]
#[doc(alias = "get_window_properties")]
fn window_properties(&self) -> Option<WindowProperties> {
unsafe {
from_glib_none(ffi::webkit_web_view_get_window_properties(
self.as_ref().to_glib_none().0,
))
}
}
/// Set the zoom level of @self.
///
/// Get the zoom level of @self, i.e. the factor by which the
/// view contents are scaled with respect to their original size.
///
/// # Returns
///
/// the current zoom level of @self
#[doc(alias = "webkit_web_view_get_zoom_level")]
#[doc(alias = "get_zoom_level")]
#[doc(alias = "zoom-level")]
fn zoom_level(&self) -> f64 {
unsafe { ffi::webkit_web_view_get_zoom_level(self.as_ref().to_glib_none().0) }
}
/// Loads the previous history item.
///
/// You can monitor the load operation by connecting to
/// #WebKitWebView::load-changed signal.
#[doc(alias = "webkit_web_view_go_back")]
fn go_back(&self) {
unsafe {
ffi::webkit_web_view_go_back(self.as_ref().to_glib_none().0);
}
}
/// Loads the next history item.
///
/// You can monitor the load operation by connecting to
/// #WebKitWebView::load-changed signal.
#[doc(alias = "webkit_web_view_go_forward")]
fn go_forward(&self) {
unsafe {
ffi::webkit_web_view_go_forward(self.as_ref().to_glib_none().0);
}
}
/// Loads the specific history item @list_item.
///
/// You can monitor the load operation by connecting to
/// #WebKitWebView::load-changed signal.
/// ## `list_item`
/// a #WebKitBackForwardListItem
#[doc(alias = "webkit_web_view_go_to_back_forward_list_item")]
fn go_to_back_forward_list_item(&self, list_item: &BackForwardListItem) {
unsafe {
ffi::webkit_web_view_go_to_back_forward_list_item(
self.as_ref().to_glib_none().0,
list_item.to_glib_none().0,
);
}
}
/// Get whether a #WebKitWebView was created with #WebKitWebView:is-controlled-by-automation
/// property enabled.
///
/// Only #WebKitWebView<!-- -->s controlled by automation can be used in an
/// automation session.
///
/// # Returns
///
/// [`true`] if @self is controlled by automation, or [`false`] otherwise.
#[doc(alias = "webkit_web_view_is_controlled_by_automation")]
fn is_controlled_by_automation(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_is_controlled_by_automation(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets whether the user is allowed to edit the HTML document.
///
/// When @self is not editable an element in the HTML document can only be edited if the
/// CONTENTEDITABLE attribute has been set on the element or one of its parent
/// elements. By default a #WebKitWebView is not editable.
///
/// # Returns
///
/// [`true`] if the user is allowed to edit the HTML document, or [`false`] otherwise.
#[doc(alias = "webkit_web_view_is_editable")]
#[doc(alias = "editable")]
fn is_editable(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_is_editable(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the value of the #WebKitWebView:is-loading property.
///
/// You can monitor when a #WebKitWebView is loading a page by connecting to
/// notify::is-loading signal of @self. This is useful when you are
/// interesting in knowing when the view is loading something but not in the
/// details about the status of the load operation, for example to start a spinner
/// when the view is loading a page and stop it when it finishes.
///
/// # Returns
///
/// [`true`] if @self is loading a page or [`false`] otherwise.
#[doc(alias = "webkit_web_view_is_loading")]
#[doc(alias = "is-loading")]
fn is_loading(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_is_loading(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the value of the #WebKitWebView:is-playing-audio property.
///
/// You can monitor when a page in a #WebKitWebView is playing audio by
/// connecting to the notify::is-playing-audio signal of @self. This
/// is useful when the application wants to provide visual feedback when a
/// page is producing sound.
///
/// # Returns
///
/// [`true`] if a page in @self is playing audio or [`false`] otherwise.
#[doc(alias = "webkit_web_view_is_playing_audio")]
#[doc(alias = "is-playing-audio")]
fn is_playing_audio(&self) -> bool {
unsafe {
from_glib(ffi::webkit_web_view_is_playing_audio(
self.as_ref().to_glib_none().0,
))
}
}
/// Load the given @content string for the URI @content_uri.
///
/// This allows clients to display page-loading errors in the #WebKitWebView itself.
/// When this method is called from #WebKitWebView::load-failed signal to show an
/// error page, then the back-forward list is maintained appropriately.
/// For everything else this method works the same way as webkit_web_view_load_html().
/// ## `content`
/// the new content to display as the main page of the @self
/// ## `content_uri`
/// the URI for the alternate page content
/// ## `base_uri`
/// the base URI for relative locations or [`None`]
#[doc(alias = "webkit_web_view_load_alternate_html")]
fn load_alternate_html(&self, content: &str, content_uri: &str, base_uri: Option<&str>) {
unsafe {
ffi::webkit_web_view_load_alternate_html(
self.as_ref().to_glib_none().0,
content.to_glib_none().0,
content_uri.to_glib_none().0,
base_uri.to_glib_none().0,
);
}
}
/// Load the specified @bytes into @self using the given @mime_type and @encoding.
///
/// When @mime_type is [`None`], it defaults to "text/html".
/// When @encoding is [`None`], it defaults to "UTF-8".
/// When @base_uri is [`None`], it defaults to "about:blank".
/// You can monitor the load operation by connecting to #WebKitWebView::load-changed signal.
/// ## `bytes`
/// input data to load
/// ## `mime_type`
/// the MIME type of @bytes, or [`None`]
/// ## `encoding`
/// the character encoding of @bytes, or [`None`]
/// ## `base_uri`
/// the base URI for relative locations or [`None`]
#[doc(alias = "webkit_web_view_load_bytes")]
fn load_bytes(
&self,
bytes: &glib::Bytes,
mime_type: Option<&str>,
encoding: Option<&str>,
base_uri: Option<&str>,
) {
unsafe {
ffi::webkit_web_view_load_bytes(
self.as_ref().to_glib_none().0,
bytes.to_glib_none().0,
mime_type.to_glib_none().0,
encoding.to_glib_none().0,
base_uri.to_glib_none().0,
);
}
}
/// Load the given @content string with the specified @base_uri.
///
/// If @base_uri is not [`None`], relative URLs in the @content will be
/// resolved against @base_uri and absolute local paths must be children of the @base_uri.
/// For security reasons absolute local paths that are not children of @base_uri
/// will cause the web process to terminate.
/// If you need to include URLs in @content that are local paths in a different
/// directory than @base_uri you can build a data URI for them. When @base_uri is [`None`],
/// it defaults to "about:blank". The mime type of the document will be "text/html".
/// You can monitor the load operation by connecting to #WebKitWebView::load-changed signal.
/// ## `content`
/// The HTML string to load
/// ## `base_uri`
/// The base URI for relative locations or [`None`]
#[doc(alias = "webkit_web_view_load_html")]
fn load_html(&self, content: &str, base_uri: Option<&str>) {
unsafe {
ffi::webkit_web_view_load_html(
self.as_ref().to_glib_none().0,
content.to_glib_none().0,
base_uri.to_glib_none().0,
);
}
}
/// Load the specified @plain_text string into @self.
///
/// The mime type of document will be "text/plain". You can monitor the load
/// operation by connecting to #WebKitWebView::load-changed signal.
/// ## `plain_text`
/// The plain text to load
#[doc(alias = "webkit_web_view_load_plain_text")]
fn load_plain_text(&self, plain_text: &str) {
unsafe {
ffi::webkit_web_view_load_plain_text(
self.as_ref().to_glib_none().0,
plain_text.to_glib_none().0,
);
}
}
/// Requests loading of the specified #WebKitURIRequest.
///
/// You can monitor the load operation by connecting to
/// #WebKitWebView::load-changed signal.
/// ## `request`
/// a #WebKitURIRequest to load
#[doc(alias = "webkit_web_view_load_request")]
fn load_request(&self, request: &URIRequest) {
unsafe {
ffi::webkit_web_view_load_request(
self.as_ref().to_glib_none().0,
request.to_glib_none().0,
);
}
}
/// Requests loading of the specified URI string.
///
/// You can monitor the load operation by connecting to
/// #WebKitWebView::load-changed signal.
/// ## `uri`
/// an URI string
#[doc(alias = "webkit_web_view_load_uri")]
fn load_uri(&self, uri: &str) {
unsafe {
ffi::webkit_web_view_load_uri(self.as_ref().to_glib_none().0, uri.to_glib_none().0);
}
}
/// Reloads the current contents of @self.
///
/// See also webkit_web_view_reload_bypass_cache().
#[doc(alias = "webkit_web_view_reload")]
fn reload(&self) {
unsafe {
ffi::webkit_web_view_reload(self.as_ref().to_glib_none().0);
}
}
/// Reloads the current contents of @self without
/// using any cached data.
#[doc(alias = "webkit_web_view_reload_bypass_cache")]
fn reload_bypass_cache(&self) {
unsafe {
ffi::webkit_web_view_reload_bypass_cache(self.as_ref().to_glib_none().0);
}
}
/// Restore the @self session state from @state
/// ## `state`
/// a #WebKitWebViewSessionState
#[doc(alias = "webkit_web_view_restore_session_state")]
fn restore_session_state(&self, state: &WebViewSessionState) {
unsafe {
ffi::webkit_web_view_restore_session_state(
self.as_ref().to_glib_none().0,
state.to_glib_none().0,
);
}
}
/// Asynchronously save the current web page.
///
/// Asynchronously save the current web page associated to the
/// #WebKitWebView into a self-contained format using the mode
/// specified in @save_mode.
///
/// When the operation is finished, @callback will be called. You can
/// then call webkit_web_view_save_finish() to get the result of the
/// operation.
/// ## `save_mode`
/// the #WebKitSaveMode specifying how the web page should be saved.
/// ## `cancellable`
/// a #GCancellable or [`None`] to ignore
/// ## `callback`
/// a #GAsyncReadyCallback to call when the request is satisfied
#[doc(alias = "webkit_web_view_save")]
fn save<P: FnOnce(Result<gio::InputStream, glib::Error>) + 'static>(
&self,
save_mode: SaveMode,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn save_trampoline<
P: FnOnce(Result<gio::InputStream, glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::ptr::null_mut();
let ret = ffi::webkit_web_view_save_finish(_source_object as *mut _, res, &mut error);
let result = if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = save_trampoline::<P>;
unsafe {
ffi::webkit_web_view_save(
self.as_ref().to_glib_none().0,
save_mode.into_glib(),
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box_::into_raw(user_data) as *mut _,
);
}
}
fn save_future(
&self,
save_mode: SaveMode,
) -> Pin<Box_<dyn std::future::Future<Output = Result<gio::InputStream, glib::Error>> + 'static>>
{
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.save(save_mode, Some(cancellable), move |res| {
send.resolve(res);
});
}))
}
/// Asynchronously save the current web page.
///
/// Asynchronously save the current web page associated to the
/// #WebKitWebView into a self-contained format using the mode
/// specified in @save_mode and writing it to @file.
///
/// When the operation is finished, @callback will be called. You can
/// then call webkit_web_view_save_to_file_finish() to get the result of the
/// operation.
/// ## `file`
/// the #GFile where the current web page should be saved to.
/// ## `save_mode`
/// the #WebKitSaveMode specifying how the web page should be saved.
/// ## `cancellable`
/// a #GCancellable or [`None`] to ignore
/// ## `callback`
/// a #GAsyncReadyCallback to call when the request is satisfied
#[doc(alias = "webkit_web_view_save_to_file")]
fn save_to_file<P: FnOnce(Result<(), glib::Error>) + 'static>(
&self,
file: &impl IsA<gio::File>,
save_mode: SaveMode,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn save_to_file_trampoline<
P: FnOnce(Result<(), glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::ptr::null_mut();
let _ =
ffi::webkit_web_view_save_to_file_finish(_source_object as *mut _, res, &mut error);
let result = if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = save_to_file_trampoline::<P>;
unsafe {
ffi::webkit_web_view_save_to_file(
self.as_ref().to_glib_none().0,
file.as_ref().to_glib_none().0,
save_mode.into_glib(),
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box_::into_raw(user_data) as *mut _,
);
}
}
fn save_to_file_future(
&self,
file: &(impl IsA<gio::File> + Clone + 'static),
save_mode: SaveMode,
) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
let file = file.clone();
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.save_to_file(&file, save_mode, Some(cancellable), move |res| {
send.resolve(res);
});
}))
}
/// Send @message to the #WebKitWebPage corresponding to @self.
///
/// If @message is floating, it's consumed.
/// If you don't expect any reply, or you simply want to ignore it, you can pass [`None`] as @callback.
/// When the operation is finished, @callback will be called. You can then call
/// webkit_web_view_send_message_to_page_finish() to get the message reply.
/// ## `message`
/// a #WebKitUserMessage
/// ## `cancellable`
/// a #GCancellable or [`None`] to ignore
/// ## `callback`
/// (nullable): A #GAsyncReadyCallback to call when the request is satisfied or [`None`]
#[doc(alias = "webkit_web_view_send_message_to_page")]
fn send_message_to_page<P: FnOnce(Result<UserMessage, glib::Error>) + 'static>(
&self,
message: &UserMessage,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn send_message_to_page_trampoline<
P: FnOnce(Result<UserMessage, glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::ptr::null_mut();
let ret = ffi::webkit_web_view_send_message_to_page_finish(
_source_object as *mut _,
res,
&mut error,
);
let result = if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = send_message_to_page_trampoline::<P>;
unsafe {
ffi::webkit_web_view_send_message_to_page(
self.as_ref().to_glib_none().0,
message.to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box_::into_raw(user_data) as *mut _,
);
}
}
fn send_message_to_page_future(
&self,
message: &UserMessage,
) -> Pin<Box_<dyn std::future::Future<Output = Result<UserMessage, glib::Error>> + 'static>>
{
let message = message.clone();
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.send_message_to_page(&message, Some(cancellable), move |res| {
send.resolve(res);
});
}))
}
/// Sets the color that will be used to draw the @self background.
///
/// Sets the color that will be used to draw the @self background before
/// the actual contents are rendered. Note that if the web page loaded in @self
/// specifies a background color, it will take precedence over the @rgba color.
/// By default the @self background color is opaque white.
/// ## `rgba`
/// a #GdkRGBA
#[doc(alias = "webkit_web_view_set_background_color")]
fn set_background_color(&self, rgba: &gdk::RGBA) {
unsafe {
ffi::webkit_web_view_set_background_color(
self.as_ref().to_glib_none().0,
rgba.to_glib_none().0,
);
}
}
/// Set the camera capture state of a #WebKitWebView.
///
/// If #WebKitSettings:enable-mediastream is [`false`], this method will have no visible effect. Once the
/// state of the device has been set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] it cannot be changed
/// anymore. The page can however request capture again using the mediaDevices API.
/// ## `state`
/// a #WebKitMediaCaptureState
#[doc(alias = "webkit_web_view_set_camera_capture_state")]
#[doc(alias = "camera-capture-state")]
fn set_camera_capture_state(&self, state: MediaCaptureState) {
unsafe {
ffi::webkit_web_view_set_camera_capture_state(
self.as_ref().to_glib_none().0,
state.into_glib(),
);
}
}
/// Sets the @allowlist for CORS.
///
/// Sets the @allowlist for which
/// [Cross-Origin Resource Sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
/// checks are disabled in @self. URI patterns must be of the form
/// `[protocol]://[host]/[path]`, each component may contain the wildcard
/// character (`*`) to represent zero or more other characters. All three
/// components are required and must not be omitted from the URI
/// patterns.
///
/// Disabling CORS checks permits resources from other origins to load
/// allowlisted resources. It does not permit the allowlisted resources
/// to load resources from other origins.
///
/// If this function is called multiple times, only the allowlist set by
/// the most recent call will be effective.
/// ## `allowlist`
/// an allowlist of URI patterns, or [`None`]
#[doc(alias = "webkit_web_view_set_cors_allowlist")]
fn set_cors_allowlist(&self, allowlist: &[&str]) {
unsafe {
ffi::webkit_web_view_set_cors_allowlist(
self.as_ref().to_glib_none().0,
allowlist.to_glib_none().0,
);
}
}
/// Sets the current custom character encoding override of @self.
///
/// The custom character encoding will override any text encoding detected via HTTP headers or
/// META tags. Calling this method will stop any current load operation and reload the
/// current page. Setting the custom character encoding to [`None`] removes the character
/// encoding override.
/// ## `charset`
/// a character encoding name or [`None`]
#[doc(alias = "webkit_web_view_set_custom_charset")]
fn set_custom_charset(&self, charset: Option<&str>) {
unsafe {
ffi::webkit_web_view_set_custom_charset(
self.as_ref().to_glib_none().0,
charset.to_glib_none().0,
);
}
}
/// Set the display capture state of a #WebKitWebView.
///
/// If #WebKitSettings:enable-mediastream is [`false`], this method will have no visible effect. Once the
/// state of the device has been set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] it cannot be changed
/// anymore. The page can however request capture again using the mediaDevices API.
/// ## `state`
/// a #WebKitMediaCaptureState
#[doc(alias = "webkit_web_view_set_display_capture_state")]
#[doc(alias = "display-capture-state")]
fn set_display_capture_state(&self, state: MediaCaptureState) {
unsafe {
ffi::webkit_web_view_set_display_capture_state(
self.as_ref().to_glib_none().0,
state.into_glib(),
);
}
}
/// Sets whether the user is allowed to edit the HTML document.
///
/// If @editable is [`true`], @self allows the user to edit the HTML document. If
/// @editable is [`false`], an element in @self's document can only be edited if the
/// CONTENTEDITABLE attribute has been set on the element or one of its parent
/// elements. By default a #WebKitWebView is not editable.
///
/// Normally, a HTML document is not editable unless the elements within the
/// document are editable. This function provides a way to make the contents
/// of a #WebKitWebView editable without altering the document or DOM structure.
/// ## `editable`
/// a #gboolean indicating the editable state
#[doc(alias = "webkit_web_view_set_editable")]
#[doc(alias = "editable")]
fn set_editable(&self, editable: bool) {
unsafe {
ffi::webkit_web_view_set_editable(self.as_ref().to_glib_none().0, editable.into_glib());
}
}
/// Set the #WebKitInputMethodContext to be used by @self.
///
/// Set the #WebKitInputMethodContext to be used by @self, or [`None`] to not use any input method.
/// Note that the same #WebKitInputMethodContext can't be set on more than one #WebKitWebView at the same time.
/// ## `context`
/// the #WebKitInputMethodContext to set, or [`None`]
#[doc(alias = "webkit_web_view_set_input_method_context")]
fn set_input_method_context(&self, context: Option<&impl IsA<InputMethodContext>>) {
unsafe {
ffi::webkit_web_view_set_input_method_context(
self.as_ref().to_glib_none().0,
context.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Sets the mute state of @self.
/// ## `muted`
/// mute flag
#[doc(alias = "webkit_web_view_set_is_muted")]
#[doc(alias = "is-muted")]
fn set_is_muted(&self, muted: bool) {
unsafe {
ffi::webkit_web_view_set_is_muted(self.as_ref().to_glib_none().0, muted.into_glib());
}
}
/// Set the microphone capture state of a #WebKitWebView.
///
/// If #WebKitSettings:enable-mediastream is [`false`], this method will have no visible effect. Once the
/// state of the device has been set to [`MediaCaptureState::None`][crate::MediaCaptureState::None] it cannot be changed
/// anymore. The page can however request capture again using the mediaDevices API.
/// ## `state`
/// a #WebKitMediaCaptureState
#[doc(alias = "webkit_web_view_set_microphone_capture_state")]
#[doc(alias = "microphone-capture-state")]
fn set_microphone_capture_state(&self, state: MediaCaptureState) {
unsafe {
ffi::webkit_web_view_set_microphone_capture_state(
self.as_ref().to_glib_none().0,
state.into_glib(),
);
}
}
/// Sets the #WebKitSettings to be applied to @self.
///
/// The
/// existing #WebKitSettings of @self will be replaced by
/// @settings. New settings are applied immediately on @self.
/// The same #WebKitSettings object can be shared
/// by multiple #WebKitWebView<!-- -->s.
/// ## `settings`
/// a #WebKitSettings
#[doc(alias = "webkit_web_view_set_settings")]
#[doc(alias = "settings")]
fn set_settings(&self, settings: &Settings) {
unsafe {
ffi::webkit_web_view_set_settings(
self.as_ref().to_glib_none().0,
settings.to_glib_none().0,
);
}
}
/// Set the zoom level of @self.
///
/// Set the zoom level of @self, i.e. the factor by which the
/// view contents are scaled with respect to their original size.
/// ## `zoom_level`
/// the zoom level
#[doc(alias = "webkit_web_view_set_zoom_level")]
#[doc(alias = "zoom-level")]
fn set_zoom_level(&self, zoom_level: f64) {
unsafe {
ffi::webkit_web_view_set_zoom_level(self.as_ref().to_glib_none().0, zoom_level);
}
}
/// Stops any ongoing loading operation in @self.
///
/// This method does nothing if no content is being loaded.
/// If there is a loading operation in progress, it will be cancelled and
/// #WebKitWebView::load-failed signal will be emitted with
/// [`NetworkError::Cancelled`][crate::NetworkError::Cancelled] error.
#[doc(alias = "webkit_web_view_stop_loading")]
fn stop_loading(&self) {
unsafe {
ffi::webkit_web_view_stop_loading(self.as_ref().to_glib_none().0);
}
}
/// Terminates the web process associated to @self.
///
/// When the web process gets terminated
/// using this method, the #WebKitWebView::web-process-terminated signal is emitted with
/// [`WebProcessTerminationReason::TerminatedByApi`][crate::WebProcessTerminationReason::TerminatedByApi] as the reason for termination.
#[doc(alias = "webkit_web_view_terminate_web_process")]
fn terminate_web_process(&self) {
unsafe {
ffi::webkit_web_view_terminate_web_process(self.as_ref().to_glib_none().0);
}
}
/// Tries to close the @self.
///
/// This will fire the onbeforeunload event
/// to ask the user for confirmation to close the page. If there isn't an
/// onbeforeunload event handler or the user confirms to close the page,
/// the #WebKitWebView::close signal is emitted, otherwise nothing happens.
#[doc(alias = "webkit_web_view_try_close")]
fn try_close(&self) {
unsafe {
ffi::webkit_web_view_try_close(self.as_ref().to_glib_none().0);
}
}
/// The #WebKitWebContext of the view.
#[doc(alias = "web-context")]
fn web_context(&self) -> Option<WebContext> {
ObjectExt::property(self.as_ref(), "web-context")
}
/// This signal is emitted when the user is challenged with HTTP
/// authentication. To let the application access or supply
/// the credentials as well as to allow the client application
/// to either cancel the request or perform the authentication,
/// the signal will pass an instance of the
/// #WebKitAuthenticationRequest in the @request argument.
/// To handle this signal asynchronously you should keep a ref
/// of the request and return [`true`]. To disable HTTP authentication
/// entirely, connect to this signal and simply return [`true`].
///
/// The default signal handler will run a default authentication
/// dialog asynchronously for the user to interact with.
/// ## `request`
/// a #WebKitAuthenticationRequest
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "authenticate")]
fn connect_authenticate<F: Fn(&Self, &AuthenticationRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn authenticate_trampoline<
P: IsA<WebView>,
F: Fn(&P, &AuthenticationRequest) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
request: *mut ffi::WebKitAuthenticationRequest,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(request),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"authenticate\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
authenticate_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when closing a #WebKitWebView is requested. This occurs when a
/// call is made from JavaScript's <function>window.close</function> function or
/// after trying to close the @web_view with webkit_web_view_try_close().
/// It is the owner's responsibility to handle this signal to hide or
/// destroy the #WebKitWebView, if necessary.
#[doc(alias = "close")]
fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn close_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"close\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
close_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when a context menu is about to be displayed to give the application
/// a chance to customize the proposed menu, prevent the menu from being displayed,
/// or build its own context menu.
/// <itemizedlist>
/// <listitem><para>
/// To customize the proposed menu you can use webkit_context_menu_prepend(),
/// webkit_context_menu_append() or webkit_context_menu_insert() to add new
/// #WebKitContextMenuItem<!-- -->s to @context_menu, webkit_context_menu_move_item()
/// to reorder existing items, or webkit_context_menu_remove() to remove an
/// existing item. The signal handler should return [`false`], and the menu represented
/// by @context_menu will be shown.
/// </para></listitem>
/// <listitem><para>
/// To prevent the menu from being displayed you can just connect to this signal
/// and return [`true`] so that the proposed menu will not be shown.
/// </para></listitem>
/// <listitem><para>
/// To build your own menu, you can remove all items from the proposed menu with
/// webkit_context_menu_remove_all(), add your own items and return [`false`] so
/// that the menu will be shown. You can also ignore the proposed #WebKitContextMenu,
/// build your own #GtkMenu and return [`true`] to prevent the proposed menu from being shown.
/// </para></listitem>
/// <listitem><para>
/// If you just want the default menu to be shown always, simply don't connect to this
/// signal because showing the proposed context menu is the default behaviour.
/// </para></listitem>
/// </itemizedlist>
///
/// If the signal handler returns [`false`] the context menu represented by @context_menu
/// will be shown, if it return [`true`] the context menu will not be shown.
///
/// The proposed #WebKitContextMenu passed in @context_menu argument is only valid
/// during the signal emission.
/// ## `context_menu`
/// the proposed #WebKitContextMenu
/// ## `hit_test_result`
/// a #WebKitHitTestResult
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "context-menu")]
fn connect_context_menu<F: Fn(&Self, &ContextMenu, &HitTestResult) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn context_menu_trampoline<
P: IsA<WebView>,
F: Fn(&P, &ContextMenu, &HitTestResult) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
context_menu: *mut ffi::WebKitContextMenu,
hit_test_result: *mut ffi::WebKitHitTestResult,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(context_menu),
&from_glib_borrow(hit_test_result),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"context-menu\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
context_menu_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted after #WebKitWebView::context-menu signal, if the context menu is shown,
/// to notify that the context menu is dismissed.
#[doc(alias = "context-menu-dismissed")]
fn connect_context_menu_dismissed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn context_menu_dismissed_trampoline<
P: IsA<WebView>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitWebView,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"context-menu-dismissed\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
context_menu_dismissed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the creation of a new #WebKitWebView is requested.
/// If this signal is handled the signal handler should return the
/// newly created #WebKitWebView.
///
/// The #WebKitNavigationAction parameter contains information about the
/// navigation action that triggered this signal.
///
/// The new #WebKitWebView must be related to @web_view, see
/// #WebKitWebView:related-view for more details.
///
/// The new #WebKitWebView should not be displayed to the user
/// until the #WebKitWebView::ready-to-show signal is emitted.
/// ## `navigation_action`
/// a #WebKitNavigationAction
///
/// # Returns
///
/// a newly allocated #WebKitWebView widget
/// or [`None`] to propagate the event further.
#[doc(alias = "create")]
fn connect_create<F: Fn(&Self, &NavigationAction) -> gtk::Widget + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn create_trampoline<
P: IsA<WebView>,
F: Fn(&P, &NavigationAction) -> gtk::Widget + 'static,
>(
this: *mut ffi::WebKitWebView,
navigation_action: *mut ffi::WebKitNavigationAction,
f: glib::ffi::gpointer,
) -> *mut gtk::ffi::GtkWidget {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(navigation_action),
)
.to_glib_full()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"create\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
create_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when WebKit is requesting the client to decide a policy
/// decision, such as whether to navigate to a page, open a new window or whether or
/// not to download a resource. The #WebKitNavigationPolicyDecision passed in the
/// @decision argument is a generic type, but should be casted to a more
/// specific type when making the decision. For example:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static gboolean
/// decide_policy_cb (WebKitWebView *web_view,
/// WebKitPolicyDecision *decision,
/// WebKitPolicyDecisionType type)
/// {
/// switch (type) {
/// case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
/// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
/// // Make a policy decision here
/// break;
/// }
/// case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: {
/// WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
/// // Make a policy decision here
/// break;
/// }
/// case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
/// WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision);
/// // Make a policy decision here
/// break;
/// default:
/// // Making no decision results in webkit_policy_decision_use()
/// return FALSE;
/// }
/// return TRUE;
/// }
/// ```
///
/// It is possible to make policy decision asynchronously, by simply calling g_object_ref()
/// on the @decision argument and returning [`true`] to block the default signal handler.
/// If the last reference is removed on a #WebKitPolicyDecision and no decision has been
/// made explicitly, webkit_policy_decision_use() will be the default policy decision. The
/// default signal handler will simply call webkit_policy_decision_use(). Only the first
/// policy decision chosen for a given #WebKitPolicyDecision will have any affect.
/// ## `decision`
/// the #WebKitPolicyDecision
/// ## `decision_type`
/// a #WebKitPolicyDecisionType denoting the type of @decision
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "decide-policy")]
fn connect_decide_policy<
F: Fn(&Self, &PolicyDecision, PolicyDecisionType) -> bool + 'static,
>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn decide_policy_trampoline<
P: IsA<WebView>,
F: Fn(&P, &PolicyDecision, PolicyDecisionType) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
decision: *mut ffi::WebKitPolicyDecision,
decision_type: ffi::WebKitPolicyDecisionType,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(decision),
from_glib(decision_type),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"decide-policy\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
decide_policy_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when JavaScript code calls
/// <function>element.webkitRequestFullScreen</function>. If the
/// signal is not handled the #WebKitWebView will proceed to full screen
/// its top level window. This signal can be used by client code to
/// request permission to the user prior doing the full screen
/// transition and eventually prepare the top-level window
/// (e.g. hide some widgets that would otherwise be part of the
/// full screen window).
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to continue emission of the event.
#[doc(alias = "enter-fullscreen")]
fn connect_enter_fullscreen<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn enter_fullscreen_trampoline<
P: IsA<WebView>,
F: Fn(&P) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"enter-fullscreen\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
enter_fullscreen_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Prior to 2.46, this signal was emitted when insecure content was
/// loaded in a secure content. Since 2.46, this signal is generally
/// no longer emitted.
///
/// # Deprecated since 2.46
///
/// ## `event`
/// the #WebKitInsecureContentEvent
#[cfg_attr(feature = "v2_46", deprecated = "Since 2.46")]
#[doc(alias = "insecure-content-detected")]
fn connect_insecure_content_detected<F: Fn(&Self, InsecureContentEvent) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn insecure_content_detected_trampoline<
P: IsA<WebView>,
F: Fn(&P, InsecureContentEvent) + 'static,
>(
this: *mut ffi::WebKitWebView,
event: ffi::WebKitInsecureContentEvent,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(event),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"insecure-content-detected\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
insecure_content_detected_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the #WebKitWebView is about to restore its top level
/// window out of its full screen state. This signal can be used by
/// client code to restore widgets hidden during the
/// #WebKitWebView::enter-fullscreen stage for instance.
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to continue emission of the event.
#[doc(alias = "leave-fullscreen")]
fn connect_leave_fullscreen<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn leave_fullscreen_trampoline<
P: IsA<WebView>,
F: Fn(&P) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"leave-fullscreen\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
leave_fullscreen_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when a load operation in @web_view changes.
/// The signal is always emitted with [`LoadEvent::Started`][crate::LoadEvent::Started] when a
/// new load request is made and [`LoadEvent::Finished`][crate::LoadEvent::Finished] when the load
/// finishes successfully or due to an error. When the ongoing load
/// operation fails #WebKitWebView::load-failed signal is emitted
/// before #WebKitWebView::load-changed is emitted with
/// [`LoadEvent::Finished`][crate::LoadEvent::Finished].
/// If a redirection is received from the server, this signal is emitted
/// with [`LoadEvent::Redirected`][crate::LoadEvent::Redirected] after the initial emission with
/// [`LoadEvent::Started`][crate::LoadEvent::Started] and before [`LoadEvent::Committed`][crate::LoadEvent::Committed].
/// When the page content starts arriving the signal is emitted with
/// [`LoadEvent::Committed`][crate::LoadEvent::Committed] event.
///
/// You can handle this signal and use a switch to track any ongoing
/// load operation.
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void web_view_load_changed (WebKitWebView *web_view,
/// WebKitLoadEvent load_event,
/// gpointer user_data)
/// {
/// switch (load_event) {
/// case WEBKIT_LOAD_STARTED:
/// // New load, we have now a provisional URI
/// provisional_uri = webkit_web_view_get_uri (web_view);
/// // Here we could start a spinner or update the
/// // location bar with the provisional URI
/// break;
/// case WEBKIT_LOAD_REDIRECTED:
/// redirected_uri = webkit_web_view_get_uri (web_view);
/// break;
/// case WEBKIT_LOAD_COMMITTED:
/// // The load is being performed. Current URI is
/// // the final one and it won't change unless a new
/// // load is requested or a navigation within the
/// // same page is performed
/// uri = webkit_web_view_get_uri (web_view);
/// break;
/// case WEBKIT_LOAD_FINISHED:
/// // Load finished, we can now stop the spinner
/// break;
/// }
/// }
/// ```
/// ## `load_event`
/// the #WebKitLoadEvent
#[doc(alias = "load-changed")]
fn connect_load_changed<F: Fn(&Self, LoadEvent) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn load_changed_trampoline<
P: IsA<WebView>,
F: Fn(&P, LoadEvent) + 'static,
>(
this: *mut ffi::WebKitWebView,
load_event: ffi::WebKitLoadEvent,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(load_event),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"load-changed\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
load_changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when an error occurs during a load operation.
/// If the error happened when starting to load data for a page
/// @load_event will be [`LoadEvent::Started`][crate::LoadEvent::Started]. If it happened while
/// loading a committed data source @load_event will be [`LoadEvent::Committed`][crate::LoadEvent::Committed].
/// Since a load error causes the load operation to finish, the signal
/// WebKitWebView::load-changed will always be emitted with
/// [`LoadEvent::Finished`][crate::LoadEvent::Finished] event right after this one.
///
/// By default, if the signal is not handled, a stock error page will be displayed.
/// You need to handle the signal if you want to provide your own error page.
/// ## `load_event`
/// the #WebKitLoadEvent of the load operation
/// ## `failing_uri`
/// the URI that failed to load
/// ## `error`
/// the #GError that was triggered
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "load-failed")]
fn connect_load_failed<F: Fn(&Self, LoadEvent, &str, &glib::Error) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn load_failed_trampoline<
P: IsA<WebView>,
F: Fn(&P, LoadEvent, &str, &glib::Error) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
load_event: ffi::WebKitLoadEvent,
failing_uri: *mut libc::c_char,
error: *mut glib::ffi::GError,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(load_event),
&glib::GString::from_glib_borrow(failing_uri),
&from_glib_borrow(error),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"load-failed\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
load_failed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when a TLS error occurs during a load operation.
/// To allow an exception for this @certificate
/// and the host of @failing_uri use webkit_web_context_allow_tls_certificate_for_host().
///
/// To handle this signal asynchronously you should call g_object_ref() on @certificate
/// and return [`true`].
///
/// If [`false`] is returned, #WebKitWebView::load-failed will be emitted. The load
/// will finish regardless of the returned value.
/// ## `failing_uri`
/// the URI that failed to load
/// ## `certificate`
/// a #GTlsCertificate
/// ## `errors`
/// a #GTlsCertificateFlags with the verification status of @certificate
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "load-failed-with-tls-errors")]
fn connect_load_failed_with_tls_errors<
F: Fn(&Self, &str, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn load_failed_with_tls_errors_trampoline<
P: IsA<WebView>,
F: Fn(&P, &str, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
failing_uri: *mut libc::c_char,
certificate: *mut gio::ffi::GTlsCertificate,
errors: gio::ffi::GTlsCertificateFlags,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&glib::GString::from_glib_borrow(failing_uri),
&from_glib_borrow(certificate),
from_glib(errors),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"load-failed-with-tls-errors\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
load_failed_with_tls_errors_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when the mouse cursor moves over an
/// element such as a link, image or a media element. To determine
/// what type of element the mouse cursor is over, a Hit Test is performed
/// on the current mouse coordinates and the result is passed in the
/// @hit_test_result argument. The @modifiers argument is a bitmask of
/// #GdkModifierType flags indicating the state of modifier keys.
/// The signal is emitted again when the mouse is moved out of the
/// current element with a new @hit_test_result.
/// ## `hit_test_result`
/// a #WebKitHitTestResult
/// ## `modifiers`
/// a bitmask of #GdkModifierType
#[doc(alias = "mouse-target-changed")]
fn connect_mouse_target_changed<F: Fn(&Self, &HitTestResult, u32) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn mouse_target_changed_trampoline<
P: IsA<WebView>,
F: Fn(&P, &HitTestResult, u32) + 'static,
>(
this: *mut ffi::WebKitWebView,
hit_test_result: *mut ffi::WebKitHitTestResult,
modifiers: libc::c_uint,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(hit_test_result),
modifiers,
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"mouse-target-changed\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
mouse_target_changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when WebKit is requesting the client to
/// decide about a permission request, such as allowing the browser
/// to switch to fullscreen mode, sharing its location or similar
/// operations.
///
/// A possible way to use this signal could be through a dialog
/// allowing the user decide what to do with the request:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static gboolean permission_request_cb (WebKitWebView *web_view,
/// WebKitPermissionRequest *request,
/// GtkWindow *parent_window)
/// {
/// GtkWidget *dialog = gtk_message_dialog_new (parent_window,
/// GTK_DIALOG_MODAL,
/// GTK_MESSAGE_QUESTION,
/// GTK_BUTTONS_YES_NO,
/// "Allow Permission Request?");
/// gtk_widget_show (dialog);
/// gint result = gtk_dialog_run (GTK_DIALOG (dialog));
///
/// switch (result) {
/// case GTK_RESPONSE_YES:
/// webkit_permission_request_allow (request);
/// break;
/// default:
/// webkit_permission_request_deny (request);
/// break;
/// }
/// gtk_widget_destroy (dialog);
///
/// return TRUE;
/// }
/// ```
///
/// It is possible to handle permission requests asynchronously, by
/// simply calling g_object_ref() on the @request argument and
/// returning [`true`] to block the default signal handler. If the
/// last reference is removed on a #WebKitPermissionRequest and the
/// request has not been handled, webkit_permission_request_deny()
/// will be the default action.
///
/// If the signal is not handled, the @request will be completed automatically
/// by the specific #WebKitPermissionRequest that could allow or deny it. Check the
/// documentation of classes implementing #WebKitPermissionRequest interface to know
/// their default action.
/// ## `request`
/// the #WebKitPermissionRequest
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "permission-request")]
fn connect_permission_request<F: Fn(&Self, &PermissionRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn permission_request_trampoline<
P: IsA<WebView>,
F: Fn(&P, &PermissionRequest) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
request: *mut ffi::WebKitPermissionRequest,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(request),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"permission-request\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
permission_request_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when printing is requested on @web_view, usually by a JavaScript call,
/// before the print dialog is shown. This signal can be used to set the initial
/// print settings and page setup of @print_operation to be used as default values in
/// the print dialog. You can call webkit_print_operation_set_print_settings() and
/// webkit_print_operation_set_page_setup() and then return [`false`] to propagate the
/// event so that the print dialog is shown.
///
/// You can connect to this signal and return [`true`] to cancel the print operation
/// or implement your own print dialog.
/// ## `print_operation`
/// the #WebKitPrintOperation that will handle the print request
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "print")]
fn connect_print<F: Fn(&Self, &PrintOperation) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn print_trampoline<
P: IsA<WebView>,
F: Fn(&P, &PrintOperation) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
print_operation: *mut ffi::WebKitPrintOperation,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(print_operation),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"print\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
print_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal allows the User-Agent to respond to permission requests for powerful features, as
/// specified by the [Permissions W3C Specification](https://w3c.github.io/permissions/).
/// You can reply to the query using webkit_permission_state_query_finish().
///
/// You can handle the query asynchronously by calling webkit_permission_state_query_ref() on
/// @query and returning [`true`]. If the last reference of @query is removed and the query has not
/// been handled, the query result will be set to `WEBKIT_QUERY_PERMISSION_PROMPT`.
/// ## `query`
/// the #WebKitPermissionStateQuery
///
/// # Returns
///
/// [`true`] if the message was handled, or [`false`] otherwise.
#[doc(alias = "query-permission-state")]
fn connect_query_permission_state<F: Fn(&Self, &PermissionStateQuery) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn query_permission_state_trampoline<
P: IsA<WebView>,
F: Fn(&P, &PermissionStateQuery) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
query: *mut ffi::WebKitPermissionStateQuery,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(query),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"query-permission-state\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
query_permission_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted after #WebKitWebView::create on the newly created #WebKitWebView
/// when it should be displayed to the user. When this signal is emitted
/// all the information about how the window should look, including
/// size, position, whether the location, status and scrollbars
/// should be displayed, is already set on the #WebKitWindowProperties
/// of @web_view. See also webkit_web_view_get_window_properties().
#[doc(alias = "ready-to-show")]
fn connect_ready_to_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn ready_to_show_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"ready-to-show\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
ready_to_show_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when a new resource is going to be loaded. The @request parameter
/// contains the #WebKitURIRequest that will be sent to the server.
/// You can monitor the load operation by connecting to the different signals
/// of @resource.
/// ## `resource`
/// a #WebKitWebResource
/// ## `request`
/// a #WebKitURIRequest
#[doc(alias = "resource-load-started")]
fn connect_resource_load_started<F: Fn(&Self, &WebResource, &URIRequest) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn resource_load_started_trampoline<
P: IsA<WebView>,
F: Fn(&P, &WebResource, &URIRequest) + 'static,
>(
this: *mut ffi::WebKitWebView,
resource: *mut ffi::WebKitWebResource,
request: *mut ffi::WebKitURIRequest,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(resource),
&from_glib_borrow(request),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"resource-load-started\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
resource_load_started_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted after #WebKitWebView::ready-to-show on the newly
/// created #WebKitWebView when JavaScript code calls
/// <function>window.showModalDialog</function>. The purpose of
/// this signal is to allow the client application to prepare the
/// new view to behave as modal. Once the signal is emitted a new
/// main loop will be run to block user interaction in the parent
/// #WebKitWebView until the new dialog is closed.
#[doc(alias = "run-as-modal")]
fn connect_run_as_modal<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn run_as_modal_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"run-as-modal\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
run_as_modal_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when the user interacts with a <input
/// type='color' /> HTML element, requesting from WebKit to show
/// a dialog to select a color. To let the application know the details of
/// the color chooser, as well as to allow the client application to either
/// cancel the request or perform an actual color selection, the signal will
/// pass an instance of the #WebKitColorChooserRequest in the @request
/// argument.
///
/// It is possible to handle this request asynchronously by increasing the
/// reference count of the request.
///
/// The default signal handler will asynchronously run a regular
/// #GtkColorChooser for the user to interact with.
/// ## `request`
/// a #WebKitColorChooserRequest
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "run-color-chooser")]
fn connect_run_color_chooser<F: Fn(&Self, &ColorChooserRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn run_color_chooser_trampoline<
P: IsA<WebView>,
F: Fn(&P, &ColorChooserRequest) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
request: *mut ffi::WebKitColorChooserRequest,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(request),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"run-color-chooser\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
run_color_chooser_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when the user interacts with a <input
/// type='file' /> HTML element, requesting from WebKit to show
/// a dialog to select one or more files to be uploaded. To let the
/// application know the details of the file chooser, as well as to
/// allow the client application to either cancel the request or
/// perform an actual selection of files, the signal will pass an
/// instance of the #WebKitFileChooserRequest in the @request
/// argument.
///
/// The default signal handler will asynchronously run a regular
/// #GtkFileChooserDialog for the user to interact with.
/// ## `request`
/// a #WebKitFileChooserRequest
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "run-file-chooser")]
fn connect_run_file_chooser<F: Fn(&Self, &FileChooserRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn run_file_chooser_trampoline<
P: IsA<WebView>,
F: Fn(&P, &FileChooserRequest) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
request: *mut ffi::WebKitFileChooserRequest,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(request),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"run-file-chooser\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
run_file_chooser_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when JavaScript code calls <function>window.alert</function>,
/// <function>window.confirm</function> or <function>window.prompt</function>,
/// or when <function>onbeforeunload</function> event is fired.
/// The @dialog parameter should be used to build the dialog.
/// If the signal is not handled a different dialog will be built and shown depending
/// on the dialog type:
/// <itemizedlist>
/// <listitem><para>
/// [`ScriptDialogType::Alert`][crate::ScriptDialogType::Alert]: message dialog with a single Close button.
/// </para></listitem>
/// <listitem><para>
/// [`ScriptDialogType::Confirm`][crate::ScriptDialogType::Confirm]: message dialog with OK and Cancel buttons.
/// </para></listitem>
/// <listitem><para>
/// [`ScriptDialogType::Prompt`][crate::ScriptDialogType::Prompt]: message dialog with OK and Cancel buttons and
/// a text entry with the default text.
/// </para></listitem>
/// <listitem><para>
/// [`ScriptDialogType::BeforeUnloadConfirm`][crate::ScriptDialogType::BeforeUnloadConfirm]: message dialog with Stay and Leave buttons.
/// </para></listitem>
/// </itemizedlist>
///
/// It is possible to handle the script dialog request asynchronously, by simply
/// caling webkit_script_dialog_ref() on the @dialog argument and calling
/// webkit_script_dialog_close() when done.
/// If the last reference is removed on a #WebKitScriptDialog and the dialog has not been
/// closed, webkit_script_dialog_close() will be called.
/// ## `dialog`
/// the #WebKitScriptDialog to show
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "script-dialog")]
fn connect_script_dialog<F: Fn(&Self, &ScriptDialog) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn script_dialog_trampoline<
P: IsA<WebView>,
F: Fn(&P, &ScriptDialog) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
dialog: *mut ffi::WebKitScriptDialog,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(dialog),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"script-dialog\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
script_dialog_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when a notification should be presented to the
/// user. The @notification is kept alive until either: 1) the web page cancels it
/// or 2) a navigation happens.
///
/// The default handler will emit a notification using libnotify, if built with
/// support for it.
/// ## `notification`
/// a #WebKitNotification
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked. [`false`] otherwise.
#[doc(alias = "show-notification")]
fn connect_show_notification<F: Fn(&Self, &Notification) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn show_notification_trampoline<
P: IsA<WebView>,
F: Fn(&P, &Notification) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
notification: *mut ffi::WebKitNotification,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(notification),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"show-notification\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
show_notification_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when a select element in @web_view needs to display a
/// dropdown menu. This signal can be used to show a custom menu, using @menu to get
/// the details of all items that should be displayed. The area of the element in the
/// #WebKitWebView is given as @rectangle parameter, it can be used to position the
/// menu.
/// To handle this signal asynchronously you should keep a ref of the @menu.
///
/// The default signal handler will pop up a #GtkMenu.
/// ## `menu`
/// the #WebKitOptionMenu
/// ## `rectangle`
/// the option element area
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "show-option-menu")]
fn connect_show_option_menu<F: Fn(&Self, &OptionMenu, &gdk::Rectangle) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn show_option_menu_trampoline<
P: IsA<WebView>,
F: Fn(&P, &OptionMenu, &gdk::Rectangle) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
menu: *mut ffi::WebKitOptionMenu,
rectangle: *mut gdk::ffi::GdkRectangle,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(menu),
&from_glib_borrow(rectangle),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"show-option-menu\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
show_option_menu_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when a form is about to be submitted. The @request
/// argument passed contains information about the text fields of the form. This
/// is typically used to store login information that can be used later to
/// pre-fill the form.
/// The form will not be submitted until webkit_form_submission_request_submit() is called.
///
/// It is possible to handle the form submission request asynchronously, by
/// simply calling g_object_ref() on the @request argument and calling
/// webkit_form_submission_request_submit() when done to continue with the form submission.
/// If the last reference is removed on a #WebKitFormSubmissionRequest and the
/// form has not been submitted, webkit_form_submission_request_submit() will be called.
/// ## `request`
/// a #WebKitFormSubmissionRequest
#[doc(alias = "submit-form")]
fn connect_submit_form<F: Fn(&Self, &FormSubmissionRequest) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn submit_form_trampoline<
P: IsA<WebView>,
F: Fn(&P, &FormSubmissionRequest) + 'static,
>(
this: *mut ffi::WebKitWebView,
request: *mut ffi::WebKitFormSubmissionRequest,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(request),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"submit-form\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
submit_form_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when a #WebKitUserMessage is received from the
/// #WebKitWebPage corresponding to @web_view. You can reply to the message
/// using webkit_user_message_send_reply().
///
/// You can handle the user message asynchronously by calling g_object_ref() on
/// @message and returning [`true`]. If the last reference of @message is removed
/// and the message has not been replied to, the operation in the #WebKitWebPage will
/// finish with error [`UserMessageError::Message`][crate::UserMessageError::Message].
/// ## `message`
/// the #WebKitUserMessage received
///
/// # Returns
///
/// [`true`] if the message was handled, or [`false`] otherwise.
#[doc(alias = "user-message-received")]
fn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn user_message_received_trampoline<
P: IsA<WebView>,
F: Fn(&P, &UserMessage) -> bool + 'static,
>(
this: *mut ffi::WebKitWebView,
message: *mut ffi::WebKitUserMessage,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(message),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"user-message-received\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
user_message_received_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// This signal is emitted when the web process terminates abnormally due
/// to @reason.
/// ## `reason`
/// the a #WebKitWebProcessTerminationReason
#[doc(alias = "web-process-terminated")]
fn connect_web_process_terminated<F: Fn(&Self, WebProcessTerminationReason) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn web_process_terminated_trampoline<
P: IsA<WebView>,
F: Fn(&P, WebProcessTerminationReason) + 'static,
>(
this: *mut ffi::WebKitWebView,
reason: ffi::WebKitWebProcessTerminationReason,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
WebView::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(reason),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"web-process-terminated\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
web_process_terminated_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "camera-capture-state")]
fn connect_camera_capture_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_camera_capture_state_trampoline<
P: IsA<WebView>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::camera-capture-state\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_camera_capture_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "display-capture-state")]
fn connect_display_capture_state_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_display_capture_state_trampoline<
P: IsA<WebView>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::display-capture-state\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_display_capture_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "editable")]
fn connect_editable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_editable_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::editable\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_editable_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "estimated-load-progress")]
fn connect_estimated_load_progress_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_estimated_load_progress_trampoline<
P: IsA<WebView>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::estimated-load-progress\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_estimated_load_progress_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "favicon")]
fn connect_favicon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_favicon_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::favicon\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_favicon_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "is-loading")]
fn connect_is_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_is_loading_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::is-loading\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_loading_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "is-muted")]
fn connect_is_muted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_is_muted_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::is-muted\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_muted_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "is-playing-audio")]
fn connect_is_playing_audio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_is_playing_audio_trampoline<
P: IsA<WebView>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::is-playing-audio\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_playing_audio_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "is-web-process-responsive")]
fn connect_is_web_process_responsive_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_is_web_process_responsive_trampoline<
P: IsA<WebView>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::is-web-process-responsive\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_web_process_responsive_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "microphone-capture-state")]
fn connect_microphone_capture_state_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_microphone_capture_state_trampoline<
P: IsA<WebView>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::microphone-capture-state\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_microphone_capture_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "page-id")]
fn connect_page_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_page_id_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::page-id\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_page_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "settings")]
fn connect_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_settings_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::settings\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_settings_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "title")]
fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_title_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::title\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_title_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "uri")]
fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_uri_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::uri\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_uri_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "zoom-level")]
fn connect_zoom_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_zoom_level_trampoline<P: IsA<WebView>, F: Fn(&P) + 'static>(
this: *mut ffi::WebKitWebView,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(WebView::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::zoom-level\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_zoom_level_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<WebView>> WebViewExt for O {}