2015-02-20 15:29:43 +01:00
|
|
|
<?xml version='1.0' encoding="UTF-8"?>
|
2012-04-23 03:45:08 +02:00
|
|
|
<!DOCTYPE part PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
2010-01-07 09:47:20 +01:00
|
|
|
]>
|
|
|
|
<part label="V">
|
|
|
|
<title>Related Tools</title>
|
|
|
|
|
|
|
|
<partintro>
|
2005-05-27 14:04:54 +02:00
|
|
|
<para>
|
2010-01-07 09:47:20 +01:00
|
|
|
Several useful developer tools have been build around GObject
|
|
|
|
technology. The next sections briefly introduce them and link to
|
|
|
|
the respective project pages.
|
2005-05-27 14:04:54 +02:00
|
|
|
</para>
|
2010-01-07 09:47:20 +01:00
|
|
|
|
|
|
|
<para>
|
|
|
|
For example, writing GObjects is often seen as a tedious task. It
|
|
|
|
requires a lot of typing and just doing a copy/paste requires a
|
|
|
|
great deal of care. A lot of projects and scripts have been
|
|
|
|
written to generate GObject skeleton form boilerplate code, or
|
|
|
|
even translating higher-level language into plain C.
|
|
|
|
</para>
|
|
|
|
</partintro>
|
|
|
|
|
|
|
|
<chapter id="tools-vala">
|
|
|
|
<title>Vala</title>
|
|
|
|
<para>
|
2014-07-02 06:52:19 +02:00
|
|
|
From the <ulink url="https://wiki.gnome.org/Projects/Vala">Vala
|
2010-01-07 09:47:20 +01:00
|
|
|
homepage</ulink> itself: <quote>Vala is a new programming language
|
|
|
|
that aims to bring modern programming language features to GNOME
|
|
|
|
developers without imposing any additional runtime requirements
|
|
|
|
and without using a different ABI compared to applications and
|
|
|
|
libraries written in C.</quote>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The syntax of Vala is similar to C#. The available compiler
|
|
|
|
translates Vala into GObject C code. It can also compile
|
|
|
|
non-GObject C, using plain C API.
|
|
|
|
</para>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<chapter id="tools-gob">
|
|
|
|
<title>GObject builder</title>
|
|
|
|
|
|
|
|
<para>
|
2014-01-03 02:40:47 +01:00
|
|
|
In order to help a GObject class developer, one obvious idea is
|
|
|
|
to use some sort of templates for the skeletons and then run
|
2010-01-07 09:47:20 +01:00
|
|
|
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.
|
|
|
|
</para>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<chapter id="tools-ginspector">
|
|
|
|
<title>Graphical inspection of GObjects</title>
|
|
|
|
|
|
|
|
<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
|
|
|
|
is able to display GLib/GTK+ objects and their properties.
|
|
|
|
</para>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<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.
|
|
|
|
In large applications, finding the exact spot where the reference count
|
2013-12-03 03:48:03 +01:00
|
|
|
of an Object is not properly handled can be very difficult.
|
2010-01-07 09:47:20 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2013-12-03 03:48:03 +01:00
|
|
|
A useful tool in debugging reference counting problems is to
|
|
|
|
set breakpoints in gdb on g_object_ref() and g_object_unref().
|
|
|
|
Once you know the address of the object you are interested in,
|
|
|
|
you can make the breakpoints conditional:
|
2010-01-07 09:47:20 +01:00
|
|
|
<programlisting>
|
2013-12-03 03:48:03 +01:00
|
|
|
break g_object_ref if _object == 0xcafebabe
|
|
|
|
break g_object_unref if _object == 0xcafebabe
|
2010-01-07 09:47:20 +01:00
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<chapter id="tools-gtkdoc">
|
|
|
|
<title>Writing API docs</title>
|
2004-11-04 15:55:05 +01:00
|
|
|
|
2010-01-07 09:47:20 +01:00
|
|
|
<para>The API documentation for most of the GLib, GObject, GTK+ and GNOME
|
|
|
|
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
|
2019-04-25 10:25:49 +02:00
|
|
|
generates DocBook XML and merges this DocBook XML with a set of template XML
|
2010-01-07 09:47:20 +01:00
|
|
|
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.
|
|
|
|
The following code excerpt shows what these comments look like.
|
2014-09-18 16:41:32 +02:00
|
|
|
<informalexample><programlisting>
|
2004-11-04 15:55:05 +01:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
...
|
2014-09-18 16:41:32 +02:00
|
|
|
</programlisting></informalexample>
|
2010-01-07 09:47:20 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Thorough
|
2014-09-18 20:31:52 +02:00
|
|
|
<ulink url="https://developer.gnome.org/gtk-doc-manual/stable/">documentation</ulink>
|
2010-11-14 02:08:51 +01:00
|
|
|
on how to set up and use gtk-doc in your project is provided on the
|
2014-09-18 20:31:52 +02:00
|
|
|
<ulink url="https://developer.gnome.org/">GNOME developer website</ulink>.
|
2010-01-07 09:47:20 +01:00
|
|
|
</para>
|
|
|
|
</chapter>
|
|
|
|
</part>
|