pidgin: 9654fbb4: Use glib log functions to show error mes...

sadrul at pidgin.im sadrul at pidgin.im
Fri Nov 28 01:30:47 EST 2008


-----------------------------------------------------------------
Revision: 9654fbb42d0733387232427d4589f92c4a7d0846
Ancestor: 5beb2ba1811b95a4aa7a3913466322c733f313fb
Author: sadrul at pidgin.im
Date: 2008-11-28T06:29:37
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9654fbb42d0733387232427d4589f92c4a7d0846

Added files:
        finch/libgnt/gntinternal.h
Modified files:
        finch/gntdebug.c finch/libgnt/Makefile.am
        finch/libgnt/gntbindable.c finch/libgnt/gntcolors.c
        finch/libgnt/gntfilesel.c finch/libgnt/gntkeys.c
        finch/libgnt/gntmain.c finch/libgnt/gntstyle.c
        finch/libgnt/gnttextview.c finch/libgnt/gntutils.c
        finch/libgnt/gntwm.c

ChangeLog: 

Use glib log functions to show error messages.

-------------- next part --------------
============================================================
--- finch/libgnt/gntinternal.h	363f9df88c6ab973ad7b619e6010e4a5ff50b0d5
+++ finch/libgnt/gntinternal.h	363f9df88c6ab973ad7b619e6010e4a5ff50b0d5
@@ -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
+
============================================================
--- finch/gntdebug.c	1f55b955ff4fe333c1d14ba5435b82856dc70aaf
+++ finch/gntdebug.c	c8d27ecf2e5e2492248f9f4197b09588131956cf
@@ -344,6 +344,7 @@ void finch_debug_init()
 	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
============================================================
--- finch/libgnt/Makefile.am	bbfc5139add07f7c22fd1161478b3494ce6a99ba
+++ finch/libgnt/Makefile.am	1bc224bebca5b1874e3bb1eef6ed3e68e618ffe7
@@ -6,6 +6,8 @@ lib_LTLIBRARIES = libgnt.la
 
 lib_LTLIBRARIES = libgnt.la
 
+noinst_HEADERS = gntinternal.h
+
 BUILT_SOURCES = gntmarshal.h
 
 libgnt_la_SOURCES = \
============================================================
--- finch/libgnt/gntbindable.c	616c134da67b11e4f1fe9a085f8c4b16bed29042
+++ finch/libgnt/gntbindable.c	e8d783cda3b3e933b372cfcf12dc966abbaab034
@@ -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 @@ register_binding(GntBindableClass *klass
 
 	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);
============================================================
--- finch/libgnt/gntcolors.c	76355879e5ead1f05d0b76517b75cb075cf46808
+++ finch/libgnt/gntcolors.c	2489e4a5e6eddddc7533d3342c3472136824f8d1
@@ -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 @@ void gnt_colors_parse(GKeyFile *kfile)
 
 	if (error)
 	{
-		g_printerr("GntColors: %s\n", error->message);
+		gnt_warning("%s", error->message);
 		g_error_free(error);
 		error = NULL;
 	}
@@ -226,7 +230,7 @@ void gnt_color_pairs_parse(GKeyFile *kfi
 
 	if (error)
 	{
-		g_printerr("GntColors: %s\n", error->message);
+		gnt_warning("%s", error->message);
 		g_error_free(error);
 		return;
 	}
============================================================
--- finch/libgnt/gntfilesel.c	3583c3bb977baf11ea03ce2dae7208a08934ab08
+++ finch/libgnt/gntfilesel.c	2814dbc419c8d0b4138f786cd650d27d224e6f27
@@ -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 @@ local_read_fn(const char *path, GList **
 		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 @@ location_changed(GntFileSel *sel, GError
 		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;
 	}
============================================================
--- finch/libgnt/gntkeys.c	22ccb155d220dd80ce4feffe8b06115ee0dd99f9
+++ finch/libgnt/gntkeys.c	801d4ae48b1248bc3b2e183242fd6d50f94aec53
@@ -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>
============================================================
--- finch/libgnt/gntmain.c	09dab2b08828573846c8fa9426e2fa601503cf54
+++ finch/libgnt/gntmain.c	c45223fca436f7f68669e693b7271da50b25e57a
@@ -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 @@ setup_io()
 	                                 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
============================================================
--- finch/libgnt/gntstyle.c	a863480c1bddefa79acd8085fbeb0dddc7a62832
+++ finch/libgnt/gntstyle.c	4320c8acbbd69eb81abc644aa5f6d1e7c2de0cac
@@ -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 @@ void gnt_style_read_actions(GType type, 
 		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 @@ void gnt_style_read_actions(GType type, 
 
 			if (error)
 			{
-				g_printerr("GntStyle: %s\n", error->message);
+				gnt_warning("%s", error->message);
 				g_error_free(error);
 				error = NULL;
 			}
@@ -249,7 +253,7 @@ void gnt_style_read_actions(GType type, 
 			{
 				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 @@ gboolean gnt_style_read_menu_accels(cons
 		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 @@ gboolean gnt_style_read_menu_accels(cons
 
 			if (error)
 			{
-				g_printerr("GntStyle: %s\n", error->message);
+				gnt_warning("%s", error->message);
 				g_error_free(error);
 				error = NULL;
 			}
@@ -303,7 +307,7 @@ gboolean gnt_style_read_menu_accels(cons
 			{
 				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 @@ void gnt_styles_get_keyremaps(GType type
 		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 @@ void gnt_styles_get_keyremaps(GType type
 
 			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 @@ read_general_style(GKeyFile *kfile)
 
 	if (error)
 	{
-		g_printerr("GntStyle: %s\n", error->message);
+		gnt_warning("%s", error->message);
 		g_error_free(error);
 	}
 	else
@@ -426,7 +430,7 @@ void gnt_style_read_configure_file(const
 	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;
 	}
============================================================
--- finch/libgnt/gnttextview.c	9836c0bbe3e9a826df5176b8ae95a83db742f021
+++ finch/libgnt/gnttextview.c	efe7b3b8b88f454ca86a8a39eaf5c4327f9a0daf
@@ -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 @@ int gnt_text_view_tag_change(GntTextView
 						/* 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", "");
 					}
 				}
 			}
============================================================
--- finch/libgnt/gntutils.c	a6c08954944e16c690452ce6e9b3ac9edb58d1ba
+++ finch/libgnt/gntutils.c	9aa3d9626669ad50b34499585ddb12fcd3492e83
@@ -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 @@ gnt_widget_from_xmlnode(xmlNode *node, G
 	xmlFree(content);
 
 	if (widget == NULL) {
-		g_printerr("Invalid widget name %s\n", name);
+		gnt_warning("Invalid widget name %s", name);
 		return NULL;
 	}
 
============================================================
--- finch/libgnt/gntwm.c	29e44df1a64425e6c564cd3b33ca0b57ccca3631
+++ finch/libgnt/gntwm.c	b1ddd57958275d53952c70d88ab919a185f01ef5
@@ -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 @@ read_window_positions(GntWM *wm)
 	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 @@ read_window_positions(GntWM *wm)
 
 	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 @@ read_window_positions(GntWM *wm)
 				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 @@ write_already(gpointer data)
 
 	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);


More information about the Commits mailing list