📄 gtkfaq.txt
字号:
GTK+ FAQ Nathan Froyd, Tony Gale, Shawn T. Amundson, Emmanuel Deloget August 29th 1999 This document is intended to answer questions that are likely to be frequently asked by programmers using GTK+ or people who are just looking at using GTK+. ______________________________________________________________________ Table of Contents 1. General Information 1.1 Before anything else: the greetings 1.2 Authors 1.3 What is GTK+? 1.4 What is the + in GTK+? 1.5 Does the G in GTK+, GDK and GLib stand for? 1.6 Where is the documentation for GTK+? 1.7 Is there a mailing list (or mailing list archive) for GTK+? 1.8 How to get help with GTK+ 1.9 How to report bugs in GTK+ 1.10 Is there a Windows version of GTK+? 1.11 What applications have been written with GTK+? 1.12 I'm looking for an application to write in GTK+. How about an IRC client? 2. How to find, configure, install, and troubleshoot GTK+ 2.1 What do I need to run GTK+? 2.2 Where can I get GTK+? 2.3 How do I configure/compile GTK+? 2.4 When compiling GTK+ I get an error like: 2.5 I've compiled and installed GTK+, but I can't get any programs to link with it! 2.6 When compiling programs with GTK+, I get compiler error messages about not being able to find 2.7 When installing a GTK+ application, configure reports that it can't find GTK. 3. Development of GTK+ 3.1 Whats this CVS thing that everyone keeps talking about, and how do I access it? 3.2 How can I contribute to GTK+? 3.3 How do I know if my patch got applied, and if not, why not? 3.4 What is the policy on incorporating new widgets into the library? 3.5 Is anyone working on bindings for languages other than C? 4. Development with GTK+: the begining 4.1 How do I get started? 4.2 I tried to compile a small 4.3 What about using the 4.4 I use the backquote stuff in my makefiles, but my make process failed. 4.5 I want to add some configure stuff, how could I do this? 4.6 I try to debug my GTK+ application with gdb, but it hangs my X server when I hit some breakpoint. Any Idea ? 5. Development with GTK+: general questions 5.1 What widgets are in GTK? 5.2 Is GTK+ thread safe? How do I write multi-threaded GTK+ applications? 5.3 Why do this strange 'x io error' occur when I 5.4 Why don't the contents of a button move when the button is pressed? Here's a patch to make it work that way... 5.5 How to I identifiy a widgets top level window or other ancestor? 5.6 How do I catch a double click event (in a list widget, for example)? 5.7 By the way, what are the differences between signals and events? 5.8 I have my signal connected to the the (whatever) event, but it seems I don't catch it. What's wrong? 5.9 Is it possible to get some text displayed which is truncated to fit inside its allocation? 5.10 How do I make my window modal? / How do I make a single window active? 5.11 Why doesn't my widget (e.g. progressbar) update? 5.12 How do I attach data to some GTK+ object/widget? 5.13 How do I remove the data I have attached to an object? 5.14 How could I get any widgets position? 5.15 How do I set the size of a widget/window? How do I prevent the user resizing my window? 5.16 How do I add a popup menu to my GTK+ application? 5.17 How do I disable or enable a widget, such as a button? 5.18 Shouldn't the text argument in the gtk_clist_* functions be declared const? 6. Development with GTK+: widget specific questions 6.1 How do I find out about the selection of a GtkList? 6.2 I don't want the user of my applications to enter text into a GtkCombo. Any idea? 6.3 How do I catch a combo box change? 6.4 How can I define a separation line in a menu? 6.5 How can I right justify a menu, such as Help? 6.6 How do I add some underlined accelerators to menu items? 6.7 How do I right (or otherwise) justify a GtkLabel? 6.8 How do I set the color and font of a GtkLabel using a Resource File? 6.9 How do I configure Tooltips in a Resource File? 6.10 How do I use horizontal scrollbars with a GtkText widget? 6.11 I can't add more than (something like) 2000 chars in a GtkEntry. What's wrong? 6.12 How do I change the font of a GtkText widget? 6.13 How do I set the cursor position in a GtkText object? 7. About gdk 7.1 What is GDK? 7.2 How do I use color allocation? 8. About GLib 8.1 What is GLib? 8.2 How can I use the doubly linked lists? 8.3 Why use g_print, g_malloc, g_strdup and fellow glib functions? 8.4 What's a GScanner and how do I use one? 9. GTK+ FAQ Contributions, Maintainers and Copyright ______________________________________________________________________ 11.. GGeenneerraall IInnffoorrmmaattiioonn 11..11.. BBeeffoorree aannyytthhiinngg eellssee:: tthhee ggrreeeettiinnggss The FAQ authors want to thank: +o Havoc Pennington +o Erik Mouw +o Owen Taylor +o Tim Janik +o Thomas Mailund Jensen +o Joe Pfeiffer +o Andy Kahn +o Federico Mena Quintero +o Damon Chaplin +o and all the members of the GTK+ lists If we forgot you, please email us ! Thanks again (I know, it's really short :) 11..22.. AAuutthhoorrss The original authors of GTK+ were: +o Peter Mattis +o Spencer Kimball +o Josh MacDonald Since then, much has been added by others. Please see the AUTHORS file in the distribution for the GTK+ Team. 11..33.. WWhhaatt iiss GGTTKK++?? GTK+ is a small and efficient widget set designed with the general look and feel of Motif. In reality, it looks much better than Motif. It contains common widgets and some more complex widgets such as a file selection, and color selection widgets. GTK+ provides some unique features. (At least, I know of no other widget library which provides them). For example, a button does not contain a label, it contains a child widget, which in most instances will be a label. However, the child widget can also be a pixmap, image or any combination possible the programmer desires. This flexibility is adhered to throughout the library. 11..44.. WWhhaatt iiss tthhee ++ iinn GGTTKK++?? Peter Mattis informed the gtk mailing list that: "I originally wrote gtk which included the three libraries, libglib, libgdk and libgtk. It featured a flat widget hier- archy. That is, you couldn't derive a new widget from an existing one. And it contained a more standard callback mechanism instead of the signal mechanism now present in gtk+. The + was added to distinguish between the original version of gtk and the new version. You can think of it as being an enhancement to the original gtk that adds object oriented features." 11..55.. DDooeess tthhee GG iinn GGTTKK++,, GGDDKK aanndd GGLLiibb ssttaanndd ffoorr?? GTK+ == Gimp Toolkit GDK == Gtk+ Drawing Kit GLib == G Library 11..66.. WWhheerree iiss tthhee ddooccuummeennttaattiioonn ffoorr GGTTKK++?? In the GTK+ distribution's doc/ directory you will find the reference material for both GTK and GDK, this FAQ and the GTK Tutorial. In addition, you can find links to HTML versions of these documents by going to http://www.gtk.org/. A packaged version of the GTK Tutorial, with SGML, HTML, Postscript, DVI and text versions can be found in ftp://ftp.gtk.org/pub/gtk/tutorial There is also a book available that details programming with GTK+ and GDK which has been written by Eric Harlow. It is entitled "Developing Linux Applications with GTK+ and GDK" and is available at all good book stores. The ISBN is 0-7357-0021-4 The example code from Eric's book is available on-line at http://www.bcpl.net/~eharlow/book 11..77.. IIss tthheerree aa mmaaiilliinngg lliisstt ((oorr mmaaiilliinngg lliisstt aarrcchhiivvee)) ffoorr GGTTKK++?? Information on mailing lists relating to GTK+ can be found at: http://www.gtk.org/mailinglists.html 11..88.. HHooww ttoo ggeett hheellpp wwiitthh GGTTKK++ First, make sure your question isn't answered in the documentation, this FAQ or the tutorial. Done that? You're sure you've done that, right? In that case, the best place to post questions is to the GTK+ mailing list. 11..99.. HHooww ttoo rreeppoorrtt bbuuggss iinn GGTTKK++ Bugs should be reported to the GNOME bug tracking system (http://bugs.gnome.org). To report a problem about GTK+, send mail to submit@bugs.gnome.org. The subject of the mail should describe your problem. In the body of the mail, you should first include a "pseudo-header" that gives the package and version number. This should be separated by a blank line from the actual headers. Package: gtk+ Version: 1.2.0 Substitute 1.2.0 with the version of GTK+ that you have installed. Then describe the bug. Include: +o Information about your system. For instance: +o What operating system and version +o What version of X +o For Linux, what version of the C library And anything else you think is relevant. +o How to reproduce the bug. If you can reproduce it with the testgtk program that is built in the gtk/ subdirectory, that will be most convenient. Otherwise, please include a short test program that exhibits the behavior. As a last resort, you can also provide a pointer to a larger piece of software that can be downloaded. (Bugs that can be reproduced within the GIMP are almost as good as bugs that can be reproduced in testgtk. If you are reporting a bug found with the GIMP, please include the version number of the GIMP you are using) +o If the bug was a crash, the exact text that was printed out when the crash occured. +o Further information such as stack traces may be useful, but are not necessary. If you do send a stack trace, and the error is an X error, it will be more useful if the stacktrace is produced running the test program with the --sync command line option. 11..1100.. IIss tthheerree aa WWiinnddoowwss vveerrssiioonn ooff GGTTKK++?? There is an on going port of GTK+ to the Windows platform which is making impressive progress. See http://www.iki.fi/tml/gimp/win32 for more information. 11..1111.. WWhhaatt aapppplliiccaattiioonnss hhaavvee bbeeeenn wwrriitttteenn wwiitthh GGTTKK++?? A list of some GTK+ based application can be found on the GTK+ web server at http://www.gtk.org/apps/ and contains more than 350 applications. Failing that, look for a project to work on for the GNOME project, http://www.gnome.org/ Write a game. Write something that is useful. Some of these are: +o GIMP (http://www.gimp.org/), an image manipulation program +o AbiWord (http://www.abisource.com/), a professional word processor +o GUBI (http://www.SoftHome.net/pub/users/timj/gubi/index.htm), a user interface builder +o Gzilla (http://www.levien.com/gzilla/), a web browser +o SANE (http://www.azstarnet.com/~axplinux/sane/ ), a universal scanner interface +o XQF (http://www.botik.ru/~roma/quake/), a QuakeWorld/Quake2 server browser and launcher +o ElectricEyes (http://www.labs.redhat.com/ee.shtml), an image viewer that aims to be a free replacement for xv +o GPK - the General Proxy Kit (http://www.humanfactor.com/gpk/), an add-on library to permit thread-safe access to GTK+ +o GCK - the General Convenience Kit (http://www.ii.uib.no/~tomb/gck.html), miscellaneous functions intended to ease color handling, UI construction, vector operations, and math functions +o GDK Imlib (http://www.labs.redhat.com/imlib/), a fast image loading and manipulation library for GDK +o Glade (http://glade.pn.org/), a GTK+ based RAD tool which produces GTK+ applications In addition to the above, the GNOME project (http://www.gnome.org) is using GTK+ to build a free desktop for Linux. Many more programs can be found there. 11..1122.. II''mm llooookkiinngg ffoorr aann aapppplliiccaattiioonn ttoo wwrriittee iinn GGTTKK++.. HHooww aabboouutt aann IIRRCC cclliieenntt?? Ask on gtk-list for suggestions. There are at least three IRC clients already under development (probably more in fact. The server at http://www.forcix.cx/irc-clients.html list a bunch of them). +o girc. (Included with GNOME) +o Bezerk (http://www.gtk.org/~trog/) +o gsirc. (In the gnome CVS tree) 22.. HHooww ttoo ffiinndd,, ccoonnffiigguurree,, iinnssttaallll,, aanndd ttrroouubblleesshhoooott GGTTKK++
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -