1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 #include <config.h>
21 #include <missing.h>
22 #include <version.h>
23
24 #include <stdio.h>
25 #include <sys/stat.h>
26 #include <ctype.h>
27 #ifdef HAVE_STRING_H
28 #include <string.h>
29 #endif
30 #ifdef HAVE_STDLIB_H
31 #include <stdlib.h>
32 #endif
33 #ifdef HAVE_UNISTD_H
34 #include <unistd.h>
35 #endif
36
37 #include "gschem.h"
38
39 #ifdef HAVE_LIBDMALLOC
40 #include <dmalloc.h>
41 #endif
42
43 /*! \todo Finish function documentation!!!
44 * \brief
45 * \par Function Description
46 *
47 */
g_rc_parse_gtkrc()48 void g_rc_parse_gtkrc()
49 {
50 gchar *filename;
51
52 filename = g_build_filename (s_path_sys_config (), "gschem-gtkrc", NULL);
53 gtk_rc_parse (filename);
54 g_free (filename);
55
56 filename = g_build_filename (s_path_user_config (), "gschem-gtkrc", NULL);
57 gtk_rc_parse (filename);
58 g_free (filename);
59 }
60
61 /*! \brief Verify the version of the RC file under evaluation.
62 * \par Function Description
63 *
64 * Implements the Scheme function "gschem-version". Tests the version
65 * string in the argument against the version of the application
66 * itself.
67 *
68 * \param [in] scm_version Scheme object containing RC file version string
69 *
70 * \returns #t if the version of the RC file matches the application,
71 * else #f.
72 */
g_rc_gschem_version(SCM scm_version)73 SCM g_rc_gschem_version(SCM scm_version)
74 {
75 SCM ret;
76 char *version;
77 SCM rc_filename;
78 char *sourcefile;
79
80 SCM_ASSERT (scm_is_string (scm_version), scm_version,
81 SCM_ARG1, "gschem-version");
82
83 scm_dynwind_begin (0);
84 version = scm_to_utf8_string (scm_version);
85 scm_dynwind_free (version);
86
87 if (g_utf8_collate (g_utf8_casefold (version,-1),
88 g_utf8_casefold (PACKAGE_DATE_VERSION,-1)) != 0) {
89 sourcefile = NULL;
90 rc_filename = g_rc_rc_filename ();
91 sourcefile = scm_to_utf8_string (rc_filename);
92 scm_dynwind_free (sourcefile);
93 fprintf(stderr,
94 "You are running gEDA/gaf version [%s%s.%s],\n",
95 PREPEND_VERSION_STRING, PACKAGE_DOTTED_VERSION,
96 PACKAGE_DATE_VERSION);
97 fprintf(stderr,
98 "but you have a version [%s] gschemrc file:\n[%s]\n",
99 version, sourcefile);
100 fprintf(stderr,
101 "Please be sure that you have the latest rc file.\n");
102 ret = SCM_BOOL_F;
103 } else {
104 ret = SCM_BOOL_T;
105 }
106 scm_dynwind_end();
107 return ret;
108 }
109
110
111 /*! \todo Finish function documentation!!!
112 * \brief
113 * \par Function Description
114 *
115 */
g_rc_net_endpoint_mode(SCM mode)116 SCM g_rc_net_endpoint_mode(SCM mode)
117 {
118 static const vstbl_entry mode_table[] = {
119 {FILLEDBOX, "filledbox"}
120 };
121
122 RETURN_G_RC_MODE("net-endpoint-mode",
123 default_net_endpoint_mode,
124 1);
125 }
126
127 /*! \todo Finish function documentation!!!
128 * \brief
129 * \par Function Description
130 *
131 */
g_rc_net_midpoint_mode(SCM mode)132 SCM g_rc_net_midpoint_mode(SCM mode)
133 {
134 static const vstbl_entry mode_table[] = {
135 {FILLED, "filled"}
136 };
137
138 RETURN_G_RC_MODE("net-midpoint-mode",
139 default_net_midpoint_mode,
140 1);
141 }
142
143 /*! \todo Finish function documentation!!!
144 * \brief
145 * \par Function Description
146 *
147 */
g_rc_net_direction_mode(SCM mode)148 SCM g_rc_net_direction_mode(SCM mode)
149 {
150 static const vstbl_entry mode_table[] = {
151 {TRUE , "enabled" },
152 {FALSE, "disabled"}
153 };
154
155 RETURN_G_RC_MODE("net-direction-mode",
156 default_net_direction_mode,
157 2);
158 }
159
160 /*! \todo Finish function documentation!!!
161 * \brief
162 * \par Function Description
163 *
164 */
g_rc_net_selection_mode(SCM mode)165 SCM g_rc_net_selection_mode(SCM mode)
166 {
167 static const vstbl_entry mode_table[] = {
168 {0, "disabled"},
169 {2, "enabled_net"},
170 {3, "enabled_all"}
171 };
172
173 RETURN_G_RC_MODE("net-selection-mode",
174 default_net_selection_mode,
175 3);
176 }
177
178 /*! \todo Finish function documentation!!!
179 * \brief
180 * \par Function Description
181 *
182 */
g_rc_net_style(SCM mode)183 SCM g_rc_net_style(SCM mode)
184 {
185 static const vstbl_entry mode_table[] = {
186 {THIN , "thin" },
187 {THICK, "thick"}
188 };
189
190 RETURN_G_RC_MODE("net-style",
191 default_net_style,
192 2);
193 }
194
195 /*! \todo Finish function documentation!!!
196 * \brief
197 * \par Function Description
198 *
199 */
g_rc_bus_style(SCM mode)200 SCM g_rc_bus_style(SCM mode)
201 {
202 static const vstbl_entry mode_table[] = {
203 {THIN , "thin" },
204 {THICK, "thick"}
205 };
206
207 RETURN_G_RC_MODE("bus-style",
208 default_bus_style,
209 2);
210 }
211
212 /*! \todo Finish function documentation!!!
213 * \brief
214 * \par Function Description
215 *
216 */
g_rc_pin_style(SCM mode)217 SCM g_rc_pin_style(SCM mode)
218 {
219 static const vstbl_entry mode_table[] = {
220 {THIN , "thin" },
221 {THICK, "thick"}
222 };
223
224 RETURN_G_RC_MODE("pin-style",
225 default_pin_style,
226 2);
227 }
228
229 /*! \todo Finish function documentation!!!
230 * \brief
231 * \par Function Description
232 *
233 */
g_rc_line_style(SCM mode)234 SCM g_rc_line_style(SCM mode)
235 {
236 static const vstbl_entry mode_table[] = {
237 {THIN , "thin" },
238 {THICK, "thick"}
239 };
240
241 RETURN_G_RC_MODE("line-style",
242 default_line_style,
243 2);
244 }
245
246 /*! \todo Finish function documentation!!!
247 * \brief
248 * \par Function Description
249 *
250 */
g_rc_action_feedback_mode(SCM mode)251 SCM g_rc_action_feedback_mode(SCM mode)
252 {
253 static const vstbl_entry mode_table[] = {
254 {OUTLINE , "outline" },
255 {BOUNDINGBOX, "boundingbox"}
256 };
257
258 RETURN_G_RC_MODE("action-feedback-mode",
259 default_actionfeedback_mode,
260 2);
261 }
262
263 /*! \todo Finish function documentation!!!
264 * \brief
265 * \par Function Description
266 *
267 */
g_rc_zoom_with_pan(SCM mode)268 SCM g_rc_zoom_with_pan(SCM mode)
269 {
270 static const vstbl_entry mode_table[] = {
271 {TRUE, "enabled" },
272 {FALSE, "disabled"}
273 };
274
275 RETURN_G_RC_MODE("zoom-with-pan",
276 default_zoom_with_pan,
277 2);
278 }
279
280 /*! \todo Finish function documentation!!!
281 * \brief
282 * \par Function Description
283 *
284 */
g_rc_text_feedback(SCM mode)285 SCM g_rc_text_feedback(SCM mode)
286 {
287 static const vstbl_entry mode_table[] = {
288 {ALWAYS , "always" },
289 {ONLY_WHEN_READABLE, "only-when-readable"}
290 };
291
292 RETURN_G_RC_MODE("text-feedback",
293 default_text_feedback,
294 2);
295 }
296
297 /*! \todo Finish function documentation!!!
298 * \brief
299 * \par Function Description
300 *
301 */
g_rc_text_display_zoomfactor(SCM zoomfactor)302 SCM g_rc_text_display_zoomfactor(SCM zoomfactor)
303 {
304 int val;
305
306 SCM_ASSERT (scm_is_integer (zoomfactor), zoomfactor,
307 SCM_ARG1, "test-display-zoom-factor");
308
309 val = scm_to_int (zoomfactor);
310 if (val == 0) {
311 fprintf(stderr,
312 _("Invalid zoomfactor [%d] passed to %s\n"),
313 val,
314 "text-display-zoom-factor");
315 val = 10; /* absolute default */
316 }
317
318 default_text_display_zoomfactor = val;
319
320 return SCM_BOOL_T;
321 }
322
323 /*! \todo Finish function documentation!!!
324 * \brief
325 * \par Function Description
326 *
327 */
g_rc_scrollbar_update(SCM scmmode)328 SCM g_rc_scrollbar_update(SCM scmmode)
329 {
330 SCM ret = SCM_BOOL_T;
331
332 SCM_ASSERT (scm_is_string (scmmode), scmmode,
333 SCM_ARG1, "scrollbar-update");
334
335 return ret;
336 }
337
338 /*! \todo Finish function documentation!!!
339 * \brief
340 * \par Function Description
341 *
342 */
g_rc_object_clipping(SCM mode)343 SCM g_rc_object_clipping(SCM mode)
344 {
345 static const vstbl_entry mode_table[] = {
346 {TRUE , "enabled" },
347 {FALSE, "disabled"}
348 };
349
350 RETURN_G_RC_MODE("object-clipping",
351 default_object_clipping,
352 2);
353 }
354
355 /*! \todo Finish function documentation!!!
356 * \brief
357 * \par Function Description
358 *
359 */
g_rc_logging(SCM mode)360 SCM g_rc_logging(SCM mode)
361 {
362 static const vstbl_entry mode_table[] = {
363 {TRUE , "enabled" },
364 {FALSE, "disabled"}
365 };
366
367 RETURN_G_RC_MODE("logging",
368 default_do_logging,
369 2);
370 }
371
372 /*! \todo Finish function documentation!!!
373 * \brief
374 * \par Function Description
375 *
376 */
g_rc_embed_components(SCM mode)377 SCM g_rc_embed_components(SCM mode)
378 {
379 static const vstbl_entry mode_table[] = {
380 {TRUE , "enabled" },
381 {FALSE, "disabled"}
382 };
383
384 RETURN_G_RC_MODE("embed-components",
385 default_embed_complex,
386 2);
387 }
388
389 static void
free_string_glist(void * data)390 free_string_glist(void *data)
391 {
392 GList *iter, *glst = *((GList **) data);
393
394 for (iter = glst; iter != NULL; iter = g_list_next (iter)) {
395 g_free (iter->data);
396 }
397 g_list_free (glst);
398 }
399
400 /*! \brief read the configuration string list for the component dialog
401 * \par Function Description
402 * This function reads the string list from the component-dialog-attributes
403 * configuration parameter and converts the list into a GList.
404 * The GList is stored in the global default_component_select_attrlist variable.
405 */
g_rc_component_dialog_attributes(SCM stringlist)406 SCM g_rc_component_dialog_attributes(SCM stringlist)
407 {
408 int length, i;
409 GList *list=NULL;
410 gchar *attr;
411
412 SCM_ASSERT(scm_list_p(stringlist), stringlist, SCM_ARG1, "scm_is_list failed");
413 length = scm_ilength(stringlist);
414
415 /* If the command is called multiple times, remove the old list before
416 recreating it */
417 g_list_foreach(default_component_select_attrlist, (GFunc)g_free, NULL);
418 g_list_free(default_component_select_attrlist);
419
420 scm_dynwind_begin(0);
421 scm_dynwind_unwind_handler(free_string_glist, (void *) &list, 0);
422
423 /* convert the scm list into a GList */
424 for (i=0; i < length; i++) {
425 char *str;
426 SCM elem = scm_list_ref(stringlist, scm_from_int(i));
427
428 SCM_ASSERT(scm_is_string(elem), elem, SCM_ARG1, "list element is not a string");
429
430 str = scm_to_utf8_string(elem);
431 attr = g_strdup(str);
432 free(str);
433 list = g_list_prepend(list, attr);
434 }
435
436 scm_dynwind_end();
437
438 default_component_select_attrlist = g_list_reverse(list);
439
440 return SCM_BOOL_T;
441 }
442
443
444 /*! \todo Finish function documentation!!!
445 * \brief
446 * \par Function Description
447 *
448 */
g_rc_text_size(SCM size)449 SCM g_rc_text_size(SCM size)
450 {
451 int val;
452
453 SCM_ASSERT (scm_is_integer (size), size, SCM_ARG1, "text-size");
454
455 val = scm_to_int (size);
456 if (val == 0) {
457 fprintf(stderr,
458 _("Invalid size [%d] passed to text-size\n"),
459 val);
460 val = 10; /* absolute default */
461 }
462
463 default_text_size = val;
464
465 return SCM_BOOL_T;
466 }
467
468 /*! \todo Finish function documentation!!!
469 * \brief
470 * \par Function Description
471 *
472 * \todo inconsistant naming with keyword name and variable to hold
473 * variable
474 */
g_rc_text_caps_style(SCM mode)475 SCM g_rc_text_caps_style(SCM mode)
476 {
477 static const vstbl_entry mode_table[] = {
478 {LOWER, "lower" },
479 {UPPER, "upper" },
480 {BOTH , "both" }
481 };
482
483 RETURN_G_RC_MODE("text-caps-style",
484 default_text_caps,
485 3);
486 }
487
488 /*! \todo Finish function documentation!!!
489 * \brief
490 * \par Function Description
491 *
492 */
g_rc_snap_size(SCM size)493 SCM g_rc_snap_size(SCM size)
494 {
495 int val;
496
497 SCM_ASSERT (scm_is_integer (size), size, SCM_ARG1, "snap-size");
498
499 val = scm_to_int (size);
500 if (val == 0) {
501 fprintf(stderr, _("Invalid size [%d] passed to snap-size\n"),
502 val);
503 val = 100; /* absolute default */
504 }
505
506 default_snap_size = val;
507
508 return SCM_BOOL_T;
509 }
510
511 /*! \todo Finish function documentation!!!
512 * \brief
513 * \par Function Description
514 *
515 */
g_rc_logging_destination(SCM mode)516 SCM g_rc_logging_destination(SCM mode)
517 {
518 static const vstbl_entry mode_table[] = {
519 {LOG_WINDOW , "log_window" },
520 {STDOUT_TTY , "tty" },
521 {BOTH_LOGWIN_STDOUT , "both" }
522 };
523
524 RETURN_G_RC_MODE("logging-destination",
525 logging_dest,
526 3);
527 }
528
529 /*! \todo Finish function documentation!!!
530 * \brief
531 * \par Function Description
532 *
533 */
g_rc_attribute_name(SCM scm_path)534 SCM g_rc_attribute_name(SCM scm_path)
535 {
536 char *path;
537 SCM ret;
538
539 SCM_ASSERT (scm_is_string (scm_path), scm_path,
540 SCM_ARG1, "attribute-name");
541
542 path = scm_to_utf8_string (scm_path);
543
544 /* not unique? */
545 if (!s_attrib_uniq(path)) {
546 ret = SCM_BOOL_F;
547 } else {
548 s_attrib_add_entry (path);
549 ret = SCM_BOOL_T;
550 }
551
552 free(path);
553 return ret;
554 }
555
556 /*! \todo Finish function documentation!!!
557 * \brief
558 * \par Function Description
559 *
560 */
g_rc_scrollbars(SCM mode)561 SCM g_rc_scrollbars(SCM mode)
562 {
563 static const vstbl_entry mode_table[] = {
564 {TRUE , "enabled" },
565 {FALSE, "disabled"},
566 };
567
568 RETURN_G_RC_MODE("scrollbars",
569 default_scrollbars_flag,
570 2);
571 }
572
573 /*! \todo Finish function documentation!!!
574 * \brief
575 * \par Function Description
576 *
577 */
g_rc_paper_size(SCM width,SCM height)578 SCM g_rc_paper_size(SCM width, SCM height)
579 #define FUNC_NAME "paper-size"
580 {
581 SCM_ASSERT (SCM_NIMP (width) && SCM_REALP (width), width,
582 SCM_ARG1, FUNC_NAME);
583 SCM_ASSERT (SCM_NIMP (height) && SCM_REALP (height), height,
584 SCM_ARG2, FUNC_NAME);
585
586 /* yes this is legit, we are casting the resulting double to an int */
587 default_paper_width = (int) (scm_to_double (width) * MILS_PER_INCH);
588 default_paper_height = (int) (scm_to_double (height) * MILS_PER_INCH);
589
590 return SCM_BOOL_T;
591 }
592 #undef FUNC_NAME
593
594 /*! \todo Finish function documentation!!!
595 * \brief
596 * \par Function Description
597 *
598 */
g_rc_paper_sizes(SCM scm_papername,SCM scm_width,SCM scm_height)599 SCM g_rc_paper_sizes(SCM scm_papername, SCM scm_width, SCM scm_height)
600 #define FUNC_NAME "paper-sizes"
601 {
602 int width;
603 int height;
604 char *papername;
605 SCM ret;
606
607 SCM_ASSERT (scm_is_string (scm_papername), scm_papername,
608 SCM_ARG1, FUNC_NAME);
609 SCM_ASSERT (SCM_NIMP (scm_width) && SCM_REALP (scm_width), scm_width,
610 SCM_ARG2, FUNC_NAME);
611 SCM_ASSERT (SCM_NIMP (scm_height) && SCM_REALP (scm_height), scm_height,
612 SCM_ARG3, FUNC_NAME);
613
614 width = (int) (scm_to_double (scm_width) * MILS_PER_INCH);
615 height = (int) (scm_to_double (scm_height) * MILS_PER_INCH);
616 papername = scm_to_utf8_string (scm_papername);
617
618 if (!s_papersizes_uniq(papername)) {
619 ret = SCM_BOOL_F;
620 } else {
621 s_papersizes_add_entry(papername, width, height);
622 ret = SCM_BOOL_T;
623 }
624
625 free(papername);
626 return ret;
627 }
628 #undef FUNC_NAME
629
630 /*! \todo Finish function documentation!!!
631 * \brief
632 * \par Function Description
633 *
634 * \todo this keyword needs a better name ...
635 */
g_rc_output_type(SCM mode)636 SCM g_rc_output_type(SCM mode)
637 {
638 static const vstbl_entry mode_table[] = {
639 {WINDOW, "current window" },
640 {EXTENTS, "limits" }, /* deprecated */
641 {EXTENTS, "extents" },
642 {EXTENTS_NOMARGINS, "extents no margins" },
643 };
644
645 RETURN_G_RC_MODE("output-type",
646 default_print_output_type,
647 4);
648 }
649
650 /*! \todo Finish function documentation!!!
651 * \brief
652 * \par Function Description
653 *
654 */
g_rc_output_orientation(SCM mode)655 SCM g_rc_output_orientation(SCM mode)
656 {
657 static const vstbl_entry mode_table[] = {
658 {PORTRAIT , "portrait" },
659 {LANDSCAPE, "landscape"},
660 };
661
662 RETURN_G_RC_MODE("output-orientation",
663 default_print_orientation,
664 2);
665 }
666
667 /*! \todo Finish function documentation!!!
668 * \brief
669 * \par Function Description
670 *
671 */
g_rc_image_color(SCM mode)672 SCM g_rc_image_color(SCM mode)
673 {
674 static const vstbl_entry mode_table[] = {
675 {TRUE , "enabled" },
676 {FALSE, "disabled"},
677 };
678
679 RETURN_G_RC_MODE("image-color",
680 default_image_color,
681 2);
682 }
683
684 /*! \todo Finish function documentation!!!
685 * \brief
686 * \par Function Description
687 *
688 */
g_rc_image_size(SCM width,SCM height)689 SCM g_rc_image_size(SCM width, SCM height)
690 {
691 SCM_ASSERT (scm_is_integer (width), width, SCM_ARG1, "image-size");
692 SCM_ASSERT (scm_is_integer (height), height, SCM_ARG2, "image-size");
693
694 /* yes this is legit, we are casting the resulting double to an int */
695 default_image_width = scm_to_int (width);
696 default_image_height = scm_to_int (height);
697
698 return SCM_BOOL_T;
699 }
700
701 /*! \todo Finish function documentation!!!
702 * \brief
703 * \par Function Description
704 *
705 */
g_rc_output_color(SCM mode)706 SCM g_rc_output_color(SCM mode)
707 {
708 static const vstbl_entry mode_table[] = {
709 {TRUE , "enabled" },
710 {FALSE, "disabled"},
711 };
712
713 /* this variable is inconsistantly named with the rest */
714 RETURN_G_RC_MODE("output-color",
715 default_print_color,
716 2);
717 }
718
719 /*! \todo Finish function documentation!!!
720 * \brief
721 * \par Function Description
722 *
723 */
g_rc_output_capstyle(SCM mode)724 SCM g_rc_output_capstyle(SCM mode)
725 {
726 static const vstbl_entry mode_table[] = {
727 {BUTT_CAP , "butt" },
728 {ROUND_CAP , "round" },
729 {SQUARE_CAP, "square"},
730 };
731
732 RETURN_G_RC_MODE("output-capstyle",
733 default_print_output_capstyle,
734 3);
735 }
736
737 /*! \todo Finish function documentation!!!
738 * \brief
739 * \par Function Description
740 *
741 */
g_rc_log_window(SCM mode)742 SCM g_rc_log_window(SCM mode)
743 {
744 static const vstbl_entry mode_table[] = {
745 {MAP_ON_STARTUP, "startup" },
746 {MAP_LATER , "later" },
747 };
748
749 RETURN_G_RC_MODE("log-window",
750 default_log_window,
751 2);
752 }
753
754 /*! \todo Finish function documentation!!!
755 * \brief
756 * \par Function Description
757 *
758 */
g_rc_log_window_type(SCM mode)759 SCM g_rc_log_window_type(SCM mode)
760 {
761 static const vstbl_entry mode_table[] = {
762 {TRANSIENT, "transient" },
763 {DECORATED, "decorated" },
764 };
765
766 RETURN_G_RC_MODE("log-window-type",
767 default_log_window_type,
768 2);
769 }
770
771 /*! \todo Finish function documentation!!!
772 * \brief
773 * \par Function Description
774 *
775 */
g_rc_third_button(SCM mode)776 SCM g_rc_third_button(SCM mode)
777 {
778 static const vstbl_entry mode_table[] = {
779 {POPUP_ENABLED , "popup" },
780 {MOUSEPAN_ENABLED, "mousepan"},
781 };
782
783 RETURN_G_RC_MODE("third-button",
784 default_third_button,
785 2);
786 }
787
788 /*! \todo Finish function documentation!!!
789 * \brief
790 * \par Function Description
791 *
792 */
g_rc_middle_button(SCM mode)793 SCM g_rc_middle_button(SCM mode)
794 {
795 static const vstbl_entry mode_table[] = {
796 {STROKE, "stroke"},
797 {REPEAT, "repeat"},
798 {ACTION, "action"},
799 {MID_MOUSEPAN_ENABLED, "mousepan"},
800 };
801
802 RETURN_G_RC_MODE("middle-button",
803 default_middle_button,
804 4);
805 }
806
807 /*! \todo Finish function documentation!!!
808 * \brief
809 * \par Function Description
810 *
811 */
g_rc_scroll_wheel(SCM mode)812 SCM g_rc_scroll_wheel(SCM mode)
813 {
814 static const vstbl_entry mode_table[] = {
815 {SCROLL_WHEEL_CLASSIC, "classic"},
816 {SCROLL_WHEEL_GTK, "gtk"},
817 };
818
819 RETURN_G_RC_MODE("scroll-wheel",
820 default_scroll_wheel,
821 2);
822 }
823
824 /*! \todo Finish function documentation!!!
825 * \brief
826 * \par Function Description
827 *
828 */
g_rc_net_consolidate(SCM mode)829 SCM g_rc_net_consolidate(SCM mode)
830 {
831 static const vstbl_entry mode_table[] = {
832 {TRUE , "enabled" },
833 {FALSE, "disabled"},
834 };
835
836 RETURN_G_RC_MODE("net-consolidate",
837 default_net_consolidate,
838 2);
839 }
840
841 /*! \todo Finish function documentation!!!
842 * \brief
843 * \par Function Description
844 *
845 */
g_rc_file_preview(SCM mode)846 SCM g_rc_file_preview(SCM mode)
847 {
848 static const vstbl_entry mode_table[] = {
849 {TRUE , "enabled" },
850 {FALSE, "disabled"},
851 };
852
853 /* this variable is inconsistantly named with the rest */
854 RETURN_G_RC_MODE("file-preview",
855 default_file_preview,
856 2);
857 }
858
859 /*! \todo Finish function documentation!!!
860 * \brief
861 * \par Function Description
862 *
863 */
g_rc_enforce_hierarchy(SCM mode)864 SCM g_rc_enforce_hierarchy(SCM mode)
865 {
866 static const vstbl_entry mode_table[] = {
867 {TRUE , "enabled" },
868 {FALSE, "disabled"},
869 };
870
871 RETURN_G_RC_MODE("enforce-hierarchy",
872 default_enforce_hierarchy,
873 2);
874 }
875
876 /*! \todo Finish function documentation!!!
877 * \brief
878 * \par Function Description
879 *
880 */
g_rc_text_origin_marker(SCM mode)881 SCM g_rc_text_origin_marker(SCM mode)
882 {
883 static const vstbl_entry mode_table[] = {
884 {TRUE , "enabled" },
885 {FALSE, "disabled"},
886 };
887
888 RETURN_G_RC_MODE("text-origin-marker",
889 default_text_origin_marker,
890 2);
891 }
892
893 /*! \todo Finish function documentation!!!
894 * \brief
895 * \par Function Description
896 *
897 */
g_rc_fast_mousepan(SCM mode)898 SCM g_rc_fast_mousepan(SCM mode)
899 {
900 static const vstbl_entry mode_table[] = {
901 {TRUE , "enabled" },
902 {FALSE, "disabled"},
903 };
904
905 RETURN_G_RC_MODE("fast-mousepan",
906 default_fast_mousepan,
907 2);
908 }
909
910 /*! \todo Finish function documentation!!!
911 * \brief
912 * \par Function Description
913 *
914 */
g_rc_raise_dialog_boxes_on_expose(SCM mode)915 SCM g_rc_raise_dialog_boxes_on_expose(SCM mode)
916 {
917 static const vstbl_entry mode_table[] = {
918 {TRUE , "enabled" },
919 {FALSE, "disabled"},
920 };
921
922 RETURN_G_RC_MODE("raise-dialog-boxes-on-expose",
923 default_raise_dialog_boxes,
924 2);
925 }
926
927 /*! \todo Finish function documentation!!!
928 * \brief
929 * \par Function Description
930 *
931 */
g_rc_continue_component_place(SCM mode)932 SCM g_rc_continue_component_place(SCM mode)
933 {
934 static const vstbl_entry mode_table[] = {
935 {TRUE , "enabled" },
936 {FALSE, "disabled"},
937 };
938
939 RETURN_G_RC_MODE("continue-component-place",
940 default_continue_component_place,
941 2);
942 }
943
944 /*! \todo Finish function documentation!!!
945 * \brief
946 * \par Function Description
947 *
948 */
g_rc_undo_levels(SCM levels)949 SCM g_rc_undo_levels(SCM levels)
950 {
951 int val;
952
953 SCM_ASSERT (scm_is_integer (levels), levels, SCM_ARG1, "undo-levels");
954
955 val = scm_to_int (levels);
956
957 if (val == 0) {
958 fprintf(stderr, _("Invalid num levels [%d] passed to undo-levels\n"),
959 val);
960 val = 10; /* absolute default */
961 }
962
963 default_undo_levels = val;
964
965 return SCM_BOOL_T;
966 }
967
968 /*! \todo Finish function documentation!!!
969 * \brief
970 * \par Function Description
971 *
972 */
g_rc_undo_control(SCM mode)973 SCM g_rc_undo_control(SCM mode)
974 {
975 static const vstbl_entry mode_table[] = {
976 {TRUE , "enabled" },
977 {FALSE, "disabled"},
978 };
979
980 RETURN_G_RC_MODE("undo-control", default_undo_control, 2);
981 }
982
983 /*! \todo Finish function documentation!!!
984 * \brief
985 * \par Function Description
986 *
987 */
g_rc_undo_type(SCM mode)988 SCM g_rc_undo_type(SCM mode)
989 {
990 static const vstbl_entry mode_table[] = {
991 {UNDO_DISK , "disk" },
992 {UNDO_MEMORY, "memory" },
993 };
994
995 RETURN_G_RC_MODE("undo-type",
996 default_undo_type,
997 2);
998 }
999
1000 /*! \todo Finish function documentation!!!
1001 * \brief
1002 * \par Function Description
1003 *
1004 */
g_rc_undo_panzoom(SCM mode)1005 SCM g_rc_undo_panzoom(SCM mode)
1006 {
1007 static const vstbl_entry mode_table[] = {
1008 {TRUE , "enabled" },
1009 {FALSE, "disabled"},
1010 };
1011
1012 RETURN_G_RC_MODE("undo-panzoom", default_undo_panzoom, 2);
1013 }
1014
1015 /*! \todo Finish function documentation!!!
1016 * \brief
1017 * \par Function Description
1018 *
1019 */
g_rc_draw_grips(SCM mode)1020 SCM g_rc_draw_grips(SCM mode)
1021 {
1022 static const vstbl_entry mode_table[] = {
1023 {TRUE , "enabled" },
1024 {FALSE, "disabled"},
1025 };
1026
1027 RETURN_G_RC_MODE("draw-grips",
1028 default_draw_grips,
1029 2);
1030 }
1031
1032 /*! \todo Finish function documentation!!!
1033 * \brief
1034 * \par Function Description
1035 *
1036 */
g_rc_netconn_rubberband(SCM mode)1037 SCM g_rc_netconn_rubberband(SCM mode)
1038 {
1039 static const vstbl_entry mode_table[] = {
1040 {TRUE , "enabled" },
1041 {FALSE, "disabled"},
1042 };
1043
1044 RETURN_G_RC_MODE("netconn-rubberband",
1045 default_netconn_rubberband,
1046 2);
1047 }
1048
1049
1050 /*! \todo Finish function documentation!!!
1051 * \brief
1052 * \par Function Description
1053 *
1054 */
g_rc_magnetic_net_mode(SCM mode)1055 SCM g_rc_magnetic_net_mode(SCM mode)
1056 {
1057 static const vstbl_entry mode_table[] = {
1058 {TRUE , "enabled" },
1059 {FALSE, "disabled"},
1060 };
1061
1062 RETURN_G_RC_MODE("magnetic-net-mode",
1063 default_magnetic_net_mode,
1064 2);
1065 }
1066
1067 /*! \todo Finish function documentation!!!
1068 * \brief
1069 * \par Function Description
1070 *
1071 */
g_rc_sort_component_library(SCM mode)1072 SCM g_rc_sort_component_library(SCM mode)
1073 {
1074 static const vstbl_entry mode_table[] = {
1075 {TRUE , "enabled" },
1076 {FALSE, "disabled"},
1077 };
1078
1079 RETURN_G_RC_MODE("sort_component_library",
1080 default_sort_component_library,
1081 2);
1082 }
1083
1084 /*! \todo Finish function documentation!!!
1085 * \brief
1086 * \par Function Description
1087 *
1088 */
g_rc_add_menu(SCM scm_menu_name,SCM scm_menu_items)1089 SCM g_rc_add_menu(SCM scm_menu_name, SCM scm_menu_items)
1090 {
1091 char *menu_name;
1092
1093 SCM_ASSERT (scm_is_string (scm_menu_name), scm_menu_name,
1094 SCM_ARG1, "add-menu");
1095 SCM_ASSERT (SCM_NIMP (scm_menu_items) && SCM_CONSP (scm_menu_items), scm_menu_items,
1096 SCM_ARG2, "add-menu");
1097
1098 menu_name = scm_to_utf8_string (scm_menu_name);
1099 s_menu_add_entry(menu_name, scm_menu_items);
1100 free (menu_name);
1101
1102 return SCM_BOOL_T;
1103 }
1104
1105 /*! \todo Finish function documentation!!!
1106 * \brief
1107 * \par Function Description
1108 *
1109 */
g_rc_window_size(SCM width,SCM height)1110 SCM g_rc_window_size(SCM width, SCM height)
1111 {
1112 SCM_ASSERT (scm_is_integer (width), width, SCM_ARG1, "window-size");
1113 SCM_ASSERT (scm_is_integer (height), height, SCM_ARG2, "window-size");
1114
1115 default_width = scm_to_int (width);
1116 default_height = scm_to_int (height);
1117
1118 return SCM_BOOL_T;
1119 }
1120
1121 /*! \todo Finish function documentation!!!
1122 * \brief
1123 * \par Function Description
1124 *
1125 */
g_rc_warp_cursor(SCM mode)1126 SCM g_rc_warp_cursor(SCM mode)
1127 {
1128 static const vstbl_entry mode_table[] = {
1129 {TRUE , "enabled" },
1130 {FALSE, "disabled"},
1131 };
1132
1133 RETURN_G_RC_MODE("warp-cursor",
1134 default_warp_cursor,
1135 2);
1136 }
1137
1138 /*! \todo Finish function documentation!!!
1139 * \brief
1140 * \par Function Description
1141 *
1142 */
g_rc_toolbars(SCM mode)1143 SCM g_rc_toolbars(SCM mode)
1144 {
1145 static const vstbl_entry mode_table[] = {
1146 {TRUE , "enabled" },
1147 {FALSE, "disabled"},
1148 };
1149
1150 RETURN_G_RC_MODE("toolbars",
1151 default_toolbars,
1152 2);
1153 }
1154
1155 /*! \todo Finish function documentation!!!
1156 * \brief
1157 * \par Function Description
1158 *
1159 */
g_rc_handleboxes(SCM mode)1160 SCM g_rc_handleboxes(SCM mode)
1161 {
1162 static const vstbl_entry mode_table[] = {
1163 {TRUE , "enabled" },
1164 {FALSE, "disabled"},
1165 };
1166
1167 RETURN_G_RC_MODE("handleboxes",
1168 default_handleboxes,
1169 2);
1170 }
1171
1172 /*! \todo Finish function documentation!!!
1173 * \brief
1174 * \par Function Description
1175 *
1176 */
g_rc_setpagedevice_orientation(SCM mode)1177 SCM g_rc_setpagedevice_orientation(SCM mode)
1178 {
1179 static const vstbl_entry mode_table[] = {
1180 {TRUE , "enabled" },
1181 {FALSE, "disabled"},
1182 };
1183
1184 RETURN_G_RC_MODE("setpagedevice-orientation",
1185 default_setpagedevice_orientation,
1186 2);
1187 }
1188
1189 /*! \todo Finish function documentation!!!
1190 * \brief
1191 * \par Function Description
1192 *
1193 */
g_rc_setpagedevice_pagesize(SCM mode)1194 SCM g_rc_setpagedevice_pagesize(SCM mode)
1195 {
1196 static const vstbl_entry mode_table[] = {
1197 {TRUE , "enabled" },
1198 {FALSE, "disabled"},
1199 };
1200
1201 RETURN_G_RC_MODE("setpagedevice-pagesize",
1202 default_setpagedevice_pagesize,
1203 2);
1204 }
1205
1206 /*! \todo Finish function documentation!!!
1207 * \brief
1208 * \par Function Description
1209 *
1210 */
g_rc_bus_ripper_size(SCM size)1211 SCM g_rc_bus_ripper_size(SCM size)
1212 {
1213 int val;
1214
1215 SCM_ASSERT (scm_is_integer (size), size, SCM_ARG1, "bus-ripper-size");
1216
1217 val = scm_to_int (size);
1218
1219 if (val == 0) {
1220 fprintf(stderr, _("Invalid size [%d] passed to bus-ripper-size\n"),
1221 val);
1222 val = 200; /* absolute default */
1223 }
1224
1225 default_bus_ripper_size = val;
1226
1227 return SCM_BOOL_T;
1228 }
1229
1230 /*! \todo Finish function documentation!!!
1231 * \brief
1232 * \par Function Description
1233 *
1234 */
g_rc_bus_ripper_type(SCM mode)1235 SCM g_rc_bus_ripper_type(SCM mode)
1236 {
1237 static const vstbl_entry mode_table[] = {
1238 {COMP_BUS_RIPPER, "component" },
1239 {NET_BUS_RIPPER, "net" }
1240 };
1241
1242 RETURN_G_RC_MODE("bus-ripper-type",
1243 default_bus_ripper_type,
1244 2);
1245 }
1246
1247 /*! \todo Finish function documentation!!!
1248 * \brief
1249 * \par Function Description
1250 *
1251 */
g_rc_bus_ripper_rotation(SCM mode)1252 SCM g_rc_bus_ripper_rotation(SCM mode)
1253 {
1254 static const vstbl_entry mode_table[] = {
1255 {SYMMETRIC, "symmetric" },
1256 {NON_SYMMETRIC, "non-symmetric" }
1257 };
1258
1259 RETURN_G_RC_MODE("bus-ripper-rotation",
1260 default_bus_ripper_rotation,
1261 2);
1262 }
1263
1264 /*! \todo Finish function documentation!!!
1265 * \brief
1266 * \par Function Description
1267 *
1268 */
g_rc_force_boundingbox(SCM mode)1269 SCM g_rc_force_boundingbox(SCM mode)
1270 {
1271 static const vstbl_entry mode_table[] = {
1272 {TRUE, "enabled" },
1273 {FALSE, "disabled" }
1274 };
1275
1276 RETURN_G_RC_MODE("force-boundingbox",
1277 default_force_boundingbox,
1278 2);
1279 }
1280
1281 /*! \todo Finish function documentation!!!
1282 * \brief
1283 * \par Function Description
1284 *
1285 */
g_rc_dots_grid_dot_size(SCM dotsize)1286 SCM g_rc_dots_grid_dot_size (SCM dotsize)
1287 {
1288 int val;
1289
1290 SCM_ASSERT (scm_is_integer (dotsize), dotsize, SCM_ARG1, "dots-grid-dot-size");
1291
1292 val = scm_to_int (dotsize);
1293
1294 if (val <= 0) {
1295 fprintf(stderr, _("Invalid dot size [%d] passed to dots-grid-dot-size\n"),
1296 val);
1297 val = 1; /* absolute default */
1298 }
1299
1300 default_dots_grid_dot_size = val;
1301
1302 return SCM_BOOL_T;
1303 }
1304
1305 /*! \todo Finish function documentation!!!
1306 * \brief
1307 * \par Function Description
1308 *
1309 */
g_rc_dots_grid_mode(SCM mode)1310 SCM g_rc_dots_grid_mode (SCM mode)
1311 {
1312 static const vstbl_entry mode_table[] = {
1313 {DOTS_GRID_VARIABLE_MODE, "variable" },
1314 {DOTS_GRID_FIXED_MODE, "fixed" }
1315 };
1316
1317 RETURN_G_RC_MODE ("dots-grid-mode",
1318 default_dots_grid_mode,
1319 2);
1320 }
1321
1322 /*! \todo Finish function documentation!!!
1323 * \brief
1324 * \par Function Description
1325 *
1326 */
g_rc_dots_grid_fixed_threshold(SCM spacing)1327 SCM g_rc_dots_grid_fixed_threshold (SCM spacing)
1328 {
1329 int val;
1330
1331 SCM_ASSERT (scm_is_integer (spacing), spacing, SCM_ARG1, "dots-grid-fixed-threshold");
1332
1333 val = scm_to_int (spacing);
1334
1335 if (val <= 0) {
1336 fprintf(stderr, _("Invalid pixel spacing [%d] passed to dots-grid-fixed-threshold\n"),
1337 val);
1338 val = 10; /* absolute default */
1339 }
1340
1341 default_dots_grid_fixed_threshold = val;
1342
1343 return SCM_BOOL_T;
1344 }
1345
1346
1347 /*! \todo Finish function documentation!!!
1348 * \brief
1349 * \par Function Description
1350 *
1351 */
g_rc_mesh_grid_display_threshold(SCM spacing)1352 SCM g_rc_mesh_grid_display_threshold (SCM spacing)
1353 {
1354 int val;
1355
1356 SCM_ASSERT (scm_is_integer (spacing), spacing, SCM_ARG1,
1357 "mesh-grid-display-threshold");
1358
1359 val = scm_to_int (spacing);
1360
1361 if (val <= 0) {
1362 fprintf (stderr, _("Invalid pixel spacing [%d] passed to "
1363 "mesh-grid-display-threshold\n"), val);
1364 val = 3; /* absolute default */
1365 }
1366
1367 default_mesh_grid_display_threshold = val;
1368
1369 return SCM_BOOL_T;
1370 }
1371
1372 /*! \todo Finish function documentation!!!
1373 * \brief
1374 * \par Function Description
1375 *
1376 */
g_rc_add_attribute_offset(SCM offset)1377 SCM g_rc_add_attribute_offset(SCM offset)
1378 {
1379 int val;
1380
1381 SCM_ASSERT (scm_is_integer (offset), offset,
1382 SCM_ARG1, "add-attribute-offset");
1383
1384 val = scm_to_int (offset);
1385
1386 if (val < 0) {
1387 fprintf(stderr, _("Invalid offset [%d] passed to add-attribute-offset\n"),
1388 val);
1389 val = 50; /* absolute default */
1390 }
1391
1392 default_add_attribute_offset = val;
1393
1394 return SCM_BOOL_T;
1395 }
1396
1397 /*! \todo Finish function documentation!!!
1398 * \brief
1399 * \par Function Description
1400 *
1401 */
g_rc_auto_save_interval(SCM seconds)1402 SCM g_rc_auto_save_interval(SCM seconds)
1403 {
1404 int val;
1405
1406 SCM_ASSERT (scm_is_integer (seconds), seconds, SCM_ARG1, "auto-save-interval");
1407
1408 val = scm_to_int (seconds);
1409
1410 if (val < 0) {
1411 fprintf(stderr, _("Invalid number of seconds [%d] passed to auto-save-interval\n"),
1412 val);
1413 val = 120; /* absolute default */
1414 }
1415
1416 default_auto_save_interval = val;
1417
1418 return SCM_BOOL_T;
1419 }
1420
1421 /*! \todo Finish function documentation!!!
1422 * \brief
1423 * \par Function Description
1424 *
1425 */
g_rc_mousepan_gain(SCM gain)1426 SCM g_rc_mousepan_gain(SCM gain)
1427 {
1428 int val;
1429
1430 SCM_ASSERT (scm_is_integer (gain), gain, SCM_ARG1, "mousepan-gain");
1431
1432 val = scm_to_int (gain);
1433
1434 if (val <= 0) {
1435 fprintf(stderr, _("Invalid gain [%d] passed to mousepan-gain\n"),
1436 val);
1437 val = 5; /* absolute default */
1438 }
1439
1440 default_mousepan_gain = val;
1441
1442 return SCM_BOOL_T;
1443 }
1444
1445 /*! \brief Scheme function for setting the step for keyboard pan.
1446 *
1447 * Default setting is 20.
1448 */
g_rc_keyboardpan_gain(SCM gain)1449 SCM g_rc_keyboardpan_gain(SCM gain)
1450 {
1451 int val;
1452
1453 SCM_ASSERT (scm_is_integer (gain), gain, SCM_ARG1, "keyboardpan-gain");
1454
1455 val = scm_to_int (gain);
1456
1457 if (val <= 0) {
1458 fprintf(stderr, _("Invalid gain [%d] passed to keyboardpan-gain\n"),
1459 val);
1460 val = 20; /* absolute default */
1461 }
1462
1463 default_keyboardpan_gain = val;
1464
1465 return SCM_BOOL_T;
1466 }
1467
1468 /*! \todo Finish function documentation!!!
1469 * \brief
1470 * \par Function Description
1471 *
1472 */
g_rc_print_command(SCM scm_command)1473 SCM g_rc_print_command(SCM scm_command)
1474 #define FUNC_NAME "print-command"
1475 {
1476 char *command;
1477
1478 SCM_ASSERT (scm_is_string (scm_command), scm_command,
1479 SCM_ARG1, FUNC_NAME);
1480
1481 command = scm_to_utf8_string (scm_command);
1482
1483 g_free (default_print_command);
1484 default_print_command = g_strdup (command);
1485 free (command);
1486
1487 return SCM_BOOL_T;
1488 }
1489 #undef FUNC_NAME
1490
1491 /*! \todo Finish function documentation!!!
1492 * \brief
1493 * \par Function Description
1494 *
1495 */
g_rc_select_slack_pixels(SCM pixels)1496 SCM g_rc_select_slack_pixels(SCM pixels)
1497 {
1498 int val;
1499
1500 SCM_ASSERT (scm_is_integer (pixels), pixels, SCM_ARG1, "select-slack-pixels");
1501
1502 val = scm_to_int (pixels);
1503
1504 if (val <= 0) {
1505 fprintf(stderr, _("Invalid number of pixels [%d] passed to select-slack-pixels\n"),
1506 val);
1507 val = 4; /* absolute default */
1508 }
1509
1510 default_select_slack_pixels = val;
1511
1512 return SCM_BOOL_T;
1513 }
1514
1515 /*! \todo Finish function documentation!!!
1516 * \brief
1517 * \par Function Description
1518 *
1519 */
g_rc_zoom_gain(SCM gain)1520 SCM g_rc_zoom_gain(SCM gain)
1521 {
1522 int val;
1523
1524 SCM_ASSERT (scm_is_integer (gain), gain, SCM_ARG1, "zoom-gain");
1525
1526 val = scm_to_int (gain);
1527
1528 /* Allow -ve numbers in case the user wishes to reverse zoom direction,
1529 * but don't allow zero gain as this would disable the zoom action */
1530 if (val == 0) {
1531 fprintf(stderr, _("Invalid gain [%d] passed to zoom-gain\n"), val);
1532 val = 20; /* absolute default */
1533 }
1534
1535 default_zoom_gain = val;
1536
1537 return SCM_BOOL_T;
1538 }
1539
1540 /*! \todo Finish function documentation!!!
1541 * \brief
1542 * \par Function Description
1543 *
1544 */
g_rc_scrollpan_steps(SCM steps)1545 SCM g_rc_scrollpan_steps(SCM steps)
1546 {
1547 int val;
1548
1549 SCM_ASSERT (scm_is_integer (steps), steps, SCM_ARG1, "scrollpan-steps");
1550
1551 val = scm_to_int (steps);
1552
1553 /* Allow -ve numbers in case the user wishes to reverse scroll direction,
1554 * but don't allow zero steps as this would cause a division by zero error */
1555 if (val == 0) {
1556 fprintf(stderr, _("Invalid number of steps [%d] scrollpan-steps\n"), val);
1557 val = 8; /* absolute default */
1558 }
1559
1560 default_scrollpan_steps = val;
1561
1562 return SCM_BOOL_T;
1563 }
1564
1565
1566 extern COLOR display_colors[MAX_COLORS];
1567 extern COLOR display_outline_colors[MAX_COLORS];
1568
g_rc_display_color_map(SCM scm_map)1569 SCM g_rc_display_color_map (SCM scm_map)
1570 {
1571 if (scm_map == SCM_UNDEFINED) {
1572 return s_color_map_to_scm (display_colors);
1573 }
1574
1575 SCM_ASSERT (scm_is_true (scm_list_p (scm_map)),
1576 scm_map, SCM_ARG1, "display-color-map");
1577
1578 s_color_map_from_scm (display_colors, scm_map, "display-color-map");
1579 return SCM_BOOL_T;
1580 }
1581
g_rc_display_outline_color_map(SCM scm_map)1582 SCM g_rc_display_outline_color_map (SCM scm_map)
1583 {
1584 if (scm_map == SCM_UNDEFINED) {
1585 return s_color_map_to_scm (display_outline_colors);
1586 }
1587
1588 SCM_ASSERT (scm_is_true (scm_list_p (scm_map)),
1589 scm_map, SCM_ARG1, "display-outline-color-map");
1590
1591 s_color_map_from_scm (display_outline_colors, scm_map, "display-outline-color-map");
1592 return SCM_BOOL_T;
1593 }
1594