]> git.sur5r.net Git - glabels/blob - src/warning-handler.c
Imported Upstream version 2.2.8
[glabels] / src / warning-handler.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2
3 /*
4  *  (GLABELS) Label and Business Card Creation program for GNOME
5  *
6  *  warning-handler.c:  non-critical error handler
7  *
8  *  Copyright (C) 2005  Jim Evins <evins@snaught.com>.
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
23  */
24
25 #include <config.h>
26
27 #include "warning-handler.h"
28
29 #include <glib/gmessages.h>
30 #include <glib/gi18n.h>
31 #include <gtk/gtkmessagedialog.h>
32 #include <gtk/gtkstock.h>
33 #include <stdlib.h>
34
35 static void warning_handler (const gchar    *log_domain,
36                              GLogLevelFlags  log_level,
37                              const gchar    *message,
38                              gpointer        user_data);
39
40 \f
41 /***************************************************************************/
42 /* Initialize error handler.                                               */
43 /***************************************************************************/
44 void
45 gl_warning_handler_init (void)
46 {
47         g_log_set_handler ("LibGlabels",
48                            G_LOG_LEVEL_WARNING,
49                            warning_handler,
50                            "libglabels");
51
52         g_log_set_handler (G_LOG_DOMAIN,
53                            G_LOG_LEVEL_WARNING,
54                            warning_handler,
55                            "glabels");
56 }
57
58 /*-------------------------------------------------------------------------*/
59 /* PRIVATE.  Actual error handler.                                         */
60 /*-------------------------------------------------------------------------*/
61 static void
62 warning_handler (const gchar    *log_domain,
63                  GLogLevelFlags  log_level,
64                  const gchar    *message,
65                  gpointer        user_data)
66 {
67         GtkWidget *dialog;
68
69         dialog = gtk_message_dialog_new (NULL,
70                                          GTK_DIALOG_MODAL,
71                                          GTK_MESSAGE_WARNING,
72                                          GTK_BUTTONS_CLOSE,
73                                          _("gLabels Error!"));
74         gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
75                                                   "%s", message);
76
77         gtk_dialog_run (GTK_DIALOG (dialog));
78
79         gtk_widget_destroy (GTK_WIDGET (dialog));
80 }
81