Compare commits
675 Commits
a11y/build
...
matthiasc/
Author | SHA1 | Date | |
---|---|---|---|
|
1af40af3cb | ||
|
a62d6b992f | ||
|
0d5c270dd4 | ||
|
69d6eb73e7 | ||
|
9885525c9f | ||
|
c82080ccea | ||
|
91923c29da | ||
|
d62c987f63 | ||
|
bd206429eb | ||
|
42c7490b05 | ||
|
11dbab714a | ||
|
47defabe0c | ||
|
8cd1f2bf08 | ||
|
2aab906174 | ||
|
52ca3fa73f | ||
|
188c435549 | ||
|
73269f9601 | ||
|
bf5473e78a | ||
|
f7da082a88 | ||
|
cca39077b3 | ||
|
c5a6848b2c | ||
|
2a41ad7bd6 | ||
|
c2375809fc | ||
|
25b0ed1911 | ||
|
549bcceb42 | ||
|
fd5f54df15 | ||
|
b94382e9d2 | ||
|
a017ebf944 | ||
|
e102c52964 | ||
|
e3cec72cce | ||
|
626ba8716d | ||
|
7deaf6b648 | ||
|
026c0ed347 | ||
|
87a09e07fd | ||
|
68ac24ef65 | ||
|
6ce05c23f1 | ||
|
3f77e0455d | ||
|
1eacc48580 | ||
|
21d19fddbd | ||
|
7daf99a1c8 | ||
|
5c9a8f69e5 | ||
|
fbe3f2e581 | ||
|
c84c014536 | ||
|
1e994419ee | ||
|
7b22c44b39 | ||
|
2e744260e0 | ||
|
7190a31b5f | ||
|
729f007379 | ||
|
b75b359f19 | ||
|
d7de720275 | ||
|
ef86e46238 | ||
|
0a46baeb56 | ||
|
fd3a6299ce | ||
|
803b147483 | ||
|
1f44319588 | ||
|
505478bc59 | ||
|
de7833b6a0 | ||
|
3a1b2083d6 | ||
|
3e996f61ae | ||
|
56eac4f846 | ||
|
61dcb685b2 | ||
|
bd0d75e237 | ||
|
179fc68355 | ||
|
9828756e05 | ||
|
40f2b49c0d | ||
|
8e81cbef2c | ||
|
47d572834b | ||
|
46601325f1 | ||
|
0abc7a3361 | ||
|
1e01b9079d | ||
|
be688c46f2 | ||
|
ab163f168d | ||
|
e937f7eac8 | ||
|
b84945e43f | ||
|
b3dba1dca6 | ||
|
060cfc713f | ||
|
6be575992f | ||
|
4bec75c66b | ||
|
8e4cc59a7a | ||
|
c17227966d | ||
|
a2ce6268b2 | ||
|
5ab14ff7f6 | ||
|
8482b956d6 | ||
|
562c7b1ff3 | ||
|
8099de22f9 | ||
|
a4c3bee4a1 | ||
|
5afa985e85 | ||
|
e600a07237 | ||
|
8fa58c2e17 | ||
|
d436c2e839 | ||
|
b37634dcd5 | ||
|
2d636fdda0 | ||
|
28095641c5 | ||
|
d58b06ceeb | ||
|
82b4c34eca | ||
|
ee47ddf5fd | ||
|
f32ae2964a | ||
|
eae5eaeb21 | ||
|
09fd2d61c4 | ||
|
86d7ab7c50 | ||
|
88be92ceee | ||
|
04c4b387a0 | ||
|
7551f85d4c | ||
|
184886f893 | ||
|
36ef94b002 | ||
|
831ebe3ef2 | ||
|
76b8676955 | ||
|
b3243132a0 | ||
|
de461712a1 | ||
|
dd7f52c59a | ||
|
3f1bc740e4 | ||
|
9128ad105b | ||
|
745cbc6c91 | ||
|
b635736ac2 | ||
|
ba081bf119 | ||
|
3003f37e9d | ||
|
c1e05e7c52 | ||
|
6b475aacd2 | ||
|
bc4969ec42 | ||
|
1c7daece7a | ||
|
37a8c138f9 | ||
|
34d547a2aa | ||
|
163c04c101 | ||
|
f2284ff40f | ||
|
eded9459df | ||
|
8fd1530848 | ||
|
77f9efa747 | ||
|
109ec523cb | ||
|
5cc5022a8f | ||
|
3c769bb11d | ||
|
33b07e4825 | ||
|
714e5c72f6 | ||
|
153c6424d3 | ||
|
b76e514322 | ||
|
1501aa0603 | ||
|
cf5a173a4f | ||
|
2b8c3731c1 | ||
|
ade2f1030a | ||
|
4f12df5f1c | ||
|
9941799449 | ||
|
5a938ad83d | ||
|
835c807d7a | ||
|
2ef72442ec | ||
|
3bc2bf40a8 | ||
|
cd4c0b6127 | ||
|
fa79e8651e | ||
|
9a29487e25 | ||
|
fceff93994 | ||
|
acd8b08d35 | ||
|
2abee57421 | ||
|
437f902c9d | ||
|
a7befc647e | ||
|
121e61cf01 | ||
|
f7ac13b78f | ||
|
c2ae73f247 | ||
|
4b0b6100d6 | ||
|
2c9bf55eea | ||
|
1d11d42aa0 | ||
|
361407201b | ||
|
50c29398e6 | ||
|
dff8a9eb46 | ||
|
1bb4e660fd | ||
|
ded6ec6424 | ||
|
47e49acc7d | ||
|
0996b178dc | ||
|
4befd13744 | ||
|
bb1463871c | ||
|
12a9164414 | ||
|
108fe033aa | ||
|
9de2b4b0e1 | ||
|
ee056fd8bd | ||
|
bc4f71a107 | ||
|
125442297f | ||
|
eec92b40ea | ||
|
d392f6f2a4 | ||
|
41a9c46ec8 | ||
|
0530aeec17 | ||
|
22741a74ff | ||
|
23331c1919 | ||
|
d266bd62de | ||
|
57c95937b1 | ||
|
1d86086434 | ||
|
e2f26b0d9a | ||
|
7816fc2b83 | ||
|
04d802f7f4 | ||
|
994cc32d7b | ||
|
f14ca28c4e | ||
|
da9d32e472 | ||
|
08d6db4ab6 | ||
|
6891f40110 | ||
|
cdbf24c3af | ||
|
b30715da6a | ||
|
5e9883453d | ||
|
b97b95b0c7 | ||
|
dd0a854bbb | ||
|
b8d0ad8643 | ||
|
65d57877a8 | ||
|
afc73c38ce | ||
|
f4e1c271ea | ||
|
8e42239439 | ||
|
5b4ac5456e | ||
|
f1db73379e | ||
|
20918dbe8e | ||
|
b5ec20db88 | ||
|
d347df431d | ||
|
25e6988d95 | ||
|
a7f05b8d91 | ||
|
fe690265eb | ||
|
f45ea3fa90 | ||
|
bdc28cd870 | ||
|
c648c1f235 | ||
|
8a92ee03ea | ||
|
e3c72f8f09 | ||
|
1f472104ad | ||
|
4b41580041 | ||
|
c136f84584 | ||
|
80de00a248 | ||
|
50a7e59623 | ||
|
92ca3a3419 | ||
|
8203d9cc40 | ||
|
abc9b403f8 | ||
|
b9ad3172a4 | ||
|
0d7fcdda28 | ||
|
75f9b83b1e | ||
|
61e980bfb6 | ||
|
ebda736a09 | ||
|
d4ddfdc265 | ||
|
f8bb206034 | ||
|
87f92a93d3 | ||
|
e49e084f4c | ||
|
995daa1e29 | ||
|
d34936c1ea | ||
|
a59889a274 | ||
|
bfb054a023 | ||
|
e940704018 | ||
|
429c7fc039 | ||
|
0d6e4f7a6e | ||
|
1f9eb5c64c | ||
|
056a073061 | ||
|
e46522e4b5 | ||
|
7ac7919697 | ||
|
5d9799d4e3 | ||
|
f95943a752 | ||
|
ef88e9ffcc | ||
|
49613dca8e | ||
|
a651a0ce69 | ||
|
08d59d3f68 | ||
|
afff39c503 | ||
|
a2897e1868 | ||
|
15172ebdb0 | ||
|
9ac4a7d99f | ||
|
8157717e03 | ||
|
9052f6dafe | ||
|
292576f312 | ||
|
2285382074 | ||
|
526f1e315b | ||
|
877a7f98ca | ||
|
73b14a3c3a | ||
|
40c0826921 | ||
|
27b9b2e76c | ||
|
04c4d293a7 | ||
|
033791b374 | ||
|
95ee5ff424 | ||
|
65d29e00c7 | ||
|
3b2cd972d5 | ||
|
428ec29598 | ||
|
bfe5b0d1b7 | ||
|
82b855cc4b | ||
|
0db504edde | ||
|
5ed3ad6cc8 | ||
|
27c4c19333 | ||
|
74a7f73239 | ||
|
a047b7d6d1 | ||
|
a76f37a501 | ||
|
d6a0948182 | ||
|
7215c74933 | ||
|
e4be785c6c | ||
|
18779b9d67 | ||
|
9b056f57f7 | ||
|
d6c753bde7 | ||
|
d69a943661 | ||
|
0ececc7109 | ||
|
3cc0870084 | ||
|
2229d7f66c | ||
|
ed7619ec16 | ||
|
7ed06480cf | ||
|
f9db651f32 | ||
|
c264254d4b | ||
|
6af89e9034 | ||
|
1bdc8b9061 | ||
|
c442f9f05a | ||
|
6cbd7e29dd | ||
|
6079033cde | ||
|
d63afaf5ad | ||
|
7e089664fc | ||
|
06fbad0b26 | ||
|
2a3c3b4c6a | ||
|
eb3933cffd | ||
|
d1de9234c5 | ||
|
3e8260d528 | ||
|
192f515682 | ||
|
2543c9f5a3 | ||
|
a745dbfc15 | ||
|
14be50839e | ||
|
a85d9cda07 | ||
|
7d49f1e250 | ||
|
6fa2936956 | ||
|
b81463e7d3 | ||
|
b622745501 | ||
|
5379a4bf34 | ||
|
b966f593a5 | ||
|
706a8f9784 | ||
|
2dc7e327ad | ||
|
7b151c3ef0 | ||
|
0af6630521 | ||
|
4b459a99be | ||
|
e093ed7d67 | ||
|
ddbea8feda | ||
|
6b5dff5667 | ||
|
53cd499621 | ||
|
30c5a6f79c | ||
|
4e1191550c | ||
|
3b1363d31a | ||
|
160e29ea95 | ||
|
b9adad304e | ||
|
ef17d716d7 | ||
|
8ec01772be | ||
|
4084b4c6c6 | ||
|
c3cb8e0a79 | ||
|
19b5e5349e | ||
|
f87923e09e | ||
|
05684f6c3c | ||
|
08193ecf1c | ||
|
8c9a827516 | ||
|
638987f359 | ||
|
8190f0c420 | ||
|
f7de0bc9c8 | ||
|
08f2990eac | ||
|
e6d46ec5ad | ||
|
db6d7dccd8 | ||
|
4e8a5f2ec8 | ||
|
63e9414210 | ||
|
4751ac1ac8 | ||
|
9d56c56117 | ||
|
0d82faa239 | ||
|
fb27724042 | ||
|
90141ef305 | ||
|
bc05da8dc0 | ||
|
bf3e1e5b40 | ||
|
0ae93c8cdc | ||
|
f9813019a7 | ||
|
5e907ebd58 | ||
|
fa5fa3a881 | ||
|
9b9cc2f947 | ||
|
80f5be8b13 | ||
|
ec5b5e8aaa | ||
|
95463719ae | ||
|
041415e9b4 | ||
|
abd5383d40 | ||
|
c5dc0e2e4c | ||
|
88116712f6 | ||
|
7dfa41bbc4 | ||
|
c09ff35df4 | ||
|
d526bcc71b | ||
|
13d1e497f7 | ||
|
3eaae748d3 | ||
|
7f16067383 | ||
|
024e048c26 | ||
|
c31c3848df | ||
|
b0e0af1838 | ||
|
3785bf1f17 | ||
|
79fb5724f9 | ||
|
65b2ea1888 | ||
|
6309bd12ac | ||
|
7444a151b2 | ||
|
ce9cc2db86 | ||
|
e91b930648 | ||
|
ed78fb1366 | ||
|
388f12b7d9 | ||
|
8ae415acff | ||
|
d2cc9365fc | ||
|
dcfb6e5ef5 | ||
|
75f96b83de | ||
|
66bba1493e | ||
|
1dde54b872 | ||
|
c48a990778 | ||
|
23c425618e | ||
|
d2a7ecf72c | ||
|
f220a1e3c7 | ||
|
ba63aa76ca | ||
|
72415eaa49 | ||
|
d88f7c9459 | ||
|
425d8ad02a | ||
|
ae9758b964 | ||
|
828a067b2b | ||
|
bb24b350ac | ||
|
dafb2b0361 | ||
|
30210c7087 | ||
|
d8a795df0a | ||
|
499e4b4c50 | ||
|
fd52220b1b | ||
|
e9438224ab | ||
|
2120e9df88 | ||
|
ddd16dd312 | ||
|
7624f66fec | ||
|
dab11ea841 | ||
|
a3f3dc0f1c | ||
|
5d59447ccb | ||
|
e3c38e4143 | ||
|
e5ec4df702 | ||
|
1340ff2bc2 | ||
|
dbdc909e19 | ||
|
c6ef1943e4 | ||
|
a3c9f8594a | ||
|
354f2b65fa | ||
|
b3657d5f2e | ||
|
82ca65956f | ||
|
c8c2106f3e | ||
|
8178dfb85a | ||
|
50e78198a8 | ||
|
ee04cbcfa8 | ||
|
fc312f7ffe | ||
|
e6e964c3f3 | ||
|
df5e796d99 | ||
|
d3239c953d | ||
|
fb9a3bf32b | ||
|
ace83a938d | ||
|
fb028f0fe7 | ||
|
8a13909bab | ||
|
4e745f06e9 | ||
|
14b65a3c4f | ||
|
64ad490bc1 | ||
|
d2d7a4bcab | ||
|
14cbd13ef2 | ||
|
efc314196d | ||
|
403a70ca89 | ||
|
44b36b6321 | ||
|
4bd829e3e1 | ||
|
38f74d8a23 | ||
|
2613c2ef9b | ||
|
5751cd662d | ||
|
4039b713c3 | ||
|
c3f8010b19 | ||
|
3e8a22ae8a | ||
|
c01f3be6e6 | ||
|
0cf372c814 | ||
|
ac20c9cd41 | ||
|
d74c2a74e5 | ||
|
b79637ac41 | ||
|
e135772119 | ||
|
3cf26b471b | ||
|
c630285692 | ||
|
5702b71037 | ||
|
a4e5f5ca50 | ||
|
b0b00d49d2 | ||
|
cb018ec047 | ||
|
168b21c77e | ||
|
2dcc641d5a | ||
|
c8432ae668 | ||
|
642ad4e06f | ||
|
924796b478 | ||
|
319d4c7e01 | ||
|
07c491f235 | ||
|
970f91ec24 | ||
|
48381bd4f6 | ||
|
1a12999431 | ||
|
90676540ec | ||
|
7db58d5f8d | ||
|
875452b476 | ||
|
1c4c5e3b80 | ||
|
af5e13b9a1 | ||
|
9b78bc4af7 | ||
|
1702a4c223 | ||
|
f0e35c8ed8 | ||
|
26150d8489 | ||
|
48dcbf4935 | ||
|
59dd7d8900 | ||
|
c279bdaa81 | ||
|
01d52a7292 | ||
|
2b38d14bf5 | ||
|
d35a21873e | ||
|
b23cae9643 | ||
|
505df337c2 | ||
|
117997da54 | ||
|
19052d4360 | ||
|
2dbaca2464 | ||
|
4b8134b19b | ||
|
588fe5b5c1 | ||
|
b8f44de48e | ||
|
49bdc4f0c2 | ||
|
a0ee25a21e | ||
|
d8192013f3 | ||
|
8ed1f51f7f | ||
|
03fec389f4 | ||
|
38c39e2aa1 | ||
|
6298fd1eef | ||
|
5a77994516 | ||
|
6142238237 | ||
|
3164f328b5 | ||
|
ce78d0c301 | ||
|
94305f248b | ||
|
3afd5d7a89 | ||
|
d2adbad408 | ||
|
2df382277d | ||
|
9f71bdd045 | ||
|
838d0924b9 | ||
|
1f8d593931 | ||
|
574a3a456d | ||
|
3617fbab42 | ||
|
29ccd13e15 | ||
|
de9c9efa6f | ||
|
eb809ba425 | ||
|
adf60fb3a1 | ||
|
a3fd46c516 | ||
|
0040667965 | ||
|
60e67a62e6 | ||
|
931f130377 | ||
|
524fbc35a7 | ||
|
51d35750f6 | ||
|
90fde9c939 | ||
|
5cbc55578f | ||
|
f90e7b9c56 | ||
|
d5b9489408 | ||
|
975d763db1 | ||
|
907fc30fac | ||
|
25d2efeabe | ||
|
3a119a3d3a | ||
|
8df883ed71 | ||
|
0c49f7349d | ||
|
eef1097c90 | ||
|
08004d4eed | ||
|
6d7e56bed6 | ||
|
8e6701c9a6 | ||
|
6d5c512571 | ||
|
b94ea1b4f7 | ||
|
b2d6011679 | ||
|
c0aa1c8a49 | ||
|
5fe837483c | ||
|
4f15b988e7 | ||
|
6cd3bc7384 | ||
|
0faadef36f | ||
|
af6c3017fb | ||
|
8157abe591 | ||
|
61e08baec1 | ||
|
0493e89897 | ||
|
c783e9aa5f | ||
|
4661f15fab | ||
|
e51a98d184 | ||
|
b67eee5741 | ||
|
d9259fc958 | ||
|
65f748fc62 | ||
|
bed3616bf0 | ||
|
1605ca0140 | ||
|
8692f5d8e3 | ||
|
42e2c54922 | ||
|
291c61891a | ||
|
59e08c0dac | ||
|
a70c9c69a0 | ||
|
dffe6b87e4 | ||
|
28b7962bee | ||
|
64e131f285 | ||
|
a9f0f18c3a | ||
|
2e0822bed0 | ||
|
b0fb31fc96 | ||
|
163d32eea1 | ||
|
b7728a884b | ||
|
86b4b2eef2 | ||
|
09eda804f7 | ||
|
37d4932b31 | ||
|
0fddf73ddb | ||
|
f981ab7a9e | ||
|
677ea5f22d | ||
|
fce455ae0b | ||
|
e050a2661c | ||
|
a03581ce39 | ||
|
13b9b9b7d8 | ||
|
0a3b370805 | ||
|
313ba0280a | ||
|
adb7676fc1 | ||
|
8ffb398517 | ||
|
9a943e21d3 | ||
|
7c106578ed | ||
|
d1d9b92aee | ||
|
434b145ee0 | ||
|
2546b88661 | ||
|
bba6d604f0 | ||
|
274f9ad919 | ||
|
89a8c89663 | ||
|
e7b290debb | ||
|
46e754a17d | ||
|
b12992c1cb | ||
|
374a451eeb | ||
|
1e13acb206 | ||
|
5b2b2feb9f | ||
|
77af993181 | ||
|
c5ed5c5ff9 | ||
|
6b53a55dd7 | ||
|
83fbdcd5e6 | ||
|
cb8bf6540c | ||
|
fdb1fa4d08 | ||
|
10d7ccc8e0 | ||
|
b973f7f375 | ||
|
7671c1074b | ||
|
6ce2e19bbe | ||
|
3a08706e40 | ||
|
e5722fe9d2 | ||
|
700f957d9a | ||
|
9109dee072 | ||
|
b6a843a05b | ||
|
ff1fb4f10d | ||
|
1bf79a4dae | ||
|
85d4b86545 | ||
|
98e88b7b53 | ||
|
85702f8f5d | ||
|
d97cb851f1 | ||
|
6dcdb4a601 | ||
|
41ef1d87ef | ||
|
44728d09a9 | ||
|
b1664534af | ||
|
56e89e8d26 | ||
|
f6ebc06767 | ||
|
3db5e15bde | ||
|
a2291fb989 | ||
|
af97f19926 | ||
|
0dae1f48fd | ||
|
c7dbb8ef91 | ||
|
3a1e019e83 | ||
|
a923be95b3 | ||
|
a11ab6c995 | ||
|
1d802881eb | ||
|
6c796cf201 | ||
|
44c6619660 | ||
|
ef7499a31b | ||
|
ed571ae68a | ||
|
e2b3cbac23 | ||
|
ba290eb9b0 | ||
|
3805e1d507 | ||
|
daf3b3a3b4 | ||
|
800eb76a2d | ||
|
bcbc6159f4 | ||
|
5f8c6d2287 | ||
|
88eb3a9c34 | ||
|
3e43dda9d4 | ||
|
f96a1cfadd | ||
|
758bcd5343 | ||
|
2bfd4196fb | ||
|
1b7a99cb24 | ||
|
087c0078ca | ||
|
b9ae54c951 | ||
|
7ac6e25ffc | ||
|
d3089ebbc2 | ||
|
14a64c7372 | ||
|
ca9b06878d | ||
|
8f100269ad | ||
|
48bb9200d9 | ||
|
d7794bf608 | ||
|
3151906157 | ||
|
6153efd02a | ||
|
b5b8f42a0c | ||
|
043ffd38bc | ||
|
32b826e312 | ||
|
700ca3b946 | ||
|
e45dd771db | ||
|
698cbee1fb | ||
|
f1e14c4858 | ||
|
8d46bd1d7c | ||
|
fbb08a30e2 | ||
|
81371e7c79 | ||
|
39dfdac771 | ||
|
b7fa00e22d | ||
|
3df0a333ad | ||
|
a4aa6d79ad | ||
|
ea3933b87a | ||
|
6ae9f7e7c3 | ||
|
efbbfb6547 |
@@ -1,3 +1,7 @@
|
||||
include:
|
||||
- project: 'gnome/citemplates'
|
||||
file: 'flatpak/flatpak_ci_initiative.yml'
|
||||
|
||||
stages:
|
||||
- build
|
||||
- analysis
|
||||
@@ -149,6 +153,7 @@ msys2-mingw64:
|
||||
artifacts:
|
||||
paths:
|
||||
- "${APPID}-dev.flatpak"
|
||||
- 'repo.tar'
|
||||
expire_in: 1 day
|
||||
script:
|
||||
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
|
||||
@@ -200,6 +205,24 @@ flatpak-master:icon-browser:
|
||||
variables:
|
||||
APPID: org.gtk.IconBrowser4
|
||||
|
||||
# Publish the demo apps to the GNOME Nightly repo
|
||||
# https://wiki.gnome.org/Apps/Nightly
|
||||
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
|
||||
nightly demo:
|
||||
extends: '.publish_nightly'
|
||||
dependencies: ['flatpak-master:demo']
|
||||
needs: ['flatpak-master:demo']
|
||||
|
||||
nightly factory:
|
||||
extends: '.publish_nightly'
|
||||
dependencies: ['flatpak-master:widget-factory']
|
||||
needs: ['flatpak-master:widget-factory']
|
||||
|
||||
nightly icon-browser:
|
||||
extends: '.publish_nightly'
|
||||
dependencies: ['flatpak-master:icon-browser']
|
||||
needs: ['flatpak-master:icon-browser']
|
||||
|
||||
static-scan:
|
||||
image: $FEDORA_IMAGE
|
||||
stage: analysis
|
||||
|
@@ -40,3 +40,8 @@ flatpak build-bundle \
|
||||
${appid}-dev.flatpak \
|
||||
--runtime-repo=https://nightly.gnome.org/gnome-nightly.flatpakrepo \
|
||||
${appid}
|
||||
|
||||
# to be consumed by the nightly publish jobs
|
||||
if [[ $CI_COMMIT_BRANCH == master ]]; then
|
||||
tar cf repo.tar ${repodir}
|
||||
fi
|
||||
|
86
NEWS
@@ -1,3 +1,89 @@
|
||||
Overview of Changes in 3.99.4
|
||||
=============================
|
||||
|
||||
* GtkColumnView:
|
||||
- Improve column resizing
|
||||
- Make double-click reset column widths
|
||||
- Move header outside of scrollbars
|
||||
|
||||
* GtkSearchEntry:
|
||||
- Add an icon
|
||||
|
||||
* GtkDropDown:
|
||||
- Polish the appearance
|
||||
|
||||
* GtkColorChooser:
|
||||
- Accessibility improvements
|
||||
|
||||
* GtkPopoverMenu:
|
||||
- Add accessibility support
|
||||
- Allow custom items. This adds new API:
|
||||
gtk_popover_menu_add/remove_child
|
||||
gtk_popover_menu_bar_add/remove_child
|
||||
|
||||
* GtkTextView:
|
||||
- Fix rendering and positioning of anchored children
|
||||
- Fix positioning of touch handles
|
||||
|
||||
* Constraints:
|
||||
- Fix loading constraints from ui files
|
||||
|
||||
* Media support:
|
||||
- Use cubic instead of linear volume
|
||||
|
||||
* Accessibility:
|
||||
- Implement Component for all widgets
|
||||
- Implement Text and EditableText for all editables
|
||||
- Rework accessible name/description computation
|
||||
- Add documentation for app and widget developers
|
||||
- Handle HIDDEN state changes by adding/removing elements
|
||||
- Support setting accessibility attributes in ui files
|
||||
- Make window controls accessible
|
||||
|
||||
* Introspection:
|
||||
- Add some missing annotations
|
||||
|
||||
* gdk:
|
||||
- Deliver events on flush
|
||||
- Drop the unused GdkPoint struct from the API
|
||||
- Improve popup autohide behavior
|
||||
|
||||
* Demos:
|
||||
- Add another constraints demo
|
||||
- Tweak various demos to improve consistency
|
||||
- Small accessibility improvements
|
||||
|
||||
* Tools:
|
||||
- Improve gtk4-builder-tool handling of various
|
||||
widgets when converting ui files from GTK 3
|
||||
|
||||
* Documentation:
|
||||
- Use GtkApplication in all examples
|
||||
- Improve and expand the widget gallery
|
||||
|
||||
* Testsuite:
|
||||
- Improve coverage of GDK
|
||||
- Improve coverage of gtk4-builder-tool
|
||||
|
||||
* Build:
|
||||
- Fix the build with cups 2.2.12
|
||||
- Make cloudprint support build without warnings
|
||||
|
||||
* Broadway:
|
||||
- Support modifiers for scroll events
|
||||
|
||||
* Windows:
|
||||
- Improve IME support
|
||||
|
||||
* OS X:
|
||||
- Fix various input issues
|
||||
- Make GtkGLArea work (with the cairo backend)
|
||||
|
||||
* Translation updates:
|
||||
German
|
||||
Polish
|
||||
|
||||
|
||||
Overview of Changes in 3.99.3
|
||||
=============================
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* always defined to indicate that i18n is enabled */
|
||||
#define ENABLE_NLS 1
|
||||
|
||||
/* Use structured logging */
|
||||
#define G_LOG_STRUCTURED 1
|
||||
|
||||
/* The prefix for our gettext translation domains. */
|
||||
#mesondefine GETTEXT_PACKAGE
|
||||
|
||||
|
@@ -36,7 +36,7 @@ struct _ConstraintEditorWindow
|
||||
G_DEFINE_TYPE(ConstraintEditorWindow, constraint_editor_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
|
||||
static GtkConstraintTarget *
|
||||
find_target (GListModel *model,
|
||||
find_target (GListModel *model,
|
||||
GtkConstraintTarget *orig)
|
||||
{
|
||||
const char *name;
|
||||
@@ -163,20 +163,30 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
|
||||
GtkConstraint *clone;
|
||||
GtkConstraintTarget *target;
|
||||
GtkConstraintTarget *source;
|
||||
GtkConstraintAttribute source_attr;
|
||||
|
||||
item = g_list_model_get_item (list, i);
|
||||
constraint = GTK_CONSTRAINT (item);
|
||||
|
||||
target = gtk_constraint_get_target (constraint);
|
||||
source = gtk_constraint_get_source (constraint);
|
||||
clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
|
||||
source_attr = gtk_constraint_get_source_attribute (constraint);
|
||||
|
||||
if (source == NULL && source_attr == GTK_CONSTRAINT_ATTRIBUTE_NONE)
|
||||
clone = gtk_constraint_new_constant (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
|
||||
gtk_constraint_get_target_attribute (constraint),
|
||||
gtk_constraint_get_relation (constraint),
|
||||
find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source),
|
||||
gtk_constraint_get_target_attribute (constraint),
|
||||
gtk_constraint_get_multiplier (constraint),
|
||||
gtk_constraint_get_constant (constraint),
|
||||
gtk_constraint_get_strength (constraint));
|
||||
else
|
||||
clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
|
||||
gtk_constraint_get_target_attribute (constraint),
|
||||
gtk_constraint_get_relation (constraint),
|
||||
find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source),
|
||||
source_attr,
|
||||
gtk_constraint_get_multiplier (constraint),
|
||||
gtk_constraint_get_constant (constraint),
|
||||
gtk_constraint_get_strength (constraint));
|
||||
|
||||
constraint_view_add_constraint (CONSTRAINT_VIEW (self->view), clone);
|
||||
|
||||
@@ -300,7 +310,7 @@ save_response_cb (GtkNativeDialog *dialog,
|
||||
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
|
||||
text = serialize_model (model);
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
g_file_replace_contents (file, text, -1,
|
||||
g_file_replace_contents (file, text, strlen (text),
|
||||
NULL, FALSE,
|
||||
G_FILE_CREATE_NONE,
|
||||
NULL,
|
||||
|
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="ConstraintEditorWindow" parent="GtkApplicationWindow">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
</style>
|
||||
<property name="title" translatable="yes">GTK Constraint Editor</property>
|
||||
<property name="default-width">1024</property>
|
||||
<property name="default-height">768</property>
|
||||
|
@@ -142,6 +142,9 @@ get_target (GListModel *model,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (id == NULL)
|
||||
return NULL;
|
||||
|
||||
if (strcmp ("super", id) == 0)
|
||||
return NULL;
|
||||
|
||||
@@ -212,6 +215,22 @@ get_relation_nick (GtkConstraintRelation relation)
|
||||
return nick;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_relation_display_name (GtkConstraintRelation relation)
|
||||
{
|
||||
switch (relation)
|
||||
{
|
||||
case GTK_CONSTRAINT_RELATION_LE:
|
||||
return "≤";
|
||||
case GTK_CONSTRAINT_RELATION_EQ:
|
||||
return "=";
|
||||
case GTK_CONSTRAINT_RELATION_GE:
|
||||
return "≥";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
static GtkConstraintStrength
|
||||
get_strength (const char *id)
|
||||
{
|
||||
@@ -331,6 +350,7 @@ source_attr_changed (ConstraintEditor *editor)
|
||||
{
|
||||
gtk_widget_set_sensitive (editor->source, TRUE);
|
||||
gtk_widget_set_sensitive (editor->multiplier, TRUE);
|
||||
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +367,7 @@ constraint_editor_constraint_to_string (GtkConstraint *constraint)
|
||||
|
||||
name = get_target_name (gtk_constraint_get_target (constraint));
|
||||
attr = get_attr_nick (gtk_constraint_get_target_attribute (constraint));
|
||||
relation = get_relation_nick (gtk_constraint_get_relation (constraint));
|
||||
relation = get_relation_display_name (gtk_constraint_get_relation (constraint));
|
||||
|
||||
if (name == NULL)
|
||||
name = "[ ]";
|
||||
@@ -441,8 +461,12 @@ update_preview (ConstraintEditor *editor)
|
||||
static void
|
||||
update_button (ConstraintEditor *editor)
|
||||
{
|
||||
if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target)) != NULL &&
|
||||
gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source)) != NULL)
|
||||
const char *target = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
|
||||
const char *source = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
|
||||
const char *source_attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
|
||||
|
||||
if (target &&
|
||||
(source || (source_attr && get_target_attr (source_attr) == GTK_CONSTRAINT_ATTRIBUTE_NONE)))
|
||||
gtk_widget_set_sensitive (editor->button, TRUE);
|
||||
else
|
||||
gtk_widget_set_sensitive (editor->button, FALSE);
|
||||
|
@@ -78,6 +78,7 @@
|
||||
<object class="GtkComboBoxText" id="source_attr">
|
||||
<signal name="changed" handler="update_preview" swapped="yes"/>
|
||||
<signal name="changed" handler="source_attr_changed" swapped="yes"/>
|
||||
<signal name="changed" handler="update_button" swapped="yes"/>
|
||||
<layout>
|
||||
<property name="column">2</property>
|
||||
<property name="row">3</property>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="resizable">0</property>
|
||||
<property name="title">CSS Blend Modes</property>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* Builder
|
||||
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, toolbar
|
||||
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, GtkShortcutController, toolbar
|
||||
*
|
||||
* Demonstrates a traditional interface, loaded from a XML description,
|
||||
* and shows how to connect actions to the menu items and toolbar buttons.
|
||||
|
@@ -1,9 +1,16 @@
|
||||
/* Constraints/Simple
|
||||
/* Constraints/Simple Constraints
|
||||
* #Keywords: GtkLayoutManager
|
||||
*
|
||||
* GtkConstraintLayout provides a layout manager that uses relations
|
||||
* between widgets (also known as "constraints") to compute the position
|
||||
* between widgets (also known as “constraints”) to compute the position
|
||||
* and size of each child.
|
||||
*
|
||||
* In addition to child widgets, the constraints can involve spacer
|
||||
* objects (also known as “guides”). This example has a guide between
|
||||
* the two buttons in the top row.
|
||||
*
|
||||
* Try resizing the window to see how the constraints react to update
|
||||
* the layout.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
@@ -234,15 +241,12 @@ simple_grid_init (SimpleGrid *self)
|
||||
|
||||
self->button1 = gtk_button_new_with_label ("Child 1");
|
||||
gtk_widget_set_parent (self->button1, widget);
|
||||
gtk_widget_set_name (self->button1, "button1");
|
||||
|
||||
self->button2 = gtk_button_new_with_label ("Child 2");
|
||||
gtk_widget_set_parent (self->button2, widget);
|
||||
gtk_widget_set_name (self->button2, "button2");
|
||||
|
||||
self->button3 = gtk_button_new_with_label ("Child 3");
|
||||
gtk_widget_set_parent (self->button3, widget);
|
||||
gtk_widget_set_name (self->button3, "button3");
|
||||
|
||||
GtkLayoutManager *manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
||||
build_constraints (self, GTK_CONSTRAINT_LAYOUT (manager));
|
||||
@@ -259,7 +263,8 @@ do_constraints (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Simple Constraints");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
74
demos/gtk-demo/constraints_builder.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/* Constraints/Builder
|
||||
*
|
||||
* GtkConstraintLayouts can be created in .ui files, and constraints can
|
||||
* be set up at that time as well, as this example demonstrates. It shows
|
||||
* various ways to do spacing and sizing with constraints.
|
||||
*
|
||||
* Make the window wider to see the rows react differently
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_DECLARE_FINAL_TYPE (ConstraintsGrid, constraints_grid, CONSTRAINTS, GRID, GtkWidget)
|
||||
|
||||
struct _ConstraintsGrid
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ConstraintsGrid, constraints_grid, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
constraints_grid_init (ConstraintsGrid *grid)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
constraints_grid_dispose (GObject *object)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (object);
|
||||
GtkWidget *child;
|
||||
|
||||
while ((child = gtk_widget_get_first_child (widget)))
|
||||
gtk_widget_unparent (child);
|
||||
|
||||
G_OBJECT_CLASS (constraints_grid_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
constraints_grid_class_init (ConstraintsGridClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = constraints_grid_dispose;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_constraints_builder (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
|
||||
g_type_ensure (constraints_grid_get_type ());
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/constraints_builder/constraints_builder.ui");
|
||||
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
460
demos/gtk-demo/constraints_builder.ui
Normal file
@@ -0,0 +1,460 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="title" translatable="yes">Constraints — Builder</property>
|
||||
<property name="default-width">260</property>
|
||||
<child>
|
||||
<object class="ConstraintsGrid">
|
||||
<property name="halign">fill</property>
|
||||
<property name="valign">fill</property>
|
||||
<property name="margin-top">10</property>
|
||||
<property name="margin-bottom">10</property>
|
||||
<property name="margin-start">10</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="layout-manager">
|
||||
<object class="GtkConstraintLayout">
|
||||
<constraints>
|
||||
<guide name="guide1" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide2" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide3" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide4" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide5" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide6" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide7" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide8" min-width="10" nat-width="200" strength="weak"/>
|
||||
<guide name="guide9" min-width="0" nat-width="200" strength="weak"/>
|
||||
<guide name="guide10" min-width="0" nat-width="200" strength="weak"/>
|
||||
<guide name="barrier1" min-height="10"/>
|
||||
<guide name="barrier2" min-height="10"/>
|
||||
<guide name="barrier3" min-height="10"/>
|
||||
<guide name="barrier4" min-height="10"/>
|
||||
|
||||
<!-- Spread Chain -->
|
||||
<constraint target="super" target-attribute="top"
|
||||
relation="eq"
|
||||
source="button1" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="top"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="top"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="top"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="super" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide1" source-attribute="left"
|
||||
strength="required"/>
|
||||
<constraint target="button1" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide1" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="guide2" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button1" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="button2" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide2" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="guide3" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="button3" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide3" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="guide4" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="right"
|
||||
relation="eq"
|
||||
source="guide4" source-attribute="right"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="guide1" target-attribute="width"
|
||||
relation="eq"
|
||||
source="guide2" source-attribute="width"
|
||||
strength="required"/>
|
||||
<constraint target="guide2" target-attribute="width"
|
||||
relation="eq"
|
||||
source="guide3" source-attribute="width"
|
||||
strength="required"/>
|
||||
<constraint target="guide3" target-attribute="width"
|
||||
relation="eq"
|
||||
source="guide4" source-attribute="width"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button1" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="width"
|
||||
strength="required"/>
|
||||
<constraint target="button2" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="width"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button1" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier1" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button2" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier1" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button3" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier1" source-attribute="top"
|
||||
strength="required"/>
|
||||
|
||||
<!-- Spread Inside Chain -->
|
||||
|
||||
<constraint target="super" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button4" source-attribute="left"
|
||||
strength="required"/>
|
||||
<constraint target="guide5" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button4" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="button5" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide5" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="guide6" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button5" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="button6" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide6" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="right"
|
||||
relation="eq"
|
||||
source="button6" source-attribute="right"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="guide5" target-attribute="width"
|
||||
relation="eq"
|
||||
source="guide6" source-attribute="width"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button4" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button5" source-attribute="width"
|
||||
strength="required"/>
|
||||
<constraint target="button5" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button6" source-attribute="width"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button4" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier1" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button5" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier1" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button6" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier1" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button4" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier2" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button5" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier2" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button6" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier2" source-attribute="top"
|
||||
strength="required"/>
|
||||
|
||||
<!-- Weighted Chain -->
|
||||
|
||||
<constraint target="super" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button7" source-attribute="left"
|
||||
strength="required"/>
|
||||
<constraint target="button8" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button7" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="button9" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button8" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="right"
|
||||
relation="eq"
|
||||
source="button9" source-attribute="right"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button8" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button7" source-attribute="width"
|
||||
multiplier="2"
|
||||
strength="required"/>
|
||||
<constraint target="button9" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button7" source-attribute="width"
|
||||
multiplier="3"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button7" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier2" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button8" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier2" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button9" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier2" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button7" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier3" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button8" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier3" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button9" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier3" source-attribute="top"
|
||||
strength="required"/>
|
||||
|
||||
<!-- Packed Chain -->
|
||||
|
||||
<constraint target="super" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide7" source-attribute="left"
|
||||
strength="required"/>
|
||||
<constraint target="button10" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide7" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="button11" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button10" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="button12" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button11" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="guide8" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button12" source-attribute="right"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="right"
|
||||
relation="eq"
|
||||
source="guide8" source-attribute="right"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="guide7" target-attribute="width"
|
||||
relation="eq"
|
||||
source="guide8" source-attribute="width"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button10" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button11" source-attribute="width"
|
||||
strength="required"/>
|
||||
<constraint target="button11" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button12" source-attribute="width"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button10" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier3" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button11" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier3" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button12" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier3" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button10" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier4" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button11" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier4" source-attribute="top"
|
||||
strength="required"/>
|
||||
<constraint target="button12" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="barrier4" source-attribute="top"
|
||||
strength="required"/>
|
||||
|
||||
<!-- Packed Chain with Bias -->
|
||||
|
||||
<constraint target="super" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide9" source-attribute="left"
|
||||
strength="required"/>
|
||||
<constraint target="button13" target-attribute="left"
|
||||
relation="eq"
|
||||
source="guide9" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="button14" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button13" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="button15" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button14" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="guide10" target-attribute="left"
|
||||
relation="eq"
|
||||
source="button15" source-attribute="right"
|
||||
constant="10"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="right"
|
||||
relation="eq"
|
||||
source="guide10" source-attribute="right"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="guide9" target-attribute="width"
|
||||
relation="eq"
|
||||
source="guide10" source-attribute="width"
|
||||
multiplier="4"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button13" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button14" source-attribute="width"
|
||||
strength="required"/>
|
||||
<constraint target="button14" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button15" source-attribute="width"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="button13" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier4" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button14" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier4" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="button15" target-attribute="top"
|
||||
relation="eq"
|
||||
source="barrier4" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
|
||||
<constraint target="super" target-attribute="bottom"
|
||||
relation="ge"
|
||||
source="button13" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="bottom"
|
||||
relation="ge"
|
||||
source="button14" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="bottom"
|
||||
relation="ge"
|
||||
source="button15" source-attribute="bottom"
|
||||
strength="required"/>
|
||||
</constraints>
|
||||
</object>
|
||||
</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">A</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label">B</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button3">
|
||||
<property name="label">C</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button4">
|
||||
<property name="label">A</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button5">
|
||||
<property name="label">B</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button6">
|
||||
<property name="label">C</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button7">
|
||||
<property name="label">A</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button8">
|
||||
<property name="label">B</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button9">
|
||||
<property name="label">C</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button10">
|
||||
<property name="label">A</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button11">
|
||||
<property name="label">B</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button12">
|
||||
<property name="label">C</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button13">
|
||||
<property name="label">A</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button14">
|
||||
<property name="label">B</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button15">
|
||||
<property name="label">C</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
@@ -1,7 +1,7 @@
|
||||
/* Constraints/Interactive
|
||||
/* Constraints/Interactive Constraints
|
||||
* #Keywords: GtkConstraintLayout
|
||||
*
|
||||
* Demonstrate how constraints can be updates during user interaction.
|
||||
* This example shows how constraints can be updated during user interaction.
|
||||
* The vertical edge between the buttons can be dragged with the mouse.
|
||||
*/
|
||||
|
||||
@@ -205,7 +205,7 @@ interactive_grid_init (InteractiveGrid *self)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_constraints2 (GtkWidget *do_widget)
|
||||
do_constraints_interactive (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window;
|
||||
|
||||
@@ -215,7 +215,8 @@ do_constraints2 (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Interactive Constraints");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
@@ -2,6 +2,10 @@
|
||||
*
|
||||
* GtkConstraintLayout allows defining constraints using a
|
||||
* compact syntax called Visual Format Language, or VFL.
|
||||
*
|
||||
* A typical example of a VFL specification looks like this:
|
||||
*
|
||||
* H:|-[button1(==button2)]-12-[button2]-|
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
@@ -124,7 +128,7 @@ vfl_grid_init (VflGrid *self)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_constraints3 (GtkWidget *do_widget)
|
||||
do_constraints_vfl (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window;
|
||||
|
||||
@@ -134,7 +138,8 @@ do_constraints3 (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints — VFL");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
@@ -18,6 +18,9 @@
|
||||
<file>demoimage.c</file>
|
||||
<file>demoimage.h</file>
|
||||
</gresource>
|
||||
<gresource prefix="/constraints_builder">
|
||||
<file>constraints_builder.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/css_accordion">
|
||||
<file>css_accordion.css</file>
|
||||
<file>reset.css</file>
|
||||
@@ -40,6 +43,11 @@
|
||||
<file>cssview.css</file>
|
||||
<file>reset.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/dropdown">
|
||||
<file>suggestionentry.h</file>
|
||||
<file>suggestionentry.c</file>
|
||||
<file>suggestionentry.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/theming_style_classes">
|
||||
<file>theming.ui</file>
|
||||
</gresource>
|
||||
@@ -205,6 +213,8 @@
|
||||
<file>demo3widget.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/paintable_svg">
|
||||
<file>svgpaintable.h</file>
|
||||
<file>svgpaintable.c</file>
|
||||
<file>org.gtk.gtk4.NodeEditor.Devel.svg</file>
|
||||
</gresource>
|
||||
<gresource prefix="/shortcuts">
|
||||
@@ -226,9 +236,12 @@
|
||||
<file>revealer.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/images">
|
||||
<file>pixbufpaintable.h</file>
|
||||
<file>pixbufpaintable.c</file>
|
||||
<file>alphatest.png</file>
|
||||
<file>floppybuddy.gif</file>
|
||||
<file>gtk-logo.webm</file>
|
||||
<file alias="org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
|
||||
</gresource>
|
||||
<gresource prefix="/video-player">
|
||||
<file>bbb.png</file>
|
||||
@@ -240,8 +253,9 @@
|
||||
<file>clipboard.c</file>
|
||||
<file>combobox.c</file>
|
||||
<file>constraints.c</file>
|
||||
<file>constraints2.c</file>
|
||||
<file>constraints3.c</file>
|
||||
<file>constraints_interactive.c</file>
|
||||
<file>constraints_vfl.c</file>
|
||||
<file>constraints_builder.c</file>
|
||||
<file>css_accordion.c</file>
|
||||
<file>css_basics.c</file>
|
||||
<file>css_blendmodes.c</file>
|
||||
@@ -280,7 +294,7 @@
|
||||
<file>layoutmanager2.c</file>
|
||||
<file>links.c</file>
|
||||
<file>listbox.c</file>
|
||||
<file>listbox2.c</file>
|
||||
<file>listbox_controls.c</file>
|
||||
<file>listview_applauncher.c</file>
|
||||
<file>listview_colors.c</file>
|
||||
<file>listview_clocks.c</file>
|
||||
@@ -295,7 +309,7 @@
|
||||
<file>markup.c</file>
|
||||
<file>menu.c</file>
|
||||
<file>overlay.c</file>
|
||||
<file>overlay2.c</file>
|
||||
<file>overlay_decorative.c</file>
|
||||
<file>paint.c</file>
|
||||
<file>pagesetup.c</file>
|
||||
<file>paintable.c</file>
|
||||
@@ -305,6 +319,9 @@
|
||||
<file>paintable_svg.c</file>
|
||||
<file>panes.c</file>
|
||||
<file>password_entry.c</file>
|
||||
<file>path_fill.c</file>
|
||||
<file>path_maze.c</file>
|
||||
<file>path_text.c</file>
|
||||
<file>peg_solitaire.c</file>
|
||||
<file>pickers.c</file>
|
||||
<file>printing.c</file>
|
||||
@@ -345,8 +362,8 @@
|
||||
<file>messages.txt</file>
|
||||
<file>apple-red.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listbox2">
|
||||
<file>listbox2.ui</file>
|
||||
<gresource prefix="/listbox_controls">
|
||||
<file>listbox_controls.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/glarea">
|
||||
<file>glarea-gl.fs.glsl</file>
|
||||
@@ -389,6 +406,9 @@
|
||||
<gresource prefix="/fontrendering">
|
||||
<file>fontrendering.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/path_text">
|
||||
<file>path_text.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/gtk/Demo4">
|
||||
<file>icons/16x16/actions/application-exit.png</file>
|
||||
<file>icons/16x16/actions/document-new.png</file>
|
||||
|
@@ -83,7 +83,7 @@
|
||||
</menu>
|
||||
<object class="GtkAboutDialog" id="aboutdialog1">
|
||||
<property name="program-name" translatable="yes">Builder demo</property>
|
||||
<property name="logo-icon-name" translatable="yes">gtk3-demo</property>
|
||||
<property name="logo-icon-name" translatable="yes">org.gtk.Demo4</property>
|
||||
<property name="modal">True</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="window1">
|
||||
@@ -96,13 +96,18 @@
|
||||
<child>
|
||||
<object class="GtkPopoverMenuBar" id="menubar1">
|
||||
<property name="menu-model">menubar</property>
|
||||
<accessibility>
|
||||
<property name="label">Main Menu</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="toolbar1">
|
||||
<style>
|
||||
<class name="toolbar"/>
|
||||
</style>
|
||||
<property name="accessible-role">toolbar</property>
|
||||
<property name="css-classes">toolbar</property>
|
||||
<accessibility>
|
||||
<property name="label">Toolbar</property>
|
||||
</accessibility>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">New</property>
|
||||
|
@@ -44,11 +44,23 @@ G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
|
||||
static void
|
||||
demo_tagged_entry_init (DemoTaggedEntry *entry)
|
||||
{
|
||||
GtkCssProvider *provider;
|
||||
|
||||
entry->text = gtk_text_new ();
|
||||
gtk_widget_set_hexpand (entry->text, TRUE);
|
||||
gtk_widget_set_vexpand (entry->text, TRUE);
|
||||
gtk_widget_set_parent (entry->text, GTK_WIDGET (entry));
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (entry));
|
||||
gtk_editable_set_width_chars (GTK_EDITABLE (entry->text), 6);
|
||||
gtk_editable_set_max_width_chars (GTK_EDITABLE (entry->text), 6);
|
||||
gtk_widget_add_css_class (GTK_WIDGET (entry), "tagged");
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -212,7 +224,6 @@ static void
|
||||
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
|
||||
@@ -222,13 +233,6 @@ demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
|
||||
gesture = gtk_gesture_click_new ();
|
||||
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
|
||||
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -113,12 +113,9 @@ apply_transform (CanvasItem *item)
|
||||
y = gtk_widget_get_allocated_height (item->label) / 2.0;
|
||||
item->r = sqrt (x*x + y*y);
|
||||
|
||||
transform = gsk_transform_translate (
|
||||
gsk_transform_rotate (
|
||||
gsk_transform_translate (NULL,
|
||||
&(graphene_point_t) { item->r, item->r }),
|
||||
item->angle + item->delta),
|
||||
&(graphene_point_t) { - x, - y });
|
||||
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
|
||||
transform = gsk_transform_rotate (transform, item->angle + item->delta);
|
||||
transform = gsk_transform_translate (transform, &(graphene_point_t) { -x, -y });
|
||||
|
||||
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
|
||||
gsk_transform_unref (transform);
|
||||
|
@@ -311,6 +311,7 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 250, -1);
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (close_window), NULL);
|
||||
@@ -325,9 +326,8 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
/*
|
||||
* Create the groups area
|
||||
*/
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Knockout groups</u>");
|
||||
label = gtk_label_new ("Knockout groups");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -344,9 +344,8 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
* Create the scribble area
|
||||
*/
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Scribble area</u>");
|
||||
label = gtk_label_new ("Scribble area");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
|
@@ -1,17 +1,16 @@
|
||||
/* Drop Downs
|
||||
/* Lists/Selections
|
||||
*
|
||||
* The GtkDropDown widget is a modern alternative to GtkComboBox.
|
||||
* It uses list models instead of tree models, and the content is
|
||||
* displayed using widgets instead of cell renderers.
|
||||
*
|
||||
* The examples here demonstrate how to use different kinds of
|
||||
* list models with GtkDropDown, how to use search and how to
|
||||
* display the selected item differently from the presentation
|
||||
* in the popup.
|
||||
* This example also shows a custom widget that can replace
|
||||
* GtkEntryCompletion or GtkComboBoxText. It is not currently
|
||||
* part of GTK.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "suggestionentry.h"
|
||||
|
||||
#define STRING_TYPE_HOLDER (string_holder_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (StringHolder, string_holder, STRING, HOLDER, GObject)
|
||||
@@ -65,18 +64,22 @@ strings_setup_item_single_line (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box, *image, *title;
|
||||
GtkWidget *checkmark;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
|
||||
image = gtk_image_new ();
|
||||
title = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
|
||||
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
|
||||
|
||||
gtk_box_append (GTK_BOX (box), image);
|
||||
gtk_box_append (GTK_BOX (box), title);
|
||||
gtk_box_append (GTK_BOX (box), checkmark);
|
||||
|
||||
g_object_set_data (G_OBJECT (item), "title", title);
|
||||
g_object_set_data (G_OBJECT (item), "image", image);
|
||||
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
|
||||
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
@@ -86,6 +89,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box, *box2, *image, *title, *description;
|
||||
GtkWidget *checkmark;
|
||||
|
||||
image = gtk_image_new ();
|
||||
title = gtk_label_new ("");
|
||||
@@ -93,6 +97,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
description = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (description), 0.0);
|
||||
gtk_widget_add_css_class (description, "dim-label");
|
||||
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
@@ -101,26 +106,48 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
gtk_box_append (GTK_BOX (box), box2);
|
||||
gtk_box_append (GTK_BOX (box2), title);
|
||||
gtk_box_append (GTK_BOX (box2), description);
|
||||
gtk_box_append (GTK_BOX (box), checkmark);
|
||||
|
||||
g_object_set_data (G_OBJECT (item), "title", title);
|
||||
g_object_set_data (G_OBJECT (item), "image", image);
|
||||
g_object_set_data (G_OBJECT (item), "description", description);
|
||||
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
|
||||
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
|
||||
static void
|
||||
strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
selected_item_changed (GtkDropDown *dropdown,
|
||||
GParamSpec *pspec,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *checkmark;
|
||||
|
||||
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
|
||||
|
||||
if (gtk_drop_down_get_selected_item (dropdown) == gtk_list_item_get_item (item))
|
||||
gtk_widget_set_opacity (checkmark, 1.0);
|
||||
else
|
||||
gtk_widget_set_opacity (checkmark, 0.0);
|
||||
}
|
||||
|
||||
static void
|
||||
strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkDropDown *dropdown = data;
|
||||
GtkWidget *image, *title, *description;
|
||||
GtkWidget *checkmark;
|
||||
StringHolder *holder;
|
||||
GtkWidget *popup;
|
||||
|
||||
holder = gtk_list_item_get_item (item);
|
||||
|
||||
title = g_object_get_data (G_OBJECT (item), "title");
|
||||
image = g_object_get_data (G_OBJECT (item), "image");
|
||||
description = g_object_get_data (G_OBJECT (item), "description");
|
||||
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (title), holder->title);
|
||||
if (image)
|
||||
@@ -133,19 +160,43 @@ strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
gtk_label_set_label (GTK_LABEL (description), holder->description);
|
||||
gtk_widget_set_visible (description , holder->description != NULL);
|
||||
}
|
||||
|
||||
popup = gtk_widget_get_ancestor (title, GTK_TYPE_POPOVER);
|
||||
if (popup && gtk_widget_is_ancestor (popup, GTK_WIDGET (dropdown)))
|
||||
{
|
||||
gtk_widget_show (checkmark);
|
||||
g_signal_connect (dropdown, "notify::selected-item",
|
||||
G_CALLBACK (selected_item_changed), item);
|
||||
selected_item_changed (dropdown, NULL, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (checkmark);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
strings_unbind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkDropDown *dropdown = data;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (dropdown, selected_item_changed, list_item);
|
||||
}
|
||||
|
||||
static GtkListItemFactory *
|
||||
strings_factory_new (gboolean full)
|
||||
strings_factory_new (gpointer data, gboolean full)
|
||||
{
|
||||
GtkListItemFactory *factory;
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
if (full)
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), NULL);
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), data);
|
||||
else
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), NULL);
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), data);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), data);
|
||||
g_signal_connect (factory, "unbind", G_CALLBACK (strings_unbind_item), data);
|
||||
|
||||
return factory;
|
||||
}
|
||||
@@ -186,19 +237,22 @@ drop_down_new_from_strings (const char *const *titles,
|
||||
g_return_val_if_fail (descriptions == NULL || g_strv_length ((char **)icons) == g_strv_length ((char **)descriptions), NULL);
|
||||
|
||||
model = strings_model_new (titles, icons, descriptions);
|
||||
factory = strings_factory_new (FALSE);
|
||||
widget = g_object_new (GTK_TYPE_DROP_DOWN,
|
||||
"model", model,
|
||||
NULL);
|
||||
g_object_unref (model);
|
||||
|
||||
factory = strings_factory_new (widget, FALSE);
|
||||
if (icons != NULL || descriptions != NULL)
|
||||
list_factory = strings_factory_new (TRUE);
|
||||
list_factory = strings_factory_new (widget, TRUE);
|
||||
else
|
||||
list_factory = NULL;
|
||||
|
||||
widget = g_object_new (GTK_TYPE_DROP_DOWN,
|
||||
"model", model,
|
||||
"factory", factory,
|
||||
"list-factory", list_factory,
|
||||
NULL);
|
||||
g_object_set (widget,
|
||||
"factory", factory,
|
||||
"list-factory", list_factory,
|
||||
NULL);
|
||||
|
||||
g_object_unref (model);
|
||||
g_object_unref (factory);
|
||||
if (list_factory)
|
||||
g_object_unref (list_factory);
|
||||
@@ -218,13 +272,110 @@ get_title (gpointer item)
|
||||
return g_strdup (STRING_HOLDER (item)->title);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_file_name (gpointer item)
|
||||
{
|
||||
return g_strdup (g_file_info_get_display_name (G_FILE_INFO (item)));
|
||||
}
|
||||
|
||||
static void
|
||||
setup_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box;
|
||||
GtkWidget *icon;
|
||||
GtkWidget *label;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
icon = gtk_image_new ();
|
||||
label = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_box_append (GTK_BOX (box), icon);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
MatchObject *match = MATCH_OBJECT (gtk_list_item_get_item (item));
|
||||
GFileInfo *info = G_FILE_INFO (match_object_get_item (match));
|
||||
GtkWidget *box = gtk_list_item_get_child (item);
|
||||
GtkWidget *icon = gtk_widget_get_first_child (box);
|
||||
GtkWidget *label = gtk_widget_get_last_child (box);
|
||||
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (icon), g_file_info_get_icon (info));
|
||||
gtk_label_set_label (GTK_LABEL (label), g_file_info_get_display_name (info));
|
||||
}
|
||||
|
||||
static void
|
||||
setup_highlight_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_list_item_set_child (item, label);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_highlight_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
MatchObject *obj;
|
||||
GtkWidget *label;
|
||||
PangoAttrList *attrs;
|
||||
PangoAttribute *attr;
|
||||
const char *str;
|
||||
|
||||
obj = MATCH_OBJECT (gtk_list_item_get_item (item));
|
||||
label = gtk_list_item_get_child (item);
|
||||
|
||||
str = match_object_get_string (obj);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (label), str);
|
||||
attrs = pango_attr_list_new ();
|
||||
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
|
||||
attr->start_index = match_object_get_match_start (obj);
|
||||
attr->end_index = match_object_get_match_end (obj);
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
gtk_label_set_attributes (GTK_LABEL (label), attrs);
|
||||
pango_attr_list_unref (attrs);
|
||||
}
|
||||
|
||||
static void
|
||||
match_func (MatchObject *obj,
|
||||
const char *search,
|
||||
gpointer user_data)
|
||||
{
|
||||
char *tmp1, *tmp2;
|
||||
char *p;
|
||||
|
||||
tmp1 = g_utf8_normalize (match_object_get_string (obj), -1, G_NORMALIZE_ALL);
|
||||
tmp2 = g_utf8_normalize (search, -1, G_NORMALIZE_ALL);
|
||||
|
||||
if ((p = strstr (tmp1, tmp2)) != NULL)
|
||||
match_object_set_match (obj,
|
||||
p - tmp1,
|
||||
(p - tmp1) + g_utf8_strlen (search, -1),
|
||||
1);
|
||||
else
|
||||
match_object_set_match (obj, 0, 0, 0);
|
||||
|
||||
g_free (tmp1);
|
||||
g_free (tmp2);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_dropdown (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *button, *box, *spin, *check;
|
||||
GtkWidget *button, *box, *spin, *check, *hbox, *label, *entry;
|
||||
GListModel *model;
|
||||
GtkExpression *expression;
|
||||
GtkListItemFactory *factory;
|
||||
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
|
||||
const char * const many_times[] = {
|
||||
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
|
||||
@@ -237,22 +388,49 @@ do_dropdown (GtkWidget *do_widget)
|
||||
const char * const device_descriptions[] = {
|
||||
"Built-in Audio", "Built-in audio", "Thinkpad Tunderbolt 3 Dock USB Audio", "Thinkpad Tunderbolt 3 Dock USB Audio", NULL
|
||||
};
|
||||
char *cwd;
|
||||
GFile *file;
|
||||
GListModel *dir;
|
||||
GtkStringList *strings;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Drop Downs");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Selections");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
|
||||
|
||||
gtk_widget_set_margin_start (hbox, 20);
|
||||
gtk_widget_set_margin_end (hbox, 20);
|
||||
gtk_widget_set_margin_top (hbox, 20);
|
||||
gtk_widget_set_margin_bottom (hbox, 20);
|
||||
gtk_window_set_child (GTK_WINDOW (window), hbox);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_widget_set_margin_start (box, 10);
|
||||
gtk_widget_set_margin_end (box, 10);
|
||||
gtk_widget_set_margin_top (box, 10);
|
||||
gtk_widget_set_margin_bottom (box, 10);
|
||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||
gtk_box_append (GTK_BOX (hbox), box);
|
||||
|
||||
label = gtk_label_new ("Dropdowns");
|
||||
gtk_widget_add_css_class (label, "title-4");
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
|
||||
/* A basic dropdown */
|
||||
button = drop_down_new_from_strings (times, NULL, NULL);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
/* A dropdown using an expression to obtain strings */
|
||||
button = drop_down_new_from_strings (many_times, NULL, NULL);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)get_title,
|
||||
NULL, NULL);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
|
||||
gtk_expression_unref (expression);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
button = gtk_drop_down_new (NULL, NULL);
|
||||
|
||||
@@ -270,30 +448,118 @@ do_dropdown (GtkWidget *do_widget)
|
||||
|
||||
spin = gtk_spin_button_new_with_range (-1, g_list_model_get_n_items (G_LIST_MODEL (model)), 1);
|
||||
gtk_widget_set_halign (spin, GTK_ALIGN_START);
|
||||
gtk_widget_set_margin_start (spin, 20);
|
||||
g_object_bind_property (button, "selected", spin, "value", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||
gtk_box_append (GTK_BOX (box), spin);
|
||||
|
||||
check = gtk_check_button_new_with_label ("Enable search");
|
||||
gtk_widget_set_margin_start (check, 20);
|
||||
g_object_bind_property (button, "enable-search", check, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||
gtk_box_append (GTK_BOX (box), check);
|
||||
|
||||
g_object_unref (model);
|
||||
|
||||
button = drop_down_new_from_strings (times, NULL, NULL);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
button = drop_down_new_from_strings (many_times, NULL, NULL);
|
||||
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)get_title,
|
||||
NULL, NULL);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
|
||||
gtk_expression_unref (expression);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
/* A dropdown with a separate list factory */
|
||||
button = drop_down_new_from_strings (device_titles, device_icons, device_descriptions);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
gtk_box_append (GTK_BOX (hbox), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_box_append (GTK_BOX (hbox), box);
|
||||
|
||||
label = gtk_label_new ("Suggestions");
|
||||
gtk_widget_add_css_class (label, "title-4");
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
|
||||
/* A basic suggestion entry */
|
||||
entry = suggestion_entry_new ();
|
||||
g_object_set (entry, "placeholder-text", "Words with T or G…", NULL);
|
||||
strings = gtk_string_list_new ((const char *[]){
|
||||
"GNOME",
|
||||
"gnominious",
|
||||
"Gnomonic projection",
|
||||
"total",
|
||||
"totally",
|
||||
"toto",
|
||||
"tottery",
|
||||
"totterer",
|
||||
"Totten trust",
|
||||
"totipotent",
|
||||
"totipotency",
|
||||
"totemism",
|
||||
"totem pole",
|
||||
"Totara",
|
||||
"totalizer",
|
||||
"totalizator",
|
||||
"totalitarianism",
|
||||
"total parenteral nutrition",
|
||||
"total hysterectomy",
|
||||
"total eclipse",
|
||||
"Totipresence",
|
||||
"Totipalmi",
|
||||
"Tomboy",
|
||||
"zombie",
|
||||
NULL});
|
||||
suggestion_entry_set_model (SUGGESTION_ENTRY (entry), G_LIST_MODEL (strings));
|
||||
g_object_unref (strings);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), entry);
|
||||
|
||||
/* A suggestion entry using a custom model, and no filtering */
|
||||
entry = suggestion_entry_new ();
|
||||
|
||||
cwd = g_get_current_dir ();
|
||||
file = g_file_new_for_path (cwd);
|
||||
dir = G_LIST_MODEL (gtk_directory_list_new ("standard::display-name,standard::content-type,standard::icon,standard::size", file));
|
||||
suggestion_entry_set_model (SUGGESTION_ENTRY (entry), dir);
|
||||
g_object_unref (dir);
|
||||
g_object_unref (file);
|
||||
g_free (cwd);
|
||||
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)get_file_name,
|
||||
NULL, NULL);
|
||||
suggestion_entry_set_expression (SUGGESTION_ENTRY (entry), expression);
|
||||
gtk_expression_unref (expression);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
|
||||
|
||||
suggestion_entry_set_factory (SUGGESTION_ENTRY (entry), factory);
|
||||
g_object_unref (factory);
|
||||
|
||||
suggestion_entry_set_use_filter (SUGGESTION_ENTRY (entry), FALSE);
|
||||
suggestion_entry_set_show_arrow (SUGGESTION_ENTRY (entry), TRUE);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), entry);
|
||||
|
||||
/* A suggestion entry with match highlighting */
|
||||
entry = suggestion_entry_new ();
|
||||
g_object_set (entry, "placeholder-text", "Destination", NULL);
|
||||
|
||||
strings = gtk_string_list_new ((const char *[]){
|
||||
"app-mockups",
|
||||
"settings-mockups",
|
||||
"os-mockups",
|
||||
"software-mockups",
|
||||
"mocktails",
|
||||
NULL});
|
||||
suggestion_entry_set_model (SUGGESTION_ENTRY (entry), G_LIST_MODEL (strings));
|
||||
g_object_unref (strings);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), entry);
|
||||
|
||||
suggestion_entry_set_match_func (SUGGESTION_ENTRY (entry), match_func, NULL, NULL);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_highlight_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_highlight_item), NULL);
|
||||
suggestion_entry_set_factory (SUGGESTION_ENTRY (entry), factory);
|
||||
g_object_unref (factory);
|
||||
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@@ -78,11 +78,11 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
|
@@ -27,16 +27,16 @@ do_entry_undo (GtkWidget *do_widget)
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"Use Primary+z or Primary+Shift+z to undo or redo changes");
|
||||
"Use Control+z or Control+Shift+z to undo or redo changes");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
/* Create our entry */
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Error states
|
||||
/* Error States
|
||||
*
|
||||
* GtkLabel and GtkEntry can indicate errors if you set the .error
|
||||
* style class on them.
|
||||
|
@@ -5,7 +5,7 @@
|
||||
<property name="modal">1</property>
|
||||
<property name="resizable">0</property>
|
||||
<property name="use-header-bar">1</property>
|
||||
<property name="title" translatable="yes">Settings</property>
|
||||
<property name="title" translatable="yes">Error States</property>
|
||||
<property name="hide-on-close">1</property>
|
||||
<child internal-child="content_area">
|
||||
<object class="GtkBox">
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.16"/>
|
||||
<object class="GtkListStore" id="liststore1">
|
||||
<columns>
|
||||
<column type="gint"/>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="default-width">600</property>
|
||||
<property name="default-height">500</property>
|
||||
|
@@ -1068,7 +1068,6 @@ update_font_variations (void)
|
||||
unsigned int length;
|
||||
int i;
|
||||
|
||||
child = gtk_widget_get_first_child (variations_grid);
|
||||
while ((child = gtk_widget_get_first_child (variations_grid)))
|
||||
gtk_grid_remove (GTK_GRID (variations_grid), child);
|
||||
|
||||
|
@@ -501,7 +501,7 @@ fontify (const char *format,
|
||||
char *theme;
|
||||
gboolean prefer_dark;
|
||||
const char *style_arg;
|
||||
const char *text;
|
||||
char *text;
|
||||
GtkTextIter start, end;
|
||||
GBytes *bytes;
|
||||
GError *error = NULL;
|
||||
@@ -553,7 +553,7 @@ fontify (const char *format,
|
||||
|
||||
gtk_text_buffer_get_bounds (source_buffer, &start, &end);
|
||||
text = gtk_text_buffer_get_text (source_buffer, &start, &end, TRUE);
|
||||
bytes = g_bytes_new_static (text, strlen (text));
|
||||
bytes = g_bytes_new_take (text, strlen (text));
|
||||
|
||||
#ifdef HAVE_GIO_UNIX
|
||||
/* Work around https://gitlab.gnome.org/GNOME/glib/-/issues/2182 */
|
||||
@@ -570,4 +570,5 @@ fontify (const char *format,
|
||||
NULL,
|
||||
fontify_finish,
|
||||
g_object_ref (source_buffer));
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Pango/Font rendering
|
||||
/* Pango/Font Rendering
|
||||
*
|
||||
* Demonstrates various aspects of font rendering.
|
||||
*/
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* OpenGL/Transitions
|
||||
/* OpenGL/Transitions and Effects
|
||||
* #Keywords: OpenGL, shader, effect
|
||||
*
|
||||
* Create transitions between pages using a custom fragment shader.
|
||||
@@ -282,11 +282,12 @@ create_gltransition_window (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Transitions");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Transitions and Effects");
|
||||
headerbar = gtk_header_bar_new ();
|
||||
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
||||
gtk_widget_set_size_request (scale, 100, -1);
|
||||
gtk_widget_set_tooltip_text (scale, "Transition duration");
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
|
||||
|
@@ -179,6 +179,9 @@ gtk_fishbowl_add (GtkFishbowl *fishbowl,
|
||||
child_info->dy = new_speed ();
|
||||
|
||||
gtk_widget_set_parent (widget, GTK_WIDGET (fishbowl));
|
||||
gtk_accessible_update_state (GTK_ACCESSIBLE (widget),
|
||||
GTK_ACCESSIBLE_STATE_HIDDEN, TRUE,
|
||||
-1);
|
||||
|
||||
g_hash_table_insert (priv->children, widget, child_info);
|
||||
priv->count++;
|
||||
@@ -342,6 +345,8 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_PRESENTATION);
|
||||
}
|
||||
|
||||
guint
|
||||
|
@@ -13,7 +13,7 @@ static GtkWidget *window = NULL;
|
||||
static GtkWidget *scrolledwindow;
|
||||
static int selected;
|
||||
|
||||
#define N_WIDGET_TYPES 6
|
||||
#define N_WIDGET_TYPES 7
|
||||
|
||||
|
||||
static int hincrement = 5;
|
||||
@@ -177,6 +177,24 @@ populate_grid (void)
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
|
||||
}
|
||||
|
||||
extern GtkWidget *create_ucd_view (GtkWidget *label);
|
||||
|
||||
static void
|
||||
populate_list2 (void)
|
||||
{
|
||||
GtkWidget *list;
|
||||
|
||||
list = create_ucd_view (NULL);
|
||||
|
||||
hincrement = 0;
|
||||
vincrement = 5;
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
|
||||
}
|
||||
|
||||
static void
|
||||
set_widget_type (int type)
|
||||
{
|
||||
@@ -216,6 +234,11 @@ set_widget_type (int type)
|
||||
break;
|
||||
|
||||
case 5:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a columned list");
|
||||
populate_list2 ();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
|
||||
populate_grid ();
|
||||
break;
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include <glib/gstdio.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "pixbufpaintable.h"
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GdkPixbufLoader *pixbuf_loader = NULL;
|
||||
@@ -56,6 +57,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
picture = GTK_WIDGET (data);
|
||||
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), NULL);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
}
|
||||
|
||||
@@ -262,7 +264,7 @@ start_progressive_loading (GtkWidget *picture)
|
||||
* The timeout simply simulates a slow data source by inserting
|
||||
* pauses in the reading process.
|
||||
*/
|
||||
load_timeout = g_timeout_add (1500, progressive_timeout, picture);
|
||||
load_timeout = g_timeout_add (300, progressive_timeout, picture);
|
||||
g_source_set_name_by_id (load_timeout, "[gtk] progressive_timeout");
|
||||
}
|
||||
|
||||
@@ -345,9 +347,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Image loaded from a file</u>");
|
||||
label = gtk_label_new ("Image from a resource");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -355,7 +356,7 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
image = gtk_image_new_from_icon_name ("gtk3-demo");
|
||||
image = gtk_image_new_from_resource ("/images/org.gtk.Demo4.svg");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
|
||||
gtk_frame_set_child (GTK_FRAME (frame), image);
|
||||
@@ -363,9 +364,8 @@ do_images (GtkWidget *do_widget)
|
||||
|
||||
/* Animation */
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Animation loaded from a file</u>");
|
||||
label = gtk_label_new ("Animation from a resource");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -373,15 +373,16 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");
|
||||
paintable = pixbuf_paintable_new_from_resource ("/images/floppybuddy.gif");
|
||||
picture = gtk_picture_new_for_paintable (paintable);
|
||||
g_object_unref (paintable);
|
||||
|
||||
gtk_frame_set_child (GTK_FRAME (frame), picture);
|
||||
|
||||
/* Symbolic icon */
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Symbolic themed icon</u>");
|
||||
label = gtk_label_new ("Symbolic themed icon");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -400,9 +401,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Progressive image loading</u>");
|
||||
label = gtk_label_new ("Progressive image loading");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -414,6 +414,7 @@ do_images (GtkWidget *do_widget)
|
||||
* will create the pixbuf and fill it in.
|
||||
*/
|
||||
picture = gtk_picture_new ();
|
||||
gtk_picture_set_alternative_text (GTK_PICTURE (picture), "A slowly loading image");
|
||||
gtk_frame_set_child (GTK_FRAME (frame), picture);
|
||||
|
||||
start_progressive_loading (picture);
|
||||
@@ -422,9 +423,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Displaying video</u>");
|
||||
label = gtk_label_new ("Displaying video");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -440,9 +440,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>GtkWidgetPaintable</u>");
|
||||
label = gtk_label_new ("GtkWidgetPaintable");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
paintable = gtk_widget_paintable_new (do_widget);
|
||||
|
@@ -34,7 +34,7 @@ do_layoutmanager (GtkWidget *parent)
|
||||
int i;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager—Transition");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transition");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
@@ -170,7 +170,7 @@ do_layoutmanager2 (GtkWidget *parent)
|
||||
int i;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager—Transformation");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transformation");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 620);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* List Box/Complex list
|
||||
/* List Box/Complex
|
||||
*
|
||||
* GtkListBox allows lists with complicated layouts, using
|
||||
* regular widgets supporting sorting and filtering.
|
||||
@@ -197,7 +197,7 @@ gtk_message_row_update (GtkMessageRow *row)
|
||||
|
||||
if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0)
|
||||
{
|
||||
gtk_image_set_from_icon_name (priv->avatar_image, "gtk3-demo");
|
||||
gtk_image_set_from_icon_name (priv->avatar_image, "org.gtk.Demo4");
|
||||
gtk_image_set_icon_size (priv->avatar_image, GTK_ICON_SIZE_LARGE);
|
||||
}
|
||||
else
|
||||
@@ -349,7 +349,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box — Complex");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
@@ -34,7 +34,7 @@ row_activated (GtkListBox *list,
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listbox2 (GtkWidget *do_widget)
|
||||
do_listbox_controls (GtkWidget *do_widget)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ do_listbox2 (GtkWidget *do_widget)
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
|
||||
gtk_builder_add_from_resource (builder, "/listbox2/listbox2.ui", NULL);
|
||||
gtk_builder_add_from_resource (builder, "/listbox_controls/listbox_controls.ui", NULL);
|
||||
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
@@ -80,7 +80,7 @@ ucd_model_new (void)
|
||||
iter = g_variant_iter_new (v);
|
||||
|
||||
store = g_list_store_new (G_TYPE_OBJECT);
|
||||
while (g_variant_iter_next (iter, "(us)", &u, &name))
|
||||
while (g_variant_iter_next (iter, "(u&s)", &u, &name))
|
||||
{
|
||||
if (u == 0)
|
||||
continue;
|
||||
@@ -259,7 +259,7 @@ selection_changed (GObject *object,
|
||||
gtk_label_set_label (GTK_LABEL (label), buffer);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
GtkWidget *
|
||||
create_ucd_view (GtkWidget *label)
|
||||
{
|
||||
GtkWidget *cv;
|
||||
@@ -273,7 +273,8 @@ create_ucd_view (GtkWidget *label)
|
||||
selection = gtk_single_selection_new (ucd_model);
|
||||
gtk_single_selection_set_autoselect (selection, TRUE);
|
||||
gtk_single_selection_set_can_unselect (selection, FALSE);
|
||||
g_signal_connect (selection, "notify::selected", G_CALLBACK (selection_changed), label);
|
||||
if (label)
|
||||
g_signal_connect (selection, "notify::selected", G_CALLBACK (selection_changed), label);
|
||||
|
||||
cv = gtk_column_view_new (GTK_SELECTION_MODEL (selection));
|
||||
gtk_column_view_set_show_column_separators (GTK_COLUMN_VIEW (cv), TRUE);
|
||||
@@ -283,12 +284,14 @@ create_ucd_view (GtkWidget *label)
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_codepoint), NULL);
|
||||
column = gtk_column_view_column_new ("Codepoint", factory);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
g_object_unref (column);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_centered_label), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_char), NULL);
|
||||
column = gtk_column_view_column_new ("Char", factory);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
g_object_unref (column);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
|
||||
@@ -296,6 +299,7 @@ create_ucd_view (GtkWidget *label)
|
||||
column = gtk_column_view_column_new ("Name", factory);
|
||||
gtk_column_view_column_set_resizable (column, TRUE);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
g_object_unref (column);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
|
||||
@@ -303,6 +307,7 @@ create_ucd_view (GtkWidget *label)
|
||||
column = gtk_column_view_column_new ("Type", factory);
|
||||
gtk_column_view_column_set_resizable (column, TRUE);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
g_object_unref (column);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
|
||||
@@ -310,6 +315,7 @@ create_ucd_view (GtkWidget *label)
|
||||
column = gtk_column_view_column_new ("Break Type", factory);
|
||||
gtk_column_view_column_set_resizable (column, TRUE);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
g_object_unref (column);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
|
||||
@@ -317,6 +323,7 @@ create_ucd_view (GtkWidget *label)
|
||||
column = gtk_column_view_column_new ("Combining Class", factory);
|
||||
gtk_column_view_column_set_resizable (column, TRUE);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
g_object_unref (column);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
|
||||
@@ -324,6 +331,7 @@ create_ucd_view (GtkWidget *label)
|
||||
column = gtk_column_view_column_new ("Script", factory);
|
||||
gtk_column_view_column_set_resizable (column, TRUE);
|
||||
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
|
||||
g_object_unref (column);
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
@@ -337,8 +337,8 @@ display_text (const char *format,
|
||||
|
||||
bytes = g_resources_lookup_data (resource, 0, NULL);
|
||||
g_assert (bytes);
|
||||
|
||||
g_assert (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL));
|
||||
text = g_bytes_get_data (bytes, &len);
|
||||
g_assert (g_utf8_validate (text, len, NULL));
|
||||
|
||||
textview = gtk_text_view_new ();
|
||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview), 20);
|
||||
@@ -354,9 +354,8 @@ display_text (const char *format,
|
||||
gtk_text_view_set_monospace (GTK_TEXT_VIEW (textview), TRUE);
|
||||
|
||||
buffer = gtk_text_buffer_new (NULL);
|
||||
|
||||
text = g_bytes_unref_to_data (bytes, &len);
|
||||
gtk_text_buffer_set_text (buffer, text, len);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
if (format)
|
||||
fontify (format, buffer);
|
||||
|
@@ -17,9 +17,6 @@
|
||||
</section>
|
||||
</menu>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
</style>
|
||||
<property name="default-width">800</property>
|
||||
<property name="default-height">600</property>
|
||||
<child type="titlebar">
|
||||
@@ -28,14 +25,7 @@
|
||||
<object class="GtkButton">
|
||||
<property name="valign">center</property>
|
||||
<property name="action-name">win.run</property>
|
||||
<style>
|
||||
<class name="text-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="yes">Run</property>
|
||||
</object>
|
||||
</child>
|
||||
<property name="label" translatable="yes">Run</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
@@ -43,6 +33,9 @@
|
||||
<property name="valign">center</property>
|
||||
<property name="menu-model">gear_menu</property>
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Primary menu</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -51,6 +44,9 @@
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<property name="width-request">120</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="min-content-width">150</property>
|
||||
@@ -63,7 +59,11 @@
|
||||
<object class="GtkSearchBar" id="searchbar">
|
||||
<property name="key-capture-widget">window</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search-entry"/>
|
||||
<object class="GtkSearchEntry" id="search-entry">
|
||||
<accessibility>
|
||||
<relation name="controls">listview</relation>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
@@ -78,6 +78,10 @@
|
||||
<property name="resource">/ui/main-listitem.ui</property>
|
||||
</object>
|
||||
</property>
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Demo list</property>
|
||||
<relation name="controls">notebook</relation>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
@@ -85,9 +89,6 @@
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkNotebook" id="notebook">
|
||||
<property name="scrollable">1</property>
|
||||
@@ -112,6 +113,10 @@
|
||||
<property name="editable">0</property>
|
||||
<property name="wrap-mode">word</property>
|
||||
<property name="cursor-visible">0</property>
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Info</property>
|
||||
<property name="description" translatable="yes">A description of the demo</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -142,6 +147,10 @@
|
||||
<property name="wrap-mode">word</property>
|
||||
<property name="pixels-above-lines">2</property>
|
||||
<property name="pixels-below-lines">2</property>
|
||||
<accessibility>
|
||||
<property name="label" translatable="yes">Source</property>
|
||||
<property name="description" translatable="yes">The source code of the demo</property>
|
||||
</accessibility>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@@ -7,8 +7,9 @@ demos = files([
|
||||
'clipboard.c',
|
||||
'combobox.c',
|
||||
'constraints.c',
|
||||
'constraints2.c',
|
||||
'constraints3.c',
|
||||
'constraints_interactive.c',
|
||||
'constraints_vfl.c',
|
||||
'constraints_builder.c',
|
||||
'css_accordion.c',
|
||||
'css_basics.c',
|
||||
'css_blendmodes.c',
|
||||
@@ -18,7 +19,6 @@ demos = files([
|
||||
'cursors.c',
|
||||
'dialog.c',
|
||||
'drawingarea.c',
|
||||
'dropdown.c',
|
||||
'dnd.c',
|
||||
'editable_cells.c',
|
||||
'entry_completion.c',
|
||||
@@ -44,7 +44,7 @@ demos = files([
|
||||
'layoutmanager2.c',
|
||||
'links.c',
|
||||
'listbox.c',
|
||||
'listbox2.c',
|
||||
'listbox_controls.c',
|
||||
'menu.c',
|
||||
'flowbox.c',
|
||||
'list_store.c',
|
||||
@@ -53,12 +53,14 @@ demos = files([
|
||||
'listview_colors.c',
|
||||
'listview_filebrowser.c',
|
||||
'listview_minesweeper.c',
|
||||
'dropdown.c',
|
||||
'listview_settings.c',
|
||||
'listview_ucd.c',
|
||||
'listview_weather.c',
|
||||
'listview_words.c',
|
||||
'markup.c',
|
||||
'overlay.c',
|
||||
'overlay2.c',
|
||||
'overlay_decorative.c',
|
||||
'paint.c',
|
||||
'paintable.c',
|
||||
'paintable_animated.c',
|
||||
@@ -66,6 +68,9 @@ demos = files([
|
||||
'paintable_mediastream.c',
|
||||
'panes.c',
|
||||
'password_entry.c',
|
||||
'path_fill.c',
|
||||
'path_maze.c',
|
||||
'path_text.c',
|
||||
'peg_solitaire.c',
|
||||
'pickers.c',
|
||||
'printing.c',
|
||||
@@ -118,11 +123,15 @@ extra_demo_sources = files(['main.c',
|
||||
'singular_value_decomposition.c',
|
||||
'four_point_transform.c',
|
||||
'demo2widget.c',
|
||||
'demo3widget.c'])
|
||||
'demo3widget.c',
|
||||
'pixbufpaintable.c',
|
||||
'script-names.c',
|
||||
'unicode-names.c',
|
||||
'suggestionentry.c'])
|
||||
|
||||
if harfbuzz_dep.found() and pangoft_dep.found()
|
||||
demos += files(['font_features.c', 'listview_ucd.c'])
|
||||
extra_demo_sources += files(['script-names.c', 'language-names.c', 'unicode-names.c'])
|
||||
demos += files(['font_features.c'])
|
||||
extra_demo_sources += files(['language-names.c'])
|
||||
gtkdemo_deps += [ harfbuzz_dep, epoxy_dep ]
|
||||
endif
|
||||
|
||||
@@ -134,6 +143,7 @@ librsvg_dep = dependency('librsvg-2.0', version: '>= 2.46.0', required: false)
|
||||
|
||||
if librsvg_dep.found()
|
||||
demos += files('paintable_svg.c')
|
||||
extra_demo_sources += files(['svgpaintable.c'])
|
||||
gtkdemo_deps += [ librsvg_dep ]
|
||||
endif
|
||||
|
||||
|
@@ -21,7 +21,7 @@ margin_changed (GtkAdjustment *adjustment,
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_overlay2 (GtkWidget *do_widget)
|
||||
do_overlay_decorative (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Paintable/A simple paintable
|
||||
/* Paintable/Simple Paintable
|
||||
*
|
||||
* GdkPaintable is an interface used by GTK for drawings of any sort
|
||||
* that do not require layouting or positioning.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Paintable/An animated paintable
|
||||
/* Paintable/Animated Paintable
|
||||
*
|
||||
* GdkPaintable also allows paintables to change.
|
||||
*
|
||||
|
@@ -153,7 +153,7 @@ do_paintable_emblem (GtkWidget *do_widget)
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Emblems");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paintable — Emblems");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Paintable/A media stream
|
||||
/* Paintable/Media Stream
|
||||
*
|
||||
* GdkPaintable is also used by the GtkMediaStream class.
|
||||
*
|
||||
|
@@ -9,183 +9,20 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <librsvg/rsvg.h>
|
||||
|
||||
#define SVG_TYPE_PAINTABLE (svg_paintable_get_type ())
|
||||
#include "svgpaintable.h"
|
||||
|
||||
G_DECLARE_FINAL_TYPE (SvgPaintable, svg_paintable, SVG, PAINTABLE, GObject)
|
||||
|
||||
struct _SvgPaintable
|
||||
{
|
||||
GObject parent_instance;
|
||||
GFile *file;
|
||||
RsvgHandle *handle;
|
||||
};
|
||||
|
||||
struct _SvgPaintableClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_FILE = 1,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static void
|
||||
svg_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
cairo_t *cr;
|
||||
GError *error = NULL;
|
||||
|
||||
cr = gtk_snapshot_append_cairo (GTK_SNAPSHOT (snapshot),
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
|
||||
if (!rsvg_handle_render_document (self->handle, cr,
|
||||
&(RsvgRectangle) {0, 0, width, height},
|
||||
&error))
|
||||
{
|
||||
g_error ("%s", error->message);
|
||||
}
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
static int
|
||||
svg_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
RsvgDimensionData data;
|
||||
|
||||
rsvg_handle_get_dimensions (self->handle, &data);
|
||||
|
||||
return data.width;
|
||||
}
|
||||
|
||||
static int
|
||||
svg_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
RsvgDimensionData data;
|
||||
|
||||
rsvg_handle_get_dimensions (self->handle, &data);
|
||||
|
||||
return data.height;
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_init_interface (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->snapshot = svg_paintable_snapshot;
|
||||
iface->get_intrinsic_width = svg_paintable_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = svg_paintable_get_intrinsic_height;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (SvgPaintable, svg_paintable, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
svg_paintable_init_interface))
|
||||
|
||||
static void
|
||||
svg_paintable_init (SvgPaintable *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_dispose (GObject *object)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (object);
|
||||
|
||||
g_clear_object (&self->file);
|
||||
g_clear_object (&self->handle);
|
||||
|
||||
G_OBJECT_CLASS (svg_paintable_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FILE:
|
||||
{
|
||||
GFile *file = g_value_get_object (value);
|
||||
RsvgHandle *handle = rsvg_handle_new_from_gfile_sync (file,
|
||||
RSVG_HANDLE_FLAGS_NONE,
|
||||
NULL,
|
||||
NULL);
|
||||
rsvg_handle_set_dpi (handle, 90);
|
||||
|
||||
g_set_object (&self->file, file);
|
||||
g_set_object (&self->handle, handle);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FILE:
|
||||
g_value_set_object (value, self->file);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
svg_paintable_class_init (SvgPaintableClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->dispose = svg_paintable_dispose;
|
||||
object_class->set_property = svg_paintable_set_property;
|
||||
object_class->get_property = svg_paintable_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILE,
|
||||
g_param_spec_object ("file", "File", "File",
|
||||
G_TYPE_FILE,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static SvgPaintable *
|
||||
svg_paintable_new (GFile *file)
|
||||
{
|
||||
return g_object_new (SVG_TYPE_PAINTABLE,
|
||||
"file", file,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
file_set (GtkFileChooserButton *button,
|
||||
GtkWidget *picture)
|
||||
{
|
||||
GFile *file;
|
||||
SvgPaintable *paintable;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
|
||||
|
||||
paintable = svg_paintable_new (file);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (paintable));
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
|
||||
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (file);
|
||||
@@ -201,14 +38,15 @@ do_paintable_svg (GtkWidget *do_widget)
|
||||
GtkFileFilter *filter;
|
||||
GtkWidget *button;
|
||||
GFile *file;
|
||||
SvgPaintable *paintable;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 330, 330);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paintable — SVG");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
button = gtk_file_chooser_button_new ("Select an SVG file", GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
@@ -227,7 +65,7 @@ do_paintable_svg (GtkWidget *do_widget)
|
||||
|
||||
file = g_file_new_for_uri ("resource:///paintable_svg/org.gtk.gtk4.NodeEditor.Devel.svg");
|
||||
paintable = svg_paintable_new (file);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (paintable));
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
@@ -3,100 +3,16 @@
|
||||
* The GtkPaned Widget divides its content area into two panes
|
||||
* with a divider in between that the user can adjust. A separate
|
||||
* child is placed into each pane. GtkPaned widgets can be split
|
||||
* horizontally or vertially.
|
||||
* horizontally or vertically. This test contains both a horizontal
|
||||
* and a vertical GtkPaned widget.
|
||||
*
|
||||
* There are a number of options that can be set for each pane.
|
||||
* This test contains both a horizontal and a vertical GtkPaned
|
||||
* widget, and allows you to adjust the options for each side of
|
||||
* each widget.
|
||||
* You can use the Inspector to adjust the options for each side
|
||||
* of each widget.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
toggle_resize (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkPaned *paned;
|
||||
|
||||
parent = gtk_widget_get_parent (child);
|
||||
paned = GTK_PANED (parent);
|
||||
|
||||
if (child == gtk_paned_get_start_child (paned))
|
||||
gtk_paned_set_resize_start_child (paned, !gtk_paned_get_resize_start_child (paned));
|
||||
else
|
||||
gtk_paned_set_resize_end_child (paned, !gtk_paned_get_resize_end_child (paned));
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_shrink (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkPaned *paned;
|
||||
|
||||
parent = gtk_widget_get_parent (child);
|
||||
paned = GTK_PANED (parent);
|
||||
|
||||
if (child == gtk_paned_get_start_child (paned))
|
||||
gtk_paned_set_shrink_start_child (paned, !gtk_paned_get_shrink_start_child (paned));
|
||||
else
|
||||
gtk_paned_set_shrink_end_child (paned, !gtk_paned_get_shrink_end_child (paned));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_pane_options (GtkPaned *paned,
|
||||
const char *frame_label,
|
||||
const char *label1,
|
||||
const char *label2)
|
||||
{
|
||||
GtkWidget *child1, *child2;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkWidget *check_button;
|
||||
|
||||
child1 = gtk_paned_get_start_child (paned);
|
||||
child2 = gtk_paned_get_end_child (paned);
|
||||
|
||||
frame = gtk_frame_new (frame_label);
|
||||
|
||||
table = gtk_grid_new ();
|
||||
gtk_frame_set_child (GTK_FRAME (frame), table);
|
||||
|
||||
label = gtk_label_new (label1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 1, 1, 1);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child1);
|
||||
|
||||
label = gtk_label_new (label2);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 1, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child2);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child2);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_panes (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -104,19 +20,19 @@ do_panes (GtkWidget *do_widget)
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hpaned;
|
||||
GtkWidget *vpaned;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *box;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 330, 250);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
@@ -132,41 +48,37 @@ do_panes (GtkWidget *do_widget)
|
||||
|
||||
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_paned_set_start_child (GTK_PANED (vpaned), hpaned);
|
||||
gtk_paned_set_shrink_start_child (GTK_PANED (vpaned), FALSE);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 60, 60);
|
||||
gtk_paned_set_start_child (GTK_PANED (hpaned), box);
|
||||
label = gtk_label_new ("Hi there");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_start_child (GTK_PANED (hpaned), label);
|
||||
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Hi there");
|
||||
gtk_widget_set_margin_start (button, 4);
|
||||
gtk_widget_set_margin_end (button, 4);
|
||||
gtk_widget_set_margin_top (button, 4);
|
||||
gtk_widget_set_margin_bottom (button, 4);
|
||||
gtk_widget_set_hexpand (button, TRUE);
|
||||
gtk_widget_set_vexpand (button, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
label = gtk_label_new ("Hello");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_end_child (GTK_PANED (hpaned), label);
|
||||
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 80, 60);
|
||||
gtk_paned_set_end_child (GTK_PANED (hpaned), box);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 60, 80);
|
||||
gtk_paned_set_end_child (GTK_PANED (vpaned), box);
|
||||
|
||||
/* Now create toggle buttons to control sizing */
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
create_pane_options (GTK_PANED (hpaned),
|
||||
"Horizontal",
|
||||
"Left",
|
||||
"Right"));
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
create_pane_options (GTK_PANED (vpaned),
|
||||
"Vertical",
|
||||
"Top",
|
||||
"Bottom"));
|
||||
label = gtk_label_new ("Goodbye");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_end_child (GTK_PANED (vpaned), label);
|
||||
gtk_paned_set_shrink_end_child (GTK_PANED (vpaned), FALSE);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
303
demos/gtk-demo/path_fill.c
Normal file
@@ -0,0 +1,303 @@
|
||||
/* Path/Fill
|
||||
*
|
||||
* This demo shows how to use PangoCairo to draw text with more than
|
||||
* just a single color.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "paintable.h"
|
||||
|
||||
#define GTK_TYPE_PATH_PAINTABLE (gtk_path_paintable_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkPathPaintable, gtk_path_paintable, GTK, PATH_PAINTABLE, GObject)
|
||||
|
||||
struct _GtkPathPaintable
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
GskPath *path;
|
||||
GdkPaintable *background;
|
||||
};
|
||||
|
||||
struct _GtkPathPaintableClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
static int
|
||||
gtk_path_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
if (self->background)
|
||||
return MAX (gdk_paintable_get_intrinsic_width (self->background), self->width);
|
||||
else
|
||||
return self->width;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_path_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
if (self->background)
|
||||
return MAX (gdk_paintable_get_intrinsic_height (self->background), self->height);
|
||||
else
|
||||
return self->height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
#if 0
|
||||
gtk_snapshot_push_fill (snapshot, self->path, GSK_FILL_RULE_WINDING);
|
||||
#else
|
||||
GskStroke *stroke = gsk_stroke_new (4.0);
|
||||
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
#endif
|
||||
|
||||
if (self->background)
|
||||
{
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_snapshot_append_linear_gradient (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (0, 0),
|
||||
&GRAPHENE_POINT_INIT (width, height),
|
||||
(GskColorStop[8]) {
|
||||
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
|
||||
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
|
||||
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
|
||||
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
|
||||
},
|
||||
8);
|
||||
}
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
}
|
||||
|
||||
static GdkPaintableFlags
|
||||
gtk_path_paintable_get_flags (GdkPaintable *paintable)
|
||||
{
|
||||
GtkPathPaintable *self = GTK_PATH_PAINTABLE (paintable);
|
||||
|
||||
if (self->background)
|
||||
return gdk_paintable_get_flags (self->background);
|
||||
else
|
||||
return GDK_PAINTABLE_STATIC_CONTENTS | GDK_PAINTABLE_STATIC_SIZE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_paintable_paintable_init (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->get_intrinsic_width = gtk_path_paintable_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = gtk_path_paintable_get_intrinsic_height;
|
||||
iface->snapshot = gtk_path_paintable_snapshot;
|
||||
iface->get_flags = gtk_path_paintable_get_flags;
|
||||
}
|
||||
|
||||
/* When defining the GType, we need to implement the GdkPaintable interface */
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkPathPaintable, gtk_path_paintable, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
gtk_path_paintable_paintable_init))
|
||||
|
||||
/* Here's the boilerplate for the GObject declaration.
|
||||
* We don't need to do anything special here, because we keep no
|
||||
* data of our own.
|
||||
*/
|
||||
static void
|
||||
gtk_path_paintable_class_init (GtkPathPaintableClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_paintable_init (GtkPathPaintable *self)
|
||||
{
|
||||
}
|
||||
|
||||
/* And finally, we add a simple constructor.
|
||||
* It is declared in the header so that the other examples
|
||||
* can use it.
|
||||
*/
|
||||
GdkPaintable *
|
||||
gtk_path_paintable_new (GskPath *path,
|
||||
GdkPaintable *background,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GtkPathPaintable *self;
|
||||
|
||||
self = g_object_new (GTK_TYPE_PATH_PAINTABLE, NULL);
|
||||
self->path = path;
|
||||
self->background = background;
|
||||
if (self->background)
|
||||
{
|
||||
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gdk_paintable_invalidate_contents), self);
|
||||
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gdk_paintable_invalidate_size), self);
|
||||
}
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
|
||||
return GDK_PAINTABLE (self);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_path_paintable_set_path (GtkPathPaintable *self,
|
||||
GskPath *path)
|
||||
{
|
||||
g_clear_pointer (&self->path, gsk_path_unref);
|
||||
self->path = gsk_path_ref (path);
|
||||
|
||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
create_hexagon (GtkWidget *widget)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
|
||||
gsk_path_builder_move_to (builder, 120, 0);
|
||||
gsk_path_builder_line_to (builder, 360, 0);
|
||||
gsk_path_builder_line_to (builder, 480, 208);
|
||||
gsk_path_builder_line_to (builder, 360, 416);
|
||||
gsk_path_builder_line_to (builder, 120, 416);
|
||||
gsk_path_builder_line_to (builder, 0, 208);
|
||||
gsk_path_builder_close (builder);
|
||||
|
||||
return gsk_path_builder_free_to_path (builder);
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
create_path_from_text (GtkWidget *widget)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
cairo_path_t *path;
|
||||
PangoLayout *layout;
|
||||
PangoFontDescription *desc;
|
||||
GskPath *result;
|
||||
|
||||
surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, "Pango power!\nPango power!\nPango power!");
|
||||
desc = pango_font_description_from_string ("sans bold 36");
|
||||
pango_layout_set_font_description (layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
pango_cairo_layout_path (cr, layout);
|
||||
path = cairo_copy_path_flat (cr);
|
||||
result = gsk_path_new_from_cairo (path);
|
||||
|
||||
cairo_path_destroy (path);
|
||||
g_object_unref (layout);
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_path (GtkWidget *widget,
|
||||
GdkFrameClock *frame_clock,
|
||||
gpointer measure)
|
||||
{
|
||||
float progress = gdk_frame_clock_get_frame_time (frame_clock) % (60 * G_USEC_PER_SEC) / (float) (30 * G_USEC_PER_SEC);
|
||||
GskPathBuilder *builder;
|
||||
GskPath *path;
|
||||
graphene_point_t pos;
|
||||
graphene_vec2_t tangent;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
gsk_path_measure_add_segment (measure,
|
||||
builder,
|
||||
progress > 1 ? (progress - 1) * gsk_path_measure_get_length (measure) : 0.0,
|
||||
(progress < 1 ? progress : 1.0) * gsk_path_measure_get_length (measure));
|
||||
|
||||
gsk_path_measure_get_point (measure,
|
||||
(progress > 1 ? (progress - 1) : progress) * gsk_path_measure_get_length (measure),
|
||||
&pos,
|
||||
&tangent);
|
||||
gsk_path_builder_move_to (builder, pos.x + 5 * graphene_vec2_get_x (&tangent), pos.y + 5 * graphene_vec2_get_y (&tangent));
|
||||
gsk_path_builder_line_to (builder, pos.x + 3 * graphene_vec2_get_y (&tangent), pos.y + 3 * graphene_vec2_get_x (&tangent));
|
||||
gsk_path_builder_line_to (builder, pos.x - 3 * graphene_vec2_get_y (&tangent), pos.y - 3 * graphene_vec2_get_x (&tangent));
|
||||
gsk_path_builder_close (builder);
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
gtk_path_paintable_set_path (GTK_PATH_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget))),
|
||||
path);
|
||||
gsk_path_unref (path);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_path_fill (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
GdkPaintable *paintable;
|
||||
GtkMediaStream *stream;
|
||||
GskPath *path;
|
||||
graphene_rect_t bounds;
|
||||
GskPathMeasure *measure;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Path Fill");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
#if 0
|
||||
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||
#else
|
||||
stream = gtk_nuclear_media_stream_new ();
|
||||
#endif
|
||||
gtk_media_stream_play (stream);
|
||||
gtk_media_stream_set_loop (stream, TRUE);
|
||||
|
||||
path = create_hexagon (window);
|
||||
path = create_path_from_text (window);
|
||||
gsk_path_get_bounds (path, &bounds);
|
||||
|
||||
paintable = gtk_path_paintable_new (path,
|
||||
GDK_PAINTABLE (stream),
|
||||
bounds.origin.x + bounds.size.width,
|
||||
bounds.origin.y + bounds.size.height);
|
||||
picture = gtk_picture_new_for_paintable (paintable);
|
||||
measure = gsk_path_measure_new (path);
|
||||
gtk_widget_add_tick_callback (picture, update_path, measure, (GDestroyNotify) gsk_path_measure_unref);
|
||||
gtk_picture_set_keep_aspect_ratio (GTK_PICTURE (picture), FALSE);
|
||||
gtk_picture_set_can_shrink (GTK_PICTURE (picture), FALSE);
|
||||
g_object_unref (paintable);
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), picture);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
338
demos/gtk-demo/path_maze.c
Normal file
@@ -0,0 +1,338 @@
|
||||
/* Path/Maze
|
||||
*
|
||||
* This demo shows how to use a GskPath to create a maze and use
|
||||
* gsk_path_measure_get_closest_point() to check the mouse stays
|
||||
* on the path.
|
||||
*
|
||||
* It also shows off the performance of GskPath (or not) as this
|
||||
* is a rather complex path.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "paintable.h"
|
||||
|
||||
#define MAZE_GRID_SIZE 20
|
||||
#define MAZE_STROKE_SIZE_ACTIVE (MAZE_GRID_SIZE - 4)
|
||||
#define MAZE_STROKE_SIZE_INACTIVE (MAZE_GRID_SIZE - 12)
|
||||
#define MAZE_WIDTH 31
|
||||
#define MAZE_HEIGHT 21
|
||||
|
||||
#define GTK_TYPE_MAZE (gtk_maze_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkMaze, gtk_maze, GTK, MAZE, GtkWidget)
|
||||
|
||||
struct _GtkMaze
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
GskPath *path;
|
||||
GskPathMeasure *measure;
|
||||
GdkPaintable *background;
|
||||
|
||||
gboolean active;
|
||||
};
|
||||
|
||||
struct _GtkMazeClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkMaze, gtk_maze, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_maze_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum,
|
||||
int *natural,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkMaze *self = GTK_MAZE (widget);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
*minimum = *natural = self->width;
|
||||
else
|
||||
*minimum = *natural = self->height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_snapshot (GtkWidget *widget,
|
||||
GdkSnapshot *snapshot)
|
||||
{
|
||||
GtkMaze *self = GTK_MAZE (widget);
|
||||
double width = gtk_widget_get_width (widget);
|
||||
double height = gtk_widget_get_height (widget);
|
||||
GskStroke *stroke;
|
||||
|
||||
stroke = gsk_stroke_new (MAZE_STROKE_SIZE_INACTIVE);
|
||||
if (self->active)
|
||||
gsk_stroke_set_line_width (stroke, MAZE_STROKE_SIZE_ACTIVE);
|
||||
gsk_stroke_set_line_join (stroke, GSK_LINE_JOIN_ROUND);
|
||||
gsk_stroke_set_line_cap (stroke, GSK_LINE_CAP_ROUND);
|
||||
gtk_snapshot_push_stroke (snapshot, self->path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
|
||||
if (self->background)
|
||||
{
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_snapshot_append_linear_gradient (snapshot,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (0, 0),
|
||||
&GRAPHENE_POINT_INIT (width, height),
|
||||
(GskColorStop[8]) {
|
||||
{ 0.0, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.2, { 1.0, 0.0, 0.0, 1.0 } },
|
||||
{ 0.3, { 1.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.4, { 0.0, 1.0, 0.0, 1.0 } },
|
||||
{ 0.6, { 0.0, 1.0, 1.0, 1.0 } },
|
||||
{ 0.7, { 0.0, 0.0, 1.0, 1.0 } },
|
||||
{ 0.8, { 1.0, 0.0, 1.0, 1.0 } },
|
||||
{ 1.0, { 1.0, 0.0, 1.0, 1.0 } }
|
||||
},
|
||||
8);
|
||||
}
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_dispose (GObject *object)
|
||||
{
|
||||
GtkMaze *self = GTK_MAZE (object);
|
||||
|
||||
g_clear_pointer (&self->path, gsk_path_unref);
|
||||
g_clear_pointer (&self->measure, gsk_path_measure_unref);
|
||||
if (self->background)
|
||||
{
|
||||
g_signal_handlers_disconnect_matched (self->background, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
|
||||
g_clear_object (&self->background);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gtk_maze_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_class_init (GtkMazeClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_maze_dispose;
|
||||
|
||||
widget_class->measure = gtk_maze_measure;
|
||||
widget_class->snapshot = gtk_maze_snapshot;
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_motion (GtkEventControllerMotion *controller,
|
||||
double x,
|
||||
double y,
|
||||
GtkMaze *self)
|
||||
{
|
||||
if (!self->active)
|
||||
return;
|
||||
|
||||
if (gsk_path_measure_get_closest_point (self->measure, &GRAPHENE_POINT_INIT (x, y), NULL) <= MAZE_STROKE_SIZE_ACTIVE / 2.0f)
|
||||
return;
|
||||
|
||||
self->active = FALSE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_leave (GtkEventControllerMotion *controller,
|
||||
GtkMaze *self)
|
||||
{
|
||||
if (!self->active)
|
||||
{
|
||||
self->active = TRUE;
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_init (GtkMaze *self)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
self->active = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_maze_set_path (GtkMaze *self,
|
||||
GskPath *path)
|
||||
{
|
||||
g_clear_pointer (&self->path, gsk_path_unref);
|
||||
g_clear_pointer (&self->measure, gsk_path_measure_unref);
|
||||
self->path = gsk_path_ref (path);
|
||||
self->measure = gsk_path_measure_new (path);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_maze_new (GskPath *path,
|
||||
GdkPaintable *background,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GtkMaze *self;
|
||||
|
||||
self = g_object_new (GTK_TYPE_MAZE, NULL);
|
||||
|
||||
gtk_maze_set_path (self, path);
|
||||
gsk_path_unref (path);
|
||||
self->background = background;
|
||||
if (self->background)
|
||||
{
|
||||
g_signal_connect_swapped (self->background, "invalidate-contents", G_CALLBACK (gtk_widget_queue_draw), self);
|
||||
g_signal_connect_swapped (self->background, "invalidate-size", G_CALLBACK (gtk_widget_queue_resize), self);
|
||||
}
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
|
||||
return GTK_WIDGET (self);
|
||||
}
|
||||
|
||||
static void
|
||||
add_point_to_maze (GtkBitset *maze,
|
||||
GskPathBuilder *builder,
|
||||
guint x,
|
||||
guint y)
|
||||
{
|
||||
gboolean set[4] = { };
|
||||
guint dir;
|
||||
|
||||
gtk_bitset_add (maze, y * MAZE_WIDTH + x);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
set[0] = set[0] || x == 0 || gtk_bitset_contains (maze, y * MAZE_WIDTH + x - 1);
|
||||
set[1] = set[1] || y == 0 || gtk_bitset_contains (maze, (y - 1) * MAZE_WIDTH + x);
|
||||
set[2] = set[2] || x + 1 == MAZE_WIDTH || gtk_bitset_contains (maze, y * MAZE_WIDTH + x + 1);
|
||||
set[3] = set[3] || y + 1 == MAZE_HEIGHT || gtk_bitset_contains (maze, (y + 1) * MAZE_WIDTH + x);
|
||||
|
||||
if (set[0] && set[1] && set[2] && set[3])
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
dir = g_random_int_range (0, 4);
|
||||
}
|
||||
while (set[dir]);
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case 0:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x - 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x - 1, y);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y - 0.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x, y - 1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x + 1.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x + 1, y);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
gsk_path_builder_move_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 0.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (x + 0.5) * MAZE_GRID_SIZE, (y + 1.5) * MAZE_GRID_SIZE);
|
||||
add_point_to_maze (maze, builder, x, y + 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
create_path_for_maze (GtkWidget *widget)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
GtkBitset *maze;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
maze = gtk_bitset_new_empty ();
|
||||
/* make sure the outer lines are unreachable:
|
||||
* Set the full range, then remove the center again. */
|
||||
gtk_bitset_add_range (maze, 0, MAZE_WIDTH * MAZE_HEIGHT);
|
||||
gtk_bitset_remove_rectangle (maze, MAZE_WIDTH + 1, MAZE_WIDTH - 2, MAZE_HEIGHT - 2, MAZE_WIDTH);
|
||||
|
||||
/* Fill the maze */
|
||||
add_point_to_maze (maze, builder, MAZE_WIDTH / 2, MAZE_HEIGHT / 2);
|
||||
|
||||
/* Add start and stop lines */
|
||||
gsk_path_builder_move_to (builder, 1.5 * MAZE_GRID_SIZE, -0.5 * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, 1.5 * MAZE_GRID_SIZE, 1.5 * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_move_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT - 1.5) * MAZE_GRID_SIZE);
|
||||
gsk_path_builder_line_to (builder, (MAZE_WIDTH - 1.5) * MAZE_GRID_SIZE, (MAZE_HEIGHT + 0.5) * MAZE_GRID_SIZE);
|
||||
|
||||
|
||||
gtk_bitset_unref (maze);
|
||||
|
||||
return gsk_path_builder_free_to_path (builder);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_path_maze (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *maze;
|
||||
GtkMediaStream *stream;
|
||||
GskPath *path;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Follow the maze with the mouse");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
#if 0
|
||||
stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
|
||||
#else
|
||||
stream = gtk_nuclear_media_stream_new ();
|
||||
#endif
|
||||
gtk_media_stream_play (stream);
|
||||
gtk_media_stream_set_loop (stream, TRUE);
|
||||
|
||||
path = create_path_for_maze (window);
|
||||
|
||||
maze = gtk_maze_new (path,
|
||||
GDK_PAINTABLE (stream),
|
||||
MAZE_WIDTH * MAZE_GRID_SIZE,
|
||||
MAZE_HEIGHT * MAZE_GRID_SIZE);
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), maze);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
590
demos/gtk-demo/path_text.c
Normal file
@@ -0,0 +1,590 @@
|
||||
/* Path/Text
|
||||
*
|
||||
* This demo shows how to use GskPath to animate a path along another path.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define GTK_TYPE_PATH_WIDGET (gtk_path_widget_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkPathWidget, gtk_path_widget, GTK, PATH_WIDGET, GtkWidget)
|
||||
|
||||
#define POINT_SIZE 8
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_TEXT,
|
||||
PROP_EDITABLE,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
struct _GtkPathWidget
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
char *text;
|
||||
gboolean editable;
|
||||
|
||||
graphene_point_t points[4];
|
||||
|
||||
guint active_point;
|
||||
float line_closest;
|
||||
|
||||
GskPath *line_path;
|
||||
GskPathMeasure *line_measure;
|
||||
GskPath *text_path;
|
||||
|
||||
GdkPaintable *background;
|
||||
};
|
||||
|
||||
struct _GtkPathWidgetClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE (GtkPathWidget, gtk_path_widget, GTK_TYPE_WIDGET)
|
||||
|
||||
static GskPath *
|
||||
create_path_from_text (GtkWidget *widget,
|
||||
const char *text)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
cairo_path_t *path;
|
||||
PangoLayout *layout;
|
||||
PangoFontDescription *desc;
|
||||
GskPath *result;
|
||||
|
||||
surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, text);
|
||||
desc = pango_font_description_from_string ("sans bold 36");
|
||||
pango_layout_set_font_description (layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
cairo_move_to (cr, 0, - pango_layout_get_baseline (layout) / (double) PANGO_SCALE);
|
||||
pango_cairo_layout_path (cr, layout);
|
||||
path = cairo_copy_path_flat (cr);
|
||||
result = gsk_path_new_from_cairo (path);
|
||||
|
||||
cairo_path_destroy (path);
|
||||
g_object_unref (layout);
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GskPathMeasure *measure;
|
||||
GskPathBuilder *builder;
|
||||
double scale;
|
||||
} GtkPathTransform;
|
||||
|
||||
static void
|
||||
gtk_path_transform_point (GskPathMeasure *measure,
|
||||
const graphene_point_t *pt,
|
||||
float scale,
|
||||
graphene_point_t *res)
|
||||
{
|
||||
graphene_vec2_t tangent;
|
||||
|
||||
gsk_path_measure_get_point (measure, pt->x * scale, res, &tangent);
|
||||
|
||||
res->x -= pt->y * scale * graphene_vec2_get_y (&tangent);
|
||||
res->y += pt->y * scale * graphene_vec2_get_x (&tangent);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_path_transform_op (GskPathOperation op,
|
||||
const graphene_point_t *pts,
|
||||
gsize n_pts,
|
||||
float weight,
|
||||
gpointer data)
|
||||
{
|
||||
GtkPathTransform *transform = data;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case GSK_PATH_MOVE:
|
||||
{
|
||||
graphene_point_t res;
|
||||
gtk_path_transform_point (transform->measure, &pts[0], transform->scale, &res);
|
||||
gsk_path_builder_move_to (transform->builder, res.x, res.y);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_LINE:
|
||||
{
|
||||
graphene_point_t res;
|
||||
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res);
|
||||
gsk_path_builder_line_to (transform->builder, res.x, res.y);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_CURVE:
|
||||
{
|
||||
graphene_point_t res[3];
|
||||
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res[0]);
|
||||
gtk_path_transform_point (transform->measure, &pts[2], transform->scale, &res[1]);
|
||||
gtk_path_transform_point (transform->measure, &pts[3], transform->scale, &res[2]);
|
||||
gsk_path_builder_curve_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y, res[2].x, res[2].y);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_CONIC:
|
||||
{
|
||||
graphene_point_t res[2];
|
||||
gtk_path_transform_point (transform->measure, &pts[1], transform->scale, &res[0]);
|
||||
gtk_path_transform_point (transform->measure, &pts[2], transform->scale, &res[1]);
|
||||
gsk_path_builder_conic_to (transform->builder, res[0].x, res[0].y, res[1].x, res[1].y, weight);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_PATH_CLOSE:
|
||||
gsk_path_builder_close (transform->builder);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GskPath *
|
||||
gtk_path_transform (GskPathMeasure *measure,
|
||||
GskPath *path)
|
||||
{
|
||||
GtkPathTransform transform = { measure, gsk_path_builder_new () };
|
||||
graphene_rect_t bounds;
|
||||
|
||||
gsk_path_get_bounds (path, &bounds);
|
||||
if (bounds.origin.x + bounds.size.width > 0)
|
||||
transform.scale = gsk_path_measure_get_length (measure) / (bounds.origin.x + bounds.size.width);
|
||||
else
|
||||
transform.scale = 1.0f;
|
||||
|
||||
gsk_path_foreach (path, gtk_path_transform_op, &transform);
|
||||
|
||||
return gsk_path_builder_free_to_path (transform.builder);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_clear_text_path (GtkPathWidget *self)
|
||||
{
|
||||
g_clear_pointer (&self->text_path, gsk_path_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_clear_paths (GtkPathWidget *self)
|
||||
{
|
||||
gtk_path_widget_clear_text_path (self);
|
||||
|
||||
g_clear_pointer (&self->line_path, gsk_path_unref);
|
||||
g_clear_pointer (&self->line_measure, gsk_path_measure_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_create_text_path (GtkPathWidget *self)
|
||||
{
|
||||
GskPath *path;
|
||||
|
||||
gtk_path_widget_clear_text_path (self);
|
||||
|
||||
if (self->line_measure == NULL)
|
||||
return;
|
||||
|
||||
path = create_path_from_text (GTK_WIDGET (self), self->text);
|
||||
self->text_path = gtk_path_transform (self->line_measure, path);
|
||||
|
||||
gsk_path_unref (path);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_create_paths (GtkPathWidget *self)
|
||||
{
|
||||
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
GskPathBuilder *builder;
|
||||
|
||||
gtk_path_widget_clear_paths (self);
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
gsk_path_builder_move_to (builder,
|
||||
self->points[0].x * width, self->points[0].y * height);
|
||||
gsk_path_builder_curve_to (builder,
|
||||
self->points[1].x * width, self->points[1].y * height,
|
||||
self->points[2].x * width, self->points[2].y * height,
|
||||
self->points[3].x * width, self->points[3].y * height);
|
||||
self->line_path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
self->line_measure = gsk_path_measure_new (self->line_path);
|
||||
|
||||
gtk_path_widget_create_text_path (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_path_widget_parent_class)->size_allocate (widget, width, height, baseline);
|
||||
|
||||
gtk_path_widget_create_paths (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (widget);
|
||||
double width = gtk_widget_get_width (widget);
|
||||
double height = gtk_widget_get_height (widget);
|
||||
GskPath *path;
|
||||
GskStroke *stroke;
|
||||
gsize i;
|
||||
|
||||
/* frosted glass the background */
|
||||
gtk_snapshot_push_blur (snapshot, 100);
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 0.6 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
/* draw the text */
|
||||
if (self->text_path)
|
||||
{
|
||||
gtk_snapshot_push_fill (snapshot, self->text_path, GSK_FILL_RULE_WINDING);
|
||||
gdk_paintable_snapshot (self->background, snapshot, width, height);
|
||||
|
||||
/* ... with an emboss effect */
|
||||
stroke = gsk_stroke_new (2.0);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(1, 1));
|
||||
gtk_snapshot_push_stroke (snapshot, self->text_path, stroke);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 0.2 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gsk_stroke_free (stroke);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
if (self->editable)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
|
||||
/* draw the control line */
|
||||
stroke = gsk_stroke_new (1.0);
|
||||
gtk_snapshot_push_stroke (snapshot, self->line_path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
/* draw the points */
|
||||
builder = gsk_path_builder_new ();
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
gsk_path_builder_add_circle (builder, &GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), POINT_SIZE);
|
||||
}
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 1, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
stroke = gsk_stroke_new (1.0);
|
||||
gtk_snapshot_push_stroke (snapshot, path, stroke);
|
||||
gsk_stroke_free (stroke);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gsk_path_unref (path);
|
||||
}
|
||||
|
||||
if (self->line_closest >= 0)
|
||||
{
|
||||
GskPathBuilder *builder;
|
||||
graphene_point_t closest;
|
||||
|
||||
builder = gsk_path_builder_new ();
|
||||
gsk_path_measure_get_point (self->line_measure, self->line_closest, &closest, NULL);
|
||||
gsk_path_builder_add_circle (builder, &closest, POINT_SIZE);
|
||||
path = gsk_path_builder_free_to_path (builder);
|
||||
|
||||
gtk_snapshot_push_fill (snapshot, path, GSK_FILL_RULE_WINDING);
|
||||
gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 0, 0, 1, 1 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
gsk_path_unref (path);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_set_text (GtkPathWidget *self,
|
||||
const char *text)
|
||||
{
|
||||
if (g_strcmp0 (self->text, text) == 0)
|
||||
return;
|
||||
|
||||
g_free (self->text);
|
||||
self->text = g_strdup (text);
|
||||
|
||||
gtk_path_widget_create_paths (self);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TEXT]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_set_editable (GtkPathWidget *self,
|
||||
gboolean editable)
|
||||
{
|
||||
if (self->editable == editable)
|
||||
return;
|
||||
|
||||
self->editable = editable;
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EDITABLE]);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
gtk_path_widget_set_text (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE:
|
||||
gtk_path_widget_set_editable (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
g_value_set_string (value, self->text);
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE:
|
||||
g_value_set_boolean (value, self->editable);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_dispose (GObject *object)
|
||||
{
|
||||
GtkPathWidget *self = GTK_PATH_WIDGET (object);
|
||||
|
||||
gtk_path_widget_clear_paths (self);
|
||||
|
||||
G_OBJECT_CLASS (gtk_path_widget_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_class_init (GtkPathWidgetClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_path_widget_dispose;
|
||||
object_class->set_property = gtk_path_widget_set_property;
|
||||
object_class->get_property = gtk_path_widget_get_property;
|
||||
|
||||
widget_class->size_allocate = gtk_path_widget_allocate;
|
||||
widget_class->snapshot = gtk_path_widget_snapshot;
|
||||
|
||||
properties[PROP_TEXT] =
|
||||
g_param_spec_string ("text",
|
||||
"text",
|
||||
"Text transformed along a path",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_EDITABLE] =
|
||||
g_param_spec_boolean ("editable",
|
||||
"editable",
|
||||
"If the path can be edited by the user",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
drag_begin (GtkGestureDrag *gesture,
|
||||
double x,
|
||||
double y,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
graphene_point_t mouse = GRAPHENE_POINT_INIT (x, y);
|
||||
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (graphene_point_distance (&GRAPHENE_POINT_INIT (self->points[i].x * width, self->points[i].y * height), &mouse, NULL, NULL) <= POINT_SIZE)
|
||||
{
|
||||
self->active_point = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 4)
|
||||
{
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
drag_update (GtkGestureDrag *drag,
|
||||
double offset_x,
|
||||
double offset_y,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
double width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
double height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
double start_x, start_y;
|
||||
|
||||
gtk_gesture_drag_get_start_point (drag, &start_x, &start_y);
|
||||
|
||||
self->points[self->active_point] = GRAPHENE_POINT_INIT ((start_x + offset_x) / width,
|
||||
(start_y + offset_y) / height);
|
||||
self->points[self->active_point].x = CLAMP (self->points[self->active_point].x, 0, 1);
|
||||
self->points[self->active_point].y = CLAMP (self->points[self->active_point].y, 0, 1);
|
||||
|
||||
gtk_path_widget_create_paths (self);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_motion (GtkEventControllerMotion *controller,
|
||||
double x,
|
||||
double y,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
gsk_path_measure_get_closest_point_full (self->line_measure,
|
||||
&GRAPHENE_POINT_INIT (x, y),
|
||||
INFINITY,
|
||||
&self->line_closest,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_leave (GtkEventControllerMotion *controller,
|
||||
GtkPathWidget *self)
|
||||
{
|
||||
self->line_closest = -1;
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_widget_init (GtkPathWidget *self)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
|
||||
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
|
||||
g_signal_connect (controller, "drag-update", G_CALLBACK (drag_update), self);
|
||||
g_signal_connect (controller, "drag-end", G_CALLBACK (drag_update), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_event_controller_motion_new ());
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (pointer_motion), self);
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (pointer_motion), self);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (pointer_leave), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), controller);
|
||||
|
||||
self->line_closest = -1;
|
||||
|
||||
self->points[0] = GRAPHENE_POINT_INIT (0.1, 0.9);
|
||||
self->points[1] = GRAPHENE_POINT_INIT (0.3, 0.1);
|
||||
self->points[2] = GRAPHENE_POINT_INIT (0.7, 0.1);
|
||||
self->points[3] = GRAPHENE_POINT_INIT (0.9, 0.9);
|
||||
|
||||
self->background = GDK_PAINTABLE (gdk_texture_new_from_resource ("/sliding_puzzle/portland-rose.jpg"));
|
||||
|
||||
gtk_path_widget_set_text (self, "It's almost working");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_path_widget_new (void)
|
||||
{
|
||||
GtkPathWidget *self;
|
||||
|
||||
self = g_object_new (GTK_TYPE_PATH_WIDGET, NULL);
|
||||
|
||||
return GTK_WIDGET (self);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_path_text (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
|
||||
g_type_ensure (GTK_TYPE_PATH_WIDGET);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/path_text/path_text.ui");
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
38
demos/gtk-demo/path_text.ui
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="title" translatable="yes">Text along a Path</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="edit-toggle">
|
||||
<property name="icon-name">document-edit-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkRevealer">
|
||||
<property name="reveal-child" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="text">
|
||||
<property name="text">Through the looking glass</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPathWidget" id="view">
|
||||
<property name="editable" bind-source="edit-toggle" bind-property="active" bind-flags="sync-create"></property>
|
||||
<property name="text" bind-source="text" bind-property="text" bind-flags="sync-create"></property>
|
||||
<property name="hexpand">true</property>
|
||||
<property name="vexpand">true</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
187
demos/gtk-demo/pixbufpaintable.c
Normal file
@@ -0,0 +1,187 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "pixbufpaintable.h"
|
||||
|
||||
struct _PixbufPaintable {
|
||||
GObject parent_instance;
|
||||
|
||||
char *resource_path;
|
||||
GdkPixbufAnimation *anim;
|
||||
GdkPixbufAnimationIter *iter;
|
||||
|
||||
guint timeout;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_RESOURCE_PATH = 1,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
static void
|
||||
pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
|
||||
GTimeVal val;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
|
||||
g_get_current_time (&val);
|
||||
gdk_pixbuf_animation_iter_advance (self->iter, &val);
|
||||
pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (self->iter);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (texture), snapshot, width, height);
|
||||
|
||||
g_object_unref (texture);
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
static int
|
||||
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
|
||||
|
||||
return gdk_pixbuf_animation_get_width (self->anim);
|
||||
}
|
||||
|
||||
static int
|
||||
pixbuf_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
|
||||
|
||||
return gdk_pixbuf_animation_get_height (self->anim);
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_init_interface (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->snapshot = pixbuf_paintable_snapshot;
|
||||
iface->get_intrinsic_width = pixbuf_paintable_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = pixbuf_paintable_get_intrinsic_height;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE(PixbufPaintable, pixbuf_paintable, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
pixbuf_paintable_init_interface))
|
||||
|
||||
static void
|
||||
pixbuf_paintable_init (PixbufPaintable *paintable)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
delay_cb (gpointer data)
|
||||
{
|
||||
PixbufPaintable *self = data;
|
||||
int delay;
|
||||
|
||||
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
|
||||
self->timeout = g_timeout_add (delay, delay_cb, self);
|
||||
|
||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_set_resource_path (PixbufPaintable *self,
|
||||
const char *resource_path)
|
||||
{
|
||||
int delay;
|
||||
|
||||
g_free (self->resource_path);
|
||||
self->resource_path = g_strdup (resource_path);
|
||||
|
||||
g_clear_object (&self->anim);
|
||||
self->anim = gdk_pixbuf_animation_new_from_resource (resource_path, NULL);
|
||||
g_clear_object (&self->iter);
|
||||
self->iter = gdk_pixbuf_animation_get_iter (self->anim, NULL);
|
||||
|
||||
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
|
||||
self->timeout = g_timeout_add (delay, delay_cb, self);
|
||||
|
||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||
|
||||
g_object_notify (G_OBJECT (self), "resource-path");
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RESOURCE_PATH:
|
||||
pixbuf_paintable_set_resource_path (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RESOURCE_PATH:
|
||||
g_value_set_string (value, self->resource_path);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_dispose (GObject *object)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
|
||||
|
||||
g_clear_pointer (&self->resource_path, g_free);
|
||||
g_clear_object (&self->anim);
|
||||
g_clear_object (&self->iter);
|
||||
if (self->timeout)
|
||||
{
|
||||
g_source_remove (self->timeout);
|
||||
self->timeout = 0;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (pixbuf_paintable_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_class_init (PixbufPaintableClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->dispose = pixbuf_paintable_dispose;
|
||||
object_class->get_property = pixbuf_paintable_get_property;
|
||||
object_class->set_property = pixbuf_paintable_set_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_RESOURCE_PATH,
|
||||
g_param_spec_string ("resource-path", "Resource path", "Resource path",
|
||||
NULL, G_PARAM_READWRITE));
|
||||
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
pixbuf_paintable_new_from_resource (const char *path)
|
||||
{
|
||||
return g_object_new (PIXBUF_TYPE_PAINTABLE,
|
||||
"resource-path", path,
|
||||
NULL);
|
||||
}
|
13
demos/gtk-demo/pixbufpaintable.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define PIXBUF_TYPE_PAINTABLE (pixbuf_paintable_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE(PixbufPaintable, pixbuf_paintable, PIXBUF, PAINTABLE, GObject)
|
||||
|
||||
GdkPaintable * pixbuf_paintable_new_from_resource (const char *path);
|
||||
|
||||
G_END_DECLS
|
@@ -110,17 +110,17 @@ set_search_by (GSimpleAction *action,
|
||||
if (g_str_equal (term, "name"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by name");
|
||||
gtk_entry_set_placeholder_text (entry, "name");
|
||||
gtk_entry_set_placeholder_text (entry, "Name…");
|
||||
}
|
||||
else if (g_str_equal (term, "description"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by description");
|
||||
gtk_entry_set_placeholder_text (entry, "description");
|
||||
gtk_entry_set_placeholder_text (entry, "Description…");
|
||||
}
|
||||
else if (g_str_equal (term, "filename"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by file name");
|
||||
gtk_entry_set_placeholder_text (entry, "file name");
|
||||
gtk_entry_set_placeholder_text (entry, "File name…");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,6 @@ do_search_entry (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *find_button;
|
||||
GtkWidget *cancel_button;
|
||||
@@ -268,18 +267,14 @@ do_search_entry (GtkWidget *do_widget)
|
||||
|
||||
g_object_weak_ref (G_OBJECT (window), search_entry_destroyed, &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label), "Search entry demo");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
|
||||
/* Create our entry */
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/* Entry/Delayed Search Entry
|
||||
/* Entry/Type to Search
|
||||
*
|
||||
* GtkSearchEntry provides an entry that is ready for search.
|
||||
*
|
||||
* Search entries have their "changed" signal delayed and should
|
||||
* be used when the searched operation is slow such as loads of
|
||||
* entries to search, or online searches.
|
||||
* Search entries have their "search-changed" signal delayed and
|
||||
* should be used when the search operation is slow, such as big
|
||||
* datasets to search, or online searches.
|
||||
*
|
||||
* GtkSearchBar allows have a hidden search entry that 'springs
|
||||
* into action' upon keyboard input.
|
||||
@@ -18,101 +18,69 @@ search_changed_cb (GtkSearchEntry *entry,
|
||||
{
|
||||
const char *text;
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
g_message ("search changed: %s", text);
|
||||
gtk_label_set_text (result_label, text ? text : "");
|
||||
}
|
||||
|
||||
static void
|
||||
changed_cb (GtkEditable *editable)
|
||||
{
|
||||
const char *text;
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (editable));
|
||||
g_message ("changed: %s", text);
|
||||
}
|
||||
|
||||
static void
|
||||
search_changed (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "search-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
next_match (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "next-match");
|
||||
}
|
||||
|
||||
static void
|
||||
previous_match (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "previous-match");
|
||||
}
|
||||
|
||||
static void
|
||||
stop_search (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "stop-search");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_search_entry2 (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *container;
|
||||
GtkWidget *searchbar;
|
||||
GtkWidget *button;
|
||||
GtkWidget *header;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Delayed Search Entry");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Type to Search");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
gtk_widget_set_size_request (window, 200, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
entry = gtk_search_entry_new ();
|
||||
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (container), entry);
|
||||
gtk_widget_set_halign (entry, GTK_ALIGN_CENTER);
|
||||
searchbar = gtk_search_bar_new ();
|
||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (searchbar), GTK_EDITABLE (entry));
|
||||
gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (searchbar), FALSE);
|
||||
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), container);
|
||||
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), entry);
|
||||
gtk_box_append (GTK_BOX (vbox), searchbar);
|
||||
|
||||
/* Hook the search bar to key presses */
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
|
||||
|
||||
/* Help */
|
||||
label = gtk_label_new ("Start Typing to search");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
|
||||
gtk_widget_set_margin_start (box, 18);
|
||||
gtk_widget_set_margin_end (box, 18);
|
||||
gtk_widget_set_margin_top (box, 18);
|
||||
gtk_widget_set_margin_bottom (box, 18);
|
||||
gtk_box_append (GTK_BOX (vbox), box);
|
||||
|
||||
/* Toggle button */
|
||||
button = gtk_toggle_button_new_with_label ("Search");
|
||||
button = gtk_toggle_button_new ();
|
||||
gtk_button_set_icon_name (GTK_BUTTON (button), "system-search-symbolic");
|
||||
g_object_bind_property (button, "active",
|
||||
searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
gtk_box_append (GTK_BOX (vbox), button);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
/* Result */
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
gtk_box_append (GTK_BOX (box), hbox);
|
||||
|
||||
label = gtk_label_new ("Result:");
|
||||
label = gtk_label_new ("Searching for:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_set_margin_start (label, 6);
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
@@ -120,28 +88,6 @@ do_search_entry2 (GtkWidget *do_widget)
|
||||
|
||||
g_signal_connect (entry, "search-changed",
|
||||
G_CALLBACK (search_changed_cb), label);
|
||||
g_signal_connect (entry, "changed",
|
||||
G_CALLBACK (changed_cb), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
|
||||
label = gtk_label_new ("Signal:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_set_margin_start (label, 6);
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
g_signal_connect (entry, "search-changed",
|
||||
G_CALLBACK (search_changed), label);
|
||||
g_signal_connect (entry, "next-match",
|
||||
G_CALLBACK (next_match), label);
|
||||
g_signal_connect (entry, "previous-match",
|
||||
G_CALLBACK (previous_match), label);
|
||||
g_signal_connect (entry, "stop-search",
|
||||
G_CALLBACK (stop_search), label);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@@ -57,6 +57,8 @@ do_shortcut_triggers (GtkWidget *do_widget)
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Shortcuts");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 200, -1);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
list = gtk_list_box_new ();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* Sliding Puzzle
|
||||
* #Keywords: GdkPaintable, GdkGesture, game
|
||||
* #Keywords: GdkPaintable, GdkGesture, GtkShortcutController, game
|
||||
*
|
||||
* This demo demonstrates how to use gestures and paintables to create a
|
||||
* small sliding puzzle game.
|
||||
@@ -281,7 +281,8 @@ start_puzzle (GdkPaintable *paintable)
|
||||
gtk_aspect_frame_set_obey_child (GTK_ASPECT_FRAME (frame), FALSE);
|
||||
|
||||
/* Add shortcuts so people can use the arrow
|
||||
* keys to move the puzzle */
|
||||
* keys to move the puzzle
|
||||
*/
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller),
|
||||
GTK_SHORTCUT_SCOPE_LOCAL);
|
||||
|
1215
demos/gtk-demo/suggestionentry.c
Normal file
28
demos/gtk-demo/suggestionentry.css
Normal file
@@ -0,0 +1,28 @@
|
||||
entry.suggestion > popover.menu.background > contents {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
entry.suggestion arrow {
|
||||
-gtk-icon-source: -gtk-icontheme('pan-down-symbolic');
|
||||
min-height: 16px;
|
||||
min-width: 16px;
|
||||
}
|
||||
|
||||
entry.suggestion > popover {
|
||||
margin-top: 6px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
entry.suggestion > popover listview {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
entry.suggestion > popover listview > row {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
entry.suggestion > popover listview > row:selected {
|
||||
outline-color: rgba(1,1,1,0.2);
|
||||
color: @theme_text_color;
|
||||
background-color: shade(#f6f5f4, 0.97);
|
||||
}
|
66
demos/gtk-demo/suggestionentry.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define MATCH_TYPE_OBJECT (match_object_get_type ())
|
||||
#define MATCH_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATCH_TYPE_OBJECT, MatchObject))
|
||||
#define MATCH_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATCH_TYPE_OBJECT))
|
||||
|
||||
typedef struct _MatchObject MatchObject;
|
||||
|
||||
GType match_object_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gpointer match_object_get_item (MatchObject *object);
|
||||
const char * match_object_get_string (MatchObject *object);
|
||||
guint match_object_get_match_start (MatchObject *object);
|
||||
guint match_object_get_match_end (MatchObject *object);
|
||||
guint match_object_get_score (MatchObject *object);
|
||||
void match_object_set_match (MatchObject *object,
|
||||
guint start,
|
||||
guint end,
|
||||
guint score);
|
||||
|
||||
#define SUGGESTION_TYPE_ENTRY (suggestion_entry_get_type ())
|
||||
#define SUGGESTION_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SUGGESTION_TYPE_ENTRY, SuggestionEntry))
|
||||
#define SUGGESTION_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SUGGESTION_TYPE_ENTRY))
|
||||
|
||||
typedef struct _SuggestionEntry SuggestionEntry;
|
||||
|
||||
GType suggestion_entry_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget* suggestion_entry_new (void);
|
||||
|
||||
void suggestion_entry_set_model (SuggestionEntry *self,
|
||||
GListModel *model);
|
||||
GListModel * suggestion_entry_get_model (SuggestionEntry *self);
|
||||
|
||||
void suggestion_entry_set_factory (SuggestionEntry *self,
|
||||
GtkListItemFactory *factory);
|
||||
GtkListItemFactory *
|
||||
suggestion_entry_get_factory (SuggestionEntry *self);
|
||||
|
||||
void suggestion_entry_set_use_filter (SuggestionEntry *self,
|
||||
gboolean use_ilter);
|
||||
gboolean suggestion_entry_get_use_filter (SuggestionEntry *self);
|
||||
|
||||
void suggestion_entry_set_expression (SuggestionEntry *self,
|
||||
GtkExpression *expression);
|
||||
GtkExpression * suggestion_entry_get_expression (SuggestionEntry *self);
|
||||
|
||||
void suggestion_entry_set_show_arrow (SuggestionEntry *self,
|
||||
gboolean show_arrow);
|
||||
gboolean suggestion_entry_get_show_arrow (SuggestionEntry *self);
|
||||
|
||||
typedef void (* SuggestionEntryMatchFunc) (MatchObject *object,
|
||||
const char *search,
|
||||
gpointer user_data);
|
||||
|
||||
void suggestion_entry_set_match_func (SuggestionEntry *self,
|
||||
SuggestionEntryMatchFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy);
|
||||
|
||||
G_END_DECLS
|
166
demos/gtk-demo/svgpaintable.c
Normal file
@@ -0,0 +1,166 @@
|
||||
#include "svgpaintable.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <librsvg/rsvg.h>
|
||||
|
||||
struct _SvgPaintable
|
||||
{
|
||||
GObject parent_instance;
|
||||
GFile *file;
|
||||
RsvgHandle *handle;
|
||||
};
|
||||
|
||||
struct _SvgPaintableClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_FILE = 1,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static void
|
||||
svg_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
cairo_t *cr;
|
||||
GError *error = NULL;
|
||||
|
||||
cr = gtk_snapshot_append_cairo (GTK_SNAPSHOT (snapshot),
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
|
||||
if (!rsvg_handle_render_document (self->handle, cr,
|
||||
&(RsvgRectangle) {0, 0, width, height},
|
||||
&error))
|
||||
{
|
||||
g_error ("%s", error->message);
|
||||
}
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
static int
|
||||
svg_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
RsvgDimensionData data;
|
||||
|
||||
rsvg_handle_get_dimensions (self->handle, &data);
|
||||
|
||||
return data.width;
|
||||
}
|
||||
|
||||
static int
|
||||
svg_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (paintable);
|
||||
RsvgDimensionData data;
|
||||
|
||||
rsvg_handle_get_dimensions (self->handle, &data);
|
||||
|
||||
return data.height;
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_init_interface (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->snapshot = svg_paintable_snapshot;
|
||||
iface->get_intrinsic_width = svg_paintable_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = svg_paintable_get_intrinsic_height;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (SvgPaintable, svg_paintable, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
svg_paintable_init_interface))
|
||||
|
||||
static void
|
||||
svg_paintable_init (SvgPaintable *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_dispose (GObject *object)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (object);
|
||||
|
||||
g_clear_object (&self->file);
|
||||
g_clear_object (&self->handle);
|
||||
|
||||
G_OBJECT_CLASS (svg_paintable_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FILE:
|
||||
{
|
||||
GFile *file = g_value_get_object (value);
|
||||
RsvgHandle *handle = rsvg_handle_new_from_gfile_sync (file,
|
||||
RSVG_HANDLE_FLAGS_NONE,
|
||||
NULL,
|
||||
NULL);
|
||||
rsvg_handle_set_dpi (handle, 90);
|
||||
|
||||
g_set_object (&self->file, file);
|
||||
g_set_object (&self->handle, handle);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
svg_paintable_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SvgPaintable *self = SVG_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FILE:
|
||||
g_value_set_object (value, self->file);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
svg_paintable_class_init (SvgPaintableClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->dispose = svg_paintable_dispose;
|
||||
object_class->set_property = svg_paintable_set_property;
|
||||
object_class->get_property = svg_paintable_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILE,
|
||||
g_param_spec_object ("file", "File", "File",
|
||||
G_TYPE_FILE,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
svg_paintable_new (GFile *file)
|
||||
{
|
||||
return g_object_new (SVG_TYPE_PAINTABLE,
|
||||
"file", file,
|
||||
NULL);
|
||||
}
|
13
demos/gtk-demo/svgpaintable.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SVG_TYPE_PAINTABLE (svg_paintable_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (SvgPaintable, svg_paintable, SVG, PAINTABLE, GObject)
|
||||
|
||||
GdkPaintable * svg_paintable_new (GFile *file);
|
||||
|
||||
G_END_DECLS
|
@@ -66,6 +66,7 @@ do_tagged_entry (GtkWidget *do_widget)
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
tag {
|
||||
margin: 4px;
|
||||
margin: 4px 0px;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
background: lightskyblue;
|
||||
@@ -17,3 +17,7 @@ tag button {
|
||||
padding: 0;
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
entry.tagged {
|
||||
border-spacing: 4px;
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="resizable">0</property>
|
||||
<property name="title">Themes</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<child type="start">
|
||||
|
@@ -13,9 +13,6 @@
|
||||
</section>
|
||||
</menu>
|
||||
<template class="IconBrowserWindow" parent="GtkApplicationWindow">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
</style>
|
||||
<property name="title" translatable="yes">Icon Browser</property>
|
||||
<property name="default-width">1024</property>
|
||||
<property name="default-height">768</property>
|
||||
@@ -66,11 +63,14 @@
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<child>
|
||||
<object class="GtkListView">
|
||||
<style>
|
||||
<class name="navigation-sidebar" />
|
||||
<class name="navigation-sidebar"/>
|
||||
</style>
|
||||
<property name="model">
|
||||
<object class="GtkSingleSelection" id="context_model">
|
||||
@@ -108,11 +108,6 @@
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="orientation">vertical</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="content_box">
|
||||
<property name="orientation">vertical</property>
|
||||
|
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
</style>
|
||||
<property name="title" translatable="yes">Help</property>
|
||||
<property name="default-width">720</property>
|
||||
<property name="default-height">520</property>
|
||||
|
@@ -102,12 +102,11 @@ text_buffer_remove_all_tags (GtkTextBuffer *buffer)
|
||||
}
|
||||
|
||||
static void
|
||||
deserialize_error_func (const GtkCssSection *section,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
deserialize_error_func (const GskParseLocation *start_location,
|
||||
const GskParseLocation *end_location,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
const GtkCssLocation *start_location = gtk_css_section_get_start_location (section);
|
||||
const GtkCssLocation *end_location = gtk_css_section_get_end_location (section);
|
||||
NodeEditorWindow *self = user_data;
|
||||
GtkTextIter start_iter, end_iter;
|
||||
TextViewError text_view_error;
|
||||
@@ -466,7 +465,7 @@ save_response_cb (GtkWidget *dialog,
|
||||
text = get_current_text (self->text_buffer);
|
||||
|
||||
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||
g_file_replace_contents (file, text, -1,
|
||||
g_file_replace_contents (file, text, strlen (text),
|
||||
NULL, FALSE,
|
||||
G_FILE_CREATE_NONE,
|
||||
NULL,
|
||||
|
@@ -94,9 +94,6 @@
|
||||
</object>
|
||||
|
||||
<template class="NodeEditorWindow" parent="GtkApplicationWindow">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
</style>
|
||||
<property name="title" translatable="yes">GTK Node Editor</property>
|
||||
<property name="default-width">1024</property>
|
||||
<property name="default-height">768</property>
|
||||
|
@@ -164,7 +164,7 @@ save_file (GFile *save_filename)
|
||||
NULL,
|
||||
&error);
|
||||
|
||||
if (error != NULL)
|
||||
if (error == NULL)
|
||||
{
|
||||
if (save_filename != filename)
|
||||
{
|
||||
@@ -812,8 +812,6 @@ activate (GApplication *app)
|
||||
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);
|
||||
update_title (GTK_WINDOW (main_window));
|
||||
|
||||
gtk_widget_add_css_class (main_window, "devel");
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (main_window), box);
|
||||
|
||||
|
@@ -91,6 +91,16 @@ change_theme_state (GSimpleAction *action,
|
||||
|
||||
static GtkWidget *page_stack;
|
||||
|
||||
static void
|
||||
transition_speed_changed (GtkRange *range,
|
||||
gpointer data)
|
||||
{
|
||||
double value;
|
||||
|
||||
value = gtk_range_get_value (range);
|
||||
gtk_stack_set_transition_duration (GTK_STACK (page_stack), (int)value);
|
||||
}
|
||||
|
||||
static void
|
||||
change_transition_state (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
@@ -250,6 +260,8 @@ activate_about (GSimpleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkApplication *app = user_data;
|
||||
GtkWindow *window;
|
||||
GtkWidget *button;
|
||||
const char *authors[] = {
|
||||
"Andrea Cimitan",
|
||||
"Cosimo Cecchi",
|
||||
@@ -267,6 +279,10 @@ activate_about (GSimpleAction *action,
|
||||
|
||||
s = g_string_new ("");
|
||||
|
||||
window = gtk_application_get_active_window (app);
|
||||
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
|
||||
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
|
||||
|
||||
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
|
||||
os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
|
||||
if (os_name && os_version)
|
||||
@@ -292,6 +308,7 @@ activate_about (GSimpleAction *action,
|
||||
|
||||
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
||||
"transient-for", gtk_application_get_active_window (app),
|
||||
"modal", TRUE,
|
||||
"program-name", "GTK Widget Factory",
|
||||
"version", version,
|
||||
"copyright", "© 1997—2020 The GTK Team",
|
||||
@@ -315,6 +332,21 @@ activate_about (GSimpleAction *action,
|
||||
g_free (os_version);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_shortcuts_window (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkApplication *app = user_data;
|
||||
GtkWindow *window;
|
||||
GtkWidget *button;
|
||||
|
||||
window = gtk_application_get_active_window (app);
|
||||
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
|
||||
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
|
||||
gtk_widget_activate_action (GTK_WIDGET (window), "win.show-help-overlay", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_quit (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
@@ -2022,6 +2054,7 @@ activate (GApplication *app)
|
||||
"validate_more_details", (GCallback)validate_more_details,
|
||||
"mode_switch_state_set", (GCallback)mode_switch_state_set,
|
||||
"level_scale_value_changed", (GCallback)level_scale_value_changed,
|
||||
"transition_speed_changed", (GCallback)transition_speed_changed,
|
||||
NULL);
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
g_object_unref (scope);
|
||||
@@ -2359,6 +2392,7 @@ main (int argc, char *argv[])
|
||||
GAction *action;
|
||||
static GActionEntry app_entries[] = {
|
||||
{ "about", activate_about, NULL, NULL, NULL },
|
||||
{ "shortcuts", activate_shortcuts_window, NULL, NULL, NULL },
|
||||
{ "quit", activate_quit, NULL, NULL, NULL },
|
||||
{ "inspector", activate_inspector, NULL, NULL, NULL },
|
||||
{ "main", NULL, "s", "'steak'", NULL },
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id="gear_menu">
|
||||
<menu id="gear_menu_model">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Get Busy</attribute>
|
||||
@@ -40,6 +40,9 @@
|
||||
<attribute name="label" translatable="yes">Transition Pages</attribute>
|
||||
<attribute name="action">win.transition</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="custom">transition-speed</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
@@ -48,7 +51,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">win.show-help-overlay</attribute>
|
||||
<attribute name="action">app.shortcuts</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_About Widget Factory</attribute>
|
||||
@@ -430,9 +433,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
</style>
|
||||
<property name="title">GTK Widget Factory</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar1">
|
||||
@@ -444,7 +444,26 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="gear_menu_button">
|
||||
<property name="valign">center</property>
|
||||
<property name="menu-model">gear_menu</property>
|
||||
<property name="popover">
|
||||
<object class="GtkPopoverMenu" id="gear_menu">
|
||||
<property name="menu-model">gear_menu_model</property>
|
||||
<child type="transition-speed">
|
||||
<object class="GtkScale">
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
<property name="lower">0</property>
|
||||
<property name="upper">1000</property>
|
||||
<property name="value">250</property>
|
||||
<property name="step-increment">50</property>
|
||||
<property name="page-increment">50</property>
|
||||
<property name="page-size">0</property>
|
||||
</object>
|
||||
</property>
|
||||
<signal name="value-changed" handler="transition_speed_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -1123,7 +1142,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Caption</property>
|
||||
<style><class name="Caption"/></style>
|
||||
<style><class name="caption"/></style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@@ -3198,7 +3217,7 @@ bad things might happen.</property>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="halign">end</property>
|
||||
<property name="icon-name">emblem-system-symbolic</property>
|
||||
<property name="menu-model">gear_menu</property>
|
||||
<property name="menu-model">gear_menu_model</property>
|
||||
<property name="tooltip-text">This is a menu button</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
@@ -3282,246 +3301,6 @@ bad things might happen.</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="new_style_menu">
|
||||
<style><class name="menu"/></style>
|
||||
<child>
|
||||
<object class="GtkStack">
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">main</property>
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
<class name="circular-buttons"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="icon">
|
||||
<object class="GThemedIcon">
|
||||
<property name="name">printer-symbolic</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="iconic">1</property>
|
||||
<property name="action-name">win.print</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="halign">center</property>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="icon">
|
||||
<object class="GThemedIcon">
|
||||
<property name="name">emblem-shared-symbolic</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="iconic">1</property>
|
||||
<property name="action-name">app.share</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="halign">center</property>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Open in New Window</property>
|
||||
<property name="action-name">app.open-in</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
<class name="inline-buttons"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkLabel" id="cut_copy_paste_filler"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Edit</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="hexpand">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="icon">
|
||||
<object class="GThemedIcon">
|
||||
<property name="name">edit-cut-symbolic</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="iconic">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="icon">
|
||||
<object class="GThemedIcon">
|
||||
<property name="name">edit-copy-symbolic</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="iconic">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="icon">
|
||||
<object class="GThemedIcon">
|
||||
<property name="name">edit-paste-symbolic</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="iconic">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Pin</property>
|
||||
<property name="action-name">app.pin</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Select Labels…</property>
|
||||
<property name="action-name">app.labels</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Share…</property>
|
||||
<property name="action-name">app.share</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Basement</property>
|
||||
<property name="menu-name">basement</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Large</property>
|
||||
<property name="action-name">app.size</property>
|
||||
<property name="action-target">'large'</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Medium</property>
|
||||
<property name="action-name">app.size</property>
|
||||
<property name="action-target">'medium'</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Small</property>
|
||||
<property name="action-name">app.size</property>
|
||||
<property name="action-target">'small'</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Move to Trash</property>
|
||||
<property name="action-name">win.delete</property>
|
||||
<property name="indicator-size-group">main-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">basement</property>
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Basement</property>
|
||||
<property name="role">title</property>
|
||||
<property name="menu-name">main</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Berk</property>
|
||||
<property name="action-name">app.berk</property>
|
||||
<property name="indicator-size-group">basement-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Broni</property>
|
||||
<property name="action-name">app.broni</property>
|
||||
<property name="indicator-size-group">basement-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">Drutt</property>
|
||||
<property name="action-name">app.drutt</property>
|
||||
<property name="indicator-size-group">basement-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton">
|
||||
<property name="text">The Thing Upstairs</property>
|
||||
<property name="action-name">app.upstairs</property>
|
||||
<property name="indicator-size-group">basement-indicators</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkSizeGroup" id="main-indicators">
|
||||
<widgets>
|
||||
<widget name="cut_copy_paste_filler"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup" id="basement-indicators"/>
|
||||
<menu id="new_style_menu_model">
|
||||
<section>
|
||||
|
@@ -16,14 +16,16 @@
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
<reference id="reference">
|
||||
<chapter>
|
||||
<title>API Reference</title>
|
||||
<xi:include href="xml/general.xml" />
|
||||
<xi:include href="xml/gdkdisplaymanager.xml" />
|
||||
<xi:include href="xml/gdkdisplay.xml" />
|
||||
<xi:include href="xml/gdkseat.xml" />
|
||||
<xi:include href="xml/gdkdevice.xml" />
|
||||
<xi:include href="xml/gdkdevicepad.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkdevicepad.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkmonitor.xml" />
|
||||
<xi:include href="xml/regions.xml" />
|
||||
<xi:include href="xml/textures.xml" />
|
||||
@@ -32,16 +34,24 @@
|
||||
<xi:include href="xml/cursors.xml" />
|
||||
<xi:include href="xml/gdksurface.xml" />
|
||||
<xi:include href="xml/gdktoplevel.xml" />
|
||||
<xi:include href="xml/gdktoplevellayout.xml" />
|
||||
<xi:include href="xml/gdktoplevelsize.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdktoplevellayout.xml" />
|
||||
<xi:include href="xml/gdktoplevelsize.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkpopup.xml" />
|
||||
<xi:include href="xml/gdkpopuplayout.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkpopuplayout.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkframeclock.xml" />
|
||||
<xi:include href="xml/gdkframetimings.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkframetimings.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkdrawcontext.xml" />
|
||||
<xi:include href="xml/gdkglcontext.xml" />
|
||||
<xi:include href="xml/gdkvulkancontext.xml" />
|
||||
<xi:include href="xml/gdkcairocontext.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkglcontext.xml" />
|
||||
<xi:include href="xml/gdkvulkancontext.xml" />
|
||||
<xi:include href="xml/gdkcairocontext.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/events.xml" />
|
||||
<xi:include href="xml/keys.xml" />
|
||||
<xi:include href="xml/gdkclipboard.xml" />
|
||||
@@ -50,13 +60,16 @@
|
||||
<xi:include href="xml/gdkcontentprovider.xml" />
|
||||
<xi:include href="xml/gdkcontentserializer.xml" />
|
||||
<xi:include href="xml/gdkcontentdeserializer.xml" />
|
||||
<xi:include href="xml/gdkapplaunchcontext.xml" />
|
||||
<xi:include href="xml/pixbufs.xml" />
|
||||
<xi:include href="xml/pango_interaction.xml" />
|
||||
<xi:include href="xml/cairo_interaction.xml" />
|
||||
</chapter>
|
||||
<chapter>
|
||||
<title>GDK Platform Support</title>
|
||||
<xi:include href="xml/gdkapplaunchcontext.xml" />
|
||||
<xi:include href="xml/x_interaction.xml" />
|
||||
<xi:include href="xml/wayland_interaction.xml" />
|
||||
</reference>
|
||||
</chapter>
|
||||
|
||||
<index id="api-index-full">
|
||||
<title>Index of all symbols</title>
|
||||
|
@@ -10,8 +10,8 @@
|
||||
</MACRO>
|
||||
|
||||
<MACRO>
|
||||
<NAME>GDK_WINDOWING_QUARTZ</NAME>
|
||||
#define GDK_WINDOWING_QUARTZ
|
||||
<NAME>GDK_WINDOWING_MACOS</NAME>
|
||||
#define GDK_WINDOWING_MACOS
|
||||
</MACRO>
|
||||
|
||||
<MACRO>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<SUBSECTION>
|
||||
GDK_WINDOWING_X11
|
||||
GDK_WINDOWING_WIN32
|
||||
GDK_WINDOWING_QUARTZ
|
||||
GDK_WINDOWING_MACOS
|
||||
GDK_WINDOWING_WAYLAND
|
||||
|
||||
<SUBSECTION>
|
||||
@@ -303,11 +303,8 @@ gdk_cairo_draw_from_gl
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<TITLE>Points, Rectangles and Regions</TITLE>
|
||||
<TITLE>Rectangles and Regions</TITLE>
|
||||
<FILE>regions</FILE>
|
||||
GdkPoint
|
||||
|
||||
<SUBSECTION>
|
||||
GdkRectangle
|
||||
gdk_rectangle_intersect
|
||||
gdk_rectangle_union
|
||||
@@ -968,7 +965,7 @@ gdk_wayland_seat_get_wl_seat
|
||||
gdk_wayland_device_get_wl_seat
|
||||
gdk_wayland_device_get_wl_pointer
|
||||
gdk_wayland_device_get_wl_keyboard
|
||||
gdk_wayland_device_get_node_ath
|
||||
gdk_wayland_device_get_node_path
|
||||
|
||||
<SUBSECTION Monitor>
|
||||
gdk_wayland_monitor_get_wl_output
|
||||
|
@@ -23,6 +23,13 @@
|
||||
<xi:include href="xml/GskGLShader.xml" />
|
||||
</reference>
|
||||
|
||||
<part id="paths">
|
||||
<title>Paths</title>
|
||||
<xi:include href="xml/GskPath.xml" />
|
||||
<xi:include href="xml/GskPathBuilder.xml" />
|
||||
<xi:include href="xml/GskStroke.xml" />
|
||||
</part>
|
||||
|
||||
<index id="api-index-full">
|
||||
<title>Index of all symbols</title>
|
||||
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||
|
@@ -62,97 +62,123 @@ gsk_render_node_write_to_file
|
||||
GskScalingFilter
|
||||
gsk_render_node_get_bounds
|
||||
|
||||
<SUBSECTION Nodes>
|
||||
<SUBSECTION>
|
||||
gsk_color_node_new
|
||||
gsk_color_node_peek_color
|
||||
gsk_color_node_get_color
|
||||
gsk_texture_node_new
|
||||
gsk_texture_node_get_texture
|
||||
<SUBSECTION>
|
||||
GskColorStop
|
||||
gsk_linear_gradient_node_new
|
||||
gsk_linear_gradient_node_peek_start
|
||||
gsk_linear_gradient_node_peek_end
|
||||
gsk_linear_gradient_node_get_n_color_stops
|
||||
gsk_linear_gradient_node_peek_color_stops
|
||||
gsk_repeating_linear_gradient_node_new
|
||||
gsk_linear_gradient_node_get_start
|
||||
gsk_linear_gradient_node_get_end
|
||||
gsk_linear_gradient_node_get_n_color_stops
|
||||
gsk_linear_gradient_node_get_color_stops
|
||||
<SUBSECTION>
|
||||
gsk_radial_gradient_node_new
|
||||
gsk_repeating_radial_gradient_node_new
|
||||
gsk_radial_gradient_node_get_n_color_stops
|
||||
gsk_radial_gradient_node_peek_color_stops
|
||||
gsk_radial_gradient_node_get_color_stops
|
||||
gsk_radial_gradient_node_get_start
|
||||
gsk_radial_gradient_node_get_end
|
||||
gsk_radial_gradient_node_get_hradius
|
||||
gsk_radial_gradient_node_get_vradius
|
||||
gsk_radial_gradient_node_peek_center
|
||||
gsk_repeating_radial_gradient_node_new
|
||||
gsk_radial_gradient_node_get_center
|
||||
<SUBSECTION>
|
||||
gsk_border_node_new
|
||||
gsk_border_node_peek_outline
|
||||
gsk_border_node_peek_widths
|
||||
gsk_border_node_peek_colors
|
||||
gsk_border_node_get_outline
|
||||
gsk_border_node_get_widths
|
||||
gsk_border_node_get_colors
|
||||
<SUBSECTION>
|
||||
gsk_inset_shadow_node_new
|
||||
gsk_inset_shadow_node_peek_outline
|
||||
gsk_inset_shadow_node_peek_color
|
||||
gsk_inset_shadow_node_get_outline
|
||||
gsk_inset_shadow_node_get_color
|
||||
gsk_inset_shadow_node_get_dx
|
||||
gsk_inset_shadow_node_get_dy
|
||||
gsk_inset_shadow_node_get_spread
|
||||
gsk_inset_shadow_node_get_blur_radius
|
||||
<SUBSECTION>
|
||||
gsk_outset_shadow_node_new
|
||||
gsk_outset_shadow_node_peek_outline
|
||||
gsk_outset_shadow_node_peek_color
|
||||
gsk_outset_shadow_node_get_outline
|
||||
gsk_outset_shadow_node_get_color
|
||||
gsk_outset_shadow_node_get_dx
|
||||
gsk_outset_shadow_node_get_dy
|
||||
gsk_outset_shadow_node_get_spread
|
||||
gsk_outset_shadow_node_get_blur_radius
|
||||
<SUBSECTION>
|
||||
gsk_cairo_node_new
|
||||
gsk_cairo_node_get_draw_context
|
||||
gsk_cairo_node_peek_surface
|
||||
gsk_cairo_node_get_surface
|
||||
<SUBSECTION>
|
||||
gsk_container_node_new
|
||||
gsk_container_node_get_n_children
|
||||
gsk_container_node_get_child
|
||||
<SUBSECTION>
|
||||
gsk_transform_node_new
|
||||
gsk_transform_node_get_child
|
||||
gsk_transform_node_get_transform
|
||||
<SUBSECTION>
|
||||
gsk_opacity_node_new
|
||||
gsk_opacity_node_get_child
|
||||
gsk_opacity_node_get_opacity
|
||||
<SUBSECTION>
|
||||
gsk_color_matrix_node_new
|
||||
gsk_color_matrix_node_get_child
|
||||
gsk_color_matrix_node_peek_color_matrix
|
||||
gsk_color_matrix_node_peek_color_offset
|
||||
gsk_color_matrix_node_get_color_matrix
|
||||
gsk_color_matrix_node_get_color_offset
|
||||
<SUBSECTION>
|
||||
gsk_repeat_node_new
|
||||
gsk_repeat_node_get_child
|
||||
gsk_repeat_node_peek_child_bounds
|
||||
gsk_repeat_node_get_child_bounds
|
||||
<SUBSECTION>
|
||||
gsk_clip_node_new
|
||||
gsk_clip_node_get_child
|
||||
gsk_clip_node_peek_clip
|
||||
gsk_clip_node_get_clip
|
||||
<SUBSECTION>
|
||||
gsk_rounded_clip_node_new
|
||||
gsk_rounded_clip_node_get_child
|
||||
gsk_rounded_clip_node_peek_clip
|
||||
gsk_rounded_clip_node_get_clip
|
||||
<SUBSECTION>
|
||||
GskFillRule
|
||||
gsk_fill_node_new
|
||||
gsk_fill_node_get_child
|
||||
gsk_fill_node_get_path
|
||||
gsk_fill_node_get_fill_rule
|
||||
<SUBSECTION>
|
||||
GskShadow
|
||||
gsk_shadow_node_new
|
||||
gsk_shadow_node_peek_shadow
|
||||
gsk_shadow_node_get_shadow
|
||||
gsk_shadow_node_get_n_shadows
|
||||
gsk_shadow_node_get_child
|
||||
<SUBSECTION>
|
||||
GskBlendMode
|
||||
gsk_blend_node_new
|
||||
gsk_blend_node_get_bottom_child
|
||||
gsk_blend_node_get_top_child
|
||||
gsk_blend_node_get_blend_mode
|
||||
<SUBSECTION>
|
||||
gsk_cross_fade_node_new
|
||||
gsk_cross_fade_node_get_start_child
|
||||
gsk_cross_fade_node_get_end_child
|
||||
gsk_cross_fade_node_get_progress
|
||||
<SUBSECTION>
|
||||
gsk_text_node_new
|
||||
gsk_text_node_peek_font
|
||||
gsk_text_node_peek_glyphs
|
||||
gsk_text_node_peek_color
|
||||
gsk_text_node_get_font
|
||||
gsk_text_node_get_glyphs
|
||||
gsk_text_node_get_color
|
||||
gsk_text_node_has_color_glyphs
|
||||
gsk_text_node_get_num_glyphs
|
||||
gsk_text_node_get_offset
|
||||
<SUBSECTION>
|
||||
gsk_blur_node_new
|
||||
gsk_blur_node_get_child
|
||||
gsk_blur_node_get_radius
|
||||
<SUBSECTION>
|
||||
gsk_debug_node_new
|
||||
gsk_debug_node_get_child
|
||||
gsk_debug_node_get_message
|
||||
<SUBSECTION>
|
||||
gsk_gl_shader_node_new
|
||||
gsk_gl_shader_node_get_n_children
|
||||
gsk_gl_shader_node_get_child
|
||||
@@ -172,6 +198,7 @@ GSK_TYPE_COLOR_NODE
|
||||
GSK_TYPE_CONTAINER_NODE
|
||||
GSK_TYPE_CROSS_FADE_NODE
|
||||
GSK_TYPE_DEBUG_NODE
|
||||
GSK_TYPE_FILL_NODE
|
||||
GSK_TYPE_INSET_SHADOW_NODE
|
||||
GSK_TYPE_LINEAR_GRADIENT_NODE
|
||||
GSK_TYPE_OPACITY_NODE
|
||||
@@ -197,6 +224,7 @@ gsk_color_node_get_type
|
||||
gsk_container_node_get_type
|
||||
gsk_cross_fade_node_get_type
|
||||
gsk_debug_node_get_type
|
||||
gsk_fill_node_get_type
|
||||
gsk_inset_shadow_node_get_type
|
||||
gsk_linear_gradient_node_get_type
|
||||
gsk_opacity_node_get_type
|
||||
@@ -234,6 +262,66 @@ gsk_rounded_rect_contains_rect
|
||||
gsk_rounded_rect_intersects_rect
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>GskPath</FILE>
|
||||
<SUBSECTION>
|
||||
GskPath
|
||||
gsk_path_ref
|
||||
gsk_path_unref
|
||||
gsk_path_new_rect
|
||||
gsk_path_new_from_cairo
|
||||
<SUBSECTION>
|
||||
gsk_path_print
|
||||
gsk_path_to_string
|
||||
gsk_path_to_cairo
|
||||
<SUBSECTION>
|
||||
gsk_path_is_empty
|
||||
gsk_path_get_bounds
|
||||
<SUBSECTION Private>
|
||||
GSK_TYPE_PATH
|
||||
gsk_path_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>GskPathBuilder</FILE>
|
||||
GskPathBuilder
|
||||
gsk_path_builder_new
|
||||
gsk_path_builder_ref
|
||||
gsk_path_builder_unref
|
||||
gsk_path_builder_to_path
|
||||
gsk_path_builder_free_to_path
|
||||
<SUBSECTION>
|
||||
gsk_path_builder_add_rect
|
||||
<SUBSECTION>
|
||||
gsk_path_builder_move_to
|
||||
gsk_path_builder_line_to
|
||||
gsk_path_builder_curve_to
|
||||
gsk_path_builder_conic_to
|
||||
gsk_path_builder_close
|
||||
<SUBSECTION Private>
|
||||
GSK_TYPE_PATH_BUILDER
|
||||
gsk_path_builder_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>GskStroke</FILE>
|
||||
GskLineCap
|
||||
GskLineJoin
|
||||
gsk_stroke_new
|
||||
gsk_stroke_copy
|
||||
gsk_stroke_free
|
||||
gsk_stroke_equal
|
||||
gsk_stroke_set_line_width
|
||||
gsk_stroke_get_line_width
|
||||
gsk_stroke_set_line_cap
|
||||
gsk_stroke_get_line_cap
|
||||
gsk_stroke_set_line_join
|
||||
gsk_stroke_get_line_join
|
||||
<SUBSECTION Private>
|
||||
GSK_TYPE_STROKE
|
||||
gsk_stroke_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>GskTransform</FILE>
|
||||
GskTransform
|
||||
|
@@ -107,7 +107,9 @@ The `plain` build type provided by Meson should only be used when
|
||||
packaging GTK, and it's expected that packagers will provide their
|
||||
own compiler flags when building GTK. See the previous section for
|
||||
the list of environment variables to be used to define compiler and
|
||||
linker flags.
|
||||
linker flags. Note that with the plain build type, you are also
|
||||
responsible for controlling the debugging features of GTK with
|
||||
`-DG_ENABLE_DEBUG` and `-DG_DISABLE_CAST_CHECKS`.
|
||||
|
||||
## Dependencies {#dependencies}
|
||||
|
||||
@@ -159,7 +161,8 @@ Other libraries are maintained separately.
|
||||
fonts and matching them against font names.
|
||||
- [Cairo](https://www.cairographics.org) is a graphics library that
|
||||
supports vector graphics and image compositing. Both Pango and GTK
|
||||
use Cairo for drawing.
|
||||
use Cairo for drawing. Note that we also need the auxiliary cairo-gobject
|
||||
library.
|
||||
- [libepoxy](https://github.com/anholt/libepoxy) is a library that
|
||||
abstracts the differences between different OpenGL libraries. GTK
|
||||
uses it for cross-platform GL support and for its own drawing.
|
||||
|
@@ -586,53 +586,53 @@ print_hello (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
quit_cb (GtkWidget *widget, gpointer data)
|
||||
quit_cb (GtkWindow *window)
|
||||
{
|
||||
gboolean *done = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
gtk_window_close (window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
static void
|
||||
activate (GtkApplication *app,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GObject *window;
|
||||
GObject *button;
|
||||
gboolean done = FALSE;
|
||||
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
gtk_init ();
|
||||
|
||||
/* Construct a GtkBuilder instance and load our UI description */
|
||||
builder = gtk_builder_new ();
|
||||
GtkBuilder *builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (builder, "builder.ui", NULL);
|
||||
|
||||
/* Connect signal handlers to the constructed widgets. */
|
||||
window = gtk_builder_get_object (builder, "window");
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
||||
GObject *window = gtk_builder_get_object (builder, "window");
|
||||
gtk_window_set_application (GTK_WINDOW (window), app);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button1");
|
||||
GObject *button = gtk_builder_get_object (builder, "button1");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button2");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "quit");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
/* We do not need the builder any more */
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
return 0;
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
||||
|
||||
int status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
return status;
|
||||
}
|
||||
```
|
||||
|
||||
|
@@ -1432,6 +1432,7 @@ GTK_TYPE_BOOKMARK_LIST
|
||||
<FILE>gtkfilter</FILE>
|
||||
<TITLE>GtkFilter</TITLE>
|
||||
GtkFilter
|
||||
GtkFilterMatch
|
||||
gtk_filter_match
|
||||
gtk_filter_get_strictness
|
||||
<SUBSECTION>
|
||||
@@ -2107,6 +2108,7 @@ gtk_native_dialog_get_type
|
||||
<TITLE>GtkNotebook</TITLE>
|
||||
GtkNotebook
|
||||
GtkNotebookPage
|
||||
GtkNotebookTab
|
||||
gtk_notebook_new
|
||||
gtk_notebook_get_page
|
||||
gtk_notebook_get_pages
|
||||
@@ -2163,7 +2165,6 @@ GTK_NOTEBOOK_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
gtk_notebook_get_type
|
||||
gtk_notebook_page_get_type
|
||||
GtkNotebookTab
|
||||
GtkNotebookPrivate
|
||||
</SECTION>
|
||||
|
||||
@@ -4303,6 +4304,8 @@ gtk_snapshot_push_color_matrix
|
||||
gtk_snapshot_push_repeat
|
||||
gtk_snapshot_push_clip
|
||||
gtk_snapshot_push_rounded_clip
|
||||
gtk_snapshot_push_fill
|
||||
gtk_snapshot_push_stroke
|
||||
gtk_snapshot_push_cross_fade
|
||||
gtk_snapshot_push_blend
|
||||
gtk_snapshot_push_blur
|
||||
@@ -4335,7 +4338,6 @@ gtk_snapshot_render_background
|
||||
gtk_snapshot_render_frame
|
||||
gtk_snapshot_render_focus
|
||||
gtk_snapshot_render_layout
|
||||
gtk_snapshot_render_insertion_cursor
|
||||
<SUBSECTION Private>
|
||||
gtk_snapshot_get_type
|
||||
</SECTION>
|
||||
@@ -4845,7 +4847,6 @@ gtk_render_line
|
||||
gtk_render_option
|
||||
gtk_render_activity
|
||||
gtk_render_icon
|
||||
gtk_render_insertion_cursor
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_STYLE_CONTEXT
|
||||
@@ -6177,6 +6178,8 @@ gtk_popover_menu_new_from_model
|
||||
gtk_popover_menu_new_from_model_full
|
||||
gtk_popover_menu_set_menu_model
|
||||
gtk_popover_menu_get_menu_model
|
||||
gtk_popover_menu_add_child
|
||||
gtk_popover_menu_remove_child
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_POPOVER_MENU
|
||||
@@ -6195,6 +6198,8 @@ GtkPopoverMenuBar
|
||||
gtk_popover_menu_bar_new_from_model
|
||||
gtk_popover_menu_bar_set_menu_model
|
||||
gtk_popover_menu_bar_get_menu_model
|
||||
gtk_popover_menu_bar_add_child
|
||||
gtk_popover_menu_bar_remove_child
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_POPOVER_MENU_BAR
|
||||
|
BIN
docs/reference/gtk/images/box.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
docs/reference/gtk/images/calendar.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
docs/reference/gtk/images/centerbox.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
docs/reference/gtk/images/drawingarea.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.5 KiB |
BIN
docs/reference/gtk/images/emojichooser.png
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
docs/reference/gtk/images/expander.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 4.4 KiB |
BIN
docs/reference/gtk/images/grid.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 5.6 KiB |
BIN
docs/reference/gtk/images/menu.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
docs/reference/gtk/images/overlay.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.1 KiB |
BIN
docs/reference/gtk/images/popover.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.9 KiB |