1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1987, 1993, 1994, 1995, 1997, 2001, 2002, 2003,
3 @c 2004, 2005 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node X Resources, Antinews, Emacs Invocation, Top
6 @appendix X Options and Resources
8 You can customize some X-related aspects of Emacs behavior using X
9 resources, as is usual for programs that use X. On MS-Windows, you
10 can customize some of the same aspects using the system registry.
11 @xref{MS-Windows Registry}.
13 When Emacs is built using an `X toolkit', such as Lucid or LessTif,
14 you need to use X resources to customize the appearance of the
15 widgets, including the menu-bar, scroll-bar, and dialog boxes. This
16 is because the libraries that implement these don't provide for
17 customization through Emacs. GTK+ widgets use a separate system of
18 `GTK resources', which we will also describe.
21 * Resources:: Using X resources with Emacs (in general).
22 * Table of Resources:: Table of specific X resources that affect Emacs.
23 * Face Resources:: X resources for customizing faces.
24 * Lucid Resources:: X resources for Lucid menus.
25 * LessTif Resources:: X resources for LessTif and Motif menus.
26 * GTK resources:: Resources for GTK widgets.
30 @appendixsec X Resources
33 @cindex @file{~/.Xdefaults} file
34 @cindex @file{~/.Xresources} file
36 Programs running under the X Window System organize their user
37 options under a hierarchy of classes and resources. You can specify
38 default values for these options in your X resources file, usually
39 named @file{~/.Xdefaults} or @file{~/.Xresources}.
40 If changes in @file{~/.Xdefaults} do not
41 take effect, it is because your X server stores its own list of
42 resources; to update them, use the shell command @command{xrdb}---for
43 instance, @samp{xrdb ~/.Xdefaults}.
45 Each line in the file specifies a value for one option or for a
46 collection of related options, for one program or for several programs
47 (optionally even for all programs).
49 @cindex Registry (MS-Windows)
50 MS-Windows systems don't support @file{~/.Xdefaults} files, but
51 Emacs compiled for Windows looks for X resources in the Windows
52 Registry, under the key @samp{HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs}
53 and then under the key @samp{HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs}.
54 The menu and scrollbars are native widgets on MS-Windows, so they are
55 only customizable via the system-wide settings in the Display Control
56 Panel. You can also set resources using the @samp{-xrm} command line
59 Programs define named resources with particular meanings. They also
60 define how to group resources into named classes. For instance, in
61 Emacs, the @samp{internalBorder} resource controls the width of the
62 internal border, and the @samp{borderWidth} resource controls the width
63 of the external border. Both of these resources are part of the
64 @samp{BorderWidth} class. Case distinctions are significant in these
67 Every resource definition is associated with a specific program
68 name---the name of the executable file that you ran. For Emacs, that
69 is normally @samp{emacs}. To specify a definition for all instances
70 of Emacs, regardless of their names, use @samp{Emacs}.
72 In @file{~/.Xdefaults}, you can specify a value for a single resource
73 on one line, like this:
80 Or you can use a class name to specify the same value for all resources
81 in that class. Here's an example:
87 If you specify a value for a class, it becomes the default for all
88 resources in that class. You can specify values for individual
89 resources as well; these override the class value, for those particular
90 resources. Thus, this example specifies 2 as the default width for all
91 borders, but overrides this value with 4 for the external border:
98 The order in which the lines appear in the file does not matter.
99 Also, command-line options always override the X resources file.
100 Here is a list of X command-line options and their corresponding
104 @item -name @var{name}
106 @itemx --name=@var{name}
107 @cindex resource name, command-line argument
108 Use @var{name} as the resource name (and the title) for the initial
109 Emacs frame. This option does not affect subsequent frames, but Lisp
110 programs can specify frame names when they create frames.
112 If you don't specify this option, the default is to use the Emacs
113 executable's name as the resource name.
115 @item -xrm @var{resource-values}
117 @itemx --xrm=@var{resource-values}
118 @cindex resource values, command-line argument
119 Specify X resource values for this Emacs job (see below).
122 For consistency, @samp{-name} also specifies the name to use for
123 other resource values that do not belong to any particular frame.
125 The resources that name Emacs invocations also belong to a class; its
126 name is @samp{Emacs}. If you write @samp{Emacs} instead of
127 @samp{emacs}, the resource applies to all frames in all Emacs jobs,
128 regardless of frame titles and regardless of the name of the executable
129 file. Here is an example:
136 You can specify a string of additional resource values for Emacs to
137 use with the command line option @samp{-xrm @var{resources}}. The text
138 @var{resources} should have the same format that you would use inside a file
139 of X resources. To include multiple resource specifications in
140 @var{resources}, put a newline between them, just as you would in a file.
141 You can also use @samp{#include "@var{filename}"} to include a file full
142 of resource specifications. Resource values specified with @samp{-xrm}
143 take precedence over all other resource specifications.
145 One way to experiment with the effect of different resource settings
146 is to use the @code{editres} program. Select @samp{Get Tree} from the
147 @samp{Commands} menu, then click on an Emacs frame. This will display
148 a tree showing the structure of X toolkit widgets used in an Emacs
149 frame. Select one of them, such as @samp{menubar}, then select
150 @samp{Show Resource Box} from the @samp{Commands} menu. This displays
151 a list of all the meaningful X resources and allows you to edit them.
152 Changes take effect immediately if you click on the @samp{Apply} button.
153 (See the @code{editres} man page for more details.)
155 @node Table of Resources
156 @appendixsec Table of X Resources for Emacs
158 This table lists the resource names that designate options for
159 Emacs, not counting those for the appearance of the menu bar, each
160 with the class that it belongs to:
163 @item @code{background} (class @code{Background})
164 Background color name.
166 @item @code{bitmapIcon} (class @code{BitmapIcon})
167 Use a bitmap icon (a picture of a gnu) if @samp{on}, let the window
168 manager choose an icon if @samp{off}.
170 @item @code{borderColor} (class @code{BorderColor})
171 Color name for the external border.
173 @item @code{borderWidth} (class @code{BorderWidth})
174 Width in pixels of the external border.
176 @item @code{cursorColor} (class @code{Foreground})
177 Color name for text cursor (point).
179 @item @code{cursorBlink} (class @code{CursorBlink})
180 Specifies whether to make the cursor blink. The default is @samp{on}. Use
181 @samp{off} or @samp{false} to turn cursor blinking off.
183 @item @code{font} (class @code{Font})
184 Font name for text (or fontset name, @pxref{Fontsets}).
186 @item @code{foreground} (class @code{Foreground})
189 @item @code{geometry} (class @code{Geometry})
190 Window size and position. Be careful not to specify this resource as
191 @samp{emacs*geometry}, because that may affect individual menus as well
192 as the Emacs frame itself.
194 If this resource specifies a position, that position applies only to the
195 initial Emacs frame (or, in the case of a resource for a specific frame
196 name, only that frame). However, the size, if specified here, applies to
199 @item @code{fullscreen} (class @code{Fullscreen})
200 The desired fullscreen size. The value can be one of @code{fullboth},
201 @code{fullwidth} or @code{fullheight}, which correspond to
202 the command-line options @samp{-fs}, @samp{-fw}, and @samp{-fh}
203 (@pxref{Window Size X}).
205 Note that this applies to all frames created, not just the initial
208 @item @code{iconName} (class @code{Title})
209 Name to display in the icon.
211 @item @code{internalBorder} (class @code{BorderWidth})
212 Width in pixels of the internal border.
214 @item @code{lineSpacing} (class @code{LineSpacing})
217 Additional space (@dfn{leading}) between lines, in pixels.
219 @item @code{menuBar} (class @code{MenuBar})
221 Give frames menu bars if @samp{on}; don't have menu bars if
222 @samp{off}. @xref{Lucid Resources}, and @ref{LessTif Resources}, for
223 how to control the appearance of the menu bar if you have one.
225 @item @code{minibuffer} (class @code{Minibuffer})
226 If @samp{none}, don't make a minibuffer in this frame.
227 It will use a separate minibuffer frame instead.
229 @item @code{paneFont} (class @code{Font})
230 @cindex font for menus
231 Font name for menu pane titles, in non-toolkit versions of Emacs.
233 @item @code{pointerColor} (class @code{Foreground})
234 Color of the mouse cursor.
236 @item @code{privateColormap} (class @code{PrivateColormap})
237 If @samp{on}, use a private color map, in the case where the ``default
238 visual'' of class PseudoColor and Emacs is using it.
240 @item @code{reverseVideo} (class @code{ReverseVideo})
241 Switch foreground and background default colors if @samp{on}, use colors as
242 specified if @samp{off}.
244 @item @code{screenGamma} (class @code{ScreenGamma})
245 @cindex gamma correction
246 Gamma correction for colors, equivalent to the frame parameter
249 @item @code{selectionFont} (class @code{SelectionFont})
250 Font name for pop-up menu items, in non-toolkit versions of Emacs. (For
251 toolkit versions, see @ref{Lucid Resources}, also see @ref{LessTif
254 @item @code{selectionTimeout} (class @code{SelectionTimeout})
255 Number of milliseconds to wait for a selection reply.
256 If the selection owner doesn't reply in this time, we give up.
257 A value of 0 means wait as long as necessary.
259 @item @code{synchronous} (class @code{Synchronous})
260 @cindex debugging X problems
261 @cindex synchronous X mode
262 Run Emacs in synchronous mode if @samp{on}. Synchronous mode is
263 useful for debugging X problems.
265 @item @code{title} (class @code{Title})
266 Name to display in the title bar of the initial Emacs frame.
268 @item @code{toolBar} (class @code{ToolBar})
270 Number of lines to reserve for the tool bar. A zero value suppresses
271 the tool bar. If the value is non-zero and
272 @code{auto-resize-tool-bars} is non-@code{nil}, the tool bar's size
273 will be changed automatically so that all tool bar items are visible.
275 @item @code{useXIM} (class @code{UseXIM})
277 @cindex X input methods
278 @cindex input methods, X
279 Turn off use of X input methods (XIM) if @samp{false} or @samp{off}.
280 This is only relevant if your Emacs is actually built with XIM
281 support. It is potentially useful to turn off XIM for efficiency,
282 especially slow X client/server links.
284 @item @code{verticalScrollBars} (class @code{ScrollBars})
285 Give frames scroll bars if @samp{on}; don't have scroll bars if
288 @item @code{visualClass} (class @code{VisualClass})
289 Specify the ``visual'' that X should use. This tells X how to handle
292 The value should start with one of @samp{TrueColor},
293 @samp{PseudoColor}, @samp{DirectColor}, @samp{StaticColor},
294 @samp{GrayScale}, and @samp{StaticGray}, followed by
295 @samp{-@var{depth}}, where @var{depth} is the number of color planes.
296 Most terminals only allow a few ``visuals,'' and the @samp{dpyinfo}
297 program outputs information saying which ones.
301 @appendixsec X Resources for Faces
303 You can also use resources to customize the appearance of particular
304 faces (@pxref{Faces}):
307 @item @var{face}.attributeFont
308 Font for face @var{face}.
309 @item @var{face}.attributeForeground
310 Foreground color for face @var{face}.
311 @item @var{face}.attributeBackground
312 Background color for face @var{face}.
313 @item @var{face}.attributeUnderline
314 Underline flag for face @var{face}. Use @samp{on} or @samp{true} for
316 @item @var{face}.attributeFamily
317 Font family for face @var{face}.
318 @item @var{face}.attributeWidth
319 Relative proportional width of the font to use for face @var{face}.
320 It should be one of @code{ultra-condensed}, @code{extra-condensed},
321 @code{condensed}, @code{semi-condensed}, @code{normal},
322 @code{semi-expanded}, @code{expanded}, @code{extra-expanded}, or
323 @code{ultra-expanded}.
324 @item @var{face}.attributeHeight
325 Height of the font to use for face @var{face}: either an integer
326 specifying the height in units of 1/10@dmn{pt}, or a floating point
327 number that specifies a scale factor to scale the underlying face's
328 default font, or a function to be called with the default height which
329 will return a new height.
330 @item @var{face}.attributeWeight
331 A weight to use for the face @var{face}. It must be one of
332 @code{ultra-bold}, @code{extra-bold}, @code{bold},
333 @code{semi-bold}, @code{normal}, @code{semi-light}, @code{light},
334 @code{extra-light}, @code{ultra-light}.
335 @item @var{face}.attributeSlant
336 The slant to use for the font of face @var{face}. It must be one of
337 @code{italic}, @code{oblique}, @code{normal},
338 @code{reverse-italic}, or @code{reverse-oblique}.
339 @item @var{face}.attributeStrikeThrough
340 Whether the face @var{face} should be drawn with a line striking
341 through the characters.
342 @item @var{face}.attributeOverline
343 Whether the characters in the face @var{face} should be overlined.
344 @item @var{face}.attributeBox
345 Whether to draw a box around the characters in face @var{face}.
346 @item @var{face}.attributeInverse
347 Whether to display the characters in face @var{face} in inverse
349 @item @var{face}.attributeStipple
350 The name of a pixmap data file to use for the stipple pattern, or
351 @code{false} to not use stipple for the face @var{face}.
352 @item @var{face}.attributeBackgroundPixmap
353 The background pixmap for the face @var{face}. Should be a name of a
354 pixmap file or @code{false}.
355 @item @var{face}.attributeBold
356 Whether to draw the characters in the face @var{face} as bold.
357 @item @var{face}.attributeItalic
358 Whether to draw the characters in the face @var{face} as italic.
361 @node Lucid Resources
362 @appendixsec Lucid Menu X Resources
363 @cindex Menu X Resources (Lucid widgets)
364 @cindex Lucid Widget X Resources
366 If the Emacs installed at your site was built to use the X toolkit
367 with the Lucid menu widgets, then the menu bar is a separate widget and
368 has its own resources. The resource names contain @samp{pane.menubar}
369 (following, as always, the name of the Emacs invocation, or @samp{Emacs},
370 which stands for all Emacs invocations). Specify them like this:
373 Emacs.pane.menubar.@var{resource}: @var{value}
377 For example, to specify the font @samp{8x16} for the menu-bar items,
381 Emacs.pane.menubar.font: 8x16
385 Resources for @emph{non-menubar} toolkit pop-up menus have
386 @samp{menu*}, in like fashion. For example, to specify the font
387 @samp{8x16} for the pop-up menu items, write this:
390 Emacs.menu*.font: 8x16
394 For dialog boxes, use @samp{dialog} instead of @samp{menu}:
397 Emacs.dialog*.font: 8x16
401 The Lucid menus can display multilingual text in your locale. For more
402 information about fontsets see the man page for XCreateFontSet. To enable
403 multilingual menu text you specify a fontSet resource instead of the font
404 resource. If both font and fontSet resources are specified, the fontSet
405 resource is used. To specify
406 @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*} for both the popup and
407 menu bar menus, write this:
410 Emacs*fontSet: -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
414 Experience shows that on some systems you may need to add
415 @samp{shell.}@: before the @samp{pane.menubar} or @samp{menu*}. On
416 some other systems, you must not add @samp{shell.}.
418 Here is a list of the specific resources for menu bars and pop-up menus:
422 Font for menu item text.
424 Fontset for menu item text.
426 Color of the foreground.
428 Color of the background.
429 @item buttonForeground
430 In the menu bar, the color of the foreground for a selected item.
431 @item horizontalSpacing
432 Horizontal spacing in pixels between items. Default is 3.
433 @item verticalSpacing
434 Vertical spacing in pixels between items. Default is 2.
436 Horizontal spacing between the arrow (which indicates a submenu) and
437 the associated text. Default is 10.
438 @item shadowThickness
439 Thickness of shadow line around the widget. Default is 1.
441 Also determines the thickness of shadow lines around other objects,
442 for instance 3D buttons and arrows. If you have the impression that
443 the arrows in the menus do not stand out clearly enough or that the
444 difference between ``in'' and ``out'' buttons is difficult to see, set
445 this to 2. If you have no problems with visibility, the default
446 probably looks better. The background color may also have some effect
449 The margin of the menu bar, in characters. Default is 1.
452 @node LessTif Resources
453 @appendixsec LessTif Menu X Resources
454 @cindex Menu X Resources (LessTif widgets)
455 @cindex LessTif Widget X Resources
457 If the Emacs installed at your site was built to use the X toolkit
458 with the LessTif or Motif widgets, then the menu bar, the dialog
459 boxes, the pop-up menus, and the file-selection box are separate
460 widgets and have their own resources.
462 The resource names for the menu bar contain @samp{pane.menubar}
463 (following, as always, the name of the Emacs invocation, or
464 @samp{Emacs}, which stands for all Emacs invocations). Specify them
468 Emacs.pane.menubar.@var{subwidget}.@var{resource}: @var{value}
471 Each individual string in the menu bar is a subwidget; the subwidget's
472 name is the same as the menu item string. For example, the word
473 @samp{File} in the menu bar is part of a subwidget named
474 @samp{emacs.pane.menubar.File}. Most likely, you want to specify the
475 same resources for the whole menu bar. To do this, use @samp{*} instead
476 of a specific subwidget name. For example, to specify the font
477 @samp{8x16} for the menu-bar items, write this:
480 Emacs.pane.menubar.*.fontList: 8x16
484 This also specifies the resource value for submenus.
486 Each item in a submenu in the menu bar also has its own name for X
487 resources; for example, the @samp{File} submenu has an item named
488 @samp{Save (current buffer)}. A resource specification for a submenu
489 item looks like this:
492 Emacs.pane.menubar.popup_*.@var{menu}.@var{item}.@var{resource}: @var{value}
496 For example, here's how to specify the font for the @samp{Save (current
500 Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16
504 For an item in a second-level submenu, such as @samp{Complete Word}
505 under @samp{Spell Checking} under @samp{Tools}, the resource fits this
509 Emacs.pane.menubar.popup_*.popup_*.@var{menu}.@var{resource}: @var{value}
516 Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: @var{value}
520 (This should be one long line.)
522 It's impossible to specify a resource for all the menu-bar items
523 without also specifying it for the submenus as well. So if you want the
524 submenu items to look different from the menu bar itself, you must ask
525 for that in two steps. First, specify the resource for all of them;
526 then, override the value for submenus alone. Here is an example:
529 Emacs.pane.menubar.*.fontList: 8x16
530 Emacs.pane.menubar.popup_*.fontList: 8x16
534 For LessTif pop-up menus, use @samp{menu*} instead of
535 @samp{pane.menubar}. For example, to specify the font @samp{8x16} for
536 the pop-up menu items, write this:
539 Emacs.menu*.fontList: 8x16
543 For LessTif dialog boxes, use @samp{dialog} instead of @samp{menu}:
546 Emacs.dialog*.fontList: 8x16
547 Emacs.dialog*.foreground: hotpink
550 To specify resources for the LessTif file-selection box, use
551 @samp{fsb*}, like this:
554 Emacs.fsb*.fontList: 8x16
560 Here is a list of the specific resources for LessTif menu bars and
565 The color to show in an armed button.
574 Amount of space to leave around the item, within the border.
576 The width of the border around the menu item, on all sides.
577 @item shadowThickness
578 The width of the border shadow.
579 @item bottomShadowColor
580 The color for the border shadow, on the bottom and the right.
582 The color for the border shadow, on the top and the left.
587 @appendixsec GTK resources
588 @cindex GTK resources and customization
589 @cindex resource files for GTK
590 @cindex @file{~/.gtkrc-2.0} file
591 @cindex @file{~/.emacs.d/gtkrc} file
593 If Emacs was built to use the GTK widget set, then the menu bar,
594 scroll bar and the dialogs are customized with the standard GTK
595 customization file, @file{~/.gtkrc-2.0}, or with the Emacs specific
596 file @file{~/.emacs.d/gtkrc}. We recommend that you use
597 @file{~/.emacs.d/gtkrc} for customizations, since @file{~/.gtkrc-2.0}
598 seems to be ignored when running GConf with GNOME. These files apply
599 only to GTK widget features. To customize Emacs font, background,
600 faces, etc., use the normal X resources (@pxref{Resources}).
602 Some GTK themes override these mechanisms, which means that using
603 these mechanisms will not work to customize them.
605 In these files you first define a style and say what it means; then
606 you specify to apply the style to various widget types (@pxref{GTK
607 widget names}). Here is an example of how to change the font for
611 # @r{Define the style @samp{metafont}.}
614 font_name = "helvetica bold 14" # This is a Pango font name
617 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{metafont}.}
618 widget "*emacs-menuitem*" style "menufont"
621 Here is a more elaborate example, showing how to change the parts of
627 fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
628 bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
629 bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
630 bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
633 widget "*verticalScrollBar*" style "scroll"
636 There are also parameters that affect GTK as a whole. For example,
637 the property @code{gtk-font-name} sets the default font for GTK. You
638 must use Pango font names (@pxref{GTK styles}). A GTK resources file
639 that just sets a default font looks like this:
642 gtk-font-name = "courier 12"
645 The GTK resources file is fully described in the GTK API document.
647 @file{@var{prefix}/share/gtk-doc/html/gtk/gtk-resource-files.html},
648 where @file{prefix} is the directory in which the GTK libraries were
649 installed (usually @file{/usr} or @file{/usr/local}). You can also
650 find the document online, at
651 @uref{http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html}.
654 * GTK widget names:: How widgets in GTK are named in general.
655 * GTK Names in Emacs:: GTK widget names in Emacs.
656 * GTK styles:: What can be customized in a GTK widget.
659 @node GTK widget names
660 @appendixsubsec GTK widget names
661 @cindex GTK widget names
663 A GTK widget is specified by its @dfn{widget class} and
664 @dfn{widget name}. The widget class is the type of the widget: for
665 example, @code{GtkMenuBar}. The widget name is the name given to a
666 specific widget. A widget always has a class, but need not have a
669 @dfn{Absolute names} are sequences of widget names or widget
670 classes, corresponding to hierarchies of widgets embedded within
671 other widgets. For example, if a @code{GtkWindow} named @code{top}
672 contains a @code{GtkVBox} named @code{box}, which in turn contains
673 a @code{GtkMenuBar} called @code{menubar}, the absolute class name
674 of the menu-bar widget is @code{GtkWindow.GtkVBox.GtkMenuBar}, and
675 its absolute widget name is @code{top.box.menubar}.
677 When assigning a style to a widget, you can use the absolute class
678 name or the absolute widget name.
680 There are two commands to specify changes for widgets:
683 @item @code{widget_class}
684 specifies a style for widgets based on the absolute class name.
687 specifies a style for widgets based on the absolute class name,
692 You must specify the class and the style in double-quotes, and put
693 these commands at the top level in the GTK customization file, like
699 font_name = "helvetica bold 14"
702 widget "top.box.menubar" style "menufont"
703 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "menufont"
706 Matching of absolute names uses shell wildcard syntax: @samp{*}
707 matches zero or more characters and @samp{?} matches one character.
708 This example assigns @code{base_style} to all widgets:
711 widget "*" style "base_style"
714 Given the absolute class name @code{GtkWindow.GtkVBox.GtkMenuBar}
715 and the corresponding absolute widget name @code{top.box.menubar}, all
716 these examples specify @code{my_style} for the menu bar:
719 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
720 widget_class "GtkWindow.*.GtkMenuBar" style "my_style"
721 widget_class "*GtkMenuBar" style "my_style"
722 widget "top.box.menubar" style "my_style"
723 widget "*box*menubar" style "my_style"
724 widget "*menubar" style "my_style"
725 widget "*menu*" style "my_style"
728 @node GTK Names in Emacs
729 @appendixsubsec GTK Widget Names in Emacs
730 @cindex GTK widget names
731 @cindex GTK widget classes
733 In Emacs, the top level widget for a frame is a @code{GtkWindow}
734 that contains a @code{GtkVBox}. The @code{GtkVBox} contains the
735 @code{GtkMenuBar} and a @code{GtkFixed} widget. The vertical scroll
736 bars, @code{GtkVScrollbar}, are contained in the @code{GtkFixed}
737 widget. The text you write in Emacs is drawn in the @code{GtkFixed}
740 Dialogs in Emacs are @code{GtkDialog} widgets. The file dialog is a
741 @code{GtkFileSelection} widget.
744 To set a style for the menu bar using the absolute class name, use:
747 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
751 For the scroll bar, the absolute class name is:
755 "GtkWindow.GtkVBox.GtkFixed.GtkVScrollbar"
760 The names for the emacs widgets, and their classes, are:
762 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
763 @item @code{emacs-filedialog}
764 @tab @code{GtkFileSelection}
765 @item @code{emacs-dialog}
766 @tab @code{GtkDialog}
768 @tab @code{GtkWindow}
773 @item @code{verticalScrollBar}
774 @tab @code{GtkVScrollbar}
775 @item @code{emacs-toolbar}
776 @tab @code{GtkToolbar}
778 @tab @code{GtkMenuBar}
779 @item @code{emacs-menuitem}
780 @tab anything in menus
784 Thus, for Emacs you can write the two examples above as:
787 widget "Emacs.pane.menubar" style "my_style"
788 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
791 GTK absolute names are quite strange when it comes to menus
792 and dialogs. The names do not start with @samp{Emacs}, as they are
793 free-standing windows and not contained (in the GTK sense) by the
794 Emacs GtkWindow. To customize the dialogs and menus, use wildcards like this:
797 widget "*emacs-dialog*" style "my_dialog_style"
798 widget "*emacs-filedialog* style "my_file_style"
799 widget "*emacs-menuitem* style "my_menu_style"
802 If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
803 automatically applies only to Emacs, since other programs don't read
804 that file. For example, the drop down menu in the file dialog can not
805 be customized by any absolute widget name, only by an absolute class
806 name. This is because the widgets in the drop down menu do not
807 have names and the menu is not contained in the Emacs GtkWindow. To
808 have all menus in Emacs look the same, use this in
809 @file{~/.emacs.d/gtkrc}:
812 widget_class "*Menu*" style "my_menu_style"
816 @appendixsubsec GTK styles
819 In a GTK style you specify the appearance widgets shall have. You
820 can specify foreground and background color, background pixmap and
821 font. The edit widget (where you edit the text) in Emacs is a GTK
822 widget, but trying to specify a style for the edit widget will have no
823 effect. This is so that Emacs compiled for GTK is compatible with
824 Emacs compiled for other X toolkits. The settings for foreground,
825 background and font for the edit widget is taken from the X resources;
826 @pxref{Resources}. Here is an example of two style declarations,
827 @samp{default} and @samp{ruler}:
830 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
834 font_name = "helvetica 12"
836 bg[NORMAL] = @{ 0.83, 0.80, 0.73 @}
837 bg[SELECTED] = @{ 0.0, 0.55, 0.55 @}
838 bg[INSENSITIVE] = @{ 0.77, 0.77, 0.66 @}
839 bg[ACTIVE] = @{ 0.0, 0.55, 0.55 @}
840 bg[PRELIGHT] = @{ 0.0, 0.55, 0.55 @}
843 fg[SELECTED] = @{ 0.9, 0.9, 0.9 @}
845 fg[PRELIGHT] = @{ 0.9, 0.9, 0.9 @}
847 base[INSENSITIVE] = "#777766"
848 text[INSENSITIVE] = @{ 0.60, 0.65, 0.57 @}
850 bg_pixmap[NORMAL] = "background.xpm"
851 bg_pixmap[INSENSITIVE] = "background.xpm"
852 bg_pixmap[ACTIVE] = "background.xpm"
853 bg_pixmap[PRELIGHT] = "<none>"
857 style "ruler" = "default"
859 font_name = "helvetica 8"
864 The style @samp{ruler} inherits from @samp{default}. This way you can build
865 on existing styles. The syntax for fonts and colors is described below.
867 As this example shows, it is possible to specify several values for
868 foreground and background depending on the widget's @dfn{state}. The
873 This is the default state for widgets.
875 This is the state for a widget that is ready to do something. It is
876 also for the trough of a scroll bar, i.e. @code{bg[ACTIVE] = "red"}
877 sets the scroll bar trough to red. Buttons that have been pressed but
878 not released yet (``armed'') are in this state.
880 This is the state when widgets that can be manipulated have the mouse
881 pointer over them. For example when the mouse is over the thumb in the
882 scroll bar or over a menu item. When the mouse is over a button that
883 is not pressed, the button is in this state.
885 This is the state when some data has been selected by the user. It can
886 be selected text or items selected in a list.
887 There is no place in Emacs where this setting has any effect.
889 This is the state for widgets that are visible, but they can not be
890 manipulated in the usual way---for example, buttons that can't be
891 pressed, and disabled menu items. To display disabled menu items in
892 yellow, use @code{fg[INSENSITIVE] = "yellow"}.
895 Here are the things that can go in a style declaration:
898 @item bg[@var{state}] = @var{color}
899 This specifies the background color for the widget. Note that
900 editable text doesn't use @code{bg}; it uses @code{base} instead.
902 @item base[@var{state}] = @var{color}
903 This specifies the background color for editable text. In Emacs, this
904 color is used for the background of the text fields in the file
907 @item bg_pixmap[@var{state}] = "@var{pixmap}"
908 This specifies an image background (instead of a background color).
909 @var{pixmap} should be the image file name. GTK can use a number of
910 image file formats, including XPM, XBM, GIF, JPEG and PNG. If you
911 want a widget to use the same image as its parent, use
912 @samp{<parent>}. If you don't want any image, use @samp{<none>}.
913 @samp{<none>} is the way to cancel a background image inherited from a
916 You can't specify the file by its absolute file name. GTK looks for
917 the pixmap file in directories specified in @code{pixmap_path}.
918 @code{pixmap_path} is a colon-separated list of directories within
919 double quotes, specified at the top level in a @file{gtkrc} file
920 (i.e. not inside a style definition; see example above):
923 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
926 @item fg[@var{state}] = @var{color}
927 This specifies the foreground color for widgets to use. It is the
928 color of text in menus and buttons, and the color for the arrows in
929 the scroll bar. For editable text, use @code{text}.
931 @item text[@var{state}] = @var{color}
932 This is the color for editable text. In Emacs, this color is used for the
933 text fields in the file dialog.
935 @item font_name = "@var{font}"
936 This specifies the font for text in the widget. @var{font} is a
937 Pango font name, for example @samp{Sans Italic 10}, @samp{Helvetica
938 Bold 12}, @samp{Courier 14}, @samp{Times 18}. See below for exact
939 syntax. The names are case insensitive.
942 There are three ways to specify a color: by name, in hexadecimal
943 form, and with an RGB triplet.
946 A color name is written within double quotes, for example @code{"red"}.
949 Hexadecimal form is the same as in X:
950 @code{#@var{rrrr}@var{gggg}@var{bbbb}}, where all three color specs
951 must have the same number of hex digits (1, 2, 3 or 4).
954 An RGB triplet looks like @code{@{ @var{r}, @var{g}, @var{b} @}},
955 where @var{r}, @var{g} and @var{b} are either integers in the range
956 0-65535 or floats in the range 0.0-1.0.
958 Pango font names have the form ``@var{family-list} @var{style-options}
960 @cindex Pango font name
962 @var{family-list} is a comma separated list of font families optionally
963 terminated by a comma. This way you can specify several families and the
964 first one found will be used. @var{family} corresponds to the second part in
965 an X font name, for example in
968 -adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
972 the family name is ``times''.
975 @var{style-options} is a whitespace separated list of words where each word
976 is a style, variant, weight, or stretch. The default value for all of
977 these is @code{normal}.
980 A `style' corresponds to the fourth part of an X font name. In X font
981 names it is the character @samp{r}, @samp{i} or @samp{o}; in Pango
982 font names the corresponding values are @code{normal}, @code{italic},
986 A `variant' is either @code{normal} or @code{small-caps}.
987 Small caps is a font with the lower case characters replaced by
988 smaller variants of the capital characters.
991 Weight describes the ``boldness'' of a font. It corresponds to the third
992 part of an X font name. It is one of @code{ultra-light}, @code{light},
993 @code{normal}, @code{bold}, @code{ultra-bold}, or @code{heavy}.
996 Stretch gives the width of the font relative to other designs within a
997 family. It corresponds to the fifth part of an X font name. It is one of
998 @code{ultra-condensed}, @code{extra-condensed}, @code{condensed},
999 @code{semi-condensed}, @code{normal}, @code{semi-expanded},
1000 @code{expanded}, @code{extra-expanded}, or @code{ultra-expanded}.
1003 @var{size} is a decimal number that describes the font size in points.
1006 arch-tag: 9b6ff773-48b6-41f6-b2f9-f114b8bdd97f