gschem

x_rc.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * gschem - gEDA Schematic Capture
00003  * Copyright (C) 1998-2011 gEDA Contributors (see ChangeLog for details)
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
00018  */
00019 #include <config.h>
00020 #include "gschem.h"
00021 
00022 #ifdef HAVE_LOCALE_H
00023 #include <locale.h>
00024 #endif
00025 
00026 /* Error handler function used by x_rc_parse_gschem(). */
00027 static void
00028 x_rc_parse_gschem_error (GError **err, GSCHEM_TOPLEVEL *w_current)
00029 {
00030   char *msg2; /* Secondary text */
00031   GtkWidget *dialog;
00032 
00033   g_assert (w_current != NULL);
00034   g_assert (err != NULL);
00035 
00036   /* Take no chances; if err was not set for some reason, it's a
00037    * problem. */
00038   if (*err == NULL) {
00039     /* Log message */
00040     s_log_message (_("ERROR: An unknown error occurred while parsing "
00041                      "configuration files.\n"));
00042 
00043     /* Dialog message */
00044     msg2 =
00045       g_strdup (_("An unknown error occurred while parsing configuration files."
00046                   "\n\nThe gschem log may contain more information."));
00047   } else {
00048 
00049     /* Config files are allowed to be missing or skipped; check for
00050      * this. */
00051     if (g_error_matches (*err, G_FILE_ERROR, G_FILE_ERROR_NOENT) ||
00052         g_error_matches (*err, EDA_ERROR, EDA_ERROR_RC_TWICE)) {
00053       return;
00054     }
00055 
00056     /* Log message */
00057     s_log_message (_("ERROR: %s\n"), (*err)->message);
00058 
00059     /* Dialog message */
00060     msg2 = g_strdup_printf (_("%s\n\n"
00061                               "The gschem log may contain more information."),
00062                             (*err)->message);
00063   }
00064 
00065   dialog = gtk_message_dialog_new (GTK_WINDOW (w_current->main_window),
00066                                    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
00067                                    GTK_BUTTONS_OK,
00068                                    _("Cannot load gschem configuration."));
00069   g_object_set (G_OBJECT (dialog), "secondary-text", msg2, NULL);
00070   gtk_dialog_run (GTK_DIALOG (dialog));
00071   gtk_widget_destroy (dialog);
00072   g_free (msg2);
00073 }
00074 
00084 void
00085 x_rc_parse_gschem (GSCHEM_TOPLEVEL *w_current, const gchar *rcfile) {
00086   TOPLEVEL *toplevel = w_current->toplevel;
00087   g_rc_parse_handler (toplevel, "gschemrc", rcfile,
00088                       (ConfigParseErrorFunc) x_rc_parse_gschem_error,
00089                       (void *) w_current);
00090 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines