2007-02-10 23:08:42 +01:00
|
|
|
<?xml version='1.0' encoding="ISO-8859-1"?>
|
2005-04-22 12:27:37 +02:00
|
|
|
<partintro>
|
2007-02-07 23:15:34 +01:00
|
|
|
<para>
|
|
|
|
Several useful developer tools have been build around GObject technology.
|
|
|
|
The next sections briefly introduce them and link to the respective project pages.
|
|
|
|
</para>
|
2005-04-22 12:27:37 +02:00
|
|
|
</partintro>
|
2004-11-04 15:55:05 +01:00
|
|
|
|
2005-04-22 12:27:37 +02:00
|
|
|
<chapter id="tools-gob">
|
|
|
|
<title>GObject builder</title>
|
|
|
|
|
|
|
|
<para>
|
2007-02-07 23:15:34 +01:00
|
|
|
Writing GObjects can be a tedious task. It requires a lot of typing and just
|
|
|
|
doing a copy/paste requires a great deal of care.
|
|
|
|
One obvious idea is to use some sort of templates for the class skeletons.
|
|
|
|
and then run them through a special tool to generate the real C files.
|
|
|
|
<ulink url="http://www.5z.com/jirka/gob.html">GOB/</ulink> (or GOB2) is such
|
|
|
|
a tool. It is a preprocessor which can be used to build GObjects
|
|
|
|
with inline C code so that there is no need to edit the generated C code.
|
|
|
|
The syntax is inspired by Java and Yacc or Lex. The implementation is
|
|
|
|
intentionally kept simple: the inline C code provided by the user
|
|
|
|
is not parsed.
|
2005-04-22 12:27:37 +02:00
|
|
|
</para>
|
|
|
|
</chapter>
|
|
|
|
|
2005-05-27 14:04:54 +02:00
|
|
|
<chapter id="tools-ginspector">
|
2007-02-07 23:15:34 +01:00
|
|
|
<title>Graphical inspection of GObjects</title>
|
2005-05-27 14:04:54 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Yet another tool that you may find helpful when working with
|
|
|
|
GObjects is <ulink
|
|
|
|
url="http://sourceforge.net/projects/g-inspector">G-Inspector</ulink>. It
|
2007-11-13 08:10:42 +01:00
|
|
|
is able to display GLib/GTK+ objects and their properties.
|
2005-05-27 14:04:54 +02:00
|
|
|
</para>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
|
2005-04-22 12:27:37 +02:00
|
|
|
<chapter id="tools-refdb">
|
|
|
|
<title>Debugging reference count problems</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The reference counting scheme used by GObject does solve quite
|
|
|
|
a few memory management problems but also introduces new sources of bugs.
|
2005-05-27 14:04:54 +02:00
|
|
|
In large applications, finding the exact spot where the reference count
|
2005-04-22 12:27:37 +02:00
|
|
|
of an Object is not properly handled can be very difficult. Hopefully,
|
2005-05-27 14:04:54 +02:00
|
|
|
there exist a tool named <ulink url="http://refdbg.sf.net/">refdbg/</ulink>
|
2005-04-22 12:27:37 +02:00
|
|
|
which can be used to automate the task of tracking down the location
|
|
|
|
of invalid code with regard to reference counting. This application
|
|
|
|
intercepts the reference counting calls and tries to detect invalid behavior.
|
2007-11-13 08:10:42 +01:00
|
|
|
It supports a filter-rule mechanism to let you trace only the objects you are
|
|
|
|
interested in and it can be used together with GDB.
|
2005-04-22 12:27:37 +02:00
|
|
|
</para>
|
2006-01-26 20:28:33 +01:00
|
|
|
<para>
|
|
|
|
<indexterm><primary>g_trap_object_ref</primary></indexterm>
|
|
|
|
Note that if GObject has been compiled with <option>--enable-debug=yes</option>,
|
|
|
|
it exports a trap variable
|
|
|
|
<programlisting>
|
|
|
|
static volatile GObject *g_trap_object_ref;
|
|
|
|
</programlisting>
|
|
|
|
If set to a non-NULL value, <link linkend="g-object-ref">g_object_ref</link>()
|
|
|
|
and <link linkend="g-object-unref">g_object_unref</link>() will be intercepted
|
|
|
|
when called with that value.
|
|
|
|
</para>
|
2005-04-22 12:27:37 +02:00
|
|
|
</chapter>
|
2004-11-04 15:55:05 +01:00
|
|
|
|
2005-04-22 12:27:37 +02:00
|
|
|
<chapter id="tools-gtkdoc">
|
|
|
|
<title>Writing API docs</title>
|
2004-11-04 15:55:05 +01:00
|
|
|
|
2007-11-13 08:10:42 +01:00
|
|
|
<para>The API documentation for most of the GLib, GObject, GTK+ and GNOME
|
2005-04-22 12:27:37 +02:00
|
|
|
libraries is built with a combination of complex tools. Typically, the part of
|
|
|
|
the documentation which describes the behavior of each function is extracted
|
|
|
|
from the specially-formatted source code comments by a tool named gtk-doc which
|
2007-11-13 08:10:42 +01:00
|
|
|
generates DocBook XML and merges this DocBook XML with a set of master XML
|
|
|
|
DocBook files. These XML DocBook files are finally processed with xsltproc
|
|
|
|
(a small program part of the libxslt library) to generate the final HTML
|
|
|
|
output. Other tools can be used to generate PDF output from the source XML.
|
2005-04-22 12:27:37 +02:00
|
|
|
The following code excerpt shows what these comments look like.
|
2004-11-04 15:55:05 +01:00
|
|
|
<programlisting>
|
|
|
|
/**
|
|
|
|
* gtk_widget_freeze_child_notify:
|
|
|
|
* @widget: a #GtkWidget
|
|
|
|
*
|
|
|
|
* Stops emission of "child-notify" signals on @widget. The signals are
|
|
|
|
* queued until gtk_widget_thaw_child_notify() is called on @widget.
|
|
|
|
*
|
|
|
|
* This is the analogue of g_object_freeze_notify() for child properties.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_widget_freeze_child_notify (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
...
|
|
|
|
</programlisting>
|
2005-04-22 12:27:37 +02:00
|
|
|
</para>
|
|
|
|
<para>
|
2007-11-13 08:10:42 +01:00
|
|
|
Thorough
|
2005-04-22 12:27:37 +02:00
|
|
|
<ulink url="http://developer.gnome.org/arch/doc/authors.html">documentation</ulink>
|
2007-11-13 08:10:42 +01:00
|
|
|
on how to set up and use gtk-doc in your
|
|
|
|
project is provided on the GNOME developer website.
|
2005-04-22 12:27:37 +02:00
|
|
|
</para>
|
2004-11-04 15:55:05 +01:00
|
|
|
</chapter>
|