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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#![allow(deprecated)]
use crate::{
Accessible, Align, Allocation, Buildable, ConstraintTarget, DirectionType, EventController,
LayoutManager, Native, Orientation, Overflow, PickFlags, Requisition, Root, Settings,
SizeRequestMode, Snapshot, StateFlags, StyleContext, TextDirection, Tooltip,
};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem, mem::transmute};
glib::wrapper! {
/// The base class for all widgets.
///
/// [`Widget`][crate::Widget] is the base class all widgets in GTK derive from. It manages the
/// widget lifecycle, layout, states and style.
///
/// ### Height-for-width Geometry Management
///
/// GTK uses a height-for-width (and width-for-height) geometry management
/// system. Height-for-width means that a widget can change how much
/// vertical space it needs, depending on the amount of horizontal space
/// that it is given (and similar for width-for-height). The most common
/// example is a label that reflows to fill up the available width, wraps
/// to fewer lines, and therefore needs less height.
///
/// Height-for-width geometry management is implemented in GTK by way
/// of two virtual methods:
///
/// - [`WidgetImpl::request_mode()`][crate::subclass::prelude::WidgetImpl::request_mode()]
/// - [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()]
///
/// There are some important things to keep in mind when implementing
/// height-for-width and when using it in widget implementations.
///
/// If you implement a direct [`Widget`][crate::Widget] subclass that supports
/// height-for-width or width-for-height geometry management for itself
/// or its child widgets, the [`WidgetImpl::request_mode()`][crate::subclass::prelude::WidgetImpl::request_mode()] virtual
/// function must be implemented as well and return the widget's preferred
/// request mode. The default implementation of this virtual function
/// returns [`SizeRequestMode::ConstantSize`][crate::SizeRequestMode::ConstantSize], which means that the widget will
/// only ever get -1 passed as the for_size value to its
/// [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()] implementation.
///
/// The geometry management system will query a widget hierarchy in
/// only one orientation at a time. When widgets are initially queried
/// for their minimum sizes it is generally done in two initial passes
/// in the [`SizeRequestMode`][crate::SizeRequestMode] chosen by the toplevel.
///
/// For example, when queried in the normal [`SizeRequestMode::HeightForWidth`][crate::SizeRequestMode::HeightForWidth] mode:
///
/// First, the default minimum and natural width for each widget
/// in the interface will be computed using [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()] with an
/// orientation of [`Orientation::Horizontal`][crate::Orientation::Horizontal] and a for_size of -1.
/// Because the preferred widths for each widget depend on the preferred
/// widths of their children, this information propagates up the hierarchy,
/// and finally a minimum and natural width is determined for the entire
/// toplevel. Next, the toplevel will use the minimum width to query for the
/// minimum height contextual to that width using [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()] with an
/// orientation of [`Orientation::Vertical`][crate::Orientation::Vertical] and a for_size of the just computed
/// width. This will also be a highly recursive operation. The minimum height
/// for the minimum width is normally used to set the minimum size constraint
/// on the toplevel.
///
/// After the toplevel window has initially requested its size in both
/// dimensions it can go on to allocate itself a reasonable size (or a size
/// previously specified with [`GtkWindowExt::set_default_size()`][crate::prelude::GtkWindowExt::set_default_size()]). During the
/// recursive allocation process it’s important to note that request cycles
/// will be recursively executed while widgets allocate their children.
/// Each widget, once allocated a size, will go on to first share the
/// space in one orientation among its children and then request each child's
/// height for its target allocated width or its width for allocated height,
/// depending. In this way a [`Widget`][crate::Widget] will typically be requested its size
/// a number of times before actually being allocated a size. The size a
/// widget is finally allocated can of course differ from the size it has
/// requested. For this reason, [`Widget`][crate::Widget] caches a small number of results
/// to avoid re-querying for the same sizes in one allocation cycle.
///
/// If a widget does move content around to intelligently use up the
/// allocated size then it must support the request in both
/// [`SizeRequestMode`][crate::SizeRequestMode]s even if the widget in question only
/// trades sizes in a single orientation.
///
/// For instance, a [`Label`][crate::Label] that does height-for-width word wrapping
/// will not expect to have [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()] with an orientation of
/// [`Orientation::Vertical`][crate::Orientation::Vertical] called because that call is specific to a
/// width-for-height request. In this case the label must return the height
/// required for its own minimum possible width. By following this rule any
/// widget that handles height-for-width or width-for-height requests will
/// always be allocated at least enough space to fit its own content.
///
/// Here are some examples of how a [`SizeRequestMode::HeightForWidth`][crate::SizeRequestMode::HeightForWidth] widget
/// generally deals with width-for-height requests:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void
/// foo_widget_measure (GtkWidget *widget,
/// GtkOrientation orientation,
/// int for_size,
/// int *minimum_size,
/// int *natural_size,
/// int *minimum_baseline,
/// int *natural_baseline)
/// {
/// if (orientation == GTK_ORIENTATION_HORIZONTAL)
/// {
/// // Calculate minimum and natural width
/// }
/// else // VERTICAL
/// {
/// if (i_am_in_height_for_width_mode)
/// {
/// int min_width, dummy;
///
/// // First, get the minimum width of our widget
/// GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
/// &min_width, &dummy, &dummy, &dummy);
///
/// // Now use the minimum width to retrieve the minimum and natural height to display
/// // that width.
/// GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_VERTICAL, min_width,
/// minimum_size, natural_size, &dummy, &dummy);
/// }
/// else
/// {
/// // ... some widgets do both.
/// }
/// }
/// }
/// ```
///
/// Often a widget needs to get its own request during size request or
/// allocation. For example, when computing height it may need to also
/// compute width. Or when deciding how to use an allocation, the widget
/// may need to know its natural size. In these cases, the widget should
/// be careful to call its virtual methods directly, like in the code
/// example above.
///
/// It will not work to use the wrapper function [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()]
/// inside your own [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()] implementation.
/// These return a request adjusted by [`SizeGroup`][crate::SizeGroup], the widget's
/// align and expand flags, as well as its CSS style.
///
/// If a widget used the wrappers inside its virtual method implementations,
/// then the adjustments (such as widget margins) would be applied
/// twice. GTK therefore does not allow this and will warn if you try
/// to do it.
///
/// Of course if you are getting the size request for another widget, such
/// as a child widget, you must use [`WidgetExt::measure()`][crate::prelude::WidgetExt::measure()]; otherwise, you
/// would not properly consider widget margins, [`SizeGroup`][crate::SizeGroup], and
/// so forth.
///
/// GTK also supports baseline vertical alignment of widgets. This
/// means that widgets are positioned such that the typographical baseline of
/// widgets in the same row are aligned. This happens if a widget supports
/// baselines, has a vertical alignment using baselines, and is inside
/// a widget that supports baselines and has a natural “row” that it aligns to
/// the baseline, or a baseline assigned to it by the grandparent.
///
/// Baseline alignment support for a widget is also done by the
/// [`WidgetImpl::measure()`][crate::subclass::prelude::WidgetImpl::measure()] virtual function. It allows you to report
/// both a minimum and natural size.
///
/// If a widget ends up baseline aligned it will be allocated all the space in
/// the parent as if it was [`Align::Fill`][crate::Align::Fill], but the selected baseline can be
/// found via [`WidgetExt::baseline()`][crate::prelude::WidgetExt::baseline()]. If the baseline has a
/// value other than -1 you need to align the widget such that the baseline
/// appears at the position.
///
/// ### GtkWidget as GtkBuildable
///
/// The [`Widget`][crate::Widget] implementation of the [`Buildable`][crate::Buildable] interface
/// supports various custom elements to specify additional aspects of widgets
/// that are not directly expressed as properties.
///
/// If the widget uses a [`LayoutManager`][crate::LayoutManager], [`Widget`][crate::Widget] supports
/// a custom `<layout>` element, used to define layout properties:
///
/// ```xml
/// <object class="GtkGrid" id="my_grid">
/// <child>
/// <object class="GtkLabel" id="label1">
/// <property name="label">Description</property>
/// <layout>
/// <property name="column">0</property>
/// <property name="row">0</property>
/// <property name="row-span">1</property>
/// <property name="column-span">1</property>
/// </layout>
/// </object>
/// </child>
/// <child>
/// <object class="GtkEntry" id="description_entry">
/// <layout>
/// <property name="column">1</property>
/// <property name="row">0</property>
/// <property name="row-span">1</property>
/// <property name="column-span">1</property>
/// </layout>
/// </object>
/// </child>
/// </object>
/// ```
///
/// [`Widget`][crate::Widget] allows style information such as style classes to
/// be associated with widgets, using the custom `<style>` element:
///
/// ```xml
/// <object class="GtkButton" id="button1">
/// <style>
/// <class name="my-special-button-class"/>
/// <class name="dark-button"/>
/// </style>
/// </object>
/// ```
///
/// [`Widget`][crate::Widget] allows defining accessibility information, such as properties,
/// relations, and states, using the custom `<accessibility>` element:
///
/// ```xml
/// <object class="GtkButton" id="button1">
/// <accessibility>
/// <property name="label">Download</property>
/// <relation name="labelled-by">label1</relation>
/// </accessibility>
/// </object>
/// ```
///
/// ### Building composite widgets from template XML
///
/// `GtkWidget `exposes some facilities to automate the procedure
/// of creating composite widgets using "templates".
///
/// To create composite widgets with [`Builder`][crate::Builder] XML, one must associate
/// the interface description with the widget class at class initialization
/// time using [`WidgetClassExt::set_template()`][crate::subclass::prelude::WidgetClassExt::set_template()].
///
/// The interface description semantics expected in composite template descriptions
/// is slightly different from regular [`Builder`][crate::Builder] XML.
///
/// Unlike regular interface descriptions, [`WidgetClassExt::set_template()`][crate::subclass::prelude::WidgetClassExt::set_template()]
/// will expect a `<template>` tag as a direct child of the toplevel
/// `<interface>` tag. The `<template>` tag must specify the “class” attribute
/// which must be the type name of the widget. Optionally, the “parent”
/// attribute may be specified to specify the direct parent type of the widget
/// type; this is ignored by [`Builder`][crate::Builder] but can be used by UI design tools to
/// introspect what kind of properties and internal children exist for a given
/// type when the actual type does not exist.
///
/// The XML which is contained inside the `<template>` tag behaves as if it were
/// added to the `<object>` tag defining the widget itself. You may set properties
/// on a widget by inserting `<property>` tags into the `<template>` tag, and also
/// add `<child>` tags to add children and extend a widget in the normal way you
/// would with `<object>` tags.
///
/// Additionally, `<object>` tags can also be added before and after the initial
/// `<template>` tag in the normal way, allowing one to define auxiliary objects
/// which might be referenced by other widgets declared as children of the
/// `<template>` tag.
///
/// An example of a template definition:
///
/// ```xml
/// <interface>
/// <template class="FooWidget" parent="GtkBox">
/// <property name="orientation">horizontal</property>
/// <property name="spacing">4</property>
/// <child>
/// <object class="GtkButton" id="hello_button">
/// <property name="label">Hello World</property>
/// <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/>
/// </object>
/// </child>
/// <child>
/// <object class="GtkButton" id="goodbye_button">
/// <property name="label">Goodbye World</property>
/// </object>
/// </child>
/// </template>
/// </interface>
/// ```
///
/// Typically, you'll place the template fragment into a file that is
/// bundled with your project, using `GResource`. In order to load the
/// template, you need to call [`WidgetClassExt::set_template_from_resource()`][crate::subclass::prelude::WidgetClassExt::set_template_from_resource()]
/// from the class initialization of your [`Widget`][crate::Widget] type:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void
/// foo_widget_class_init (FooWidgetClass *klass)
/// {
/// // ...
///
/// gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
/// "/com/example/ui/foowidget.ui");
/// }
/// ```
///
/// You will also need to call `Gtk::Widget::init_template()` from the
/// instance initialization function:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void
/// foo_widget_init (FooWidget *self)
/// {
/// gtk_widget_init_template (GTK_WIDGET (self));
///
/// // Initialize the rest of the widget...
/// }
/// ```
///
/// as well as calling `Gtk::Widget::dispose_template()` from the dispose
/// function:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void
/// foo_widget_dispose (GObject *gobject)
/// {
/// FooWidget *self = FOO_WIDGET (gobject);
///
/// // Dispose objects for which you have a reference...
///
/// // Clear the template children for this widget type
/// gtk_widget_dispose_template (GTK_WIDGET (self), FOO_TYPE_WIDGET);
///
/// G_OBJECT_CLASS (foo_widget_parent_class)->dispose (gobject);
/// }
/// ```
///
/// You can access widgets defined in the template using the
/// `Gtk::Widget::get_template_child()` function, but you will typically declare
/// a pointer in the instance private data structure of your type using the same
/// name as the widget in the template definition, and call
/// [`WidgetClassExt::bind_template_child_full()`][crate::subclass::prelude::WidgetClassExt::bind_template_child_full()] (or one of its wrapper macros
/// `widget_class_bind_template_child()` and `widget_class_bind_template_child_private()`)
/// with that name, e.g.
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// typedef struct {
/// GtkWidget *hello_button;
/// GtkWidget *goodbye_button;
/// } FooWidgetPrivate;
///
/// G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, GTK_TYPE_BOX)
///
/// static void
/// foo_widget_dispose (GObject *gobject)
/// {
/// gtk_widget_dispose_template (GTK_WIDGET (gobject), FOO_TYPE_WIDGET);
///
/// G_OBJECT_CLASS (foo_widget_parent_class)->dispose (gobject);
/// }
///
/// static void
/// foo_widget_class_init (FooWidgetClass *klass)
/// {
/// // ...
/// G_OBJECT_CLASS (klass)->dispose = foo_widget_dispose;
///
/// gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
/// "/com/example/ui/foowidget.ui");
/// gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
/// FooWidget, hello_button);
/// gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
/// FooWidget, goodbye_button);
/// }
///
/// static void
/// foo_widget_init (FooWidget *widget)
/// {
/// gtk_widget_init_template (GTK_WIDGET (widget));
/// }
/// ```
///
/// You can also use [`WidgetClassExt::bind_template_callback_full()`][crate::subclass::prelude::WidgetClassExt::bind_template_callback_full()] (or
/// is wrapper macro `widget_class_bind_template_callback()`) to connect
/// a signal callback defined in the template with a function visible in the
/// scope of the class, e.g.
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// // the signal handler has the instance and user data swapped
/// // because of the swapped="yes" attribute in the template XML
/// static void
/// hello_button_clicked (FooWidget *self,
/// GtkButton *button)
/// {
/// g_print ("Hello, world!\n");
/// }
///
/// static void
/// foo_widget_class_init (FooWidgetClass *klass)
/// {
/// // ...
/// gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
/// "/com/example/ui/foowidget.ui");
/// gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked);
/// }
/// ```
///
/// This is an Abstract Base Class, you cannot instantiate it.
///
/// ## Properties
///
///
/// #### `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::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 [`LayoutManager`][crate::LayoutManager] 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
/// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::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
/// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::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
/// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::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
/// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::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 [`Root`][crate::Root] 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 [`Tooltip::set_markup()`][crate::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::Widget#has-tooltip] will automatically be set to [`true`]
/// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
/// the default signal handler.
///
/// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
/// [`tooltip-markup`][struct@crate::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 [`Tooltip::set_text()`][crate::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::Widget#has-tooltip] will automatically be set to [`true`]
/// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
/// the default signal handler.
///
/// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
/// [`tooltip-markup`][struct@crate::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><summary><h4>Accessible</h4></summary>
///
///
/// #### `accessible-role`
/// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
///
/// The accessible role cannot be changed once set.
///
/// Readable | Writeable
/// </details>
///
/// ## Signals
///
///
/// #### `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 [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::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::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::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::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 [`gdk::Surface`][crate::gdk::Surface].
///
/// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::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 [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::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 [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
///
/// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
/// or the widget has been unmapped (that is, it is going to be hidden).
///
///
///
/// # Implements
///
/// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
#[doc(alias = "GtkWidget")]
pub struct Widget(Object<ffi::GtkWidget, ffi::GtkWidgetClass>) @implements Accessible, Buildable, ConstraintTarget;
match fn {
type_ => || ffi::gtk_widget_get_type(),
}
}
impl Widget {
pub const NONE: Option<&'static Widget> = None;
/// Obtains the current default reading direction.
///
/// See [`set_default_direction()`][Self::set_default_direction()].
///
/// # Returns
///
/// the current default direction.
#[doc(alias = "gtk_widget_get_default_direction")]
#[doc(alias = "get_default_direction")]
pub fn default_direction() -> TextDirection {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::gtk_widget_get_default_direction()) }
}
/// Sets the default reading direction for widgets.
///
/// See [`WidgetExt::set_direction()`][crate::prelude::WidgetExt::set_direction()].
/// ## `dir`
/// the new default direction. This cannot be [`TextDirection::None`][crate::TextDirection::None].
#[doc(alias = "gtk_widget_set_default_direction")]
pub fn set_default_direction(dir: TextDirection) {
assert_initialized_main_thread!();
unsafe {
ffi::gtk_widget_set_default_direction(dir.into_glib());
}
}
}
impl fmt::Display for Widget {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&WidgetExt::widget_name(self))
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Widget>> Sealed for T {}
}
/// Trait containing all [`struct@Widget`] methods.
///
/// # Implementors
///
/// [`ActionBar`][struct@crate::ActionBar], [`Actionable`][struct@crate::Actionable], [`AppChooserButton`][struct@crate::AppChooserButton], [`AppChooserWidget`][struct@crate::AppChooserWidget], [`AppChooser`][struct@crate::AppChooser], [`AspectFrame`][struct@crate::AspectFrame], [`Box`][struct@crate::Box], [`Button`][struct@crate::Button], [`Calendar`][struct@crate::Calendar], [`CellEditable`][struct@crate::CellEditable], [`CellView`][struct@crate::CellView], [`CenterBox`][struct@crate::CenterBox], [`CheckButton`][struct@crate::CheckButton], [`ColorButton`][struct@crate::ColorButton], [`ColorChooserWidget`][struct@crate::ColorChooserWidget], [`ColorDialogButton`][struct@crate::ColorDialogButton], [`ColumnView`][struct@crate::ColumnView], [`ComboBox`][struct@crate::ComboBox], [`DragIcon`][struct@crate::DragIcon], [`DrawingArea`][struct@crate::DrawingArea], [`DropDown`][struct@crate::DropDown], [`EditableLabel`][struct@crate::EditableLabel], [`Editable`][struct@crate::Editable], [`Entry`][struct@crate::Entry], [`Expander`][struct@crate::Expander], [`FileChooserWidget`][struct@crate::FileChooserWidget], [`Fixed`][struct@crate::Fixed], [`FlowBoxChild`][struct@crate::FlowBoxChild], [`FlowBox`][struct@crate::FlowBox], [`FontButton`][struct@crate::FontButton], [`FontChooserWidget`][struct@crate::FontChooserWidget], [`FontDialogButton`][struct@crate::FontDialogButton], [`Frame`][struct@crate::Frame], [`GLArea`][struct@crate::GLArea], [`Grid`][struct@crate::Grid], [`HeaderBar`][struct@crate::HeaderBar], [`IconView`][struct@crate::IconView], [`Image`][struct@crate::Image], [`InfoBar`][struct@crate::InfoBar], [`Inscription`][struct@crate::Inscription], [`Label`][struct@crate::Label], [`LevelBar`][struct@crate::LevelBar], [`ListBase`][struct@crate::ListBase], [`ListBoxRow`][struct@crate::ListBoxRow], [`ListBox`][struct@crate::ListBox], [`MediaControls`][struct@crate::MediaControls], [`MenuButton`][struct@crate::MenuButton], [`Native`][struct@crate::Native], [`Notebook`][struct@crate::Notebook], [`Overlay`][struct@crate::Overlay], [`Paned`][struct@crate::Paned], [`PasswordEntry`][struct@crate::PasswordEntry], [`Picture`][struct@crate::Picture], [`PopoverMenuBar`][struct@crate::PopoverMenuBar], [`Popover`][struct@crate::Popover], [`ProgressBar`][struct@crate::ProgressBar], [`Range`][struct@crate::Range], [`Revealer`][struct@crate::Revealer], [`Root`][struct@crate::Root], [`ScaleButton`][struct@crate::ScaleButton], [`Scrollbar`][struct@crate::Scrollbar], [`ScrolledWindow`][struct@crate::ScrolledWindow], [`SearchBar`][struct@crate::SearchBar], [`SearchEntry`][struct@crate::SearchEntry], [`Separator`][struct@crate::Separator], [`ShortcutLabel`][struct@crate::ShortcutLabel], [`ShortcutsShortcut`][struct@crate::ShortcutsShortcut], [`SpinButton`][struct@crate::SpinButton], [`Spinner`][struct@crate::Spinner], [`StackSidebar`][struct@crate::StackSidebar], [`StackSwitcher`][struct@crate::StackSwitcher], [`Stack`][struct@crate::Stack], [`Statusbar`][struct@crate::Statusbar], [`Switch`][struct@crate::Switch], [`TextView`][struct@crate::TextView], [`Text`][struct@crate::Text], [`TreeExpander`][struct@crate::TreeExpander], [`TreeView`][struct@crate::TreeView], [`Video`][struct@crate::Video], [`Viewport`][struct@crate::Viewport], [`Widget`][struct@crate::Widget], [`WindowControls`][struct@crate::WindowControls], [`WindowHandle`][struct@crate::WindowHandle], [`Window`][struct@crate::Window]
pub trait WidgetExt: IsA<Widget> + sealed::Sealed + 'static {
/// Enable or disable an action installed with
/// gtk_widget_class_install_action().
/// ## `action_name`
/// action name, such as "clipboard.paste"
/// ## `enabled`
/// whether the action is now enabled
#[doc(alias = "gtk_widget_action_set_enabled")]
fn action_set_enabled(&self, action_name: &str, enabled: bool) {
unsafe {
ffi::gtk_widget_action_set_enabled(
self.as_ref().to_glib_none().0,
action_name.to_glib_none().0,
enabled.into_glib(),
);
}
}
/// For widgets that can be “activated” (buttons, menu items, etc.),
/// this function activates them.
///
/// The activation will emit the signal set using
/// [`WidgetClassExt::set_activate_signal()`][crate::subclass::prelude::WidgetClassExt::set_activate_signal()] during class initialization.
///
/// Activation is what happens when you press <kbd>Enter</kbd>
/// on a widget during key navigation.
///
/// If you wish to handle the activation keybinding yourself, it is
/// recommended to use [`WidgetClassExt::add_shortcut()`][crate::subclass::prelude::WidgetClassExt::add_shortcut()] with an action
/// created with [`SignalAction::new()`][crate::SignalAction::new()].
///
/// If @self isn't activatable, the function returns [`false`].
///
/// # Returns
///
/// [`true`] if the widget was activatable
#[doc(alias = "gtk_widget_activate")]
fn activate(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_activate(self.as_ref().to_glib_none().0)) }
}
/// Looks up the action in the action groups associated with
/// @self and its ancestors, and activates it.
///
/// If the action is in an action group added with
/// [`insert_action_group()`][Self::insert_action_group()], the @name is expected
/// to be prefixed with the prefix that was used when the group was
/// inserted.
///
/// The arguments must match the actions expected parameter type,
/// as returned by `g_action_get_parameter_type()`.
/// ## `name`
/// the name of the action to activate
/// ## `args`
/// parameters to use
///
/// # Returns
///
/// [`true`] if the action was activated, [`false`] if the
/// action does not exist.
#[doc(alias = "gtk_widget_activate_action_variant")]
#[doc(alias = "activate_action_variant")]
fn activate_action(
&self,
name: &str,
args: Option<&glib::Variant>,
) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gtk_widget_activate_action_variant(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
args.to_glib_none().0
),
"Action does not exist"
)
}
}
/// Activates the `default.activate` action from @self.
#[doc(alias = "gtk_widget_activate_default")]
fn activate_default(&self) {
unsafe {
ffi::gtk_widget_activate_default(self.as_ref().to_glib_none().0);
}
}
/// Adds @controller to @self so that it will receive events.
///
/// You will usually want to call this function right after
/// creating any kind of [`EventController`][crate::EventController].
/// ## `controller`
/// a [`EventController`][crate::EventController] that hasn't been
/// added to a widget yet
#[doc(alias = "gtk_widget_add_controller")]
fn add_controller(&self, controller: impl IsA<EventController>) {
unsafe {
ffi::gtk_widget_add_controller(
self.as_ref().to_glib_none().0,
controller.upcast().into_glib_ptr(),
);
}
}
/// Adds a style class to @self.
///
/// After calling this function, the widget’s style will match
/// for @css_class, according to CSS matching rules.
///
/// Use [`remove_css_class()`][Self::remove_css_class()] to remove the
/// style again.
/// ## `css_class`
/// The style class to add to @self, without
/// the leading '.' used for notation of style classes
#[doc(alias = "gtk_widget_add_css_class")]
fn add_css_class(&self, css_class: &str) {
unsafe {
ffi::gtk_widget_add_css_class(
self.as_ref().to_glib_none().0,
css_class.to_glib_none().0,
);
}
}
/// Adds a widget to the list of mnemonic labels for this widget.
///
/// See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()]. Note the
/// list of mnemonic labels for the widget is cleared when the
/// widget is destroyed, so the caller must make sure to update
/// its internal state at this point as well.
/// ## `label`
/// a [`Widget`][crate::Widget] that acts as a mnemonic label for @self
#[doc(alias = "gtk_widget_add_mnemonic_label")]
fn add_mnemonic_label(&self, label: &impl IsA<Widget>) {
unsafe {
ffi::gtk_widget_add_mnemonic_label(
self.as_ref().to_glib_none().0,
label.as_ref().to_glib_none().0,
);
}
}
/// This function is only used by [`Widget`][crate::Widget] subclasses, to
/// assign a size, position and (optionally) baseline to their
/// child widgets.
///
/// In this function, the allocation and baseline may be adjusted.
/// The given allocation will be forced to be bigger than the
/// widget's minimum size, as well as at least 0×0 in size.
///
/// For a version that does not take a transform, see
/// [`size_allocate()`][Self::size_allocate()].
/// ## `width`
/// New width of @self
/// ## `height`
/// New height of @self
/// ## `baseline`
/// New baseline of @self, or -1
/// ## `transform`
/// Transformation to be applied to @self
#[doc(alias = "gtk_widget_allocate")]
fn allocate(&self, width: i32, height: i32, baseline: i32, transform: Option<gsk::Transform>) {
unsafe {
ffi::gtk_widget_allocate(
self.as_ref().to_glib_none().0,
width,
height,
baseline,
transform.into_glib_ptr(),
);
}
}
/// Called by widgets as the user moves around the window using
/// keyboard shortcuts.
///
/// The @direction argument indicates what kind of motion is taking place (up,
/// down, left, right, tab forward, tab backward).
///
/// This function calls the [`WidgetImpl::focus()`][crate::subclass::prelude::WidgetImpl::focus()] virtual function; widgets
/// can override the virtual function in order to implement appropriate focus
/// behavior.
///
/// The default `focus()` virtual function for a widget should return `TRUE` if
/// moving in @direction left the focus on a focusable location inside that
/// widget, and `FALSE` if moving in @direction moved the focus outside the
/// widget. When returning `TRUE`, widgets normally call [`grab_focus()`][Self::grab_focus()]
/// to place the focus accordingly; when returning `FALSE`, they don’t modify
/// the current focus location.
///
/// This function is used by custom widget implementations; if you're
/// writing an app, you’d use [`grab_focus()`][Self::grab_focus()] to move
/// the focus to a particular widget.
/// ## `direction`
/// direction of focus movement
///
/// # Returns
///
/// [`true`] if focus ended up inside @self
#[doc(alias = "gtk_widget_child_focus")]
fn child_focus(&self, direction: DirectionType) -> bool {
unsafe {
from_glib(ffi::gtk_widget_child_focus(
self.as_ref().to_glib_none().0,
direction.into_glib(),
))
}
}
/// Computes the bounds for @self in the coordinate space of @target.
///
/// The bounds of widget are (the bounding box of) the region that it is
/// expected to draw in. See the [coordinate system](coordinates.html)
/// overview to learn more.
///
/// If the operation is successful, [`true`] is returned. If @self has no
/// bounds or the bounds cannot be expressed in @target's coordinate space
/// (for example if both widgets are in different windows), [`false`] is
/// returned and @bounds is set to the zero rectangle.
///
/// It is valid for @self and @target to be the same widget.
/// ## `target`
/// the [`Widget`][crate::Widget]
///
/// # Returns
///
/// [`true`] if the bounds could be computed
///
/// ## `out_bounds`
/// the rectangle taking the bounds
#[doc(alias = "gtk_widget_compute_bounds")]
fn compute_bounds(&self, target: &impl IsA<Widget>) -> Option<graphene::Rect> {
unsafe {
let mut out_bounds = graphene::Rect::uninitialized();
let ret = from_glib(ffi::gtk_widget_compute_bounds(
self.as_ref().to_glib_none().0,
target.as_ref().to_glib_none().0,
out_bounds.to_glib_none_mut().0,
));
if ret {
Some(out_bounds)
} else {
None
}
}
}
/// Computes whether a container should give this widget
/// extra space when possible.
///
/// Containers should check this, rather than looking at
/// [`hexpands()`][Self::hexpands()] or [`vexpands()`][Self::vexpands()].
///
/// This function already checks whether the widget is visible, so
/// visibility does not need to be checked separately. Non-visible
/// widgets are not expanded.
///
/// The computed expand value uses either the expand setting explicitly
/// set on the widget itself, or, if none has been explicitly set,
/// the widget may expand if some of its children do.
/// ## `orientation`
/// expand direction
///
/// # Returns
///
/// whether widget tree rooted here should be expanded
#[doc(alias = "gtk_widget_compute_expand")]
fn compute_expand(&self, orientation: Orientation) -> bool {
unsafe {
from_glib(ffi::gtk_widget_compute_expand(
self.as_ref().to_glib_none().0,
orientation.into_glib(),
))
}
}
/// Translates the given @point in @self's coordinates to coordinates
/// relative to @target’s coordinate system.
///
/// In order to perform this operation, both widgets must share a
/// common ancestor.
/// ## `target`
/// the [`Widget`][crate::Widget] to transform into
/// ## `point`
/// a point in @self's coordinate system
///
/// # Returns
///
/// [`true`] if the point could be determined, [`false`] on failure.
/// In this case, 0 is stored in @out_point.
///
/// ## `out_point`
/// Set to the corresponding coordinates in
/// @target's coordinate system
#[doc(alias = "gtk_widget_compute_point")]
fn compute_point(
&self,
target: &impl IsA<Widget>,
point: &graphene::Point,
) -> Option<graphene::Point> {
unsafe {
let mut out_point = graphene::Point::uninitialized();
let ret = from_glib(ffi::gtk_widget_compute_point(
self.as_ref().to_glib_none().0,
target.as_ref().to_glib_none().0,
point.to_glib_none().0,
out_point.to_glib_none_mut().0,
));
if ret {
Some(out_point)
} else {
None
}
}
}
/// Computes a matrix suitable to describe a transformation from
/// @self's coordinate system into @target's coordinate system.
///
/// The transform can not be computed in certain cases, for example
/// when @self and @target do not share a common ancestor. In that
/// case @out_transform gets set to the identity matrix.
///
/// To learn more about widget coordinate systems, see the coordinate
/// system [overview](coordinates.html).
/// ## `target`
/// the target widget that the matrix will transform to
///
/// # Returns
///
/// [`true`] if the transform could be computed, [`false`] otherwise
///
/// ## `out_transform`
/// location to
/// store the final transformation
#[doc(alias = "gtk_widget_compute_transform")]
fn compute_transform(&self, target: &impl IsA<Widget>) -> Option<graphene::Matrix> {
unsafe {
let mut out_transform = graphene::Matrix::uninitialized();
let ret = from_glib(ffi::gtk_widget_compute_transform(
self.as_ref().to_glib_none().0,
target.as_ref().to_glib_none().0,
out_transform.to_glib_none_mut().0,
));
if ret {
Some(out_transform)
} else {
None
}
}
}
/// Tests if the point at (@x, @y) is contained in @self.
///
/// The coordinates for (@x, @y) must be in widget coordinates, so
/// (0, 0) is assumed to be the top left of @self's content area.
/// ## `x`
/// X coordinate to test, relative to @self's origin
/// ## `y`
/// Y coordinate to test, relative to @self's origin
///
/// # Returns
///
/// [`true`] if @self contains (@x, @y).
#[doc(alias = "gtk_widget_contains")]
fn contains(&self, x: f64, y: f64) -> bool {
unsafe {
from_glib(ffi::gtk_widget_contains(
self.as_ref().to_glib_none().0,
x,
y,
))
}
}
/// Creates a new [`pango::Context`][crate::pango::Context] with the appropriate font map,
/// font options, font description, and base direction for drawing
/// text for this widget.
///
/// See also [`pango_context()`][Self::pango_context()].
///
/// # Returns
///
/// the new [`pango::Context`][crate::pango::Context]
#[doc(alias = "gtk_widget_create_pango_context")]
fn create_pango_context(&self) -> pango::Context {
unsafe {
from_glib_full(ffi::gtk_widget_create_pango_context(
self.as_ref().to_glib_none().0,
))
}
}
/// Creates a new [`pango::Layout`][crate::pango::Layout] with the appropriate font map,
/// font description, and base direction for drawing text for
/// this widget.
///
/// If you keep a [`pango::Layout`][crate::pango::Layout] created in this way around,
/// you need to re-create it when the widget [`pango::Context`][crate::pango::Context]
/// is replaced. This can be tracked by listening to changes
/// of the [`root`][struct@crate::Widget#root] property on the widget.
/// ## `text`
/// text to set on the layout
///
/// # Returns
///
/// the new [`pango::Layout`][crate::pango::Layout]
#[doc(alias = "gtk_widget_create_pango_layout")]
fn create_pango_layout(&self, text: Option<&str>) -> pango::Layout {
unsafe {
from_glib_full(ffi::gtk_widget_create_pango_layout(
self.as_ref().to_glib_none().0,
text.to_glib_none().0,
))
}
}
/// Checks to see if a drag movement has passed the GTK drag threshold.
/// ## `start_x`
/// X coordinate of start of drag
/// ## `start_y`
/// Y coordinate of start of drag
/// ## `current_x`
/// current X coordinate
/// ## `current_y`
/// current Y coordinate
///
/// # Returns
///
/// [`true`] if the drag threshold has been passed.
#[doc(alias = "gtk_drag_check_threshold")]
fn drag_check_threshold(
&self,
start_x: i32,
start_y: i32,
current_x: i32,
current_y: i32,
) -> bool {
unsafe {
from_glib(ffi::gtk_drag_check_threshold(
self.as_ref().to_glib_none().0,
start_x,
start_y,
current_x,
current_y,
))
}
}
/// Notifies the user about an input-related error on this widget.
///
/// If the [`gtk-error-bell`][struct@crate::Settings#gtk-error-bell] setting is [`true`],
/// it calls `Gdk::Surface::beep()`, otherwise it does nothing.
///
/// Note that the effect of `Gdk::Surface::beep()` can be configured
/// in many ways, depending on the windowing backend and the desktop
/// environment or window manager that is used.
#[doc(alias = "gtk_widget_error_bell")]
fn error_bell(&self) {
unsafe {
ffi::gtk_widget_error_bell(self.as_ref().to_glib_none().0);
}
}
/// Returns the baseline that has currently been allocated to @self.
///
/// This function is intended to be used when implementing handlers
/// for the [`Widget`][crate::Widget]Class.snapshot() function, and when allocating
/// child widgets in [`Widget`][crate::Widget]Class.size_allocate().
///
/// # Deprecated since 4.12
///
/// Use [`baseline()`][Self::baseline()] instead
///
/// # Returns
///
/// the baseline of the @self, or -1 if none
#[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_get_allocated_baseline")]
#[doc(alias = "get_allocated_baseline")]
fn allocated_baseline(&self) -> i32 {
unsafe { ffi::gtk_widget_get_allocated_baseline(self.as_ref().to_glib_none().0) }
}
/// Returns the height that has currently been allocated to @self.
///
/// To learn more about widget sizes, see the coordinate
/// system [overview](coordinates.html).
///
/// # Deprecated since 4.12
///
/// Use [`height()`][Self::height()] instead
///
/// # Returns
///
/// the height of the @self
#[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_get_allocated_height")]
#[doc(alias = "get_allocated_height")]
fn allocated_height(&self) -> i32 {
unsafe { ffi::gtk_widget_get_allocated_height(self.as_ref().to_glib_none().0) }
}
/// Returns the width that has currently been allocated to @self.
///
/// To learn more about widget sizes, see the coordinate
/// system [overview](coordinates.html).
///
/// # Deprecated since 4.12
///
/// Use [`width()`][Self::width()] instead
///
/// # Returns
///
/// the width of the @self
#[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_get_allocated_width")]
#[doc(alias = "get_allocated_width")]
fn allocated_width(&self) -> i32 {
unsafe { ffi::gtk_widget_get_allocated_width(self.as_ref().to_glib_none().0) }
}
/// Retrieves the widget’s allocation.
///
/// Note, when implementing a layout container: a widget’s allocation
/// will be its “adjusted” allocation, that is, the widget’s parent
/// typically calls [`size_allocate()`][Self::size_allocate()] with an allocation,
/// and that allocation is then adjusted (to handle margin
/// and alignment for example) before assignment to the widget.
/// [`allocation()`][Self::allocation()] returns the adjusted allocation that
/// was actually assigned to the widget. The adjusted allocation is
/// guaranteed to be completely contained within the
/// [`size_allocate()`][Self::size_allocate()] allocation, however.
///
/// So a layout container is guaranteed that its children stay inside
/// the assigned bounds, but not that they have exactly the bounds the
/// container assigned.
///
/// # Deprecated since 4.12
///
/// Use [`compute_bounds()`][Self::compute_bounds()],
/// [`width()`][Self::width()] or [`height()`][Self::height()] instead.
///
/// # Returns
///
///
/// ## `allocation`
/// a pointer to a `GtkAllocation` to copy to
#[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_get_allocation")]
#[doc(alias = "get_allocation")]
fn allocation(&self) -> Allocation {
unsafe {
let mut allocation = Allocation::uninitialized();
ffi::gtk_widget_get_allocation(
self.as_ref().to_glib_none().0,
allocation.to_glib_none_mut().0,
);
allocation
}
}
/// Gets the first ancestor of @self with type @widget_type.
///
/// For example, `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)`
/// gets the first [`Box`][crate::Box] that’s an ancestor of @self. No
/// reference will be added to the returned widget; it should
/// not be unreferenced.
///
/// Note that unlike [`is_ancestor()`][Self::is_ancestor()], this function
/// considers @self to be an ancestor of itself.
/// ## `widget_type`
/// ancestor type
///
/// # Returns
///
/// the ancestor widget
#[doc(alias = "gtk_widget_get_ancestor")]
#[doc(alias = "get_ancestor")]
#[must_use]
fn ancestor(&self, widget_type: glib::types::Type) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_widget_get_ancestor(
self.as_ref().to_glib_none().0,
widget_type.into_glib(),
))
}
}
/// Returns the baseline that has currently been allocated to @self.
///
/// This function is intended to be used when implementing handlers
/// for the [`Widget`][crate::Widget]Class.snapshot() function, and when allocating
/// child widgets in [`Widget`][crate::Widget]Class.size_allocate().
///
/// # Returns
///
/// the baseline of the @self, or -1 if none
#[cfg(feature = "v4_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
#[doc(alias = "gtk_widget_get_baseline")]
#[doc(alias = "get_baseline")]
fn baseline(&self) -> i32 {
unsafe { ffi::gtk_widget_get_baseline(self.as_ref().to_glib_none().0) }
}
/// Determines whether the input focus can enter @self or any
/// of its children.
///
/// See [`set_focusable()`][Self::set_focusable()].
///
/// # Returns
///
/// [`true`] if the input focus can enter @self, [`false`] otherwise
#[doc(alias = "gtk_widget_get_can_focus")]
#[doc(alias = "get_can_focus")]
fn can_focus(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_can_focus(
self.as_ref().to_glib_none().0,
))
}
}
/// Queries whether @self can be the target of pointer events.
///
/// # Returns
///
/// [`true`] if @self can receive pointer events
#[doc(alias = "gtk_widget_get_can_target")]
#[doc(alias = "get_can_target")]
fn can_target(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_can_target(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the value set with gtk_widget_set_child_visible().
///
/// If you feel a need to use this function, your code probably
/// needs reorganization.
///
/// This function is only useful for container implementations
/// and should never be called by an application.
///
/// # Returns
///
/// [`true`] if the widget is mapped with the parent.
#[doc(alias = "gtk_widget_get_child_visible")]
#[doc(alias = "get_child_visible")]
fn is_child_visible(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_child_visible(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the clipboard object for @self.
///
/// This is a utility function to get the clipboard object for the
/// [`gdk::Display`][crate::gdk::Display] that @self is using.
///
/// Note that this function always works, even when @self is not
/// realized yet.
///
/// # Returns
///
/// the appropriate clipboard object
#[doc(alias = "gtk_widget_get_clipboard")]
#[doc(alias = "get_clipboard")]
fn clipboard(&self) -> gdk::Clipboard {
unsafe {
from_glib_none(ffi::gtk_widget_get_clipboard(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the current foreground color for the widget’s
/// CSS style.
///
/// This function should only be used in snapshot
/// implementations that need to do custom
/// drawing with the foreground color.
///
/// # Returns
///
///
/// ## `color`
/// return location for the color
#[cfg(feature = "v4_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
#[doc(alias = "gtk_widget_get_color")]
#[doc(alias = "get_color")]
fn color(&self) -> gdk::RGBA {
unsafe {
let mut color = gdk::RGBA::uninitialized();
ffi::gtk_widget_get_color(self.as_ref().to_glib_none().0, color.to_glib_none_mut().0);
color
}
}
/// Returns the list of style classes applied to @self.
///
/// # Returns
///
/// a [`None`]-terminated list of
/// css classes currently applied to @self. The returned
/// list must freed using g_strfreev().
#[doc(alias = "gtk_widget_get_css_classes")]
#[doc(alias = "get_css_classes")]
fn css_classes(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gtk_widget_get_css_classes(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the CSS name that is used for @self.
///
/// # Returns
///
/// the CSS name
#[doc(alias = "gtk_widget_get_css_name")]
#[doc(alias = "get_css_name")]
fn css_name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::gtk_widget_get_css_name(self.as_ref().to_glib_none().0)) }
}
/// Queries the cursor set on @self.
///
/// See [`set_cursor()`][Self::set_cursor()] for details.
///
/// # Returns
///
/// the cursor
/// currently in use or [`None`] if the cursor is inherited
#[doc(alias = "gtk_widget_get_cursor")]
#[doc(alias = "get_cursor")]
fn cursor(&self) -> Option<gdk::Cursor> {
unsafe { from_glib_none(ffi::gtk_widget_get_cursor(self.as_ref().to_glib_none().0)) }
}
/// Gets the reading direction for a particular widget.
///
/// See [`set_direction()`][Self::set_direction()].
///
/// # Returns
///
/// the reading direction for the widget.
#[doc(alias = "gtk_widget_get_direction")]
#[doc(alias = "get_direction")]
fn direction(&self) -> TextDirection {
unsafe {
from_glib(ffi::gtk_widget_get_direction(
self.as_ref().to_glib_none().0,
))
}
}
/// Get the [`gdk::Display`][crate::gdk::Display] for the toplevel window associated with
/// this widget.
///
/// This function can only be called after the widget has been
/// added to a widget hierarchy with a [`Window`][crate::Window] at the top.
///
/// In general, you should only create display specific
/// resources when a widget has been realized, and you should
/// free those resources when the widget is unrealized.
///
/// # Returns
///
/// the [`gdk::Display`][crate::gdk::Display] for the toplevel
/// for this widget.
#[doc(alias = "gtk_widget_get_display")]
#[doc(alias = "get_display")]
fn display(&self) -> gdk::Display {
unsafe { from_glib_none(ffi::gtk_widget_get_display(self.as_ref().to_glib_none().0)) }
}
/// Returns the widget’s first child.
///
/// This API is primarily meant for widget implementations.
///
/// # Returns
///
/// The widget's first child
#[doc(alias = "gtk_widget_get_first_child")]
#[doc(alias = "get_first_child")]
#[must_use]
fn first_child(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_widget_get_first_child(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the current focus child of @self.
///
/// # Returns
///
/// The current focus
/// child of @self
#[doc(alias = "gtk_widget_get_focus_child")]
#[doc(alias = "get_focus_child")]
#[must_use]
fn focus_child(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_widget_get_focus_child(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns whether the widget should grab focus when it is clicked
/// with the mouse.
///
/// See [`set_focus_on_click()`][Self::set_focus_on_click()].
///
/// # Returns
///
/// [`true`] if the widget should grab focus when it is
/// clicked with the mouse
#[doc(alias = "gtk_widget_get_focus_on_click")]
#[doc(alias = "get_focus_on_click")]
fn gets_focus_on_click(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_focus_on_click(
self.as_ref().to_glib_none().0,
))
}
}
/// Determines whether @self can own the input focus.
///
/// See [`set_focusable()`][Self::set_focusable()].
///
/// # Returns
///
/// [`true`] if @self can own the input focus, [`false`] otherwise
#[doc(alias = "gtk_widget_get_focusable")]
#[doc(alias = "get_focusable")]
fn is_focusable(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_focusable(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the font map of @self.
///
/// See [`set_font_map()`][Self::set_font_map()].
///
/// # Returns
///
/// A [`pango::FontMap`][crate::pango::FontMap]
#[doc(alias = "gtk_widget_get_font_map")]
#[doc(alias = "get_font_map")]
fn font_map(&self) -> Option<pango::FontMap> {
unsafe { from_glib_none(ffi::gtk_widget_get_font_map(self.as_ref().to_glib_none().0)) }
}
/// Returns the [`cairo::FontOptions`][crate::cairo::FontOptions] of widget.
///
/// Seee [`set_font_options()`][Self::set_font_options()].
///
/// # Returns
///
/// the [`cairo::FontOptions`][crate::cairo::FontOptions]
/// of widget
#[doc(alias = "gtk_widget_get_font_options")]
#[doc(alias = "get_font_options")]
fn font_options(&self) -> Option<cairo::FontOptions> {
unsafe {
from_glib_none(ffi::gtk_widget_get_font_options(
self.as_ref().to_glib_none().0,
))
}
}
/// Obtains the frame clock for a widget.
///
/// The frame clock is a global “ticker” that can be used to drive
/// animations and repaints. The most common reason to get the frame
/// clock is to call [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], in order
/// to get a time to use for animating. For example you might record
/// the start of the animation with an initial value from
/// [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()], and then update the animation
/// by calling [`FrameClock::frame_time()`][crate::gdk::FrameClock::frame_time()] again during each repaint.
///
/// [`FrameClock::request_phase()`][crate::gdk::FrameClock::request_phase()] will result in a new frame on the
/// clock, but won’t necessarily repaint any widgets. To repaint a
/// widget, you have to use [`queue_draw()`][Self::queue_draw()] which invalidates
/// the widget (thus scheduling it to receive a draw on the next
/// frame). gtk_widget_queue_draw() will also end up requesting a frame
/// on the appropriate frame clock.
///
/// A widget’s frame clock will not change while the widget is
/// mapped. Reparenting a widget (which implies a temporary unmap) can
/// change the widget’s frame clock.
///
/// Unrealized widgets do not have a frame clock.
///
/// # Returns
///
/// a [`gdk::FrameClock`][crate::gdk::FrameClock]
#[doc(alias = "gtk_widget_get_frame_clock")]
#[doc(alias = "get_frame_clock")]
fn frame_clock(&self) -> Option<gdk::FrameClock> {
unsafe {
from_glib_none(ffi::gtk_widget_get_frame_clock(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the horizontal alignment of @self.
///
/// For backwards compatibility reasons this method will never return
/// one of the baseline alignments, but instead it will convert it to
/// `GTK_ALIGN_FILL` or `GTK_ALIGN_CENTER`.
///
/// Baselines are not supported for horizontal alignment.
///
/// # Returns
///
/// the horizontal alignment of @self
#[doc(alias = "gtk_widget_get_halign")]
#[doc(alias = "get_halign")]
fn halign(&self) -> Align {
unsafe { from_glib(ffi::gtk_widget_get_halign(self.as_ref().to_glib_none().0)) }
}
/// Returns the current value of the `has-tooltip` property.
///
/// # Returns
///
/// current value of `has-tooltip` on @self.
#[doc(alias = "gtk_widget_get_has_tooltip")]
#[doc(alias = "get_has_tooltip")]
fn has_tooltip(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_has_tooltip(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the content height of the widget.
///
/// This function returns the height passed to its
/// size-allocate implementation, which is the height you
/// should be using in [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()].
///
/// For pointer events, see [`contains()`][Self::contains()].
///
/// To learn more about widget sizes, see the coordinate
/// system [overview](coordinates.html).
///
/// # Returns
///
/// The height of @self
#[doc(alias = "gtk_widget_get_height")]
#[doc(alias = "get_height")]
fn height(&self) -> i32 {
unsafe { ffi::gtk_widget_get_height(self.as_ref().to_glib_none().0) }
}
/// Gets whether the widget would like any available extra horizontal
/// space.
///
/// When a user resizes a [`Window`][crate::Window], widgets with expand=TRUE
/// generally receive the extra space. For example, a list or
/// scrollable area or document in your window would often be set to
/// expand.
///
/// Containers should use [`compute_expand()`][Self::compute_expand()] rather
/// than this function, to see whether a widget, or any of its children,
/// has the expand flag set. If any child of a widget wants to
/// expand, the parent may ask to expand also.
///
/// This function only looks at the widget’s own hexpand flag, rather
/// than computing whether the entire widget tree rooted at this widget
/// wants to expand.
///
/// # Returns
///
/// whether hexpand flag is set
#[doc(alias = "gtk_widget_get_hexpand")]
#[doc(alias = "get_hexpand")]
fn hexpands(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_get_hexpand(self.as_ref().to_glib_none().0)) }
}
/// Gets whether gtk_widget_set_hexpand() has been used
/// to explicitly set the expand flag on this widget.
///
/// If [`hexpand`][struct@crate::Widget#hexpand] property is set, then it
/// overrides any computed expand value based on child widgets.
/// If `hexpand` is not set, then the expand value depends on
/// whether any children of the widget would like to expand.
///
/// There are few reasons to use this function, but it’s here
/// for completeness and consistency.
///
/// # Returns
///
/// whether hexpand has been explicitly set
#[doc(alias = "gtk_widget_get_hexpand_set")]
#[doc(alias = "get_hexpand_set")]
fn is_hexpand_set(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_hexpand_set(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the widget’s last child.
///
/// This API is primarily meant for widget implementations.
///
/// # Returns
///
/// The widget's last child
#[doc(alias = "gtk_widget_get_last_child")]
#[doc(alias = "get_last_child")]
#[must_use]
fn last_child(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_widget_get_last_child(
self.as_ref().to_glib_none().0,
))
}
}
/// Retrieves the layout manager used by @self.
///
/// See [`set_layout_manager()`][Self::set_layout_manager()].
///
/// # Returns
///
/// a [`LayoutManager`][crate::LayoutManager]
#[doc(alias = "gtk_widget_get_layout_manager")]
#[doc(alias = "get_layout_manager")]
fn layout_manager(&self) -> Option<LayoutManager> {
unsafe {
from_glib_none(ffi::gtk_widget_get_layout_manager(
self.as_ref().to_glib_none().0,
))
}
}
/// Whether the widget is mapped.
///
/// # Returns
///
/// [`true`] if the widget is mapped, [`false`] otherwise.
#[doc(alias = "gtk_widget_get_mapped")]
#[doc(alias = "get_mapped")]
fn is_mapped(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_get_mapped(self.as_ref().to_glib_none().0)) }
}
/// Gets the bottom margin of @self.
///
/// # Returns
///
/// The bottom margin of @self
#[doc(alias = "gtk_widget_get_margin_bottom")]
#[doc(alias = "get_margin_bottom")]
fn margin_bottom(&self) -> i32 {
unsafe { ffi::gtk_widget_get_margin_bottom(self.as_ref().to_glib_none().0) }
}
/// Gets the end margin of @self.
///
/// # Returns
///
/// The end margin of @self
#[doc(alias = "gtk_widget_get_margin_end")]
#[doc(alias = "get_margin_end")]
fn margin_end(&self) -> i32 {
unsafe { ffi::gtk_widget_get_margin_end(self.as_ref().to_glib_none().0) }
}
/// Gets the start margin of @self.
///
/// # Returns
///
/// The start margin of @self
#[doc(alias = "gtk_widget_get_margin_start")]
#[doc(alias = "get_margin_start")]
fn margin_start(&self) -> i32 {
unsafe { ffi::gtk_widget_get_margin_start(self.as_ref().to_glib_none().0) }
}
/// Gets the top margin of @self.
///
/// # Returns
///
/// The top margin of @self
#[doc(alias = "gtk_widget_get_margin_top")]
#[doc(alias = "get_margin_top")]
fn margin_top(&self) -> i32 {
unsafe { ffi::gtk_widget_get_margin_top(self.as_ref().to_glib_none().0) }
}
/// Retrieves the name of a widget.
///
/// See [`set_widget_name()`][Self::set_widget_name()] for the significance of widget names.
///
/// # Returns
///
/// name of the widget. This string is owned by GTK and
/// should not be modified or freed
#[doc(alias = "gtk_widget_get_name")]
#[doc(alias = "get_name")]
fn widget_name(&self) -> glib::GString {
unsafe { from_glib_none(ffi::gtk_widget_get_name(self.as_ref().to_glib_none().0)) }
}
/// Returns the nearest [`Native`][crate::Native] ancestor of @self.
///
/// This function will return [`None`] if the widget is not
/// contained inside a widget tree with a native ancestor.
///
/// [`Native`][crate::Native] widgets will return themselves here.
///
/// # Returns
///
/// the [`Native`][crate::Native] ancestor of @self
#[doc(alias = "gtk_widget_get_native")]
#[doc(alias = "get_native")]
fn native(&self) -> Option<Native> {
unsafe { from_glib_none(ffi::gtk_widget_get_native(self.as_ref().to_glib_none().0)) }
}
/// Returns the widget’s next sibling.
///
/// This API is primarily meant for widget implementations.
///
/// # Returns
///
/// The widget's next sibling
#[doc(alias = "gtk_widget_get_next_sibling")]
#[doc(alias = "get_next_sibling")]
#[must_use]
fn next_sibling(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_widget_get_next_sibling(
self.as_ref().to_glib_none().0,
))
}
}
/// #Fetches the requested opacity for this widget.
///
/// See [`set_opacity()`][Self::set_opacity()].
///
/// # Returns
///
/// the requested opacity for this widget.
#[doc(alias = "gtk_widget_get_opacity")]
#[doc(alias = "get_opacity")]
fn opacity(&self) -> f64 {
unsafe { ffi::gtk_widget_get_opacity(self.as_ref().to_glib_none().0) }
}
/// Returns the widget’s overflow value.
///
/// # Returns
///
/// The widget's overflow.
#[doc(alias = "gtk_widget_get_overflow")]
#[doc(alias = "get_overflow")]
fn overflow(&self) -> Overflow {
unsafe { from_glib(ffi::gtk_widget_get_overflow(self.as_ref().to_glib_none().0)) }
}
/// Gets a [`pango::Context`][crate::pango::Context] with the appropriate font map, font description,
/// and base direction for this widget.
///
/// Unlike the context returned by [`create_pango_context()`][Self::create_pango_context()],
/// this context is owned by the widget (it can be used until the screen
/// for the widget changes or the widget is removed from its toplevel),
/// and will be updated to match any changes to the widget’s attributes.
/// This can be tracked by listening to changes of the
/// [`root`][struct@crate::Widget#root] property on the widget.
///
/// # Returns
///
/// the [`pango::Context`][crate::pango::Context] for the widget.
#[doc(alias = "gtk_widget_get_pango_context")]
#[doc(alias = "get_pango_context")]
fn pango_context(&self) -> pango::Context {
unsafe {
from_glib_none(ffi::gtk_widget_get_pango_context(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the parent widget of @self.
///
/// # Returns
///
/// the parent widget of @self
#[doc(alias = "gtk_widget_get_parent")]
#[doc(alias = "get_parent")]
#[must_use]
fn parent(&self) -> Option<Widget> {
unsafe { from_glib_none(ffi::gtk_widget_get_parent(self.as_ref().to_glib_none().0)) }
}
/// Retrieves the minimum and natural size of a widget, taking
/// into account the widget’s preference for height-for-width management.
///
/// This is used to retrieve a suitable size by container widgets which do
/// not impose any restrictions on the child placement. It can be used
/// to deduce toplevel window and menu sizes as well as child widgets in
/// free-form containers such as [`Fixed`][crate::Fixed].
///
/// Handle with care. Note that the natural height of a height-for-width
/// widget will generally be a smaller size than the minimum height, since
/// the required height for the natural width is generally smaller than the
/// required height for the minimum width.
///
/// Use [`measure()`][Self::measure()] if you want to support baseline alignment.
///
/// # Returns
///
///
/// ## `minimum_size`
/// location for storing the minimum size
///
/// ## `natural_size`
/// location for storing the natural size
#[doc(alias = "gtk_widget_get_preferred_size")]
#[doc(alias = "get_preferred_size")]
fn preferred_size(&self) -> (Requisition, Requisition) {
unsafe {
let mut minimum_size = Requisition::uninitialized();
let mut natural_size = Requisition::uninitialized();
ffi::gtk_widget_get_preferred_size(
self.as_ref().to_glib_none().0,
minimum_size.to_glib_none_mut().0,
natural_size.to_glib_none_mut().0,
);
(minimum_size, natural_size)
}
}
/// Returns the widget’s previous sibling.
///
/// This API is primarily meant for widget implementations.
///
/// # Returns
///
/// The widget's previous sibling
#[doc(alias = "gtk_widget_get_prev_sibling")]
#[doc(alias = "get_prev_sibling")]
#[must_use]
fn prev_sibling(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_widget_get_prev_sibling(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the primary clipboard of @self.
///
/// This is a utility function to get the primary clipboard object
/// for the [`gdk::Display`][crate::gdk::Display] that @self is using.
///
/// Note that this function always works, even when @self is not
/// realized yet.
///
/// # Returns
///
/// the appropriate clipboard object
#[doc(alias = "gtk_widget_get_primary_clipboard")]
#[doc(alias = "get_primary_clipboard")]
fn primary_clipboard(&self) -> gdk::Clipboard {
unsafe {
from_glib_none(ffi::gtk_widget_get_primary_clipboard(
self.as_ref().to_glib_none().0,
))
}
}
/// Determines whether @self is realized.
///
/// # Returns
///
/// [`true`] if @self is realized, [`false`] otherwise
#[doc(alias = "gtk_widget_get_realized")]
#[doc(alias = "get_realized")]
fn is_realized(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_get_realized(self.as_ref().to_glib_none().0)) }
}
/// Determines whether @self is always treated as the default widget
/// within its toplevel when it has the focus, even if another widget
/// is the default.
///
/// See [`set_receives_default()`][Self::set_receives_default()].
///
/// # Returns
///
/// [`true`] if @self acts as the default widget when focused,
/// [`false`] otherwise
#[doc(alias = "gtk_widget_get_receives_default")]
#[doc(alias = "get_receives_default")]
fn receives_default(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_receives_default(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets whether the widget prefers a height-for-width layout
/// or a width-for-height layout.
///
/// Single-child widgets generally propagate the preference of
/// their child, more complex widgets need to request something
/// either in context of their children or in context of their
/// allocation capabilities.
///
/// # Returns
///
/// The [`SizeRequestMode`][crate::SizeRequestMode] preferred by @self.
#[doc(alias = "gtk_widget_get_request_mode")]
#[doc(alias = "get_request_mode")]
fn request_mode(&self) -> SizeRequestMode {
unsafe {
from_glib(ffi::gtk_widget_get_request_mode(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the [`Root`][crate::Root] widget of @self.
///
/// This function will return [`None`] if the widget is not contained
/// inside a widget tree with a root widget.
///
/// [`Root`][crate::Root] widgets will return themselves here.
///
/// # Returns
///
/// the root widget of @self
#[doc(alias = "gtk_widget_get_root")]
#[doc(alias = "get_root")]
fn root(&self) -> Option<Root> {
unsafe { from_glib_none(ffi::gtk_widget_get_root(self.as_ref().to_glib_none().0)) }
}
/// Retrieves the internal scale factor that maps from window
/// coordinates to the actual device pixels.
///
/// On traditional systems this is 1, on high density outputs,
/// it can be a higher value (typically 2).
///
/// See `Gdk::Surface::get_scale_factor()`.
///
/// # Returns
///
/// the scale factor for @self
#[doc(alias = "gtk_widget_get_scale_factor")]
#[doc(alias = "get_scale_factor")]
fn scale_factor(&self) -> i32 {
unsafe { ffi::gtk_widget_get_scale_factor(self.as_ref().to_glib_none().0) }
}
/// Returns the widget’s sensitivity.
///
/// This function returns the value that has been set using
/// [`set_sensitive()`][Self::set_sensitive()]).
///
/// The effective sensitivity of a widget is however determined
/// by both its own and its parent widget’s sensitivity.
/// See [`is_sensitive()`][Self::is_sensitive()].
///
/// # Returns
///
/// [`true`] if the widget is sensitive
#[doc(alias = "gtk_widget_get_sensitive")]
fn get_sensitive(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_sensitive(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the settings object holding the settings used for this widget.
///
/// Note that this function can only be called when the [`Widget`][crate::Widget]
/// is attached to a toplevel, since the settings object is specific
/// to a particular [`gdk::Display`][crate::gdk::Display]. If you want to monitor the widget for
/// changes in its settings, connect to the `notify::display` signal.
///
/// # Returns
///
/// the relevant [`Settings`][crate::Settings] object
#[doc(alias = "gtk_widget_get_settings")]
#[doc(alias = "get_settings")]
fn settings(&self) -> Settings {
unsafe { from_glib_none(ffi::gtk_widget_get_settings(self.as_ref().to_glib_none().0)) }
}
/// Returns the content width or height of the widget.
///
/// Which dimension is returned depends on @orientation.
///
/// This is equivalent to calling [`width()`][Self::width()]
/// for [`Orientation::Horizontal`][crate::Orientation::Horizontal] or [`height()`][Self::height()]
/// for [`Orientation::Vertical`][crate::Orientation::Vertical], but can be used when
/// writing orientation-independent code, such as when
/// implementing [`Orientable`][crate::Orientable] widgets.
///
/// To learn more about widget sizes, see the coordinate
/// system [overview](coordinates.html).
/// ## `orientation`
/// the orientation to query
///
/// # Returns
///
/// The size of @self in @orientation.
#[doc(alias = "gtk_widget_get_size")]
#[doc(alias = "get_size")]
fn size(&self, orientation: Orientation) -> i32 {
unsafe { ffi::gtk_widget_get_size(self.as_ref().to_glib_none().0, orientation.into_glib()) }
}
/// Gets the size request that was explicitly set for the widget using
/// gtk_widget_set_size_request().
///
/// A value of -1 stored in @width or @height indicates that that
/// dimension has not been set explicitly and the natural requisition
/// of the widget will be used instead. See
/// [`set_size_request()`][Self::set_size_request()]. To get the size a widget will
/// actually request, call [`measure()`][Self::measure()] instead of
/// this function.
///
/// # Returns
///
///
/// ## `width`
/// return location for width
///
/// ## `height`
/// return location for height
#[doc(alias = "gtk_widget_get_size_request")]
#[doc(alias = "get_size_request")]
fn size_request(&self) -> (i32, i32) {
unsafe {
let mut width = mem::MaybeUninit::uninit();
let mut height = mem::MaybeUninit::uninit();
ffi::gtk_widget_get_size_request(
self.as_ref().to_glib_none().0,
width.as_mut_ptr(),
height.as_mut_ptr(),
);
(width.assume_init(), height.assume_init())
}
}
/// Returns the widget state as a flag set.
///
/// It is worth mentioning that the effective [`StateFlags::INSENSITIVE`][crate::StateFlags::INSENSITIVE]
/// state will be returned, that is, also based on parent insensitivity,
/// even if @self itself is sensitive.
///
/// Also note that if you are looking for a way to obtain the
/// [`StateFlags`][crate::StateFlags] to pass to a [`StyleContext`][crate::StyleContext]
/// method, you should look at [`StyleContextExt::state()`][crate::prelude::StyleContextExt::state()].
///
/// # Returns
///
/// The state flags for widget
#[doc(alias = "gtk_widget_get_state_flags")]
#[doc(alias = "get_state_flags")]
fn state_flags(&self) -> StateFlags {
unsafe {
from_glib(ffi::gtk_widget_get_state_flags(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the style context associated to @self.
///
/// The returned object is guaranteed to be the same
/// for the lifetime of @self.
///
/// # Deprecated since 4.10
///
/// Style contexts will be removed in GTK 5
///
/// # Returns
///
/// the widget’s [`StyleContext`][crate::StyleContext]
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_get_style_context")]
#[doc(alias = "get_style_context")]
fn style_context(&self) -> StyleContext {
unsafe {
from_glib_none(ffi::gtk_widget_get_style_context(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the contents of the tooltip for @self.
///
/// If the tooltip has not been set using
/// [`set_tooltip_markup()`][Self::set_tooltip_markup()], this
/// function returns [`None`].
///
/// # Returns
///
/// the tooltip text
#[doc(alias = "gtk_widget_get_tooltip_markup")]
#[doc(alias = "get_tooltip_markup")]
fn tooltip_markup(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gtk_widget_get_tooltip_markup(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the contents of the tooltip for @self.
///
/// If the @self's tooltip was set using
/// [`set_tooltip_markup()`][Self::set_tooltip_markup()],
/// this function will return the escaped text.
///
/// # Returns
///
/// the tooltip text
#[doc(alias = "gtk_widget_get_tooltip_text")]
#[doc(alias = "get_tooltip_text")]
fn tooltip_text(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gtk_widget_get_tooltip_text(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the vertical alignment of @self.
///
/// # Returns
///
/// the vertical alignment of @self
#[doc(alias = "gtk_widget_get_valign")]
#[doc(alias = "get_valign")]
fn valign(&self) -> Align {
unsafe { from_glib(ffi::gtk_widget_get_valign(self.as_ref().to_glib_none().0)) }
}
/// Gets whether the widget would like any available extra vertical
/// space.
///
/// See [`hexpands()`][Self::hexpands()] for more detail.
///
/// # Returns
///
/// whether vexpand flag is set
#[doc(alias = "gtk_widget_get_vexpand")]
#[doc(alias = "get_vexpand")]
fn vexpands(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_get_vexpand(self.as_ref().to_glib_none().0)) }
}
/// Gets whether gtk_widget_set_vexpand() has been used to
/// explicitly set the expand flag on this widget.
///
/// See [`is_hexpand_set()`][Self::is_hexpand_set()] for more detail.
///
/// # Returns
///
/// whether vexpand has been explicitly set
#[doc(alias = "gtk_widget_get_vexpand_set")]
#[doc(alias = "get_vexpand_set")]
fn is_vexpand_set(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_get_vexpand_set(
self.as_ref().to_glib_none().0,
))
}
}
/// Determines whether the widget is visible.
///
/// If you want to take into account whether the widget’s
/// parent is also marked as visible, use
/// [`is_visible()`][Self::is_visible()] instead.
///
/// This function does not check if the widget is
/// obscured in any way.
///
/// See [`set_visible()`][Self::set_visible()].
///
/// # Returns
///
/// [`true`] if the widget is visible
#[doc(alias = "gtk_widget_get_visible")]
fn get_visible(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_get_visible(self.as_ref().to_glib_none().0)) }
}
/// Returns the content width of the widget.
///
/// This function returns the width passed to its
/// size-allocate implementation, which is the width you
/// should be using in [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()].
///
/// For pointer events, see [`contains()`][Self::contains()].
///
/// To learn more about widget sizes, see the coordinate
/// system [overview](coordinates.html).
///
/// # Returns
///
/// The width of @self
#[doc(alias = "gtk_widget_get_width")]
#[doc(alias = "get_width")]
fn width(&self) -> i32 {
unsafe { ffi::gtk_widget_get_width(self.as_ref().to_glib_none().0) }
}
/// Causes @self to have the keyboard focus for the [`Window`][crate::Window] it's inside.
///
/// If @self is not focusable, or its [`WidgetImpl::grab_focus()`][crate::subclass::prelude::WidgetImpl::grab_focus()]
/// implementation cannot transfer the focus to a descendant of @self
/// that is focusable, it will not take focus and [`false`] will be returned.
///
/// Calling [`grab_focus()`][Self::grab_focus()] on an already focused widget
/// is allowed, should not have an effect, and return [`true`].
///
/// # Returns
///
/// [`true`] if focus is now inside @self.
#[doc(alias = "gtk_widget_grab_focus")]
fn grab_focus(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_grab_focus(self.as_ref().to_glib_none().0)) }
}
/// Returns whether @css_class is currently applied to @self.
/// ## `css_class`
/// A style class, without the leading '.'
/// used for notation of style classes
///
/// # Returns
///
/// [`true`] if @css_class is currently applied to @self,
/// [`false`] otherwise.
#[doc(alias = "gtk_widget_has_css_class")]
fn has_css_class(&self, css_class: &str) -> bool {
unsafe {
from_glib(ffi::gtk_widget_has_css_class(
self.as_ref().to_glib_none().0,
css_class.to_glib_none().0,
))
}
}
/// Determines whether @self is the current default widget
/// within its toplevel.
///
/// # Returns
///
/// [`true`] if @self is the current default widget
/// within its toplevel, [`false`] otherwise
#[doc(alias = "gtk_widget_has_default")]
fn has_default(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_has_default(self.as_ref().to_glib_none().0)) }
}
/// Determines if the widget has the global input focus.
///
/// See [`is_focus()`][Self::is_focus()] for the difference between
/// having the global input focus, and only having the focus
/// within a toplevel.
///
/// # Returns
///
/// [`true`] if the widget has the global input focus.
#[doc(alias = "gtk_widget_has_focus")]
fn has_focus(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_has_focus(self.as_ref().to_glib_none().0)) }
}
/// Determines if the widget should show a visible indication that
/// it has the global input focus.
///
/// This is a convenience function that takes into account whether
/// focus indication should currently be shown in the toplevel window
/// of @self. See [`GtkWindowExt::gets_focus_visible()`][crate::prelude::GtkWindowExt::gets_focus_visible()] for more
/// information about focus indication.
///
/// To find out if the widget has the global input focus, use
/// [`has_focus()`][Self::has_focus()].
///
/// # Returns
///
/// [`true`] if the widget should display a “focus rectangle”
#[doc(alias = "gtk_widget_has_visible_focus")]
fn has_visible_focus(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_has_visible_focus(
self.as_ref().to_glib_none().0,
))
}
}
/// Reverses the effects of gtk_widget_show().
///
/// This is causing the widget to be hidden (invisible to the user).
///
/// # Deprecated since 4.10
///
/// Use [`set_visible()`][Self::set_visible()] instead
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_hide")]
fn hide(&self) {
unsafe {
ffi::gtk_widget_hide(self.as_ref().to_glib_none().0);
}
}
/// Returns whether the widget is currently being destroyed.
///
/// This information can sometimes be used to avoid doing
/// unnecessary work.
///
/// # Returns
///
/// [`true`] if @self is being destroyed
#[doc(alias = "gtk_widget_in_destruction")]
fn in_destruction(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_in_destruction(
self.as_ref().to_glib_none().0,
))
}
}
/// Inserts @group into @self.
///
/// Children of @self that implement [`Actionable`][crate::Actionable] can
/// then be associated with actions in @group by setting their
/// “action-name” to @prefix.`action-name`.
///
/// Note that inheritance is defined for individual actions. I.e.
/// even if you insert a group with prefix @prefix, actions with
/// the same prefix will still be inherited from the parent, unless
/// the group contains an action with the same name.
///
/// If @group is [`None`], a previously inserted group for @name is
/// removed from @self.
/// ## `name`
/// the prefix for actions in @group
/// ## `group`
/// a `GActionGroup`, or [`None`] to remove
/// the previously inserted group for @name
#[doc(alias = "gtk_widget_insert_action_group")]
fn insert_action_group(&self, name: &str, group: Option<&impl IsA<gio::ActionGroup>>) {
unsafe {
ffi::gtk_widget_insert_action_group(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
group.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Inserts @self into the child widget list of @parent.
///
/// It will be placed after @previous_sibling, or at the beginning if
/// @previous_sibling is [`None`].
///
/// After calling this function, `gtk_widget_get_prev_sibling(widget)`
/// will return @previous_sibling.
///
/// If @parent is already set as the parent widget of @self, this
/// function can also be used to reorder @self in the child widget
/// list of @parent.
///
/// This API is primarily meant for widget implementations; if you are
/// just using a widget, you *must* use its own API for adding children.
/// ## `parent`
/// the parent [`Widget`][crate::Widget] to insert @self into
/// ## `previous_sibling`
/// the new previous sibling of @self
#[doc(alias = "gtk_widget_insert_after")]
fn insert_after(&self, parent: &impl IsA<Widget>, previous_sibling: Option<&impl IsA<Widget>>) {
unsafe {
ffi::gtk_widget_insert_after(
self.as_ref().to_glib_none().0,
parent.as_ref().to_glib_none().0,
previous_sibling.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Inserts @self into the child widget list of @parent.
///
/// It will be placed before @next_sibling, or at the end if
/// @next_sibling is [`None`].
///
/// After calling this function, `gtk_widget_get_next_sibling(widget)`
/// will return @next_sibling.
///
/// If @parent is already set as the parent widget of @self, this function
/// can also be used to reorder @self in the child widget list of @parent.
///
/// This API is primarily meant for widget implementations; if you are
/// just using a widget, you *must* use its own API for adding children.
/// ## `parent`
/// the parent [`Widget`][crate::Widget] to insert @self into
/// ## `next_sibling`
/// the new next sibling of @self
#[doc(alias = "gtk_widget_insert_before")]
fn insert_before(&self, parent: &impl IsA<Widget>, next_sibling: Option<&impl IsA<Widget>>) {
unsafe {
ffi::gtk_widget_insert_before(
self.as_ref().to_glib_none().0,
parent.as_ref().to_glib_none().0,
next_sibling.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Determines whether @self is somewhere inside @ancestor,
/// possibly with intermediate containers.
/// ## `ancestor`
/// another [`Widget`][crate::Widget]
///
/// # Returns
///
/// [`true`] if @ancestor contains @self as a child,
/// grandchild, great grandchild, etc.
#[doc(alias = "gtk_widget_is_ancestor")]
fn is_ancestor(&self, ancestor: &impl IsA<Widget>) -> bool {
unsafe {
from_glib(ffi::gtk_widget_is_ancestor(
self.as_ref().to_glib_none().0,
ancestor.as_ref().to_glib_none().0,
))
}
}
/// Determines whether @self can be drawn to.
///
/// A widget can be drawn if it is mapped and visible.
///
/// # Returns
///
/// [`true`] if @self is drawable, [`false`] otherwise
#[doc(alias = "gtk_widget_is_drawable")]
fn is_drawable(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_is_drawable(self.as_ref().to_glib_none().0)) }
}
/// Determines if the widget is the focus widget within its
/// toplevel.
///
/// This does not mean that the [`has-focus`][struct@crate::Widget#has-focus]
/// property is necessarily set; [`has-focus`][struct@crate::Widget#has-focus]
/// will only be set if the toplevel widget additionally has the
/// global input focus.
///
/// # Returns
///
/// [`true`] if the widget is the focus widget.
#[doc(alias = "gtk_widget_is_focus")]
fn is_focus(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_is_focus(self.as_ref().to_glib_none().0)) }
}
/// Returns the widget’s effective sensitivity.
///
/// This means it is sensitive itself and also its
/// parent widget is sensitive.
///
/// # Returns
///
/// [`true`] if the widget is effectively sensitive
#[doc(alias = "gtk_widget_is_sensitive")]
fn is_sensitive(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_is_sensitive(self.as_ref().to_glib_none().0)) }
}
/// Determines whether the widget and all its parents are marked as
/// visible.
///
/// This function does not check if the widget is obscured in any way.
///
/// See also [`get_visible()`][Self::get_visible()] and
/// [`set_visible()`][Self::set_visible()].
///
/// # Returns
///
/// [`true`] if the widget and all its parents are visible
#[doc(alias = "gtk_widget_is_visible")]
fn is_visible(&self) -> bool {
unsafe { from_glib(ffi::gtk_widget_is_visible(self.as_ref().to_glib_none().0)) }
}
/// Emits the `::keynav-failed` signal on the widget.
///
/// This function should be called whenever keyboard navigation
/// within a single widget hits a boundary.
///
/// The return value of this function should be interpreted
/// in a way similar to the return value of
/// [`child_focus()`][Self::child_focus()]. When [`true`] is returned,
/// stay in the widget, the failed keyboard navigation is OK
/// and/or there is nowhere we can/should move the focus to.
/// When [`false`] is returned, the caller should continue with
/// keyboard navigation outside the widget, e.g. by calling
/// [`child_focus()`][Self::child_focus()] on the widget’s toplevel.
///
/// The default [`keynav-failed`][struct@crate::Widget#keynav-failed] handler returns
/// [`false`] for [`DirectionType::TabForward`][crate::DirectionType::TabForward] and [`DirectionType::TabBackward`][crate::DirectionType::TabBackward].
/// For the other values of [`DirectionType`][crate::DirectionType] it returns [`true`].
///
/// Whenever the default handler returns [`true`], it also calls
/// [`error_bell()`][Self::error_bell()] to notify the user of the
/// failed keyboard navigation.
///
/// A use case for providing an own implementation of ::keynav-failed
/// (either by connecting to it or by overriding it) would be a row of
/// [`Entry`][crate::Entry] widgets where the user should be able to navigate
/// the entire row with the cursor keys, as e.g. known from user
/// interfaces that require entering license keys.
/// ## `direction`
/// direction of focus movement
///
/// # Returns
///
/// [`true`] if stopping keyboard navigation is fine, [`false`]
/// if the emitting widget should try to handle the keyboard
/// navigation attempt in its parent container(s).
#[doc(alias = "gtk_widget_keynav_failed")]
fn keynav_failed(&self, direction: DirectionType) -> bool {
unsafe {
from_glib(ffi::gtk_widget_keynav_failed(
self.as_ref().to_glib_none().0,
direction.into_glib(),
))
}
}
/// Returns the widgets for which this widget is the target of a
/// mnemonic.
///
/// Typically, these widgets will be labels. See, for example,
/// [`Label::set_mnemonic_widget()`][crate::Label::set_mnemonic_widget()].
///
/// The widgets in the list are not individually referenced.
/// If you want to iterate through the list and perform actions
/// involving callbacks that might destroy the widgets, you
/// must call `g_list_foreach (result, (GFunc)g_object_ref, NULL)`
/// first, and then unref all the widgets afterwards.
///
/// # Returns
///
/// the list
/// of mnemonic labels; free this list with g_list_free() when you
/// are done with it.
#[doc(alias = "gtk_widget_list_mnemonic_labels")]
fn list_mnemonic_labels(&self) -> Vec<Widget> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::gtk_widget_list_mnemonic_labels(
self.as_ref().to_glib_none().0,
))
}
}
/// Causes a widget to be mapped if it isn’t already.
///
/// This function is only for use in widget implementations.
#[doc(alias = "gtk_widget_map")]
fn map(&self) {
unsafe {
ffi::gtk_widget_map(self.as_ref().to_glib_none().0);
}
}
/// Measures @self in the orientation @orientation and for the given @for_size.
///
/// As an example, if @orientation is [`Orientation::Horizontal`][crate::Orientation::Horizontal] and @for_size
/// is 300, this functions will compute the minimum and natural width of @self
/// if it is allocated at a height of 300 pixels.
///
/// See [GtkWidget’s geometry management section](class.Widget.html#height-for-width-geometry-management) for
/// a more details on implementing `GtkWidgetClass.measure()`.
/// ## `orientation`
/// the orientation to measure
/// ## `for_size`
/// Size for the opposite of @orientation, i.e.
/// if @orientation is [`Orientation::Horizontal`][crate::Orientation::Horizontal], this is
/// the height the widget should be measured with. The [`Orientation::Vertical`][crate::Orientation::Vertical]
/// case is analogous. This way, both height-for-width and width-for-height
/// requests can be implemented. If no size is known, -1 can be passed.
///
/// # Returns
///
///
/// ## `minimum`
/// location to store the minimum size
///
/// ## `natural`
/// location to store the natural size
///
/// ## `minimum_baseline`
/// location to store the baseline
/// position for the minimum size, or -1 to report no baseline
///
/// ## `natural_baseline`
/// location to store the baseline
/// position for the natural size, or -1 to report no baseline
#[doc(alias = "gtk_widget_measure")]
fn measure(&self, orientation: Orientation, for_size: i32) -> (i32, i32, i32, i32) {
unsafe {
let mut minimum = mem::MaybeUninit::uninit();
let mut natural = mem::MaybeUninit::uninit();
let mut minimum_baseline = mem::MaybeUninit::uninit();
let mut natural_baseline = mem::MaybeUninit::uninit();
ffi::gtk_widget_measure(
self.as_ref().to_glib_none().0,
orientation.into_glib(),
for_size,
minimum.as_mut_ptr(),
natural.as_mut_ptr(),
minimum_baseline.as_mut_ptr(),
natural_baseline.as_mut_ptr(),
);
(
minimum.assume_init(),
natural.assume_init(),
minimum_baseline.assume_init(),
natural_baseline.assume_init(),
)
}
}
/// Emits the ::mnemonic-activate signal.
///
/// See [`mnemonic-activate`][struct@crate::Widget#mnemonic-activate].
/// ## `group_cycling`
/// [`true`] if there are other widgets with the same mnemonic
///
/// # Returns
///
/// [`true`] if the signal has been handled
#[doc(alias = "gtk_widget_mnemonic_activate")]
fn mnemonic_activate(&self, group_cycling: bool) -> bool {
unsafe {
from_glib(ffi::gtk_widget_mnemonic_activate(
self.as_ref().to_glib_none().0,
group_cycling.into_glib(),
))
}
}
/// Returns a `GListModel` to track the children of @self.
///
/// Calling this function will enable extra internal bookkeeping
/// to track children and emit signals on the returned listmodel.
/// It may slow down operations a lot.
///
/// Applications should try hard to avoid calling this function
/// because of the slowdowns.
///
/// # Returns
///
///
/// a `GListModel` tracking @self's children
#[doc(alias = "gtk_widget_observe_children")]
fn observe_children(&self) -> gio::ListModel {
unsafe {
from_glib_full(ffi::gtk_widget_observe_children(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns a `GListModel` to track the [`EventController`][crate::EventController]s
/// of @self.
///
/// Calling this function will enable extra internal bookkeeping
/// to track controllers and emit signals on the returned listmodel.
/// It may slow down operations a lot.
///
/// Applications should try hard to avoid calling this function
/// because of the slowdowns.
///
/// # Returns
///
///
/// a `GListModel` tracking @self's controllers
#[doc(alias = "gtk_widget_observe_controllers")]
fn observe_controllers(&self) -> gio::ListModel {
unsafe {
from_glib_full(ffi::gtk_widget_observe_controllers(
self.as_ref().to_glib_none().0,
))
}
}
/// Finds the descendant of @self closest to the point (@x, @y).
///
/// The point must be given in widget coordinates, so (0, 0) is assumed
/// to be the top left of @self's content area.
///
/// Usually widgets will return [`None`] if the given coordinate is not
/// contained in @self checked via [`contains()`][Self::contains()].
/// Otherwise they will recursively try to find a child that does
/// not return [`None`]. Widgets are however free to customize their
/// picking algorithm.
///
/// This function is used on the toplevel to determine the widget
/// below the mouse cursor for purposes of hover highlighting and
/// delivering events.
/// ## `x`
/// X coordinate to test, relative to @self's origin
/// ## `y`
/// Y coordinate to test, relative to @self's origin
/// ## `flags`
/// Flags to influence what is picked
///
/// # Returns
///
/// The widget descendant at
/// the given point
#[doc(alias = "gtk_widget_pick")]
#[must_use]
fn pick(&self, x: f64, y: f64, flags: PickFlags) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_widget_pick(
self.as_ref().to_glib_none().0,
x,
y,
flags.into_glib(),
))
}
}
/// Flags the widget for a rerun of the [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()]
/// function.
///
/// Use this function instead of [`queue_resize()`][Self::queue_resize()]
/// when the @self's size request didn't change but it wants to
/// reposition its contents.
///
/// An example user of this function is [`set_halign()`][Self::set_halign()].
///
/// This function is only for use in widget implementations.
#[doc(alias = "gtk_widget_queue_allocate")]
fn queue_allocate(&self) {
unsafe {
ffi::gtk_widget_queue_allocate(self.as_ref().to_glib_none().0);
}
}
/// Schedules this widget to be redrawn in the paint phase
/// of the current or the next frame.
///
/// This means @self's [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()]
/// implementation will be called.
#[doc(alias = "gtk_widget_queue_draw")]
fn queue_draw(&self) {
unsafe {
ffi::gtk_widget_queue_draw(self.as_ref().to_glib_none().0);
}
}
/// Flags a widget to have its size renegotiated.
///
/// This should be called when a widget for some reason has a new
/// size request. For example, when you change the text in a
/// [`Label`][crate::Label], the label queues a resize to ensure there’s
/// enough space for the new text.
///
/// Note that you cannot call gtk_widget_queue_resize() on a widget
/// from inside its implementation of the [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()]
/// virtual method. Calls to gtk_widget_queue_resize() from inside
/// [`WidgetImpl::size_allocate()`][crate::subclass::prelude::WidgetImpl::size_allocate()] will be silently ignored.
///
/// This function is only for use in widget implementations.
#[doc(alias = "gtk_widget_queue_resize")]
fn queue_resize(&self) {
unsafe {
ffi::gtk_widget_queue_resize(self.as_ref().to_glib_none().0);
}
}
/// Creates the GDK resources associated with a widget.
///
/// Normally realization happens implicitly; if you show a widget
/// and all its parent containers, then the widget will be realized
/// and mapped automatically.
///
/// Realizing a widget requires all the widget’s parent widgets to be
/// realized; calling this function realizes the widget’s parents
/// in addition to @self itself. If a widget is not yet inside a
/// toplevel window when you realize it, bad things will happen.
///
/// This function is primarily used in widget implementations, and
/// isn’t very useful otherwise. Many times when you think you might
/// need it, a better approach is to connect to a signal that will be
/// called after the widget is realized automatically, such as
/// [`realize`][struct@crate::Widget#realize].
#[doc(alias = "gtk_widget_realize")]
fn realize(&self) {
unsafe {
ffi::gtk_widget_realize(self.as_ref().to_glib_none().0);
}
}
/// Removes @controller from @self, so that it doesn't process
/// events anymore.
///
/// It should not be used again.
///
/// Widgets will remove all event controllers automatically when they
/// are destroyed, there is normally no need to call this function.
/// ## `controller`
/// a [`EventController`][crate::EventController]
#[doc(alias = "gtk_widget_remove_controller")]
fn remove_controller(&self, controller: &impl IsA<EventController>) {
unsafe {
ffi::gtk_widget_remove_controller(
self.as_ref().to_glib_none().0,
controller.as_ref().to_glib_none().0,
);
}
}
/// Removes a style from @self.
///
/// After this, the style of @self will stop matching for @css_class.
/// ## `css_class`
/// The style class to remove from @self, without
/// the leading '.' used for notation of style classes
#[doc(alias = "gtk_widget_remove_css_class")]
fn remove_css_class(&self, css_class: &str) {
unsafe {
ffi::gtk_widget_remove_css_class(
self.as_ref().to_glib_none().0,
css_class.to_glib_none().0,
);
}
}
/// Removes a widget from the list of mnemonic labels for this widget.
///
/// See [`list_mnemonic_labels()`][Self::list_mnemonic_labels()]. The widget must
/// have previously been added to the list with
/// [`add_mnemonic_label()`][Self::add_mnemonic_label()].
/// ## `label`
/// a [`Widget`][crate::Widget] that was previously set as a mnemonic
/// label for @self with [`add_mnemonic_label()`][Self::add_mnemonic_label()]
#[doc(alias = "gtk_widget_remove_mnemonic_label")]
fn remove_mnemonic_label(&self, label: &impl IsA<Widget>) {
unsafe {
ffi::gtk_widget_remove_mnemonic_label(
self.as_ref().to_glib_none().0,
label.as_ref().to_glib_none().0,
);
}
}
/// Specifies whether the input focus can enter the widget
/// or any of its children.
///
/// Applications should set @can_focus to [`false`] to mark a
/// widget as for pointer/touch use only.
///
/// Note that having @can_focus be [`true`] is only one of the
/// necessary conditions for being focusable. A widget must
/// also be sensitive and focusable and not have an ancestor
/// that is marked as not can-focus in order to receive input
/// focus.
///
/// See [`grab_focus()`][Self::grab_focus()] for actually setting
/// the input focus on a widget.
/// ## `can_focus`
/// whether or not the input focus can enter
/// the widget or any of its children
#[doc(alias = "gtk_widget_set_can_focus")]
fn set_can_focus(&self, can_focus: bool) {
unsafe {
ffi::gtk_widget_set_can_focus(self.as_ref().to_glib_none().0, can_focus.into_glib());
}
}
/// Sets whether @self can be the target of pointer events.
/// ## `can_target`
/// whether this widget should be able to
/// receive pointer events
#[doc(alias = "gtk_widget_set_can_target")]
fn set_can_target(&self, can_target: bool) {
unsafe {
ffi::gtk_widget_set_can_target(self.as_ref().to_glib_none().0, can_target.into_glib());
}
}
/// Sets whether @self should be mapped along with its parent.
///
/// The child visibility can be set for widget before it is added
/// to a container with [`set_parent()`][Self::set_parent()], to avoid
/// mapping children unnecessary before immediately unmapping them.
/// However it will be reset to its default state of [`true`] when the
/// widget is removed from a container.
///
/// Note that changing the child visibility of a widget does not
/// queue a resize on the widget. Most of the time, the size of
/// a widget is computed from all visible children, whether or
/// not they are mapped. If this is not the case, the container
/// can queue a resize itself.
///
/// This function is only useful for container implementations
/// and should never be called by an application.
/// ## `child_visible`
/// if [`true`], @self should be mapped along
/// with its parent.
#[doc(alias = "gtk_widget_set_child_visible")]
fn set_child_visible(&self, child_visible: bool) {
unsafe {
ffi::gtk_widget_set_child_visible(
self.as_ref().to_glib_none().0,
child_visible.into_glib(),
);
}
}
/// Clear all style classes applied to @self
/// and replace them with @classes.
/// ## `classes`
///
/// [`None`]-terminated list of style classes to apply to @self.
#[doc(alias = "gtk_widget_set_css_classes")]
fn set_css_classes(&self, classes: &[&str]) {
unsafe {
ffi::gtk_widget_set_css_classes(
self.as_ref().to_glib_none().0,
classes.to_glib_none().0,
);
}
}
/// Sets the cursor to be shown when pointer devices point
/// towards @self.
///
/// If the @cursor is NULL, @self will use the cursor
/// inherited from the parent widget.
/// ## `cursor`
/// the new cursor
#[doc(alias = "gtk_widget_set_cursor")]
fn set_cursor(&self, cursor: Option<&gdk::Cursor>) {
unsafe {
ffi::gtk_widget_set_cursor(self.as_ref().to_glib_none().0, cursor.to_glib_none().0);
}
}
/// Sets a named cursor to be shown when pointer devices point
/// towards @self.
///
/// This is a utility function that creates a cursor via
/// [`gdk::Cursor::from_name()`][crate::gdk::Cursor::from_name()] and then sets it on @self
/// with [`set_cursor()`][Self::set_cursor()]. See those functions for
/// details.
///
/// On top of that, this function allows @name to be [`None`], which
/// will do the same as calling [`set_cursor()`][Self::set_cursor()]
/// with a [`None`] cursor.
/// ## `name`
/// The name of the cursor
#[doc(alias = "gtk_widget_set_cursor_from_name")]
fn set_cursor_from_name(&self, name: Option<&str>) {
unsafe {
ffi::gtk_widget_set_cursor_from_name(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
);
}
}
/// Sets the reading direction on a particular widget.
///
/// This direction controls the primary direction for widgets
/// containing text, and also the direction in which the children
/// of a container are packed. The ability to set the direction is
/// present in order so that correct localization into languages with
/// right-to-left reading directions can be done. Generally, applications
/// will let the default reading direction present, except for containers
/// where the containers are arranged in an order that is explicitly
/// visual rather than logical (such as buttons for text justification).
///
/// If the direction is set to [`TextDirection::None`][crate::TextDirection::None], then the value
/// set by [`Widget::set_default_direction()`][crate::Widget::set_default_direction()] will be used.
/// ## `dir`
/// the new direction
#[doc(alias = "gtk_widget_set_direction")]
fn set_direction(&self, dir: TextDirection) {
unsafe {
ffi::gtk_widget_set_direction(self.as_ref().to_glib_none().0, dir.into_glib());
}
}
/// Set @child as the current focus child of @self.
///
/// This function is only suitable for widget implementations.
/// If you want a certain widget to get the input focus, call
/// [`grab_focus()`][Self::grab_focus()] on it.
/// ## `child`
/// a direct child widget of @self or [`None`]
/// to unset the focus child of @self
#[doc(alias = "gtk_widget_set_focus_child")]
fn set_focus_child(&self, child: Option<&impl IsA<Widget>>) {
unsafe {
ffi::gtk_widget_set_focus_child(
self.as_ref().to_glib_none().0,
child.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Sets whether the widget should grab focus when it is clicked
/// with the mouse.
///
/// Making mouse clicks not grab focus is useful in places like
/// toolbars where you don’t want the keyboard focus removed from
/// the main area of the application.
/// ## `focus_on_click`
/// whether the widget should grab focus when clicked
/// with the mouse
#[doc(alias = "gtk_widget_set_focus_on_click")]
fn set_focus_on_click(&self, focus_on_click: bool) {
unsafe {
ffi::gtk_widget_set_focus_on_click(
self.as_ref().to_glib_none().0,
focus_on_click.into_glib(),
);
}
}
/// Specifies whether @self can own the input focus.
///
/// Widget implementations should set @focusable to [`true`] in
/// their init() function if they want to receive keyboard input.
///
/// Note that having @focusable be [`true`] is only one of the
/// necessary conditions for being focusable. A widget must
/// also be sensitive and can-focus and not have an ancestor
/// that is marked as not can-focus in order to receive input
/// focus.
///
/// See [`grab_focus()`][Self::grab_focus()] for actually setting
/// the input focus on a widget.
/// ## `focusable`
/// whether or not @self can own the input focus
#[doc(alias = "gtk_widget_set_focusable")]
fn set_focusable(&self, focusable: bool) {
unsafe {
ffi::gtk_widget_set_focusable(self.as_ref().to_glib_none().0, focusable.into_glib());
}
}
/// Sets the font map to use for Pango rendering.
///
/// The font map is the object that is used to look up fonts.
/// Setting a custom font map can be useful in special situations,
/// e.g. when you need to add application-specific fonts to the set
/// of available fonts.
///
/// When not set, the widget will inherit the font map from its parent.
/// ## `font_map`
/// a [`pango::FontMap`][crate::pango::FontMap], or [`None`] to unset any
/// previously set font map
#[doc(alias = "gtk_widget_set_font_map")]
fn set_font_map(&self, font_map: Option<&impl IsA<pango::FontMap>>) {
unsafe {
ffi::gtk_widget_set_font_map(
self.as_ref().to_glib_none().0,
font_map.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
/// Sets the [`cairo::FontOptions`][crate::cairo::FontOptions] used for Pango rendering
/// in this widget.
///
/// When not set, the default font options for the [`gdk::Display`][crate::gdk::Display]
/// will be used.
/// ## `options`
/// a [`cairo::FontOptions`][crate::cairo::FontOptions]
/// to unset any previously set default font options
#[doc(alias = "gtk_widget_set_font_options")]
fn set_font_options(&self, options: Option<&cairo::FontOptions>) {
unsafe {
ffi::gtk_widget_set_font_options(
self.as_ref().to_glib_none().0,
options.to_glib_none().0,
);
}
}
/// Sets the horizontal alignment of @self.
/// ## `align`
/// the horizontal alignment
#[doc(alias = "gtk_widget_set_halign")]
fn set_halign(&self, align: Align) {
unsafe {
ffi::gtk_widget_set_halign(self.as_ref().to_glib_none().0, align.into_glib());
}
}
/// Sets the `has-tooltip` property on @self to @has_tooltip.
/// ## `has_tooltip`
/// whether or not @self has a tooltip.
#[doc(alias = "gtk_widget_set_has_tooltip")]
fn set_has_tooltip(&self, has_tooltip: bool) {
unsafe {
ffi::gtk_widget_set_has_tooltip(
self.as_ref().to_glib_none().0,
has_tooltip.into_glib(),
);
}
}
/// Sets whether the widget would like any available extra horizontal
/// space.
///
/// When a user resizes a [`Window`][crate::Window], widgets with expand=TRUE
/// generally receive the extra space. For example, a list or
/// scrollable area or document in your window would often be set to
/// expand.
///
/// Call this function to set the expand flag if you would like your
/// widget to become larger horizontally when the window has extra
/// room.
///
/// By default, widgets automatically expand if any of their children
/// want to expand. (To see if a widget will automatically expand given
/// its current children and state, call [`compute_expand()`][Self::compute_expand()].
/// A container can decide how the expandability of children affects the
/// expansion of the container by overriding the compute_expand virtual
/// method on [`Widget`][crate::Widget].).
///
/// Setting hexpand explicitly with this function will override the
/// automatic expand behavior.
///
/// This function forces the widget to expand or not to expand,
/// regardless of children. The override occurs because
/// [`set_hexpand()`][Self::set_hexpand()] sets the hexpand-set property (see
/// [`set_hexpand_set()`][Self::set_hexpand_set()]) which causes the widget’s hexpand
/// value to be used, rather than looking at children and widget state.
/// ## `expand`
/// whether to expand
#[doc(alias = "gtk_widget_set_hexpand")]
fn set_hexpand(&self, expand: bool) {
unsafe {
ffi::gtk_widget_set_hexpand(self.as_ref().to_glib_none().0, expand.into_glib());
}
}
/// Sets whether the hexpand flag will be used.
///
/// The [`hexpand-set`][struct@crate::Widget#hexpand-set] property will be set
/// automatically when you call [`set_hexpand()`][Self::set_hexpand()]
/// to set hexpand, so the most likely reason to use this function
/// would be to unset an explicit expand flag.
///
/// If hexpand is set, then it overrides any computed
/// expand value based on child widgets. If hexpand is not
/// set, then the expand value depends on whether any
/// children of the widget would like to expand.
///
/// There are few reasons to use this function, but it’s here
/// for completeness and consistency.
/// ## `set`
/// value for hexpand-set property
#[doc(alias = "gtk_widget_set_hexpand_set")]
fn set_hexpand_set(&self, set: bool) {
unsafe {
ffi::gtk_widget_set_hexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
}
}
/// Sets the layout manager delegate instance that provides an
/// implementation for measuring and allocating the children of @self.
/// ## `layout_manager`
/// a [`LayoutManager`][crate::LayoutManager]
#[doc(alias = "gtk_widget_set_layout_manager")]
fn set_layout_manager(&self, layout_manager: Option<impl IsA<LayoutManager>>) {
unsafe {
ffi::gtk_widget_set_layout_manager(
self.as_ref().to_glib_none().0,
layout_manager.map(|p| p.upcast()).into_glib_ptr(),
);
}
}
/// Sets the bottom margin of @self.
/// ## `margin`
/// the bottom margin
#[doc(alias = "gtk_widget_set_margin_bottom")]
fn set_margin_bottom(&self, margin: i32) {
unsafe {
ffi::gtk_widget_set_margin_bottom(self.as_ref().to_glib_none().0, margin);
}
}
/// Sets the end margin of @self.
/// ## `margin`
/// the end margin
#[doc(alias = "gtk_widget_set_margin_end")]
fn set_margin_end(&self, margin: i32) {
unsafe {
ffi::gtk_widget_set_margin_end(self.as_ref().to_glib_none().0, margin);
}
}
/// Sets the start margin of @self.
/// ## `margin`
/// the start margin
#[doc(alias = "gtk_widget_set_margin_start")]
fn set_margin_start(&self, margin: i32) {
unsafe {
ffi::gtk_widget_set_margin_start(self.as_ref().to_glib_none().0, margin);
}
}
/// Sets the top margin of @self.
/// ## `margin`
/// the top margin
#[doc(alias = "gtk_widget_set_margin_top")]
fn set_margin_top(&self, margin: i32) {
unsafe {
ffi::gtk_widget_set_margin_top(self.as_ref().to_glib_none().0, margin);
}
}
/// Sets a widgets name.
///
/// Setting a name allows you to refer to the widget from a
/// CSS file. You can apply a style to widgets with a particular name
/// in the CSS file. See the documentation for the CSS syntax (on the
/// same page as the docs for [`StyleContext`][crate::StyleContext].
///
/// Note that the CSS syntax has certain special characters to delimit
/// and represent elements in a selector (period, #, >, *...), so using
/// these will make your widget impossible to match by name. Any combination
/// of alphanumeric symbols, dashes and underscores will suffice.
/// ## `name`
/// name for the widget
#[doc(alias = "gtk_widget_set_name")]
#[doc(alias = "set_name")]
fn set_widget_name(&self, name: &str) {
unsafe {
ffi::gtk_widget_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
}
}
/// Request the @self to be rendered partially transparent.
///
/// An opacity of 0 is fully transparent and an opacity of 1
/// is fully opaque.
///
/// Opacity works on both toplevel widgets and child widgets, although
/// there are some limitations: For toplevel widgets, applying opacity
/// depends on the capabilities of the windowing system. On X11, this
/// has any effect only on X displays with a compositing manager,
/// see gdk_display_is_composited(). On Windows and Wayland it should
/// always work, although setting a window’s opacity after the window
/// has been shown may cause some flicker.
///
/// Note that the opacity is inherited through inclusion — if you set
/// a toplevel to be partially translucent, all of its content will
/// appear translucent, since it is ultimatively rendered on that
/// toplevel. The opacity value itself is not inherited by child
/// widgets (since that would make widgets deeper in the hierarchy
/// progressively more translucent). As a consequence, [`Popover`][crate::Popover]s
/// and other [`Native`][crate::Native] widgets with their own surface will use their
/// own opacity value, and thus by default appear non-translucent,
/// even if they are attached to a toplevel that is translucent.
/// ## `opacity`
/// desired opacity, between 0 and 1
#[doc(alias = "gtk_widget_set_opacity")]
fn set_opacity(&self, opacity: f64) {
unsafe {
ffi::gtk_widget_set_opacity(self.as_ref().to_glib_none().0, opacity);
}
}
/// Sets how @self treats content that is drawn outside the
/// widget's content area.
///
/// See the definition of [`Overflow`][crate::Overflow] for details.
///
/// This setting is provided for widget implementations and
/// should not be used by application code.
///
/// The default value is [`Overflow::Visible`][crate::Overflow::Visible].
/// ## `overflow`
/// desired overflow
#[doc(alias = "gtk_widget_set_overflow")]
fn set_overflow(&self, overflow: Overflow) {
unsafe {
ffi::gtk_widget_set_overflow(self.as_ref().to_glib_none().0, overflow.into_glib());
}
}
/// Sets @parent as the parent widget of @self.
///
/// This takes care of details such as updating the state and style
/// of the child to reflect its new location and resizing the parent.
/// The opposite function is [`unparent()`][Self::unparent()].
///
/// This function is useful only when implementing subclasses of
/// [`Widget`][crate::Widget].
/// ## `parent`
/// parent widget
#[doc(alias = "gtk_widget_set_parent")]
fn set_parent(&self, parent: &impl IsA<Widget>) {
unsafe {
ffi::gtk_widget_set_parent(
self.as_ref().to_glib_none().0,
parent.as_ref().to_glib_none().0,
);
}
}
/// Specifies whether @self will be treated as the default
/// widget within its toplevel when it has the focus, even if
/// another widget is the default.
/// ## `receives_default`
/// whether or not @self can be a default widget.
#[doc(alias = "gtk_widget_set_receives_default")]
fn set_receives_default(&self, receives_default: bool) {
unsafe {
ffi::gtk_widget_set_receives_default(
self.as_ref().to_glib_none().0,
receives_default.into_glib(),
);
}
}
/// Sets the sensitivity of a widget.
///
/// A widget is sensitive if the user can interact with it.
/// Insensitive widgets are “grayed out” and the user can’t
/// interact with them. Insensitive widgets are known as
/// “inactive”, “disabled”, or “ghosted” in some other toolkits.
/// ## `sensitive`
/// [`true`] to make the widget sensitive
#[doc(alias = "gtk_widget_set_sensitive")]
fn set_sensitive(&self, sensitive: bool) {
unsafe {
ffi::gtk_widget_set_sensitive(self.as_ref().to_glib_none().0, sensitive.into_glib());
}
}
/// Sets the minimum size of a widget.
///
/// That is, the widget’s size request will be at least @width
/// by @height. You can use this function to force a widget to
/// be larger than it normally would be.
///
/// In most cases, [`GtkWindowExt::set_default_size()`][crate::prelude::GtkWindowExt::set_default_size()] is a better
/// choice for toplevel windows than this function; setting the default
/// size will still allow users to shrink the window. Setting the size
/// request will force them to leave the window at least as large as
/// the size request.
///
/// Note the inherent danger of setting any fixed size - themes,
/// translations into other languages, different fonts, and user action
/// can all change the appropriate size for a given widget. So, it's
/// basically impossible to hardcode a size that will always be
/// correct.
///
/// The size request of a widget is the smallest size a widget can
/// accept while still functioning well and drawing itself correctly.
/// However in some strange cases a widget may be allocated less than
/// its requested size, and in many cases a widget may be allocated more
/// space than it requested.
///
/// If the size request in a given direction is -1 (unset), then
/// the “natural” size request of the widget will be used instead.
///
/// The size request set here does not include any margin from the
/// properties
/// [`margin-start`][struct@crate::Widget#margin-start],
/// [`margin-end`][struct@crate::Widget#margin-end],
/// [`margin-top`][struct@crate::Widget#margin-top], and
/// [`margin-bottom`][struct@crate::Widget#margin-bottom], but it does include pretty
/// much all other padding or border properties set by any subclass
/// of [`Widget`][crate::Widget].
/// ## `width`
/// width @self should request, or -1 to unset
/// ## `height`
/// height @self should request, or -1 to unset
#[doc(alias = "gtk_widget_set_size_request")]
fn set_size_request(&self, width: i32, height: i32) {
unsafe {
ffi::gtk_widget_set_size_request(self.as_ref().to_glib_none().0, width, height);
}
}
/// Turns on flag values in the current widget state.
///
/// Typical widget states are insensitive, prelighted, etc.
///
/// This function accepts the values [`StateFlags::DIR_LTR`][crate::StateFlags::DIR_LTR] and
/// [`StateFlags::DIR_RTL`][crate::StateFlags::DIR_RTL] but ignores them. If you want to set
/// the widget's direction, use [`set_direction()`][Self::set_direction()].
///
/// This function is for use in widget implementations.
/// ## `flags`
/// State flags to turn on
/// ## `clear`
/// Whether to clear state before turning on @flags
#[doc(alias = "gtk_widget_set_state_flags")]
fn set_state_flags(&self, flags: StateFlags, clear: bool) {
unsafe {
ffi::gtk_widget_set_state_flags(
self.as_ref().to_glib_none().0,
flags.into_glib(),
clear.into_glib(),
);
}
}
/// Sets @markup as the contents of the tooltip, which is marked
/// up with Pango markup.
///
/// This function will take care of setting the
/// [`has-tooltip`][struct@crate::Widget#has-tooltip] as a side effect, and of the
/// default handler for the [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
///
/// See also [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
/// ## `markup`
/// the contents of the tooltip for @self
#[doc(alias = "gtk_widget_set_tooltip_markup")]
fn set_tooltip_markup(&self, markup: Option<&str>) {
unsafe {
ffi::gtk_widget_set_tooltip_markup(
self.as_ref().to_glib_none().0,
markup.to_glib_none().0,
);
}
}
/// Sets @text as the contents of the tooltip.
///
/// If @text contains any markup, it will be escaped.
///
/// This function will take care of setting
/// [`has-tooltip`][struct@crate::Widget#has-tooltip] as a side effect,
/// and of the default handler for the
/// [`query-tooltip`][struct@crate::Widget#query-tooltip] signal.
///
/// See also [`Tooltip::set_text()`][crate::Tooltip::set_text()].
/// ## `text`
/// the contents of the tooltip for @self
#[doc(alias = "gtk_widget_set_tooltip_text")]
fn set_tooltip_text(&self, text: Option<&str>) {
unsafe {
ffi::gtk_widget_set_tooltip_text(self.as_ref().to_glib_none().0, text.to_glib_none().0);
}
}
/// Sets the vertical alignment of @self.
/// ## `align`
/// the vertical alignment
#[doc(alias = "gtk_widget_set_valign")]
fn set_valign(&self, align: Align) {
unsafe {
ffi::gtk_widget_set_valign(self.as_ref().to_glib_none().0, align.into_glib());
}
}
/// Sets whether the widget would like any available extra vertical
/// space.
///
/// See [`set_hexpand()`][Self::set_hexpand()] for more detail.
/// ## `expand`
/// whether to expand
#[doc(alias = "gtk_widget_set_vexpand")]
fn set_vexpand(&self, expand: bool) {
unsafe {
ffi::gtk_widget_set_vexpand(self.as_ref().to_glib_none().0, expand.into_glib());
}
}
/// Sets whether the vexpand flag will be used.
///
/// See [`set_hexpand_set()`][Self::set_hexpand_set()] for more detail.
/// ## `set`
/// value for vexpand-set property
#[doc(alias = "gtk_widget_set_vexpand_set")]
fn set_vexpand_set(&self, set: bool) {
unsafe {
ffi::gtk_widget_set_vexpand_set(self.as_ref().to_glib_none().0, set.into_glib());
}
}
/// Sets the visibility state of @self.
///
/// Note that setting this to [`true`] doesn’t mean the widget is
/// actually viewable, see [`get_visible()`][Self::get_visible()].
/// ## `visible`
/// whether the widget should be shown or not
#[doc(alias = "gtk_widget_set_visible")]
fn set_visible(&self, visible: bool) {
unsafe {
ffi::gtk_widget_set_visible(self.as_ref().to_glib_none().0, visible.into_glib());
}
}
/// Returns whether @self should contribute to
/// the measuring and allocation of its parent.
///
/// This is [`false`] for invisible children, but also
/// for children that have their own surface.
///
/// # Returns
///
/// [`true`] if child should be included in
/// measuring and allocating
#[doc(alias = "gtk_widget_should_layout")]
fn should_layout(&self) -> bool {
unsafe {
from_glib(ffi::gtk_widget_should_layout(
self.as_ref().to_glib_none().0,
))
}
}
/// Flags a widget to be displayed.
///
/// Any widget that isn’t shown will not appear on the screen.
///
/// Remember that you have to show the containers containing a widget,
/// in addition to the widget itself, before it will appear onscreen.
///
/// When a toplevel container is shown, it is immediately realized and
/// mapped; other shown widgets are realized and mapped when their
/// toplevel container is realized and mapped.
///
/// # Deprecated since 4.10
///
/// Use [`set_visible()`][Self::set_visible()] instead
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_show")]
fn show(&self) {
unsafe {
ffi::gtk_widget_show(self.as_ref().to_glib_none().0);
}
}
/// Allocates widget with a transformation that translates
/// the origin to the position in @allocation.
///
/// This is a simple form of [`allocate()`][Self::allocate()].
/// ## `allocation`
/// position and size to be allocated to @self
/// ## `baseline`
/// The baseline of the child, or -1
#[doc(alias = "gtk_widget_size_allocate")]
fn size_allocate(&self, allocation: &Allocation, baseline: i32) {
unsafe {
ffi::gtk_widget_size_allocate(
self.as_ref().to_glib_none().0,
allocation.to_glib_none().0,
baseline,
);
}
}
/// Snapshot the a child of @self.
///
/// When a widget receives a call to the snapshot function,
/// it must send synthetic [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()] calls
/// to all children. This function provides a convenient way
/// of doing this. A widget, when it receives a call to its
/// [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()] function, calls
/// gtk_widget_snapshot_child() once for each child, passing in
/// the @snapshot the widget received.
///
/// gtk_widget_snapshot_child() takes care of translating the origin of
/// @snapshot, and deciding whether the child needs to be snapshot.
///
/// This function does nothing for children that implement [`Native`][crate::Native].
/// ## `child`
/// a child of @self
/// ## `snapshot`
/// [`Snapshot`][crate::Snapshot] as passed to the widget. In particular, no
/// calls to gtk_snapshot_translate() or other transform calls should
/// have been made.
#[doc(alias = "gtk_widget_snapshot_child")]
fn snapshot_child(&self, child: &impl IsA<Widget>, snapshot: &impl IsA<Snapshot>) {
unsafe {
ffi::gtk_widget_snapshot_child(
self.as_ref().to_glib_none().0,
child.as_ref().to_glib_none().0,
snapshot.as_ref().to_glib_none().0,
);
}
}
/// Translate coordinates relative to @self’s allocation
/// to coordinates relative to @dest_widget’s allocations.
///
/// In order to perform this operation, both widget must share
/// a common ancestor.
///
/// # Deprecated since 4.12
///
/// Use gtk_widget_compute_point() instead
/// ## `dest_widget`
/// a [`Widget`][crate::Widget]
/// ## `src_x`
/// X position relative to @self
/// ## `src_y`
/// Y position relative to @self
///
/// # Returns
///
/// [`false`] if @self and @dest_widget have no common
/// ancestor. In this case, 0 is stored in *@dest_x and *@dest_y.
/// Otherwise [`true`].
///
/// ## `dest_x`
/// location to store X position relative to @dest_widget
///
/// ## `dest_y`
/// location to store Y position relative to @dest_widget
#[cfg_attr(feature = "v4_12", deprecated = "Since 4.12")]
#[allow(deprecated)]
#[doc(alias = "gtk_widget_translate_coordinates")]
fn translate_coordinates(
&self,
dest_widget: &impl IsA<Widget>,
src_x: f64,
src_y: f64,
) -> Option<(f64, f64)> {
unsafe {
let mut dest_x = mem::MaybeUninit::uninit();
let mut dest_y = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::gtk_widget_translate_coordinates(
self.as_ref().to_glib_none().0,
dest_widget.as_ref().to_glib_none().0,
src_x,
src_y,
dest_x.as_mut_ptr(),
dest_y.as_mut_ptr(),
));
if ret {
Some((dest_x.assume_init(), dest_y.assume_init()))
} else {
None
}
}
}
/// Triggers a tooltip query on the display where the toplevel
/// of @self is located.
#[doc(alias = "gtk_widget_trigger_tooltip_query")]
fn trigger_tooltip_query(&self) {
unsafe {
ffi::gtk_widget_trigger_tooltip_query(self.as_ref().to_glib_none().0);
}
}
/// Causes a widget to be unmapped if it’s currently mapped.
///
/// This function is only for use in widget implementations.
#[doc(alias = "gtk_widget_unmap")]
fn unmap(&self) {
unsafe {
ffi::gtk_widget_unmap(self.as_ref().to_glib_none().0);
}
}
/// Dissociate @self from its parent.
///
/// This function is only for use in widget implementations,
/// typically in dispose.
#[doc(alias = "gtk_widget_unparent")]
fn unparent(&self) {
unsafe {
ffi::gtk_widget_unparent(self.as_ref().to_glib_none().0);
}
}
/// Causes a widget to be unrealized (frees all GDK resources
/// associated with the widget).
///
/// This function is only useful in widget implementations.
#[doc(alias = "gtk_widget_unrealize")]
fn unrealize(&self) {
unsafe {
ffi::gtk_widget_unrealize(self.as_ref().to_glib_none().0);
}
}
/// Turns off flag values for the current widget state.
///
/// See [`set_state_flags()`][Self::set_state_flags()].
///
/// This function is for use in widget implementations.
/// ## `flags`
/// State flags to turn off
#[doc(alias = "gtk_widget_unset_state_flags")]
fn unset_state_flags(&self, flags: StateFlags) {
unsafe {
ffi::gtk_widget_unset_state_flags(self.as_ref().to_glib_none().0, flags.into_glib());
}
}
/// Override for height request of the widget.
///
/// If this is -1, the natural request will be used.
#[doc(alias = "height-request")]
fn height_request(&self) -> i32 {
ObjectExt::property(self.as_ref(), "height-request")
}
/// Override for height request of the widget.
///
/// If this is -1, the natural request will be used.
#[doc(alias = "height-request")]
fn set_height_request(&self, height_request: i32) {
ObjectExt::set_property(self.as_ref(), "height-request", height_request)
}
/// Override for width request of the widget.
///
/// If this is -1, the natural request will be used.
#[doc(alias = "width-request")]
fn width_request(&self) -> i32 {
ObjectExt::property(self.as_ref(), "width-request")
}
/// Override for width request of the widget.
///
/// If this is -1, the natural request will be used.
#[doc(alias = "width-request")]
fn set_width_request(&self, width_request: i32) {
ObjectExt::set_property(self.as_ref(), "width-request", width_request)
}
/// 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.
#[doc(alias = "destroy")]
fn connect_destroy<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn destroy_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"destroy\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
destroy_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the text direction of a widget changes.
/// ## `previous_direction`
/// the previous text direction of @widget
#[doc(alias = "direction-changed")]
fn connect_direction_changed<F: Fn(&Self, TextDirection) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn direction_changed_trampoline<
P: IsA<Widget>,
F: Fn(&P, TextDirection) + 'static,
>(
this: *mut ffi::GtkWidget,
previous_direction: ffi::GtkTextDirection,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Widget::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(previous_direction),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"direction-changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
direction_changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when @widget is hidden.
#[doc(alias = "hide")]
fn connect_hide<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn hide_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"hide\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
hide_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted if keyboard navigation fails.
///
/// See [`keynav_failed()`][Self::keynav_failed()] for details.
/// ## `direction`
/// the direction of movement
///
/// # Returns
///
/// [`true`] if stopping keyboard navigation is fine, [`false`]
/// if the emitting widget should try to handle the keyboard
/// navigation attempt in its parent widget(s).
#[doc(alias = "keynav-failed")]
fn connect_keynav_failed<F: Fn(&Self, DirectionType) -> glib::Propagation + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn keynav_failed_trampoline<
P: IsA<Widget>,
F: Fn(&P, DirectionType) -> glib::Propagation + 'static,
>(
this: *mut ffi::GtkWidget,
direction: ffi::GtkDirectionType,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
Widget::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(direction),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"keynav-failed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
keynav_failed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when @widget is going to be mapped.
///
/// A widget is mapped when the widget is visible (which is controlled with
/// [`visible`][struct@crate::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::Widget#unmap].
#[doc(alias = "map")]
fn connect_map<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn map_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"map\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
map_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// 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`].
/// ## `group_cycling`
/// [`true`] if there are other widgets with the same mnemonic
///
/// # Returns
///
/// [`true`] to stop other handlers from being invoked for the event.
/// [`false`] to propagate the event further.
#[doc(alias = "mnemonic-activate")]
fn connect_mnemonic_activate<F: Fn(&Self, bool) -> glib::Propagation + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn mnemonic_activate_trampoline<
P: IsA<Widget>,
F: Fn(&P, bool) -> glib::Propagation + 'static,
>(
this: *mut ffi::GtkWidget,
group_cycling: glib::ffi::gboolean,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
Widget::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(group_cycling),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"mnemonic-activate\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
mnemonic_activate_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// 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.
/// ## `direction`
/// the direction of the focus move
#[doc(alias = "move-focus")]
fn connect_move_focus<F: Fn(&Self, DirectionType) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn move_focus_trampoline<
P: IsA<Widget>,
F: Fn(&P, DirectionType) + 'static,
>(
this: *mut ffi::GtkWidget,
direction: ffi::GtkDirectionType,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Widget::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(direction),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"move-focus\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
move_focus_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn emit_move_focus(&self, direction: DirectionType) {
self.emit_by_name::<()>("move-focus", &[&direction]);
}
/// Emitted when the widget’s tooltip is about to be shown.
///
/// This happens when the [`has-tooltip`][struct@crate::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.
/// ## `x`
/// the x coordinate of the cursor position where the request has
/// been emitted, relative to @widget's left side
/// ## `y`
/// the y coordinate of the cursor position where the request has
/// been emitted, relative to @widget's top
/// ## `keyboard_mode`
/// [`true`] if the tooltip was triggered using the keyboard
/// ## `tooltip`
/// a [`Tooltip`][crate::Tooltip]
///
/// # Returns
///
/// [`true`] if @tooltip should be shown right now, [`false`] otherwise.
#[doc(alias = "query-tooltip")]
fn connect_query_tooltip<F: Fn(&Self, i32, i32, bool, &Tooltip) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn query_tooltip_trampoline<
P: IsA<Widget>,
F: Fn(&P, i32, i32, bool, &Tooltip) -> bool + 'static,
>(
this: *mut ffi::GtkWidget,
x: libc::c_int,
y: libc::c_int,
keyboard_mode: glib::ffi::gboolean,
tooltip: *mut ffi::GtkTooltip,
f: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let f: &F = &*(f as *const F);
f(
Widget::from_glib_borrow(this).unsafe_cast_ref(),
x,
y,
from_glib(keyboard_mode),
&from_glib_borrow(tooltip),
)
.into_glib()
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"query-tooltip\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
query_tooltip_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
///
/// This means that [`realize()`][Self::realize()] has been called
/// or the widget has been mapped (that is, it is going to be drawn).
#[doc(alias = "realize")]
fn connect_realize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn realize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"realize\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
realize_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when @widget is shown.
#[doc(alias = "show")]
fn connect_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn show_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"show\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
show_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the widget state changes.
///
/// See [`state_flags()`][Self::state_flags()].
/// ## `flags`
/// The previous state flags.
#[doc(alias = "state-flags-changed")]
fn connect_state_flags_changed<F: Fn(&Self, StateFlags) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn state_flags_changed_trampoline<
P: IsA<Widget>,
F: Fn(&P, StateFlags) + 'static,
>(
this: *mut ffi::GtkWidget,
flags: ffi::GtkStateFlags,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
Widget::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(flags),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"state-flags-changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
state_flags_changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// 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.
#[doc(alias = "unmap")]
fn connect_unmap<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn unmap_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"unmap\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
unmap_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
///
/// This means that [`unrealize()`][Self::unrealize()] has been called
/// or the widget has been unmapped (that is, it is going to be hidden).
#[doc(alias = "unrealize")]
fn connect_unrealize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn unrealize_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"unrealize\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
unrealize_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "can-focus")]
fn connect_can_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_can_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::can-focus\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_can_focus_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "can-target")]
fn connect_can_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_can_target_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::can-target\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_can_target_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "css-classes")]
fn connect_css_classes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_css_classes_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::css-classes\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_css_classes_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "cursor")]
fn connect_cursor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_cursor_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::cursor\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_cursor_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "focus-on-click")]
fn connect_focus_on_click_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_focus_on_click_trampoline<
P: IsA<Widget>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::focus-on-click\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_focus_on_click_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "focusable")]
fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_focusable_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::focusable\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_focusable_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "halign")]
fn connect_halign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_halign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::halign\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_halign_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "has-default")]
fn connect_has_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_has_default_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::has-default\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_has_default_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "has-focus")]
fn connect_has_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_has_focus_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::has-focus\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_has_focus_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "has-tooltip")]
fn connect_has_tooltip_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_has_tooltip_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::has-tooltip\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_has_tooltip_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "height-request")]
fn connect_height_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_height_request_trampoline<
P: IsA<Widget>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::height-request\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_height_request_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "hexpand")]
fn connect_hexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_hexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::hexpand\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_hexpand_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "hexpand-set")]
fn connect_hexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_hexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::hexpand-set\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_hexpand_set_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "layout-manager")]
fn connect_layout_manager_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_layout_manager_trampoline<
P: IsA<Widget>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::layout-manager\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_layout_manager_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "margin-bottom")]
fn connect_margin_bottom_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_margin_bottom_trampoline<
P: IsA<Widget>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::margin-bottom\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_margin_bottom_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "margin-end")]
fn connect_margin_end_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_margin_end_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::margin-end\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_margin_end_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "margin-start")]
fn connect_margin_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_margin_start_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::margin-start\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_margin_start_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "margin-top")]
fn connect_margin_top_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_margin_top_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::margin-top\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_margin_top_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "name")]
fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_name_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::name\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_name_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "opacity")]
fn connect_opacity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_opacity_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::opacity\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_opacity_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "overflow")]
fn connect_overflow_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_overflow_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::overflow\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_overflow_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "parent")]
fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_parent_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::parent\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_parent_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "receives-default")]
fn connect_receives_default_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_receives_default_trampoline<
P: IsA<Widget>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::receives-default\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_receives_default_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "root")]
fn connect_root_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_root_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::root\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_root_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "scale-factor")]
fn connect_scale_factor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_scale_factor_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::scale-factor\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_scale_factor_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "sensitive")]
fn connect_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_sensitive_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::sensitive\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_sensitive_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "tooltip-markup")]
fn connect_tooltip_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_tooltip_markup_trampoline<
P: IsA<Widget>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::tooltip-markup\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_tooltip_markup_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "tooltip-text")]
fn connect_tooltip_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_tooltip_text_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::tooltip-text\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_tooltip_text_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "valign")]
fn connect_valign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_valign_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::valign\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_valign_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "vexpand")]
fn connect_vexpand_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_vexpand_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::vexpand\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_vexpand_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "vexpand-set")]
fn connect_vexpand_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_vexpand_set_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::vexpand-set\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_vexpand_set_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "visible")]
fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_visible_trampoline<P: IsA<Widget>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::visible\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_visible_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "width-request")]
fn connect_width_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_width_request_trampoline<
P: IsA<Widget>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkWidget,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Widget::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::width-request\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_width_request_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Widget>> WidgetExt for O {}