From 599f3be4bcea39fb4da1ee940be7d566abd1abef Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Fri, 9 Dec 2005 00:15:33 +0000 Subject: [PATCH] 2005-12-08 Jim Evins * libglabels/libglabels-private.h: Set G_LOG_DOMAIN * libglabels/paper.c: (read_papers): * libglabels/template.c: (read_templates): Made appropriate warnings critical. * src/Makefile.am: * src/critical-error-handler.h: * src/critical-error-handler.c: (gl_critical_error_handler_init), (critical_error_handler): Created critical error handler. * src/glabels.c: (main): Register critical error handler. * src/merge-properties-dialog.c: (gl_merge_properties_dialog_init): * src/object-editor.c: (gl_object_editor_init): * src/prefs-dialog.c: (gl_prefs_dialog_init): * src/template-designer.c: (gl_template_designer_init): * src/ui-property-bar.c: (gl_ui_property_bar_instance_init): Made appropriate warnings critical. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@563 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 21 ++++++ glabels2/libglabels/libglabels-private.h | 3 + glabels2/libglabels/paper.c | 2 +- glabels2/libglabels/template.c | 2 +- glabels2/src/Makefile.am | 2 + glabels2/src/critical-error-handler.c | 83 ++++++++++++++++++++++++ glabels2/src/critical-error-handler.h | 36 ++++++++++ glabels2/src/glabels.c | 4 ++ glabels2/src/merge-properties-dialog.c | 2 +- glabels2/src/object-editor.c | 2 +- glabels2/src/prefs-dialog.c | 2 +- glabels2/src/template-designer.c | 2 +- glabels2/src/ui-property-bar.c | 2 +- 13 files changed, 156 insertions(+), 7 deletions(-) create mode 100644 glabels2/src/critical-error-handler.c create mode 100644 glabels2/src/critical-error-handler.h diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 61333fdb..8b3df333 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,24 @@ +2005-12-08 Jim Evins + + * libglabels/libglabels-private.h: + Set G_LOG_DOMAIN + * libglabels/paper.c: (read_papers): + * libglabels/template.c: (read_templates): + Made appropriate warnings critical. + * src/Makefile.am: + * src/critical-error-handler.h: + * src/critical-error-handler.c: (gl_critical_error_handler_init), + (critical_error_handler): + Created critical error handler. + * src/glabels.c: (main): + Register critical error handler. + * src/merge-properties-dialog.c: (gl_merge_properties_dialog_init): + * src/object-editor.c: (gl_object_editor_init): + * src/prefs-dialog.c: (gl_prefs_dialog_init): + * src/template-designer.c: (gl_template_designer_init): + * src/ui-property-bar.c: (gl_ui_property_bar_instance_init): + Made appropriate warnings critical. + 2005-11-27 Jim Evins * src/merge-evolution.c: (gl_merge_evolution_get_key_list), diff --git a/glabels2/libglabels/libglabels-private.h b/glabels2/libglabels/libglabels-private.h index e5011b2f..a6a78e73 100644 --- a/glabels2/libglabels/libglabels-private.h +++ b/glabels2/libglabels/libglabels-private.h @@ -33,4 +33,7 @@ #define GL_SYSTEM_DATA_DIR g_build_filename (LIBGLABELS_TEMPLATE_DIR, NULL) #define GL_USER_DATA_DIR g_build_filename (g_get_home_dir (), ".glabels", NULL) +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "LibGlabels" + #endif /* __LIBGLABELS_PRIVATE_H__ */ diff --git a/glabels2/libglabels/paper.c b/glabels2/libglabels/paper.c index 26063a64..88e4b374 100644 --- a/glabels2/libglabels/paper.c +++ b/glabels2/libglabels/paper.c @@ -454,7 +454,7 @@ read_papers (void) g_free (data_dir); if (papers == NULL) { - g_warning (_("No paper files found!")); + g_critical (_("Unable to locate paper size definitions. Libglabels may not be installed correctly!")); } return papers; diff --git a/glabels2/libglabels/template.c b/glabels2/libglabels/template.c index a91306cb..abadc480 100644 --- a/glabels2/libglabels/template.c +++ b/glabels2/libglabels/template.c @@ -900,7 +900,7 @@ read_templates (void) g_free (data_dir); if (templates == NULL) { - g_warning (_("No template files found!")); + g_critical (_("Unable to locate any template files. Libglabels may not be installed correctly!")); } return templates; diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index fb4cf2f1..51f87a62 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -41,6 +41,8 @@ glabels_SOURCES = \ glabels.c \ splash.c \ splash.h \ + critical-error-handler.c \ + critical-error-handler.h \ window.c \ window.h \ stock.c \ diff --git a/glabels2/src/critical-error-handler.c b/glabels2/src/critical-error-handler.c new file mode 100644 index 00000000..be2c2ed0 --- /dev/null +++ b/glabels2/src/critical-error-handler.c @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * critical-error-handler.c: critical error handler + * + * Copyright (C) 2005 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include "critical-error-handler.h" + +#include +#include +#include +#include +#include + +static void critical_error_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data); + + +/***************************************************************************/ +/* Initialize error handler. */ +/***************************************************************************/ +void +gl_critical_error_handler_init (void) +{ + g_log_set_handler ("LibGlabels", + G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, + critical_error_handler, + "libglabels"); + + g_log_set_handler (NULL, + G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, + critical_error_handler, + "glabels"); +} + +/*-------------------------------------------------------------------------*/ +/* PRIVATE. Actual error handler. */ +/*-------------------------------------------------------------------------*/ +static void +critical_error_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_NONE, + _("gLabels Fatal Error!")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + message); + gtk_dialog_add_button (GTK_DIALOG (dialog), + GTK_STOCK_QUIT, 0); + + gtk_dialog_run (GTK_DIALOG (dialog)); + + exit (-1); +} + diff --git a/glabels2/src/critical-error-handler.h b/glabels2/src/critical-error-handler.h new file mode 100644 index 00000000..890db9b5 --- /dev/null +++ b/glabels2/src/critical-error-handler.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * critical-error-handler.h: critical error handler header file + * + * Copyright (C) 2005 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __CRITICAL_ERROR_HANDLER_H__ +#define __CRITICAL_ERROR_HANDLER_H__ + +#include + +G_BEGIN_DECLS + +void gl_critical_error_handler_init (void); + +G_END_DECLS + +#endif diff --git a/glabels2/src/glabels.c b/glabels2/src/glabels.c index 8cb329d3..b1354b0e 100644 --- a/glabels2/src/glabels.c +++ b/glabels2/src/glabels.c @@ -29,6 +29,7 @@ #include #include +#include "critical-error-handler.h" #include "splash.h" #include "stock.h" #include "merge-init.h" @@ -90,6 +91,9 @@ main (int argc, char **argv) GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); + /* Install graphical handler for critical errors. */ + gl_critical_error_handler_init(); + /* Splash screen */ gl_splash (); diff --git a/glabels2/src/merge-properties-dialog.c b/glabels2/src/merge-properties-dialog.c index 7f4c34fe..d7e22e33 100644 --- a/glabels2/src/merge-properties-dialog.c +++ b/glabels2/src/merge-properties-dialog.c @@ -176,7 +176,7 @@ gl_merge_properties_dialog_init (glMergePropertiesDialog *dialog) NULL); if (!dialog->priv->gui) { - g_warning ("Could not open merge-properties-dialog.glade, reinstall glabels!"); + g_critical ("Could not open merge-properties-dialog.glade. gLabels may not be installed correctly!"); return; } diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c index 3b2cf9ba..a7e817d3 100644 --- a/glabels2/src/object-editor.c +++ b/glabels2/src/object-editor.c @@ -152,7 +152,7 @@ gl_object_editor_init (glObjectEditor *editor) NULL); if (!editor->priv->gui) { - g_warning ("Could not open object-editor.glade, reinstall glabels!"); + g_critical ("Could not open object-editor.glade. gLabels may not be installed correctly!"); return; } diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index f2d47336..1ff63d0a 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -171,7 +171,7 @@ gl_prefs_dialog_init (glPrefsDialog *dlg) NULL); if (!dlg->priv->gui) { - g_warning ("Could not open prefs-dialog.glade, reinstall glabels!"); + g_critical ("Could not open prefs-dialog.glade. gLabels may not be installed correctly!"); return; } diff --git a/glabels2/src/template-designer.c b/glabels2/src/template-designer.c index 8b15d3b3..236c75f2 100644 --- a/glabels2/src/template-designer.c +++ b/glabels2/src/template-designer.c @@ -344,7 +344,7 @@ gl_template_designer_init (glTemplateDesigner *dlg) NULL); if (!dlg->priv->gui) { - g_warning ("Could not open template-designer.glade, reinstall glabels!"); + g_critical ("Could not open template-designer.glade. gLabels may not be installed correctly!"); return; } diff --git a/glabels2/src/ui-property-bar.c b/glabels2/src/ui-property-bar.c index 8d9de525..6af07594 100644 --- a/glabels2/src/ui-property-bar.c +++ b/glabels2/src/ui-property-bar.c @@ -212,7 +212,7 @@ gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar) NULL); if (!property_bar->priv->gui) { - g_warning ("Could not open property-bar.glade, reinstall glabels!"); + g_critical ("Could not open property-bar.glade. gLabels may not be installed correctly!"); return; } -- 2.39.5