Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 345aa895e80053137c21f8693106c3a0 > files > 4

gtkmm2.4-documentation-2.17.4-1mdv2010.0.noarch.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>gtkmm Frequently Asked Questions</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><meta name="description" content="Here are some frequently-asked questions and answers about gtkmm. If your questions aren't answered here then please email the gtkmm mailing list. If you would like to add to this FAQ, then please patch this file (gtkmm-faq.xml) or just send your suggestion to the mailing list."><link rel="start" href="index.html" title="gtkmm Frequently Asked Questions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gtkmm Frequently Asked Questions</th></tr></table><hr></div><div class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="gtkmm-faq"></a>gtkmm Frequently Asked Questions</h2></div><div><div class="abstract"><p class="title"><b>Abstract</b></p><p>Here are some frequently-asked questions and answers about
    gtkmm. If your questions aren't answered here then please email
    the <a class="ulink" href="http://www.gtkmm.org/mailinglist.shtml" target="_top">gtkmm mailing
    list</a>. If you would like to add to this FAQ, then please
    patch this file (gtkmm-faq.xml) or just send your suggestion to
    the <a class="ulink" href="http://www.gtkmm.org/mailinglist.shtml" target="_top">mailing
    list</a>.</p></div></div></div><hr></div><div class="qandaset"><dl><dt>1.  <a href="index.html#id3005736">gtkmm's place in the world.</a></dt><dd><dl><dt>1.1. <a href="index.html#id3005742">What is GTK+?</a></dt><dt>1.2. <a href="index.html#id2966706">What is gtkmm (Previously known as Gtk--)?</a></dt><dt>1.3. <a href="index.html#id3005771">Why is it named gtkmm?</a></dt><dt>1.4. <a href="index.html#id3005791">Why use gtkmm instead of GTK+?</a></dt><dt>1.5. <a href="index.html#id2965927">Why use libsigc++? Why not just use the regular GTK+ signal functions?</a></dt><dt>1.6. <a href="index.html#id2965961">Why isn't GTK+/GNOME itself written in C++.</a></dt><dt>1.7. <a href="index.html#id2965999">Why not just use Qt if you like C++ so much?</a></dt><dt>1.8. <a href="index.html#id2966027">What about Inti or gcode?</a></dt></dl></dd><dt>2.  <a href="index.html#id2966374">How good is gtkmm?</a></dt><dd><dl><dt>2.1. <a href="index.html#id2966380">What systems does it run under?</a></dt><dt>2.2. <a href="index.html#id2966419">How complete is it?</a></dt><dt>2.3. <a href="index.html#id2966440">Does gtkmm support all the C++ goodies like inheritance, polymorphism, etc?</a></dt><dt>2.4. <a href="index.html#id2966460">Does gtkmm use Standard C++ (STL) containers such as std::string and std::list</a></dt><dt>2.5. <a href="index.html#id2966832">Does gtkmm force STL-style interfaces onto GTK+ widgets in a way that is inappropriate, difficult, or badly-implemented?</a></dt><dt>2.6. <a href="index.html#id2966874">Does the gtkmm API use C types, such as structs?</a></dt><dt>2.7. <a href="index.html#id2966897">What applications have been written in gtkmm?</a></dt><dt>2.8. <a href="index.html#id2966920">How does gtkmm compare to Qt?</a></dt><dt>2.9. <a href="index.html#id2966974">Have you wrapped all of the GNOME APIs as well as GTK+?</a></dt><dt>2.10. <a href="index.html#id2966994">Is gtkmm "bloated"</a></dt></dl></dd><dt>3.  <a href="index.html#id2967037">Further information</a></dt><dd><dl><dt>3.1. <a href="index.html#id2967043">Is there a gtkmm mailing list?</a></dt><dt>3.2. <a href="index.html#id2967065">What documentation is there for gtkmm?</a></dt><dt>3.3. <a href="index.html#id2967090">Where can I find some example code?</a></dt></dl></dd><dt>4.  <a href="index.html#id2967105">Using gtkmm</a></dt><dd><dl><dt>4.1. <a href="index.html#id2967110">What compiler arguments should I use to compile a gtkmm program?</a></dt><dt>4.2. <a href="index.html#id2967151">My application complains that it can't find libgtkmm.so</a></dt><dt>4.3. <a href="index.html#id2967179">How can I build a static executable?</a></dt><dt>4.4. <a href="index.html#id2967218">How can I get the GTK+ object from a gtkmm object?</a></dt><dt>4.5. <a href="index.html#id3014942">How can I wrap a GTK+ widget in a gtkmm instance?</a></dt><dt>4.6. <a href="index.html#id3014961">Can I use C++ exceptions with gtkmm?</a></dt><dt>4.7. <a href="index.html#id3014992">How can I use Glade and/or libglade with gtkmm?</a></dt><dt>4.8. <a href="index.html#id3015036">What does Gtk::manage(widget) do?</a></dt><dt>4.9. <a href="index.html#id3015052">How can I learn about arranging widgets? I am confused by the packing options</a></dt><dt>4.10. <a href="index.html#id3015075">I'm used to MFC. Where's the Document and the View? or How do I use the Document/View idea? or How do I use the MVC pattern?</a></dt><dt>4.11. <a href="index.html#id3015117">How do I load pixmaps for use with gtkmm?</a></dt><dt>4.12. <a href="index.html#id3015136">Is gtkmm thread-safe?</a></dt><dt>4.13. <a href="index.html#id3015200">Why does my application seem to segfault inside a dynamic_cast&lt;&gt;
in gtkmm?</a></dt></dl></dd></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="id3005736"></a>1. gtkmm's place in the world.</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>1.1. <a href="index.html#id3005742">What is GTK+?</a></dt><dt>1.2. <a href="index.html#id2966706">What is gtkmm (Previously known as Gtk--)?</a></dt><dt>1.3. <a href="index.html#id3005771">Why is it named gtkmm?</a></dt><dt>1.4. <a href="index.html#id3005791">Why use gtkmm instead of GTK+?</a></dt><dt>1.5. <a href="index.html#id2965927">Why use libsigc++? Why not just use the regular GTK+ signal functions?</a></dt><dt>1.6. <a href="index.html#id2965961">Why isn't GTK+/GNOME itself written in C++.</a></dt><dt>1.7. <a href="index.html#id2965999">Why not just use Qt if you like C++ so much?</a></dt><dt>1.8. <a href="index.html#id2966027">What about Inti or gcode?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="id3005742"></a><a name="id3005744"></a><p><b>1.1.</b></p></td><td align="left" valign="top"><p>What is GTK+?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>GTK+ is the GUI widget toolkit, written in C, which serves as the foundation for the GNOME project as well as many stand-alone applications. GTK+ is the foundation on which gtkmm is built. See <a class="ulink" href="http://www.gtk.org" target="_top">http://www.gtk.org</a>.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966706"></a><a name="id2966688"></a><p><b>1.2.</b></p></td><td align="left" valign="top"><p>What is gtkmm (Previously known as Gtk--)?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>gtkmm is a C++ wrapper for GTK+. That is, it is a language binding that lets you use GTK+ from C++. This includes support for C++ features such as inheritance, polymorphism and other powerful techniques which C++ programmers expect to have at their disposal.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3005771"></a><a name="id3005773"></a><p><b>1.3.</b></p></td><td align="left" valign="top"><p>Why is it named gtkmm?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p> gtkmm was orignally named gtk-- because GTK+ already has a + in the name. However, as -- is not easily indexed by search engines the package generally went by the name gtkmm, and that's what we stuck with.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3005791"></a><a name="id3005793"></a><p><b>1.4.</b></p></td><td align="left" valign="top"><p>Why use gtkmm instead of GTK+?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><div class="orderedlist"><ol type="1"><li><p>gtkmm allows you to write code using normal C++ techniques such as encapsulation, derivation, and polymorphism. As a C++ programmer you probably already realise that this leads to clearer and better organised code.</p></li><li><p>gtkmm is more type-safe, so the compiler can detect errors that would only be detected at run time when using C. This use of specific types also makes the API clearer because you can see what types should be used just by looking at a method's declaration.</p></li><li><p>Inheritance can be used to derive new widgets. The derivation of new widgets in GTK+ C code is so complicated and error prone that almost no C coders do it. As a C++ developer you know that derivation is an essential Object Orientated technique.</p></li><li><p>Member instances can be used, simplifying memory management. All GTK+ C widgets are dealt with by use of pointers. As a C++ coder you know that pointers should be avoided where possible.</p></li><li><p>Less code. The GTK+ C object model uses prefixed function names and cast macros. For instance:</p><pre class="programlisting">gtk_button_set_text(GTK_BUTTON(button), "sometext");</pre><p>gtkmm C++ code is shorter and clearer. For instance:</p><pre class="programlisting">button.set_text("sometext");</pre></li><li><p>There's no need to worry about GTK+'s inconsistent reference-counting policy.</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id2965927"></a><a name="id2965929"></a><p><b>1.5.</b></p></td><td align="left" valign="top"><p>Why use libsigc++? Why not just use the regular GTK+ signal functions?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><div class="orderedlist"><ol type="1"><li><p>GTK+ signals aren't typesafe, so the compiler can't tell you whether your callback has the wrong number or type of arguments or return value.</p></li><li><p>They can only be used with functions or static methods. With libsigc++ callbacks can also be instance methods, using the member data of a particular object. They can also be virtual methods which you could override in a derived class.</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id2965961"></a><a name="id2965964"></a><p><b>1.6.</b></p></td><td align="left" valign="top"><p>Why isn't GTK+/GNOME itself written in C++.</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><div class="orderedlist"><ol type="1"><li><p>C is a simpler language so more people are familiar with it, particularly on Unix.</p></li><li><p>C can be wrapped by any other language, making the API available to more developers.</p></li><li><p>GTK+ and GNOME have very well organised C code, much more sane than most of the gnarly C code that we encounter. This is partly due to it's C-based object-orientated structure.</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id2965999"></a><a name="id2966001"></a><p><b>1.7.</b></p></td><td align="left" valign="top"><p>Why not just use Qt if you like C++ so much?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>gtkmm developers tend to prefer gtkmm to Qt because gtkmm does things in a more C++ way. Qt originates from a time when C++ and the standard library were not standardised or well supported by compilers. It therefore duplicates a lot of stuff that is now in the standard library, such as containers and type information. Most significantly, they modified the C++ language to provide signals, so that Qt classes can not be used easily with non-Qt classes.  gtkmm was able to use standard C++ to provide signals without changing the C++ language.</p><p>Also, gtkmm and gnomemm allow you to build software which works more closely with the GNOME desktop.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966027"></a><a name="id2966029"></a><p><b>1.8.</b></p></td><td align="left" valign="top"><p>What about Inti or gcode?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Inti was a RedHat project which aimed to create a monolothic C++
programming framework palatable to corporate customers, and
which could be led by RedHat. Among other things, it was intended to include a
GTK+ binding for C++. That binding was to be similar, but less
versatile, than gtkmm. Inti did not release any code, though some existed in CVS. That project was discontinued see <a class="ulink" href="http://sources.redhat.com/ml/inti/2002-q2/msg00001.html" target="_top">here</a>. The Inti name has now been adopted by the previously-named gcode project.</p><p>GCode/Inti seems to have inherited some of the original Inti's code while also
tracking gtkmm. As far as we can tell, the only difference is that
GCode uses less C++ techniques, preferring to expose more of the GTK+
C API. At the present time, the gcode/inti FAQ makes false suggestions about gtkmm - See the questions about <a class="link" href="index.html#question-stl-style" title="Question">STL-style iterfaces</a> and <a class="link" href="index.html#question-c-types" title="Question">C types</a>. Also, gcode/inti forces the use of a memory management system that is equivalent to gtkmm's optional Gtk::manage() feature. It does not allow the complete range of normal C++ memory management techniques.
</p><p>We don't know why the author chose to start a
separate and secret project instead of helping the gtkmm community.</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="id2966374"></a>2. How good is gtkmm?</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>2.1. <a href="index.html#id2966380">What systems does it run under?</a></dt><dt>2.2. <a href="index.html#id2966419">How complete is it?</a></dt><dt>2.3. <a href="index.html#id2966440">Does gtkmm support all the C++ goodies like inheritance, polymorphism, etc?</a></dt><dt>2.4. <a href="index.html#id2966460">Does gtkmm use Standard C++ (STL) containers such as std::string and std::list</a></dt><dt>2.5. <a href="index.html#id2966832">Does gtkmm force STL-style interfaces onto GTK+ widgets in a way that is inappropriate, difficult, or badly-implemented?</a></dt><dt>2.6. <a href="index.html#id2966874">Does the gtkmm API use C types, such as structs?</a></dt><dt>2.7. <a href="index.html#id2966897">What applications have been written in gtkmm?</a></dt><dt>2.8. <a href="index.html#id2966920">How does gtkmm compare to Qt?</a></dt><dt>2.9. <a href="index.html#id2966974">Have you wrapped all of the GNOME APIs as well as GTK+?</a></dt><dt>2.10. <a href="index.html#id2966994">Is gtkmm "bloated"</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966380"></a><a name="id2966382"></a><p><b>2.1.</b></p></td><td align="left" valign="top"><p>What systems does it run under?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>gtkmm should run under any UNIX-type system with the
proper compilers and libraries installed. The GNU C++ compiler (g++,
part of gcc) together with the GNU toolset (such as found on Linux and
*BSD systems) comprise its default build environment.</p><p>gtkmm can also be be built and used with:
</p><div class="orderedlist"><ol type="1"><li><p>Sun's Forte C++, on Solaris.</p></li><li><p>Windows, with the mingw build tools.</p></li></ol></div><p>
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966419"></a><a name="id2966421"></a><p><b>2.2.</b></p></td><td align="left" valign="top"><p>How complete is it?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>gtkmm tries to offer all of the functionality offered by GTK+. This means that you should be able to do anything with gtkmm that's supported by GTK+, and do it more easily. If something isn't covered then we want to know about it.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966440"></a><a name="id2966442"></a><p><b>2.3.</b></p></td><td align="left" valign="top"><p>Does gtkmm support all the C++ goodies like inheritance, polymorphism, etc?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes. gtkmm objects are normal C++ objects which implement the GTK+ inheritance model through C++ inheritance. You can do with the gtkmm widgets everything that you can do with any other C++ class.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966460"></a><a name="id2966463"></a><p><b>2.4.</b></p></td><td align="left" valign="top"><p>Does gtkmm use Standard C++ (STL) containers such as std::string and std::list</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes, we believe in reusing standard C++ code wherever
possible. This might not be obvious at first because:
</p><div class="orderedlist"><ol type="1"><li><p>gtkmm has Glib::ustring which has almost the same
interface as std::string.  This new type exists because the C++
standard does not support UTF8-encoded strings.</p></li><li><p>The gtkmm API uses types such as
Glib::ListHandle&lt;int&gt; which can be assigned to almost any
standard C++ container, such as std::list or std::vector. These
intermediate types have been used instead of forcing you to use
any particular container.</p></li></ol></div><p>
</p><p>In addition, some widgets, such as Gtk::TreeView, have
interfaces which are very similar to the standard containers. For
instance, you can iterate through the selected rows.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966832"></a><a name="question-stl-style"></a><p><b>2.5.</b></p></td><td align="left" valign="top"><p>Does gtkmm force STL-style interfaces onto GTK+ widgets in a way that is inappropriate, difficult, or badly-implemented?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
No, we do not force you. We have provided STL-style interfaces for some container widgets, to allow you to iterate over the child widgets, but these are in addition the the simpler interfaces. We have done this because we believe that STL-style interfaces sometimes require too much code to perform simple tasks. On the other hand, some people religiously prefer STL-code wherever possible. You have the choice.
</p><p>
These STL-interfaces are implemented with quite simple code and have been found to work without problems. There are no known bugs, as you can see on the bugs page.
</p><p>
Some classes such as Gtk::TextBuffer have only an STL-style interface. This is because the underlying widget has an STL-style interface, implemented in C. So this is the most appropriate, and easiest, way to wrap that API in C++.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966874"></a><a name="question-c-types"></a><p><b>2.6.</b></p></td><td align="left" valign="top"><p>Does the gtkmm API use C types, such as structs?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>No, we wrap almost all parameters as C++ classes. which use C++ memory management. If you find parameters that use C types without good reason then we want to know about it.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966897"></a><a name="id2966899"></a><p><b>2.7.</b></p></td><td align="left" valign="top"><p>What applications have been written in gtkmm?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Check out the list of applications on the <a class="ulink" href="http://www.gtkmm.org/extra.shtml" target="_top">Additional Resources</a> page from the gtkmm site.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966920"></a><a name="id2966922"></a><p><b>2.8.</b></p></td><td align="left" valign="top"><p>How does gtkmm compare to Qt?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><div class="orderedlist"><ol type="1"><li><p>gtkmm uses pure C++. Qt requires extensions to C++ that are parsed by the moc  pre-processor.</p></li><li><p>gtkmm uses std::string, std::list, std::vector, iterators, etc. Qt has it's own Qt-specific containers.</p></li><li><p>With gtkmm normal C++ memory management can be used. Qt demands that all widgets are dealt with as pointers, and that deletion of widgets is surrendered to parent widgets.</p></li><li><p>Arrangement of widgets seems to be simpler in gtkmm. In Qt, Containers and Layouts are separate classes, and child widgets must be added to both. </p></li><li><p>The gtkmm API tends to be more explicit. The behaviour of Qt classes is often dependent upon the implicit effects of confusingly-overridden constructors.</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966974"></a><a name="id2966976"></a><p><b>2.9.</b></p></td><td align="left" valign="top"><p>Have you wrapped all of the GNOME APIs as well as GTK+?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>We have wrapped gnome-libs, in gnomemm, which provides the additional GNOME functionality. Some parts, such as the gnome-vfs, and Bonobo wrappers are not yet mature.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2966994"></a><a name="id2966996"></a><p><b>2.10.</b></p></td><td align="left" valign="top"><p>Is gtkmm "bloated"</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>No, gtkmm is a thin wrapper. People might be surprised at the large size of the gtkmm source tarball. The gtkmm tarball is large because
</p><div class="orderedlist"><ol type="1"><li><p>It contains lots of generated HTML documentation - the reference documentation, the book, and this FAQ, for instance. It also contains the Docbook XML sources for that documentation.</p></li><li><p>It contains the .hg/.ccg source files used to generate the .h/.cc C++ source files, as well as those generated files.</p></li></ol></div><p>
We ship these generated files to reduce the dependencies needed to build gtkmm itself, to make your life easier.
</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="id2967037"></a>3. Further information</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>3.1. <a href="index.html#id2967043">Is there a gtkmm mailing list?</a></dt><dt>3.2. <a href="index.html#id2967065">What documentation is there for gtkmm?</a></dt><dt>3.3. <a href="index.html#id2967090">Where can I find some example code?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="id2967043"></a><a name="id2967045"></a><p><b>3.1.</b></p></td><td align="left" valign="top"><p>Is there a gtkmm mailing list?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes. See the <a class="ulink" href="http://www.gtkmm.org/mailinglist.shtml" target="_top">subscription page</a></p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2967065"></a><a name="id2967067"></a><p><b>3.2.</b></p></td><td align="left" valign="top"><p>What documentation is there for gtkmm?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>There is a largely complete tutorial, automatically-generated reference documentation, this faq, and a wealth of running examples available at the <a class="ulink" href="http://www.gtkmm.org/docs/gtkmm-2.4/docs/" target="_top">documentation page</a></p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2967090"></a><a name="id2967092"></a><p><b>3.3.</b></p></td><td align="left" valign="top"><p>Where can I find some example code?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>See the examples directory in the gtkmm distribution. There are also several large third-party applications whose source you can examine.</p></td></tr><tr class="qandadiv"><td align="left" valign="top" colspan="2"><h3 class="title"><a name="id2967105"></a>4. Using gtkmm</h3></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>4.1. <a href="index.html#id2967110">What compiler arguments should I use to compile a gtkmm program?</a></dt><dt>4.2. <a href="index.html#id2967151">My application complains that it can't find libgtkmm.so</a></dt><dt>4.3. <a href="index.html#id2967179">How can I build a static executable?</a></dt><dt>4.4. <a href="index.html#id2967218">How can I get the GTK+ object from a gtkmm object?</a></dt><dt>4.5. <a href="index.html#id3014942">How can I wrap a GTK+ widget in a gtkmm instance?</a></dt><dt>4.6. <a href="index.html#id3014961">Can I use C++ exceptions with gtkmm?</a></dt><dt>4.7. <a href="index.html#id3014992">How can I use Glade and/or libglade with gtkmm?</a></dt><dt>4.8. <a href="index.html#id3015036">What does Gtk::manage(widget) do?</a></dt><dt>4.9. <a href="index.html#id3015052">How can I learn about arranging widgets? I am confused by the packing options</a></dt><dt>4.10. <a href="index.html#id3015075">I'm used to MFC. Where's the Document and the View? or How do I use the Document/View idea? or How do I use the MVC pattern?</a></dt><dt>4.11. <a href="index.html#id3015117">How do I load pixmaps for use with gtkmm?</a></dt><dt>4.12. <a href="index.html#id3015136">Is gtkmm thread-safe?</a></dt><dt>4.13. <a href="index.html#id3015200">Why does my application seem to segfault inside a dynamic_cast&lt;&gt;
in gtkmm?</a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a name="id2967110"></a><a name="id2967113"></a><p><b>4.1.</b></p></td><td align="left" valign="top"><p>What compiler arguments should I use to compile a gtkmm program?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>For gtkmm 2, you should use pkg-config. For instance, for gtkmm 2.0/2.2:</p><p><span class="command"><strong>pkg-config gtkmm-2.0 --libs --cflags</strong></span></p><p>Or for gtkmm 2.4, wich installs in parallel with gtkmm 2.0/2.2:</p><p><span class="command"><strong>pkg-config gtkmm-2.4 --libs --cflags</strong></span></p><p>You should use pkg-config's PKG_CHECK_MODULES macro in your configure.in file, as demonstrated in the gtkmm_hello package.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2967151"></a><a name="id2967153"></a><p><b>4.2.</b></p></td><td align="left" valign="top"><p>My application complains that it can't find libgtkmm.so</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Since this is the single most asked question about running GTK+ programs, we'll answer it here, even though it is in the GTK+ FAQ. Make sure the /usr/local/lib (the default install dir for gtkmm) is properly configured in your /etc/ldconf or that it is in your LD_LIBRARY_PATH environment variable.</p><p>Alternatively, specify another prefix when running configure. For instance, on RedHat, you should do this: ./configure --prefix=/usr</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2967179"></a><a name="id2967181"></a><p><b>4.3.</b></p></td><td align="left" valign="top"><p>How can I build a static executable?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>gtkmm is pre-installed on most linux distributions so you don't really need to, but you can reconfigure gtkmm like so:</p><p><span class="command"><strong>./configure --enable-static</strong></span></p><p><span class="command"><strong>make</strong></span></p><p><span class="command"><strong>make install</strong></span></p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2967218"></a><a name="id2967220"></a><p><b>4.4.</b></p></td><td align="left" valign="top"><p>How can I get the GTK+ object from a gtkmm object?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>If you need some GTK+ functionality which is not supported through gtkmm, you can call <span class="command"><strong>Gtk::Widget::gobj()</strong></span> (<span class="command"><strong>gtkobj()</strong></span> in gtkmm version 1.x) which will return a pointer to the plain C GTK+ data structure. You can then operate directly on this C object as you would in any GTK+ program.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3014942"></a><a name="id3014944"></a><p><b>4.5.</b></p></td><td align="left" valign="top"><p>How can I wrap a GTK+ widget in a gtkmm instance?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Glib::wrap() will give you a pointer to gtkmm object. It is an
overloaded function, so it will give you an instance of the appropriate
class.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3014961"></a><a name="id3014963"></a><p><b>4.6.</b></p></td><td align="left" valign="top"><p>Can I use C++ exceptions with gtkmm?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Yes, it is possible but it is not a very good idea. The official
answer is that, since plain C doesn't know what a C++ exception is,
you can use exceptions in your gtkmm code as long as there are no C
functions in your call stack between the thrower and the catcher. This
means that you have to catch your exception locally.</p><p>You will be warned at runtime
about uncaught exceptions, and you can specify a different handler for
uncaught exceptions.  Some gtkmm methods do even use exceptions to report
errors.  The exceptions types that might be thrown are listed in the
reference documentation of these methods.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3014992"></a><a name="id3014994"></a><p><b>4.7.</b></p></td><td align="left" valign="top"><p>How can I use Glade and/or libglade with gtkmm?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><div class="orderedlist"><ol type="1"><li><p>Use libglademm, which is part of gnomemm and wraps libglade.
It allows you to load widget information from the XML user interface
description files that Glade generates at runtime. This method is strongly
recommended. Experience has shown that it works well for large projects, and
there is a lot of example code out there you can look at. For an introduction,
see the corresponding chapter in the gtkmm tutorial.</p></li><li><p>Alternatively, Glade 2 can output C++ code instead of C code,
when using <a class="ulink" href="http://home.wtal.de/petig/" target="_top">Glade--</a>, which is not part of gnomemm.
Note that code generation is a deprecated feature in Glade 3. For questions
regarding Glade--, please use its own mailing list.</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id3015036"></a><a name="id3015038"></a><p><b>4.8.</b></p></td><td align="left" valign="top"><p>What does Gtk::manage(widget) do?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>- This means 'The container widget will delete this widget.' Some people prefer to use it so that they don't need to worry about when to delete their widgets. Gtk::manage() should only be used when add()ing a widget to a container widget.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3015052"></a><a name="id3015054"></a><p><b>4.9.</b></p></td><td align="left" valign="top"><p>How can I learn about arranging widgets? I am confused by the packing options</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Glade is a great way to see what can be done with GTK+ and GNOME
widgets. Use Glade to explore the choice of widgets and to see how
they can be put together. You should then be able to use the same
settings as arguments to your widget constructors, and to the add()
and pack() method. Or you could us libglademm to load the GUI at runtime.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3015075"></a><a name="id3015077"></a><p><b>4.10.</b></p></td><td align="left" valign="top"><p>I'm used to MFC. Where's the Document and the View? or How do I use the Document/View idea? or How do I use the MVC pattern?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><div class="orderedlist"><ol type="1"><li><p>Document/View (which is a useful version of MVC) is not supported directly by GTK+, though it is commonly used by GTK+ programmers.  However, the TextView and TreeView interfaces are split up into model and view.</p></li><li><p>The <a class="ulink" href="http://bakery.sourceforge.net/" target="_top">Bakery</a> library makes it very easy for  gtkmm/gnomemm C++ coders to use the Document/View framework.</p></li></ol></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id3015117"></a><a name="id3015120"></a><p><b>4.11.</b></p></td><td align="left" valign="top"><p>How do I load pixmaps for use with gtkmm?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Use Gdk::Pixbuf and/or Gtk::Image.  Both are easy to use and support a wide range of image file types via pixbuf loader plugins.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3015136"></a><a name="id3015139"></a><p><b>4.12.</b></p></td><td align="left" valign="top"><p>Is gtkmm thread-safe?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>Paul Davis wrote:</p><p>Neither X, nor GDK nor GTK+ nor gtkmm are thread safe by
themselves. You must use either the gdk_threads_{enter,leave}() functions to
protect any and every call to GDK/GTK+/gtkmm functions, or
alternatively, ensure that only a single thread makes such calls. One
common way to do this is to have non-GUI threads send requests to the
GUI thread via a pipe.  The pipe is hooked into the main glib event
loop used by GTK.
</p><p>
Personally, i have always used the single-threaded approach, which I
find much more suitable for my apps.
</p><p>
Note that glibmm comes with Glib::Dispatcher, which implements
a cross-thread signal using the pipe approach described above.
</p><p>Andreas Rottmann added:</p><p>
If you need a more sophisticated cross-thread message-passing
approach, take a look at <a class="ulink" href="http://libsigcx.sourceforge.net" target="_top">libsigc++ extras</a>. It
provides cross-thread, typesafe slot invocation on top of <a class="ulink" href="http://libsigc.sourceforge.net" target="_top">libsigc++</a> and comes with
a <a class="ulink" href="http://libsigcx.sourceforge.net/docs/sigcx_starting.html" target="_top">gtkmm
example</a>.
</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id3015200"></a><a name="id3015202"></a><p><b>4.13.</b></p></td><td align="left" valign="top"><p>Why does my application seem to segfault inside a dynamic_cast&lt;&gt;
in gtkmm?</p></td></tr><tr class="answer"><td align="left" valign="top"></td><td align="left" valign="top"><p>
gcc 2.96 and earlier have a bug which prevents use of dynamic_cast&lt;&gt;
during a constructor. This is only a problem when you derive a new
class from a gtkmm class and specify a specific base class
constructor. You can avoid this by using a different constructor. For instance, instead of using the
Gtk::Button("sometext") constructor, you could use the
default constructor and then call Gtk::Button::set_label().
See this <a class="ulink" href="http://bugzilla.gnome.org/show_bug.cgi?id=78578" target="_top">bug report</a> for more information. This bug does not apply to all non-default constructors - if you are using an old compiler then you should just try it and see.
</p></td></tr></tbody></table></div></div><div class="navfooter"><hr></div></body></html>