File: ch26s02.html

package info (click to toggle)
gtk%2B3.0 3.22.11-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 182,828 kB
  • ctags: 82,378
  • sloc: ansic: 1,165,043; xml: 9,259; makefile: 6,914; sh: 5,179; python: 402; perl: 370; cpp: 34; sed: 16
file content (1417 lines) | stat: -rw-r--r-- 72,979 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Changes that need to be done at the time of the switch: GTK+ 3 Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GTK+ 3 Reference Manual">
<link rel="up" href="gtk-migrating-2-to-3.html" title="Migrating from GTK+ 2.x to GTK+ 3">
<link rel="prev" href="gtk-migrating-2-to-3.html" title="Migrating from GTK+ 2.x to GTK+ 3">
<link rel="next" href="gtk-migrating-GtkStyleContext.html" title="Theming changes">
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="gtk-migrating-2-to-3.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="gtk-migrating-2-to-3.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="gtk-migrating-GtkStyleContext.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id-1.6.3.4"></a>Changes that need to be done at the time of the switch</h2></div></div></div>
<p>
    This section outlines porting tasks that you need to tackle when
    you get to the point that you actually build your application against
    GTK+ 3. Making it possible to prepare for these in GTK+ 2.24 would
    have been either impossible or impractical.
  </p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.3"></a>Replace size_request by get_preferred_width/height</h3></div></div></div>
<p>
      The request-phase of the traditional GTK+ geometry management
      has been replaced by a more flexible height-for-width system,
      which is described in detail in the API documentation
      (see <a class="xref" href="GtkWidget.html#geometry-management" title="Height-for-width Geometry Management">the section called “Height-for-width Geometry Management”</a>). As a consequence,
      the ::size-request signal and vfunc has been removed from
      <a class="link" href="GtkWidget.html#GtkWidgetClass" title="struct GtkWidgetClass"><span class="type">GtkWidgetClass</span></a>. The replacement for <code class="function">size_request()</code> can
      take several levels of sophistication:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
        As a minimal replacement to keep current functionality,
        you can simply implement the <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-width"><code class="function">GtkWidgetClass.get_preferred_width()</code></a> and
        <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-height"><code class="function">GtkWidgetClass.get_preferred_height()</code></a> vfuncs by calling your existing
        <code class="function">size_request()</code> function. So you go from
        </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static void</span>
<span class="function">my_widget_class_init</span> <span class="gtkdoc opt">(</span>MyWidgetClass <span class="gtkdoc opt">*</span><span class="gtkdoc kwc">class</span><span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GtkWidgetClass <span class="gtkdoc opt">*</span>widget_class <span class="gtkdoc opt">=</span> <span class="function">GTK_WIDGET_CLASS</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwc">class</span><span class="gtkdoc opt">);</span>

  <span class="comment">/* ... */</span>

  widget_class<span class="gtkdoc opt">-&gt;</span>size_request <span class="gtkdoc opt">=</span> my_widget_size_request<span class="gtkdoc opt">;</span>

  <span class="comment">/* ... */</span>
<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
        </p>
<p>
        to something that looks more like this:
        </p>
<p>
        </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static void</span>
<span class="function">my_widget_get_preferred_width</span> <span class="gtkdoc opt">(</span>GtkWidget <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                               gint      <span class="gtkdoc opt">*</span>minimal_width<span class="gtkdoc opt">,</span>
                               gint      <span class="gtkdoc opt">*</span>natural_width<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GtkRequisition requisition<span class="gtkdoc opt">;</span>

  <span class="function">my_widget_size_request</span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">, &amp;</span>requisition<span class="gtkdoc opt">);</span>

  <span class="gtkdoc opt">*</span>minimal_width <span class="gtkdoc opt">= *</span>natural_width <span class="gtkdoc opt">=</span> requisition<span class="gtkdoc opt">.</span>width<span class="gtkdoc opt">;</span>
<span class="gtkdoc opt">}</span>

<span class="gtkdoc kwb">static void</span>
<span class="function">my_widget_get_preferred_height</span> <span class="gtkdoc opt">(</span>GtkWidget <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                                gint      <span class="gtkdoc opt">*</span>minimal_height<span class="gtkdoc opt">,</span>
                                gint      <span class="gtkdoc opt">*</span>natural_height<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GtkRequisition requisition<span class="gtkdoc opt">;</span>

  <span class="function">my_widget_size_request</span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">, &amp;</span>requisition<span class="gtkdoc opt">);</span>

  <span class="gtkdoc opt">*</span>minimal_height <span class="gtkdoc opt">= *</span>natural_height <span class="gtkdoc opt">=</span> requisition<span class="gtkdoc opt">.</span>height<span class="gtkdoc opt">;</span>
<span class="gtkdoc opt">}</span>

 <span class="comment">/* ... */</span>

<span class="gtkdoc kwb">static void</span>
<span class="function">my_widget_class_init</span> <span class="gtkdoc opt">(</span>MyWidgetClass <span class="gtkdoc opt">*</span><span class="gtkdoc kwc">class</span><span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GtkWidgetClass <span class="gtkdoc opt">*</span>widget_class <span class="gtkdoc opt">=</span> <span class="function">GTK_WIDGET_CLASS</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwc">class</span><span class="gtkdoc opt">);</span>

  <span class="comment">/* ... */</span>

  widget_class<span class="gtkdoc opt">-&gt;</span>get_preferred_width <span class="gtkdoc opt">=</span> my_widget_get_preferred_width<span class="gtkdoc opt">;</span>
  widget_class<span class="gtkdoc opt">-&gt;</span>get_preferred_height <span class="gtkdoc opt">=</span> my_widget_get_preferred_height<span class="gtkdoc opt">;</span>

  <span class="comment">/* ... */</span>

<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
          </p>
<p>
          Sometimes you can make things a little more streamlined
          by replacing your existing <code class="function">size_request()</code> implementation by
          one that takes an orientation parameter:
          </p>
<p>
          </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static void</span>
<span class="function">my_widget_get_preferred_size</span> <span class="gtkdoc opt">(</span>GtkWidget      <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                              GtkOrientation  orientation<span class="gtkdoc opt">,</span>
                               gint          <span class="gtkdoc opt">*</span>minimal_size<span class="gtkdoc opt">,</span>
                               gint          <span class="gtkdoc opt">*</span>natural_size<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>

  <span class="comment">/* do things that are common for both orientations ... */</span>

  <span class="keyword">if</span> <span class="gtkdoc opt">(</span>orientation <span class="gtkdoc opt">==</span> GTK_ORIENTATION_HORIZONTAL<span class="gtkdoc opt">)</span>
    <span class="gtkdoc opt">{</span>
      <span class="comment">/* do stuff that only applies to width... */</span>

      <span class="gtkdoc opt">*</span>minimal_size <span class="gtkdoc opt">= *</span>natural_size <span class="gtkdoc opt">= ...</span>
    <span class="gtkdoc opt">}</span>
  <span class="keyword">else</span>
   <span class="gtkdoc opt">{</span>
      <span class="comment">/* do stuff that only applies to height... */</span>

      <span class="gtkdoc opt">*</span>minimal_size <span class="gtkdoc opt">= *</span>natural_size <span class="gtkdoc opt">= ...</span>
   <span class="gtkdoc opt">}</span>
<span class="gtkdoc opt">}</span>

<span class="gtkdoc kwb">static void</span>
<span class="function">my_widget_get_preferred_width</span> <span class="gtkdoc opt">(</span>GtkWidget <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                               gint      <span class="gtkdoc opt">*</span>minimal_width<span class="gtkdoc opt">,</span>
                               gint      <span class="gtkdoc opt">*</span>natural_width<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  <span class="function">my_widget_get_preferred_size</span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">,</span>
                                GTK_ORIENTATION_HORIZONTAL<span class="gtkdoc opt">,</span>
                                minimal_width<span class="gtkdoc opt">,</span>
                                natural_width<span class="gtkdoc opt">);</span>
<span class="gtkdoc opt">}</span>

<span class="gtkdoc kwb">static void</span>
<span class="function">my_widget_get_preferred_height</span> <span class="gtkdoc opt">(</span>GtkWidget <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                                gint      <span class="gtkdoc opt">*</span>minimal_height<span class="gtkdoc opt">,</span>
                                gint      <span class="gtkdoc opt">*</span>natural_height<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  <span class="function">my_widget_get_preferred_size</span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">,</span>
                                GTK_ORIENTATION_VERTICAL<span class="gtkdoc opt">,</span>
                                minimal_height<span class="gtkdoc opt">,</span>
                                natural_height<span class="gtkdoc opt">);</span>
<span class="gtkdoc opt">}</span>

 <span class="comment">/* ... */</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
          </p>
