<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Chapter 26. Recommended Techniques</title> <link rel="stylesheet" href="style.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.73.2"> <link rel="start" href="index.html" title="Programming with gtkmm"> <link rel="up" href="index.html" title="Programming with gtkmm"> <link rel="prev" href="ch25s02.html" title="Custom Widgets"> <link rel="next" href="ch26s02.html" title="Using a gtkmm widget"> </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">Chapter 26. Recommended Techniques</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="ch25s02.html"><img src="../icons/prev.png" alt="Prev"></a> </td> <th width="60%" align="center"> </th> <td width="20%" align="right"> <a accesskey="n" href="ch26s02.html"><img src="../icons/next.png" alt="Next"></a> </td> </tr> </table> <hr> </div> <div class="chapter" lang="en"> <div class="titlepage"><div><div><h2 class="title"> <a name="sec-gathering"></a>Chapter 26. Recommended Techniques</h2></div></div></div> <div class="toc"> <p><b>Table of Contents</b></p> <ul> <li><span class="sect1"><a href="ch26.html#id2595258">Application lifetime</a></span></li> <li><span class="sect1"><a href="ch26s02.html">Using a <span class="application">gtkmm</span> widget</a></span></li> </ul> </div> <p>This section is simply a gathering of wisdom, general style guidelines and hints for creating <span class="application">gtkmm</span> applications. </p> <p>Use GNU <span class="application">autoconf</span> and <span class="application">automake</span>! They are your friends :) <span class="application">Automake</span> examines C files, determines how they depend on each other, and generates a <code class="filename">Makefile</code> so the files can be compiled in the correct order. <span class="application">Autoconf</span> permits automatic configuration of software installation, handling a large number of system quirks to increase portability.. </p> <p>Subclass Widgets to better organise your code. You should probably subclass your main <code class="classname">Window</code> at least. Then you can make your child Widgets and signal handlers members of that class. </p> <p>Create your own signals instead of passing pointers around. Objects can communicate with each other via signals and signal handlers. This is much simpler than objects holding pointers to each other and calling each other's methods. <span class="application">gtkmm</span>'s classes uses special versions of <code class="classname">Sigc::Signal</code>, but you should use normal <code class="classname">sigc::signal</code>s, as described in the <span class="application">libsigc++</span> documentation.</p> <div class="sect1" lang="en"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> <a name="id2595258"></a>Application lifetime</h2></div></div></div> <p>Most applications will have only one <code class="classname">Window</code>, or only one main window. These applications can use the <code class="function">Gtk::Main::run(Gtk::Window&)</code> overload. It shows the window and returns when the window has been hidden. This might happen when the user closes the window, or when your code decides to <code class="function">hide()</code> the window. You can prevent the user from closing the window (for instance, if there are unsaved changes) by overriding <code class="function">Gtk::Window::on_delete_event()</code>.</p> <p>Most of our examples use this technique.</p> </div> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="ch25s02.html"><img src="../icons/prev.png" alt="Prev"></a> </td> <td width="20%" align="center"> </td> <td width="40%" align="right"> <a accesskey="n" href="ch26s02.html"><img src="../icons/next.png" alt="Next"></a> </td> </tr> <tr> <td width="40%" align="left" valign="top">Custom Widgets </td> <td width="20%" align="center"><a accesskey="h" href="index.html"><img src="../icons/home.png" alt="Home"></a></td> <td width="40%" align="right" valign="top"> Using a <span class="application">gtkmm</span> widget</td> </tr> </table> </div> </body> </html>