~ubuntu-branches/ubuntu/precise/gtk+2.0/precise-updates

« back to all changes in this revision

Viewing changes to docs/reference/gtk/tmpl/gtkrc.sgml

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2011-12-01 11:40:06 UTC
  • mfrom: (1.14.11)
  • Revision ID: package-import@ubuntu.com-20111201114006-nrmf6qu3pg512veo
Tags: 2.24.8-0ubuntu1
* New upstream release 
  - gtkfilechooser should be more robust to malformed URIs
    in .gtk-bookmarks (LP: #189494)
* debian/patches/010_make_bg_changes_queue_repaint.patch
  - dropped it introduces performance regressions in some gtk2 
    apps (LP: #889019)
* 101_filechooser.patch, 000git_file_chooser.patch: dropped, upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!-- ##### SECTION Title ##### -->
2
 
Resource Files
3
 
 
4
 
<!-- ##### SECTION Short_Description ##### -->
5
 
Routines for handling resource files
6
 
 
7
 
<!-- ##### SECTION Long_Description ##### -->
8
 
<para>
9
 
GTK+ provides resource file mechanism for configuring
10
 
various aspects of the operation of a GTK+ program
11
 
at runtime.
12
 
</para>
13
 
 
14
 
<refsect2><title>Default files</title>
15
 
<para>
16
 
An application can cause GTK+ to parse a specific RC
17
 
file by calling gtk_rc_parse(). In addition to this,
18
 
certain files will be read at the end of gtk_init().
19
 
Unless modified, the files looked for will be 
20
 
<filename>&lt;SYSCONFDIR&gt;/gtk-2.0/gtkrc</filename> 
21
 
and <filename>.gtkrc-2.0</filename> in the users home directory.
22
 
(<filename>&lt;SYSCONFDIR&gt;</filename> defaults to 
23
 
<filename>/usr/local/etc</filename>. It can be changed with the
24
 
<option>--prefix</option> or <option>--sysconfdir</option> options when 
25
 
configuring GTK+.) Note that although the filenames contain the version 
26
 
number 2.0, all 2.x versions of GTK+ look for these files.  
27
 
</para>
28
 
<para>
29
 
The set of these <firstterm>default</firstterm> files
30
 
can be retrieved with gtk_rc_get_default_files()
31
 
and modified with gtk_rc_add_default_file() and
32
 
gtk_rc_set_default_files().
33
 
Additionally, the <envar>GTK2_RC_FILES</envar> environment variable
34
 
can be set to a #G_SEARCHPATH_SEPARATOR_S-separated list of files
35
 
in order to overwrite the set of default files at runtime.
36
 
</para>
37
 
<para><anchor id="locale-specific-rc"/>
38
 
For each RC file, in addition to the file itself, GTK+ will look for 
39
 
a locale-specific file that will be parsed after the main file. 
40
 
For instance, if <envar>LANG</envar> is set to <literal>ja_JP.ujis</literal>,
41
 
when loading the default file <filename>~/.gtkrc</filename> then GTK+ looks 
42
 
for <filename>~/.gtkrc.ja_JP</filename> and <filename>~/.gtkrc.ja</filename>, 
43
 
and parses the first of those that exists.
44
 
</para>
45
 
</refsect2>
46
 
 
47
 
<refsect2><title>Pathnames and patterns</title>
48
 
<anchor id="gtkrc-pathnames-and-patterns"/>
49
 
<para>
50
 
A resource file defines a number of styles and key bindings and
51
 
attaches them to particular widgets. The attachment is done
52
 
by the <literal>widget</literal>, <literal>widget_class</literal>,
53
 
and <literal>class</literal> declarations. As an example
54
 
of such a statement:
55
 
 
56
 
<informalexample><programlisting>
57
 
widget "mywindow.*.GtkEntry" style "my-entry-class"
58
 
</programlisting></informalexample>
59
 
 
60
 
attaches the style <literal>"my-entry-class"</literal> to all 
61
 
widgets  whose <firstterm>widget path</firstterm> matches the 
62
 
<firstterm>pattern</firstterm> <literal>"mywindow.*.GtkEntry"</literal>. 
63
 
That is, all #GtkEntry widgets which are part of a #GtkWindow named 
64
 
<literal>"mywindow"</literal>.
65
 
</para>
66
 
 
67
 
<para>
68
 
The patterns here are given in the standard shell glob syntax. 
69
 
The <literal>"?"</literal> wildcard matches any character, while 
70
 
<literal>"*"</literal> matches zero or more of any character.  
71
 
The three types of matching are against the widget path, the
72
 
<firstterm>class path</firstterm> and the class hierarchy. Both the 
73
 
widget path and the class path consist of a <literal>"."</literal> 
74
 
separated list of all the parents of the widget and the widget itself 
75
 
from outermost to innermost. The difference is that in the widget path, 
76
 
the name assigned by gtk_widget_set_name() is used if present, otherwise 
77
 
the class name of the widget, while for the class path, the class name is 
78
 
always used.
79
 
</para>
80
 
<para>
81
 
Since GTK+ 2.10, <literal>widget_class</literal> paths can also contain
82
 
<literal>&lt;classname&gt;</literal> substrings, which are matching
83
 
the class with the given name and any derived classes. For instance,
84
 
<informalexample><programlisting>
85
 
widget_class "*&lt;GtkMenuItem&gt;.GtkLabel" style "my-style"
86
 
</programlisting></informalexample>
87
 
will match #GtkLabel widgets which are contained in any kind of menu item.
88
 
</para>
89
 
<para>
90
 
So, if you have a #GtkEntry named <literal>"myentry"</literal>, inside of a 
91
 
horizontal box in a window named <literal>"mywindow"</literal>, then the
92
 
widget path is: <literal>"mywindow.GtkHBox.myentry"</literal>
93
 
while the class path is: <literal>"GtkWindow.GtkHBox.GtkEntry"</literal>.
94
 
</para>
95
 
<para>
96
 
Matching against class is a little different. The pattern match is done
97
 
against all class names in the widgets class hierarchy (not the layout 
98
 
hierarchy) in sequence, so the pattern:
99
 
<informalexample><programlisting>
100
 
class "GtkButton" style "my-style"
101
 
</programlisting></informalexample>
102
 
will match not just #GtkButton widgets, but also #GtkToggleButton and
103
 
#GtkCheckButton widgets, since those classes derive from #GtkButton.
104
 
</para>
105
 
<para>
106
 
Additionally, a priority can be specified for each pattern, and styles 
107
 
override other styles first by priority, then by pattern type and then 
108
 
by order of specification (later overrides earlier). The priorities 
109
 
that can be specified are (highest to lowest):
110
 
<simplelist>
111
 
<member><literal>highest</literal></member>
112
 
<member><literal>rc</literal></member>
113
 
<member><literal>theme</literal></member>
114
 
<member><literal>application</literal></member>
115
 
<member><literal>gtk</literal></member>
116
 
<member><literal>lowest</literal></member>
117
 
</simplelist>
118
 
<literal>rc</literal> is the default for styles
119
 
read from an RC file, <literal>theme</literal>
120
 
is the default for styles read from theme RC files,
121
 
<literal>application</literal> 
122
 
should be used for styles an application sets
123
 
up, and <literal>gtk</literal> is used for styles
124
 
that GTK+ creates internally.
125
 
</para>
126
 
 
127
 
</refsect2>
128
 
 
129
 
<refsect2>
130
 
<anchor id="optimizing-rc-style-matches"/>
131
 
<title>Optimizing RC Style Matches</title>
132
 
<para>
133
 
Everytime a widget is created and added to the layout hierarchy of a #GtkWindow
134
 
("anchored" to be exact), a list of matching RC styles out of all RC styles read
135
 
in so far is composed.
136
 
For this, every RC style is matched against the widgets class path,
137
 
the widgets name path and widgets inheritance hierarchy.
138
 
As a consequence, significant slowdown can be caused by utilization of many
139
 
RC styles and by using RC style patterns that are slow or complicated to match
140
 
against a given widget.
141
 
The following ordered list provides a number of advices (prioritized by 
142
 
effectiveness) to reduce the performance overhead associated with RC style 
143
 
matches:
144
 
 
145
 
<orderedlist>
146
 
 
147
 
  <listitem><para>
148
 
  Move RC styles for specific applications into RC files dedicated to those
149
 
  applications and parse application specific RC files only from
150
 
  applications that are affected by them.
151
 
  This reduces the overall amount of RC styles that have to be considered
152
 
  for a match across a group of applications.
153
 
  </para></listitem>
154
 
 
155
 
  <listitem><para>
156
 
  Merge multiple styles which use the same matching rule, for instance:
157
 
<informalexample><programlisting>
158
 
     style "Foo" { foo_content }
159
 
     class "X" style "Foo"
160
 
     style "Bar" { bar_content }
161
 
     class "X" style "Bar"
162
 
</programlisting></informalexample>
163
 
   is faster to match as:
164
 
<informalexample><programlisting>
165
 
     style "FooBar" { foo_content bar_content }
166
 
     class "X" style "FooBar"
167
 
</programlisting></informalexample>
168
 
  </para></listitem>
169
 
 
170
 
  <listitem><para>
171
 
  Use of wildcards should be avoided, this can reduce the individual RC style
172
 
  match to a single integer comparison in most cases.
173
 
  </para></listitem>
174
 
 
175
 
  <listitem><para>
176
 
  To avoid complex recursive matching, specification of full class names
177
 
  (for <literal>class</literal> matches) or full path names (for
178
 
  <literal>widget</literal> and <literal>widget_class</literal> matches)
179
 
  is to be preferred over shortened names
180
 
  containing <literal>"*"</literal> or <literal>"?"</literal>.
181
 
  </para></listitem>
182
 
 
183
 
  <listitem><para>
184
 
  If at all necessary, wildcards should only be used at the tail or head
185
 
  of a pattern. This reduces the match complexity to a string comparison
186
 
  per RC style.
187
 
  </para></listitem>
188
 
 
189
 
  <listitem><para>
190
 
  When using wildcards, use of <literal>"?"</literal> should be preferred
191
 
  over <literal>"*"</literal>. This can reduce the matching complexity from
192
 
  O(n^2) to O(n). For example <literal>"Gtk*Box"</literal> can be turned into
193
 
  <literal>"Gtk?Box"</literal> and will still match #GtkHBox and #GtkVBox.
194
 
  </para></listitem>
195
 
 
196
 
  <listitem><para>
197
 
  The use of <literal>"*"</literal> wildcards should be restricted as much
198
 
  as possible, because matching <literal>"A*B*C*RestString"</literal> can
199
 
  result in matching complexities of O(n^2) worst case.
200
 
  </para></listitem>
201
 
</orderedlist>
202
 
 
203
 
</para>
204
 
</refsect2>
205
 
 
206
 
<refsect2><title>Toplevel declarations</title>
207
 
<para>
208
 
An RC file is a text file which is composed of a sequence
209
 
of declarations. <literal>'#'</literal> characters delimit comments and
210
 
the portion of a line after a <literal>'#'</literal> is ignored when parsing
211
 
an RC file.
212
 
</para>
213
 
 
214
 
<para>
215
 
The possible toplevel declarations are:
216
 
 
217
 
<variablelist>
218
 
  <varlistentry>
219
 
    <term><literal>binding <replaceable>name</replaceable>
220
 
     { ... }</literal></term>
221
 
    <listitem>
222
 
      <para>Declares a binding set.</para>
223
 
    </listitem>
224
 
  </varlistentry>
225
 
 
226
 
  <varlistentry>
227
 
    <term><literal>class <replaceable>pattern</replaceable> 
228
 
          [ style | binding ][ : <replaceable>priority</replaceable> ]
229
 
          <replaceable>name</replaceable></literal></term>
230
 
    <listitem>
231
 
     <para>Specifies a style or binding set for a particular
232
 
     branch of the inheritance hierarchy.</para>
233
 
    </listitem>
234
 
  </varlistentry>
235
 
 
236
 
  <varlistentry>
237
 
    <term><literal>include <replaceable>filename</replaceable></literal></term>
238
 
    <listitem>
239
 
      <para>Parses another file at this point. If
240
 
        <replaceable>filename</replaceable> is not an absolute filename, 
241
 
        it is searched in the directories of the currently open RC files.
242
 
      </para>
243
 
      <para>GTK+ also tries to load a 
244
 
        <link linkend="locale-specific-rc">locale-specific variant</link> of
245
 
        the included file.
246
 
       </para>
247
 
    </listitem>
248
 
  </varlistentry>
249
 
 
250
 
  <varlistentry>
251
 
    <term><literal>module_path <replaceable>path</replaceable></literal></term>
252
 
    <listitem>
253
 
      <para>Sets a path (a list of directories separated
254
 
      by colons) that will be searched for theme engines referenced in
255
 
      RC files.</para>
256
 
    </listitem>
257
 
  </varlistentry>
258
 
 
259
 
  <varlistentry>
260
 
    <term><literal>pixmap_path <replaceable>path</replaceable></literal></term>
261
 
    <listitem>
262
 
      <para>Sets a path (a list of directories separated
263
 
      by colons) that will be searched for pixmaps referenced in
264
 
      RC files.</para>
265
 
    </listitem>
266
 
  </varlistentry>
267
 
 
268
 
  <varlistentry>
269
 
    <term><literal>im_module_file <replaceable>pathname</replaceable></literal></term>
270
 
    <listitem>
271
 
      <para>Sets the pathname for the IM modules file. Setting this from RC files
272
 
      is deprecated; you should use the environment variable <envar>GTK_IM_MODULE_FILE</envar>
273
 
      instead.</para>
274
 
    </listitem>
275
 
  </varlistentry>
276
 
 
277
 
  <varlistentry>
278
 
    <term><literal>style <replaceable>name</replaceable> [ =
279
 
    <replaceable>parent</replaceable> ] { ... }</literal></term>
280
 
    <listitem>
281
 
      <para>Declares a style.</para>
282
 
    </listitem>
283
 
  </varlistentry>
284
 
 
285
 
  <varlistentry>
286
 
    <term><literal>widget <replaceable>pattern</replaceable> 
287
 
          [ style | binding ][ : <replaceable>priority</replaceable> ]
288
 
          <replaceable>name</replaceable></literal></term>
289
 
    <listitem>
290
 
     <para>Specifies a style or binding set for a particular
291
 
     group of widgets by matching on the widget pathname.</para>
292
 
    </listitem>
293
 
  </varlistentry>
294
 
 
295
 
  <varlistentry>
296
 
    <term><literal>widget_class <replaceable>pattern</replaceable> 
297
 
          [ style | binding ][ : <replaceable>priority</replaceable> ]
298
 
          <replaceable>name</replaceable></literal></term>
299
 
    <listitem>
300
 
     <para>Specifies a style or binding set for a particular
301
 
     group of widgets by matching on the class pathname.</para>
302
 
    </listitem>
303
 
  </varlistentry>
304
 
 
305
 
  <varlistentry>
306
 
    <term><replaceable>setting</replaceable> = <replaceable>value</replaceable></term>
307
 
    <listitem>
308
 
      <para>Specifies a value for a <link linkend="GtkSettings">setting</link>.
309
 
        Note that settings in RC files are overwritten by system-wide settings 
310
 
        (which are managed by an XSettings manager on X11).</para>
311
 
    </listitem>
312
 
  </varlistentry>
313
 
</variablelist>
314
 
</para>
315
 
</refsect2>
316
 
 
317
 
<refsect2><title>Styles</title>
318
 
<para>
319
 
A RC style is specified by a <literal>style</literal> 
320
 
declaration in a RC file, and then bound to widgets
321
 
with a <literal>widget</literal>, <literal>widget_class</literal>,
322
 
or <literal>class</literal> declaration. All styles
323
 
applying to a particular widget are composited together
324
 
with <literal>widget</literal> declarations overriding
325
 
<literal>widget_class</literal> declarations which, in
326
 
turn, override <literal>class</literal> declarations.
327
 
Within each type of declaration, later declarations override
328
 
earlier ones.
329
 
</para>
330
 
 
331
 
<para>
332
 
Within a <literal>style</literal> declaration, the possible
333
 
elements are:
334
 
 
335
 
<variablelist>
336
 
  <varlistentry>
337
 
    <term><literal>bg[<replaceable>state</replaceable>] =
338
 
      <replaceable>color</replaceable></literal></term>
339
 
     <listitem>
340
 
       <para>
341
 
         Sets the color used for the background of most widgets.
342
 
       </para>
343
 
     </listitem>
344
 
  </varlistentry>
345
 
  <varlistentry>
346
 
    <term><literal>fg[<replaceable>state</replaceable>] =
347
 
      <replaceable>color</replaceable></literal></term>
348
 
     <listitem>
349
 
       <para>
350
 
         Sets the color used for the foreground of most widgets.
351
 
       </para>
352
 
     </listitem>
353
 
  </varlistentry>
354
 
  <varlistentry>
355
 
    <term><literal>base[<replaceable>state</replaceable>] =
356
 
      <replaceable>color</replaceable></literal></term>
357
 
     <listitem>
358
 
       <para>
359
 
         Sets the color used for the background of widgets displaying
360
 
         editable text. This color is used for the background
361
 
         of, among others, #GtkText, #GtkEntry, #GtkList, and #GtkCList.
362
 
       </para>
363
 
     </listitem>
364
 
  </varlistentry>
365
 
  <varlistentry>
366
 
    <term><literal>text[<replaceable>state</replaceable>] =
367
 
      <replaceable>color</replaceable></literal></term>
368
 
     <listitem>
369
 
       <para>
370
 
         Sets the color used for foreground of widgets using
371
 
         <literal>base</literal> for the background color.
372
 
       </para>
373
 
     </listitem>
374
 
  </varlistentry>
375
 
  <varlistentry>
376
 
    <term><literal>xthickness =
377
 
      <replaceable>number</replaceable></literal></term>
378
 
     <listitem>
379
 
       <para>
380
 
         Sets the xthickness, which is used for various horizontal padding
381
 
         values in GTK+.
382
 
       </para>
383
 
     </listitem>
384
 
  </varlistentry>
385
 
  <varlistentry>
386
 
    <term><literal>ythickness =
387
 
      <replaceable>number</replaceable></literal></term>
388
 
     <listitem>
389
 
       <para>
390
 
         Sets the ythickness, which is used for various vertical padding
391
 
         values in GTK+.
392
 
       </para>
393
 
     </listitem>
394
 
  </varlistentry>
395
 
 
396
 
  <varlistentry>
397
 
    <term><literal>bg_pixmap[<replaceable>state</replaceable>] =
398
 
      <replaceable>pixmap</replaceable></literal></term>
399
 
     <listitem>
400
 
       <para>
401
 
         Sets a background pixmap to be used in place of
402
 
         the <literal>bg</literal> color (or for #GtkText,
403
 
         in place of the <literal>base</literal> color. The special
404
 
         value <literal>"&lt;parent&gt;"</literal> may be used to indicate that the widget should
405
 
         use the same background pixmap as its parent. The special value
406
 
         <literal>"&lt;none&gt;"</literal> may be used to indicate no background pixmap.
407
 
       </para>
408
 
     </listitem>
409
 
  </varlistentry>
410
 
  <varlistentry>
411
 
    <term><literal>font = <replaceable>font</replaceable></literal></term>
412
 
     <listitem>
413
 
       <para>
414
 
         Starting with GTK+ 2.0, the "font" and "fontset"
415
 
         declarations are ignored; use "font_name" declarations instead.
416
 
       </para>
417
 
     </listitem>
418
 
  </varlistentry>
419
 
  <varlistentry>
420
 
    <term><literal>fontset = <replaceable>font</replaceable></literal></term>
421
 
     <listitem>
422
 
       <para>
423
 
         Starting with GTK+ 2.0, the "font" and "fontset"
424
 
         declarations are ignored; use "font_name" declarations instead.
425
 
       </para>
426
 
     </listitem>
427
 
  </varlistentry>
428
 
  <varlistentry>
429
 
    <term><literal>font_name = <replaceable>font</replaceable></literal></term>
430
 
     <listitem>
431
 
       <para>
432
 
         Sets the font for a widget. <replaceable>font</replaceable> must be 
433
 
         a Pango font name, e.g. <literal>"Sans Italic 10"</literal>. 
434
 
         For details about Pango font names, see 
435
 
         pango_font_description_from_string().
436
 
       </para>
437
 
     </listitem>   
438
 
  </varlistentry>
439
 
  <varlistentry>
440
 
    <term><literal>stock[<replaceable>"stock-id"</replaceable>] = { <replaceable>icon source specifications</replaceable> }</literal></term>
441
 
     <listitem>
442
 
       <para>
443
 
        Defines the icon for a stock item.
444
 
       </para>
445
 
     </listitem>
446
 
  </varlistentry>
447
 
  <varlistentry>
448
 
    <term><literal>color[<replaceable>"color-name"</replaceable>] = <replaceable>color specification</replaceable></literal></term>
449
 
     <listitem>
450
 
       <para>
451
 
        Since 2.10, this element can be used to defines symbolic colors. See below for
452
 
        the syntax of color specifications. 
453
 
       </para>
454
 
     </listitem>
455
 
  </varlistentry>
456
 
  <varlistentry>
457
 
    <term><literal>engine <replaceable>"engine"</replaceable> { <replaceable>engine-specific
458
 
settings</replaceable> }</literal></term>
459
 
     <listitem>
460
 
       <para>
461
 
        Defines the engine to be used when drawing with this style.
462
 
       </para>
463
 
     </listitem>
464
 
  </varlistentry>
465
 
  <varlistentry>
466
 
    <term><literal><replaceable>class</replaceable>::<replaceable>property</replaceable> = <replaceable>value</replaceable></literal></term>
467
 
     <listitem>
468
 
       <para>
469
 
        Sets a <link linkend="style-properties">style property</link> for a widget class.
470
 
       </para>
471
 
     </listitem>
472
 
  </varlistentry>
473
 
</variablelist>
474
 
</para>
475
 
<para>
476
 
The colors and background pixmaps are specified as a function of the
477
 
state of the widget. The states are:
478
 
 
479
 
<variablelist>
480
 
  <varlistentry>
481
 
    <term><literal>NORMAL</literal></term>
482
 
    <listitem>
483
 
      <para>
484
 
        A color used for a widget in its normal state.
485
 
      </para>
486
 
    </listitem>
487
 
  </varlistentry>
488
 
  <varlistentry>
489
 
    <term><literal>ACTIVE</literal></term>
490
 
    <listitem>
491
 
      <para>
492
 
        A variant of the <literal>NORMAL</literal> color used when the
493
 
        widget is in the %GTK_STATE_ACTIVE state, and also for
494
 
        the trough of a ScrollBar, tabs of a NoteBook
495
 
        other than the current tab and similar areas.
496
 
        Frequently, this should be a darker variant
497
 
        of the <literal>NORMAL</literal> color.
498
 
      </para>
499
 
    </listitem>
500
 
  </varlistentry>
501
 
  <varlistentry>
502
 
    <term><literal>PRELIGHT</literal></term>
503
 
    <listitem>
504
 
      <para>
505
 
        A color used for widgets in the %GTK_STATE_PRELIGHT state. This
506
 
        state is the used for Buttons and MenuItems
507
 
        that have the mouse cursor over them, and for 
508
 
        their children.
509
 
      </para>
510
 
    </listitem>
511
 
  </varlistentry>
512
 
  <varlistentry>
513
 
    <term><literal>SELECTED</literal></term>
514
 
    <listitem>
515
 
      <para>
516
 
        A color used to highlight data selected by the user.
517
 
        for instance, the selected items in a list widget, and the
518
 
        selection in an editable widget.
519
 
      </para>
520
 
    </listitem>
521
 
  </varlistentry>
522
 
  <varlistentry>
523
 
    <term><literal>INSENSITIVE</literal></term>
524
 
    <listitem>
525
 
      <para>
526
 
        A color used for the background of widgets that have
527
 
        been set insensitive with gtk_widget_set_sensitive().
528
 
      </para>
529
 
    </listitem>
530
 
  </varlistentry>
531
 
</variablelist>
532
 
</para>
533
 
 
534
 
<para><anchor id="color-format"/>
535
 
Colors can be specified as a string containing a color name (GTK+ knows
536
 
all names from the X color database <filename>/usr/lib/X11/rgb.txt</filename>),  
537
 
in one of the hexadecimal forms <literal>&num;rrrrggggbbbb</literal>,
538
 
<literal>&num;rrrgggbbb</literal>, <literal>&num;rrggbb</literal>,
539
 
or <literal>&num;rgb</literal>, where <literal>r</literal>,
540
 
<literal>g</literal> and <literal>b</literal> are
541
 
hex digits, or they can be specified as a triplet 
542
 
<literal>{ <replaceable>r</replaceable>, <replaceable>g</replaceable>,
543
 
<replaceable>b</replaceable>}</literal>, where <literal>r</literal>,
544
 
<literal>g</literal> and <literal>b</literal> are either integers in 
545
 
the range 0-65535 or floats in the range 0.0-1.0.
546
 
</para>
547
 
<para>
548
 
Since 2.10, colors can also be specified by refering to a symbolic color, as
549
 
follows: <literal>@<!-- -->color-name</literal>, or by using expressions to combine
550
 
colors. The following expressions are currently supported:
551
 
  <variablelist>
552
 
    <varlistentry>
553
 
      <term>mix (<replaceable>factor</replaceable>, <replaceable>color1</replaceable>, <replaceable>color2</replaceable>)</term>
554
 
      <listitem><para>
555
 
        Computes a new color by mixing <replaceable>color1</replaceable> and 
556
 
        <replaceable>color2</replaceable>. The <replaceable>factor</replaceable> 
557
 
        determines how close the new color is to <replaceable>color1</replaceable>. 
558
 
        A factor of 1.0 gives pure <replaceable>color1</replaceable>, a factor of 
559
 
        0.0 gives pure <replaceable>color2</replaceable>.  
560
 
      </para></listitem>        
561
 
    </varlistentry>
562
 
 
563
 
    <varlistentry>
564
 
      <term>shade (<replaceable>factor</replaceable>, <replaceable>color</replaceable>)</term>
565
 
      <listitem><para>
566
 
        Computes a lighter or darker variant of <replaceable>color</replaceable>. 
567
 
        A <replaceable>factor</replaceable> of 1.0 leaves the color unchanged, smaller 
568
 
        factors yield darker colors, larger factors yield lighter colors.
569
 
      </para></listitem>
570
 
    </varlistentry>
571
 
 
572
 
    <varlistentry>
573
 
      <term>lighter (<replaceable>color</replaceable>)</term>
574
 
      <listitem><para>
575
 
        This is an abbreviation for 
576
 
        <literal>shade (1.3, <replaceable>color</replaceable>)</literal>.
577
 
      </para></listitem>
578
 
    </varlistentry>
579
 
 
580
 
    <varlistentry>
581
 
      <term>darker (<replaceable>color</replaceable>)</term>
582
 
      <listitem><para>
583
 
        This is an abbreviation for 
584
 
        <literal>shade (0.7, <replaceable>color</replaceable>)</literal>.
585
 
      </para></listitem>
586
 
    </varlistentry>
587
 
  </variablelist>      
588
 
</para>
589
 
<para>
590
 
Here are some examples of color expressions:
591
 
<informalexample><programlisting>  
592
 
 mix (0.5, "red", "blue")
593
 
 shade (1.5, mix (0.3, "&num;0abbc0", { 0.3, 0.5, 0.9 }))
594
 
 lighter (@<!-- -->foreground)
595
 
</programlisting></informalexample>
596
 
</para>
597
 
 
598
 
<para>
599
 
In a <literal>stock</literal> definition, icon sources are specified as a
600
 
4-tuple of image filename or icon name, text direction, widget state, and size, in that
601
 
order.  Each icon source specifies an image filename or icon name to use with a given
602
 
direction, state, and size. Filenames are specified as a string such
603
 
as <literal>"itemltr.png"</literal>, while icon names (looked up
604
 
in the current icon theme), are specified with a leading
605
 
<literal>@</literal>, such as <literal>@"item-ltr"</literal>.
606
 
The <literal>*</literal> character can be used as a
607
 
wildcard, and if direction/state/size are omitted they default to
608
 
<literal>*</literal>. So for example, the following specifies different icons to
609
 
use for left-to-right and right-to-left languages:
610
 
<informalexample><programlisting>
611
 
stock["my-stock-item"] = 
612
 
{
613
 
  { "itemltr.png", LTR, *, * },
614
 
  { "itemrtl.png", RTL, *, * }
615
 
}
616
 
</programlisting></informalexample>
617
 
This could be abbreviated as follows:
618
 
<informalexample><programlisting>
619
 
stock["my-stock-item"] = 
620
 
{
621
 
  { "itemltr.png", LTR },
622
 
  { "itemrtl.png", RTL }
623
 
}
624
 
</programlisting></informalexample>
625
 
</para>
626
 
 
627
 
<para>
628
 
You can specify custom icons for specific sizes, as follows:
629
 
<informalexample><programlisting>
630
 
stock["my-stock-item"] = 
631
 
{
632
 
  { "itemmenusize.png", *, *, "gtk-menu" },
633
 
  { "itemtoolbarsize.png", *, *, "gtk-large-toolbar" }
634
 
  { "itemgeneric.png" } /* implicit *, *, * as a fallback */
635
 
}
636
 
</programlisting></informalexample>
637
 
The sizes that come with GTK+ itself are <literal>"gtk-menu"</literal>,
638
 
<literal>"gtk-small-toolbar"</literal>, <literal>"gtk-large-toolbar"</literal>,
639
 
<literal>"gtk-button"</literal>, <literal>"gtk-dialog"</literal>. Applications
640
 
can define other sizes.
641
 
</para>
642
 
 
643
 
<para>
644
 
It's also possible to use custom icons for a given state, for example:
645
 
<informalexample><programlisting>
646
 
stock["my-stock-item"] = 
647
 
{
648
 
  { "itemprelight.png", *, PRELIGHT },
649
 
  { "iteminsensitive.png", *, INSENSITIVE }, 
650
 
  { "itemgeneric.png" } /* implicit *, *, * as a fallback */
651
 
}
652
 
</programlisting></informalexample>
653
 
</para>
654
 
 
655
 
<para>
656
 
When selecting an icon source to use, GTK+ will consider text direction most
657
 
important, state second, and size third. It will select the best match based on
658
 
those criteria. If an attribute matches exactly (e.g. you specified
659
 
<literal>PRELIGHT</literal> or specified the size), GTK+ won't modify the image;
660
 
if the attribute matches with a wildcard, GTK+ will scale or modify the image to
661
 
match the state and size the user requested.
662
 
</para>
663
 
 
664
 
</refsect2>
665
 
 
666
 
<refsect2><title>Key bindings</title>
667
 
<para>
668
 
Key bindings allow the user to specify actions to be 
669
 
taken on particular key presses. The form of a binding
670
 
set declaration is:
671
 
</para>
672
 
 
673
 
<informalexample><programlisting>
674
 
binding <replaceable>name</replaceable> {
675
 
  bind <replaceable>key</replaceable> { 
676
 
    <replaceable>signalname</replaceable> (<replaceable>param</replaceable>, ...)
677
 
    ...
678
 
  }
679
 
  ...
680
 
}
681
 
</programlisting></informalexample>
682
 
 
683
 
<para>
684
 
<replaceable>key</replaceable> is a string consisting of a 
685
 
series of modifiers followed by the name of a key. The
686
 
modifiers can be:
687
 
<simplelist>
688
 
<member><literal>&lt;alt&gt;</literal></member>
689
 
<member><literal>&lt;ctl&gt;</literal></member>
690
 
<member><literal>&lt;control&gt;</literal></member>
691
 
<member><literal>&lt;meta&gt;</literal></member>
692
 
<member><literal>&lt;hyper&gt;</literal></member>
693
 
<member><literal>&lt;super&gt;</literal></member>
694
 
<member><literal>&lt;mod1&gt;</literal></member>
695
 
<member><literal>&lt;mod2&gt;</literal></member>
696
 
<member><literal>&lt;mod3&gt;</literal></member>
697
 
<member><literal>&lt;mod4&gt;</literal></member>
698
 
<member><literal>&lt;mod5&gt;</literal></member>
699
 
<member><literal>&lt;release&gt;</literal></member>
700
 
<member><literal>&lt;shft&gt;</literal></member>
701
 
<member><literal>&lt;shift&gt;</literal></member>
702
 
</simplelist>
703
 
<literal>&lt;shft&gt;</literal> is an alias for 
704
 
<literal>&lt;shift&gt;</literal>,
705
 
<literal>&lt;ctl&gt;</literal> is an alias for 
706
 
<literal>&lt;control&gt;</literal>,
707
 
 and 
708
 
<literal>&lt;alt&gt;</literal> is an alias for
709
 
<literal>&lt;mod1&gt;</literal>.
710
 
</para>
711
 
 
712
 
<para>
713
 
The action that is bound to the key is a sequence
714
 
of signal names (strings) followed by parameters for 
715
 
each signal. The signals must be action signals.
716
 
(See g_signal_new()). Each parameter can be
717
 
a float, integer, string, or unquoted string
718
 
representing an enumeration value. The types of
719
 
the parameters specified must match the types of the 
720
 
parameters of the signal.
721
 
</para>
722
 
 
723
 
<para>
724
 
Binding sets are connected to widgets in the same manner as styles, 
725
 
with one difference: Binding sets override other binding sets first 
726
 
by pattern type, then by priority and then by order of specification.
727
 
The priorities that can be specified and their default values are the 
728
 
same as for styles.
729
 
</para>
730
 
</refsect2>
731
 
 
732
 
<!-- ##### SECTION See_Also ##### -->
733
 
<para>
734
 
 
735
 
</para>
736
 
 
737
 
<!-- ##### SECTION Stability_Level ##### -->
738
 
 
739
 
 
740
 
<!-- ##### SECTION Image ##### -->
741
 
 
742
 
 
743
 
<!-- ##### STRUCT GtkRcStyle ##### -->
744
 
<para>
745
 
The #GtkRcStyle structure is used to represent a set
746
 
of information about the appearance of a widget.
747
 
This can later be composited together with other
748
 
#GtkRcStyle structures to form a #GtkStyle.
749
 
</para>
750
 
 
751
 
@name: 
752
 
@bg_pixmap_name: 
753
 
@font_desc: 
754
 
@color_flags: 
755
 
@fg: 
756
 
@bg: 
757
 
@text: 
758
 
@base: 
759
 
@xthickness: 
760
 
@ythickness: 
761
 
 
762
 
<!-- ##### ENUM GtkRcFlags ##### -->
763
 
<para>
764
 
The #GtkRcFlags enumeration is used as a bitmask
765
 
to specify which fields of a #GtkRcStyle have been
766
 
set for each state.
767
 
</para>
768
 
 
769
 
@GTK_RC_FG: If present, the foreground color has been set for this state.
770
 
@GTK_RC_BG: If present, the background color has been set for this state.
771
 
@GTK_RC_TEXT: If present, the text color has been set for this state.
772
 
@GTK_RC_BASE: If present, the base color has been set for this state.
773
 
 
774
 
<!-- ##### ENUM GtkRcTokenType ##### -->
775
 
<para>
776
 
The #GtkRcTokenType enumeration represents the tokens
777
 
in the RC file. It is exposed so that theme engines
778
 
can reuse these tokens when parsing the theme-engine
779
 
specific portions of a RC file.
780
 
</para>
781
 
 
782
 
@GTK_RC_TOKEN_INVALID: 
783
 
@GTK_RC_TOKEN_INCLUDE: 
784
 
@GTK_RC_TOKEN_NORMAL: 
785
 
@GTK_RC_TOKEN_ACTIVE: 
786
 
@GTK_RC_TOKEN_PRELIGHT: 
787
 
@GTK_RC_TOKEN_SELECTED: 
788
 
@GTK_RC_TOKEN_INSENSITIVE: 
789
 
@GTK_RC_TOKEN_FG: 
790
 
@GTK_RC_TOKEN_BG: 
791
 
@GTK_RC_TOKEN_TEXT: 
792
 
@GTK_RC_TOKEN_BASE: 
793
 
@GTK_RC_TOKEN_XTHICKNESS: 
794
 
@GTK_RC_TOKEN_YTHICKNESS: 
795
 
@GTK_RC_TOKEN_FONT: 
796
 
@GTK_RC_TOKEN_FONTSET: 
797
 
@GTK_RC_TOKEN_FONT_NAME: 
798
 
@GTK_RC_TOKEN_BG_PIXMAP: 
799
 
@GTK_RC_TOKEN_PIXMAP_PATH: 
800
 
@GTK_RC_TOKEN_STYLE: 
801
 
@GTK_RC_TOKEN_BINDING: 
802
 
@GTK_RC_TOKEN_BIND: 
803
 
@GTK_RC_TOKEN_WIDGET: 
804
 
@GTK_RC_TOKEN_WIDGET_CLASS: 
805
 
@GTK_RC_TOKEN_CLASS: 
806
 
@GTK_RC_TOKEN_LOWEST: 
807
 
@GTK_RC_TOKEN_GTK: 
808
 
@GTK_RC_TOKEN_APPLICATION: 
809
 
@GTK_RC_TOKEN_THEME: 
810
 
@GTK_RC_TOKEN_RC: 
811
 
@GTK_RC_TOKEN_HIGHEST: 
812
 
@GTK_RC_TOKEN_ENGINE: 
813
 
@GTK_RC_TOKEN_MODULE_PATH: 
814
 
@GTK_RC_TOKEN_IM_MODULE_PATH: 
815
 
@GTK_RC_TOKEN_IM_MODULE_FILE: 
816
 
@GTK_RC_TOKEN_STOCK: 
817
 
@GTK_RC_TOKEN_LTR: 
818
 
@GTK_RC_TOKEN_RTL: 
819
 
@GTK_RC_TOKEN_COLOR: 
820
 
@GTK_RC_TOKEN_UNBIND: 
821
 
@GTK_RC_TOKEN_LAST: 
822
 
 
823
 
<!-- ##### FUNCTION gtk_rc_scanner_new ##### -->
824
 
<para>
825
 
 
826
 
</para>
827
 
 
828
 
@void: 
829
 
@Returns: 
830
 
 
831
 
 
832
 
<!-- ##### FUNCTION gtk_rc_get_style ##### -->
833
 
<para>
834
 
</para>
835
 
 
836
 
@widget: 
837
 
@Returns: 
838
 
 
839
 
 
840
 
<!-- ##### FUNCTION gtk_rc_get_style_by_paths ##### -->
841
 
<para>
842
 
 
843
 
</para>
844
 
 
845
 
@settings: 
846
 
@widget_path: 
847
 
@class_path: 
848
 
@type: 
849
 
@Returns: 
850
 
 
851
 
 
852
 
<!-- ##### FUNCTION gtk_rc_add_widget_name_style ##### -->
853
 
<para>
854
 
Adds a #GtkRcStyle that will be looked up by a match against
855
 
the widget's pathname. This is equivalent to a:
856
 
 <literal>widget PATTERN style STYLE</literal>
857
 
statement in a RC file.
858
 
</para>
859
 
 
860
 
@rc_style: the #GtkRcStyle to use for widgets matching @pattern
861
 
@pattern: the pattern
862
 
@Deprecated: Use gtk_rc_parse_string() with a suitable string instead.
863
 
 
864
 
 
865
 
<!-- ##### FUNCTION gtk_rc_add_widget_class_style ##### -->
866
 
<para>
867
 
Adds a #GtkRcStyle that will be looked up by a match against
868
 
the widget's class pathname. This is equivalent to a:
869
 
<literal>widget_class PATTERN style STYLE</literal>
870
 
statement in a RC file.
871
 
</para>
872
 
 
873
 
@rc_style: the #GtkRcStyle to use for widgets matching @pattern
874
 
@pattern: the pattern
875
 
@Deprecated: Use gtk_rc_parse_string() with a suitable string instead.
876
 
 
877
 
 
878
 
<!-- ##### FUNCTION gtk_rc_add_class_style ##### -->
879
 
<para>
880
 
Adds a #GtkRcStyle that will be looked up by a matching against
881
 
the class hierarchy of the widget. This is equivalent to a:
882
 
<literal>class PATTERN style STYLE</literal>
883
 
statement in a RC file.
884
 
</para>
885
 
 
886
 
@rc_style: the #GtkRcStyle to use for widgets deriving from @pattern
887
 
@pattern: the pattern
888
 
@Deprecated: Use gtk_rc_parse_string() with a suitable string instead.
889
 
 
890
 
 
891
 
<!-- ##### MACRO gtk_rc_parse ##### -->
892
 
<para>
893
 
Parses a given resource file.
894
 
</para>
895
 
 
896
 
<!-- # Unused Parameters # -->
897
 
@filename: the filename of a file to parse. If @filename is not absolute, it
898
 
  is searched in the current directory.
899
 
 
900
 
 
901
 
<!-- ##### FUNCTION gtk_rc_parse_string ##### -->
902
 
<para>
903
 
Parses resource information directly from a string.
904
 
</para>
905
 
 
906
 
@rc_string: a string to parse.
907
 
 
908
 
 
909
 
<!-- ##### FUNCTION gtk_rc_reparse_all ##### -->
910
 
<para>
911
 
</para>
912
 
 
913
 
@void: 
914
 
@Returns: 
915
 
 
916
 
 
917
 
<!-- ##### FUNCTION gtk_rc_reparse_all_for_settings ##### -->
918
 
<para>
919
 
 
920
 
</para>
921
 
 
922
 
@settings: 
923
 
@force_load: 
924
 
@Returns: 
925
 
 
926
 
 
927
 
<!-- ##### FUNCTION gtk_rc_reset_styles ##### -->
928
 
<para>
929
 
 
930
 
</para>
931
 
 
932
 
@settings: 
933
 
 
934
 
 
935
 
<!-- ##### MACRO gtk_rc_add_default_file ##### -->
936
 
<para>
937
 
</para>
938
 
 
939
 
 
940
 
 
941
 
<!-- ##### FUNCTION gtk_rc_get_default_files ##### -->
942
 
<para>
943
 
</para>
944
 
 
945
 
@void: 
946
 
@Returns: 
947
 
 
948
 
 
949
 
<!-- ##### MACRO gtk_rc_set_default_files ##### -->
950
 
<para>
951
 
</para>
952
 
 
953
 
 
954
 
 
955
 
<!-- ##### FUNCTION gtk_rc_parse_color ##### -->
956
 
<para>
957
 
 
958
 
</para>
959
 
 
960
 
@scanner: 
961
 
@color: 
962
 
@Returns: 
963
 
 
964
 
 
965
 
<!-- ##### FUNCTION gtk_rc_parse_color_full ##### -->
966
 
<para>
967
 
 
968
 
</para>
969
 
 
970
 
@scanner: 
971
 
@style: 
972
 
@color: 
973
 
@Returns: 
974
 
 
975
 
 
976
 
<!-- ##### FUNCTION gtk_rc_parse_state ##### -->
977
 
<para>
978
 
Parses a #GtkStateType variable from the format expected
979
 
in a RC file.
980
 
</para>
981
 
 
982
 
@scanner: a #GtkScanner (must be initialized for parsing an RC file)
983
 
@state: A pointer to a #GtkStateType variable in which to
984
 
store the result.
985
 
@Returns: %G_TOKEN_NONE if parsing succeeded, otherwise the token
986
 
that was expected but not found.
987
 
 
988
 
 
989
 
<!-- ##### FUNCTION gtk_rc_parse_priority ##### -->
990
 
<para>
991
 
Parses a #GtkPathPriorityType variable from the format expected
992
 
in a RC file.
993
 
</para>
994
 
 
995
 
@scanner: a #GtkScanner (must be initialized for parsing an RC file)
996
 
@priority: A pointer to #GtkPathPriorityType variable in which
997
 
to store the result.
998
 
@Returns: %G_TOKEN_NONE if parsing succeeded, otherwise the token
999
 
that was expected but not found.
1000
 
 
1001
 
 
1002
 
<!-- ##### FUNCTION gtk_rc_find_module_in_path ##### -->
1003
 
<para>
1004
 
</para>
1005
 
 
1006
 
@module_file: The name of the module to search for.
1007
 
@Returns: 
1008
 
 
1009
 
 
1010
 
<!-- ##### FUNCTION gtk_rc_find_pixmap_in_path ##### -->
1011
 
<para>
1012
 
</para>
1013
 
 
1014
 
@settings: 
1015
 
@scanner: a #GtkScanner. Used for printing out warning messages
1016
 
if the file is not found.
1017
 
@pixmap_file: The name of the file to search for.
1018
 
@Returns: The filename, if found (must be freed with g_free()),
1019
 
otherwise %NULL.
1020
 
 
1021
 
 
1022
 
<!-- ##### FUNCTION gtk_rc_get_module_dir ##### -->
1023
 
<para>
1024
 
</para>
1025
 
 
1026
 
@void: 
1027
 
@Returns: 
1028
 
 
1029
 
 
1030
 
<!-- ##### FUNCTION gtk_rc_get_im_module_path ##### -->
1031
 
<para>
1032
 
 
1033
 
</para>
1034
 
 
1035
 
@void: 
1036
 
@Returns: 
1037
 
 
1038
 
 
1039
 
<!-- ##### FUNCTION gtk_rc_get_im_module_file ##### -->
1040
 
<para>
1041
 
 
1042
 
</para>
1043
 
 
1044
 
@void: 
1045
 
@Returns: 
1046
 
 
1047
 
 
1048
 
<!-- ##### FUNCTION gtk_rc_get_theme_dir ##### -->
1049
 
<para>
1050
 
Returns the standard directory in which themes should
1051
 
be installed. (GTK+ does not actually use this directory
1052
 
itself.)
1053
 
</para>
1054
 
 
1055
 
@void: 
1056
 
@Returns: The directory (must be freed with g_free()).
1057
 
 
1058
 
 
1059
 
<!-- ##### FUNCTION gtk_rc_style_new ##### -->
1060
 
<para>
1061
 
Creates a new #GtkRcStyle with no fields set and
1062
 
a reference count of 1.
1063
 
</para>
1064
 
 
1065
 
@void: 
1066
 
@Returns: the newly-created #GtkRcStyle
1067
 
 
1068
 
 
1069
 
<!-- ##### FUNCTION gtk_rc_style_copy ##### -->
1070
 
<para>
1071
 
 
1072
 
</para>
1073
 
 
1074
 
@orig: 
1075
 
@Returns: 
1076
 
 
1077
 
 
1078
 
<!-- ##### FUNCTION gtk_rc_style_ref ##### -->
1079
 
<para>
1080
 
Increments the reference count of a #GtkRcStyle.
1081
 
</para>
1082
 
 
1083
 
@rc_style: a #GtkRcStyle
1084
 
@Deprecated: Use g_object_ref() instead
1085
 
 
1086
 
 
1087
 
<!-- ##### FUNCTION gtk_rc_style_unref ##### -->
1088
 
<para>
1089
 
Decrements the reference count of a #GtkRcStyle and
1090
 
frees if the result is 0.
1091
 
</para>
1092
 
 
1093
 
@rc_style: a #GtkRcStyle
1094
 
@Deprecated: Use g_object_unref() instead
1095
 
 
1096