gschem

g_rc.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * gschem - gEDA Schematic Capture
00003  * Copyright (C) 1998-2010 Ales Hvezda
00004  * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 #include <config.h>
00021 #include <missing.h>
00022 #include <version.h>
00023 
00024 #include <stdio.h>
00025 #include <sys/stat.h>
00026 #include <ctype.h>
00027 #ifdef HAVE_STRING_H
00028 #include <string.h>
00029 #endif
00030 #ifdef HAVE_STDLIB_H
00031 #include <stdlib.h>
00032 #endif
00033 #ifdef HAVE_UNISTD_H
00034 #include <unistd.h>
00035 #endif
00036 
00037 #include "gschem.h"
00038 
00039 #ifdef HAVE_LIBDMALLOC
00040 #include <dmalloc.h>
00041 #endif
00042 
00048 void g_rc_parse_gtkrc()
00049 {
00050   gchar *filename;
00051 
00052   filename = g_build_filename (s_path_sys_config (), "gschem-gtkrc", NULL);
00053   gtk_rc_parse (filename);
00054   g_free (filename);
00055 
00056   filename = g_build_filename (s_path_user_config (), "gschem-gtkrc", NULL);
00057   gtk_rc_parse (filename);
00058   g_free (filename);
00059 }
00060 
00073 SCM g_rc_gschem_version(SCM scm_version)
00074 {
00075   SCM ret;
00076   char *version;
00077   SCM rc_filename;
00078   char *sourcefile;
00079   
00080   SCM_ASSERT (scm_is_string (scm_version), scm_version,
00081               SCM_ARG1, "gschem-version");
00082 
00083   scm_dynwind_begin (0);
00084   version = scm_to_utf8_string (scm_version);
00085   scm_dynwind_free (version);
00086 
00087   if (g_utf8_collate (g_utf8_casefold (version,-1),
00088               g_utf8_casefold (PACKAGE_DATE_VERSION,-1)) != 0) {
00089     sourcefile = NULL;
00090     rc_filename = g_rc_rc_filename ();
00091     sourcefile = scm_to_utf8_string (rc_filename);
00092     scm_dynwind_free (sourcefile);
00093     fprintf(stderr,
00094             "You are running gEDA/gaf version [%s%s.%s],\n",
00095             PREPEND_VERSION_STRING, PACKAGE_DOTTED_VERSION,
00096             PACKAGE_DATE_VERSION);
00097     fprintf(stderr,
00098             "but you have a version [%s] gschemrc file:\n[%s]\n",
00099             version, sourcefile);
00100     fprintf(stderr,
00101             "Please be sure that you have the latest rc file.\n");
00102     ret = SCM_BOOL_F;
00103   } else {
00104     ret = SCM_BOOL_T;
00105   }
00106   scm_dynwind_end();
00107   return ret;
00108 }
00109 
00110 
00116 SCM g_rc_net_endpoint_mode(SCM mode)
00117 {
00118   static const vstbl_entry mode_table[] = {
00119     {FILLEDBOX, "filledbox"}
00120   };
00121 
00122   RETURN_G_RC_MODE("net-endpoint-mode",
00123            default_net_endpoint_mode,
00124            1);
00125 }
00126 
00132 SCM g_rc_net_midpoint_mode(SCM mode)
00133 {
00134   static const vstbl_entry mode_table[] = {
00135     {FILLED, "filled"}
00136   };
00137 
00138   RETURN_G_RC_MODE("net-midpoint-mode",
00139            default_net_midpoint_mode,
00140            1);
00141 }
00142 
00148 SCM g_rc_net_direction_mode(SCM mode)
00149 {
00150   static const vstbl_entry mode_table[] = {
00151     {TRUE , "enabled" },
00152     {FALSE, "disabled"}
00153   };
00154 
00155   RETURN_G_RC_MODE("net-direction-mode",
00156            default_net_direction_mode,
00157            2);
00158 }
00159 
00165 SCM g_rc_net_selection_mode(SCM mode)
00166 {
00167   static const vstbl_entry mode_table[] = {
00168     {0, "disabled"},
00169     {2, "enabled_net"},
00170     {3, "enabled_all"}
00171   };
00172 
00173   RETURN_G_RC_MODE("net-selection-mode",
00174            default_net_selection_mode,
00175            3);
00176 }
00177 
00183 SCM g_rc_net_style(SCM mode)
00184 {
00185   static const vstbl_entry mode_table[] = {
00186     {THIN , "thin" },
00187     {THICK, "thick"}
00188   };
00189 
00190   RETURN_G_RC_MODE("net-style",
00191            default_net_style,
00192            2);
00193 }
00194 
00200 SCM g_rc_bus_style(SCM mode)
00201 {
00202   static const vstbl_entry mode_table[] = {
00203     {THIN , "thin" },
00204     {THICK, "thick"}
00205   };
00206 
00207   RETURN_G_RC_MODE("bus-style",
00208            default_bus_style,
00209            2);
00210 }
00211 
00217 SCM g_rc_pin_style(SCM mode)
00218 {
00219   static const vstbl_entry mode_table[] = {
00220     {THIN , "thin" },
00221     {THICK, "thick"}
00222   };
00223 
00224   RETURN_G_RC_MODE("pin-style",
00225            default_pin_style,
00226            2);
00227 }
00228 
00234 SCM g_rc_line_style(SCM mode)
00235 {
00236   static const vstbl_entry mode_table[] = {
00237     {THIN , "thin" },
00238     {THICK, "thick"}
00239   };
00240 
00241   RETURN_G_RC_MODE("line-style",
00242            default_line_style,
00243            2);
00244 }
00245 
00251 SCM g_rc_action_feedback_mode(SCM mode)
00252 {
00253   static const vstbl_entry mode_table[] = {
00254     {OUTLINE    , "outline"   },
00255     {BOUNDINGBOX, "boundingbox"}
00256   };
00257 
00258   RETURN_G_RC_MODE("action-feedback-mode",
00259            default_actionfeedback_mode,
00260            2);
00261 }
00262 
00268 SCM g_rc_zoom_with_pan(SCM mode)
00269 {
00270   static const vstbl_entry mode_table[] = {
00271     {TRUE,  "enabled" },
00272     {FALSE, "disabled"}
00273   };
00274 
00275   RETURN_G_RC_MODE("zoom-with-pan",
00276            default_zoom_with_pan,
00277            2);
00278 }
00279 
00285 SCM g_rc_text_feedback(SCM mode)
00286 {
00287   static const vstbl_entry mode_table[] = {
00288     {ALWAYS            , "always"            },
00289     {ONLY_WHEN_READABLE, "only-when-readable"}
00290   };
00291 
00292   RETURN_G_RC_MODE("text-feedback",
00293            default_text_feedback,
00294            2);
00295 }
00296 
00302 SCM g_rc_text_display_zoomfactor(SCM zoomfactor)
00303 {
00304   int val;
00305   
00306   SCM_ASSERT (scm_is_integer (zoomfactor), zoomfactor,
00307               SCM_ARG1, "test-display-zoom-factor");
00308 
00309   val = scm_to_int (zoomfactor);
00310   if (val == 0) {
00311     fprintf(stderr,
00312             _("Invalid zoomfactor [%d] passed to %s\n"),
00313             val,
00314             "text-display-zoom-factor");
00315     val = 10; /* absolute default */
00316   }
00317 
00318   default_text_display_zoomfactor = val;
00319 
00320   return SCM_BOOL_T;
00321 }
00322 
00328 SCM g_rc_scrollbar_update(SCM scmmode)
00329 {
00330   SCM ret = SCM_BOOL_T;
00331 
00332   SCM_ASSERT (scm_is_string (scmmode), scmmode,
00333               SCM_ARG1, "scrollbar-update");
00334   
00335   return ret;
00336 }
00337 
00343 SCM g_rc_object_clipping(SCM mode)
00344 {
00345   static const vstbl_entry mode_table[] = {
00346     {TRUE , "enabled" },
00347     {FALSE, "disabled"}
00348   };
00349 
00350   RETURN_G_RC_MODE("object-clipping",
00351            default_object_clipping,
00352            2);
00353 }
00354 
00360 SCM g_rc_logging(SCM mode)
00361 {
00362   static const vstbl_entry mode_table[] = {
00363     {TRUE , "enabled" },
00364     {FALSE, "disabled"}
00365   };
00366 
00367   RETURN_G_RC_MODE("logging",
00368            default_do_logging,
00369            2);
00370 }
00371 
00377 SCM g_rc_embed_components(SCM mode)
00378 {
00379   static const vstbl_entry mode_table[] = {
00380     {TRUE , "enabled" },
00381     {FALSE, "disabled"}
00382   };
00383 
00384   RETURN_G_RC_MODE("embed-components",
00385            default_embed_complex,
00386            2);
00387 }
00388 
00389 static void
00390 free_string_glist(void *data)
00391 {
00392   GList *iter, *glst = *((GList **) data);
00393 
00394   for (iter = glst; iter != NULL; iter = g_list_next (iter)) {
00395     g_free (iter->data);
00396   }
00397   g_list_free (glst);
00398 }
00399 
00406 SCM g_rc_component_dialog_attributes(SCM stringlist)
00407 {
00408   int length, i;
00409   GList *list=NULL;
00410   gchar *attr;
00411 
00412   SCM_ASSERT(scm_list_p(stringlist), stringlist, SCM_ARG1, "scm_is_list failed");
00413   length = scm_ilength(stringlist);
00414 
00415   /* If the command is called multiple times, remove the old list before
00416      recreating it */
00417   g_list_foreach(default_component_select_attrlist, (GFunc)g_free, NULL);
00418   g_list_free(default_component_select_attrlist);
00419 
00420   scm_dynwind_begin(0);
00421   scm_dynwind_unwind_handler(free_string_glist, (void *) &list, 0);
00422 
00423   /* convert the scm list into a GList */
00424   for (i=0; i < length; i++) {
00425     char *str;
00426     SCM elem = scm_list_ref(stringlist, scm_from_int(i));
00427 
00428     SCM_ASSERT(scm_is_string(elem), elem, SCM_ARG1, "list element is not a string");
00429 
00430     str = scm_to_utf8_string(elem);
00431     attr = g_strdup(str);
00432     free(str);
00433     list = g_list_prepend(list, attr);
00434   }
00435 
00436   scm_dynwind_end();
00437 
00438   default_component_select_attrlist = g_list_reverse(list);
00439 
00440   return SCM_BOOL_T;
00441 }
00442 
00443 
00449 SCM g_rc_text_size(SCM size)
00450 {
00451   int val;
00452 
00453   SCM_ASSERT (scm_is_integer (size), size, SCM_ARG1, "text-size");
00454   
00455   val = scm_to_int (size);
00456   if (val == 0) {
00457     fprintf(stderr,
00458             _("Invalid size [%d] passed to text-size\n"),
00459             val);
00460     val = 10; /* absolute default */
00461   }
00462 
00463   default_text_size = val;
00464 
00465   return SCM_BOOL_T;
00466 }
00467 
00475 SCM g_rc_text_caps_style(SCM mode)
00476 {
00477   static const vstbl_entry mode_table[] = {
00478     {LOWER, "lower" },
00479     {UPPER, "upper" },
00480     {BOTH , "both"  }
00481   };
00482 
00483   RETURN_G_RC_MODE("text-caps-style",
00484            default_text_caps,
00485            3);
00486 }
00487 
00493 SCM g_rc_snap_size(SCM size)
00494 {
00495   int val;
00496 
00497   SCM_ASSERT (scm_is_integer (size), size, SCM_ARG1, "snap-size");
00498 
00499   val = scm_to_int (size);
00500   if (val == 0) {
00501     fprintf(stderr, _("Invalid size [%d] passed to snap-size\n"),
00502             val);
00503     val = 100; /* absolute default */
00504   }
00505 
00506   default_snap_size = val;
00507 
00508   return SCM_BOOL_T;
00509 }
00510 
00516 SCM g_rc_logging_destination(SCM mode)
00517 {
00518   static const vstbl_entry mode_table[] = {
00519     {LOG_WINDOW         , "log_window" },
00520     {STDOUT_TTY         , "tty"        },
00521     {BOTH_LOGWIN_STDOUT , "both"       }
00522   };
00523 
00524   RETURN_G_RC_MODE("logging-destination",
00525            logging_dest,
00526            3);
00527 }
00528 
00534 SCM g_rc_attribute_name(SCM scm_path)
00535 {
00536   char *path;
00537   SCM ret;
00538 
00539   SCM_ASSERT (scm_is_string (scm_path), scm_path,
00540               SCM_ARG1, "attribute-name");
00541 
00542   path = scm_to_utf8_string (scm_path);
00543 
00544   /* not unique? */
00545   if (!s_attrib_uniq(path)) {
00546     ret = SCM_BOOL_F;
00547   } else {
00548     s_attrib_add_entry (path);
00549     ret = SCM_BOOL_T;
00550   }
00551 
00552   free(path);
00553   return ret;
00554 }
00555 
00561 SCM g_rc_scrollbars(SCM mode)
00562 {
00563   static const vstbl_entry mode_table[] = {
00564     {TRUE , "enabled" },
00565     {FALSE, "disabled"},
00566   };
00567 
00568   RETURN_G_RC_MODE("scrollbars",
00569            default_scrollbars_flag,
00570            2);
00571 }
00572 
00578 SCM g_rc_paper_size(SCM width, SCM height)
00579 #define FUNC_NAME "paper-size"
00580 {
00581   SCM_ASSERT (SCM_NIMP (width) && SCM_REALP (width), width,
00582               SCM_ARG1, FUNC_NAME);
00583   SCM_ASSERT (SCM_NIMP (height) && SCM_REALP (height), height,
00584               SCM_ARG2, FUNC_NAME);
00585   
00586   /* yes this is legit, we are casting the resulting double to an int */
00587   default_paper_width  = (int) (scm_to_double (width)  * MILS_PER_INCH);
00588   default_paper_height = (int) (scm_to_double (height) * MILS_PER_INCH);
00589 
00590   return SCM_BOOL_T;
00591 }
00592 #undef FUNC_NAME
00593 
00599 SCM g_rc_paper_sizes(SCM scm_papername, SCM scm_width, SCM scm_height)
00600 #define FUNC_NAME "paper-sizes"
00601 {
00602   int width;
00603   int height;
00604   char *papername;
00605   SCM ret;
00606 
00607   SCM_ASSERT (scm_is_string (scm_papername), scm_papername,
00608               SCM_ARG1, FUNC_NAME);
00609   SCM_ASSERT (SCM_NIMP (scm_width) && SCM_REALP (scm_width), scm_width,
00610               SCM_ARG2, FUNC_NAME);
00611   SCM_ASSERT (SCM_NIMP (scm_height) && SCM_REALP (scm_height), scm_height,
00612               SCM_ARG3, FUNC_NAME);
00613 
00614   width  = (int) (scm_to_double (scm_width)  * MILS_PER_INCH);
00615   height = (int) (scm_to_double (scm_height) * MILS_PER_INCH);
00616   papername = scm_to_utf8_string (scm_papername);
00617 
00618   if (!s_papersizes_uniq(papername)) {
00619     ret = SCM_BOOL_F;
00620   } else {
00621     s_papersizes_add_entry(papername, width, height);
00622     ret = SCM_BOOL_T;
00623   }
00624 
00625   free(papername);
00626   return ret;
00627 }
00628 #undef FUNC_NAME
00629 
00636 SCM g_rc_output_type(SCM mode)
00637 {
00638   static const vstbl_entry mode_table[] = {
00639     {WINDOW, "current window" },
00640     {EXTENTS, "limits" },  /* deprecated */
00641     {EXTENTS, "extents" },
00642     {EXTENTS_NOMARGINS, "extents no margins" },
00643   };
00644 
00645   RETURN_G_RC_MODE("output-type",
00646            default_print_output_type,
00647            4);
00648 }
00649 
00655 SCM g_rc_output_orientation(SCM mode)
00656 {
00657   static const vstbl_entry mode_table[] = {
00658     {PORTRAIT , "portrait" },
00659     {LANDSCAPE, "landscape"},
00660   };
00661   
00662   RETURN_G_RC_MODE("output-orientation",
00663            default_print_orientation,
00664            2);
00665 }
00666 
00672 SCM g_rc_image_color(SCM mode)
00673 {
00674   static const vstbl_entry mode_table[] = {
00675     {TRUE , "enabled" },
00676     {FALSE, "disabled"},
00677   };
00678 
00679   RETURN_G_RC_MODE("image-color",
00680            default_image_color,
00681            2);
00682 }
00683 
00689 SCM g_rc_image_size(SCM width, SCM height)
00690 {
00691   SCM_ASSERT (scm_is_integer (width),  width,  SCM_ARG1, "image-size");
00692   SCM_ASSERT (scm_is_integer (height), height, SCM_ARG2, "image-size");
00693   
00694   /* yes this is legit, we are casting the resulting double to an int */
00695   default_image_width  = scm_to_int (width);
00696   default_image_height = scm_to_int (height);
00697 
00698   return SCM_BOOL_T;
00699 }
00700 
00706 SCM g_rc_output_color(SCM mode)
00707 {
00708   static const vstbl_entry mode_table[] = {
00709     {TRUE , "enabled" },
00710     {FALSE, "disabled"},
00711   };
00712 
00713   /* this variable is inconsistantly named with the rest */
00714   RETURN_G_RC_MODE("output-color",
00715            default_print_color,
00716            2);
00717 }
00718 
00724 SCM g_rc_output_capstyle(SCM mode)
00725 {
00726   static const vstbl_entry mode_table[] = {
00727     {BUTT_CAP , "butt" },
00728     {ROUND_CAP , "round" },
00729     {SQUARE_CAP, "square"},
00730   };
00731 
00732   RETURN_G_RC_MODE("output-capstyle",
00733            default_print_output_capstyle,
00734            3);
00735 }
00736 
00742 SCM g_rc_log_window(SCM mode)
00743 {
00744   static const vstbl_entry mode_table[] = {
00745     {MAP_ON_STARTUP, "startup" },
00746     {MAP_LATER     , "later"   },
00747   };
00748 
00749   RETURN_G_RC_MODE("log-window",
00750            default_log_window,
00751            2);
00752 }
00753 
00759 SCM g_rc_log_window_type(SCM mode)
00760 {
00761   static const vstbl_entry mode_table[] = {
00762     {TRANSIENT, "transient" },
00763     {DECORATED, "decorated" },
00764   };
00765   
00766   RETURN_G_RC_MODE("log-window-type",
00767            default_log_window_type,
00768            2);
00769 }
00770 
00776 SCM g_rc_third_button(SCM mode)
00777 {
00778   static const vstbl_entry mode_table[] = {
00779     {POPUP_ENABLED   , "popup"   },
00780     {MOUSEPAN_ENABLED, "mousepan"},
00781   };
00782 
00783   RETURN_G_RC_MODE("third-button",
00784            default_third_button,
00785            2);
00786 }
00787 
00793 SCM g_rc_middle_button(SCM mode)
00794 {
00795   static const vstbl_entry mode_table[] = {
00796     {STROKE, "stroke"},
00797     {REPEAT, "repeat"},
00798     {ACTION, "action"},
00799     {MID_MOUSEPAN_ENABLED, "mousepan"},
00800   };
00801 
00802   RETURN_G_RC_MODE("middle-button",
00803            default_middle_button,
00804            4);
00805 }
00806 
00812 SCM g_rc_scroll_wheel(SCM mode)
00813 {
00814   static const vstbl_entry mode_table[] = {
00815     {SCROLL_WHEEL_CLASSIC, "classic"},
00816     {SCROLL_WHEEL_GTK,     "gtk"},
00817   };
00818 
00819   RETURN_G_RC_MODE("scroll-wheel",
00820                    default_scroll_wheel,
00821                    2);
00822 }
00823 
00829 SCM g_rc_net_consolidate(SCM mode)
00830 {
00831   static const vstbl_entry mode_table[] = {
00832     {TRUE , "enabled" },
00833     {FALSE, "disabled"},
00834   };
00835 
00836   RETURN_G_RC_MODE("net-consolidate",
00837            default_net_consolidate,
00838            2);
00839 }
00840 
00846 SCM g_rc_file_preview(SCM mode)
00847 {
00848   static const vstbl_entry mode_table[] = {
00849     {TRUE , "enabled" },
00850     {FALSE, "disabled"},
00851   };
00852 
00853   /* this variable is inconsistantly named with the rest */
00854   RETURN_G_RC_MODE("file-preview",
00855            default_file_preview,
00856            2);
00857 }
00858 
00864 SCM g_rc_enforce_hierarchy(SCM mode)
00865 {
00866   static const vstbl_entry mode_table[] = {
00867     {TRUE , "enabled" },
00868     {FALSE, "disabled"},
00869   };
00870 
00871   RETURN_G_RC_MODE("enforce-hierarchy",
00872            default_enforce_hierarchy,
00873            2);
00874 }
00875 
00881 SCM g_rc_text_origin_marker(SCM mode)
00882 {
00883   static const vstbl_entry mode_table[] = {
00884     {TRUE , "enabled" },
00885     {FALSE, "disabled"},
00886   };
00887 
00888   RETURN_G_RC_MODE("text-origin-marker",
00889            default_text_origin_marker,
00890            2);
00891 }
00892 
00898 SCM g_rc_fast_mousepan(SCM mode)
00899 {
00900   static const vstbl_entry mode_table[] = {
00901     {TRUE , "enabled" },
00902     {FALSE, "disabled"},
00903   };
00904 
00905   RETURN_G_RC_MODE("fast-mousepan",
00906            default_fast_mousepan,
00907            2);
00908 }
00909 
00915 SCM g_rc_raise_dialog_boxes_on_expose(SCM mode)
00916 {
00917   static const vstbl_entry mode_table[] = {
00918     {TRUE , "enabled" },
00919     {FALSE, "disabled"},
00920   };
00921   
00922   RETURN_G_RC_MODE("raise-dialog-boxes-on-expose",
00923            default_raise_dialog_boxes,
00924            2);
00925 }
00926 
00932 SCM g_rc_continue_component_place(SCM mode)
00933 {
00934   static const vstbl_entry mode_table[] = {
00935     {TRUE , "enabled" },
00936     {FALSE, "disabled"},
00937   };
00938 
00939   RETURN_G_RC_MODE("continue-component-place",
00940            default_continue_component_place,
00941            2);
00942 }
00943 
00949 SCM g_rc_undo_levels(SCM levels)
00950 {
00951   int val;
00952 
00953   SCM_ASSERT (scm_is_integer (levels), levels, SCM_ARG1, "undo-levels");
00954 
00955   val = scm_to_int (levels);
00956 
00957   if (val == 0) {
00958     fprintf(stderr, _("Invalid num levels [%d] passed to undo-levels\n"),
00959             val);
00960     val = 10; /* absolute default */
00961   }
00962 
00963   default_undo_levels = val;
00964 
00965   return SCM_BOOL_T;
00966 }
00967 
00973 SCM g_rc_undo_control(SCM mode)
00974 {
00975   static const vstbl_entry mode_table[] = {
00976     {TRUE , "enabled" },
00977     {FALSE, "disabled"},
00978   };
00979 
00980   RETURN_G_RC_MODE("undo-control", default_undo_control, 2);
00981 }
00982 
00988 SCM g_rc_undo_type(SCM mode)
00989 {
00990   static const vstbl_entry mode_table[] = {
00991     {UNDO_DISK  , "disk"   },
00992     {UNDO_MEMORY, "memory" },
00993   };
00994 
00995   RETURN_G_RC_MODE("undo-type",
00996            default_undo_type,
00997            2);
00998 }
00999 
01005 SCM g_rc_undo_panzoom(SCM mode)
01006 {
01007   static const vstbl_entry mode_table[] = {
01008     {TRUE , "enabled" },
01009     {FALSE, "disabled"},
01010   };
01011 
01012   RETURN_G_RC_MODE("undo-panzoom", default_undo_panzoom, 2);
01013 }
01014 
01020 SCM g_rc_draw_grips(SCM mode)
01021 {
01022   static const vstbl_entry mode_table[] = {
01023     {TRUE , "enabled" },
01024     {FALSE, "disabled"},
01025   };
01026   
01027   RETURN_G_RC_MODE("draw-grips",
01028            default_draw_grips,
01029            2);
01030 }
01031 
01037 SCM g_rc_netconn_rubberband(SCM mode)
01038 {
01039   static const vstbl_entry mode_table[] = {
01040     {TRUE , "enabled" },
01041     {FALSE, "disabled"},
01042   };
01043 
01044   RETURN_G_RC_MODE("netconn-rubberband",
01045            default_netconn_rubberband,
01046            2);
01047 }
01048 
01049 
01055 SCM g_rc_magnetic_net_mode(SCM mode)
01056 {
01057   static const vstbl_entry mode_table[] = {
01058     {TRUE , "enabled" },
01059     {FALSE, "disabled"},
01060   };
01061 
01062   RETURN_G_RC_MODE("magnetic-net-mode",
01063            default_magnetic_net_mode,
01064            2);
01065 }
01066 
01072 SCM g_rc_sort_component_library(SCM mode)
01073 {
01074   static const vstbl_entry mode_table[] = {
01075     {TRUE , "enabled" },
01076     {FALSE, "disabled"},
01077   };
01078 
01079   RETURN_G_RC_MODE("sort_component_library",
01080                    default_sort_component_library, 
01081                    2);
01082 }
01083 
01089 SCM g_rc_add_menu(SCM scm_menu_name, SCM scm_menu_items)
01090 {
01091   char *menu_name;
01092 
01093   SCM_ASSERT (scm_is_string (scm_menu_name), scm_menu_name,
01094               SCM_ARG1, "add-menu");
01095   SCM_ASSERT (SCM_NIMP (scm_menu_items) && SCM_CONSP (scm_menu_items), scm_menu_items,
01096               SCM_ARG2, "add-menu");
01097 
01098   menu_name = scm_to_utf8_string (scm_menu_name);
01099   s_menu_add_entry(menu_name, scm_menu_items);
01100   free (menu_name);
01101 
01102   return SCM_BOOL_T;
01103 }
01104 
01110 SCM g_rc_window_size(SCM width, SCM height)
01111 {
01112   SCM_ASSERT (scm_is_integer (width),  width,  SCM_ARG1, "window-size");
01113   SCM_ASSERT (scm_is_integer (height), height, SCM_ARG2, "window-size");
01114   
01115   default_width  = scm_to_int (width);
01116   default_height = scm_to_int (height);
01117 
01118   return SCM_BOOL_T;
01119 }
01120 
01126 SCM g_rc_warp_cursor(SCM mode)
01127 {
01128   static const vstbl_entry mode_table[] = {
01129     {TRUE , "enabled" },
01130     {FALSE, "disabled"},
01131   };
01132 
01133   RETURN_G_RC_MODE("warp-cursor",
01134            default_warp_cursor,
01135            2);
01136 }
01137 
01143 SCM g_rc_toolbars(SCM mode)
01144 {
01145   static const vstbl_entry mode_table[] = {
01146     {TRUE , "enabled" },
01147     {FALSE, "disabled"},
01148   };
01149 
01150   RETURN_G_RC_MODE("toolbars",
01151            default_toolbars,
01152            2);
01153 }
01154 
01160 SCM g_rc_handleboxes(SCM mode)
01161 {
01162   static const vstbl_entry mode_table[] = {
01163     {TRUE , "enabled" },
01164     {FALSE, "disabled"},
01165   };
01166 
01167   RETURN_G_RC_MODE("handleboxes",
01168            default_handleboxes,
01169            2);
01170 }
01171 
01177 SCM g_rc_setpagedevice_orientation(SCM mode)
01178 {
01179   static const vstbl_entry mode_table[] = {
01180     {TRUE , "enabled" },
01181     {FALSE, "disabled"},
01182   };
01183 
01184   RETURN_G_RC_MODE("setpagedevice-orientation",
01185                    default_setpagedevice_orientation,
01186            2);
01187 }
01188 
01194 SCM g_rc_setpagedevice_pagesize(SCM mode)
01195 {
01196   static const vstbl_entry mode_table[] = {
01197     {TRUE , "enabled" },
01198     {FALSE, "disabled"},
01199   };
01200 
01201   RETURN_G_RC_MODE("setpagedevice-pagesize",
01202                    default_setpagedevice_pagesize,
01203            2);
01204 }
01205 
01211 SCM g_rc_bus_ripper_size(SCM size)
01212 {
01213   int val;
01214 
01215   SCM_ASSERT (scm_is_integer (size), size, SCM_ARG1, "bus-ripper-size");
01216   
01217   val = scm_to_int (size);
01218 
01219   if (val == 0) {
01220     fprintf(stderr, _("Invalid size [%d] passed to bus-ripper-size\n"),
01221             val);
01222     val = 200; /* absolute default */
01223   }
01224 
01225   default_bus_ripper_size = val;
01226 
01227   return SCM_BOOL_T;
01228 }
01229 
01235 SCM g_rc_bus_ripper_type(SCM mode)
01236 {
01237   static const vstbl_entry mode_table[] = {
01238     {COMP_BUS_RIPPER, "component" },
01239     {NET_BUS_RIPPER,  "net" }
01240   };
01241 
01242   RETURN_G_RC_MODE("bus-ripper-type",
01243            default_bus_ripper_type,
01244            2);
01245 }
01246 
01252 SCM g_rc_bus_ripper_rotation(SCM mode)
01253 {
01254   static const vstbl_entry mode_table[] = {
01255     {SYMMETRIC,     "symmetric" },
01256     {NON_SYMMETRIC, "non-symmetric"  }
01257   };
01258 
01259   RETURN_G_RC_MODE("bus-ripper-rotation",
01260            default_bus_ripper_rotation,
01261            2);
01262 }
01263 
01269 SCM g_rc_force_boundingbox(SCM mode)
01270 {
01271   static const vstbl_entry mode_table[] = {
01272     {TRUE,  "enabled" },
01273     {FALSE, "disabled"  }
01274   };
01275 
01276   RETURN_G_RC_MODE("force-boundingbox",
01277            default_force_boundingbox,
01278            2);
01279 }
01280 
01286 SCM g_rc_dots_grid_dot_size (SCM dotsize)
01287 {
01288   int val;
01289 
01290   SCM_ASSERT (scm_is_integer (dotsize), dotsize, SCM_ARG1, "dots-grid-dot-size");
01291   
01292   val = scm_to_int (dotsize);
01293 
01294   if (val <= 0) {
01295     fprintf(stderr, _("Invalid dot size [%d] passed to dots-grid-dot-size\n"),
01296             val);
01297     val = 1; /* absolute default */
01298   }
01299 
01300   default_dots_grid_dot_size = val;
01301 
01302   return SCM_BOOL_T;
01303 }
01304 
01310 SCM g_rc_dots_grid_mode (SCM mode)
01311 {
01312   static const vstbl_entry mode_table[] = {
01313     {DOTS_GRID_VARIABLE_MODE, "variable" },
01314     {DOTS_GRID_FIXED_MODE,    "fixed"  }
01315   };
01316 
01317   RETURN_G_RC_MODE ("dots-grid-mode",
01318                     default_dots_grid_mode,
01319                     2);
01320 }
01321 
01327 SCM g_rc_dots_grid_fixed_threshold (SCM spacing)
01328 {
01329   int val;
01330 
01331   SCM_ASSERT (scm_is_integer (spacing), spacing, SCM_ARG1, "dots-grid-fixed-threshold");
01332   
01333   val = scm_to_int (spacing);
01334 
01335   if (val <= 0) {
01336     fprintf(stderr, _("Invalid pixel spacing [%d] passed to dots-grid-fixed-threshold\n"),
01337             val);
01338     val = 10; /* absolute default */
01339   }
01340 
01341   default_dots_grid_fixed_threshold = val;
01342 
01343   return SCM_BOOL_T;
01344 }
01345 
01346 
01352 SCM g_rc_mesh_grid_display_threshold (SCM spacing)
01353 {
01354   int val;
01355 
01356   SCM_ASSERT (scm_is_integer (spacing), spacing, SCM_ARG1,
01357               "mesh-grid-display-threshold");
01358 
01359   val = scm_to_int (spacing);
01360 
01361   if (val <= 0) {
01362     fprintf (stderr, _("Invalid pixel spacing [%d] passed to "
01363                        "mesh-grid-display-threshold\n"), val);
01364     val = 3; /* absolute default */
01365   }
01366 
01367   default_mesh_grid_display_threshold = val;
01368 
01369   return SCM_BOOL_T;
01370 }
01371 
01377 SCM g_rc_add_attribute_offset(SCM offset)
01378 {
01379   int val;
01380 
01381   SCM_ASSERT (scm_is_integer (offset), offset,
01382               SCM_ARG1, "add-attribute-offset");
01383   
01384   val = scm_to_int (offset);
01385 
01386   if (val < 0) {
01387     fprintf(stderr, _("Invalid offset [%d] passed to add-attribute-offset\n"),
01388             val);
01389     val = 50; /* absolute default */
01390   }
01391 
01392   default_add_attribute_offset = val;
01393 
01394   return SCM_BOOL_T;
01395 }
01396 
01402 SCM g_rc_auto_save_interval(SCM seconds)
01403 {
01404   int val;
01405 
01406   SCM_ASSERT (scm_is_integer (seconds), seconds, SCM_ARG1, "auto-save-interval");
01407 
01408   val = scm_to_int (seconds);
01409 
01410   if (val < 0) {
01411     fprintf(stderr, _("Invalid number of seconds [%d] passed to auto-save-interval\n"),
01412             val);
01413     val = 120; /* absolute default */
01414   }
01415 
01416   default_auto_save_interval = val;
01417 
01418   return SCM_BOOL_T;
01419 }
01420 
01426 SCM g_rc_mousepan_gain(SCM gain)
01427 {
01428   int val;
01429 
01430   SCM_ASSERT (scm_is_integer (gain), gain, SCM_ARG1, "mousepan-gain");
01431   
01432   val = scm_to_int (gain);
01433 
01434   if (val <= 0) {
01435     fprintf(stderr, _("Invalid gain [%d] passed to mousepan-gain\n"),
01436             val);
01437     val = 5; /* absolute default */
01438   }
01439 
01440   default_mousepan_gain = val;
01441 
01442   return SCM_BOOL_T;
01443 }
01444 
01449 SCM g_rc_keyboardpan_gain(SCM gain)
01450 {
01451   int val;
01452 
01453   SCM_ASSERT (scm_is_integer (gain), gain, SCM_ARG1, "keyboardpan-gain");
01454   
01455   val = scm_to_int (gain);
01456 
01457   if (val <= 0) {
01458     fprintf(stderr, _("Invalid gain [%d] passed to keyboardpan-gain\n"),
01459             val);
01460     val = 20; /* absolute default */
01461   }
01462 
01463   default_keyboardpan_gain = val;
01464 
01465   return SCM_BOOL_T;
01466 }
01467 
01473 SCM g_rc_print_command(SCM scm_command)
01474 #define FUNC_NAME "print-command"
01475 {
01476   char *command;
01477 
01478   SCM_ASSERT (scm_is_string (scm_command), scm_command,
01479               SCM_ARG1, FUNC_NAME);
01480   
01481   command = scm_to_utf8_string (scm_command);
01482 
01483   g_free (default_print_command);
01484   default_print_command = g_strdup (command);
01485   free (command);
01486 
01487   return SCM_BOOL_T;
01488 }
01489 #undef FUNC_NAME
01490 
01496 SCM g_rc_select_slack_pixels(SCM pixels)
01497 {
01498   int val;
01499 
01500   SCM_ASSERT (scm_is_integer (pixels), pixels, SCM_ARG1, "select-slack-pixels");
01501   
01502   val = scm_to_int (pixels);
01503 
01504   if (val <= 0) {
01505     fprintf(stderr, _("Invalid number of pixels [%d] passed to select-slack-pixels\n"),
01506             val);
01507     val = 4; /* absolute default */
01508   }
01509 
01510   default_select_slack_pixels = val;
01511 
01512   return SCM_BOOL_T;
01513 }
01514 
01520 SCM g_rc_zoom_gain(SCM gain)
01521 {
01522   int val;
01523 
01524   SCM_ASSERT (scm_is_integer (gain), gain, SCM_ARG1, "zoom-gain");
01525 
01526   val = scm_to_int (gain);
01527 
01528   /* Allow -ve numbers in case the user wishes to reverse zoom direction,
01529    * but don't allow zero gain as this would disable the zoom action */
01530   if (val == 0) {
01531     fprintf(stderr, _("Invalid gain [%d] passed to zoom-gain\n"), val);
01532     val = 20; /* absolute default */
01533   }
01534 
01535   default_zoom_gain = val;
01536 
01537   return SCM_BOOL_T;
01538 }
01539 
01545 SCM g_rc_scrollpan_steps(SCM steps)
01546 {
01547   int val;
01548 
01549   SCM_ASSERT (scm_is_integer (steps), steps, SCM_ARG1, "scrollpan-steps");
01550 
01551   val = scm_to_int (steps);
01552 
01553   /* Allow -ve numbers in case the user wishes to reverse scroll direction,
01554    * but don't allow zero steps as this would cause a division by zero error */
01555   if (val == 0) {
01556     fprintf(stderr, _("Invalid number of steps [%d] scrollpan-steps\n"), val);
01557     val = 8; /* absolute default */
01558   }
01559 
01560   default_scrollpan_steps = val;
01561 
01562   return SCM_BOOL_T;
01563 }
01564 
01565 
01566 extern COLOR display_colors[MAX_COLORS];
01567 extern COLOR display_outline_colors[MAX_COLORS];
01568 
01569 SCM g_rc_display_color_map (SCM scm_map)
01570 {
01571   if (scm_map == SCM_UNDEFINED) {
01572     return s_color_map_to_scm (display_colors);
01573   }
01574 
01575   SCM_ASSERT (scm_is_true (scm_list_p (scm_map)),
01576               scm_map, SCM_ARG1, "display-color-map");
01577 
01578   s_color_map_from_scm (display_colors, scm_map, "display-color-map");
01579   return SCM_BOOL_T;
01580 }
01581 
01582 SCM g_rc_display_outline_color_map (SCM scm_map)
01583 {
01584   if (scm_map == SCM_UNDEFINED) {
01585     return s_color_map_to_scm (display_outline_colors);
01586   }
01587 
01588   SCM_ASSERT (scm_is_true (scm_list_p (scm_map)),
01589               scm_map, SCM_ARG1, "display-outline-color-map");
01590 
01591   s_color_map_from_scm (display_outline_colors, scm_map, "display-outline-color-map");
01592   return SCM_BOOL_T;
01593 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines