📄 gtk-resource-files.html
字号:
</p><p>The patterns here are given in the standard shell glob syntax. The <code class="literal">"?"</code> wildcard matches any character, while <code class="literal">"*"</code> matches zero or more of any character. The three types of matching are against the widget path, the<em class="firstterm">class path</em> and the class hierarchy. Both the widget path and the class path consist of a <code class="literal">"."</code> separated list of all the parents of the widget and the widget itself from outermost to innermost. The difference is that in the widget path, the name assigned by <a class="link" href="GtkWidget.html#gtk-widget-set-name"><code class="function">gtk_widget_set_name()</code></a> is used if present, otherwise the class name of the widget, while for the class path, the class name is always used.</p><p>Since GTK+ 2.10,<code class="literal">widget_class</code> paths can also contain<code class="literal"><classname></code> substrings, which are matching the class with the given name and any derived classes. For instance,</p><div class="informalexample"><pre class="programlisting">widget_class "*<GtkMenuItem>.GtkLabel" style "my-style"</pre></div><p>will match <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a> widgets which are contained in any kind of menu item.</p><p>So, if you have a <a class="link" href="GtkEntry.html" title="GtkEntry"><span class="type">GtkEntry</span></a> named <code class="literal">"myentry"</code>, inside of a horizontal box in a window named <code class="literal">"mywindow"</code>, then thewidget path is: <code class="literal">"mywindow.GtkHBox.myentry"</code>while the class path is: <code class="literal">"GtkWindow.GtkHBox.GtkEntry"</code>.</p><p>Matching against class is a little different. The pattern match is doneagainst all class names in the widgets class hierarchy (not the layout hierarchy) in sequence, so the pattern:</p><div class="informalexample"><pre class="programlisting">class "GtkButton" style "my-style"</pre></div><p>will match not just <a class="link" href="GtkButton.html" title="GtkButton"><span class="type">GtkButton</span></a> widgets, but also <a class="link" href="GtkToggleButton.html" title="GtkToggleButton"><span class="type">GtkToggleButton</span></a> and<a class="link" href="GtkCheckButton.html" title="GtkCheckButton"><span class="type">GtkCheckButton</span></a> widgets, since those classes derive from <a class="link" href="GtkButton.html" title="GtkButton"><span class="type">GtkButton</span></a>.</p><p>Additionally, a priority can be specified for each pattern, and styles override other styles first by priority, then by pattern type and then by order of specification (later overrides earlier). The priorities that can be specified are (highest to lowest):</p><table class="simplelist" border="0" summary="Simple list"><tr><td><code class="literal">highest</code></td></tr><tr><td><code class="literal">rc</code></td></tr><tr><td><code class="literal">theme</code></td></tr><tr><td><code class="literal">application</code></td></tr><tr><td><code class="literal">gtk</code></td></tr><tr><td><code class="literal">lowest</code></td></tr></table><p><code class="literal">rc</code> is the default for stylesread from an RC file, <code class="literal">theme</code>is the default for styles read from theme RC files,<code class="literal">application</code> should be used for styles an application setsup, and <code class="literal">gtk</code> is used for stylesthat GTK+ creates internally.</p></div><hr><div class="refsect2" lang="en"><a name="id3234716"></a><h3>Optimizing RC Style Matches</h3><a name="optimizing-rc-style-matches"></a><p>Everytime a widget is created and added to the layout hierarchy of a <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a>("anchored" to be exact), a list of matching RC styles out of all RC styles readin 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 manyRC styles and by using RC style patterns that are slow or complicated to matchagainst 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:</p><div class="orderedlist"><ol type="1"><li><p> 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. </p></li><li><p> Merge multiple styles which use the same matching rule, for instance:</p><div class="informalexample"><pre class="programlisting"> style "Foo" { foo_content } class "X" style "Foo" style "Bar" { bar_content } class "X" style "Bar"</pre></div><p> is faster to match as:</p><div class="informalexample"><pre class="programlisting"> style "FooBar" { foo_content bar_content } class "X" style "FooBar"</pre></div><p> </p></li><li><p> Use of wildcards should be avoided, this can reduce the individual RC style match to a single integer comparison in most cases. </p></li><li><p> To avoid complex recursive matching, specification of full class names (for <code class="literal">class</code> matches) or full path names (for <code class="literal">widget</code> and <code class="literal">widget_class</code> matches) is to be preferred over shortened names containing <code class="literal">"*"</code> or <code class="literal">"?"</code>. </p></li><li><p> 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. </p></li><li><p> When using wildcards, use of <code class="literal">"?"</code> should be preferred over <code class="literal">"*"</code>. This can reduce the matching complexity from O(n^2) to O(n). For example <code class="literal">"Gtk*Box"</code> can be turned into <code class="literal">"Gtk?Box"</code> and will still match <a class="link" href="GtkHBox.html" title="GtkHBox"><span class="type">GtkHBox</span></a> and <a class="link" href="GtkVBox.html" title="GtkVBox"><span class="type">GtkVBox</span></a>. </p></li><li><p> The use of <code class="literal">"*"</code> wildcards should be restricted as much as possible, because matching <code class="literal">"A*B*C*RestString"</code> can result in matching complexities of O(n^2) worst case. </p></li></ol></div><p></p></div><hr><div class="refsect2" lang="en"><a name="id3234909"></a><h3>Toplevel declarations</h3><p>An RC file is a text file which is composed of a sequenceof declarations. <code class="literal">'#'</code> characters delimit comments andthe portion of a line after a <code class="literal">'#'</code> is ignored when parsingan RC file.</p><p>The possible toplevel declarations are:</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><code class="literal">binding <em class="replaceable"><code>name</code></em> { ... }</code></span></p></td><td><p>Declares a binding set.</p></td></tr><tr><td><p><span class="term"><code class="literal">class <em class="replaceable"><code>pattern</code></em> [ style | binding ][ : <em class="replaceable"><code>priority</code></em> ] <em class="replaceable"><code>name</code></em></code></span></p></td><td><p>Specifies a style or binding set for a particular branch of the inheritance hierarchy.</p></td></tr><tr><td><p><span class="term"><code class="literal">include <em class="replaceable"><code>filename</code></em></code></span></p></td><td><p>Parses another file at this point. If <em class="replaceable"><code>filename</code></em> is not an absolute filename, it is searched in the directories of the currently open RC files. </p><p>GTK+ also tries to load a <a class="link" href="gtk-Resource-Files.html#locale-specific-rc">locale-specific variant</a> of the included file. </p></td></tr><tr><td><p><span class="term"><code class="literal">module_path <em class="replaceable"><code>path</code></em></code></span></p></td><td><p>Sets a path (a list of directories separated by colons) that will be searched for theme engines referenced in RC files.</p></td></tr><tr><td><p><span class="term"><code class="literal">pixmap_path <em class="replaceable"><code>path</code></em></code></span></p></td><td><p>Sets a path (a list of directories separated by colons) that will be searched for pixmaps referenced in RC files.</p></td></tr><tr><td><p><span class="term"><code class="literal">im_module_file <em class="replaceable"><code>pathname</code></em></code></span></p></td><td><p>Sets the pathname for the IM modules file. Setting this from RC files is deprecated; you should use the environment variable <code class="envar">GTK_IM_MODULE_FILE</code> instead.</p></td></tr><tr><td><p><span class="term"><code class="literal">style <em class="replaceable"><code>name</code></em> [ = <em class="replaceable"><code>parent</code></em> ] { ... }</code></span></p></td><td><p>Declares a style.</p></td></tr><tr><td><p><span class="term"><code class="literal">widget <em class="replaceable"><code>pattern</code></em> [ style | binding ][ : <em class="replaceable"><code>priority</code></em> ] <em class="replaceable"><code>name</code></em></code></span></p></td><td><p>Specifies a style or binding set for a particular group of widgets by matching on the widget pathname.</p></td></tr><tr><td><p><span class="term"><code class="literal">widget_class <em class="replaceable"><code>pattern</code></em> [ style | binding ][ : <em class="replaceable"><code>priority</code></em> ] <em class="replaceable"><code>name</code></em></code></span></p></td><td><p>Specifies a style or binding set for a particular group of widgets by matching on the class pathname.</p></td></tr><tr><td><p><span class="term"><em class="replaceable"><code>setting</code></em> = <em class="replaceable"><code>value</code></em></span></p></td><td><p>Specifies a value for a <a class="link" href="GtkSettings.html" title="Settings">setting</a>. Note that settings in RC files are overwritten by system-wide settings (which are managed by an XSettings manager on X11).</p></td></tr></tbody></table></div><p></p></div><hr><div class="refsect2" lang="en"><a name="id3235204"></a><h3>Styles</h3><p>A RC style is specified by a <code class="literal">style</code> declaration in a RC file, and then bound to widgetswith a <code class="literal">widget</code>, <code class="literal">widget_class</code>,or <code class="literal">class</code> declaration. All stylesapplying to a particular widget are composited togetherwith <code class="literal">widget</code> declarations overriding<code class="literal">widget_class</code> declarations which, inturn, override <code class="literal">class</code> declarations.Within each type of declaration, later declarations overrideearlier ones.</p><p>Within a <code class="literal">style</code> declaration, the possibleelements are:</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><code class="literal">bg[<em class="replaceable"><code>state</code></em>] = <em class="replaceable"><code>color</code></em></code></span></p></td><td><p> Sets the color used for the background of most widgets. </p></td></tr><tr><td><p><span class="term"><code class="literal">fg[<em class="replaceable"><code>state</code></em>] = <em class="replaceable"><code>color</code></em></code></span></p></td><td><p> Sets the color used for the foreground of most widgets. </p></td></tr><tr><td><p><span class="term"><code class="literal">base[<em class="replaceable"><code>state</code></em>] = <em class="replaceable"><code>color</code></em></code></span></p></td><td><p> Sets the color used for the background of widgets displaying editable text. This color is used for the background of, among others, <a class="link" href="GtkText.html" title="GtkText"><span class="type">GtkText</span></a>, <a class="link" href="GtkEntry.html" title="GtkEntry"><span class="type">GtkEntry</span></a>, <a class="link" href="GtkList.html" title="GtkList"><span class="type">GtkList</span></a>, and <a class="link" href="GtkCList.html" title="GtkCList"><span class="type">GtkCList</span></a>. </p></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -