gtk-Resource-Files: Resource Files

Description Methods and Functions Hierarchy Detailed Description Default files Optimizing RC Style Matches Structures Enums and Flags Author(s) References

Description

Routines for handling resource files

Methods and Functions

gtkRcScannerNew()
gtkRcGetStyle(object)
gtkRcGetStyleByPaths(settings, widget.path, class.path, type)
gtkRcAddWidgetNameStyle(object, pattern)
gtkRcAddWidgetClassStyle(object, pattern)
gtkRcAddClassStyle(object, pattern)
gtkRcParseString(rc.string)
gtkRcReparseAll()
gtkRcReparseAllForSettings(settings, force.load)
gtkRcResetStyles(settings)
gtkRcGetDefaultFiles()
gtkRcParseColor(scanner, color)
gtkRcParseColorFull(scanner, style)
gtkRcParseState(scanner)
gtkRcParsePriority(scanner)
gtkRcFindModuleInPath(module.file)
gtkRcFindPixmapInPath(settings, scanner = NULL, pixmap.file)
gtkRcGetModuleDir()
gtkRcGetImModulePath()
gtkRcGetImModuleFile()
gtkRcGetThemeDir()
gtkRcStyleNew()
gtkRcStyleCopy(object)

Hierarchy

1
2

Detailed Description

GTK+ provides resource file mechanism for configuring various aspects of the operation of a GTK+ program at runtime.

Default files

An application can cause GTK+ to parse a specific RC file by calling gtkRcParse. In addition to this, certain files will be read at the end of gtkInit. Unless modified, the files looked for will be ‘<SYSCONFDIR>/gtk-2.0/gtkrc’ and ‘.gtkrc-2.0’ in the users home directory. (‘<SYSCONFDIR>’ defaults to ‘/usr/local/etc’. It can be changed with the --prefix or --sysconfdir options when configuring GTK+.) Note that although the filenames contain the version number 2.0, all 2.x versions of GTK+ look for these files.

The set of these default files can be retrieved with gtkRcGetDefaultFiles and modified with gtkRcAddDefaultFile and gtkRcSetDefaultFiles. Additionally, the GTK2_RC_FILES environment variable can be set to a G_SEARCHPATH_SEPARATOR_S-separated list of files in order to overwrite the set of default files at runtime.

For each RC file, in addition to the file itself, GTK+ will look for a locale-specific file that will be parsed after the main file. For instance, if LANG is set to ja_JP.ujis, when loading the default file ‘~/.gtkrc’ then GTK+ looks for ‘~/.gtkrc.ja_JP’ and ‘~/.gtkrc.ja’, and parses the first of those that exists.

Optimizing RC Style Matches

Everytime a widget is created and added to the layout hierarchy of a GtkWindow ("anchored" to be exact), a list of matching RC styles out of all RC styles read in so far is composed. For this, every RC style is matched against the widgets class path, the widgets name path and widgets inheritance hierarchy. As a consequence, significant slowdown can be caused by utilization of many RC styles and by using RC style patterns that are slow or complicated to match against a given widget. The following ordered list provides a number of advices (prioritized by effectiveness) to reduce the performance overhead associated with RC style matches:

  1. Move RC styles for specific applications into RC files dedicated to those applications and parse application specific RC files only from applications that are affected by them. This reduces the overall amount of RC styles that have to be considered for a match across a group of applications.

  2. Merge multiple styles which use the same matching rule, for instance:

         style "Foo" { foo_content }
         class "X" style "Foo"
         style "Bar" { bar_content }
         class "X" style "Bar"
    

    is faster to match as:

         style "FooBar" { foo_content bar_content }
         class "X" style "FooBar"
    
  3. Use of wildcards should be avoided, this can reduce the individual RC style match to a single integer comparison in most cases.

  4. To avoid complex recursive matching, specification of full class names (for class matches) or full path names (for widget and widget_class matches) is to be preferred over shortened names containing "*" or "?".

  5. If at all necessary, wildcards should only be used at the tail or head of a pattern. This reduces the match complexity to a string comparison per RC style.

  6. When using wildcards, use of "?" should be preferred over "*". This can reduce the matching complexity from O(n^2) to O(n). For example "Gtk*Box" can be turned into "Gtk?Box" and will still match GtkHBox and GtkVBox.

  7. The use of "*" wildcards should be restricted as much as possible, because matching "A*B*C*RestString" can result in matching complexities of O(n^2) worst case.

Structures

GtkRcStyle

The GtkRcStyle structure is used to represent a set of information about the appearance of a widget. This can later be composited together with other GtkRcStyle structures to form a GtkStyle.

Enums and Flags

GtkRcFlags

The GtkRcFlags enumeration is used as a bitmask to specify which fields of a GtkRcStyle have been set for each state.

fg

If present, the foreground color has been set for this state.

bg

If present, the background color has been set for this state.

text

If present, the text color has been set for this state.

base

If present, the base color has been set for this state.

GtkRcTokenType

The GtkRcTokenType enumeration represents the tokens in the RC file. It is exposed so that theme engines can reuse these tokens when parsing the theme-engine specific portions of a RC file.

invalid

undocumented

include

undocumented

normal

undocumented

active

undocumented

prelight

undocumented

selected

undocumented

insensitive

undocumented

fg

undocumented

bg

undocumented

text

undocumented

base

undocumented

xthickness

undocumented

ythickness

undocumented

font

undocumented

fontset

undocumented

font-name

undocumented

bg-pixmap

undocumented

pixmap-path

undocumented

style

undocumented

binding

undocumented

bind

undocumented

widget

undocumented

widget-class

undocumented

class

undocumented

lowest

undocumented

gtk

undocumented

application

undocumented

theme

undocumented

rc

undocumented

highest

undocumented

engine

undocumented

module-path

undocumented

im-module-path

undocumented

im-module-file

undocumented

stock

undocumented

ltr

undocumented

rtl

undocumented

last

undocumented

Author(s)

Derived by RGtkGen from GTK+ documentation

References

https://developer.gnome.org/gtk2/stable/gtk2-Resource-Files.html


RGtk2 documentation built on May 30, 2017, 5:53 a.m.