</li>
<li class="listitem">
<p>If your widget can cope with a small size,
          but would appreciate getting some more space (a common
          example would be that it contains ellipsizable labels),
          you can do that by making your <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-width"><code class="function">GtkWidgetClass.get_preferred_width()</code></a> /
          <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-height"><code class="function">GtkWidgetClass.get_preferred_height()</code></a>
          functions return a smaller value for <em class="parameter"><code>minimal</code></em> than for <em class="parameter"><code>natural</code></em>.
          For <em class="parameter"><code>minimal</code></em>, you probably want to return the same value
          that your <code class="function">size_request()</code> function returned before (since
          <code class="function">size_request()</code> was defined as returning the minimal size
          a widget can work with). A simple way to obtain good
          values for <em class="parameter"><code>natural</code></em>, in the case of containers, is to use
          <a class="link" href="GtkWidget.html#gtk-widget-get-preferred-width" title="gtk_widget_get_preferred_width ()"><code class="function">gtk_widget_get_preferred_width()</code></a> and
          <a class="link" href="GtkWidget.html#gtk-widget-get-preferred-height" title="gtk_widget_get_preferred_height ()"><code class="function">gtk_widget_get_preferred_height()</code></a> on the children of the
          container, as in the following example:
          </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static void</span>
<span class="function">gtk_fixed_get_preferred_height</span> <span class="gtkdoc opt">(</span>GtkWidget <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                                gint      <span class="gtkdoc opt">*</span>minimum<span class="gtkdoc opt">,</span>
                                gint      <span class="gtkdoc opt">*</span>natural<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GtkFixed <span class="gtkdoc opt">*</span>fixed <span class="gtkdoc opt">=</span> <span class="function">GTK_FIXED</span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">);</span>
  GtkFixedPrivate <span class="gtkdoc opt">*</span>priv <span class="gtkdoc opt">=</span> fixed<span class="gtkdoc opt">-&gt;</span>priv<span class="gtkdoc opt">;</span>
  GtkFixedChild <span class="gtkdoc opt">*</span>child<span class="gtkdoc opt">;</span>
  GList <span class="gtkdoc opt">*</span>children<span class="gtkdoc opt">;</span>
  gint child_min<span class="gtkdoc opt">,</span> child_nat<span class="gtkdoc opt">;</span>

  <span class="gtkdoc opt">*</span>minimum <span class="gtkdoc opt">=</span> <span class="number">0</span><span class="gtkdoc opt">;</span>
  <span class="gtkdoc opt">*</span>natural <span class="gtkdoc opt">=</span> <span class="number">0</span><span class="gtkdoc opt">;</span>

  <span class="keyword">for</span> <span class="gtkdoc opt">(</span>children <span class="gtkdoc opt">=</span> priv<span class="gtkdoc opt">-&gt;</span>children<span class="gtkdoc opt">;</span> children<span class="gtkdoc opt">;</span> children <span class="gtkdoc opt">=</span> children<span class="gtkdoc opt">-&gt;</span>next<span class="gtkdoc opt">)</span>
    <span class="gtkdoc opt">{</span>
      child <span class="gtkdoc opt">=</span> children<span class="gtkdoc opt">-&gt;</span>data<span class="gtkdoc opt">;</span>

      <span class="keyword">if</span> <span class="gtkdoc opt">(!</span><span class="function"><a href="GtkWidget.html#gtk-widget-get-visible">gtk_widget_get_visible</a></span> <span class="gtkdoc opt">(</span>child<span class="gtkdoc opt">-&gt;</span>widget<span class="gtkdoc opt">))</span>
        <span class="keyword">continue</span><span class="gtkdoc opt">;</span>

      <span class="function"><a href="GtkWidget.html#gtk-widget-get-preferred-height">gtk_widget_get_preferred_height</a></span> <span class="gtkdoc opt">(</span>child<span class="gtkdoc opt">-&gt;</span>widget<span class="gtkdoc opt">, &amp;</span>child_min<span class="gtkdoc opt">, &amp;</span>child_nat<span class="gtkdoc opt">);</span>

      <span class="gtkdoc opt">*</span>minimum <span class="gtkdoc opt">=</span> <span class="function"><a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#MAX:CAPS">MAX</a></span> <span class="gtkdoc opt">(*</span>minimum<span class="gtkdoc opt">,</span> child<span class="gtkdoc opt">-&gt;</span>y <span class="gtkdoc opt">+</span> child_min<span class="gtkdoc opt">);</span>
      <span class="gtkdoc opt">*</span>natural <span class="gtkdoc opt">=</span> <span class="function"><a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#MAX:CAPS">MAX</a></span> <span class="gtkdoc opt">(*</span>natural<span class="gtkdoc opt">,</span> child<span class="gtkdoc opt">-&gt;</span>y <span class="gtkdoc opt">+</span> child_nat<span class="gtkdoc opt">);</span>
    <span class="gtkdoc opt">}</span>
<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
          </p>
</li>
<li class="listitem"><p>
          Note that the <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-width"><code class="function">GtkWidgetClass.get_preferred_width()</code></a> /
          <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-height"><code class="function">GtkWidgetClass.get_preferred_height()</code></a> functions
          only allow you to deal with one dimension at a time. If your
          <code class="function">size_request()</code> handler is doing things that involve both
          width and height at the same time (e.g. limiting the aspect
          ratio), you will have to implement
          <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-height-for-width"><code class="function">GtkWidgetClass.get_preferred_height_for_width()</code></a>
          and <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-width-for-height"><code class="function">GtkWidgetClass.get_preferred_width_for_height()</code></a>.
          </p></li>
<li class="listitem"><p>
          To make full use of the new capabilities of the
          height-for-width geometry management, you need to additionally
          implement the <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-height-for-width"><code class="function">GtkWidgetClass.get_preferred_height_for_width()</code></a> and
          <a class="link" href="GtkWidget.html#GtkWidgetClass.get-preferred-width-for-height"><code class="function">GtkWidgetClass.get_preferred_width_for_height()</code></a>. For details on
          these functions, see <a class="xref" href="GtkWidget.html#geometry-management" title="Height-for-width Geometry Management">the section called “Height-for-width Geometry Management”</a>.
          </p></li>
</ul></div>
<p>
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.4"></a>Replace GdkRegion by cairo_region_t</h3></div></div></div>
<p>
      Starting with version 1.10, cairo provides a region API that is
      equivalent to the GDK region API (which was itself copied from
      the X server). Therefore, the region API has been removed in GTK+ 3.
    </p>
<p>
      Porting your application to the cairo region API should be a straight
      find-and-replace task. Please refer to the following table:
      </p>
<div class="table">
<a name="id-1.6.3.4.4.3.1"></a><p class="title"><b>Table 14. </b></p>
<div class="table-contents"><table class="table" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>GDK</th>
<th>cairo</th>
</tr></thead>
<tbody>
<tr>
<td><span class="type">GdkRegion</span></td>
<td><span class="type">cairo_region_t</span></td>
</tr>
<tr>
<td><a href="http://developer.gnome.org/gdk3/gdk4-Points-Rectangles-and-Regions.html#GdkRectangle"><span class="type">GdkRectangle</span></a></td>
<td><span class="type">cairo_rectangle_int_t</span></td>
</tr>
<tr>
<td><a href="http://developer.gnome.org/gdk3/gdk4-Points-Rectangles-and-Regions.html#gdk-rectangle-intersect"><code class="function">gdk_rectangle_intersect()</code></a></td>
<td>this function is still there</td>
</tr>
<tr>
<td><a href="http://developer.gnome.org/gdk3/gdk4-Points-Rectangles-and-Regions.html#gdk-rectangle-union"><code class="function">gdk_rectangle_union()</code></a></td>
<td>this function is still there</td>
</tr>
<tr>
<td><code class="function">gdk_region_new()</code></td>
<td><code class="function">cairo_region_create()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_copy()</code></td>
<td><code class="function">cairo_region_copy()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_destroy()</code></td>
<td><code class="function">cairo_region_destroy()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_rectangle()</code></td>
<td><code class="function">cairo_region_create_rectangle()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_get_clipbox()</code></td>
<td><code class="function">cairo_region_get_extents()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_get_rectangles()</code></td>
<td>
<code class="function">cairo_region_num_rectangles()</code> and
                                <code class="function">cairo_region_get_rectangle()</code>
</td>
</tr>
<tr>
<td><code class="function">gdk_region_empty()</code></td>
<td><code class="function">cairo_region_is_empty()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_equal()</code></td>
<td><code class="function">cairo_region_equal()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_point_in()</code></td>
<td><code class="function">cairo_region_contains_point()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_rect_in()</code></td>
<td><code class="function">cairo_region_contains_rectangle()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_offset()</code></td>
<td><code class="function">cairo_region_translate()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_union_with_rect()</code></td>
<td><code class="function">cairo_region_union_rectangle()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_intersect()</code></td>
<td><code class="function">cairo_region_intersect()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_union()</code></td>
<td><code class="function">cairo_region_union()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_subtract()</code></td>
<td><code class="function">cairo_region_subtract()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_xor()</code></td>
<td><code class="function">cairo_region_xor()</code></td>
</tr>
<tr>
<td><code class="function">gdk_region_shrink()</code></td>
<td>no replacement</td>
</tr>
<tr>
<td><code class="function">gdk_region_polygon()</code></td>
<td>no replacement, use cairo paths instead</td>
</tr>
</tbody>
</table></div>
</div>
<p><br class="table-break">
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.5"></a>Replace GdkPixmap by cairo surfaces</h3></div></div></div>
<p>
      The <span class="type">GdkPixmap</span> object and related functions have been removed.
      In the cairo-centric world of GTK+ 3, cairo surfaces take over
      the role of pixmaps.
    </p>
<div class="example">
<a name="id-1.6.3.4.5.3"></a><p class="title"><b>Example 41. Creating custom cursors</b></p>
<div class="example-contents">
<p>
        One place where pixmaps were commonly used is to create custom
        cursors:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15</pre></td>
        <td class="listing_code"><pre class="programlisting">GdkCursor <span class="gtkdoc opt">*</span>cursor<span class="gtkdoc opt">;</span>
GdkPixmap <span class="gtkdoc opt">*</span>pixmap<span class="gtkdoc opt">;</span>
cairo_t <span class="gtkdoc opt">*</span>cr<span class="gtkdoc opt">;</span>
GdkColor fg <span class="gtkdoc opt">= {</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">0</span> <span class="gtkdoc opt">};</span>

pixmap <span class="gtkdoc opt">=</span> <span class="function">gdk_pixmap_new</span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> <span class="number">1</span><span class="gtkdoc opt">,</span> <span class="number">1</span><span class="gtkdoc opt">,</span> <span class="number">1</span><span class="gtkdoc opt">);</span>

cr <span class="gtkdoc opt">=</span> <span class="function">gdk_cairo_create</span> <span class="gtkdoc opt">(</span>pixmap<span class="gtkdoc opt">);</span>
<span class="function">cairo_rectangle</span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">1</span><span class="gtkdoc opt">,</span> <span class="number">1</span><span class="gtkdoc opt">);</span>
<span class="function">cairo_fill</span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">);</span>
<span class="function">cairo_destroy</span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">);</span>

cursor <span class="gtkdoc opt">=</span> <span class="function">gdk_cursor_new_from_pixmap</span> <span class="gtkdoc opt">(</span>pixmap<span class="gtkdoc opt">,</span> pixmap<span class="gtkdoc opt">, &amp;</span>fg<span class="gtkdoc opt">, &amp;</span>fg<span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">);</span>

<span class="function"><a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref">g_object_unref</a></span> <span class="gtkdoc opt">(</span>pixmap<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      The same can be achieved without pixmaps, by drawing onto
      an image surface:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20</pre></td>
        <td class="listing_code"><pre class="programlisting">GdkCursor <span class="gtkdoc opt">*</span>cursor<span class="gtkdoc opt">;</span>
cairo_surface_t <span class="gtkdoc opt">*</span>s<span class="gtkdoc opt">;</span>
cairo_t <span class="gtkdoc opt">*</span>cr<span class="gtkdoc opt">;</span>
GdkPixbuf <span class="gtkdoc opt">*</span>pixbuf<span class="gtkdoc opt">;</span>

s <span class="gtkdoc opt">=</span> <span class="function">cairo_image_surface_create</span> <span class="gtkdoc opt">(</span>CAIRO_FORMAT_A1<span class="gtkdoc opt">,</span> <span class="number">3</span><span class="gtkdoc opt">,</span> <span class="number">3</span><span class="gtkdoc opt">);</span>
cr <span class="gtkdoc opt">=</span> <span class="function">cairo_create</span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">);</span>
<span class="function">cairo_arc</span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">,</span> <span class="number">1.5</span><span class="gtkdoc opt">,</span> <span class="number">1.5</span><span class="gtkdoc opt">,</span> <span class="number">1.5</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">2</span> <span class="gtkdoc opt">*</span> M_PI<span class="gtkdoc opt">);</span>
<span class="function">cairo_fill</span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">);</span>
<span class="function">cairo_destroy</span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">);</span>

pixbuf <span class="gtkdoc opt">=</span> <span class="function"><a href="http://developer.gnome.org/gdk3/gdk4-Pixbufs.html#gdk-pixbuf-get-from-surface">gdk_pixbuf_get_from_surface</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span>
                                      <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span>
                                      <span class="number">3</span><span class="gtkdoc opt">,</span> <span class="number">3</span><span class="gtkdoc opt">);</span>

<span class="function">cairo_surface_destroy</span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">);</span>

cursor <span class="gtkdoc opt">=</span> <span class="function"><a href="http://developer.gnome.org/gdk3/gdk4-Cursors.html#gdk-cursor-new-from-pixbuf">gdk_cursor_new_from_pixbuf</a></span> <span class="gtkdoc opt">(</span>display<span class="gtkdoc opt">,</span> pixbuf<span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">);</span>

<span class="function"><a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref">g_object_unref</a></span> <span class="gtkdoc opt">(</span>pixbuf<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      </p>
</div>
</div>
<br class="example-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.6"></a>Replace GdkColormap by GdkVisual</h3></div></div></div>
<p>
      For drawing with cairo, it is not necessary to allocate colors, and
      a <a href="http://developer.gnome.org/gdk3/gdk4-Visuals.html#GdkVisual-struct"><span class="type">GdkVisual</span></a> provides enough information for cairo to handle colors
      in 'native' surfaces. Therefore, <span class="type">GdkColormap</span> and related functions
      have been removed in GTK+ 3, and visuals are used instead. The
      colormap-handling functions of <a class="link" href="GtkWidget.html" title="GtkWidget"><span class="type">GtkWidget</span></a> (<code class="function">gtk_widget_set_colormap()</code>,
      etc) have been removed and <a class="link" href="GtkWidget.html#gtk-widget-set-visual" title="gtk_widget_set_visual ()"><code class="function">gtk_widget_set_visual()</code></a> has been added.
    </p>
<div class="example">
<a name="id-1.6.3.4.6.3"></a><p class="title"><b>Example 42. Setting up a translucent window</b></p>
<div class="example-contents">
<p>You might have a screen-changed handler like the following
     to set up a translucent window with an alpha-channel:
    </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static void</span>
<span class="function">on_alpha_screen_changed</span> <span class="gtkdoc opt">(</span>GtkWidget <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                         GdkScreen <span class="gtkdoc opt">*</span>old_screen<span class="gtkdoc opt">,</span>
                         GtkWidget <span class="gtkdoc opt">*</span>label<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GdkScreen <span class="gtkdoc opt">*</span>screen <span class="gtkdoc opt">=</span> <span class="function"><a href="GtkWidget.html#gtk-widget-get-screen">gtk_widget_get_screen</a></span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">);</span>
  GdkColormap <span class="gtkdoc opt">*</span>colormap <span class="gtkdoc opt">=</span> <span class="function">gdk_screen_get_rgba_colormap</span> <span class="gtkdoc opt">(</span>screen<span class="gtkdoc opt">);</span>

  <span class="keyword">if</span> <span class="gtkdoc opt">(</span>colormap <span class="gtkdoc opt">==</span> NULL<span class="gtkdoc opt">)</span>
    colormap <span class="gtkdoc opt">=</span> <span class="function">gdk_screen_get_default_colormap</span> <span class="gtkdoc opt">(</span>screen<span class="gtkdoc opt">);</span>

  <span class="function">gtk_widget_set_colormap</span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">,</span> colormap<span class="gtkdoc opt">);</span>
<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
    With visuals instead of colormaps, this will look as follows:
    </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static void</span>
<span class="function">on_alpha_screen_changed</span> <span class="gtkdoc opt">(</span>GtkWindow <span class="gtkdoc opt">*</span>window<span class="gtkdoc opt">,</span>
                         GdkScreen <span class="gtkdoc opt">*</span>old_screen<span class="gtkdoc opt">,</span>
                         GtkWidget <span class="gtkdoc opt">*</span>label<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GdkScreen <span class="gtkdoc opt">*</span>screen <span class="gtkdoc opt">=</span> <span class="function"><a href="GtkWidget.html#gtk-widget-get-screen">gtk_widget_get_screen</a></span> <span class="gtkdoc opt">(</span><span class="function">GTK_WIDGET</span> <span class="gtkdoc opt">(</span>window<span class="gtkdoc opt">));</span>
  GdkVisual <span class="gtkdoc opt">*</span>visual <span class="gtkdoc opt">=</span> <span class="function">gdk_screen_get_rgba_visual</span> <span class="gtkdoc opt">(</span>screen<span class="gtkdoc opt">);</span>

  <span class="keyword">if</span> <span class="gtkdoc opt">(</span>visual <span class="gtkdoc opt">==</span> NULL<span class="gtkdoc opt">)</span>
    visual <span class="gtkdoc opt">=</span> <span class="function">gdk_screen_get_system_visual</span> <span class="gtkdoc opt">(</span>screen<span class="gtkdoc opt">);</span>

  <span class="function"><a href="GtkWidget.html#gtk-widget-set-visual">gtk_widget_set_visual</a></span> <span class="gtkdoc opt">(</span>window<span class="gtkdoc opt">,</span> visual<span class="gtkdoc opt">);</span>
<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
</div>
<br class="example-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.7"></a>GdkDrawable is gone</h3></div></div></div>
<p>
      <span class="type">GdkDrawable</span> has been removed in GTK+ 3, together with <span class="type">GdkPixmap</span>
      and <span class="type">GdkImage</span>. The only remaining drawable class is <a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#GdkWindow-struct"><span class="type">GdkWindow</span></a>.
      For dealing with image data, you should use a <span class="type">cairo_surface_t</span> or
      a <a href="http://library.gnome.org/devel/gdk-pixbuf/unstable/gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf-struct"><span class="type">GdkPixbuf</span></a>.
    </p>
<p>
      GdkDrawable functions that are useful with windows have been replaced
      by corresponding GdkWindow functions:
      </p>
<div class="table">
<a name="id-1.6.3.4.7.3.1"></a><p class="title"><b>Table 15. GdkDrawable to GdkWindow</b></p>
<div class="table-contents"><table class="table" summary="GdkDrawable to GdkWindow" border="1">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>GDK 2.x</th>
<th>GDK 3</th>
</tr></thead>
<tbody>
<tr>
<td><code class="function">gdk_drawable_get_visual()</code></td>
<td><code class="function">gdk_window_get_visual()</code></td>
</tr>
<tr>
<td><code class="function">gdk_drawable_get_size()</code></td>
<td>
<a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#gdk-window-get-width"><code class="function">gdk_window_get_width()</code></a>
                                                              <a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#gdk-window-get-height"><code class="function">gdk_window_get_height()</code></a>
</td>
</tr>
<tr>
<td><code class="function">gdk_pixbuf_get_from_drawable()</code></td>
<td><code class="function">gdk_pixbuf_get_from_window()</code></td>
</tr>
<tr>
<td><code class="function">gdk_drawable_get_clip_region()</code></td>
<td><a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#gdk-window-get-clip-region"><code class="function">gdk_window_get_clip_region()</code></a></td>
</tr>
<tr>
<td><code class="function">gdk_drawable_get_visible_region()</code></td>
<td><a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#gdk-window-get-visible-region"><code class="function">gdk_window_get_visible_region()</code></a></td>
</tr>
</tbody>
</table></div>
</div>
<p><br class="table-break">
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.8"></a>Event filtering</h3></div></div></div>
<p>
      If your application uses the low-level event filtering facilities in GDK,
      there are some changes you need to be aware of.
    </p>
<p>
      The special-purpose GdkEventClient events and the <code class="function">gdk_add_client_message_filter()</code> and <code class="function">gdk_display_add_client_message_filter()</code> functions have been
      removed. Receiving X11 ClientMessage events is still possible, using
      the general <a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#gdk-window-add-filter"><code class="function">gdk_window_add_filter()</code></a> API. A client message filter like
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static</span> GdkFilterReturn
<span class="function">message_filter</span> <span class="gtkdoc opt">(</span>GdkXEvent <span class="gtkdoc opt">*</span>xevent<span class="gtkdoc opt">,</span> GdkEvent <span class="gtkdoc opt">*</span>event<span class="gtkdoc opt">,</span> gpointer data<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  XClientMessageEvent <span class="gtkdoc opt">*</span>evt <span class="gtkdoc opt">= (</span>XClientMessageEvent <span class="gtkdoc opt">*)</span>xevent<span class="gtkdoc opt">;</span>

  <span class="comment">/* do something with evt ... */</span>
<span class="gtkdoc opt">}</span>

 <span class="gtkdoc opt">...</span>

message_type <span class="gtkdoc opt">=</span> <span class="function"><a href="http://developer.gnome.org/gdk3/gdk4-Properties-and-Atoms.html#gdk-atom-intern">gdk_atom_intern</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;MANAGER&quot;</span><span class="gtkdoc opt">,</span> FALSE<span class="gtkdoc opt">);</span>
<span class="function">gdk_display_add_client_message_filter</span> <span class="gtkdoc opt">(</span>display<span class="gtkdoc opt">,</span> message_type<span class="gtkdoc opt">,</span> message_filter<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
    then looks like this:
    </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwb">static</span> GdkFilterReturn
<span class="function">event_filter</span> <span class="gtkdoc opt">(</span>GdkXEvent <span class="gtkdoc opt">*</span>xevent<span class="gtkdoc opt">,</span> GdkEvent <span class="gtkdoc opt">*</span>event<span class="gtkdoc opt">,</span> gpointer data<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  XClientMessageEvent <span class="gtkdoc opt">*</span>evt<span class="gtkdoc opt">;</span>
  GdkAtom message_type<span class="gtkdoc opt">;</span>

  <span class="keyword">if</span> <span class="gtkdoc opt">(((</span>XEvent <span class="gtkdoc opt">*)</span>xevent<span class="gtkdoc opt">)-&gt;</span>type <span class="gtkdoc opt">!=</span> ClientMessage<span class="gtkdoc opt">)</span>
    <span class="keyword">return</span> GDK_FILTER_CONTINUE<span class="gtkdoc opt">;</span>

  evt <span class="gtkdoc opt">= (</span>XClientMessageEvent <span class="gtkdoc opt">*)</span>xevent<span class="gtkdoc opt">;</span>
  message_type <span class="gtkdoc opt">=</span> <span class="function">XInternAtom</span> <span class="gtkdoc opt">(</span>evt<span class="gtkdoc opt">-&gt;</span>display<span class="gtkdoc opt">,</span> <span class="string">&quot;MANAGER&quot;</span><span class="gtkdoc opt">,</span> FALSE<span class="gtkdoc opt">);</span>

  <span class="keyword">if</span> <span class="gtkdoc opt">(</span>evt<span class="gtkdoc opt">-&gt;</span>message_type <span class="gtkdoc opt">!=</span> message_type<span class="gtkdoc opt">)</span>
    <span class="keyword">return</span> GDK_FILTER_CONTINUE<span class="gtkdoc opt">;</span>

  <span class="comment">/* do something with evt ... */</span>
<span class="gtkdoc opt">}</span>

 <span class="gtkdoc opt">...</span>

<span class="function"><a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#gdk-window-add-filter">gdk_window_add_filter</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> message_filter<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      One advantage of using an event filter is that you can actually
      remove the filter when you don't need it anymore, using
      <a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#gdk-window-remove-filter"><code class="function">gdk_window_remove_filter()</code></a>.
    </p>
<p>
      The other difference to be aware of when working with event filters
      in GTK+ 3 is that GDK now uses XI2 by default when available. That
      means that your application does not receive core X11 key or button
      events. Instead, all input events are delivered as XIDeviceEvents.
      As a short-term workaround for this, you can force your application
      to not use XI2, with <a href="http://developer.gnome.org/gdk3/GdkDeviceManager.html#gdk-disable-multidevice"><code class="function">gdk_disable_multidevice()</code></a>. In the long term,
      you probably want to rewrite your event filter to deal with
      XIDeviceEvents.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.9"></a>Backend-specific code</h3></div></div></div>
<p>
      In GTK+ 2.x, GDK could only be compiled for one backend at a time,
      and the <a href="http://developer.gnome.org/gdk3/gdk4-General.html#GDK-WINDOWING-X11:CAPS"><code class="literal">GDK_WINDOWING_X11</code></a> or <code class="literal">GDK_WINDOWING_WIN32</code> macros could
      be used to find out which one you are dealing with:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc ppc">#ifdef GDK_WINDOWING_X11</span>
      <span class="keyword">if</span> <span class="gtkdoc opt">(</span>timestamp <span class="gtkdoc opt">!=</span> GDK_CURRENT_TIME<span class="gtkdoc opt">)</span>
        <span class="function"><a href="http://developer.gnome.org/gdk3/gdk4-X-Window-System-Interaction.html#gdk-x11-window-set-user-time">gdk_x11_window_set_user_time</a></span> <span class="gtkdoc opt">(</span>gdk_window<span class="gtkdoc opt">,</span> timestamp<span class="gtkdoc opt">);</span>
<span class="gtkdoc ppc">#endif</span>
<span class="gtkdoc ppc">#ifdef GDK_WINDOWING_WIN32</span>
        <span class="comment">/* ... win32 specific code ... */</span>
<span class="gtkdoc ppc">#endif</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      In GTK+ 3, GDK can be built with multiple backends, and currently
      used backend has to be determined at runtime, typically using
      type-check macros on a <a href="http://developer.gnome.org/gdk3/GdkDisplay.html#GdkDisplay-struct"><span class="type">GdkDisplay</span></a> or <a href="http://developer.gnome.org/gdk3/gdk4-Windows.html#GdkWindow-struct"><span class="type">GdkWindow</span></a>. You still need
      to use the GDK_WINDOWING macros to only compile code referring
      to supported backends:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc ppc">#ifdef GDK_WINDOWING_X11</span>
      <span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function">GDK_IS_X11_DISPLAY</span> <span class="gtkdoc opt">(</span>display<span class="gtkdoc opt">))</span>
        <span class="gtkdoc opt">{</span>
          <span class="keyword">if</span> <span class="gtkdoc opt">(</span>timestamp <span class="gtkdoc opt">!=</span> GDK_CURRENT_TIME<span class="gtkdoc opt">)</span>
            <span class="function"><a href="http://developer.gnome.org/gdk3/gdk4-X-Window-System-Interaction.html#gdk-x11-window-set-user-time">gdk_x11_window_set_user_time</a></span> <span class="gtkdoc opt">(</span>gdk_window<span class="gtkdoc opt">,</span> timestamp<span class="gtkdoc opt">);</span>
        <span class="gtkdoc opt">}</span>
      <span class="keyword">else</span>
<span class="gtkdoc ppc">#endif</span>
<span class="gtkdoc ppc">#ifdef GDK_WINDOWING_WIN32</span>
      <span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function">GDK_IS_WIN32_DISPLAY</span> <span class="gtkdoc opt">(</span>display<span class="gtkdoc opt">))</span>
        <span class="gtkdoc opt">{</span>
          <span class="comment">/* ... win32 specific code ... */</span>
        <span class="gtkdoc opt">}</span>
      <span class="keyword">else</span>
<span class="gtkdoc ppc">#endif</span>
       <span class="gtkdoc opt">{</span>
         <span class="function"><a href="https://developer.gnome.org/glib/unstable/glib-Message-Logging.html#g-warning">g_warning</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;Unsupported GDK backend&quot;</span><span class="gtkdoc opt">);</span>
       <span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
    </p>
<p>
      If you used the pkg-config variable <code class="varname">target</code> to
      conditionally build part of your project depending on the GDK backend,
      for instance like this:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function">AM_CONDITIONAL</span><span class="gtkdoc opt">(</span>BUILD_X11<span class="gtkdoc opt">,</span> test `$PKG_CONFIG <span class="gtkdoc opt">--</span>variable<span class="gtkdoc opt">=</span>target gtk<span class="gtkdoc opt">+-</span><span class="number">2.0</span>` <span class="gtkdoc opt">=</span> <span class="string">&quot;x11&quot;</span><span class="gtkdoc opt">)</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      then you should now use the M4 macro provided by GTK+ itself:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function">GTK_CHECK_BACKEND</span><span class="gtkdoc opt">([</span>x11<span class="gtkdoc opt">], [</span><span class="number">3.0.2</span><span class="gtkdoc opt">], [</span>have_x11<span class="gtkdoc opt">=</span>yes<span class="gtkdoc opt">], [</span>have_x11<span class="gtkdoc opt">=</span>no<span class="gtkdoc opt">])</span>
<span class="function">AM_CONDITIONAL</span><span class="gtkdoc opt">(</span>BUILD_x11<span class="gtkdoc opt">, [</span>test <span class="string">&quot;x$have_x11&quot;</span> <span class="gtkdoc opt">=</span> <span class="string">&quot;xyes&quot;</span><span class="gtkdoc opt">])</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.10"></a>GtkPlug and GtkSocket</h3></div></div></div>
<p>
      The <a class="link" href="GtkPlug.html" title="GtkPlug"><span class="type">GtkPlug</span></a> and <a class="link" href="GtkSocket.html" title="GtkSocket"><span class="type">GtkSocket</span></a> widgets are now X11-specific, and you
      have to include the <code class="filename">&lt;gtk/gtkx.h&gt;</code> header
      to use them. The previous section about proper handling of
      backend-specific code applies, if you care about other backends.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.11"></a>The GtkWidget::draw signal</h3></div></div></div>
<p>
      The GtkWidget <span class="type">“expose-event”</span> signal has been replaced by
      a new <a class="link" href="GtkWidget.html#GtkWidget-draw" title="The “draw” signal"><span class="type">“draw”</span></a> signal, which takes a <span class="type">cairo_t</span> instead of
      an expose event. The cairo context is being set up so that the origin
      at (0, 0) coincides with the upper left corner of the widget, and
      is properly clipped.
    </p>
<div class="note"><p>In other words, the cairo context of the draw signal is set
      up in 'widget coordinates', which is different from traditional expose
      event handlers, which always assume 'window coordinates'.
    </p></div>
<p>
      The widget is expected to draw itself with its allocated size, which
      is available via the new <a class="link" href="GtkWidget.html#gtk-widget-get-allocated-width" title="gtk_widget_get_allocated_width ()"><code class="function">gtk_widget_get_allocated_width()</code></a> and
      <a class="link" href="GtkWidget.html#gtk-widget-get-allocated-height" title="gtk_widget_get_allocated_height ()"><code class="function">gtk_widget_get_allocated_height()</code></a> functions. It is not necessary to
      check for <a class="link" href="GtkWidget.html#gtk-widget-is-drawable" title="gtk_widget_is_drawable ()"><code class="function">gtk_widget_is_drawable()</code></a>, since GTK+ already does this check
      before emitting the <a class="link" href="GtkWidget.html#GtkWidget-draw" title="The “draw” signal"><span class="type">“draw”</span></a> signal.
    </p>
<p>
      There are some special considerations for widgets with multiple windows.
      Expose events are window-specific, and widgets with multiple windows
      could expect to get an expose event for each window that needs to be
      redrawn. Therefore, multi-window expose event handlers typically look
      like this:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="keyword">if</span> <span class="gtkdoc opt">(</span>event<span class="gtkdoc opt">-&gt;</span>window <span class="gtkdoc opt">==</span> widget<span class="gtkdoc opt">-&gt;</span>window1<span class="gtkdoc opt">)</span>
  <span class="gtkdoc opt">{</span>
     <span class="comment">/* ... draw window1 ... */</span>
  <span class="gtkdoc opt">}</span>
<span class="keyword">else if</span> <span class="gtkdoc opt">(</span>event<span class="gtkdoc opt">-&gt;</span>window <span class="gtkdoc opt">==</span> widget<span class="gtkdoc opt">-&gt;</span>window2<span class="gtkdoc opt">)</span>
  <span class="gtkdoc opt">{</span>
     <span class="comment">/* ... draw window2 ... */</span>
  <span class="gtkdoc opt">}</span>
<span class="gtkdoc opt">...</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      In contrast, the <a class="link" href="GtkWidget.html#GtkWidget-draw" title="The “draw” signal"><span class="type">“draw”</span></a> signal handler may have to draw multiple
      windows in one call. GTK+ has a convenience function
      <a class="link" href="GtkWidget.html#gtk-cairo-should-draw-window" title="gtk_cairo_should_draw_window ()"><code class="function">gtk_cairo_should_draw_window()</code></a> that can be used to find out if
      a window needs to be drawn. With that, the example above would look
      like this (note that the 'else' is gone):
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function"><a href="GtkWidget.html#gtk-cairo-should-draw-window">gtk_cairo_should_draw_window</a></span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">,</span> widget<span class="gtkdoc opt">-&gt;</span>window1<span class="gtkdoc opt">)</span>
  <span class="gtkdoc opt">{</span>
     <span class="comment">/* ... draw window1 ... */</span>
  <span class="gtkdoc opt">}</span>
<span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function"><a href="GtkWidget.html#gtk-cairo-should-draw-window">gtk_cairo_should_draw_window</a></span> <span class="gtkdoc opt">(</span>cr<span class="gtkdoc opt">,</span> widget<span class="gtkdoc opt">-&gt;</span>window2<span class="gtkdoc opt">)</span>
  <span class="gtkdoc opt">{</span>
     <span class="comment">/* ... draw window2 ... */</span>
  <span class="gtkdoc opt">}</span>
<span class="gtkdoc opt">...</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      Another convenience function that can help when implementing
      ::draw for multi-window widgets is <a class="link" href="GtkWidget.html#gtk-cairo-transform-to-window" title="gtk_cairo_transform_to_window ()"><code class="function">gtk_cairo_transform_to_window()</code></a>,
      which transforms a cairo context from widget-relative coordinates
      to window-relative coordinates. You may want to use <code class="function">cairo_save()</code> and
      <code class="function">cairo_restore()</code> when modifying the cairo context in your draw function.
    </p>
<p>
      All GtkStyle drawing functions (<a class="link" href="GtkStyle.html#gtk-paint-box" title="gtk_paint_box ()"><code class="function">gtk_paint_box()</code></a>, etc) have been changed
      to take a <span class="type">cairo_t</span> instead of a window and a clip area. ::draw
      implementations will usually just use the cairo context that has been
      passed in for this.
    </p>
<div class="example">
<a name="id-1.6.3.4.11.7"></a><p class="title"><b>Example 43. A simple ::draw function</b></p>
<div class="example-contents">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20</pre></td>
        <td class="listing_code"><pre class="programlisting">gboolean
<span class="function">gtk_arrow_draw</span> <span class="gtkdoc opt">(</span>GtkWidget <span class="gtkdoc opt">*</span>widget<span class="gtkdoc opt">,</span>
                cairo_t   <span class="gtkdoc opt">*</span>cr<span class="gtkdoc opt">)</span>
<span class="gtkdoc opt">{</span>
  GtkStyleContext <span class="gtkdoc opt">*</span>context<span class="gtkdoc opt">;</span>
  gint x<span class="gtkdoc opt">,</span> y<span class="gtkdoc opt">;</span>
  gint width<span class="gtkdoc opt">,</span> height<span class="gtkdoc opt">;</span>
  gint extent<span class="gtkdoc opt">;</span>

  context <span class="gtkdoc opt">=</span> <span class="function"><a href="GtkWidget.html#gtk-widget-get-style-context">gtk_widget_get_style_context</a></span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">);</span>

  width <span class="gtkdoc opt">=</span> <span class="function"><a href="GtkWidget.html#gtk-widget-get-allocated-width">gtk_widget_get_allocated_width</a></span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">);</span>
  height <span class="gtkdoc opt">=</span> <span class="function"><a href="GtkWidget.html#gtk-widget-get-allocated-height">gtk_widget_get_allocated_height</a></span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">);</span>

  extent <span class="gtkdoc opt">=</span> <span class="function"><a href="https://developer.gnome.org/glib/unstable/glib-Standard-Macros.html#MIN:CAPS">MIN</a></span> <span class="gtkdoc opt">(</span>width <span class="gtkdoc opt">-</span> <span class="number">2</span> <span class="gtkdoc opt">*</span> PAD<span class="gtkdoc opt">,</span> height <span class="gtkdoc opt">-</span> <span class="number">2</span> <span class="gtkdoc opt">*</span> PAD<span class="gtkdoc opt">);</span>
  x <span class="gtkdoc opt">=</span> PAD<span class="gtkdoc opt">;</span>
  y <span class="gtkdoc opt">=</span> PAD<span class="gtkdoc opt">;</span>

  <span class="function"><a href="GtkStyleContext.html#gtk-render-arrow">gtk_render_arrow</a></span> <span class="gtkdoc opt">(</span>context<span class="gtkdoc opt">,</span> rc<span class="gtkdoc opt">,</span> G_PI <span class="gtkdoc opt">/</span> <span class="number">2</span><span class="gtkdoc opt">,</span> x<span class="gtkdoc opt">,</span> y<span class="gtkdoc opt">,</span> extent<span class="gtkdoc opt">);</span>
<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<br class="example-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.12"></a>GtkProgressBar orientation</h3></div></div></div>
<p>
      In GTK+ 2.x, <a class="link" href="GtkProgressBar.html" title="GtkProgressBar"><span class="type">GtkProgressBar</span></a> and <a class="link" href="GtkCellRendererProgress.html" title="GtkCellRendererProgress"><span class="type">GtkCellRendererProgress</span></a> were using the
      GtkProgressBarOrientation enumeration to specify their orientation and
      direction. In GTK+ 3, both the widget and the cell renderer implement
      <a class="link" href="gtk3-Orientable.html#GtkOrientable"><span class="type">GtkOrientable</span></a>, and have an additional 'inverted' property to determine
      their direction. Therefore, a call to <code class="function">gtk_progress_bar_set_orientation()</code>
      needs to be replaced by a pair of calls to
      <a class="link" href="gtk3-Orientable.html#gtk-orientable-set-orientation" title="gtk_orientable_set_orientation ()"><code class="function">gtk_orientable_set_orientation()</code></a> and <a class="link" href="GtkProgressBar.html#gtk-progress-bar-set-inverted" title="gtk_progress_bar_set_inverted ()"><code class="function">gtk_progress_bar_set_inverted()</code></a>.
      The following values correspond:
      </p>
<div class="table">
<a name="id-1.6.3.4.12.2.7"></a><p class="title"><b>Table 16. </b></p>
<div class="table-contents"><table class="table" border="1">
<colgroup>
<col class="1">
<col class="2">
<col class="3">
</colgroup>
<thead>
<tr>
<th>GTK+ 2.x</th>
<th colspan="2">GTK+ 3</th>
</tr>
<tr>
<th>GtkProgressBarOrientation</th>
<th>GtkOrientation</th>
<th>inverted</th>
</tr>
</thead>
<tbody>
<tr>
<td>GTK_PROGRESS_LEFT_TO_RIGHT</td>
<td>GTK_ORIENTATION_HORIZONTAL</td>
<td>FALSE</td>
</tr>
<tr>
<td>GTK_PROGRESS_RIGHT_TO_LEFT</td>
<td>GTK_ORIENTATION_HORIZONTAL</td>
<td>TRUE</td>
</tr>
<tr>
<td>GTK_PROGRESS_TOP_TO_BOTTOM</td>
<td>GTK_ORIENTATION_VERTICAL</td>
<td>FALSE</td>
</tr>
<tr>
<td>GTK_PROGRESS_BOTTOM_TO_TOP</td>
<td>GTK_ORIENTATION_VERTICAL</td>
<td>TRUE</td>
</tr>
</tbody>
</table></div>
</div>
<p><br class="table-break">
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.13"></a>Check your expand and fill flags</h3></div></div></div>
<p>
      The behaviour of expanding widgets has changed slightly in GTK+ 3,
      compared to GTK+ 2.x. It is now 'inherited', i.e. a container that
      has an expanding child is considered expanding itself. This is often
      the desired behaviour. In places where you don't want this to happen,
      setting the container explicity as not expanding will stop the
      expand flag of the child from being inherited. See
      <a class="link" href="GtkWidget.html#gtk-widget-set-hexpand" title="gtk_widget_set_hexpand ()"><code class="function">gtk_widget_set_hexpand()</code></a> and <a class="link" href="GtkWidget.html#gtk-widget-set-vexpand" title="gtk_widget_set_vexpand ()"><code class="function">gtk_widget_set_vexpand()</code></a>.
    </p>
<p>
      If you experience sizing problems with widgets in ported code,
      carefully check the <a class="link" href="GtkBox.html" title="GtkBox"><span class="type">GtkBox</span></a> expand and <a class="link" href="GtkBox.html" title="GtkBox"><span class="type">GtkBox</span></a> fill child properties of your
      boxes.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.14"></a>Scrolling changes</h3></div></div></div>
<p>
      The default values for the <a class="link" href="GtkScrolledWindow.html#GtkScrolledWindow--hscrollbar-policy" title="The “hscrollbar-policy” property"><span class="type">“hscrollbar-policy”</span></a> and
      <a class="link" href="GtkScrolledWindow.html#GtkScrolledWindow--vscrollbar-policy" title="The “vscrollbar-policy” property"><span class="type">“vscrollbar-policy”</span></a> properties have been changed from
      'never' to 'automatic'. If your application was relying on the default
      value, you will have to set it explicitly.
    </p>
<p>
      The ::set-scroll-adjustments signal on GtkWidget has been replaced
      by the <a class="link" href="GtkScrollable.html" title="GtkScrollable"><span class="type">GtkScrollable</span></a> interface which must be implemented by a widget
      that wants to be placed in a <a class="link" href="GtkScrolledWindow.html" title="GtkScrolledWindow"><span class="type">GtkScrolledWindow</span></a>. Instead of emitting
      ::set-scroll-adjustments, the scrolled window simply sets the
      <a class="link" href="GtkScrollable.html#GtkScrollable--hadjustment" title="The “hadjustment” property"><span class="type">“hadjustment”</span></a> and <a class="link" href="GtkScrollable.html#GtkScrollable--vadjustment" title="The “vadjustment” property"><span class="type">“vadjustment”</span></a> properties.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.15"></a>GtkObject is gone</h3></div></div></div>
<p>
      GtkObject has been removed in GTK+ 3. Its remaining functionality,
      the ::destroy signal, has been moved to GtkWidget. If you have non-widget
      classes that are directly derived from GtkObject, you have to make
      them derive from <a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#GInitiallyUnowned"><span class="type">GInitiallyUnowned</span></a> (or, if you don't need the floating
      functionality, <a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#GObject-struct"><span class="type">GObject</span></a>). If you have widgets that override the
      destroy class handler, you have to adjust your class_init function,
      since destroy is now a member of GtkWidgetClass:
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting">GtkObjectClass <span class="gtkdoc opt">*</span>object_class <span class="gtkdoc opt">=</span> <span class="function">GTK_OBJECT_CLASS</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwc">class</span><span class="gtkdoc opt">);</span>

object_class<span class="gtkdoc opt">-&gt;</span>destroy <span class="gtkdoc opt">=</span> my_destroy<span class="gtkdoc opt">;</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      becomes
      </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting">GtkWidgetClass <span class="gtkdoc opt">*</span>widget_class <span class="gtkdoc opt">=</span> <span class="function">GTK_WIDGET_CLASS</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwc">class</span><span class="gtkdoc opt">);</span>

widget_class<span class="gtkdoc opt">-&gt;</span>destroy <span class="gtkdoc opt">=</span> my_destroy<span class="gtkdoc opt">;</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
      In the unlikely case that you have a non-widget class that is derived
      from GtkObject and makes use of the destroy functionality, you have
      to implement ::destroy yourself.
    </p>
<p>
      If your program used functions like gtk_object_get or gtk_object_set,
      these can be replaced directly with g_object_get or g_object_set. In
      fact, most every gtk_object_* function can be replaced with the
      corresponding g_object_ function, even in GTK+ 2 code. The one exception
      to this rule is gtk_object_destroy, which can be replaced with
      gtk_widget_destroy, again in both GTK+ 2 and GTK+ 3.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.16"></a>GtkEntryCompletion signal parameters</h3></div></div></div>
<p>
      The <a class="link" href="GtkEntryCompletion.html#GtkEntryCompletion-match-selected" title="The “match-selected” signal"><span class="type">“match-selected”</span></a> and
      <a class="link" href="GtkEntryCompletion.html#GtkEntryCompletion-cursor-on-match" title="The “cursor-on-match” signal"><span class="type">“cursor-on-match”</span></a> signals were erroneously
      given the internal filter model instead of the users model.
      This oversight has been fixed in GTK+ 3; if you have handlers
      for these signals, they will likely need slight adjustments.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.17"></a>Resize grips</h3></div></div></div>
<p>
     The resize grip functionality has been moved from <a class="link" href="GtkStatusbar.html" title="GtkStatusbar"><span class="type">GtkStatusbar</span></a>
     to <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a>. Any window can now have resize grips, regardless whether
     it has a statusbar or not. The functions
     <code class="function">gtk_statusbar_set_has_resize_grip()</code> and <code class="function">gtk_statusbar_get_has_resize_grip()</code>
     have disappeared, and instead there are now
     <a class="link" href="GtkWindow.html#gtk-window-set-has-resize-grip" title="gtk_window_set_has_resize_grip ()"><code class="function">gtk_window_set_has_resize_grip()</code></a> and <a class="link" href="GtkWindow.html#gtk-window-get-has-resize-grip" title="gtk_window_get_has_resize_grip ()"><code class="function">gtk_window_get_has_resize_grip()</code></a>.
    </p>
<p>
     In more recent versions of GTK+ 3, the resize grip functionality has
     been removed entirely, in favor of invisible resize borders around the
     window. When updating to newer versions of GTK+ 3, you should simply
     remove all code dealing with resize grips.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.18"></a>Prevent mixed linkage</h3></div></div></div>
<p>
      Linking against GTK+ 2.x and GTK+ 3 in the same process is problematic
      and can lead to hard-to-diagnose crashes. The <a class="link" href="gtk3-General.html#gtk-init" title="gtk_init ()"><code class="function">gtk_init()</code></a> function in
      both GTK+ 2.22 and in GTK+ 3 tries to detect this situation and abort
      with a diagnostic message, but this check is not 100% reliable (e.g. if
      the problematic linking happens only in loadable modules).
    </p>
<p>
      Direct linking of your application against both versions of GTK+ is
      easy to avoid; the problem gets harder when your application is using
      libraries that are themselves linked against some version of GTK+.
      In that case, you have to verify that you are using a version of the
      library that is linked against GTK+ 3.
    </p>
<p>
      If you are using packages provided by a distributor, it is likely that
      parallel installable versions of the library exist for GTK+ 2.x and
      GTK+ 3, e.g for vte, check for vte3; for webkitgtk look for webkitgtk3,
      and so on.
    </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.6.3.4.19"></a>Install GTK+ modules in the right place</h3></div></div></div>
<p>
    Some software packages install loadable GTK+ modules such as theme engines,
    gdk-pixbuf loaders or input methods. Since GTK+ 3 is parallel-installable
    with GTK+ 2.x, the two GTK+ versions have separate locations for their
    loadable modules. The location for GTK+ 2.x is
    <code class="filename"><em class="replaceable"><code>libdir</code></em>/gtk-2.0</code>
    (and its subdirectories), for GTK+ 3 the location is
    <code class="filename"><em class="replaceable"><code>libdir</code></em>/gtk-3.0</code>
    (and its subdirectories).
  </p>
<p>
    For some kinds of modules, namely input methods and pixbuf loaders,
    GTK+ keeps a cache file with extra information about the modules.
    For GTK+ 2.x, these cache files are located in
    <code class="filename"><em class="replaceable"><code>sysconfdir</code></em>/gtk-2.0</code>.
    For GTK+ 3, they have been moved to
    <code class="filename"><em class="replaceable"><code>libdir</code></em>/gtk-3.0/3.0.0/</code>.
    The commands that create these cache files have been renamed with a -3
    suffix to make them parallel-installable.
  </p>
<p>
    Note that GTK+ modules often link against libgtk, libgdk-pixbuf, etc.
    If that is the case for your module, you have to be careful to link the
    GTK+ 2.x version of your module against the 2.x version of the libraries,
    and the GTK+ 3 version against hte 3.x versions. Loading a module linked
    against libgtk 2.x into an application using GTK+ 3 will lead to
    unhappiness and must be avoided.
  </p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25.1</div>
</body>
</html>