⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sec-gtksrcfileformat.html

📁 gtk 开发手册和参考文档。 包括gtk glib gdk等
💻 HTML
字号:
<HTML><HEAD><TITLE>GTK's rc File Format</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.49"><LINKREL="HOME"TITLE="GTK+ 1.2 Tutorial"HREF="gtk-tut.html"><LINKREL="UP"TITLE="GTK's rc Files"HREF="ch-gtkrcfiles.html"><LINKREL="PREVIOUS"TITLE="GTK's rc Files"HREF="ch-gtkrcfiles.html"><LINKREL="NEXT"TITLE="Example rc file"HREF="sec-examplercfile.html"></HEAD></head><body bgcolor="#FFFFFF" marginheight=0 marginwidth=0 width="100%"><table cellspacing=6 border=0 cellpadding=0 width="100%">  <tr>    <td bgcolor="#FFFFFF" valign=top nowrap>    <centeR><A HREF="/"><img src="/images/gtk-logo-rgb.gif" width=107 height=140 border=0></A>      <font face="helvetica,lucidia" color="#000000"><BR><BR><b>GTK+<BR>The GIMP Toolkit</b></center><BR><table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B>General</B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="/">Introduction</A><BR><A HREF="/screenshots/">Screenshots</A><br><A HREF="/download/">Download</A><br><A HREF="/mailinglists.html">Mailing Lists</A><BR><A HREF="/bindings.html">Language Bindings</A><BR><A HREF="http://gtk.themes.org/">Themes</A><BR><A HREF="/bugs.html">Bug Tracker</A><BR></td></tr></table></td></tr></table><BR>  <table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B>Documentation</B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="/faq/">FAQ</A><br><A HREF="/tutorial/">Tutorial</A><BR><A HREF="/api/">API Reference</A><br><A HREF="/books.html">Published Books</A><BR></td></tr></table></td></tr></table><BR>  <table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B>Projects</B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="http://www.pango.org/">Pango</A><BR><A HREF="http://sources.redhat.com/inti/">Inti</A><BR><A HREF="http://www.gnome.org/">GNOME</A><BR><A HREF="http://user.sgic.fi/~tml/gimp/win32/">GTK+ for Win32</A><br><A HREF="http://people.redhat.com/sopwith/gtkfb/">GtkFB (Framebuffer)</A><br><A HREF="http://www.directfb.org/gtk.xml">GTK+ on DirectFB</A><BR><A HREF="/beos/">GTK+ for BeOS</A></td></tr></table></td></tr></table><BR>  <table width=100% cellspacing=0 cellpadding=2 border=0><tr><td bgcolor="#000000"><table width=100% cellspacing=0 cellpadding=4 border=0><tr><td bgcolor="#AAAAEE" nowrap><B><B>Applications</B></B></td></tr><tr><td bgcolor="#FFFFFF" nowrap><A HREF="http://www.gimp.org/">GIMP</A><BR><A HREF="http://www.abiword.org/">Abiword</A><BR><A HREF="http://www.lysator.liu.se/~alla/dia/dia.html">Dia</A><BR><A HREF="http://glade.pn.org/">Glade</A><BR><A HREF="http://www.gnucash.org/">GnuCash</A><BR><A HREF="http://www.gnome.org/projects/gnumeric/">Gnumeric</A><BR><BR><A HREF="http://www.gnome.org/applist/">GNOME Software Map</A><br></td></tr></table></td></tr></table><BR>      </td>  <td bgcolor="#ffffff" valign=top width="99%"><font face="lucida,helvetica"><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">GTK+ 1.2 Tutorial</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="ch-gtkrcfiles.html">&#60;&#60;&#60; Previous</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 23. GTK's rc Files</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="sec-examplercfile.html">Next &#62;&#62;&#62;</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SEC-GTKSRCFILEFORMAT">23.2. GTK's rc File Format</A></H1><P>The format of the GTK file is illustrated in the example below. This isthe testgtkrc file from the GTK distribution, but I've added afew comments and things. You may wish to include this explanation inyour application to allow the user to fine tune his application.</P><P>There are several directives to change the attributes of a widget.</P><P></P><UL><LI><P>fg - Sets the foreground color of a widget.</P></LI><LI><P>bg - Sets the background color of a widget.</P></LI><LI><P>bg_pixmap - Sets the background of a widget to a tiled pixmap.</P></LI><LI><P>font - Sets the font to be used with the given widget.</P></LI></UL><P>In addition to this, there are several states a widget can be in, and youcan set different colors, pixmaps and fonts for each state. These states are:</P><P></P><UL><LI><P>NORMAL - The normal state of a widget, without the mouse over top ofit, and not being pressed, etc.</P></LI><LI><P>PRELIGHT - When the mouse is over top of the widget, colors definedusing this state will be in effect.</P></LI><LI><P>ACTIVE - When the widget is pressed or clicked it will be active, andthe attributes assigned by this tag will be in effect.</P></LI><LI><P>INSENSITIVE - When a widget is set insensitive, and cannot beactivated, it will take these attributes.</P></LI><LI><P>SELECTED - When an object is selected, it takes these attributes.</P></LI></UL><P>When using the "fg" and "bg" keywords to set the colors of widgets, theformat is:</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">fg[&#60;STATE&#62;] = { Red, Green, Blue }</PRE></TD></TR></TABLE><P>Where STATE is one of the above states (PRELIGHT, ACTIVE, etc), and the Red,Green and Blue are values in the range of 0 - 1.0,  { 1.0, 1.0, 1.0 } beingwhite. They must be in float form, or they will register as 0, so a straight "1" will not work, it must be "1.0".  A straight "0" is fine because it doesn't matter if it's not recognized.  Unrecognized values are set to 0.</P><P>bg_pixmap is very similar to the above, except the colors are replaced by afilename.</P><P>pixmap_path is a list of paths separated by ":"'s.  These paths will besearched for any pixmap you specify.</P><P>The font directive is simply:</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">font = "&#60;font name&#62;"</PRE></TD></TR></TABLE><P>The only hard part is figuring out the font string. Using xfontsel ora similar utility should help.</P><P>The "widget_class" sets the style of a class of widgets. These classes arelisted in the widget overview on the class hierarchy.</P><P>The "widget" directive sets a specifically named set of widgets to agiven style, overriding any style set for the given widget class.These widgets are registered inside the application using thegtk_widget_set_name() call. This allows you to specify the attributes of awidget on a per widget basis, rather than setting the attributes of anentire widget class. I urge you to document any of these special widgets sousers may customize them.</P><P>When the keyword <TTCLASS="LITERAL">parent</TT> is used as an attribute, the widget will take onthe attributes of its parent in the application.</P><P>When defining a style, you may assign the attributes of a previously definedstyle to this new one.</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">style "main_button" = "button"{  font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"  bg[PRELIGHT] = { 0.75, 0, 0 }}</PRE></TD></TR></TABLE><P>This example takes the "button" style, and creates a new "main_button" stylesimply by changing the font and prelight background color of the "button"style.</P><P>Of course, many of these attributes don't apply to all widgets. It's asimple matter of common sense really. Anything that could apply, should.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="ch-gtkrcfiles.html">&#60;&#60;&#60; Previous</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="gtk-tut.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="sec-examplercfile.html">Next &#62;&#62;&#62;</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">GTK's rc Files</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ch-gtkrcfiles.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Example rc file</TD></TR></TABLE></DIV>        </td>    </tr></table>  </td>  </tr></table></body></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -