1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./style.css" />
6 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./design.css" />
7 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"./print.css" />
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
14 <em>Translations of this page are also available in the following languages:
</em> <a href=
"geda-devel-tips.ru.html" class=
"wikilink1" title=
"geda-devel-tips.ru.html">Русский
</a>.
17 <h1 id=
"gedadevelopertipstricksandhints">gEDA Developer Tips, tricks and hints
</h1>
22 <h2 id=
"datastructureofaschematic">Data Structure of a Schematic
</h2>
26 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.
30 An overview of the data structure of a schematic can be retrieved here. The sketch was drawn in
2005 by Stuart Brorson.
35 <h2 id=
"doxygencommentsandstyles">Doxygen Comments and Styles
</h2>
39 <strong>Doxygen
</strong> is a tool which extracts API documentation from comments in the source code. Markup can be placed in the comments, which is then extracted and rendered to HTML 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.
43 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 on this site, made available by Bert Timmerman.
47 If you want to see Doxygen
's ideas on how to format documentation see the Doxygen website. The individual commands are documented here. There is also a very handy Doxygen quick reference card.
51 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.
56 <h3 id=
"documentingfiles">Documenting Files
</h3>
60 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.
62 <pre class=
"code c"> <span class=
"coMULTI">/*! \file
<filename.ext
>
63 \brief Put a brief summary of what this file is for...
65 A lengthier description of what the file is for (this is optional).
70 <h3 id=
"documentingvariablesdefinestypedefs">Documenting Variables/Defines/Typedefs
</h3>
74 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.
76 <pre class=
"code c"> <span class=
"coMULTI">/*! \brief fill style of objects like cirle, rect, path */
</span>
77 <span class=
"kw4">typedef
</span> <span class=
"kw2">enum
</span> <span class=
"br0">{</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">}</span> OBJECT_FILLING
<span class=
"sy0">;
</span></pre>
81 <h3 id=
"documentingfunctions">Documenting Functions
</h3>
85 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
90 Usually an additional
<strong>Function Description
</strong> paragraph is used for the lengthy description of the function
's purpose.
91 Also
<strong>\param
</strong> commands are used with the [in] or [out] attributes to document if the parameter will be modified by the function.
93 <pre class=
"code c"> <span class=
"coMULTI">/*! \brief
"Save
" a file into a string buffer
94 * \par Function Description
95 * This function saves a whole schematic into a buffer in libgeda
96 * format. The buffer should be freed when no longer needed.
98 * \param [in] toplevel The current TOPLEVEL.
99 * \param [in] object_list The head of a GList of OBJECTs to save.
100 * \return a buffer containing schematic data or NULL on failure.
105 <h3 id=
"structuredocumentation">Structure Documentation
</h3>
109 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>/*!
<</strong> at the end of the line it applies to.
111 <pre class=
"code c"> <span class=
"coMULTI">/*! \brief Structure for connections between OBJECTs
113 * The st_conn structure contains a single connection
115 * The connection system in s_conn.c uses this struct
117 <span class=
"kw4">struct
</span> st_conn
<span class=
"br0">{</span>
118 OBJECT
<span class=
"sy0">*
</span>other_object
<span class=
"sy0">;
</span> <span class=
"coMULTI">/*!
< The
"other
" object connected to this one */
</span>
119 <span class=
"coMULTI">/*! \brief type of connection. Always in reference to how the
"other
"
120 object is connected to the current one */
</span>
121 <span class=
"kw4">int
</span> type
<span class=
"sy0">;
</span>
122 <span class=
"kw4">int
</span> x
<span class=
"sy0">;
</span> <span class=
"coMULTI">/*!
< x coord of the connection position */
</span>
123 <span class=
"kw4">int
</span> y
<span class=
"sy0">;
</span> <span class=
"coMULTI">/*!
< y coord of the connection position */
</span>
124 <span class=
"kw4">int
</span> whichone
<span class=
"sy0">;
</span> <span class=
"coMULTI">/*!
< which endpoint of the current object caused this connection */
</span>
125 <span class=
"kw4">int
</span> other_whichone
<span class=
"sy0">;
</span> <span class=
"coMULTI">/*!
< which endpoint of the
"other
" object caused this connection */
</span>
126 <span class=
"br0">}</span><span class=
"sy0">;
</span></pre>
130 <h3 id=
"bugtodocommands">Bug/Todo Commands
</h3>
134 <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.
139 <h2 id=
"dialogsdesignandbehaviour">Dialogs: Design and Behaviour
</h2>
144 <h3 id=
"dialogdesign">Dialog Design
</h3>
148 There
's a nice document from the gnome guys called Gnome HIG.
149 There are several suggestions on how to design dialogs and how they should behave.
153 <strong> The dialog design is mostly a matter of taste:
</strong>
156 <li class=
"level1"><div class=
"li"> alignment of elements. See Window Layout
</div>
158 <li class=
"level1"><div class=
"li"> right alignment of dialog buttons
</div>
160 <li class=
"level1"><div class=
"li"> some spacing around the dialog (but how much?)
</div>
162 <li class=
"level1"><div class=
"li"> some spacing between the elements (vertical and horizontal)
</div>
164 <li class=
"level1"><div class=
"li"> option groups with frames or indentation?
</div>
166 <li class=
"level1"><div class=
"li"> frame labels or bold headlines?
</div>
172 <h3 id=
"modalornonmodaldialogs">Modal or Nonmodal dialogs
</h3>
176 A modal dialog is required whenever the main application provides data for the dialog.
178 <pre class=
"code">Example:
179 The dialog is called with a selection list and the dialog only should operate on this selection.
</pre>
182 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.
186 A modal dialog is not OK if there is a lot of user interaction with the dialog. The component selection is a good example.
191 <h3 id=
"wheretoplacethedialog">Where to place the dialog
</h3>
195 A dialog can be put on different places in on the screen.
196 A list of possible places can be found in the GtkReference
200 The current dialogs are placed either on the mouse position (GTK_WIN_POS_MOUSE) or at no preset position (GTK_WIN_POS_NONE).
201 The Gnome HID does not say anything about that topic.
205 The default setting is GTK_WIN_POS_NONE for GtkWindow see GtkWindow.
206 The default for GtkDialog is GTK_WIN_POS_CENTER_ON_PARENT ( taken from the GtkDialog source).
211 <h3 id=
"placingdialogsinfrontoftheirparentwindow">Placing dialogs in front of their parent window
</h3>
215 Most of the dialogs are placed in front of their parent window using the transient_for property (see. GtkReference). This property should be set for all modal dialogs.
219 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.
223 <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
's configuration files, it may cause problems with some window managers.
224 If dialogs are flickering at
100% CPU load, then disable that setting.
226 <pre class=
"code lisp"><span class=
"co1">; raise-dialog-boxes-on-expose string
</span>
227 <span class=
"co1">;
</span>
228 <span class=
"co1">; Controls if dialog boxes are raised whenever an expose event happens
</span>
229 <span class=
"co1">; Default is enabled
</span>
230 <span class=
"co1">;
</span>
231 <span class=
"co1">;(raise-dialog-boxes-on-expose
"enabled
")
</span>
232 <span class=
"br0">(</span>raise-dialog-boxes-on-expose
<span class=
"st0">"disabled
"</span><span class=
"br0">)</span></pre>
236 <h3 id=
"buttonorderindialogs">Button order in dialogs
</h3>
240 Button order at the bottom of the dialog depends on which operating system the user is using.
241 GTK handles this automatically, but requires the developers set the alternative button order. For more information, check the GTK documentation here.
245 The alternative button order is set with just one call to a GTK function:
247 <pre class=
"code C"><span class=
"coMULTI">/* Set the alternative button order (ok, no, cancel, help) for other systems */
</span>
248 gtk_dialog_set_alternative_button_order
<span class=
"br0">(</span>GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">,
</span>
249 GTK_RESPONSE_OK
<span class=
"sy0">,
</span>
250 GTK_RESPONSE_NO
<span class=
"sy0">,
</span>
251 GTK_RESPONSE_CANCEL
<span class=
"sy0">,
</span>
252 GTK_RESPONSE_HELP
<span class=
"sy0">,
</span>
253 <span class=
"sy0">-
</span><span class=
"nu0">1</span><span class=
"br0">)</span><span class=
"sy0">;
</span></pre>
256 This should be done for every new dialog created, before running it.
261 <h3 id=
"dialogdesignofthecurrentdialogs">Dialog design of the current dialogs
</h3>
265 <a href=
"media/devel_tips/dialog_picture.png" class=
"media" target=
"_blank" title=
"devel_tips:dialog_picture.png">devel_tips:dialog_picture.png
</a>
268 <li class=
"level1"><div class=
"li"> There is some space around the whole dialog (
<em>DIALOG_BORDER_SPACING
</em>).
</div>
270 <li class=
"level1"><div class=
"li"> Some indentation to show the topic group (
<em>DIALOG_INDENTATION
</em>) below it
's bold headline.
</div>
272 <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>
278 <h3 id=
"sourcetemplateforsimpledialogs">Source template for simple dialogs
</h3>
282 This template is not intented to compile, but you can easily copy the code block that you need.
284 <pre class=
"code c"><span class=
"kw4">void
</span> dialog
<span class=
"br0">(</span>TOPLEVEL
<span class=
"sy0">*
</span>w_current
<span class=
"br0">)</span>
285 <span class=
"br0">{</span>
286 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>
287 GtkWidget
<span class=
"sy0">*
</span>dialog
<span class=
"sy0">;
</span>
289 <span class=
"coMULTI">/* only create the dialog if it is not there yet. This usually is a
290 widget pointer in the w_current structure:
291 dialog = w_current-
>tewindow */
</span>
292 <span class=
"kw1">if
</span> <span class=
"br0">(</span><span class=
"sy0">!
</span>dialog
<span class=
"br0">)</span> <span class=
"br0">{</span>
293 dialog
<span class=
"sy0">=
</span> gtk_dialog_new_with_buttons
<span class=
"br0">(</span>_
<span class=
"br0">(</span><span class=
"st0">"Dialog title
"</span><span class=
"br0">)</span><span class=
"sy0">,
</span>
294 <span class=
"coMULTI">/* the parent window or NULL */
</span>
295 GTK_WINDOW
<span class=
"br0">(</span>w_current
<span class=
"sy0">-
></span>main_window
<span class=
"br0">)</span><span class=
"sy0">,
</span>
296 <span class=
"coMULTI">/* dialog properties */
</span>
297 GTK_DIALOG_MODAL
<span class=
"sy0">,
</span> <span class=
"coMULTI">/*
0 for nonmodal dialogs */
</span>
298 <span class=
"coMULTI">/* dialog buttons and response signals */
</span>
299 GTK_STOCK_CANCEL
<span class=
"sy0">,
</span>
300 GTK_RESPONSE_REJECT
<span class=
"sy0">,
</span>
301 GTK_STOCK_OK
<span class=
"sy0">,
</span>
302 GTK_RESPONSE_ACCEPT
<span class=
"sy0">,
</span>
303 NULL
<span class=
"br0">)</span><span class=
"sy0">;
</span>
305 <span class=
"coMULTI">/* Set the alternative button order (ok, no, cancel, help) for other systems */
</span>
306 gtk_dialog_set_alternative_button_order
<span class=
"br0">(</span>GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">,
</span>
307 GTK_RESPONSE_OK
<span class=
"sy0">,
</span>
308 GTK_RESPONSE_NO
<span class=
"sy0">,
</span>
309 GTK_RESPONSE_CANCEL
<span class=
"sy0">,
</span>
310 GTK_RESPONSE_HELP
<span class=
"sy0">,
</span>
311 <span class=
"sy0">-
</span><span class=
"nu0">1</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
313 <span class=
"coMULTI">/* set default response signal. This is usually triggered by the
314 "Return
" key */
</span>
315 gtk_dialog_set_default_response
<span class=
"br0">(</span>GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">,
</span>
316 GTK_RESPONSE_ACCEPT
<span class=
"br0">)</span><span class=
"sy0">;
</span>
318 <span class=
"coMULTI">/* set the function for handling the button responses and dialog close
319 for nonmodal dialogs you can use dialog_run() too.*/
</span>
320 gtk_signal_connect
<span class=
"br0">(</span>GTK_OBJECT
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">,
</span> <span class=
"st0">"response
"</span><span class=
"sy0">,
</span>
321 GTK_SIGNAL_FUNC
<span class=
"br0">(</span>dialog_response
<span class=
"br0">)</span><span class=
"sy0">,
</span> w_current
<span class=
"br0">)</span><span class=
"sy0">;
</span>
323 <span class=
"coMULTI">/* where to place the dialog: GTK_WIN_POS_MOUSE or GTK_WIN_POS_NONE */
</span>
324 gtk_window_position
<span class=
"br0">(</span>GTK_WINDOW
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">,
</span> GTK_WIN_POS_MOUSE
<span class=
"br0">)</span><span class=
"sy0">;
</span>
326 <span class=
"coMULTI">/* set the border spacing and the vbox spacing of the dialog */
</span>
327 vbox
<span class=
"sy0">=
</span> GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">-
></span>vbox
<span class=
"sy0">;
</span>
328 gtk_container_set_border_width
<span class=
"br0">(</span>GTK_CONTAINER
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">,
</span>DIALOG_BORDER_SPACING
<span class=
"br0">)</span><span class=
"sy0">;
</span>
329 gtk_box_set_spacing
<span class=
"br0">(</span>GTK_BOX
<span class=
"br0">(</span>vbox
<span class=
"br0">)</span><span class=
"sy0">,
</span> DIALOG_V_SPACING
<span class=
"br0">)</span><span class=
"sy0">;
</span>
331 <span class=
"coMULTI">/* create a label (with markup) and pack it into the dialog box */
</span>
332 label
<span class=
"sy0">=
</span> gtk_label_new
<span class=
"br0">(</span>_
<span class=
"br0">(</span><span class=
"st0">"<b
>Section label
</b
>"</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
333 gtk_label_set_use_markup
<span class=
"br0">(</span>GTK_LABEL
<span class=
"br0">(</span>label
<span class=
"br0">)</span><span class=
"sy0">,
</span> TRUE
<span class=
"br0">)</span><span class=
"sy0">;
</span>
334 gtk_misc_set_alignment
<span class=
"br0">(</span>GTK_MISC
<span class=
"br0">(</span>label
<span class=
"br0">)</span><span class=
"sy0">,
</span><span class=
"nu0">0</span><span class=
"sy0">,
</span><span class=
"nu0">0</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
335 gtk_box_pack_start
<span class=
"br0">(</span>GTK_BOX
<span class=
"br0">(</span>vbox
<span class=
"br0">)</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">)</span><span class=
"sy0">;
</span>
337 <span class=
"coMULTI">/* create a alignment container with the DIALOG_INDENTATION on the left */
</span>
338 alignment
<span class=
"sy0">=
</span> gtk_alignment_new
<span class=
"br0">(</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">)</span><span class=
"sy0">;
</span>
339 gtk_alignment_set_padding
<span class=
"br0">(</span>GTK_ALIGNMENT
<span class=
"br0">(</span>alignment
<span class=
"br0">)</span><span class=
"sy0">,
</span> <span class=
"nu0">0</span><span class=
"sy0">,
</span> <span class=
"nu0">0</span><span class=
"sy0">,
</span>
340 DIALOG_INDENTATION
<span class=
"sy0">,
</span> <span class=
"nu0">0</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
341 gtk_box_pack_start
<span class=
"br0">(</span>GTK_BOX
<span class=
"br0">(</span>vbox
<span class=
"br0">)</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">)</span><span class=
"sy0">;
</span>
343 <span class=
"coMULTI">/* a table can store several entries. It is stored in the aligment container.
344 Note: the vertical and horizontal cell spacings */
</span>
345 table
<span class=
"sy0">=
</span> gtk_table_new
<span class=
"br0">(</span><span class=
"nu0">3</span><span class=
"sy0">,
</span> <span class=
"nu0">2</span><span class=
"sy0">,
</span> FALSE
<span class=
"br0">)</span><span class=
"sy0">;
</span>
346 gtk_table_set_row_spacings
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</span><span class=
"sy0">,
</span> DIALOG_V_SPACING
<span class=
"br0">)</span><span class=
"sy0">;
</span>
347 gtk_table_set_col_spacings
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</span><span class=
"sy0">,
</span> DIALOG_H_SPACING
<span class=
"br0">)</span><span class=
"sy0">;
</span>
348 gtk_container_add
<span class=
"br0">(</span>GTK_CONTAINER
<span class=
"br0">(</span>alignment
<span class=
"br0">)</span><span class=
"sy0">,
</span> table
<span class=
"br0">)</span><span class=
"sy0">;
</span>
350 <span class=
"coMULTI">/* a simple text label in one table cell with left alignment.
351 Note: the GTK_FILL in the third line is required */
</span>
352 label
<span class=
"sy0">=
</span> gtk_label_new
<span class=
"br0">(</span>_
<span class=
"br0">(</span><span class=
"st0">"Text:
"</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
353 gtk_misc_set_alignment
<span class=
"br0">(</span>GTK_MISC
<span class=
"br0">(</span>label
<span class=
"br0">)</span><span class=
"sy0">,
</span><span class=
"nu0">0</span><span class=
"sy0">,
</span><span class=
"nu0">0</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
354 gtk_table_attach
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</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">)</span><span class=
"sy0">;
</span>
356 <span class=
"coMULTI">/* a simple text entry completes the option row */
</span>
357 textentry
<span class=
"sy0">=
</span> gtk_entry_new_with_max_length
<span class=
"br0">(</span><span class=
"nu0">10</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
358 gtk_table_attach_defaults
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</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">)</span><span class=
"sy0">;
</span>
359 gtk_entry_set_activates_default
<span class=
"br0">(</span>GTK_ENTRY
<span class=
"br0">(</span>textentry
<span class=
"br0">)</span><span class=
"sy0">,
</span> TRUE
<span class=
"br0">)</span><span class=
"sy0">;
</span>
361 <span class=
"coMULTI">/* ..... more table rows with options, or new sections */
</span>
363 <span class=
"coMULTI">/* create references to all widgets that you need later */
</span>
364 GLADE_HOOKUP_OBJECT
<span class=
"br0">(</span>dialog
<span class=
"sy0">,
</span> sizeentry
<span class=
"sy0">,
</span><span class=
"st0">"textentry
"</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
366 <span class=
"coMULTI">/* show all widgets recursivly */
</span>
367 gtk_widget_show_all
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">;
</span>
368 <span class=
"br0">}</span>
370 <span class=
"kw1">else
</span> <span class=
"br0">{</span>
371 <span class=
"coMULTI">/* Dialog is already there. Present it to the user.
372 This is only required if you have a nonmodal dialog */
</span>
373 gtk_window_present
<span class=
"br0">(</span>GTK_WINDOW
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
374 <span class=
"br0">}</span>
376 <span class=
"coMULTI">/* always set the current values to the dialog
377 If you're placing that part at the end of the dialog function you can
378 easily create dialogs that can be called, even if they are already open */
</span>
379 textentry
<span class=
"sy0">=
</span> g_object_get_data
<span class=
"br0">(</span>G_OBJECT
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"sy0">,
</span> <span class=
"st0">"textentry
"</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
380 gtk_entry_set_text
<span class=
"br0">(</span>GTK_ENTRY
<span class=
"br0">(</span>textentry
<span class=
"br0">)</span><span class=
"sy0">,
</span> string
<span class=
"br0">)</span><span class=
"sy0">;
</span>
381 <span class=
"coMULTI">/* select the text region that the user usually likes to overwrite */
</span>
382 gtk_entry_select_region
<span class=
"br0">(</span>GTK_ENTRY
<span class=
"br0">(</span>textentry
<span class=
"br0">)</span><span class=
"sy0">,
</span> <span class=
"nu0">0</span><span class=
"sy0">,
</span> <a href=
"http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span class=
"kw3">strlen
</span></a><span class=
"br0">(</span>string
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
383 <span class=
"br0">}</span></pre>
386 The response function for such a dialog may look like this:
388 <pre class=
"code c"><span class=
"kw4">void
</span> dialog_response
<span class=
"br0">(</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">)</span>
389 <span class=
"br0">{</span>
390 <span class=
"kw1">switch
</span> <span class=
"br0">(</span>response
<span class=
"br0">)</span> <span class=
"br0">{</span>
391 <span class=
"kw1">case
</span> GTK_RESPONSE_ACCEPT
<span class=
"sy0">:
</span>
392 <span class=
"coMULTI">/* apply the dialog settings:
393 just insert your code here if it is short
394 call an extra apply function if the required code is long */
</span>
395 <span class=
"kw2">break
</span><span class=
"sy0">;
</span>
396 <span class=
"kw1">case
</span> GTK_RESPONSE_REJECT
<span class=
"sy0">:
</span>
397 <span class=
"kw1">case
</span> GTK_RESPONSE_DELETE_EVENT
<span class=
"sy0">:
</span>
398 <span class=
"coMULTI">/* for modal dialogs just do nothing,
399 for nonmodal dialogs, destroy the dialog and clean up */
</span>
400 <span class=
"kw2">break
</span><span class=
"sy0">;
</span>
401 <span class=
"kw1">default
</span><span class=
"sy0">:
</span>
402 <span class=
"coMULTI">/* catch wrong signals signals (paranoid error checking ;-)) */
</span>
403 <a href=
"http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class=
"kw3">printf
</span></a><span class=
"br0">(</span><span class=
"st0">"dialog_response(): strange signal %d
<span class=
"es1">\n
</span>"</span><span class=
"sy0">,
</span> response
<span class=
"br0">)</span><span class=
"sy0">;
</span>
404 <span class=
"br0">}</span>
406 <span class=
"coMULTI">/* for nonmodal dialogs just do nothing,
407 for modal dialogs, always destroy the dialog and clean up */
</span>
408 <span class=
"br0">}</span></pre>
412 <h3 id=
"currentdialogissuesingschem">Current Dialog Issues in Gschem
</h3>
415 <li class=
"level1"><div class=
"li"> every dialog has it
's own design
</div>
417 <li class=
"level1"><div class=
"li"> dialog placement: mouse position or no predefined position?
</div>
419 <li class=
"level1"><div class=
"li"> dialogs do not remember their last size, position and contents.
</div>
421 <li class=
"level1"><div class=
"li"> missing keyboard shortcuts
</div>
426 <strong>Here
's a list of things that could be improved:
</strong>
431 <h5 id=
"printdialog">Print Dialog
</h5>
434 <li class=
"level1"><div class=
"li"> change design?
</div>
440 <h5 id=
"writeimage">Write Image
</h5>
443 <li class=
"level1"><div class=
"li"> In the fileselect dialog the default filename is missing if the file does not exist
</div>
445 <li class=
"level1"><div class=
"li"> Return key does not work in the filename entry
</div>
451 <h5 id=
"executescript">Execute Script
</h5>
454 <li class=
"level1"><div class=
"li"></div>
460 <h5 id=
"edittext">Edit Text
</h5>
463 <li class=
"level1"><div class=
"li"> some missing keyboard shortcuts
</div>
465 <li class=
"level1"><div class=
"li"> add *unmodified* tags if there are multiple selections
</div>
467 <li class=
"level1"><div class=
"li"> maybe add some color pixbufs for the color
</div>
469 <li class=
"level1"><div class=
"li"> maybe replace the text alignment with nine ratio buttons, toggle buttons with icons or ...
</div>
475 <h5 id=
"colordialog">Color Dialog
</h5>
478 <li class=
"level1"><div class=
"li"> maybe add some color pixbufs for the color
</div>
484 <h5 id=
"linewidthandtype">Line Width and Type
</h5>
487 <li class=
"level1"><div class=
"li"> keyboard shortcuts missing
</div>
489 <li class=
"level1"><div class=
"li"> icons for the line type
</div>
495 <h5 id=
"filltype">Fill Type
</h5>
498 <li class=
"level1"><div class=
"li"> keyboard shortcuts missing
</div>
500 <li class=
"level1"><div class=
"li"> icons in the fill type
</div>
506 <h5 id=
"translatesymbol">Translate Symbol
</h5>
509 <li class=
"level1"><div class=
"li"></div>
515 <h5 id=
"pagemanager">Page Manager
</h5>
518 <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>
520 <li class=
"level1"><div class=
"li"> Maybe the
"Return
" key should trigger Refresh
</div>
526 <h5 id=
"componentselector">Component Selector
</h5>
529 <li class=
"level1"><div class=
"li"> strange edit widget when typing and the tree is selected (It
's a search helper widget, disable it?!)
</div>
535 <h5 id=
"singleattributeditor">Single Attribut Editor
</h5>
538 <li class=
"level1 node"><div class=
"li"> when multiple elements are selected and you call edit (ee) there are a few problems:
</div>
540 <li class=
"level3"><div class=
"li"> if the first object is text, then this dialog is opened (but with the wrong list parameter
</div>
542 <li class=
"level3"><div class=
"li"> if the first object is complex then the multiple attribute editor is called
</div>
550 <h5 id=
"multiattributeeditor">Multi Attribute Editor
</h5>
553 <li class=
"level1"><div class=
"li"></div>
559 <h5 id=
"addtext">Add Text
</h5>
562 <li class=
"level1"><div class=
"li"></div>
568 <h5 id=
"arcparams">Arc Params
</h5>
571 <li class=
"level1"><div class=
"li"> add the diameter to the dialog, but select the start angle entry (increment = grid)
</div>
573 <li class=
"level1"><div class=
"li"> let
"ee
" call that dialog if only a single arc is selected
</div>
575 <li class=
"level1"><div class=
"li"> maybe add a section label
</div>
581 <h5 id=
"insertpicture">Insert Picture
</h5>
584 <li class=
"level1"><div class=
"li"></div>
590 <h5 id=
"picturereplace">Picture Replace
</h5>
593 <li class=
"level1"><div class=
"li"> the new picture uses the aspect ratio of the old picture
</div>
595 <li class=
"level1"><div class=
"li"> the dialog has lots in common with the Insert Picture dialog. They could use some code together
</div>
601 <h5 id=
"findtext">Find Text
</h5>
604 <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>
606 <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>
608 <li class=
"level1"><div class=
"li"> maybe add an option:
"Select all matching text objects
", disable hierarchy for that feature!
</div>
610 <li class=
"level1"><div class=
"li"> FIXME gschem hangs if you use that dialog with hierarchical schematics that have dependancy loops (e.g. the autonumber test schematics)
</div>
612 <li class=
"level1"><div class=
"li"> add an option
"search for visible text only
"</div>
614 <li class=
"level1"><div class=
"li"> maybe use regular expressions instead of the substring for the searchtext
</div>
620 <h5 id=
"hidetext">Hide Text
</h5>
623 <li class=
"level1"><div class=
"li"> use regular expressions instead of starting substring
</div>
629 <h5 id=
"showtext">Show Text
</h5>
632 <li class=
"level1"><div class=
"li"> use regular expressions instead of starting substring
</div>
634 <li class=
"level1"><div class=
"li"> Maybe merge that dialog together with the
"Hide Text
" dialog
</div>
640 <h5 id=
"autonumbertext">Autonumber Text
</h5>
643 <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>
649 <h5 id=
"textsize">Text Size
</h5>
652 <li class=
"level1"><div class=
"li"></div>
658 <h5 id=
"snapgridspacing">Snap Grid Spacing
</h5>
661 <li class=
"level1"><div class=
"li"></div>
667 <h5 id=
"coorddialog">Coord Dialog
</h5>
670 <li class=
"level1"><div class=
"li"> maybe move the world coordinates to the main window status bar
</div>
676 <h5 id=
"aboutdialog">About Dialog
</h5>
679 <li class=
"level1"><div class=
"li"></div>
685 <h5 id=
"hotkeys">Hotkeys
</h5>
688 <li class=
"level1"><div class=
"li"></div>