1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 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
35 #include <libgeda/libgeda.h>
37 #include "../include/globals.h"
38 #include "../include/prototype.h"
39 #include "../include/x_dialog.h"
41 #ifdef HAVE_LIBDMALLOC
45 /*! \todo Finish function documentation!!!
47 * \par Function Description
50 SCM
g_funcs_print(SCM filename
)
52 SCM_ASSERT (scm_is_string (filename
), filename
,
53 SCM_ARG1
, "gschem-print");
55 if (output_filename
) {
56 if (f_print_file (global_window_current
, output_filename
))
59 if (f_print_file (global_window_current
, SCM_STRING_CHARS (filename
)))
66 /*! \todo Finish function documentation!!!
68 * \par Function Description
71 SCM
g_funcs_postscript(SCM filename
)
73 SCM_ASSERT (scm_is_string (filename
), filename
,
74 SCM_ARG1
, "gschem-postscript");
76 if (output_filename
) {
77 if (f_print_file (global_window_current
, output_filename
))
80 if (f_print_file (global_window_current
, SCM_STRING_CHARS (filename
)))
87 /*! \todo Finish function documentation!!!
89 * \par Function Description
92 SCM
g_funcs_image(SCM filename
)
94 SCM_ASSERT (scm_is_string (filename
), filename
,
95 SCM_ARG1
, "gschem-image");
97 if (output_filename
) {
98 x_image_lowlevel (global_window_current
, output_filename
,
99 global_window_current
->image_width
,
100 global_window_current
->image_height
,
103 x_image_lowlevel (global_window_current
, SCM_STRING_CHARS (filename
),
104 global_window_current
->image_width
,
105 global_window_current
->image_height
,
112 /*! \todo Finish function documentation!!!
114 * \par Function Description
117 SCM
g_funcs_exit(void)
122 /*! \todo Finish function documentation!!!
124 * \par Function Description
127 SCM
g_funcs_log(SCM msg
)
130 SCM_ASSERT (scm_is_string (msg
), msg
,
131 SCM_ARG1
, "gschem-log");
133 s_log_message (SCM_STRING_CHARS (msg
));
138 /*! \todo Finish function documentation!!!
140 * \par Function Description
143 SCM
g_funcs_msg(SCM msg
)
146 SCM_ASSERT (scm_is_string (msg
), msg
,
147 SCM_ARG1
, "gschem-msg");
149 generic_msg_dialog (SCM_STRING_CHARS (msg
));
154 /*! \todo Finish function documentation!!!
156 * \par Function Description
159 SCM
g_funcs_confirm(SCM msg
)
163 SCM_ASSERT (scm_is_string (msg
), msg
,
164 SCM_ARG1
, "gschem-msg");
166 r
= generic_confirm_dialog (SCM_STRING_CHARS (msg
));
174 /*! \todo Finish function documentation!!!
176 * \par Function Description
179 SCM
g_funcs_filesel(SCM msg
, SCM templ
, SCM flags
)
185 SCM_ASSERT (scm_is_string (msg
), msg
,
186 SCM_ARG1
, "gschem-filesel");
188 SCM_ASSERT (scm_is_string (templ
), templ
,
189 SCM_ARG1
, "gschem-filesel");
191 /*! \bug FIXME -- figure out the magic SCM_ASSERT for the flags */
193 /*! \bug FIXME -- how to deal with conflicting flags?
194 * Should I throw a scheme error? Just deal in the c code?
196 for (c_flags
= 0; scm_pair_p (flags
) == SCM_BOOL_T
; flags
= SCM_CDR (flags
)) {
197 SCM f
= SCM_CAR (flags
);
198 if (strcmp (SCM_STRING_CHARS (f
), "may_exist") == 0) {
199 c_flags
|= FSB_MAY_EXIST
;
201 } else if (strcmp (SCM_STRING_CHARS (f
), "must_exist") == 0) {
202 c_flags
|= FSB_MUST_EXIST
;
204 } else if (strcmp (SCM_STRING_CHARS (f
), "must_not_exist") == 0) {
205 c_flags
|= FSB_SHOULD_NOT_EXIST
;
207 } else if (strcmp (SCM_STRING_CHARS (f
), "save") == 0) {
210 } else if (strcmp (SCM_STRING_CHARS (f
), "open") == 0) {
214 scm_wrong_type_arg ("gschem-filesel", 1, f
);
218 r
= generic_filesel_dialog (SCM_STRING_CHARS (msg
),
219 SCM_STRING_CHARS (templ
),
223 v
= scm_makfrom0str (r
);
229 /*! \todo Finish function documentation!!!
231 * \par Function Description
234 SCM
g_funcs_use_rc_values(void)
236 i_vars_set(global_window_current
);
240 /*! \todo Finish function documentation!!!
242 * \par Function Description
246 * Gets names from all objects of current page which selected-flags are true.
248 /* all of the declaration part is copied from some other c-code of
250 * I don't really know, whether this all are necessary or not, but
253 hash_table_2_list (gpointer key
,
257 SCM
*plist
= (SCM
*)user_data
;
258 *plist
= scm_cons (scm_makfrom0str ((char*)value
), *plist
);
261 /*! \todo Finish function documentation!!!
263 * \par Function Description
266 SCM
get_selected_component_attributes(TOPLEVEL
*toplevel
)
272 /* build a hash table */
273 ht
= g_hash_table_new (g_str_hash
, g_str_equal
);
274 for (obj
= toplevel
->page_current
->object_head
; obj
!= NULL
;
277 obj
->type
== OBJ_TEXT
&&
278 obj
->text
->string
!= NULL
) {
279 /* add text string in the hash table */
280 g_hash_table_insert (ht
,
285 /* now create a scheme list of the entries in the hash table */
286 g_hash_table_foreach (ht
, hash_table_2_list
, &list
);
287 /* and get ride of the hast table */
288 g_hash_table_destroy (ht
);
293 /*! \todo Finish function documentation!!!
294 * \brief Get selected filename of current schematic.
295 * \par Function Description
296 * This function gets the whole filename of the current schematic.
297 * Specifically, the <B>page_filename</B> of the current page.
299 * \param [in] w_current The TOPLEVEL object to get filename from.
300 * \return whole filename of current schematic.
302 SCM
get_selected_filename(TOPLEVEL
*w_current
)
306 exit_if_null(w_current
);
308 return_value
= scm_take0str (w_current
->page_current
->page_filename
);
310 return(return_value
);
313 /*! \brief Use gschemdoc to open a browser to a specific wiki page
315 * \param [in] wikiname the name of the wiki page
317 * \par Function Description
318 * Invokes gschemdoc with its -w switch to open a browser to the wiki
319 * page specified by wikiname. If wikiname is empty or not a string,
320 * will browse to the main wiki page.
322 SCM
g_funcs_browse_wiki(SCM wikiname
)
327 /* Extract wiki name string from Scheme value structure.
328 * If not a string, use the empty string */
329 if (scm_is_string (wikiname
)) {
330 wikistr
= SCM_STRING_CHARS(wikiname
);
340 /* Fork failed. Still in parent process, so can use the log
342 s_log_message(_("Could not fork\n"));
344 } else if (pid
> 0) {
345 /* Parent process, we're finished here */
349 /* begin daughter process stuff */
351 /* assume gschemdoc is part of path */
352 char *gschemdoc
= "gschemdoc";
353 char *wikiarg
= "-w";
355 execlp(gschemdoc
, gschemdoc
, wikiarg
, wikistr
, NULL
);
357 /* if we return, then nothing happened */
358 fprintf(stderr
, _("Could not invoke %s\n"), gschemdoc
);
361 /* end daughter process stuff */
363 #else /* __MINGW32__ */
364 s_log_message(_("Documentation commands not supported under MinGW.\n"));
366 #endif /* __MINGW32__ */