Mercurial > pidgin
changeset 24558:e2e57d3c0578
Use glib log functions to show error messages.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 28 Nov 2008 06:29:37 +0000 |
parents | 7b27f7c41d85 |
children | 10ab5441572f |
files | finch/gntdebug.c finch/libgnt/Makefile.am finch/libgnt/gntbindable.c finch/libgnt/gntcolors.c finch/libgnt/gntfilesel.c finch/libgnt/gntinternal.h finch/libgnt/gntkeys.c finch/libgnt/gntmain.c finch/libgnt/gntstyle.c finch/libgnt/gnttextview.c finch/libgnt/gntutils.c finch/libgnt/gntwm.c |
diffstat | 12 files changed, 94 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntdebug.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/gntdebug.c Fri Nov 28 06:29:37 2008 +0000 @@ -344,6 +344,7 @@ REGISTER_G_LOG_HANDLER("GModule"); REGISTER_G_LOG_HANDLER("GLib-GObject"); REGISTER_G_LOG_HANDLER("GThread"); + REGISTER_G_LOG_HANDLER("Gnt"); #ifdef USE_GSTREAMER REGISTER_G_LOG_HANDLER("GStreamer"); #endif
--- a/finch/libgnt/Makefile.am Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/Makefile.am Fri Nov 28 06:29:37 2008 +0000 @@ -6,6 +6,8 @@ lib_LTLIBRARIES = libgnt.la +noinst_HEADERS = gntinternal.h + BUILT_SOURCES = gntmarshal.h libgnt_la_SOURCES = \
--- a/finch/libgnt/gntbindable.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntbindable.c Fri Nov 28 06:29:37 2008 +0000 @@ -22,6 +22,10 @@ #include <string.h> +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "Bindable" + #include "gntbindable.h" #include "gntstyle.h" #include "gnt.h" @@ -360,7 +364,7 @@ action = g_hash_table_lookup(klass->actions, name); if (!action) { - g_printerr("GntBindable: Invalid action name %s for %s\n", + gnt_warning("Invalid action name %s for %s", name, g_type_name(G_OBJECT_CLASS_TYPE(klass))); if (list) g_list_free(list);
--- a/finch/libgnt/gntcolors.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntcolors.c Fri Nov 28 06:29:37 2008 +0000 @@ -24,6 +24,10 @@ #include <ncurses.h> +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "Colors" + #include "gntcolors.h" #include "gntstyle.h" @@ -182,7 +186,7 @@ if (error) { - g_printerr("GntColors: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); error = NULL; } @@ -226,7 +230,7 @@ if (error) { - g_printerr("GntColors: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); return; }
--- a/finch/libgnt/gntfilesel.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntfilesel.c Fri Nov 28 06:29:37 2008 +0000 @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "FileSel" + #include "gntbutton.h" #include "gntentry.h" #include "gntfilesel.h" @@ -254,7 +258,7 @@ struct stat st; if (stat(fp, &st)) { - g_printerr("Error stating location %s\n", fp); + gnt_warning("Error stating location %s", fp); } else { if (S_ISDIR(st.st_mode)) { file = gnt_file_new_dir(str); @@ -309,7 +313,7 @@ success = local_read_fn(sel->current, &files, err); if (!success || *err) { - g_printerr("GntFileSel: error opening location %s (%s)\n", + gnt_warning("error opening location %s (%s)", sel->current, *err ? (*err)->message : "reason unknown"); return FALSE; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/finch/libgnt/gntinternal.h Fri Nov 28 06:29:37 2008 +0000 @@ -0,0 +1,33 @@ +/* + * GNT - The GLib Ncurses Toolkit + * + * GNT is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This library 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 02111-1301 USA + */ +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "Gnt" + +#ifdef __GNUC__ +# ifndef GNT_LOG_DOMAIN +# define GNT_LOG_DOMAIN "" +# endif +# define gnt_warning(format, args...) g_warning("(%s) %s: " format, GNT_LOG_DOMAIN, __PRETTY_FUNCTION__, args) +#else /* __GNUC__ */ +# define gnt_warning g_warning +#endif +
--- a/finch/libgnt/gntkeys.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntkeys.c Fri Nov 28 06:29:37 2008 +0000 @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "Keys" + #include "gntkeys.h" #include <glib.h>
--- a/finch/libgnt/gntmain.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntmain.c Fri Nov 28 06:29:37 2008 +0000 @@ -32,6 +32,10 @@ #include <sys/types.h> #include <sys/wait.h> +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "Main" + #include "gnt.h" #include "gntbox.h" #include "gntbutton.h" @@ -319,7 +323,7 @@ But irssi does this, so I am going to assume the crashes were caused by some other stuff. */ - g_printerr("gntmain: setting up IO (%d)\n", channel_read_callback); + gnt_warning("setting up IO (%d)", channel_read_callback); } static gboolean
--- a/finch/libgnt/gntstyle.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntstyle.c Fri Nov 28 06:29:37 2008 +0000 @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "Style" + #include "gntstyle.h" #include "gntcolors.h" #include "gntws.h" @@ -226,7 +230,7 @@ keys = g_key_file_get_keys(gkfile, name, &len, &error); if (error) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); g_free(name); return; @@ -241,7 +245,7 @@ if (error) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); error = NULL; } @@ -249,7 +253,7 @@ { const char *keycode = parse_key(key); if (keycode == NULL) { - g_printerr("GntStyle: Invalid key-binding %s\n", key); + gnt_warning("Invalid key-binding %s", key); } else { gnt_bindable_register_binding(klass, action, keycode, NULL); } @@ -280,7 +284,7 @@ keys = g_key_file_get_keys(gkfile, kname, &len, &error); if (error) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); g_free(kname); return ret; @@ -295,7 +299,7 @@ if (error) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); error = NULL; } @@ -303,7 +307,7 @@ { const char *keycode = parse_key(key); if (keycode == NULL) { - g_printerr("GntStyle: Invalid key-binding %s\n", key); + gnt_warning("Invalid key-binding %s", key); } else { ret = TRUE; g_hash_table_replace(table, g_strdup(keycode), menuid); @@ -338,7 +342,7 @@ keys = g_key_file_get_keys(gkfile, name, &len, &error); if (error) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); g_free(name); return; @@ -353,7 +357,7 @@ if (error) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); error = NULL; g_free(key); @@ -402,7 +406,7 @@ if (error) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); } else @@ -426,7 +430,7 @@ if (!g_key_file_load_from_file(gkfile, filename, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { - g_printerr("GntStyle: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); return; }
--- a/finch/libgnt/gnttextview.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gnttextview.c Fri Nov 28 06:29:37 2008 +0000 @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "TextView" + #include "gntstyle.h" #include "gnttextview.h" #include "gntutils.h" @@ -780,7 +784,7 @@ /* XXX: Make things work if the tagged text spans over several lines. */ } else { /* XXX: handle the rest of the conditions */ - g_printerr("WTF! This needs to be handled properly!!\n"); + gnt_warning("WTF! This needs to be handled properly!!%s", ""); } } }
--- a/finch/libgnt/gntutils.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntutils.c Fri Nov 28 06:29:37 2008 +0000 @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "Utils" + #include "gntbutton.h" #include "gntcheckbox.h" #include "gntcombobox.h" @@ -306,7 +310,7 @@ xmlFree(content); if (widget == NULL) { - g_printerr("Invalid widget name %s\n", name); + gnt_warning("Invalid widget name %s", name); return NULL; }
--- a/finch/libgnt/gntwm.c Fri Nov 28 02:58:00 2008 +0000 +++ b/finch/libgnt/gntwm.c Fri Nov 28 06:29:37 2008 +0000 @@ -46,6 +46,10 @@ #include <string.h> #include <time.h> +#include "gntinternal.h" +#undef GNT_LOG_DOMAIN +#define GNT_LOG_DOMAIN "WM" + #include "gntwm.h" #include "gntstyle.h" #include "gntmarshal.h" @@ -325,7 +329,7 @@ gsize nk; if (!g_key_file_load_from_file(gfile, filename, G_KEY_FILE_NONE, &error)) { - g_printerr("GntWM: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); g_free(filename); return; @@ -333,7 +337,7 @@ keys = g_key_file_get_keys(gfile, "positions", &nk, &error); if (error) { - g_printerr("GntWM: %s\n", error->message); + gnt_warning("%s", error->message); g_error_free(error); error = NULL; } else { @@ -349,7 +353,7 @@ p->y = y; g_hash_table_replace(wm->positions, g_strdup(title + 1), p); } else { - g_printerr("GntWM: Invalid number of arguments for positioing a window.\n"); + gnt_warning("Invalid number of arguments (%d) for positioning a window.", l); } g_strfreev(coords); } @@ -2095,7 +2099,7 @@ file = fopen(filename, "wb"); if (file == NULL) { - g_printerr("GntWM: error opening file to save positions\n"); + gnt_warning("error opening file (%s) to save positions", filename); } else { fprintf(file, "[positions]\n"); g_hash_table_foreach(wm->positions, write_gdi, file);