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