Compare commits
1387 Commits
test-branc
...
map-list-c
Author | SHA1 | Date | |
---|---|---|---|
|
eb3381723f | ||
|
7e87ad1887 | ||
|
ef6babf896 | ||
|
7f9570b95b | ||
|
d8d8a71a7a | ||
|
2ff3e3d1e4 | ||
|
73f4f518b8 | ||
|
6e9dbba130 | ||
|
706aa93ab5 | ||
|
54deed9a5a | ||
|
0e70ddcab3 | ||
|
f2bdb1fb87 | ||
|
ec9fd76c87 | ||
|
bacaa5eb9a | ||
|
9a297516ba | ||
|
e9bff53015 | ||
|
3078b180fe | ||
|
556997f9df | ||
|
d375dce9f5 | ||
|
d7266b25ba | ||
|
2a43ce1705 | ||
|
3324a6e6b3 | ||
|
46423e614d | ||
|
f7b73b2e01 | ||
|
c85e424279 | ||
|
b146c48e23 | ||
|
3176d69009 | ||
|
89f7d841ab | ||
|
7e2fceebca | ||
|
1e00c887ec | ||
|
561d3c68a0 | ||
|
03601cb794 | ||
|
3108b8b4d3 | ||
|
d1afe32762 | ||
|
603dd72b09 | ||
|
e81ba8924a | ||
|
8832ab45d9 | ||
|
87d6e17bc7 | ||
|
a5033cd79b | ||
|
44cbf3d605 | ||
|
fb6288791e | ||
|
2160f52cbf | ||
|
8825e621c9 | ||
|
e22abd73f2 | ||
|
f77d4d7fc0 | ||
|
8243133ca7 | ||
|
63a4345d2c | ||
|
56685a483d | ||
|
b23f793753 | ||
|
2b19e2fc1f | ||
|
703f8b8136 | ||
|
5b18968867 | ||
|
e8c4e1205a | ||
|
bf5c540357 | ||
|
c03383d3e5 | ||
|
eaaa287078 | ||
|
554defaf1a | ||
|
659fe52b7b | ||
|
0970077af9 | ||
|
814c88fbc1 | ||
|
3b24c8a0a4 | ||
|
e34c7e6796 | ||
|
8c608e9c1c | ||
|
283c3b70dd | ||
|
93599c2c48 | ||
|
080e625090 | ||
|
26696a741e | ||
|
a209e54b8f | ||
|
8921dadaa1 | ||
|
47232acbd8 | ||
|
cbad8ec2e4 | ||
|
800170b47d | ||
|
97c5cb3514 | ||
|
081afc0477 | ||
|
e807fc3be0 | ||
|
a1bd3389ed | ||
|
03a3b5a0b1 | ||
|
1ee2d9a5fa | ||
|
2e07fcd680 | ||
|
d3365d5a60 | ||
|
9dbf99d91a | ||
|
0154a7f528 | ||
|
add47bebc6 | ||
|
514b62223d | ||
|
7884ab6161 | ||
|
bc542c5304 | ||
|
d66ac4981e | ||
|
9b647a47d1 | ||
|
b67ffe9650 | ||
|
2c519b006d | ||
|
852429d163 | ||
|
ee9c6bbf75 | ||
|
d9ece94377 | ||
|
486fbce42b | ||
|
ed92026632 | ||
|
05e614feb7 | ||
|
14059afdf1 | ||
|
9b294eb94e | ||
|
96d42cf1cc | ||
|
4786a16696 | ||
|
14bb12125f | ||
|
07e8dafcea | ||
|
ab67a81f11 | ||
|
aa76f7e210 | ||
|
0c15463e41 | ||
|
5df1356295 | ||
|
95fc81c565 | ||
|
378e594f75 | ||
|
86c7fceb09 | ||
|
b5e20a3e37 | ||
|
75a30b1f98 | ||
|
c64a021af4 | ||
|
9b64635925 | ||
|
7b76be5360 | ||
|
2e2336ffce | ||
|
76d80ef516 | ||
|
287d80bd36 | ||
|
77072b3eaa | ||
|
c7833bb090 | ||
|
899024cef7 | ||
|
4da3edd42e | ||
|
6b59626817 | ||
|
7c02ae00c2 | ||
|
80e29a3627 | ||
|
26163a4f30 | ||
|
dbd88fc210 | ||
|
2de31e4cac | ||
|
1bff328895 | ||
|
facf78a5b6 | ||
|
6b19fcd859 | ||
|
ca784e3e1a | ||
|
314c8558d7 | ||
|
af30a7fe06 | ||
|
9ffd7d1970 | ||
|
cb906c80eb | ||
|
96ce0eb600 | ||
|
0e476c1f28 | ||
|
f2924988db | ||
|
671435e07f | ||
|
b17cfb9b65 | ||
|
0385f1aaf4 | ||
|
8611faf338 | ||
|
7e19911d3f | ||
|
c1f5153f6d | ||
|
2bd87ce771 | ||
|
de0547ede7 | ||
|
14589c2a59 | ||
|
f678b3804d | ||
|
720c298786 | ||
|
f721d2de15 | ||
|
11f07cb5ad | ||
|
37d7ab88dc | ||
|
6cde64072d | ||
|
6a60b0f591 | ||
|
339d9f05e4 | ||
|
4e4207457f | ||
|
46bb3e3046 | ||
|
34008e6aab | ||
|
d6b3ac850d | ||
|
9742200ff6 | ||
|
ec10857b84 | ||
|
353d4d161c | ||
|
bcd650f169 | ||
|
72d66dfcdd | ||
|
5e97df5058 | ||
|
059d131e2b | ||
|
8f7c207c7c | ||
|
b9e8935037 | ||
|
5f33f4ae8e | ||
|
adf0e8b1e6 | ||
|
7500f9b255 | ||
|
a8d433dd26 | ||
|
ecaf6fced0 | ||
|
31a7cac4a6 | ||
|
5eec736b07 | ||
|
cf4a8e2152 | ||
|
31bb969cce | ||
|
f4a7c7f6bf | ||
|
495069c868 | ||
|
dfe470475b | ||
|
de56e892aa | ||
|
e518c1f2f3 | ||
|
c5ea59d7d1 | ||
|
22eccbdbb6 | ||
|
58e85c85e4 | ||
|
6b89148487 | ||
|
ddb9e428ec | ||
|
b7fa353db2 | ||
|
87b5eadb7c | ||
|
60a09e59e8 | ||
|
6f8e9bf3a9 | ||
|
90b7b84337 | ||
|
088b5fc57f | ||
|
a4cd974912 | ||
|
65359dcc59 | ||
|
ac8b398c50 | ||
|
aac2417893 | ||
|
ad8892df10 | ||
|
edc7977c4e | ||
|
8bf8ac5076 | ||
|
c36cbd5140 | ||
|
ee96bc7185 | ||
|
f94f325636 | ||
|
6c1217dd93 | ||
|
edb792503b | ||
|
3a43859286 | ||
|
c55dd104d4 | ||
|
497d137fb8 | ||
|
df01c5c7a4 | ||
|
2d1135fba6 | ||
|
f54ed6f7dc | ||
|
b7efd896b6 | ||
|
46eb51bc30 | ||
|
500dbaabc3 | ||
|
594ec3d822 | ||
|
f280508209 | ||
|
480b88c776 | ||
|
a4e63905b1 | ||
|
5666127dbc | ||
|
c1c110ba65 | ||
|
eb2a839892 | ||
|
1c537a6d2e | ||
|
c12261a6ec | ||
|
5af7d6bff3 | ||
|
de0f4b0f5b | ||
|
966ab1152d | ||
|
74a4432688 | ||
|
115d0cdc07 | ||
|
d0ec616fba | ||
|
38cce2bb18 | ||
|
9cb7002b98 | ||
|
eb9c91c0a9 | ||
|
be07153efa | ||
|
627ec82e60 | ||
|
ccc34ca06c | ||
|
2b5dd0082d | ||
|
7b36b339aa | ||
|
b7eb663b82 | ||
|
1b28353be5 | ||
|
a07c030d02 | ||
|
339cccdf53 | ||
|
577126e99c | ||
|
125ea5ee4a | ||
|
3c5afc06d1 | ||
|
f87c15f4f9 | ||
|
fe5c0e2fe3 | ||
|
c8421cfd82 | ||
|
fbf99b8d65 | ||
|
57312c9b79 | ||
|
35d2539ef8 | ||
|
08a4f4552c | ||
|
6502d3669f | ||
|
53831e67a7 | ||
|
e742fc1206 | ||
|
4ef5ee23e6 | ||
|
4a8330fda0 | ||
|
b4096cee64 | ||
|
032302c358 | ||
|
a888e1cb65 | ||
|
c80b33b2ad | ||
|
f32239df1f | ||
|
22c1b541df | ||
|
78a59c95fe | ||
|
7583d48266 | ||
|
f1188aaeac | ||
|
4dac5c222f | ||
|
0145809a94 | ||
|
2e6b8810c0 | ||
|
d8abcdb5a1 | ||
|
65ecfa20dd | ||
|
aa5ab02166 | ||
|
7ddbbb50ff | ||
|
f2eb036119 | ||
|
8a8b96bf4b | ||
|
bdcda2d8f0 | ||
|
ef3f997d55 | ||
|
b41d380230 | ||
|
0210850e86 | ||
|
053223bf65 | ||
|
746b84cc0f | ||
|
f1ad883e00 | ||
|
191e0e8d5e | ||
|
55217e2181 | ||
|
7c8cd23c5f | ||
|
6aafb81702 | ||
|
0578422612 | ||
|
ad04da84c9 | ||
|
333b013f7f | ||
|
b3dc517565 | ||
|
70e4dabe89 | ||
|
d3443d6f2a | ||
|
a508f68044 | ||
|
f191b64bbc | ||
|
e9efe77839 | ||
|
d98c0d32f2 | ||
|
dfa2dcceb8 | ||
|
d441e7106b | ||
|
4cd92f979c | ||
|
d1a068e5b1 | ||
|
4d90846182 | ||
|
986f721938 | ||
|
7903246355 | ||
|
0252ae2be3 | ||
|
fa90e42a38 | ||
|
2d36109565 | ||
|
de8258171a | ||
|
2ed6224778 | ||
|
e1a0171094 | ||
|
395521f3d3 | ||
|
8c95a84ea4 | ||
|
75db19c789 | ||
|
f00d2b30bb | ||
|
c0c5ce2f9b | ||
|
ee9f9ae05e | ||
|
387649ded4 | ||
|
be12131d74 | ||
|
896ebdc9d7 | ||
|
bc58bd0b83 | ||
|
8d4c87876b | ||
|
cebc99ddc7 | ||
|
1b62203f18 | ||
|
06dd8c2cfd | ||
|
5da21ca4dc | ||
|
3e16ef33b0 | ||
|
2746a2d929 | ||
|
e31bacf7be | ||
|
911ae64931 | ||
|
99a0b35705 | ||
|
89bf8af878 | ||
|
f3744c991a | ||
|
dcee15c0f1 | ||
|
2321e9de05 | ||
|
73dcda460f | ||
|
0f8bc67a98 | ||
|
379d830123 | ||
|
bc8bc68b80 | ||
|
8c4df51a14 | ||
|
06d67d2384 | ||
|
cc8bb5fc54 | ||
|
8fb1e33d0f | ||
|
0dc946da63 | ||
|
26a23d3e56 | ||
|
766f4bc8fe | ||
|
3d008d5929 | ||
|
0546e26434 | ||
|
e6d8eedc00 | ||
|
13b37b0ba4 | ||
|
779c71b66d | ||
|
8e73d007f5 | ||
|
e376d638fb | ||
|
52982a88aa | ||
|
422c1d9c0d | ||
|
ccc8ad8700 | ||
|
6b0eb970d8 | ||
|
775e35865c | ||
|
49ce680d53 | ||
|
463f3d3a52 | ||
|
f6347f18b0 | ||
|
2e959fe300 | ||
|
56f771ba29 | ||
|
32e96215b4 | ||
|
86f800e11d | ||
|
4d371b2b16 | ||
|
7e97c2513f | ||
|
2bf5a150e6 | ||
|
18c87faaa5 | ||
|
fdeda388bf | ||
|
ea2c27c640 | ||
|
dfc04a590d | ||
|
fe5b364675 | ||
|
9b73c55559 | ||
|
0b38a0663d | ||
|
e5c0716293 | ||
|
54a3293cad | ||
|
818287a7ce | ||
|
59119cd898 | ||
|
817da34f7e | ||
|
8fa44fc3e6 | ||
|
c7e94151b2 | ||
|
729ba44297 | ||
|
2a2a6879c5 | ||
|
e7b773b031 | ||
|
57a225681c | ||
|
ea07a92366 | ||
|
76290e8ddb | ||
|
26d83b1ab7 | ||
|
2bba856206 | ||
|
bf3382a89e | ||
|
3162e25671 | ||
|
3d931b4fe2 | ||
|
fc770a383a | ||
|
62c385a9dd | ||
|
7c4ad1a5c4 | ||
|
ac524bb13a | ||
|
66fa9380b5 | ||
|
b64eb6ca13 | ||
|
9b2d8ac362 | ||
|
2a90bc1a9b | ||
|
d4b868d9bc | ||
|
b54f6710a7 | ||
|
6bb7caf155 | ||
|
202348f9d0 | ||
|
1a613de2f6 | ||
|
665df37703 | ||
|
acad5e4e3d | ||
|
6267c8469b | ||
|
5a2f791bdd | ||
|
286a00a1db | ||
|
11dd602b28 | ||
|
35988d659d | ||
|
be3449b3ce | ||
|
2d8fddc1e9 | ||
|
644d522d19 | ||
|
a8b0125da1 | ||
|
acccac516e | ||
|
d65214fa4e | ||
|
1d96fc8237 | ||
|
882a87ca19 | ||
|
1dbb8df95f | ||
|
f6c2c2edbd | ||
|
c4e4de36f6 | ||
|
67cbb2a7d3 | ||
|
a979daa8ea | ||
|
fb14f50ec1 | ||
|
6099fbafc1 | ||
|
6f2f828bce | ||
|
795d3122cc | ||
|
5080730728 | ||
|
f75a3a0e95 | ||
|
b75db7d1c6 | ||
|
b03069bdf6 | ||
|
1c71e56e75 | ||
|
9332d0dcc8 | ||
|
9ad37583e6 | ||
|
69975627e9 | ||
|
b74a489aba | ||
|
599b807726 | ||
|
6510ca8bdd | ||
|
be20a04e04 | ||
|
92e5536335 | ||
|
c2da2f7ecd | ||
|
130bd5937c | ||
|
54bfd380a8 | ||
|
f01d695e6c | ||
|
619b2465c1 | ||
|
cc18191a8e | ||
|
1f8e7c8aab | ||
|
671daea262 | ||
|
76533513c2 | ||
|
0d3988365b | ||
|
0966636803 | ||
|
7c3b30036e | ||
|
988901294d | ||
|
43b9fc6981 | ||
|
25f670faae | ||
|
d0068a036f | ||
|
fae014eb45 | ||
|
f0ea0be15d | ||
|
9650236b23 | ||
|
c0e2d7c62f | ||
|
cc072eb7cd | ||
|
613213f597 | ||
|
e25c25fcb5 | ||
|
52666d6fe5 | ||
|
56b3669411 | ||
|
e3b5b76cdd | ||
|
bbb28196e5 | ||
|
72d3a9042c | ||
|
f2853ffa8e | ||
|
fca2ba963d | ||
|
806779769e | ||
|
82aa0d1f7c | ||
|
72f1d34eca | ||
|
c267a75eef | ||
|
7170fdebb9 | ||
|
7ccf32db57 | ||
|
520c2116a3 | ||
|
e818685921 | ||
|
6ddd9793f3 | ||
|
6bdca276a2 | ||
|
d4ff275002 | ||
|
2b6f243578 | ||
|
8770584bfb | ||
|
4f7f15700c | ||
|
cab6808673 | ||
|
b77110c35a | ||
|
c4e8218f49 | ||
|
c8b57154cb | ||
|
c4b2112f16 | ||
|
3132353ec5 | ||
|
3dc6267146 | ||
|
6a6146a9e0 | ||
|
01fbf8444b | ||
|
1f8c79eca1 | ||
|
5229069101 | ||
|
a6752bd3e0 | ||
|
93a51f77c4 | ||
|
9f2926dde3 | ||
|
d31bb8b503 | ||
|
d46b04631e | ||
|
30eca5a523 | ||
|
4fa71fd82a | ||
|
6819c7c792 | ||
|
0c9a0dfed1 | ||
|
5d9bcfb64a | ||
|
7047d68404 | ||
|
334f95479b | ||
|
9dff4d6ff3 | ||
|
4d7d031ee0 | ||
|
7c98af6358 | ||
|
ddcba4d33f | ||
|
59fe4a3a09 | ||
|
6774f36636 | ||
|
608cbc28af | ||
|
117c71faeb | ||
|
24d6a190af | ||
|
6a4b5ead86 | ||
|
2fb755e0c9 | ||
|
cd096819d8 | ||
|
674ede8665 | ||
|
8a269de89a | ||
|
ace4eac25a | ||
|
66bce08d10 | ||
|
65902367c6 | ||
|
8f0b92e42d | ||
|
f3d5f6628d | ||
|
4d687366ed | ||
|
3aa5019e70 | ||
|
4fb495d0fe | ||
|
83543423e2 | ||
|
d0bb72a2aa | ||
|
8cc2a44268 | ||
|
4800dd3f95 | ||
|
2534310ce9 | ||
|
3a4fbc5e50 | ||
|
89a67ac719 | ||
|
21b84b1890 | ||
|
20935f678b | ||
|
c41b4130c6 | ||
|
f1b010af66 | ||
|
ec1133d6e1 | ||
|
8fcf1b78a4 | ||
|
21f9148155 | ||
|
d4f0593b37 | ||
|
c447fa8442 | ||
|
3a70ca9d03 | ||
|
5d11e9812d | ||
|
0d10982379 | ||
|
c20a966f06 | ||
|
64db05d3dd | ||
|
913cd91df0 | ||
|
2c5533589d | ||
|
cfdc81af02 | ||
|
7fa8a69fdc | ||
|
fd2861d683 | ||
|
cd9f5733b3 | ||
|
8b4560cbfb | ||
|
2d914d52be | ||
|
a26865e741 | ||
|
3558beaa61 | ||
|
9b9a9f14e2 | ||
|
0ce4f66976 | ||
|
b81bbde7c8 | ||
|
3f55bfe2cb | ||
|
4185ba242b | ||
|
e04191a5ea | ||
|
f07d304f19 | ||
|
1d1f618a13 | ||
|
e20610cdc6 | ||
|
721396b6d6 | ||
|
dc1dbe6158 | ||
|
30488e60e2 | ||
|
a5949960bc | ||
|
ec4a489093 | ||
|
7c52e03815 | ||
|
724c9361f3 | ||
|
147388e69a | ||
|
64aa281c97 | ||
|
c2b0330c56 | ||
|
de4803bb21 | ||
|
e574dcb091 | ||
|
488b0cbb69 | ||
|
6ceab55148 | ||
|
3d8b6f6b79 | ||
|
58d3213eef | ||
|
006dfdc55a | ||
|
a38c423ddb | ||
|
fa0295629b | ||
|
8395698090 | ||
|
277a91dbf8 | ||
|
ff36cfb5be | ||
|
db452f0c45 | ||
|
5b1195f874 | ||
|
d830724d4f | ||
|
0ef0edfa9a | ||
|
0ec868bd69 | ||
|
30e79e8412 | ||
|
c9b032acab | ||
|
1f410faccb | ||
|
d0e56106fe | ||
|
3d3d7dbc59 | ||
|
c0cbf9db5f | ||
|
db82eaec0a | ||
|
f4e200708d | ||
|
ba1944ded2 | ||
|
8eeef54b2e | ||
|
8e549d73a0 | ||
|
102d2a36f3 | ||
|
f046e27bb4 | ||
|
1c5cf17f1c | ||
|
ddb3a4be3e | ||
|
994f32704b | ||
|
1f798643c8 | ||
|
2f8d5e2dcd | ||
|
df30741535 | ||
|
762748028a | ||
|
f7c5cf137c | ||
|
455d91b0fc | ||
|
e834e51c0f | ||
|
bce518b214 | ||
|
3656994f82 | ||
|
fd5f6ef57f | ||
|
386b63b85d | ||
|
803103640a | ||
|
469a4a73f9 | ||
|
f401b05e7b | ||
|
42ed8a2748 | ||
|
f872eb64b5 | ||
|
29d054c421 | ||
|
7be6afe84d | ||
|
cf1fbdf8b5 | ||
|
6d2860efb7 | ||
|
5f29b8fcec | ||
|
59a8106373 | ||
|
c1d90273ca | ||
|
31b95ce47f | ||
|
4fe608e423 | ||
|
2cfeb1048c | ||
|
e8210d5865 | ||
|
fff981b220 | ||
|
a3f4caa291 | ||
|
ec54399d89 | ||
|
83f22fcce2 | ||
|
34a12f47f1 | ||
|
518462d882 | ||
|
1912513d7a | ||
|
1643e81c47 | ||
|
7ff427b456 | ||
|
91a96d27f1 | ||
|
a0f6ff101e | ||
|
9bcf401ef7 | ||
|
67a7ad069f | ||
|
367d24be7f | ||
|
1791c637d0 | ||
|
c6fe8818ed | ||
|
53a30eaa12 | ||
|
692cc42e10 | ||
|
9faaa5e8be | ||
|
418bbb2685 | ||
|
fb148027d9 | ||
|
05736afaf8 | ||
|
8a91d1d1ce | ||
|
2df139cf40 | ||
|
9f1208b595 | ||
|
9fd3212241 | ||
|
293f2e6b1c | ||
|
f83aa16f59 | ||
|
c73dd9ecaf | ||
|
607f08e79b | ||
|
511e5f39fa | ||
|
7d409dd2e0 | ||
|
9b8c0f3c7f | ||
|
727a78a74f | ||
|
a928ea6c57 | ||
|
d3f7dea624 | ||
|
456b7628ee | ||
|
f149beb474 | ||
|
1b0451761a | ||
|
1d26341b03 | ||
|
8348a113c6 | ||
|
bfdede7acc | ||
|
70894b48af | ||
|
b0c6b282fd | ||
|
393054dd3f | ||
|
97b10df723 | ||
|
62b214ffdf | ||
|
3549f43902 | ||
|
45167d5c0d | ||
|
0214b98c5e | ||
|
19c38158fc | ||
|
7ff35340ca | ||
|
a10340859d | ||
|
8475d88af0 | ||
|
79b1d24128 | ||
|
ad98e72884 | ||
|
3fab2b55cc | ||
|
2842030e59 | ||
|
7c2d21892f | ||
|
677bfe6857 | ||
|
b7ddf0b2e5 | ||
|
eb25fc1d5a | ||
|
395d40485d | ||
|
17af979b24 | ||
|
8511f25b97 | ||
|
290611f9ce | ||
|
6280066207 | ||
|
f054c317ee | ||
|
9555e611e1 | ||
|
5629ac3c63 | ||
|
110c316810 | ||
|
470a1aabdd | ||
|
b299d62a73 | ||
|
02b293b59c | ||
|
c659a231d6 | ||
|
4e56581222 | ||
|
e8ba16d9c2 | ||
|
4a43c77f66 | ||
|
55936087e0 | ||
|
3141eaecd0 | ||
|
69e14ba02f | ||
|
dffbcd8fdf | ||
|
ff3b03c5e2 | ||
|
32f4aa12cd | ||
|
fbb7948c13 | ||
|
d81a5a8338 | ||
|
652323a4bf | ||
|
e45518fb5f | ||
|
424e46849a | ||
|
68886ba847 | ||
|
da85815399 | ||
|
3bd648e72e | ||
|
2ae8ace784 | ||
|
1f89f21ca9 | ||
|
c6921cdc9d | ||
|
7c9f2949ce | ||
|
0b13e68bca | ||
|
5dde4c0a39 | ||
|
b2875d7b19 | ||
|
0c1cfbbad1 | ||
|
ddacf8cc43 | ||
|
395d13d5f1 | ||
|
1e6e522a93 | ||
|
f49a02e5b5 | ||
|
1e4dc90d62 | ||
|
2c3a41a81a | ||
|
203bb42cc1 | ||
|
461497e8d4 | ||
|
a974c83423 | ||
|
5eb181281a | ||
|
9eaeb04863 | ||
|
5e6c316603 | ||
|
77b4f6d68e | ||
|
a614716d0f | ||
|
1c856a208f | ||
|
c7916c8e48 | ||
|
0c023bb5bb | ||
|
df73bf38c2 | ||
|
7a1df3f914 | ||
|
3f78199cd5 | ||
|
0a55d4c981 | ||
|
7e03288724 | ||
|
979bf5c6fb | ||
|
a7f5b2e8fc | ||
|
94f246240d | ||
|
bd5fcf2998 | ||
|
c0cf839729 | ||
|
2a51d4fba8 | ||
|
cd1078563d | ||
|
a9943922d5 | ||
|
b46bfcafd1 | ||
|
6141c139e6 | ||
|
0fb83d7619 | ||
|
f64d0d8cbf | ||
|
e5d6bb68ce | ||
|
74899599a6 | ||
|
12c38c1d57 | ||
|
d243c6d7f9 | ||
|
c5481a125e | ||
|
68d80babce | ||
|
981c71c497 | ||
|
10bcbae68c | ||
|
1b265a7971 | ||
|
29c0dfb1d2 | ||
|
dbec5a8ce5 | ||
|
53eb85ba64 | ||
|
73fdefd65c | ||
|
86562a6c5a | ||
|
ceb63b83f2 | ||
|
7373e73067 | ||
|
985ba832fb | ||
|
de729e936d | ||
|
019f4b6b34 | ||
|
5bcb01e182 | ||
|
25c2059abb | ||
|
2a9c92f8e2 | ||
|
d468ea3efa | ||
|
d2cfe9f69a | ||
|
8dbe9e975b | ||
|
dd6174c496 | ||
|
7c1cf7781b | ||
|
9b363a62fe | ||
|
2cc39fe282 | ||
|
6255bd6c08 | ||
|
ab50d2090d | ||
|
c8843d0730 | ||
|
687da2ca6b | ||
|
990a87fd79 | ||
|
c4215a2bec | ||
|
342400d155 | ||
|
1ca308a5fd | ||
|
37eb0496b6 | ||
|
6a13bbbfef | ||
|
c175a7a470 | ||
|
937317e674 | ||
|
4248835ba1 | ||
|
180f7e4861 | ||
|
b526722000 | ||
|
b25bba4862 | ||
|
02ce417279 | ||
|
b0d2ae612f | ||
|
23e3d48eb9 | ||
|
14f26d2345 | ||
|
7c357423a3 | ||
|
cf2d6f6ec5 | ||
|
1443ef85be | ||
|
887aa2abdd | ||
|
9c5d6eaa71 | ||
|
c49318e973 | ||
|
131cc6497a | ||
|
d9d591ff7a | ||
|
f16b34f286 | ||
|
85d822b2e8 | ||
|
4e5689abeb | ||
|
b046c8d4ad | ||
|
72c72d0b37 | ||
|
5e69181d8d | ||
|
9c5a9fb100 | ||
|
ceb2349823 | ||
|
818b7c44be | ||
|
044026d330 | ||
|
66882f3825 | ||
|
1d0235780c | ||
|
770d6cb2bd | ||
|
106e1080ae | ||
|
07ecb3cb78 | ||
|
74ac435ae6 | ||
|
c80ba49a60 | ||
|
404d79153e | ||
|
ed9941ec2c | ||
|
c3b43f2ad2 | ||
|
86718439be | ||
|
933e373b07 | ||
|
e6dcd55480 | ||
|
0d901ef174 | ||
|
716e0db690 | ||
|
90b78132d4 | ||
|
c2285d923d | ||
|
4a79ac4473 | ||
|
2a3e5422ad | ||
|
e0c39dbf7e | ||
|
8c670b3b5d | ||
|
5dddec4dd9 | ||
|
93017bb8db | ||
|
059c45a85b | ||
|
63692a491d | ||
|
bbe79c1ef9 | ||
|
4b241f8da2 | ||
|
bdd6ae3252 | ||
|
24a3ff3aef | ||
|
ba988cd899 | ||
|
1bf1646d25 | ||
|
2c82151d65 | ||
|
d2235b71f3 | ||
|
ecc6c255ef | ||
|
57135acd2d | ||
|
54c098761f | ||
|
2f98400b80 | ||
|
ea7c9b93ea | ||
|
4317c008f0 | ||
|
d605d9ae73 | ||
|
c9fad25131 | ||
|
693200f1eb | ||
|
5f087a9dff | ||
|
b9cde6f8ea | ||
|
86eece78b1 | ||
|
8cb50ac6e9 | ||
|
997fbbde8f | ||
|
805ddc3c3a | ||
|
da9b3a9256 | ||
|
876560924f | ||
|
ca1c89c5bd | ||
|
7875e28d9f | ||
|
bd2f2a6f65 | ||
|
541aaa2392 | ||
|
d294b01cee | ||
|
5d9dc25115 | ||
|
c8988ec784 | ||
|
071dbc1115 | ||
|
80c5e4a156 | ||
|
6eac3063fa | ||
|
27925fcb0e | ||
|
5f4d21422a | ||
|
b0bb413faa | ||
|
37633985bd | ||
|
6ff8f1b2fd | ||
|
d13a3c7540 | ||
|
0a469d7bd6 | ||
|
115edc5fd1 | ||
|
a28c75f215 | ||
|
b9d7dab329 | ||
|
bb7500e984 | ||
|
e94268944b | ||
|
3225b487e8 | ||
|
e35c0e043e | ||
|
b251893030 | ||
|
15257e3922 | ||
|
180a5a1ad7 | ||
|
11f971d870 | ||
|
7c382c6b47 | ||
|
087f42d998 | ||
|
2abb5b6419 | ||
|
f2259adcdc | ||
|
a73457237d | ||
|
9f335d3ee6 | ||
|
856c8950ff | ||
|
61ccf4e719 | ||
|
1567db1f02 | ||
|
8316d5e366 | ||
|
8fca040163 | ||
|
c0fe1a7ffe | ||
|
e72c243aca | ||
|
14605d4b92 | ||
|
d1509971d8 | ||
|
951c9c5d73 | ||
|
3e6e247e56 | ||
|
27ce68b74a | ||
|
b0cf7a95b0 | ||
|
fd7f19c934 | ||
|
8090e213de | ||
|
de6327a885 | ||
|
8699c0f340 | ||
|
bda5454549 | ||
|
c3a6e35070 | ||
|
71c29bfcff | ||
|
647ed59d11 | ||
|
a0c489048a | ||
|
0f9def660d | ||
|
9fa65eadae | ||
|
facfff0022 | ||
|
f8b4083f47 | ||
|
b047b7838d | ||
|
b1c00ecee6 | ||
|
93abd8da59 | ||
|
3412f0554f | ||
|
61c83f9ffe | ||
|
3d7c1f8950 | ||
|
b0e81acc12 | ||
|
a682d97663 | ||
|
0e5137ae61 | ||
|
005a3da18f | ||
|
be6bcf882d | ||
|
fb344e8108 | ||
|
b99389bcb8 | ||
|
0fefdc99b2 | ||
|
e63419fbf4 | ||
|
428bb09a35 | ||
|
7c2c795681 | ||
|
165f352c58 | ||
|
3d6e702f63 | ||
|
597e9a96b4 | ||
|
6f4ed6c105 | ||
|
c3eafed472 | ||
|
7480fb703e | ||
|
24e8b484e0 | ||
|
d60f7f2e7a | ||
|
0dcffe7c33 | ||
|
9f09cfcfbd | ||
|
7373cd962c | ||
|
ac3f0df083 | ||
|
f95d54a13d | ||
|
fc512f0b9f | ||
|
f5ed59b7f2 | ||
|
9d51aa1443 | ||
|
f0bdc865b9 | ||
|
eda1703f9d | ||
|
51fc382582 | ||
|
6e52ef96a4 | ||
|
9606c1eee9 | ||
|
959c101400 | ||
|
6b096e5c5b | ||
|
9ac1eacdc8 | ||
|
8e7395a7e3 | ||
|
80fbc1b72d | ||
|
17ea03eee2 | ||
|
985b5a052e | ||
|
ed1872f0a8 | ||
|
34841c3a5f | ||
|
185f0181ac | ||
|
60d6a0f2d5 | ||
|
99a1d10bf1 | ||
|
2f1028ed79 | ||
|
f631e0e1e0 | ||
|
6df489d5a9 | ||
|
15c6ad88c0 | ||
|
40f6a9d830 | ||
|
bd06c00f3a | ||
|
f6d23f0c29 | ||
|
2a24459b92 | ||
|
f6da324670 | ||
|
11a18bd61a | ||
|
972134abe4 | ||
|
f8770b78ea | ||
|
10f2b11fda | ||
|
ea1cc4b991 | ||
|
8bee3e2fe0 | ||
|
1f7adfd9ff | ||
|
9e55cd68e4 | ||
|
2a6dc67fd7 | ||
|
1061ad289a | ||
|
0f81b58545 | ||
|
2437c5a0ae | ||
|
669a6ddeaa | ||
|
f5de46670b | ||
|
91af8a705b | ||
|
82c314f1af | ||
|
672413f1f6 | ||
|
843bf23f84 | ||
|
eeb2d2cc38 | ||
|
c370b8f309 | ||
|
acd9c12667 | ||
|
5535b26395 | ||
|
20611cf68c | ||
|
06c34ce02f | ||
|
4fb50c7408 | ||
|
c37bea1676 | ||
|
ed985640e8 | ||
|
2bd938952d | ||
|
623a56391c | ||
|
1b7fb10361 | ||
|
f6b6688186 | ||
|
99453e937c | ||
|
d3e0a1f68c | ||
|
76ff1a2a49 | ||
|
51c6ce1734 | ||
|
1998b673f4 | ||
|
627497f942 | ||
|
f9287941b4 | ||
|
5059854a2e | ||
|
aa8a061a83 | ||
|
3f2d44d517 | ||
|
b4af23be23 | ||
|
8ddf1f1ea5 | ||
|
475d8c4c11 | ||
|
fc823eb610 | ||
|
8707bab450 | ||
|
612955f2b7 | ||
|
36314c3ff7 | ||
|
33fb38d8de | ||
|
38e2a910df | ||
|
ef32df77be | ||
|
5154693ea4 | ||
|
4b68362981 | ||
|
658e4c5357 | ||
|
ce0dd650d7 | ||
|
77b65ada4f | ||
|
fa37225a42 | ||
|
78a06859b9 | ||
|
3ec8f4e84e | ||
|
f13a596d15 | ||
|
94f14778a3 | ||
|
7312284e4f | ||
|
ebc07d1458 | ||
|
510f719975 | ||
|
03c2202942 | ||
|
b3a97cb755 | ||
|
a9273e1c73 | ||
|
14d11ebcab | ||
|
7dc458d925 | ||
|
a0f04bdcf3 | ||
|
28f6e27276 | ||
|
5ef427bd65 | ||
|
03c1fa43f4 | ||
|
3b9f0ab866 | ||
|
9617a00ae3 | ||
|
1408199957 | ||
|
067df8d4dd | ||
|
2ab1b13092 | ||
|
964d0c219a | ||
|
c58eb9c276 | ||
|
5d4893b3f0 | ||
|
11b4e0d4c0 | ||
|
e637693131 | ||
|
c9d5b77403 | ||
|
574595993c | ||
|
50f4e53aef | ||
|
ac082e5504 | ||
|
f65f9591a1 | ||
|
a1eadde25b | ||
|
66e5027756 | ||
|
aa2d339508 | ||
|
d43aacefc9 | ||
|
f0a0e20b2f | ||
|
befdd8bb66 | ||
|
27ed2cc009 | ||
|
a60c866a12 | ||
|
a84f6228ca | ||
|
19da93b675 | ||
|
aa38fc712f | ||
|
0b1c91dc7c | ||
|
ab2c8de4de | ||
|
00f2b134e3 | ||
|
0b8cebd6ef | ||
|
53a9b7f6c0 | ||
|
667fd927ee | ||
|
a8956838d3 | ||
|
e7c9e2060c | ||
|
f6be407e33 | ||
|
2bf9b37e59 | ||
|
d2e0ada794 | ||
|
c07ae5806e | ||
|
5afe6f7825 | ||
|
d02c48f987 | ||
|
c835214540 | ||
|
cb2901ec40 | ||
|
f27bd061fb | ||
|
572386e4ce | ||
|
67a972182e | ||
|
5955e11a5a | ||
|
8daaafc864 | ||
|
ebaa96c0fa | ||
|
fb3d08c651 | ||
|
9d15e64f0b | ||
|
b62564fd98 | ||
|
0266bcab7a | ||
|
6652e14662 | ||
|
7a50f86f3f | ||
|
59218d02c8 | ||
|
fe73730d21 | ||
|
b814970bdd | ||
|
8dfbef5e6f | ||
|
0b9a3fc160 | ||
|
79105962a7 | ||
|
a36e2bc764 | ||
|
cc878160bd | ||
|
382153e82d | ||
|
e195341e30 | ||
|
c6c8263704 | ||
|
ed02bea20d | ||
|
f89a1b05fe | ||
|
af65b7e6d7 | ||
|
1995ad6d63 | ||
|
83c0937a46 | ||
|
f5cc2c0d20 | ||
|
931d68bc92 | ||
|
06946c35d3 | ||
|
cbe81fd443 | ||
|
173e919d2a | ||
|
73fdb8f7b0 | ||
|
8e0ba37866 | ||
|
8780f50e7e | ||
|
06dc357ea0 | ||
|
fb587cb529 | ||
|
a026677849 | ||
|
1c389b1f24 | ||
|
55b9aa0309 | ||
|
2d5cf2b4c4 | ||
|
4877bb5b5c | ||
|
b9269d5644 | ||
|
1a4723988e | ||
|
93353888ca | ||
|
c3a90b76d0 | ||
|
43e5ca9a1b | ||
|
c5829bd0e2 | ||
|
2a9d2cc7e9 | ||
|
0d9873d8bc | ||
|
23bc38ed06 | ||
|
42d26b4b05 | ||
|
04700789e1 | ||
|
e23baa59f0 | ||
|
e8e28b61db | ||
|
b766707f28 | ||
|
0787f262a0 | ||
|
d833f4a632 | ||
|
ce1e364ab8 | ||
|
adb5b299c9 | ||
|
fc9462d49e | ||
|
9c849d2084 | ||
|
336b30c532 | ||
|
b331e29e43 | ||
|
54cdafdd67 | ||
|
30541201b6 | ||
|
6346fa960c | ||
|
99c98d0736 | ||
|
496e673d77 | ||
|
d3aad3b574 | ||
|
371dab51bb | ||
|
3ea2258ce9 | ||
|
c7feae65f1 | ||
|
b087948933 | ||
|
f611d55f16 | ||
|
12b1007046 | ||
|
4a4c15b2ac | ||
|
8804427677 | ||
|
d717971f41 | ||
|
f33df84eff | ||
|
7910271b6c | ||
|
e3ce99988f | ||
|
fb78f1ef8e | ||
|
1ba1eda8ab | ||
|
2945430ad7 | ||
|
66500a6882 | ||
|
2c4c07c96d | ||
|
69c86ae385 | ||
|
21eac434c3 | ||
|
2f21003064 | ||
|
58b65d1bf6 | ||
|
542829ee81 | ||
|
b43c8ae646 | ||
|
22e6fa3a64 | ||
|
c337887e29 | ||
|
650688c635 | ||
|
2787e916b2 | ||
|
e72119e9bb | ||
|
efcb3a9d67 | ||
|
9f19699806 | ||
|
326cb1148b | ||
|
767e7cb06f | ||
|
084725e280 | ||
|
6e3b6980de | ||
|
9927d9bda2 | ||
|
34c6ef5332 | ||
|
8af3e407c2 | ||
|
8736343544 | ||
|
9caca0b127 | ||
|
9d86020d4c | ||
|
32eedec565 | ||
|
1af004361c | ||
|
b33c56819b | ||
|
30f09ea10b | ||
|
db3e225f09 | ||
|
a44c06b264 | ||
|
f5f9f70dd0 | ||
|
03e5c6e32d | ||
|
ca9e0c0e68 | ||
|
0e1632d002 | ||
|
f4eb026c86 | ||
|
e46fa81927 | ||
|
33c6b428f7 | ||
|
12331e3376 | ||
|
dd5e6d47db | ||
|
2541037ec2 | ||
|
9d6aa7d88e | ||
|
0bd16308d6 | ||
|
0011ce949c | ||
|
cc987b31ae | ||
|
c092d0a616 | ||
|
ea390a4a73 | ||
|
6b98948f9a | ||
|
f57afe51af | ||
|
bc22d04737 | ||
|
093677b0f8 | ||
|
c38e050cc7 | ||
|
ba0122fd02 | ||
|
affd2737d5 | ||
|
cc68073af0 | ||
|
cb2948eda6 | ||
|
1b105cdbef | ||
|
dd436e8fe6 | ||
|
a8d2bb6b22 | ||
|
fcdc5030bd | ||
|
aad9adf8c3 | ||
|
48a223abdf | ||
|
12e720fb23 | ||
|
042e13a932 | ||
|
2b9481ecdc | ||
|
933c0c678a | ||
|
2539828eac | ||
|
4b6f3e0f2c | ||
|
b9eb818b57 | ||
|
eda547fc4e | ||
|
1dbd017766 | ||
|
08d9a57c6e | ||
|
d7b5966fa7 | ||
|
bb44120ae3 | ||
|
8b1f034242 | ||
|
bb7968ba77 | ||
|
7451e51619 | ||
|
ea93e18081 | ||
|
443e44853a | ||
|
b73e95655d | ||
|
e8bb84e0e2 | ||
|
626c525706 | ||
|
2ef2148fb5 | ||
|
86ad1bec16 | ||
|
360a728d77 | ||
|
cfcf0a7a8a | ||
|
f57fca7a00 | ||
|
7c38ac1954 | ||
|
dbe802f685 | ||
|
cfb293d396 | ||
|
2227fb957f | ||
|
824326a029 | ||
|
10b967ae1f | ||
|
0174bf4345 | ||
|
1acfae8df2 | ||
|
ce489f21fb | ||
|
368f04e06b | ||
|
dc91782165 | ||
|
86a75abe51 | ||
|
70aaecc937 | ||
|
057effc5d6 | ||
|
d8c116f20a | ||
|
01386aef29 | ||
|
b3fb80c608 | ||
|
5b69fd535d | ||
|
7831980c1d | ||
|
fbfc7dc690 | ||
|
d8eec549f0 | ||
|
7389e704dc | ||
|
b64da6d268 | ||
|
2ba2a216ca | ||
|
e5add36a17 | ||
|
fe14181d4e | ||
|
378a573cf4 | ||
|
ec8684e87d | ||
|
54042029d3 | ||
|
e1fa627158 | ||
|
9d5bb875b1 | ||
|
b3c150e929 | ||
|
d03a55599b | ||
|
ed8fe6c219 | ||
|
c835ae2a02 | ||
|
e20c207a22 | ||
|
e19c4a3372 | ||
|
934bfc8887 | ||
|
713a6676ff | ||
|
448a88e4f5 | ||
|
ed22af50bc | ||
|
d3dc9c41b4 | ||
|
d1b2ded7e2 | ||
|
ee3faf24b9 | ||
|
16ab648093 | ||
|
11a1f8f36a | ||
|
1eda9884a0 | ||
|
ae4bb2d914 | ||
|
6d68c536f3 | ||
|
e74a9d09e6 | ||
|
b2b847f365 | ||
|
cb15ec0257 | ||
|
115923b2d9 | ||
|
ad60efb5d7 | ||
|
b7efe4eb4f | ||
|
92c359ca09 | ||
|
ec742f9373 | ||
|
fde75aa9f6 | ||
|
2df3c39e50 | ||
|
22659afd00 | ||
|
410e7dcf5d | ||
|
bd8655fdee | ||
|
e9f1ee5aab | ||
|
4abdf695e3 | ||
|
b1090ac8e2 | ||
|
1ab081b584 | ||
|
1df17f2fea | ||
|
682e97826c | ||
|
805fea20cb | ||
|
415bfeb950 | ||
|
2f20a40922 | ||
|
5235a4c48a | ||
|
bb7f6ed544 | ||
|
f1d6a0a4ed | ||
|
3c1cca13b7 | ||
|
1ef805328f | ||
|
fd73f8d972 | ||
|
3a8ebf4c9f | ||
|
b482b7d8af | ||
|
0d69c42320 | ||
|
011f5afe4e | ||
|
8bab7b237c | ||
|
821a458393 | ||
|
66120cff4b | ||
|
8ce1034e87 | ||
|
a39d708859 | ||
|
98df0be43d | ||
|
4125eb01ba | ||
|
0bd039a524 | ||
|
f4705bab1e |
@@ -17,7 +17,12 @@ stages:
|
||||
# Common variables
|
||||
variables:
|
||||
COMMON_MESON_FLAGS: "--fatal-meson-warnings --werror"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 2
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true -Dvulkan=yes"
|
||||
FEATURE_FLAGS: "-Dcloudproviders=true"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v20"
|
||||
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
|
||||
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19"
|
||||
|
||||
.only-default:
|
||||
only:
|
||||
@@ -27,14 +32,14 @@ variables:
|
||||
|
||||
style-check-diff:
|
||||
extends: .only-default
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v17
|
||||
image: $FEDORA_IMAGE
|
||||
stage: .pre
|
||||
allow_failure: true
|
||||
script:
|
||||
- .gitlab-ci/run-style-check-diff.sh
|
||||
|
||||
.build-fedora-default:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v17
|
||||
image: $FEDORA_IMAGE
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -66,11 +71,7 @@ fedora-x86_64:
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
|
||||
script:
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
|
||||
-Dx11-backend=true
|
||||
-Dwayland-backend=true
|
||||
-Dbroadway-backend=true
|
||||
-Dvulkan=yes
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
|
||||
-Dprofiler=true
|
||||
_build
|
||||
- ninja -C _build
|
||||
@@ -84,11 +85,7 @@ release-build:
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
script:
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
|
||||
-Dx11-backend=true
|
||||
-Dwayland-backend=true
|
||||
-Dbroadway-backend=true
|
||||
-Dvulkan=yes
|
||||
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
|
||||
_build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build x11
|
||||
@@ -110,14 +107,14 @@ release-build:
|
||||
- subprojects/libepoxy/
|
||||
- subprojects/pango/
|
||||
|
||||
msys2-mingw32:
|
||||
msys2-mingw64:
|
||||
extends: .mingw-defaults
|
||||
variables:
|
||||
MSYSTEM: "MINGW32"
|
||||
MSYSTEM: "MINGW64"
|
||||
CHERE_INVOKING: "yes"
|
||||
|
||||
.flatpak-defaults:
|
||||
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
|
||||
image: $FLATPAK_IMAGE
|
||||
stage: flatpak
|
||||
allow_failure: true
|
||||
tags:
|
||||
@@ -171,7 +168,7 @@ flatpak-master:icon-browser:
|
||||
APPID: org.gtk.IconBrowser4
|
||||
|
||||
static-scan:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
|
||||
image: $FEDORA_IMAGE
|
||||
stage: analysis
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=debug"
|
||||
@@ -183,8 +180,24 @@ static-scan:
|
||||
- _scan_build/meson-logs
|
||||
allow_failure: true
|
||||
|
||||
# Run tests with the address sanitizer. We need to turn off introspection,
|
||||
# since it is incompatible with asan
|
||||
asan-build:
|
||||
image: $FEDORA_IMAGE
|
||||
tags: [ asan ]
|
||||
stage: analysis
|
||||
variables:
|
||||
script:
|
||||
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=false _build
|
||||
- ninja -C _build
|
||||
- .gitlab-ci/run-tests.sh _build wayland
|
||||
artifacts:
|
||||
paths:
|
||||
- _build/meson-logs
|
||||
allow_failure: true
|
||||
|
||||
reference:
|
||||
image: registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19
|
||||
image: $DOCS_IMAGE
|
||||
stage: docs
|
||||
variables:
|
||||
EXTRA_MESON_FLAGS: "--buildtype=release"
|
||||
|
0
.gitlab-ci/.lock
Normal file
0
.gitlab-ci/.lock
Normal file
@@ -35,4 +35,13 @@ branch, as well as their available versions.
|
||||
- [ ] Add the new job to `.gitlab-ci.yml` referencing the image
|
||||
- [ ] Open a merge request with your changes and let it run
|
||||
|
||||
### Checklist for Adding a new dependency to a CI image
|
||||
|
||||
Our images are layered, and the base (called fedora-base) contains
|
||||
all the rpm payload. Therefore, adding a new dependency is a 2-step
|
||||
process:
|
||||
|
||||
1. [ ] Build and upload fedora-base:$version+1
|
||||
1. [ ] Build and upload fedora:$version+1 based on fedora-base:version+1
|
||||
|
||||
[registry]: https://gitlab.gnome.org/GNOME/gtk/container_registry
|
||||
|
@@ -41,12 +41,14 @@ RUN dnf -y install \
|
||||
itstool \
|
||||
json-glib-devel \
|
||||
lcov \
|
||||
libasan \
|
||||
libattr-devel \
|
||||
libepoxy-devel \
|
||||
libffi-devel \
|
||||
libmount-devel \
|
||||
librsvg2 \
|
||||
libselinux-devel \
|
||||
libubsan \
|
||||
libXcomposite-devel \
|
||||
libXcursor-devel \
|
||||
libXcursor-devel \
|
||||
|
@@ -1,4 +1,4 @@
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v19
|
||||
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v20
|
||||
|
||||
ARG HOST_USER_ID=5555
|
||||
ENV HOST_USER_ID ${HOST_USER_ID}
|
||||
|
@@ -4,8 +4,15 @@ set -e
|
||||
|
||||
# We need to add a new remote for the upstream master, since this script could
|
||||
# be running in a personal fork of the repository which has out of date branches.
|
||||
git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
|
||||
git fetch upstream
|
||||
if [ "${CI_PROJECT_NAMESPACE}" != "GNOME" ]; then
|
||||
echo "Retrieving the current upstream repository from ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}..."
|
||||
git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
|
||||
git fetch upstream
|
||||
ORIGIN="upstream"
|
||||
else
|
||||
echo "Reusing the existing repository on ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}"
|
||||
ORIGIN="origin"
|
||||
fi
|
||||
|
||||
# Work out the newest common ancestor between the detached HEAD that this CI job
|
||||
# has checked out, and the upstream target branch (which will typically be
|
||||
@@ -13,7 +20,7 @@ git fetch upstream
|
||||
#
|
||||
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if we’re running in
|
||||
# a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
|
||||
newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
|
||||
newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "${ORIGIN}/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
|
||||
git diff -U0 --no-color "${newest_common_ancestor_sha}" | .gitlab-ci/clang-format-diff.py -binary "clang-format" -p1
|
||||
exit_status=$?
|
||||
|
||||
|
@@ -7,10 +7,14 @@ srcdir=$( pwd )
|
||||
builddir=$1
|
||||
backend=$2
|
||||
|
||||
# Ignore memory leaks lower in dependencies
|
||||
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp
|
||||
|
||||
case "${backend}" in
|
||||
x11)
|
||||
xvfb-run -a -s "-screen 0 1024x768x24" \
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
@@ -30,6 +34,7 @@ case "${backend}" in
|
||||
export WAYLAND_DISPLAY=wayland-5
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
@@ -48,6 +53,7 @@ case "${backend}" in
|
||||
export BROADWAY_DISPLAY=:5
|
||||
|
||||
meson test -C ${builddir} \
|
||||
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
|
||||
--print-errorlogs \
|
||||
--setup=${backend} \
|
||||
--suite=gtk \
|
||||
|
@@ -34,8 +34,8 @@ pacman --noconfirm -S --needed \
|
||||
mingw-w64-$MSYS2_ARCH-shared-mime-info
|
||||
|
||||
# https://gitlab.gnome.org/GNOME/gtk/issues/2243
|
||||
wget "https://gitlab.gnome.org/creiter/gitlab-ci-win32-runner-v2/raw/master/pango/mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
|
||||
pacman --noconfirm -U "mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
|
||||
wget "https://gitlab.gnome.org/creiter/gitlab-ci-win32-runner-v2/raw/master/pango/mingw-w64-$MSYS2_ARCH-pango-git-1.44.7.90.ge48ae523-1-any.pkg.tar.zst"
|
||||
pacman --noconfirm -U "mingw-w64-$MSYS2_ARCH-pango-git-1.44.7.90.ge48ae523-1-any.pkg.tar.zst"
|
||||
|
||||
# https://github.com/msys2/MINGW-packages/pull/6465
|
||||
pacman --noconfirm -S --needed mingw-w64-$MSYS2_ARCH-brotli
|
||||
|
175
NEWS
175
NEWS
@@ -1,3 +1,178 @@
|
||||
Overview of Changes in GTK 3.99.0
|
||||
=================================
|
||||
|
||||
* Add GtkEditableLabel, a label that can be edited
|
||||
|
||||
* Add GtkBookmarkList, a list model for bookmarks
|
||||
|
||||
* Add GtkStringList, a list model for strings
|
||||
|
||||
* Add GtkBitset, and use it for representing selections
|
||||
|
||||
* GtkTreeView:
|
||||
- Make cell editing work again
|
||||
|
||||
* GtkSpinButton:
|
||||
- Make autosizing work again
|
||||
|
||||
* Printing:
|
||||
- Use GtkDropDown in the print dialog
|
||||
|
||||
* GtkApplication
|
||||
- Support opening files on OS X
|
||||
|
||||
* GtkFileChooser:
|
||||
- Fix libcloudproviders support
|
||||
- Turn GtkFileFilter into a GtkFilter
|
||||
- Simplify the api
|
||||
|
||||
* GtkGridView, GtkListView:
|
||||
- Improve scrolling behavior
|
||||
- Autoscroll and autoexpand during DND
|
||||
|
||||
* GtkScrolledWindow:
|
||||
- Make autoscrolling work again
|
||||
|
||||
* GtkFilterListModel:
|
||||
- Add incremental filtering
|
||||
|
||||
* GtkSortListModel:
|
||||
- Use timsort
|
||||
- Add various tweaks that massively speed up sorting
|
||||
- Add incremental sorting
|
||||
|
||||
* GtkWidget:
|
||||
- Massively speed up action handling
|
||||
|
||||
* GtkEntry:
|
||||
- Make entry completion work again
|
||||
- Drop action support from GtkEntryCompletion
|
||||
|
||||
* Inspector:
|
||||
- Improve list model support
|
||||
- Add direct navigation between objects
|
||||
|
||||
* GDK:
|
||||
- Compress scroll events
|
||||
- Keep a scroll history
|
||||
- Clean up GdkDevice api
|
||||
- Improve frame clock accuracy
|
||||
- Add a new macOS backend
|
||||
|
||||
* GSK:
|
||||
- Use GL_ARB_framebuffer_object
|
||||
|
||||
* gtk-demo:
|
||||
- Add incremental refill to the color grid
|
||||
- Improve performance of the color grid
|
||||
- Add an incrementally filtering word list
|
||||
- Improve the sidebar
|
||||
|
||||
* Install print-editor as another demo
|
||||
|
||||
* Translation updates
|
||||
Basque
|
||||
Catalan
|
||||
Chinese
|
||||
Japanese
|
||||
Kazakh
|
||||
Lithuanian
|
||||
Polish
|
||||
Romanian
|
||||
Spanish
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in GTK 3.98.5
|
||||
=================================
|
||||
|
||||
* Introduce new list widgets and supporting infrastructure.
|
||||
The main APIs are:
|
||||
- GtkListView
|
||||
- GtkGridView
|
||||
- GtkColumnView and GtkColumnViewColumn
|
||||
- GtkDropDown
|
||||
- GtkListItemFactory and implementations
|
||||
- GtkExpression
|
||||
- GtkFilter and subclasses, and GtkFilterListModel
|
||||
- GtkSorter and subclasses, and GtkSortListModel
|
||||
- GtkSelectionModel and subclasses
|
||||
- GtkTreeListModel, GtkTreeExpander and GtkTreeListRowSorter
|
||||
|
||||
* GtkFileChooser:
|
||||
- Add a tracker3-based search engine implementation
|
||||
- Rate-limit updates from the trash monitor
|
||||
|
||||
* GtkWindow:
|
||||
- Redo the css node setup. There is now a single 'window' node
|
||||
- Fix rounded corners on tiled windows
|
||||
|
||||
* GtkApplication:
|
||||
- Drop app menu support. Menubar support is still there
|
||||
|
||||
* GtkFixed:
|
||||
- Change coordinate APIs to take doubles
|
||||
|
||||
* GtkOverlay:
|
||||
- Make GtkOverlayLayout public
|
||||
|
||||
* GtkTooltips:
|
||||
- Fix line wrapping of tooltips
|
||||
|
||||
* Shortcuts:
|
||||
- Fix mnemonic cycling
|
||||
- Fix using '0' as a mnemonic
|
||||
|
||||
* Menus:
|
||||
- Differentiate keypad keys in accelerators
|
||||
|
||||
* GtkIMContext:
|
||||
- Add gtk_im_context_filter_key to allow event reinjection
|
||||
|
||||
* Themes:
|
||||
- Adwaita: Limit the scope of backdrop
|
||||
|
||||
* Accessibility:
|
||||
- Clean up and reorganize the code to prepare for the
|
||||
dropping of ATK
|
||||
|
||||
* GDK:
|
||||
- Drop unused enum and struct definitions from headers
|
||||
- Make keymap translation API public again. Still needed
|
||||
- Frameclock: Always use compositor refresh rate info
|
||||
- Frameclock: Use quadratic correction for frame time jitter
|
||||
- Frameclock: Ensure monotonicity
|
||||
- Frameclock: Track resason for paint
|
||||
- X11: Improve sync when the Nvidia driver is used
|
||||
|
||||
* GSK:
|
||||
- GL renderer: Fix blurred outset shadows
|
||||
- GL renderer: handle nested transform nodes properly
|
||||
- GL renderer: Optimize clip handling
|
||||
|
||||
* gtk-demo:
|
||||
- Improve the Drag-and-Drop demo with proper drag icons
|
||||
- Don't show the main window if --run is given
|
||||
- Add demos for list widgets and GtkDropDrown
|
||||
|
||||
* Documentation:
|
||||
- Convert freestanding sections to markdown
|
||||
- Drop the glossary
|
||||
- Expand and improve the migration guide
|
||||
|
||||
* Build:
|
||||
- We require pandoc now, for building the documentation
|
||||
- Require Pango 1.45
|
||||
|
||||
* Translation updates:
|
||||
Polish
|
||||
Romanian
|
||||
Slovenian
|
||||
Turkish
|
||||
Ukrainian
|
||||
|
||||
|
||||
Overview of Changes in GTK 3.98.4
|
||||
=================================
|
||||
|
||||
|
@@ -1,29 +1,38 @@
|
||||
{
|
||||
"app-id": "org.gtk.WidgetFactory4",
|
||||
"runtime": "org.gnome.Platform",
|
||||
"runtime-version": "master",
|
||||
"sdk": "org.gnome.Sdk",
|
||||
"command": "gtk4-widget-factory",
|
||||
"tags": ["devel", "development", "nightly"],
|
||||
"desktop-file-name-prefix": "(Development) ",
|
||||
"finish-args": [
|
||||
"app-id" : "org.gtk.WidgetFactory4",
|
||||
"runtime" : "org.gnome.Platform",
|
||||
"runtime-version" : "master",
|
||||
"sdk" : "org.gnome.Sdk",
|
||||
"command" : "gtk4-widget-factory",
|
||||
"tags" : [
|
||||
"devel",
|
||||
"development",
|
||||
"nightly"
|
||||
],
|
||||
"desktop-file-name-prefix" : "(Development) ",
|
||||
"finish-args" : [
|
||||
"--device=dri",
|
||||
"--share=ipc",
|
||||
"--socket=fallback-x11",
|
||||
"--socket=wayland",
|
||||
"--talk-name=org.gtk.vfs", "--talk-name=org.gtk.vfs.*"
|
||||
"--talk-name=org.gtk.vfs",
|
||||
"--talk-name=org.gtk.vfs.*"
|
||||
],
|
||||
"cleanup": [
|
||||
"cleanup" : [
|
||||
"/include",
|
||||
"/lib/pkgconfig", "/share/pkgconfig",
|
||||
"/lib/pkgconfig",
|
||||
"/share/pkgconfig",
|
||||
"/share/aclocal",
|
||||
"/man", "/share/man", "/share/gtk-doc",
|
||||
"*.la", ".a",
|
||||
"/man",
|
||||
"/share/man",
|
||||
"/share/gtk-doc",
|
||||
"*.la",
|
||||
".a",
|
||||
"/lib/girepository-1.0",
|
||||
"/share/gir-1.0",
|
||||
"/share/doc"
|
||||
],
|
||||
"modules": [
|
||||
"modules" : [
|
||||
{
|
||||
"name" : "wayland",
|
||||
"buildsystem" : "autotools",
|
||||
@@ -39,18 +48,18 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "graphene",
|
||||
"buildsystem": "meson",
|
||||
"builddir": true,
|
||||
"config-opts": [
|
||||
"name" : "graphene",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib",
|
||||
"-Dtests=false",
|
||||
"-Dbenchmarks=false"
|
||||
],
|
||||
"sources": [
|
||||
"sources" : [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/ebassi/graphene.git"
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/ebassi/graphene.git"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -58,7 +67,7 @@
|
||||
"name" : "libsass",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
@@ -73,7 +82,7 @@
|
||||
"name" : "sassc",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts": [
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources" : [
|
||||
@@ -85,18 +94,23 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "gtk",
|
||||
"buildsystem": "meson",
|
||||
"builddir": true,
|
||||
"config-opts": [
|
||||
"name" : "gtk",
|
||||
"buildsystem" : "meson",
|
||||
"builddir" : true,
|
||||
"config-opts" : [
|
||||
"--libdir=/app/lib"
|
||||
],
|
||||
"sources": [
|
||||
"sources" : [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
"type" : "git",
|
||||
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"build-options" : {
|
||||
"env" : {
|
||||
"DBUS_SESSION_BUS_ADDRESS" : "''"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,13 @@ if 'DESTDIR' not in os.environ:
|
||||
gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules')
|
||||
|
||||
print('Compiling GSettings schemas...')
|
||||
subprocess.call(['glib-compile-schemas',
|
||||
glib_compile_schemas = subprocess.check_output(['pkg-config',
|
||||
'--variable=glib_compile_schemas',
|
||||
'gio-2.0']).strip()
|
||||
if not os.path.exists(glib_compile_schemas):
|
||||
# pkg-config variables only available since GLib 2.62.0.
|
||||
glib_compile_schemas = 'glib-compile-schemas'
|
||||
subprocess.call([glib_compile_schemas,
|
||||
os.path.join(gtk_datadir, 'glib-2.0', 'schemas')])
|
||||
|
||||
print('Updating icon cache...')
|
||||
@@ -24,8 +30,14 @@ if 'DESTDIR' not in os.environ:
|
||||
|
||||
print('Updating module cache for print backends...')
|
||||
os.makedirs(gtk_printmodule_dir, exist_ok=True)
|
||||
subprocess.call(['gio-querymodules', gtk_printmodule_dir])
|
||||
gio_querymodules = subprocess.check_output(['pkg-config',
|
||||
'--variable=gio_querymodules',
|
||||
'gio-2.0']).strip()
|
||||
if not os.path.exists(gio_querymodules):
|
||||
# pkg-config variables only available since GLib 2.62.0.
|
||||
gio_querymodules = 'gio-querymodules'
|
||||
subprocess.call([gio_querymodules, gtk_printmodule_dir])
|
||||
|
||||
print('Updating module cache for input methods...')
|
||||
os.makedirs(gtk_immodule_dir, exist_ok=True)
|
||||
subprocess.call(['gio-querymodules', gtk_immodule_dir])
|
||||
subprocess.call([gio_querymodules, gtk_immodule_dir])
|
||||
|
@@ -27,14 +27,6 @@
|
||||
/* Define to 1 if you have the `dcgettext' function. */
|
||||
#mesondefine HAVE_DCGETTEXT
|
||||
|
||||
/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.
|
||||
*/
|
||||
#mesondefine HAVE_DECL_ISINF
|
||||
|
||||
/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
|
||||
*/
|
||||
#mesondefine HAVE_DECL_ISNAN
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#mesondefine HAVE_DLFCN_H
|
||||
|
||||
@@ -80,9 +72,6 @@
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#mesondefine HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the `nearbyint' function. */
|
||||
#mesondefine HAVE_NEARBYINT
|
||||
|
||||
/* Define to 1 if you have the `posix_fallocate' function. */
|
||||
#mesondefine HAVE_POSIX_FALLOCATE
|
||||
|
||||
@@ -92,21 +81,9 @@
|
||||
/* Have the Xrandr 1.5 extension library */
|
||||
#mesondefine HAVE_RANDR15
|
||||
|
||||
/* Define to 1 if you have the `rint' function. */
|
||||
#mesondefine HAVE_RINT
|
||||
|
||||
/* Define to 1 if you have the `round' function. */
|
||||
#mesondefine HAVE_ROUND
|
||||
|
||||
/* Define to 1 if you have the `sincos' function. */
|
||||
#mesondefine HAVE_SINCOS
|
||||
|
||||
/* Define to 1 if you have the `log2` function */
|
||||
#mesondefine HAVE_LOG2
|
||||
|
||||
/* Define to 1 if you ahve the `exp2` function */
|
||||
#mesondefine HAVE_EXP2
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#mesondefine HAVE_STDINT_H
|
||||
|
||||
@@ -146,6 +123,9 @@
|
||||
/* Have the Xcursor library */
|
||||
#mesondefine HAVE_XCURSOR
|
||||
|
||||
/* Have the XDAMAGE X extension */
|
||||
#mesondefine HAVE_XDAMAGE
|
||||
|
||||
/* Have the XFIXES X extension */
|
||||
#mesondefine HAVE_XFIXES
|
||||
|
||||
@@ -294,4 +274,4 @@
|
||||
#mesondefine ISO_CODES_PREFIX
|
||||
|
||||
/* Define if tracker3 is available */
|
||||
#mesondefine HAVE_TRACKER3
|
||||
#mesondefine HAVE_TRACKER3
|
||||
|
@@ -81,11 +81,11 @@ constraint_editor_application_activate (GApplication *app)
|
||||
static void
|
||||
constraint_editor_application_open (GApplication *app,
|
||||
GFile **files,
|
||||
gint n_files,
|
||||
const gchar *hint)
|
||||
int n_files,
|
||||
const char *hint)
|
||||
{
|
||||
ConstraintEditorWindow *win;
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n_files; i++)
|
||||
{
|
||||
|
@@ -193,7 +193,7 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
|
||||
|
||||
static void
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
gint response,
|
||||
int response,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
@@ -285,7 +285,7 @@ serialize_model (GListModel *list)
|
||||
|
||||
static void
|
||||
save_response_cb (GtkNativeDialog *dialog,
|
||||
gint response,
|
||||
int response,
|
||||
ConstraintEditorWindow *self)
|
||||
{
|
||||
gtk_native_dialog_hide (dialog);
|
||||
|
@@ -9,7 +9,6 @@
|
||||
<property name="default-height">768</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">document-open-symbolic</property>
|
||||
|
@@ -169,28 +169,34 @@ constraint_view_init (ConstraintView *self)
|
||||
GListModel *guides;
|
||||
GListModel *children;
|
||||
GListModel *constraints;
|
||||
GtkFilter *filter;
|
||||
|
||||
manager = gtk_constraint_layout_new ();
|
||||
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
|
||||
|
||||
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
|
||||
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
|
||||
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
|
||||
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, omit_internal, NULL, NULL);
|
||||
children = (GListModel *)gtk_filter_list_model_new (all_children, omit_internal, NULL, NULL);
|
||||
|
||||
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
|
||||
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
|
||||
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
|
||||
g_object_unref (filter);
|
||||
g_object_unref (all_constraints);
|
||||
|
||||
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
|
||||
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
|
||||
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
|
||||
g_object_unref (filter);
|
||||
g_object_unref (all_children);
|
||||
|
||||
list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
g_list_store_append (list, children);
|
||||
g_list_store_append (list, guides);
|
||||
g_list_store_append (list, constraints);
|
||||
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_TYPE_OBJECT, G_LIST_MODEL (list)));
|
||||
g_object_unref (children);
|
||||
g_object_unref (guides);
|
||||
g_object_unref (constraints);
|
||||
g_object_unref (all_children);
|
||||
g_object_unref (all_constraints);
|
||||
g_object_unref (list);
|
||||
|
||||
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||
|
||||
controller = (GtkEventController *)gtk_gesture_drag_new ();
|
||||
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
|
||||
|
@@ -184,58 +184,6 @@ max_input (GtkSpinButton *spin_button,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
min_output (GtkSpinButton *spin_button)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
double value;
|
||||
GtkWidget *box, *text;
|
||||
|
||||
adjustment = gtk_spin_button_get_adjustment (spin_button);
|
||||
value = gtk_adjustment_get_value (adjustment);
|
||||
|
||||
box = gtk_widget_get_first_child (GTK_WIDGET (spin_button));
|
||||
text = gtk_widget_get_first_child (box);
|
||||
|
||||
if (value == 0.0)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (spin_button), "");
|
||||
gtk_text_set_placeholder_text (GTK_TEXT (text), "unset");
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_set_placeholder_text (GTK_TEXT (text), "");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
max_output (GtkSpinButton *spin_button)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
double value;
|
||||
GtkWidget *box, *text;
|
||||
|
||||
adjustment = gtk_spin_button_get_adjustment (spin_button);
|
||||
value = gtk_adjustment_get_value (adjustment);
|
||||
|
||||
box = gtk_widget_get_first_child (GTK_WIDGET (spin_button));
|
||||
text = gtk_widget_get_first_child (box);
|
||||
|
||||
if (value == (double)G_MAXINT)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (spin_button), "");
|
||||
gtk_text_set_placeholder_text (GTK_TEXT (text), "unset");
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_set_placeholder_text (GTK_TEXT (text), "");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
guide_editor_constructed (GObject *object)
|
||||
{
|
||||
@@ -244,16 +192,12 @@ guide_editor_constructed (GObject *object)
|
||||
guide_strength_combo (editor->strength);
|
||||
|
||||
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
|
||||
g_signal_connect (editor->min_width, "output", G_CALLBACK (min_output), NULL);
|
||||
|
||||
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
|
||||
g_signal_connect (editor->min_height, "output", G_CALLBACK (min_output), NULL);
|
||||
|
||||
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
|
||||
g_signal_connect (editor->max_width, "output", G_CALLBACK (max_output), NULL);
|
||||
|
||||
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
|
||||
g_signal_connect (editor->max_height, "output", G_CALLBACK (max_output), NULL);
|
||||
|
||||
if (editor->guide)
|
||||
{
|
||||
|
@@ -34,7 +34,7 @@ static void create_window (GApplication *app, const char *contents);
|
||||
static void
|
||||
show_action_dialog (GSimpleAction *action)
|
||||
{
|
||||
const gchar *name;
|
||||
const char *name;
|
||||
GtkWidget *dialog;
|
||||
|
||||
name = g_action_get_name (G_ACTION (action));
|
||||
@@ -58,9 +58,9 @@ show_action_infobar (GSimpleAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
DemoApplicationWindow *window = data;
|
||||
gchar *text;
|
||||
const gchar *name;
|
||||
const gchar *value;
|
||||
char *text;
|
||||
const char *name;
|
||||
const char *value;
|
||||
|
||||
name = g_action_get_name (G_ACTION (action));
|
||||
value = g_variant_get_string (parameter, NULL);
|
||||
@@ -92,7 +92,7 @@ activate_new (GSimpleAction *action,
|
||||
|
||||
static void
|
||||
open_response_cb (GtkNativeDialog *dialog,
|
||||
gint response_id,
|
||||
int response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileChooserNative *native = user_data;
|
||||
@@ -185,7 +185,7 @@ activate_about (GSimpleAction *action,
|
||||
{
|
||||
GtkWidget *window = user_data;
|
||||
|
||||
const gchar *authors[] = {
|
||||
const char *authors[] = {
|
||||
"Peter Mattis",
|
||||
"Spencer Kimball",
|
||||
"Josh MacDonald",
|
||||
@@ -193,7 +193,7 @@ activate_about (GSimpleAction *action,
|
||||
NULL
|
||||
};
|
||||
|
||||
const gchar *documentors[] = {
|
||||
const char *documentors[] = {
|
||||
"Owen Taylor",
|
||||
"Tony Gale",
|
||||
"Matthias Clasen <mclasen@redhat.com>",
|
||||
@@ -244,9 +244,9 @@ static void
|
||||
update_statusbar (GtkTextBuffer *buffer,
|
||||
DemoApplicationWindow *window)
|
||||
{
|
||||
gchar *msg;
|
||||
gint row, col;
|
||||
gint count;
|
||||
char *msg;
|
||||
int row, col;
|
||||
int count;
|
||||
GtkTextIter iter;
|
||||
|
||||
/* clear any previous message, underflow is allowed */
|
||||
|
@@ -16,8 +16,8 @@ static GtkWidget *placeholder;
|
||||
|
||||
static void
|
||||
on_name_appeared (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
const gchar *name_owner,
|
||||
const char *name,
|
||||
const char *name_owner,
|
||||
gpointer user_data)
|
||||
{
|
||||
name_seen = TRUE;
|
||||
@@ -25,7 +25,7 @@ on_name_appeared (GDBusConnection *connection,
|
||||
|
||||
static void
|
||||
on_name_vanished (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
const char *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (!name_seen)
|
||||
@@ -55,7 +55,7 @@ do_application_demo (GtkWidget *toplevel)
|
||||
|
||||
if (placeholder == NULL)
|
||||
{
|
||||
const gchar *command;
|
||||
const char *command;
|
||||
GError *error = NULL;
|
||||
|
||||
if (g_file_test ("./gtk4-demo-application" APP_EXTENSION, G_FILE_TEST_IS_EXECUTABLE))
|
||||
|
@@ -12,7 +12,7 @@ static GtkWidget *progress_bar = NULL;
|
||||
static gboolean
|
||||
apply_changes_gradually (gpointer data)
|
||||
{
|
||||
gdouble fraction;
|
||||
double fraction;
|
||||
|
||||
/* Work, work, work... */
|
||||
fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress_bar));
|
||||
@@ -47,8 +47,8 @@ on_assistant_close_cancel (GtkWidget *widget, gpointer data)
|
||||
static void
|
||||
on_assistant_prepare (GtkWidget *widget, GtkWidget *page, gpointer data)
|
||||
{
|
||||
gint current_page, n_pages;
|
||||
gchar *title;
|
||||
int current_page, n_pages;
|
||||
char *title;
|
||||
|
||||
current_page = gtk_assistant_get_current_page (GTK_ASSISTANT (widget));
|
||||
n_pages = gtk_assistant_get_n_pages (GTK_ASSISTANT (widget));
|
||||
@@ -70,8 +70,8 @@ on_entry_changed (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkAssistant *assistant = GTK_ASSISTANT (data);
|
||||
GtkWidget *current_page;
|
||||
gint page_number;
|
||||
const gchar *text;
|
||||
int page_number;
|
||||
const char *text;
|
||||
|
||||
page_number = gtk_assistant_get_current_page (assistant);
|
||||
current_page = gtk_assistant_get_nth_page (assistant, page_number);
|
||||
|
9344
demos/gtk-demo/color.names.txt
Normal file
9344
demos/gtk-demo/color.names.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ create_icon_store (void)
|
||||
|
||||
GtkTreeIter iter;
|
||||
GtkListStore *store;
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
|
||||
|
||||
@@ -77,7 +77,7 @@ set_sensitive (GtkCellLayout *cell_layout,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gint *indices;
|
||||
int *indices;
|
||||
gboolean sensitive;
|
||||
|
||||
path = gtk_tree_model_get_path (tree_model, iter);
|
||||
@@ -175,7 +175,7 @@ create_capital_store (void)
|
||||
|
||||
GtkTreeIter iter, iter2;
|
||||
GtkTreeStore *store;
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
store = gtk_tree_store_new (1, G_TYPE_STRING);
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* Constraints/Interactive
|
||||
*
|
||||
* Demonstrate how constraints can be updates during
|
||||
* user interaction.
|
||||
* Demonstrate how constraints can be updates during user interaction.
|
||||
* The vertical edge between the buttons can be dragged with the mouse.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
@@ -94,7 +94,7 @@ do_css_basics (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
container = gtk_scrolled_window_new (NULL, NULL);
|
||||
container = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), container);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
|
||||
|
@@ -38,14 +38,14 @@ struct {
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
static void
|
||||
update_css_for_blend_mode (GtkCssProvider *provider,
|
||||
const gchar *blend_mode)
|
||||
const char *blend_mode)
|
||||
{
|
||||
GBytes *bytes;
|
||||
gchar *css;
|
||||
char *css;
|
||||
|
||||
bytes = g_resources_lookup_data ("/css_blendmodes/css_blendmodes.css", 0, NULL);
|
||||
|
||||
css = g_strdup_printf ((gchar*) g_bytes_get_data (bytes, NULL),
|
||||
css = g_strdup_printf ((char *) g_bytes_get_data (bytes, NULL),
|
||||
blend_mode,
|
||||
blend_mode,
|
||||
blend_mode);
|
||||
@@ -62,7 +62,7 @@ row_activated (GtkListBox *listbox,
|
||||
GtkListBoxRow *row,
|
||||
GtkCssProvider *provider)
|
||||
{
|
||||
const gchar *blend_mode;
|
||||
const char *blend_mode;
|
||||
|
||||
blend_mode = blend_modes[gtk_list_box_row_get_index (row)].id;
|
||||
|
||||
@@ -75,7 +75,7 @@ setup_listbox (GtkBuilder *builder,
|
||||
{
|
||||
GtkWidget *normal_row;
|
||||
GtkWidget *listbox;
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
normal_row = NULL;
|
||||
listbox = gtk_list_box_new ();
|
||||
|
@@ -132,7 +132,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_paned_set_end_child (GTK_PANED (paned), sw);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), child);
|
||||
|
@@ -101,7 +101,7 @@ do_css_pixbufs (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
container = gtk_scrolled_window_new (NULL, NULL);
|
||||
container = gtk_scrolled_window_new ();
|
||||
gtk_paned_set_end_child (GTK_PANED (paned), container);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
|
||||
|
@@ -119,7 +119,7 @@ do_css_shadows (GtkWidget *do_widget)
|
||||
|
||||
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
|
||||
|
||||
container = gtk_scrolled_window_new (NULL, NULL);
|
||||
container = gtk_scrolled_window_new ();
|
||||
gtk_paned_set_end_child (GTK_PANED (paned), container);
|
||||
child = gtk_text_view_new_with_buffer (text);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
|
||||
|
@@ -1,9 +1,8 @@
|
||||
/* Cursors
|
||||
*
|
||||
* Demonstrates a useful set of available cursors. The cursors shown here are the ones
|
||||
* defined by CSS, which we assume to be available.
|
||||
*
|
||||
* The example shows creating cursors by name or from an image, with or without a fallback.
|
||||
* Demonstrates a useful set of available cursors. The cursors shown here are the
|
||||
* ones defined by CSS, which we assume to be available. The example shows creating
|
||||
* cursors by name or from an image, with or without a fallback.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
@@ -1,7 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/">
|
||||
</gresource>
|
||||
<gresource prefix="/ui">
|
||||
<file preprocess="xml-stripblanks">main.ui</file>
|
||||
<file preprocess="xml-stripblanks">main-listitem.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/application_demo">
|
||||
<file>application.c</file>
|
||||
@@ -102,6 +105,9 @@
|
||||
<file>zoom_in_cursor.png</file>
|
||||
<file>zoom_out_cursor.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/dnd">
|
||||
<file>dnd.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/fishbowl">
|
||||
<file>fishbowl.ui</file>
|
||||
<file>gtkfishbowl.c</file>
|
||||
@@ -118,6 +124,24 @@
|
||||
<file>gnome-fs-directory.png</file>
|
||||
<file>gnome-fs-regular.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_filebrowser">
|
||||
<file>listview_filebrowser.ui</file>
|
||||
<file>listview_filebrowser.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_minesweeper">
|
||||
<file>listview_minesweeper.ui</file>
|
||||
<file>listview_minesweeper_cell.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_settings">
|
||||
<file>listview_settings.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_weather">
|
||||
<file compressed="true">listview_weather.txt</file>
|
||||
</gresource>
|
||||
<gresource prefix="/listview_colors">
|
||||
<file compressed="true">color.names.txt</file>
|
||||
<file>listview_colors.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/shortcuts">
|
||||
<file>shortcuts.ui</file>
|
||||
<file>shortcuts-builder.ui</file>
|
||||
@@ -170,6 +194,7 @@
|
||||
<file>cursors.c</file>
|
||||
<file>dialog.c</file>
|
||||
<file>drawingarea.c</file>
|
||||
<file>dropdown.c</file>
|
||||
<file>dnd.c</file>
|
||||
<file>editable_cells.c</file>
|
||||
<file>entry_completion.c</file>
|
||||
@@ -194,6 +219,14 @@
|
||||
<file>infobar.c</file>
|
||||
<file>links.c</file>
|
||||
<file>listbox.c</file>
|
||||
<file>listview_applauncher.c</file>
|
||||
<file>listview_colors.c</file>
|
||||
<file>listview_clocks.c</file>
|
||||
<file>listview_filebrowser.c</file>
|
||||
<file>listview_minesweeper.c</file>
|
||||
<file>listview_settings.c</file>
|
||||
<file>listview_weather.c</file>
|
||||
<file>listview_words.c</file>
|
||||
<file>list_store.c</file>
|
||||
<file>markup.c</file>
|
||||
<file>modelbutton.c</file>
|
||||
@@ -268,6 +301,7 @@
|
||||
</gresource>
|
||||
<gresource prefix="/transparent">
|
||||
<file>portland-rose.jpg</file>
|
||||
<file>bluroverlay.h</file>
|
||||
<file>bluroverlay.c</file>
|
||||
</gresource>
|
||||
<gresource prefix="/markup">
|
||||
|
@@ -17,7 +17,7 @@ G_DEFINE_TYPE(DemoImage, demo_image, GTK_TYPE_WIDGET)
|
||||
static GdkPaintable *
|
||||
get_image_paintable (GtkImage *image)
|
||||
{
|
||||
const gchar *icon_name;
|
||||
const char *icon_name;
|
||||
GtkIconTheme *icon_theme;
|
||||
GtkIconPaintable *icon;
|
||||
|
||||
|
@@ -25,31 +25,36 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtk-a11y.h>
|
||||
|
||||
typedef struct {
|
||||
struct _DemoTaggedEntry
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *entry;
|
||||
} DemoTaggedEntryPrivate;
|
||||
};
|
||||
|
||||
struct _DemoTaggedEntryClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
static void demo_tagged_entry_editable_init (GtkEditableInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (DemoTaggedEntry)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, demo_tagged_entry_editable_init))
|
||||
|
||||
static void
|
||||
demo_tagged_entry_init (DemoTaggedEntry *entry)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
entry->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_parent (entry->box, GTK_WIDGET (entry));
|
||||
|
||||
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_parent (priv->box, GTK_WIDGET (entry));
|
||||
|
||||
priv->entry = gtk_text_new ();
|
||||
gtk_widget_set_hexpand (priv->entry, TRUE);
|
||||
gtk_widget_set_vexpand (priv->entry, TRUE);
|
||||
gtk_widget_set_hexpand (priv->box, FALSE);
|
||||
gtk_widget_set_vexpand (priv->box, FALSE);
|
||||
gtk_box_append (GTK_BOX (priv->box), priv->entry);
|
||||
entry->entry = gtk_text_new ();
|
||||
gtk_widget_set_hexpand (entry->entry, TRUE);
|
||||
gtk_widget_set_vexpand (entry->entry, TRUE);
|
||||
gtk_widget_set_hexpand (entry->box, FALSE);
|
||||
gtk_widget_set_vexpand (entry->box, FALSE);
|
||||
gtk_box_append (GTK_BOX (entry->box), entry->entry);
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (entry));
|
||||
}
|
||||
|
||||
@@ -57,23 +62,16 @@ static void
|
||||
demo_tagged_entry_dispose (GObject *object)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (object);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
if (priv->entry)
|
||||
if (entry->entry)
|
||||
gtk_editable_finish_delegate (GTK_EDITABLE (entry));
|
||||
|
||||
g_clear_pointer (&priv->entry, gtk_widget_unparent);
|
||||
g_clear_pointer (&priv->box, gtk_widget_unparent);
|
||||
g_clear_pointer (&entry->entry, gtk_widget_unparent);
|
||||
g_clear_pointer (&entry->box, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (demo_tagged_entry_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (demo_tagged_entry_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -98,44 +96,12 @@ demo_tagged_entry_get_property (GObject *object,
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum,
|
||||
int *natural,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
gtk_widget_measure (priv->box, orientation, for_size,
|
||||
minimum, natural,
|
||||
minimum_baseline, natural_baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
demo_tagged_entry_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
gtk_widget_size_allocate (priv->box,
|
||||
&(GtkAllocation) { 0, 0, width, height },
|
||||
baseline);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
demo_tagged_entry_grab_focus (GtkWidget *widget)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
return gtk_widget_grab_focus (priv->entry);
|
||||
return gtk_widget_grab_focus (entry->entry);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -145,16 +111,14 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = demo_tagged_entry_dispose;
|
||||
object_class->finalize = demo_tagged_entry_finalize;
|
||||
object_class->get_property = demo_tagged_entry_get_property;
|
||||
object_class->set_property = demo_tagged_entry_set_property;
|
||||
|
||||
widget_class->measure = demo_tagged_entry_measure;
|
||||
widget_class->size_allocate = demo_tagged_entry_size_allocate;
|
||||
widget_class->grab_focus = demo_tagged_entry_grab_focus;
|
||||
|
||||
|
||||
gtk_editable_install_properties (object_class, 1);
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, "entry");
|
||||
}
|
||||
@@ -162,10 +126,7 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
|
||||
static GtkEditable *
|
||||
demo_tagged_entry_get_delegate (GtkEditable *editable)
|
||||
{
|
||||
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (editable);
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
return GTK_EDITABLE (priv->entry);
|
||||
return GTK_EDITABLE (DEMO_TAGGED_ENTRY (editable)->entry);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -184,11 +145,9 @@ void
|
||||
demo_tagged_entry_add_tag (DemoTaggedEntry *entry,
|
||||
GtkWidget *tag)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
|
||||
|
||||
gtk_box_append (GTK_BOX (priv->box), tag);
|
||||
gtk_box_append (GTK_BOX (entry->box), tag);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -196,30 +155,27 @@ demo_tagged_entry_insert_tag_after (DemoTaggedEntry *entry,
|
||||
GtkWidget *tag,
|
||||
GtkWidget *sibling)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
|
||||
|
||||
if (sibling == NULL)
|
||||
gtk_box_append (GTK_BOX (priv->box), tag);
|
||||
gtk_box_append (GTK_BOX (entry->box), tag);
|
||||
else
|
||||
gtk_box_insert_child_after (GTK_BOX (priv->box), tag, sibling);
|
||||
gtk_box_insert_child_after (GTK_BOX (entry->box), tag, sibling);
|
||||
}
|
||||
|
||||
void
|
||||
demo_tagged_entry_remove_tag (DemoTaggedEntry *entry,
|
||||
GtkWidget *tag)
|
||||
{
|
||||
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
|
||||
|
||||
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
|
||||
|
||||
gtk_box_remove (GTK_BOX (priv->box), tag);
|
||||
gtk_box_remove (GTK_BOX (entry->box), tag);
|
||||
}
|
||||
|
||||
struct _DemoTaggedEntryTag
|
||||
{
|
||||
GtkWidget parent;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *button;
|
||||
@@ -250,11 +206,11 @@ static guint signals[LAST_SIGNAL] = { 0, };
|
||||
G_DEFINE_TYPE (DemoTaggedEntryTag, demo_tagged_entry_tag, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
on_released (GtkGestureClick *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
DemoTaggedEntryTag *tag)
|
||||
on_released (GtkGestureClick *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
DemoTaggedEntryTag *tag)
|
||||
{
|
||||
g_signal_emit (tag, signals[SIGNAL_CLICKED], 0);
|
||||
}
|
||||
@@ -469,7 +425,7 @@ demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *tag,
|
||||
|
||||
image = gtk_image_new_from_icon_name ("window-close-symbolic");
|
||||
tag->button = gtk_button_new ();
|
||||
gtk_box_append (GTK_BOX (tag->button), image);
|
||||
gtk_button_set_child (GTK_BUTTON (tag->button), image);
|
||||
gtk_widget_set_halign (tag->button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (tag->button, GTK_ALIGN_CENTER);
|
||||
gtk_button_set_has_frame (GTK_BUTTON (tag->button), FALSE);
|
||||
|
@@ -25,39 +25,11 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define DEMO_TYPE_TAGGED_ENTRY (demo_tagged_entry_get_type ())
|
||||
#define DEMO_TAGGED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntry))
|
||||
#define DEMO_TAGGED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntryClass))
|
||||
#define DEMO_IS_TAGGED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEMO_TYPE_TAGGED_ENTRY))
|
||||
#define DEMO_IS_TAGGED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEMO_TYPE_TAGGED_ENTRY))
|
||||
#define DEMO_TAGGED_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntryClass))
|
||||
#define DEMO_TYPE_TAGGED_ENTRY (demo_tagged_entry_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (DemoTaggedEntry, demo_tagged_entry, DEMO, TAGGED_ENTRY, GtkWidget)
|
||||
|
||||
typedef struct _DemoTaggedEntry DemoTaggedEntry;
|
||||
typedef struct _DemoTaggedEntryClass DemoTaggedEntryClass;
|
||||
|
||||
struct _DemoTaggedEntry
|
||||
{
|
||||
GtkWidget parent;
|
||||
};
|
||||
|
||||
struct _DemoTaggedEntryClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
#define DEMO_TYPE_TAGGED_ENTRY_TAG (demo_tagged_entry_tag_get_type ())
|
||||
#define DEMO_TAGGED_ENTRY_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTag))
|
||||
#define DEMO_TAGGED_ENTRY_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTag))
|
||||
#define DEMO_IS_TAGGED_ENTRY_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG))
|
||||
#define DEMO_IS_TAGGED_ENTRY_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEMO_TYPE_TAGGED_ENTRY_TAG))
|
||||
#define DEMO_TAGGED_ENTRY_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTagClass))
|
||||
|
||||
typedef struct _DemoTaggedEntryTag DemoTaggedEntryTag;
|
||||
typedef struct _DemoTaggedEntryTagClass DemoTaggedEntryTagClass;
|
||||
|
||||
|
||||
GType demo_tagged_entry_get_type (void) G_GNUC_CONST;
|
||||
GType demo_tagged_entry_tag_get_type (void) G_GNUC_CONST;
|
||||
#define DEMO_TYPE_TAGGED_ENTRY_TAG (demo_tagged_entry_tag_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (DemoTaggedEntryTag, demo_tagged_entry_tag, DEMO, TAGGED_ENTRY_TAG, GtkWidget)
|
||||
|
||||
GtkWidget * demo_tagged_entry_new (void);
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/* Dialogs and Message Boxes
|
||||
/* Dialogs
|
||||
*
|
||||
* Dialog widgets are used to pop up a transient window for user feedback.
|
||||
* Dialogs are used to pop up transient windows for information
|
||||
* and user feedback.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
@@ -15,16 +16,15 @@ message_dialog_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
static gint i = 1;
|
||||
static int i = 1;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK_CANCEL,
|
||||
"This message box has been popped up the following\n"
|
||||
"number of times:");
|
||||
"Test message");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%d", i);
|
||||
ngettext ("Has been shown once", "Has been shown %d times", i), i);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
i++;
|
||||
@@ -61,8 +61,6 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
{
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *table;
|
||||
GtkWidget *local_entry1;
|
||||
GtkWidget *local_entry2;
|
||||
@@ -71,26 +69,24 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
|
||||
GTK_WINDOW (window),
|
||||
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
_("_OK"),
|
||||
GTK_RESPONSE_OK,
|
||||
"_Cancel",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_USE_HEADER_BAR,
|
||||
_("_OK"), GTK_RESPONSE_OK,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
||||
gtk_box_append (GTK_BOX (content_area), hbox);
|
||||
|
||||
image = gtk_image_new_from_icon_name ("dialog-question");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
gtk_box_append (GTK_BOX (hbox), image);
|
||||
|
||||
table = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 4);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 4);
|
||||
gtk_box_append (GTK_BOX (hbox), table);
|
||||
gtk_widget_set_hexpand (table, TRUE);
|
||||
gtk_widget_set_vexpand (table, TRUE);
|
||||
gtk_widget_set_halign (table, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (table, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (content_area), table);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 6);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 6);
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("_Entry 1");
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
local_entry1 = gtk_entry_new ();
|
||||
@@ -123,7 +119,6 @@ interactive_dialog_clicked (GtkButton *button,
|
||||
GtkWidget *
|
||||
do_dialog (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *hbox;
|
||||
@@ -136,22 +131,16 @@ do_dialog (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), "Dialogs and Message Boxes");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Dialogs");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
frame = gtk_frame_new ("Dialogs");
|
||||
gtk_widget_set_margin_start (frame, 8);
|
||||
gtk_widget_set_margin_end (frame, 8);
|
||||
gtk_widget_set_margin_top (frame, 8);
|
||||
gtk_widget_set_margin_bottom (frame, 8);
|
||||
gtk_window_set_child (GTK_WINDOW (window), frame);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
gtk_widget_set_margin_top (vbox, 8);
|
||||
gtk_widget_set_margin_bottom (vbox, 8);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), vbox);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
/* Standard message dialog */
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
|
||||
|
@@ -38,15 +38,20 @@ set_color (CanvasItem *item,
|
||||
char *str;
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
|
||||
str = gdk_rgba_to_string (color);
|
||||
css = g_strdup_printf ("* { background: %s; padding: 10px; margin: 1px; }", str);
|
||||
css = g_strdup_printf ("* { background: %s; }", str);
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
|
||||
@@ -56,6 +61,27 @@ set_color (CanvasItem *item,
|
||||
g_free (css);
|
||||
}
|
||||
|
||||
static void
|
||||
set_css (CanvasItem *item,
|
||||
const char *class)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
|
||||
gtk_widget_add_css_class (item->label, class);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
item_drag_drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
@@ -65,7 +91,10 @@ item_drag_drop (GtkDropTarget *dest,
|
||||
GtkWidget *label = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
|
||||
CanvasItem *item = CANVAS_ITEM (gtk_widget_get_parent (gtk_widget_get_parent (label)));
|
||||
|
||||
set_color (item, g_value_get_boxed (value));
|
||||
if (G_VALUE_TYPE (value) == GDK_TYPE_RGBA)
|
||||
set_color (item, g_value_get_boxed (value));
|
||||
else if (G_VALUE_TYPE (value) == G_TYPE_STRING)
|
||||
set_css (item, g_value_get_string (value));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -132,11 +161,13 @@ canvas_item_init (CanvasItem *item)
|
||||
GdkRGBA rgba;
|
||||
GtkDropTarget *dest;
|
||||
GtkGesture *gesture;
|
||||
GType types[2] = { GDK_TYPE_RGBA, G_TYPE_STRING };
|
||||
|
||||
n_items++;
|
||||
|
||||
text = g_strdup_printf ("Item %d", n_items);
|
||||
item->label = gtk_label_new (text);
|
||||
gtk_widget_add_css_class (item->label, "canvasitem");
|
||||
g_free (text);
|
||||
|
||||
item->fixed = gtk_fixed_new ();
|
||||
@@ -154,7 +185,8 @@ canvas_item_init (CanvasItem *item)
|
||||
|
||||
item->angle = 0;
|
||||
|
||||
dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
|
||||
dest = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_COPY);
|
||||
gtk_drop_target_set_gtypes (dest, types, G_N_ELEMENTS (types));
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (item_drag_drop), NULL);
|
||||
gtk_widget_add_controller (GTK_WIDGET (item->label), GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
@@ -529,6 +561,119 @@ canvas_new (void)
|
||||
return canvas;
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
css_drag_prepare (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *button)
|
||||
{
|
||||
const char *class;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
class = (const char *)g_object_get_data (G_OBJECT (button), "css-class");
|
||||
|
||||
paintable = gtk_widget_paintable_new (button);
|
||||
gtk_drag_source_set_icon (source, paintable, 0, 0);
|
||||
g_object_unref (paintable);
|
||||
|
||||
return gdk_content_provider_new_typed (G_TYPE_STRING, class);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
css_button_new (const char *class)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkDragSource *source;
|
||||
|
||||
button = gtk_image_new ();
|
||||
gtk_widget_set_size_request (button, 48, 32);
|
||||
gtk_widget_add_css_class (button, class);
|
||||
g_object_set_data (G_OBJECT (button), "css-class", (gpointer)class);
|
||||
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (css_drag_prepare), button);
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
GdkRGBA color;
|
||||
} ColorSwatch;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
} ColorSwatchClass;
|
||||
|
||||
G_DEFINE_TYPE (ColorSwatch, color_swatch, GTK_TYPE_WIDGET)
|
||||
|
||||
static GdkContentProvider *
|
||||
color_swatch_drag_prepare (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
ColorSwatch *swatch)
|
||||
{
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &swatch->color);
|
||||
}
|
||||
|
||||
static void
|
||||
color_swatch_init (ColorSwatch *swatch)
|
||||
{
|
||||
GtkDragSource *source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (color_swatch_drag_prepare), swatch);
|
||||
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (source));
|
||||
}
|
||||
|
||||
static void
|
||||
color_swatch_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
ColorSwatch *swatch = (ColorSwatch *)widget;
|
||||
float w = gtk_widget_get_width (widget);
|
||||
float h = gtk_widget_get_height (widget);
|
||||
|
||||
gtk_snapshot_append_color (snapshot, &swatch->color,
|
||||
&GRAPHENE_RECT_INIT(0, 0, w, h));
|
||||
}
|
||||
|
||||
void
|
||||
color_swatch_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum_size,
|
||||
int *natural_size,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
*minimum_size = *natural_size = 48;
|
||||
else
|
||||
*minimum_size = *natural_size = 32;
|
||||
}
|
||||
|
||||
static void
|
||||
color_swatch_class_init (ColorSwatchClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
widget_class->snapshot = color_swatch_snapshot;
|
||||
widget_class->measure = color_swatch_measure;
|
||||
gtk_widget_class_set_css_name (widget_class, "colorswatch");
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
color_swatch_new (const char *color)
|
||||
{
|
||||
ColorSwatch *swatch = g_object_new (color_swatch_get_type (), NULL);
|
||||
|
||||
gdk_rgba_parse (&swatch->color, color);
|
||||
|
||||
return GTK_WIDGET (swatch);
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
@@ -548,10 +693,18 @@ do_dnd (GtkWidget *do_widget)
|
||||
};
|
||||
int i;
|
||||
int x, y;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
button = gtk_color_button_new ();
|
||||
g_object_unref (g_object_ref_sink (button));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/dnd/dnd.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
@@ -583,7 +736,7 @@ do_dnd (GtkWidget *do_widget)
|
||||
y += 100;
|
||||
}
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_NEVER);
|
||||
@@ -594,18 +747,11 @@ do_dnd (GtkWidget *do_widget)
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), box3);
|
||||
|
||||
for (i = 0; colors[i]; i++)
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
GtkWidget *swatch;
|
||||
gtk_box_append (GTK_BOX (box3), color_swatch_new (colors[i]));
|
||||
|
||||
gdk_rgba_parse (&rgba, colors[i]);
|
||||
|
||||
swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
|
||||
"rgba", &rgba,
|
||||
"selectable", FALSE,
|
||||
NULL);
|
||||
gtk_box_append (GTK_BOX (box3), swatch);
|
||||
}
|
||||
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow1"));
|
||||
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow2"));
|
||||
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow3"));
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
37
demos/gtk-demo/dnd.css
Normal file
37
demos/gtk-demo/dnd.css
Normal file
@@ -0,0 +1,37 @@
|
||||
label.canvasitem {
|
||||
padding: 10px;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.canvasitem.rainbow1,
|
||||
image.rainbow1 {
|
||||
background: linear-gradient(140deg,red,orange,yellow,green,blue,purple);
|
||||
}
|
||||
|
||||
.canvasitem.rainbow2,
|
||||
image.rainbow2 {
|
||||
animation: rainbow2 1s infinite linear;
|
||||
}
|
||||
|
||||
@keyframes rainbow2 {
|
||||
0% { background: linear-gradient(0deg,red,orange,yellow,green,blue,purple); }
|
||||
25% { background: linear-gradient(90deg,red,orange,yellow,green,blue,purple); }
|
||||
50% { background: linear-gradient(180deg,red,orange,yellow,green,blue,purple); }
|
||||
75% { background: linear-gradient(270deg,red,orange,yellow,green,blue,purple); }
|
||||
100% { background: linear-gradient(360deg,red,orange,yellow,green,blue,purple); }
|
||||
}
|
||||
|
||||
.canvasitem.rainbow3,
|
||||
image.rainbow3 {
|
||||
animation: rainbow3 1s infinite linear;
|
||||
}
|
||||
|
||||
@keyframes rainbow3 {
|
||||
0% { background: linear-gradient(140deg,red,orange,yellow,green,blue,purple); }
|
||||
16.6% { background: linear-gradient(140deg,purple,red,orange,yellow,green,blue); }
|
||||
33.2% { background: linear-gradient(140deg,blue,purple,red,orange,yellow,green); }
|
||||
50% { background: linear-gradient(140deg,green,blue,purple,red,orange,yellow); }
|
||||
66.6% { background: linear-gradient(140deg,yellow,green,blue,purple,red,orange); }
|
||||
83.2% { background: linear-gradient(140deg,orange,yellow,green,blue,purple,red); }
|
||||
100% { background: linear-gradient(140deg,red,orange,yellow,green,blue,purple); }
|
||||
}
|
@@ -64,8 +64,8 @@ scribble_draw (GtkDrawingArea *da,
|
||||
/* Draw a rectangle on the screen */
|
||||
static void
|
||||
draw_brush (GtkWidget *widget,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GdkRectangle update_rect;
|
||||
cairo_t *cr;
|
||||
|
305
demos/gtk-demo/dropdown.c
Normal file
305
demos/gtk-demo/dropdown.c
Normal file
@@ -0,0 +1,305 @@
|
||||
/* Drop Downs
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
#define STRING_TYPE_HOLDER (string_holder_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (StringHolder, string_holder, STRING, HOLDER, GObject)
|
||||
|
||||
struct _StringHolder {
|
||||
GObject parent_instance;
|
||||
char *title;
|
||||
char *icon;
|
||||
char *description;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (StringHolder, string_holder, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
string_holder_init (StringHolder *holder)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
string_holder_finalize (GObject *object)
|
||||
{
|
||||
StringHolder *holder = STRING_HOLDER (object);
|
||||
|
||||
g_free (holder->title);
|
||||
g_free (holder->icon);
|
||||
g_free (holder->description);
|
||||
|
||||
G_OBJECT_CLASS (string_holder_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
string_holder_class_init (StringHolderClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->finalize = string_holder_finalize;
|
||||
}
|
||||
|
||||
static StringHolder *
|
||||
string_holder_new (const char *title, const char *icon, const char *description)
|
||||
{
|
||||
StringHolder *holder = g_object_new (STRING_TYPE_HOLDER, NULL);
|
||||
holder->title = g_strdup (title);
|
||||
holder->icon = g_strdup (icon);
|
||||
holder->description = g_strdup (description);
|
||||
return holder;
|
||||
}
|
||||
|
||||
static void
|
||||
strings_setup_item_single_line (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box, *image, *title;
|
||||
|
||||
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);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), image);
|
||||
gtk_box_append (GTK_BOX (box), title);
|
||||
|
||||
g_object_set_data (G_OBJECT (item), "title", title);
|
||||
g_object_set_data (G_OBJECT (item), "image", image);
|
||||
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
|
||||
static void
|
||||
strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box, *box2, *image, *title, *description;
|
||||
|
||||
image = gtk_image_new ();
|
||||
title = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
|
||||
description = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (description), 0.0);
|
||||
gtk_widget_add_css_class (description, "dim-label");
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), image);
|
||||
gtk_box_append (GTK_BOX (box), box2);
|
||||
gtk_box_append (GTK_BOX (box2), title);
|
||||
gtk_box_append (GTK_BOX (box2), description);
|
||||
|
||||
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);
|
||||
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
|
||||
static void
|
||||
strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *image, *title, *description;
|
||||
StringHolder *holder;
|
||||
|
||||
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");
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (title), holder->title);
|
||||
if (image)
|
||||
{
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), holder->icon);
|
||||
gtk_widget_set_visible (image, holder->icon != NULL);
|
||||
}
|
||||
if (description)
|
||||
{
|
||||
gtk_label_set_label (GTK_LABEL (description), holder->description);
|
||||
gtk_widget_set_visible (description , holder->description != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static GtkListItemFactory *
|
||||
strings_factory_new (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);
|
||||
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);
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
strings_model_new (const char *const *titles,
|
||||
const char *const *icons,
|
||||
const char *const *descriptions)
|
||||
{
|
||||
GListStore *store;
|
||||
int i;
|
||||
|
||||
store = g_list_store_new (STRING_TYPE_HOLDER);
|
||||
for (i = 0; titles[i]; i++)
|
||||
{
|
||||
StringHolder *holder = string_holder_new (titles[i],
|
||||
icons ? icons[i] : NULL,
|
||||
descriptions ? descriptions[i] : NULL);
|
||||
g_list_store_append (store, holder);
|
||||
g_object_unref (holder);
|
||||
}
|
||||
|
||||
return G_LIST_MODEL (store);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
drop_down_new_from_strings (const char *const *titles,
|
||||
const char *const *icons,
|
||||
const char *const *descriptions)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GListModel *model;
|
||||
GtkListItemFactory *factory;
|
||||
GtkListItemFactory *list_factory;
|
||||
|
||||
g_return_val_if_fail (titles != NULL, NULL);
|
||||
g_return_val_if_fail (icons == NULL || g_strv_length ((char **)icons) == g_strv_length ((char **)titles), NULL);
|
||||
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);
|
||||
if (icons != NULL || descriptions != NULL)
|
||||
list_factory = strings_factory_new (TRUE);
|
||||
else
|
||||
list_factory = NULL;
|
||||
|
||||
widget = g_object_new (GTK_TYPE_DROP_DOWN,
|
||||
"model", model,
|
||||
"factory", factory,
|
||||
"list-factory", list_factory,
|
||||
NULL);
|
||||
|
||||
g_object_unref (model);
|
||||
g_object_unref (factory);
|
||||
if (list_factory)
|
||||
g_object_unref (list_factory);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_family_name (gpointer item)
|
||||
{
|
||||
return g_strdup (pango_font_family_get_name (PANGO_FONT_FAMILY (item)));
|
||||
}
|
||||
|
||||
static char *
|
||||
get_title (gpointer item)
|
||||
{
|
||||
return g_strdup (STRING_HOLDER (item)->title);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_dropdown (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *button, *box, *spin, *check;
|
||||
GListModel *model;
|
||||
GtkExpression *expression;
|
||||
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",
|
||||
"25 minutes", "30 minutes", "35 minutes", "40 minutes", "45 minutes", "50 minutes",
|
||||
"55 minutes", "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
|
||||
"8 hours", "9 hours", "10 hours", "11 hours", "12 hours", NULL
|
||||
};
|
||||
const char * const device_titles[] = { "Digital Output", "Headphones", "Digital Output", "Analog Output", NULL };
|
||||
const char * const device_icons[] = { "audio-card-symbolic", "audio-headphones-symbolic", "audio-card-symbolic", "audio-card-symbolic", NULL };
|
||||
const char * const device_descriptions[] = {
|
||||
"Built-in Audio", "Built-in audio", "Thinkpad Tunderbolt 3 Dock USB Audio", "Thinkpad Tunderbolt 3 Dock USB Audio", NULL
|
||||
};
|
||||
|
||||
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_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
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);
|
||||
|
||||
button = gtk_drop_down_new ();
|
||||
|
||||
model = G_LIST_MODEL (pango_cairo_font_map_get_default ());
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (button), model);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (button), 0);
|
||||
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
|
||||
0, NULL,
|
||||
(GCallback)get_family_name,
|
||||
NULL, NULL);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
|
||||
gtk_expression_unref (expression);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
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);
|
||||
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");
|
||||
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);
|
||||
|
||||
button = drop_down_new_from_strings (device_titles, device_icons, device_descriptions);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
@@ -16,9 +16,9 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint number;
|
||||
gchar *product;
|
||||
gint yummy;
|
||||
int number;
|
||||
char *product;
|
||||
int yummy;
|
||||
}
|
||||
Item;
|
||||
|
||||
@@ -74,7 +74,7 @@ add_items (void)
|
||||
static GtkTreeModel *
|
||||
create_items_model (void)
|
||||
{
|
||||
gint i = 0;
|
||||
int i = 0;
|
||||
GtkListStore *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
@@ -109,7 +109,7 @@ static GtkTreeModel *
|
||||
create_numbers_model (void)
|
||||
{
|
||||
#define N_NUMBERS 10
|
||||
gint i = 0;
|
||||
int i = 0;
|
||||
GtkListStore *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
@@ -192,7 +192,7 @@ remove_item (GtkWidget *widget, gpointer data)
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
{
|
||||
gint i;
|
||||
int i;
|
||||
GtkTreePath *path;
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
@@ -211,7 +211,7 @@ separator_row (GtkTreeModel *model,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gint idx;
|
||||
int idx;
|
||||
|
||||
path = gtk_tree_model_get_path (model, iter);
|
||||
idx = gtk_tree_path_get_indices (path)[0];
|
||||
@@ -224,7 +224,7 @@ separator_row (GtkTreeModel *model,
|
||||
static void
|
||||
editing_started (GtkCellRenderer *cell,
|
||||
GtkCellEditable *editable,
|
||||
const gchar *path,
|
||||
const char *path,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (editable),
|
||||
@@ -233,15 +233,15 @@ editing_started (GtkCellRenderer *cell,
|
||||
|
||||
static void
|
||||
cell_edited (GtkCellRendererText *cell,
|
||||
const gchar *path_string,
|
||||
const gchar *new_text,
|
||||
const char *path_string,
|
||||
const char *new_text,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model = (GtkTreeModel *)data;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
|
||||
GtkTreeIter iter;
|
||||
|
||||
gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
|
||||
int column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
|
||||
@@ -249,7 +249,7 @@ cell_edited (GtkCellRendererText *cell,
|
||||
{
|
||||
case COLUMN_ITEM_NUMBER:
|
||||
{
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
i = gtk_tree_path_get_indices (path)[0];
|
||||
g_array_index (articles, Item, i).number = atoi (new_text);
|
||||
@@ -261,8 +261,8 @@ cell_edited (GtkCellRendererText *cell,
|
||||
|
||||
case COLUMN_ITEM_PRODUCT:
|
||||
{
|
||||
gint i;
|
||||
gchar *old_text;
|
||||
int i;
|
||||
char *old_text;
|
||||
|
||||
gtk_tree_model_get (model, &iter, column, &old_text, -1);
|
||||
g_free (old_text);
|
||||
@@ -364,7 +364,7 @@ do_editable_cells (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
gtk_label_new ("Shopping list (you can edit the cells!)"));
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Entry/Entry Completion
|
||||
/* Entry/Completion
|
||||
*
|
||||
* GtkEntryCompletion provides a mechanism for adding support for
|
||||
* completion in GtkEntry.
|
||||
@@ -12,22 +12,48 @@
|
||||
static GtkTreeModel *
|
||||
create_completion_model (void)
|
||||
{
|
||||
const char *strings[] = {
|
||||
"GNOME",
|
||||
"gnominious",
|
||||
"Gnomonic projection",
|
||||
"Gnosophy",
|
||||
"total",
|
||||
"totally",
|
||||
"toto",
|
||||
"tottery",
|
||||
"totterer",
|
||||
"Totten trust",
|
||||
"Tottenham hotspurs",
|
||||
"totipotent",
|
||||
"totipotency",
|
||||
"totemism",
|
||||
"totem pole",
|
||||
"Totara",
|
||||
"totalizer",
|
||||
"totalizator",
|
||||
"totalitarianism",
|
||||
"total parenteral nutrition",
|
||||
"total eclipse",
|
||||
"Totipresence",
|
||||
"Totipalmi",
|
||||
"zombie",
|
||||
"aæx",
|
||||
"aæy",
|
||||
"aæz",
|
||||
NULL
|
||||
};
|
||||
int i;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
|
||||
/* Append one word */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, "GNOME", -1);
|
||||
|
||||
/* Append another word */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, "total", -1);
|
||||
|
||||
/* And another word */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, "totally", -1);
|
||||
for (i = 0; strings[i]; i++)
|
||||
{
|
||||
/* Append one word */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, strings[i], -1);
|
||||
}
|
||||
|
||||
return GTK_TREE_MODEL (store);
|
||||
}
|
||||
@@ -48,7 +74,7 @@ do_entry_completion (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), "Entry Completion");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Completion");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
@@ -60,7 +86,7 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label), "Completion demo, try writing <b>total</b> or <b>gnome</b> for example.");
|
||||
gtk_label_set_markup (GTK_LABEL (label), "Try writing <b>total</b> or <b>gnome</b> for example.");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
/* Create our entry */
|
||||
@@ -81,6 +107,9 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
|
||||
/* Use model column 0 as the text column */
|
||||
gtk_entry_completion_set_text_column (completion, 0);
|
||||
|
||||
gtk_entry_completion_set_inline_completion (completion, TRUE);
|
||||
gtk_entry_completion_set_inline_selection (completion, TRUE);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/* Entry/Entry Undo
|
||||
/* Entry/Undo and Redo
|
||||
*
|
||||
* GtkEntry can provide basic Undo/Redo support using standard keyboard
|
||||
* accelerators such as Primary+z to undo and Primary+Shift+z to redo.
|
||||
* Additionally, Primary+y can be used to redo.
|
||||
* accelerators such as Control+z to undo and Control+Shift+z to redo.
|
||||
* Additionally, Control+y can be used to redo.
|
||||
*
|
||||
* Use gtk_entry_set_enable_undo() to enable undo/redo support.
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ do_entry_undo (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), "Entry Undo");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Undo and Redo");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
static void
|
||||
response_cb (GtkDialog *dialog, gint response_id)
|
||||
response_cb (GtkDialog *dialog, int response_id)
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
window = NULL;
|
||||
@@ -57,7 +57,7 @@ do_expander (GtkWidget *do_widget)
|
||||
|
||||
expander = gtk_expander_new ("Details:");
|
||||
gtk_widget_set_vexpand (expander, TRUE);
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 100);
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
|
@@ -22,8 +22,8 @@ format_number (GtkTreeViewColumn *col,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
gint num;
|
||||
gchar *text;
|
||||
int num;
|
||||
char *text;
|
||||
|
||||
gtk_tree_model_get (model, iter, GPOINTER_TO_INT (data), &num, -1);
|
||||
text = g_strdup_printf ("%d", num);
|
||||
@@ -35,11 +35,11 @@ static void
|
||||
filter_modify_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
GValue *value,
|
||||
gint column,
|
||||
int column,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModelFilter *filter_model = GTK_TREE_MODEL_FILTER (model);
|
||||
gint width, height;
|
||||
int width, height;
|
||||
GtkTreeModel *child_model;
|
||||
GtkTreeIter child_iter;
|
||||
|
||||
@@ -75,7 +75,7 @@ visible_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
gint width;
|
||||
int width;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
WIDTH_COLUMN, &width,
|
||||
|
@@ -249,6 +249,14 @@ fishbowl_changes_toggled_cb (GtkToggleButton *button,
|
||||
gtk_button_set_icon_name (GTK_BUTTON (button), "changes-allow");
|
||||
}
|
||||
|
||||
char *
|
||||
format_header_cb (GObject *object,
|
||||
guint count,
|
||||
double fps)
|
||||
{
|
||||
return g_strdup_printf ("%u Icons, %.2f fps", count, fps);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_fishbowl (GtkWidget *do_widget)
|
||||
{
|
||||
|
@@ -6,7 +6,6 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
@@ -28,22 +27,12 @@
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">fps</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkLabel">
|
||||
<property name="label" bind-source="bowl" bind-property="framerate-string"/>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Icons, </property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkLabel">
|
||||
<property name="label" bind-source="bowl" bind-property="count"/>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="format_header_cb">
|
||||
<lookup name="count">bowl</lookup>
|
||||
<lookup name="framerate">bowl</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Fixed layout
|
||||
/* Fixed Layout
|
||||
*
|
||||
* GtkFixed is a container that allows placing and transforming
|
||||
* widgets manually.
|
||||
@@ -126,11 +126,11 @@ create_demo_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), "Fixed layout");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Fixed Layout");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
|
||||
fixed = gtk_fixed_new ();
|
||||
|
@@ -1,9 +1,10 @@
|
||||
/* Flow Box
|
||||
*
|
||||
* GtkFlowBox allows flexible and responsive grids which reflow
|
||||
* as needed and support sorting and filtering.
|
||||
* as needed and support sorting and filtering. The children of
|
||||
* a GtkFlowBox are regular widgets
|
||||
*
|
||||
* The children of a GtkFlowBox are regular widgets
|
||||
* The dataset used here has 665 colors.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@@ -28,7 +29,7 @@ draw_color (GtkDrawingArea *drawingarea,
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
color_swatch_new (const gchar *color)
|
||||
color_swatch_new (const char *color)
|
||||
{
|
||||
GtkWidget *button, *area;
|
||||
|
||||
@@ -47,7 +48,7 @@ do_flowbox (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *scrolled, *flowbox;
|
||||
const gchar *colors[] = {
|
||||
const char *colors[] = {
|
||||
"AliceBlue",
|
||||
"AntiqueWhite",
|
||||
"AntiqueWhite1",
|
||||
@@ -715,7 +716,7 @@ do_flowbox (GtkWidget *do_widget)
|
||||
"YellowGreen",
|
||||
NULL
|
||||
};
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
@@ -726,7 +727,7 @@ do_flowbox (GtkWidget *do_widget)
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
flowbox = gtk_flow_box_new ();
|
||||
gtk_widget_set_valign (flowbox, GTK_ALIGN_START);
|
||||
|
@@ -7,7 +7,6 @@
|
||||
<property name="title">Font Explorer</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset">
|
||||
<property name="receives-default">1</property>
|
||||
|
@@ -295,7 +295,7 @@ update_display (void)
|
||||
GList *l;
|
||||
PangoAttrList *attrs;
|
||||
PangoAttribute *attr;
|
||||
gint ins, bound;
|
||||
int ins, bound;
|
||||
guint start, end;
|
||||
PangoLanguage *lang;
|
||||
char *font_desc;
|
||||
@@ -479,7 +479,7 @@ update_script_combo (void)
|
||||
{
|
||||
GtkListStore *store;
|
||||
hb_font_t *hb_font;
|
||||
gint i, j, k;
|
||||
int i, j, k;
|
||||
PangoFont *pango_font;
|
||||
GHashTable *tags;
|
||||
GHashTableIter iter;
|
||||
@@ -593,7 +593,7 @@ update_script_combo (void)
|
||||
static void
|
||||
update_features (void)
|
||||
{
|
||||
gint i, j;
|
||||
int i, j;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
guint script_index, lang_index;
|
||||
@@ -728,8 +728,8 @@ static void
|
||||
entry_activated (GtkEntry *entry,
|
||||
GtkAdjustment *adjustment)
|
||||
{
|
||||
gdouble value;
|
||||
gchar *err = NULL;
|
||||
double value;
|
||||
char *err = NULL;
|
||||
|
||||
value = g_strtod (gtk_editable_get_text (GTK_EDITABLE (entry)), &err);
|
||||
if (err != NULL)
|
||||
@@ -939,7 +939,7 @@ instance_changed (GtkComboBox *combo)
|
||||
{
|
||||
Axis *axis;
|
||||
Axis akey;
|
||||
gdouble value;
|
||||
double value;
|
||||
|
||||
value = coords[ai[i].axis_index];
|
||||
|
||||
|
@@ -36,11 +36,11 @@ adjustment_get_normalized_value (GtkAdjustment *adj)
|
||||
|
||||
static void
|
||||
val_to_xy (GtkFontPlane *plane,
|
||||
gint *x,
|
||||
gint *y)
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
gdouble u, v;
|
||||
gint width, height;
|
||||
double u, v;
|
||||
int width, height;
|
||||
|
||||
width = gtk_widget_get_allocated_width (GTK_WIDGET (plane));
|
||||
height = gtk_widget_get_allocated_height (GTK_WIDGET (plane));
|
||||
@@ -57,8 +57,8 @@ plane_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkFontPlane *plane = GTK_FONT_PLANE (widget);
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
int x, y;
|
||||
int width, height;
|
||||
cairo_t *cr;
|
||||
|
||||
val_to_xy (plane, &x, &y);
|
||||
@@ -125,11 +125,11 @@ adjustment_set_normalized_value (GtkAdjustment *adj,
|
||||
|
||||
static void
|
||||
update_value (GtkFontPlane *plane,
|
||||
gint x,
|
||||
gint y)
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (plane);
|
||||
gdouble u, v;
|
||||
double u, v;
|
||||
|
||||
u = CLAMP (x * (1.0 / gtk_widget_get_allocated_width (widget)), 0, 1);
|
||||
v = CLAMP (1 - y * (1.0 / gtk_widget_get_allocated_height (widget)), 0, 1);
|
||||
@@ -142,8 +142,8 @@ update_value (GtkFontPlane *plane,
|
||||
|
||||
static void
|
||||
plane_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
gdouble start_x,
|
||||
gdouble start_y,
|
||||
double start_x,
|
||||
double start_y,
|
||||
GtkFontPlane *plane)
|
||||
{
|
||||
guint button;
|
||||
@@ -164,11 +164,11 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
|
||||
static void
|
||||
plane_drag_gesture_update (GtkGestureDrag *gesture,
|
||||
gdouble offset_x,
|
||||
gdouble offset_y,
|
||||
double offset_x,
|
||||
double offset_y,
|
||||
GtkFontPlane *plane)
|
||||
{
|
||||
gdouble start_x, start_y;
|
||||
double start_x, start_y;
|
||||
|
||||
gtk_gesture_drag_get_start_point (GTK_GESTURE_DRAG (gesture),
|
||||
&start_x, &start_y);
|
||||
@@ -177,8 +177,8 @@ plane_drag_gesture_update (GtkGestureDrag *gesture,
|
||||
|
||||
static void
|
||||
plane_drag_gesture_end (GtkGestureDrag *gesture,
|
||||
gdouble offset_x,
|
||||
gdouble offset_y,
|
||||
double offset_x,
|
||||
double offset_y,
|
||||
GtkFontPlane *plane)
|
||||
{
|
||||
set_cross_cursor (GTK_WIDGET (plane), FALSE);
|
||||
|
@@ -13,17 +13,16 @@ in_files = sys.argv[2:]
|
||||
file_output = """
|
||||
typedef GtkWidget *(*GDoDemoFunc) (GtkWidget *do_widget);
|
||||
|
||||
typedef struct _Demo Demo;
|
||||
typedef struct _DemoData DemoData;
|
||||
|
||||
struct _Demo
|
||||
struct _DemoData
|
||||
{
|
||||
const char *name;
|
||||
const char *title;
|
||||
const char *filename;
|
||||
GDoDemoFunc func;
|
||||
Demo *children;
|
||||
DemoData *children;
|
||||
};
|
||||
|
||||
"""
|
||||
|
||||
# Demo = namedtuple('Demo', ['name', 'title', 'file', 'func'])
|
||||
@@ -67,7 +66,7 @@ for demo in demos:
|
||||
i = 0
|
||||
for parent in parents:
|
||||
id = parent_ids[i]
|
||||
file_output += "\nDemo child" + str(id) + "[] = {\n"
|
||||
file_output += "\nDemoData child" + str(id) + "[] = {\n"
|
||||
# iterate over all demos and check if the name starts with the given parent name
|
||||
for child in demos:
|
||||
if child[1].startswith(parent + "/"):
|
||||
@@ -82,7 +81,7 @@ for parent in parents:
|
||||
# Sort demos by title
|
||||
demos = sorted(demos, key=lambda x: x[1])
|
||||
|
||||
file_output += "\nDemo gtk_demos[] = {\n"
|
||||
file_output += "\nDemoData gtk_demos[] = {\n"
|
||||
for demo in demos:
|
||||
# Do not generate one of these for demos with a parent demo
|
||||
if "/" not in demo[1]:
|
||||
|
@@ -9,8 +9,8 @@
|
||||
|
||||
static GtkGesture *rotate = NULL;
|
||||
static GtkGesture *zoom = NULL;
|
||||
static gdouble swipe_x = 0;
|
||||
static gdouble swipe_y = 0;
|
||||
static double swipe_x = 0;
|
||||
static double swipe_y = 0;
|
||||
static gboolean long_pressed = FALSE;
|
||||
|
||||
static gboolean
|
||||
@@ -26,8 +26,8 @@ touchpad_swipe_gesture_begin (GtkGesture *gesture,
|
||||
|
||||
static void
|
||||
swipe_gesture_swept (GtkGestureSwipe *gesture,
|
||||
gdouble velocity_x,
|
||||
gdouble velocity_y,
|
||||
double velocity_x,
|
||||
double velocity_y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
swipe_x = velocity_x / 10;
|
||||
@@ -37,8 +37,8 @@ swipe_gesture_swept (GtkGestureSwipe *gesture,
|
||||
|
||||
static void
|
||||
long_press_gesture_pressed (GtkGestureLongPress *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
long_pressed = TRUE;
|
||||
@@ -56,8 +56,8 @@ long_press_gesture_end (GtkGesture *gesture,
|
||||
|
||||
static void
|
||||
rotation_angle_changed (GtkGestureRotate *gesture,
|
||||
gdouble angle,
|
||||
gdouble delta,
|
||||
double angle,
|
||||
double delta,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
gtk_widget_queue_draw (widget);
|
||||
@@ -65,7 +65,7 @@ rotation_angle_changed (GtkGestureRotate *gesture,
|
||||
|
||||
static void
|
||||
zoom_scale_changed (GtkGestureZoom *gesture,
|
||||
gdouble scale,
|
||||
double scale,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
gtk_widget_queue_draw (widget);
|
||||
@@ -93,8 +93,8 @@ drawing_area_draw (GtkDrawingArea *area,
|
||||
{
|
||||
cairo_pattern_t *pat;
|
||||
cairo_matrix_t matrix;
|
||||
gdouble angle, scale;
|
||||
gdouble x_center, y_center;
|
||||
double angle, scale;
|
||||
double x_center, y_center;
|
||||
|
||||
gtk_gesture_get_bounding_box_center (GTK_GESTURE (zoom), &x_center, &y_center);
|
||||
|
||||
|
@@ -25,7 +25,7 @@ typedef struct _GtkFishbowlChild GtkFishbowlChild;
|
||||
struct _GtkFishbowlPrivate
|
||||
{
|
||||
GtkFishCreationFunc creation_func;
|
||||
GList *children;
|
||||
GHashTable *children;
|
||||
guint count;
|
||||
|
||||
gint64 last_frame_time;
|
||||
@@ -53,7 +53,6 @@ enum {
|
||||
PROP_BENCHMARK,
|
||||
PROP_COUNT,
|
||||
PROP_FRAMERATE,
|
||||
PROP_FRAMERATE_STRING,
|
||||
PROP_UPDATE_DELAY,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
@@ -68,6 +67,8 @@ gtk_fishbowl_init (GtkFishbowl *fishbowl)
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
|
||||
priv->update_delay = G_USEC_PER_SEC;
|
||||
priv->children = g_hash_table_new_full (NULL, NULL,
|
||||
NULL, (GDestroyNotify) g_free);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,20 +95,18 @@ gtk_fishbowl_measure (GtkWidget *widget,
|
||||
{
|
||||
GtkFishbowl *fishbowl = GTK_FISHBOWL (widget);
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
GtkFishbowlChild *child;
|
||||
GList *children;
|
||||
gint child_min, child_nat;
|
||||
int child_min, child_nat;
|
||||
|
||||
*minimum = 0;
|
||||
*natural = 0;
|
||||
|
||||
for (children = priv->children; children; children = children->next)
|
||||
g_hash_table_iter_init (&iter, priv->children);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
child = children->data;
|
||||
|
||||
if (!gtk_widget_get_visible (child->widget))
|
||||
continue;
|
||||
|
||||
child = value;
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
@@ -137,14 +136,13 @@ gtk_fishbowl_size_allocate (GtkWidget *widget,
|
||||
GtkFishbowlChild *child;
|
||||
GtkAllocation child_allocation;
|
||||
GtkRequisition child_requisition;
|
||||
GList *children;
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
for (children = priv->children; children; children = children->next)
|
||||
g_hash_table_iter_init (&iter, priv->children);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
child = children->data;
|
||||
|
||||
if (!gtk_widget_get_visible (child->widget))
|
||||
continue;
|
||||
child = value;
|
||||
|
||||
gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
|
||||
child_allocation.x = round (child->x * (width - child_requisition.width));
|
||||
@@ -182,7 +180,7 @@ gtk_fishbowl_add (GtkFishbowl *fishbowl,
|
||||
|
||||
gtk_widget_set_parent (widget, GTK_WIDGET (fishbowl));
|
||||
|
||||
priv->children = g_list_prepend (priv->children, child_info);
|
||||
g_hash_table_insert (priv->children, widget, child_info);
|
||||
priv->count++;
|
||||
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
|
||||
}
|
||||
@@ -192,34 +190,26 @@ gtk_fishbowl_remove (GtkFishbowl *fishbowl,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
GtkFishbowlChild *child;
|
||||
GtkWidget *widget_bowl = GTK_WIDGET (fishbowl);
|
||||
GList *children;
|
||||
|
||||
for (children = priv->children; children; children = children->next)
|
||||
if (g_hash_table_remove (priv->children, widget))
|
||||
{
|
||||
child = children->data;
|
||||
gtk_widget_unparent (widget);
|
||||
|
||||
if (child->widget == widget)
|
||||
{
|
||||
gboolean was_visible = gtk_widget_get_visible (widget);
|
||||
|
||||
gtk_widget_unparent (widget);
|
||||
|
||||
priv->children = g_list_remove_link (priv->children, children);
|
||||
g_list_free (children);
|
||||
g_free (child);
|
||||
|
||||
if (was_visible && gtk_widget_get_visible (widget_bowl))
|
||||
gtk_widget_queue_resize (widget_bowl);
|
||||
|
||||
priv->count--;
|
||||
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
|
||||
break;
|
||||
}
|
||||
priv->count--;
|
||||
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_fishbowl_finalize (GObject *object)
|
||||
{
|
||||
GtkFishbowl *fishbowl = GTK_FISHBOWL (object);
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
|
||||
g_hash_table_destroy (priv->children);
|
||||
priv->children = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_fishbowl_dispose (GObject *object)
|
||||
{
|
||||
@@ -289,14 +279,6 @@ gtk_fishbowl_get_property (GObject *object,
|
||||
g_value_set_double (value, gtk_fishbowl_get_framerate (fishbowl));
|
||||
break;
|
||||
|
||||
case PROP_FRAMERATE_STRING:
|
||||
{
|
||||
char *s = g_strdup_printf ("%.2f", gtk_fishbowl_get_framerate (fishbowl));
|
||||
g_value_set_string (value, s);
|
||||
g_free (s);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_UPDATE_DELAY:
|
||||
g_value_set_int64 (value, gtk_fishbowl_get_update_delay (fishbowl));
|
||||
break;
|
||||
@@ -313,6 +295,7 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_fishbowl_finalize;
|
||||
object_class->dispose = gtk_fishbowl_dispose;
|
||||
object_class->set_property = gtk_fishbowl_set_property;
|
||||
object_class->get_property = gtk_fishbowl_get_property;
|
||||
@@ -350,13 +333,6 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
|
||||
0,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
props[PROP_FRAMERATE_STRING] =
|
||||
g_param_spec_string ("framerate-string",
|
||||
"Framerate as string",
|
||||
"Framerate as string, with 2 decimals",
|
||||
NULL,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
props[PROP_UPDATE_DELAY] =
|
||||
g_param_spec_int64 ("update-delay",
|
||||
"Update delay",
|
||||
@@ -508,7 +484,6 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
|
||||
priv->framerate = ((int)(priv->framerate * 100))/100.0;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE]);
|
||||
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE_STRING]);
|
||||
|
||||
if (!priv->benchmark)
|
||||
return;
|
||||
@@ -552,8 +527,9 @@ gtk_fishbowl_tick (GtkWidget *widget,
|
||||
GtkFishbowl *fishbowl = GTK_FISHBOWL (widget);
|
||||
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
|
||||
GtkFishbowlChild *child;
|
||||
GList *l;
|
||||
gint64 frame_time, elapsed;
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
gboolean do_update;
|
||||
|
||||
frame_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
|
||||
@@ -565,9 +541,10 @@ gtk_fishbowl_tick (GtkWidget *widget,
|
||||
if (elapsed == frame_time)
|
||||
return G_SOURCE_CONTINUE;
|
||||
|
||||
for (l = priv->children; l; l = l->next)
|
||||
g_hash_table_iter_init (&iter, priv->children);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
child = l->data;
|
||||
child = value;
|
||||
|
||||
child->x += child->dx * ((double) elapsed / G_USEC_PER_SEC);
|
||||
child->y += child->dy * ((double) elapsed / G_USEC_PER_SEC);
|
||||
|
@@ -30,7 +30,6 @@ do_headerbar (GtkWidget *do_widget)
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
|
||||
button = gtk_button_new ();
|
||||
icon = g_themed_icon_new ("mail-send-receive-symbolic");
|
||||
|
@@ -18,7 +18,7 @@ static void
|
||||
insert_link (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
const char *text,
|
||||
gint page)
|
||||
int page)
|
||||
{
|
||||
GtkTextTag *tag;
|
||||
|
||||
@@ -35,7 +35,7 @@ insert_link (GtkTextBuffer *buffer,
|
||||
*/
|
||||
static void
|
||||
show_page (GtkTextBuffer *buffer,
|
||||
gint page)
|
||||
int page)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
|
||||
@@ -91,7 +91,7 @@ follow_if_link (GtkWidget *text_view,
|
||||
for (tagp = tags; tagp != NULL; tagp = tagp->next)
|
||||
{
|
||||
GtkTextTag *tag = tagp->data;
|
||||
gint page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
|
||||
int page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
|
||||
|
||||
if (page != 0)
|
||||
{
|
||||
@@ -134,14 +134,14 @@ key_pressed (GtkEventController *controller,
|
||||
}
|
||||
|
||||
static void set_cursor_if_appropriate (GtkTextView *text_view,
|
||||
gint x,
|
||||
gint y);
|
||||
int x,
|
||||
int y);
|
||||
|
||||
static void
|
||||
released_cb (GtkGestureClick *gesture,
|
||||
guint n_press,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *text_view)
|
||||
{
|
||||
GtkTextIter start, end, iter;
|
||||
@@ -168,8 +168,8 @@ released_cb (GtkGestureClick *gesture,
|
||||
|
||||
static void
|
||||
motion_cb (GtkEventControllerMotion *controller,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
double x,
|
||||
double y,
|
||||
GtkTextView *text_view)
|
||||
{
|
||||
set_cursor_if_appropriate (text_view, x, y);
|
||||
@@ -183,8 +183,8 @@ static gboolean hovering_over_link = FALSE;
|
||||
*/
|
||||
static void
|
||||
set_cursor_if_appropriate (GtkTextView *text_view,
|
||||
gint x,
|
||||
gint y)
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
GSList *tags = NULL, *tagp = NULL;
|
||||
GtkTextIter iter;
|
||||
@@ -196,7 +196,7 @@ set_cursor_if_appropriate (GtkTextView *text_view,
|
||||
for (tagp = tags; tagp != NULL; tagp = tagp->next)
|
||||
{
|
||||
GtkTextTag *tag = tagp->data;
|
||||
gint page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
|
||||
int page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
|
||||
|
||||
if (page != 0)
|
||||
{
|
||||
@@ -260,7 +260,7 @@ do_hypertext (GtkWidget *do_widget)
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_set_enable_undo (buffer, TRUE);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
@@ -12,7 +12,7 @@ static GtkWidget *window = NULL;
|
||||
static GtkWidget *scrolledwindow;
|
||||
static int selected;
|
||||
|
||||
#define N_WIDGET_TYPES 4
|
||||
#define N_WIDGET_TYPES 6
|
||||
|
||||
|
||||
static int hincrement = 5;
|
||||
@@ -64,6 +64,7 @@ populate_icons (void)
|
||||
gtk_grid_attach (GTK_GRID (grid), create_icon (), left, top, 1, 1);
|
||||
|
||||
hincrement = 0;
|
||||
vincrement = 5;
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_NEVER,
|
||||
@@ -100,6 +101,7 @@ populate_text (gboolean hilight)
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
|
||||
|
||||
hincrement = 0;
|
||||
vincrement = 5;
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_NEVER,
|
||||
@@ -124,6 +126,7 @@ populate_image (void)
|
||||
gtk_picture_set_can_shrink (GTK_PICTURE (image), FALSE);
|
||||
|
||||
hincrement = 5;
|
||||
vincrement = 5;
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
@@ -131,6 +134,42 @@ populate_image (void)
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), image);
|
||||
}
|
||||
|
||||
extern GtkWidget *create_weather_view (void);
|
||||
|
||||
static void
|
||||
populate_list (void)
|
||||
{
|
||||
GtkWidget *list;
|
||||
|
||||
list = create_weather_view ();
|
||||
|
||||
hincrement = 5;
|
||||
vincrement = 0;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
extern GtkWidget *create_color_grid (void);
|
||||
|
||||
static void
|
||||
populate_grid (void)
|
||||
{
|
||||
GtkWidget *list;
|
||||
|
||||
list = create_color_grid ();
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -164,6 +203,16 @@ set_widget_type (int type)
|
||||
populate_image ();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a list");
|
||||
populate_list ();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
|
||||
populate_grid ();
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@
|
||||
<property name="default-height">500</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
|
@@ -25,7 +25,7 @@ enum
|
||||
|
||||
|
||||
static GdkPixbuf *file_pixbuf, *folder_pixbuf;
|
||||
gchar *parent;
|
||||
char *parent;
|
||||
GtkWidget *up_button;
|
||||
|
||||
/* Loads the images for the demo and returns whether the operation succeeded */
|
||||
@@ -47,7 +47,7 @@ static void
|
||||
fill_store (GtkListStore *store)
|
||||
{
|
||||
GDir *dir;
|
||||
const gchar *name;
|
||||
const char *name;
|
||||
GtkTreeIter iter;
|
||||
|
||||
/* First clear the store */
|
||||
@@ -62,7 +62,7 @@ fill_store (GtkListStore *store)
|
||||
name = g_dir_read_name (dir);
|
||||
while (name != NULL)
|
||||
{
|
||||
gchar *path, *display_name;
|
||||
char *path, *display_name;
|
||||
gboolean is_dir;
|
||||
|
||||
/* We ignore hidden files that start with a '.' */
|
||||
@@ -90,14 +90,14 @@ fill_store (GtkListStore *store)
|
||||
g_dir_close (dir);
|
||||
}
|
||||
|
||||
static gint
|
||||
static int
|
||||
sort_func (GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean is_dir_a, is_dir_b;
|
||||
gchar *name_a, *name_b;
|
||||
char *name_a, *name_b;
|
||||
int ret;
|
||||
|
||||
/* We need this function because we want to sort
|
||||
@@ -158,7 +158,7 @@ item_activated (GtkIconView *icon_view,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkListStore *store;
|
||||
gchar *path;
|
||||
char *path;
|
||||
GtkTreeIter iter;
|
||||
gboolean is_dir;
|
||||
|
||||
@@ -192,7 +192,7 @@ up_clicked (GtkButton *item,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkListStore *store;
|
||||
gchar *dir_name;
|
||||
char *dir_name;
|
||||
|
||||
store = GTK_LIST_STORE (user_data);
|
||||
|
||||
@@ -276,7 +276,7 @@ do_iconview (GtkWidget *do_widget)
|
||||
gtk_box_append (GTK_BOX (tool_bar), home_button);
|
||||
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
|
@@ -19,8 +19,8 @@ static void
|
||||
fill_store (GtkListStore *store)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
const gchar *text[] = { "Red", "Green", "Blue", "Yellow" };
|
||||
gint i;
|
||||
const char *text[] = { "Red", "Green", "Blue", "Yellow" };
|
||||
int i;
|
||||
|
||||
/* First clear the store */
|
||||
gtk_list_store_clear (store);
|
||||
@@ -49,7 +49,7 @@ set_cell_color (GtkCellLayout *cell_layout,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *text;
|
||||
char *text;
|
||||
GdkRGBA color;
|
||||
guint32 pixel = 0;
|
||||
GdkPixbuf *pixbuf;
|
||||
@@ -60,10 +60,10 @@ set_cell_color (GtkCellLayout *cell_layout,
|
||||
|
||||
if (gdk_rgba_parse (&color, text))
|
||||
pixel =
|
||||
((gint)(color.red * 255)) << 24 |
|
||||
((gint)(color.green * 255)) << 16 |
|
||||
((gint)(color.blue * 255)) << 8 |
|
||||
((gint)(color.alpha * 255));
|
||||
((int)(color.red * 255)) << 24 |
|
||||
((int)(color.green * 255)) << 16 |
|
||||
((int)(color.blue * 255)) << 8 |
|
||||
((int)(color.alpha * 255));
|
||||
|
||||
g_free (text);
|
||||
|
||||
@@ -77,8 +77,8 @@ set_cell_color (GtkCellLayout *cell_layout,
|
||||
|
||||
static void
|
||||
edited (GtkCellRendererText *cell,
|
||||
gchar *path_string,
|
||||
gchar *text,
|
||||
char *path_string,
|
||||
char *text,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
|
@@ -43,10 +43,10 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
|
||||
static void
|
||||
progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
@@ -58,7 +58,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
}
|
||||
|
||||
static gint
|
||||
static int
|
||||
progressive_timeout (gpointer data)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
static void
|
||||
on_bar_response (GtkInfoBar *info_bar,
|
||||
gint response_id,
|
||||
int response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
static void
|
||||
response_cb (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
int response_id,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
@@ -17,7 +17,7 @@ response_cb (GtkWidget *dialog,
|
||||
|
||||
static gboolean
|
||||
activate_link (GtkWidget *label,
|
||||
const gchar *uri,
|
||||
const char *uri,
|
||||
gpointer data)
|
||||
{
|
||||
if (g_strcmp0 (uri, "keynav") == 0)
|
||||
|
@@ -81,7 +81,7 @@ spinner_timeout (gpointer data)
|
||||
static GtkTreeModel *
|
||||
create_model (void)
|
||||
{
|
||||
gint i = 0;
|
||||
int i = 0;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
@@ -269,7 +269,7 @@ do_list_store (GtkWidget *do_widget)
|
||||
label = gtk_label_new ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
|
@@ -236,7 +236,6 @@ reshare_clicked (GtkMessageRow *row,
|
||||
|
||||
priv->message->n_reshares++;
|
||||
gtk_message_row_update (row);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -255,11 +254,12 @@ gtk_message_row_state_flags_changed (GtkWidget *widget,
|
||||
{
|
||||
GtkMessageRowPrivate *priv = GTK_MESSAGE_ROW (widget)->priv;
|
||||
GtkStateFlags flags;
|
||||
gboolean visible;
|
||||
|
||||
flags = gtk_widget_get_state_flags (widget);
|
||||
|
||||
gtk_widget_set_visible (priv->extra_buttons_box,
|
||||
flags & (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED));
|
||||
visible = flags & (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED) ? TRUE : FALSE;
|
||||
gtk_widget_set_visible (priv->extra_buttons_box, visible);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_message_row_parent_class)->state_flags_changed (widget, previous_state_flags);
|
||||
}
|
||||
@@ -358,7 +358,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
label = gtk_label_new ("Messages from GTK and friends");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
scrolled = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_vexpand (scrolled, TRUE);
|
||||
gtk_box_append (GTK_BOX (vbox), scrolled);
|
||||
|
202
demos/gtk-demo/listview_applauncher.c
Normal file
202
demos/gtk-demo/listview_applauncher.c
Normal file
@@ -0,0 +1,202 @@
|
||||
/* Lists/Application launcher
|
||||
*
|
||||
* This demo uses the GtkListView widget as a fancy application launcher.
|
||||
*
|
||||
* It is also a very small introduction to listviews.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* This is the function that creates the #GListModel that we need.
|
||||
* GTK list widgets need a #GListModel to display, as models support change
|
||||
* notifications.
|
||||
* Unfortunately various older APIs do not provide list models, so we create
|
||||
* our own.
|
||||
*/
|
||||
static GListModel *
|
||||
create_application_list (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GList *apps, *l;
|
||||
|
||||
/* We use a #GListStore here, which is a simple array-like list implementation
|
||||
* for manual management.
|
||||
* List models need to know what type of data they provide, so we need to
|
||||
* provide the type here. As we want to do a list of applications, #GAppInfo
|
||||
* is the object we provide.
|
||||
*/
|
||||
store = g_list_store_new (G_TYPE_APP_INFO);
|
||||
|
||||
apps = g_app_info_get_all ();
|
||||
|
||||
for (l = apps; l; l = l->next)
|
||||
g_list_store_append (store, l->data);
|
||||
|
||||
g_list_free_full (apps, g_object_unref);
|
||||
|
||||
return G_LIST_MODEL (store);
|
||||
}
|
||||
|
||||
/* This is the function we use for setting up new listitems to display.
|
||||
* We add just an #GtkImage and a #GtkKabel here to display the application's
|
||||
* icon and name, as this is just a simple demo.
|
||||
*/
|
||||
static void
|
||||
setup_listitem_cb (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *box;
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
image = gtk_image_new ();
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
gtk_box_append (GTK_BOX (box), image);
|
||||
label = gtk_label_new ("");
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
gtk_list_item_set_child (list_item, box);
|
||||
}
|
||||
|
||||
/* Here we need to prepare the listitem for displaying its item. We get the
|
||||
* listitem already set up from the previous function, so we can reuse the
|
||||
* #GtkImage widget we set up above.
|
||||
* We get the item - which we know is a #GAppInfo because it comes out of
|
||||
* the model we set up above, grab its icon and display it.
|
||||
*/
|
||||
static void
|
||||
bind_listitem_cb (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
GAppInfo *app_info;
|
||||
|
||||
image = gtk_widget_get_first_child (gtk_list_item_get_child (list_item));
|
||||
label = gtk_widget_get_next_sibling (image);
|
||||
app_info = gtk_list_item_get_item (list_item);
|
||||
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
|
||||
gtk_label_set_label (GTK_LABEL (label), g_app_info_get_display_name (app_info));
|
||||
}
|
||||
|
||||
/* In more complex code, we would also need functions to unbind and teardown
|
||||
* the listitem, but this is simple code, so the default implementations are
|
||||
* enough. If we had connected signals, this step would have been necessary.
|
||||
*
|
||||
* The #GtkSignalListItemFactory documentation contains more information about
|
||||
* this step.
|
||||
*/
|
||||
|
||||
/* This function is called whenever an item in the list is activated. This is
|
||||
* the simple way to allow reacting to the Enter key or double-clicking on a
|
||||
* listitem.
|
||||
* Of course, it is possible to use far more complex interactions by turning
|
||||
* off activation and adding buttons or other widgets in the setup function
|
||||
* above, but this is a simple demo, so we'll use the simple way.
|
||||
*/
|
||||
static void
|
||||
activate_cb (GtkListView *list,
|
||||
guint position,
|
||||
gpointer unused)
|
||||
{
|
||||
GAppInfo *app_info;
|
||||
GdkAppLaunchContext *context;
|
||||
GError *error = NULL;
|
||||
|
||||
app_info = g_list_model_get_item (gtk_list_view_get_model (list), position);
|
||||
|
||||
/* Prepare the context for launching the application and launch it. This
|
||||
* code is explained in detail in the documentation for #GdkAppLaunchContext
|
||||
* and #GAppInfo.
|
||||
*/
|
||||
context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (list)));
|
||||
if (!g_app_info_launch (app_info,
|
||||
NULL,
|
||||
G_APP_LAUNCH_CONTEXT (context),
|
||||
&error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
/* And because error handling is important, even a simple demo has it:
|
||||
* We display an error dialog that something went wrong.
|
||||
*/
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Could not launch %s", g_app_info_get_display_name (app_info));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
|
||||
g_clear_error (&error);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
g_object_unref (context);
|
||||
g_object_unref (app_info);
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
do_listview_applauncher (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkWidget *list, *sw;
|
||||
GListModel *model;
|
||||
GtkListItemFactory *factory;
|
||||
|
||||
/* Create a window and set a few defaults */
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 640, 320);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Application Launcher");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
|
||||
/* The #GtkListitemFactory is what is used to create #GtkListItems
|
||||
* to display the data from the model. So it is absolutely necessary
|
||||
* to create one.
|
||||
* We will use a #GtkSignalListItemFactory because it is the simplest
|
||||
* one to use. Different ones are available for different use cases.
|
||||
* The most powerful one is #GtkBuilderListItemFactory which uses
|
||||
* #GtkBuilder .ui files, so it requires little code.
|
||||
*/
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
|
||||
|
||||
/* Create the list widget here.
|
||||
*/
|
||||
list = gtk_list_view_new_with_factory (factory);
|
||||
/* We connect the activate signal here. It's the function we defined
|
||||
* above for launching the selected application.
|
||||
*/
|
||||
g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
|
||||
|
||||
/* And of course we need to set the data model. Here we call the function
|
||||
* we wrote above that gives us the list of applications. Then we set
|
||||
* it on the list widget.
|
||||
* The list will now take items from the model and use the factory
|
||||
* to create as many listitems as it needs to show itself to the user.
|
||||
*/
|
||||
model = create_application_list ();
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
|
||||
g_object_unref (model);
|
||||
|
||||
/* List widgets should always be contained in a #GtkScrolledWindow,
|
||||
* because otherwise they might get too large or they might not
|
||||
* be scrollable.
|
||||
*/
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
506
demos/gtk-demo/listview_clocks.c
Normal file
506
demos/gtk-demo/listview_clocks.c
Normal file
@@ -0,0 +1,506 @@
|
||||
/* Lists/Clocks
|
||||
*
|
||||
* This demo displays the time in different timezones.
|
||||
*
|
||||
* The goal is to show how to set up expressions that track changes
|
||||
* in objects and make them update widgets. For that, we create a
|
||||
* GtkClock object that updates its time every second and then use
|
||||
* various ways to display that time.
|
||||
*
|
||||
* Typically, this will be done using GtkBuilder .ui files with the
|
||||
* help of the <binding> tag, but this demo shows the code that runs
|
||||
* behind that.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define GTK_TYPE_CLOCK (gtk_clock_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkClock, gtk_clock, GTK, CLOCK, GObject)
|
||||
|
||||
/* This is our object. It's just a timezone */
|
||||
typedef struct _GtkClock GtkClock;
|
||||
struct _GtkClock
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
/* We allow this to be NULL for the local timezone */
|
||||
GTimeZone *timezone;
|
||||
/* Name of the location we're displaying time for */
|
||||
char *location;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_LOCATION,
|
||||
PROP_TIME,
|
||||
PROP_TIMEZONE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
/* This function returns the current time in the clock's timezone.
|
||||
* Note that this returns a new object every time, so we need to
|
||||
* remember to unref it after use.
|
||||
*/
|
||||
static GDateTime *
|
||||
gtk_clock_get_time (GtkClock *clock)
|
||||
{
|
||||
if (clock->timezone)
|
||||
return g_date_time_new_now (clock->timezone);
|
||||
else
|
||||
return g_date_time_new_now_local ();
|
||||
}
|
||||
|
||||
/* Here, we implement the functionality required by the GdkPaintable
|
||||
* interface. This way we have a trivial way to display an analog clock.
|
||||
* It also allows demonstrating how to directly use objects in the
|
||||
* listview later by making this object do something interesting.
|
||||
*/
|
||||
static void
|
||||
gtk_clock_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
GtkClock *self = GTK_CLOCK (paintable);
|
||||
GDateTime *time;
|
||||
GskRoundedRect outline;
|
||||
|
||||
#define BLACK ((GdkRGBA) { 0, 0, 0, 1 })
|
||||
|
||||
/* save/restore() is necessary so we can undo the transforms we start
|
||||
* out with.
|
||||
*/
|
||||
gtk_snapshot_save (snapshot);
|
||||
|
||||
/* First, we move the (0, 0) point to the center of the area so
|
||||
* we can draw everything relative to it.
|
||||
*/
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (width / 2, height / 2));
|
||||
|
||||
/* Next we scale it, so that we can pretend that the clock is
|
||||
* 100px in size. That way, we don't need to do any complicated
|
||||
* math later. We use MIN() here so that we use the smaller
|
||||
* dimension for sizing. That way we don't overdraw but keep
|
||||
* the aspect ratio.
|
||||
*/
|
||||
gtk_snapshot_scale (snapshot, MIN (width, height) / 100.0, MIN (width, height) / 100.0);
|
||||
|
||||
/* Now we have a circle with diameter 100px (and radius 50px) that
|
||||
* has its (0, 0) point at the center. Let's draw a simple clock into it.
|
||||
*/
|
||||
time = gtk_clock_get_time (self);
|
||||
|
||||
/* First, draw a circle. This is a neat little trick to draw a circle
|
||||
* without requiring Cairo.
|
||||
*/
|
||||
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-50, -50, 100, 100), 50);
|
||||
gtk_snapshot_append_border (snapshot,
|
||||
&outline,
|
||||
(float[4]) { 4, 4, 4, 4 },
|
||||
(GdkRGBA [4]) { BLACK, BLACK, BLACK, BLACK });
|
||||
|
||||
/* Next, draw the hour hand.
|
||||
* We do this using tranforms again: Instead of computing where the angle
|
||||
* points to, we just rotate everything and then draw the hand as if it
|
||||
* was :00. We don't even need to care about am/pm here because rotations
|
||||
* just work.
|
||||
*/
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_rotate (snapshot, 30 * g_date_time_get_hour (time) + 0.5 * g_date_time_get_minute (time));
|
||||
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-2, -23, 4, 25), 2);
|
||||
gtk_snapshot_push_rounded_clip (snapshot, &outline);
|
||||
gtk_snapshot_append_color (snapshot, &BLACK, &outline.bounds);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
/* And the same as above for the minute hand. Just make this one longer
|
||||
* so people can tell the hands apart.
|
||||
*/
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_rotate (snapshot, 6 * g_date_time_get_minute (time));
|
||||
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-2, -43, 4, 45), 2);
|
||||
gtk_snapshot_push_rounded_clip (snapshot, &outline);
|
||||
gtk_snapshot_append_color (snapshot, &BLACK, &outline.bounds);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
/* and finally, the second indicator. */
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_rotate (snapshot, 6 * g_date_time_get_second (time));
|
||||
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-2, -43, 4, 10), 2);
|
||||
gtk_snapshot_push_rounded_clip (snapshot, &outline);
|
||||
gtk_snapshot_append_color (snapshot, &BLACK, &outline.bounds);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
/* And finally, don't forget to restore the initial save() that
|
||||
* we did for the initial transformations.
|
||||
*/
|
||||
gtk_snapshot_restore (snapshot);
|
||||
|
||||
g_date_time_unref (time);
|
||||
}
|
||||
|
||||
/* Our desired size is 100px. That sounds okay for an analog clock */
|
||||
static int
|
||||
gtk_clock_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_clock_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
/* Initialize the paintable interface. This way we turn our clocks
|
||||
* into objects that can be drawn. There are more functions to this
|
||||
* interface to define desired size, but this is enough.
|
||||
*/
|
||||
static void
|
||||
gtk_clock_paintable_init (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->snapshot = gtk_clock_snapshot;
|
||||
iface->get_intrinsic_width = gtk_clock_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = gtk_clock_get_intrinsic_height;
|
||||
}
|
||||
|
||||
/* Finally, we define the type. The important part is adding the
|
||||
* paintable interface, so GTK knows that this object can indeed
|
||||
* be drawn.
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkClock, gtk_clock, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
gtk_clock_paintable_init))
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
gtk_clock_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkClock *self = GTK_CLOCK (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_LOCATION:
|
||||
g_value_set_string (value, self->location);
|
||||
break;
|
||||
|
||||
case PROP_TIME:
|
||||
g_value_take_boxed (value, gtk_clock_get_time (self));
|
||||
break;
|
||||
|
||||
case PROP_TIMEZONE:
|
||||
g_value_set_boxed (value, self->timezone);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_clock_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkClock *self = GTK_CLOCK (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_LOCATION:
|
||||
self->location = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_TIMEZONE:
|
||||
self->timezone = g_value_dup_boxed (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is the list of all the ticking clocks */
|
||||
static GSList *ticking_clocks = NULL;
|
||||
|
||||
/* This is the ID of the timeout source that is updating all
|
||||
* ticking clocks.
|
||||
*/
|
||||
static guint ticking_clock_id = 0;
|
||||
|
||||
/* Every second, this function is called to tell everybody that
|
||||
* the clocks are ticking.
|
||||
*/
|
||||
static gboolean
|
||||
gtk_clock_tick (gpointer unused)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = ticking_clocks; l; l = l->next)
|
||||
{
|
||||
GtkClock *clock = l->data;
|
||||
|
||||
/* We will now return a different value for the time property,
|
||||
* so notify about that.
|
||||
*/
|
||||
g_object_notify_by_pspec (G_OBJECT (clock), properties[PROP_TIME]);
|
||||
|
||||
/* We will also draw the hands of the clock differently.
|
||||
* So notify about that, too.
|
||||
*/
|
||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (clock));
|
||||
}
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_clock_stop_ticking (GtkClock *self)
|
||||
{
|
||||
ticking_clocks = g_slist_remove (ticking_clocks, self);
|
||||
|
||||
/* If no clock is remaining, stop running the tick updates */
|
||||
if (ticking_clocks == NULL && ticking_clock_id != 0)
|
||||
g_clear_handle_id (&ticking_clock_id, g_source_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_clock_start_ticking (GtkClock *self)
|
||||
{
|
||||
/* if no clock is ticking yet, start */
|
||||
if (ticking_clock_id == 0)
|
||||
ticking_clock_id = g_timeout_add_seconds (1, gtk_clock_tick, NULL);
|
||||
|
||||
ticking_clocks = g_slist_prepend (ticking_clocks, self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_clock_finalize (GObject *object)
|
||||
{
|
||||
GtkClock *self = GTK_CLOCK (object);
|
||||
|
||||
gtk_clock_stop_ticking (self);
|
||||
|
||||
g_free (self->location);
|
||||
g_clear_pointer (&self->timezone, g_time_zone_unref);
|
||||
|
||||
G_OBJECT_CLASS (gtk_clock_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_clock_class_init (GtkClockClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->get_property = gtk_clock_get_property;
|
||||
gobject_class->set_property = gtk_clock_set_property;
|
||||
gobject_class->finalize = gtk_clock_finalize;
|
||||
|
||||
properties[PROP_LOCATION] =
|
||||
g_param_spec_string ("location", NULL, NULL, NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
properties[PROP_TIME] =
|
||||
g_param_spec_boxed ("time", NULL, NULL, G_TYPE_DATE_TIME, G_PARAM_READABLE);
|
||||
properties[PROP_TIMEZONE] =
|
||||
g_param_spec_boxed ("timezone", NULL, NULL, G_TYPE_TIME_ZONE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_clock_init (GtkClock *self)
|
||||
{
|
||||
gtk_clock_start_ticking (self);
|
||||
}
|
||||
|
||||
static GtkClock *
|
||||
gtk_clock_new (const char *location,
|
||||
GTimeZone *_tz)
|
||||
{
|
||||
GtkClock *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_CLOCK,
|
||||
"location", location,
|
||||
"timezone", _tz,
|
||||
NULL);
|
||||
|
||||
g_clear_pointer (&_tz, g_time_zone_unref);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_clocks_model (void)
|
||||
{
|
||||
GListStore *result;
|
||||
GtkClock *clock;
|
||||
|
||||
result = g_list_store_new (GTK_TYPE_CLOCK);
|
||||
|
||||
/* local time */
|
||||
clock = gtk_clock_new ("local", NULL);
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
/* UTC time */
|
||||
clock = gtk_clock_new ("UTC", g_time_zone_new_utc ());
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
/* A bunch of timezones with GTK hackers */
|
||||
clock = gtk_clock_new ("San Francisco", g_time_zone_new ("America/Los_Angeles"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
clock = gtk_clock_new ("Xalapa", g_time_zone_new ("America/Mexico_City"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
clock = gtk_clock_new ("Boston", g_time_zone_new ("America/New_York"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
clock = gtk_clock_new ("London", g_time_zone_new ("Europe/London"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
clock = gtk_clock_new ("Berlin", g_time_zone_new ("Europe/Berlin"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
clock = gtk_clock_new ("Moscow", g_time_zone_new ("Europe/Moscow"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
clock = gtk_clock_new ("New Delhi", g_time_zone_new ("Asia/Kolkata"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
clock = gtk_clock_new ("Shanghai", g_time_zone_new ("Asia/Shanghai"));
|
||||
g_list_store_append (result, clock);
|
||||
g_object_unref (clock);
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
}
|
||||
|
||||
static char *
|
||||
convert_time_to_string (GObject *image,
|
||||
GDateTime *time,
|
||||
gpointer unused)
|
||||
{
|
||||
return g_date_time_format (time, "%x\n%X");
|
||||
}
|
||||
|
||||
/* And this function is the crux for this whole demo.
|
||||
* It shows how to use expressions to set up bindings.
|
||||
*/
|
||||
static void
|
||||
setup_listitem_cb (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *box, *picture, *location_label, *time_label;
|
||||
GtkExpression *clock_expression, *expression;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_list_item_set_child (list_item, box);
|
||||
|
||||
/* First, we create an expression that gets us the clock from the listitem:
|
||||
* 1. Create an expression that gets the list item.
|
||||
* 2. Use that expression's "item" property to get the clock
|
||||
*/
|
||||
expression = gtk_constant_expression_new (GTK_TYPE_LIST_ITEM, list_item);
|
||||
clock_expression = gtk_property_expression_new (GTK_TYPE_LIST_ITEM, expression, "item");
|
||||
|
||||
/* Bind the clock's location to a label.
|
||||
* This is easy: We just get the "location" property of the clock.
|
||||
*/
|
||||
expression = gtk_property_expression_new (GTK_TYPE_CLOCK,
|
||||
gtk_expression_ref (clock_expression),
|
||||
"location");
|
||||
/* Now create the label and bind the expression to it. */
|
||||
location_label = gtk_label_new (NULL);
|
||||
gtk_expression_bind (expression, location_label, "label", location_label);
|
||||
gtk_box_append (GTK_BOX (box), location_label);
|
||||
|
||||
|
||||
/* Here we bind the item itself to a GdkPicture.
|
||||
* This is simply done by using the clock expression itself.
|
||||
*/
|
||||
expression = gtk_expression_ref (clock_expression);
|
||||
/* Now create the widget and bind the expression to it. */
|
||||
picture = gtk_picture_new ();
|
||||
gtk_expression_bind (expression, picture, "paintable", picture);
|
||||
gtk_box_append (GTK_BOX (box), picture);
|
||||
|
||||
|
||||
/* And finally, everything comes together.
|
||||
* We create a label for displaying the time as text.
|
||||
* For that, we need to transform the "GDateTime" of the
|
||||
* time property into a string so that the label can display it.
|
||||
*/
|
||||
expression = gtk_property_expression_new (GTK_TYPE_CLOCK,
|
||||
gtk_expression_ref (clock_expression),
|
||||
"time");
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING,
|
||||
NULL,
|
||||
1, (GtkExpression *[1]) { expression },
|
||||
G_CALLBACK (convert_time_to_string),
|
||||
NULL, NULL);
|
||||
/* Now create the label and bind the expression to it. */
|
||||
time_label = gtk_label_new (NULL);
|
||||
gtk_expression_bind (expression, time_label, "label", time_label);
|
||||
gtk_box_append (GTK_BOX (box), time_label);
|
||||
|
||||
gtk_expression_unref (clock_expression);
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
do_listview_clocks (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkWidget *gridview, *sw;
|
||||
GtkListItemFactory *factory;
|
||||
GListModel *model;
|
||||
GtkNoSelection *selection;
|
||||
|
||||
/* This is the normal window setup code every demo does */
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Clocks");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
|
||||
/* List widgets go into a scrolled window. Always. */
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
|
||||
/* Create the factory that creates the listitems. Because we
|
||||
* used bindings above during setup, we only need to connect
|
||||
* to the setup signal.
|
||||
* The bindings take care of the bind step.
|
||||
*/
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
|
||||
|
||||
gridview = gtk_grid_view_new_with_factory (factory);
|
||||
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
|
||||
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
|
||||
|
||||
model = create_clocks_model ();
|
||||
selection = gtk_no_selection_new (model);
|
||||
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
|
||||
g_object_unref (selection);
|
||||
g_object_unref (model);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
1142
demos/gtk-demo/listview_colors.c
Normal file
1142
demos/gtk-demo/listview_colors.c
Normal file
File diff suppressed because it is too large
Load Diff
3
demos/gtk-demo/listview_colors.css
Normal file
3
demos/gtk-demo/listview_colors.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.view.compact > child {
|
||||
padding: 1px;
|
||||
}
|
281
demos/gtk-demo/listview_filebrowser.c
Normal file
281
demos/gtk-demo/listview_filebrowser.c
Normal file
@@ -0,0 +1,281 @@
|
||||
/* Lists/File browser
|
||||
*
|
||||
* This demo shows off the different layouts that are quickly achievable
|
||||
* with GtkListview and GtkGridView by implementing a file browser with
|
||||
* different views.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
/* Create a simple object that holds the data for the different views */
|
||||
typedef struct _FileBrowserView FileBrowserView;
|
||||
struct _FileBrowserView
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkListItemFactory *factory;
|
||||
char *icon_name;
|
||||
char *title;
|
||||
GtkOrientation orientation;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_FACTORY,
|
||||
PROP_ICON_NAME,
|
||||
PROP_TITLE,
|
||||
PROP_ORIENTATION,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
#define FILE_BROWSER_TYPE_VIEW (file_browser_view_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (FileBrowserView, file_browser_view, FILE_BROWSER, VIEW, GObject);
|
||||
|
||||
G_DEFINE_TYPE (FileBrowserView, file_browser_view, G_TYPE_OBJECT);
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
file_browser_view_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
FileBrowserView *self = FILE_BROWSER_VIEW (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_FACTORY:
|
||||
g_value_set_object (value, self->factory);
|
||||
break;
|
||||
|
||||
case PROP_ICON_NAME:
|
||||
g_value_set_string (value, self->icon_name);
|
||||
break;
|
||||
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, self->title);
|
||||
break;
|
||||
|
||||
case PROP_ORIENTATION:
|
||||
g_value_set_enum (value, self->orientation);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
file_browser_view_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
FileBrowserView *self = FILE_BROWSER_VIEW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FACTORY:
|
||||
g_set_object (&self->factory, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_ICON_NAME:
|
||||
g_free (self->icon_name);
|
||||
self->icon_name = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_TITLE:
|
||||
g_free (self->title);
|
||||
self->title = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_ORIENTATION:
|
||||
self->orientation = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
file_browser_view_finalize (GObject *object)
|
||||
{
|
||||
FileBrowserView *self = FILE_BROWSER_VIEW (object);
|
||||
|
||||
g_object_unref (self->factory);
|
||||
g_free (self->icon_name);
|
||||
g_free (self->title);
|
||||
|
||||
G_OBJECT_CLASS (file_browser_view_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
file_browser_view_class_init (FileBrowserViewClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->get_property = file_browser_view_get_property;
|
||||
gobject_class->set_property = file_browser_view_set_property;
|
||||
gobject_class->finalize = file_browser_view_finalize;
|
||||
|
||||
properties[PROP_FACTORY] =
|
||||
g_param_spec_object ("factory",
|
||||
"factory",
|
||||
"factory to use in the main view",
|
||||
GTK_TYPE_LIST_ITEM_FACTORY,
|
||||
G_PARAM_READWRITE);
|
||||
properties[PROP_ICON_NAME] =
|
||||
g_param_spec_string ("icon-name",
|
||||
"icon name",
|
||||
"icon to display for selecting this view",
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
properties[PROP_TITLE] =
|
||||
g_param_spec_string ("title",
|
||||
"title",
|
||||
"title to display for selecting this view",
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
properties[PROP_ORIENTATION] =
|
||||
g_param_spec_enum ("orientation",
|
||||
"orientation",
|
||||
"orientation of the view",
|
||||
GTK_TYPE_ORIENTATION,
|
||||
GTK_ORIENTATION_VERTICAL,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void file_browser_view_init (FileBrowserView *self)
|
||||
{
|
||||
}
|
||||
|
||||
char *
|
||||
filebrowser_get_display_name (GObject *object,
|
||||
GFileInfo *info)
|
||||
{
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
return g_strdup (g_file_info_get_attribute_string (info, "standard::display-name"));
|
||||
}
|
||||
|
||||
char *
|
||||
filebrowser_get_content_type (GObject *object,
|
||||
GFileInfo *info)
|
||||
{
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
return g_strdup (g_file_info_get_attribute_string (info, "standard::content-type"));
|
||||
}
|
||||
|
||||
char *
|
||||
filebrowser_get_size (GObject *object,
|
||||
GFileInfo *info)
|
||||
{
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
return g_format_size (g_file_info_get_attribute_uint64 (info, "standard::size"));
|
||||
}
|
||||
|
||||
GIcon *
|
||||
filebrowser_get_icon (GObject *object,
|
||||
GFileInfo *info)
|
||||
{
|
||||
GIcon *icon;
|
||||
|
||||
if (info)
|
||||
icon = G_ICON (g_file_info_get_attribute_object (info, "standard::icon"));
|
||||
else
|
||||
icon = NULL;
|
||||
|
||||
if (icon)
|
||||
g_object_ref (icon);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
void
|
||||
filebrowser_up_clicked_cb (GtkButton *button,
|
||||
GtkDirectoryList *list)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = g_file_get_parent (gtk_directory_list_get_file (list));
|
||||
if (file == NULL)
|
||||
return;
|
||||
|
||||
gtk_directory_list_set_file (list, file);
|
||||
}
|
||||
|
||||
void
|
||||
filebrowser_view_activated_cb (GtkGridView *view,
|
||||
guint pos,
|
||||
GtkDirectoryList *list)
|
||||
{
|
||||
GFileInfo *info;
|
||||
|
||||
info = g_list_model_get_item (gtk_grid_view_get_model (view), pos);
|
||||
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
|
||||
gtk_directory_list_set_file (list, G_FILE (g_file_info_get_attribute_object (info, "standard::file")));
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_filebrowser (GtkWidget *do_widget)
|
||||
{
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *view;
|
||||
GtkBuilder *builder;
|
||||
GtkDirectoryList *dirlist;
|
||||
GFile *file;
|
||||
char *cwd;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/listview_filebrowser/listview_filebrowser.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/listview_filebrowser/listview_filebrowser.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);
|
||||
|
||||
/* Create the model and fill it with the contents of the current directory */
|
||||
cwd = g_get_current_dir ();
|
||||
file = g_file_new_for_path (cwd);
|
||||
g_free (cwd);
|
||||
dirlist = GTK_DIRECTORY_LIST (gtk_builder_get_object (builder, "dirlist"));
|
||||
gtk_directory_list_set_file (dirlist, file);
|
||||
g_object_unref (file);
|
||||
|
||||
/* grab focus in the view */
|
||||
view = GTK_WIDGET (gtk_builder_get_object (builder, "view"));
|
||||
gtk_widget_grab_focus (view);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
11
demos/gtk-demo/listview_filebrowser.css
Normal file
11
demos/gtk-demo/listview_filebrowser.css
Normal file
@@ -0,0 +1,11 @@
|
||||
listview.viewswitcher {
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
listview.viewswitcher > row {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
listview.viewswitcher row:selected {
|
||||
background: gray;
|
||||
}
|
248
demos/gtk-demo/listview_filebrowser.ui
Normal file
248
demos/gtk-demo/listview_filebrowser.ui
Normal file
@@ -0,0 +1,248 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GListStore" id="viewlist">
|
||||
<property name="item-type">FileBrowserView</property>
|
||||
<child>
|
||||
<object class="FileBrowserView">
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<binding name="gicon">
|
||||
<closure type="GIcon" function="filebrowser_get_icon">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">start</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="filebrowser_get_display_name">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="icon-name">view-list-symbolic</property>
|
||||
<property name="title" translatable="yes">List</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="FileBrowserView">
|
||||
<property name="icon-name">view-grid-symbolic</property>
|
||||
<property name="title" translatable="yes">Grid</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="icon-size">large</property>
|
||||
<binding name="gicon">
|
||||
<closure type="GIcon" function="filebrowser_get_icon">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="wrap">1</property>
|
||||
<property name="wrap-mode">word-char</property>
|
||||
<property name="lines">2</property>
|
||||
<property name="ellipsize">end</property>
|
||||
<property name="width-chars">10</property>
|
||||
<property name="max-width-chars">30</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="filebrowser_get_display_name">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="orientation">vertical</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="FileBrowserView">
|
||||
<property name="icon-name">view-paged-symbolic</property>
|
||||
<property name="title" translatable="yes">Paged</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="icon-size">large</property>
|
||||
<binding name="gicon">
|
||||
<closure type="GIcon" function="filebrowser_get_icon">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">start</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="filebrowser_get_display_name">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">start</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="filebrowser_get_size">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">start</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="filebrowser_get_content_type">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkDirectoryList" id="dirlist">
|
||||
<property name="attributes">standard::name,standard::display-name,standard::icon,standard::size,standard::content-type</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="title" translatable="yes">File browser</property>
|
||||
<property name="default-width">600</property>
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="">
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">go-up-symbolic</property>
|
||||
<signal name="clicked" handler="filebrowser_up_clicked_cb" object="dirlist" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkListView">
|
||||
<property name="valign">center</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
<class name="viewswitcher"/>
|
||||
</style>
|
||||
<property name="model">
|
||||
<object class="GtkSingleSelection" id="selected-view">
|
||||
<property name="model">viewlist</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkImage">
|
||||
<binding name="icon-name">
|
||||
<lookup type="FileBrowserView" name="icon-name">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<binding name="tooltip-text">
|
||||
<lookup type="FileBrowserView" name="title">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="can-focus">1</property>
|
||||
<child>
|
||||
<object class="GtkGridView" id="view">
|
||||
<property name="model">dirlist</property>
|
||||
<property name="max-columns">15</property>
|
||||
<binding name="factory">
|
||||
<lookup name="factory" type="FileBrowserView">
|
||||
<lookup name="selected-item">selected-view</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<binding name="orientation">
|
||||
<lookup name="orientation" type="FileBrowserView">
|
||||
<lookup name="selected-item">selected-view</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<signal name="activate" handler="filebrowser_view_activated_cb" object="dirlist" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
472
demos/gtk-demo/listview_minesweeper.c
Normal file
472
demos/gtk-demo/listview_minesweeper.c
Normal file
@@ -0,0 +1,472 @@
|
||||
/* Lists/Minesweeper
|
||||
*
|
||||
* This demo shows how to develop a user interface for small game using a
|
||||
* gridview.
|
||||
*
|
||||
* It demonstrates how to use the activate signal and single-press behavior
|
||||
* to implement rather different interaction behavior to a typical list.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/*** The cell object ***/
|
||||
|
||||
/* Create an object that holds the data for a cell in the game */
|
||||
typedef struct _SweeperCell SweeperCell;
|
||||
struct _SweeperCell
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
gboolean is_mine;
|
||||
gboolean is_visible;
|
||||
guint neighbor_mines;
|
||||
};
|
||||
|
||||
enum {
|
||||
CELL_PROP_0,
|
||||
CELL_PROP_LABEL,
|
||||
|
||||
N_CELL_PROPS
|
||||
};
|
||||
|
||||
#define SWEEPER_TYPE_CELL (sweeper_cell_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (SweeperCell, sweeper_cell, SWEEPER, CELL, GObject);
|
||||
|
||||
G_DEFINE_TYPE (SweeperCell, sweeper_cell, G_TYPE_OBJECT);
|
||||
static GParamSpec *cell_properties[N_CELL_PROPS] = { NULL, };
|
||||
|
||||
static const char *
|
||||
sweeper_cell_get_label (SweeperCell *self)
|
||||
{
|
||||
static const char *minecount_labels[10] = { "", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
if (!self->is_visible)
|
||||
return "?";
|
||||
|
||||
if (self->is_mine)
|
||||
return "💣";
|
||||
|
||||
return minecount_labels[self->neighbor_mines];
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_cell_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SweeperCell *self = SWEEPER_CELL (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case CELL_PROP_LABEL:
|
||||
g_value_set_string (value, sweeper_cell_get_label (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_cell_class_init (SweeperCellClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->get_property = sweeper_cell_get_property;
|
||||
|
||||
cell_properties[CELL_PROP_LABEL] =
|
||||
g_param_spec_string ("label",
|
||||
"label",
|
||||
"label to display for this row",
|
||||
NULL,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_CELL_PROPS, cell_properties);
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_cell_init (SweeperCell *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_cell_reveal (SweeperCell *self)
|
||||
{
|
||||
if (self->is_visible)
|
||||
return;
|
||||
|
||||
self->is_visible = TRUE;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), cell_properties[CELL_PROP_LABEL]);
|
||||
}
|
||||
|
||||
static SweeperCell *
|
||||
sweeper_cell_new (void)
|
||||
{
|
||||
return g_object_new (SWEEPER_TYPE_CELL, NULL);
|
||||
}
|
||||
|
||||
/*** The board object ***/
|
||||
|
||||
/* Create an object that holds the data for the game */
|
||||
typedef struct _SweeperGame SweeperGame;
|
||||
struct _SweeperGame
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GPtrArray *cells;
|
||||
guint width;
|
||||
guint height;
|
||||
gboolean playing;
|
||||
gboolean win;
|
||||
};
|
||||
|
||||
enum {
|
||||
GAME_PROP_0,
|
||||
GAME_PROP_HEIGHT,
|
||||
GAME_PROP_PLAYING,
|
||||
GAME_PROP_WIDTH,
|
||||
GAME_PROP_WIN,
|
||||
|
||||
N_GAME_PROPS
|
||||
};
|
||||
|
||||
#define SWEEPER_TYPE_GAME (sweeper_game_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (SweeperGame, sweeper_game, SWEEPER, GAME, GObject);
|
||||
|
||||
static GType
|
||||
sweeper_game_list_model_get_item_type (GListModel *model)
|
||||
{
|
||||
return SWEEPER_TYPE_GAME;
|
||||
}
|
||||
|
||||
static guint
|
||||
sweeper_game_list_model_get_n_items (GListModel *model)
|
||||
{
|
||||
SweeperGame *self = SWEEPER_GAME (model);
|
||||
|
||||
return self->width * self->height;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
sweeper_game_list_model_get_item (GListModel *model,
|
||||
guint position)
|
||||
{
|
||||
SweeperGame *self = SWEEPER_GAME (model);
|
||||
|
||||
return g_object_ref (g_ptr_array_index (self->cells, position));
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_list_model_init (GListModelInterface *iface)
|
||||
{
|
||||
iface->get_item_type = sweeper_game_list_model_get_item_type;
|
||||
iface->get_n_items = sweeper_game_list_model_get_n_items;
|
||||
iface->get_item = sweeper_game_list_model_get_item;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (SweeperGame, sweeper_game, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, sweeper_game_list_model_init))
|
||||
|
||||
static GParamSpec *game_properties[N_GAME_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
sweeper_game_dispose (GObject *object)
|
||||
{
|
||||
SweeperGame *self = SWEEPER_GAME (object);
|
||||
|
||||
g_clear_pointer (&self->cells, g_ptr_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (sweeper_game_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SweeperGame *self = SWEEPER_GAME (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case GAME_PROP_HEIGHT:
|
||||
g_value_set_uint (value, self->height);
|
||||
break;
|
||||
|
||||
case GAME_PROP_PLAYING:
|
||||
g_value_set_boolean (value, self->playing);
|
||||
break;
|
||||
|
||||
case GAME_PROP_WIDTH:
|
||||
g_value_set_uint (value, self->width);
|
||||
break;
|
||||
|
||||
case GAME_PROP_WIN:
|
||||
g_value_set_boolean (value, self->win);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_class_init (SweeperGameClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = sweeper_game_dispose;
|
||||
gobject_class->get_property = sweeper_game_get_property;
|
||||
|
||||
game_properties[GAME_PROP_HEIGHT] =
|
||||
g_param_spec_uint ("height",
|
||||
"height",
|
||||
"height of the game grid",
|
||||
1, G_MAXUINT, 8,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
game_properties[GAME_PROP_PLAYING] =
|
||||
g_param_spec_boolean ("playing",
|
||||
"playing",
|
||||
"if the game is still going on",
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
game_properties[GAME_PROP_WIDTH] =
|
||||
g_param_spec_uint ("width",
|
||||
"width",
|
||||
"width of the game grid",
|
||||
1, G_MAXUINT, 8,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
game_properties[GAME_PROP_WIN] =
|
||||
g_param_spec_boolean ("win",
|
||||
"win",
|
||||
"if the game was won",
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_GAME_PROPS, game_properties);
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_reset_board (SweeperGame *self,
|
||||
guint width,
|
||||
guint height)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_ptr_array_set_size (self->cells, 0);
|
||||
|
||||
for (i = 0; i < width * height; i++)
|
||||
{
|
||||
g_ptr_array_add (self->cells, sweeper_cell_new ());
|
||||
}
|
||||
|
||||
if (self->width != width)
|
||||
{
|
||||
self->width = width;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_WIDTH]);
|
||||
}
|
||||
if (self->height != height)
|
||||
{
|
||||
self->height = height;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_HEIGHT]);
|
||||
}
|
||||
if (!self->playing)
|
||||
{
|
||||
self->playing = TRUE;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_PLAYING]);
|
||||
}
|
||||
if (self->win)
|
||||
{
|
||||
self->win = FALSE;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_WIN]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_place_mines (SweeperGame *self,
|
||||
guint n_mines)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < n_mines; i++)
|
||||
{
|
||||
SweeperCell *cell;
|
||||
|
||||
do {
|
||||
cell = g_ptr_array_index (self->cells, g_random_int_range (0, self->cells->len));
|
||||
} while (cell->is_mine);
|
||||
|
||||
cell->is_mine = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static SweeperCell *
|
||||
get_cell (SweeperGame *self,
|
||||
guint x,
|
||||
guint y)
|
||||
{
|
||||
return g_ptr_array_index (self->cells, y * self->width + x);
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_count_neighbor_mines (SweeperGame *self,
|
||||
guint width,
|
||||
guint height)
|
||||
{
|
||||
guint x, y, x2, y2;
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
SweeperCell *cell = get_cell (self, x, y);
|
||||
|
||||
for (y2 = MAX (1, y) - 1; y2 < MIN (height, y + 2); y2++)
|
||||
{
|
||||
for (x2 = MAX (1, x) - 1; x2 < MIN (width, x + 2); x2++)
|
||||
{
|
||||
SweeperCell *other = get_cell (self, x2, y2);
|
||||
|
||||
if (other->is_mine)
|
||||
cell->neighbor_mines++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_new_game (SweeperGame *self,
|
||||
guint width,
|
||||
guint height,
|
||||
guint n_mines)
|
||||
{
|
||||
guint n_items_before;
|
||||
|
||||
g_return_if_fail (n_mines <= width * height);
|
||||
|
||||
n_items_before = self->width * self->height;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
|
||||
sweeper_game_reset_board (self, width, height);
|
||||
sweeper_game_place_mines (self, n_mines);
|
||||
sweeper_game_count_neighbor_mines (self, width, height);
|
||||
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), 0, n_items_before, width * height);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (self));
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_init (SweeperGame *self)
|
||||
{
|
||||
self->cells = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
|
||||
sweeper_game_new_game (self, 8, 8, 10);
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_end (SweeperGame *self,
|
||||
gboolean win)
|
||||
{
|
||||
if (self->playing)
|
||||
{
|
||||
self->playing = FALSE;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_PLAYING]);
|
||||
}
|
||||
if (self->win != win)
|
||||
{
|
||||
self->win = win;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_WIN]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_check_finished (SweeperGame *self)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (!self->playing)
|
||||
return;
|
||||
|
||||
for (i = 0; i < self->cells->len; i++)
|
||||
{
|
||||
SweeperCell *cell = g_ptr_array_index (self->cells, i);
|
||||
|
||||
/* There's still a non-revealed cell that isn't a mine */
|
||||
if (!cell->is_visible && !cell->is_mine)
|
||||
return;
|
||||
}
|
||||
|
||||
sweeper_game_end (self, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
sweeper_game_reveal_cell (SweeperGame *self,
|
||||
guint position)
|
||||
{
|
||||
SweeperCell *cell;
|
||||
|
||||
if (!self->playing)
|
||||
return;
|
||||
|
||||
cell = g_ptr_array_index (self->cells, position);
|
||||
sweeper_cell_reveal (cell);
|
||||
|
||||
if (cell->is_mine)
|
||||
sweeper_game_end (self, FALSE);
|
||||
|
||||
sweeper_game_check_finished (self);
|
||||
}
|
||||
|
||||
void
|
||||
minesweeper_cell_clicked_cb (GtkGridView *gridview,
|
||||
guint pos,
|
||||
SweeperGame *game)
|
||||
{
|
||||
sweeper_game_reveal_cell (game, pos);
|
||||
}
|
||||
|
||||
void
|
||||
minesweeper_new_game_cb (GtkButton *button,
|
||||
SweeperGame *game)
|
||||
{
|
||||
sweeper_game_new_game (game, 8, 8, 10);
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
do_listview_minesweeper (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
|
||||
g_type_ensure (SWEEPER_TYPE_GAME);
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/listview_minesweeper/listview_minesweeper.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;
|
||||
}
|
48
demos/gtk-demo/listview_minesweeper.ui
Normal file
48
demos/gtk-demo/listview_minesweeper.ui
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="SweeperGame" id="game">
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="title" translatable="yes">Minesweeper</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="">
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">New Game</property>
|
||||
<signal name="clicked" handler="minesweeper_new_game_cb" object="game" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child type="title">
|
||||
<object class="GtkImage">
|
||||
<property name="icon-name">trophy-gold</property>
|
||||
<binding name="visible">
|
||||
<lookup name="win">game</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGridView" id="view">
|
||||
<property name="model">
|
||||
<object class="GtkNoSelection">
|
||||
<property name="model">game</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="single-click-activate">1</property>
|
||||
<binding name="max-columns">
|
||||
<lookup name="width">game</lookup>
|
||||
</binding>
|
||||
<binding name="min-columns">
|
||||
<lookup name="width">game</lookup>
|
||||
</binding>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="resource">/listview_minesweeper/listview_minesweeper_cell.ui</property>
|
||||
</object>
|
||||
</property>
|
||||
<signal name="activate" handler="minesweeper_cell_clicked_cb" object="game" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
16
demos/gtk-demo/listview_minesweeper_cell.ui
Normal file
16
demos/gtk-demo/listview_minesweeper_cell.ui
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<binding name="label">
|
||||
<lookup name="label" type="SweeperCell">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
438
demos/gtk-demo/listview_settings.c
Normal file
438
demos/gtk-demo/listview_settings.c
Normal file
@@ -0,0 +1,438 @@
|
||||
/* Lists/Settings
|
||||
*
|
||||
* This demo shows a settings viewer for GSettings.
|
||||
*
|
||||
* It demonstrates how to implement support for trees with GtkListView.
|
||||
* It also shows how to set up sorting and filtering for columns in a
|
||||
* GtkColumnView.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Create an object that wraps GSettingsSchemaKey because that's a boxed type */
|
||||
typedef struct _SettingsKey SettingsKey;
|
||||
struct _SettingsKey
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GSettings *settings;
|
||||
GSettingsSchemaKey *key;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_SUMMARY,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_VALUE,
|
||||
PROP_TYPE,
|
||||
PROP_DEFAULT_VALUE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
#define SETTINGS_TYPE_KEY (settings_key_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (SettingsKey, settings_key, SETTINGS, KEY, GObject);
|
||||
|
||||
G_DEFINE_TYPE (SettingsKey, settings_key, G_TYPE_OBJECT);
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
settings_key_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_DESCRIPTION:
|
||||
g_value_set_string (value, g_settings_schema_key_get_description (self->key));
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, g_settings_schema_key_get_name (self->key));
|
||||
break;
|
||||
|
||||
case PROP_SUMMARY:
|
||||
g_value_set_string (value, g_settings_schema_key_get_summary (self->key));
|
||||
break;
|
||||
|
||||
case PROP_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_get_value (self->settings, g_settings_schema_key_get_name (self->key));
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_TYPE:
|
||||
{
|
||||
const GVariantType *type = g_settings_schema_key_get_value_type (self->key);
|
||||
g_value_set_string (value, g_variant_type_peek_string (type));
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEFAULT_VALUE:
|
||||
{
|
||||
GVariant *variant = g_settings_schema_key_get_default_value (self->key);
|
||||
g_value_take_string (value, g_variant_print (variant, FALSE));
|
||||
g_variant_unref (variant);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_finalize (GObject *object)
|
||||
{
|
||||
SettingsKey *self = SETTINGS_KEY (object);
|
||||
|
||||
g_object_unref (self->settings);
|
||||
g_settings_schema_key_unref (self->key);
|
||||
|
||||
G_OBJECT_CLASS (settings_key_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_class_init (SettingsKeyClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = settings_key_finalize;
|
||||
gobject_class->get_property = settings_key_get_property;
|
||||
|
||||
properties[PROP_DESCRIPTION] =
|
||||
g_param_spec_string ("description", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_NAME] =
|
||||
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_SUMMARY] =
|
||||
g_param_spec_string ("summary", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_VALUE] =
|
||||
g_param_spec_string ("value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_TYPE] =
|
||||
g_param_spec_string ("type", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
properties[PROP_DEFAULT_VALUE] =
|
||||
g_param_spec_string ("default-value", NULL, NULL, NULL, G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_key_init (SettingsKey *self)
|
||||
{
|
||||
}
|
||||
|
||||
static SettingsKey *
|
||||
settings_key_new (GSettings *settings,
|
||||
GSettingsSchemaKey *key)
|
||||
{
|
||||
SettingsKey *result = g_object_new (SETTINGS_TYPE_KEY, NULL);
|
||||
|
||||
result->settings = g_object_ref (settings);
|
||||
result->key = g_settings_schema_key_ref (key);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
item_value_changed (GtkEditableLabel *label,
|
||||
GParamSpec *pspec,
|
||||
GtkListItem *item)
|
||||
{
|
||||
SettingsKey *self;
|
||||
const char *text;
|
||||
const GVariantType *type;
|
||||
GVariant *variant;
|
||||
GError *error = NULL;
|
||||
const char *name;
|
||||
char *value;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (label));
|
||||
|
||||
g_object_get (item, "item", &self, NULL);
|
||||
g_object_unref (self);
|
||||
|
||||
type = g_settings_schema_key_get_value_type (self->key);
|
||||
name = g_settings_schema_key_get_name (self->key);
|
||||
|
||||
variant = g_variant_parse (type, text, NULL, NULL, &error);
|
||||
if (!variant)
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
if (!g_settings_schema_key_range_check (self->key, variant))
|
||||
{
|
||||
g_warning ("Not a valid value for %s", name);
|
||||
goto revert;
|
||||
}
|
||||
|
||||
g_settings_set_value (self->settings, name, variant);
|
||||
g_variant_unref (variant);
|
||||
return;
|
||||
|
||||
revert:
|
||||
gtk_widget_error_bell (GTK_WIDGET (label));
|
||||
|
||||
g_object_get (self, "value", &value, NULL);
|
||||
gtk_editable_set_text (GTK_EDITABLE (label), value);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static int
|
||||
strvcmp (gconstpointer p1,
|
||||
gconstpointer p2)
|
||||
{
|
||||
const char * const *s1 = p1;
|
||||
const char * const *s2 = p2;
|
||||
|
||||
return strcmp (*s1, *s2);
|
||||
}
|
||||
|
||||
static GtkFilter *current_filter;
|
||||
|
||||
static gboolean
|
||||
transform_settings_to_keys (GBinding *binding,
|
||||
const GValue *from_value,
|
||||
GValue *to_value,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeListRow *treelistrow;
|
||||
GSettings *settings;
|
||||
GSettingsSchema *schema;
|
||||
GListStore *store;
|
||||
GtkSortListModel *sort_model;
|
||||
GtkFilterListModel *filter_model;
|
||||
GtkFilter *filter;
|
||||
GtkNoSelection *selection_model;
|
||||
char **keys;
|
||||
guint i;
|
||||
|
||||
treelistrow = g_value_get_object (from_value);
|
||||
if (treelistrow == NULL)
|
||||
return TRUE;
|
||||
settings = gtk_tree_list_row_get_item (treelistrow);
|
||||
g_object_get (settings, "settings-schema", &schema, NULL);
|
||||
|
||||
store = g_list_store_new (SETTINGS_TYPE_KEY);
|
||||
|
||||
keys = g_settings_schema_list_keys (schema);
|
||||
|
||||
for (i = 0; keys[i] != NULL; i++)
|
||||
{
|
||||
GSettingsSchemaKey *almost_there = g_settings_schema_get_key (schema, keys[i]);
|
||||
SettingsKey *finally = settings_key_new (settings, almost_there);
|
||||
g_list_store_append (store, finally);
|
||||
g_object_unref (finally);
|
||||
g_settings_schema_key_unref (almost_there);
|
||||
}
|
||||
|
||||
g_strfreev (keys);
|
||||
g_settings_schema_unref (schema);
|
||||
g_object_unref (settings);
|
||||
|
||||
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data)));
|
||||
g_object_unref (store);
|
||||
|
||||
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
|
||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
|
||||
g_object_unref (sort_model);
|
||||
|
||||
g_set_object (¤t_filter, filter);
|
||||
|
||||
g_object_unref (filter);
|
||||
|
||||
selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
|
||||
g_object_unref (filter_model);
|
||||
|
||||
g_value_take_object (to_value, selection_model);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_settings_model (gpointer item,
|
||||
gpointer unused)
|
||||
{
|
||||
GSettings *settings = item;
|
||||
char **schemas;
|
||||
GListStore *result;
|
||||
guint i;
|
||||
|
||||
if (settings == NULL)
|
||||
{
|
||||
g_settings_schema_source_list_schemas (g_settings_schema_source_get_default (),
|
||||
TRUE,
|
||||
&schemas,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
schemas = g_settings_list_children (settings);
|
||||
}
|
||||
|
||||
if (schemas == NULL || schemas[0] == NULL)
|
||||
{
|
||||
g_free (schemas);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qsort (schemas, g_strv_length (schemas), sizeof (char *), strvcmp);
|
||||
|
||||
result = g_list_store_new (G_TYPE_SETTINGS);
|
||||
for (i = 0; schemas[i] != NULL; i++)
|
||||
{
|
||||
GSettings *child;
|
||||
|
||||
if (settings == NULL)
|
||||
child = g_settings_new (schemas[i]);
|
||||
else
|
||||
child = g_settings_get_child (settings, schemas[i]);
|
||||
|
||||
g_list_store_append (result, child);
|
||||
g_object_unref (child);
|
||||
}
|
||||
|
||||
g_strfreev (schemas);
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
}
|
||||
|
||||
static void
|
||||
search_enabled (GtkSearchEntry *entry)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
||||
}
|
||||
|
||||
static void
|
||||
search_changed (GtkSearchEntry *entry,
|
||||
gpointer data)
|
||||
{
|
||||
const char *text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
|
||||
if (current_filter)
|
||||
gtk_string_filter_set_search (GTK_STRING_FILTER (current_filter), text);
|
||||
}
|
||||
|
||||
static void
|
||||
stop_search (GtkSearchEntry *entry,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
||||
|
||||
if (current_filter)
|
||||
gtk_string_filter_set_search (GTK_STRING_FILTER (current_filter), "");
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
do_listview_settings (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkWidget *listview, *columnview;
|
||||
GListModel *model;
|
||||
GtkTreeListModel *treemodel;
|
||||
GtkSingleSelection *selection;
|
||||
GtkBuilderScope *scope;
|
||||
GtkBuilder *builder;
|
||||
GtkColumnViewColumn *name_column;
|
||||
GtkColumnViewColumn *type_column;
|
||||
GtkColumnViewColumn *default_column;
|
||||
GtkColumnViewColumn *summary_column;
|
||||
GtkColumnViewColumn *description_column;
|
||||
GtkSorter *sorter;
|
||||
GActionGroup *actions;
|
||||
GAction *action;
|
||||
|
||||
g_type_ensure (SETTINGS_TYPE_KEY);
|
||||
|
||||
scope = gtk_builder_cscope_new ();
|
||||
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "search_enabled", (GCallback)search_enabled);
|
||||
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "search_changed", (GCallback)search_changed);
|
||||
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "stop_search", (GCallback)stop_search);
|
||||
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "item_value_changed", (GCallback)item_value_changed);
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
gtk_builder_add_from_resource (builder, "/listview_settings/listview_settings.ui", NULL);
|
||||
|
||||
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);
|
||||
|
||||
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
|
||||
columnview = GTK_WIDGET (gtk_builder_get_object (builder, "columnview"));
|
||||
type_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "type_column"));
|
||||
default_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "default_column"));
|
||||
summary_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "summary_column"));
|
||||
description_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "description_column"));
|
||||
|
||||
actions = G_ACTION_GROUP (g_simple_action_group_new ());
|
||||
|
||||
action = G_ACTION (g_property_action_new ("show-type", type_column, "visible"));
|
||||
g_action_map_add_action (G_ACTION_MAP (actions), action);
|
||||
g_object_unref (action);
|
||||
|
||||
action = G_ACTION (g_property_action_new ("show-default", default_column, "visible"));
|
||||
g_action_map_add_action (G_ACTION_MAP (actions), action);
|
||||
g_object_unref (action);
|
||||
|
||||
action = G_ACTION (g_property_action_new ("show-summary", summary_column, "visible"));
|
||||
g_action_map_add_action (G_ACTION_MAP (actions), action);
|
||||
g_object_unref (action);
|
||||
|
||||
action = G_ACTION (g_property_action_new ("show-description", description_column, "visible"));
|
||||
g_action_map_add_action (G_ACTION_MAP (actions), action);
|
||||
g_object_unref (action);
|
||||
|
||||
gtk_widget_insert_action_group (columnview, "columnview", actions);
|
||||
g_object_unref (actions);
|
||||
|
||||
model = create_settings_model (NULL, NULL);
|
||||
treemodel = gtk_tree_list_model_new (FALSE,
|
||||
model,
|
||||
TRUE,
|
||||
create_settings_model,
|
||||
NULL,
|
||||
NULL);
|
||||
selection = gtk_single_selection_new (G_LIST_MODEL (treemodel));
|
||||
g_object_bind_property_full (selection, "selected-item",
|
||||
columnview, "model",
|
||||
G_BINDING_SYNC_CREATE,
|
||||
transform_settings_to_keys,
|
||||
NULL,
|
||||
columnview, NULL);
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
|
||||
g_object_unref (selection);
|
||||
g_object_unref (treemodel);
|
||||
g_object_unref (model);
|
||||
|
||||
name_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "name_column"));
|
||||
sorter = gtk_string_sorter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
|
||||
gtk_column_view_column_set_sorter (name_column, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
279
demos/gtk-demo/listview_settings.ui
Normal file
279
demos/gtk-demo/listview_settings.ui
Normal file
@@ -0,0 +1,279 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="title" translatable="yes">Settings</property>
|
||||
<property name="default-width">640</property>
|
||||
<property name="default-height">480</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="search_button">
|
||||
<property name="icon-name">system-search-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned">
|
||||
<property name="position">300</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkTreeExpander" id="expander">
|
||||
<binding name="list-row">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="schema" type="GSettings">
|
||||
<lookup name="item">expander</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSearchBar">
|
||||
<property name="search-mode-enabled" bind-source="search_button" bind-property="active" bind-flags="bidirectional"/>
|
||||
<signal name="notify::search-mode-enabled" handler="search_enabled" object="entry"/>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="entry">
|
||||
<signal name="search-changed" handler="search_changed"/>
|
||||
<signal name="stop-search" handler="stop_search"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkColumnView" id="columnview">
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="name_column">
|
||||
<property name="title">Name</property>
|
||||
<property name="header-menu">header_menu</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="name" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn">
|
||||
<property name="title">Value</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="header-menu">header_menu</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkEditableLabel">
|
||||
<binding name="text">
|
||||
<lookup name="value" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<signal name="notify::label" handler="item_value_changed"/>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="type_column">
|
||||
<property name="title">Type</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="header-menu">header_menu</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="type" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="default_column">
|
||||
<property name="title">Default</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="expand">1</property>
|
||||
<property name="header-menu">header_menu</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<lookup name="default-value" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="summary_column">
|
||||
<property name="title">Summary</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="visible">0</property>
|
||||
<property name="expand">1</property>
|
||||
<property name="header-menu">header_menu</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<property name="wrap">1</property>
|
||||
<binding name="label">
|
||||
<lookup name="summary" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="description_column">
|
||||
<property name="title">Description</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="visible">0</property>
|
||||
<property name="expand">1</property>
|
||||
<property name="header-menu">header_menu</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<property name="wrap">1</property>
|
||||
<binding name="label">
|
||||
<lookup name="description" type="SettingsKey">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<menu id="header_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Type</attribute>
|
||||
<attribute name="action">columnview.show-type</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Default value</attribute>
|
||||
<attribute name="action">columnview.show-default</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Summary</attribute>
|
||||
<attribute name="action">columnview.show-summary</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Description</attribute>
|
||||
<attribute name="action">columnview.show-description</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
329
demos/gtk-demo/listview_weather.c
Normal file
329
demos/gtk-demo/listview_weather.c
Normal file
@@ -0,0 +1,329 @@
|
||||
/* Lists/Weather
|
||||
*
|
||||
* This demo shows a few of the rarer features of GtkListView and
|
||||
* how they can be used to display weather information.
|
||||
*
|
||||
* The hourly weather info uses a horizontal listview. This is easy
|
||||
* to achieve because GtkListView implements the GtkOrientable interface.
|
||||
* To make the items in the list stand out more, the listview uses
|
||||
* separators.
|
||||
*
|
||||
* A GtkNoSelectionModel is used to make sure no item in the list can be
|
||||
* selected. All other interactions with the items is still possible.
|
||||
*
|
||||
* The dataset used here has 70 000 items.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define GTK_TYPE_WEATHER_INFO (gtk_weather_info_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GtkWeatherInfo, gtk_weather_info, GTK, WEATHER_INFO, GObject)
|
||||
|
||||
typedef enum {
|
||||
GTK_WEATHER_CLEAR,
|
||||
GTK_WEATHER_FEW_CLOUDS,
|
||||
GTK_WEATHER_FOG,
|
||||
GTK_WEATHER_OVERCAST,
|
||||
GTK_WEATHER_SCATTERED_SHOWERS,
|
||||
GTK_WEATHER_SHOWERS,
|
||||
GTK_WEATHER_SNOW,
|
||||
GTK_WEATHER_STORM
|
||||
} GtkWeatherType;
|
||||
|
||||
struct _GtkWeatherInfo
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
gint64 timestamp;
|
||||
int temperature;
|
||||
GtkWeatherType weather_type;
|
||||
};
|
||||
|
||||
struct _GtkWeatherInfoClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkWeatherInfo, gtk_weather_info, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_weather_info_class_init (GtkWeatherInfoClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_weather_info_init (GtkWeatherInfo *self)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkWeatherInfo *
|
||||
gtk_weather_info_new (GDateTime *timestamp,
|
||||
GtkWeatherInfo *copy_from)
|
||||
{
|
||||
GtkWeatherInfo *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_WEATHER_INFO, NULL);
|
||||
|
||||
result->timestamp = g_date_time_to_unix (timestamp);
|
||||
if (copy_from)
|
||||
{
|
||||
result->temperature = copy_from->temperature;
|
||||
result->weather_type = copy_from->weather_type;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GDateTime *
|
||||
parse_timestamp (const char *string,
|
||||
GTimeZone *_tz)
|
||||
{
|
||||
char *with_seconds;
|
||||
GDateTime *result;
|
||||
|
||||
with_seconds = g_strconcat (string, ":00", NULL);
|
||||
result = g_date_time_new_from_iso8601 (with_seconds, _tz);
|
||||
g_free (with_seconds);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GtkWeatherType
|
||||
parse_weather_type (const char *clouds,
|
||||
const char *precip,
|
||||
GtkWeatherType fallback)
|
||||
{
|
||||
if (strstr (precip, "SN"))
|
||||
return GTK_WEATHER_SNOW;
|
||||
|
||||
if (strstr (precip, "TS"))
|
||||
return GTK_WEATHER_STORM;
|
||||
|
||||
if (strstr (precip, "DZ"))
|
||||
return GTK_WEATHER_SCATTERED_SHOWERS;
|
||||
|
||||
if (strstr (precip, "SH") || strstr (precip, "RA"))
|
||||
return GTK_WEATHER_SHOWERS;
|
||||
|
||||
if (strstr (precip, "FG"))
|
||||
return GTK_WEATHER_FOG;
|
||||
|
||||
if (g_str_equal (clouds, "M") ||
|
||||
g_str_equal (clouds, ""))
|
||||
return fallback;
|
||||
|
||||
if (strstr (clouds, "OVC") ||
|
||||
strstr (clouds, "BKN"))
|
||||
return GTK_WEATHER_OVERCAST;
|
||||
|
||||
if (strstr (clouds, "BKN") ||
|
||||
strstr (clouds, "SCT"))
|
||||
return GTK_WEATHER_FEW_CLOUDS;
|
||||
|
||||
if (strstr (clouds, "VV"))
|
||||
return GTK_WEATHER_FOG;
|
||||
|
||||
return GTK_WEATHER_CLEAR;
|
||||
}
|
||||
|
||||
static double
|
||||
parse_temperature (const char *s,
|
||||
double fallback)
|
||||
{
|
||||
char *endptr;
|
||||
double d;
|
||||
|
||||
d = g_ascii_strtod (s, &endptr);
|
||||
if (*endptr != '\0')
|
||||
return fallback;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_weather_model (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GTimeZone *utc;
|
||||
GDateTime *timestamp;
|
||||
GtkWeatherInfo *info;
|
||||
GBytes *data;
|
||||
char **lines;
|
||||
guint i;
|
||||
|
||||
store = g_list_store_new (GTK_TYPE_WEATHER_INFO);
|
||||
data = g_resources_lookup_data ("/listview_weather/listview_weather.txt", 0, NULL);
|
||||
lines = g_strsplit (g_bytes_get_data (data, NULL), "\n", 0);
|
||||
|
||||
utc = g_time_zone_new_utc ();
|
||||
timestamp = g_date_time_new (utc, 2011, 1, 1, 0, 0, 0);
|
||||
info = gtk_weather_info_new (timestamp, NULL);
|
||||
g_list_store_append (store, info);
|
||||
g_object_unref (info);
|
||||
|
||||
for (i = 0; lines[i] != NULL && *lines[i]; i++)
|
||||
{
|
||||
char **fields;
|
||||
GDateTime *date;
|
||||
|
||||
fields = g_strsplit (lines[i], ",", 0);
|
||||
date = parse_timestamp (fields[0], utc);
|
||||
while (g_date_time_difference (date, timestamp) > 30 * G_TIME_SPAN_MINUTE)
|
||||
{
|
||||
GDateTime *new_timestamp = g_date_time_add_hours (timestamp, 1);
|
||||
g_date_time_unref (timestamp);
|
||||
timestamp = new_timestamp;
|
||||
info = gtk_weather_info_new (timestamp, info);
|
||||
g_list_store_append (store, info);
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
info->temperature = parse_temperature (fields[1], info->temperature);
|
||||
info->weather_type = parse_weather_type (fields[2], fields[3], info->weather_type);
|
||||
g_date_time_unref (date);
|
||||
g_strfreev (fields);
|
||||
}
|
||||
|
||||
g_date_time_unref (timestamp);
|
||||
g_strfreev (lines);
|
||||
g_bytes_unref (data);
|
||||
g_time_zone_unref (utc);
|
||||
|
||||
return G_LIST_MODEL (store);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_widget (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *box, *child;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_list_item_set_child (list_item, box);
|
||||
|
||||
child = gtk_label_new (NULL);
|
||||
gtk_label_set_width_chars (GTK_LABEL (child), 5);
|
||||
gtk_box_append (GTK_BOX (box), child);
|
||||
|
||||
child = gtk_image_new ();
|
||||
gtk_image_set_icon_size (GTK_IMAGE (child), GTK_ICON_SIZE_LARGE);
|
||||
gtk_box_append (GTK_BOX (box), child);
|
||||
|
||||
child = gtk_label_new (NULL);
|
||||
gtk_widget_set_vexpand (child, TRUE);
|
||||
gtk_widget_set_valign (child, GTK_ALIGN_END);
|
||||
gtk_label_set_width_chars (GTK_LABEL (child), 4);
|
||||
gtk_box_append (GTK_BOX (box), child);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_widget (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *box, *child;
|
||||
GtkWeatherInfo *info;
|
||||
GDateTime *timestamp;
|
||||
char *s;
|
||||
|
||||
box = gtk_list_item_get_child (list_item);
|
||||
info = gtk_list_item_get_item (list_item);
|
||||
|
||||
child = gtk_widget_get_first_child (box);
|
||||
timestamp = g_date_time_new_from_unix_utc (info->timestamp);
|
||||
s = g_date_time_format (timestamp, "%R");
|
||||
gtk_label_set_text (GTK_LABEL (child), s);
|
||||
g_free (s);
|
||||
g_date_time_unref (timestamp);
|
||||
|
||||
child = gtk_widget_get_next_sibling (child);
|
||||
switch (info->weather_type)
|
||||
{
|
||||
case GTK_WEATHER_CLEAR:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-clear-symbolic");
|
||||
break;
|
||||
case GTK_WEATHER_FEW_CLOUDS:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-few-clouds-symbolic");
|
||||
break;
|
||||
case GTK_WEATHER_FOG:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-fog-symbolic");
|
||||
break;
|
||||
case GTK_WEATHER_OVERCAST:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-overcast-symbolic");
|
||||
break;
|
||||
case GTK_WEATHER_SCATTERED_SHOWERS:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-showers-scattered-symbolic");
|
||||
break;
|
||||
case GTK_WEATHER_SHOWERS:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-showers-symbolic");
|
||||
break;
|
||||
case GTK_WEATHER_SNOW:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-snow-symbolic");
|
||||
break;
|
||||
case GTK_WEATHER_STORM:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-storm-symbolic");
|
||||
break;
|
||||
default:
|
||||
gtk_image_clear (GTK_IMAGE (child));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
child = gtk_widget_get_next_sibling (child);
|
||||
s = g_strdup_printf ("%d°", info->temperature);
|
||||
gtk_label_set_text (GTK_LABEL (child), s);
|
||||
g_free (s);
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
create_weather_view (void)
|
||||
{
|
||||
GtkWidget *listview;
|
||||
GListModel *model, *selection;
|
||||
GtkListItemFactory *factory;
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_widget), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_widget), NULL);
|
||||
listview = gtk_list_view_new_with_factory (factory);
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
|
||||
model = create_weather_model ();
|
||||
selection = G_LIST_MODEL (gtk_no_selection_new (model));
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
|
||||
g_object_unref (selection);
|
||||
g_object_unref (model);
|
||||
|
||||
return listview;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_weather (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkWidget *listview, *sw;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Weather");
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Weather");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
listview = create_weather_view ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
70116
demos/gtk-demo/listview_weather.txt
Normal file
70116
demos/gtk-demo/listview_weather.txt
Normal file
File diff suppressed because it is too large
Load Diff
238
demos/gtk-demo/listview_words.c
Normal file
238
demos/gtk-demo/listview_words.c
Normal file
@@ -0,0 +1,238 @@
|
||||
/* Lists/Words
|
||||
*
|
||||
* This demo shows filtering a long list - of words.
|
||||
*
|
||||
* You should have the file `/usr/share/dict/words` installed for
|
||||
* this demo to work.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *progress;
|
||||
|
||||
const char *factory_text =
|
||||
"<?xml version='1.0' encoding='UTF-8'?>\n"
|
||||
"<interface>\n"
|
||||
" <template class='GtkListItem'>\n"
|
||||
" <property name='child'>\n"
|
||||
" <object class='GtkLabel'>\n"
|
||||
" <property name='ellipsize'>end</property>\n"
|
||||
" <property name='xalign'>0</property>\n"
|
||||
" <binding name='label'>\n"
|
||||
" <lookup name='string' type='GtkStringObject'>\n"
|
||||
" <lookup name='item'>GtkListItem</lookup>\n"
|
||||
" </lookup>\n"
|
||||
" </binding>\n"
|
||||
" </object>\n"
|
||||
" </property>\n"
|
||||
" </template>\n"
|
||||
"</interface>\n";
|
||||
|
||||
static void
|
||||
update_title_cb (GtkFilterListModel *model)
|
||||
{
|
||||
guint total;
|
||||
char *title;
|
||||
guint pending;
|
||||
|
||||
total = g_list_model_get_n_items (gtk_filter_list_model_get_model (model));
|
||||
pending = gtk_filter_list_model_get_pending (model);
|
||||
|
||||
title = g_strdup_printf ("%u lines", g_list_model_get_n_items (G_LIST_MODEL (model)));
|
||||
|
||||
gtk_widget_set_visible (progress, pending != 0);
|
||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), (total - pending) / (double) total);
|
||||
gtk_window_set_title (GTK_WINDOW (window), title);
|
||||
g_free (title);
|
||||
}
|
||||
|
||||
static void
|
||||
read_lines_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GBufferedInputStream *stream = G_BUFFERED_INPUT_STREAM (object);
|
||||
GtkStringList *stringlist = data;
|
||||
GError *error = NULL;
|
||||
gsize size;
|
||||
GPtrArray *lines;
|
||||
gssize n_filled;
|
||||
const char *buffer, *newline;
|
||||
|
||||
n_filled = g_buffered_input_stream_fill_finish (stream, result, &error);
|
||||
if (n_filled < 0)
|
||||
{
|
||||
g_print ("Could not read data: %s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = g_buffered_input_stream_peek_buffer (stream, &size);
|
||||
|
||||
if (n_filled == 0)
|
||||
{
|
||||
if (size)
|
||||
gtk_string_list_take (stringlist, g_utf8_make_valid (buffer, size));
|
||||
return;
|
||||
}
|
||||
|
||||
lines = NULL;
|
||||
while ((newline = memchr (buffer, '\n', size)))
|
||||
{
|
||||
if (newline > buffer)
|
||||
{
|
||||
if (lines == NULL)
|
||||
lines = g_ptr_array_new_with_free_func (g_free);
|
||||
g_ptr_array_add (lines, g_utf8_make_valid (buffer, newline - buffer));
|
||||
}
|
||||
if (g_input_stream_skip (G_INPUT_STREAM (stream), newline - buffer + 1, NULL, &error) < 0)
|
||||
{
|
||||
g_clear_error (&error);
|
||||
break;
|
||||
}
|
||||
buffer = g_buffered_input_stream_peek_buffer (stream, &size);
|
||||
}
|
||||
if (lines == NULL)
|
||||
{
|
||||
g_buffered_input_stream_set_buffer_size (stream, g_buffered_input_stream_get_buffer_size (stream) + 4096);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ptr_array_add (lines, NULL);
|
||||
gtk_string_list_splice (stringlist, g_list_model_get_n_items (G_LIST_MODEL (stringlist)), 0, (const char **) lines->pdata);
|
||||
g_ptr_array_free (lines, TRUE);
|
||||
}
|
||||
|
||||
g_buffered_input_stream_fill_async (stream, -1, G_PRIORITY_HIGH_IDLE, NULL, read_lines_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
file_is_open_cb (GObject *file,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GFileInputStream *file_stream;
|
||||
GBufferedInputStream *stream;
|
||||
|
||||
file_stream = g_file_read_finish (G_FILE (file), result, &error);
|
||||
if (file_stream == NULL)
|
||||
{
|
||||
g_print ("Could not open file: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
stream = G_BUFFERED_INPUT_STREAM (g_buffered_input_stream_new (G_INPUT_STREAM (file_stream)));
|
||||
g_buffered_input_stream_fill_async (stream, -1, G_PRIORITY_HIGH_IDLE, NULL, read_lines_cb, data);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
|
||||
static void
|
||||
load_file (GtkStringList *list,
|
||||
GFile *file)
|
||||
{
|
||||
gtk_string_list_splice (list, 0, g_list_model_get_n_items (G_LIST_MODEL (list)), NULL);
|
||||
g_file_read_async (file, G_PRIORITY_HIGH_IDLE, NULL, file_is_open_cb, list);
|
||||
}
|
||||
|
||||
static void
|
||||
file_selected_cb (GtkWidget *button,
|
||||
GtkStringList *stringlist)
|
||||
{
|
||||
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
|
||||
|
||||
if (file)
|
||||
{
|
||||
load_file (stringlist, file);
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_words (GtkWidget *do_widget)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
GtkWidget *header, *listview, *sw, *vbox, *search_entry, *open_button, *overlay;
|
||||
GtkFilterListModel *filter_model;
|
||||
GtkNoSelection *selection;
|
||||
GtkStringList *stringlist;
|
||||
GtkFilter *filter;
|
||||
GFile *file;
|
||||
|
||||
file = g_file_new_for_path ("/usr/share/dict/words");
|
||||
if (g_file_query_exists (file, NULL))
|
||||
{
|
||||
stringlist = gtk_string_list_new (NULL);
|
||||
load_file (stringlist, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
char **words;
|
||||
words = g_strsplit ("lorem ipsum dolor sit amet consectetur adipisci elit sed eiusmod tempor incidunt labore et dolore magna aliqua ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat", " ", -1);
|
||||
stringlist = gtk_string_list_new ((const char **) words);
|
||||
g_strfreev (words);
|
||||
}
|
||||
|
||||
filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
|
||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (stringlist), filter);
|
||||
gtk_filter_list_model_set_incremental (filter_model, TRUE);
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
open_button = gtk_file_chooser_button_new ("_Open", GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
g_signal_connect (open_button, "file-set", G_CALLBACK (file_selected_cb), stringlist);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), open_button);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer*)&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
search_entry = gtk_search_entry_new ();
|
||||
g_object_bind_property (search_entry, "text", filter, "search", 0);
|
||||
gtk_box_append (GTK_BOX (vbox), search_entry);
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_box_append (GTK_BOX (vbox), overlay);
|
||||
|
||||
progress = gtk_progress_bar_new ();
|
||||
gtk_widget_set_halign (progress, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (progress, GTK_ALIGN_START);
|
||||
gtk_widget_set_hexpand (progress, TRUE);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), progress);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_vexpand (sw, TRUE);
|
||||
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
|
||||
|
||||
listview = gtk_list_view_new_with_factory (
|
||||
gtk_builder_list_item_factory_new_from_bytes (NULL,
|
||||
g_bytes_new_static (factory_text, strlen (factory_text))));
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
||||
selection = gtk_no_selection_new (G_LIST_MODEL (filter_model));
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
|
||||
g_object_unref (selection);
|
||||
|
||||
g_signal_connect (filter_model, "items-changed", G_CALLBACK (update_title_cb), progress);
|
||||
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
|
||||
update_title_cb (filter_model);
|
||||
|
||||
g_object_unref (filter_model);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
22
demos/gtk-demo/main-listitem.ui
Normal file
22
demos/gtk-demo/main-listitem.ui
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkTreeExpander" id="expander">
|
||||
<binding name="list-row">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">start</property>
|
||||
<binding name="label">
|
||||
<lookup name="title" type="GtkDemo">
|
||||
<lookup name="item">expander</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
@@ -13,21 +13,100 @@
|
||||
static GtkWidget *info_view;
|
||||
static GtkWidget *source_view;
|
||||
|
||||
static gchar *current_file = NULL;
|
||||
static char *current_file = NULL;
|
||||
|
||||
static GtkWidget *notebook;
|
||||
static GtkWidget *treeview;
|
||||
static GtkSingleSelection *selection;
|
||||
static GtkWidget *toplevel;
|
||||
static char **search_needle;
|
||||
|
||||
typedef struct _GtkDemo GtkDemo;
|
||||
struct _GtkDemo
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
const char *name;
|
||||
const char *title;
|
||||
const char *filename;
|
||||
GDoDemoFunc func;
|
||||
GListModel *children_model;
|
||||
};
|
||||
|
||||
enum {
|
||||
NAME_COLUMN,
|
||||
TITLE_COLUMN,
|
||||
FILENAME_COLUMN,
|
||||
FUNC_COLUMN,
|
||||
STYLE_COLUMN,
|
||||
NUM_COLUMNS
|
||||
PROP_0,
|
||||
PROP_FILENAME,
|
||||
PROP_NAME,
|
||||
PROP_TITLE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
# define GTK_TYPE_DEMO (gtk_demo_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (GtkDemo, gtk_demo, GTK, DEMO, GObject);
|
||||
|
||||
G_DEFINE_TYPE (GtkDemo, gtk_demo, G_TYPE_OBJECT);
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
gtk_demo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkDemo *self = GTK_DEMO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_FILENAME:
|
||||
g_value_set_string (value, self->filename);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, self->name);
|
||||
break;
|
||||
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, self->title);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gtk_demo_class_init (GtkDemoClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->get_property = gtk_demo_get_property;
|
||||
|
||||
properties[PROP_FILENAME] =
|
||||
g_param_spec_string ("filename",
|
||||
"filename",
|
||||
"filename",
|
||||
NULL,
|
||||
G_PARAM_READABLE);
|
||||
properties[PROP_NAME] =
|
||||
g_param_spec_string ("name",
|
||||
"name",
|
||||
"name",
|
||||
NULL,
|
||||
G_PARAM_READABLE);
|
||||
properties[PROP_TITLE] =
|
||||
g_param_spec_string ("title",
|
||||
"title",
|
||||
"title",
|
||||
NULL,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void gtk_demo_init (GtkDemo *self)
|
||||
{
|
||||
}
|
||||
|
||||
typedef struct _CallbackData CallbackData;
|
||||
struct _CallbackData
|
||||
{
|
||||
@@ -35,13 +114,34 @@ struct _CallbackData
|
||||
GtkTreePath *path;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
gtk_demo_run (GtkDemo *self,
|
||||
GtkWidget *window)
|
||||
{
|
||||
GtkWidget *result;
|
||||
|
||||
if (!self->func)
|
||||
return FALSE;
|
||||
|
||||
result = self->func (window);
|
||||
if (result == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (GTK_IS_WINDOW (result))
|
||||
{
|
||||
gtk_window_set_transient_for (GTK_WINDOW (result), GTK_WINDOW (window));
|
||||
gtk_window_set_modal (GTK_WINDOW (result), TRUE);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
activate_about (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkApplication *app = user_data;
|
||||
const gchar *authors[] = {
|
||||
const char *authors[] = {
|
||||
"The GTK Team",
|
||||
NULL
|
||||
};
|
||||
@@ -115,82 +215,15 @@ activate_inspector (GSimpleAction *action,
|
||||
gtk_window_set_interactive_debugging (TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
window_closed_cb (GtkWidget *window, gpointer data)
|
||||
{
|
||||
CallbackData *cbdata = data;
|
||||
GtkTreeIter iter;
|
||||
PangoStyle style;
|
||||
|
||||
gtk_tree_model_get_iter (cbdata->model, &iter, cbdata->path);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (cbdata->model), &iter,
|
||||
STYLE_COLUMN, &style,
|
||||
-1);
|
||||
if (style == PANGO_STYLE_ITALIC)
|
||||
gtk_tree_store_set (GTK_TREE_STORE (cbdata->model), &iter,
|
||||
STYLE_COLUMN, PANGO_STYLE_NORMAL,
|
||||
-1);
|
||||
|
||||
gtk_tree_path_free (cbdata->path);
|
||||
g_free (cbdata);
|
||||
}
|
||||
|
||||
static void
|
||||
run_example_for_row (GtkWidget *window,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
PangoStyle style;
|
||||
GDoDemoFunc func;
|
||||
GtkWidget *demo;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (model),
|
||||
iter,
|
||||
FUNC_COLUMN, &func,
|
||||
STYLE_COLUMN, &style,
|
||||
-1);
|
||||
|
||||
if (func)
|
||||
{
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
iter,
|
||||
STYLE_COLUMN, (style == PANGO_STYLE_ITALIC ? PANGO_STYLE_NORMAL : PANGO_STYLE_ITALIC),
|
||||
-1);
|
||||
demo = (func) (window);
|
||||
|
||||
if (demo != NULL)
|
||||
{
|
||||
CallbackData *cbdata;
|
||||
|
||||
cbdata = g_new (CallbackData, 1);
|
||||
cbdata->model = model;
|
||||
cbdata->path = gtk_tree_model_get_path (model, iter);
|
||||
|
||||
if (GTK_IS_WINDOW (demo))
|
||||
{
|
||||
gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
|
||||
gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
|
||||
}
|
||||
|
||||
g_signal_connect (demo, "destroy",
|
||||
G_CALLBACK (window_closed_cb), cbdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activate_run (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
gpointer window)
|
||||
{
|
||||
GtkWidget *window = user_data;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeListRow *row = gtk_single_selection_get_selected_item (selection);
|
||||
GtkDemo *demo = gtk_tree_list_row_get_item (row);
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
run_example_for_row (window, model, &iter);
|
||||
gtk_demo_run (demo, window);
|
||||
}
|
||||
|
||||
/* Stupid syntax highlighting.
|
||||
@@ -219,11 +252,9 @@ static const char *types[] =
|
||||
"static",
|
||||
"const ",
|
||||
"void",
|
||||
"gint",
|
||||
" int ",
|
||||
" char ",
|
||||
"gchar ",
|
||||
"gfloat",
|
||||
"char ",
|
||||
"float",
|
||||
"double",
|
||||
"gint8",
|
||||
@@ -239,8 +270,6 @@ static const char *types[] =
|
||||
"gshort",
|
||||
"gushort",
|
||||
"gulong",
|
||||
"gdouble",
|
||||
"gldouble",
|
||||
"gpointer",
|
||||
"NULL",
|
||||
"GList",
|
||||
@@ -352,14 +381,14 @@ static const char *control[] =
|
||||
NULL
|
||||
};
|
||||
void
|
||||
parse_chars (gchar *text,
|
||||
gchar **end_ptr,
|
||||
gint *state,
|
||||
parse_chars (char *text,
|
||||
char **end_ptr,
|
||||
int *state,
|
||||
const char **tag,
|
||||
gboolean start)
|
||||
{
|
||||
gint i;
|
||||
gchar *next_token;
|
||||
int i;
|
||||
char *next_token;
|
||||
|
||||
/* Handle comments first */
|
||||
if (*state == STATE_IN_COMMENT)
|
||||
@@ -429,7 +458,7 @@ parse_chars (gchar *text,
|
||||
/* check for string */
|
||||
if (text[0] == '"')
|
||||
{
|
||||
gint maybe_escape = FALSE;
|
||||
int maybe_escape = FALSE;
|
||||
|
||||
*end_ptr = text + 1;
|
||||
*tag = "string";
|
||||
@@ -492,9 +521,9 @@ void
|
||||
fontify (GtkTextBuffer *source_buffer)
|
||||
{
|
||||
GtkTextIter start_iter, next_iter, tmp_iter;
|
||||
gint state;
|
||||
gchar *text;
|
||||
gchar *start_ptr, *end_ptr;
|
||||
int state;
|
||||
char *text;
|
||||
char *start_ptr, *end_ptr;
|
||||
const char *tag;
|
||||
|
||||
gtk_text_buffer_create_tag (source_buffer, "source",
|
||||
@@ -567,10 +596,10 @@ display_image (const char *resource)
|
||||
{
|
||||
GtkWidget *sw, *image;
|
||||
|
||||
image = gtk_image_new_from_resource (resource);
|
||||
image = gtk_picture_new_for_resource (resource);
|
||||
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), image);
|
||||
|
||||
return sw;
|
||||
@@ -610,7 +639,7 @@ display_text (const char *resource)
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
@@ -662,10 +691,10 @@ static struct {
|
||||
};
|
||||
|
||||
static void
|
||||
add_data_tab (const gchar *demoname)
|
||||
add_data_tab (const char *demoname)
|
||||
{
|
||||
gchar *resource_dir, *resource_name;
|
||||
gchar **resources;
|
||||
char *resource_dir, *resource_name;
|
||||
char **resources;
|
||||
GtkWidget *widget, *label;
|
||||
guint i, j;
|
||||
|
||||
@@ -709,15 +738,15 @@ add_data_tab (const gchar *demoname)
|
||||
static void
|
||||
remove_data_tabs (void)
|
||||
{
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
for (i = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) - 1; i > 1; i--)
|
||||
gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), i);
|
||||
}
|
||||
|
||||
void
|
||||
load_file (const gchar *demoname,
|
||||
const gchar *filename)
|
||||
load_file (const char *demoname,
|
||||
const char *filename)
|
||||
{
|
||||
GtkTextBuffer *info_buffer, *source_buffer;
|
||||
GtkTextIter start, end;
|
||||
@@ -725,9 +754,9 @@ load_file (const gchar *demoname,
|
||||
GError *err = NULL;
|
||||
int state = 0;
|
||||
gboolean in_para = 0;
|
||||
gchar **lines;
|
||||
char **lines;
|
||||
GBytes *bytes;
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
if (!g_strcmp0 (current_file, filename))
|
||||
return;
|
||||
@@ -767,9 +796,9 @@ load_file (const gchar *demoname,
|
||||
gtk_text_buffer_get_iter_at_offset (info_buffer, &start, 0);
|
||||
for (i = 0; lines[i] != NULL; i++)
|
||||
{
|
||||
gchar *p;
|
||||
gchar *q;
|
||||
gchar *r;
|
||||
char *p;
|
||||
char *q;
|
||||
char *r;
|
||||
|
||||
/* Make sure \r is stripped at the end for the poor windows people */
|
||||
lines[i] = g_strchomp (lines[i]);
|
||||
@@ -895,107 +924,194 @@ load_file (const gchar *demoname,
|
||||
}
|
||||
|
||||
static void
|
||||
selection_cb (GtkTreeSelection *selection,
|
||||
GtkTreeModel *model)
|
||||
activate_cb (GtkWidget *widget,
|
||||
guint position,
|
||||
gpointer window)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
char *name;
|
||||
char *filename;
|
||||
char *title;
|
||||
GtkTreeListRow *row = g_list_model_get_item (gtk_list_view_get_model (GTK_LIST_VIEW (widget)), position);
|
||||
GtkDemo *demo = gtk_tree_list_row_get_item (row);
|
||||
|
||||
if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
return;
|
||||
gtk_demo_run (demo, window);
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
NAME_COLUMN, &name,
|
||||
TITLE_COLUMN, &title,
|
||||
FILENAME_COLUMN, &filename,
|
||||
-1);
|
||||
|
||||
if (filename)
|
||||
load_file (name, filename);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (toplevel), title);
|
||||
|
||||
g_free (name);
|
||||
g_free (title);
|
||||
g_free (filename);
|
||||
g_object_unref (row);
|
||||
}
|
||||
|
||||
static void
|
||||
populate_model (GtkTreeModel *model)
|
||||
selection_cb (GtkSingleSelection *sel,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
Demo *d = gtk_demos;
|
||||
GtkTreeListRow *row = gtk_single_selection_get_selected_item (sel);
|
||||
GtkDemo *demo;
|
||||
|
||||
/* this code only supports 1 level of children. If we
|
||||
* want more we probably have to use a recursing function.
|
||||
*/
|
||||
while (d->title)
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (notebook), !!row);
|
||||
|
||||
if (!row)
|
||||
{
|
||||
Demo *children = d->children;
|
||||
GtkTreeIter iter;
|
||||
gtk_window_set_title (GTK_WINDOW (toplevel), "No match");
|
||||
|
||||
gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&iter,
|
||||
NAME_COLUMN, d->name,
|
||||
TITLE_COLUMN, d->title,
|
||||
FILENAME_COLUMN, d->filename,
|
||||
FUNC_COLUMN, d->func,
|
||||
STYLE_COLUMN, PANGO_STYLE_NORMAL,
|
||||
-1);
|
||||
demo = gtk_tree_list_row_get_item (row);
|
||||
|
||||
d++;
|
||||
if (demo->filename)
|
||||
load_file (demo->name, demo->filename);
|
||||
|
||||
if (!children)
|
||||
gtk_window_set_title (GTK_WINDOW (toplevel), demo->title);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
filter_demo (GtkDemo *demo)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Show only if the name maches every needle */
|
||||
for (i = 0; search_needle[i]; i++)
|
||||
{
|
||||
if (!demo->title)
|
||||
return FALSE;
|
||||
|
||||
if (g_str_match_string (search_needle[i], demo->title, TRUE))
|
||||
continue;
|
||||
|
||||
while (children->title)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
demo_filter_by_name (GtkTreeListRow *row,
|
||||
GtkFilterListModel *model)
|
||||
{
|
||||
GListModel *children;
|
||||
GtkDemo *demo;
|
||||
guint i, n;
|
||||
|
||||
/* Show all items if search is empty */
|
||||
if (!search_needle || !search_needle[0] || !*search_needle[0])
|
||||
return TRUE;
|
||||
|
||||
g_assert (GTK_IS_TREE_LIST_ROW (row));
|
||||
g_assert (GTK_IS_FILTER_LIST_MODEL (model));
|
||||
|
||||
children = gtk_tree_list_row_get_children (row);
|
||||
if (children)
|
||||
{
|
||||
n = g_list_model_get_n_items (children);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
GtkTreeIter child_iter;
|
||||
demo = g_list_model_get_item (children, i);
|
||||
g_assert (GTK_IS_DEMO (demo));
|
||||
|
||||
gtk_tree_store_append (GTK_TREE_STORE (model), &child_iter, &iter);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model),
|
||||
&child_iter,
|
||||
NAME_COLUMN, children->name,
|
||||
TITLE_COLUMN, children->title,
|
||||
FILENAME_COLUMN, children->filename,
|
||||
FUNC_COLUMN, children->func,
|
||||
STYLE_COLUMN, PANGO_STYLE_NORMAL,
|
||||
-1);
|
||||
|
||||
children++;
|
||||
if (filter_demo (demo))
|
||||
{
|
||||
g_object_unref (demo);
|
||||
return TRUE;
|
||||
}
|
||||
g_object_unref (demo);
|
||||
}
|
||||
}
|
||||
|
||||
demo = gtk_tree_list_row_get_item (row);
|
||||
g_assert (GTK_IS_DEMO (demo));
|
||||
|
||||
return filter_demo (demo);
|
||||
}
|
||||
|
||||
static void
|
||||
row_activated_cb (GtkWidget *tree_view,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column)
|
||||
demo_search_changed_cb (GtkSearchEntry *entry,
|
||||
GtkFilter *filter)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *window;
|
||||
GtkTreeModel *model;
|
||||
const char *text;
|
||||
|
||||
window = GTK_WIDGET (gtk_widget_get_root (tree_view));
|
||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
g_assert (GTK_IS_SEARCH_ENTRY (entry));
|
||||
g_assert (GTK_IS_FILTER (filter));
|
||||
|
||||
run_example_for_row (window, model, &iter);
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
|
||||
g_clear_pointer (&search_needle, g_strfreev);
|
||||
|
||||
if (text && *text)
|
||||
search_needle = g_strsplit (text, " ", 0);
|
||||
|
||||
gtk_filter_changed (filter, GTK_FILTER_CHANGE_DIFFERENT);
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_demo_model (void)
|
||||
{
|
||||
GListStore *store = g_list_store_new (GTK_TYPE_DEMO);
|
||||
DemoData *demo = gtk_demos;
|
||||
|
||||
while (demo->title)
|
||||
{
|
||||
GtkDemo *d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
|
||||
DemoData *children = demo->children;
|
||||
|
||||
d->name = demo->name;
|
||||
d->title = demo->title;
|
||||
d->filename = demo->filename;
|
||||
d->func = demo->func;
|
||||
|
||||
g_list_store_append (store, d);
|
||||
|
||||
if (children)
|
||||
{
|
||||
d->children_model = G_LIST_MODEL (g_list_store_new (GTK_TYPE_DEMO));
|
||||
|
||||
while (children->title)
|
||||
{
|
||||
GtkDemo *child = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
|
||||
|
||||
child->name = children->name;
|
||||
child->title = children->title;
|
||||
child->filename = children->filename;
|
||||
child->func = children->func;
|
||||
|
||||
g_list_store_append (G_LIST_STORE (d->children_model), child);
|
||||
children++;
|
||||
}
|
||||
}
|
||||
|
||||
demo++;
|
||||
}
|
||||
|
||||
return G_LIST_MODEL (store);
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
get_child_model (gpointer item,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkDemo *demo = item;
|
||||
|
||||
if (demo->children_model)
|
||||
return g_object_ref (G_LIST_MODEL (demo->children_model));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_search (GtkSearchBar *bar)
|
||||
{
|
||||
if (!gtk_search_bar_get_search_mode (bar))
|
||||
{
|
||||
GtkWidget *entry = gtk_search_bar_get_child (GTK_SEARCH_BAR (bar));
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activate (GApplication *app)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkWindow *window;
|
||||
GtkWidget *widget;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GListModel *listmodel;
|
||||
GtkTreeListModel *treemodel;
|
||||
GtkWidget *window, *listview, *search_entry, *search_bar;
|
||||
GtkFilterListModel *filter_model;
|
||||
GtkFilter *filter;
|
||||
|
||||
static GActionEntry win_entries[] = {
|
||||
{ "run", activate_run, NULL, NULL, NULL }
|
||||
@@ -1003,35 +1119,40 @@ activate (GApplication *app)
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/ui/main.ui");
|
||||
|
||||
window = (GtkWindow *)gtk_builder_get_object (builder, "window");
|
||||
gtk_application_add_window (GTK_APPLICATION (app), window);
|
||||
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
||||
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (window),
|
||||
win_entries, G_N_ELEMENTS (win_entries),
|
||||
window);
|
||||
|
||||
notebook = (GtkWidget *)gtk_builder_get_object (builder, "notebook");
|
||||
notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
|
||||
|
||||
info_view = (GtkWidget *)gtk_builder_get_object (builder, "info-textview");
|
||||
source_view = (GtkWidget *)gtk_builder_get_object (builder, "source-textview");
|
||||
treeview = (GtkWidget *)gtk_builder_get_object (builder, "treeview");
|
||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
|
||||
info_view = GTK_WIDGET (gtk_builder_get_object (builder, "info-textview"));
|
||||
source_view = GTK_WIDGET (gtk_builder_get_object (builder, "source-textview"));
|
||||
toplevel = GTK_WIDGET (window);
|
||||
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
|
||||
g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window);
|
||||
search_bar = GTK_WIDGET (gtk_builder_get_object (builder, "searchbar"));
|
||||
g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL);
|
||||
|
||||
load_file (gtk_demos[0].name, gtk_demos[0].filename);
|
||||
listmodel = create_demo_model ();
|
||||
treemodel = gtk_tree_list_model_new (FALSE,
|
||||
G_LIST_MODEL (listmodel),
|
||||
TRUE,
|
||||
get_child_model,
|
||||
NULL,
|
||||
NULL);
|
||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
|
||||
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
|
||||
gtk_filter_list_model_set_filter (filter_model, filter);
|
||||
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
|
||||
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
|
||||
|
||||
populate_model (model);
|
||||
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
|
||||
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
|
||||
|
||||
g_signal_connect (treeview, "row-activated", G_CALLBACK (row_activated_cb), model);
|
||||
|
||||
widget = (GtkWidget *)gtk_builder_get_object (builder, "treeview-selection");
|
||||
g_signal_connect (widget, "changed", G_CALLBACK (selection_cb), model);
|
||||
|
||||
gtk_tree_model_get_iter_first (gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)), &iter);
|
||||
gtk_tree_selection_select_iter (GTK_TREE_SELECTION (widget), &iter);
|
||||
|
||||
gtk_tree_view_collapse_all (GTK_TREE_VIEW (treeview));
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
selection_cb (selection, NULL, NULL);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
@@ -1046,7 +1167,7 @@ auto_quit (gpointer data)
|
||||
static void
|
||||
list_demos (void)
|
||||
{
|
||||
Demo *d, *c;
|
||||
DemoData *d, *c;
|
||||
|
||||
d = gtk_demos;
|
||||
|
||||
@@ -1065,15 +1186,15 @@ list_demos (void)
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static int
|
||||
command_line (GApplication *app,
|
||||
GApplicationCommandLine *cmdline)
|
||||
{
|
||||
GVariantDict *options;
|
||||
const gchar *name = NULL;
|
||||
const char *name = NULL;
|
||||
gboolean autoquit = FALSE;
|
||||
gboolean list = FALSE;
|
||||
Demo *d, *c;
|
||||
DemoData *d, *c;
|
||||
GDoDemoFunc func = 0;
|
||||
GtkWidget *window, *demo;
|
||||
|
||||
@@ -1091,11 +1212,11 @@ command_line (GApplication *app,
|
||||
return 0;
|
||||
}
|
||||
|
||||
window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
|
||||
|
||||
if (name == NULL)
|
||||
goto out;
|
||||
|
||||
window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
|
||||
|
||||
d = gtk_demos;
|
||||
|
||||
while (d->title)
|
||||
@@ -1124,8 +1245,11 @@ out:
|
||||
demo = (func) (window);
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
|
||||
gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
|
||||
}
|
||||
else
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
if (autoquit)
|
||||
g_timeout_add_seconds (1, auto_quit, app);
|
||||
@@ -1136,7 +1260,7 @@ out:
|
||||
static void
|
||||
print_version (void)
|
||||
{
|
||||
g_print ("gtk3-demo %d.%d.%d\n",
|
||||
g_print ("gtk4-demo %d.%d.%d\n",
|
||||
gtk_get_major_version (),
|
||||
gtk_get_minor_version (),
|
||||
gtk_get_micro_version ());
|
||||
@@ -1170,24 +1294,14 @@ main (int argc, char **argv)
|
||||
{ "inspector", activate_inspector, NULL, NULL, NULL },
|
||||
};
|
||||
struct {
|
||||
const gchar *action_and_target;
|
||||
const gchar *accelerators[2];
|
||||
const char *action_and_target;
|
||||
const char *accelerators[2];
|
||||
} accels[] = {
|
||||
{ "app.about", { "F1", NULL } },
|
||||
{ "app.quit", { "<Control>q", NULL } },
|
||||
};
|
||||
int i;
|
||||
|
||||
/* Most code in gtk-demo is intended to be exemplary, but not
|
||||
* these few lines, which are just a hack so gtk-demo will work
|
||||
* in the GTK tree without installing it.
|
||||
*/
|
||||
if (g_file_test ("../../modules/input/immodules.cache", G_FILE_TEST_EXISTS))
|
||||
{
|
||||
g_setenv ("GTK_IM_MODULE_FILE", "../../modules/input/immodules.cache", TRUE);
|
||||
}
|
||||
/* -- End of hack -- */
|
||||
|
||||
app = gtk_application_new ("org.gtk.Demo4", G_APPLICATION_NON_UNIQUE|G_APPLICATION_HANDLES_COMMAND_LINE);
|
||||
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (app),
|
||||
|
@@ -16,15 +16,6 @@
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<object class="GtkTreeStore" id="treestore">
|
||||
<columns>
|
||||
<column type="gchararray"/>
|
||||
<column type="gchararray"/>
|
||||
<column type="gchararray"/>
|
||||
<column type="gpointer"/>
|
||||
<column type="gint"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<style>
|
||||
<class name="devel"/>
|
||||
@@ -33,7 +24,6 @@
|
||||
<property name="default-height">600</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="valign">center</property>
|
||||
@@ -65,30 +55,29 @@
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="min-content-width">150</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="treeview">
|
||||
<property name="model">treestore</property>
|
||||
<property name="headers-visible">0</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection">
|
||||
<property name="mode">browse</property>
|
||||
</object>
|
||||
</child>
|
||||
<object class="GtkBox">
|
||||
<property name="width-request">220</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<object class="GtkSearchBar" id="searchbar">
|
||||
<property name="key-capture-widget">window</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="style">4</attribute>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="text"> </property>
|
||||
</object>
|
||||
<object class="GtkSearchEntry" id="search-entry"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkListView" id="listview">
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="resource">/ui/main-listitem.ui</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@@ -21,7 +21,7 @@ source_toggled (GtkToggleButton *button)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start, end;
|
||||
gchar *markup;
|
||||
char *markup;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view2));
|
||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
||||
@@ -50,7 +50,7 @@ do_markup (GtkWidget *do_widget)
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter;
|
||||
GBytes *bytes;
|
||||
const gchar *markup;
|
||||
const char *markup;
|
||||
GtkWidget *header;
|
||||
GtkWidget *show_source;
|
||||
|
||||
@@ -69,7 +69,6 @@ do_markup (GtkWidget *do_widget)
|
||||
g_signal_connect (show_source, "toggled", G_CALLBACK (source_toggled), stack);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), show_source);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
@@ -81,7 +80,7 @@ do_markup (GtkWidget *do_widget)
|
||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 10);
|
||||
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 10);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
@@ -94,7 +93,7 @@ do_markup (GtkWidget *do_widget)
|
||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view2), 10);
|
||||
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view2), 10);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
@@ -103,7 +102,7 @@ do_markup (GtkWidget *do_widget)
|
||||
gtk_stack_add_named (GTK_STACK (stack), sw, "source");
|
||||
|
||||
bytes = g_resources_lookup_data ("/markup/markup.txt", 0, NULL);
|
||||
markup = (const gchar *)g_bytes_get_data (bytes, NULL);
|
||||
markup = (const char *)g_bytes_get_data (bytes, NULL);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
|
@@ -5,7 +5,7 @@ Text <span color="gray">c<span color="green">o</span>l<span color="tomato">o</sp
|
||||
|
||||
Colorful <span underline="low" underline-color="blue"><span underline="double" underline-color="red">under</span>lines</span> and <span background="pink"><span underline="error">mo</span><span underline="error" underline-color="green">re</span></span>
|
||||
|
||||
Colorful <span strikethrough="true" strikethrough-color="magenta">strikethroughs</span>
|
||||
Colorful <span strikethrough="true" strikethrough-color="magenta">strikethroughs</span> and <span overline="single" overline_color="green">overlines</span>
|
||||
|
||||
Superscripts and subscripts: 𝜀<span rise="-6000" size="x-small" font_desc="italic">0</span> = 𝜔<span rise="8000" size="smaller">𝜔<span rise="14000" size="smaller">𝜔<span rise="20000">.<span rise="23000">.<span rise="26000">.</span></span></span></span></span>
|
||||
|
||||
|
@@ -18,6 +18,7 @@ demos = files([
|
||||
'cursors.c',
|
||||
'dialog.c',
|
||||
'drawingarea.c',
|
||||
'dropdown.c',
|
||||
'dnd.c',
|
||||
'editable_cells.c',
|
||||
'entry_completion.c',
|
||||
@@ -41,6 +42,14 @@ demos = files([
|
||||
'listbox.c',
|
||||
'flowbox.c',
|
||||
'list_store.c',
|
||||
'listview_applauncher.c',
|
||||
'listview_clocks.c',
|
||||
'listview_colors.c',
|
||||
'listview_filebrowser.c',
|
||||
'listview_minesweeper.c',
|
||||
'listview_settings.c',
|
||||
'listview_weather.c',
|
||||
'listview_words.c',
|
||||
'markup.c',
|
||||
'modelbutton.c',
|
||||
'overlay.c',
|
||||
@@ -95,7 +104,7 @@ extra_demo_sources = files(['main.c',
|
||||
if harfbuzz_dep.found() and pangoft_dep.found()
|
||||
demos += files('font_features.c')
|
||||
extra_demo_sources += files(['script-names.c', 'language-names.c'])
|
||||
gtkdemo_deps += [ harfbuzz_dep, ]
|
||||
gtkdemo_deps += [ harfbuzz_dep, epoxy_dep ]
|
||||
endif
|
||||
|
||||
if os_unix
|
||||
|
@@ -259,7 +259,7 @@
|
||||
259|GTK+ and friends|GTKtoolkit|#java bindings version 4.0.16 released: http://article.gmane.org/gmane.comp.gnome.bindings.java/1796 #gtk|1276885917|0||0|0
|
||||
260|GTK+ and friends|GTKtoolkit|RT @cwiiis: MxIconTheme and MxIcon respect system's icon theme (and changes) now in #mx master :) Made possible by @thosw's XSettings work|1276883019|0||0|0
|
||||
261|GTK+ and friends|GTKtoolkit|#javascript mailing list just created. Discuss its usage in GObject libraries: GTK+, Glib ... http://ur1.ca/08lwz by @jwendell #gtk|1276842639|0||0|0
|
||||
262|GTK+ and friends|GTKtoolkit|Note fot Win32 users: XP theming is back in 2.90.3 . Please test. #gtk|1276829697|0||0|0
|
||||
262|GTK+ and friends|GTKtoolkit|Note for Win32 users: XP theming is back in 2.90.3 . Please test. #gtk|1276829697|0||0|0
|
||||
263|GTK+ and friends|GTKtoolkit|GTK+ 2.90.3 (unstable) released: http://mail.gnome.org/archives/gtk-devel-list/2010-June/msg00137.html #gtk|1276829633|0||0|0
|
||||
264|GTK+ and friends|GTKtoolkit|GLib 2.25.9 (unstable) released: http://ur1.ca/08hrl WARNING: API changes in GDBus, GSettings and GApplication #gtk|1276829581|0||0|0
|
||||
265|scaroo|scaroo|RT @scaroo: #SeedKit does RGBA window with css shadows and stuff : http://dl.dropbox.com/u/5746554/seedkit-does-rgba.png|1276734086|0|GTKtoolkit|0|1
|
||||
|
@@ -4,9 +4,7 @@
|
||||
<property name="title" translatable="yes">Model Button</property>
|
||||
<property name="resizable">0</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
</object>
|
||||
<object class="GtkHeaderBar"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
|
@@ -12,9 +12,9 @@ static void
|
||||
margin_changed (GtkAdjustment *adjustment,
|
||||
GtkTextView *text)
|
||||
{
|
||||
gint value;
|
||||
int value;
|
||||
|
||||
value = (gint)gtk_adjustment_get_value (adjustment);
|
||||
value = (int)gtk_adjustment_get_value (adjustment);
|
||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text), value);
|
||||
g_object_set (tag, "pixels-above-lines", value, NULL);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ do_overlay2 (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Decorative Overlay");
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <gtk/gtkunixprint.h>
|
||||
|
||||
static void
|
||||
done_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
done_cb (GtkDialog *dialog, int response, gpointer data)
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ typedef struct
|
||||
cairo_t *cr;
|
||||
GdkRGBA draw_color;
|
||||
GtkPadController *pad_controller;
|
||||
gdouble brush_size;
|
||||
double brush_size;
|
||||
} DrawingArea;
|
||||
|
||||
typedef struct
|
||||
@@ -38,7 +38,7 @@ static GtkPadActionEntry pad_actions[] = {
|
||||
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Brush size"), "pad.brush_size" },
|
||||
};
|
||||
|
||||
static const gchar *pad_colors[] = {
|
||||
static const char *pad_colors[] = {
|
||||
"black",
|
||||
"pink",
|
||||
"green",
|
||||
@@ -55,8 +55,8 @@ static void drawing_area_set_color (DrawingArea *area,
|
||||
|
||||
static void
|
||||
drawing_area_ensure_surface (DrawingArea *area,
|
||||
gint width,
|
||||
gint height)
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
if (!area->surface ||
|
||||
cairo_image_surface_get_width (area->surface) != width ||
|
||||
@@ -154,7 +154,7 @@ on_pad_button_activate (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
DrawingArea *area)
|
||||
{
|
||||
const gchar *color = g_object_get_data (G_OBJECT (action), "color");
|
||||
const char *color = g_object_get_data (G_OBJECT (action), "color");
|
||||
GdkRGBA rgba;
|
||||
|
||||
gdk_rgba_parse (&rgba, color);
|
||||
@@ -166,7 +166,7 @@ on_pad_knob_change (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
DrawingArea *area)
|
||||
{
|
||||
gdouble value = g_variant_get_double (parameter);
|
||||
double value = g_variant_get_double (parameter);
|
||||
|
||||
area->brush_size = value;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ drawing_area_root (GtkWidget *widget)
|
||||
GSimpleActionGroup *action_group;
|
||||
GSimpleAction *action;
|
||||
GtkWidget *toplevel;
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
GTK_WIDGET_CLASS (drawing_area_parent_class)->root (widget);
|
||||
|
||||
@@ -255,9 +255,9 @@ drawing_area_class_init (DrawingAreaClass *klass)
|
||||
static void
|
||||
drawing_area_apply_stroke (DrawingArea *area,
|
||||
GdkDeviceTool *tool,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble pressure)
|
||||
double x,
|
||||
double y,
|
||||
double pressure)
|
||||
{
|
||||
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
|
||||
{
|
||||
@@ -281,8 +281,8 @@ drawing_area_apply_stroke (DrawingArea *area,
|
||||
|
||||
static void
|
||||
stylus_gesture_down (GtkGestureStylus *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
double x,
|
||||
double y,
|
||||
DrawingArea *area)
|
||||
{
|
||||
cairo_new_path (area->cr);
|
||||
@@ -290,13 +290,13 @@ stylus_gesture_down (GtkGestureStylus *gesture,
|
||||
|
||||
static void
|
||||
stylus_gesture_motion (GtkGestureStylus *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
double x,
|
||||
double y,
|
||||
DrawingArea *area)
|
||||
{
|
||||
GdkTimeCoord *backlog;
|
||||
GdkDeviceTool *tool;
|
||||
gdouble pressure;
|
||||
double pressure;
|
||||
guint n_items;
|
||||
|
||||
tool = gtk_gesture_stylus_get_device_tool (gesture);
|
||||
@@ -392,7 +392,6 @@ do_paint (GtkWidget *toplevel)
|
||||
gtk_window_set_child (GTK_WINDOW (window), draw_area);
|
||||
|
||||
headerbar = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (headerbar), TRUE);
|
||||
|
||||
colorbutton = gtk_color_button_new ();
|
||||
g_signal_connect (colorbutton, "color-set",
|
||||
|
@@ -47,9 +47,9 @@ toggle_shrink (GtkWidget *widget,
|
||||
|
||||
static GtkWidget *
|
||||
create_pane_options (GtkPaned *paned,
|
||||
const gchar *frame_label,
|
||||
const gchar *label1,
|
||||
const gchar *label2)
|
||||
const char *frame_label,
|
||||
const char *label1,
|
||||
const char *label2)
|
||||
{
|
||||
GtkWidget *child1, *child2;
|
||||
GtkWidget *frame;
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
static GtkWidget *entry;
|
||||
static GtkWidget *entry2;
|
||||
static GtkWidget *button;
|
||||
@@ -27,6 +28,13 @@ update_button (GObject *object,
|
||||
text[0] != '\0' && g_str_equal (text, text2));
|
||||
}
|
||||
|
||||
static void
|
||||
button_pressed (GtkButton *widget,
|
||||
GtkWidget *window)
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_password_entry (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -74,7 +82,7 @@ do_password_entry (GtkWidget *do_widget)
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Done");
|
||||
gtk_widget_add_css_class (button, "suggested-action");
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (button_pressed), window);
|
||||
gtk_widget_set_sensitive (button, FALSE);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
|
@@ -276,7 +276,6 @@ do_peg_solitaire (GtkWidget *do_widget)
|
||||
g_signal_connect (restart, "clicked", G_CALLBACK (restart), NULL);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
|
@@ -39,7 +39,7 @@ static GdkPixbuf *frame;
|
||||
|
||||
/* Background image */
|
||||
static GdkPixbuf *background;
|
||||
static gint back_width, back_height;
|
||||
static int back_width, back_height;
|
||||
|
||||
/* Images */
|
||||
static GdkPixbuf *images[N_IMAGES];
|
||||
@@ -51,7 +51,7 @@ static GtkWidget *da;
|
||||
static gboolean
|
||||
load_pixbufs (GError **error)
|
||||
{
|
||||
gint i;
|
||||
int i;
|
||||
|
||||
if (background)
|
||||
return TRUE; /* already loaded earlier */
|
||||
|
@@ -14,13 +14,13 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *resourcename;
|
||||
gdouble font_size;
|
||||
char *resourcename;
|
||||
double font_size;
|
||||
|
||||
gint lines_per_page;
|
||||
gchar **lines;
|
||||
gint num_lines;
|
||||
gint num_pages;
|
||||
int lines_per_page;
|
||||
char **lines;
|
||||
int num_lines;
|
||||
int num_pages;
|
||||
} PrintData;
|
||||
|
||||
static void
|
||||
@@ -55,17 +55,17 @@ begin_print (GtkPrintOperation *operation,
|
||||
static void
|
||||
draw_page (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
gint page_nr,
|
||||
int page_nr,
|
||||
gpointer user_data)
|
||||
{
|
||||
PrintData *data = (PrintData *)user_data;
|
||||
cairo_t *cr;
|
||||
PangoLayout *layout;
|
||||
gint text_width, text_height;
|
||||
gdouble width;
|
||||
gint line, i;
|
||||
int text_width, text_height;
|
||||
double width;
|
||||
int line, i;
|
||||
PangoFontDescription *desc;
|
||||
gchar *page_str;
|
||||
char *page_str;
|
||||
|
||||
cr = gtk_print_context_get_cairo_context (context);
|
||||
width = gtk_print_context_get_width (context);
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static gint count = 0;
|
||||
static int count = 0;
|
||||
static guint timeout = 0;
|
||||
|
||||
static void
|
||||
@@ -25,7 +25,7 @@ static gboolean
|
||||
reveal_one (gpointer data)
|
||||
{
|
||||
GtkWidget *window = data;
|
||||
gchar *name;
|
||||
char *name;
|
||||
GtkRevealer *revealer;
|
||||
|
||||
name = g_strdup_printf ("revealer%d", count);
|
||||
|
@@ -123,7 +123,7 @@ set_search_by (GSimpleAction *action,
|
||||
|
||||
static void
|
||||
icon_press_cb (GtkEntry *entry,
|
||||
gint position,
|
||||
int position,
|
||||
gpointer data)
|
||||
{
|
||||
if (position == GTK_ENTRY_ICON_PRIMARY)
|
||||
|
@@ -8,12 +8,12 @@
|
||||
|
||||
static void
|
||||
show_shortcuts (GtkWidget *window,
|
||||
const gchar *id,
|
||||
const gchar *view)
|
||||
const char *id,
|
||||
const char *view)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *overlay;
|
||||
gchar *path;
|
||||
char *path;
|
||||
|
||||
path = g_strdup_printf ("/shortcuts/%s.ui", id);
|
||||
builder = gtk_builder_new_from_resource (path);
|
||||
|
@@ -18,7 +18,7 @@ do_sidebar (GtkWidget *do_widget)
|
||||
GtkWidget *box;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *header;
|
||||
const gchar* pages[] = {
|
||||
const char * pages[] = {
|
||||
"Welcome to GTK",
|
||||
"GtkStackSidebar Widget",
|
||||
"Automatic navigation",
|
||||
@@ -30,7 +30,7 @@ do_sidebar (GtkWidget *do_widget)
|
||||
"Page 9",
|
||||
NULL
|
||||
};
|
||||
const gchar *c = NULL;
|
||||
const char *c = NULL;
|
||||
guint i;
|
||||
|
||||
if (!window)
|
||||
@@ -40,7 +40,6 @@ do_sidebar (GtkWidget *do_widget)
|
||||
gtk_widget_set_size_request (window, 500, 350);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR(header), TRUE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW(window), header);
|
||||
gtk_window_set_title (GTK_WINDOW(window), "Stack Sidebar");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Sliding puzzle
|
||||
/* Sliding Puzzle
|
||||
*
|
||||
* This demo demonstrates how to use gestures and paintables to create a
|
||||
* small sliding puzzle game.
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "puzzlepiece.h"
|
||||
#include "paintable.h"
|
||||
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *frame = NULL;
|
||||
static GtkWidget *choices = NULL;
|
||||
@@ -240,6 +241,8 @@ puzzle_button_pressed (GtkGestureClick *gesture,
|
||||
{
|
||||
gtk_widget_error_bell (grid);
|
||||
}
|
||||
|
||||
check_solved (grid);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -280,6 +283,8 @@ start_puzzle (GdkPaintable *paintable)
|
||||
/* Add shortcuts so people can use the arrow
|
||||
* keys to move the puzzle */
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller),
|
||||
GTK_SHORTCUT_SCOPE_GLOBAL);
|
||||
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
|
||||
GDK_KEY_Left, GDK_KEY_KP_Left,
|
||||
-1, 0);
|
||||
@@ -340,11 +345,16 @@ reshuffle (void)
|
||||
{
|
||||
GtkWidget *grid;
|
||||
|
||||
grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
|
||||
if (solved)
|
||||
start_puzzle (puzzle);
|
||||
{
|
||||
start_puzzle (puzzle);
|
||||
grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
|
||||
}
|
||||
else
|
||||
shuffle_puzzle (grid);
|
||||
{
|
||||
grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
|
||||
shuffle_puzzle (grid);
|
||||
}
|
||||
gtk_widget_grab_focus (grid);
|
||||
}
|
||||
|
||||
@@ -390,6 +400,15 @@ add_choice (GtkWidget *container,
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (container), icon, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
widget_destroyed (gpointer data,
|
||||
GObject *widget)
|
||||
{
|
||||
if (data)
|
||||
*(gpointer *) data = NULL;
|
||||
}
|
||||
|
||||
|
||||
GtkWidget *
|
||||
do_sliding_puzzle (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -424,7 +443,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
|
||||
gtk_media_stream_set_muted (media, TRUE);
|
||||
gtk_media_stream_play (media);
|
||||
add_choice (choices, GDK_PAINTABLE (media));
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), choices);
|
||||
gtk_grid_attach (GTK_GRID (tweaks), sw, 0, 0, 2, 1);
|
||||
|
||||
@@ -451,7 +470,6 @@ do_sliding_puzzle (GtkWidget *do_widget)
|
||||
g_signal_connect (restart, "clicked", G_CALLBACK (reshuffle), NULL);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), tweak);
|
||||
window = gtk_window_new ();
|
||||
@@ -460,7 +478,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Sliding Puzzle");
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
g_object_weak_ref (G_OBJECT (window), widget_destroyed, &window);
|
||||
|
||||
frame = gtk_aspect_frame_new (0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
|
||||
gtk_window_set_child (GTK_WINDOW (window), frame);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user