libgeda

i_vars.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * libgeda - gEDA's library
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 <stdio.h>
00022 
00023 #include "libgeda_priv.h"
00024 
00025 #ifdef HAVE_LIBDMALLOC
00026 #include <dmalloc.h>
00027 #endif
00028 
00030 #define INIT_STR(w, name, str) {                                        \
00031         g_free((w)->name);                                              \
00032         (w)->name = g_strdup(((default_ ## name) != NULL) ?             \
00033                              (default_ ## name) : (str));               \
00034 }
00035 
00036 /* \note 
00037  * Kazu Hirata <kazu@seul.org> on July 16, 1999 - Added these absolute
00038  * defaults used when default_... is NULL.
00039  */
00040 #define DEFAULT_UNTITLED_NAME    "untitled"
00041 #define DEFAULT_BITMAP_DIRECTORY "../lib/bitmaps"
00042 #define DEFAULT_BUS_RIPPER_SYMNAME "busripper-1.sym"
00043 #define DEFAULT_POSTSCRIPT_PROLOG  "prolog.ps"
00044 
00045 int   default_init_right = WIDTH_C;
00046 int   default_init_bottom = HEIGHT_C;
00047 char *default_untitled_name = NULL;
00048 char *default_bitmap_directory = NULL;
00049 char *default_bus_ripper_symname = NULL;
00050 char *default_postscript_prolog = NULL;
00051 GList *default_always_promote_attributes = NULL;
00052 
00053 int   default_attribute_promotion = TRUE;
00054 int   default_promote_invisible = FALSE;
00055 int   default_keep_invisible = TRUE;
00056 
00057 int   default_make_backup_files = TRUE;
00058 
00066 void i_vars_libgeda_set(TOPLEVEL *toplevel)
00067 {
00068   GList *iter;
00069 
00070   toplevel->init_right   = default_init_right;
00071   toplevel->init_bottom  = default_init_bottom;
00072 
00073   toplevel->attribute_promotion = default_attribute_promotion;
00074   toplevel->promote_invisible = default_promote_invisible;
00075   toplevel->keep_invisible = default_keep_invisible;
00076 
00077   toplevel->make_backup_files = default_make_backup_files;
00078 
00079   /* copy the always_promote_attributes list from the default */
00080   g_list_foreach(toplevel->always_promote_attributes, (GFunc) g_free, NULL);
00081   g_list_free(toplevel->always_promote_attributes);
00082   toplevel->always_promote_attributes = g_list_copy(default_always_promote_attributes);
00083   for (iter = toplevel->always_promote_attributes; iter != NULL;
00084        iter = g_list_next(iter))
00085     iter->data = g_strdup(iter->data);
00086 
00087   /* you cannot free the default* strings here since new windows */
00088   /* need them */
00089   INIT_STR(toplevel, untitled_name   , DEFAULT_UNTITLED_NAME   );
00090   INIT_STR(toplevel, bitmap_directory, DEFAULT_BITMAP_DIRECTORY);
00091   INIT_STR(toplevel, bus_ripper_symname, DEFAULT_BUS_RIPPER_SYMNAME);
00092   INIT_STR(toplevel, postscript_prolog,  DEFAULT_POSTSCRIPT_PROLOG);
00093 }
00094 
00095 
00101 void i_vars_libgeda_freenames()
00102 {
00103   g_free(default_untitled_name);
00104   g_free(default_bitmap_directory);
00105   g_free(default_bus_ripper_symname);
00106   g_free(default_postscript_prolog);
00107 
00108   g_list_foreach(default_always_promote_attributes, (GFunc) g_free, NULL);
00109   g_list_free(default_always_promote_attributes);
00110   default_always_promote_attributes = NULL;
00111 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines