gschem
|
00001 /* gEDA - GPL Electronic Design Automation 00002 * gschem - gEDA Schematic Capture 00003 * Copyright (C) 2011 Peter Brett <peter@peter-b.co.uk> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 00018 */ 00019 00024 #include <config.h> 00025 #include <missing.h> 00026 00027 #include "gschem.h" 00028 00042 SCM_DEFINE (show_uri, "%show-uri", 1, 0, 0, (SCM uri_s), 00043 "Show a URI in the associated default application") 00044 { 00045 /* Check that we were passed a string. */ 00046 SCM_ASSERT (scm_is_string (uri_s), uri_s, SCM_ARG1, s_show_uri); 00047 00048 GSCHEM_TOPLEVEL *w_current = g_current_window (); 00049 const gchar *uri = scm_to_utf8_string (uri_s); 00050 GError *err = NULL; 00051 00052 if (!x_show_uri (w_current, uri, &err)) { 00053 scm_dynwind_begin (0); 00054 scm_dynwind_unwind_handler ((void (*)(void *)) g_error_free, 00055 err, SCM_F_WIND_EXPLICITLY); 00056 scm_misc_error (s_show_uri, _("Could not launch URI ~S: ~A"), 00057 scm_list_2 (uri_s, 00058 scm_from_utf8_string (err->message))); 00059 scm_dynwind_end (); 00060 } 00061 return SCM_UNDEFINED; 00062 } 00063 00069 static void 00070 init_module_gschem_core_util () 00071 { 00072 /* Register the functions */ 00073 #include "g_util.x" 00074 00075 /* Add them to the module's public definitions. */ 00076 scm_c_export (s_show_uri, 00077 NULL); 00078 } 00079 00087 void 00088 g_init_util () 00089 { 00090 /* Define the (gschem core util) module */ 00091 scm_c_define_module ("gschem core util", 00092 init_module_gschem_core_util, 00093 NULL); 00094 }