1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2020 gEDA Contributors (see ChangeLog for details)
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.
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.
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
38 /*! \todo Finish function documentation!!!
40 * \par Function Description
43 void g_rc_parse_gtkrc()
47 filename
= g_build_filename (s_path_sys_config (), "gschem-gtkrc", NULL
);
48 gtk_rc_parse (filename
);
51 filename
= g_build_filename (s_path_user_config (), "gschem-gtkrc", NULL
);
52 gtk_rc_parse (filename
);
56 /*! \brief Verify the version of the RC file under evaluation.
57 * \par Function Description
59 * Implements the Scheme function "gschem-version". Tests the version
60 * string in the argument against the version of the application
63 * \param [in] scm_version Scheme object containing RC file version string
65 * \returns #t if the version of the RC file matches the application,
68 SCM
g_rc_gschem_version(SCM scm_version
)
72 SCM_ASSERT (scm_is_string (scm_version
), scm_version
,
73 SCM_ARG1
, "gschem-version");
75 scm_dynwind_begin (0);
76 version
= scm_to_utf8_string (scm_version
);
77 scm_dynwind_free (version
);
79 if (g_utf8_collate (g_utf8_casefold (version
,-1),
80 g_utf8_casefold (PACKAGE_DATE_VERSION
,-1)) != 0) {
85 rc_filename
= g_rc_rc_filename ();
86 if (scm_is_false (rc_filename
))
87 rc_filename
= scm_from_utf8_string (_("(filename can't be determined)"));
88 sourcefile
= scm_to_utf8_string (rc_filename
);
89 scm_dynwind_free (sourcefile
);
91 dialog
= gtk_message_dialog_new (
96 _("You are running gEDA/gaf version %s (%s%s),\n"
97 "but you have a gschemrc file for version %s:\n%s\n"
98 "Please be sure that you have the latest data files installed."),
100 PREPEND_VERSION_STRING
, PACKAGE_DOTTED_VERSION
,
101 version
, sourcefile
);
102 gtk_window_set_title (GTK_WINDOW (dialog
), _("gschem"));
103 gtk_dialog_run (GTK_DIALOG (dialog
));
104 gtk_widget_destroy (dialog
);
113 /*! \todo Finish function documentation!!!
115 * \par Function Description
118 SCM
g_rc_net_direction_mode(SCM mode
)
120 static const vstbl_entry mode_table
[] = {
125 RETURN_G_RC_MODE("net-direction-mode",
126 default_net_direction_mode
,
130 /*! \todo Finish function documentation!!!
132 * \par Function Description
135 SCM
g_rc_net_selection_mode(SCM mode
)
137 static const vstbl_entry mode_table
[] = {
143 RETURN_G_RC_MODE("net-selection-mode",
144 default_net_selection_mode
,
148 /*! \todo Finish function documentation!!!
150 * \par Function Description
153 SCM
g_rc_action_feedback_mode(SCM mode
)
155 static const vstbl_entry mode_table
[] = {
156 {OUTLINE
, "outline" },
157 {BOUNDINGBOX
, "boundingbox"}
160 RETURN_G_RC_MODE("action-feedback-mode",
161 default_actionfeedback_mode
,
165 /*! \todo Finish function documentation!!!
167 * \par Function Description
170 SCM
g_rc_zoom_with_pan(SCM mode
)
172 static const vstbl_entry mode_table
[] = {
177 RETURN_G_RC_MODE("zoom-with-pan",
178 default_zoom_with_pan
,
182 /*! \todo Finish function documentation!!!
184 * \par Function Description
187 SCM
g_rc_logging(SCM mode
)
189 static const vstbl_entry mode_table
[] = {
194 RETURN_G_RC_MODE("logging",
199 /*! \todo Finish function documentation!!!
201 * \par Function Description
204 SCM
g_rc_embed_components(SCM mode
)
206 static const vstbl_entry mode_table
[] = {
211 RETURN_G_RC_MODE("embed-components",
212 default_embed_complex
,
216 /*! \todo Finish function documentation!!!
218 * \par Function Description
221 SCM
g_rc_text_size(SCM size
)
225 SCM_ASSERT (scm_is_integer (size
), size
, SCM_ARG1
, "text-size");
227 val
= scm_to_int (size
);
230 _("Invalid size [%d] passed to text-size\n"),
232 val
= 10; /* absolute default */
235 default_text_size
= val
;
240 /*! \todo Finish function documentation!!!
242 * \par Function Description
244 * \todo inconsistant naming with keyword name and variable to hold
247 SCM
g_rc_text_caps_style(SCM mode
)
249 static const vstbl_entry mode_table
[] = {
255 RETURN_G_RC_MODE("text-caps-style",
260 /*! \todo Finish function documentation!!!
262 * \par Function Description
265 SCM
g_rc_snap_size(SCM size
)
269 SCM_ASSERT (scm_is_integer (size
), size
, SCM_ARG1
, "snap-size");
271 val
= scm_to_int (size
);
273 fprintf(stderr
, _("Invalid size [%d] passed to snap-size\n"),
275 val
= 100; /* absolute default */
278 default_snap_size
= val
;
283 /*! \todo Finish function documentation!!!
285 * \par Function Description
288 SCM
g_rc_logging_destination(SCM mode
)
290 static const vstbl_entry mode_table
[] = {
291 {LOG_WINDOW
, "log_window" },
292 {STDOUT_TTY
, "tty" },
293 {BOTH_LOGWIN_STDOUT
, "both" }
296 RETURN_G_RC_MODE("logging-destination",
301 /*! \todo Finish function documentation!!!
303 * \par Function Description
306 SCM
g_rc_attribute_name(SCM scm_path
)
311 SCM_ASSERT (scm_is_string (scm_path
), scm_path
,
312 SCM_ARG1
, "attribute-name");
314 path
= scm_to_utf8_string (scm_path
);
317 if (!s_attrib_uniq(path
)) {
320 s_attrib_add_entry (path
);
328 /*! \todo Finish function documentation!!!
330 * \par Function Description
333 SCM
g_rc_scrollbars(SCM mode
)
335 static const vstbl_entry mode_table
[] = {
340 RETURN_G_RC_MODE("scrollbars",
341 default_scrollbars_flag
,
345 /*! \todo Finish function documentation!!!
347 * \par Function Description
350 SCM
g_rc_image_color(SCM mode
)
352 static const vstbl_entry mode_table
[] = {
357 RETURN_G_RC_MODE("image-color",
362 /*! \todo Finish function documentation!!!
364 * \par Function Description
367 SCM
g_rc_image_size(SCM width
, SCM height
)
369 SCM_ASSERT (scm_is_integer (width
), width
, SCM_ARG1
, "image-size");
370 SCM_ASSERT (scm_is_integer (height
), height
, SCM_ARG2
, "image-size");
372 /* yes this is legit, we are casting the resulting double to an int */
373 default_image_width
= scm_to_int (width
);
374 default_image_height
= scm_to_int (height
);
379 /*! \todo Finish function documentation!!!
381 * \par Function Description
384 SCM
g_rc_log_window(SCM mode
)
386 static const vstbl_entry mode_table
[] = {
387 {MAP_ON_STARTUP
, "startup" },
388 {MAP_LATER
, "later" },
391 RETURN_G_RC_MODE("log-window",
396 /*! \todo Finish function documentation!!!
398 * \par Function Description
401 SCM
g_rc_log_window_type(SCM mode
)
403 static const vstbl_entry mode_table
[] = {
404 {TRANSIENT
, "transient" },
405 {DECORATED
, "decorated" },
408 RETURN_G_RC_MODE("log-window-type",
409 default_log_window_type
,
413 /*! \todo Finish function documentation!!!
415 * \par Function Description
418 SCM
g_rc_third_button(SCM mode
)
420 static const vstbl_entry mode_table
[] = {
421 {POPUP_ENABLED
, "popup" },
422 {MOUSEPAN_ENABLED
, "mousepan"},
425 RETURN_G_RC_MODE("third-button",
426 default_third_button
,
430 /*! \brief Verify if the third button cancel mode is set in the RC
431 * file under evaluation.
432 * \par Function Description
434 * Implements the Scheme function "third-button-cancel". Tests
435 * the mode string in the argument against the third button
436 * cancel mode of the application itself.
438 * \param [in] mode Scheme object containing the third button
441 * \returns #t if the third button cancel mode specified in the
442 * RC file matches the application, else #f.
444 SCM
g_rc_third_button_cancel(SCM mode
)
446 static const vstbl_entry mode_table
[] = {
451 RETURN_G_RC_MODE("third-button-cancel",
452 default_third_button_cancel
,
456 /*! \todo Finish function documentation!!!
458 * \par Function Description
461 SCM
g_rc_middle_button(SCM mode
)
463 static const vstbl_entry mode_table
[] = {
467 {MID_MOUSEPAN_ENABLED
, "mousepan"},
470 RETURN_G_RC_MODE("middle-button",
471 default_middle_button
,
475 /*! \todo Finish function documentation!!!
477 * \par Function Description
480 SCM
g_rc_scroll_wheel(SCM mode
)
482 static const vstbl_entry mode_table
[] = {
483 {SCROLL_WHEEL_CLASSIC
, "classic"},
484 {SCROLL_WHEEL_GTK
, "gtk"},
487 RETURN_G_RC_MODE("scroll-wheel",
488 default_scroll_wheel
,
492 /*! \todo Finish function documentation!!!
494 * \par Function Description
497 SCM
g_rc_net_consolidate(SCM mode
)
499 static const vstbl_entry mode_table
[] = {
504 RETURN_G_RC_MODE("net-consolidate",
505 default_net_consolidate
,
509 /*! \todo Finish function documentation!!!
511 * \par Function Description
514 SCM
g_rc_file_preview(SCM mode
)
516 static const vstbl_entry mode_table
[] = {
521 /* this variable is inconsistantly named with the rest */
522 RETURN_G_RC_MODE("file-preview",
523 default_file_preview
,
527 /*! \todo Finish function documentation!!!
529 * \par Function Description
532 SCM
g_rc_enforce_hierarchy(SCM mode
)
534 static const vstbl_entry mode_table
[] = {
539 RETURN_G_RC_MODE("enforce-hierarchy",
540 default_enforce_hierarchy
,
544 /*! \todo Finish function documentation!!!
546 * \par Function Description
549 SCM
g_rc_fast_mousepan(SCM mode
)
551 static const vstbl_entry mode_table
[] = {
556 RETURN_G_RC_MODE("fast-mousepan",
557 default_fast_mousepan
,
561 /*! \todo Finish function documentation!!!
563 * \par Function Description
566 SCM
g_rc_raise_dialog_boxes_on_expose(SCM mode
)
568 static const vstbl_entry mode_table
[] = {
573 RETURN_G_RC_MODE("raise-dialog-boxes-on-expose",
574 default_raise_dialog_boxes
,
578 /*! \todo Finish function documentation!!!
580 * \par Function Description
583 SCM
g_rc_continue_component_place(SCM mode
)
585 static const vstbl_entry mode_table
[] = {
590 RETURN_G_RC_MODE("continue-component-place",
591 default_continue_component_place
,
595 /*! \todo Finish function documentation!!!
597 * \par Function Description
600 SCM
g_rc_undo_levels(SCM levels
)
604 SCM_ASSERT (scm_is_integer (levels
), levels
, SCM_ARG1
, "undo-levels");
606 val
= scm_to_int (levels
);
609 fprintf(stderr
, _("Invalid num levels [%d] passed to undo-levels\n"),
611 val
= 10; /* absolute default */
614 default_undo_levels
= val
;
619 /*! \todo Finish function documentation!!!
621 * \par Function Description
624 SCM
g_rc_undo_control(SCM mode
)
626 static const vstbl_entry mode_table
[] = {
631 RETURN_G_RC_MODE("undo-control", default_undo_control
, 2);
634 /*! \todo Finish function documentation!!!
636 * \par Function Description
639 SCM
g_rc_undo_type(SCM mode
)
641 static const vstbl_entry mode_table
[] = {
642 {UNDO_DISK
, "disk" },
643 {UNDO_MEMORY
, "memory" },
646 RETURN_G_RC_MODE("undo-type",
651 /*! \todo Finish function documentation!!!
653 * \par Function Description
656 SCM
g_rc_undo_panzoom(SCM mode
)
658 static const vstbl_entry mode_table
[] = {
663 RETURN_G_RC_MODE("undo-panzoom", default_undo_panzoom
, 2);
666 /*! \todo Finish function documentation!!!
668 * \par Function Description
671 SCM
g_rc_draw_grips(SCM mode
)
673 static const vstbl_entry mode_table
[] = {
678 RETURN_G_RC_MODE("draw-grips",
683 /*! \todo Finish function documentation!!!
685 * \par Function Description
688 SCM
g_rc_netconn_rubberband(SCM mode
)
690 static const vstbl_entry mode_table
[] = {
695 RETURN_G_RC_MODE("netconn-rubberband",
696 default_netconn_rubberband
,
701 /*! \todo Finish function documentation!!!
703 * \par Function Description
706 SCM
g_rc_magnetic_net_mode(SCM mode
)
708 static const vstbl_entry mode_table
[] = {
713 RETURN_G_RC_MODE("magnetic-net-mode",
714 default_magnetic_net_mode
,
718 /*! \todo Finish function documentation!!!
720 * \par Function Description
723 SCM
g_rc_window_size(SCM width
, SCM height
)
725 SCM_ASSERT (scm_is_integer (width
), width
, SCM_ARG1
, "window-size");
726 SCM_ASSERT (scm_is_integer (height
), height
, SCM_ARG2
, "window-size");
728 /* no effect--window geometry is now saved/restored automatically */
730 (void) scm_to_int (width
);
731 (void) scm_to_int (height
);
736 /*! \todo Finish function documentation!!!
738 * \par Function Description
741 SCM
g_rc_warp_cursor(SCM mode
)
743 static const vstbl_entry mode_table
[] = {
748 RETURN_G_RC_MODE("warp-cursor",
753 /*! \todo Finish function documentation!!!
755 * \par Function Description
758 SCM
g_rc_toolbars(SCM mode
)
760 static const vstbl_entry mode_table
[] = {
765 RETURN_G_RC_MODE("toolbars",
770 /*! \todo Finish function documentation!!!
772 * \par Function Description
775 SCM
g_rc_handleboxes(SCM mode
)
777 static const vstbl_entry mode_table
[] = {
782 RETURN_G_RC_MODE("handleboxes",
787 /*! \todo Finish function documentation!!!
789 * \par Function Description
792 SCM
g_rc_bus_ripper_size(SCM size
)
796 SCM_ASSERT (scm_is_integer (size
), size
, SCM_ARG1
, "bus-ripper-size");
798 val
= scm_to_int (size
);
801 fprintf(stderr
, _("Invalid size [%d] passed to bus-ripper-size\n"),
803 val
= 200; /* absolute default */
806 default_bus_ripper_size
= val
;
811 /*! \todo Finish function documentation!!!
813 * \par Function Description
816 SCM
g_rc_bus_ripper_type(SCM mode
)
818 static const vstbl_entry mode_table
[] = {
819 {COMP_BUS_RIPPER
, "component" },
820 {NET_BUS_RIPPER
, "net" }
823 RETURN_G_RC_MODE("bus-ripper-type",
824 default_bus_ripper_type
,
828 /*! \todo Finish function documentation!!!
830 * \par Function Description
833 SCM
g_rc_bus_ripper_rotation(SCM mode
)
835 /* obsolete option, keep for compatibility reasons */
839 /*! \todo Finish function documentation!!!
841 * \par Function Description
844 SCM
g_rc_force_boundingbox(SCM mode
)
846 static const vstbl_entry mode_table
[] = {
851 RETURN_G_RC_MODE("force-boundingbox",
852 default_force_boundingbox
,
856 /*! \brief Verify the grid mode set in the RC file under evaluation.
857 * \par Function Description
859 * Implements the Scheme function "grid-mode". Tests the grid mode
860 * string in the argument against the grid mode of the application
863 * \param [in] mode Scheme object containing the grid mode string
865 * \returns #t if the grid mode specified in the RC file matches the
866 * application, else #f.
868 SCM
g_rc_grid_mode (SCM mode
)
870 static const vstbl_entry mode_table
[] = {
871 {GRID_MODE_NONE
, "none" },
872 {GRID_MODE_DOTS
, "dots" },
873 {GRID_MODE_MESH
, "mesh" }
876 RETURN_G_RC_MODE ("grid-mode",
881 /*! \todo Finish function documentation!!!
883 * \par Function Description
886 SCM
g_rc_dots_grid_dot_size (SCM dotsize
)
890 SCM_ASSERT (scm_is_integer (dotsize
), dotsize
, SCM_ARG1
, "dots-grid-dot-size");
892 val
= scm_to_int (dotsize
);
895 fprintf(stderr
, _("Invalid dot size [%d] passed to dots-grid-dot-size\n"),
897 val
= 1; /* absolute default */
900 default_dots_grid_dot_size
= val
;
905 /*! \todo Finish function documentation!!!
907 * \par Function Description
910 SCM
g_rc_dots_grid_mode (SCM mode
)
912 static const vstbl_entry mode_table
[] = {
913 {DOTS_GRID_VARIABLE_MODE
, "variable" },
914 {DOTS_GRID_FIXED_MODE
, "fixed" }
917 RETURN_G_RC_MODE ("dots-grid-mode",
918 default_dots_grid_mode
,
922 /*! \todo Finish function documentation!!!
924 * \par Function Description
927 SCM
g_rc_dots_grid_fixed_threshold (SCM spacing
)
931 SCM_ASSERT (scm_is_integer (spacing
), spacing
, SCM_ARG1
, "dots-grid-fixed-threshold");
933 val
= scm_to_int (spacing
);
936 fprintf(stderr
, _("Invalid pixel spacing [%d] passed to dots-grid-fixed-threshold\n"),
938 val
= 10; /* absolute default */
941 default_dots_grid_fixed_threshold
= val
;
947 /*! \todo Finish function documentation!!!
949 * \par Function Description
952 SCM
g_rc_mesh_grid_display_threshold (SCM spacing
)
956 SCM_ASSERT (scm_is_integer (spacing
), spacing
, SCM_ARG1
,
957 "mesh-grid-display-threshold");
959 val
= scm_to_int (spacing
);
962 fprintf (stderr
, _("Invalid pixel spacing [%d] passed to "
963 "mesh-grid-display-threshold\n"), val
);
964 val
= 3; /* absolute default */
967 default_mesh_grid_display_threshold
= val
;
972 /*! \todo Finish function documentation!!!
974 * \par Function Description
977 SCM
g_rc_add_attribute_offset(SCM offset
)
981 SCM_ASSERT (scm_is_integer (offset
), offset
,
982 SCM_ARG1
, "add-attribute-offset");
984 val
= scm_to_int (offset
);
987 fprintf(stderr
, _("Invalid offset [%d] passed to add-attribute-offset\n"),
989 val
= 50; /* absolute default */
992 default_add_attribute_offset
= val
;
997 /*! \todo Finish function documentation!!!
999 * \par Function Description
1002 SCM
g_rc_auto_save_interval(SCM seconds
)
1006 SCM_ASSERT (scm_is_integer (seconds
), seconds
, SCM_ARG1
, "auto-save-interval");
1008 val
= scm_to_int (seconds
);
1011 fprintf(stderr
, _("Invalid number of seconds [%d] passed to auto-save-interval\n"),
1013 val
= 120; /* absolute default */
1016 default_auto_save_interval
= val
;
1021 /*! \todo Finish function documentation!!!
1023 * \par Function Description
1026 SCM
g_rc_mousepan_gain(SCM gain
)
1030 SCM_ASSERT (scm_is_integer (gain
), gain
, SCM_ARG1
, "mousepan-gain");
1032 val
= scm_to_int (gain
);
1035 fprintf(stderr
, _("Invalid gain [%d] passed to mousepan-gain\n"),
1037 val
= 5; /* absolute default */
1040 default_mousepan_gain
= val
;
1045 /*! \brief Scheme function for setting the step for keyboard pan.
1047 * Default setting is 20.
1049 SCM
g_rc_keyboardpan_gain(SCM gain
)
1053 SCM_ASSERT (scm_is_integer (gain
), gain
, SCM_ARG1
, "keyboardpan-gain");
1055 val
= scm_to_int (gain
);
1058 fprintf(stderr
, _("Invalid gain [%d] passed to keyboardpan-gain\n"),
1060 val
= 20; /* absolute default */
1063 default_keyboardpan_gain
= val
;
1068 /*! \todo Finish function documentation!!!
1070 * \par Function Description
1073 SCM
g_rc_select_slack_pixels(SCM pixels
)
1077 SCM_ASSERT (scm_is_integer (pixels
), pixels
, SCM_ARG1
, "select-slack-pixels");
1079 val
= scm_to_int (pixels
);
1082 fprintf(stderr
, _("Invalid number of pixels [%d] passed to select-slack-pixels\n"),
1084 val
= 4; /* absolute default */
1087 default_select_slack_pixels
= val
;
1092 /*! \todo Finish function documentation!!!
1094 * \par Function Description
1097 SCM
g_rc_zoom_gain(SCM gain
)
1101 SCM_ASSERT (scm_is_integer (gain
), gain
, SCM_ARG1
, "zoom-gain");
1103 val
= scm_to_int (gain
);
1105 /* Allow -ve numbers in case the user wishes to reverse zoom direction,
1106 * but don't allow zero gain as this would disable the zoom action */
1108 fprintf(stderr
, _("Invalid gain [%d] passed to zoom-gain\n"), val
);
1109 val
= 20; /* absolute default */
1112 default_zoom_gain
= val
;
1117 /*! \todo Finish function documentation!!!
1119 * \par Function Description
1122 SCM
g_rc_scrollpan_steps(SCM steps
)
1126 SCM_ASSERT (scm_is_integer (steps
), steps
, SCM_ARG1
, "scrollpan-steps");
1128 val
= scm_to_int (steps
);
1130 /* Allow -ve numbers in case the user wishes to reverse scroll direction,
1131 * but don't allow zero steps as this would cause a division by zero error */
1133 fprintf(stderr
, _("Invalid number of steps [%d] scrollpan-steps\n"), val
);
1134 val
= 8; /* absolute default */
1137 default_scrollpan_steps
= val
;
1143 extern COLOR display_colors
[MAX_COLORS
];
1144 extern COLOR display_outline_colors
[MAX_COLORS
];
1146 SCM
g_rc_display_color_map (SCM scm_map
)
1148 if (SCM_UNBNDP (scm_map
)) {
1149 return s_color_map_to_scm (display_colors
);
1152 SCM_ASSERT (scm_is_true (scm_list_p (scm_map
)),
1153 scm_map
, SCM_ARG1
, "display-color-map");
1155 s_color_map_from_scm (display_colors
, scm_map
, "display-color-map");
1159 SCM
g_rc_display_outline_color_map (SCM scm_map
)
1161 if (SCM_UNBNDP (scm_map
)) {
1162 return s_color_map_to_scm (display_outline_colors
);
1165 SCM_ASSERT (scm_is_true (scm_list_p (scm_map
)),
1166 scm_map
, SCM_ARG1
, "display-outline-color-map");
1168 s_color_map_from_scm (display_outline_colors
, scm_map
, "display-outline-color-map");