app/app_procs.c moved some code from app_run() to errors_init().

2006-09-09  Sven Neumann  <sven@gimp.org>

	* app/app_procs.c
	* app/errors.[ch]: moved some code from app_run() to
errors_init().
This commit is contained in:
Sven Neumann 2006-09-09 17:31:28 +00:00 committed by Sven Neumann
parent 188bbe5d37
commit 6b09c1f604
4 changed files with 87 additions and 82 deletions

View File

@ -1,3 +1,8 @@
2006-09-09 Sven Neumann <sven@gimp.org>
* app/app_procs.c
* app/errors.[ch]: moved some code from app_run() to errors_init().
2006-09-09 Sven Neumann <sven@gimp.org>
* app/app_procs.[ch]

View File

@ -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);

View File

@ -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,
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,

View File

@ -24,20 +24,11 @@
#endif
void gimp_errors_init (Gimp *gimp,
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,