-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss-overview.html
More file actions
713 lines (662 loc) · 28 KB
/
Copy pathcss-overview.html
File metadata and controls
713 lines (662 loc) · 28 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<base href=".">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CSS Overview</title>
<link rel="stylesheet" href="assets/css/custom_bootstrap.css" type="text/css">
<link rel="stylesheet" href="assets/css/bootstrap-toc.min.css" type="text/css">
<link rel="stylesheet" href="assets/css/frontend.css" type="text/css">
<link rel="stylesheet" href="assets/css/jquery.mCustomScrollbar.min.css">
<link rel="stylesheet" href="assets/css/prism.css" type="text/css">
<script src="assets/js/mustache.min.js"></script>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/scrollspy.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/typeahead.jquery.min.js"></script>
<script src="assets/js/search.js"></script>
<script src="assets/js/isotope.pkgd.min.js"></script>
<script src="assets/js/compare-versions.js"></script>
<script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="assets/js/bootstrap-toc.min.js"></script>
<script src="assets/js/jquery.touchSwipe.min.js"></script>
<script src="assets/js/anchor.min.js"></script>
<script src="assets/js/tag_filtering.js"></script>
<script src="assets/js/language_switching.js"></script>
<script src="assets/js/lines_around_headings.js"></script>
<script src="assets/js/prism-core.js"></script>
<script src="assets/js/prism-autoloader.js"></script>
<script src="assets/js/prism_autoloader_path_override.js"></script>
<script src="assets/js/trie.js"></script>
</head>
<body class="no-script
" data-spy="scroll" data-target="#toc" data-offset="70">
<script>
$('body').removeClass('no-script');
</script>
<nav class="navbar navbar-fixed-top navbar-default" id="topnav">
<div class="container-fluid">
<div class="navbar-right">
<a id="toc-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-wrapper" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<form action="" class="navbar-form pull-right" id="navbar-search-form">
<div class="form-group has-feedback">
<input type="text" class="form-control input-sm" name="search" id="sidenav-lookup-field" placeholder="search" disabled>
<span class="glyphicon glyphicon-search form-control-feedback" id="search-mgn-glass"></span>
</div>
</form>
</div>
<div class="navbar-header">
<a id="sidenav-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<a id="home-link" href="index.html" class="hotdoc-navbar-brand">
<img src="assets/images/home.svg" alt="Home">
</a>
</div>
<div class="navbar-collapse collapse" id="navbar-wrapper">
<ul class="nav navbar-nav" id="menu">
</ul>
<div class="hidden-xs hidden-sm navbar-text navbar-center">
</div>
</div>
</div>
</nav>
<main>
<div data-extension="gi-extension" data-hotdoc-in-toplevel="True" data-hotdoc-project="gtk-4.0.0" data-hotdoc-ref="css-overview.html" class="page_container" id="page-wrapper" data-hotdoc-meta-gi-languages="['csharp']" data-hotdoc-meta-gi-language="c">
<script src="assets/js/utils.js"></script>
<div class="panel panel-collapse oc-collapsed" id="sidenav" data-hotdoc-role="navigation">
<script src="assets/js/navigation.js"></script>
<script src="assets/js/sitemap.js"></script>
</div>
<div id="body">
<div id="main">
<div id="page-description" data-hotdoc-source="css-overview.markdown" data-hotdoc-role="main">
<h1 id="overview-of-css-in-gtk">Overview of CSS in GTK+</h1>
<p>This chapter describes in detail how GTK+ uses CSS for styling and
layout.</p>
<p>We loosely follow the CSS <a href="https://www.w3.org/TR/css-values/#value-defs">value
definition</a> specification
in the formatting of syntax productions. Nonterminals are enclosed in
angle backets (〈〉), all other strings that are not listed here are
literals, Juxtaposition means all components must occur, in the given
order, A double ampersand (&&) means all components must occur, in any
order, A double bar (||) means one or more of the components must occur,
in any order, A single bar (|) indicates an alternative; exactly one of
the components must occur, Brackets ([]) are used for grouping, A
question mark (?) means that the preceding component is optional, An
asterisk (*) means zero or more copies of the preceding component, A
plus (+) means one or more copies of the preceding component, A number
in curly braces ({n}) means that the preceding component occurs exactly
n times, Two numbers in curly braces ({m,n}) mean that the preceding
component occurs at least m times and at most n times</p>
<h2 id="css-nodes">CSS nodes</h2>
<p>GTK+ applies the style information found in style sheets by matching the
selectors against a tree of nodes. Each node in the tree has a name, a
state and possibly style classes. The children of each node are linearly
ordered.</p>
<p>Every widget has one or more of these CSS nodes, and determines their
name, state, style classes and how they are layed out as children and
siblings in the overall node tree. The documentation for each widget
explains what CSS nodes it has.</p>
<pre><code>scale[.fine-tune]
├── marks.top
│ ├── mark
┊ ┊
│ ╰── mark
├── trough
│ ├── slider
│ ├── [highlight]
│ ╰── [fill]
╰── marks.bottom
├── mark
┊
╰── mark
</code></pre>
<h2 id="style-sheets">Style sheets</h2>
<p>The basic structure of the style sheets understood by GTK+ is a series
of statements, which are either rule sets or “@-rules”, separated by
whitespace.</p>
<p>A rule set consists of a selector and a declaration block, which is a
series of declarations enclosed in curly braces. The declarations are
separated by semicolons. Multiple selectors can share the same
declaration block, by putting all the separators in front of the block,
separated by commas.</p>
<pre><code>button, entry {
color: #ff00ea;
font: 12px "Comic Sans"
}
</code></pre>
<h2 id="importing-style-sheets">Importing style sheets</h2>
<p>GTK+ supports the CSS @import rule, in order to load another style sheet
in addition to the currently parsed one.</p>
<p>The syntax for @import rules is as follows:</p>
<pre><code>〈import rule〉 = @import [ 〈url〉 | 〈string〉] ;
〈url〉 = url( 〈string〉)
@import url("path/to/common.css");
</code></pre>
<p>To learn more about the @import rule, you can read the
<a href="https://www.w3.org/TR/css3-cascade/#at-import">Cascading</a> module of the
CSS specification.</p>
<h2 id="selectors">Selectors</h2>
<p>Selectors work very similar to the way they do in CSS.</p>
<p>All widgets have one or more CSS nodes with element names and style
classes. When style classes are used in selectors, they have to be
prefixed with a period. Widget names can be used in selectors like IDs.
When used in a selector, widget names must be prefixed with a #
character.</p>
<p>In more complicated situations, selectors can be combined in various
ways. To require that a node satisfies several conditions, combine
several selectors into one by concatenating them. To only match a node
when it occurs inside some other node, write the two selectors after
each other, separated by whitespace. To restrict the match to direct
children of the parent node, insert a > character between the two
selectors.</p>
<pre><code>window label {
background-color: #898989
}
notebook {
background-color: #a939f0
}
combobox,
notebook > entry {
color: @fg_color;
background-color: #1209a2
}
box * {
font: 20px Sans
}
label#title-label {
font: 15px Sans
}
#main-entry {
background-color: #f0a810
}
.entry {
color: #39f1f9;
}
spinbutton entry {
color: 900185;
}
</code></pre>
<p>It is possible to select CSS nodes depending on their position amongst
their siblings by applying pseudo-classes to the selector, like
:first-child, :last-child or :nth-child(even). When used in selectors,
pseudo-classes must be prefixed with a : character.</p>
<pre><code>notebook tab:first-child label {
color: #89d012;
}
</code></pre>
<p>Another use of pseudo-classes is to match widgets depending on their
state. The available pseudo-classes for widget states are :active,
:hover :disabled, :selected, :focus, :indeterminate, :checked and
:backdrop. In addition, the following pseudo-classes don't have a direct
equivalent as a widget state: :dir(ltr) and :dir(rtl) (for text
direction), :link and :visited (for links) and :drop(active) (for
highlighting drop targets). Widget state pseudo-classes may only apply
to the last element in a selector.</p>
<pre><code>button:active {
background-color: #0274d9;
}
button:hover {
background-color: #3085a9;
}
*:disabled {
background-color: #320a91;
}
checkbutton:checked {
background-color: #56f9a0;
}
label:focus {
background-color: #b4940f;
}
checkbutton:indeterminate {
background-color: #20395a;
}
</code></pre>
<p>To determine the effective style for a widget, all the matching rule
sets are merged. As in CSS, rules apply by specificity, so the rules
whose selectors more closely match a node will take precedence over the
others.</p>
<p>The full syntax for selectors understood by GTK+ can be found in the
table below. The main difference to CSS is that GTK+ does not currently
support attribute selectors.</p>
<table>
<caption>Selector syntax</caption>
<thead>
<tr class="header">
<th>Pattern</th>
<th>Matches</th>
<th>Reference</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>*</td>
<td>any node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#universal-selector">CSS</a></td>
<td></td>
</tr>
<tr class="even">
<td>E</td>
<td>any node with name E</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#type-selectors">CSS</a></td>
<td></td>
</tr>
<tr class="odd">
<td>E.class</td>
<td>any E node with the given style class</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#class-html">CSS</a></td>
<td></td>
</tr>
<tr class="even">
<td>E#id</td>
<td>any E node with the given ID</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#id-selectors">CSS</a></td>
<td>GTK+ uses the widget name as ID</td>
</tr>
<tr class="odd">
<td>E:nth‑child(〈nth‑child〉)</td>
<td>any E node which is the n-th child of its parent node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#structural-pseudos">CSS</a></td>
<td></td>
</tr>
<tr class="even">
<td>E:nth‑last‑child(〈nth‑child〉)</td>
<td>any E node which is the n-th child of its parent node, counting from the end</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#structural-pseudos">CSS</a></td>
<td></td>
</tr>
<tr class="odd">
<td>E:first‑child</td>
<td>any E node which is the first child of its parent node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#structural-pseudos">CSS</a></td>
<td></td>
</tr>
<tr class="even">
<td>E:last‑child</td>
<td>any E node which is the last child of its parent node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#structural-pseudos">CSS</a></td>
<td></td>
</tr>
<tr class="odd">
<td>E:only‑child</td>
<td>any E node which is the only child of its parent node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#structural-pseudos">CSS</a></td>
<td>Equivalent to E:first-child:last-child</td>
</tr>
<tr class="even">
<td>E:link, E:visited</td>
<td>any E node which represents a hyperlink, not yet visited (:link) or already visited (:visited)</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#link">CSS</a></td>
<td>Corresponds to GTK_STATE_FLAG_LINK and GTK_STATE_FLAGS_VISITED</td>
</tr>
<tr class="odd">
<td>E:active, E:hover, E:focus</td>
<td>any E node which is part of a widget with the corresponding state</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#useraction-pseudos">CSS</a></td>
<td>Correspond to GTK_STATE_FLAG_ACTIVE, GTK_STATE_FLAG_PRELIGHT and GTK_STATE_FLAGS_FOCUSED respectively</td>
</tr>
<tr class="even">
<td>E:disabled</td>
<td>any E node which is part of a widget which is disabled</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#UIstates">CSS</a></td>
<td>Corresponds to GTK_STATE_FLAG_INSENSITIVE</td>
</tr>
<tr class="odd">
<td>E:checked</td>
<td>any E node which is part of a widget (e.g. radio- or checkbuttons) which is checked</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#UIstates">CSS</a></td>
<td>Corresponds to GTK_STATE_FLAG_CHECKED</td>
</tr>
<tr class="even">
<td>E:indeterminate</td>
<td>any E node which is part of a widget (e.g. radio- or checkbuttons) which is in an indeterminate state</td>
<td>
<a href="https://www.w3.org/TR/css3-selectors/#indeterminate">CSS3</a>, <a href="https://drafts.csswg.org/selectors/#indeterminate">CSS4</a>
</td>
<td>Corresponds to GTK_STATE_FLAG_INCONSISTENT</td>
</tr>
<tr class="odd">
<td>E:backdrop, E:selected</td>
<td>any E node which is part of a widget with the corresponding state</td>
<td></td>
<td>Corresponds to GTK_STATE_FLAG_BACKDROP, GTK_STATE_FLAG_SELECTED</td>
</tr>
<tr class="even">
<td>E:not(〈selector〉)</td>
<td>any E node which does not match the simple selector 〈selector〉</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#negation">CSS</a></td>
<td></td>
</tr>
<tr class="odd">
<td>E:dir(ltr), E:dir(rtl)</td>
<td>any E node that has the corresponding text direction</td>
<td><a href="https://drafts.csswg.org/selectors/#the-dir-pseudo">CSS4</a></td>
<td></td>
</tr>
<tr class="even">
<td>E:drop(active)</td>
<td>any E node that is an active drop target for a current DND operation</td>
<td><a href="https://drafts.csswg.org/selectors/#drag-pseudos">CSS4</a></td>
<td></td>
</tr>
<tr class="odd">
<td>E F</td>
<td>any F node which is a descendent of an E node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#descendent-combinators">CSS</a></td>
<td></td>
</tr>
<tr class="even">
<td>E > F</td>
<td>any F node which is a child of an E node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#child-combinators">CSS</a></td>
<td></td>
</tr>
<tr class="odd">
<td>E ~ F</td>
<td>any F node which is preceded by an E node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#general-sibling-combinators">CSS</a></td>
<td></td>
</tr>
<tr class="even">
<td>E + F</td>
<td>any F node which is immediately preceded by an E node</td>
<td><a href="https://www.w3.org/TR/css3-selectors/#adjacent-sibling-combinators">CSS</a></td>
<td></td>
</tr>
</tbody>
</table>
<pre><code>〈nth-child〉 = even | odd | 〈integer〉 | 〈integer〉n | 〈integer〉n [ + | - ] 〈integer〉
</code></pre>
<p>To learn more about selectors in CSS, read the
<a href="https://www.w3.org/TR/css3-selectors/">Selectors</a> module of the CSS
specification.</p>
<h2 id="colors">Colors</h2>
<p>CSS allows to specify colors in various ways, using numeric values or
names from a predefined list of
colors.</p>
<pre><code>〈color〉 = currentColor | transparent | 〈color name〉 | 〈rgb color〉 | 〈rgba color〉 | 〈hex color〉 | 〈gtk color〉
〈rgb color 〉 = rgb( 〈number〉, 〈number〉, 〈number〉 ) | rgb( 〈percentage〉, 〈percentage〉, 〈percentage〉 )
〈rgba color 〉 = rgba(〈number〉, 〈number〉, 〈number〉, 〈alpha value〉) | rgba( 〈percentage〉, 〈percentage〉, 〈percentage〉, 〈alpha value〉 )
〈hex color〉 = #〈hex digits〉
〈alpha value〉 = 〈number〉, clamped to values between 0 and 1
</code></pre>
<p>The keyword currentColor resolves to the current value of the color
property when used in another property, and to the inherited value of
the color property when used in the color property itself.</p>
<p>The keyword transparent can be considered a shorthand for rgba(0,0,0,0).</p>
<p>For a list of valid color names and for more background on colors in
CSS, see the <a href="https://www.w3.org/TR/css3-color/#svg-color">Color</a> module
of the CSS specification.</p>
<pre><code> color: transparent;
background-color: red;
border-top-color: rgb(128,57,0);
border-left-color: rgba(10%,20%,30%,0.5);
border-right-color: #ff00cc;
border-bottom-color: #ffff0000cccc;
</code></pre>
<p>GTK+ adds several additional ways to specify colors.</p>
<pre><code>〈gtk color〉 = 〈symbolic color〉 | 〈color expression〉| 〈win32 color〉
</code></pre>
<p>The first is a reference to a color defined via a @define-color rule.
The syntax for @define-color rules is as follows:</p>
<pre><code>〈define color rule〉 = @define-color 〈name〉 〈color〉
</code></pre>
<p>To refer to the color defined by a @define-color rule, use the name from
the rule, prefixed with @.</p>
<pre><code>〈symbolic color〉 = @〈name〉
@define-color bg_color #f9a039;
* {
background-color: @bg_color;
}
</code></pre>
<p>GTK+ also supports color expressions, which allow colors to be
transformed to new ones and can be nested, providing a rich language to
define colors. Color expressions resemble functions, taking 1 or more
colors and in some cases a number as arguments.</p>
<p>shade() leaves the color unchanged when the number is 1 and transforms
it to black or white as the number approaches 0 or 2 respectively. For
mix(), 0 or 1 return the unaltered 1st or 2nd color respectively;
numbers between 0 and 1 return blends of the two; and numbers below 0 or
above 1 intensify the RGB components of the 1st or 2nd color
respectively. alpha() takes a number from 0 to 1 and applies that as the
opacity of the supplied
color.</p>
<pre><code>〈color expression〉 = lighter(〈color〉) | darker(〈color〉) | shade(〈color〉,〈number〉) | alpha(〈color〉,〈number〉) | mix(〈color〉,〈color〉,〈number〉)
</code></pre>
<p>On Windows, GTK+ allows to refer to system colors, as follows:</p>
<pre><code>〈win32 color〉 = -gtk-win32-color( 〈name〉, 〈integer〉)
</code></pre>
<h2 id="images">Images</h2>
<p>CSS allows to specify images in various ways, for backgrounds and
borders.</p>
<pre><code>〈image〉 = 〈url〉 | 〈crossfade〉 | 〈alternatives〉 | 〈gradient〉 | 〈gtk image〉
〈crossfade〉 = cross-fade( 〈percentage〉, 〈image〉, 〈image〉)
〈alternatives〉 = image([ 〈image〉, ]* [ 〈image〉 | 〈color〉 ])
〈gradient〉 = 〈linear gradient〉 | 〈radial gradient〉
〈linear gradient〉 = [ linear-gradient | repeating-linear-gradient ] (
[ [ 〈angle〉 | to 〈side or corner〉 ] , ]?
〈color stops〉 )
〈radial gradient〉 = [ radial‑gradient | repeating‑radial‑gradient ] (
[ [ 〈shape〉 || 〈size〉 ] [ at 〈position〉 ]? , | at 〈position〉, ]?
〈color stops〉 )
〈side or corner〉 = [ left | right ] || [ top | bottom ]
〈color stops〉 = 〈color stop〉 [ , 〈color stop〉]+
〈color stop〉 = 〈color〉 [ 〈percentage〉 | 〈length〉 ]?
〈shape〉 = circle | ellipse
〈size〉 = 〈extent keyword〉 | 〈length〉 | [ 〈length〉 | 〈percentage〉 ]{1,2}
〈extent keyword〉 = closest-size | farthest-side | closest-corner | farthest-corner
</code></pre>
<p>The simplest way to specify an image in CSS is to load an image file
from a URL. CSS does not specify anything about supported file formats;
within GTK+, you can expect at least PNG, JPEG and SVG to work. The full
list of supported image formats is determined by the available
gdk-pixbuf image loaders and may vary between systems.</p>
<pre><code>button {
background-image: url("water-lily.png");
}
</code></pre>
<p>A crossfade lets you specify an image as an intermediate between two
images. Crossfades are specified in the draft of the level 4
<a href="https://www.w3.org/TR/css4-images">Image</a> module of the CSS
specification.</p>
<pre><code>button {
background-image: cross-fade(50%, url("water-lily.png"), url("buffalo.jpg"));
}
</code></pre>
<p>The image() syntax provides a way to specify fallbacks in case an image
format may not be supported. Multiple fallback images can be specified,
and will be tried in turn until one can be loaded successfully. The last
fallback may be a color, which will be rendered as a solid color image.</p>
<pre><code>button {
background-image: image(url("fancy.svg"), url("plain.png"), green);
}
</code></pre>
<p>Gradients are images that smoothly fades from one color to another. CSS
provides ways to specify repeating and non-repeating linear and radial
gradients. Radial gradients can be circular, or axis-aligned ellipses.</p>
<p>A linear gradient is created by specifying a gradient line and then
several colors placed along that line. The gradient line may be
specified using an angle, or by using direction keywords.</p>
<pre><code>button {
background-image: linear-gradient(45deg, yellow, blue);
}
label {
background-image: linear-gradient(to top right, blue 20%, #f0f 80%);
}
</code></pre>
<p>A radial gradient is created by specifying a center point and one or two
radii. The radii may be given explicitly as lengths or percentages or
indirectly, by keywords that specify how the end circle or ellipsis
should be positioned relative to the area it is derawn in.</p>
<pre><code>button {
background-image: radial-gradient(ellipse at center, yellow 0%, green 100%);
}
label {
background-image: radial-gradient(circle farthest-side at left bottom, red, yellow 50px, green);
}
</code></pre>
<p>To learn more about gradients in CSS, including details of how color
stops are placed on the gradient line and keywords for specifying radial
sizes, you can read the
<a href="https://www.w3.org/TR/css3-images/#gradients">Image</a> module of the CSS
specification.</p>
<p>GTK+ extends the CSS syntax for images and also uses it for specifying
icons.</p>
<pre><code>〈gtk image〉 = 〈themed icon〉 | 〈scaled image〉 | 〈recolored image〉 | 〈win32 theme part〉
</code></pre>
<p>GTK+ has extensive support for loading icons from icon themes. It is
accessible from CSS with the -gtk-icontheme syntax.</p>
<pre><code>〈themed icon〉 = -gtk-icontheme( 〈icon name〉 )
</code></pre>
<p>The specified icon name is used to look up a themed icon, while taking
into account the values of the -gtk-icon-theme and -gtk-icon-palette
properties. This kind of image is mainly used as value of the
-gtk-icon-source property.</p>
<pre><code>spinner {
-gtk-icon-source: -gtk-icontheme('process-working-symbolic');
-gtk-icon-palette: success blue, warning #fc3, error magenta;
}
arrow.fancy {
-gtk-icon-source: -gtk-icontheme('pan-down');
-gtk-icon-theme: 'Oxygen';
}
</code></pre>
<p>GTK+ supports scaled rendering on hi-resolution displays. This works
best if images can specify normal and hi-resolution variants. From CSS,
this can be done with the -gtk-scaled syntax.</p>
<pre><code>〈scaled image〉 = -gtk-scaled( 〈image〉[, 〈image〉]* )
</code></pre>
<p>While -gtk-scaled accepts multiple higher-resolution variants, in
practice, it will mostly be used to specify a regular image and one
variant for scale 2.</p>
<pre><code>arrow {
-gtk-icon-source: -gtk-scaled(url('my-arrow.png'),
url('my-arrow@2.png'));
}
〈recolored image〉 = -gtk-recolor( 〈url〉[, 〈color palette〉] )
</code></pre>
<p>Symbolic icons from the icon theme are recolored according to the
-gtk-icon-palette property. The recoloring is sometimes needed for
images that are not part of an icon theme, and the -gtk-recolor syntax
makes this available. -gtk-recolor requires a url as first argument. The
remaining arguments specify the color palette to use. If the palette is
not explicitly specified, the current value of the -gtk-icon-palette
property is used.</p>
<pre><code>arrow {
-gtk-icon-source: -gtk-recolor(url('check.svg'), success blue, error rgb(255,0,0));
}
</code></pre>
<p>On Windows, GTK+ allows to refer to system theme parts as images, as
follows:</p>
<pre><code>〈win32 theme part〉 = -gtk-win32-theme-part( 〈name〉, 〈integer〉 〈integer〉
[, [ over( 〈integer〉 〈integer〉 [ , 〈alpha value〉]? ) | margins( 〈integer〉{1,4} ) ] ]* )
</code></pre>
<h2 id="transitions">Transitions</h2>
<p>CSS defines a mechanism by which changes in CSS property values can be
made to take effect gradually, instead of all at once. GTK+ supports
these transitions as well.</p>
<p>To enable a transition for a property when a rule set takes effect, it
needs to be listed in the transition-property property in that rule set.
Only animatable properties can be listed in the transition-property.</p>
<p>The details of a transition can modified with the transition-duration,
transition-timing-function and transition-delay properties.</p>
<p>To learn more about transitions, you can read the
<a href="www.w3.org/TR/css3-transitions/">Transitions</a> module of the CSS
specification.</p>
<h2 id="animations">Animations</h2>
<p>In addition to transitions, which are triggered by changes of the
underlying node tree, CSS also supports defined animations. While
transitions specify how property values change from one value to a new
value, animations explicitly define intermediate property values in
keyframes.</p>
<p>Keyframes are defined with an @-rule which contains one or more of rule
sets with special selectors. Property declarations for nonanimatable
properties are ignored in these rule sets (with the exception of
animation properties).</p>
<pre><code>〈keyframe rule〉 = @keyframes 〈name〉 { 〈animation rule〉 }
〈animation rule〉 = 〈animation selector〉 { 〈declaration〉* }
〈animation selector〉 = 〈single animation selector〉 [ , 〈single animation selector ]*
〈single animation selector〉 = from | to | 〈percentage〉
</code></pre>
<p>To enable an animation, the name of the keyframes must be set as the
value of the animation-name property. The details of the animation can
modified with the animation-duration, animation-timing-function,
animation-iteration-count and other animation properties.</p>
<pre><code>@keyframes spin {
to { -gtk-icon-transform: rotate(1turn); }
}
spinner {
animation-name: spin;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
</code></pre>
<p>To learn more about animations, you can read the
<a href="www.w3.org/TR/css3-animations/">Animations</a> module of the CSS
specification.</p>
<h2 id="key-bindings">Key bindings</h2>
<p>In order to extend key bindings affecting different widgets, GTK+
supports the @binding-set rule to parse a set of bind/unbind directives.
Note that in order to take effect, the binding sets defined in this way
must be associated with rule sets by setting the -gtk-key-bindings
property.</p>
<p>The syntax for @binding-set rules is as
follows:</p>
<pre><code>〈binding set rule〉 = @binding-set 〈binding name〉{ [ [ 〈binding〉 | 〈unbinding〉] ; ]* }
〈binding〉 = bind "〈accelerator〉" { 〈signal emission〉* }
〈signal emission〉 = "〈signal name〉" ( [ 〈argument〉[ , 〈argument〉]* ]? }
〈unbinding〉 = unbind "〈accelerator〉" ;
</code></pre>
<p>where 〈accelerator〉 is a string that can be parsed by
gtk_accelerator_parse(), 〈signal name〉 is the name of a keybinding
signal of the widget in question, and the 〈argument〉 list must be
according to the signals declaration.</p>
<pre><code>@binding-set binding-set1 {
bind "<alt>Left" { "move-cursor" (visual-positions, -3, 0) };
unbind "End";
};
@binding-set binding-set2 {
bind "<alt>Right" { "move-cursor" (visual-positions, 3, 0) };
bind "<alt>KP_space" { "delete-from-cursor" (whitespace, 1)
"insert-at-cursor" (" ") };
};
entry {
-gtk-key-bindings: binding-set1, binding-set2;
}
</code></pre>
</div>
</div>
<div id="search_results">
<p>The results of the search are</p>
</div>
<hr>
<div id="footer">
</div>
</div>
<div id="toc-column">
<div class="edit-button">
</div>
<div id="toc-wrapper">
<nav id="toc"></nav>
</div>
</div>
</div>
</main>
</body>
<script src="assets/js/navbar_offset_scroller.js"></script>
</html>