# HG changeset patch # User Sean Egan # Date 1065311100 0 # Node ID e09020153d857b7fcd981b11451d31bcc4238f93 # Parent 3aa374a7bc2e56d8c0f6217645f2842700c2fa97 [gaim-migrate @ 7717] I fixed this! It doesn't hate me. How could it? committer: Tailor Script diff -r 3aa374a7bc2e -r e09020153d85 src/gtkdebug.c --- a/src/gtkdebug.c Sat Oct 04 23:15:45 2003 +0000 +++ b/src/gtkdebug.c Sat Oct 04 23:45:00 2003 +0000 @@ -47,7 +47,7 @@ static char debug_fg_colors[][8] = { "#000000", /**< All debug levels. */ - "#666666", /**< Blather. */ + "#666666", /**< Misc. */ "#000000", /**< Information. */ "#660000", /**< Warnings. */ "#FF0000", /**< Errors. */ @@ -215,6 +215,57 @@ gaim_gtk_debug_window_hide(); } +static void +gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, + const gchar *msg, gpointer user_data) +{ + GaimDebugLevel level; + char *new_msg = NULL; + char *new_domain = NULL; + + if ((flags & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_ERROR) + level = GAIM_DEBUG_ERROR; + else if ((flags & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_CRITICAL) + level = GAIM_DEBUG_FATAL; + else if ((flags & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_WARNING) + level = GAIM_DEBUG_WARNING; + else if ((flags & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_MESSAGE) + level = GAIM_DEBUG_INFO; + else if ((flags & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_INFO) + level = GAIM_DEBUG_INFO; + else if ((flags & G_LOG_LEVEL_MASK) == G_LOG_LEVEL_DEBUG) + level = GAIM_DEBUG_MISC; + else { + gaim_debug(GAIM_DEBUG_WARNING, "gtkdebug", + "Unknown glib logging level in %d\n", flags); + + level = GAIM_DEBUG_MISC; /* This will never happen. */ + } + + if (msg != NULL) + new_msg = gaim_utf8_try_convert(msg); + + if (domain != NULL) + new_domain = gaim_utf8_try_convert(domain); + + if (new_msg != NULL) { + gaim_debug(GAIM_DEBUG_MISC, new_domain ? new_domain : "g_log", + "%s\n", new_msg); + + g_free(new_msg); + } + + if (new_domain != NULL) + g_free(new_domain); +} + +#ifdef _WIN32 +static void +gaim_glib_dummy_print_handler(const gchar *string) +{ +} +#endif + void gaim_gtk_debug_init(void) { @@ -235,6 +286,25 @@ gaim_prefs_connect_callback("/gaim/gtk/debug/enabled", debug_enabled_cb, NULL); + +#define REGISTER_G_LOG_HANDLER(name) \ + g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ + | G_LOG_FLAG_RECURSION, \ + gaim_glib_log_handler, NULL) + + /* Register the glib/gtk log handlers. */ + REGISTER_G_LOG_HANDLER(NULL); + REGISTER_G_LOG_HANDLER("Gdk"); + REGISTER_G_LOG_HANDLER("Gtk"); + REGISTER_G_LOG_HANDLER("GLib"); + REGISTER_G_LOG_HANDLER("GModule"); + REGISTER_G_LOG_HANDLER("GLib-GObject"); + REGISTER_G_LOG_HANDLER("GThread"); + +#ifdef _WIN32 + if (!opt_debug) + g_set_print_handler(gaim_glib_dummy_print_handler); +#endif } void diff -r 3aa374a7bc2e -r e09020153d85 src/main.c --- a/src/main.c Sat Oct 04 23:15:45 2003 +0000 +++ b/src/main.c Sat Oct 04 23:45:00 2003 +0000 @@ -474,29 +474,6 @@ gaim_accounts_reorder(account, 0); } -#ifdef _WIN32 -/* WIN32 print and log handlers */ - -static void gaim_dummy_print( const gchar* string ) { - return; -} - -static void gaim_dummy_log_handler (const gchar *domain, - GLogLevelFlags flags, - const gchar *msg, - gpointer user_data) { - return; -} - -static void gaim_log_handler (const gchar *domain, - GLogLevelFlags flags, - const gchar *msg, - gpointer user_data) { - gaim_debug(GAIM_DEBUG_MISC, "log", "%s - %s\n", domain, msg); - g_log_default_handler(domain, flags, msg, user_data); -} -#endif /* _WIN32 */ - static void debug_init(void) { @@ -788,45 +765,6 @@ } } -#ifdef _WIN32 - /* We don't want a console window.. */ - /* - * Any calls to the glib logging functions, result in a call to AllocConsole(). - * ME and 98 will in such cases produce a console window (2000 not), despite - * being built as a windows app rather than a console app. So we should either - * ignore messages by setting dummy log handlers, or redirect messages. - * This requires setting handlers for all domains (any lib which uses g_logging). - */ - - g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), - NULL); - g_log_set_handler ("Gdk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), - NULL); - g_log_set_handler ("Gtk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), - NULL); - g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), - NULL); - g_log_set_handler ("GModule", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), - NULL); - g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), - NULL); - g_log_set_handler ("GThread", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, - (opt_gdebug ? gaim_log_handler : gaim_dummy_log_handler), - NULL); - - /* g_print also makes a call to AllocConsole(), therefore a handler needs to be - set here aswell */ - if(!opt_debug) - g_set_print_handler( gaim_dummy_print ); - -#endif - /* show help message */ if (opt_help) { show_usage(0, argv[0]);