missing NULL terminator in set_config_x
[geda-gaf.git] / gschem / src / x_rc.c
blob19819b11a1549c8a15c73f9823a3a4db1377a189
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2020 gEDA Contributors (see ChangeLog for details)
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19 #include <config.h>
20 #include "gschem.h"
22 #ifdef HAVE_LOCALE_H
23 #include <locale.h>
24 #endif
26 /* Error handler function used by x_rc_parse_gschem(). */
27 static void
28 x_rc_parse_gschem_error (GError **err)
30 char *msg2; /* Secondary text */
31 GtkWidget *dialog;
33 g_assert (err != NULL);
35 /* Take no chances; if err was not set for some reason, it's a
36 * problem. */
37 if (*err == NULL) {
38 /* Log message */
39 s_log_message (_("ERROR: An unknown error occurred while parsing "
40 "configuration files.\n"));
42 /* Dialog message */
43 msg2 =
44 g_strdup (_("An unknown error occurred while parsing configuration files."
45 "\n\nThe gschem log may contain more information."));
46 } else {
48 /* Config files are allowed to be missing or skipped; check for
49 * this. */
50 if (g_error_matches (*err, G_FILE_ERROR, G_FILE_ERROR_NOENT) ||
51 g_error_matches (*err, EDA_ERROR, EDA_ERROR_RC_TWICE)) {
52 return;
55 /* Log message */
56 s_log_message (_("ERROR: %s\n"), (*err)->message);
58 /* Dialog message */
59 msg2 = g_strdup_printf (_("%s\n\n"
60 "The gschem log may contain more information."),
61 (*err)->message);
64 dialog = gtk_message_dialog_new (NULL,
65 GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
66 GTK_BUTTONS_OK,
67 _("Cannot load gschem configuration."));
68 g_object_set (G_OBJECT (dialog), "secondary-text", msg2, NULL);
69 gtk_dialog_run (GTK_DIALOG (dialog));
70 gtk_widget_destroy (dialog);
71 g_free (msg2);
74 /*! \brief Load gschem configuration files and display error dialogs.
75 * \par Function Description
76 * Loads configuration files in a similar manner to g_rc_parse().
77 * Instead of exiting on error, display error dialogs with explanatory
78 * messages.
80 * \param w_current The current #GschemToplevel structure.
81 * \param rcfile Specific config file path, or NULL.
83 void
84 x_rc_parse_gschem (TOPLEVEL *toplevel, const gchar *rcfile) {
85 return g_rc_parse_handler (toplevel, "gschemrc", rcfile,
86 (ConfigParseErrorFunc) x_rc_parse_gschem_error,
87 (void *) toplevel);