📄 gtkfaq.txt
字号:
22..11.. WWhhaatt ddoo II nneeeedd ttoo rruunn GGTTKK++?? To compile GTK+, all you need is a C compiler (gcc) and the X Window System and associated libraries on your system. 22..22.. WWhheerree ccaann II ggeett GGTTKK++?? The canonical site is: ftp://ftp.gtk.org/pub/gtk This site tends to get busy around the time of a new GTK+ release so try and use one of the mirror sites that are listed in ftp://ftp.gtk.org/etc/mirrors Here's a few mirror sites to get you started: +o Africa - ftp://ftp.is.co.za/applications/gimp/ +o Australia - ftp://ftp.au.gimp.org/pub/gimp/ +o Finland - ftp://ftp.funet.fi/pub/sci/graphics/packages/gimp +o Germany - ftp://infosoc.uni-koeln.de/pub/ftp.gimp.org/ +o Japan - ftp://SunSITE.sut.ac.jp/pub/archives/packages/gimp/ +o UK - ftp://ftp.flirble.org/pub/X/gimp/ +o US - ftp://ftp.insync.net/pub/mirrors/ftp.gimp.org/ 22..33.. HHooww ddoo II ccoonnffiigguurree//ccoommppiillee GGTTKK++?? Generally, all you will need to do is issue the commands: ./configure make in the gtk+-version/ directory. 22..44.. WWhheenn ccoommppiilliinngg GGTTKK++ II ggeett aann eerrrroorr lliikkee:: mmaakkee:: ffiillee ``MMaakkeeffiillee'' lliinnee 445566:: SSyynnttaaxx eerrrroorr Make sure that you are using GNU make (use make -v to check). There are many weird and wonderful versions of make out there, and not all of them handle the automatically generated Makefiles. 22..55.. II''vvee ccoommppiilleedd aanndd iinnssttaalllleedd GGTTKK++,, bbuutt II ccaann''tt ggeett aannyy pprrooggrraammss ttoo lliinnkk wwiitthh iitt!! 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 +o Make sure that the libraries can be found. You want to edit /etc/ld.so.conf to include the directories which contain the GTK libraries, so it looks something like: /usr/X11R6/lib /usr/local/lib Then you need to run /sbin/ldconfig as root. You can find what direc- tory GTK is in using gtk-config --libs If your system doesn't use ld.so to find libraries (such as Solaris), then you will have to use the LD_LIBRARY_PATH environment variable (or compile the path into your program, which I'm not going to cover here). So, with a Bourne type shell you can do (if your GTK libraries are in /usr/local/lib): export LD_LIBRARY_PATH=/usr/local/lib and in a csh, you can do: setenv LD_LIBRARY_PATH /usr/local/lib +o Make sure the linker is finding the correct set of libraries. If you have a Linux distribution that installs GTK+ (e.g. RedHat 5.0) then this older version may be used. Now (assuming you have a RedHat system), issue the command rpm -e gtk gtk-devel You may also want to remove the packages that depend on gtk (rpm will tell you which ones they are). If you don't have a RedHat Linux sys- tem, check to make sure that neither /usr/lib /usr/local/lib the libraries libgtk, libgdk, libglib, or libgck. If they do exist, remove them (and any gtk include files, such as /usr/include/gtk and /usr/include/gdk) and reinstall gtk+. 22..66.. WWhheenn ccoommppiilliinngg pprrooggrraammss wwiitthh GGTTKK++,, II ggeett ccoommppiilleerr eerrrroorr mmeessssaaggeess aabboouutt nnoott bbeeiinngg aabbllee ttoo ffiinndd ""gglliibbccoonnffiigg..hh"" .. The header file "glibconfig.h" was moved to the directory $exec_prefix/lib/glib/include/. $exec_prefix is the directory that was specified by giving the --exec-prefix flags to ./configure when compiling GTK+. It defaults to $prefix, (specified with --prefix), which in turn defaults to /usr/local/. This was done because "glibconfig.h" includes architecture dependent information, and the rest of the include files are put in $prefix/include, which can be shared between different architectures. GTK+ includes a shell script, gtk-config, that makes it easy to find out the correct include paths. The GTK+ tutorial includes an example of using gtk-config for simple compilation from the command line. For information about more complicated configuration, see the file docs/gtk-config.txt in the GTK+ distribution. If you are trying to compile an old program, you may be able to work around the problem by configuring it with a command line like: CPPFLAGS="-I/usr/local/include/glib/include" ./configure for Bourne-compatible shells like bash, or for csh variants: setenv CPPFLAGS "-I/usr/local/include/glib/include" ./configure (Substitute the appropriate value of $exec_prefix for /usr/local.) 22..77.. WWhheenn iinnssttaalllliinngg aa GGTTKK++ aapppplliiccaattiioonn,, ccoonnffiigguurree rreeppoorrttss tthhaatt iitt ccaann''tt ffiinndd GGTTKK.. There are several common reasons for this: +o You have an old version of GTK installed somewhere. RedHat 5.0, for example, installs an older copy of GTK that may not work with the latest applications. You should remove this old copy, but note that in the case of RedHat 5.0 this will break the control-panel applications. +o gtk-config (or another component of GTK) isn't in your path, or there is an old version on your system. Type: gtk-config --version to check for both of these. If it returns a value different from what you expect, then you have an old version of GTK on your system. +o The ./configure script can't find the GTK libraries. As ./configure compiles various test programs, it needs to be able to find the GTK libraries. See the question above for help on this. If none of the above help, then have a look in config.log, which is generated by ./configure as it runs. At the bottom will be the last action it took before failing. If it is a section of source code, copy the source code to a file and compile it with the line just above it in config.log. If the compilation is successful, try executing it. 33.. DDeevveellooppmmeenntt ooff GGTTKK++ 33..11.. WWhhaattss tthhiiss CCVVSS tthhiinngg tthhaatt eevveerryyoonnee kkeeeeppss ttaallkkiinngg aabboouutt,, aanndd hhooww ddoo II aacccceessss iitt?? CVS is the Concurent Version System and is a very popular means of version control for software projects. It is designed to allow multiple authors to be able to simultanously operate on the same source tree. This source tree is centrally maintained, but each developer has a local mirror of this repository that they make there changes to. The GTK+ developers use a CVS repository to store the master copy of the current development version of GTK+. As such, people wishing to contribute patches to GTK+ should generate them against the CVS version. Normal people should use the packaged releases. The CVS toolset is available as RPM packages from the usual RedHat sites. The latest version is available at <http://download.cyclic.com/pub/> Anyone can download the latest CVS version of GTK+ by using anonymous access using the following steps: +o In a bourne shell descendant (e.g. bash) type: CVSROOT=':pserver:anonymous@anoncvs.gnome.org:/cvs/gnome' export CVSROOT +o Next, the first time the source tree is checked out, a cvs login is needed. cvs login This will ask you for a password. There is no password for cvs.gimp.org, so just enter a carriage return. +o To get the tree and place it in a subdir of your current working directory, issue the command: cvs -z3 get gtk+ Note that with the GTK+ 1.1 tree, glib has been moved to a separate CVS module, so if you don't have glib installed you will need to get that as well: cvs -z3 get glib 33..22.. HHooww ccaann II ccoonnttrriibbuuttee ttoo GGTTKK++?? It's simple. If something doesn't work like you think it should in a program, check the documentation to make sure you're not missing something. If it is a true bug or missing feature, track it down in the GTK+ source, change it, and then generate a patch in the form of a 'context diff'. This can be done using a command such as diff -ru <oldfile> <newfile>. Then upload the patchfile to: ftp://ftp.gtk.org/incoming along with a README file. Make sure you follow the naming conventions or your patch will just be deleted! The filenames should be of this form: gtk-<username>-<date yymmdd-n>.patch.gz gtk-<username>-<date yymmdd-n>.patch.README The "n" in the date indicates a unique number (starting from 0) of patches you uploaded that day. It should be 0, unless you upload more than one patch in the same day. Example: gtk-gale-982701-0.patch.gz gtk-gale-982701-0.patch.README Once you upload _a_n_y_t_h_i_n_g, send the README to ftp-admin@gtk.org 33..33.. HHooww ddoo II kknnooww iiff mmyy ppaattcchh ggoott aapppplliieedd,, aanndd iiff nnoott,, wwhhyy nnoott?? Uploaded patches will be moved to ftp://ftp.gtk.org/pub/gtk/patches where one of the GTK+ development team will pick them up. If applied, they will be moved to /pub/gtk/patches/old. Patches that aren't applied, for whatever reason, are moved to /pub/gtk/patches/unapplied or /pub/gtk/patches/outdated. At this point you can ask on the gtk-list mailing list why your patch wasn't applied. There are many possible reasons why patches may not be applied, ranging from it doesn't apply cleanly, to it isn't right. Don't be put off if your patch didn't make it first time round. 33..44.. WWhhaatt iiss tthhee ppoolliiccyy oonn iinnccoorrppoorraattiinngg nneeww wwiiddggeettss iinnttoo tthhee lliibbrraarryy?? This is up to the authors, so you will have to ask them once you are done with your widget. As a general guideline, widgets that are generally useful, work, and are not a disgrace to the widget set will gladly be included. 33..55.. IIss aannyyoonnee wwoorrkkiinngg oonn bbiinnddiinnggss ffoorr llaanngguuaaggeess ootthheerr tthhaann CC?? The GTK+ home page (http://www.gtk.org/) presents a list of GTK+ bindings. +o There are several C++ wrappers for GTK+. +o the gtk-- package, which is a very small wrapper for GTK+. You can find the home page at: http://www.cs.tut.fi/~p150650/gtk/gtk--.html. The FTP site is ftp://ftp.gtk.org/pub/gtk/gtk--. +o the VDK package, which was built as the base package of a GTK+ application Borland-like builder. The home page can be found at www.guest.net/homepages/mmotta/VDKHome. +o The wxWindows/Gtk package, a free C++ library for cross-platform GUI development. The home page of this package is http://www.freiburg.linux.de/~wxxt/. +o There are three known Objective-c bindings currently in development: +o The GNOME project's package of choice is objgtk. Objgtk is based on the Object class and is maintained by Elliot Lee. Apparently, objgtk is being accepted as the `standard' Objective-C binding for GTK+. +o If you are more inclined towards the GNUstep project, you may want to check out GTKKit by Helge Hess. The intention is to setup a GTK+ binding using the FoundationKit. GTKKit includes nicities like writing a XML-type template file to construct a GTK+ interface. +o The GToolKit package, which can be found at ftp://ftp.gtk.org/pub/gtk/objc-gtoolkit/. +o Perl bindings ftp://ftp.gtk.org/pub/gtk/perl +o Guile bindings. The home page is at http://www.ping.de/sites/zagadka/guile-gtk. By the way, Guile is the GNU Project's implemention of R4RS Scheme (the standard). If you like Scheme, you may want to take a look at this. +o David Monniaux reports: I've started a gtk-O'Caml binding system. The basics of the system, including callbacks, work fine. The current development is in http://www.ens-lyon.fr/~dmon- niau/arcs +o Several python bindings have been done: +o pygtk is at http://www.daa.com.au/~james/pygtk and ftp://ftp.gtk.org/pub/gtk/python +o python-gtk is at http://www.ucalgary.ca/~nascheme/python-gtk +o There's are a couple of OpenGL/Mesa widgets available for GTK+. I suggest you start at http://www.student.oulu.fi/~jlof/gtkglarea/index.html +o Last, there are a lot of other language bindings for languages such as Eiffel, TOM, Pascal, Pike, etc. 44.. DDeevveellooppmmeenntt wwiitthh GGTTKK++:: tthhee bbeeggiinniinngg 44..11.. HHooww ddoo II ggeett ssttaarrtteedd?? So, after you have installed GTK+ there are a couple of things that can ease you into developing applications with it. There is the GTK+ Tutorial <http://www.gtk.org/tutorial/>, which is undergoing development. This will introduce you to writing applications using C. The Tutorial doesn't (yet) contain information on all of the widgets that are in GTK+. For example code on how to use the basics of all the GTK+ widgets you should look at the file gtk/testgtk.c (and associated source files) within the GTK+ distribution. Looking at these exmaples will give you a good grounding on what the widgets can do. 44..22.. II ttrriieedd ttoo ccoommppiillee aa ssmmaallll HHeelllloo WWoorrlldd ooff mmiinnee,, bbuutt iitt ffaaiilleedd.. AAnnyy cclluuee?? Since you are good at coding, we will not deal with compile time error here :). The classic command line to compile a GTK+ based program is gcc -o myprg [c files list] `gtk-config --cflags --libs`
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -