1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en"
6 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
7 <title>geda:devel-tips
</title>
8 <meta name=
"generator" content=
"DokuWiki Release rc2007-05-24" />
9 <meta name=
"robots" content=
"index,follow" />
10 <meta name=
"date" content=
"2007-05-24T22:27:26-0400" />
11 <meta name=
"keywords" content=
"geda,devel-tips" />
12 <link rel=
"search" type=
"application/opensearchdescription+xml" href=
"http://geda.seul.org/wiki/lib/exe/opensearch.php" title=
"geda Wiki" />
13 <link rel=
"start" href=
"http://geda.seul.org/wiki/" />
14 <link rel=
"contents" href=
"http://geda.seul.org/wiki/geda:devel-tips?do=index" title=
"Index" />
15 <link rel=
"alternate" type=
"application/rss+xml" title=
"Recent Changes" href=
"http://geda.seul.org/wiki/feed.php" />
16 <link rel=
"alternate" type=
"application/rss+xml" title=
"Current Namespace" href=
"http://geda.seul.org/wiki/feed.php?mode=list&ns=geda" />
17 <link rel=
"alternate" type=
"text/html" title=
"Plain HTML" href=
"http://geda.seul.org/wiki/_export/xhtml/geda:devel-tips" />
18 <link rel=
"alternate" type=
"text/plain" title=
"Wiki Markup" href=
"http://geda.seul.org/wiki/_export/raw/geda:devel-tips" />
19 <link rel=
"stylesheet" media=
"all" type=
"text/css" href=
"lib/exe/css" />
20 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"lib/exe/001css" />
21 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"lib/exe/002css" />
24 <div class=
"dokuwiki export">
26 <div class=
"tocheader toctoggle" id=
"toc__header">Table of Contents
</div>
27 <div id=
"toc__inside">
30 <li class=
"level1"><div class=
"li"><span class=
"li"><a href=
"#geda_developer_tips_tricks_and_hints" class=
"toc">gEDA Developer Tips, tricks and hints
</a></span></div>
32 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#how_to_branch_correctly_using_cvs" class=
"toc">How to branch correctly using CVS
</a></span></div></li>
33 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#doxygen_comments_and_styles" class=
"toc">Doxygen Comments and styles
</a></span></div></li>
34 <li class=
"level2"><div class=
"li"><span class=
"li"><a href=
"#dialogsdesign_and_behaviour" class=
"toc">Dialogs: Design and Behaviour
</a></span></div>
36 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#dialog_design" class=
"toc">Dialog Design
</a></span></div></li>
37 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#modal_or_nonmodal_dialogs" class=
"toc">Modal or Nonmodal dialogs
</a></span></div></li>
38 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#where_to_place_the_dialog" class=
"toc">Where to place the dialog
</a></span></div></li>
39 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#placing_dialogs_in_front_of_their_parent_window" class=
"toc">Placing dialogs in front of their parent window
</a></span></div></li>
40 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#button_order_in_dialogs" class=
"toc">Button order in dialogs
</a></span></div></li>
41 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#dialog_design_of_the_current_dialogs" class=
"toc">Dialog design of the current dialogs
</a></span></div></li>
42 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#source_template_for_simple_dialogs" class=
"toc">Source template for simple dialogs
</a></span></div></li>
43 <li class=
"level3"><div class=
"li"><span class=
"li"><a href=
"#current_dialog_issues_in_gschem" class=
"toc">Current Dialog Issues in Gschem
</a></span></div></li></ul>
51 <h1><a name=
"geda_developer_tips_tricks_and_hints" id=
"geda_developer_tips_tricks_and_hints">gEDA Developer Tips, tricks and hints
</a></h1>
55 <!-- SECTION "gEDA Developer Tips, tricks and hints" [1-53] -->
56 <h2><a name=
"how_to_branch_correctly_using_cvs" id=
"how_to_branch_correctly_using_cvs">How to branch correctly using CVS
</a></h2>
60 Here’s a summary of what should happen with development on a branch that is intended to later be merged to the trunk. Suppose the branch is called “mine”.
64 1) tag the repository (trunk) to create a branch point tag:
66 <pre class=
"code"> cvs tag mine-base
</pre>
71 <pre class=
"code"> cvs tag -b -r mine-base mine
</pre>
74 What step #
1 does is to keep track of where the “mine” branch started
<br/>
75 from. The
"-r mine-base” in step #
2 says to create the branch starting
<br/>
76 from the tag “mine-base”. It is important to do this because you need
<br/>
77 to be able to know where each file is rooted (i.e., what version in the
<br/>
78 trunk it is derived from).
82 Usually, it is a good idea to periodically merge changes which have taken
<br/>
83 place on the trunk to the branch. This will reduce the amount of work when
<br/>
84 the work on the branch is ready to go back to the trunk.
88 # go to where the trunk is checked out and update it
90 <pre class=
"code"> cd /to/my/trunk/sources
94 # create a temporary tag in case someone commits stuff while you’re
<br/>
95 # in the middle of this procedure. This keeps you from losing anything.
97 <pre class=
"code"> cvs tag merge-mine
</pre>
100 # go to your branch source tree
103 cd /to/my/branch/sources
107 # the following says to apply the changes that have taken place on
<br/>
108 # the trunk between the version tagged with “mine-base” and “merge-mine”
<br/>
109 # to your branch source tree
111 <pre class=
"code"> cvs update -j mine-base -j merge-mine -dP
</pre>
114 # if all goes well, you’ll have no conflicts. It is not uncommon
<br/>
115 # for there to be some cases where you have to resolve conflicts by
<br/>
116 # hand. In this case the affected files will have a special comment
<br/>
117 # showing what your file on the branch had and what the file tagged as
<br/>
118 # merge-mine had. You, as the programmer, have to figure out what is
<br/>
119 # correct. Once this is all done, proceed.
<br/>
124 # checkin with a message like “sync with trunk” or
<br/>
125 # “pull up revs #### from the trunk” (if you were pulling up
<br/>
126 # a specific change).
128 <pre class=
"code"> cvs ci
</pre>
131 # Now we move the branch point tag to the temporary merge tag
<br/>
132 # This is because we have changed what rev each file in the branch
<br/>
133 # is based on in the trunk. This is known as re-rooting.
135 <pre class=
"code"> cvs tag -F -r merge-mine mine-base
</pre>
138 # now we don’t need the temporary merge tag anymore so remove it
140 <pre class=
"code"> cvs tag -d merge-mine
</pre>
143 When it is time to merge changes that have taken place on a branch back
<br/>
144 to the trunk (usually marking the end of that branch), first do a final
<br/>
145 trunk
→ branch merge as mentioned above. Then do a branch
→ trunk merge.
149 Now for a branch to trunk merge you’d do
151 <pre class=
"code"> cd /to/my/trunk/sources
153 cvs update -j mine-base -j mine -dP
</pre>
158 <pre class=
"code"> cvs ci
159 cvs tag -F mine-base
</pre>
162 This takes any changes between “mine-base” and “mine” and tries to apply
<br/>
163 it to the trunk. If it all goes cleanly, you just check it in otherwise you
<br/>
164 have to resolve conflicts. Then you move the branch point tag because the trunk
<br/>
165 now reflects the lastest in the branch.
169 The above was contributed by Dan McMahill
173 <!-- SECTION "How to branch correctly using CVS" [54-3116] -->
174 <h2><a name=
"doxygen_comments_and_styles" id=
"doxygen_comments_and_styles">Doxygen Comments and styles
</a></h2>
178 Any volunteer for writing some notes?
181 <li class=
"level1"><div class=
"li"> which keywords to use
</div>
183 <li class=
"level1"><div class=
"li"> a template for a function
</div>
185 <li class=
"level1"><div class=
"li"> a template for structs?
</div>
187 <li class=
"level1"><div class=
"li"> bug, todo and fixme tags
</div>
192 <!-- SECTION "Doxygen Comments and styles" [3117-3310] -->
193 <h2><a name=
"dialogsdesign_and_behaviour" id=
"dialogsdesign_and_behaviour">Dialogs: Design and Behaviour
</a></h2>
197 <!-- SECTION "Dialogs: Design and Behaviour" [3311-3353] -->
198 <h3><a name=
"dialog_design" id=
"dialog_design">Dialog Design
</a></h3>
202 There’s a nice document from the gnome guys called
<a href=
"http://developer.gnome.org/projects/gup/hig/2.0/" class=
"urlextern" title=
"http://developer.gnome.org/projects/gup/hig/2.0/" rel=
"nofollow"> Gnome HIG
</a>. There are several suggestions on how to design dialogs and how they should behave.
206 <strong> The dialog design is mostly a matter of taste:
</strong>
209 <li class=
"level1"><div class=
"li"> alignment of elements. See
<a href=
"http://developer.gnome.org/projects/gup/hig/2.0/design-window.html" class=
"urlextern" title=
"http://developer.gnome.org/projects/gup/hig/2.0/design-window.html" rel=
"nofollow"> Window Layout
</a></div>
211 <li class=
"level1"><div class=
"li"> right alignment of dialog buttons
</div>
213 <li class=
"level1"><div class=
"li"> some spacing around the dialog (but how much?)
</div>
215 <li class=
"level1"><div class=
"li"> some spacing between the elements (vertical and horizontal)
</div>
217 <li class=
"level1"><div class=
"li"> option groups with frames or indentation?
</div>
219 <li class=
"level1"><div class=
"li"> frame labels or bold headlines?
</div>
224 <strong>Misc:
</strong>
227 <li class=
"level1"><div class=
"li"> with a
<a href=
"http://www.chipx86.com/wiki/Libsexy#SexyIconEntry" class=
"urlextern" title=
"http://www.chipx86.com/wiki/Libsexy#SexyIconEntry" rel=
"nofollow"> libsexy widget
</a> it would be possible to place an icon inside the text entry this would be usefull for some dialogs:
</div>
229 <li class=
"level3"><div class=
"li"> the filter entry in the component select dialog
</div>
231 <li class=
"level3"><div class=
"li"> the file select in the print dialog
</div>
233 <li class=
"level3"><div class=
"li"> the file select in the export png dialog
</div>
240 <!-- SECTION "Dialog Design" [3354-4328] -->
241 <h3><a name=
"modal_or_nonmodal_dialogs" id=
"modal_or_nonmodal_dialogs">Modal or Nonmodal dialogs
</a></h3>
245 A modal dialog is required whenever the main application provides data for the dialog.
247 <pre class=
"code">Example:
248 The dialog is called with a selection list and the dialog only should operate on this selection.
</pre>
251 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.
255 A modal dialog is not OK if there is a lot of user interaction with the dialog. The component selection is a good example.
259 <!-- SECTION "Modal or Nonmodal dialogs" [4329-4859] -->
260 <h3><a name=
"where_to_place_the_dialog" id=
"where_to_place_the_dialog">Where to place the dialog
</a></h3>
264 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://developer.gnome.org/doc/API/2.0/gtk/gtk-Standard-Enumerations.html#GtkWindowPosition" class=
"urlextern" title=
"http://developer.gnome.org/doc/API/2.0/gtk/gtk-Standard-Enumerations.html#GtkWindowPosition" rel=
"nofollow"> GtkReference
</a>
268 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.
272 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://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkdialog.c" class=
"urlextern" title=
"http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkdialog.c" rel=
"nofollow"> taken from the GtkDialog source
</a>).
276 <!-- SECTION "Where to place the dialog" [4860-5604] -->
277 <h3><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>
281 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.
285 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.
289 <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. If dialogs are flickering at
100% CPU load, then disable that setting.
291 <pre class=
"code lisp"><span class=
"co1">; raise-dialog-boxes-on-expose string
</span>
292 <span class=
"co1">;
</span>
293 <span class=
"co1">; Controls if dialog boxes are raised whenever an expose event happens
</span>
294 <span class=
"co1">; Default is enabled
</span>
295 <span class=
"co1">;
</span>
296 <span class=
"co1">;(raise-dialog-boxes-on-expose
"enabled
")
</span>
297 <span class=
"br0">(</span>raise-dialog-boxes-on-expose
<span class=
"st0">"disabled
"</span><span class=
"br0">)</span></pre>
299 <!-- SECTION "Placing dialogs in front of their parent window" [5605-6690] -->
300 <h3><a name=
"button_order_in_dialogs" id=
"button_order_in_dialogs">Button order in dialogs
</a></h3>
304 Button order at the bottom of the dialog depends on which operating system the user is using. GTK handles this automatically (require version
> 2.6.0) , but requires the developers set the alternative button order. For more information, check the GTK documentation
<a href=
"http://developer.gnome.org/doc/API/2.0/gtk/GtkSettings.html" class=
"urlextern" title=
"http://developer.gnome.org/doc/API/2.0/gtk/GtkSettings.html" rel=
"nofollow">here
</a>.
308 The alternative button order is set with just one call to a GTK function:
310 <pre class=
"code C"><span class=
"co2">#if GTK_CHECK_VERSION (
2,
6,
0)
</span>
311 <span class=
"coMULTI">/* Set the alternative button order (ok, cancel, help) for other systems */
</span>
312 gtk_dialog_set_alternative_button_order
<span class=
"br0">(</span>GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>,
317 <span class=
"nu0">-
1</span><span class=
"br0">)</span>;
318 <span class=
"co2">#endif
</span></pre>
320 This should be done for every new dialog created, before running it.
324 <!-- SECTION "Button order in dialogs" [6691-7514] -->
325 <h3><a name=
"dialog_design_of_the_current_dialogs" id=
"dialog_design_of_the_current_dialogs">Dialog design of the current dialogs
</a></h3>
329 <a href=
"_detail/devel_tips_dialog_picture.html" class=
"media" title=
"devel_tips:dialog_picture.png"><img src=
"_media/devel_tips_dialog_picture.png" class=
"media" alt=
"" /></a>
332 <li class=
"level1"><div class=
"li"> There is some space around the whole dialog (
<em>DIALOG_BORDER_SPACING
</em>).
</div>
334 <li class=
"level1"><div class=
"li"> Some indentation to show the topic group (
<em>DIALOG_INDENTATION
</em>) below it’s bold headline.
</div>
336 <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>
341 <!-- SECTION "Dialog design of the current dialogs" [7515-7879] -->
342 <h3><a name=
"source_template_for_simple_dialogs" id=
"source_template_for_simple_dialogs">Source template for simple dialogs
</a></h3>
346 This template is not intented to compile, but you can easily copy the code block that you need.
348 <pre class=
"code c"><span class=
"kw4">void
</span> dialog
<span class=
"br0">(</span>TOPLEVEL *w_current
<span class=
"br0">)</span>
349 <span class=
"br0">{</span>
350 GtkWidget *vbox, *label, *alignment, *table;
353 <span class=
"coMULTI">/* only create the dialog if it is not there yet. This usually is a
354 widget pointer in the w_current structure:
355 dialog = w_current-
>tewindow */
</span>
356 <span class=
"kw1">if
</span> <span class=
"br0">(</span>!dialog
<span class=
"br0">)</span> <span class=
"br0">{</span>
357 dialog = gtk_dialog_new_with_buttons
<span class=
"br0">(</span>_
<span class=
"br0">(</span><span class=
"st0">"Dialog title
"</span><span class=
"br0">)</span>,
358 <span class=
"coMULTI">/* the parent window or NULL */
</span>
359 GTK_WINDOW
<span class=
"br0">(</span>w_current-
>main_window
<span class=
"br0">)</span>,
360 <span class=
"coMULTI">/* dialog properties */
</span>
361 GTK_DIALOG_MODAL,
<span class=
"coMULTI">/*
0 for nonmodal dialogs */
</span>
362 <span class=
"coMULTI">/* dialog buttons and response signals */
</span>
367 <span class=
"kw2">NULL
</span><span class=
"br0">)</span>;
369 <span class=
"co2">#if GTK_CHECK_VERSION (
2,
6,
0)
</span>
370 <span class=
"coMULTI">/* Set the alternative button order (ok, cancel, help) for other systems */
</span>
371 gtk_dialog_set_alternative_button_order
<span class=
"br0">(</span>GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>,
376 <span class=
"nu0">-
1</span><span class=
"br0">)</span>;
377 <span class=
"co2">#endif
</span>
379 <span class=
"coMULTI">/* set default response signal. This is usually triggered by the
380 "Return
" key */
</span>
381 gtk_dialog_set_default_response
<span class=
"br0">(</span>GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>,
382 GTK_RESPONSE_ACCEPT
<span class=
"br0">)</span>;
384 <span class=
"coMULTI">/* set the function for handling the button responses and dialog close
385 for nonmodal dialogs you can use dialog_run() too.*/
</span>
386 gtk_signal_connect
<span class=
"br0">(</span>GTK_OBJECT
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>,
<span class=
"st0">"response
"</span>,
387 GTK_SIGNAL_FUNC
<span class=
"br0">(</span>dialog_response
<span class=
"br0">)</span>, w_current
<span class=
"br0">)</span>;
389 <span class=
"coMULTI">/* where to place the dialog: GTK_WIN_POS_MOUSE or GTK_WIN_POS_NONE */
</span>
390 gtk_window_position
<span class=
"br0">(</span>GTK_WINDOW
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>, GTK_WIN_POS_MOUSE
<span class=
"br0">)</span>;
392 <span class=
"coMULTI">/* set the border spacing and the vbox spacing of the dialog */
</span>
393 vbox = GTK_DIALOG
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>-
>vbox;
394 gtk_container_set_border_width
<span class=
"br0">(</span>GTK_CONTAINER
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>,DIALOG_BORDER_SPACING
<span class=
"br0">)</span>;
395 gtk_box_set_spacing
<span class=
"br0">(</span>GTK_BOX
<span class=
"br0">(</span>vbox
<span class=
"br0">)</span>, DIALOG_V_SPACING
<span class=
"br0">)</span>;
397 <span class=
"coMULTI">/* create a label (with markup) and pack it into the dialog box */
</span>
398 label = 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>;
399 gtk_label_set_use_markup
<span class=
"br0">(</span>GTK_LABEL
<span class=
"br0">(</span>label
<span class=
"br0">)</span>,
<span class=
"kw2">TRUE
</span><span class=
"br0">)</span>;
400 gtk_misc_set_alignment
<span class=
"br0">(</span>GTK_MISC
<span class=
"br0">(</span>label
<span class=
"br0">)</span>,
<span class=
"nu0">0</span>,
<span class=
"nu0">0</span><span class=
"br0">)</span>;
401 gtk_box_pack_start
<span class=
"br0">(</span>GTK_BOX
<span class=
"br0">(</span>vbox
<span class=
"br0">)</span>, label,
<span class=
"kw2">FALSE
</span>,
<span class=
"kw2">FALSE
</span>,
<span class=
"nu0">0</span><span class=
"br0">)</span>;
403 <span class=
"coMULTI">/* create a alignment container with the DIALOG_INDENTATION on the left */
</span>
404 alignment = gtk_alignment_new
<span class=
"br0">(</span><span class=
"nu0">0</span>,
<span class=
"nu0">0</span>,
<span class=
"nu0">1</span>,
<span class=
"nu0">1</span><span class=
"br0">)</span>;
405 gtk_alignment_set_padding
<span class=
"br0">(</span>GTK_ALIGNMENT
<span class=
"br0">(</span>alignment
<span class=
"br0">)</span>,
<span class=
"nu0">0</span>,
<span class=
"nu0">0</span>,
406 DIALOG_INDENTATION,
<span class=
"nu0">0</span><span class=
"br0">)</span>;
407 gtk_box_pack_start
<span class=
"br0">(</span>GTK_BOX
<span class=
"br0">(</span>vbox
<span class=
"br0">)</span>, alignment,
<span class=
"kw2">FALSE
</span>,
<span class=
"kw2">FALSE
</span>,
<span class=
"nu0">0</span><span class=
"br0">)</span>;
409 <span class=
"coMULTI">/* a table can store several entries. It is stored in the aligment container.
410 Note: the vertical and horizontal cell spacings */
</span>
411 table = gtk_table_new
<span class=
"br0">(</span><span class=
"nu0">3</span>,
<span class=
"nu0">2</span>,
<span class=
"kw2">FALSE
</span><span class=
"br0">)</span>;
412 gtk_table_set_row_spacings
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</span>, DIALOG_V_SPACING
<span class=
"br0">)</span>;
413 gtk_table_set_col_spacings
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</span>, DIALOG_H_SPACING
<span class=
"br0">)</span>;
414 gtk_container_add
<span class=
"br0">(</span>GTK_CONTAINER
<span class=
"br0">(</span>alignment
<span class=
"br0">)</span>, table
<span class=
"br0">)</span>;
416 <span class=
"coMULTI">/* a simple text label in one table cell with left alignment.
417 Note: the GTK_FILL in the third line is required */
</span>
418 label = gtk_label_new
<span class=
"br0">(</span>_
<span class=
"br0">(</span><span class=
"st0">"Text:
"</span><span class=
"br0">)</span><span class=
"br0">)</span>;
419 gtk_misc_set_alignment
<span class=
"br0">(</span>GTK_MISC
<span class=
"br0">(</span>label
<span class=
"br0">)</span>,
<span class=
"nu0">0</span>,
<span class=
"nu0">0</span><span class=
"br0">)</span>;
420 gtk_table_attach
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</span>, label,
<span class=
"nu0">0</span>,
<span class=
"nu0">1</span>,
<span class=
"nu0">0</span>,
<span class=
"nu0">1</span>, GTK_FILL,
<span class=
"nu0">0</span>,
<span class=
"nu0">0</span>,
<span class=
"nu0">0</span><span class=
"br0">)</span>;
422 <span class=
"coMULTI">/* a simple text entry completes the option row */
</span>
423 textentry = gtk_entry_new_with_max_length
<span class=
"br0">(</span><span class=
"nu0">10</span><span class=
"br0">)</span>;
424 gtk_table_attach_defaults
<span class=
"br0">(</span>GTK_TABLE
<span class=
"br0">(</span>table
<span class=
"br0">)</span>, textentry,
<span class=
"nu0">1</span>,
<span class=
"nu0">2</span>,
<span class=
"nu0">0</span>,
<span class=
"nu0">1</span><span class=
"br0">)</span>;
425 gtk_entry_set_activates_default
<span class=
"br0">(</span>GTK_ENTRY
<span class=
"br0">(</span>textentry
<span class=
"br0">)</span>,
<span class=
"kw2">TRUE
</span><span class=
"br0">)</span>;
427 <span class=
"coMULTI">/* ..... more table rows with options, or new sections */
</span>
429 <span class=
"coMULTI">/* create references to all widgets that you need later */
</span>
430 GLADE_HOOKUP_OBJECT
<span class=
"br0">(</span>dialog, sizeentry,
<span class=
"st0">"textentry
"</span><span class=
"br0">)</span>;
432 <span class=
"coMULTI">/* show all widgets recursivly */
</span>
433 gtk_widget_show_all
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>;
434 <span class=
"br0">}</span>
436 <span class=
"kw1">else
</span> <span class=
"br0">{</span>
437 <span class=
"coMULTI">/* Dialog is already there. Present it to the user.
438 This is only required if you have a nonmodal dialog */
</span>
439 gtk_window_present
<span class=
"br0">(</span>GTK_WINDOW
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span><span class=
"br0">)</span>;
440 <span class=
"br0">}</span>
442 <span class=
"coMULTI">/* always set the current values to the dialog
443 If you're placing that part at the end of the dialog function you can
444 easily create dialogs that can be called, even if they are already open */
</span>
445 textentry = g_object_get_data
<span class=
"br0">(</span>G_OBJECT
<span class=
"br0">(</span>dialog
<span class=
"br0">)</span>,
<span class=
"st0">"textentry
"</span><span class=
"br0">)</span>;
446 gtk_entry_set_text
<span class=
"br0">(</span>GTK_ENTRY
<span class=
"br0">(</span>textentry
<span class=
"br0">)</span>,
<span class=
"kw4">string
</span><span class=
"br0">)</span>;
447 <span class=
"coMULTI">/* select the text region that the user usually likes to overwrite */
</span>
448 gtk_entry_select_region
<span class=
"br0">(</span>GTK_ENTRY
<span class=
"br0">(</span>textentry
<span class=
"br0">)</span>,
<span class=
"nu0">0</span>, strlen
<span class=
"br0">(</span><span class=
"kw4">string
</span><span class=
"br0">)</span><span class=
"br0">)</span>;
449 <span class=
"br0">}</span></pre>
451 The response function for such a dialog may look like this:
453 <pre class=
"code c"><span class=
"kw4">void
</span> dialog_response
<span class=
"br0">(</span>GtkWidget *widget, gint response, TOPLEVEL *w_current
<span class=
"br0">)</span>
454 <span class=
"br0">{</span>
455 <span class=
"kw1">switch
</span> <span class=
"br0">(</span>response
<span class=
"br0">)</span> <span class=
"br0">{</span>
456 <span class=
"kw1">case
</span> GTK_RESPONSE_ACCEPT:
457 <span class=
"coMULTI">/* apply the dialog settings:
458 just insert your code here if it is short
459 call an extra apply function if the required code is long */
</span>
460 <span class=
"kw2">break
</span>;
461 <span class=
"kw1">case
</span> GTK_RESPONSE_REJECT:
462 <span class=
"kw1">case
</span> GTK_RESPONSE_DELETE_EVENT:
463 <span class=
"coMULTI">/* for modal dialogs just do nothing,
464 for nonmodal dialogs, destroy the dialog and clean up */
</span>
465 <span class=
"kw2">break
</span>;
466 <span class=
"kw1">default
</span>:
467 <span class=
"coMULTI">/* catch wrong signals signals (paranoid error checking ;-)) */
</span>
468 <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=
"es0">\n
</span>"</span>, response
<span class=
"br0">)</span>;
469 <span class=
"br0">}</span>
471 <span class=
"coMULTI">/* for nonmodal dialogs just do nothing,
472 for modal dialogs, always destroy the dialog and clean up */
</span>
473 <span class=
"br0">}</span></pre>
475 <!-- SECTION "Source template for simple dialogs" [7880-13015] -->
476 <h3><a name=
"current_dialog_issues_in_gschem" id=
"current_dialog_issues_in_gschem">Current Dialog Issues in Gschem
</a></h3>
479 <li class=
"level1"><div class=
"li"> every dialog has it’s own design
</div>
481 <li class=
"level1"><div class=
"li"> dialog placement: mouse position or no predefined position?
</div>
483 <li class=
"level1"><div class=
"li"> dialogs do not remember their last size, position and contents.
</div>
485 <li class=
"level1"><div class=
"li"> missing keyboard shortcuts
</div>
490 <strong>Here’s a list of things that could be improved:
</strong>
495 <h5><a name=
"print_dialog" id=
"print_dialog">Print Dialog
</a></h5>
498 <li class=
"level1"><div class=
"li"> change design?
</div>
504 <h5><a name=
"write_image" id=
"write_image">Write Image
</a></h5>
507 <li class=
"level1"><div class=
"li"> In the fileselect dialog the default filename is missing if the file does not exist
</div>
509 <li class=
"level1"><div class=
"li"> Return key does not work in the filename entry
</div>
515 <h5><a name=
"execute_script" id=
"execute_script">Execute Script
</a></h5>
518 <li class=
"level1"><div class=
"li"> </div>
524 <h5><a name=
"edit_text" id=
"edit_text">Edit Text
</a></h5>
527 <li class=
"level1"><div class=
"li"> some missing keyboard shortcuts
</div>
529 <li class=
"level1"><div class=
"li"> add *unmodified* tags if there are multiple selections
</div>
531 <li class=
"level1"><div class=
"li"> maybe add some color pixbufs for the color
</div>
533 <li class=
"level1"><div class=
"li"> maybe replace the text alignment with nine ratio buttons, toggle buttons with icons or
…</div>
539 <h5><a name=
"color_dialog" id=
"color_dialog">Color Dialog
</a></h5>
542 <li class=
"level1"><div class=
"li"> maybe add some color pixbufs for the color
</div>
548 <h5><a name=
"line_width_and_type" id=
"line_width_and_type">Line Width and Type
</a></h5>
551 <li class=
"level1"><div class=
"li"> keyboard shortcuts missing
</div>
553 <li class=
"level1"><div class=
"li"> icons for the line type
</div>
559 <h5><a name=
"fill_type" id=
"fill_type">Fill Type
</a></h5>
562 <li class=
"level1"><div class=
"li"> keyboard shortcuts missing
</div>
564 <li class=
"level1"><div class=
"li"> icons in the fill type
</div>
570 <h5><a name=
"translate_symbol" id=
"translate_symbol">Translate Symbol
</a></h5>
573 <li class=
"level1"><div class=
"li"> </div>
579 <h5><a name=
"page_manager" id=
"page_manager">Page Manager
</a></h5>
582 <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>
584 <li class=
"level1"><div class=
"li"> Maybe the “Return” key should trigger Refresh
</div>
590 <h5><a name=
"component_selector" id=
"component_selector">Component Selector
</a></h5>
593 <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>
599 <h5><a name=
"single_attribut_editor" id=
"single_attribut_editor">Single Attribut Editor
</a></h5>
602 <li class=
"level1"><div class=
"li"> when multiple elements are selected and you call edit (ee) there are a few problems:
</div>
604 <li class=
"level3"><div class=
"li"> if the first object is text, then this dialog is opened (but with the wrong list parameter
</div>
606 <li class=
"level3"><div class=
"li"> if the first object is complex then the multiple attribute editor is called
</div>
614 <h5><a name=
"multi_attribute_editor" id=
"multi_attribute_editor">Multi Attribute Editor
</a></h5>
617 <li class=
"level1"><div class=
"li"> </div>
623 <h5><a name=
"add_text" id=
"add_text">Add Text
</a></h5>
626 <li class=
"level1"><div class=
"li"> </div>
632 <h5><a name=
"arc_params" id=
"arc_params">Arc Params
</a></h5>
635 <li class=
"level1"><div class=
"li"> add the diameter to the dialog, but select the start angle entry (increment = grid)
</div>
637 <li class=
"level1"><div class=
"li"> let “ee” call that dialog if only a single arc is selected
</div>
639 <li class=
"level1"><div class=
"li"> maybe add a section label
</div>
645 <h5><a name=
"insert_picture" id=
"insert_picture">Insert Picture
</a></h5>
648 <li class=
"level1"><div class=
"li"> </div>
654 <h5><a name=
"picture_replace" id=
"picture_replace">Picture Replace
</a></h5>
657 <li class=
"level1"><div class=
"li"> the new picture uses the aspect ratio of the old picture
</div>
659 <li class=
"level1"><div class=
"li"> the dialog has lots in common with the Insert Picture dialog. They could use some code together
</div>
665 <h5><a name=
"find_text" id=
"find_text">Find Text
</a></h5>
668 <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>
670 <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>
672 <li class=
"level1"><div class=
"li"> maybe add an option: “Select all matching text objects”, disable hierarchy for that feature!
</div>
674 <li class=
"level1"><div class=
"li"> <img src=
"lib/images/smileys/fixme.gif" class=
"middle" alt=
"FIXME" /> gschem hangs if you use that dialog with hierarchical schematics that have dependancy loops (e.g. the autonumber test schematics)
</div>
676 <li class=
"level1"><div class=
"li"> add an option “search for visible text only”
</div>
678 <li class=
"level1"><div class=
"li"> maybe use regular expressions instead of the substring for the searchtext
</div>
684 <h5><a name=
"hide_text" id=
"hide_text">Hide Text
</a></h5>
687 <li class=
"level1"><div class=
"li"> use regular expressions instead of starting substring
</div>
693 <h5><a name=
"show_text" id=
"show_text">Show Text
</a></h5>
696 <li class=
"level1"><div class=
"li"> use regular expressions instead of starting substring
</div>
698 <li class=
"level1"><div class=
"li"> Maybe merge that dialog together with the “Hide Text” dialog
</div>
704 <h5><a name=
"autonumber_text" id=
"autonumber_text">Autonumber Text
</a></h5>
707 <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>
713 <h5><a name=
"text_size" id=
"text_size">Text Size
</a></h5>
716 <li class=
"level1"><div class=
"li"> </div>
722 <h5><a name=
"snap_grid_spacing" id=
"snap_grid_spacing">Snap Grid Spacing
</a></h5>
725 <li class=
"level1"><div class=
"li"> </div>
731 <h5><a name=
"coord_dialog" id=
"coord_dialog">Coord Dialog
</a></h5>
734 <li class=
"level1"><div class=
"li"> maybe move the world coordinates to the main window status bar
</div>
740 <h5><a name=
"about_dialog" id=
"about_dialog">About Dialog
</a></h5>
743 <li class=
"level1"><div class=
"li"> </div>
749 <h5><a name=
"hotkeys" id=
"hotkeys">Hotkeys
</a></h5>
752 <li class=
"level1"><div class=
"li"> </div>
757 <!-- SECTION "Current Dialog Issues in Gschem" [13016-] --></div>