📄 gtk-resource-files.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Resource Files</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GTK+ Reference Manual"><link rel="up" href="gtkbase.html" title="Part II. GTK+ Core Reference"><link rel="prev" href="gtk-Themeable-Stock-Images.html" title="Themeable Stock Images"><link rel="next" href="GtkSettings.html" title="Settings"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="part" href="gtk.html" title="Part I. GTK+ Overview"><link rel="part" href="gtkbase.html" title="Part II. GTK+ Core Reference"><link rel="part" href="gtkobjects.html" title="Part III. GTK+ Widgets and Objects"><link rel="chapter" href="ch01.html" title="Object Hierarchy"><link rel="chapter" href="ch02.html" title="Widget Gallery"><link rel="chapter" href="WindowWidgets.html" title="Windows"><link rel="chapter" href="DisplayWidgets.html" title="Display Widgets"><link rel="chapter" href="ButtonWidgets.html" title="Buttons and Toggles"><link rel="chapter" href="NumericEntry.html" title="Numeric/Text Data Entry"><link rel="chapter" href="TextWidgetObjects.html" title="Multiline Text Editor"><link rel="chapter" href="TreeWidgetObjects.html" title="Tree, List and Icon Grid Widgets"><link rel="chapter" href="MenusAndCombos.html" title="Menus, Combo Box, Toolbar"><link rel="chapter" href="Actions.html" title="Action-based menus and toolbars"><link rel="chapter" href="SelectorWidgets.html" title="Selectors (File/Font/Color/Input Devices)"><link rel="chapter" href="LayoutContainers.html" title="Layout Containers"><link rel="chapter" href="Ornaments.html" title="Ornaments"><link rel="chapter" href="ScrollingWidgets.html" title="Scrolling"><link rel="chapter" href="Printing.html" title="Printing"><link rel="chapter" href="MiscObjects.html" title="Miscellaneous"><link rel="chapter" href="AbstractObjects.html" title="Abstract Base Classes"><link rel="chapter" href="PlugSocket.html" title="Cross-process Embedding"><link rel="chapter" href="SpecialObjects.html" title="Special-purpose features"><link rel="chapter" href="RecentDocuments.html" title="Recently Used Documents"><link rel="chapter" href="Builder.html" title="Interface builder"><link rel="chapter" href="DeprecatedObjects.html" title="Deprecated"><link rel="part" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+"><link rel="chapter" href="gtk-migrating-checklist.html" title="Migration Checklist"><link rel="chapter" href="gtk-migrating-GtkFileChooser.html" title="Migrating from GtkFileSelection to GtkFileChooser"><link rel="chapter" href="gtk-migrating-GtkAction.html" title="Migrating from old menu and toolbar systems to GtkAction"><link rel="chapter" href="gtk-migrating-GtkComboBox.html" title="Migrating from GtkOptionMenu and GtkCombo to GtkComboBox and GtkComboBoxEntry"><link rel="chapter" href="gtk-migrating-GtkIconView.html" title="Migrating from GnomeIconList to GtkIconView"><link rel="chapter" href="gtk-migrating-GtkAboutDialog.html" title="Migrating from GnomeAbout to GtkAboutDialog"><link rel="chapter" href="gtk-migrating-GtkColorButton.html" title="Migrating from GnomeColorPicker to GtkColorButton"><link rel="chapter" href="gtk-migrating-GtkAssistant.html" title="Migrating from GnomeDruid to GtkAssistant"><link rel="chapter" href="gtk-migrating-GtkRecentChooser.html" title="Migrating from EggRecent to GtkRecentChooser"><link rel="chapter" href="gtk-migrating-GtkLinkButton.html" title="Migrating from GnomeHRef to GtkLinkButton"><link rel="chapter" href="gtk-migrating-GtkBuilder.html" title="Migrating from libglade to GtkBuilder"><link rel="chapter" href="gtk-migrating-tooltips.html" title="Migrating from GtkTooltips to GtkTooltip"><link rel="part" href="pt05.html" title="Part V. GTK+ Tools"><link rel="glossary" href="glossary.html" title="Glossary"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="gtk-Themeable-Stock-Images.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="gtkbase.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GTK+ Reference Manual</th><td><a accesskey="n" href="GtkSettings.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id3233421" class="shortcut">Top</a>  |  <a href="#id3234198" class="shortcut">Description</a>  |  <a href="#id3234173" class="shortcut">Object Hierarchy</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="gtk-Resource-Files"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id3233421"></a><span class="refentrytitle">Resource Files</span></h2><p>Resource Files — Routines for handling resource files</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><a name="GtkRcStyle"></a><pre class="synopsis">#include <gtk/gtk.h> <a class="link" href="gtk-Resource-Files.html#GtkRcStyle-struct">GtkRcStyle</a>;enum <a class="link" href="gtk-Resource-Files.html#GtkRcFlags">GtkRcFlags</a>;enum <a class="link" href="gtk-Resource-Files.html#GtkRcTokenType">GtkRcTokenType</a>;<ahref="/usr/share/gtk-doc/html/glib/glib-Lexical-Scanner.html#GScanner">GScanner</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-scanner-new">gtk_rc_scanner_new</a> (void);<a class="link" href="GtkStyle.html" title="Styles">GtkStyle</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-style">gtk_rc_get_style</a> (<a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a> *widget);<a class="link" href="GtkStyle.html" title="Styles">GtkStyle</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-style-by-paths">gtk_rc_get_style_by_paths</a> (<a class="link" href="GtkSettings.html" title="Settings">GtkSettings</a> *settings, const char *widget_path, const char *class_path, <ahref="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#GType">GType</a> type);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-add-widget-name-style">gtk_rc_add_widget_name_style</a> (<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a> *rc_style, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *pattern);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-add-widget-class-style">gtk_rc_add_widget_class_style</a> (<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a> *rc_style, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *pattern);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-add-class-style">gtk_rc_add_class_style</a> (<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a> *rc_style, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *pattern);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-parse">gtk_rc_parse</a> (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *filename);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-parse-string">gtk_rc_parse_string</a> (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *rc_string);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gtk-Resource-Files.html#gtk-rc-reparse-all">gtk_rc_reparse_all</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gtk-Resource-Files.html#gtk-rc-reparse-all-for-settings">gtk_rc_reparse_all_for_settings</a> (<a class="link" href="GtkSettings.html" title="Settings">GtkSettings</a> *settings, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> force_load);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-reset-styles">gtk_rc_reset_styles</a> (<a class="link" href="GtkSettings.html" title="Settings">GtkSettings</a> *settings);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-add-default-file">gtk_rc_add_default_file</a> (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *filename);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>** <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-default-files">gtk_rc_get_default_files</a> (void);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-set-default-files">gtk_rc_set_default_files</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> **filenames);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> <a class="link" href="gtk-Resource-Files.html#gtk-rc-parse-color">gtk_rc_parse_color</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Lexical-Scanner.html#GScanner">GScanner</a> *scanner, <ahref="/usr/share/gtk-doc/html/gdk/gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> <a class="link" href="gtk-Resource-Files.html#gtk-rc-parse-color-full">gtk_rc_parse_color_full</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Lexical-Scanner.html#GScanner">GScanner</a> *scanner, <a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a> *style, <ahref="/usr/share/gtk-doc/html/gdk/gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> <a class="link" href="gtk-Resource-Files.html#gtk-rc-parse-state">gtk_rc_parse_state</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Lexical-Scanner.html#GScanner">GScanner</a> *scanner, <a class="link" href="gtk-Standard-Enumerations.html#GtkStateType">GtkStateType</a> *state);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> <a class="link" href="gtk-Resource-Files.html#gtk-rc-parse-priority">gtk_rc_parse_priority</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Lexical-Scanner.html#GScanner">GScanner</a> *scanner, <a class="link" href="gtk-Standard-Enumerations.html#GtkPathPriorityType">GtkPathPriorityType</a> *priority);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-find-module-in-path">gtk_rc_find_module_in_path</a> (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *module_file);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-find-pixmap-in-path">gtk_rc_find_pixmap_in_path</a> (<a class="link" href="GtkSettings.html" title="Settings">GtkSettings</a> *settings, <ahref="/usr/share/gtk-doc/html/glib/glib-Lexical-Scanner.html#GScanner">GScanner</a> *scanner, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *pixmap_file);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-module-dir">gtk_rc_get_module_dir</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-im-module-path">gtk_rc_get_im_module_path</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-im-module-file">gtk_rc_get_im_module_file</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-theme-dir">gtk_rc_get_theme_dir</a> (void);<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-style-new">gtk_rc_style_new</a> (void);<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a>* <a class="link" href="gtk-Resource-Files.html#gtk-rc-style-copy">gtk_rc_style_copy</a> (<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a> *orig);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-style-ref">gtk_rc_style_ref</a> (<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a> *rc_style);void <a class="link" href="gtk-Resource-Files.html#gtk-rc-style-unref">gtk_rc_style_unref</a> (<a class="link" href="gtk-Resource-Files.html#GtkRcStyle">GtkRcStyle</a> *rc_style);</pre></div><div class="refsect1" lang="en"><a name="id3234173"></a><h2>Object Hierarchy</h2><pre class="synopsis"> <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> +----GtkRcStyle</pre></div><div class="refsect1" lang="en"><a name="id3234198"></a><h2>Description</h2><p>GTK+ provides resource file mechanism for configuringvarious aspects of the operation of a GTK+ programat runtime.</p><div class="refsect2" lang="en"><a name="id3234213"></a><h3>Default files</h3><p>An application can cause GTK+ to parse a specific RCfile by calling <a class="link" href="gtk-Resource-Files.html#gtk-rc-parse"><code class="function">gtk_rc_parse()</code></a>. In addition to this,certain files will be read at the end of <a class="link" href="gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>.Unless modified, the files looked for will be <code class="filename"><SYSCONFDIR>/gtk-2.0/gtkrc</code> and <code class="filename">.gtkrc-2.0</code> in the users home directory.(<code class="filename"><SYSCONFDIR></code> defaults to <code class="filename">/usr/local/etc</code>. It can be changed with the<code class="option">--prefix</code> or <code class="option">--sysconfdir</code> 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. </p><p>The set of these <em class="firstterm">default</em> filescan be retrieved with <a class="link" href="gtk-Resource-Files.html#gtk-rc-get-default-files"><code class="function">gtk_rc_get_default_files()</code></a>and modified with <a class="link" href="gtk-Resource-Files.html#gtk-rc-add-default-file"><code class="function">gtk_rc_add_default_file()</code></a> and<a class="link" href="gtk-Resource-Files.html#gtk-rc-set-default-files"><code class="function">gtk_rc_set_default_files()</code></a>.Additionally, the <code class="envar">GTK2_RC_FILES</code> environment variablecan be set to a <span class="type">G_SEARCHPATH_SEPARATOR_S-separated</span> list of filesin order to overwrite the set of default files at runtime.</p><p><a name="locale-specific-rc"></a>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 <code class="envar">LANG</code> is set to <code class="literal">ja_JP.ujis</code>,when loading the default file <code class="filename">~/.gtkrc</code> then GTK+ looks for <code class="filename">~/.gtkrc.ja_JP</code> and <code class="filename">~/.gtkrc.ja</code>, and parses the first of those that exists.</p></div><hr><div class="refsect2" lang="en"><a name="id3234380"></a><h3>Pathnames and patterns</h3><a name="gtkrc-pathnames-and-patterns"></a><p>A resource file defines a number of styles and key bindings andattaches them to particular widgets. The attachment is doneby the <code class="literal">widget</code>, <code class="literal">widget_class</code>,and <code class="literal">class</code> declarations. As an exampleof such a statement:</p><div class="informalexample"><pre class="programlisting">widget "mywindow.*.GtkEntry" style "my-entry-class"</pre></div><p>attaches the style <code class="literal">"my-entry-class"</code> to all widgets whose <em class="firstterm">widget path</em> matches the <em class="firstterm">pattern</em> <code class="literal">"mywindow.*.GtkEntry"</code>. That is, all <a class="link" href="GtkEntry.html" title="GtkEntry"><span class="type">GtkEntry</span></a> widgets which are part of a <a class="link" href="GtkWindow.html" title="GtkWindow"><span class="type">GtkWindow</span></a> named <code class="literal">"mywindow"</code>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -