Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > f2f28f61487f3042d93877451f0a311f > files > 24

geda-docs-1.8.2-4.mga5.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title></title>
  <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />
  <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />
  <link rel="stylesheet" media="print" type="text/css" href="./print.css" />

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>


<h1 class="sectionedit355"><a name="geda_developer_tips_tricks_and_hints" id="geda_developer_tips_tricks_and_hints">gEDA Developer Tips, tricks and hints</a></h1>
<div class="level1">

</div>
<!-- EDIT355 SECTION "gEDA Developer Tips, tricks and hints" [1-54] -->
<h2 class="sectionedit356"><a name="data_structure_of_a_schematic" id="data_structure_of_a_schematic">Data Structure of a Schematic</a></h2>
<div class="level2">

<p>
Internally, a schematic in gaf is implemented by number of doubly linked lists. The central type linked in the lists is OBJECT. It can represent a symbol, a line of text, a drawing primitive, a net, or an attribute.
</p>

<p>
An overview of the data structure of a schematic can be retrieved <a href="http://www.brorson.com/gEDA/gEDA_Structures_20050108.pdf" class="urlextern" title="http://www.brorson.com/gEDA/gEDA_Structures_20050108.pdf"  rel="nofollow">here</a>. The sketch was drawn in 2005 by Stuart Brorson.
</p>

</div>
<!-- EDIT356 SECTION "Data Structure of a Schematic" [55-500] -->
<h2 class="sectionedit357"><a name="doxygen_comments_and_styles" id="doxygen_comments_and_styles">Doxygen Comments and Styles</a></h2>
<div class="level2">

<p>
<strong>Doxygen</strong> is a tool which extracts <acronym title="Application Programming Interface">API</acronym> documentation from comments in the source code. Markup can be placed in the comments, which is then extracted and rendered to <acronym title="HyperText Markup Language">HTML</acronym> or LaTeX by Doxygen. This allows e.g. one function to link to another related function, and permits arguments and return values to have documentation associated with them.
</p>

<p>
Some sections of the gaf source have already been doxyfied. Currently, this includes libgeda, gschem, gnetlist, gsymcheck and gattrib. The Makefile in the <em>docs</em> dir of these tools contains a target “doxygen”. Alternatively, you can browse the output of doxygen online <a href="http://www.xs4all.nl/~ljh4timm/gaf/dox.html" class="urlextern" title="http://www.xs4all.nl/~ljh4timm/gaf/dox.html"  rel="nofollow">on this site</a>, made available by Bert Timmerman.
</p>

<p>
If you want to see Doxygen&#039;s ideas on how to format documentation see the <a href="http://www.stack.nl/~dimitri/doxygen/docblocks.html" class="urlextern" title="http://www.stack.nl/~dimitri/doxygen/docblocks.html"  rel="nofollow">Doxygen website</a>. The individual commands are documented <a href="http://www.stack.nl/~dimitri/doxygen/commands.html" class="urlextern" title="http://www.stack.nl/~dimitri/doxygen/commands.html"  rel="nofollow">here</a>. There is also a very handy Doxygen <a href="http://www.digilife.be/quickreferences/QRC/Doxygen%20Quick%20Reference.pdf" class="urlextern" title="http://www.digilife.be/quickreferences/QRC/Doxygen%20Quick%20Reference.pdf"  rel="nofollow">quick reference card</a>.
</p>

<p>
The following sections provide an introduction on how gschem and libgeda are customarily documented. Note that the QT style of <strong>/*! comment goes here */</strong> for a Doxygen-enabled comment is preferred.
</p>

</div>
<!-- EDIT357 SECTION "Doxygen Comments and Styles" [501-1843] -->
<h3 class="sectionedit358"><a name="documenting_files" id="documenting_files">Documenting Files</a></h3>
<div class="level3">

<p>
When starting a new file, you obviously need to have the normal GNU license text.  After the GNU License you should include a file comment describing what the file is for and any other descriptions that apply to the whole file.
</p>
<pre class="code c">  <span class="coMULTI">/*! \file &lt;filename.ext&gt;
      \brief Put a brief summary of what this file is for...
      \par Description
      A lengthier description of what the file is for (this is optional).
   */</span></pre>

</div>
<!-- EDIT358 SECTION "Documenting Files" [1844-2309] -->
<h3 class="sectionedit359"><a name="documenting_variables_defines_typedefs" id="documenting_variables_defines_typedefs">Documenting Variables/Defines/Typedefs</a></h3>
<div class="level3">

<p>
Global variables in a file can be documented using the <strong>\var</strong> command or by just writing a comment with a <strong>\brief</strong> command right before the definition.
</p>
<pre class="code c">  <span class="coMULTI">/*! \brief fill style of objects like cirle, rect, path */</span>
  <span class="kw4">typedef</span> <span class="kw2">enum</span> <span class="br0">&#123;</span>FILLING_HOLLOW<span class="sy0">,</span> FILLING_FILL<span class="sy0">,</span> FILLING_MESH<span class="sy0">,</span> FILLING_HATCH<span class="sy0">,</span> FILLING_VOID<span class="br0">&#125;</span> OBJECT_FILLING<span class="sy0">;</span></pre>

</div>
<!-- EDIT359 SECTION "Documenting Variables/Defines/Typedefs" [2310-2700] -->
<h3 class="sectionedit360"><a name="documenting_functions" id="documenting_functions">Documenting Functions</a></h3>
<div class="level3">

<p>
Functions can be documented in the same way as Variables, etc… Just use a comment block above the function it is documenting and use a <strong>\brief</strong> command to
start it.
</p>

<p>
Usually an additional <strong>Function Description</strong> paragraph is used for the lengthy description of the function&#039;s purpose.
Also <strong>\param</strong> commands are used with the [in] or [out] attributes to document if the parameter will be modified by the function.
</p>
<pre class="code c">  <span class="coMULTI">/*! \brief &quot;Save&quot; a file into a string buffer
   *  \par Function Description
   *  This function saves a whole schematic into a buffer in libgeda
   *  format. The buffer should be freed when no longer needed.
   *
   *  \param [in] toplevel    The current TOPLEVEL.
   *  \param [in] object_list The head of a GList of OBJECTs to save.
   *  \return a buffer containing schematic data or NULL on failure.
   */</span></pre>

</div>
<!-- EDIT360 SECTION "Documenting Functions" [2701-3588] -->
<h3 class="sectionedit361"><a name="structure_documentation" id="structure_documentation">Structure Documentation</a></h3>
<div class="level3">

<p>
Structures are documented the same as in the previous sections.  Note that comments on the structure members can be documented inline or using the same <strong>\brief</strong> syntax as variables.  Inline documentation requires the special comment starting with <strong>/*!&lt;</strong> at the end of the line it applies to.
</p>
<pre class="code c">  <span class="coMULTI">/*! \brief Structure for connections between OBJECTs
   *
   * The st_conn structure contains a single connection
   * to another object.
   * The connection system in s_conn.c uses this struct
   */</span>
  <span class="kw4">struct</span> st_conn <span class="br0">&#123;</span>
    OBJECT <span class="sy0">*</span>other_object<span class="sy0">;</span> <span class="coMULTI">/*!&lt; The &quot;other&quot; object connected to this one */</span>
    <span class="coMULTI">/*! \brief type of connection. Always in reference to how the &quot;other&quot;
        object is connected to the current one */</span>
    <span class="kw4">int</span> type<span class="sy0">;</span>
    <span class="kw4">int</span> x<span class="sy0">;</span> <span class="coMULTI">/*!&lt; x coord of the connection position */</span>
    <span class="kw4">int</span> y<span class="sy0">;</span> <span class="coMULTI">/*!&lt; y coord of the connection position */</span>
    <span class="kw4">int</span> whichone<span class="sy0">;</span> <span class="coMULTI">/*!&lt; which endpoint of the current object caused this connection */</span>
    <span class="kw4">int</span> other_whichone<span class="sy0">;</span> <span class="coMULTI">/*!&lt; which endpoint of the &quot;other&quot; object caused this connection */</span>
  <span class="br0">&#125;</span><span class="sy0">;</span></pre>

</div>
<!-- EDIT361 SECTION "Structure Documentation" [3589-4670] -->
<h3 class="sectionedit362"><a name="bug_todo_commands" id="bug_todo_commands">Bug/Todo Commands</a></h3>
<div class="level3">

<p>
<strong>\bug</strong> and <strong>\todo</strong> are useful for notating where there are defects or missing features in the code. These commands can be used anywhere within the Doxygen comments, and generate entries on special pages in the documentation so that they can easily be referred to.
</p>

</div>
<!-- EDIT362 SECTION "Bug/Todo Commands" [4671-4968] -->
<h2 class="sectionedit363"><a name="dialogsdesign_and_behaviour" id="dialogsdesign_and_behaviour">Dialogs: Design and Behaviour</a></h2>
<div class="level2">

</div>
<!-- EDIT363 SECTION "Dialogs: Design and Behaviour" [4969-5013] -->
<h3 class="sectionedit364"><a name="dialog_design" id="dialog_design">Dialog Design</a></h3>
<div class="level3">

<p>
There&#039;s a nice document from the gnome guys called <a href="http://library.gnome.org/devel/hig-book/" class="urlextern" title="http://library.gnome.org/devel/hig-book/"  rel="nofollow"> Gnome HIG</a>.
There are several suggestions on how to design dialogs and how they should behave.
</p>

<p>
<strong> The dialog design is mostly a matter of taste:</strong>
</p>
<ul>
<li class="level1"><div class="li"> alignment of elements. See <a href="http://library.gnome.org/devel/hig-book/nightly/windows.html.en" class="urlextern" title="http://library.gnome.org/devel/hig-book/nightly/windows.html.en"  rel="nofollow"> Window Layout</a></div>
</li>
<li class="level1"><div class="li"> right alignment of dialog buttons</div>
</li>
<li class="level1"><div class="li"> some spacing around the dialog (but how much?)</div>
</li>
<li class="level1"><div class="li"> some spacing between the elements (vertical and horizontal)</div>
</li>
<li class="level1"><div class="li"> option groups with frames or indentation?</div>
</li>
<li class="level1"><div class="li"> frame labels or bold headlines?</div>
</li>
</ul>

</div>
<!-- EDIT364 SECTION "Dialog Design" [5014-5633] -->
<h3 class="sectionedit365"><a name="modal_or_nonmodal_dialogs" id="modal_or_nonmodal_dialogs">Modal or Nonmodal dialogs</a></h3>
<div class="level3">

<p>
A modal dialog is required whenever the main application provides data for the dialog.
</p>
<pre class="code">Example:
  The dialog is called with a selection list and the dialog only should operate on this selection.</pre>

<p>
A modal dialog is OK too, if the dialog is only called very seldom. The file open dialog could be nonmodal because it does not require any input from the application.
</p>

<p>
A modal dialog is not OK if there is a lot of user interaction with the dialog. The component selection is a good example.
</p>

</div>
<!-- EDIT365 SECTION "Modal or Nonmodal dialogs" [5634-6163] -->
<h3 class="sectionedit366"><a name="where_to_place_the_dialog" id="where_to_place_the_dialog">Where to place the dialog</a></h3>
<div class="level3">

<p>
A dialog can be put on different places in on the screen.
A list of possible places can be found in the <a href="http://library.gnome.org/devel/gtk/unstable/gtk3-Standard-Enumerations.html#GtkWindowPosition" class="urlextern" title="http://library.gnome.org/devel/gtk/unstable/gtk3-Standard-Enumerations.html#GtkWindowPosition"  rel="nofollow"> GtkReference</a>
</p>

<p>
The current dialogs are placed either on the mouse position (GTK_WIN_POS_MOUSE) or at no preset position (GTK_WIN_POS_NONE).
The Gnome HID does not say anything about that topic.
</p>

<p>
The default setting is GTK_WIN_POS_NONE for GtkWindow see <a href="http://developer.gnome.org/doc/API/2.0/gtk/GtkWindow.html#GtkWindow--window-position" class="urlextern" title="http://developer.gnome.org/doc/API/2.0/gtk/GtkWindow.html#GtkWindow--window-position"  rel="nofollow"> GtkWindow</a>.
The default for GtkDialog is GTK_WIN_POS_CENTER_ON_PARENT (<a href="http://git.gnome.org/browse/gtk+/tree/gtk/gtkdialog.c" class="urlextern" title="http://git.gnome.org/browse/gtk+/tree/gtk/gtkdialog.c"  rel="nofollow"> taken from the GtkDialog source</a>).
</p>

</div>
<!-- EDIT366 SECTION "Where to place the dialog" [6164-6912] -->
<h3 class="sectionedit367"><a name="placing_dialogs_in_front_of_their_parent_window" id="placing_dialogs_in_front_of_their_parent_window">Placing dialogs in front of their parent window</a></h3>
<div class="level3">

<p>
Most of the dialogs are placed in front of their parent window using the transient_for property (see. <a href="http://developer.gnome.org/doc/API/2.0/gtk/GtkWindow.html#gtk-window-set-transient-for" class="urlextern" title="http://developer.gnome.org/doc/API/2.0/gtk/GtkWindow.html#gtk-window-set-transient-for"  rel="nofollow"> GtkReference</a>). This property should be set for all modal dialogs.
</p>

<p>
For nonmodal dialogs the setting of transient_for property is not obvious. While in gschem for example the coord dialog should stay above the parent window, the log window does not need to stay in front of it.
</p>

<p>
<strong>Note:</strong> There is an older mechanism that keeps the the dialogs in front of gschem. If the <em>raise-dialog-boxes-on-expose</em> variable is set to <em>enable</em> in one of gschem&#039;s configuration files, it may cause problems with some window managers.
If dialogs are flickering at 100% CPU load, then disable that setting.
</p>
<pre class="code lisp"><span class="co1">; raise-dialog-boxes-on-expose string</span>
<span class="co1">;</span>
<span class="co1">; Controls if dialog boxes are raised whenever an expose event happens</span>
<span class="co1">; Default is enabled</span>
<span class="co1">;</span>
<span class="co1">;(raise-dialog-boxes-on-expose &quot;enabled&quot;)</span>
<span class="br0">&#40;</span>raise-dialog-boxes-on-expose <span class="st0">&quot;disabled&quot;</span><span class="br0">&#41;</span></pre>

</div>
<!-- EDIT367 SECTION "Placing dialogs in front of their parent window" [6913-7997] -->
<h3 class="sectionedit368"><a name="button_order_in_dialogs" id="button_order_in_dialogs">Button order in dialogs</a></h3>
<div class="level3">

<p>
Button order at the bottom of the dialog depends on which operating system the user is using.
GTK handles this automatically, but requires the developers set the alternative button order. For more information, check the GTK documentation <a href="http://library.gnome.org/devel/gtk/unstable/GtkDialog.html#gtk-dialog-set-alternative-button-order" class="urlextern" title="http://library.gnome.org/devel/gtk/unstable/GtkDialog.html#gtk-dialog-set-alternative-button-order"  rel="nofollow">here</a>.
</p>

<p>
The alternative button order is set with just one call to a GTK function:
</p>
<pre class="code C"><span class="coMULTI">/* Set the alternative button order (ok, no, cancel, help) for other systems */</span>
gtk_dialog_set_alternative_button_order<span class="br0">&#40;</span>GTK_DIALOG<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">,</span>
			                GTK_RESPONSE_OK<span class="sy0">,</span>
					GTK_RESPONSE_NO<span class="sy0">,</span>
					GTK_RESPONSE_CANCEL<span class="sy0">,</span>
					GTK_RESPONSE_HELP<span class="sy0">,</span>
					<span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span></pre>

<p>
This should be done for every new dialog created, before running it.
</p>

</div>
<!-- EDIT368 SECTION "Button order in dialogs" [7998-8800] -->
<h3 class="sectionedit369"><a name="dialog_design_of_the_current_dialogs" id="dialog_design_of_the_current_dialogs">Dialog design of the current dialogs</a></h3>
<div class="level3">

<p>
<a href="media/devel_tips/dialog_picture.png" class="media" target="_blank" title="devel_tips:dialog_picture.png"><img src="media/devel_tips/dialog_picture.png" class="media" alt="" /></a>
</p>
<ul>
<li class="level1"><div class="li"> There is some space around the whole dialog (<em>DIALOG_BORDER_SPACING</em>).</div>
</li>
<li class="level1"><div class="li"> Some indentation to show the topic group (<em>DIALOG_INDENTATION</em>) below it&#039;s bold headline.</div>
</li>
<li class="level1"><div class="li"> The vertikal and the horizontal separation is done with <em>DIALOG_H_SPACING</em> and <em>DIALOG_V_SPACING</em>.</div>
</li>
</ul>

</div>
<!-- EDIT369 SECTION "Dialog design of the current dialogs" [8801-9164] -->
<h3 class="sectionedit370"><a name="source_template_for_simple_dialogs" id="source_template_for_simple_dialogs">Source template for simple dialogs</a></h3>
<div class="level3">

<p>
This template is not intented to compile, but you can easily copy the code block that you need.
</p>
<pre class="code c"><span class="kw4">void</span> dialog <span class="br0">&#40;</span>TOPLEVEL <span class="sy0">*</span>w_current<span class="br0">&#41;</span>
<span class="br0">&#123;</span>
  GtkWidget <span class="sy0">*</span>vbox<span class="sy0">,</span> <span class="sy0">*</span>label<span class="sy0">,</span> <span class="sy0">*</span>alignment<span class="sy0">,</span> <span class="sy0">*</span>table<span class="sy0">;</span>
  GtkWidget <span class="sy0">*</span>dialog<span class="sy0">;</span>
&nbsp;
  <span class="coMULTI">/* only create the dialog if it is not there yet. This usually is a
     widget pointer in the w_current structure:
     dialog = w_current-&gt;tewindow */</span>
  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>dialog<span class="br0">&#41;</span> <span class="br0">&#123;</span>
    dialog <span class="sy0">=</span> gtk_dialog_new_with_buttons<span class="br0">&#40;</span>_<span class="br0">&#40;</span><span class="st0">&quot;Dialog title&quot;</span><span class="br0">&#41;</span><span class="sy0">,</span>
					 <span class="coMULTI">/* the parent window or NULL */</span>
					 GTK_WINDOW<span class="br0">&#40;</span>w_current<span class="sy0">-&gt;</span>main_window<span class="br0">&#41;</span><span class="sy0">,</span>
					 <span class="coMULTI">/* dialog properties */</span>
					 GTK_DIALOG_MODAL<span class="sy0">,</span> <span class="coMULTI">/* 0 for nonmodal dialogs */</span>
					 <span class="coMULTI">/* dialog buttons and response signals */</span>
					 GTK_STOCK_CANCEL<span class="sy0">,</span>
					 GTK_RESPONSE_REJECT<span class="sy0">,</span>
					 GTK_STOCK_OK<span class="sy0">,</span>
					 GTK_RESPONSE_ACCEPT<span class="sy0">,</span>
					 NULL<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* Set the alternative button order (ok, no, cancel, help) for other systems */</span>
    gtk_dialog_set_alternative_button_order<span class="br0">&#40;</span>GTK_DIALOG<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">,</span>
	  				    GTK_RESPONSE_OK<span class="sy0">,</span>
					    GTK_RESPONSE_NO<span class="sy0">,</span>
					    GTK_RESPONSE_CANCEL<span class="sy0">,</span>
					    GTK_RESPONSE_HELP<span class="sy0">,</span>
					    <span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* set default response signal. This is usually triggered by the
       &quot;Return&quot; key */</span>
    gtk_dialog_set_default_response<span class="br0">&#40;</span>GTK_DIALOG<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">,</span>
				    GTK_RESPONSE_ACCEPT<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* set the function for handling the button responses and dialog close
       for nonmodal dialogs you can use dialog_run() too.*/</span>
    gtk_signal_connect<span class="br0">&#40;</span>GTK_OBJECT<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">,</span> <span class="st0">&quot;response&quot;</span><span class="sy0">,</span>
		       GTK_SIGNAL_FUNC<span class="br0">&#40;</span>dialog_response<span class="br0">&#41;</span><span class="sy0">,</span> w_current<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* where to place the dialog: GTK_WIN_POS_MOUSE or GTK_WIN_POS_NONE */</span>
    gtk_window_position<span class="br0">&#40;</span>GTK_WINDOW <span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">,</span> GTK_WIN_POS_MOUSE<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* set the border spacing and the vbox spacing of the dialog */</span>
    vbox <span class="sy0">=</span> GTK_DIALOG<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">-&gt;</span>vbox<span class="sy0">;</span>
    gtk_container_set_border_width<span class="br0">&#40;</span>GTK_CONTAINER<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">,</span>DIALOG_BORDER_SPACING<span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_box_set_spacing<span class="br0">&#40;</span>GTK_BOX<span class="br0">&#40;</span>vbox<span class="br0">&#41;</span><span class="sy0">,</span> DIALOG_V_SPACING<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* create a label (with markup) and pack it into the dialog box */</span>
    label <span class="sy0">=</span> gtk_label_new<span class="br0">&#40;</span>_<span class="br0">&#40;</span><span class="st0">&quot;&lt;b&gt;Section label&lt;/b&gt;&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_label_set_use_markup<span class="br0">&#40;</span>GTK_LABEL<span class="br0">&#40;</span>label<span class="br0">&#41;</span><span class="sy0">,</span> TRUE<span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_misc_set_alignment<span class="br0">&#40;</span>GTK_MISC<span class="br0">&#40;</span>label<span class="br0">&#41;</span><span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_box_pack_start<span class="br0">&#40;</span>GTK_BOX<span class="br0">&#40;</span>vbox<span class="br0">&#41;</span><span class="sy0">,</span> label<span class="sy0">,</span> FALSE<span class="sy0">,</span> FALSE<span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* create a alignment container with the DIALOG_INDENTATION on the left */</span>
    alignment <span class="sy0">=</span> gtk_alignment_new<span class="br0">&#40;</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">1</span><span class="sy0">,</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_alignment_set_padding<span class="br0">&#40;</span>GTK_ALIGNMENT<span class="br0">&#40;</span>alignment<span class="br0">&#41;</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span>
			      DIALOG_INDENTATION<span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_box_pack_start<span class="br0">&#40;</span>GTK_BOX<span class="br0">&#40;</span>vbox<span class="br0">&#41;</span><span class="sy0">,</span> alignment<span class="sy0">,</span> FALSE<span class="sy0">,</span> FALSE<span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* a table can store several entries. It is stored in the aligment container.
       Note: the vertical and horizontal cell spacings */</span>
    table <span class="sy0">=</span> gtk_table_new <span class="br0">&#40;</span><span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> FALSE<span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_table_set_row_spacings<span class="br0">&#40;</span>GTK_TABLE<span class="br0">&#40;</span>table<span class="br0">&#41;</span><span class="sy0">,</span> DIALOG_V_SPACING<span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_table_set_col_spacings<span class="br0">&#40;</span>GTK_TABLE<span class="br0">&#40;</span>table<span class="br0">&#41;</span><span class="sy0">,</span> DIALOG_H_SPACING<span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_container_add<span class="br0">&#40;</span>GTK_CONTAINER<span class="br0">&#40;</span>alignment<span class="br0">&#41;</span><span class="sy0">,</span> table<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* a simple text label in one table cell with left alignment.
       Note: the GTK_FILL in the third line is required */</span>
    label <span class="sy0">=</span> gtk_label_new<span class="br0">&#40;</span>_<span class="br0">&#40;</span><span class="st0">&quot;Text:&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_misc_set_alignment<span class="br0">&#40;</span>GTK_MISC<span class="br0">&#40;</span>label<span class="br0">&#41;</span><span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_table_attach<span class="br0">&#40;</span>GTK_TABLE<span class="br0">&#40;</span>table<span class="br0">&#41;</span><span class="sy0">,</span> label<span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span><span class="nu0">1</span><span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">1</span><span class="sy0">,</span> GTK_FILL<span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* a simple text entry completes the option row */</span>
    textentry <span class="sy0">=</span> gtk_entry_new_with_max_length <span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_table_attach_defaults<span class="br0">&#40;</span>GTK_TABLE<span class="br0">&#40;</span>table<span class="br0">&#41;</span><span class="sy0">,</span> textentry<span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span><span class="nu0">2</span><span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span>
    gtk_entry_set_activates_default<span class="br0">&#40;</span>GTK_ENTRY<span class="br0">&#40;</span>textentry<span class="br0">&#41;</span><span class="sy0">,</span> TRUE<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* ..... more table rows with options, or new sections */</span>
&nbsp;
    <span class="coMULTI">/* create references to all widgets that you need later */</span>
    GLADE_HOOKUP_OBJECT<span class="br0">&#40;</span>dialog<span class="sy0">,</span> sizeentry<span class="sy0">,</span><span class="st0">&quot;textentry&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="coMULTI">/* show all widgets recursivly */</span>
    gtk_widget_show_all<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="br0">&#125;</span>
&nbsp;
  <span class="kw1">else</span> <span class="br0">&#123;</span>
    <span class="coMULTI">/* Dialog is already there. Present it to the user.
       This is only required if you have a nonmodal dialog */</span>
    gtk_window_present<span class="br0">&#40;</span>GTK_WINDOW<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="br0">&#125;</span>
&nbsp;
  <span class="coMULTI">/* always set the current values to the dialog
     If you're placing that part at the end of the dialog function you can
     easily create dialogs that can be called, even if they are already open */</span>
  textentry <span class="sy0">=</span> g_object_get_data<span class="br0">&#40;</span>G_OBJECT<span class="br0">&#40;</span>dialog<span class="br0">&#41;</span><span class="sy0">,</span> <span class="st0">&quot;textentry&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  gtk_entry_set_text<span class="br0">&#40;</span>GTK_ENTRY<span class="br0">&#40;</span>textentry<span class="br0">&#41;</span><span class="sy0">,</span> string<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="coMULTI">/* select the text region that the user usually likes to overwrite */</span>
  gtk_entry_select_region<span class="br0">&#40;</span>GTK_ENTRY<span class="br0">&#40;</span>textentry<span class="br0">&#41;</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> strlen<span class="br0">&#40;</span>string<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre>

<p>
The response function for such a dialog may look like this:
</p>
<pre class="code c"><span class="kw4">void</span> dialog_response<span class="br0">&#40;</span>GtkWidget <span class="sy0">*</span>widget<span class="sy0">,</span> gint response<span class="sy0">,</span> TOPLEVEL <span class="sy0">*</span>w_current<span class="br0">&#41;</span>
<span class="br0">&#123;</span>
  <span class="kw1">switch</span> <span class="br0">&#40;</span>response<span class="br0">&#41;</span> <span class="br0">&#123;</span>
  <span class="kw1">case</span> GTK_RESPONSE_ACCEPT<span class="sy0">:</span>
    <span class="coMULTI">/* apply the dialog settings:
       just insert your code here if it is short
       call an extra apply function if the required code is long */</span>
    <span class="kw2">break</span><span class="sy0">;</span>
  <span class="kw1">case</span> GTK_RESPONSE_REJECT<span class="sy0">:</span>
  <span class="kw1">case</span> GTK_RESPONSE_DELETE_EVENT<span class="sy0">:</span>
    <span class="coMULTI">/* for modal dialogs just do nothing,
       for nonmodal dialogs, destroy the dialog and clean up */</span>
    <span class="kw2">break</span><span class="sy0">;</span>
  <span class="kw1">default</span><span class="sy0">:</span>
    <span class="coMULTI">/* catch wrong signals signals (paranoid error checking ;-)) */</span>
    <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&quot;dialog_response(): strange signal %d<span class="es1">\n</span>&quot;</span><span class="sy0">,</span> response<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="br0">&#125;</span>
&nbsp;
  <span class="coMULTI">/* for nonmodal dialogs just do nothing,
     for modal dialogs, always destroy the dialog and clean up */</span>
<span class="br0">&#125;</span></pre>

</div>
<!-- EDIT370 SECTION "Source template for simple dialogs" [9165-14253] -->
<h3 class="sectionedit371"><a name="current_dialog_issues_in_gschem" id="current_dialog_issues_in_gschem">Current Dialog Issues in Gschem</a></h3>
<div class="level3">
<ul>
<li class="level1"><div class="li"> every dialog has it&#039;s own design</div>
</li>
<li class="level1"><div class="li"> dialog placement: mouse position or no predefined position?</div>
</li>
<li class="level1"><div class="li"> dialogs do not remember their last size, position and contents.</div>
</li>
<li class="level1"><div class="li"> missing keyboard shortcuts</div>
</li>
</ul>

<p>
<strong>Here&#039;s a list of things that could be improved:</strong>
</p>

</div>

<h5><a name="print_dialog" id="print_dialog">Print Dialog</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> change design?</div>
</li>
</ul>

</div>

<h5><a name="write_image" id="write_image">Write Image</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> In the fileselect dialog the default filename is missing if the file does not exist</div>
</li>
<li class="level1"><div class="li"> Return key does not work in the filename entry</div>
</li>
</ul>

</div>

<h5><a name="execute_script" id="execute_script">Execute Script</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="edit_text" id="edit_text">Edit Text</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> some missing keyboard shortcuts</div>
</li>
<li class="level1"><div class="li"> add *unmodified* tags if there are multiple selections</div>
</li>
<li class="level1"><div class="li"> maybe add some color pixbufs for the color</div>
</li>
<li class="level1"><div class="li"> maybe replace the text alignment with nine ratio buttons, toggle buttons with icons or …</div>
</li>
</ul>

</div>

<h5><a name="color_dialog" id="color_dialog">Color Dialog</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> maybe add some color pixbufs for the color</div>
</li>
</ul>

</div>

<h5><a name="line_width_and_type" id="line_width_and_type">Line Width and Type</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> keyboard shortcuts missing</div>
</li>
<li class="level1"><div class="li"> icons for the line type</div>
</li>
</ul>

</div>

<h5><a name="fill_type" id="fill_type">Fill Type</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> keyboard shortcuts missing</div>
</li>
<li class="level1"><div class="li"> icons in the fill type</div>
</li>
</ul>

</div>

<h5><a name="translate_symbol" id="translate_symbol">Translate Symbol</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="page_manager" id="page_manager">Page Manager</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> wrong button order? Depends on whether you think the refresh button is the main action button or just an extra button.</div>
</li>
<li class="level1"><div class="li"> Maybe the “Return” key should trigger Refresh</div>
</li>
</ul>

</div>

<h5><a name="component_selector" id="component_selector">Component Selector</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> strange edit widget when typing and the tree is selected (It&#039;s a search helper widget, disable it?!)</div>
</li>
</ul>

</div>

<h5><a name="single_attribut_editor" id="single_attribut_editor">Single Attribut Editor</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> when multiple elements are selected and you call edit (ee) there are a few problems:</div>
<ul>
<li class="level3"><div class="li"> if the first object is text, then this dialog is opened (but with the wrong list parameter</div>
</li>
<li class="level3"><div class="li"> if the first object is complex then the multiple attribute editor is called</div>
</li>
</ul>
</li>
</ul>

</div>

<h5><a name="multi_attribute_editor" id="multi_attribute_editor">Multi Attribute Editor</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="add_text" id="add_text">Add Text</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="arc_params" id="arc_params">Arc Params</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> add the diameter to the dialog, but select the start angle entry (increment = grid)</div>
</li>
<li class="level1"><div class="li"> let “ee” call that dialog if only a single arc is selected</div>
</li>
<li class="level1"><div class="li"> maybe add a section label</div>
</li>
</ul>

</div>

<h5><a name="insert_picture" id="insert_picture">Insert Picture</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="picture_replace" id="picture_replace">Picture Replace</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> the new picture uses the aspect ratio of the old picture</div>
</li>
<li class="level1"><div class="li"> the dialog has lots in common with the Insert Picture dialog. They could use some code together</div>
</li>
</ul>

</div>

<h5><a name="find_text" id="find_text">Find Text</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> manipulates the mouse pointer (maybe the zooming code is the culprit). Just press “Return” to trigger a FindNext</div>
</li>
<li class="level1"><div class="li"> if you select hierarchy and the found text is in a different schematic, then the filename in the title is not updated</div>
</li>
<li class="level1"><div class="li"> maybe add an option: “Select all matching text objects”, disable hierarchy for that feature!</div>
</li>
<li class="level1"><div class="li"> <img src="images/smileys/fixme.gif" align="middle" alt="FIXME" /> gschem hangs if you use that dialog with hierarchical schematics that have dependancy loops (e.g. the autonumber test schematics)</div>
</li>
<li class="level1"><div class="li"> add an option “search for visible text only”</div>
</li>
<li class="level1"><div class="li"> maybe use regular expressions instead of the substring for the searchtext</div>
</li>
</ul>

</div>

<h5><a name="hide_text" id="hide_text">Hide Text</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> use regular expressions instead of starting substring</div>
</li>
</ul>

</div>

<h5><a name="show_text" id="show_text">Show Text</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> use regular expressions instead of starting substring</div>
</li>
<li class="level1"><div class="li"> Maybe merge that dialog together with the “Hide Text” dialog</div>
</li>
</ul>

</div>

<h5><a name="autonumber_text" id="autonumber_text">Autonumber Text</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> Maybe disable the skip option if the renumber scope is “selection”. The other skip options (Page and Hierarchy) are really stupid.</div>
</li>
</ul>

</div>

<h5><a name="text_size" id="text_size">Text Size</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="snap_grid_spacing" id="snap_grid_spacing">Snap Grid Spacing</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="coord_dialog" id="coord_dialog">Coord Dialog</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"> maybe move the world coordinates to the main window status bar</div>
</li>
</ul>

</div>

<h5><a name="about_dialog" id="about_dialog">About Dialog</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>

<h5><a name="hotkeys" id="hotkeys">Hotkeys</a></h5>
<div class="level5">
<ul>
<li class="level1"><div class="li"></div>
</li>
</ul>

</div>
<!-- EDIT371 SECTION "Current Dialog Issues in Gschem" [14254-] --></body>
</html>