1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 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., 59 Temple Place, Suite 330, Boston, MA 02111 USA
23 #include "libgeda_priv.h"
25 #ifdef HAVE_LIBDMALLOC
29 /*! \def INIT_STR(w, name, str) */
30 #define INIT_STR(w, name, str) { \
32 (w)->name = g_strdup(((default_ ## name) != NULL) ? \
33 (default_ ## name) : (str)); \
37 * Kazu Hirata <kazu@seul.org> on July 16, 1999 - Added these absolute
38 * defaults used when default_... is NULL.
40 #define DEFAULT_UNTITLED_NAME "untitled"
41 #define DEFAULT_SCHEME_DIRECTORY "./"
42 #define DEFAULT_BITMAP_DIRECTORY "../lib/bitmaps"
43 #define DEFAULT_BUS_RIPPER_SYMNAME "busripper-1.sym"
44 #define DEFAULT_POSTSCRIPT_PROLOG "prolog.ps"
46 int default_init_right
= WIDTH_C
;
47 int default_init_bottom
= HEIGHT_C
;
48 char *default_untitled_name
= NULL
;
49 char *default_scheme_directory
= NULL
;
50 char *default_bitmap_directory
= NULL
;
51 char *default_bus_ripper_symname
= NULL
;
52 char *default_postscript_prolog
= NULL
;
53 GList
*default_always_promote_attributes
= NULL
;
55 int default_attribute_promotion
= TRUE
;
56 int default_promote_invisible
= FALSE
;
57 int default_keep_invisible
= TRUE
;
59 /*! \brief Initialize variables in TOPLEVEL object
60 * \par Function Description
61 * This function will initialize variables to default values.
63 * \param [out] toplevel The TOPLEVEL object to be updated.
66 void i_vars_libgeda_set(TOPLEVEL
*toplevel
)
70 toplevel
->init_right
= default_init_right
;
71 toplevel
->init_bottom
= default_init_bottom
;
73 toplevel
->attribute_promotion
= default_attribute_promotion
;
74 toplevel
->promote_invisible
= default_promote_invisible
;
75 toplevel
->keep_invisible
= default_keep_invisible
;
77 /* copy the always_promote_attributes list from the default */
78 g_list_foreach(toplevel
->always_promote_attributes
, (GFunc
) g_free
, NULL
);
79 g_list_free(toplevel
->always_promote_attributes
);
80 toplevel
->always_promote_attributes
= g_list_copy(default_always_promote_attributes
);
81 for (iter
= toplevel
->always_promote_attributes
; iter
!= NULL
;
82 iter
= g_list_next(iter
))
83 iter
->data
= g_strdup(iter
->data
);
85 /* you cannot free the default* strings here since new windows */
87 INIT_STR(toplevel
, untitled_name
, DEFAULT_UNTITLED_NAME
);
88 INIT_STR(toplevel
, scheme_directory
, DEFAULT_SCHEME_DIRECTORY
);
89 INIT_STR(toplevel
, bitmap_directory
, DEFAULT_BITMAP_DIRECTORY
);
90 INIT_STR(toplevel
, bus_ripper_symname
, DEFAULT_BUS_RIPPER_SYMNAME
);
91 INIT_STR(toplevel
, postscript_prolog
, DEFAULT_POSTSCRIPT_PROLOG
);
95 /*! \brief Free default names
96 * \par Function Description
97 * This function will free all of the default variables for libgeda.
100 void i_vars_libgeda_freenames()
102 g_free(default_untitled_name
);
103 g_free(default_scheme_directory
);
104 g_free(default_bitmap_directory
);
105 g_free(default_bus_ripper_symname
);
106 g_free(default_postscript_prolog
);
108 g_list_foreach(default_always_promote_attributes
, (GFunc
) g_free
, NULL
);
109 g_list_free(default_always_promote_attributes
);
110 default_always_promote_attributes
= NULL
;