Remove extra debug message
[geda-gaf.git] / gschem / src / g_util.c
blobacf8568baa9bac277a09e623d54097a2aa0eac3b
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 2011 Peter Brett <peter@peter-b.co.uk>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
20 /*! \file g_util.c
21 * \brief Scheme utility functions
24 #include <config.h>
26 #include "gschem.h"
28 /*! \brief Launch default application for a URI.
29 * \par Function Description
30 * Launches the default application associated with \a uri_s on the
31 * host platform. Raises an error on failure.
33 * \note Scheme API: Implements the %show-uri procedure in the (gschem
34 * core util) module.
36 * \sa x_show_uri().
38 * \param uri_s URI to launch viewer for.
39 * \return undefined value.
41 SCM_DEFINE (show_uri, "%show-uri", 1, 0, 0, (SCM uri_s),
42 "Show a URI in the associated default application")
44 /* Check that we were passed a string. */
45 SCM_ASSERT (scm_is_string (uri_s), uri_s, SCM_ARG1, s_show_uri);
47 GschemToplevel *w_current = g_current_window ();
48 const gchar *uri = scm_to_utf8_string (uri_s);
49 GError *err = NULL;
51 if (!x_show_uri (w_current, uri, &err)) {
52 scm_dynwind_begin (0);
53 scm_dynwind_unwind_handler ((void (*)(void *)) g_error_free,
54 err, SCM_F_WIND_EXPLICITLY);
55 scm_misc_error (s_show_uri, _("Could not launch URI ~S: ~A"),
56 scm_list_2 (uri_s,
57 scm_from_utf8_string (err->message)));
58 scm_dynwind_end ();
60 return SCM_UNDEFINED;
63 /*! \brief Create the (gschem core util) Scheme module.
64 * \par Function Description
65 * Defines procedures in the (gschem core util) module. The module can
66 * be accessed using (use-modules (gschem core util)).
68 static void
69 init_module_gschem_core_util ()
71 /* Register the functions */
72 #include "g_util.x"
74 /* Add them to the module's public definitions. */
75 scm_c_export (s_show_uri,
76 NULL);
79 /*!
80 * \brief Initialise miscellaneous gschem utility procedures.
81 * \par Function Description
82 * Registers some Scheme utility procedures for e.g. accessing
83 * miscellaneous system services. Should only be called by
84 * main_prog().
86 void
87 g_init_util ()
89 /* Define the (gschem core util) module */
90 scm_c_define_module ("gschem core util",
91 init_module_gschem_core_util,
92 NULL);