diff --git a/ChangeLog b/ChangeLog index 4628928d9e..691e4493b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-09-09 Sven Neumann + + * app/app_procs.c + * app/errors.[ch]: moved some code from app_run() to errors_init(). + 2006-09-09 Sven Neumann * app/app_procs.[ch] diff --git a/app/app_procs.c b/app/app_procs.c index ba48dffccc..24f1e26604 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -170,30 +170,6 @@ app_run (const gchar *full_prog_name, gboolean swap_is_ok; gint i; - const gchar *log_domains[] = - { - "Gimp", - "Gimp-Actions", - "Gimp-Base", - "Gimp-Composite", - "Gimp-Config", - "Gimp-Core", - "Gimp-Dialogs", - "Gimp-Display", - "Gimp-File", - "Gimp-GUI", - "Gimp-Menus", - "Gimp-PDB", - "Gimp-Paint", - "Gimp-Paint-Funcs", - "Gimp-Plug-In", - "Gimp-Text", - "Gimp-Tools", - "Gimp-Vectors", - "Gimp-Widgets", - "Gimp-XCF" - }; - /* Create an instance of the "Gimp" object which is the root of the * core object system */ @@ -208,16 +184,7 @@ app_run (const gchar *full_prog_name, stack_trace_mode, pdb_compat_mode); - gimp_errors_init (gimp, full_prog_name, use_debug_handler, stack_trace_mode); - - for (i = 0; i < G_N_ELEMENTS (log_domains); i++) - g_log_set_handler (log_domains[i], - G_LOG_LEVEL_MESSAGE, - gimp_message_log_func, &gimp); - - g_log_set_handler (NULL, - G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL, - gimp_error_log_func, &gimp); + errors_init (gimp, full_prog_name, use_debug_handler, stack_trace_mode); units_init (gimp); diff --git a/app/errors.c b/app/errors.c index 1f794b8d42..649db21754 100644 --- a/app/errors.c +++ b/app/errors.c @@ -45,6 +45,7 @@ /* private variables */ +static Gimp *the_errors_gimp = NULL; static gboolean use_debug_handler = FALSE; static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_QUERY; static gchar *full_prog_name = NULL; @@ -56,18 +57,50 @@ static G_GNUC_NORETURN void gimp_eek (const gchar *reason, const gchar *message, gboolean use_handler); +static void gimp_message_log_func (const gchar *log_domain, + GLogLevelFlags flags, + const gchar *message, + gpointer data); +static void gimp_error_log_func (const gchar *domain, + GLogLevelFlags flags, + const gchar *message, + gpointer data) G_GNUC_NORETURN; -static Gimp *the_errors_gimp = NULL; /* public functions */ void -gimp_errors_init (Gimp *gimp, - const gchar *_full_prog_name, - gboolean _use_debug_handler, - GimpStackTraceMode _stack_trace_mode) +errors_init (Gimp *gimp, + const gchar *_full_prog_name, + gboolean _use_debug_handler, + GimpStackTraceMode _stack_trace_mode) { + const gchar * const log_domains[] = + { + "Gimp", + "Gimp-Actions", + "Gimp-Base", + "Gimp-Composite", + "Gimp-Config", + "Gimp-Core", + "Gimp-Dialogs", + "Gimp-Display", + "Gimp-File", + "Gimp-GUI", + "Gimp-Menus", + "Gimp-PDB", + "Gimp-Paint", + "Gimp-Paint-Funcs", + "Gimp-Plug-In", + "Gimp-Text", + "Gimp-Tools", + "Gimp-Vectors", + "Gimp-Widgets", + "Gimp-XCF" + }; + gint i; + g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (_full_prog_name != NULL); g_return_if_fail (full_prog_name == NULL); @@ -86,34 +119,15 @@ gimp_errors_init (Gimp *gimp, use_debug_handler = _use_debug_handler ? TRUE : FALSE; stack_trace_mode = _stack_trace_mode; full_prog_name = g_strdup (_full_prog_name); -} -void -gimp_message_log_func (const gchar *log_domain, - GLogLevelFlags flags, - const gchar *message, - gpointer data) -{ - Gimp **gimp = (Gimp **) data; + for (i = 0; i < G_N_ELEMENTS (log_domains); i++) + g_log_set_handler (log_domains[i], + G_LOG_LEVEL_MESSAGE, + gimp_message_log_func, &gimp); - if (gimp && GIMP_IS_GIMP (*gimp)) - { - gimp_show_message (*gimp, NULL, NULL, message); - } - else - { - g_printerr ("%s: %s\n\n", - gimp_filename_to_utf8 (full_prog_name), message); - } -} - -void -gimp_error_log_func (const gchar *domain, - GLogLevelFlags flags, - const gchar *message, - gpointer data) -{ - gimp_fatal_error (message); + g_log_set_handler (NULL, + G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL, + gimp_error_log_func, &gimp); } void @@ -145,6 +159,34 @@ gimp_terminate (const gchar *fmt, ...) /* private functions */ +static void +gimp_message_log_func (const gchar *log_domain, + GLogLevelFlags flags, + const gchar *message, + gpointer data) +{ + Gimp **gimp = (Gimp **) data; + + if (gimp && GIMP_IS_GIMP (*gimp)) + { + gimp_show_message (*gimp, NULL, NULL, message); + } + else + { + g_printerr ("%s: %s\n\n", + gimp_filename_to_utf8 (full_prog_name), message); + } +} + +static void +gimp_error_log_func (const gchar *domain, + GLogLevelFlags flags, + const gchar *message, + gpointer data) +{ + gimp_fatal_error (message); +} + static void gimp_eek (const gchar *reason, const gchar *message, diff --git a/app/errors.h b/app/errors.h index 3e84e19289..4a57a146f9 100644 --- a/app/errors.h +++ b/app/errors.h @@ -24,24 +24,15 @@ #endif -void gimp_errors_init (Gimp *gimp, - const gchar *full_prog_name, - gboolean use_debug_handler, - GimpStackTraceMode stack_trace_mode); +void errors_init (Gimp *gimp, + const gchar *full_prog_name, + gboolean use_debug_handler, + GimpStackTraceMode stack_trace_mode); -void gimp_message_log_func (const gchar *log_domain, - GLogLevelFlags flags, - const gchar *message, - gpointer data); -void gimp_error_log_func (const gchar *domain, - GLogLevelFlags flags, - const gchar *message, - gpointer data) G_GNUC_NORETURN; - -void gimp_fatal_error (const gchar *format, - ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN; -void gimp_terminate (const gchar *format, - ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN; +void gimp_fatal_error (const gchar *format, + ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN; +void gimp_terminate (const gchar *format, + ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN; #endif /* __ERRORS_H__ */