📄 gtk-faq.sgml
字号:
<sect1 id="faq-Compile"><title>What do I need to compile GTK+? <emphasis>[GTK 2.x]</emphasis></title><para>GTK+ is a large package that is dependent on a number of othertools and libraries. It is recommended that you use precompiledbinary packages for your system if possible</para><para>To compile GTK+ from source you need a C compiler (gcc) andthe X Window System and associated development libraries and packageson your system.</para><para>You will also need to have installed the toolsand libraries that GTK+ depends upon. These are listed below in the orderin which they need to be installed:</para><itemizedlist spacing=compact><listitem><simpara> pkg-config(<ulink url="http://www.freedesktop.org/software/pkgconfig">pkg-config Site</ulink>)</simpara></listitem><listitem><simpara> GNU make(<ulink url="http://www.gnu.org/software/make/">GNU make Site</ulink>)</simpara></listitem><listitem><simpara> JPEG, PNG and TIFF image libraries(<ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/dependencies/">GTK+ Site</ulink>)</simpara></listitem><listitem><simpara> FreeType(<ulink url="http://www.freetype.org/">FreeType Site</ulink>)</simpara></listitem><listitem><simpara> fontconfig(<ulink url="http://www.fontconfig.org/">fontconfig Site</ulink>)</simpara></listitem><listitem><simpara> GNU libiconv library (if your system doesn't have iconv())(<ulink url="http://www.gnu.org/software/libiconv/">GNU libiconv Site</ulink>)</simpara></listitem><listitem><simpara> GNU gettext (if your system doesn't have gettext())(<ulink url="http://www.gnu.org/software/gettext/">GTK+ Site</ulink>)</simpara></listitem><listitem><simpara> GLib(<ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/">GTK+ Site</ulink>)</simpara></listitem><listitem><simpara> Pango(<ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/">GTK+ Site</ulink>)</simpara></listitem><listitem><simpara> ATK(<ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/">GTK+ Site</ulink>)</simpara></listitem><listitem><simpara> GTK+(<ulink url="ftp://ftp.gtk.org/pub/gtk/v2.2/">GTK+ Site</ulink>)</simpara></listitem></itemizedlist></sect1><!-- ----------------------------------------------------------------- --><sect1><title>Where can I get GTK+? <emphasis>[GTK 2.x]</emphasis></title><para>The canonical site is <ulinkurl="ftp://ftp.gtk.org/pub/gtk">ftp://ftp.gtk.org/pub/gtk</ulink>.</para><para>This site tends to get busy around the time of a newGTK+ release so try and use one of the mirror sites that arelisted in <ulinkurl="ftp://ftp.gtk.org/etc/mirrors">ftp://ftp.gtk.org/etc/mirrors</ulink></para><para>Here's a few mirror sites to get you started:</para><itemizedlist spacing=compact><listitem><simpara> Africa -<ulink url="ftp://ftp.is.co.za/applications/gimp">ftp://ftp.is.co.za/applications/gimp</ulink></simpara> </listitem><listitem><simpara> Australia -<ulinkurl="ftp://ftp.planetmirror.com/pub/gimp/gtk">ftp://ftp.planetmirror.com/pub/gimp/gtk</ulink></simpara> </listitem><listitem><simpara> Finland -<ulink url="ftp://ftp.funet.fi/pub/sci/graphics/packages/gimp/gtk">ftp://ftp.funet.fi/pub/sci/graphics/packages/gimp/gtk</ulink></simpara> </listitem><listitem><simpara> Germany -<ulink url="ftp://ftp.gwdg.de/pub/misc/grafik/gimp/gtk">ftp://ftp.gwdg.de/pub/misc/grafik/gimp/gtk</ulink></simpara> </listitem><listitem><simpara> Japan -<ulink url="ftp://sunsite.sut.ac.jp/pub/archives/packages/gimp/gtk">ftp://sunsite.sut.ac.jp/pub/archives/packages/gimp/gtk</ulink></simpara> </listitem><listitem><simpara> UK - <ulink url="http://www.mirror.ac.uk/sites/ftp.gimp.org/pub/gtk/">http://www.mirror.ac.uk/sites/ftp.gimp.org/pub/gtk/</ulink></simpara></listitem></itemizedlist></sect1><!-- ----------------------------------------------------------------- --><sect1><title>How do I configure/compile GTK+? <emphasis>[GTK 2.x]</emphasis></title><para>Generally, the minimum you need to do is issue the commands:</para><para><literallayout><literal>./configure</literal><literal>make</literal><literal>make install</literal></literallayout></para><para>in the GTK+ source directory.</para><para>This generally also holds true for each of the packages that GTK+depends upon, listed <link linkend="faq-Compile">above</link>.</para><para>There are various options that you can pass to the configure scriptin order to change its default settings. The one that you are most likelyto want to use is the <literal>--prefix</literal>argument, which defines where the package is to be install, e.g.</para><para><literallayout><literal>./configure --prefix=/usr</literal></literallayout></para></sect1><!-- ----------------------------------------------------------------- --><sect1><title>When compiling GTK+ I get an error like: <literal>make:file `Makefile' line 456: Syntax error</literal> <emphasis>[GTK 2.x]</emphasis></title><para>Make sure that you are using GNU make(use <literal>make -v</literal>to check). There are many weird and wonderful versions of makeout there, and not all of them handle the automaticallygenerated Makefiles.</para></sect1><!-- ----------------------------------------------------------------- --><sect1><title>I've compiled and installed GTK+, but I can't get anyprograms to link with it! <emphasis>[GTK 2.x]</emphasis></title><para>This problem is most often encountered when the GTK+libraries can't be found or are the wrong version. Generally,the compiler will complain about an 'unresolved symbol'.</para><para>Make sure that the libraries can befound. You want to edit <filename>/etc/ld.so.conf</filename> toinclude the directories which contain the GTK libraries,so it looks something like:</para><para><literallayout><literal>/usr/X11R6/lib</literal><literal>/usr/local/lib</literal></literallayout></para><para>Then you need to run /sbin/ldconfig as root. You canfind what libraries GTK requires using</para><para><literallayout><literal>pkg-config gtk+-2.0 --libs</literal></literallayout></para><para>If your system doesn't use ld.so to find libraries(such as Solaris), then you will have to use the LD_LIBRARY_PATHenvironment variable (or compile the path into your program, which I'mnot going to cover here). So, with a Bourne type shell you can do (ifyour GTK libraries are in /usr/local/lib):</para><para><literallayout><literal>export LD_LIBRARY_PATH=/usr/local/lib</literal></literallayout></para><para>and in a csh, you can do:</para><para><literallayout><literal>setenv LD_LIBRARY_PATH /usr/local/lib</literal></literallayout></para></sect1><!-- ----------------------------------------------------------------- --><sect1><title>When installing a GTK+ application, configure reportsthat it can't find GTK. <emphasis>[GTK 2.x]</emphasis></title><para>There are several common reasons for this:</para><itemizedlist><listitem><simpara>You have an old version of GTK installedsomewhere. You should remove this old copy, but note thatthis may break applications that have been compiled againstthe old version.</simpara></listitem><listitem><simpara><literal>pkg-config</literal> (or anothercomponent of GTK) isn't in your path, or there is an oldversion on your system. Type:</simpara><para><literallayout><literal>pkg-config gtk+-2.0 --modversion</literal></literallayout></para><para>to check for both of these. If it returns a valuedifferent from what you expect, then you have an oldversion of GTK on your system.</para></listitem><listitem><simpara>The ./configure script can't find the GTKlibraries. As ./configure compiles various test programs, it needs to beable to find the GTK libraries. See the question abovefor help on this. </simpara></listitem></itemizedlist><para>If none of the above help, then have a look inconfig.log, which is generated by ./configure as it runs. At thebottom will be the last action it took before failing. If it is asection of source code, copy the source code to a file and compile itwith the line just above it in config.log. If the compilation issuccessful, try executing it.</para></sect1></chapter><!-- ***************************************************************** --><chapter><title>Development of GTK+</title><!-- ----------------------------------------------------------------- --><sect1><title>Whats this CVS thing that everyone keeps talking about,and how do I access it? <emphasis>[GTK 2.x]</emphasis></title><para>CVS is the Concurrent Version System and is a verypopular means of version control for software projects. It isdesigned to allow multiple authors to simultanously operate on the samesource tree. This source tree is centrally maintained, but eachdeveloper has a local mirror of this repository that they maketheir changes to.</para><para>The GTK+ developers use a CVS repository to store themaster copy of the current development version of GTK+. Assuch, people wishing to contribute patches to GTK+ shouldgenerate them against the CVS version. Normal people shoulduse the packaged releases.</para><para>The CVS toolset is available as RPM packages from theusual RedHat sites. The latest version is available at <ulinkurl="http://download.cyclic.com/pub/">http://download.cyclic.com/pub/</ulink></para><para>Anyone can download the latest CVS version of GTK+ byusing anonymous access using the following steps:</para><itemizedlist><listitem><simpara> In a bourne shell descendant (e.g. bash) type:</simpara><para><literallayout><literal>CVSROOT=':pserver:anonymous@anoncvs.gnome.org:/cvs/gnome'</literal><literal>export CVSROOT</literal></literallayout></para></listitem><listitem><simpara>Next, the first time the source tree ischecked out, a cvs login is needed. </simpara><para><literallayout><literal>cvs login</literal></literallayout></para><para>This will ask you for a password. There is nopassword for cvs.gimp.org, so just enter a carriage return.</para></listitem><listitem><simpara>To get the tree and place it in a subdir of yourcurrent working directory, issue the command:</simpara><para><literallayout><literal>cvs -z3 get gtk+</literal></literallayout></para><para>Note that with the GTK+ 1.1 tree, glib has been moved toa separate CVS module, so if you don't have glib installed you willneed to get that as well:</para><para><literallayout><literal>cvs -z3 get glib</literal></literallayout></para></listitem></itemizedlist><para>The CVS archive stores both the current development version ofGTK+ (the CVS HEAD branch) and all current and past stable versions.If you want to retrieve a specific version of GTK+ you have to specifythe CVS tag corresponding to the version you want to checkout. If youwant to checkout the current GTK+ 2.2 stable source code, you would needto use the following command:</para><para><literallayout><literal>cvs -z3 get -r gtk-2-2 gtk+</literal></literallayout></para></sect1><!-- ----------------------------------------------------------------- --><sect1 id="faq-Patches"><title>How can I contribute to GTK+? <emphasis>[GTK 2.x]</emphasis></title><para>It's simple. If something doesn't work like you think itshould in a program, check the documentation to make sureyou're not missing something. If it is a true bug or missingfeature, track it down in the GTK+ source, change it, andthen generate a patch in the form of a 'context diff'. Thiscan be done using a command such as <literal>diff -ru<oldfile> <newfile></literal>.</para><para>The patch should then be attached to a bug report inthe GNOME bug tracking system, which can also be used to storegeneral patches(<ulink url="http://bugzilla.gnome.org">http://bugzilla.gnome.org</ulink>).</para><para>This method ensures that the patch will not be lost.</para></sect1><!-- ----------------------------------------------------------------- --><sect1><title>How do I know if my patch got applied, and if not, whynot? <emphasis>[GTK 2.x]</emphasis></title><para>If you have used the GNOME bug tracking system (as stated<link linkend="faq-Patches">above</link>) then the statusof your patch should be reflected in the bug report.</para><para>The GTK+ developers will generally add comments to the bugreport stating what needs to be done to get the patch applied,or why the patch is not appropriate.</para></sect1><!-- ----------------------------------------------------------------- --><sect1><title>What is the policy on incorporating new widgets intothe library? <emphasis>[GTK 2.x]</emphasis></title><para>This is up to the authors, so you will have to ask themonce you are done with your widget. As a general guideline,widgets that are generally useful, work, and are not adisgrace to the widget set will gladly be included.</para><para>The new widgets that get added to GTK+ are generally eitherreplacements for existing widgets that are no longerdeemed to be adequate, or have been developed externally to GTK+ buthave been widely tested. One possible avenue for this is via<ulink url="http://cvs.gnome.org/lxr/source/libegg/">libegg</ulink>.</para><para>Before you spend months of your valuable time implementing yourrevolutionary widget, it is highly recommended that you get somefeedback on your idea via the appropriate <link linkend="faq-MailLists">mailing list</link>.</para></sect1><!-- ----------------------------------------------------------------- --><sect1><title>Is anyone working on bindings for languages other thanC? <emphasis>[GTK 2.x]</emphasis></title><para>There is a list of <ulink url="http://www.gtk.org/bindings.html">language bindings</ulink> on the GTK+ website.</para><para>The 'official' language bindings are C++, Ada and Python.However, bindings for many other languages are available.</para></sect1></chapter><!-- ***************************************************************** --><chapter><title>Development with GTK+: the begining</title><!-- ----------------------------------------------------------------- --><sect1><title>How do I get started? <emphasis>[GTK 2.x]</emphasis></title><para>So, after you have installed GTK+ there are a couple ofthings that can ease you into developing applications with
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -