Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Previous: LessTif Resources, Up: X Resources


D.6 GTK resources

If Emacs was built to use the GTK widget set, then the menu bar, scroll bar and the dialogs are customized with the standard GTK customization file, ~/.gtkrc-2.0, or with the Emacs specific file ~/.emacs.d/gtkrc. We recommend that you use ~/.emacs.d/gtkrc for customizations, since ~/.gtkrc-2.0 seems to be ignored when running GConf with GNOME. These files apply only to GTK widget features. To customize Emacs font, background, faces, etc., use the normal X resources (see Resources).

Some GTK themes override these mechanisms, which means that using these mechanisms will not work to customize them.

In these files you first define a style and say what it means; then you specify to apply the style to various widget types (see GTK widget names). Here is an example of how to change the font for Emacs menus:

     # Define the style ‘metafont’.
     style "menufont"
     {
       font_name = "helvetica bold 14"  # This is a Pango font name
     }
     
     # Specify that widget type ‘*emacs-menuitem*’ uses ‘metafont’.
     widget "*emacs-menuitem*" style "menufont"

Here is a more elaborate example, showing how to change the parts of the scroll bar:

     style "scroll"
     {
       fg[NORMAL] = "red"     # The arrow color.
       bg[NORMAL] = "yellow"  # The thumb and background around the arrow.
       bg[ACTIVE] = "blue"    # The trough color.
       bg[PRELIGHT] = "white" # The thumb color when the mouse is over it.
     }
     
     widget "*verticalScrollBar*" style "scroll"

There are also parameters that affect GTK as a whole. For example, the property gtk-font-name sets the default font for GTK. You must use Pango font names (see GTK styles). A GTK resources file that just sets a default font looks like this:

     gtk-font-name = "courier 12"

The GTK resources file is fully described in the GTK API document. This can be found in prefix/share/gtk-doc/html/gtk/gtk-resource-files.html, where prefix is the directory in which the GTK libraries were installed (usually /usr or /usr/local). You can also find the document online, at https://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html.


 
 
  Published under the terms of the GNU General Public License Design by Interspire